Procházet zdrojové kódy

Merge branch 'wanjing' into develop

tags/v1.0.0^2
wanjing před 1 rokem
rodič
revize
59ef883a4f
20 změnil soubory, kde provedl 1218 přidání a 1 odebrání
  1. +55
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/WorkOrderController.java
  2. +17
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/conver/WorkOrderConverMapper.java
  3. +80
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/WorkOrder.java
  4. +36
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/WorkOrderFile.java
  5. +29
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/WorkOrderStatusEnum.java
  6. +53
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/workorder/GenerateWorkorderCodeEnum.java
  7. +19
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/WorkOrderFileMapper.java
  8. +29
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/WorkOrderMapper.java
  9. +31
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/workorder/GenerateWorkorderRequest.java
  10. +60
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/workorder/QueryWorkOrderPageListRequest.java
  11. +0
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFilePageListService.java
  12. +42
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/IWorkorderService.java
  13. +62
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/WorkorderServiceImpl.java
  14. +218
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderService.java
  15. +62
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/query/QueryWorkOrderDetailsService.java
  16. +214
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/query/QueryWorkOrderPageListService.java
  17. +66
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/WorkOrderDetailsVo.java
  18. +66
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/WorkOrderPageListVo.java
  19. +26
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/WorkOrderFileMapper.xml
  20. +53
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/WorkOrderMapper.xml

+ 55
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/WorkOrderController.java Zobrazit soubor

@@ -0,0 +1,55 @@
package com.tuoheng.admin.controller;

import com.tuoheng.admin.request.workorder.QueryWorkOrderPageListRequest;
import com.tuoheng.admin.service.workorder.IWorkorderService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @Author ChengWang
* @Date 2022/11/29
*/
@Slf4j
@RestController
@RequestMapping("/workorder")
public class WorkOrderController {

@Autowired
private IWorkorderService iWorkorderService;

/**
* 生成工单
*
* @param idList
* @return
*/
@PostMapping("/generate/workorder/{idList}")
public JsonResult generateWorkorder(@PathVariable("idList") List<String> idList) {
return iWorkorderService.generate(idList);
}

/**
* 查询工单分页列表
*
* @param
* @return
*/
@GetMapping("/page/list")
public JsonResult getPageList(QueryWorkOrderPageListRequest request) {
return iWorkorderService.getPageList(request);
}

/**
* 获取工单详情信息
*/
@GetMapping(value = "/details/{id}")
public JsonResult getDetails(@PathVariable("id") String id) {
log.info("进入查询任务详情接口, id={}", id);
return iWorkorderService.getDetails(id);
}

}

+ 17
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/conver/WorkOrderConverMapper.java Zobrazit soubor

@@ -0,0 +1,17 @@
package com.tuoheng.admin.conver;

import com.tuoheng.admin.entity.WorkOrder;
import com.tuoheng.admin.vo.WorkOrderPageListVo;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface WorkOrderConverMapper {

WorkOrderConverMapper INSTANCE = Mappers.getMapper(WorkOrderConverMapper.class);

List<WorkOrderPageListVo> fromWorkOrderListToWorkOrderPageListVoList(List<WorkOrder> workOrderList);

}

+ 80
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/WorkOrder.java Zobrazit soubor

@@ -0,0 +1,80 @@
package com.tuoheng.admin.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tuoheng.common.core.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 巡检问题工单对象 th_work_order
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("th_work_order")
public class WorkOrder extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 租户ID
*/
private String tenantId;
/**
* 部门ID
*/
private String deptId;
/**
* 问题工单号
*/
private String code;
/**
* 工单状态:5待分配 10处理中(已分配) 15已完成
*/
private Integer status;
/**
* 分配人员ID
*/
private String distributionId;
/**
* 指派部门ID
*/
private String assignDeptId;
/**
* 指派负责人
*/
private String assignUser;
/**
* 指派负责人联系方式
*/
private String assignContact;
/**
* 指派备注
*/
private String assignNote;
/**
* 指派时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
private Date assignTime;
}

+ 36
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/WorkOrderFile.java Zobrazit soubor

@@ -0,0 +1,36 @@
package com.tuoheng.admin.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 巡检问题工单子对象 th_work_order_file
*
* @author wanjing
* @team tuoheng
* @date 2022-11-16
*/
@Data
@Accessors(chain = true)
@TableName("th_work_order_file")
public class WorkOrderFile {
private static final long serialVersionUID = 1L;
/**
* 租户ID
*/
private String tenantId;
/**
* 巡检问题工单ID
*/
private String workOrderId;
/**
* 巡检问题文件ID
*/
private String inspectionFileId;
}

