maven
3 天以前 b3654b855129db1b8284606e34af8242120e32e1
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -502,18 +502,16 @@
                // 添加工时
                // 判断是否只是参与计算值, 参与计算值实际没有填写
                InsProduct finalInsProduct = insProductMapper.selectById(product.getId());
                InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId());
                if (StringUtils.isNotBlank(newResult.getInsValue()) && !newResult.getInsValue().equals("[]")) {
                    threadPoolTaskExecutor.execute(() -> {
                        InsProduct finalInsProduct = insProductMapper.selectById(product.getId());
                        InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId());
                        this.addAuxiliary(userId, finalInsProduct, insOrder);
                    });
                } else {
                    // 判断是否是没有检验值的内容
                    if (saveInsContextDto.getIsNoTestValue() != null && saveInsContextDto.getIsNoTestValue() == 1) {
                        threadPoolTaskExecutor.execute(() -> {
                            InsProduct finalInsProduct = insProductMapper.selectById(product.getId());
                            InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId());
                            this.addAuxiliary(userId, finalInsProduct, insOrder);
                        });
                    }
@@ -968,7 +966,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 +975,10 @@
                        .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()));
@@ -1006,7 +1006,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 +1070,24 @@
    }
    /**
     * *****计算偏差(要求值)****
     * @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