From e1284aa3b1b400ecebb59126d7110a3bb4a6b000 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期五, 31 十月 2025 15:46:09 +0800
Subject: [PATCH] 原材料报检拆分功能V1
---
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java | 72 +++++++++++++++++++++++++++++-------
1 files changed, 58 insertions(+), 14 deletions(-)
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 f91b9bd..f8d29bd 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
@@ -277,7 +277,8 @@
}
@Override
- public List<String> checkSubmitPlan(Integer orderId, String laboratory) {
+ public Map<String,Object> checkSubmitPlan(Integer orderId, String laboratory) {
+ Map<String, Object> map = new HashMap<>();
List<String> collect = new ArrayList<>();
List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId));
List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList());
@@ -303,7 +304,19 @@
return insProduct.getInspectionItem() + "-" + insProduct.getInspectionItemSubclass();
}).collect(Collectors.toList());
}
- return collect;
+ //鏌ヨifs鎷嗗垎璁㈠崟鏄惁鏈夊凡涓嬪崟浣嗘槸鏈瀹岀殑鍗曞瓙
+ long count = 0L;
+ InsOrder insOrder = insOrderMapper.selectById(orderId);
+ if(Objects.nonNull(insOrder.getIfsInventoryId())){
+ IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectById(insOrder.getIfsInventoryId());
+ //杩囨护鍑轰笉鍚堟牸鎴栨湭鎻愪氦鐨勫崟瀛�
+ count = ifsInventoryQuantityMapper.selectSplitOrderList(one.getPartNo(),one.getLineNo(),one.getReleaseNo(),one.getReceiptNo(),one.getOrderNo())
+ .stream()
+ .filter(f->(Objects.nonNull(f.getInsOrderId()) && !Objects.equals(f.getInsOrderId(),orderId)) && (Objects.isNull(f.getInsResult()) || 0==f.getInsResult())).count();
+ }
+ map.put("errorMsg",collect);
+ map.put("unInsOrderCount",count);
+ return map;
}
@Override
@@ -502,18 +515,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);
});
}
@@ -758,7 +769,7 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode) {
+ public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode,Boolean registerInsResults) {
InsOrder order = insOrderMapper.selectById(orderId);
// 1. 鍒ゆ柇鏄惁鏈夐噸澶嶇紪鍙�, 鏈夐噸澶嶇紪鍙峰仛鎻愰啋
Long codeCount = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
@@ -928,7 +939,7 @@
// 鐧昏妫�楠岀粨鏋�
// 鍒ゆ柇鏄惁鏈変笉鍚堟牸, 鏈変笉鍚堟牸涓嶈兘绉诲簱
// todo: ifs绉诲簱
- insReportService.isRawMaterial(order);
+ insReportService.isRawMaterial(order,registerInsResults,false);
// 15 鍒ゆ柇褰撳墠鏍峰搧鏄惁涓哄師鏉愭枡, 鍘熸潗鏂欓渶瑕佽繘琛屾暟鎹垎鏋�, 鍒ゆ柇涔嬪墠10鏉℃暟鎹悓涓�涓緵搴斿晢, 鍚屼竴涓楠岄」鐨勫亸宸槸鍚﹁秴杩�10%
// 鏌ヨifs淇℃伅鑾峰彇鑾峰彇鍓�10涓緵搴斿晢涓�鏍风殑, 妫�楠岄」涓�鏍蜂俊鎭�
@@ -968,7 +979,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 +988,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 +1019,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);
@@ -1059,6 +1073,24 @@
double sum = doubleData.stream().mapToDouble(Double::doubleValue).sum();
double average = sum / doubleData.size();
+ 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 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;
@@ -3712,6 +3744,18 @@
}
/**
+ * NBSP锛堥潪闂存柇绌烘牸锛� 杞垚 鏅�氱┖鏍�
+ * @param oldStr
+ * @return
+ */
+ private String normalizedSpaces(String oldStr){
+ if(StringUtils.isBlank(oldStr)){
+ return oldStr;
+ }
+ return oldStr.replaceAll("\u00A0", " ").trim();
+ }
+
+ /**
* 娣诲姞鎶ュ憡缁撹涓嫳鏂�
* @param sample
* @param itemCh
@@ -3723,9 +3767,9 @@
String itemCh,
String itemEn) {
// 鍒ゆ柇鏄惁鏈夋楠岄」鍒嗙被map
- String classTiemName = itemCh + (StringUtils.isBlank(sample.getInspectionItemClass()) ? "" : sample.getInspectionItemClass());
- String classTiemNameEn = itemEn + (StringUtils.isBlank(sample.getInspectionItemClassEN()) ? "" : sample.getInspectionItemClassEN());
- String classTiemNameItemEN = StringUtils.isBlank(sample.getInspectionItemEn()) ? "" : sample.getInspectionItemEn();
+ String classTiemName = itemCh + (StringUtils.isBlank(sample.getInspectionItemClass()) ? "" : normalizedSpaces(sample.getInspectionItemClass()));
+ String classTiemNameEn = itemEn + (StringUtils.isBlank(sample.getInspectionItemClassEN()) ? "" : normalizedSpaces(sample.getInspectionItemClassEN()));
+ String classTiemNameItemEN = StringUtils.isBlank(sample.getInspectionItemEn()) ? "" : normalizedSpaces(sample.getInspectionItemEn());
if (errorClassItemMapCn.containsKey(classTiemName)) {
// 鍒ゆ柇鏄惁鏈夋楠岄」map
--
Gitblit v1.9.3