+ 29
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/WorkOrderStatusEnum.java Zobrazit soubor

@@ -0,0 +1,29 @@
package com.tuoheng.admin.enums;

import lombok.Getter;

/**
* 工单状态类型
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
public enum WorkOrderStatusEnum {

WAIT(5,"待分配"),
PROCESSING(10,"处理中(已分配)"),
COMPLETED(13,"已完成");

WorkOrderStatusEnum(int code, String description){
this.code = code;
this.description = description;
}

@Getter
private int code;

@Getter
private String description;

}

+ 53
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/workorder/GenerateWorkorderCodeEnum.java Zobrazit soubor

@@ -0,0 +1,53 @@
package com.tuoheng.admin.enums.code.workorder;

/**
* 生成工单返回码
* 模块代码:26(工单管理)
* 接口代码:01 (生成工单)
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
public enum GenerateWorkorderCodeEnum {

GENERATE_IS_FAILED(1260100, "生成工单失败"),
ID_LIST_IS_NULL(1260101, "任务问题id列表为空"),
INSPECTION_FILE_ID_LIST_IS_NOT_EXIST(1260102, "任务问题不存在"),
INCLUDE_NO_CONFIRMED_INSPECTION(1260103, "包含非确认状态任务问题"),
ADMIN_NOT_GENERATE_CHILD_WORKORDER(1260104, "管理员不能生成子部门工单"),
ORDINARY_USER_NO_PERMISSION_TO_GENERATE(1260105, "普通用户不能生成工单"),
;

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

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

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

}

+ 19
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/WorkOrderFileMapper.java Zobrazit soubor

@@ -0,0 +1,19 @@
package com.tuoheng.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.admin.entity.WorkOrderFile;

import java.util.List;

/**
* 巡检问题工单子Mapper接口
*
* @team tuoheng
* @author wanjing
* @date 2022-12-07
*/
public interface WorkOrderFileMapper extends BaseMapper<WorkOrderFile> {

int insertBatch(List<WorkOrderFile> workOrderFileList);

}

+ 29
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/WorkOrderMapper.java Zobrazit soubor

@@ -0,0 +1,29 @@
package com.tuoheng.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.entity.InspectionFileExtend;
import com.tuoheng.admin.entity.WorkOrder;
import com.tuoheng.admin.request.inspectionfile.QueryInspectionFilePageListRequest;
import com.tuoheng.admin.request.workorder.QueryWorkOrderPageListRequest;
import org.apache.ibatis.annotations.Param;

/**
* 巡检工单Mapper接口
*
* @team tuoheng
* @author wanjing
* @date 2022-12-07
*/
public interface WorkOrderMapper extends BaseMapper<WorkOrder> {

/**
* 查询工单分页列表
*
* @param request 巡检任务查询实体
* @return 巡检任务集合
*/
Page<WorkOrder> selectPageList(@Param("page") IPage page, @Param("request") QueryWorkOrderPageListRequest request);

}

+ 31
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/workorder/GenerateWorkorderRequest.java Zobrazit soubor

@@ -0,0 +1,31 @@
package com.tuoheng.admin.request.workorder;

import com.tuoheng.common.core.common.BaseQuery;
import lombok.Data;

/**
* 生成工单请求实体
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
@Data
public class GenerateWorkorderRequest {

/**
* 任务Id
*/
private String inspectionId;

