소스 검색

修改代办工单列表接口数据权限

tags/v1.0.0^2
chengwang 1 년 전
부모
커밋
6341a093f0
9개의 변경된 파일436개의 추가작업 그리고 89개의 파일을 삭제
  1. +12
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/WorkOrderController.java
  2. +5
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/dao/WorkOrderMapper.java
  3. +55
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/DistributionWorkorderCodeEnum.java
  4. +30
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/DistributionWorkorderRequest.java
  5. +50
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/QueryDeptChildListCodeEnum.java
  6. +3
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/IWorkOrderService.java
  7. +261
    -89
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WorkOrderServiceImpl.java
  8. +5
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/WorkOrderInfoVo.java
  9. +15
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/WorkOrderMapper.xml

+ 12
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/WorkOrderController.java 파일 보기

@@ -7,7 +7,9 @@ import com.tuoheng.miniprogram.dao.UserMapper;
import com.tuoheng.miniprogram.entity.dto.WorkOrderDto;
import com.tuoheng.miniprogram.entity.query.HandleQuery;
import com.tuoheng.miniprogram.entity.query.WorkOrderQuery;
import com.tuoheng.miniprogram.enums.DistributionWorkorderRequest;
import com.tuoheng.miniprogram.service.IWorkOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@@ -19,6 +21,7 @@ import java.util.List;
*/
@RestController
@RequestMapping("/workOrder")
@Slf4j
public class WorkOrderController extends BaseController {

@Autowired
@@ -66,6 +69,15 @@ public class WorkOrderController extends BaseController {
return workOrderService.handle(query);
}

/**
* 分配工单
*/
@PostMapping("/distribution")
public JsonResult distribution(@RequestBody DistributionWorkorderRequest request) {
log.info("进入分配工单接口, request={}", request);
return workOrderService.distribution(request);
}

/**
* 已完成工单
* @param query

+ 5
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/dao/WorkOrderMapper.java 파일 보기

@@ -13,5 +13,10 @@ import org.apache.ibatis.annotations.Param;
*/
public interface WorkOrderMapper extends BaseMapper<WorkOrder> {

/**
* 分配工单
*/
Integer updateWorkOrder(WorkOrder workOrder);

//IPage<WorkOrderInfoVo> queryPage(@Param("page") IPage<WorkOrder> page,@Param("request") WorkOrderQuery query);
}

+ 55
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/DistributionWorkorderCodeEnum.java 파일 보기

@@ -0,0 +1,55 @@
package com.tuoheng.miniprogram.enums;

/**
* 分配工单返回码
* 模块代码:26(工单管理)
* 接口代码:04 (分配工单)
*
* @author wanjing
* @team tuoheng
* @date 2022-12-08
*/
public enum DistributionWorkorderCodeEnum {

DISTRIBUTION_IS_FAILED(1260400, "分配工单失败"),
ID_LIST_IS_NULL(1260401, "工单id为空"),
WORK_ORDER_IS_NOT_EXIST(1260402, "工单不存在"),
ASSIGN_DEPT_ID_IS_NULL(1260403, "指派部门ID为空"),
ASSIGN_USER_ID_IS_NULL(1260404, "指派负责人为空"),
ASSIGN_USER_ID_IS_NOT_EXIST(1260405, "指派负责人不存在"),
SUPER_ADMIN_NOT_DISTRIBUTION(1260406, "超级管理员不能分配工单"),
ADMIN_NOT_DISTRIBUTION_CHILD_DEPT_WORK_ORDER(1260407, "管理员不能分配子部门工单"),
ORDINARY_USER_NOT_DISTRIBUTION(1260408, "普通用户不能分配工单");

/**
* 错误码
*/
private int code;

/**
* 错误信息
*/
private String msg;

DistributionWorkorderCodeEnum(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;
}

}

+ 30
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/DistributionWorkorderRequest.java 파일 보기

@@ -0,0 +1,30 @@
package com.tuoheng.miniprogram.enums;

import lombok.Data;

/**
* 分配工单请求实体
*
* @author wanjing
* @team tuoheng
* @date 2022-12-08
*/
@Data
public class DistributionWorkorderRequest {

/**
* 工单Id
*/
private String workorderId;

/**
* 指派部门ID
*/
private String assignDeptId;

/**
* 指派负责人
*/
private String assignUserIds;

}

+ 50
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/QueryDeptChildListCodeEnum.java 파일 보기

@@ -0,0 +1,50 @@
package com.tuoheng.miniprogram.enums;

/**
* 获取子部门列表返回码
* 模块代码:20(部门管理)
* 接口代码:06 (获取子部门列表)
*
* @author wanjing
* @team tuoheng
* @date 2022-11-22
*/
public enum QueryDeptChildListCodeEnum {

DEPT_LIST_IS_FAILED(1200600, "获取子部门列表失败"),
DEPT_ID_IS_NULL(1200601, "部门id为空"),
DEPT_IS_NOT_EXIST(1200602, "部门不存在"),
DEPT_LIST_IS_NULL(1200603, "子部门列表为空");

/**
* 错误码
*/
private int code;

/**
* 错误信息
*/
private String msg;

QueryDeptChildListCodeEnum(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;
}

}

+ 3
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/IWorkOrderService.java 파일 보기

@@ -6,6 +6,7 @@ import com.tuoheng.miniprogram.entity.WorkOrder;
import com.tuoheng.miniprogram.entity.dto.WorkOrderDto;
import com.tuoheng.miniprogram.entity.query.HandleQuery;
import com.tuoheng.miniprogram.entity.query.WorkOrderQuery;
import com.tuoheng.miniprogram.enums.DistributionWorkorderRequest;

import java.util.List;

@@ -31,4 +32,6 @@ public interface IWorkOrderService extends IBaseService<WorkOrder> {
JsonResult mothCount();

JsonResult generate(List<String> idList);

JsonResult distribution(DistributionWorkorderRequest request);
}

+ 261
- 89
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WorkOrderServiceImpl.java 파일 보기

@@ -105,10 +105,10 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
String code = DateUtils.generateCode("XJGD");
workOrder.setCode(code);
workOrder.setStatus(WorkOrderStatusEnum.STATUS_ALLOCATED.getCode());
workOrder.setAssignDeptId(deptId);
workOrder.setAssignUser(user.getId());
workOrder.setAssignContact(user.getMobile());
workOrder.setAssignTime(DateUtils.now());
// workOrder.setAssignDeptId(deptId);
// workOrder.setAssignUser(user.getId());
// workOrder.setAssignContact(user.getMobile());
// workOrder.setAssignTime(DateUtils.now());
workOrder.setCreateUser(user.getId());
workOrder.setCreateTime(DateUtils.now());
workOrder.setMark(1);
@@ -145,18 +145,11 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
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));
User user = CurrentUserUtil.getUserInfo();
if (ObjectUtil.isNull(user)) {
return JsonResult.error(WorkOrderEnum.USER_IS_NOT_EXIST.getCode(), WorkOrderEnum.USER_IS_NOT_EXIST.getMsg());
}
String tenantId = userInfo1.getTenantId();
String tenantId = user.getTenantId();
if (null == tenantId) {
return JsonResult.error(WorkOrderEnum.DEPT_ID_IS_NULL.getCode(), WorkOrderEnum.DEPT_ID_IS_NULL.getMsg());
}
@@ -173,15 +166,116 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
}
query.setOrderStartTime(startTime);
query.setOrderEndTime(endTime);
//根据登录用户判断角色 1超级管理员 2部门管理员 3普通用户
Integer type = user.getDataPermission();
// if (RoleEnum.SUPER_ADMIN.getCode() == type) {
//
// return JsonResult.success(null,"超级管理员代办工单不显示数据");
// }

