|
@@ -1,18 +1,30 @@
|
|
package com.ozs.service.utils;
|
|
package com.ozs.service.utils;
|
|
|
|
|
|
|
|
|
|
-import com.ozs.service.service.CameraLogDetailService;
|
|
|
|
-import com.ozs.service.service.CameraUpdateLogService;
|
|
|
|
-import com.ozs.service.service.MqLogService;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.ozs.common.core.redis.RedisCache;
|
|
|
|
+import com.ozs.common.utils.AppendUtils;
|
|
|
|
+import com.ozs.common.utils.ImgUtil;
|
|
|
|
+import com.ozs.service.entity.BaseCameraManagement;
|
|
|
|
+import com.ozs.service.entity.BaseRailwayManagement;
|
|
|
|
+import com.ozs.service.service.*;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.time.LocalTime;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 相机工具
|
|
* 相机工具
|
|
|
|
+ *
|
|
* @author Administrator
|
|
* @author Administrator
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -24,20 +36,68 @@ public class CallbackUtil {
|
|
CameraLogDetailService cameraLogDetailService;
|
|
CameraLogDetailService cameraLogDetailService;
|
|
@Autowired
|
|
@Autowired
|
|
MqLogService mqLogService;
|
|
MqLogService mqLogService;
|
|
- private static CameraLogDetailService cameraLogDetail;
|
|
|
|
- private static MqLogService mqLog;
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
+ @Autowired
|
|
|
|
+ BaseCameraManagementService baseCameraManagementService;
|
|
|
|
+ @Autowired
|
|
|
|
+ BaseRailwayManagementService baseRailwayManagementService;
|
|
|
|
+ @Value("${base.imgUrl}")
|
|
|
|
+ private String imgUrl;
|
|
|
|
+ private static CameraLogDetailService cameraLogDetail;
|
|
|
|
+ private static MqLogService mqLog;
|
|
|
|
+ private static RedisCache redis;
|
|
|
|
+ private static BaseCameraManagementService baseCameraManagement;
|
|
|
|
+ private static BaseRailwayManagementService baseRailwayManagement;
|
|
|
|
+ public static String url;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static String screenshot(String deviceSn, String stream, String imageUrl) {
|
|
|
|
+ String path = null;
|
|
|
|
+ Map<String, Object> screenshot = redis.getCacheMap("screenshot");
|
|
|
|
+ if (ObjectUtils.isEmpty(screenshot)) {
|
|
|
|
+ List<BaseCameraManagement> list = baseCameraManagement.list();
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ for (BaseCameraManagement came : list) {
|
|
|
|
+ BaseRailwayManagement baseRailwayManagementOne = baseRailwayManagement.getOne(new LambdaQueryWrapper<BaseRailwayManagement>()
|
|
|
|
+ .eq(BaseRailwayManagement::getRailwayCode, came.getRailwayCode()));
|
|
|
|
+ map.put(came.getCameraCode(), "/" + baseRailwayManagementOne.getRailwayName() + "/" + AppendUtils.stringAppend(came.getInstallMile()) + "/");
|
|
|
|
+ if (came.equals(deviceSn)) {
|
|
|
|
+ path = url + "/" + baseRailwayManagementOne.getRailwayName() + "/" + AppendUtils.stringAppend(came.getInstallMile()) + "/" + LocalDate.now().getYear() + "/" + LocalDate.now().getMonthValue() + "/" + LocalDate.now().getDayOfMonth() + "/" + LocalTime.now().getHour() + "/" + imageUrl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ redis.setCacheMap("screenshot", map);
|
|
|
|
+ return path;
|
|
|
|
+ } else {
|
|
|
|
+ for (Map.Entry<String, Object> entry : screenshot.entrySet()) {
|
|
|
|
+ String key = entry.getKey();
|
|
|
|
+ Object value = entry.getValue();
|
|
|
|
+ // 将Object转换为String
|
|
|
|
+ if (key.equals(deviceSn)) {
|
|
|
|
+ String stringValue = value != null ? value.toString() : null;
|
|
|
|
+ path = url + stringValue + LocalDate.now().getYear() + "/" + LocalDate.now().getMonthValue() + "/" + LocalDate.now().getDayOfMonth() + "/" + LocalTime.now().getHour() + "/" + imageUrl;
|
|
|
|
+ return path;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
|
|
@PostConstruct
|
|
@PostConstruct
|
|
public void init() {
|
|
public void init() {
|
|
cameraLogDetail = cameraLogDetailService;
|
|
cameraLogDetail = cameraLogDetailService;
|
|
- mqLog=mqLogService;
|
|
|
|
|
|
+ mqLog = mqLogService;
|
|
|
|
+ redis = redisCache;
|
|
|
|
+ baseCameraManagement = baseCameraManagementService;
|
|
|
|
+ baseRailwayManagement = baseRailwayManagementService;
|
|
|
|
+ url = imgUrl;
|
|
}
|
|
}
|
|
-
|
|
|
|
- public static void callback(String deviceSn,Integer code,String remark){
|
|
|
|
- CallbackUtil.cameraLogDetail.updateAccessories(deviceSn,code,remark);
|
|
|
|
|
|
+
|
|
|
|
+ public static void callback(String deviceSn, Integer code, String remark) {
|
|
|
|
+ CallbackUtil.cameraLogDetail.updateAccessories(deviceSn, code, remark);
|
|
}
|
|
}
|
|
|
|
|
|
- public static void heart(String cameraCode){
|
|
|
|
|
|
+ public static void heart(String cameraCode) {
|
|
CallbackUtil.mqLog.insetHeartLog(cameraCode);
|
|
CallbackUtil.mqLog.insetHeartLog(cameraCode);
|
|
}
|
|
}
|
|
}
|
|
}
|