From f4d4d29368ccacb807f93e2033cd4a643a3ddade Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 30 三月 2026 10:20:28 +0800
Subject: [PATCH] yys 1.修改bug
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 60 ++++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 40 insertions(+), 20 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index ffa35f1..86e560c 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -23,8 +23,13 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.other.mapper.TempFileMapper;
import com.ruoyi.other.pojo.TempFile;
+import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper;
+import com.ruoyi.procurementrecord.pojo.ReturnManagement;
+import com.ruoyi.procurementrecord.service.ReturnManagementService;
import com.ruoyi.production.mapper.*;
import com.ruoyi.production.pojo.*;
+import com.ruoyi.production.service.ProductionProductMainService;
+import com.ruoyi.production.service.impl.ProductionProductMainServiceImpl;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.mapper.SysDeptMapper;
@@ -97,6 +102,10 @@
private final ShippingInfoMapper shippingInfoMapper;
+ private final ReturnManagementMapper returnManagementMapper;
+
+ private final ReturnManagementService returnManagementService;
+
private final InvoiceLedgerMapper invoiceLedgerMapper;
private final SalesLedgerSchedulingMapper salesLedgerSchedulingMapper;
@@ -146,7 +155,9 @@
private ProductMapper productMapper;
@Autowired
private ProductStructureMapper productStructureMapper;
-;
+ @Autowired
+ private ProductionProductMainService productionProductMainService;
+ ;
@Override
public List<SalesLedger> selectSalesLedgerList(SalesLedgerDto salesLedgerDto) {
@@ -178,7 +189,7 @@
.eq(ShippingInfo::getSalesLedgerProductId, product.getId())
.orderByDesc(ShippingInfo::getCreateTime)
.last("limit 1"));
- if(shippingInfo != null){
+ if (shippingInfo != null) {
product.setShippingStatus(shippingInfo.getStatus());
}
}
@@ -350,7 +361,7 @@
// // 浜у搧澶х被鏁版嵁
// List<Product> productList = productMapper.selectList(new LambdaQueryWrapper<Product>().in(Product::getProductName,
// salesLedgerProductImportDtoList.stream().map(SalesLedgerImportDto::getProductCategory).collect(Collectors.toList())));
- List<Map<String,Object>> list = productModelMapper.getProductAndModelList();
+ List<Map<String, Object>> list = productModelMapper.getProductAndModelList();
// 褰曞叆浜烘暟鎹�
List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().in(SysUser::getNickName,
salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getEntryPerson).collect(Collectors.toList())));
@@ -358,7 +369,7 @@
SalesLedger salesLedger1 = salesLedgerMapper.selectOne(new LambdaQueryWrapper<SalesLedger>()
.eq(SalesLedger::getSalesContractNo, salesLedgerImportDto.getSalesContractNo())
.last("LIMIT 1"));
- if(salesLedger1 != null){
+ if (salesLedger1 != null) {
continue;
}
SalesLedger salesLedger = new SalesLedger();
@@ -391,7 +402,7 @@
throw new RuntimeException("閿�鍞崟鍙�:" + salesLedgerImportDto.getSalesContractNo() + ",鏃犲搴斾骇鍝佹暟鎹紒");
salesLedger.setContractAmount(salesLedgerProductImportDtos.stream()
.map(SalesLedgerProductImportDto::getTaxInclusiveTotalPrice)
- .reduce(BigDecimal.ZERO,BigDecimal::add));
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
salesLedgerMapper.insert(salesLedger);
@@ -426,6 +437,8 @@
salesLedgerProduct.setApproveStatus(0);
salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProductImportDto.getTaxInclusiveTotalPrice());
salesLedgerProductMapper.insert(salesLedgerProduct);
+ // 娣诲姞鐢熶骇鏁版嵁
+ salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct);
}
}
@@ -551,25 +564,29 @@
// 鍒犻櫎鍙戣揣鍙拌处璁板綍
List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>()
.in(ShippingInfo::getSalesLedgerId, idList));
- if(CollectionUtils.isNotEmpty(shippingInfos)){
- shippingInfoServiceImpl.delete(shippingInfos.stream().map(ShippingInfo::getId).collect(Collectors.toList()));
+ if (CollectionUtils.isNotEmpty(shippingInfos)) {
+ List<Long> shippingIds = shippingInfos.stream().map(ShippingInfo::getId).collect(Collectors.toList());
+ shippingInfoServiceImpl.delete(shippingIds);
+ // 鍒犻櫎閫�璐у彴璐﹁褰�
+ List<ReturnManagement> returnManagements = returnManagementMapper.selectList(new LambdaQueryWrapper<ReturnManagement>()
+ .in(ReturnManagement::getShippingId, shippingIds));
+ if (CollectionUtils.isNotEmpty(returnManagements)) {
+ List<Long> returnIds = returnManagements.stream().map(ReturnManagement::getId).collect(Collectors.toList());
+ returnManagementService.delete(returnIds);
+ }
}
+
// 鍒犻櫎闄勪欢琛�
commonFileService.deleteByBusinessIds(idList, FileNameType.SALE.getValue());
// 鍒犻櫎鐢熶骇绠℃帶鏁版嵁
- // 鍒犻櫎鐢熶骇璁㈠崟鏁版嵁
- LambdaQueryWrapper<SalesLedgerScheduling> in = new LambdaQueryWrapper<SalesLedgerScheduling>()
- .in(SalesLedgerScheduling::getSalesLedgerId, idList);
- salesLedgerSchedulingMapper.delete(in);
- // 鍒犻櫎鐢熶骇娲惧伐鏁版嵁
- LambdaQueryWrapper<SalesLedgerWork> workOrderWrapper = new LambdaQueryWrapper<>();
- workOrderWrapper.in(SalesLedgerWork::getSalesLedgerId, idList);
- salesLedgerWorkMapper.delete(workOrderWrapper);
- // 鍒犻櫎鐢熶骇鏍哥畻鏁版嵁
- LambdaQueryWrapper<SalesLedgerProductionAccounting> reportWrapper = new LambdaQueryWrapper<>();
- reportWrapper.in(SalesLedgerProductionAccounting::getSalesLedgerId, idList);
- salesLedgerProductionAccountingMapper.delete(reportWrapper);
+ //鏌ヨ鐢熶骇鎶ュ伐id
+ ArrayList<Long> mainIdList = productionProductMainService.listMain(idList);
+ if (CollectionUtils.isNotEmpty(mainIdList)) {
+ mainIdList.stream().forEach(mainId -> {
+ productionProductMainService.removeProductMain(mainId);
+ });
+ }
// 2. 鍐嶅垹闄や富琛ㄦ暟鎹�
return salesLedgerMapper.deleteBatchIds(idList);
}
@@ -591,9 +608,12 @@
// 3. 鏂板鎴栨洿鏂颁富琛�
if (salesLedger.getId() == null) {
String contractNo = generateSalesContractNo();
- salesLedger.setSalesContractNo(contractNo);
+ salesLedger.setSalesContractNo(salesLedgerDto.getSalesContractNo() == null ? contractNo : salesLedgerDto.getSalesContractNo());
salesLedgerMapper.insert(salesLedger);
} else {
+ if(StringUtils.isNotEmpty(salesLedgerDto.getSalesContractNo())){
+ salesLedger.setSalesContractNo(salesLedgerDto.getSalesContractNo());
+ }
salesLedgerMapper.updateById(salesLedger);
}
--
Gitblit v1.9.3