//用户角色为2部门管理员 3普通用户
if (RoleEnum.SUPER_ADMIN.getCode() == type ||RoleEnum.ADMIN.getCode() == type || RoleEnum.ORDINARY_USER.getCode() == type) {
//查询分配我的待处理工单
List<WorkOrderInfoVo> workOrderVo = this.myWorkOrderList(user,query);
List<WorkOrderInfoVo> list = new ArrayList<>();
//数据权限为1当前租户下的数据
if (RoleEnum.SUPER_ADMIN.getCode() == type) {
//查询当前租户下所有工单数据
IPage<WorkOrder> workPageData = workOrderMapper.selectPage(page, Wrappers.<WorkOrder>lambdaQuery()
.eq(WorkOrder::getStatus, 5)
.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));
if (null == workPageData.getRecords()) {
return null;
}

List<WorkOrderInfoVo> getWorkOrderVo = this.getWorkOrderList(workPageData,user);
if(CollectionUtil.isNotEmpty(workOrderVo) || workOrderVo.size() != 0){
list.addAll(workOrderVo);
}
if(CollectionUtil.isNotEmpty(getWorkOrderVo) || getWorkOrderVo.size() != 0){
list.addAll(getWorkOrderVo);
}
pageData.setRecords(list);

return JsonResult.success(pageData);
}

//数据权限为2部门管理员查询本部门及子部门工单数据
if (RoleEnum.SUPER_ADMIN.getCode() == type) {
//根据部门id获取本部门及子部门列表
String deptId = user.getDeptId();
if(StringUtils.isEmpty(deptId)){
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_ID_IS_NULL.getCode(),QueryDeptChildListCodeEnum.DEPT_ID_IS_NULL.getMsg());
}
List<String> deptIdList = deptMapper.selectAllChildListById(deptId);
if (CollectionUtil.isEmpty(deptIdList)) {
log.info("获取部门列表为空");
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_LIST_IS_FAILED.getCode(), QueryDeptChildListCodeEnum.DEPT_LIST_IS_FAILED.getMsg());
}

//查询当前部门及子部门下所有工单数据
IPage<WorkOrder> workPageData = workOrderMapper.selectPage(page, Wrappers.<WorkOrder>lambdaQuery()
.eq(WorkOrder::getStatus, 5)
.in(WorkOrder::getDeptId,deptIdList)
.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));
if (null == workPageData.getRecords()) {
return null;
}

List<WorkOrderInfoVo> getWorkOrderVo = this.getWorkOrderList(workPageData,user);
if(CollectionUtil.isNotEmpty(workOrderVo) || workOrderVo.size() != 0){
list.addAll(workOrderVo);
}
if(CollectionUtil.isNotEmpty(getWorkOrderVo) || getWorkOrderVo.size() != 0){
list.addAll(getWorkOrderVo);
}
pageData.setRecords(list);

return JsonResult.success(pageData);
}

//数据权限为3普通用户查询本部门数据
if (RoleEnum.SUPER_ADMIN.getCode() == type) {
String deptId = user.getDeptId();
if(StringUtils.isEmpty(deptId)){
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_ID_IS_NULL.getCode(),QueryDeptChildListCodeEnum.DEPT_ID_IS_NULL.getMsg());
}
IPage<WorkOrder> workPageData = workOrderMapper.selectPage(page, Wrappers.<WorkOrder>lambdaQuery()
.eq(WorkOrder::getStatus, 5)
.eq(WorkOrder::getDeptId,deptId)
.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));
if (null == workPageData.getRecords()) {
return null;
}

List<WorkOrderInfoVo> getWorkOrderVo = this.getWorkOrderList(workPageData,user);
if(CollectionUtil.isNotEmpty(workOrderVo) || workOrderVo.size() != 0){
list.addAll(workOrderVo);
}
if(CollectionUtil.isNotEmpty(getWorkOrderVo) || getWorkOrderVo.size() != 0){
list.addAll(getWorkOrderVo);
}
pageData.setRecords(list);

