diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/controller/WrkInfoAuditController.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/controller/WrkInfoAuditController.java index a2264d6..6727710 100644 --- a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/controller/WrkInfoAuditController.java +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/controller/WrkInfoAuditController.java @@ -32,9 +32,8 @@ public class WrkInfoAuditController { @PostMapping ("/audit/{wrkId}") @RequiresPermissions("wrk:info:audit") @SysLog(value = "工单审核", businessType = BusinessType.AUDIT) - public AjaxResult audit(@Validated @RequestBody AuditDTO audit, - @PathVariable Long wrkId) { - wrkInfoService.audit(audit, wrkId); + public AjaxResult audit(@Validated @RequestBody AuditDTO audit) { + wrkInfoService.audit(audit); return AjaxResult.success(); } } diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/WrkInfoService.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/WrkInfoService.java index cef7729..27adaa6 100644 --- a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/WrkInfoService.java +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/WrkInfoService.java @@ -34,5 +34,5 @@ public interface WrkInfoService extends IService { void submit(WrkInfoDTO info); - void audit(AuditDTO audit, Long wrkId); + void audit(AuditDTO audit); } diff --git a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkInfoServiceImpl.java b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkInfoServiceImpl.java index cb3aed6..faaa4eb 100644 --- a/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkInfoServiceImpl.java +++ b/chushang-modules/chushang-module-inspection/inspection-service/src/main/java/com/chushang/inspection/work/service/impl/WrkInfoServiceImpl.java @@ -70,9 +70,9 @@ import java.util.*; import java.util.stream.Collectors; /** - * @auther: zhao - * @date: 2024/6/26 17:13 - */ + * @auther: zhao + * @date: 2024/6/26 17:13 + */ @Service @RequiredArgsConstructor public class WrkInfoServiceImpl extends ServiceImpl implements WrkInfoService { @@ -107,7 +107,6 @@ public class WrkInfoServiceImpl extends ServiceImpl impl private boolean enable; - @Override public PageResult queryDispatchPage(WrkInfoQuery query) { CommonParam commonParam = CommonParam.buildPageRequest(); @@ -162,7 +161,7 @@ public class WrkInfoServiceImpl extends ServiceImpl impl List imgList = wrkImgService.list(new LambdaQueryWrapper().eq(WrkImg::getImgId, wrkId)); infoDetail.setInfoImg(BeanUtil.copyToList(imgList, WrkImgVO.class)); // 内蒙古 五统一商户 - if (terminal.getTerminalId() != null && "建行内蒙古".equals(TaskConfigUtils.getConfig(wrkInfo.getTaskId()).getName())){ + if (terminal.getTerminalId() != null && "建行内蒙古".equals(TaskConfigUtils.getConfig(wrkInfo.getTaskId()).getName())) { FiveStore fiveStore = fiveStoreService.getOne(new LambdaQueryWrapper() .eq(FiveStore::getTerminalId, terminal.getTerminalId()).last(Operator.LIMIT_ONE.getCharacter())); infoDetail.setFiveStoreDetails(BeanUtil.copyProperties(fiveStore, FiveStoreVO.class)); @@ -185,7 +184,7 @@ public class WrkInfoServiceImpl extends ServiceImpl impl Integer method = TaskConfigUtils.dispatchMethod(query.getTaskId()); - this.saveData(dispatch,query,method); + this.saveData(dispatch, query, method); if (!TaskConfigUtils.isRepeat(query.getTaskId())) { terminalService.updateOccupy(dispatch.stream().map(DispatchDTO::getTerminalId).collect(Collectors.toList()), 1); @@ -214,7 +213,7 @@ public class WrkInfoServiceImpl extends ServiceImpl impl .remark("导出巡检单信息") .createBy(SecurityUtils.getUsername()) .build(), SecurityConstants.INNER); - if (task.isSuccess() && task.getData() != null){ + if (task.isSuccess() && task.getData() != null) { return task.getData(); } throw new ResultException("创建后台任务异常"); @@ -222,6 +221,7 @@ public class WrkInfoServiceImpl extends ServiceImpl impl /** * 提交工单 + * * @param info 工单, 商户信息 */ @Override @@ -345,65 +345,68 @@ public class WrkInfoServiceImpl extends ServiceImpl impl * 工单审核 * * @param audit 审核所需 - * 工单共计有7个状态, - * 1. 已分配 - * 2. 待初审 - * 3. 待复审 - * 4. 复审通过 - * 5. 初审驳回 - * 6. 复审驳回 - * 7. 初审通过 - * 8. 默认审核通过 - * todo 当任务为只需要初审时, 点击初审通过, 则其状态由2 变为 7 - * todo 当任务需要复审时, 点击初审通过, 其状态由2 变为3 - * 当任务不需要审核时, 点击提交, 工单状态, 由1 变为8 - * @param wrkId 工单id + * 工单共计有7个状态, + * 1. 已分配 + * 2. 审核中 + * 3. 初审通过-待复审 + * 4. 复审通过 + * 5. 初审驳回 + * 6. 复审驳回 + * 7. 初审通过 + * 8. 默认审核通过 + * todo 当任务为只需要初审时, 点击初审通过, 则其状态由2 变为 7 + * todo 当任务需要复审时, 点击初审通过, 其状态由2 变为3 + * 当任务不需要审核时, 点击提交, 工单状态, 由1 变为8 */ @Override - public void audit(AuditDTO audit, Long wrkId) { + public void audit(AuditDTO audit) { Integer auditStatus = audit.getAuditStatus(); // 1== auditStatus 代表审核通过, 否则代表审核拒绝 // 获取工单信息 - WrkInfo wrkInfo = getById(wrkId); + WrkInfo wrkInfo = getById(audit.getWrkId()); AssertUtil.invalidate(ObjectUtil.isEmpty(wrkInfo), "未找寻到对应工单"); // 审核方式 Integer reviewMethod = TaskConfigUtils.reviewMethod(wrkInfo.getTaskId()); - // 工单状态 - Integer wrkStatus = wrkInfo.getWrkStatus(); + // 工单状态(记录表使用) 1. 已分配 2. 审核中 3. 初审通过-待复审 4. 复审通过 5. 初审驳回 6. 复审驳回 7. 初审通过 8. 默认审核通过 + Integer wrkStatus = 0; // 当前 任务审核方式为 无需审核 AssertUtil.invalidate(1 == reviewMethod, "当前工单所属任务为无需审核"); - // 获取最后一条数据, 用于判断是否为同一个审核人 - WrkInfoAudit one = infoAuditService.getOne(new LambdaQueryWrapper() - .eq(WrkInfoAudit::getWrkId, wrkId) - .eq(WrkInfoAudit::getAuditState, 1) - .eq(WrkInfoAudit::getIsRecord, 0) - ); - Long userId; - if (ObjectUtil.isEmpty(one)){ - userId = -1L; - }else { - userId = one.getUserId(); - } - AssertUtil.invalidate(Objects.equals(userId, SecurityUtils.getUserId()), "两次审核通过不能为同一人"); - WrkInfo auditInfo = new WrkInfo(); - auditInfo.setWrkId(wrkId); - // 初审 - if (2 == reviewMethod){ - // 审核通过 - if (1 == auditStatus){ + WrkInfo auditInfo = new WrkInfo(); + auditInfo.setWrkId(audit.getWrkId()); + // 初审 + if (2 == reviewMethod) { + // 审核通过 + if (1 == auditStatus) { + wrkStatus = 7; } // 审核驳回 else { - + wrkStatus = 5; } - // 判断原先的状态 - auditInfo.setWrkStatus(wrkStatus == 2 ? 7 : 2); + } // 需复审 - else if (3 == reviewMethod){ - + else if (3 == reviewMethod) { + // 获取上一个审核 + List list = infoAuditService.list(new LambdaQueryWrapper() + .eq(WrkInfoAudit::getWrkId, audit.getWrkId()) + .eq(WrkInfoAudit::getAuditState, 7) + .eq(WrkInfoAudit::getIsRecord, 0) + ); + for (WrkInfoAudit wrkInfoAudit : list) { + AssertUtil.invalidate(wrkInfoAudit.getUserId().equals(SecurityUtils.getUserId()), "两次审核通过不能为同一人"); + } + // 审核通过 + if (1 == auditStatus) { + wrkStatus = 4; + } + // 审核驳回 + else { + wrkStatus = 6; + } } + auditInfo.setWrkStatus(wrkStatus); updateById(auditInfo); // 新增一条审核工单记录 @@ -413,14 +416,14 @@ public class WrkInfoServiceImpl extends ServiceImpl impl infoAuditService.update( infoAudit, new LambdaQueryWrapper() - .eq(WrkInfoAudit::getWrkId, wrkId) + .eq(WrkInfoAudit::getWrkId, audit.getWrkId()) ); // 同时新增一条记录 - infoAudit.setAuditState(auditStatus); + infoAudit.setAuditState(wrkStatus); infoAudit.setAuditTime(LocalDateTime.now()); infoAudit.setUserId(SecurityUtils.getUserId()); infoAudit.setUserName(SecurityUtils.getUsername()); - infoAudit.setWrkId(wrkId); + infoAudit.setWrkId(audit.getWrkId()); infoAudit.setDeptId(SecurityUtils.getDeptId()); infoAudit.setIsRecord(0); infoAudit.setRemark(audit.getRemark()); @@ -468,8 +471,8 @@ public class WrkInfoServiceImpl extends ServiceImpl impl // 审核拒绝之后 撤回 回归原来状态 // 撤机 1 机具状态 选择 银行撤机 2 工单类型选择 撤机 - if (DictUtils.getDictLabel("terminal_status", "银行撤机").equals(info.getTerminalStatus()+"") || - DictUtils.getDictLabel("wrk_type","撤机").equals(info.getWorkType() + "")) { + if (DictUtils.getDictLabel("terminal_status", "银行撤机").equals(info.getTerminalStatus() + "") || + DictUtils.getDictLabel("wrk_type", "撤机").equals(info.getWorkType() + "")) { //设置商户状态为异常 store.setState(Integer.valueOf(Objects.requireNonNull(DictUtils.getDictValue("mer_status", "异常")))); // 添加备注 @@ -480,11 +483,11 @@ public class WrkInfoServiceImpl extends ServiceImpl impl } // 异常 服务结果 选择 原址无此终端 和 原址无此商户 机具状态 选择 设备丢失 门店状态 选择 门店不存在 - else if (DictUtils.getDictLabel("terminal_status","设备丢失").equals(info.getTerminalStatus() + "") || + else if (DictUtils.getDictLabel("terminal_status", "设备丢失").equals(info.getTerminalStatus() + "") || // 门店状态 - DictUtils.getDictLabel("store_status","门店不存在").equals(info.getStoreStatus() + "") || + DictUtils.getDictLabel("store_status", "门店不存在").equals(info.getStoreStatus() + "") || // service_results 服务结果 - List.of(DictUtils.getDictLabel("service_results","原址无此终端"), DictUtils.getDictLabel("service_results","原址无此商户")) + List.of(DictUtils.getDictLabel("service_results", "原址无此终端"), DictUtils.getDictLabel("service_results", "原址无此商户")) .contains(info.getServiceResult() + "")) { // 设置商户状态为异常 //设置商户状态为异常 @@ -501,13 +504,13 @@ public class WrkInfoServiceImpl extends ServiceImpl impl /** * 此处调用后台执行 -- 下载word 工单 */ - public Result downInspectionTemplate(String params){ + public Result downInspectionTemplate(String params) { ReviewedQuery query = JSON.parseObject(params, ReviewedQuery.class); // 先查询是否存在对应的记录 WrapperUtils.buildSql(query); // 需要导出 工单信息 List wrkInfoDetailsVOS = baseMapper.listInsTemplate(query); - if (CollectionUtil.isEmpty(wrkInfoDetailsVOS)){ + if (CollectionUtil.isEmpty(wrkInfoDetailsVOS)) { return Result.failed("查询工单为空"); } // 工单map @@ -518,7 +521,7 @@ public class WrkInfoServiceImpl extends ServiceImpl impl Map> imgMap = imgList.stream().collect(Collectors.groupingBy(WrkImgVO::getWrkId)); List insConfigs = inspectionDataService.listInspections(wrkMap.keySet()); Map> configMap = insConfigs.stream().collect(Collectors.groupingBy(InspectionConfigVO::getWrkId)); - wrkMap.forEach((wrkId, infoDetail)->{ + wrkMap.forEach((wrkId, infoDetail) -> { List wrkImgs = imgMap.get(wrkId); infoDetail.setInfoImg(wrkImgs); List inspectionConfigVOS = configMap.get(wrkId); @@ -528,7 +531,7 @@ public class WrkInfoServiceImpl extends ServiceImpl impl return Result.ok(generatedInsFactory.generated(wrkMap)); } - private WrkInfo makeWrkInfoEntity(DispatchDTO dispatch,DispatchQuery query,Long userId,String userName,Integer workMethod){ + private WrkInfo makeWrkInfoEntity(DispatchDTO dispatch, DispatchQuery query, Long userId, String userName, Integer workMethod) { WrkInfo wrkInfo = new WrkInfo(); wrkInfo.setTaskId(query.getTaskId()); wrkInfo.setUserId(userId); @@ -547,18 +550,18 @@ public class WrkInfoServiceImpl extends ServiceImpl impl return wrkInfo; } - private void saveData(List dispatch,DispatchQuery query,Integer method){ + private void saveData(List dispatch, DispatchQuery query, Integer method) { // (0 业务员领取 1 只能派给负责项目的业务员 2 只能派给商户对应的客户经理 ) - if(method.equals(0)){ + if (method.equals(0)) { Set nickNames = StreamUtils.toSet(dispatch, DispatchDTO::getAccountManager); Result> result = userFeignService.getIdByNicknames(nickNames, SecurityConstants.INNER); - if(result.isSuccess()){ - Map userIds =result .getData(); - for (DispatchDTO dispatchDTO : dispatch){ + if (result.isSuccess()) { + Map userIds = result.getData(); + for (DispatchDTO dispatchDTO : dispatch) { Long userId = userIds.get(dispatchDTO.getAccountManager()); Assert.notNull(userId, "【{}】未设置商户", dispatchDTO.getAccountManager()); // 组装wrkinfo实体 - WrkInfo wrkInfo = makeWrkInfoEntity(dispatchDTO, query, userId,dispatchDTO.getAccountManager(),0); + WrkInfo wrkInfo = makeWrkInfoEntity(dispatchDTO, query, userId, dispatchDTO.getAccountManager(), 0); save(wrkInfo); //组装wrkterminal 实体 WrkInfoTerminalRecord wrkInfoTerminalRecord = BeanUtil.copyProperties(dispatchDTO, WrkInfoTerminalRecord.class); @@ -569,13 +572,12 @@ public class WrkInfoServiceImpl extends ServiceImpl impl wrkInfoStoreRecordService.save(wrkInfoStoreRecord); } } - } - else if(method.equals(1) || method.equals(2)){ + } else if (method.equals(1) || method.equals(2)) { Assert.notNull(query.getUserId(), "需要指定业务员"); Result result = userFeignService.getInfoById(query.getUserId(), SecurityConstants.INNER); - if(result.isSuccess()){ + if (result.isSuccess()) { String nickName = result.getData().getNickName(); - for (DispatchDTO dispatchDTO : dispatch){ + for (DispatchDTO dispatchDTO : dispatch) { Assert.notNull(nickName, "【{}】未设置商户", dispatchDTO.getAccountManager()); WrkInfo wrkInfo = makeWrkInfoEntity(dispatchDTO, query, query.getUserId(), dispatchDTO.getAccountManager(), method); // 工单信息