|
|
@@ -195,12 +195,13 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
if(null == workPageData.getRecords()){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<WorkOrderInfoVo> WorkOrderInfoList = new ArrayList<>(); |
|
|
|
//设置每条工单对应的各状态问题数量 |
|
|
|
List<WorkOrderInfoVo> workOrderList = workPageData.getRecords().stream().map(x -> { |
|
|
|
WorkOrderInfoVo vo = new WorkOrderInfoVo(); |
|
|
|
//BeanUtils.copyProperties(x, vo); |
|
|
|
vo.setCode(x.getCode()); |
|
|
|
vo.setCreateTime(x.getCreateTime()); |
|
|
|
BeanUtils.copyProperties(x, vo); |
|
|
|
// vo.setCode(x.getCode()); |
|
|
|
// vo.setCreateTime(x.getCreateTime()); |
|
|
|
//被分配人员对应id |
|
|
|
String assignUser = x.getAssignUser(); |
|
|
|
String[] assignUserId = assignUser.split(","); |
|
|
@@ -210,8 +211,9 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
for (String userId : assignUserId) { |
|
|
|
User userInfo = userMapper.selectById(userId); |
|
|
|
String username1 = userInfo.getUsername(); |
|
|
|
list.add(username1); |
|
|
|
if (ObjectUtil.isNotNull(userInfo)) { |
|
|
|
list.add(userInfo.getUsername()); |
|
|
|
} |
|
|
|
} |
|
|
|
String usernames = list.stream().map(String::valueOf).collect(Collectors.joining("、")); |
|
|
|
vo.setAssignUserName(usernames); |
|
|
@@ -240,9 +242,24 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
long count1 = inspectionFileList.stream().filter(t -> t.getStatus() == 25).count(); |
|
|
|
vo.setPromProcessed((int) count1); |
|
|
|
|
|
|
|
return vo; |
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
pageData.setRecords(workOrderList); |
|
|
|
//当待处理问题总数为0时,此工单不出现在代办工单列表并且工单状态修改为15已完成 |
|
|
|
List<WorkOrderInfoVo> collect = workOrderList.stream().filter(f -> f.getPromTodo() == 0).collect(Collectors.toList()); |
|
|
|
if(null != collect){ |
|
|
|
for (WorkOrderInfoVo workOrderInfoVo : collect) { |
|
|
|
//每一个工单对应的状态发生改变,一个工单id对应一个工单 |
|
|
|
WorkOrder workOrder = workOrderMapper.selectById(workOrderInfoVo.getId()); |
|
|
|
if(ObjectUtil.isNotNull(workOrder)){ |
|
|
|
workOrder.setStatus(15); |
|
|
|
super.update(workOrder); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//工单的待处理问题个数不为0时 重新返回 |
|
|
|
WorkOrderInfoList = workOrderList.stream().filter(h -> h.getPromTodo() != 0).collect(Collectors.toList()); |
|
|
|
pageData.setRecords(WorkOrderInfoList); |
|
|
|
|
|
|
|
return JsonResult.success(pageData); |
|
|
|
} |
|
|
|
return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(),WorkOrderEnum.DATA_IS_NULL.getMsg()); |
|
|
@@ -313,5 +330,149 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
return JsonResult.success(pageData); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 已完成工单 |
|
|
|
* @param query |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public JsonResult getCompleted(WorkOrderQuery query) { |
|
|
|
// if(query.getOrderEndTime()==null && query.getOrderStartTime()==null){ |
|
|
|
// throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
// } |
|
|
|
if(query.getLimit()==null && query.getPage()==null){ |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
//String username = SecurityUserUtils.username(); |
|
|
|
String username = "admin"; |
|
|
|
if(null ==username){ |
|
|
|
return JsonResult.error(WorkOrderEnum.USER_NAME_IS_NULL.getCode(),WorkOrderEnum.USER_NAME_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() |
|
|
|
.eq(User::getMark, 1) |
|
|
|
.eq(User::getUsername, username)); |
|
|
|
if(ObjectUtil.isNull(user)){ |
|
|
|
return JsonResult.error(WorkOrderEnum.USER_IS_NOT_EXIST.getCode(),WorkOrderEnum.USER_IS_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
String tenantId = user.getTenantId(); |
|
|
|
if(null == tenantId){ |
|
|
|
return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(),WorkOrderEnum.DEPT_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
query.setTenantId(tenantId); |
|
|
|
//根据登录用户判断角色 1超级管理员 2部门管理员 3普通用户 |
|
|
|
Integer type = user.getType(); |
|
|
|
//获取分页数据 |
|
|
|
IPage<WorkOrder> page = new Page<>(query.getPage(),query.getLimit()); |
|
|
|
IPage<WorkOrderInfoVo> pageData = new Page<>(query.getPage(),query.getLimit()); |
|
|
|
//时间处理 |
|
|
|
Date startTime = null; |
|
|
|
Date endTime = null; |
|
|
|
if(StringUtils.isNotEmpty(query.getStartTime()) && StringUtils.isNotEmpty(query.getEndTime())){ |
|
|
|
startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getStartTime()+" 00:00:00"); |
|
|
|
endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getEndTime()+" 23:59:59"); |
|
|
|
} |
|
|
|
query.setOrderStartTime(startTime); |
|
|
|
query.setOrderEndTime(endTime); |
|
|
|
//用户角色为2部门管理员 3普通用户 |
|
|
|
if(UserTypeEnum.SUPER_ADMIN.getCode()==type){ |
|
|
|
//超级管理员可查看系统内所有已处理工单 |
|
|
|
IPage<WorkOrder> workPageData = workOrderMapper.selectPage(page, new LambdaQueryWrapper<WorkOrder>() |
|
|
|
.eq(WorkOrder::getStatus, 15) |
|
|
|
.eq(WorkOrder::getTenantId, tenantId) |
|
|
|
.between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime()) |
|
|
|
.eq(WorkOrder::getMark, 1)); |
|
|
|
//判空 |
|
|
|
if(StringUtils.isEmpty(workPageData.getRecords())){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
//设置每条工单对应的已完成问题数量 问题状态为25问题已处理 |
|
|
|
List<WorkOrderInfoVo> collect = workPageData.getRecords().stream().map(s -> { |
|
|
|
WorkOrderInfoVo vo = new WorkOrderInfoVo(); |
|
|
|
BeanUtils.copyProperties(s, vo); |
|
|
|
//被分配人员对应的id |
|
|
|
String assignUser = s.getAssignUser(); |
|
|
|
if (StringUtils.isEmpty(assignUser)) { |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
String[] assignUserId = assignUser.split(","); |
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
for (String userId : assignUserId) { |
|
|
|
User userInfo = userMapper.selectById(userId); |
|
|
|
if (ObjectUtil.isNotNull(userInfo)) { |
|
|
|
list.add(userInfo.getUsername()); |
|
|
|
} |
|
|
|
} |
|
|
|
String usernames = list.stream().map(String::valueOf).collect(Collectors.joining("、")); |
|
|
|
vo.setAssignUserName(usernames); |
|
|
|
//问题总数 |
|
|
|
List<WorkOrderFile> workOrderFiles = workOrderFileMapper.selectList(Wrappers.<WorkOrderFile>lambdaQuery() |
|
|
|
.eq(WorkOrderFile::getWorkOrderId, s.getId())); |
|
|
|
if (null == workOrderFiles) { |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
vo.setPromTotal(workOrderFiles.size()); |
|
|
|
//已解决问题=问题总数 |
|
|
|
vo.setPromProcessed(workOrderFiles.size()); |
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
pageData.setRecords(collect); |
|
|
|
|
|
|
|
return JsonResult.success(pageData); |
|
|
|
} |
|
|
|
//用户角色为2部门管理员 3普通用户 |
|
|
|
if(UserTypeEnum.ADMIN.getCode()== user.getType() || UserTypeEnum.ORDINARY_USER.getCode()== user.getType()){ |
|
|
|
//获取部门 |
|
|
|
String deptId = user.getDeptId(); |
|
|
|
if(StringUtils.isEmpty(deptId)){ |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
//获取当前分配人对应的工单分页数据 |
|
|
|
IPage<WorkOrder> workPageData1 = workOrderMapper.selectPage(page, Wrappers.<WorkOrder>lambdaQuery() |
|
|
|
.eq(WorkOrder::getAssignDeptId, deptId) |
|
|
|
.eq(WorkOrder::getStatus, 15) |
|
|
|
.like(StringUtils.isNotEmpty(user.getId()), WorkOrder::getAssignUser, user.getId()) |
|
|
|
.eq(WorkOrder::getTenantId, tenantId) |
|
|
|
.between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime()) |
|
|
|
.eq(WorkOrder::getMark, 1)); |
|
|
|
if(StringUtils.isEmpty(workPageData1.getRecords())){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
//设置每条工单对应的状态问题数量 |
|
|
|
List<WorkOrderInfoVo> collect1 = workPageData1.getRecords().stream().map(g -> { |
|
|
|
WorkOrderInfoVo vo = new WorkOrderInfoVo(); |
|
|
|
BeanUtils.copyProperties(g, vo); |
|
|
|
//被分配人员对应的id |
|
|
|
String assignUser = g.getAssignUser(); |
|
|
|
if (StringUtils.isEmpty(assignUser)) { |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
String[] assignUserId = assignUser.split(","); |
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
for (String userId : assignUserId) { |
|
|
|
User userInfo = userMapper.selectById(userId); |
|
|
|
if (ObjectUtil.isNotNull(userInfo)) { |
|
|
|
list.add(userInfo.getUsername()); |
|
|
|
} |
|
|
|
} |
|
|
|
String usernames = list.stream().map(String::valueOf).collect(Collectors.joining("、")); |
|
|
|
vo.setAssignUserName(usernames); |
|
|
|
//问题总数 |
|
|
|
List<WorkOrderFile> workOrderFiles = workOrderFileMapper.selectList(Wrappers.<WorkOrderFile>lambdaQuery() |
|
|
|
.eq(WorkOrderFile::getWorkOrderId, g.getId())); |
|
|
|
if (null == workOrderFiles) { |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
vo.setPromTotal(workOrderFiles.size()); |
|
|
|
//已解决问题=问题总数 |
|
|
|
vo.setPromProcessed(workOrderFiles.size()); |
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
pageData.setRecords(collect1); |
|
|
|
return JsonResult.success(pageData); |
|
|
|
} |
|
|
|
|
|
|
|
return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(),WorkOrderEnum.DATA_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |