|
|
@@ -374,7 +374,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
//每一个工单对应的状态发生改变,一个工单id对应一个工单 |
|
|
|
WorkOrder workOrder = workOrderMapper.selectById(workOrderInfoVo.getId()); |
|
|
|
if (ObjectUtil.isNotNull(workOrder)) { |
|
|
|
workOrder.setStatus(15); |
|
|
|
//问题处理完 状态改为待审核 新需求 |
|
|
|
workOrder.setStatus(WorkOrderStatusEnum.STATUS_PENDING_REVIEW.getCode()); |
|
|
|
workOrder.setUpdateTime(DateUtils.now()); |
|
|
|
workOrder.setUpdateUser(user.getId()); |
|
|
|
super.update(workOrder); |
|
|
@@ -474,6 +475,195 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
return JsonResult.success(pageData); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 待审核工单 |
|
|
|
* |
|
|
|
* @param query |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public JsonResult getAuditList(WorkOrderQuery query) { |
|
|
|
if (query.getLimit() == null && query.getPage() == null) { |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
//获取登录用户信息 |
|
|
|
User userInfo1 = CurrentUserUtil.getUserInfo(); |
|
|
|
String username = userInfo1.getUsername(); |
|
|
|
|
|
|
|
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, MarkEnum.VALID.getCode()) |
|
|
|
.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.getDataPermission(); |
|
|
|
//获取分页数据 |
|
|
|
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.getTime())) { |
|
|
|
startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getTime() + " 00:00:00"); |
|
|
|
endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getTime() + " 23:59:59"); |
|
|
|
} |
|
|
|
query.setOrderStartTime(startTime); |
|
|
|
query.setOrderEndTime(endTime); |
|
|
|
//用户角色为2部门管理员 3普通用户 |
|
|
|
if (RoleEnum.SUPER_ADMIN.getCode() == type) { |
|
|
|
//超级管理员可查看系统内所有已处理工单 |
|
|
|
IPage<WorkOrder> workPageData = workOrderMapper.selectPage(page, new LambdaQueryWrapper<WorkOrder>() |
|
|
|
.eq(WorkOrder::getStatus, 11) |
|
|
|
.eq(WorkOrder::getTenantId, tenantId) |
|
|
|
.between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime()) |
|
|
|
.eq(WorkOrder::getMark, MarkEnum.VALID.getCode()) |
|
|
|
.orderByDesc(WorkOrder::getCreateTime)); |
|
|
|
//设置每条工单对应的已完成问题数量 问题状态为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.getRealname()); |
|
|
|
} |
|
|
|
} |
|
|
|
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本部门及子部门数据列表 |
|
|
|
if (RoleEnum.ADMIN.getCode() == user.getDataPermission()) { |
|
|
|
//获取部门 |
|
|
|
String deptId = user.getDeptId(); |
|
|
|
if (StringUtils.isEmpty(deptId)) { |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
//获取当前本部门及子部门数据 |
|
|
|
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); |
|
|
|
//获取当前分配人对应的工单分页数据 |
|
|
|
IPage<WorkOrder> workPageData1 = workOrderMapper.selectPage(page, Wrappers.<WorkOrder>lambdaQuery() |
|
|
|
.in(WorkOrder::getAssignDeptId, deptIdList) |
|
|
|
.eq(WorkOrder::getStatus, 15) |
|
|
|
.eq(WorkOrder::getTenantId, tenantId) |
|
|
|
.between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime()) |
|
|
|
.eq(WorkOrder::getMark, MarkEnum.VALID.getCode()) |
|
|
|
.orderByDesc(WorkOrder::getCreateTime)); |
|
|
|
//设置每条工单对应的状态问题数量 |
|
|
|
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.getRealname()); |
|
|
|
} |
|
|
|
} |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
//3普通用户 |
|
|
|
if(RoleEnum.ORDINARY_USER.getCode() == user.getDataPermission()){ |
|
|
|
//获取部门 |
|
|
|
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) |
|
|
|
.eq(WorkOrder::getTenantId, tenantId) |
|
|
|
.between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime()) |
|
|
|
.eq(WorkOrder::getMark, MarkEnum.VALID.getCode()) |
|
|
|
.orderByDesc(WorkOrder::getCreateTime)); |
|
|
|
//设置每条工单对应的状态问题数量 |
|
|
|
List<WorkOrderInfoVo> collect2 = 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.getRealname()); |
|
|
|
} |
|
|
|
} |
|
|
|
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(collect2); |
|
|
|
return JsonResult.success(pageData); |
|
|
|
} |
|
|
|
|
|
|
|
return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(), WorkOrderEnum.DATA_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 已完成工单 |
|
|
|
* |