Browse Source

相机截图开发

gao.qiang 1 tháng trước cách đây
mục cha
commit
e071aab3c9

+ 14 - 14
hazard-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -330,20 +330,20 @@ public class GeoHazardMonitorTokenController {
                     }
                     respMsgAlarmVo.setCancelTime(null);
                 }
-                try {
-                    MsgAlarmCloud alarms = msgAlarmCloudService.getOne(lw);
-                    log.info("sdkUrl:{}", sdkUrl);
-                    log.info("alarmJSON :{}", JSON.toJSONString(alarms));
-                    String result = HttpClientUtil.postJson(sdkUrl, JSON.toJSONString(alarms));
-                    log.info("result:{}", result);
-                } catch (Exception e) {
-                    log.info(e.getMessage());
-                    e.printStackTrace();
-                    jsonObject.put("resultCode", 0);
-                    jsonObject.put("message", "失败");
-                    jsonObject.put("data", "消息推送失败");
-                    return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
-                }
+//                try {
+//                    MsgAlarmCloud alarms = msgAlarmCloudService.getOne(lw);
+//                    log.info("sdkUrl:{}", sdkUrl);
+//                    log.info("alarmJSON :{}", JSON.toJSONString(alarms));
+//                    String result = HttpClientUtil.postJson(sdkUrl, JSON.toJSONString(alarms));
+//                    log.info("result:{}", result);
+//                } catch (Exception e) {
+//                    log.info(e.getMessage());
+//                    e.printStackTrace();
+//                    jsonObject.put("resultCode", 0);
+//                    jsonObject.put("message", "失败");
+//                    jsonObject.put("data", "消息推送失败");
+//                    return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
+//                }
                 jsonObject.put("resultCode", 1);
                 jsonObject.put("message", "成功");
                 jsonObject.put("data", respMsgAlarmVo);

+ 16 - 1
hazard-sdk/src/main/java/com/ozs/controller/upload/UploadController.java

@@ -15,6 +15,8 @@ import com.ozs.service.entity.MsgAlarm;
 import com.ozs.service.service.BaseCameraManagementService;
 import com.ozs.service.service.BaseRailwayManagementService;
 import com.ozs.service.service.MsgAlarmService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.util.ObjectUtils;
@@ -36,6 +38,7 @@ import java.util.Map;
 @RestController
 public class UploadController {
 
+    private static final Logger log = LoggerFactory.getLogger(UploadController.class);
     @Value("${minio.bucketName}")
     private String bucketName;
 
@@ -145,13 +148,25 @@ public class UploadController {
                 }
                 //"/"+railwayName+"/"+installMiles+"/"+ LocalDate.now().getYear() +"/"+ LocalDate.now().getMonthValue() +"/"+LocalDate.now().getDayOfMonth()+ "/"+ LocalTime.now().getHour()
                 BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(wrapper);
+                if (ObjectUtils.isEmpty(baseCameraManagement)) {
+                    jsonObject.put("resultCode", 2);
+                    jsonObject.put("message", "失败");
+                    jsonObject.put("data", "没有该相机编码的相机");
+                    return jsonObject;
+                }
                 String filename = cameraCode + "-" +
                         DateTime.now().toString("yyyyMMddHHmmss") + stream.getOriginalFilename().substring(stream.getOriginalFilename().lastIndexOf("."));
                 BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(new LambdaQueryWrapper<BaseRailwayManagement>()
                         .eq(BaseRailwayManagement::getRailwayCode, baseCameraManagement.getRailwayCode()));
+                if (ObjectUtils.isEmpty(baseRailwayManagement)) {
+                    jsonObject.put("resultCode", 2);
+                    jsonObject.put("message", "失败");
+                    jsonObject.put("data", "该相机编码没有线路名称");
+                    return jsonObject;
+                }
                 String imgName = "alarm_picture"+ "/"+baseRailwayManagement.getRailwayName() + "/" + AppendUtils.stringAppend(baseCameraManagement.getInstallMile()) + "/" + LocalDate.now().getYear() + "/" + LocalDate.now().getMonthValue() + "/" + LocalDate.now().getDayOfMonth() + "/" + LocalTime.now().getHour() + "/" + filename;
                 minioUtils.minIoClientUpload(stream.getInputStream(), imgName);
-                uploadFile = imgUrl +"alarm_picture"+ "/" + baseRailwayManagement.getRailwayName() + "/" + AppendUtils.stringAppend(baseCameraManagement.getInstallMile()) + "/" + LocalDate.now().getYear() + "/" + LocalDate.now().getMonthValue() + "/" + LocalDate.now().getDayOfMonth() + "/" + LocalTime.now().getHour() + "/" + filename;
+                uploadFile = imgUrl +"/alarm_picture"+ "/" + baseRailwayManagement.getRailwayName() + "/" + AppendUtils.stringAppend(baseCameraManagement.getInstallMile()) + "/" + LocalDate.now().getYear() + "/" + LocalDate.now().getMonthValue() + "/" + LocalDate.now().getDayOfMonth() + "/" + LocalTime.now().getHour() + "/" + filename;
             }
         } else {
             jsonObject.put("resultCode", 2);