/**
* 问题类型
*/
private String questionId;

/**
* 问题状态:5待确认 10已忽略 15已确认 20已生成工单 25问题已处理
*/
private Integer status;

}

+ 60
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/workorder/QueryWorkOrderPageListRequest.java Zobrazit soubor

@@ -0,0 +1,60 @@
package com.tuoheng.admin.request.workorder;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.tuoheng.common.core.common.BaseQuery;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**
* 查询工单分页列表请求实体
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
@Data
public class QueryWorkOrderPageListRequest extends BaseQuery {

/**
* 问题工单号
*/
private String code;

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

/**
* 工单生成开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date beginTime;

/**
* 工单生成结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;

/**
* 用户所在部门ID
*/
private String userDeptId;

/**
* 检索条件中选择的部门ID
*/
private String deptId;

/**
* 部门idList
*/
private List<String> deptIdList;

}

+ 0
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFilePageListService.java Zobrazit soubor

@@ -121,7 +121,6 @@ public class QueryInspectionFilePageListService {
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getId, userId)
.eq(User::getMark, 1));
user.setType(UserTypeEnum.ORDINARY_USER.getCode());
if (UserTypeEnum.SUPER_ADMIN.getCode() == user.getType()) {
return null;
} else {

+ 42
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/IWorkorderService.java Zobrazit soubor

@@ -0,0 +1,42 @@
package com.tuoheng.admin.service.workorder;

import com.tuoheng.admin.request.workorder.QueryWorkOrderPageListRequest;
import com.tuoheng.common.core.utils.JsonResult;

import java.util.List;

/**
* 工单Service接口
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
public interface IWorkorderService {


/**
* 生成工单
*
* @param idList
* @return
*/
JsonResult generate(List<String> idList);

/**
* 查询工单分页列表
*
* @param request
* @return
*/
JsonResult getPageList(QueryWorkOrderPageListRequest request);

/**
* 查询工单详情
*
* @param id
* @return
*/
JsonResult getDetails(String id);

}

+ 62
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/WorkorderServiceImpl.java Zobrazit soubor

@@ -0,0 +1,62 @@
package com.tuoheng.admin.service.workorder;

import com.tuoheng.admin.request.workorder.QueryWorkOrderPageListRequest;
import com.tuoheng.admin.service.workorder.generate.GenerateWorkorderService;
import com.tuoheng.admin.service.workorder.query.QueryWorkOrderDetailsService;
import com.tuoheng.admin.service.workorder.query.QueryWorkOrderPageListService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* 工单Service接口实现
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
@Slf4j
@Service
public class WorkorderServiceImpl implements IWorkorderService {

@Autowired
private GenerateWorkorderService generateWorkorderService;

@Autowired
private QueryWorkOrderPageListService queryWorkOrderPageListService;

@Autowired
private QueryWorkOrderDetailsService queryWorkOrderDetailsService;

@Override
public JsonResult generate(List<String> idList) {
return generateWorkorderService.generate(idList);
}

/**
*
* 查询工单分页列表
*
* @param request
* @return
*/
@Override
public JsonResult getPageList(QueryWorkOrderPageListRequest request) {
return queryWorkOrderPageListService.getPageList(request);
}

/**
* 查询工单详情
*
* @param id
* @return
*/
@Override
public JsonResult getDetails(String id) {
return queryWorkOrderDetailsService.getDetails(id);
}

}

+ 218
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/generate/GenerateWorkorderService.java Zobrazit soubor

@@ -0,0 +1,218 @@
package com.tuoheng.admin.service.workorder.generate;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.InspectionFileStatusEnum;
import com.tuoheng.admin.enums.UserTypeEnum;
import com.tuoheng.admin.enums.WorkOrderStatusEnum;
import com.tuoheng.admin.enums.code.inspection.DeleteInspectionCodeEnum;
import com.tuoheng.admin.enums.code.inspectionfile.InspectionFileConfirmCodeEnum;
import com.tuoheng.admin.enums.code.inspectionfile.QueryInspectionFilePageListByInspectionIdCodeEnum;
import com.tuoheng.admin.enums.code.workorder.GenerateWorkorderCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.inspectionfile.QueryInspectionFilePageListByInspectionIdRequest;
import com.tuoheng.admin.utils.ShiroUtils;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* 生成工单业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
@Slf4j
@Service
public class GenerateWorkorderService {

@Autowired
private UserMapper userMapper;

@Autowired
private InspectionMapper inspectionMapper;
@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private WorkOrderMapper workOrderMapper;

@Autowired
private WorkOrderFileMapper workOrderFileMapper;

/**
* 生成工单
* 1)、判断参数
* 1.1)、判断参数
* 1.2)、判断权限
* 2)、添加到工单表
* 3)、添加到工单子表
* 4)、修改任务问题状态,改为已生成工单
*
* @param idList
* @return
*/
@Transactional
public JsonResult generate(List<String> idList) {
log.info("进入生成工单业务, idList:{}", idList);
String userId = ShiroUtils.getUserId();
String tenantId = ShiroUtils.getTenantId();
JsonResult result = this.check(idList);
if (0 != result.getCode()) {
log.info("进入生成工单业务:校验失败:{}", result.getMsg());
return result;
}
List<InspectionFile> inspectionFileList = (List<InspectionFile>) result.getData();
List<String> inspectionIdList = inspectionFileList.stream().map(o -> o.getInspectionId()).collect(Collectors.toList());
List<Inspection> inspectionList = inspectionMapper.selectBatchIds(inspectionIdList);
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getTenantId, tenantId)
.eq(User::getId, userId)
.eq(User::getMark, 1));
result = checkPermission(user, inspectionList);

if (0 != result.getCode()) {
log.info("进入生成工单务:校验权限失败:{}", result.getMsg());
return result;
}

WorkOrder workOrder = this.insertWorkOrder(user);

this.insertWorkOrderFile(workOrder, idList);

this.updateInspectionFileStatus(userId, idList);

return JsonResult.success();
}

/**
* 检查参数
*
* @param idList
* @return
*/
private JsonResult check(List<String> idList) {
// 判断任务问题id是否为空
if (CollectionUtil.isEmpty(idList)) {
return JsonResult.error(GenerateWorkorderCodeEnum.ID_LIST_IS_NULL.getCode(), GenerateWorkorderCodeEnum.ID_LIST_IS_NULL.getMsg());
}
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectBatchIds(idList);
if (CollectionUtil.isEmpty(inspectionFileList)) {
return JsonResult.error(GenerateWorkorderCodeEnum.INSPECTION_FILE_ID_LIST_IS_NOT_EXIST.getCode(), GenerateWorkorderCodeEnum.INSPECTION_FILE_ID_LIST_IS_NOT_EXIST.getMsg());
}
for (InspectionFile inspectionFile : inspectionFileList) {
if (inspectionFile.getStatus() != InspectionFileStatusEnum.CONFIRMED.getCode()) {
return JsonResult.error(GenerateWorkorderCodeEnum.INCLUDE_NO_CONFIRMED_INSPECTION.getCode(), GenerateWorkorderCodeEnum.INCLUDE_NO_CONFIRMED_INSPECTION.getMsg());
}
}
return JsonResult.success(inspectionFileList);
}

/**
* 判断是否有生成工单权限
* 1)、超级管理员可选择所有部门问题生成工单
* 2)、部门管理员仅可生成本部门工单,无法生成子部门工单
* 3)、普通用户无生成工单权限
*
* @param user
* @param inspectionList
* @return
*/
private JsonResult checkPermission(User user, List<Inspection> inspectionList) {
if (UserTypeEnum.SUPER_ADMIN.getCode() == user.getType()) {
return JsonResult.success(user);
} else if (UserTypeEnum.ADMIN.getCode() == user.getType()) {
for (Inspection inspection : inspectionList) {
if (!user.getDeptId().equals(inspection.getDeptId())) {
return JsonResult.error(GenerateWorkorderCodeEnum.ADMIN_NOT_GENERATE_CHILD_WORKORDER.getCode(), GenerateWorkorderCodeEnum.ADMIN_NOT_GENERATE_CHILD_WORKORDER.getMsg());
}
}
return JsonResult.success(user);
} else if (UserTypeEnum.ORDINARY_USER.getCode() == user.getType()) {
return JsonResult.error(GenerateWorkorderCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_GENERATE.getCode(), GenerateWorkorderCodeEnum.ORDINARY_USER_NO_PERMISSION_TO_GENERATE.getMsg());
}
return JsonResult.error();
}

/**
*
* 添加工单
*
*/
private WorkOrder insertWorkOrder(User user) {
WorkOrder workOrder = new WorkOrder();
String code = DateUtils.generateCode("XJRW");
workOrder.setCode(code);
workOrder.setTenantId(user.getTenantId());
workOrder.setDeptId(user.getDeptId());
workOrder.setStatus(WorkOrderStatusEnum.WAIT.getCode());
workOrder.setDistributionId(user.getId()); // 分配人员
workOrder.setCreateUser(user.getId());
workOrder.setCreateTime(DateUtils.now());
Integer rowCount = workOrderMapper.insert(workOrder);
if (rowCount <= 0) {
log.info("添加工单表失败");
}
return workOrder;
}

/**
*
* 添加工单子表
*
*/
private void insertWorkOrderFile(WorkOrder workOrder, List<String> idList) {
List<WorkOrderFile> workOrderFileList = new ArrayList<>();
WorkOrderFile workOrderFile;
for (String id : idList) {
workOrderFile = new WorkOrderFile();
workOrderFile.setTenantId(workOrder.getTenantId());
workOrderFile.setWorkOrderId(workOrder.getId());
workOrderFile.setInspectionFileId(id);
workOrderFileList.add(workOrderFile);
}

if (CollectionUtil.isEmpty(workOrderFileList)) {
return;
}
Integer rowCount = workOrderFileMapper.insertBatch(workOrderFileList);
if (rowCount <= 0) {
log.info("添加工单子表失败");
}
}

/**
*
* 问题状态,改为已生成工单
*
* @param userId
* @param idList
*/
private JsonResult updateInspectionFileStatus(String userId, List<String> idList) {
Map<String, Object> map = new HashMap<>();
map.put("status", InspectionFileStatusEnum.GENERATE_ORDER.getCode());
map.put("updateUser", userId);
map.put("updateTime", DateUtils.now());
map.put("idList", idList);

Integer rowCount = inspectionFileMapper.updateByIdList(map);
if (rowCount <= 0) {
log.info("修改任务问题状态, 确认失败");
return JsonResult.error(GenerateWorkorderCodeEnum.GENERATE_IS_FAILED.getCode(), GenerateWorkorderCodeEnum.GENERATE_IS_FAILED.getMsg());
}
return JsonResult.success();
}
}

+ 62
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/query/QueryWorkOrderDetailsService.java Zobrazit soubor

@@ -0,0 +1,62 @@
package com.tuoheng.admin.service.workorder.query;

import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.utils.ShiroUtils;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 查询工单详情业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-12-06
*/
@Slf4j
@Service
public class QueryWorkOrderDetailsService {

@Autowired
private UserMapper userMapper;
@Autowired
private DeptMapper deptMapper;

@Autowired
private WorkOrderMapper workOrderMapper;

@Autowired
private WorkOrderFileMapper workOrderFileMapper;

@Autowired
private InspectionFileMapper inspectionFileMapper;

public JsonResult getDetails(String id) {
log.info("进入查询工单详情业务, id:{}", id);

String userId = ShiroUtils.getUserId();

JsonResult result = this.check(id);
if (0 != result.getCode()) {
log.info("进入查询工单详情业务:校验失败:{}", result.getMsg());
return result;
}


return JsonResult.success();

}

/**
* 检查参数
*
* @param id
* @return
*/
private JsonResult check(String id) {

return JsonResult.success();
}

}

+ 214
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/workorder/query/QueryWorkOrderPageListService.java Zobrazit soubor

@@ -0,0 +1,214 @@
package com.tuoheng.admin.service.workorder.query;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.conver.WorkOrderConverMapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.InspectionFileStatusEnum;
import com.tuoheng.admin.enums.UserTypeEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.workorder.QueryWorkOrderPageListRequest;
import com.tuoheng.admin.utils.ShiroUtils;
import com.tuoheng.admin.vo.WorkOrderPageListVo;
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;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* 查询工单分页列表业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-12-06
*/
@Slf4j
@Service
public class QueryWorkOrderPageListService {

@Autowired
private UserMapper userMapper;
@Autowired
private DeptMapper deptMapper;

@Autowired
private WorkOrderMapper workOrderMapper;

@Autowired
private WorkOrderFileMapper workOrderFileMapper;

@Autowired
private InspectionFileMapper inspectionFileMapper;

public JsonResult getPageList(QueryWorkOrderPageListRequest request) {
log.info("进入查询工单分页列表业务, request:{}", request.toString());

String userId = ShiroUtils.getUserId();

JsonResult result = this.check(request);
if (0 != result.getCode()) {
log.info("进入查询工单分页列表业务:校验失败:{}", result.getMsg());
return result;
}

// 用户能看到被指派到自己部门的工单
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getId, userId)
.eq(User::getMark, 1));
request.setUserDeptId(user.getDeptId());

// 获取部门Id的查询范围
List<String> deptIdList = this.getDeptIdList(user, request.getDeptId());
request.setDeptIdList(deptIdList);

// 设置分页参数
IPage<InspectionFile> page = new Page<>(request.getPage(), request.getLimit());
// 查询结果
IPage<WorkOrder> pageData = workOrderMapper.selectPageList(page, request);
if (null == pageData || pageData.getTotal() == 0) {
log.info("获取任务分页列表为空");
return JsonResult.success(null, QueryInspectionPageListCodeEnum.DATA_IS_FAILED.getMsg());
}

// 构造返回结果对象
List<WorkOrderPageListVo> workOrderPageListVoList = this.buildPageList(pageData.getRecords());

// 重写返回结果对象
IPage<WorkOrderPageListVo> workOrderPageListVoPageData = new Page<>();
workOrderPageListVoPageData.setPages(pageData.getPages());
workOrderPageListVoPageData.setCurrent(pageData.getCurrent());
workOrderPageListVoPageData.setSize(pageData.getSize());
workOrderPageListVoPageData.setTotal(pageData.getTotal());
workOrderPageListVoPageData.setRecords(workOrderPageListVoList);

return JsonResult.success(workOrderPageListVoPageData);

}

/**
* 检查参数
*
* @param request
* @return
*/
private JsonResult check(QueryWorkOrderPageListRequest request) {

return JsonResult.success();
}

/**
* 获取部门Id的查询范围
* 1)、deptId:如果传了值,查该部门的任务
* 2)、deptId:如果没有传值
* 2.1)、管理员:可查全部确认问题
* 2.2)、管理员/普通用户:本部门及子部门创建的工单
*
* @param deptId
* @return
*/
private List<String> getDeptIdList( User user, String deptId) {
List<String> deptIdList = new ArrayList<>();
if (!StringUtils.isEmpty(deptId)) {
deptIdList.add(deptId);
return deptIdList;
}
if (UserTypeEnum.SUPER_ADMIN.getCode() == user.getType()) {
return null;
} else {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId());
return deptIdList;
}
}

