将一键导入拆过来

develop
Angel 1 year ago
parent d57a26ab20
commit 904d3f36dc

@ -0,0 +1,58 @@
package com.ssf.mysqloracletest.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ssf.mysqloracletest.domain.dto.DevopsVideoInfoDto;
import com.ssf.mysqloracletest.service.DevopsVideoInfoService0;
import com.ssf.mysqloracletest.task.AlarmInfoTask;
import com.ssf.mysqloracletest.utils.ConfigParam;
import com.ssf.mysqloracletest.utils.StringKit;
import lombok.RequiredArgsConstructor;
import lombok.extern.java.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* (DevopsVideoInfo)Controller
*
* @author makejava
* @since 2023-11-29 09:34:46
*/
@RequiredArgsConstructor
@Component
public class DevopsVideoInfoController {
private static final Logger logger = LoggerFactory.getLogger(DevopsVideoInfoController.class);
private final DevopsVideoInfoService0 devopsVideoInfoService;
/**
*
*/
@Scheduled(initialDelay = 100, fixedDelay = 3000)
public void yjdr(DevopsVideoInfoDto villageDeviceInfo) {
if (!"true".equals(ConfigParam.DevopeVideoInfoSwitch)) {
return;
}
String res = "error";
try {
res = devopsVideoInfoService.yjdr(villageDeviceInfo);
if (res.contains("success")) {
logger.info("导入成功");
} else {
logger.info("导入失败");
}
} catch (Exception e) {
logger.error(StringKit.getTrace(e) + "导入出现错误");
}
}
}

@ -0,0 +1,150 @@
package com.ssf.mysqloracletest.domain;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* (DevopsVideoInfo)Domain
*
* @author makejava
* @since 2023-12-01 20:06:03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "devops_video_info")
public class DevopsVideoInfo0 implements Serializable {
/**
*
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
*
*/
private String placeCode;
/**
*
*/
private String placeName;
/**
*
*/
private String deviceCode;
/**
*
*/
@TableField(condition = SqlCondition.LIKE)
private String deviceName;
/**
*
*/
private Integer monitoringType;
@TableField(exist = false)
private String monitoringTypeCn;
/**
*
*/
private String deviceAddress;
/**
*
*/
private Integer orientation;
@TableField(exist = false)
private String orientationCn;
/**
* SN
*/
private String deviceSn;
/**
*
*/
private String deviceBrand;
/**
* ip
*/
private String deviceIp;
/**
*
*/
private Integer devicePort;
/**
* MAC
*/
private String deviceMac;
/**
*
*/
private Double longitude;
/**
*
*/
private Double latitude;
/**
* U3D
*/
private Double u3dLongitude;
/**
* U3D
*/
private Double u3dLatitude;
/**
*
*/
private String deviceHeight;
/**
*
*/
private String manufactor;
/**
*
*/
private String account;
/**
*
*/
private String password;
/**
*
*/
@TableField(condition = SqlCondition.LIKE)
private String gbsChannelNo;
/**
* NVR
*/
private String gbsNvrNo;
/**
*
*/
private Integer channelNo;
}

@ -0,0 +1,93 @@
package com.ssf.mysqloracletest.domain;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* (DevopsVideoStatus)Domain
*
* @author makejava
* @since 2023-12-01 20:06:03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "devops_video_status")
public class DevopsVideoStatus implements Serializable {
/**
*
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
*
*/
private String placeCode;
/**
*
*/
private String placeName;
/**
*
*/
private String deviceCode;
/**
* NVR
*/
private String gbsNvrNo;
/**
*
*/
@TableField(condition = SqlCondition.LIKE)
private String gbsChannelNo;
/**
*
*/
@TableField(condition = SqlCondition.LIKE)
private String deviceName;
/**
* ip
*/
private String deviceIp;
/**
*
*/
private Integer monitoringType;
@TableField(exist = false)
private String monitoringTypeCn;
/**
*
*/
private Long heartbeatTime;
/**
* 线
*/
private Integer isOnline;
@TableField(exist = false)
private String isOnlineCn;
/**
*
*/
private Double longitude;
/**
*
*/
private Double latitude;
}