return JsonResult.success(pageData);
}

return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(), WorkOrderEnum.DATA_IS_NULL.getMsg());
}

/**
* 获取我的待处理工单数据
* @param user
* @param query
* @return
*/
private List<WorkOrderInfoVo> myWorkOrderList(User user,WorkOrderQuery query) {
Integer type = user.getDataPermission();
IPage<WorkOrder> page = new Page<>(query.getPage(), query.getLimit());
List<WorkOrderInfoVo> workOrderInfoList = new ArrayList<>();
if (RoleEnum.SUPER_ADMIN.getCode() == type || RoleEnum.ADMIN.getCode() == type || RoleEnum.ORDINARY_USER.getCode() == type) {
String deptId = user.getDeptId();
if (StringUtils.isEmpty(deptId)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
@@ -189,86 +283,95 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
//获取当前分配人对应的工单分页数据
IPage<WorkOrder> workPageData = workOrderMapper.selectPage(page, Wrappers.<WorkOrder>lambdaQuery()
.eq(WorkOrder::getAssignDeptId, deptId)
.in(WorkOrder::getStatus, 5,10)
.in(WorkOrder::getStatus,10)
.like(StringUtils.isNotEmpty(user.getId()), WorkOrder::getAssignUser, user.getId())
.eq(WorkOrder::getTenantId, tenantId)
.eq(WorkOrder::getTenantId, user.getTenantId())
.between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime())
.eq(WorkOrder::getMark, MarkEnum.VALID.getCode())
.orderByDesc(WorkOrder::getCreateTime));
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.setCreateTime(x.getCreateTime());
//被分配人员对应id
String assignUser = x.getAssignUser();
String[] assignUserId = assignUser.split(",");
if (StringUtils.isEmpty(assignUserId)) {
return null;
}
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, x.getId()));
if (CollectionUtil.isEmpty(workOrderFiles)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
vo.setPromTotal(workOrderFiles.size());
//对应的问题id集合
List<String> inspectionFiledIds = workOrderFiles.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList());
if (CollectionUtil.isEmpty(inspectionFiledIds)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
//获取问题集合
List<InspectionFile> inspectionFileList = new ArrayList<>();
for (String inspectionFiledId : inspectionFiledIds) {
InspectionFile inspectionFile = inspectionFileMapper.selectById(inspectionFiledId);
inspectionFileList.add(inspectionFile);
}
//待处理问题总数
long count = inspectionFileList.stream().filter(t -> t.getStatus() == 20).count();
vo.setPromTodo((int) count);
//已处理问题总数
long count1 = inspectionFileList.stream().filter(t -> t.getStatus() == 25).count();
vo.setPromProcessed((int) count1);
workOrderInfoList = this.getWorkOrderList(workPageData, user);
}
return workOrderInfoList;
}

