|  |  | 
 |  |  |             if (insProduct.getInspectionValueType().equals("1") && insProduct.getInsResult().equals(1)) { | 
 |  |  |                 List<InsProductDeviationWarningDetail> insProductAnalysisDtoList = insProductMapper.selectAnalysis(insProduct, ifsInventoryQuantity.getSupplierName()); | 
 |  |  |  | 
 |  |  |                 if (insProductAnalysisDtoList.size() < 10) { | 
 |  |  |                 if (CollectionUtils.isEmpty(insProductAnalysisDtoList)) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  | 
 |  |  |                         .collect(Collectors.toList()); | 
 |  |  |  | 
 |  |  |                 double deviation = isDeviationOverTenPercent(laseValueList, insProduct.getLastValue()); | 
 |  |  |                 // 判断要求值是否偏差超过10% | 
 |  |  |                 double asked = isDeviationOverTenPercentByAsked(insProduct.getAsk(), insProduct.getLastValue()); | 
 |  |  |                 // 判断偏差是否大于10 | 
 |  |  |                 if (deviation > 10) { | 
 |  |  |                 if (deviation > 10 || asked > 10) { | 
 |  |  |                     // 判断之前是否添加过, 添加过不需要添加 | 
 |  |  |                     long count = insProductDeviationWarningService.count(Wrappers.<InsProductDeviationWarning>lambdaQuery() | 
 |  |  |                             .eq(InsProductDeviationWarning::getInsProductId, insProduct.getId())); | 
 |  |  | 
 |  |  |                         deviationWarningDetail.setSupplierName(ifsInventoryQuantity.getSupplierName()); | 
 |  |  |                         deviationWarningDetail.setTestValue(insProduct.getLastValue()); | 
 |  |  |                         deviationWarningDetail.setDetectionTime(insProduct.getCreateTime()); | 
 |  |  |                         deviationWarningDetail.setIsIssue(1); | 
 |  |  |                         deviationWarningDetail.setIsIssue(deviation > 10 ? 1 : 0); | 
 |  |  |                         deviationWarningDetail.setIsIssueAsked(asked > 10 ? 1 : 0); | 
 |  |  |  | 
 |  |  |                         insProductAnalysisDtoList.add(deviationWarningDetail); | 
 |  |  |  | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * *****计算偏差(要求值)**** | 
 |  |  |      * @param asked | 
 |  |  |      * @param targetStr | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public static double isDeviationOverTenPercentByAsked(String asked, String targetStr) { | 
 |  |  |         if(!isNumeric(asked)) return 0; | 
 |  |  |         double average = Double.parseDouble(asked); | 
 |  |  |         double target = Double.parseDouble(targetStr); | 
 |  |  |         double deviationPercent = Math.abs(target - average) / average * 100; | 
 |  |  |  | 
 |  |  |         // 保留两位小数 | 
 |  |  |         DecimalFormat df = new DecimalFormat("#.00"); | 
 |  |  |         String formatted = df.format(deviationPercent); | 
 |  |  |         return Double.parseDouble(formatted); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * ******原始记录模板复制***** | 
 |  |  |      * @param orderId | 
 |  |  |      * @param ids |