| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.oa.OAProcess; |
| | | import com.ruoyi.common.oa.OAProperty; |
| | | import com.ruoyi.common.oa.OAResult; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | |
| | | |
| | | @Resource |
| | | private CommonOaService commonOaService; |
| | | @Resource |
| | | private OAProperty oaProperty; |
| | | |
| | | @Resource |
| | | private InsUnqualifiedHandlerFileService insUnqualifiedHandlerFileService; |
| | | @Resource |
| | |
| | | |
| | | @Override |
| | | public Result pushOA(PushOADto pushOADto) { |
| | | //获取不合格处理记录 |
| | | UnqualifiedHandlerVO vo = baseMapper.findById(pushOADto.getHandlerId()); |
| | | |
| | | if (vo.getRequestId() != null) { |
| | | throw new ErrorException("该不合格处理已提交过OA"); |
| | | } |
| | | |
| | | //提交oa相关字段赋值 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | Map<String, String> mainFields = new HashMap<>(); |
| | | mainFields.put("bh", vo.getNo());//编号 |
| | | mainFields.put("gysmc", vo.getSupplierName());//供应商名称 |
| | | mainFields.put("wlmc", vo.getMaterialName());//物料名称 |
| | | mainFields.put("scpc", vo.getProductionBatch());//生产批次 |
| | | mainFields.put("dhsl", vo.getCargoQuantity());//到货数量 |
| | | mainFields.put("ggxh", vo.getSpecsModels());//规格型号 |
| | | mainFields.put("bjrq", vo.getInspectTime().format(formatter));//报检日期 |
| | | mainFields.put("fkr", SecurityUtils.getUsername());//反馈人 |
| | | mainFields.put("fkrq", vo.getFeedbackTime().format(formatter));//反馈日期 |
| | | mainFields.put("fl", vo.getClassification());//分类 |
| | | mainFields.put("bhggs", vo.getOffGradeAscription());//不合格归属 |
| | | mainFields.put("bhgqkms", vo.getUnqualifiedDesc());//不合格情况描述 |
| | | |
| | | //查询附件 |
| | | List<InsUnqualifiedHandlerFile> handlerFiles = insUnqualifiedHandlerFileService.list(Wrappers.<InsUnqualifiedHandlerFile>lambdaQuery() |
| | | .eq(InsUnqualifiedHandlerFile::getUnqualifiedId, vo.getHandlerId())); |
| | | if (CollectionUtils.isNotEmpty(handlerFiles)) { |
| | | StringBuilder fileUrl = new StringBuilder(); |
| | | for (int i = 0; i < handlerFiles.size(); i++) { |
| | | String path = handlerFiles.get(i).getType().equals(1) ? "/lims/img/" : "/lims/word/"; |
| | | if (i == handlerFiles.size() - 1) { |
| | | fileUrl.append("<a href='" + oaProperty.getProdIp()).append(path + handlerFiles.get(i).getFileUrl() |
| | | + "'target='_blank'>" + handlerFiles.get(i).getFileName() + "</a>"); |
| | | } else { |
| | | fileUrl.append("<a href='" + oaProperty.getProdIp()).append(path + handlerFiles.get(i).getFileUrl() |
| | | + "'target='_blank'>" + handlerFiles.get(i).getFileName() + "</a>").append("<br/>"); |
| | | } |
| | | } |
| | | mainFields.put("xlimsfj", fileUrl.toString()); |
| | | } |
| | | //流程标题 |
| | | String requestName = vo.getHeadline(); |
| | | //发起OA |
| | | boolean oa = false; |
| | | try { |
| | | log.info("发起不合格处理OA审核流程"); |
| | | String unqualifiedProcessId = oaProperty.getUnqualifiedProcessId(); |
| | | OAResult oaResult = OAProcess.start(mainFields, requestName, unqualifiedProcessId,SecurityUtils.getUsername()); |
| | | log.info("不合格处理OA审核流程结束,返回结果->{}" + oaResult); |
| | | oa = oaResult.success(); |
| | | if (oa) { |
| | | String addWorkflowResult = oaResult.getAddWorkflowResult(); |
| | | baseMapper.update(null, new LambdaUpdateWrapper<InsUnqualifiedHandler>() |
| | | .set(InsUnqualifiedHandler::getRequestId, addWorkflowResult) |
| | | .set(InsUnqualifiedHandler::getOaState, 2) |
| | | .eq(InsUnqualifiedHandler::getId, pushOADto.getHandlerId())); |
| | | } else { |
| | | return Result.fail("提交oa失败: " + oaResult.getErrorMsg()); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return Result.success(); |
| | | } |
| | | |