@ -0,0 +1,144 @@
package com.ssf.mysqloracletest.domain.dto;
import lombok.Data;
import java.io.Serializable;
/**
* (DevopsVideoInfo)Domain
*
* @author makejava
* @since 2023-09-15 17:30:11
*/
@Data
public class DevopsVideoInfoDto implements Serializable {
/**
*
*/
private Long id;
/**
*
*/
private String placeCode;
/**
*
*/
private String placeName;
/**
*
*/
private String deviceName;
/**
*
*/
private Integer monitoringType;
private String monitoringTypeCn;
/**
*
*/
private String deviceAddress;
/**
*
*/
private String gbsChannelNo;
/**
* NVR
*/
private String gbsNvrNo;
/**
* ip
*/
private String deviceIp;
/**
*
*/
private Double longitude;
/**
*
*/
private Double latitude;
/**
*
*/
private String deviceHeight;
/**
*
*/
private Integer orientation;
private String orientationCn;
/**
*
*/
private Integer channelNo;
/**
* U3D
*/
private Double u3dLongitude;
/**
* U3D
*/
private Double u3dLatitude;
/**
*
*/
private String account;
/**
*
*/
private String password;
/**
*
*/
private String manufactor;
/**
*
*/
private String deviceBrand;
/**
* SN
*/
private String deviceSn;
/**
*
*/
private Integer devicePort;
/**
* MAC
*/
private String deviceMac;
/**
*
*/
private String deviceCode;
private String type;
}

@ -0,0 +1,140 @@
package com.ssf.mysqloracletest.domain.vo;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
/**
* (DevopsVideoInfo)Domain
*
* @author makejava
* @since 2023-12-01 20:06:03
*/
@Data
public class DevopsVideoInfoVo extends BaseEntity {
/**
*
*/
private Long id;
/**
*
*/
private String placeCode;
/**
*
*/
private String placeName;
/**
*
*/
private String deviceCode;
/**
*
*/
private String deviceName;
/**
*
*/
private Integer monitoringType;
/**
*
*/
private String deviceAddress;
/**
*
*/
private Integer orientation;
/**
* SN
*/
private String deviceSn;
/**
*
*/
private String deviceBrand;
/**
* ip
*/
private String deviceIp;
/**
*
*/
private Integer devicePort;
/**
* MAC
*/
private String deviceMac;
/**
*
*/
private Double longitude;
/**
*
*/
private Double latitude;
/**
* U3D
*/
private Double u3dLongitude;
/**
* U3D
*/
private Double u3dLatitude;
/**
*
*/
private String deviceHeight;
/**
*
*/
private String manufactor;
/**
*
*/
private String account;
/**
*
*/
private String password;
/**
*
*/
private String gbsChannelNo;
/**
* NVR
*/
private String gbsNvrNo;
/**
*
*/
private Integer channelNo;
private String plateNo;
}

@ -0,0 +1,74 @@
package com.ssf.mysqloracletest.exception;
/**
*
*
* @author ruoyi
*/
public final class ServiceException extends RuntimeException
{
private static final long serialVersionUID = 1L;
/**
*
*/
private Integer code;
/**
*
*/
private String message;
/**
*
*
*
*/
private String detailMessage;
/**
*
*/
public ServiceException()
{
}
public ServiceException(String message)
{
this.message = message;
}
public ServiceException(String message, Integer code)
{
this.message = message;
this.code = code;
}
public String getDetailMessage()
{
return detailMessage;
}
@Override
public String getMessage()
{
return message;
}
public Integer getCode()
{
return code;
}
public ServiceException setMessage(String message)
{
this.message = message;
return this;
}
public ServiceException setDetailMessage(String detailMessage)
{
this.detailMessage = detailMessage;
return this;
}
}

