| | |
| | | // 判断是否有不合格, 有不合格不能移库 |
| | | // todo: ifs移库 |
| | | insReportService.isRawMaterial(order); |
| | | |
| | | // 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) { |
| | | // // 发送通知, 并且添加数据 |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // } |
| | | // } |
| | | // } |
| | | // }); |
| | | |
| | | |
| | | } else { |
| | | // 修改成品状态 |
| | | // 判断是否有不合格 |
| | |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * *****计算偏差**** |
| | | * @param data |
| | | * @param targetStr |
| | | * @return |
| | | */ |
| | | public static double isDeviationOverTenPercent(List<String> data, String targetStr) { |
| | | if (data.isEmpty()) { |
| | | return 0; |
| | | } |
| | | List<Double> doubleData = data.stream() |
| | | .map(Double::parseDouble) |
| | | .collect(Collectors.toList()); |
| | | double sum = doubleData.stream().mapToDouble(Double::doubleValue).sum(); |
| | | double average = sum / doubleData.size(); |
| | | |
| | | double target = Double.parseDouble(targetStr); |
| | | double deviationPercent = Math.abs(target - average) / average * 100; |
| | | |
| | | return deviationPercent; |
| | | } |
| | | |
| | | /** |
| | | * ******原始记录模板复制***** |
| | | * @param orderId |
| | | * @param ids |
| | | */ |
| | | private void templateCopy(Integer orderId, List<Integer> ids) { |
| | | // 删除原本模板 |
| | | insOrderStandardTemplateService.remove(Wrappers.<InsOrderStandardTemplate>lambdaQuery() |
| | |
| | | |
| | | ConfigureBuilder builder = Configure.builder(); |
| | | builder.useSpringEL(true); |
| | | // 获取当前时间 |
| | | LocalDate currentDate = LocalDate.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | String formattedDate = currentDate.format(formatter); |
| | | |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/small-report-template.docx"); |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render( |