package com.ruoyi.web.controller.api;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.framework.web.service.TokenService;
|
import com.ruoyi.system.dto.WorkBenchesDTO;
|
import com.ruoyi.system.model.*;
|
import com.ruoyi.system.query.DataStatisticsQuery;
|
import com.ruoyi.system.query.TaskSituationQuery;
|
import com.ruoyi.system.service.*;
|
import com.ruoyi.system.vo.system.*;
|
import com.ruoyi.web.util.OssUploadUtil;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.util.CollectionUtils;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import javax.annotation.Resource;
|
import java.math.BigDecimal;
|
import java.math.RoundingMode;
|
import java.time.LocalDate;
|
import java.time.LocalDateTime;
|
import java.time.format.DateTimeFormatter;
|
import java.time.temporal.ChronoUnit;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
/**
|
* <p>
|
* 任务申诉 前端控制器
|
* </p>
|
*
|
* @author xiaochen
|
* @since 2025-05-28
|
*/
|
@Api(tags = "工作台")
|
@RestController
|
@RequestMapping("/workbenches")
|
public class WorkbenchesController {
|
@Resource
|
private TTaskCleanService taskCleanService;
|
@Resource
|
private TLocationTypeService locationTypeService;
|
@Resource
|
private TLocationService locationService;
|
@Resource
|
private TProjectDeptService projectDeptService;
|
@Resource
|
private TTaskDetailService tTaskDetailService;
|
@Resource
|
private ISysUserService sysUserService;
|
|
@Resource
|
private TokenService tokenService;
|
|
@Resource
|
private TDictDataService dictDataService;
|
@Resource
|
private TCleanerService cleanerService;
|
@Resource
|
private TLeaveService leaveService;
|
|
@ApiOperation(value = "查询部门 项目部列表 不分页")
|
@GetMapping(value = "/listDepts")
|
public R<List<DeptNoLimitVO>> listDepts() {
|
Long userId = tokenService.getLoginUser().getUserId();
|
SysUser sysUser = sysUserService.selectUserById(userId);
|
List<TProjectDept> parent = projectDeptService.lambdaQuery().eq(TProjectDept::getParentId, "0").list();
|
List<TProjectDept> child = projectDeptService.lambdaQuery().ne(TProjectDept::getParentId, "0").list();
|
List<DeptNoLimitVO> res = new ArrayList<>();
|
DeptNoLimitVO deptNoLimitVO2 = new DeptNoLimitVO();
|
deptNoLimitVO2.setDeptName("公司");
|
res.add(deptNoLimitVO2);
|
if (sysUser.getDeptType()==1){
|
parent = parent.stream().filter(e -> e.getId().equals(sysUser.getDeptId())).collect(Collectors.toList());
|
}
|
for (DeptNoLimitVO re : res) {
|
if (re.getDeptName().equals("项目部")) {
|
List<DeptNoLimitParentVO> deptNoLimitVOS = new ArrayList<>();
|
for (TProjectDept tProjectDept : parent) {
|
DeptNoLimitParentVO deptNoLimitVO = new DeptNoLimitParentVO();
|
deptNoLimitVO.setDeptName(tProjectDept.getProjectName());
|
deptNoLimitVO.setDeptId(tProjectDept.getId());
|
List<TProjectDept> collect = child.stream().filter(e -> e.getParentId().equals(tProjectDept.getId())).collect(Collectors.toList());
|
List<DeptNoLimitChildVO> deptNoLimitChildVOS = new ArrayList<>();
|
for (TProjectDept projectDept : collect) {
|
DeptNoLimitChildVO deptNoLimitChildVO = new DeptNoLimitChildVO();
|
deptNoLimitChildVO.setDeptName(projectDept.getProjectName());
|
deptNoLimitChildVO.setDeptId(projectDept.getId());
|
deptNoLimitChildVOS.add(deptNoLimitChildVO);
|
}
|
deptNoLimitVO.setDeptChild(deptNoLimitChildVOS);
|
deptNoLimitVOS.add(deptNoLimitVO);
|
}
|
re.setDeptChild(deptNoLimitVOS);
|
}
|
}
|
return R.ok(res);
|
}
|
|
@ApiOperation(value = "查询片区")
|
@GetMapping(value = "/queryProject")
|
public R<List<TProjectDept>> queryProject() {
|
Integer deptType = tokenService.getLoginUser().getUser().getDeptType();
|
String deptId = tokenService.getLoginUser().getUser().getDeptId();
|
Long userId = tokenService.getLoginUser().getUserId();
|
List<TProjectDept> projectDeptList = new ArrayList<>();
|
if(userId != 1L){
|
if (deptType == 1) {
|
// 查询片区
|
TProjectDept projectDept = projectDeptService.getById(deptId);
|
if("0".equals(projectDept.getParentId())){
|
// 查询项目部
|
List<TProjectDept> childProjectDept = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus,1)
|
.eq(TProjectDept::getParentId,projectDept.getId()));
|
projectDept.setChildren(childProjectDept);
|
projectDeptList.add(projectDept);
|
}else {
|
// 查询项目部
|
TProjectDept parent = projectDeptService.getById(projectDept.getParentId());
|
List<TProjectDept> children = new ArrayList<>();
|
children.add(projectDept);
|
parent.setChildren(children);
|
projectDeptList.add(parent);
|
}
|
}else {
|
projectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus,1)
|
.eq(TProjectDept::getParentId,0));
|
// 查询片区
|
projectDeptList.forEach(projectDept -> {
|
List<TProjectDept> children = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getParentId, projectDept.getId()));
|
projectDept.setChildren(children);
|
});
|
}
|
}else {
|
projectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus,1)
|
.eq(TProjectDept::getParentId,0));
|
// 查询片区
|
projectDeptList.forEach(projectDept -> {
|
List<TProjectDept> children = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getParentId, projectDept.getId()));
|
projectDept.setChildren(children);
|
});
|
}
|
return R.ok(projectDeptList);
|
}
|
|
@ApiOperation(value = "通过片区id查询点位类型")
|
@GetMapping(value = "/queryLocationByProjectId")
|
public R<List<TLocationType>> queryLocationByProjectId() {
|
List<TLocationType> locationTypes = locationTypeService.list();
|
return R.ok(locationTypes);
|
}
|
|
@ApiOperation(value = "顶部数量统计")
|
@PostMapping(value = "/topQuantityStatistics")
|
public R<Map<String, Object>> topQuantityStatistics(@RequestBody DataStatisticsQuery query) {
|
Map<String, Object> map = new HashMap<>();
|
Integer deptType = tokenService.getLoginUser().getUser().getDeptType();
|
String deptId = tokenService.getLoginUser().getUser().getDeptId();
|
Long userId = tokenService.getLoginUser().getUserId();
|
|
LambdaQueryWrapper<TTask> wrapper = new LambdaQueryWrapper<>();
|
|
List<TTask> list;
|
if (userId != 1L) {
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
map.put("totalLocationNum", locationList.size());
|
}
|
List<TTask> taskList = new ArrayList<>();
|
if (deptType == 1) {
|
// 项目部人员
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
TProjectDept projectDept = projectDeptService.getById(deptId);
|
List<String> projectIds = new ArrayList<>();
|
if("0".equals(projectDept.getParentId())){
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.eq(TProjectDept::getParentId, projectDept.getId()));
|
List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
projectIds.addAll(ids);
|
}else {
|
projectIds.add(deptId);
|
}
|
query.setProjectId(projectIds);
|
}
|
}else {
|
// 公司人员
|
// 查询自己的任务列表
|
taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
|
.eq(TTask::getPatrolInspector, userId));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
// 查询点位数
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getProjectId, query.getProjectId()));
|
map.put("totalLocationNum", locationList.size());
|
}
|
|
list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok();
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
list = list.stream().distinct().collect(Collectors.toList());
|
}else {
|
// 超级管理员
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
map.put("totalLocationNum", locationList.size());
|
}
|
// 超级管理员 查询所有的任务列表
|
List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getProjectId, query.getProjectId()));
|
map.put("totalLocationNum", locationList.size());
|
}
|
|
list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok();
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
list = list.stream().distinct().collect(Collectors.toList());
|
}
|
|
// 查询任务相关数据
|
// 总计任务数
|
map.put("totalTaskNum", list.size());
|
// 今日任务数
|
map.put("todayTaskNum", list.stream().filter(tTask -> tTask.getImplementTime().toLocalDate().isEqual(LocalDate.now())).count());
|
// 待执行任务数
|
map.put("waitTaskNum", list.stream().filter(tTask -> tTask.getStatus() == 1).count());
|
|
// 总计员工数
|
Integer totalEmployeeNum = sysUserService.selectUserCount(null,deptType);
|
if (deptType != 1) {
|
totalEmployeeNum = totalEmployeeNum + 1;
|
}
|
map.put("totalEmployeeNum", totalEmployeeNum);
|
|
// 今日请假员工数量
|
List<TLeave> leaves = leaveService.list(Wrappers.lambdaQuery(TLeave.class)
|
.le(TLeave::getStartTime, LocalDate.now())
|
.ge(TLeave::getEndTime, LocalDate.now())
|
.eq(TLeave::getAuditStatus, 2));
|
if(!CollectionUtils.isEmpty(leaves)){
|
map.put("todayLeaveNum", leaves.size());
|
}else {
|
map.put("todayLeaveNum", 0);
|
}
|
|
// 总计保洁员数
|
long totalCleanerNum = cleanerService.count(Wrappers.lambdaQuery(TCleaner.class)
|
.in(TCleaner::getProjectId, query.getProjectId()));
|
map.put("totalCleanerNum", totalCleanerNum);
|
|
return R.ok(map);
|
}
|
|
|
@ApiOperation(value = "任务情况")
|
@PostMapping(value = "/taskSituation")
|
public R<TaskSituationVO> taskSituation(@RequestBody TaskSituationQuery query) {
|
Integer deptType = tokenService.getLoginUser().getUser().getDeptType();
|
String deptId = tokenService.getLoginUser().getUser().getDeptId();
|
Long userId = tokenService.getLoginUser().getUserId();
|
|
TaskSituationVO taskSituationVO = new TaskSituationVO();
|
LambdaQueryWrapper<TTask> wrapper = new LambdaQueryWrapper<>();
|
|
if(StringUtils.isEmpty(query.getStartTime()) || StringUtils.isEmpty(query.getEndTime())){
|
LocalDate now = LocalDate.now();
|
String startTime = now.minusDays(6) + " 00:00:00";
|
String endTime = now + " 23:59:59";
|
query.setStartTime(startTime);
|
query.setEndTime(endTime);
|
}else {
|
query.setStartTime(query.getStartTime() + " 00:00:00");
|
query.setEndTime(query.getEndTime() + " 23:59:59");
|
}
|
|
wrapper.between(TTask::getImplementTime, query.getStartTime(), query.getEndTime());
|
|
List<TTask> list;
|
if (userId != 1L) {
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
}
|
List<TTask> taskList = new ArrayList<>();
|
if (deptType == 1) {
|
// 项目部人员
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
TProjectDept projectDept = projectDeptService.getById(deptId);
|
List<String> projectIds = new ArrayList<>();
|
if("0".equals(projectDept.getParentId())){
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.eq(TProjectDept::getParentId, projectDept.getId()));
|
List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
projectIds.addAll(ids);
|
}else {
|
projectIds.add(deptId);
|
}
|
query.setProjectId(projectIds);
|
}
|
}else {
|
// 公司人员
|
// 查询自己的任务列表
|
taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
|
.eq(TTask::getPatrolInspector, userId)
|
.between(TTask::getImplementTime, query.getStartTime(), query.getEndTime()));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
}
|
|
list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok();
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
list = list.stream().distinct().collect(Collectors.toList());
|
}else {
|
// 超级管理员
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
}
|
// 超级管理员 查询所有的任务列表
|
List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
|
.between(TTask::getImplementTime, query.getStartTime(), query.getEndTime()));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
}
|
|
list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok();
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
list = list.stream().distinct().collect(Collectors.toList());
|
}
|
// 任务总数
|
taskSituationVO.setTotalTaskNum(list.size());
|
List<TTask> result = list.stream().filter(task -> task.getStatus() == 6).collect(Collectors.toList());
|
// 已完成任务数
|
taskSituationVO.setCompletedTaskNum(result.size());
|
// 匹配任务详情查看合格数量
|
List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
|
if(CollectionUtils.isEmpty(tasks)){
|
taskSituationVO.setPassRate(BigDecimal.ZERO);
|
return R.ok(taskSituationVO);
|
}
|
List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
|
List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
|
.in(TTaskDetail::getTaskId, taskIds)
|
.orderByDesc(TTaskDetail::getCreateTime));
|
int qualifiedWarn = 0;
|
for (TTask task : list) {
|
TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
|
if(Objects.nonNull(tTaskDetail)){
|
if(Objects.nonNull(tTaskDetail.getClearStatus()) && tTaskDetail.getClearStatus() == 1){
|
qualifiedWarn++;
|
}
|
}
|
}
|
taskSituationVO.setPassRate(new BigDecimal(qualifiedWarn).divide(new BigDecimal(tasks.size()), 2, RoundingMode.HALF_DOWN));
|
|
// 过滤每天的任务
|
LocalDateTime start = DateUtils.stringToLocalDateTime(query.getStartTime());
|
LocalDateTime end = DateUtils.stringToLocalDateTime(query.getEndTime());
|
|
long daysBetween = ChronoUnit.DAYS.between(start, end);
|
|
List<TaskSituationDayVO> taskSituationDayVOList = new ArrayList<>();
|
|
LocalDateTime localDateTime = DateUtils.stringToLocalDateTime(query.getStartTime());
|
String format = null;
|
for (long i = 0; i <= daysBetween; i++) {
|
TaskSituationDayVO taskSituationDayVO = new TaskSituationDayVO();
|
if(i == 0){
|
format = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
}else {
|
format = DateUtils.stringToLocalDate(format).plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
}
|
taskSituationDayVO.setTaskTime(format);
|
String finalFormat = format;
|
List<TTask> tTasks = list.stream().filter(task -> DateUtils.localDateTimeToString(task.getImplementTime()).contains(finalFormat)).collect(Collectors.toList());
|
// 任务数
|
taskSituationDayVO.setTaskNum(tTasks.size());
|
// 完成数
|
taskSituationDayVO.setCompletedNum(tTasks.stream().filter(task -> task.getStatus() == 6).collect(Collectors.toList()).size());
|
int qualifiedWarnChild = 0;
|
for (TTask task : tTasks) {
|
TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
|
if(Objects.nonNull(tTaskDetail)){
|
if(Objects.nonNull(tTaskDetail.getClearStatus()) && tTaskDetail.getClearStatus() == 1){
|
qualifiedWarnChild++;
|
}
|
}
|
}
|
if(tTasks.isEmpty()){
|
taskSituationDayVO.setCompleteRate(BigDecimal.ZERO);
|
}else {
|
taskSituationDayVO.setCompleteRate(new BigDecimal(qualifiedWarnChild).divide(new BigDecimal(tTasks.size()), 2, RoundingMode.HALF_DOWN));
|
}
|
taskSituationDayVOList.add(taskSituationDayVO);
|
}
|
taskSituationVO.setTaskSituationDayVO(taskSituationDayVOList);
|
return R.ok(taskSituationVO);
|
}
|
|
@ApiOperation(value = "今日预警")
|
@PostMapping(value = "/todayWarning")
|
public R<List<TTask>> todayWarning(@RequestBody DataStatisticsQuery query) {
|
Integer deptType = tokenService.getLoginUser().getUser().getDeptType();
|
String deptId = tokenService.getLoginUser().getUser().getDeptId();
|
Long userId = tokenService.getLoginUser().getUserId();
|
|
// 查询所有点位
|
List<TLocation> locations = locationService.list();
|
|
LambdaQueryWrapper<TTask> wrapper = new LambdaQueryWrapper<>();
|
String startTime = LocalDate.now() + " 00:00:00";
|
String endTime = LocalDate.now() + " 23:59:59";
|
wrapper.between(TTask::getImplementTime, startTime, endTime);
|
if (userId != 1L) {
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
}
|
List<TTask> taskList = new ArrayList<>();
|
if (deptType == 1) {
|
// 项目部人员
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
TProjectDept projectDept = projectDeptService.getById(deptId);
|
List<String> projectIds = new ArrayList<>();
|
if("0".equals(projectDept.getParentId())){
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.eq(TProjectDept::getParentId, projectDept.getId()));
|
List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
projectIds.addAll(ids);
|
}else {
|
projectIds.add(deptId);
|
}
|
query.setProjectId(projectIds);
|
}
|
}else {
|
// 公司人员
|
// 查询自己的任务列表
|
taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
|
.eq(TTask::getPatrolInspector, userId)
|
.between(TTask::getImplementTime, startTime, endTime));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
}
|
|
List<TTask> list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok();
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
list = list.stream().distinct().collect(Collectors.toList());
|
List<TTask> result = list.stream().filter(task -> task.getStatus() == 2).collect(Collectors.toList());
|
List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
|
if(CollectionUtils.isEmpty(tasks)){
|
for (TTask task : result) {
|
TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
|
if(Objects.nonNull(tLocation)) {
|
task.setLocationName(tLocation.getLocationName());
|
}
|
}
|
return R.ok(result);
|
}
|
List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
|
List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
|
.in(TTaskDetail::getTaskId, taskIds)
|
.orderByDesc(TTaskDetail::getCreateTime));
|
for (TTask task : list) {
|
TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
|
if(Objects.nonNull(tTaskDetail)){
|
if(Objects.nonNull(tTaskDetail.getClearStatus()) && tTaskDetail.getClearStatus() == 2){
|
result.add(task);
|
}
|
}
|
}
|
for (TTask task : result) {
|
TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
|
if(Objects.nonNull(tLocation)) {
|
task.setLocationName(tLocation.getLocationName());
|
}
|
}
|
return R.ok(result);
|
}else {
|
// 超级管理员
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
}
|
// 超级管理员 查询所有的任务列表
|
List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
|
.between(TTask::getImplementTime, startTime, endTime));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
}
|
|
List<TTask> list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok();
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
list = list.stream().distinct().collect(Collectors.toList());
|
List<TTask> result = list.stream().filter(task -> task.getStatus() == 2).collect(Collectors.toList());
|
List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
|
if(CollectionUtils.isEmpty(tasks)){
|
for (TTask task : result) {
|
TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
|
if(Objects.nonNull(tLocation)) {
|
task.setLocationName(tLocation.getLocationName());
|
}
|
}
|
return R.ok(result);
|
}
|
List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
|
List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
|
.in(TTaskDetail::getTaskId, taskIds)
|
.orderByDesc(TTaskDetail::getCreateTime));
|
for (TTask task : list) {
|
TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
|
if(Objects.nonNull(tTaskDetail)){
|
if(Objects.nonNull(tTaskDetail.getClearStatus()) && tTaskDetail.getClearStatus() == 2){
|
result.add(task);
|
}
|
}
|
}
|
for (TTask task : result) {
|
TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
|
if(Objects.nonNull(tLocation)) {
|
task.setLocationName(tLocation.getLocationName());
|
}
|
}
|
return R.ok(result);
|
}
|
}
|
|
@ApiOperation(value = "待审核任务")
|
@PostMapping(value = "/pendingAuditTasks")
|
public R<List<TTask>> pendingAuditTasks(@RequestBody DataStatisticsQuery query) {
|
Integer deptType = tokenService.getLoginUser().getUser().getDeptType();
|
String deptId = tokenService.getLoginUser().getUser().getDeptId();
|
Long userId = tokenService.getLoginUser().getUserId();
|
|
// 查询所有点位
|
List<TLocation> locations = locationService.list();
|
|
LambdaQueryWrapper<TTask> wrapper = new LambdaQueryWrapper<>();
|
if (userId != 1L) {
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
}
|
List<TTask> taskList = new ArrayList<>();
|
if (deptType == 1) {
|
// 项目部人员
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
TProjectDept projectDept = projectDeptService.getById(deptId);
|
List<String> projectIds = new ArrayList<>();
|
if("0".equals(projectDept.getParentId())){
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.eq(TProjectDept::getParentId, projectDept.getId()));
|
List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
projectIds.addAll(ids);
|
}else {
|
projectIds.add(deptId);
|
}
|
query.setProjectId(projectIds);
|
}
|
}else {
|
// 公司人员
|
// 查询自己的任务列表
|
taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
|
.eq(TTask::getPatrolInspector, userId));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
}
|
|
List<TTask> list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok();
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
list = list.stream().distinct().collect(Collectors.toList());
|
List<TTask> result = list.stream().filter(task -> task.getStatus() == 3).collect(Collectors.toList());
|
for (TTask task : result) {
|
TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
|
if(Objects.nonNull(tLocation)) {
|
task.setLocationName(tLocation.getLocationName());
|
}
|
}
|
return R.ok(result);
|
}else {
|
// 超级管理员
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
}
|
// 超级管理员 查询所有的任务列表
|
List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
}
|
|
List<TTask> list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok();
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
list = list.stream().distinct().collect(Collectors.toList());
|
List<TTask> result = list.stream().filter(task -> task.getStatus() == 3).collect(Collectors.toList());
|
for (TTask task : result) {
|
TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
|
if(Objects.nonNull(tLocation)) {
|
task.setLocationName(tLocation.getLocationName());
|
}
|
}
|
return R.ok(result);
|
}
|
}
|
|
@ApiOperation(value = "保洁质量汇总")
|
@PostMapping(value = "/cleaningQualitySummary")
|
public R<Map<String, Object>> cleaningQualitySummary(@RequestBody DataStatisticsQuery query) {
|
Map<String, Object> map = new HashMap<>();
|
Integer deptType = tokenService.getLoginUser().getUser().getDeptType();
|
String deptId = tokenService.getLoginUser().getUser().getDeptId();
|
Long userId = tokenService.getLoginUser().getUserId();
|
LambdaQueryWrapper<TTask> wrapper = new LambdaQueryWrapper<>();
|
if (userId != 1L) {
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
}
|
List<TTask> taskList = new ArrayList<>();
|
if (deptType == 1) {
|
// 项目部人员
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
TProjectDept projectDept = projectDeptService.getById(deptId);
|
List<String> projectIds = new ArrayList<>();
|
if("0".equals(projectDept.getParentId())){
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.eq(TProjectDept::getParentId, projectDept.getId()));
|
List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
projectIds.addAll(ids);
|
}else {
|
projectIds.add(deptId);
|
}
|
query.setProjectId(projectIds);
|
}
|
}else {
|
// 公司人员
|
// 查询自己的任务列表
|
taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
|
.eq(TTask::getPatrolInspector, userId));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
}
|
|
List<TTask> list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok(map);
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
list = list.stream().distinct().collect(Collectors.toList());
|
List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
|
if(CollectionUtils.isEmpty(tasks)){
|
map.put("unqualifiedWarn", 0);
|
map.put("qualifiedWarn", 0);
|
return R.ok(map);
|
}
|
List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
|
List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
|
.in(TTaskDetail::getTaskId, taskIds)
|
.orderByDesc(TTaskDetail::getCreateTime));
|
int unqualifiedWarn = 0;
|
int qualifiedWarn = 0;
|
for (TTask task : list) {
|
TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
|
if(Objects.nonNull(tTaskDetail)){
|
if(Objects.nonNull(tTaskDetail.getClearStatus())){
|
if(tTaskDetail.getClearStatus() == 2){
|
unqualifiedWarn++;
|
}else {
|
qualifiedWarn++;
|
}
|
}else {
|
unqualifiedWarn++;
|
}
|
}
|
}
|
map.put("qualifiedWarn", qualifiedWarn);
|
map.put("unqualifiedWarn", unqualifiedWarn);
|
}else {
|
// 超级管理员
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
}
|
// 超级管理员 查询所有的任务列表
|
List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
}
|
|
List<TTask> list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok(map);
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
list = list.stream().distinct().collect(Collectors.toList());
|
List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
|
if(CollectionUtils.isEmpty(tasks)){
|
map.put("unqualifiedWarn", 0);
|
map.put("qualifiedWarn", 0);
|
return R.ok(map);
|
}
|
List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
|
List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
|
.in(TTaskDetail::getTaskId, taskIds)
|
.orderByDesc(TTaskDetail::getCreateTime));
|
int unqualifiedWarn = 0;
|
int qualifiedWarn = 0;
|
for (TTask task : list) {
|
TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
|
if(Objects.nonNull(tTaskDetail)){
|
if(Objects.nonNull(tTaskDetail.getClearStatus())){
|
if(tTaskDetail.getClearStatus() == 2){
|
unqualifiedWarn++;
|
}else {
|
qualifiedWarn++;
|
}
|
}else {
|
unqualifiedWarn++;
|
}
|
}
|
}
|
map.put("unqualifiedWarn", unqualifiedWarn);
|
map.put("qualifiedWarn", qualifiedWarn);
|
}
|
return R.ok(map);
|
}
|
|
@ApiOperation(value = "清洁不合格分析")
|
@PostMapping(value = "/analysisUnqualifiedCleaning")
|
public R<AnalysisUnqualifiedCleaningVO> analysisUnqualifiedCleaning(@RequestBody DataStatisticsQuery query) {
|
Integer deptType = tokenService.getLoginUser().getUser().getDeptType();
|
String deptId = tokenService.getLoginUser().getUser().getDeptId();
|
Long userId = tokenService.getLoginUser().getUserId();
|
AnalysisUnqualifiedCleaningVO analysisUnqualifiedCleaningVO = new AnalysisUnqualifiedCleaningVO();
|
LambdaQueryWrapper<TTask> wrapper = new LambdaQueryWrapper<>();
|
if(userId != 1L){
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
}
|
List<TTask> taskList = new ArrayList<>();
|
if (deptType == 1) {
|
// 项目部人员
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
TProjectDept projectDept = projectDeptService.getById(deptId);
|
List<String> projectIds = new ArrayList<>();
|
if("0".equals(projectDept.getParentId())){
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.eq(TProjectDept::getParentId, projectDept.getId()));
|
List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
projectIds.addAll(ids);
|
}else {
|
projectIds.add(deptId);
|
}
|
query.setProjectId(projectIds);
|
}
|
}else {
|
// 公司人员
|
// 查询自己的任务列表
|
taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
|
.eq(TTask::getPatrolInspector, userId));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
}
|
|
List<TTask> list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok();
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
list = list.stream().distinct().collect(Collectors.toList());
|
List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
|
if(CollectionUtils.isEmpty(tasks)){
|
return R.ok();
|
}
|
List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
|
List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
|
.in(TTaskDetail::getTaskId, taskIds)
|
.eq(TTaskDetail::getClearStatus, 2)
|
.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());
|
List<TTaskDetail> taskDetailList = new ArrayList<>();
|
for (TTask task : list) {
|
TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
|
if(Objects.nonNull(tTaskDetail)){
|
taskDetailList.add(tTaskDetail);
|
}
|
}
|
analysisUnqualifiedCleaningVO.setTotal(taskDetailList.size());
|
|
// 查询所有的不合格原因
|
List<TDictData> dictDataList = dictDataService.list(Wrappers.lambdaQuery(TDictData.class)
|
.eq(TDictData::getDataType, 2));
|
List<AnalysisUnqualifiedCleaningDetailVO> analysisUnqualifiedCleaningDetailVOS = new ArrayList<>();
|
for (TDictData tDictData : dictDataList) {
|
List<TTaskDetail> tTaskDetails = taskDetailList.stream().filter(taskDetail -> StringUtils.isNotEmpty(taskDetail.getUnqualified())&&taskDetail.getUnqualified().equals(tDictData.getId())).collect(Collectors.toList());
|
AnalysisUnqualifiedCleaningDetailVO analysisUnqualifiedCleaningDetailVO = new AnalysisUnqualifiedCleaningDetailVO();
|
analysisUnqualifiedCleaningDetailVO.setUnqualifiedName(tDictData.getDataContent());
|
analysisUnqualifiedCleaningDetailVO.setCount(tTaskDetails.size());
|
analysisUnqualifiedCleaningDetailVOS.add(analysisUnqualifiedCleaningDetailVO);
|
}
|
analysisUnqualifiedCleaningVO.setAnalysisUnqualifiedCleaningDetailVOS(analysisUnqualifiedCleaningDetailVOS);
|
}else {
|
// 超级管理员
|
// 查询点位类型
|
if(StringUtils.isNotEmpty(query.getLocationTypeId())){
|
// 查询点位
|
List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
|
.in(TLocation::getLocationType, query.getLocationTypeId()));
|
if(!CollectionUtils.isEmpty(locationList)){
|
List<String> locationIds = locationList.stream().map(TLocation::getId).collect(Collectors.toList());
|
wrapper.in(TTask::getLocationId, locationIds);
|
}
|
}
|
// 超级管理员 查询所有的任务列表
|
List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
|
if(CollectionUtils.isEmpty(query.getProjectId())){
|
// 查询所有项目部的任务列表
|
List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
|
.eq(TProjectDept::getStatus, 1)
|
.ne(TProjectDept::getParentId, 0));
|
if(!CollectionUtils.isEmpty(tProjectDeptList)){
|
List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
|
query.setProjectId(projectIds);
|
}
|
}
|
|
// 查询片区
|
if(!CollectionUtils.isEmpty(query.getProjectId())){
|
query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
|
wrapper.in(TTask::getProjectId, query.getProjectId());
|
}
|
|
List<TTask> list = taskCleanService.list(wrapper);
|
if(CollectionUtils.isEmpty(list)){
|
return R.ok();
|
}
|
|
if(!CollectionUtils.isEmpty(taskList)){
|
list.addAll(taskList);
|
}
|
|
list = list.stream().distinct().collect(Collectors.toList());
|
|
List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
|
if(CollectionUtils.isEmpty(tasks)){
|
return R.ok();
|
}
|
List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
|
List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
|
.in(TTaskDetail::getTaskId, taskIds)
|
.eq(TTaskDetail::getHandleType,1)
|
.eq(TTaskDetail::getClearStatus, 2)
|
.orderByDesc(TTaskDetail::getCreateTime));
|
taskDetails = new ArrayList<>(taskDetails.stream()
|
.collect(Collectors.groupingBy(
|
TTaskDetail::getTaskId,
|
Collectors.collectingAndThen(
|
Collectors.toList(),
|
listAll -> listAll.get(0)
|
)
|
))
|
.values());
|
List<TTaskDetail> taskDetailList = new ArrayList<>();
|
for (TTask task : list) {
|
TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
|
if(Objects.nonNull(tTaskDetail)){
|
taskDetailList.add(tTaskDetail);
|
}
|
}
|
analysisUnqualifiedCleaningVO.setTotal(taskDetailList.size());
|
|
// 查询所有的不合格原因
|
List<TDictData> dictDataList = dictDataService.list(Wrappers.lambdaQuery(TDictData.class)
|
.eq(TDictData::getDataType, 2));
|
List<AnalysisUnqualifiedCleaningDetailVO> analysisUnqualifiedCleaningDetailVOS = new ArrayList<>();
|
for (TDictData tDictData : dictDataList) {
|
List<TTaskDetail> tTaskDetails = taskDetailList.stream().filter(taskDetail -> StringUtils.isNotEmpty(taskDetail.getUnqualified())&&taskDetail.getUnqualified().equals(tDictData.getId())).collect(Collectors.toList());
|
AnalysisUnqualifiedCleaningDetailVO analysisUnqualifiedCleaningDetailVO = new AnalysisUnqualifiedCleaningDetailVO();
|
analysisUnqualifiedCleaningDetailVO.setUnqualifiedName(tDictData.getDataContent());
|
analysisUnqualifiedCleaningDetailVO.setCount(tTaskDetails.size());
|
analysisUnqualifiedCleaningDetailVOS.add(analysisUnqualifiedCleaningDetailVO);
|
}
|
// 按照数量倒序排序
|
analysisUnqualifiedCleaningDetailVOS.sort(Comparator.comparingInt(AnalysisUnqualifiedCleaningDetailVO::getCount).reversed());
|
analysisUnqualifiedCleaningVO.setAnalysisUnqualifiedCleaningDetailVOS(analysisUnqualifiedCleaningDetailVOS);
|
}
|
|
return R.ok(analysisUnqualifiedCleaningVO);
|
}
|
|
}
|