@ -0,0 +1,26 @@
package com.ssf.mysqloracletest.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ssf.mysqloracletest.domain.DevopsVideoInfo0;
import com.ssf.mysqloracletest.domain.vo.DevopsVideoInfoVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* (DevopsVideoInfo)Mapper
*
* @author makejava
* @since 2023-11-29 09:33:21
*/
@Mapper
public interface DevopsVideoInfoMapper extends BaseMapper<DevopsVideoInfo0> {
@Select(" select " +
" *, " +
" CONCAT('苏',SUBSTRING_INDEX(SUBSTRING_INDEX(device_name, '苏', -1), ' ', 1) ) AS plate_no " +
" from devops_video_info where device_name like '%苏J%' ")
public List<DevopsVideoInfoVo> listPoliceVehicle(DevopsVideoInfo0 bean) ;
}

@ -0,0 +1,39 @@
package com.ssf.mysqloracletest.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ssf.mysqloracletest.domain.DevopsVideoInfo0;
import com.ssf.mysqloracletest.domain.dto.DevopsVideoInfoDto;
import com.ssf.mysqloracletest.domain.vo.DevopsVideoInfoVo;
import java.util.List;
/**
* (DevopsVideoInfo)Service
*
* @author makejava
* @since 2023-11-29 09:33:20
*/
public interface DevopsVideoInfoService0 extends IService<DevopsVideoInfo0> {
/**
*
*
* @param devopsVideoInfo
* @return
*/
boolean insertOrUpdate(DevopsVideoInfo0 devopsVideoInfo);
/**
*
*
* @param list
* @return
*/
Object importData(List<DevopsVideoInfo0> list);
public String yjdr(DevopsVideoInfoDto bean);
public List<DevopsVideoInfoVo> listPoliceVehicle(DevopsVideoInfo0 bean);
}

@ -0,0 +1,35 @@
package com.ssf.mysqloracletest.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ssf.mysqloracletest.domain.DevopsVideoStatus;
import java.util.List;
/**
* (DevopsVideoStatus)Service
*
* @author makejava
* @since 2023-11-29 09:33:21
*/
public interface DevopsVideoStatusService extends IService<DevopsVideoStatus> {
/**
*
*
* @param devopsVideoStatus
* @return
*/
boolean insertOrUpdate(DevopsVideoStatus devopsVideoStatus);
/**
*
*
* @param list
* @return
*/
Object importData(List<DevopsVideoStatus> list);
int getGbsListOnline();
}

