| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.system.applet.dto.IndexDTO; |
| | | import com.ruoyi.system.applet.query.TaskUserListQuery; |
| | | import com.ruoyi.system.applet.vo.TaskUserListVO; |
| | | import com.ruoyi.system.mapper.TDeptMapper; |
| | | import com.ruoyi.system.mapper.TTaskDetailMapper; |
| | | import com.ruoyi.system.mapper.TTaskMapper; |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.PointDetailQuery; |
| | | import com.ruoyi.system.query.TaskListQuery; |
| | | import com.ruoyi.system.query.TaskProgressQuery; |
| | | import com.ruoyi.system.service.TTaskCleanService; |
| | | import com.ruoyi.system.vo.system.ProgressListVO; |
| | | import com.ruoyi.system.vo.system.TLocationTaskListVO; |
| | | import com.ruoyi.system.vo.system.TaskListVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private TDeptMapper deptMapper; |
| | | @Autowired |
| | | private TTaskDetailMapper taskDetailMapper; |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | @Autowired |
| | | private TProjectDeptMapper projectDeptMapper; |
| | | |
| | | @Override |
| | | public PageInfo<TaskListVO> pageList(TaskListQuery query) { |
| | | PageInfo<TaskListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TaskListVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | List<String> collect = list.stream().map(TTask::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | return pageInfo; |
| | | } |
| | | List<TTaskDetail> taskDetails = taskDetailMapper.selectList(Wrappers.lambdaQuery(TTaskDetail.class) |
| | | .in(TTaskDetail::getTaskId, collect) |
| | | .eq(TTaskDetail::getHandleType,1) |
| | | .orderByDesc(TTaskDetail::getCreateTime)); |
| | | taskDetails = new ArrayList<>(taskDetails.stream() |
| | | .collect(Collectors.groupingBy( |
| | | TTaskDetail::getTaskId, |
| | | Collectors.collectingAndThen( |
| | | Collectors.toList(), |
| | | listAll -> listAll.get(0) |
| | | ) |
| | | )) |
| | | .values()); |
| | | |
| | | for (TaskListVO temp : list) { |
| | | SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(temp.getPatrolInspector())); |
| | | if(sysUser!=null){ |
| | | if ( sysUser.getDeptType() == 1){ |
| | | TProjectDept tProjectDept = projectDeptMapper.selectById(sysUser.getDeptId()); |
| | | if (!tProjectDept.getParentId().equals("0")){ |
| | | TProjectDept tProjectDept1 = projectDeptMapper.selectById(tProjectDept.getParentId()); |
| | | temp.setDeptName(tProjectDept1.getProjectName()+">"+tProjectDept.getProjectName()); |
| | | }else{ |
| | | temp.setDeptName(tProjectDept.getProjectName()); |
| | | } |
| | | }else{ |
| | | TDept tDept = deptMapper.selectById(sysUser.getDeptId()); |
| | | if (tDept != null){ |
| | | temp.setDeptName(tDept.getDeptName()); |
| | | |
| | | } |
| | | } |
| | | } |
| | | TTaskDetail tTaskDetail = taskDetails.stream().filter(e -> e.getTaskId().equals(temp.getId())).findFirst().orElse(null); |
| | | if (tTaskDetail!=null){ |
| | | temp.setPicture(tTaskDetail.getPicture()); |
| | | temp.setClearStatus(tTaskDetail.getClearStatus()); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<TaskUserListVO> pageListUser(TaskUserListQuery query) { |
| | | PageInfo<TaskUserListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TaskUserListVO> list = this.baseMapper.pageListUser(query,pageInfo); |
| | | for (TaskUserListVO taskUserListVO : list) { |
| | | |
| | | if (taskUserListVO.getDistance()!=null){ |
| | | taskUserListVO.setDistance(taskUserListVO.getDistance().divide(new BigDecimal("1000"),2, RoundingMode.HALF_DOWN)); |
| | | }else{ |
| | | taskUserListVO.setDistance(new BigDecimal("0")); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public List<TaskListVO> exportList(TaskListQuery query) { |
| | | List<TaskListVO> list = this.baseMapper.exportList(query); |
| | | |
| | | List<TTaskDetail> tTaskDetails = taskDetailMapper.selectList(new LambdaQueryWrapper<TTaskDetail>() |
| | | .orderByDesc(BaseModel::getCreateTime) |
| | |
| | | if (tTaskDetail!=null){ |
| | | taskListVO.setPicture(tTaskDetail.getPicture()); |
| | | taskListVO.setClearStatus(tTaskDetail.getClearStatus()); |
| | | taskListVO.setFinishTimeStr(DateUtils.localDateTimeToString(tTaskDetail.getCreateTime())); |
| | | taskListVO.setRemark(tTaskDetail.getRemark()); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<ProgressListVO> taskProgress(TaskProgressQuery query) { |
| | | PageInfo<ProgressListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<ProgressListVO> list = this.baseMapper.taskProgress(query,pageInfo); |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public List<ProgressListVO> taskProgressExport(TaskProgressQuery query) { |
| | | List<ProgressListVO> list = this.baseMapper.taskProgressExport(query); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<TLocationTaskListVO> pointInspectionHeatDetailTaskList(PointDetailQuery query) { |
| | | PageInfo<TLocationTaskListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TLocationTaskListVO> list = this.baseMapper.pointInspectionHeatDetailTaskList(query,pageInfo); |
| | | |
| | | List<TDept> deptList = deptMapper.selectList(Wrappers.lambdaQuery(TDept.class)); |
| | | List<TProjectDept> projectDeptList = projectDeptMapper.selectList(Wrappers.lambdaQuery(TProjectDept.class)); |
| | | |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return pageInfo; |
| | | } |
| | | |
| | | List<String> taskIds = list.stream().map(TLocationTaskListVO::getId).collect(Collectors.toList()); |
| | | List<TTaskDetail> taskDetails = taskDetailMapper.selectList(Wrappers.lambdaQuery(TTaskDetail.class) |
| | | .in(TTaskDetail::getTaskId,taskIds) |
| | | .orderByDesc(BaseModel::getCreateTime)); |
| | | |
| | | for (TLocationTaskListVO tLocationTaskListVO : list) { |
| | | if(tLocationTaskListVO.getDeptType()==1){ |
| | | projectDeptList.stream().filter(e -> e.getId().equals(tLocationTaskListVO.getDeptId())).findFirst().ifPresent(e -> { |
| | | if("0".equals(e.getParentId())){ |
| | | tLocationTaskListVO.setDeptName(e.getProjectName()); |
| | | }else { |
| | | projectDeptList.stream().filter(ee -> ee.getId().equals(e.getParentId())).findFirst().ifPresent(ee -> { |
| | | tLocationTaskListVO.setDeptName(ee.getProjectName()); |
| | | }); |
| | | } |
| | | }); |
| | | }else { |
| | | deptList.stream().filter(e -> e.getId().equals(tLocationTaskListVO.getDeptId())).findFirst().ifPresent(e -> { |
| | | tLocationTaskListVO.setDeptName(e.getDeptName()); |
| | | }); |
| | | } |
| | | |
| | | taskDetails.stream().filter(e -> e.getTaskId().equals(tLocationTaskListVO.getId())).findFirst().ifPresent(e -> { |
| | | tLocationTaskListVO.setClearStatus(e.getClearStatus()); |
| | | }); |
| | | |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<TaskUserListVO> pageListUser(TaskUserListQuery query) { |
| | | PageInfo<TaskUserListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TaskUserListVO> list = this.baseMapper.pageListUser(query,pageInfo); |
| | | for (TaskUserListVO taskUserListVO : list) { |
| | | taskUserListVO.setDistance(taskUserListVO.getDistance().divide(new BigDecimal("1000"),2, RoundingMode.HALF_UP)); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | public List<TTask> indexTask(IndexDTO dto) { |
| | | return this.baseMapper.indexTask(dto); |
| | | } |
| | | |
| | | |
| | | } |