From f71f31780ed55200f3e370e61c81cfd05feb34bd Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期五, 10 四月 2026 14:25:01 +0800
Subject: [PATCH] 对接网关的地磅抓拍,生成批复告警内容

---
 fzzy-igdss-inte/src/main/java/com/fzzy/igds/api/v1/service/ApiV1Service3031.java |   99 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 61 insertions(+), 38 deletions(-)

diff --git a/fzzy-igdss-inte/src/main/java/com/fzzy/igds/api/v1/service/ApiV1Service3031.java b/fzzy-igdss-inte/src/main/java/com/fzzy/igds/api/v1/service/ApiV1Service3031.java
index e591539..8a40905 100644
--- a/fzzy-igdss-inte/src/main/java/com/fzzy/igds/api/v1/service/ApiV1Service3031.java
+++ b/fzzy-igdss-inte/src/main/java/com/fzzy/igds/api/v1/service/ApiV1Service3031.java
@@ -1,25 +1,29 @@
 package com.fzzy.igds.api.v1.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fzzy.igds.api.v1.data.ApiV1Req;
 import com.fzzy.igds.api.v1.data.ApiV1Resp;
-import com.fzzy.igds.api.v1.data.Param3030;
 import com.fzzy.igds.api.v1.data.Param3031;
-import com.fzzy.igds.constant.WarnStatus;
+import com.fzzy.igds.constant.Constant;
+import com.fzzy.igds.constant.MonitorPointType;
+import com.fzzy.igds.data.BaseResp;
+import com.fzzy.igds.domain.Camera;
 import com.fzzy.igds.domain.EventInfo;
 import com.fzzy.igds.domain.GatewaySer;
-import com.alibaba.fastjson.JSONObject;
-import com.fzzy.igds.domain.SnapRecord;
+import com.fzzy.igds.domain.SnapReply;
 import com.fzzy.igds.service.EventInfoService;
 import com.fzzy.igds.service.FileService;
+import com.fzzy.igds.service.SecCameraService;
+import com.fzzy.igds.service.SnapReplyService;
 import com.fzzy.igds.utils.ContextUtil;
 import com.ruoyi.common.config.FrameworkConfig;
+import com.ruoyi.common.utils.StringUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.time.DateUtils;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
-import java.util.List;
 
 /**
  * @Description AI浜嬩欢瑙f瀽
@@ -34,64 +38,83 @@
     private EventInfoService eventInfoService;
     @Resource
     private FileService fileService;
+    @Resource
+    private SecCameraService cameraService;
+    @Resource
+    private SnapReplyService snapReplyService;
 
     /**
-     *
      * @param req
      * @param gatewaySer
      * @return
      */
