| | |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.parser.Feature; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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.common.util.TranslateDictTextUtils; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | 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.*; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | /** |
| | | * @Description: 周保工单 |
| | |
| | | private IEamWeekMaintenanceOrderService eamWeekMaintenanceOrderService; |
| | | @Autowired |
| | | private ISysBusinessCodeRuleService businessCodeRuleService; |
| | | @Autowired |
| | | private ObjectMapper objectMapper; |
| | | @Autowired |
| | | private TranslateDictTextUtils translateDictTextUtils; |
| | | @Autowired |
| | | private IEamWeekMaintenanceOrderDetailService weekMaintenanceOrderDetailService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | |
| | | } |
| | | String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.WEEK_MAINTENANCE_CODE_RULE); |
| | | request.setOrderNum(codeSeq); |
| | | request.setCreationMethod(OrderCreationMethodEnum.MANUAL.name()); |
| | | boolean b = eamWeekMaintenanceOrderService.addWeekMaintenance(request); |
| | | if (!b) { |
| | | return Result.error("添加失败!"); |
| | |
| | | @DeleteMapping(value = "/abolish") |
| | | public Result<?> abolish(@RequestParam(name = "id", required = true) String id) { |
| | | EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderService.getById(id); |
| | | if(entity == null) { |
| | | if (entity == null) { |
| | | return Result.error("要作废的数据不存在,请刷新重试!"); |
| | | } |
| | | if(!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | if (!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | return Result.error("该状态的数据不允许进行作废!"); |
| | | } |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.ABOLISH.name()); |
| | |
| | | @GetMapping(value = "/collect") |
| | | public Result<?> collect(@RequestParam(name = "id", required = true) String id) { |
| | | boolean b = eamWeekMaintenanceOrderService.collect(id); |
| | | if(!b) { |
| | | if (!b) { |
| | | Result.OK("领取失败!"); |
| | | } |
| | | return Result.OK("领取成功!"); |
| | |
| | | @DeleteMapping(value = "/abolishBatch") |
| | | public Result<?> abolishBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | AtomicInteger i = new AtomicInteger(); |
| | | list.forEach(id -> { |
| | | EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderService.getById(id); |
| | | if (entity != null && WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.ABOLISH.name()); |
| | | eamWeekMaintenanceOrderService.updateById(entity); |
| | | i.getAndIncrement(); |
| | | } |
| | | }); |
| | | return Result.OK("批量作废成功!"); |
| | | return Result.OK("批量作废成功 " + i.get() + " 条工单!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id批量领取 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "周保工单-批量领取") |
| | | @ApiOperation(value = "周保工单-批量领取", notes = "周保工单-批量领取") |
| | | @DeleteMapping(value = "/collectBatch") |
| | | public Result<?> collectBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | AtomicInteger i = new AtomicInteger(); |
| | | list.forEach(id -> { |
| | | EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderService.getById(id); |
| | | if (entity != null && WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | boolean b = eamWeekMaintenanceOrderService.collect(id); |
| | | if (b) { |
| | | i.getAndIncrement(); |
| | | } |
| | | } |
| | | }); |
| | | return Result.OK("批量领取成功 " + i.get() + " 条工单!"); |
| | | } |
| | | |
| | | /** |
| | |
| | | @GetMapping(value = "/queryById") |
| | | public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | EamWeekMaintenanceOrder eamWeekMaintenanceOrder = eamWeekMaintenanceOrderService.getById(id); |
| | | return Result.OK(eamWeekMaintenanceOrder); |
| | | if (eamWeekMaintenanceOrder == null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | try { |
| | | String json = objectMapper.writeValueAsString(eamWeekMaintenanceOrder); |
| | | JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); |
| | | translateDictTextUtils.translateField("equipmentId", eamWeekMaintenanceOrder.getEquipmentId(), item, "eam_equipment,equipment_code,id"); |
| | | translateDictTextUtils.translateField("standardId", eamWeekMaintenanceOrder.getStandardId(), item, "eam_maintenance_standard,standard_name,id"); |
| | | translateDictTextUtils.translateField("operator", eamWeekMaintenanceOrder.getOperator(), item, "sys_user,realname,username"); |
| | | translateDictTextUtils.translateField("operatorPhone", eamWeekMaintenanceOrder.getOperator(), item, "sys_user,phone,username"); |
| | | translateDictTextUtils.translateField("creationMethod", eamWeekMaintenanceOrder.getCreationMethod(), item, "order_creation_method"); |
| | | translateDictTextUtils.translateField("maintenanceStatus", eamWeekMaintenanceOrder.getMaintenanceStatus(), item, "week_maintenance_status"); |
| | | translateDictTextUtils.translateField("confirmUser", eamWeekMaintenanceOrder.getConfirmUser(), item, "sys_user,realname,username"); |
| | | translateDictTextUtils.translateField("confirmDealType", eamWeekMaintenanceOrder.getConfirmDealType(), item, "approved_rejected"); |
| | | translateDictTextUtils.translateField("initialAcceptanceUser", eamWeekMaintenanceOrder.getInitialAcceptanceUser(), item, "sys_user,realname,username"); |
| | | translateDictTextUtils.translateField("finalAcceptanceUser", eamWeekMaintenanceOrder.getFinalAcceptanceUser(), item, "sys_user,realname,username"); |
| | | translateDictTextUtils.translateField("installationPosition", eamWeekMaintenanceOrder.getEquipmentId(), item, "eam_equipment,installation_position,id"); |
| | | return Result.OK(item); |
| | | } catch (JsonProcessingException e) { |
| | | return Result.error("数据转译失败!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 我的待办,审批动作 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | |
| | | if (StrUtil.isBlank(request.getTaskId()) || StrUtil.isBlank(request.getDataId()) || StrUtil.isBlank(request.getInstanceId())) { |
| | | return Result.error("审批任务错误或不存在!"); |
| | | } |
| | | boolean b = eamWeekMaintenanceOrderService.approval(request); |
| | | if(!b) { |
| | | EamWeekMaintenanceOrder b = eamWeekMaintenanceOrderService.approval(request); |
| | | if (b == null) { |
| | | return Result.error("操作失败!"); |
| | | } |
| | | return Result.ok("操作成功!"); |
| | | } |
| | | |
| | | @ApiOperation(value = "周保工单-批量审批流程", notes = "周保工单-批量审批流程") |
| | | @PostMapping("/batchApproval") |
| | | public Result<?> batchApproval(@RequestBody EamWeekMaintenanceBatchApprovalRequest request) { |
| | | if (request == null || CollectionUtil.isEmpty(request.getTaskList())) { |
| | | return Result.error("没有需要审批的数据!"); |
| | | } |
| | | int n = 0; |
| | | StringBuilder errorMsg = new StringBuilder(); |
| | | List<WorkTaskDataVo> tastList = request.getTaskList(); |
| | | 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(",不存在或已被删除!\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(",状态无法批量审批!\n"); |
| | | continue; |
| | | } |
| | | List<EamWeekMaintenanceOrderDetail> tableDetailList = weekMaintenanceOrderDetailService.queryListByOrderId(order.getId()); |
| | | try { |
| | | orderRequest.setId(order.getId()); |
| | | orderRequest.setEquipmentId(order.getEquipmentId()); |
| | | //审批信息 |
| | | 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(",审批失败!\n"); |
| | | continue; |
| | | } |
| | | n++; |
| | | |
| | | } catch (Exception e) { |
| | | errorMsg.append("工单号:"); |
| | | errorMsg.append(order.getOrderNum()); |
| | | errorMsg.append(",审批失败,错误原因:"); |
| | | errorMsg.append(e.getMessage() + "\n"); |
| | | } |
| | | |
| | | } |
| | | if (n > 0) { |
| | | String message = "成功审批通过" + n + "条记录!\n" + errorMsg; |
| | | return Result.OK(message); |
| | | } |
| | | return Result.error(errorMsg.toString()); |
| | | } |
| | | } |