瀏覽代碼

电子围栏

lyq 3 周之前
父節點
當前提交
de10d01183

+ 6 - 1
src/main/java/com/sooka/sponest/monitor/ai/controller/BusAiAlgorithmTaskController.java

@@ -17,6 +17,7 @@ import com.sooka.sponest.monitor.ai.domain.BusAiAlgorithmTask;
 import com.sooka.sponest.monitor.ai.service.IBusAiAlgorithmService;
 import com.sooka.sponest.monitor.ai.service.IBusAiAlgorithmTaskService;
 import com.sooka.sponest.monitor.ai.util.DHOauthUtil;
+import com.sooka.sponest.monitor.channelrail.service.IChannelRailService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -41,6 +42,9 @@ public class BusAiAlgorithmTaskController extends BaseController
     @Autowired
     private IBusAiAlgorithmService busAiAlgorithmService;
 
+    @Autowired
+    private IChannelRailService channelRailService;
+
     /**
      * 同步任务
      */
@@ -51,6 +55,7 @@ public class BusAiAlgorithmTaskController extends BaseController
         OauthConfigUserPwdInfo config = DHOauthUtil.getInstance().getOauthConfig();
         GeneralResponse response = null;
         BusAiAlgorithmTask aiAlgorithmTask = busAiAlgorithmTaskService.selectBusAiAlgorithmTaskById(id);
