Browse Source

报警和预警添加毫秒级日志

gao.qiang 11 months atrás
parent
commit
9d38e99906

+ 1 - 1
business-service/src/main/java/com/ozs/utils/CameraUtil.java

@@ -1160,7 +1160,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
      */
     public static String getPreviewURLs(String url, String body) {
         long begin = System.currentTimeMillis();
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
         log.info("天网接口请求时间: " + sdf.format(new Date(begin)));
         /**
          * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.

+ 13 - 1
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -245,6 +245,9 @@ public class GeoHazardMonitorTokenController {
     @PostMapping("/api/alarm")
     @Transactional(rollbackFor = Exception.class)
     public String alarm(@RequestBody ParameterVo parameterVo, HttpServletRequest request) throws Exception {
+        long begin = System.currentTimeMillis();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+        log.info("报警信息数据传输开始时间: " + simpleDateFormat.format(new Date(begin)));
         String token = apiTokenUtils.getGeoHazardMonitorToken(request);
         log.info("token:{}", token);
         log.info("parameter:{}", parameterVo);
@@ -415,6 +418,9 @@ public class GeoHazardMonitorTokenController {
                 msgAlarmFrequencyService.save(msgAlarmVice);
             }
             AjaxResults1 = new AjaxResults(1, "ok");
+            long end = System.currentTimeMillis();
+            log.info("报警信息数据传输结束时间: " + simpleDateFormat.format(new Date(end)));
+            log.info("报警信息数据传输请求用时时间:" + (end - begin) + "毫秒");
             return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
         } else {
             AjaxResults1 = new AjaxResults(2, "token验证失败");
@@ -509,7 +515,7 @@ public class GeoHazardMonitorTokenController {
     @Transactional
     public String heartbeat(@RequestBody ParameterVo parameterVo, HttpServletRequest request) throws Exception {
         long begin = System.currentTimeMillis();
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
         log.info("接受心跳时间: " + sdf.format(new Date(begin)));
         int distance = 0;
         boolean type = true;
@@ -2317,6 +2323,9 @@ public class GeoHazardMonitorTokenController {
      */
     @PostMapping("/api/preAlarm")
     public String preAlarm(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
+        long begin = System.currentTimeMillis();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+        log.info("预警信息传输开始时间: " + simpleDateFormat.format(new Date(begin)));
         String token = apiTokenUtils.getGeoHazardMonitorToken(request);
         log.info("token:{}", token);
         log.info("parameterVo:{}", parameterVo);
@@ -2383,6 +2392,9 @@ public class GeoHazardMonitorTokenController {
             preAlarm.setCreatedTime(new Date());
             if (preAlarmService.save(preAlarm)) {
                 AjaxResults1 = new AjaxResults(1, "ok");
+                long end = System.currentTimeMillis();
+                log.info("预警信息传输结束时间: " + simpleDateFormat.format(new Date(end)));
+                log.info("预警信息传输请求用时时间:" + (end - begin) + "毫秒");
                 return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
             } else {
                 AjaxResults1 = new AjaxResults(0, "新增失败");