Browse Source

巡检填报速度优化-保养标准优化

guarantee-lsq 2 years ago
parent
commit
eef37a6a7a

+ 2 - 0
platform-dao/src/main/java/com/platform/dao/dto/fill/FillGatherTaskDetailDTO.java

@@ -92,4 +92,6 @@ public class FillGatherTaskDetailDTO extends BaseDTO implements Serializable {
      */
     private Integer sortNum;
 
+    private Integer generateNum;
+
 }

+ 2 - 0
platform-dao/src/main/java/com/platform/dao/mapper/fill/FillGatherTaskDetailMapper.java

@@ -29,4 +29,6 @@ public interface FillGatherTaskDetailMapper extends MyMapper<FillGatherTaskDetai
 
     List<FillGatherTaskDetail> selectListSortNum(FillGatherTaskDetailDTO dto);
 
+    FillGatherTaskDetail selectSpecial(FillGatherTaskDetailDTO dto);
+
 }

+ 15 - 0
platform-dao/src/main/resources/mapper/fill/FillGatherTaskDetailMapper.xml

@@ -114,4 +114,19 @@
         </where>
         order by sort_num asc
     </select>
+
+    <select id="selectSpecial" parameterType="com.platform.dao.dto.fill.FillGatherTaskDetailDTO"
+            resultType="com.platform.dao.entity.fill.FillGatherTaskDetail">
+        select detail.* from t_fill_gather_task_detail detail
+        join t_fill_gather_task task on detail.task_id = task.id
+        <where>
+            <if test="sbId != null and sbId != ''">
+                and detail.sb_id = #{sbId}
+            </if>
+            <if test="generateNum != null">
+                and task.generate_num = #{generateNum}
+            </if>
+        </where>
+
+    </select>
 </mapper>

+ 7 - 0
platform-rest/src/main/java/com/platform/rest/controller/sb/SbInfoController.java

@@ -19,6 +19,7 @@ import com.platform.dao.vo.sb.SbInfoWorkplaceVO;
 import com.platform.office.poi.excel.ExcelImportUtil;
 import com.platform.office.poi.excel.entity.ImportParams;
 import com.platform.rest.log.annotation.SysLog;
+import com.platform.service.fill.FillGatherTaskService;
 import com.platform.service.sb.SbInfoService;
 import com.platform.service.upms.SysUserRoleService;
 import lombok.AllArgsConstructor;
@@ -46,6 +47,7 @@ public class SbInfoController {
 
     private final SbInfoService sbInfoService;
     private final SysUserRoleService sysUserRoleService;
+    private final FillGatherTaskService fillGatherTaskService;
 
     /**
      * 设备工作台数据
@@ -214,6 +216,8 @@ public class SbInfoController {
                 throw new DeniedException("不具备删除权限");
             }
         }
+        // 根据sbId获取巡检任务的taskId和detailId
+        fillGatherTaskService.getDetailBySbId(id);
         sbInfoService.deleteByPrimaryKey(id);
         return new R<>();
     }
@@ -236,6 +240,9 @@ public class SbInfoController {
                 throw new DeniedException("不具备删除权限");
             }
         }
+        ids.forEach(item->{
+            fillGatherTaskService.getDetailBySbId(item);
+        });
         sbInfoService.batchDelete(ids);
         return new R<>();
     }

+ 1 - 0
platform-service/src/main/java/com/platform/service/fill/FillGatherTaskDetailService.java

@@ -39,4 +39,5 @@ public interface FillGatherTaskDetailService extends IBaseService<FillGatherTask
      */
     void updateSortNum(String id,Integer sortNum);
 
+
                                                                                                                                         }

+ 2 - 0
platform-service/src/main/java/com/platform/service/fill/FillGatherTaskService.java

@@ -96,4 +96,6 @@ public interface FillGatherTaskService extends IBaseService<FillGatherTask, Fill
      */
     void fillStopDefault(String taskId,String detailId);
 
+    void getDetailBySbId(String sbId);
+
                                                                                                                                                                                                                 }

+ 3 - 0
platform-service/src/main/java/com/platform/service/fill/impl/FillGatherTaskDetailServiceImpl.java

@@ -6,7 +6,9 @@ import com.platform.common.util.ListUtils;
 import com.platform.common.util.RedisUtils;
 import com.platform.common.util.StringUtils;
 import com.platform.dao.bean.MyPage;
+import com.platform.dao.dto.fill.FillGatherTaskDTO;
 import com.platform.dao.dto.fill.FillGatherTaskDetailDTO;
+import com.platform.dao.entity.fill.FillGatherTask;
 import com.platform.dao.entity.fill.FillGatherTaskDetail;
 import com.platform.dao.mapper.fill.FillGatherTaskDetailMapper;
 import com.platform.dao.vo.query.fill.FillGatherTaskDetailVO;