return vo;
}).collect(Collectors.toList());
//当待处理问题总数为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);
workOrder.setUpdateTime(DateUtils.now());
workOrder.setUpdateUser(user.getId());
super.update(workOrder);
}
/**
* vo数据封装
* @param workPageData
* @return
*/
private List<WorkOrderInfoVo> getWorkOrderList(IPage<WorkOrder> workPageData,User user) {

List<WorkOrderInfoVo> WorkOrderInfoList = new ArrayList<>();
//设置每条工单对应的各状态问题数量
List<WorkOrderInfoVo> workOrderList = workPageData.getRecords().stream().map(x -> {
WorkOrderInfoVo vo = new WorkOrderInfoVo();
BeanUtils.copyProperties(x, vo);
vo.setCreateTime(x.getCreateTime());
//被分配人员对应id
String assignUser = x.getAssignUser();
String[] assignUserId = assignUser.split(",");
if (StringUtils.isEmpty(assignUserId)) {
return null;
}
List<String> list = new ArrayList<>();
for (String userId : assignUserId) {
User userInfo = userMapper.selectById(userId);
if (ObjectUtil.isNotNull(userInfo)) {
list.add(userInfo.getRealname());
}
}
//工单的待处理问题个数不为0时 重新返回
WorkOrderInfoList = workOrderList.stream().filter(h -> h.getPromTodo() != 0).collect(Collectors.toList());
pageData.setRecords(WorkOrderInfoList);
String usernames = list.stream().map(String::valueOf).collect(Collectors.joining("、"));
vo.setAssignUserName(usernames);
//问题总数
List<WorkOrderFile> workOrderFiles = workOrderFileMapper.selectList(Wrappers.<WorkOrderFile>lambdaQuery()
.eq(WorkOrderFile::getWorkOrderId, x.getId()));
if (CollectionUtil.isEmpty(workOrderFiles)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
vo.setPromTotal(workOrderFiles.size());
//对应的问题id集合
List<String> inspectionFiledIds = workOrderFiles.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList());
if (CollectionUtil.isEmpty(inspectionFiledIds)) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
//获取问题集合
List<InspectionFile> inspectionFileList = new ArrayList<>();
for (String inspectionFiledId : inspectionFiledIds) {
InspectionFile inspectionFile = inspectionFileMapper.selectById(inspectionFiledId);
inspectionFileList.add(inspectionFile);
}
//待处理问题总数
long count = inspectionFileList.stream().filter(t -> t.getStatus() == 20).count();
vo.setPromTodo((int) count);
//已处理问题总数
long count1 = inspectionFileList.stream().filter(t -> t.getStatus() == 25).count();
vo.setPromProcessed((int) count1);

return JsonResult.success(pageData);
return vo;
}).collect(Collectors.toList());
//当待处理问题总数为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);
workOrder.setUpdateTime(DateUtils.now());
workOrder.setUpdateUser(user.getId());
super.update(workOrder);
}
}
}
return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(), WorkOrderEnum.DATA_IS_NULL.getMsg());
//工单的待处理问题个数不为0时 重新返回
WorkOrderInfoList = workOrderList.stream().filter(h -> h.getPromTodo() != 0).collect(Collectors.toList());
return WorkOrderInfoList;
}


/**
* 处理工单
*
@@ -771,6 +874,75 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
return JsonResult.success();
}

/**
* 分配工单
* @param request
* @return
*/
@Override
public JsonResult distribution(DistributionWorkorderRequest request) {
log.info("进入分配工单业务, request:{}", request);
JsonResult jsonResult = this.disCheck(request);
if (0 != jsonResult.getCode()) {
log.info("进入分配工单业务:校验失败:{}", jsonResult.getMsg());
return jsonResult;
}
User user = CurrentUserUtil.getUserInfo();
String userId = user.getId();
jsonResult = this.distributionWorkOrder(userId, request);
if (0 != jsonResult.getCode()) {
log.info("进入分配工单:分配工单失败:{}", jsonResult.getMsg());
return jsonResult;
}
return JsonResult.success();
}

private JsonResult disCheck(DistributionWorkorderRequest request) {
if(StringUtils.isEmpty(request.getWorkorderId())){
return JsonResult.error(DistributionWorkorderCodeEnum.ID_LIST_IS_NULL.getCode(),DistributionWorkorderCodeEnum.ID_LIST_IS_NULL.getMsg());
}
if(StringUtils.isEmpty(request.getAssignDeptId())){
return JsonResult.error(DistributionWorkorderCodeEnum.ASSIGN_DEPT_ID_IS_NULL.getCode(),DistributionWorkorderCodeEnum.ASSIGN_DEPT_ID_IS_NULL.getMsg());
}
if(StringUtils.isEmpty(request.getAssignUserIds())){
return JsonResult.error(DistributionWorkorderCodeEnum.ASSIGN_USER_ID_IS_NULL.getCode(), DistributionWorkorderCodeEnum.ASSIGN_USER_ID_IS_NULL.getMsg());
}
WorkOrder workOrder = workOrderMapper.selectOne(new LambdaQueryWrapper<WorkOrder>()
.eq(WorkOrder::getId, request.getWorkorderId())
.eq(WorkOrder::getMark, 1));
if (null == workOrder) {
return JsonResult.error(DistributionWorkorderCodeEnum.WORK_ORDER_IS_NOT_EXIST.getCode(), DistributionWorkorderCodeEnum.WORK_ORDER_IS_NOT_EXIST.getMsg());
}
return JsonResult.success(workOrder);
}

