@@ -0,0 +1,49 @@ | |||
package com.tuoheng.admin.enums.code.workorder; | |||
/** | |||
* 工单详情返回码 | |||
* 模块代码:26(工单管理) | |||
* 接口代码:02 (工单详情) | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-12-08 | |||
*/ | |||
public enum QueryWorkOrderDetailsCodeEnum { | |||
QUERY_IS_FAILED(1260200, "查看工单详情失败"), | |||
ID_IS_NULL(1260201, "工单id"), | |||
WORK_ORDER_IS_NOT_EXIST(1260202, "工单不存在"); | |||
/** | |||
* 错误码 | |||
*/ | |||
private int code; | |||
/** | |||
* 错误信息 | |||
*/ | |||
private String msg; | |||
QueryWorkOrderDetailsCodeEnum(int code, String msg){ | |||
this.code = code; | |||
this.msg = msg; | |||
} | |||
public int getCode() { | |||
return code; | |||
} | |||
public void setCode(int code) { | |||
this.code = code; | |||
} | |||
public String getMsg() { | |||
return msg; | |||
} | |||
public void setMsg(String msg) { | |||
this.msg = msg; | |||
} | |||
} |
@@ -0,0 +1,47 @@ | |||
package com.tuoheng.admin.enums.code.workorder; | |||
/** | |||
* 查询工单分页列表返回码 | |||
* 模块代码:26(工单管理) | |||
* 接口代码:03 (查询工单分页列表) | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-12-08 | |||
*/ | |||
public enum QueryWorkOrderPageListCodeEnum { | |||
QUERY_IS_FAILED(1260300, "查询工单分页列表失败"); | |||
/** | |||
* 错误码 | |||
*/ | |||
private int code; | |||
/** | |||
* 错误信息 | |||
*/ | |||
private String msg; | |||
QueryWorkOrderPageListCodeEnum(int code, String msg){ | |||
this.code = code; | |||
this.msg = msg; | |||
} | |||
public int getCode() { | |||
return code; | |||
} | |||
public void setCode(int code) { | |||
this.code = code; | |||
} | |||
public String getMsg() { | |||
return msg; | |||
} | |||
public void setMsg(String msg) { | |||
this.msg = msg; | |||
} | |||
} |
@@ -1,8 +1,15 @@ | |||
package com.tuoheng.admin.service.workorder.query; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.WorkOrder; | |||
import com.tuoheng.admin.entity.WorkOrderFile; | |||
import com.tuoheng.admin.enums.code.inspectionfile.QueryInspectionFilePageListByInspectionIdCodeEnum; | |||
import com.tuoheng.admin.enums.code.workorder.QueryWorkOrderDetailsCodeEnum; | |||
import com.tuoheng.admin.mapper.*; | |||
import com.tuoheng.admin.utils.ShiroUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -18,11 +25,6 @@ import org.springframework.stereotype.Service; | |||
@Service | |||
public class QueryWorkOrderDetailsService { | |||
@Autowired | |||
private UserMapper userMapper; | |||
@Autowired | |||
private DeptMapper deptMapper; | |||
@Autowired | |||
private WorkOrderMapper workOrderMapper; | |||
@@ -43,9 +45,9 @@ public class QueryWorkOrderDetailsService { | |||
return result; | |||
} | |||
WorkOrder workOrder = (WorkOrder) result.getData(); | |||
return JsonResult.success(); | |||
return JsonResult.success(workOrder); | |||
} | |||
/** | |||
@@ -55,8 +57,19 @@ public class QueryWorkOrderDetailsService { | |||
* @return | |||
*/ | |||
private JsonResult check(String id) { | |||
// 判断任务id是否为空 | |||
if (StringUtils.isEmpty(id)) { | |||
return JsonResult.error(QueryWorkOrderDetailsCodeEnum.ID_IS_NULL.getCode(), QueryWorkOrderDetailsCodeEnum.ID_IS_NULL.getMsg()); | |||
} | |||
return JsonResult.success(); | |||
// 判断工单是否存在 | |||
WorkOrder workOrder = workOrderMapper.selectOne(new LambdaQueryWrapper<WorkOrder>() | |||
.eq(WorkOrder::getId, id) | |||
.eq(WorkOrder::getMark, 1)); | |||
if (null == workOrder) { | |||
return JsonResult.error(QueryWorkOrderDetailsCodeEnum.WORK_ORDER_IS_NOT_EXIST.getCode(), QueryWorkOrderDetailsCodeEnum.WORK_ORDER_IS_NOT_EXIST.getMsg()); | |||
} | |||
return JsonResult.success(workOrder); | |||
} | |||
} |
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.function.Function; | |||
@@ -65,7 +66,9 @@ public class QueryWorkOrderPageListService { | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(User::getId, userId) | |||
.eq(User::getMark, 1)); | |||
request.setUserDeptId(user.getDeptId()); | |||
if (UserTypeEnum.SUPER_ADMIN.getCode() != user.getType()) { | |||
request.setUserDeptId(user.getDeptId()); | |||
} | |||
// 获取部门Id的查询范围 | |||
List<String> deptIdList = this.getDeptIdList(user, request.getDeptId()); | |||
@@ -116,7 +119,7 @@ public class QueryWorkOrderPageListService { | |||
* @param deptId | |||
* @return | |||
*/ | |||
private List<String> getDeptIdList( User user, String deptId) { | |||
private List<String> getDeptIdList(User user, String deptId) { | |||
List<String> deptIdList = new ArrayList<>(); | |||
if (!StringUtils.isEmpty(deptId)) { | |||
deptIdList.add(deptId); | |||
@@ -143,7 +146,7 @@ public class QueryWorkOrderPageListService { | |||
private List<WorkOrderPageListVo> buildPageList(List<WorkOrder> workOrderList) { | |||
Map<String, Dept> deptMap = this.getDeptMap(workOrderList); | |||
Map<String, User> userMap = this.getUserMap(workOrderList); | |||
Map<String, User> assignUserMap = this.getAssignUserMap(workOrderList); | |||
Map<String, List<WorkOrderFile>> workOrderFileMap = this.getWorkOrderFileMap(workOrderList); | |||
List<String> inspectionFileIdList; | |||
@@ -151,8 +154,11 @@ public class QueryWorkOrderPageListService { | |||
List<WorkOrderPageListVo> workOrderPageListVoList = WorkOrderConverMapper.INSTANCE.fromWorkOrderListToWorkOrderPageListVoList(workOrderList); | |||
Dept dept; | |||
User user; | |||
User assignUser; | |||
String assignUserNames; | |||
List<WorkOrderFile> workOrderFileList; | |||
for (WorkOrderPageListVo workOrderPageListVo : workOrderPageListVoList) { | |||
assignUserNames = ""; | |||
dept = deptMap.get(workOrderPageListVo.getDeptId()); | |||
user = userMap.get(workOrderPageListVo.getDistributionId()); | |||
workOrderFileList = workOrderFileMap.get(workOrderPageListVo.getId()); | |||
@@ -169,6 +175,19 @@ public class QueryWorkOrderPageListService { | |||
if (null != user) { | |||
workOrderPageListVo.setDistributionName(user.getRealname()); | |||
} | |||
String assignUsers = workOrderPageListVo.getAssignUser(); | |||
if (!StringUtils.isEmpty(assignUsers)) { | |||
String[] assignUserArr = assignUsers.split(","); | |||
for (String au : assignUserArr) { | |||
assignUser = assignUserMap.get(au); | |||
assignUserNames += assignUser.getRealname() + ","; | |||
} | |||
} | |||
if (!StringUtils.isEmpty(assignUserNames)) { | |||
assignUserNames = assignUserNames.substring(0, assignUserNames.length() - 1); | |||
workOrderPageListVo.setAssignUserNames(assignUserNames); | |||
} | |||
} | |||
return workOrderPageListVoList; | |||
} | |||
@@ -203,6 +222,33 @@ public class QueryWorkOrderPageListService { | |||
return userMap; | |||
} | |||
/** | |||
* 获取指派用户列表,放到map,减少循环次数 | |||
* | |||
* @param workOrderList | |||
* @return | |||
*/ | |||
private Map<String, User> getAssignUserMap(List<WorkOrder> workOrderList) { | |||
List<String> assignUserIdList = workOrderList.stream().map(o -> o.getDistributionId()).collect(Collectors.toList()); | |||
List<String> tmpList; | |||
for (WorkOrder workOrder : workOrderList) { | |||
String assignUser = workOrder.getAssignUser(); | |||
if (!StringUtils.isEmpty(assignUser)) { | |||
String[] arr = assignUser.split(","); | |||
tmpList = Arrays.asList(arr); | |||
assignUserIdList.addAll(tmpList); | |||
} | |||
} | |||
List<User> userList = null; | |||
if (!CollectionUtil.isEmpty(assignUserIdList)) { | |||
userList = userMapper.selectList(new LambdaQueryWrapper<User>() | |||
.in(User::getId, assignUserIdList) | |||
.eq(User::getMark, 1)); | |||
} | |||
Map<String, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, Function.identity())); | |||
return userMap; | |||
} | |||
private Map<String, List<WorkOrderFile>> getWorkOrderFileMap(List<WorkOrder> workOrderList) { | |||
List<String> workOrderIdList = workOrderList.stream().map(o -> o.getId()).collect(Collectors.toList()); | |||
List<WorkOrderFile> workOrderFileList = workOrderFileMapper.selectList(new LambdaQueryWrapper<WorkOrderFile>() |
@@ -54,6 +54,36 @@ public class WorkOrderPageListVo { | |||
*/ | |||
private String distributionName; | |||
/** | |||
* 指派部门ID | |||
*/ | |||
private String assignDeptId; | |||
/** | |||
* 指派负责人,可以是多个(",")隔开 | |||
*/ | |||
private String assignUser; | |||
/** | |||
* 指派负责人名称,可以是多个(",")隔开 | |||
*/ | |||
private String assignUserNames; | |||
/** | |||
* 指派负责人联系方式 | |||
*/ | |||
private String assignContact; | |||
/** | |||
* 指派指派备注 | |||
*/ | |||
private String assignNote; | |||
/** | |||
* 指派时间 | |||
*/ | |||
private Date assignTime; | |||
/** | |||
* 所在部门ID | |||
*/ | |||
@@ -63,4 +93,14 @@ public class WorkOrderPageListVo { | |||
* 所在部门名称 | |||
*/ | |||
private String deptName; | |||
/** | |||
* 更新人 | |||
*/ | |||
private String updateUser; | |||
/** | |||
* 更新时间 | |||
*/ | |||
private Date updateTime; | |||
} |