/**
* 处理字段
* 1)、部门名称
* 2)、分配人员名称
* 3)、问题总数
* 4)、已处理问题数
*
* @param workOrderList
* @return
*/
private List<WorkOrderPageListVo> buildPageList(List<WorkOrder> workOrderList) {
Map<String, Dept> deptMap = this.getDeptMap(workOrderList);
Map<String, User> userMap = this.getUserMap(workOrderList);

Map<String, List<WorkOrderFile>> workOrderFileMap = this.getWorkOrderFileMap(workOrderList);

List<String> inspectionFileIdList;
List<InspectionFile> inspectionFileList;
List<WorkOrderPageListVo> workOrderPageListVoList = WorkOrderConverMapper.INSTANCE.fromWorkOrderListToWorkOrderPageListVoList(workOrderList);
Dept dept;
User user;
List<WorkOrderFile> workOrderFileList;
for (WorkOrderPageListVo workOrderPageListVo : workOrderPageListVoList) {
dept = deptMap.get(workOrderPageListVo.getDeptId());
user = userMap.get(workOrderPageListVo.getDistributionId());
workOrderFileList = workOrderFileMap.get(workOrderPageListVo.getId());
if (!CollectionUtil.isEmpty(workOrderFileList)) {
inspectionFileIdList = workOrderFileList.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList());
inspectionFileList = inspectionFileMapper.selectBatchIds(inspectionFileIdList);
List<InspectionFile> inspectionFileListTmp = inspectionFileList.stream().filter(s -> s.getStatus() == InspectionFileStatusEnum.PROCESSED.getCode()).collect(Collectors.toList());
workOrderPageListVo.setProblemTotalCount(workOrderFileList.size());
workOrderPageListVo.setProcessedProblemCount(inspectionFileListTmp.size());
}
if (null != dept) {
workOrderPageListVo.setDeptName(dept.getName());
}
if (null != user) {
workOrderPageListVo.setDistributionName(user.getRealname());
}
}
return workOrderPageListVoList;
}

/**
* 获取部门列表,放到map,减少循环次数
*
* @param workOrderList
* @return
*/
private Map<String, Dept> getDeptMap(List<WorkOrder> workOrderList) {
List<String> deptIdList = workOrderList.stream().map(o -> o.getDeptId()).collect(Collectors.toList());
List<Dept> deptList = deptMapper.selectList(new LambdaQueryWrapper<Dept>()
.in(Dept::getId, deptIdList)
.eq(Dept::getMark, 1));
Map<String, Dept> deptMap = deptList.stream().collect(Collectors.toMap(Dept::getId, Function.identity()));
return deptMap;
}

/**
* 获取用户列表,放到map,减少循环次数
*
* @param workOrderList
* @return
*/
private Map<String, User> getUserMap(List<WorkOrder> workOrderList) {
List<String> distributionIdList = workOrderList.stream().map(o -> o.getDistributionId()).collect(Collectors.toList());
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>()
.in(User::getId, distributionIdList)
.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>()
.in(WorkOrderFile::getWorkOrderId, workOrderIdList));
Map<String, List<WorkOrderFile>> workOrderFileMap = workOrderFileList.stream().collect(Collectors.groupingBy(WorkOrderFile::getWorkOrderId));
return workOrderFileMap;
}

}

+ 66
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/WorkOrderDetailsVo.java Zobrazit soubor

@@ -0,0 +1,66 @@
package com.tuoheng.admin.vo;

import lombok.Data;

import java.util.Date;

/**
* 返回工单视图Vo
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
@Data
public class WorkOrderDetailsVo {

/**
* 工单ID
*/
private String id;

/**
* 工单编号
*/
private String code;

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

/**
* 工单生成时间
*/
private Date createTime;

/**
* 问题总数
*/
private Integer problemTotalCount;

/**
* 已处理问题数
*/
private Integer processedProblemCount;

/**
* 分配人员ID
*/
private String distributionId;

/**
* 分配人员名称
*/
private String distributionName;

/**
* 所在部门ID
*/
private String deptId;

/**
* 所在部门名称
*/
private String deptName;
}

+ 66
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/WorkOrderPageListVo.java Zobrazit soubor

