From 4989e77189bbed2322c16ed38e60e4a960ef2fca Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期四, 24 七月 2025 15:03:44 +0800
Subject: [PATCH] yys 添加分析数据算法修改,表新增字段
---
inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsProductDeviationWarningDetail.java | 5 ++++-
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java | 27 ++++++++++++++++++++++++---
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsProductDeviationWarningDetail.java b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsProductDeviationWarningDetail.java
index 5d33071..ceb6636 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsProductDeviationWarningDetail.java
+++ b/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;
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
index 8d29eee..62a2daa 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
+++ b/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
--
Gitblit v1.9.3