tjf 1 өдөр өмнө
parent
commit
0cebaa2f35

+ 2 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/TaskManageController.java

@@ -66,7 +66,7 @@ public class TaskManageController extends BaseController {
     @Log(title = "任务管理", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody TaskManage taskManage) {
-        return toAjax(taskManageService.insertTaskManage(taskManage));
+        return taskManageService.insertTaskManage(taskManage);
     }
 
     /**
@@ -76,7 +76,7 @@ public class TaskManageController extends BaseController {
     @Log(title = "任务管理", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
     public AjaxResult edit(@RequestBody TaskManage taskManage) {
-        return toAjax(taskManageService.updateTaskManage(taskManage));
+        return taskManageService.updateTaskManage(taskManage);
     }
 
     /**

+ 27 - 21
ruoyi-system/src/main/java/com/ruoyi/manage/domain/TaskManage.java

@@ -1,12 +1,11 @@
 package com.ruoyi.manage.domain;
 
-import com.ruoyi.common.core.domain.entity.AlgorithmSet;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
+import com.ruoyi.common.core.domain.entity.AlgorithmSet;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -61,7 +60,18 @@ public class TaskManage extends BaseEntity
      * 算法集合
      */
     private List<AlgorithmSet> algorithmSetList = new ArrayList<>();
+    /**
+     * 算法集合id
+     */
+    private Long[] algorithmSetIds;
 
+    public Long[] getAlgorithmSetIds() {
+        return algorithmSetIds;
+    }
+
+    public void setAlgorithmSetIds(Long[] algorithmSetIds) {
+        this.algorithmSetIds = algorithmSetIds;
+    }
     public List<AlgorithmSet> getAlgorithmSetList() {
         return algorithmSetList;
     }
@@ -172,23 +182,19 @@ public class TaskManage extends BaseEntity
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("taskId", getTaskId())
-            .append("clockSetId", getClockSetId())
-            .append("clockName", getClockName())
-            .append("taskNum", getTaskNum())
-            .append("taskDetails", getTaskDetails())
-            .append("ioOutput", getIoOutput())
-            .append("channelId", getChannelId())
-            .append("videoAddress", getVideoAddress())
-            .append("reportAddress", getReportAddress())
-            .append("delFlag", getDelFlag())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("algorithmSetList", getAlgorithmSetList())
-            .append("remark", getRemark())
-            .toString();
+        return "TaskManage{" +
+                "taskId=" + taskId +
+                ", clockSetId=" + clockSetId +
+                ", clockName='" + clockName + '\'' +
+                ", taskNum='" + taskNum + '\'' +
+                ", taskDetails='" + taskDetails + '\'' +
+                ", ioOutput='" + ioOutput + '\'' +
+                ", channelId=" + channelId +
+                ", videoAddress='" + videoAddress + '\'' +
+                ", reportAddress='" + reportAddress + '\'' +
+                ", delFlag='" + delFlag + '\'' +
+                ", algorithmSetList=" + algorithmSetList +
+                ", algorithmSetIds=" + Arrays.toString(algorithmSetIds) +
+                '}';
     }
 }

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/mapper/TaskManageMapper.java

@@ -19,6 +19,7 @@ public interface TaskManageMapper
      * @return 任务管理
      */
     public TaskManage selectTaskManageByTaskId(Long taskId);
+    public TaskManage selectTaskManageByChannelId(Long channelId);
 
     /**
      * 查询任务管理列表

+ 3 - 2
ruoyi-system/src/main/java/com/ruoyi/manage/service/ITaskManageService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.manage.service;
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.manage.domain.TaskManage;
 
 import java.util.List;
@@ -34,7 +35,7 @@ public interface ITaskManageService
      * @param taskManage 任务管理
      * @return 结果
      */
-    public int insertTaskManage(TaskManage taskManage);
+    public AjaxResult insertTaskManage(TaskManage taskManage);
 
     /**
      * 修改任务管理
@@ -42,7 +43,7 @@ public interface ITaskManageService
      * @param taskManage 任务管理
      * @return 结果
      */