@ -0,0 +1,233 @@
package com.ssf.mysqloracletest.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ssf.mysqloracletest.domain.DevopsVideoInfo0;
import com.ssf.mysqloracletest.domain.DevopsVideoStatus;
import com.ssf.mysqloracletest.domain.dto.DevopsVideoInfoDto;
import com.ssf.mysqloracletest.domain.vo.DevopsVideoInfoVo;
import com.ssf.mysqloracletest.exception.ServiceException;
import com.ssf.mysqloracletest.mapper.DevopsVideoInfoMapper;
import com.ssf.mysqloracletest.service.DevopsVideoInfoService0;
import com.ssf.mysqloracletest.service.DevopsVideoStatusService;
import com.ssf.mysqloracletest.utils.JsoupUtils;
import com.ssf.mysqloracletest.utils.NumKit;
import com.ssf.mysqloracletest.utils.PropertiesUtil;
import com.ssf.mysqloracletest.utils.StringKit;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* (DevopsVideoInfo)ServiceImpl
*
* @author makejava
* @since 2023-11-29 09:33:20
*/
@Service
@RequiredArgsConstructor
public class DevopsVideoInfoServiceImpl extends ServiceImpl<DevopsVideoInfoMapper, DevopsVideoInfo0> implements DevopsVideoInfoService0 {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
private final DevopsVideoInfoMapper videoInfoMapper;
private final DevopsVideoStatusService videoStatusService;
@Override
public boolean insertOrUpdate(DevopsVideoInfo0 devopsVideoInfo) {
return false;
}
@Override
public Object importData(List<DevopsVideoInfo0> list) {
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (DevopsVideoInfo0 devopsVideoInfo : list) {
try {
insertOrUpdate(devopsVideoInfo);
successNum++;
successMsg.append(StrUtil.format("<br/>{}、待替换 {} 导入成功", successNum, "待替换"));
} catch (Exception e) {
failureNum++;
failureMsg.append(StrUtil.format("<br/>{}、待替换 {} 导入失败:{}", failureNum, "待替换", e.getMessage()));
}
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
return successMsg.toString();
}
}
@Override
public String yjdr(DevopsVideoInfoDto bean) {
String type = StringKit.toString(bean.getType());
if ("".equals(type)) {
return "error-导入类型未设置";
}
if ("gbs".equals(type)) {
int count = 0;
String gbsip = PropertiesUtil.queryPropertiesByKey("gbsIp");
String gbsport = PropertiesUtil.queryPropertiesByKey("gbsPort");
String loginurl = "http://" + gbsip + ":" + gbsport + "/api/v1/login?username=admin&password=af7548eedff8e737c0e4b2a669497290#&url_token_only=true";
String res = JsoupUtils.getJsoupDocGet(loginurl);
JSONObject loginResJson = JSON.parseObject(res);
String urlToken = "";
if (loginResJson != null) {
urlToken = StringKit.toString(loginResJson.get("URLToken"));
}
//如果urltoken获取失败直接结束方法
if ("".equals(urlToken)) {
return "urltoken 获取失败!请检查配置文件是否正确";
}
String channellistUrl = "http://" + gbsip + ":" + gbsport + "/api/v1/device/channellist?token=" + urlToken + "&url_token_only=true&start=0&limit=20000";
logger.info("channellistUrl"+ channellistUrl);
String channellistRes = JsoupUtils.getJsoupDocGet(channellistUrl);
if ("".equals(StringKit.toString(channellistRes))) {
return "调用设备列表失败!请检查配置文件是否正确";
}
JSONObject channelObj = JSONObject.parseObject(channellistRes);
String channelJsonArrStr = StringKit.toString(channelObj.get("ChannelList"));
JSONArray channelJsonArr = JSONArray.parseArray(channelJsonArrStr);
if (channelJsonArr != null && channelJsonArr.size() > 0) {
logger.info("channelJsonArr size = " + channelJsonArr.size());
for (Object o : channelJsonArr) {
try {
bean = new DevopsVideoInfoDto();
count = 1;
String channelStr = StringKit.toString(o);
JSONObject channelJson = JSONObject.parseObject(channelStr);
String Name = StringKit.toString(channelJson.get("Name"));
if (Name.contains("GB")) {
logger.info("过滤包含GB的数据");
continue;
}
String villageName = "";
String villageCode = "";
String code = StringKit.toString(channelJson.get("ID"));
//在线离线 ON在线 OFF离线
String Status = StringKit.toString(channelJson.get("Status"));
bean.setGbsChannelNo(code);
String name = StringKit.toString(channelJson.get("CustomName"));
if ("".equals(name)) {
name = StringKit.toString(channelJson.get("Name"));
}
String deviceip = StringKit.toString(channelJson.get("CustomIPAddress"));
if ("".equals(StringKit.toString(name))) {
logger.info("地址数据为空:" + deviceip + ",code:" + code);
continue;
}
bean.setDeviceName(name);
//默认公共区域
if (code.contains("151")) {
bean.setMonitoringType(5);
} else {
bean.setMonitoringType(1);
}
bean.setPlaceCode(villageCode);
bean.setPlaceName(villageName);
bean.setDeviceIp(deviceip);
String address = name;
bean.setDeviceAddress(address);
String manufacturer = StringKit.toString(channelJson.get("Manufacturer"));
bean.setManufactor(manufacturer);
String port = StringKit.toString(channelJson.get("Port"));
bean.setDevicePort(NumKit.checkInt(port));
String latitude = StringKit.toString(channelJson.get("Latitude"));
bean.setLatitude(NumKit.checkDouble(latitude));
String longitude = StringKit.toString(channelJson.get("Longitude"));
bean.setLongitude(NumKit.checkDouble(longitude));
String channel = StringKit.toString(channelJson.get("Channel"));
bean.setChannelNo(NumKit.checkInt(channel));
String gbsNvrNo = StringKit.toString(channelJson.get("DeviceId"));
bean.setGbsNvrNo(StringKit.toString(gbsNvrNo));
if (!"".equals(StringKit.toString(bean.getGbsChannelNo()))) {
List<DevopsVideoInfo0> checklists = videoInfoMapper.selectList(new LambdaQueryWrapper<DevopsVideoInfo0>()
.eq(DevopsVideoInfo0::getGbsChannelNo, bean.getGbsChannelNo()));
if (checklists != null && checklists.size() > 0) {
logger.info("设备国标已存在:" + bean.getGbsChannelNo());
continue;
}
} else {
logger.info("国标编码为空:" + bean.getGbsChannelNo());
continue;
}
DevopsVideoInfo0 videoInfo = new DevopsVideoInfo0();
BeanUtils.copyProperties(bean, videoInfo);
int b = videoInfoMapper.insert(videoInfo);
//默认离线
int isOnline = 2;
if ("ON".equals(Status)) {
isOnline = 1;
}
//如果设备插入成功
DevopsVideoStatus videoStatus = new DevopsVideoStatus();
videoStatus.setGbsNvrNo(StringKit.toString(videoInfo.getGbsNvrNo()));
videoStatus.setGbsChannelNo(StringKit.toString(videoInfo.getGbsChannelNo()));
videoStatus.setDeviceName(StringKit.toString(videoInfo.getDeviceName()));
videoStatus.setDeviceIp(StringKit.toString(videoInfo.getDeviceIp()));
videoStatus.setMonitoringType(videoInfo.getMonitoringType());
videoStatus.setHeartbeatTime(System.currentTimeMillis() / 1000);
videoStatus.setIsOnline(isOnline);
videoStatusService.save(videoStatus);
logger.info("保存成功:" + videoInfo.getGbsChannelNo());
} catch (Exception e) {
logger.info("保存失败," + StringKit.getTrace(e));
continue;
}
}
} else {
return "结果集为空请检查gbs是否配置。";
}
return "success-" + count;
} else if ("nvr".equals(type)) {
//调用nvr插入设备
} else {
return "error-类型不正确";
}
return "error-未知错误";
}
@Override
public List<DevopsVideoInfoVo> listPoliceVehicle(DevopsVideoInfo0 bean) {
return videoInfoMapper.listPoliceVehicle(bean);
}
}

