From 74a29854bb8ff92d2ff2fcb55fa5028609ec6a33 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期二, 14 七月 2026 15:26:47 +0800
Subject: [PATCH] 采购删除导致审批报错+发货台账导入关联销售台账+生成出库记录
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java | 61 +++++++++++++++++-------------
1 files changed, 34 insertions(+), 27 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 4042a3e..c21e1ae 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -27,7 +27,9 @@
import com.ruoyi.sales.pojo.SalesLedger;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.pojo.ShippingInfo;
+import com.ruoyi.sales.pojo.WeighingRecord;
import com.ruoyi.sales.service.ISalesLedgerProductService;
+import com.ruoyi.sales.service.IWeighingRecordService;
import com.ruoyi.stock.mapper.StockInventoryMapper;
import com.ruoyi.stock.pojo.StockInventory;
import lombok.AllArgsConstructor;
@@ -88,13 +90,14 @@
private StockUtils stockUtils;
-
@Autowired
private ProductStructureMapper productStructureMapper;
@Autowired
private StockInventoryMapper stockInventoryMapper;
@Autowired
private ProductOrderServiceImpl productOrderServiceImpl;
+ @Autowired
+ private IWeighingRecordService iWeighingRecordService;
@Override
public SalesLedgerProduct selectSalesLedgerProductById(Long id) {
@@ -107,20 +110,23 @@
// queryWrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedgerProduct.getSalesLedgerId())
// .eq(SalesLedgerProduct::getType, salesLedgerProduct.getType());
List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectSalesLedgerProductList(salesLedgerProduct);
- if(!CollectionUtils.isEmpty(salesLedgerProducts)){
+ if (!CollectionUtils.isEmpty(salesLedgerProducts)) {
salesLedgerProducts.forEach(item -> {
// 鍙戣揣淇℃伅
- ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>()
- .eq(ShippingInfo::getSalesLedgerProductId, item.getId())
- .orderByDesc(ShippingInfo::getCreateTime)
- .last("limit 1"));
- if(shippingInfo != null){
- item.setShippingDate(shippingInfo.getShippingDate());
- item.setShippingCarNumber(shippingInfo.getShippingCarNumber());
- item.setShippingStatus(shippingInfo.getStatus());
- item.setExpressCompany(shippingInfo.getExpressCompany());
- item.setExpressNumber(shippingInfo.getExpressNumber());
+ List<WeighingRecord> list = iWeighingRecordService.list(new QueryWrapper<WeighingRecord>().lambda().eq(WeighingRecord::getRecordId, item.getId()).orderByDesc(WeighingRecord::getCreateTime));
+ if (!list.isEmpty()) {
+ BigDecimal reduce = list.stream().map(WeighingRecord::getNetWeight).collect(Collectors.toList()).stream().reduce(BigDecimal.ZERO, BigDecimal::add);
+ item.setShippingDate(list.get(0).getSecondWeighTime());
+ item.setShippingCarNumber(list.get(0).getCarNo());
+ if (reduce.compareTo(BigDecimal.ZERO) == 0) {
+ item.setShippingStatus("鏈彂璐�");
+ } else if (reduce.compareTo(item.getQuantity()) < 0) {
+ item.setShippingStatus("閮ㄥ垎鍙戣揣");
+ } else {
+ item.setShippingStatus("宸插彂璐�");
+ }
}
+ item.setShippingStatus("鏈彂璐�");
});
// 寮�绁�
InvoiceRegistrationProductDto invoiceRegistrationProductDto = new InvoiceRegistrationProductDto();
@@ -134,8 +140,8 @@
BigDecimal noInvoiceNum = BigDecimal.ZERO;
BigDecimal noInvoiceAmount = BigDecimal.ZERO;
for (InvoiceRegistrationProductDto registrationProductDto : invoiceRegistrationProductDtoList) {
- if(ledgerProduct.getId().intValue() == registrationProductDto.getSalesLedgerProductId()){
- invoiceNum = invoiceNum.add(registrationProductDto.getInvoiceNum());
+ if (ledgerProduct.getId().intValue() == registrationProductDto.getSalesLedgerProductId()) {
+ invoiceNum = invoiceNum.add(registrationProductDto.getInvoiceNum());
invoiceAmount = invoiceAmount.add(registrationProductDto.getInvoiceAmount());
}
}
@@ -169,7 +175,7 @@
//鍒犻櫎鍙戣揣淇℃伅
List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>()
.in(ShippingInfo::getSalesLedgerProductId, Arrays.asList(ids)));
- if(!CollectionUtils.isEmpty(shippingInfos)){
+ if (!CollectionUtils.isEmpty(shippingInfos)) {
shippingInfoService.delete(shippingInfos.stream().map(ShippingInfo::getId).collect(Collectors.toList()));
}
@@ -296,12 +302,12 @@
BigDecimal ticketsTotal = salesLedgerProduct.getTicketsTotal() != null ? salesLedgerProduct.getTicketsTotal() : BigDecimal.ZERO;
// 寰呭洖娆撅紝浠樻
- if(salesLedgerProduct.getType().equals(1)){
+ if (salesLedgerProduct.getType().equals(1)) {
salesLedgerProduct.setPendingInvoiceTotal(totalPrice.subtract(invoiceTotal));
//鏈紑绁ㄦ暟閲�+閲戦
salesLedgerProduct.setNoInvoiceNum(salesLedgerProduct.getQuantity());
salesLedgerProduct.setNoInvoiceAmount(totalPrice);
- }else{
+ } else {
salesLedgerProduct.setPendingTicketsTotal(totalPrice.subtract(ticketsTotal));
// 鏈潵绁ㄦ暟閲�+閲戦
salesLedgerProduct.setFutureTickets(salesLedgerProduct.getQuantity());
@@ -376,7 +382,7 @@
List<ProcessRoute> processRoutes = processRouteMapper.selectList(new QueryWrapper<ProcessRoute>().lambda()
.eq(ProcessRoute::getProductModelId, salesLedgerProduct.getProductModelId())
.orderByDesc(ProcessRoute::getCreateTime));
- if (processRoutes.size()>0){
+ if (processRoutes.size() > 0) {
ProcessRoute processRoute = processRoutes.get(0);
//鏂板鐢熶骇璁㈠崟宸ヨ壓璺嚎涓昏〃
ProductProcessRoute productProcessRoute = new ProductProcessRoute();
@@ -413,7 +419,7 @@
}
}
// 鐢熸垚瀹屾暣鐨勫伐鍗曞彿
- String workOrderNoStr ="GD"+ String.format("%s%03d", datePrefix, sequenceNumber);
+ String workOrderNoStr = "GD" + String.format("%s%03d", datePrefix, sequenceNumber);
ProductWorkOrder productWorkOrder = new ProductWorkOrder();
productWorkOrder.setProductProcessRouteItemId(productProcessRouteItem.getId());
productWorkOrder.setProductOrderId(productOrder.getId());
@@ -434,7 +440,7 @@
* 鍒犻櫎鐢熶骇鏁版嵁
*/
public void deleteProductionData(List<Long> productIds) {
- if (productIds == null || productIds.isEmpty()){
+ if (productIds == null || productIds.isEmpty()) {
return;
}
//鎵归噺鏌ヨproductOrder
@@ -533,9 +539,9 @@
// 鍒ゆ柇鐘舵��
BigDecimal taxInclusiveTotalPrice = item.getTaxInclusiveTotalPrice();
BigDecimal invoiceTotal = item.getInvoiceTotal();
- if(taxInclusiveTotalPrice != null && invoiceTotal != null && taxInclusiveTotalPrice.compareTo(invoiceTotal) == 0){
+ if (taxInclusiveTotalPrice != null && invoiceTotal != null && taxInclusiveTotalPrice.compareTo(invoiceTotal) == 0) {
item.setStatusName("宸插畬鎴愪粯娆�");
- }else{
+ } else {
item.setStatusName("鏈畬鎴愪粯娆�");
}
});
@@ -549,9 +555,9 @@
// 鍒ゆ柇鐘舵��
BigDecimal taxInclusiveTotalPrice = item.getTaxInclusiveTotalPrice();
BigDecimal ticketsTotal = item.getTicketsTotal();
- if(taxInclusiveTotalPrice != null && ticketsTotal != null && taxInclusiveTotalPrice.compareTo(ticketsTotal) == 0){
+ if (taxInclusiveTotalPrice != null && ticketsTotal != null && taxInclusiveTotalPrice.compareTo(ticketsTotal) == 0) {
item.setStatusName("宸插畬鎴愪粯娆�");
- }else{
+ } else {
item.setStatusName("鏈畬鎴愪粯娆�");
}
});
@@ -592,6 +598,7 @@
throw new RuntimeException("鍔ㄦ�佹洿鏂颁富琛ㄩ噾棰濆け璐�", e);
}
}
+
@Override
public R judgmentInventory(SalesLedgerProduct salesLedgerProduct) {
//鑾峰彇浜у搧鏈�鏂扮殑宸ヨ壓璺嚎
@@ -610,7 +617,7 @@
//鎵�闇�鏁伴噺
BigDecimal multiply = salesLedgerProduct.getQuantity().multiply(productStructureDto.getUnitQuantity());
- BigDecimal subtract =stockInventory.getQualitity().subtract(stockInventory.getLockedQuantity()).subtract(multiply).divide(BigDecimal.ONE, 2, RoundingMode.CEILING);
+ BigDecimal subtract = stockInventory.getQualitity().subtract(stockInventory.getLockedQuantity()).subtract(multiply).divide(BigDecimal.ONE, 2, RoundingMode.CEILING);
if (subtract.compareTo(BigDecimal.ZERO) <= 0) {
count++;
stringBuffer.append(productStructureDto.getProductName())
@@ -621,9 +628,9 @@
.append(System.lineSeparator());
}
}
- if (count>0) {
+ if (count > 0) {
return R.fail(stringBuffer.toString());
- }else {
+ } else {
return R.ok();
}
}
--
Gitblit v1.9.3