@@ -18,6 +20,7 @@ import tk.mybatis.mapper.weekend.Weekend;
 import tk.mybatis.mapper.weekend.WeekendCriteria;
 
 import java.util.List;
+import java.util.Queue;
 
 /**
  * @Description 巡检任务详情表 service 实现类

+ 43 - 18
platform-service/src/main/java/com/platform/service/fill/impl/FillGatherTaskServiceImpl.java

@@ -61,13 +61,28 @@ public class FillGatherTaskServiceImpl extends BaseServiceImpl<FillGatherTaskMap
     private final FillUpdateRecordMapper fillUpdateRecordMapper;
     private final SysRoleMapper sysRoleMapper;
 
-    private void deleteDetails(List<String> detailIds){
+    private void deleteDetails(List<String> detailIds,String taskId){
+        StringBuilder ids = new StringBuilder();
         for(int i=0;i<detailIds.size();i++){
             FillGatherTaskDetail detail = new FillGatherTaskDetail();
             detail.setId(detailIds.get(i));
+            ids.append(detail.getId()).append("&");
             fillGatherTaskDetailMapper.deleteByPrimaryKey(detail);
         }
-
+        // 将redis缓存中的集合进行一个删除
+        String idString = ids.toString();
+        List<FillGatherTaskDetailVO> list = RedisUtils.getList(taskId,0,-1);
+        List<FillGatherTaskDetailVO> updateList = ListUtils.newArrayList();
+        if(list != null && list.size() > 0){
+            for(FillGatherTaskDetailVO vo : updateList){
+                if(idString.contains(vo.getId())){ // 过滤已经删除的任务明细
+                    continue;
+                }
+                updateList.add(vo);
+            }
+            RedisUtils.del(taskId);
+            RedisUtils.setList(taskId,updateList,24*60*60);
+        }
     }
 
     @Override
@@ -153,10 +168,10 @@ public class FillGatherTaskServiceImpl extends BaseServiceImpl<FillGatherTaskMap
             }
         }
         if (userInfo.getSuperAdmin()==1||flag) {
-            if (dto.getIsAdd() == 0) {
+            if (dto.getIsAdd() == 0) { // 删除巡检明细
                 task.setTotalNum(task1.getTotalNum() - dto.getDetailIds().size());
                 task.setWaitNum(task1.getTotalNum() - dto.getDetailIds().size());
-                deleteDetails(dto.getDetailIds());
+                deleteDetails(dto.getDetailIds(),dto.getId());
             } else if (dto.getIsAdd() == 1) {
                 List<FillGatherTaskDetailVO> detailVOS = fillGatherTaskDetailMapper.selectVOByTaskId(task1.getId());
                 StringBuffer sb = new StringBuffer();
@@ -523,6 +538,24 @@ public class FillGatherTaskServiceImpl extends BaseServiceImpl<FillGatherTaskMap
         mapper.updateByPrimaryKeySelective(updTask);
     }
 
+    @Override
+    public void getDetailBySbId(String sbId) {
+        FillGatherTaskDetailDTO query = new FillGatherTaskDetailDTO();
+        query.setSbId(sbId);
+        query.setGenerateNum(0);
+        FillGatherTaskDetail detail = fillGatherTaskDetailMapper.selectSpecial(query);
+        // 调用删除接口
+        if(detail != null){
+            FillGatherTaskDTO up = new FillGatherTaskDTO();
+            up.setId(detail.getId());
+            List<String> ids = ListUtils.newArrayList();
+            ids.add(detail.getId());
+            up.setDetailIds(ids);
+            up.setIsAdd(0);
+            this.updateDetails(up);
+        }
+    }
+
 
     /**
      * 给巡检人发送消息
@@ -622,22 +655,14 @@ public class FillGatherTaskServiceImpl extends BaseServiceImpl<FillGatherTaskMap
             detail.setTaskId(taskId);
             detail.setId(IdGeneratorUtils.getObjectId());
             detail.setStatus(0);
-
             details.add(detail);
         }
-//        for(String sbId : sbIds){
-//            FillGatherTaskDetail detail = new FillGatherTaskDetail();
-//            detail.setContent(content);
-//            detail.setCreatedTime(LocalDateTime.now());
-//            detail.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
-//            detail.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
-//            detail.setSbId(sbId);
-//            detail.setTaskId(taskId);
-//            detail.setId(IdGeneratorUtils.getObjectId());
-//            detail.setStatus(0);
-//            detail.setSortNum(100);
-//            details.add(detail);
-//        }
         fillGatherTaskDetailMapper.insertListforComplex(details);
+        // 获取最新的任务明细
+        List<FillGatherTaskDetailVO> list = fillGatherTaskDetailMapper.selectList(new FillGatherTaskDetailDTO().setTaskId(taskId));
+        if(list != null && list.size() > 0){
+            RedisUtils.del(taskId);
+            RedisUtils.setList(taskId,list,24*60*60);
+        }
     }
 }