From 124e7de0dc6dd727677fc04c53774c415e8783db Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期一, 02 二月 2026 14:07:13 +0800
Subject: [PATCH] 优化代码

---
 fzzy-igdss-inte/src/main/java/com/fzzy/igds/api/v1/service/ApiV1Service3031.java |   62 +++++++++++++-----------------
 1 files changed, 27 insertions(+), 35 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 aa91ec4..f67ce14 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,14 +1,11 @@
 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.domain.EventInfo;
 import com.fzzy.igds.domain.GatewaySer;
-import com.alibaba.fastjson.JSONObject;
-import com.fzzy.igds.domain.SnapRecord;
 import com.fzzy.igds.service.EventInfoService;
 import com.fzzy.igds.service.FileService;
 import com.fzzy.igds.utils.ContextUtil;
@@ -36,7 +33,6 @@
     private FileService fileService;
 
     /**
-     *
      * @param req
      * @param gatewaySer
      * @return
@@ -44,13 +40,13 @@
     public ApiV1Resp<Object> analysis(ApiV1Req<Object> req, GatewaySer gatewaySer) throws Exception {
 
         //杞寲涓哄璞�
-        List<Param3031> list = JSONObject.parseArray(JSONObject.toJSONString(req.getData()), 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);
+        step1(param, gatewaySer);
 
         return ApiV1Resp.success(null, req);
 
@@ -58,39 +54,35 @@
 
     /**
      * 寮傛瑙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());
 
+        //璁剧疆淇濆瓨鍥剧墖璺緞
+        info.setImgName(filePath.replace(FrameworkConfig.getProfile(), "/profile/"));
 
-            //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);
-        }
+        eventInfoService.addData(info);
 
         log.info("璐ㄦ娂鐩戠鎺ュ彛V1锛�3031鎺ュ彛瑙f瀽瀹屾垚");
 

--
Gitblit v1.9.3