From 25b19e60e004290531f61fdf608d1adb5e531903 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期六, 12 七月 2025 14:40:12 +0800 Subject: [PATCH] 保洁巡检本周代码 --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TEarlyWarningServiceImpl.java | 138 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 112 insertions(+), 26 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TEarlyWarningServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TEarlyWarningServiceImpl.java index 1bc2f35..0e2fb33 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TEarlyWarningServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TEarlyWarningServiceImpl.java @@ -9,10 +9,18 @@ import com.ruoyi.system.service.TEarlyWarningService; import com.ruoyi.system.vo.system.CleanerListVO; import com.ruoyi.system.vo.system.TaskWarningVO; +import com.sun.org.apache.bcel.internal.generic.NEW; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * <p> @@ -38,9 +46,11 @@ @Override public PageInfo<TaskWarningVO> pageList(TaskWarningQuery query) { List<TTask> taskList = taskMapper.selectList(null); - PageInfo<TaskWarningVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); - List<TaskWarningVO> list = this.baseMapper.pageList(query,pageInfo); + List<TaskWarningVO> list = this.baseMapper.pageList(query); + List<String> strings = new ArrayList<>(); + List<String> taskIds = new ArrayList<>(); + List<TaskWarningVO> res = new ArrayList<>(); for (TaskWarningVO taskWarningVO : list) { String[] split = taskWarningVO.getTaskId().split(","); TTask tTask = taskList.stream().filter(e -> e.getId().equals(split[0])).findFirst().orElse(null); @@ -52,33 +62,109 @@ } } // 去除最后一位 - taskWarningVO.setTaskCode(taskWarningVO.getTaskCode().substring(0, taskWarningVO.getTaskCode().length() - 1)); - if (tTask!=null){ - TLocation tLocation = locationMapper.selectById(tTask.getLocationId()); - if (tLocation!=null){ - taskWarningVO.setLocationName(tLocation.getLocationName()); - } - SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(tTask.getPatrolInspector())); - if (sysUser!=null){ - taskWarningVO.setPhonenumber(sysUser.getPhonenumber()); - taskWarningVO.setPatrolInspectorName(sysUser.getNickName()); - if (sysUser.getDeptType() == 1){ - TProjectDept tProjectDept = projectDeptMapper.selectById(sysUser.getDeptId()); - if (!tProjectDept.getParentId().equals("0")){ - TProjectDept tProjectDept1 = projectDeptMapper.selectById(tProjectDept.getParentId()); - taskWarningVO.setDeptName(tProjectDept1.getProjectName()+">"+tProjectDept.getProjectName()); - }else{ - taskWarningVO.setDeptName(tProjectDept.getProjectName()); - } - }else{ - TDept tDept = deptMapper.selectById(sysUser.getDeptId()); - taskWarningVO.setDeptName(tDept.getDeptName()); - } - } + if (StringUtils.hasLength(taskCode.toString())){ + taskWarningVO.setTaskCode(taskCode.substring(0, taskCode.length() - 1)); + strings.add(taskWarningVO.getTaskCode()); } + String format = taskWarningVO.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + + taskIds.add(taskWarningVO.getTaskId()+","+format); } - pageInfo.setRecords(list); + + for (String string : taskIds) { + if (string.split(",").length>2){ + List<String> userIds = new ArrayList<>(); + List<TaskWarningVO> temp = new ArrayList<>(); + String s1 = string.split(",")[3]; + // 转化为LocalDateTime + LocalDateTime localDateTime = LocalDateTime.parse(s1, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + // 点位不合格预警 + for (String s : string.split(",")) { + TaskWarningVO taskWarningVO = new TaskWarningVO(); + taskWarningVO.setWarningType(2); + taskWarningVO.setCreateTime(localDateTime); + TTask tTask = taskList.stream().filter(e -> e.getId().equals(s)).findFirst().orElse(null); + // 任务所属巡检员 + if (tTask!=null){ + SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(tTask.getPatrolInspector())); + if (!userIds.contains(tTask.getPatrolInspector())){ + userIds.add(tTask.getPatrolInspector()); + taskWarningVO.setTaskCode(tTask.getTaskCode()); + TLocation tLocation = locationMapper.selectById(tTask.getLocationId()); + if (tLocation!=null){ + taskWarningVO.setLocationName(tLocation.getLocationName()); + } + if (sysUser!=null){ + taskWarningVO.setPhonenumber(sysUser.getPhonenumber()); + taskWarningVO.setPatrolInspectorName(sysUser.getNickName()); + if (sysUser.getDeptType() == 1){ + TProjectDept tProjectDept = projectDeptMapper.selectById(sysUser.getDeptId()); + if (!tProjectDept.getParentId().equals("0")){ + TProjectDept tProjectDept1 = projectDeptMapper.selectById(tProjectDept.getParentId()); + taskWarningVO.setDeptName(tProjectDept1.getProjectName()+">"+tProjectDept.getProjectName()); + }else{ + taskWarningVO.setDeptName(tProjectDept.getProjectName()); + } + }else{ + TDept tDept = deptMapper.selectById(sysUser.getDeptId()); + taskWarningVO.setDeptName(tDept.getDeptName()); + } + } + temp.add(taskWarningVO); + res.add(taskWarningVO); + }else{ + for (TaskWarningVO warningVO : temp) { + if (warningVO.getPhonenumber().equals(sysUser.getPhonenumber()+"")){ + warningVO.setTaskCode(warningVO.getTaskCode()+","+tTask.getTaskCode()); + break; + } + } + } + } + } + }else{ + String s1 = string.split(",")[1]; + // 转化为LocalDateTime + LocalDateTime localDateTime = LocalDateTime.parse(s1, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + // 超时预警 + TaskWarningVO taskWarningVO = new TaskWarningVO(); + taskWarningVO.setCreateTime(localDateTime); + + taskWarningVO.setWarningType(1); + TTask tTask = taskList.stream().filter(e -> e.getId().equals(string.split(",")[0])).findFirst().orElse(null); + // 任务所属巡检员 + if (tTask!=null){ + SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(tTask.getPatrolInspector())); + taskWarningVO.setTaskCode(tTask.getTaskCode()); + TLocation tLocation = locationMapper.selectById(tTask.getLocationId()); + if (tLocation!=null){ + taskWarningVO.setLocationName(tLocation.getLocationName()); + } + if (sysUser!=null){ + taskWarningVO.setPhonenumber(sysUser.getPhonenumber()); + taskWarningVO.setPatrolInspectorName(sysUser.getNickName()); + if (sysUser.getDeptType() == 1){ + TProjectDept tProjectDept = projectDeptMapper.selectById(sysUser.getDeptId()); + if (!tProjectDept.getParentId().equals("0")){ + TProjectDept tProjectDept1 = projectDeptMapper.selectById(tProjectDept.getParentId()); + taskWarningVO.setDeptName(tProjectDept1.getProjectName()+">"+tProjectDept.getProjectName()); + }else{ + taskWarningVO.setDeptName(tProjectDept.getProjectName()); + } + }else{ + TDept tDept = deptMapper.selectById(sysUser.getDeptId()); + taskWarningVO.setDeptName(tDept.getDeptName()); + } + } + res.add(taskWarningVO); + } + } + } + pageInfo.setTotal(res.size()); + // 手动对res进行分页 + res = res.stream().skip((long) (query.getPageNum() - 1) * query.getPageSize()).limit(query.getPageSize()).collect(Collectors.toList()); + pageInfo.setRecords(res); return pageInfo; } } -- Gitblit v1.7.1