maven
2 天以前 4989e77189bbed2322c16ed38e60e4a960ef2fca
yys  添加分析数据算法修改,表新增字段
已修改2个文件
32 ■■■■ 文件已修改
inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsProductDeviationWarningDetail.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsProductDeviationWarningDetail.java
@@ -56,9 +56,12 @@
    @ApiModelProperty("检测时间")
    private LocalDateTime detectionTime;
    @ApiModelProperty("是否是问题数据 0: 否, 1: 是")
    @ApiModelProperty("是否是问题数据 0: 否, 1: 是(平均值)")
    private Integer isIssue;
    @ApiModelProperty("是否是问题数据 0: 否, 1: 是(要求值)")
    private Integer isIssueAsked;
    @TableField(fill = FieldFill.INSERT)
    private String createUser;
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