+        channelRailService.fill(aiAlgorithmTask);// 电子围栏
         if (StringUtils.isNull(aiAlgorithmTask.getTaskId())) {
             try {
                 response = HttpUtils.executeJson("/evo-apigw/evo-gmai/1.0.0/api/algorithmTask/add", aiAlgorithmTask, null, Method.POST, config, GeneralResponse.class);
@@ -207,7 +212,7 @@ public class BusAiAlgorithmTaskController extends BaseController
     /**
      * 查询算法列表
      */
-    @RequiresPermissions("ai:algorithmtask:remove")
+    @RequiresPermissions("ai:algorithmtask:list")
     @GetMapping("/listAlgorithm")
     public AjaxResult listAlgorithm(BusAiAlgorithm algorithm)
     {

+ 7 - 98
src/main/java/com/sooka/sponest/monitor/ai/domain/BusAiAlgorithmTaskChannel.java

@@ -1,8 +1,10 @@
 package com.sooka.sponest.monitor.ai.domain;
 
+import com.alibaba.fastjson.JSONObject;
 import com.ruoyi.common.core.web.domain.BaseEntity;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
+import lombok.Data;
+
+import java.util.List;
 
 /**
  * 任务通道对象 bus_ai_algorithm_task_channel
@@ -10,6 +12,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
  * @author lyq
  * @date 2025-09-15
  */
+@Data
 public class BusAiAlgorithmTaskChannel extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -41,100 +44,6 @@ public class BusAiAlgorithmTaskChannel extends BaseEntity
     /** 裁剪区域点,JSON格式字符串 */
     private String areaPoints;
 
-    public void setAlgorithmTaskId(Long algorithmTaskId)
-    {
-        this.algorithmTaskId = algorithmTaskId;
-    }
-
-    public Long getAlgorithmTaskId()
-    {
-        return algorithmTaskId;
-    }
-    public void setChannelCode(String channelCode)
-    {
-        this.channelCode = channelCode;
-    }
-
-    public String getChannelCode()
-    {
-        return channelCode;
-    }
-    public void setChannelName(String channelName)
-    {
-        this.channelName = channelName;
-    }
-
-    public String getChannelName()
-    {
-        return channelName;
-    }
-    public void setOrgName(String orgName)
-    {
-        this.orgName = orgName;
-    }
-
-    public String getOrgName()
-    {
-        return orgName;
-    }
-    public void setOrgCode(String orgCode)
-    {
-        this.orgCode = orgCode;
-    }
-
-    public String getOrgCode()
-    {
-        return orgCode;
-    }
-    public void setDeviceName(String deviceName)
-    {
-        this.deviceName = deviceName;
-    }
-
-    public String getDeviceName()
-    {
-        return deviceName;
-    }
-    public void setProtocol(String protocol)
-    {
-        this.protocol = protocol;
-    }
-
-    public String getProtocol()
-    {
-        return protocol;
-    }
-    public void setSnapMethod(Integer snapMethod)
-    {
-        this.snapMethod = snapMethod;
-    }
-
-    public Integer getSnapMethod()
-    {
-        return snapMethod;
-    }
-    public void setAreaPoints(String areaPoints)
-    {
-        this.areaPoints = areaPoints;
-    }
-
-    public String getAreaPoints()
-    {
-        return areaPoints;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("algorithmTaskId", getAlgorithmTaskId())
-            .append("channelCode", getChannelCode())
-            .append("channelName", getChannelName())
-            .append("orgName", getOrgName())
-            .append("orgCode", getOrgCode())
-            .append("deviceName", getDeviceName())
-            .append("protocol", getProtocol())
-            .append("snapMethod", getSnapMethod())
-            .append("areaPoints", getAreaPoints())
-            .toString();
-    }
+    /** 预制点,电子围栏 */
+    private List<JSONObject> channelPresetPointVOS;
 }

+ 13 - 4
src/main/java/com/sooka/sponest/monitor/channelrail/controller/ChannelRailController.java

@@ -2,6 +2,8 @@ package com.sooka.sponest.monitor.channelrail.controller;
 
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.sooka.sponest.monitor.ai.domain.BusAiAlgorithmTask;
+import com.sooka.sponest.monitor.ai.service.IBusAiAlgorithmTaskService;
 import com.sooka.sponest.monitor.channelrail.domain.ChannelRail;
 import com.sooka.sponest.monitor.channelrail.service.IChannelRailService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +22,9 @@ public class ChannelRailController extends BaseController {
     @Autowired
     private IChannelRailService channelRailService;
 
+    @Autowired
+    private IBusAiAlgorithmTaskService busAiAlgorithmTaskService;
+
     @GetMapping("/get")
     public AjaxResult get(String channelId, Long taskId, Long pointId, String type) {
         return success(channelRailService.get(channelId, taskId, pointId, type));
@@ -27,10 +32,14 @@ public class ChannelRailController extends BaseController {
 
     @PostMapping("/save")
     public AjaxResult save(@RequestBody ChannelRail channelRail) {
+        int result = 0;
         channelRailService.delete(channelRail.getChannelId(), channelRail.getTaskId(), channelRail.getPointId());
-        return channelRailService.save(channelRail) > 0 ? success() : error();
+        if (channelRailService.save(channelRail) > 0) {
+            BusAiAlgorithmTask task = new BusAiAlgorithmTask();
+            task.setId(channelRail.getTaskId());
+            task.setSyncStatus("0");
+            result = busAiAlgorithmTaskService.updateBusAiAlgorithmTask(task);
+        }
+        return result > 0 ? success() : error();
     }
 }
-
-
-

+ 0 - 2
src/main/java/com/sooka/sponest/monitor/channelrail/domain/ChannelRail.java

@@ -17,7 +17,5 @@ public class ChannelRail {
 
     private String jsonData;
 
-    private Integer syncStatus;
-
     private String info;
 }

+ 3 - 0
src/main/java/com/sooka/sponest/monitor/channelrail/service/IChannelRailService.java

@@ -1,5 +1,6 @@
 package com.sooka.sponest.monitor.channelrail.service;
 
+import com.sooka.sponest.monitor.ai.domain.BusAiAlgorithmTask;
 import com.sooka.sponest.monitor.channelrail.domain.ChannelRail;
 
 /**
@@ -15,6 +16,8 @@ public interface IChannelRailService {
     int save(ChannelRail channelRail);
 
     int delete(String channelId, Long taskId, Long pointId);
+
+    void fill(BusAiAlgorithmTask aiAlgorithmTask);
 }
 
 

+ 35 - 49
src/main/java/com/sooka/sponest/monitor/channelrail/service/impl/ChannelRailServiceImpl.java

@@ -1,16 +1,14 @@
 package com.sooka.sponest.monitor.channelrail.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.sooka.sponest.monitor.ai.domain.BusAiAlgorithmTask;
 import com.sooka.sponest.monitor.channelrail.domain.ChannelRail;
 import com.sooka.sponest.monitor.channelrail.mapper.ChannelRailMapper;
 import com.sooka.sponest.monitor.channelrail.service.IChannelRailService;
-import com.sooka.sponest.monitor.dahua.service.DahuaService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * 摄像头通道Service业务层处理
@@ -24,9 +22,6 @@ public class ChannelRailServiceImpl implements IChannelRailService {
     @Autowired
     private ChannelRailMapper channelRailMapper;
 
-    @Autowired
-    private DahuaService dahuaService;
-
     @Override
     public ChannelRail get(String channelId, Long taskId, Long pointId, String type) {
         return channelRailMapper.get(channelId, taskId, pointId, type);
@@ -34,51 +29,8 @@ public class ChannelRailServiceImpl implements IChannelRailService {
 
     @Override
     public int save(ChannelRail channelRail) {
-        int result = 0;
         List<ChannelRail> rails = channelRailMapper.getList(channelRail.getChannelId(), channelRail.getTaskId());
         rails.add(channelRail);
-        try {
-            JSONObject jsonObject = JSONObject.parseObject(channelRail.getInfo());
-            List<JSONObject> channels = JSONObject.parseArray(jsonObject.getString("channelInfos"), JSONObject.class);
-            channels = channels.stream().map(channel -> {
-                if (channel.getString("channelCode").equals(channelRail.getChannelId())) {
-                    List<JSONObject> channelPresetPointVOS = new ArrayList<>();
-                    for (ChannelRail rail : rails) {
-                        JSONObject channelPresetPointVO = new JSONObject();
-                        channelPresetPointVO.put("presetPointId", rail.getPointId());
-                        channelPresetPointVO.put("pointName", rail.getPointName());
-                        List<Map<String, Object>> channelCutInfos = new ArrayList<>();
-                        List<JSONObject> polygons = JSONObject.parseArray(JSONObject.parseObject(rail.getJsonData()).getString("polygons"), JSONObject.class);
-                        polygons.forEach(item -> {
-                            Map<String, Object> map = new HashMap<>();
-                            map.put("pointId", rail.getPointId());
-                            map.put("pointName", rail.getPointName());
-                            map.put("type", rail.getType());
-                            map.put("areaPoints", item.toJSONString());
-                            map.put("taskId", jsonObject.getLong("id"));
-                            map.put("channelCode", channel.getString("channelCode"));
-                            map.put("channelName", channel.getString("channelName"));
-                            channelCutInfos.add(map);
-                        });
-                        Collections.reverse(channelCutInfos);
-                        channelPresetPointVO.put("channelCutInfos", channelCutInfos);
-                        channelPresetPointVO.put("taskId", rail.getTaskId());
-                        channelPresetPointVO.put("channelCode", channel.getString("channelCode"));
-                        channelPresetPointVO.put("channelName", channel.getString("channelName"));
-                        channelPresetPointVO.put("pointType", 1);
-                        channelPresetPointVOS.add(channelPresetPointVO);
-                    }
-                    channel.put("channelPresetPointVOS", channelPresetPointVOS);
-                }
-                return channel;
-            }).collect(Collectors.toList());
-            jsonObject.put("channelInfos", channels);
-            System.out.println(JSON.toJSONString(jsonObject));
-            result = dahuaService.updateTask(jsonObject);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        channelRail.setSyncStatus(result);
         return channelRailMapper.save(channelRail);
     }
 
@@ -86,4 +38,38 @@ public class ChannelRailServiceImpl implements IChannelRailService {
     public int delete(String channelId, Long taskId, Long pointId) {
         return channelRailMapper.delete(channelId, taskId, pointId);
     }
+
+    @Override
+    public void fill(BusAiAlgorithmTask aiAlgorithmTask) {
+        aiAlgorithmTask.getChannelInfos().forEach(channel -> {
+            List<ChannelRail> rails = channelRailMapper.getList(channel.getChannelCode(), aiAlgorithmTask.getId());
+            List<JSONObject> channelPresetPointVOS = new ArrayList<>();
+            for (ChannelRail rail : rails) {
+                JSONObject channelPresetPointVO = new JSONObject();
+                channelPresetPointVO.put("presetPointId", rail.getPointId());
+                channelPresetPointVO.put("pointName", rail.getPointName());
+                List<Map<String, Object>> channelCutInfos = new ArrayList<>();
+                List<JSONObject> polygons = JSONObject.parseArray(JSONObject.parseObject(rail.getJsonData()).getString("polygons"), JSONObject.class);
+                polygons.forEach(item -> {
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("pointId", rail.getPointId());
+                    map.put("pointName", rail.getPointName());
+                    map.put("type", rail.getType());
+                    map.put("areaPoints", item.toJSONString());
+                    map.put("taskId", rail.getTaskId());
+                    map.put("channelCode", channel.getChannelCode());
+                    map.put("channelName", channel.getChannelName());
+                    channelCutInfos.add(map);
+                });
+                Collections.reverse(channelCutInfos);
+                channelPresetPointVO.put("channelCutInfos", channelCutInfos);
+                channelPresetPointVO.put("taskId", rail.getTaskId());
+                channelPresetPointVO.put("channelCode", channel.getChannelCode());
+                channelPresetPointVO.put("channelName", channel.getChannelName());
+                channelPresetPointVO.put("pointType", 1);
+                channelPresetPointVOS.add(channelPresetPointVO);
+            }
+            channel.setChannelPresetPointVOS(channelPresetPointVOS);
+        });
+    }
 }

+ 4 - 4
src/main/resources/mapper/monitor/channelrail/ChannelRailMapper.xml

@@ -5,12 +5,12 @@
 <mapper namespace="com.sooka.sponest.monitor.channelrail.mapper.ChannelRailMapper">
 
     <select id="get" resultType="ChannelRail">
-        select channel_id channelId, task_id taskId, point_id pointId, type, json_data jsonData, sync_status syncStatus from centermonitor_t_channel_rail
+        select channel_id channelId, task_id taskId, point_id pointId, type, json_data jsonData from centermonitor_t_channel_rail
         where channel_id = #{channelId} and task_id = #{taskId} and point_id = #{pointId} and type = #{type}
     </select>
 
     <select id="getList" resultType="ChannelRail">
-        select channel_id channelId, task_id taskId, point_id pointId, type, json_data jsonData from centermonitor_t_channel_rail
+        select channel_id channelId, task_id taskId, point_id pointId, point_name pointName, type, json_data jsonData from centermonitor_t_channel_rail
         where channel_id = #{channelId} and task_id = #{taskId}
     </select>
 
@@ -20,17 +20,17 @@
             <if test="channelId != null">channel_id,</if>
             <if test="taskId != null">task_id,</if>
             <if test="pointId != null">point_id,</if>
+            <if test="pointName != null">point_name,</if>
             <if test="type != null">type,</if>
             <if test="jsonData != null">json_data,</if>
-            <if test="syncStatus != null">sync_status,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="channelId != null">#{channelId},</if>
             <if test="taskId != null">#{taskId},</if>
             <if test="pointId != null">#{pointId},</if>
+            <if test="pointName != null">#{pointName},</if>
             <if test="type != null">#{type},</if>
             <if test="jsonData != null">#{jsonData},</if>
-            <if test="syncStatus != null">#{syncStatus},</if>
         </trim>
     </insert>