@ -0,0 +1,188 @@
package com.ssf.mysqloracletest.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.InputStream;
import java.util.Map;
import java.util.Set;
public class JsoupUtils {
private static final Logger log = LoggerFactory.getLogger(JsoupUtils.class);
public static String getJsoupDocGet(String url) {
//三次试错
final int MAX = 10;
int time = 0;
Document doc = null;
while (time < MAX) {
try {
doc = Jsoup
.connect(url)
.ignoreContentType(true)
.ignoreHttpErrors(true)
.timeout(1000 * 30)
.userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36")
.header("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
.header("accept-encoding", "gzip, deflate, br")
.header("accept-language", "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7")
.maxBodySize(0)
.get();
String text = doc.text();
if (text.contains("illegal")) {
return "";
} else {
return doc.text();
}
} catch (Exception e) {
log.info(StringKit.getTrace(e));
} finally {
time++;
}
}
return "";
}
//将文件传入 post请求中
public static String doPostFileRequest(String url, Map<String, String> param, InputStream fis, String fileName) throws Exception {
try {
Connection conn = Jsoup.connect(url);
if (param != null) {
conn.data(param);
}
conn.data("imagefile", fileName, fis);
Connection.Response response = conn.timeout(50000)
.ignoreContentType(true)
.maxBodySize(0)
.followRedirects(true)
.method(Connection.Method.POST).execute();
return response.body();
} catch (Exception e) {
throw new Exception(e);
}
}
/**
* post
*
* @param url
* @param map
* @return
*/
public static String jsoupPost(String url, Map<String, Object> map, String json) {
String res = "";
try {
Connection con = Jsoup.connect(url);
con.requestBody(json);
con.header("Content-Type", "application/json");
con.ignoreContentType(true);
Document doc = con.timeout(50000).post();
res = doc.text();
} catch (Exception e) {
log.info(StringKit.getTrace(e));
}
return res;
}
public static String jsoupPost(String url, Map<String, Object> map) {
String res = "";
try {
Connection con = Jsoup.connect(url);
if (map != null && map.size() > 0) {
Set<String> sets = map.keySet();
for (String s : sets) {
con.data(s, StringKit.toString(map.get(s)));
}
}
con.ignoreContentType(true);
Document doc =
con.timeout(50000)
.post();
res = doc.text();
} catch (Exception e) {
log.info(StringKit.getTrace(e));
}
return res;
}
/**
* Gbstoken
*
* @return
*/
public static String getGbsToken() {
String urlToken = "";
try {
String gbsIp = PropertiesUtil.queryPropertiesByKey("gbsIp");
if (StringUtils.isBlank(gbsIp)) {
gbsIp = "127.0.0.1";
}
String gbsPort = PropertiesUtil.queryPropertiesByKey("gbsPort");
String url = "http://" + gbsIp + ":" + gbsPort + "/api/v1/login?username=admin&password=af7548eedff8e737c0e4b2a669497290&url_token_only=true";
String res = JsoupUtils.getJsoupDocGet(url);
JSONObject loginResJson = JSON.parseObject(res);
if (loginResJson != null) {
urlToken = StringKit.toString(loginResJson.get("URLToken"));
}
} catch (Exception e) {
log.info(StringKit.getTrace(e));
}
return urlToken;
}
public static String getGbsToken(String ip) {
String urlToken = "";
try {
String gbsIp = PropertiesUtil.queryPropertiesByKey("gbsIp");
if (StringUtils.isBlank(gbsIp)) {
gbsIp = ip;
}
String gbsPort = PropertiesUtil.queryPropertiesByKey("gbsPort");
String url = "http://" + gbsIp + ":" + gbsPort + "/api/v1/login?username=admin&password=af7548eedff8e737c0e4b2a669497290&url_token_only=true";
String res = JsoupUtils.getJsoupDocGet(url);
JSONObject loginResJson = JSON.parseObject(res);
if (loginResJson != null) {
urlToken = StringKit.toString(loginResJson.get("URLToken"));
}
} catch (Exception e) {
}
return urlToken;
}
/**
* NVRtoken
*
* @return
*/
public static String getNvrToken() {
String urlToken = "";
try {
String nvrIp = PropertiesUtil.queryPropertiesByKey("nvrIp");
String nvrPort = PropertiesUtil.queryPropertiesByKey("nvrPort");
String url = "http://" + nvrIp + ":" + nvrPort + "/api/v1/login?username=admin&password=af7548eedff8e737c0e4b2a669497290&url_token_only=true";
String res = JsoupUtils.getJsoupDocGet(url);
JSONObject loginResJson = JSON.parseObject(res);
JSONObject liveQing = JSON.parseObject(StringKit.toString(loginResJson.get("LiveQing")));
JSONObject body = JSON.parseObject(StringKit.toString(liveQing.get("Body")));
urlToken = StringKit.toString(body.get("URLToken"));
if (StringUtils.isNotBlank(urlToken)) {
System.out.println("urlToken:" + urlToken);
}
} catch (Exception e) {
}
return urlToken;
}
}
Loading…
Cancel
Save