From 13fd47c5aa585b74bfc8b77722bde3f7a2399587 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 21 五月 2026 10:26:42 +0800
Subject: [PATCH] refactor(invoice): 删除invoice_registration invoice_registration_product invoice_ledger invoice_ledger_file
---
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java | 66 +++++++++++---------------------
1 files changed, 23 insertions(+), 43 deletions(-)
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
index 71378e7..e9e5179 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -51,11 +51,9 @@
import com.ruoyi.quality.pojo.QualityTestStandard;
import com.ruoyi.quality.pojo.QualityTestStandardParam;
import com.ruoyi.sales.mapper.CommonFileMapper;
-import com.ruoyi.sales.mapper.InvoiceRegistrationProductMapper;
import com.ruoyi.sales.mapper.SalesLedgerMapper;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
import com.ruoyi.sales.pojo.CommonFile;
-import com.ruoyi.sales.pojo.InvoiceRegistrationProduct;
import com.ruoyi.sales.pojo.SalesLedger;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.service.impl.CommonFileServiceImpl;
@@ -102,7 +100,6 @@
private final TicketRegistrationMapper ticketRegistrationMapper;
private final ProductRecordMapper productRecordMapper;
private final PaymentRegistrationMapper paymentRegistrationMapper;
- private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
private final StringRedisTemplate redisTemplate;
private final QualityInspectMapper qualityInspectMapper;
private final CommonFileServiceImpl commonFileService;
@@ -132,6 +129,8 @@
@Transactional(rollbackFor = Exception.class)
public int addOrEditPurchase(PurchaseLedgerDto purchaseLedgerDto) throws Exception {
PurchaseLedger purchaseLedger = new PurchaseLedger();
+ // DTO杞珽ntity
+ BeanUtils.copyProperties(purchaseLedgerDto, purchaseLedger);
SalesLedger salesLedger = salesLedgerMapper.selectById(purchaseLedgerDto.getSalesLedgerId());
//褰曞叆浜�
SysUser sysUser = userMapper.selectUserById(purchaseLedgerDto.getRecorderId());
@@ -146,9 +145,6 @@
SupplierManage supplierManage = supplierManageMapper.selectById(purchaseLedgerDto.getSupplierId());
- // DTO杞珽ntity
-
- BeanUtils.copyProperties(purchaseLedgerDto, purchaseLedger);
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtils.isNotEmpty(loginUser) && null != loginUser.getTenantId()) {
purchaseLedger.setTenantId(loginUser.getTenantId());
@@ -174,23 +170,14 @@
}
purchaseLedgerMapper.updateById(purchaseLedger);
}
- // 6.閲囪喘瀹℃牳鏂板
- addApproveByPurchase(loginUser, purchaseLedger);
// 4. 澶勭悊瀛愯〃鏁版嵁
List<SalesLedgerProduct> productList = purchaseLedgerDto.getProductData();
if (productList != null && !productList.isEmpty()) {
handleSalesLedgerProducts(purchaseLedger.getId(), productList, purchaseLedgerDto.getType());
}
- //鏂板鍘熸潗鏂欐楠� 瀹℃壒涔嬪悗鎵嶇敓鎴愭楠�
-// if (productList != null) {
-// for (SalesLedgerProduct saleProduct : productList) {
-// //鏄惁鎺ㄩ�佽川妫�锛屽鏋渢rue灏辨坊鍔�
-// if (saleProduct.getIsChecked()) {
-// addQualityInspect(purchaseLedger, saleProduct);
-// }
-// }
-// }
+ // 6.閲囪喘瀹℃牳鏂板锛涘鎵圭鐞嗘湭閰嶇疆閲囪喘瀹℃壒浜烘椂锛屽鎵规湇鍔′細鑷姩缃负瀹℃壒閫氳繃銆�
+ addApproveByPurchase(loginUser, purchaseLedger);
// 5. 杩佺Щ涓存椂鏂囦欢鍒版寮忕洰褰�
fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.PURCHASE_LEDGER, purchaseLedger.getId(), purchaseLedgerDto.getStorageBlobDTOS());
return 1;
@@ -229,6 +216,7 @@
if (products == null || products.isEmpty()) {
throw new BaseException("浜у搧淇℃伅涓嶅瓨鍦�");
}
+ Integer ledgerType = type == null ? 2 : type;
// 鎻愬墠鏀堕泦鎵�鏈夐渶瑕佹煡璇㈢殑ID
Set<Long> productIds = products.stream()
@@ -280,14 +268,14 @@
// 鎵ц鏇存柊鎿嶄綔
if (!updateList.isEmpty()) {
for (SalesLedgerProduct product : updateList) {
- product.setType(type);
+ product.setType(ledgerType);
salesLedgerProductMapper.updateById(product);
}
}
// 鎵ц鎻掑叆鎿嶄綔
if (!insertList.isEmpty()) {
for (SalesLedgerProduct salesLedgerProduct : insertList) {
- salesLedgerProduct.setType(type);
+ salesLedgerProduct.setType(ledgerType);
Date entryDate = purchaseLedger.getEntryDate();
LocalDateTime localDateTime = entryDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
@@ -510,18 +498,6 @@
}
@Override
- public List<InvoiceRegistrationProduct> getProductBySalesNo(Long id) {
- List<InvoiceRegistrationProduct> invoiceRegistrationProducts = invoiceRegistrationProductMapper.selectList(new LambdaQueryWrapper<InvoiceRegistrationProduct>()
- .select(InvoiceRegistrationProduct::getId, InvoiceRegistrationProduct::getProductCategory, InvoiceRegistrationProduct::getSpecificationModel,
- InvoiceRegistrationProduct::getUnit, InvoiceRegistrationProduct::getQuantity)
- .eq(InvoiceRegistrationProduct::getSalesLedgerId, id));
- if (invoiceRegistrationProducts.isEmpty()) {
- return new ArrayList<>();
- }
- return invoiceRegistrationProducts;
- }
-
- @Override
public String getPurchaseNo() {
// 鐢熸垚鏃ユ湡鍓嶇紑锛堜緥濡傦細CG20250405锛�
String purchaseNo = "CG" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
@@ -601,20 +577,21 @@
if(salesLedger1 != null){
salesLedger.setSalesLedgerId(salesLedger1.getId());
}
- // 閲囪喘瀹℃牳
- // 閫氳繃鏄电О鑾峰彇鐢ㄦ埛ID
- String[] split = salesLedger.getApproveUserIds().split("锛�");
- List<Long> ids = new ArrayList<>();
- for (int i = 0; i < split.length; i++) {
- SysUser sysUser = sysUserMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getNickName, split[i])
- .last("LIMIT 1"));
- if (sysUser != null) {
- ids.add(sysUser.getUserId());
+ if (StringUtils.hasText(salesLedger.getApproveUserIds())) {
+ // 閲囪喘瀹℃牳锛氬巻鍙插鍏ユā鏉夸紶瀹℃壒浜哄鍚嶆椂锛岀户缁吋瀹硅浆鎹负鐢ㄦ埛ID銆�
+ String[] split = salesLedger.getApproveUserIds().split("锛�");
+ List<Long> ids = new ArrayList<>();
+ for (int i = 0; i < split.length; i++) {
+ SysUser sysUser = sysUserMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getNickName, split[i])
+ .last("LIMIT 1"));
+ if (sysUser != null) {
+ ids.add(sysUser.getUserId());
+ }
}
+ // 灏嗛泦鍚堣浆涓哄瓧绗︿覆锛岄殧寮�
+ String collect = ids.stream().map(Object::toString).collect(Collectors.joining(","));
+ salesLedger.setApproveUserIds(collect);
}
- // 灏嗛泦鍚堣浆涓哄瓧绗︿覆锛岄殧寮�
- String collect = ids.stream().map(Object::toString).collect(Collectors.joining(","));
- salesLedger.setApproveUserIds(collect);
purchaseLedgerMapper.insert(salesLedger);
for (PurchaseLedgerProductImportDto salesLedgerProductImportDto : salesLedgerProductImportDtos) {
@@ -682,6 +659,9 @@
}
public void addApproveByPurchase(LoginUser loginUser,PurchaseLedger purchaseLedger) throws Exception {
+ if (loginUser == null) {
+ return;
+ }
ApproveProcessVO approveProcessVO = new ApproveProcessVO();
approveProcessVO.setApproveType(5);
approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
--
Gitblit v1.9.3