From 23ec64ed997fc206fba9f0d6a84975f7b36c47be Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期日, 11 十月 2026 16:09:26 +0800
Subject: [PATCH] 天津-奇缘恒艺 录数据需求修改
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java | 54 +++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 41 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
index 9f6e004..66285d4 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -4,6 +4,8 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.pojo.ProductModel;
+import com.ruoyi.basic.service.IProductService;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.procurementrecord.utils.StockUtils;
import com.ruoyi.production.mapper.*;
@@ -25,6 +27,8 @@
import com.ruoyi.technology.mapper.TechnologyBomStructureMapper;
import com.ruoyi.technology.mapper.TechnologyRoutingMapper;
import com.ruoyi.technology.pojo.TechnologyRouting;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -33,9 +37,7 @@
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
-import java.time.LocalDate;
import java.time.LocalDateTime;
-import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
@@ -87,6 +89,8 @@
private StockUtils stockUtils;
@Autowired
private StockInventoryMapper stockInventoryMapper;
+ @Autowired
+ private IProductService productService;
@Override
public SalesLedgerProduct selectSalesLedgerProductById(Long id) {
@@ -98,16 +102,29 @@
List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectSalesLedgerProductList(salesLedgerProduct);
if(!CollectionUtils.isEmpty(salesLedgerProducts)){
salesLedgerProducts.forEach(item -> {
- // 鍙戣揣淇℃伅
- ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>()
+ // 鍙戣揣淇℃伅锛堝彇鏈�鏂颁竴鏉★紝鍙煡璇㈠鏍搁�氳繃鎴栧凡鍙戣揣鐨勮褰曪級
+ ShippingInfo latestShippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>()
.eq(ShippingInfo::getSalesLedgerProductId, item.getId())
+ .in(ShippingInfo::getStatus, "瀹℃牳閫氳繃", "宸插彂璐�")
.orderByDesc(ShippingInfo::getCreateTime)
.last("limit 1"));
- if(shippingInfo != null){
- item.setShippingDate(shippingInfo.getShippingDate());
- item.setShippingCarNumber(shippingInfo.getShippingCarNumber());
- item.setExpressCompany(shippingInfo.getExpressCompany());
- item.setExpressNumber(shippingInfo.getExpressNumber());
+ if(latestShippingInfo != null){
+ item.setShippingDate(latestShippingInfo.getShippingDate());
+ item.setExpressCompany(latestShippingInfo.getExpressCompany());
+ item.setExpressNumber(latestShippingInfo.getExpressNumber());
+ }
+ // 杞︾墝鍙凤細鍙栨墍鏈夊鏍搁�氳繃鎴栧凡鍙戣揣璁板綍鐨勮溅鐗屽彿锛岄�楀彿鎷兼帴
+ List<ShippingInfo> allShippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>()
+ .eq(ShippingInfo::getSalesLedgerProductId, item.getId())
+ .in(ShippingInfo::getStatus, "瀹℃牳閫氳繃", "宸插彂璐�")
+ .orderByAsc(ShippingInfo::getCreateTime));
+ if(!CollectionUtils.isEmpty(allShippingInfos)){
+ String carNumbers = allShippingInfos.stream()
+ .map(ShippingInfo::getShippingCarNumber)
+ .filter(carNo -> carNo != null && !carNo.trim().isEmpty())
+ .distinct()
+ .collect(Collectors.joining(","));
+ item.setShippingCarNumber(carNumbers);
}
});
}
@@ -166,6 +183,18 @@
@Transactional(rollbackFor = Exception.class)
public int addOrUpdateSalesLedgerProduct(SalesLedgerProduct salesLedgerProduct) {
+ // 閿�鍞彴璐�(type=1)鎵嬪伐褰曞叆浜у搧澶х被/瑙勬牸鍨嬪彿鏃讹紝鑷姩娉ㄥ唽鍒颁骇鍝佺淮鎶わ紙缁熶竴鎸傘�屾垚鍝併�嶅ぇ绫讳笅锛�
+ if (Integer.valueOf(1).equals(salesLedgerProduct.getType())) {
+ ProductModel productModel = productService.ensureProductHierarchy(
+ salesLedgerProduct.getProductCategory(),
+ salesLedgerProduct.getSpecificationModel(),
+ salesLedgerProduct.getUnit());
+ if (productModel != null) {
+ salesLedgerProduct.setProductId(productModel.getProductId());
+ salesLedgerProduct.setProductModelId(productModel.getId());
+ }
+ }
+
int result;
Long salesLedgerId = salesLedgerProduct.getSalesLedgerId();
if (salesLedgerProduct.getId() == null) {
@@ -216,16 +245,15 @@
*/
public void addProductionData(SalesLedgerProduct salesLedgerProduct) {
//鍏堝垽鏂浜у搧鏄惁闇�瑕佺敓浜�
- if (!salesLedgerProduct.getIsProduction()) {
+ if (!BooleanUtils.isTrue(salesLedgerProduct.getIsProduction())) {
return;
}
SalesLedger salesLedger = salesLedgerMapper.selectById(salesLedgerProduct.getSalesLedgerId());
ProductionPlan productionPlan = new ProductionPlan();
productionPlan.setSalesLedgerId(salesLedgerProduct.getSalesLedgerId());
productionPlan.setSalesLedgerProductId(salesLedgerProduct.getId());
- productionPlan.setMpsNo(generateNextPlanNo(salesLedger.getEntryDate().toInstant()
- .atZone(ZoneId.systemDefault())
- .toLocalDate().format(DateTimeFormatter.ofPattern("yyyyMMdd"))));
+ productionPlan.setMpsNo(generateNextPlanNo(com.ruoyi.common.utils.DateUtils.toLocalDate(salesLedger.getEntryDate())
+ .format(DateTimeFormatter.ofPattern("yyyyMMdd"))));
productionPlan.setProductModelId(salesLedgerProduct.getProductModelId());
productionPlan.setQtyRequired(salesLedgerProduct.getQuantity());
productionPlan.setSource("閿�鍞�");
--
Gitblit v1.9.3