From 173f44a1f9a59509996192e3446cbd26f2613b5e Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 10 十月 2025 15:55:32 +0800
Subject: [PATCH] yys 新增关键煤种锁仓模块
---
main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java | 83 ++++++++++++++++++++++++++++-------------
1 files changed, 57 insertions(+), 26 deletions(-)
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java
index 6a2d46c..d4521c4 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java
@@ -49,6 +49,8 @@
private final PendingInventoryMapper pendingInventoryMapper;
+ private final ProductionSchedulingMapper productionSchedulingMapper;
+
@Override
public IPage<ProductionMasterDto> selectPMList(Page page, ProductionMasterDto productionMasterDto) {
// 1. 鏋勫缓涓昏〃鏌ヨ鏉′欢
@@ -173,7 +175,7 @@
batchInsertInventories(masterId, dto.getProductionInventoryList());
// 鎻掑叆寰呭叆搴撴暟鎹�
- insertPendingInventory(dto.getProductionList());
+// insertPendingInventory(dto.getProductionList());
return 1;
}
@@ -263,6 +265,7 @@
BeanUtils.copyProperties(p, copy);
copy.setId(null);
copy.setProductionMasterId(masterId);
+ copy.setStatus(1);
productionMapper.insert(copy);
}
}
@@ -283,49 +286,68 @@
/**
* 灏嗗姞宸ヤ骇鐢熺殑浜у搧璁板綍鍒板緟鍏ュ簱琛�
*/
- private void insertPendingInventory(List<Production> list) {
+ public void insertPendingInventory(List<Production> list) {
LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = currentDate.format(formatter);
- // 甯搁噺瀹氫箟锛氫繚鐣�2浣嶅皬鏁帮紝鍥涜垗浜斿叆妯″紡
final int SCALE = 2;
final RoundingMode ROUNDING_MODE = RoundingMode.HALF_UP;
- // 绋庣巼13%锛岀敤瀛楃涓叉瀯閫燘igDecimal閬垮厤绮惧害璇樊
final BigDecimal TAX_RATE = new BigDecimal("1.13");
for (Production p : list) {
PendingInventory pending = new PendingInventory();
pending.setCoalId(p.getCoalId());
pending.setInventoryQuantity(p.getProductionQuantity());
- pending.setUnit("t");
+ pending.setUnit("鍚�");
pending.setSupplierName(formattedDate + " - " + "鐢熶骇鍔犲伐鍏ュ簱");
- // 1. 闈炵┖澶勭悊锛氶伩鍏峮ull瀵艰嚧鐨勮繍绠楀紓甯�
+ // 闈炵┖澶勭悊
BigDecimal totalCost = p.getTotalCost() == null ? BigDecimal.ZERO : p.getTotalCost();
BigDecimal productionQuantity = p.getProductionQuantity() == null ? BigDecimal.ZERO : p.getProductionQuantity();
- // 2. 鍚◣鎬讳环 = 鍚◣鍗曚环 * 浜ч噺 鈫� 淇濈暀2浣嶅皬鏁�
+ // 鍚◣鎬讳环
BigDecimal totalPriceIncludingTax = totalCost.multiply(productionQuantity)
.setScale(SCALE, ROUNDING_MODE);
pending.setTotalPriceIncludingTax(totalPriceIncludingTax);
- // 3. 鍚◣鍗曚环 鈫� 鐩存帴淇濈暀2浣嶅皬鏁�
+ // 鍚◣鍗曚环
pending.setPriceIncludingTax(totalCost.setScale(SCALE, ROUNDING_MODE));
- // 4. 涓嶅惈绋庡崟浠� = 鍚◣鍗曚环 / 1.13 鈫� 鍏堥珮绮惧害璁$畻锛屽啀淇濈暀2浣�
- BigDecimal priceExcludingTax = totalCost.divide(TAX_RATE, 10, ROUNDING_MODE) // 涓棿淇濈暀10浣嶉槻璇樊
- .setScale(SCALE, ROUNDING_MODE); // 鏈�缁堜繚鐣�2浣�
+ // 涓嶅惈绋庡崟浠凤紙鐩存帴淇濈暀2浣嶅皬鏁帮級
+ BigDecimal priceExcludingTax = totalCost.divide(TAX_RATE, SCALE, ROUNDING_MODE);
pending.setPriceExcludingTax(priceExcludingTax);
- // 5. 涓嶅惈绋庢�讳环 = 涓嶅惈绋庡崟浠� * 浜ч噺 鈫� 淇濈暀2浣嶅皬鏁�
+ // 涓嶅惈绋庢�讳环
BigDecimal totalPriceExcludingTax = priceExcludingTax.multiply(productionQuantity)
.setScale(SCALE, ROUNDING_MODE);
pending.setTotalPriceExcludingTax(totalPriceExcludingTax);
pending.setRegistrantId(p.getProducerId());
pending.setRegistrationDate(LocalDate.now());
+
+ pending.setCode(generateCode(p.getType()));
+ pending.setType(p.getType());
pendingInventoryMapper.insert(pending);
}
+ }
+
+ private String generateCode(Integer type) {
+ LocalDate now = LocalDate.now();
+ String year = now.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
+ String s = "";
+ //鐢熸垚缂栫爜
+ switch (type){
+ case 1:
+ s = "CP";
+ break;
+ case 2:
+ s = "YL";
+ break;
+ }
+ // 鏌ヨ褰撳ぉ寰呭叆搴撴柊澧炴潯鏁�
+ Long count = pendingInventoryMapper.selectCount(new LambdaQueryWrapper<PendingInventory>()
+ .apply("date_trunc('day', create_time) = date_trunc('day', now())"));
+ return s + year + String.format("%03d", count + 1);
}
@Override
@@ -368,12 +390,21 @@
.collect(Collectors.toList());
productionInventoryMapper.deleteBatchIds(inventoryIds);
}
+ List<Production> productions = productionMapper.selectList(new LambdaQueryWrapper<Production>()
+ .in(Production::getProductionMasterId, idList));
+
+ // 鍒犻櫎鐢熶骇鎶ュ伐璁板綍
+ productionSchedulingMapper.delete(
+ new LambdaQueryWrapper<ProductionScheduling>()
+ .in(ProductionScheduling::getProductionId, productions.stream().map(Production::getId).collect(Collectors.toList()))
+ );
// 鍒犻櫎鐢熶骇鏄庣粏
productionMapper.delete(
new LambdaQueryWrapper<Production>()
.in(Production::getProductionMasterId, idList)
);
+
// 5. 鍒犻櫎涓昏褰�
return productionMasterMapper.deleteBatchIds(idList);
@@ -405,20 +436,20 @@
}
// 鎵归噺鏇存柊瀹樻柟搴撳瓨
- for (Map.Entry<Long, BigDecimal> entry : inventoryAdjustMap.entrySet()) {
- OfficialInventory official = officialInventoryMapper.selectById(entry.getKey());
- if (official == null) {
- throw new BaseException("瀹樻柟搴撳瓨涓嶅瓨鍦紝ID: " + entry.getKey());
- }
-
- // 浣跨敤绾跨▼瀹夊叏鐨凚igDecimal鎿嶄綔
- official.setInventoryQuantity(
- Optional.ofNullable(official.getInventoryQuantity())
- .orElse(BigDecimal.ZERO)
- .add(entry.getValue())
- );
- officialInventoryMapper.updateById(official);
- }
+// for (Map.Entry<Long, BigDecimal> entry : inventoryAdjustMap.entrySet()) {
+// OfficialInventory official = officialInventoryMapper.selectById(entry.getKey());
+// if (official == null) {
+// throw new BaseException("瀹樻柟搴撳瓨涓嶅瓨鍦紝ID: " + entry.getKey());
+// }
+//
+// // 浣跨敤绾跨▼瀹夊叏鐨凚igDecimal鎿嶄綔
+// official.setInventoryQuantity(
+// Optional.ofNullable(official.getInventoryQuantity())
+// .orElse(BigDecimal.ZERO)
+// .add(entry.getValue())
+// );
+// officialInventoryMapper.updateById(official);
+// }
// 鎵归噺鍒犻櫎鐢熶骇搴撳瓨
if (!productionIdsToDelete.isEmpty()) {
--
Gitblit v1.9.3