/**
*
* 分配工单
* 1)、修改分配字段信息
* 2)、修改工单状态
* 3)、修改更新字段
*
* @param userId
* @param request
*/
private JsonResult distributionWorkOrder(String userId, DistributionWorkorderRequest request) {
WorkOrder workOrder = new WorkOrder();
workOrder.setId(request.getWorkorderId());
workOrder.setUpdateUser(userId);
workOrder.setUpdateTime(DateUtils.now());
workOrder.setStatus(WorkOrderStatusEnum.STATUS_ASSIGNED.getCode());
workOrder.setAssignDeptId(request.getAssignDeptId());
workOrder.setAssignUser(request.getAssignUserIds());
workOrder.setAssignTime(DateUtils.now());
Integer rowCount = workOrderMapper.updateWorkOrder(workOrder);
if (rowCount <= 0) {
log.info("修改工单状态, 确认失败");
return JsonResult.error(GenerateWorkorderCodeEnum.GENERATE_IS_FAILED.getCode(), GenerateWorkorderCodeEnum.GENERATE_IS_FAILED.getMsg());
}
return JsonResult.success();
}

/**
* 判断是否有生成工单权限
* 1)、超级管理员可选择所有部门问题生成工单
@@ -836,9 +1008,9 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
//分配人员为当前登录用户
workOrder.setDistributionId(user.getId());
//指派人员目前临时是当前登录用户
workOrder.setAssignUser(user.getId());
workOrder.setAssignContact(user.getMobile());
workOrder.setAssignTime(DateUtils.now());
// workOrder.setAssignUser(user.getId());
// workOrder.setAssignContact(user.getMobile());
// workOrder.setAssignTime(DateUtils.now());
workOrder.setCreateUser(user.getId());
workOrder.setCreateTime(DateUtils.now());
Integer rowCount = workOrderMapper.insert(workOrder);

+ 5
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/WorkOrderInfoVo.java 파일 보기

@@ -50,6 +50,11 @@ public class WorkOrderInfoVo {
*/
private Integer promProcessed;

/**
* 工单状态:5待分配 10处理中(已分配) 15已完成
*/
private Integer status;





+ 15
- 0
tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/WorkOrderMapper.xml 파일 보기

@@ -16,4 +16,19 @@
<!-- where wo.mark = 1-->
<!-- </select>-->

<update id="updateWorkOrder" parameterType="com.tuoheng.miniprogram.entity.WorkOrder">
update th_work_order
<trim prefix="SET" suffixOverrides=",">
<if test="assignDeptId != null and assignDeptId !='' "> assign_dept_id = #{assignDeptId}, </if>
<if test="assignUser != null and assignUser !='' "> assign_user = #{assignUser}, </if>
<if test="assignContact != null and assignContact !='' "> assign_contact = #{assignContact}, </if>
<if test="assignNote != null and assignNote !='' "> assign_note = #{assignNote}, </if>
<if test="assignTime != null"> assign_time = #{assignTime}, </if>
<if test="status != null"> status = #{status}, </if>
<if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if>
<if test="updateTime != null"> update_time = #{updateTime}, </if>
</trim>
where id = #{id}
</update>

</mapper>

Loading…
취소
저장