maven
2 天以前 4989e77189bbed2322c16ed38e60e4a960ef2fca
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -968,7 +968,7 @@
            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;
                }
@@ -977,8 +977,10 @@
                        .collect(Collectors.toList());
                double deviation = isDeviationOverTenPercent(laseValueList, insProduct.getLastValue());
                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()));
@@ -1006,7 +1008,8 @@
                        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);
@@ -1069,6 +1072,24 @@
    }
    /**
     * *****计算偏差****
     * @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