-    public int updateTaskManage(TaskManage taskManage);
+    public AjaxResult updateTaskManage(TaskManage taskManage);
 
     /**
      * 批量删除任务管理

+ 56 - 23
ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/TaskManageServiceImpl.java

@@ -1,97 +1,130 @@
 package com.ruoyi.manage.service.impl;
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.manage.domain.AlgorithmChannel;
 import com.ruoyi.manage.domain.TaskManage;
+import com.ruoyi.manage.mapper.AlgorithmChannelMapper;
 import com.ruoyi.manage.mapper.TaskManageMapper;
 import com.ruoyi.manage.service.ITaskManageService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
  * 任务管理Service业务层处理
- * 
+ *
  * @author boman
  * @date 2025-05-07
  */
 @Service
-public class TaskManageServiceImpl implements ITaskManageService 
-{
+public class TaskManageServiceImpl implements ITaskManageService {
     @Autowired
     private TaskManageMapper taskManageMapper;
+    @Autowired
+    private AlgorithmChannelMapper algorithmChannelMapper;
 
     /**
      * 查询任务管理
-     * 
+     *
      * @param taskId 任务管理主键
      * @return 任务管理
      */
     @Override
-    public TaskManage selectTaskManageByTaskId(Long taskId)
-    {
+    public TaskManage selectTaskManageByTaskId(Long taskId) {
         return taskManageMapper.selectTaskManageByTaskId(taskId);
     }
 
     /**
      * 查询任务管理列表
-     * 
+     *
      * @param taskManage 任务管理
      * @return 任务管理
      */
     @Override
-    public List<TaskManage> selectTaskManageList(TaskManage taskManage)
-    {
+    public List<TaskManage> selectTaskManageList(TaskManage taskManage) {
         return taskManageMapper.selectTaskManageList(taskManage);
     }
 
     /**
      * 新增任务管理
-     * 
+     *
      * @param taskManage 任务管理
      * @return 结果
      */
     @Override
-    public int insertTaskManage(TaskManage taskManage)
-    {
+    public AjaxResult insertTaskManage(TaskManage taskManage) {
+        Long channelId = taskManage.getChannelId();
+        TaskManage taskManageOld = taskManageMapper.selectTaskManageByChannelId(channelId);
+        if (taskManageOld != null) {
+            return AjaxResult.error("当前通道编号任务已存在");
+        }
+        //判断该通道号是否已经有任务
         taskManage.setCreateTime(DateUtils.getNowDate());
-        return taskManageMapper.insertTaskManage(taskManage);
+        taskManageMapper.insertTaskManage(taskManage);
+        insertAlgorithmChannel(channelId, taskManage.getAlgorithmSetIds());
+        return AjaxResult.success();
+    }
+
+    /**
+     * 新增算法和通道信息
+     */
+    public void insertAlgorithmChannel(Long channelId, Long[] algorithmSetIds) {
+        if (StringUtils.isNotEmpty(algorithmSetIds)) {
+            //新增算法和通道信息
+            List<AlgorithmChannel> list = new ArrayList<AlgorithmChannel>(algorithmSetIds.length);
+            for (Long algorithmSetId : algorithmSetIds) {
+                AlgorithmChannel algorithmChannel = new AlgorithmChannel();
+                algorithmChannel.setChannelId(channelId);
+                algorithmChannel.setAlgorithmId(algorithmSetId);
+                algorithmChannel.setCreateTime(DateUtils.getNowDate());
+                list.add(algorithmChannel);
+            }
+            algorithmChannelMapper.batchAlgorithmChannel(list);
+        }
     }
 
     /**
      * 修改任务管理
-     * 
+     *
      * @param taskManage 任务管理
      * @return 结果
      */
     @Override
-    public int updateTaskManage(TaskManage taskManage)
-    {
+    @Transactional
+    public AjaxResult updateTaskManage(TaskManage taskManage) {
+        //删除算法和通道信息
+        algorithmChannelMapper.deleteAlgorithmChannelByChannelId(taskManage.getChannelId());
+        //新增算法和通道信息
+        insertAlgorithmChannel(taskManage.getChannelId(), taskManage.getAlgorithmSetIds());
         taskManage.setUpdateTime(DateUtils.getNowDate());
-        return taskManageMapper.updateTaskManage(taskManage);
+        taskManageMapper.updateTaskManage(taskManage);
+        return AjaxResult.success();
     }
 
     /**
      * 批量删除任务管理
-     * 
+     *
      * @param taskIds 需要删除的任务管理主键
      * @return 结果
      */
     @Override
-    public int deleteTaskManageByTaskIds(Long[] taskIds)
-    {
+    public int deleteTaskManageByTaskIds(Long[] taskIds) {
         return taskManageMapper.deleteTaskManageByTaskIds(taskIds);
     }
 
     /**
      * 删除任务管理信息
-     * 
+     *
      * @param taskId 任务管理主键
      * @return 结果
      */
     @Override
-    public int deleteTaskManageByTaskId(Long taskId)
-    {
+    public int deleteTaskManageByTaskId(Long taskId) {
         return taskManageMapper.deleteTaskManageByTaskId(taskId);
     }
 }

+ 41 - 10
ruoyi-system/src/main/resources/mapper/manage/ChannelNumberMapper.xml

@@ -23,28 +23,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
         <result property="remark"    column="remark"    />
+        <collection  property="algorithmSetList"   javaType="java.util.List"  resultMap="AlgorithmSetResult" />
+    </resultMap>
+    <resultMap type="AlgorithmSet" id="AlgorithmSetResult">
+        <result property="algorithmId" column="algorithm_id"/>
+        <result property="algorithmNum" column="algorithm_num"/>
+        <result property="algorithmName" column="algorithm_name"/>
     </resultMap>
-
     <sql id="selectChannelNumberVo">
         select channel_id, channel_num,equipment_id, equipment_num, equipment_name, video_address,photo_address,port, account,password,protocol_type, channel_details, del_flag, create_by, create_time, update_by, update_time, remark from channel_number
     </sql>
 
     <select id="selectChannelNumberList" parameterType="ChannelNumber" resultMap="ChannelNumberResult">
-        <include refid="selectChannelNumberVo"/>
+        select c.channel_id, c.channel_num,c.equipment_id, c.equipment_num, c.equipment_name, c.video_address,c.photo_address,c.port, c.account,c.password,c.protocol_type,
+        c.channel_details, c.del_flag, c.create_by, c.create_time, c.update_by, c.update_time, c.remark,als.algorithm_name,als.algorithm_id
+        from channel_number c
+            left join algorithm_channel a on a.channel_id = c.channel_id
+            left join algorithm_set als on als.algorithm_id = a.algorithm_id
         <where>
-            <if test="equipmentNum != null  and equipmentNum != ''"> and equipment_num  like concat('%', #{equipmentNum}, '%')</if>
-            <if test="equipmentName != null  and equipmentName != ''"> and equipment_name like concat('%', #{equipmentName}, '%')</if>
-            <if test="channelNum != null  and channelNum != ''"> and channel_num = #{channelNum}</if>
-            <if test="videoAddress != null  and videoAddress != ''"> and video_address = #{videoAddress}</if>
-            <if test="protocolType != null  and protocolType != ''"> and protocol_type = #{protocolType}</if>
-            <if test="channelDetails != null  and channelDetails != ''"> and channel_details = #{channelDetails}</if>
+            <if test="equipmentNum != null  and equipmentNum != ''"> and c.equipment_num  like concat('%', #{equipmentNum}, '%')</if>
+            <if test="equipmentName != null  and equipmentName != ''"> and c.equipment_name like concat('%', #{equipmentName}, '%')</if>
+            <if test="channelNum != null  and channelNum != ''"> and c.channel_num = #{channelNum}</if>
+            <if test="videoAddress != null  and videoAddress != ''"> and c.video_address = #{videoAddress}</if>
+            <if test="protocolType != null  and protocolType != ''"> and c.protocol_type = #{protocolType}</if>
+            <if test="channelDetails != null  and channelDetails != ''"> and c.channel_details = #{channelDetails}</if>
         </where>
         order by create_time DESC
     </select>
     
     <select id="selectChannelNumberByChannelId" parameterType="ChannelNumber" resultMap="ChannelNumberResult">
-        <include refid="selectChannelNumberVo"/>
-        where channel_id = #{channelId}
+        select c.channel_id,
+               c.channel_num,
+               c.equipment_id,
+               c.equipment_num,
+               c.equipment_name,
+               c.video_address,
+               c.photo_address,
+               c.port,
+               c.account,
+               c.password,
+               c.protocol_type,
+               c.channel_details,
+               c.del_flag,
+               c.create_by,
+               c.create_time,
+               c.update_by,
+               c.update_time,
+               c.remark,
+               als.algorithm_name,
+               als.algorithm_id
+        from channel_number c
+                 left join algorithm_channel a on a.channel_id = c.channel_id
+                 left join algorithm_set als on als.algorithm_id = a.algorithm_id
+        where c.channel_id = #{channelId}
     </select>
     <select id="selectChannelNumberByChannelNum" parameterType="string" resultMap="ChannelNumberResult">
         <include refid="selectChannelNumberVo"/>

+ 20 - 3
ruoyi-system/src/main/resources/mapper/manage/TaskManageMapper.xml

@@ -20,14 +20,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
         <result property="remark"    column="remark"    />
+        <collection  property="algorithmSetList"   javaType="java.util.List"  resultMap="AlgorithmSetResult" />
+    </resultMap>
+    <resultMap type="AlgorithmSet" id="AlgorithmSetResult">
+        <result property="algorithmId" column="algorithm_id"/>
+        <result property="algorithmNum" column="algorithm_num"/>
+        <result property="algorithmName" column="algorithm_name"/>
     </resultMap>
-
     <sql id="selectTaskManageVo">
         select task_id, clock_set_id, clock_name, task_num, task_details, io_output, channel_id, video_address, report_address, del_flag, create_by, create_time, update_by, update_time, remark from task_manage
     </sql>
 
     <select id="selectTaskManageList" parameterType="TaskManage" resultMap="TaskManageResult">
-        <include refid="selectTaskManageVo"/>
+        select t.task_id, t.clock_set_id, t.clock_name, t.task_num, t.task_details, t.io_output, t.channel_id, t.video_address, t.report_address, t.del_flag,
+        t.create_by, t.create_time, t.update_by, t.update_time, t.remark,als.algorithm_name,als.algorithm_id
+        from task_manage t
+        left join algorithm_channel a on a.channel_id = t.channel_id
+        left join algorithm_set als on als.algorithm_id = a.algorithm_id
         <where>  
             <if test="clockSetId != null "> and clock_set_id = #{clockSetId}</if>
             <if test="clockName != null  and clockName != ''"> and clock_name like concat('%', #{clockName}, '%')</if>
@@ -41,8 +50,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
     
     <select id="selectTaskManageByTaskId" parameterType="Long" resultMap="TaskManageResult">
+        select t.task_id, t.clock_set_id, t.clock_name, t.task_num, t.task_details, t.io_output, t.channel_id, t.video_address, t.report_address, t.del_flag,
+               t.create_by, t.create_time, t.update_by, t.update_time, t.remark,als.algorithm_name,als.algorithm_id
+        from task_manage t
+                 left join algorithm_channel a on a.channel_id = t.channel_id
+                 left join algorithm_set als on als.algorithm_id = a.algorithm_id
+        where t.task_id = #{taskId}
+    </select>
+    <select id="selectTaskManageByChannelId" parameterType="Long" resultMap="TaskManageResult">
         <include refid="selectTaskManageVo"/>
-        where task_id = #{taskId}
+        where channel_id = #{channelId}
     </select>
 
     <insert id="insertTaskManage" parameterType="TaskManage" useGeneratedKeys="true" keyProperty="taskId">