-    public ApiV1Resp<Object> analysis(ApiV1Req<JSONObject> req, GatewaySer gatewaySer) throws Exception {
+    public ApiV1Resp<Object> analysis(ApiV1Req<Object> req, GatewaySer gatewaySer) throws Exception {
 
         //杞寲涓哄璞�
-        List<Param3031> list = JSONObject.parseArray(req.getData().toString(), Param3031.class);
+        Param3031 param = JSONObject.parseObject(JSONObject.toJSONString(req.getData()), Param3031.class);
 
-        if(null == list || list.isEmpty()){
+        if (null == param) {
             return ApiV1Resp.error("鎶撴媿淇℃伅涓虹┖锛屼笉瑙f瀽锛�", req);
         }
 
-        step1(list, gatewaySer);
-        log.info("璐ㄦ娂鐩戠鎺ュ彛V1锛�3031鎺ュ彛瑙f瀽瀹屾垚={}", req);
+        step1(param, gatewaySer);
+
         return ApiV1Resp.success(null, req);
 
     }
 
     /**
      * 寮傛瑙f瀽
-     * @param list
+     *
+     * @param param
      */
     @Async
-    public void step1(List<Param3031> list, GatewaySer gatewaySer) throws Exception {
+    public void step1(Param3031 param, GatewaySer gatewaySer) throws Exception {
 
-        EventInfo info;
-        for (Param3031 param : list) {
+        EventInfo info = new EventInfo();
+        info.setId(ContextUtil.generateId());
+        info.setCompanyId(gatewaySer.getCompanyId());
+        info.setDeptId(gatewaySer.getDeptId());
+        info.setSerId(param.getCameraId());
+        info.setName(param.getName());
+        info.setBizType(param.getBizType());
+        info.setType(param.getType());
+        info.setLevel(param.getLevel());
+        info.setInfo(param.getInfo());
+        info.setTime(DateUtils.parseDate(param.getTime(), "yyyy-MM-dd HH:mm:ss"));
+        info.setTags(param.getTags());
 
-            info = new EventInfo();
-            info.setId(ContextUtil.generateId());
-            info.setCompanyId(gatewaySer.getCompanyId());
-            info.setDeptId(gatewaySer.getDeptId());
-            info.setSerId(param.getCameraId());
-            info.setName(param.getName());
-            info.setBizType(param.getBizType());
-            info.setType(param.getType());
-            info.setLevel(param.getLevel());
-            info.setInfo(param.getInfo());
-            info.setTime(DateUtils.parseDate(param.getTime(),"yyyy-MM-dd HH:mm:ss"));
-            info.setTags(param.getTags());
+        //base64杞寲涓哄浘鐗囦繚瀛�
+        String savePath = fileService.getFileSavePath("EVENT");
+        String fileName = ContextUtil.UUID() + ".jpg";
+        String filePath = savePath + fileName;
+        fileService.baseImg2Disk(filePath, param.getImgBase64());
 
-
-            //base64杞寲涓哄浘鐗囦繚瀛�
-            String savePath = fileService.getFileSavePath("EVENT");
-            String fileName = ContextUtil.UUID() + ".jpg";
-            String filePath = savePath+fileName;
-            fileService.baseImg2Disk(filePath, param.getImgBase64());
-
-            //璁剧疆淇濆瓨鍥剧墖璺緞
-            info.setImgName(filePath.replace(FrameworkConfig.getProfile(), "/profile/"));
-
-            eventInfoService.addData(info);
+        //璁剧疆淇濆瓨鍥剧墖璺緞
+        info.setImgName(filePath.replace(FrameworkConfig.getProfile(), "/profile/"));
+        eventInfoService.addData(info);
+        //鍦扮鎶撴媿鍒ゆ柇鏄惁鐢熸垚鎵瑰鍛婅
+        Camera cameraById = cameraService.getCameraById(gatewaySer.getCompanyId(), param.getCameraId());
+        //鍒ゆ柇褰撳墠鎶撴媿鍥剧殑瑙﹀彂璁惧鏄惁鏄湴纾呯洃鎺ц澶�
+        if(null != cameraById && MonitorPointType.WEIGHBRIDGE_ROOM.getCode().equals(cameraById.getSpdwlx())){
+            String isGenerateAReply = param.getIsGenerateAReply();
+            //鍒ゆ柇褰撳墠AI浜嬩欢鎶撴媿锛屾槸鍚﹁Е鍙戠敓鎴愭壒澶嶅憡璀�
+            if(StringUtils.isNotBlank(isGenerateAReply) && Constant.YN_Y.equals(isGenerateAReply)){
+                SnapReply snapReply = new SnapReply();
+                snapReply.setDeptId(gatewaySer.getDeptId());
+                String content = "妫�娴嬪埌搴撳尯鏈夌枒浼煎嚭鍏ュ簱琛屼负锛岃鏍稿澶勭悊銆�";
+                snapReply.setContent(content);
+                BaseResp baseResp = snapReplyService.addData(snapReply);
+                if(BaseResp.isSuccess(baseResp)){
+                    log.info("鐢熸垚鍥炲鍛婅鎴愬姛锛�");
+                    // todo 鎺ㄩ�佸叕浼楀彿淇℃伅
+                }
+            }
         }
 
+
+        log.info("璐ㄦ娂鐩戠鎺ュ彛V1锛�3031鎺ュ彛瑙f瀽瀹屾垚");
+
     }
 
 }

--
Gitblit v1.9.3