| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.beanutils.BeanUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | |
| | | import org.jeecg.modules.eam.constant.OrderCreationMethodEnum; |
| | | import org.jeecg.modules.eam.constant.WeekMaintenanceStatusEnum; |
| | | import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder; |
| | | import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrderDetail; |
| | | import org.jeecg.modules.eam.request.EamWeekMaintenanceBatchApprovalRequest; |
| | | import org.jeecg.modules.eam.request.EamWeekMaintenanceQuery; |
| | | import org.jeecg.modules.eam.request.EamWeekMaintenanceRequest; |
| | | import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderDetailService; |
| | | import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderService; |
| | | import org.jeecg.modules.flowable.domain.vo.WorkTaskDataVo; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | private ObjectMapper objectMapper; |
| | | @Autowired |
| | | private TranslateDictTextUtils translateDictTextUtils; |
| | | @Autowired |
| | | private IEamWeekMaintenanceOrderDetailService weekMaintenanceOrderDetailService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | |
| | | } |
| | | return Result.ok("操作成功!"); |
| | | } |
| | | |
| | | @ApiOperation(value = "周保工单-批量审批流程", notes = "周保工单-批量审批流程") |
| | | @PostMapping("/batchApproval") |
| | | public Result<?> batchApproval(@RequestBody EamWeekMaintenanceBatchApprovalRequest request) { |
| | | if (request == null || CollectionUtil.isEmpty(request.getTastList())) { |
| | | return Result.error("没有需要审批的数据!"); |
| | | } |
| | | int n = 0; |
| | | StringBuilder errorMsg = new StringBuilder(); |
| | | List<WorkTaskDataVo> tastList = request.getTastList(); |
| | | for (WorkTaskDataVo workTaskDataVo : tastList) { |
| | | EamWeekMaintenanceRequest orderRequest = new EamWeekMaintenanceRequest(); |
| | | EamWeekMaintenanceOrder order = eamWeekMaintenanceOrderService.getById(workTaskDataVo.getDataId()); |
| | | if (order == null) { |
| | | errorMsg.append("工单ID:"); |
| | | errorMsg.append(workTaskDataVo.getDataId()); |
| | | errorMsg.append(",不存在或已被删除!\r\n"); |
| | | continue; |
| | | } |
| | | if (!(WeekMaintenanceStatusEnum.WAIT_CONFIRM.name().equals(order.getMaintenanceStatus()) |
| | | || WeekMaintenanceStatusEnum.WAIT_INITIAL_ACCEPTANCE.name().equals(order.getMaintenanceStatus()) |
| | | || WeekMaintenanceStatusEnum.WAIT_FINAL_ACCEPTANCE.name().equals(order.getMaintenanceStatus()))) { |
| | | errorMsg.append("工单号:"); |
| | | errorMsg.append(order.getOrderNum()); |
| | | errorMsg.append(",状态无法批量审批!\r\n"); |
| | | continue; |
| | | } |
| | | List<EamWeekMaintenanceOrderDetail> tableDetailList = weekMaintenanceOrderDetailService.queryListByOrderId(order.getId()); |
| | | try { |
| | | BeanUtils.copyProperties(orderRequest, order); |
| | | //审批信息 |
| | | if (WeekMaintenanceStatusEnum.WAIT_CONFIRM.name().equals(order.getMaintenanceStatus())) { |
| | | orderRequest.setConfirmComment(request.getConfirmComment()); |
| | | orderRequest.setConfirmDealType(request.getConfirmDealType()); |
| | | } else if (WeekMaintenanceStatusEnum.WAIT_INITIAL_ACCEPTANCE.name().equals(order.getMaintenanceStatus())) { |
| | | orderRequest.setInitialAcceptanceComment(request.getInitialAcceptanceComment()); |
| | | orderRequest.setInitialAcceptanceFilesResult(request.getInitialAcceptanceFilesResult()); |
| | | } else if (WeekMaintenanceStatusEnum.WAIT_FINAL_ACCEPTANCE.name().equals(order.getMaintenanceStatus())) { |
| | | orderRequest.setFinalAcceptanceComment(request.getFinalAcceptanceComment()); |
| | | orderRequest.setFinalAcceptanceFilesResult(request.getFinalAcceptanceFilesResult()); |
| | | } |
| | | //任务信息 |
| | | orderRequest.setDataId(workTaskDataVo.getDataId()); |
| | | orderRequest.setTaskId(workTaskDataVo.getId()); |
| | | orderRequest.setUserId(workTaskDataVo.getAssignee()); |
| | | orderRequest.setInstanceId(workTaskDataVo.getProcInstId()); |
| | | orderRequest.setValues(workTaskDataVo.getVariables()); |
| | | orderRequest.setTableDetailList(tableDetailList); |
| | | EamWeekMaintenanceOrder result = eamWeekMaintenanceOrderService.approval(orderRequest); |
| | | if (result == null) { |
| | | errorMsg.append("工单号:"); |
| | | errorMsg.append(order.getOrderNum()); |
| | | errorMsg.append(",审批失败!\r\n"); |
| | | continue; |
| | | } |
| | | n++; |
| | | |
| | | } catch (Exception e) { |
| | | errorMsg.append("工单号:"); |
| | | errorMsg.append(order.getOrderNum()); |
| | | errorMsg.append(",审批失败,错误原因:"); |
| | | errorMsg.append(e.getMessage() + "\r\n"); |
| | | } |
| | | |
| | | } |
| | | if (n > 0) { |
| | | String message = "成功审批通过" + n + "条记录!\r\n" + errorMsg; |
| | | return Result.OK(message); |
| | | } |
| | | return Result.error(errorMsg.toString()); |
| | | } |
| | | } |