| | |
| | | private ISysDictTypeService iSysDictTypeService; |
| | | @Resource |
| | | private InsOrderRatesService insOrderRatesService; |
| | | @Resource |
| | | private InsProductDeviationWarningService insProductDeviationWarningService; |
| | | @Resource |
| | | private InsProductDeviationWarningDetailService insProductDeviationWarningDetailService; |
| | | |
| | | |
| | | @Override |
| | | public IPage<InsOrderPlanVO> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) { |
| | |
| | | |
| | | // 16 判断当前样品是否为原材料, 原材料需要进行数据分析, 判断之前10条数据同一个供应商, 同一个检验项的偏差是否超过10% |
| | | // 查询ifs信息获取获取前10个供应商一样的, 检验项一样信息 |
| | | // threadPoolTaskExecutor.execute(() -> { |
| | | // |
| | | // for (InsProduct insProduct : productList) { |
| | | // // todo: 暂时判断是否是老化 |
| | | // if (insProduct.getInspectionItem().contains("老化")) { |
| | | // List<InsProductAnalysisDto> insProductAnalysisDtoList = insProductMapper.selectAnalysis(insProduct, ifsInventoryQuantity.getSupplierName()); |
| | | // |
| | | // if (insProductAnalysisDtoList.size() < 10) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // // 判断当前检测项是否偏差超过10% |
| | | // List<String> laseValueList = insProductAnalysisDtoList.stream().map(InsProductAnalysisDto::getLastValue) |
| | | // .collect(Collectors.toList()); |
| | | // |
| | | // double deviation = isDeviationOverTenPercent(laseValueList, insProduct.getLastValue()); |
| | | // // 判断偏差是否大于10 |
| | | // if (deviation > 10) { |
| | | // // 发送通知, 并且添加数据 |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // } |
| | | // } |
| | | // } |
| | | // }); |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | // 添加分析数据 |
| | | addAnalysis(productList, ifsInventoryQuantity, order); |
| | | }); |
| | | |
| | | |
| | | } else { |
| | |
| | | } |
| | | |
| | | /** |
| | | * *****添加分析数据****** |
| | | * @param productList |
| | | * @param ifsInventoryQuantity |
| | | * @param order |
| | | */ |
| | | private void addAnalysis(List<InsProduct> productList, IfsInventoryQuantity ifsInventoryQuantity, InsOrder order) { |
| | | for (InsProduct insProduct : productList) { |
| | | // todo: 暂时判断是否是老化 |
| | | if (insProduct.getInspectionItem().contains("老化")) { |
| | | List<InsProductDeviationWarningDetail> insProductAnalysisDtoList = insProductMapper.selectAnalysis(insProduct, ifsInventoryQuantity.getSupplierName()); |
| | | |
| | | if (insProductAnalysisDtoList.size() < 10) { |
| | | continue; |
| | | } |
| | | |
| | | // 判断当前检测项是否偏差超过10% |
| | | List<String> laseValueList = insProductAnalysisDtoList.stream().map(InsProductDeviationWarningDetail::getTestValue) |
| | | .collect(Collectors.toList()); |
| | | |
| | | double deviation = isDeviationOverTenPercent(laseValueList, insProduct.getLastValue()); |
| | | // 判断偏差是否大于10 |
| | | if (deviation > 10) { |
| | | // 判断之前是否添加过, 添加过不需要添加 |
| | | long count = insProductDeviationWarningService.count(Wrappers.<InsProductDeviationWarning>lambdaQuery() |
| | | .eq(InsProductDeviationWarning::getInsProductId, insProduct.getId())); |
| | | if (count == 0L) { |
| | | // 发送通知, 并且添加数据 |
| | | // 添加主表信息 |
| | | InsProductDeviationWarning deviationWarning = new InsProductDeviationWarning(); |
| | | deviationWarning.setInsOrderId(order.getId()); |
| | | deviationWarning.setInsSampleId(insProduct.getInsSampleId()); |
| | | deviationWarning.setInsProductId(insProduct.getId()); |
| | | deviationWarning.setEntrustCode(order.getEntrustCode()); |
| | | deviationWarning.setSampleCode(insProduct.getSampleCode()); |
| | | deviationWarning.setSupplierName(ifsInventoryQuantity.getSupplierName()); |
| | | deviationWarning.setDeviationValue(Double.toString(deviation)); |
| | | deviationWarning.setDetectionTime(insProduct.getUpdateTime()); |
| | | insProductDeviationWarningService.save(deviationWarning); |
| | | |
| | | // 添加详情数据 |
| | | InsProductDeviationWarningDetail deviationWarningDetail = new InsProductDeviationWarningDetail(); |
| | | deviationWarningDetail.setInsOrderId(order.getId()); |
| | | deviationWarningDetail.setInsSampleId(insProduct.getInsSampleId()); |
| | | deviationWarningDetail.setInsProductId(insProduct.getId()); |
| | | deviationWarningDetail.setEntrustCode(order.getEntrustCode()); |
| | | deviationWarningDetail.setSampleCode(insProduct.getSampleCode()); |
| | | deviationWarningDetail.setSupplierName(ifsInventoryQuantity.getSupplierName()); |
| | | deviationWarningDetail.setTestValue(insProduct.getLastValue()); |
| | | deviationWarningDetail.setIsIssue(1); |
| | | |
| | | insProductAnalysisDtoList.add(deviationWarningDetail); |
| | | |
| | | // 添加id |
| | | for (InsProductDeviationWarningDetail warningDetail : insProductAnalysisDtoList) { |
| | | warningDetail.setDeviationWarningId(deviationWarning.getDeviationWarningId()); |
| | | } |
| | | |
| | | insProductDeviationWarningDetailService.saveBatch(insProductAnalysisDtoList); |
| | | |
| | | |
| | | // String message = ""; |
| | | // message += "检验任务复核通知"; |
| | | // message += "\n提交人: " + userName; |
| | | // message += "\n委托编号: " + order.getEntrustCode(); |
| | | // message += "\n样品名称: " + insSample.getModel(); |
| | | // message += "\n规格型号: " + order.getPartDetail(); |
| | | // if (ifsInventoryQuantity != null) { |
| | | // message += "\n批次号: " + ifsInventoryQuantity.getUpdateBatchNo(); |
| | | // } |
| | | // //发送企业微信消息通知 提交复核 |
| | | // try { |
| | | // WxCpUtils.inform(sendUserAccount, message, null); |
| | | // } catch (Exception e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * *****计算偏差**** |
| | | * @param data |
| | | * @param targetStr |