|
|
@ -45,6 +45,9 @@ public class YDeviceImageService extends ServiceImpl<YDeviceImageMapper, DeviceI |
|
|
|
if (StrUtil.isNotBlank(searchVo.get("type"))) { |
|
|
|
queryWrapper.eq("type", searchVo.get("type")); |
|
|
|
} |
|
|
|
if (StrUtil.isNotBlank(searchVo.get("ckId"))) { |
|
|
|
queryWrapper.eq("ckId", searchVo.get("ckId")); |
|
|
|
} |
|
|
|
queryWrapper.eq("isDelete", 0); |
|
|
|
queryWrapper.eq("isShow", 1); |
|
|
|
queryWrapper.orderByAsc("channelNo"); |
|
|
@ -69,13 +72,13 @@ public class YDeviceImageService extends ServiceImpl<YDeviceImageMapper, DeviceI |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void getImage(String channelNo) { |
|
|
|
public void getImage(Device device) { |
|
|
|
// 访问接口 把图片保存到本地
|
|
|
|
String url = "https://api2.hik-cloud.com/api/v1/open/basic/channels/actions/capture"; |
|
|
|
String picName = ""; |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("deviceSerial", "L20560109"); // 设备序列号 string
|
|
|
|
param.put("channelNo", channelNo); // 组编号 string
|
|
|
|
param.put("deviceSerial", device.getNvrSerial()); // 设备序列号 string
|
|
|
|
param.put("channelNo", device.getChannelNo()); // 组编号 string
|
|
|
|
String paramJson = JSONObject.toJSONString(param); |
|
|
|
String result = HttpUtils.sendPostJson(url, paramJson, SyncService.haiKangToken); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result); |
|
|
@ -83,7 +86,7 @@ public class YDeviceImageService extends ServiceImpl<YDeviceImageMapper, DeviceI |
|
|
|
String picUrl = dataJson.get("picUrl").toString(); |
|
|
|
|
|
|
|
String day = DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss"); |
|
|
|
picName = day + channelNo + ".png"; |
|
|
|
picName = day + device.getChannelNo() + ".png"; |
|
|
|
try { |
|
|
|
ImageDownloadUtil.download(picUrl, filePath, picName); |
|
|
|
} catch (IOException e) { |
|
|
@ -94,19 +97,22 @@ public class YDeviceImageService extends ServiceImpl<YDeviceImageMapper, DeviceI |
|
|
|
// 入库操作
|
|
|
|
QueryWrapper<DeviceImage> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("isShow", "1"); |
|
|
|
wrapper.eq("channelNo", channelNo); |
|
|
|
wrapper.eq("channelNo", device.getChannelNo()); |
|
|
|
wrapper.orderByDesc("createTime"); |
|
|
|
List<DeviceImage> deviceImageList = this.list(wrapper); |
|
|
|
|
|
|
|
DeviceImage deviceImage = new DeviceImage(); |
|
|
|
deviceImage.setDeviceSerial("L20560109"); |
|
|
|
deviceImage.setDeviceSerial(device.getNvrSerial()); |
|
|
|
deviceImage.setCreateTime(new Date()); |
|
|
|
deviceImage.setChannelNo(channelNo); |
|
|
|
deviceImage.setChannelNo(device.getChannelNo()); |
|
|
|
deviceImage.setIsShow("1"); |
|
|
|
deviceImage.setCkId(device.getCkId()); |
|
|
|
|
|
|
|
if (deviceImageList.size() > 0) { |
|
|
|
DeviceImage deviceImageExit = deviceImageList.get(0); |
|
|
|
String convertImage = deviceImageExit.getImgAfter(); |
|
|
|
Date time = deviceImageExit.getModifyTime(); |
|
|
|
deviceImage.setCreateTime(time); |
|
|
|
deviceImage.setImgBefore(convertImage); |
|
|
|
deviceImage.setImgAfter(picName); |
|
|
|
String similar = String.valueOf(ImageCompareUtil.compareImage(filePath + "/" + convertImage, filePath + "/" + picName)); |
|
|
@ -119,7 +125,7 @@ public class YDeviceImageService extends ServiceImpl<YDeviceImageMapper, DeviceI |
|
|
|
deviceImage.setModifyTime(new Date()); |
|
|
|
|
|
|
|
// 添加之前先把历史数据isShow改成不展示
|
|
|
|
this.flushDeviceImageIsShow(channelNo); |
|
|
|
this.flushDeviceImageIsShow(device.getChannelNo()); |
|
|
|
this.save(deviceImage); |
|
|
|
} else { |
|
|
|
deviceImage.setImgBefore(picName); |
|
|
|