@@ -1,5 +1,6 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.request.inspectionfile.InspectionFileHandleAuditRresultRequest; | |||
import com.tuoheng.admin.request.inspectionfile.InspectionFileProcessingRresultRequest; | |||
import com.tuoheng.admin.service.inspectionfile.IInspectionFileService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
@@ -34,4 +35,16 @@ public class InspectionFileHandleController { | |||
return iInspectionFileService.processing(request); | |||
} | |||
/** | |||
* 审核结果 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
@PostMapping("/audit") | |||
public JsonResult audit(@RequestBody InspectionFileHandleAuditRresultRequest request){ | |||
return iInspectionFileService.audit(request); | |||
} | |||
} |
@@ -55,4 +55,19 @@ public class InspectionFileHandle extends BaseEntity { | |||
@JsonFormat(pattern = "yyyy-MM-dd") | |||
private Date handlerTime; | |||
/** | |||
* 审核结果 0未审核 1审核通过 2审核未通过 | |||
*/ | |||
private Integer audit; | |||
/** | |||
* 审核意见 | |||
*/ | |||
private String auditView; | |||
/** | |||
* 审核时间 | |||
*/ | |||
private Date auditTime; | |||
} |
@@ -41,7 +41,8 @@ public class WorkOrder extends BaseEntity { | |||
private String code; | |||
/** | |||
* 工单状态:5待分配 10处理中(已分配) 15已完成 | |||
* 更新前 (工单状态:5待分配 10处理中(已分配) 15已完成) | |||
* 更新后 工单状态:5待分配 10处理中(问题未全部处理) 11待审核(问题已经处理完) 15已完成 | |||
*/ | |||
private Integer status; | |||
@@ -0,0 +1,31 @@ | |||
package com.tuoheng.admin.enums; | |||
import lombok.Getter; | |||
/** | |||
* 工单状态类型 | |||
* | |||
* @author chenlu | |||
* @team tuoheng | |||
* @date 2022-12-07 | |||
* 审核结果 0未审核 1审核通过 2审核未通过 | |||
*/ | |||
public enum AuditEnum { | |||
ZERO(0,"未审核"), | |||
ONE(1,"审核通过"), | |||
TWO(2,"审核未通过"); | |||
AuditEnum(int code, String description){ | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
} |
@@ -13,6 +13,9 @@ public enum WorkOrderStatusEnum { | |||
WAIT(5,"待分配"), | |||
PROCESSING(10,"处理中(已分配)"), | |||
PENDING_REVIEW(11,"待审核"), | |||
COMPLETED(15,"已完成"); | |||
WorkOrderStatusEnum(int code, String description){ |
@@ -16,7 +16,9 @@ public enum InspectionFileProcessingCodeEnum { | |||
WORK_ORDER_IS_NOT_EXIST(1250102, "工单不存在"), | |||
INSPECTION_FILE_ID_IS_NULL(1250103, "任务问题id为空"), | |||
INSPECTION_FILE_IS_NOT_EXIST(1250104, "任务问题不存在"), | |||
INSPECTION_FILE_Handle_IS_EXIST(1250105, "该问题已处理"); | |||
INSPECTION_FILE_Handle_IS_EXIST(1250105, "该问题已处理"), | |||
INSPECTION_FILE_HANDLE_ISERROR(1250106, "当前问题未处理完毕或数据已失效"); | |||
/** | |||
* 错误码 |
@@ -0,0 +1,36 @@ | |||
package com.tuoheng.admin.request.inspectionfile; | |||
import lombok.Data; | |||
import java.util.Date; | |||
/** | |||
* 处理任务问题结果请求实体 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-12-09 | |||
*/ | |||
@Data | |||
public class InspectionFileHandleAuditRresultRequest { | |||
/** | |||
* 工单ID | |||
*/ | |||
private String workOrderId; | |||
/** | |||
* 巡检问题文件ID | |||
*/ | |||
private String inspectionFileId; | |||
/** | |||
* 审核结果 0未审核 1审核通过 2审核未通过 | |||
*/ | |||
private Integer audit; | |||
/** | |||
* 审核意见 | |||
*/ | |||
private String auditView; | |||
} |
@@ -119,4 +119,7 @@ public interface IInspectionFileService { | |||
* @return | |||
*/ | |||
JsonResult add(AddInspectionFileRequest request); | |||
JsonResult audit(InspectionFileHandleAuditRresultRequest request); | |||
} |
@@ -6,10 +6,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.InspectionFile; | |||
import com.tuoheng.admin.entity.InspectionFileHandle; | |||
import com.tuoheng.admin.entity.QuestionType; | |||
import com.tuoheng.admin.entity.Report; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.entity.WorkOrder; | |||
import com.tuoheng.admin.entity.WorkOrderFile; | |||
import com.tuoheng.admin.enums.AuditEnum; | |||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.enums.WorkOrderStatusEnum; | |||
import com.tuoheng.admin.enums.code.inspectionfile.ListByDeptUserTypeEnum; | |||
import com.tuoheng.admin.enums.code.inspectionfilehandle.InspectionFileProcessingCodeEnum; | |||
import com.tuoheng.admin.enums.code.questiontype.QuestionTypeEnum; | |||
import com.tuoheng.admin.mapper.*; | |||
import com.tuoheng.admin.query.InspectionFileQuery; | |||
@@ -31,6 +39,7 @@ import com.tuoheng.admin.vo.ListByDeptUserTypeVo; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
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; | |||
@@ -38,11 +47,14 @@ import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.Objects; | |||
import java.util.stream.Collectors; | |||
/** | |||
@@ -103,6 +115,16 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
@Autowired | |||
private AddInspectionFileService addInspectionFileService; | |||
@Autowired | |||
private InspectionFileHandleMapper inspectionFileHandleMapper; | |||
@Autowired | |||
private WorkOrderMapper workOrderMapper; | |||
@Autowired | |||
private WorkOrderFileMapper workOrderFileMapper; | |||
/** | |||
* 问题类型和任务名称 | |||
* | |||
@@ -477,4 +499,73 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
public JsonResult add(AddInspectionFileRequest request) { | |||
return addInspectionFileService.add(request); | |||
} | |||
@Override | |||
@Transactional(rollbackFor = Exception.class) | |||
public JsonResult audit(InspectionFileHandleAuditRresultRequest request) { | |||
//获取当前用户信息 | |||
User user = CurrentUserUtil.getUserInfo(); | |||
String userId = user.getId(); | |||
String tenantId = user.getTenantId(); | |||
//查询巡检问题处理结果表 | |||
LambdaQueryWrapper<InspectionFileHandle> queryWrapper = new LambdaQueryWrapper<>(); | |||
queryWrapper.eq( InspectionFileHandle::getInspectionFileId, request.getInspectionFileId()); | |||
queryWrapper.eq( InspectionFileHandle::getMark, MarkEnum.VALID.getCode() ); | |||
InspectionFileHandle inspectionFileHandle = inspectionFileHandleMapper.selectOne(queryWrapper); | |||
if (Objects.isNull(inspectionFileHandle) || !inspectionFileHandle.getAudit().equals(0)){ | |||
log.info("问题单未处理/或者已审核,inspectionFileId:{}", request.getInspectionFileId()); | |||
return JsonResult.error(InspectionFileProcessingCodeEnum.PROCESSING_IS_FAILED.getCode(), InspectionFileProcessingCodeEnum.INSPECTION_FILE_HANDLE_ISERROR.getMsg()); | |||
} | |||
//审核 新增审核意见 审核理由 | |||
inspectionFileHandle.setAudit(request.getAudit()); | |||
inspectionFileHandle.setAuditView(request.getAuditView()); | |||
inspectionFileHandle.setAuditTime(new Date()); | |||
int i = inspectionFileHandleMapper.updateById(inspectionFileHandle); | |||
if (i < 1 ){ | |||
log.info("修改问题处理单失败,inspectionFileId:{}", request.getInspectionFileId()); | |||
return JsonResult.error(InspectionFileProcessingCodeEnum.PROCESSING_IS_FAILED.getCode(), InspectionFileProcessingCodeEnum.PROCESSING_IS_FAILED.getMsg()); | |||
} | |||
//判断处理工单的状态 | |||
JsonResult jsonResult = workOrderUpdateStatus(userId, request); | |||
return jsonResult; | |||
} | |||
private JsonResult workOrderUpdateStatus(String userId, InspectionFileHandleAuditRresultRequest request) { | |||
//当工单关联的任务问题都审核完,将工单状态改为已完成 反之待审核 | |||
//巡检问题工单子表 | |||
List<WorkOrderFile> workOrderFileList = workOrderFileMapper.selectList(new LambdaQueryWrapper<WorkOrderFile>() | |||
.eq(WorkOrderFile::getWorkOrderId, request.getWorkOrderId())); | |||
List<String> inspectionFileIdList = workOrderFileList.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList()); | |||
//巡检问题处理结果表 | |||
LambdaQueryWrapper<InspectionFileHandle> queryWrapper = new LambdaQueryWrapper<>(); | |||
queryWrapper.in(InspectionFileHandle::getInspectionFileId, inspectionFileIdList); | |||
List<Integer> list = new ArrayList<>(); | |||
list.add(AuditEnum.ONE.getCode()); | |||
list.add(AuditEnum.TWO.getCode()); | |||
queryWrapper.in(InspectionFileHandle::getAudit, list); | |||
List<InspectionFileHandle> inspectionFileHandles = inspectionFileHandleMapper.selectList(queryWrapper); | |||
if (CollectionUtil.isEmpty(inspectionFileHandles)){ | |||
return JsonResult.success(); | |||
} | |||
//查询所有的审核单的数据 | |||
List<String> idList = inspectionFileHandles.stream().map(InspectionFileHandle::getInspectionFileId).collect(Collectors.toList()); | |||
//如果这条审核的数据+原始数据 = 所有问题单 代表所有问题均审核 修改工单状态为已完成 反之不做修改 | |||
if (workOrderFileList.size() != idList.size()){ | |||
return JsonResult.success(); | |||
} | |||
//处理工单表的状态 | |||
WorkOrder workOrder = new WorkOrder(); | |||
workOrder.setId(request.getWorkOrderId()); | |||
workOrder.setStatus(WorkOrderStatusEnum.COMPLETED.getCode()); | |||
workOrder.setUpdateUser(userId); | |||
workOrder.setUpdateTime(DateUtils.now()); | |||
Integer rowCount = workOrderMapper.update(workOrder); | |||
if (rowCount <= 0) { | |||
log.info("更新工单状态失败,workOrderId:{}", request.getWorkOrderId()); | |||
return JsonResult.error(InspectionFileProcessingCodeEnum.PROCESSING_IS_FAILED.getCode(), InspectionFileProcessingCodeEnum.PROCESSING_IS_FAILED.getMsg()); | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -70,7 +70,7 @@ public class InspectionFileProcessingService { | |||
return result; | |||
} | |||
result = this.updateWorkOrderStatus(userId, request); | |||
result = this.updateNewWorkOrderStatus(userId, request); | |||
if (0 != result.getCode()) { | |||
log.info("进入任务问题处理业务:更新工单状态失败:{}", result.getMsg()); | |||
return result; | |||
@@ -182,4 +182,35 @@ public class InspectionFileProcessingService { | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 更新工单状态 —— 更新 | |||
* 当工单关联的任务问题都被处理完时,将工单状态改为待审核 反之处理中 | |||
*/ | |||
private JsonResult updateNewWorkOrderStatus(String userId, InspectionFileProcessingRresultRequest request) { | |||
//巡检问题工单子表 | |||
List<WorkOrderFile> workOrderFileList = workOrderFileMapper.selectList(new LambdaQueryWrapper<WorkOrderFile>() | |||
.eq(WorkOrderFile::getWorkOrderId, request.getWorkOrderId())); | |||
List<String> inspectionFileIdList = workOrderFileList.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList()); | |||
//巡检问题处理结果表 | |||
Integer count = inspectionFileHandleMapper.selectCount(new LambdaQueryWrapper<InspectionFileHandle>() | |||
.in(InspectionFileHandle::getInspectionFileId, inspectionFileIdList)); | |||
if (workOrderFileList.size() > count) { | |||
return JsonResult.success(); | |||
} | |||
//处理工单表的状态 | |||
WorkOrder workOrder = new WorkOrder(); | |||
workOrder.setId(request.getWorkOrderId()); | |||
workOrder.setStatus(WorkOrderStatusEnum.PENDING_REVIEW.getCode()); | |||
workOrder.setUpdateUser(userId); | |||
workOrder.setUpdateTime(DateUtils.now()); | |||
Integer rowCount = workOrderMapper.update(workOrder); | |||
if (rowCount <= 0) { | |||
log.info("更新工单状态失败,workOrderId:{}", request.getWorkOrderId()); | |||
return JsonResult.error(InspectionFileProcessingCodeEnum.PROCESSING_IS_FAILED.getCode(), InspectionFileProcessingCodeEnum.PROCESSING_IS_FAILED.getMsg()); | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -87,9 +87,14 @@ public class QueryInspectionFilePageListByWorkOrderIdService { | |||
.in(InspectionFile::getId, inspectionFileIdList) | |||
.eq(InspectionFile::getTenantId, tenantId) | |||
.eq(InspectionFile::getMark, 1)); | |||
//查询问题单子表审核时间 意见等信息 | |||
List<InspectionFileHandle> inspectionFileHandles = inspectionFileHandleMapper.selectList(new LambdaQueryWrapper<InspectionFileHandle>() | |||
.in(InspectionFileHandle::getInspectionFileId, inspectionFileIdList) | |||
.eq(InspectionFileHandle::getTenantId, tenantId) | |||
.eq(InspectionFileHandle::getMark, 1)); | |||
// 构造返回结果对象 | |||
List<InspectionFileHandleVo> inspectionFileHandleVoList = this.buildInspectionFileHandleVoList(request.getWorkOrderId(), inspectionFileIdList, inspectionFileList); | |||
List<InspectionFileHandleVo> inspectionFileHandleVoList = this.buildInspectionFileHandleVoList(request.getWorkOrderId(), inspectionFileIdList, inspectionFileList, inspectionFileHandles); | |||
// 重写返回结果对象 | |||
IPage<InspectionFileHandleVo> inspectionFilePageListVoPageData = new Page<>(); | |||
@@ -130,7 +135,7 @@ public class QueryInspectionFilePageListByWorkOrderIdService { | |||
* | |||
* @return | |||
*/ | |||
private List<InspectionFileHandleVo> buildInspectionFileHandleVoList(String workOrderId, List<String> inspectionFileIdList, List<InspectionFile> inspectionFileList) { | |||
private List<InspectionFileHandleVo> buildInspectionFileHandleVoList(String workOrderId, List<String> inspectionFileIdList, List<InspectionFile> inspectionFileList, List<InspectionFileHandle> inspectionFileHandles) { | |||
Map<String, QuestionType> questionTypeMap = this.getQuestionTypeMap(); | |||
List<InspectionFileHandle> inspectionFileHandleList = this.getInspectionFileHandleList(inspectionFileIdList); | |||
Map<String, InspectionFileHandle> inspectionFileHandleMap = this.getInspectionFileHandleMap(inspectionFileHandleList); | |||
@@ -141,8 +146,22 @@ public class QueryInspectionFilePageListByWorkOrderIdService { | |||
User user; | |||
QuestionType questionType; | |||
InspectionFileHandle inspectionFileHandle; | |||
//子表信息处理 | |||
Map<String, InspectionFileHandle> detailMap = new HashMap<>(); | |||
if (!CollectionUtil.isEmpty(inspectionFileHandles)){ | |||
detailMap = inspectionFileHandles.stream().collect(Collectors.toMap(InspectionFileHandle::getInspectionFileId, a -> a)); | |||
} | |||
for (InspectionFile inspectionFile : inspectionFileList) { | |||
inspectionFileHandleVo = new InspectionFileHandleVo(); | |||
//处理明细表审核数据 | |||
if (!CollectionUtil.isEmpty(detailMap) && Objects.nonNull(detailMap.get(inspectionFile.getId())) ){ | |||
InspectionFileHandle item = detailMap.get(inspectionFile.getId()); | |||
inspectionFileHandleVo.setAudit(item.getAudit()); | |||
inspectionFileHandleVo.setAuditView(item.getAuditView()); | |||
inspectionFileHandleVo.setAuditTime(item.getAuditTime()); | |||
}else { | |||
inspectionFileHandleVo.setAudit(0); | |||
} | |||
inspectionFileHandleVo.setWorkOrderId(workOrderId); | |||
inspectionFileHandleVo.setInspectionFileId(inspectionFile.getId()); | |||
inspectionFileHandleVo.setStatus(inspectionFile.getStatus()); |
@@ -107,4 +107,20 @@ public class InspectionFileHandleVo { | |||
*/ | |||
private String inspectionCode; | |||
/** | |||
* 审核结果 0未审核 1审核通过 2审核未通过 | |||
*/ | |||
private Integer audit; | |||
/** | |||
* 审核意见 | |||
*/ | |||
private String auditView; | |||
/** | |||
* 审核时间 | |||
*/ | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8") | |||
private Date auditTime; | |||
} |
@@ -1,7 +1,10 @@ | |||
package com.tuoheng.miniprogram.vo; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import java.util.Date; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/11/28 | |||
@@ -54,6 +57,22 @@ public class SeeQuestionVo { | |||
*/ | |||
private String handlerUser; | |||
/** | |||
* 审核结果 0未审核 1审核通过 2审核未通过 | |||
*/ | |||
private Integer audit; | |||
/** | |||
* 审核意见 | |||
*/ | |||
private String auditView; | |||
/** | |||
* 审核时间 | |||
*/ | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8") | |||
private Date auditTime; | |||
} |
@@ -15,7 +15,10 @@ | |||
tfh.handler_image as handlerImage, | |||
tfh.handler_result as handlerResult, | |||
tfh.handler_time as handlerTime, | |||
tfh.handler_user as handlerUser | |||
tfh.handler_user as handlerUser, | |||
tfh.audit as audit, | |||
tfh.audit_view as auditView, | |||
tfh.audit_time as auditTime | |||
from | |||
th_inspection_file as tf | |||
left join th_inspection_file_handle AS tfh on tf.id = tfh.inspection_file_id |