From 271f4a25576ac6c2c8f2c4eb4c9782d6eef85124 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期四, 07 五月 2026 13:13:55 +0800
Subject: [PATCH] 修改报错
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 104 +++++++++++++++++++++++++++------------------------
1 files changed, 55 insertions(+), 49 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 9ba0e6f..9803611 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -9,14 +9,10 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.service.AccountIncomeService;
-import com.ruoyi.basic.dto.CustomerPrivatePoolDto;
-import com.ruoyi.basic.enums.ApplicationTypeEnum;
-import com.ruoyi.basic.enums.RecordTypeEnum;
import com.ruoyi.basic.mapper.CustomerMapper;
-import com.ruoyi.basic.mapper.CustomerPrivatePoolMapper;
+import com.ruoyi.basic.mapper.ProductMapper;
import com.ruoyi.basic.mapper.ProductModelMapper;
import com.ruoyi.basic.pojo.Customer;
-import com.ruoyi.basic.utils.FileUtil;
import com.ruoyi.common.enums.FileNameType;
import com.ruoyi.common.enums.SaleEnum;
import com.ruoyi.common.exception.base.BaseException;
@@ -29,9 +25,7 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.other.mapper.TempFileMapper;
import com.ruoyi.other.pojo.TempFile;
-import com.ruoyi.production.mapper.ProductionProductInputMapper;
-import com.ruoyi.production.mapper.ProductionProductMainMapper;
-import com.ruoyi.production.mapper.ProductionProductOutputMapper;
+import com.ruoyi.production.mapper.*;
import com.ruoyi.production.service.ProductionProductMainService;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.domain.SysUser;
@@ -50,6 +44,7 @@
import org.apache.commons.io.FilenameUtils;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript;
@@ -106,16 +101,23 @@
private final ProductionProductOutputMapper productionProductOutputMapper;
private final ProductionProductInputMapper productionProductInputMapper;
private final QualityInspectMapper qualityInspectMapper;
- private final ProductModelMapper productModelMapper;
private final RedisTemplate<String, String> redisTemplate;
- private final SysDeptMapper sysDeptMapper;
+ @Autowired
+ private SysDeptMapper sysDeptMapper;
@Value("${file.upload-dir}")
private String uploadDir;
- private final ProductionProductMainService productionProductMainService;
- private final PurchaseReturnOrderProductsMapper purchaseReturnOrderProductsMapper;
- private final SysUserMapper sysUserMapper;
- private final CustomerPrivatePoolMapper customerPrivatePoolMapper;
- private final FileUtil fileUtil;
+ @Autowired
+ private ProductModelMapper productModelMapper;
+
+ @Autowired
+ private ProductMapper productMapper;
+ @Autowired
+ private ProductionProductMainService productionProductMainService;
+ @Autowired
+ private PurchaseReturnOrderProductsMapper purchaseReturnOrderProductsMapper;
+ ;
+ @Autowired
+ private SysUserMapper sysUserMapper;
@Override
public List<SalesLedger> selectSalesLedgerList(SalesLedgerDto salesLedgerDto) {
@@ -525,7 +527,7 @@
List<Long> productIds = products.stream()
.map(SalesLedgerProduct::getId)
.collect(Collectors.toList());
- //鍒犻櫎鐢熶骇璁″垝
+ //鍒犻櫎鐢熶骇鏁版嵁
salesLedgerProductServiceImpl.deleteProductionData(productIds);
// 鎵归噺鍒犻櫎浜у搧瀛愯〃
@@ -580,43 +582,47 @@
@Override
@Transactional(rollbackFor = Exception.class)
public int addOrUpdateSalesLedger(SalesLedgerDto salesLedgerDto) {
- // 1. 鏍¢獙瀹㈡埛淇℃伅
- CustomerPrivatePoolDto customer = customerPrivatePoolMapper.selectInfo(salesLedgerDto.getCustomerId());
- if (customer == null) {
- throw new BaseException("瀹㈡埛涓嶅瓨鍦�");
- }
+ try {
+ // 1. 鏍¢獙瀹㈡埛淇℃伅
+ Customer customer = customerMapper.selectById(salesLedgerDto.getCustomerId());
+ if (customer == null) {
+ throw new BaseException("瀹㈡埛涓嶅瓨鍦�");
+ }
- // 2. DTO杞珽ntity
- SalesLedger salesLedger = convertToEntity(salesLedgerDto);
- salesLedger.setCustomerName(customer.getCustomerName());
- salesLedger.setTenantId(customer.getTenantId());
- // 3. 鏂板鎴栨洿鏂颁富琛�
- if (salesLedger.getId() == null) {
- String contractNo = generateSalesContractNo();
- salesLedger.setSalesContractNo(contractNo);
- salesLedgerMapper.insert(salesLedger);
- } else {
- salesLedgerMapper.updateById(salesLedger);
- }
+ // 2. DTO杞珽ntity
+ SalesLedger salesLedger = convertToEntity(salesLedgerDto);
+ salesLedger.setCustomerName(customer.getCustomerName());
+ salesLedger.setTenantId(customer.getTenantId());
+ // 3. 鏂板鎴栨洿鏂颁富琛�
+ if (salesLedger.getId() == null) {
+ String contractNo = generateSalesContractNo();
+ salesLedger.setSalesContractNo(contractNo);
+ salesLedgerMapper.insert(salesLedger);
+ } else {
+ salesLedgerMapper.updateById(salesLedger);
+ }
- // 4. 澶勭悊瀛愯〃鏁版嵁
- List<SalesLedgerProduct> productList = salesLedgerDto.getProductData();
- if (productList != null && !productList.isEmpty()) {
- handleSalesLedgerProducts(salesLedger.getId(), productList, EnumUtil.fromCode(SaleEnum.class, salesLedgerDto.getType()));
- updateMainContractAmount(
- salesLedger.getId(),
- productList,
- SalesLedgerProduct::getTaxInclusiveTotalPrice,
- salesLedgerMapper,
- SalesLedger.class
- );
- }
+ // 4. 澶勭悊瀛愯〃鏁版嵁
+ List<SalesLedgerProduct> productList = salesLedgerDto.getProductData();
+ if (productList != null && !productList.isEmpty()) {
+ handleSalesLedgerProducts(salesLedger.getId(), productList, EnumUtil.fromCode(SaleEnum.class, salesLedgerDto.getType()));
+ updateMainContractAmount(
+ salesLedger.getId(),
+ productList,
+ SalesLedgerProduct::getTaxInclusiveTotalPrice,
+ salesLedgerMapper,
+ SalesLedger.class
+ );
+ }
- // 5. 淇濆瓨鏂囦欢
- if (salesLedgerDto.getStorageBlobDTOs() != null && !salesLedgerDto.getStorageBlobDTOs().isEmpty()) {
- fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.SALES_LEDGER, salesLedger.getId(), salesLedgerDto.getStorageBlobDTOs());
+ // 5. 杩佺Щ涓存椂鏂囦欢鍒版寮忕洰褰�
+ if (salesLedgerDto.getTempFileIds() != null && !salesLedgerDto.getTempFileIds().isEmpty()) {
+ migrateTempFilesToFormal(salesLedger.getId(), salesLedgerDto.getTempFileIds());
+ }
+ return 1;
+ } catch (IOException e) {
+ throw new BaseException("鏂囦欢杩佺Щ澶辫触: " + e.getMessage());
}
- return 1;
}
/**
--
Gitblit v1.9.3