无关风月
2 天以前 165e73d176191ae75b57c70e049c0cfd552bbdfa
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TEarlyWarningServiceImpl.java
@@ -1,10 +1,18 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.mapper.TEarlyWarningMapper;
import com.ruoyi.system.model.TEarlyWarning;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TaskWarningQuery;
import com.ruoyi.system.service.TEarlyWarningService;
import com.ruoyi.system.vo.system.CleanerListVO;
import com.ruoyi.system.vo.system.TaskWarningVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * <p>
@@ -17,4 +25,60 @@
@Service
public class TEarlyWarningServiceImpl extends ServiceImpl<TEarlyWarningMapper, TEarlyWarning> implements TEarlyWarningService {
    @Autowired
    private SysUserMapper sysUserMapper;
    @Autowired
    private TProjectDeptMapper projectDeptMapper;
    @Autowired
    private TDeptMapper deptMapper;
    @Autowired
    private TTaskMapper taskMapper;
    @Autowired
    private TLocationMapper locationMapper;
    @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);
        for (TaskWarningVO taskWarningVO : list) {
            String[] split = taskWarningVO.getTaskId().split(",");
            TTask tTask = taskList.stream().filter(e -> e.getId().equals(split[0])).findFirst().orElse(null);
            StringBuilder taskCode = new StringBuilder();
            for (String s : split) {
                TTask task = taskList.stream().filter(e -> e.getId().equals(s)).findFirst().orElse(null);
                if (task!=null){
                    taskCode.append(task.getTaskCode()).append(",");
                }
            }
            // 去除最后一位
            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());
                    }
                }
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
}