From f05fd2a067d751333f00a81dad095a7650900c95 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 13 三月 2026 13:16:20 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_宁夏_中盛建材' into dev_宁夏_中盛建材
---
src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java | 37 ++++++++++++++++++++++++++-----------
1 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java b/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
index e2c41db..db23add 100644
--- a/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
+++ b/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
@@ -24,6 +24,7 @@
import com.ruoyi.productionPlan.dto.ProductionPlanDto;
import com.ruoyi.productionPlan.dto.ProductionPlanImportDto;
import com.ruoyi.productionPlan.dto.ProductionPlanSummaryDto;
+import com.ruoyi.productionPlan.enums.DataSourceTypeEnum;
import com.ruoyi.productionPlan.mapper.ProductOrderPlanMapper;
import com.ruoyi.productionPlan.mapper.ProductionPlanMapper;
import com.ruoyi.productionPlan.pojo.ProductOrderPlan;
@@ -45,7 +46,6 @@
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
-import static com.ruoyi.productionPlan.enums.DataSourceTypeEnum.PRODUCTION_FORECAST;
/**
* <br>
@@ -120,25 +120,25 @@
// 鏍¢獙鏄惁瀛樺湪涓嶅悓鐨勪骇鍝佸悕绉�
String firstProductName = plans.get(0).getProductName();
- if (plans.stream().anyMatch(p -> !p.getProductName().equals(firstProductName))) {
+ if (plans.stream().anyMatch(p -> p.getProductName() == null || !p.getProductName().equals(firstProductName))) {
throw new BaseException("鍚堝苟澶辫触锛屽瓨鍦ㄤ笉鍚岀殑浜у搧鍚嶇О");
}
// 鏍¢獙鏄惁瀛樺湪涓嶅悓鐨勪骇鍝佽鏍�
String firstProductSpec = plans.get(0).getSpecification();
- if (plans.stream().anyMatch(p -> !p.getSpecification().equals(firstProductSpec))) {
+ if (plans.stream().anyMatch(p -> p.getSpecification() == null || !p.getSpecification().equals(firstProductSpec))) {
throw new BaseException("鍚堝苟澶辫触锛屽瓨鍦ㄤ笉鍚岀殑浜у搧瑙勬牸");
}
// 鍙犲姞鍓╀綑鏂规暟
BigDecimal totalRemainingVolume = plans.stream()
.map(ProductionPlan::getRemainingVolume)
- .filter(v -> v != null)
+ .filter(vull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 鍒ゆ柇涓嬪彂鏁伴噺鏄惁澶т簬绛変簬鍓╀綑鏂规暟
if (productionPlanDto.getTotalAssignedQuantity().compareTo(totalRemainingVolume) > 0) {
throw new BaseException("鎿嶄綔澶辫触锛屼笅鍙戞暟閲忎笉鑳藉ぇ浜庡墿浣欐柟鏁�");
- }
+ } -> v != n
// 鍒涘缓鐢熶骇璁㈠崟
ProductOrder productOrder = new ProductOrder();
@@ -166,6 +166,10 @@
if (assignedVolume.add(remainingVolume).compareTo(productionPlanDto.getTotalAssignedQuantity()) >= 0) {
// 鏈�鍚庝竴涓鍒掞紝鍒嗛厤鍓╀綑鏂规暟
BigDecimal lastRemainingVolume = productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume);
+ plan.setStatus(1);
+ if (lastRemainingVolume.compareTo(BigDecimal.ZERO) <= 0) {
+ plan.setStatus(2);
+ }
plan.setAssignedQuantity(plan.getAssignedQuantity().add(lastRemainingVolume));
productOrderPlan.setAssignedQuantity(lastRemainingVolume);
productionPlanMapper.updateById(plan);
@@ -174,6 +178,10 @@
}
// 鍒嗛厤褰撳墠璁″垝鏂规暟
+ plan.setStatus(1);
+ if (remainingVolume.compareTo(BigDecimal.ZERO) <= 0) {
+ plan.setStatus(2);
+ }
plan.setAssignedQuantity(plan.getAssignedQuantity().add(remainingVolume));
productOrderPlan.setAssignedQuantity(remainingVolume);
// 鏇存柊鐢熶骇璁″垝
@@ -188,7 +196,8 @@
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(ProductionPlanDto productionPlanDto) {
- productionPlanDto.setDataSourceType(PRODUCTION_FORECAST.getCode());
+ productionPlanDto.setDataSourceType(DataSourceTypeEnum.MANUAL.getCode())
+ productionPlanDto.setStatus(0);
productionPlanMapper.insert(productionPlanDto);
return true;
}
@@ -196,6 +205,10 @@
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(ProductionPlanDto productionPlanDto) {
+ // 宸蹭笅鍙戠姸鎬侊紝涓嶈兘缂栬緫
+ if (productionPlanDto.getStatus() != 0) {
+ throw new BaseException("宸蹭笅鍙戞垨閮ㄥ垎涓嬪彂鐘舵�侊紝涓嶈兘缂栬緫");
+ }
// 鏌ヨ鏄惁鏈夊叧鑱旇鍗�
boolean hasProductOrderPlan = productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().eq(ProductOrderPlan::getProductionPlanId, productionPlanDto.getId())).stream().anyMatch(p -> p.getProductOrderId() != null);
if (hasProductOrderPlan) {
@@ -212,6 +225,10 @@
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<Long> ids) {
+ // 濡傛灉瀛樺湪宸蹭笅鍙戠殑璁″垝锛屽垯涓嶈兘鍒犻櫎
+ if (productionPlanMapper.selectList(Wrappers.<ProductionPlan>lambdaQuery().in(ProductionPlan::getId, ids)).stream().anyMatch(p -> p.getStatus() == 1 || p.getStatus() == 2)) {
+ throw new BaseException("鍒犻櫎澶辫触锛屽瓨鍦ㄥ凡涓嬪彂鎴栭儴鍒嗕笅鍙戠殑璁″垝");
+ }
// 濡傛灉鏈夊叧鑱旇鍗曪紝鍒欎笉鑳藉垹闄�
if (productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().in(ProductOrderPlan::getProductionPlanId, ids)).stream().anyMatch(p -> p.getProductOrderId() != null)) {
throw new BaseException("鍒犻櫎澶辫触锛屽瓨鍦ㄥ叧鑱旇鍗�");
@@ -226,7 +243,7 @@
@Transactional(rollbackFor = Exception.class)
public void syncProdData(Integer dataSyncType) {
if (!syncLock.tryLock()) {
- log.warn("鍚屾姝e湪杩涜涓紝鏈 {} 鍚屾璇锋眰琚烦杩�", dataSyncType == 1 ? "鎵嬪姩" : "瀹氭椂浠诲姟");
+ log.warn("鍚屾姝e湪杩涜涓紝鏈 {} 鍚屾璇锋眰琚烦杩�", dataSyncType == 1 ? "鎵嬪姩鍚屾" : "瀹氭椂浠诲姟鍚屾");
return;
}
@@ -443,8 +460,7 @@
plan.setFormCreatedTime(parseUtcTime(item.getString("createdTimeGMT")));
plan.setFormModifiedTime(parseUtcTime(item.getString("modifiedTimeGMT")));
- plan.setDataSyncType(dataSyncType);
- plan.setDataSourceType(1);
+ plan.setDataSourceType(DataSourceTypeEnum.DING_TALK.getCode());
plan.setCreateTime(now);
plan.setUpdateTime(now);
plan.setTotalCount(totalCount);
@@ -543,8 +559,7 @@
entity.setAssignedQuantity(BigDecimal.ZERO);
entity.setCreateTime(LocalDateTime.now());
entity.setUpdateTime(LocalDateTime.now());
- entity.setDataSourceType(2);
- entity.setDataSyncType(1);
+ entity.setDataSourceType(DataSourceTypeEnum.DING_TALK.getCode());
// 鏍规嵁鐗╂枡缂栫爜濉厖鍏宠仈ID
if (StringUtils.isNotEmpty(dto.getMaterialCode())) {
--
Gitblit v1.9.3