@@ -0,0 +1,66 @@
package com.tuoheng.admin.vo;

import lombok.Data;

import java.util.Date;

/**
* 返回工单列表视图Vo
*
* @author wanjing
* @team tuoheng
* @date 2022-12-07
*/
@Data
public class WorkOrderPageListVo {

/**
* 工单ID
*/
private String id;

/**
* 工单编号
*/
private String code;

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

/**
* 工单生成时间
*/
private Date createTime;

/**
* 问题总数
*/
private Integer problemTotalCount;

/**
* 已处理问题数
*/
private Integer processedProblemCount;

/**
* 分配人员ID
*/
private String distributionId;

/**
* 分配人员名称
*/
private String distributionName;

/**
* 所在部门ID
*/
private String deptId;

/**
* 所在部门名称
*/
private String deptName;
}

+ 26
- 0
tuoheng-service/tuoheng-admin/src/main/resources/mapper/WorkOrderFileMapper.xml Zobrazit soubor

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.admin.mapper.WorkOrderFileMapper">
<resultMap type="com.tuoheng.admin.entity.WorkOrderFile" id="WorkOrderFileResult">
<result property="tenantId" column="tenant_id" />
<result property="workOrderId" column="work_order_id" />
<result property="inspectionFileId" column="inspection_file_id" />
</resultMap>
<sql id="selectThWorkOrderFileVo">
select tenant_id, work_order_id, inspection_file_id from th_work_order_file
</sql>
<!-- 批量新增数据 -->
<insert id="insertBatch" parameterType="com.tuoheng.admin.entity.WorkOrderFile">
insert into th_work_order_file (tenant_id, work_order_id, inspection_file_id)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
( #{item.tenantId, jdbcType=INTEGER}, #{item.workOrderId, jdbcType=VARCHAR}, #{item.inspectionFileId, jdbcType=VARCHAR} )
</foreach>
</insert>
</mapper>

+ 53
- 0
tuoheng-service/tuoheng-admin/src/main/resources/mapper/WorkOrderMapper.xml Zobrazit soubor

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.admin.mapper.WorkOrderMapper">
<resultMap type="com.tuoheng.admin.entity.WorkOrder" id="WorkOrderResult">
<result property="id" column="id" />
<result property="tenantId" column="tenant_id" />
<result property="deptId" column="dept_id" />
<result property="code" column="code" />
<result property="status" column="status" />
<result property="assignDeptId" column="assign_dept_id" />
<result property="assignUser" column="assign_user" />
<result property="assignContact" column="assign_contact" />
<result property="assignNote" column="assign_note" />
<result property="assignTime" column="assign_time" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="updateUser" column="update_user" />
<result property="updateTime" column="update_time" />
<result property="mark" column="mark" />
</resultMap>
<sql id="selectThWorkOrderVo">
select id, tenant_id, dept_id, code, status, assign_dept_id, assign_user, assign_contact, assign_note, assign_time, create_user, create_time, update_user, update_time, mark
from th_work_order
</sql>
<select id="selectPageList" parameterType="com.tuoheng.admin.request.workorder.QueryWorkOrderPageListRequest" resultMap="WorkOrderResult">
<include refid="selectThWorkOrderVo"/>
<where>
<if test="1 == 1"> and mark = 1 </if>
<if test="request.code != null and request.code != 0"> and code = #{request.code} </if>
<if test="request.status != null and request.status != ''"> and status = #{request.status} </if>
<if test="request.userDeptId != null and request.userDeptId != ''"> and assign_dept_id = #{request.userDeptId} </if>
<if test="request.deptIdList != null and request.deptIdList.size() > 0">
and dept_id in
<foreach item="deptId" collection="request.deptIdList" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
<if test="request.beginTime != null">
and check_time &gt;= #{request.beginTime}
</if>
<if test="request.endTime != null">
and check_time &lt;= #{request.endTime}
</if>
</where>
order by create_time desc
</select>
</mapper>

Načítá se…
Zrušit
Uložit