From ce531d3bb32f5221b35f9e24d027ef83450ebbc6 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 21 十月 2025 16:58:34 +0800
Subject: [PATCH] 修改bug
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java | 63 +++++++++++++++++++++++++++++--
1 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java
index dc26d97..ac9843a 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java
@@ -467,8 +467,8 @@
String datePart = "C" + DateUtils.dateTimeNow();
// 直接获取后五位数字并+1,不考虑是否同一天
- String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
try {
+ String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
int number = Integer.parseInt(numberPart);
if (number < 99999) {
number++;
@@ -606,8 +606,34 @@
tErpSupplierOutbound.setOutboundType(7);
//TODO 确定这个是采购价还是销售价格
tErpSupplierOutbound.setTotalMoney(tErpProcurementGoods.getPurchasePrice().multiply(new BigDecimal(purchaseCount)));
- tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow());
- erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
+
+ TErpSupplierOutbound last = erpSupplierOutboundMapper.selectOne(new LambdaQueryWrapper<TErpSupplierOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
+ if(last==null){
+ tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+"00001");
+ }else {
+ String lastProcurementCode = last.getOutboundNumber();
+ String datePart = "G" + DateUtils.dateTimeNow();
+
+ // 直接获取后五位数字并+1,不考虑是否同一天
+ try {
+ String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
+ int number = Integer.parseInt(numberPart);
+ if (number < 99999) {
+ number++;
+ } else {
+ number = 2; // 达到99999后重置为00002
+ }
+ tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number));
+ } catch (NumberFormatException e) {
+ // 如果解析失败,默认从00001开始
+ tErpSupplierOutbound.setOutboundNumber(datePart + "00001");
+ }
+ }
+ try {
+ erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
+ }catch (Exception e){
+ throw new RuntimeException("网络繁忙,请重试");
+ }
TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods();
tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
@@ -629,8 +655,35 @@
tErpSupplierOutbound.setOutboundType(7);
//TODO 确定这个是采购价还是销售价格
tErpSupplierOutbound.setTotalMoney(tErpProcurementGoods.getPurchasePrice().multiply(new BigDecimal(purchaseCount)));
- tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow());
- erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
+ TErpSupplierOutbound last = erpSupplierOutboundMapper.selectOne(new LambdaQueryWrapper<TErpSupplierOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1"));
+ if(last==null){
+ tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+"00001");
+ }else {
+ String lastProcurementCode = last.getOutboundNumber();
+ String datePart = "G" + DateUtils.dateTimeNow();
+
+ // 直接获取后五位数字并+1,不考虑是否同一天
+ try {
+ String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5));
+ int number = Integer.parseInt(numberPart);
+ if (number < 99999) {
+ number++;
+ } else {
+ number = 2; // 达到99999后重置为00002
+ }
+ tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number));
+ } catch (NumberFormatException e) {
+ // 如果解析失败,默认从00001开始
+ tErpSupplierOutbound.setOutboundNumber(datePart + "00001");
+ }
+ }
+
+ try {
+
+ erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
+ }catch (Exception e){
+ throw new RuntimeException("网络繁忙,请重试");
+ }
TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods();
tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
--
Gitblit v1.7.1