From 214f90a39cdf2d401f9eb50084d062dab878a249 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期三, 21 一月 2026 17:42:49 +0800
Subject: [PATCH] yys 1.车俩管理开发 2.调整生产管控流
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 345 ++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 289 insertions(+), 56 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 a31835b..7cdba61 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.sales.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
@@ -8,20 +9,39 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.account.pojo.AccountIncome;
+import com.ruoyi.account.service.AccountIncomeService;
import com.ruoyi.basic.mapper.CustomerMapper;
+import com.ruoyi.basic.mapper.ProductMapper;
+import com.ruoyi.basic.mapper.ProductModelMapper;
import com.ruoyi.basic.pojo.Customer;
+import com.ruoyi.basic.pojo.Product;
+import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.common.enums.FileNameType;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.framework.security.LoginUser;
+import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.other.mapper.TempFileMapper;
import com.ruoyi.other.pojo.TempFile;
+import com.ruoyi.production.dto.ProductStructureDto;
+import com.ruoyi.production.mapper.*;
+import com.ruoyi.production.pojo.*;
import com.ruoyi.project.system.domain.SysDept;
+import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.mapper.SysDeptMapper;
+import com.ruoyi.project.system.mapper.SysUserMapper;
+import com.ruoyi.quality.mapper.QualityInspectMapper;
+import com.ruoyi.quality.pojo.QualityInspect;
import com.ruoyi.sales.dto.MonthlyAmountDto;
import com.ruoyi.sales.dto.SalesLedgerDto;
+import com.ruoyi.sales.dto.SalesLedgerImportDto;
+import com.ruoyi.sales.dto.SalesLedgerProductImportDto;
import com.ruoyi.sales.mapper.*;
import com.ruoyi.sales.pojo.*;
+import com.ruoyi.sales.service.ISalesLedgerProductService;
import com.ruoyi.sales.service.ISalesLedgerService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -33,10 +53,13 @@
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
+import java.io.InputStream;
import java.lang.reflect.Field;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -60,12 +83,14 @@
@RequiredArgsConstructor
@Slf4j
public class SalesLedgerServiceImpl extends ServiceImpl<SalesLedgerMapper, SalesLedger> implements ISalesLedgerService {
+ private final AccountIncomeService accountIncomeService;
private final SalesLedgerMapper salesLedgerMapper;
private final CustomerMapper customerMapper;
private final SalesLedgerProductMapper salesLedgerProductMapper;
+ private final SalesLedgerProductServiceImpl salesLedgerProductServiceImpl;
private final CommonFileMapper commonFileMapper;
@@ -74,6 +99,35 @@
private final ReceiptPaymentMapper receiptPaymentMapper;
private final InvoiceLedgerMapper invoiceLedgerMapper;
+
+ private final SalesLedgerSchedulingMapper salesLedgerSchedulingMapper;
+
+ private final SalesLedgerWorkMapper salesLedgerWorkMapper;
+
+ private final SalesLedgerProductionAccountingMapper salesLedgerProductionAccountingMapper;
+
+ private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
+
+ private final InvoiceRegistrationMapper invoiceRegistrationMapper;
+
+ private final ProductOrderMapper productOrderMapper;
+
+ private final ProcessRouteMapper processRouteMapper;
+ private final ProductProcessRouteMapper productProcessRouteMapper;
+
+ private final ProcessRouteItemMapper processRouteItemMapper;
+
+ private final ProductProcessRouteItemMapper productProcessRouteItemMapper;
+
+ private final ProductWorkOrderMapper productWorkOrderMapper;
+
+ private final ProductionProductMainMapper productionProductMainMapper;
+
+ private final ProductionProductOutputMapper productionProductOutputMapper;
+
+ private final ProductionProductInputMapper productionProductInputMapper;
+
+ private final QualityInspectMapper qualityInspectMapper;
@Autowired
private SysDeptMapper sysDeptMapper;
@@ -86,6 +140,13 @@
private static final long LOCK_EXPIRE_TIME = 30; // 閿佽嚜鍔ㄨ繃鏈熸椂闂达紙绉掞級
private final RedisTemplate<String, String> redisTemplate;
+ @Autowired
+ private ProductModelMapper productModelMapper;
+
+ @Autowired
+ private ProductMapper productMapper;
+ @Autowired
+ private ProductStructureMapper productStructureMapper;
@Override
public List<SalesLedger> selectSalesLedgerList(SalesLedgerDto salesLedgerDto) {
@@ -103,6 +164,7 @@
// 2. 鏌ヨ瀛愯〃
LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>();
productWrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedger.getId());
+ productWrapper.eq(SalesLedgerProduct::getType, 1);
List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(productWrapper);
for (SalesLedgerProduct product : products) {
product.setOriginalNoInvoiceNum(product.getNoInvoiceNum());
@@ -110,12 +172,13 @@
product.setTempnoInvoiceAmount(product.getNoInvoiceAmount());
product.setTempNoInvoiceNum(product.getNoInvoiceNum());
product.setRegister(SecurityUtils.getLoginUser().getUser().getNickName());
- product.setRegisterDate(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+ product.setRegisterDate(LocalDateTime.now());
}
// 3.鏌ヨ涓婁紶鏂囦欢
LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>();
- salesLedgerFileWrapper.eq(CommonFile::getCommonId, salesLedger.getId());
+ salesLedgerFileWrapper.eq(CommonFile::getCommonId, salesLedger.getId())
+ .eq(CommonFile::getType, FileNameType.SALE.getValue());
List<CommonFile> salesLedgerFiles = commonFileMapper.selectList(salesLedgerFileWrapper);
// 4. 杞崲 DTO
@@ -171,8 +234,8 @@
// 鏌ヨ鍘熷鏁版嵁
LambdaQueryWrapper<SalesLedger> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.select(SalesLedger::getCustomerId,
- SalesLedger::getCustomerName,
- SalesLedger::getContractAmount)
+ SalesLedger::getCustomerName,
+ SalesLedger::getContractAmount)
.orderByDesc(SalesLedger::getContractAmount);
List<SalesLedger> records = salesLedgerMapper.selectList(queryWrapper);
@@ -180,7 +243,7 @@
Map<Long, GroupedCustomer> groupedMap = new LinkedHashMap<>(); // 浣跨敤LinkedHashMap淇濇寔鎺掑簭
for (SalesLedger record : records) {
groupedMap.computeIfAbsent(record.getCustomerId(),
- k -> new GroupedCustomer(record.getCustomerId(), record.getCustomerName()))
+ k -> new GroupedCustomer(record.getCustomerId(), record.getCustomerName()))
.addAmount(record.getContractAmount());
}
@@ -199,58 +262,175 @@
}
@Override
- public List<MonthlyAmountDto> getAmountHalfYear() {
+ public List<MonthlyAmountDto> getAmountHalfYear(Integer type) {
LocalDate now = LocalDate.now();
- YearMonth currentMonth = YearMonth.from(now);
+ LocalDateTime currentDateTime = LocalDateTime.now();
- List<MonthlyAmountDto> monthlyAmounts = new ArrayList<>();
+ // 鏍规嵁 type 纭畾鏌ヨ鐨勬椂闂撮棿闅旓紙澶╂暟锛夊拰鎬绘煡璇㈠ぉ鏁�
+ int daysPerPeriod;
+ int totalDays;
+ switch (type) {
+ case 1:
+ daysPerPeriod = 5; // 姣�5澶╂煡涓�娆�
+ totalDays = 30; // 6娆� 脳 5澶� = 30澶�
+ break;
+ case 2:
+ daysPerPeriod = 15; // 姣�15澶╂煡涓�娆�
+ totalDays = 90; // 6娆� 脳 15澶� = 90澶�
+ break;
+ case 3:
+ daysPerPeriod = 30; // 姣�30澶╂煡涓�娆�
+ totalDays = 180; // 6娆� 脳 30澶� = 180澶�
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid type value: " + type);
+ }
+ List<MonthlyAmountDto> result = new ArrayList<>();
+
+ // 寰幆6娆★紝姣忔鏌ヨ涓�涓椂闂存鐨勬暟鎹�
for (int i = 0; i < 6; i++) {
- YearMonth targetMonth = currentMonth.minusMonths(i);
- LocalDate firstDayOfMonth = targetMonth.atDay(1);
- LocalDate firstDayOfNextMonth = targetMonth.plusMonths(1).atDay(1);
+ // 璁$畻褰撳墠鏃堕棿娈电殑璧峰鍜岀粨鏉熸椂闂�
+ LocalDateTime endTime = currentDateTime.minusDays(i * daysPerPeriod);
+ LocalDateTime startTime = endTime.minusDays(daysPerPeriod);
- LocalDateTime startOfMonth = firstDayOfMonth.atStartOfDay();
- LocalDateTime startOfNextMonth = firstDayOfNextMonth.atStartOfDay();
+ // 鏌ヨ鍥炴閲戦
+ LambdaQueryWrapper<ReceiptPayment> receiptPaymentQuery = new LambdaQueryWrapper<>();
+ receiptPaymentQuery
+ .ge(ReceiptPayment::getCreateTime, startTime)
+ .lt(ReceiptPayment::getCreateTime, endTime);
+ List<ReceiptPayment> receiptPayments = receiptPaymentMapper.selectList(receiptPaymentQuery);
- LambdaQueryWrapper<ReceiptPayment> receiptPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>();
- receiptPaymentLambdaQueryWrapper.ge(ReceiptPayment::getCreateTime, startOfMonth)
- .lt(ReceiptPayment::getCreateTime, startOfNextMonth);
+ // 鏌ヨ寮�绁ㄩ噾棰�
+ LambdaQueryWrapper<InvoiceLedger> invoiceLedgerQuery = new LambdaQueryWrapper<>();
+ invoiceLedgerQuery
+ .ge(InvoiceLedger::getCreateTime, startTime)
+ .lt(InvoiceLedger::getCreateTime, endTime);
+ List<InvoiceLedger> invoiceLedgers = invoiceLedgerMapper.selectList(invoiceLedgerQuery);
- LambdaQueryWrapper<InvoiceLedger> invoiceLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
- invoiceLedgerLambdaQueryWrapper.ge(InvoiceLedger::getCreateTime, startOfMonth)
- .lt(InvoiceLedger::getCreateTime, startOfNextMonth);
-
- // 鑾峰彇鍥炴閲戦
- List<ReceiptPayment> receiptPaymentList = receiptPaymentMapper.selectList(receiptPaymentLambdaQueryWrapper);
- //寮�绁ㄩ噾棰�
- List<InvoiceLedger> invoiceLedgerList = invoiceLedgerMapper.selectList(invoiceLedgerLambdaQueryWrapper);
-
- // 浣跨敤 Stream 姹傚拰
- BigDecimal invoiceAmount = invoiceLedgerList.stream()
- .map(InvoiceLedger::getInvoiceTotal)
- .filter(Objects::nonNull)
- .reduce(BigDecimal.ZERO, BigDecimal::add);
-
- BigDecimal receiptAmount = receiptPaymentList.stream()
+ // 璁$畻鍥炴鎬婚
+ BigDecimal receiptAmount = receiptPayments.stream()
.map(ReceiptPayment::getReceiptPaymentAmount)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
- MonthlyAmountDto monthlyAmount = new MonthlyAmountDto();
- monthlyAmount.setMonth(targetMonth.format(DateTimeFormatter.ofPattern("yyyy-MM")));
- monthlyAmount.setInvoiceAmount(invoiceAmount);
- monthlyAmount.setReceiptAmount(receiptAmount);
+ // 璁$畻寮�绁ㄦ�婚
+ BigDecimal invoiceAmount = invoiceLedgers.stream()
+ .map(InvoiceLedger::getInvoiceTotal)
+ .filter(Objects::nonNull)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
- monthlyAmounts.add(monthlyAmount);
+ // 鏋勯�犺繑鍥炵殑 DTO
+ MonthlyAmountDto dto = new MonthlyAmountDto();
+ dto.setMonth(startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " ~ " +
+ endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+ dto.setReceiptAmount(receiptAmount);
+ dto.setInvoiceAmount(invoiceAmount);
+
+ result.add(dto);
}
- Collections.reverse(monthlyAmounts);
- return monthlyAmounts;
+
+ // 鍙嶈浆鍒楄〃锛屼娇鏃堕棿椤哄簭浠庢棭鍒版櫄
+ Collections.reverse(result);
+ return result;
}
@Override
public IPage<SalesLedger> selectSalesLedgerListPage(Page page, SalesLedgerDto salesLedgerDto) {
return salesLedgerMapper.selectSalesLedgerListPage(page, salesLedgerDto);
+ }
+
+ @Autowired
+ private SysUserMapper sysUserMapper;
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public AjaxResult importData(MultipartFile file) {
+ LoginUser loginUser = SecurityUtils.getLoginUser();
+ try {
+ InputStream inputStream = file.getInputStream();
+ ExcelUtil<SalesLedgerImportDto> salesLedgerImportDtoExcelUtil = new ExcelUtil<>(SalesLedgerImportDto.class);
+ Map<String, List<SalesLedgerImportDto>> stringListMap = salesLedgerImportDtoExcelUtil.importExcelMultiSheet(Arrays.asList("閿�鍞彴璐︽暟鎹�","閿�鍞骇鍝佹暟鎹�"), inputStream, 0);
+ if(CollectionUtils.isEmpty(stringListMap)) return AjaxResult.error("閿�鍞〃鏍间负绌猴紒");
+ // 涓氬姟灞傚悎骞�
+ List<SalesLedgerImportDto> salesLedgerImportDtoList = stringListMap.get("閿�鍞彴璐︽暟鎹�");
+ if(CollectionUtils.isEmpty(salesLedgerImportDtoList)) return AjaxResult.error("閿�鍞彴璐︽暟鎹负绌猴紒");
+ List<SalesLedgerImportDto> salesLedgerProductImportDtoList = stringListMap.get("閿�鍞骇鍝佹暟鎹�");
+ if(CollectionUtils.isEmpty(salesLedgerProductImportDtoList)) return AjaxResult.error("閿�鍞骇鍝佹暟鎹负绌猴紒");
+ // 瀹㈡埛鏁版嵁
+ List<Customer> customers = customerMapper.selectList(new LambdaQueryWrapper<Customer>().in(Customer::getCustomerName,
+ salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getCustomerName).toArray(String[]::new)));
+ // 瑙勬牸鍨嬪彿鏁版嵁
+ List<ProductModel> productModels = productModelMapper.selectList(new LambdaQueryWrapper<ProductModel>().in(ProductModel::getModel,
+ salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getSpecificationModel).toArray(String[]::new)));
+ // 浜у搧澶х被鏁版嵁
+ List<Product> productList = productMapper.selectList(new LambdaQueryWrapper<Product>().in(Product::getProductName,
+ salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getProductCategory).toArray(String[]::new)));
+ // 褰曞叆浜烘暟鎹�
+ List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().in(SysUser::getNickName,
+ salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getEntryPerson).toArray(String[]::new)));
+ for (SalesLedgerImportDto salesLedgerImportDto : salesLedgerImportDtoList) {
+ SalesLedger salesLedger = new SalesLedger();
+ BeanUtils.copyProperties(salesLedgerImportDto, salesLedger);
+ // 閫氳繃瀹㈡埛鍚嶇О鏌ヨ瀹㈡埛ID锛屽鎴峰悎鍚屽彿
+ salesLedger.setCustomerId(customers.stream()
+ .filter(customer -> customer.getCustomerName().equals(salesLedger.getCustomerName()))
+ .findFirst()
+ .map(Customer::getId)
+ .orElse(null));
+ salesLedger.setCustomerContractNo(customers.stream()
+ .filter(customer -> customer.getCustomerName().equals(salesLedger.getCustomerName()))
+ .findFirst()
+ .map(Customer::getTaxpayerIdentificationNumber)
+ .orElse(null));
+ Long aLong = sysUsers.stream()
+ .filter(sysUser -> sysUser.getNickName().equals(salesLedger.getEntryPerson()))
+ .findFirst()
+ .map(SysUser::getUserId)
+ .orElse(null);
+ if(aLong == null) throw new RuntimeException("褰曞叆浜�:"+salesLedger.getEntryPerson()+",鏃犲搴旂敤鎴凤紒");
+ salesLedger.setEntryPerson(aLong.toString());
+ salesLedgerMapper.insert(salesLedger);
+ // 閿�鍞骇鍝佹暟鎹粦瀹氾紝閫氳繃閿�鍞崟鍙疯幏鍙栧搴旈攢鍞骇鍝佹暟鎹�
+ List<SalesLedgerProductImportDto> salesLedgerProductImportDtos = salesLedgerProductImportDtoList.stream()
+ .filter(salesLedgerProductImportDto -> salesLedgerProductImportDto.getSalesContractNo().equals(salesLedger.getSalesContractNo()))
+ .collect(Collectors.toList());
+ if(CollectionUtils.isEmpty(salesLedgerProductImportDtos)) throw new RuntimeException("閿�鍞崟鍙�:"+salesLedgerImportDto.getSalesContractNo()+",鏃犲搴斾骇鍝佹暟鎹紒");
+ for (SalesLedgerProductImportDto salesLedgerProductImportDto : salesLedgerProductImportDtos) {
+ SalesLedgerProduct salesLedgerProduct = new SalesLedgerProduct();
+ BeanUtils.copyProperties(salesLedgerProductImportDto, salesLedgerProduct);
+ salesLedgerProduct.setSalesLedgerId(salesLedger.getId());
+ salesLedgerProduct.setType(1);
+ // 璁$畻涓嶅惈绋庢�讳环
+ salesLedgerProduct.setTaxExclusiveTotalPrice(salesLedgerProduct.getTaxInclusiveTotalPrice().divide(new BigDecimal(1).add(salesLedgerProduct.getTaxRate().divide(new BigDecimal(100))), 2, RoundingMode.HALF_UP));
+ salesLedgerProduct.setNoInvoiceNum(salesLedgerProduct.getQuantity());
+ salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxExclusiveTotalPrice());
+
+ salesLedgerProduct.setProductId(productList.stream()
+ .filter(product -> product.getProductName().equals(salesLedgerProduct.getProductCategory()))
+ .findFirst()
+ .map(Product::getId)
+ .orElse(null));
+ salesLedgerProduct.setProductModelId(productModels.stream()
+ .filter(productModel -> productModel.getModel().equals(salesLedgerProduct.getSpecificationModel()))
+ .findFirst()
+ .map(ProductModel::getId)
+ .orElse(null));
+ salesLedgerProduct.setRegister(loginUser.getNickName());
+ salesLedgerProduct.setRegisterDate(LocalDateTime.now());
+ salesLedgerProduct.setApproveStatus(0);
+ salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProductImportDto.getTaxInclusiveTotalPrice());
+ salesLedgerProductMapper.insert(salesLedgerProduct);
+ }
+
+
+ }
+
+ return AjaxResult.success("瀵煎叆鎴愬姛");
+ }catch (Exception e) {
+ e.printStackTrace();
+ }
+ return AjaxResult.success("瀵煎叆澶辫触");
}
// 鍐呴儴绫荤敤浜庡瓨鍌ㄨ仛鍚堢粨鏋�
@@ -311,15 +491,63 @@
List<Long> idList = Arrays.stream(ids)
.filter(Objects::nonNull)
.collect(Collectors.toList());
-
if (CollectionUtils.isEmpty(idList)) {
return 0;
}
- // 1. 鍏堝垹闄ゅ瓙琛ㄦ暟鎹�
- LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>();
- productWrapper.in(SalesLedgerProduct::getSalesLedgerId, idList);
- salesLedgerProductMapper.delete(productWrapper);
+ // 鍒犻櫎閿�鍞鐞嗘暟鎹�
+ LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.in(SalesLedgerProduct::getSalesLedgerId, idList)
+ .select(SalesLedgerProduct::getId);
+ List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(queryWrapper);
+ List<Long> productIds = products.stream()
+ .map(SalesLedgerProduct::getId)
+ .collect(Collectors.toList());
+
+ //鍒犻櫎鐢熶骇鏁版嵁
+ salesLedgerProductServiceImpl.deleteProductionData(productIds);
+
+ // 鎵归噺鍒犻櫎浜у搧瀛愯〃
+ if (!productIds.isEmpty()) {
+ salesLedgerProductMapper.deleteBatchIds(productIds);
+ }
+ LambdaQueryWrapper<InvoiceRegistrationProduct> wrapper = new LambdaQueryWrapper<>();
+ wrapper.in(InvoiceRegistrationProduct::getSalesLedgerId, idList);
+ List<InvoiceRegistrationProduct> invoiceRegistrationProducts = invoiceRegistrationProductMapper.selectList(wrapper);
+ List<Integer> invoiceLedgerIds = new ArrayList<>();
+ if (CollectionUtils.isNotEmpty(invoiceRegistrationProducts)) {
+ LambdaQueryWrapper<InvoiceLedger> wrapperOne = new LambdaQueryWrapper<>();
+ wrapperOne.in(InvoiceLedger::getInvoiceRegistrationProductId, invoiceRegistrationProducts.stream().map(InvoiceRegistrationProduct::getId).collect(Collectors.toList()));
+ List<InvoiceLedger> invoiceLedgers = invoiceLedgerMapper.selectList(wrapperOne);
+ if (CollectionUtils.isNotEmpty(invoiceLedgers)) {
+ invoiceLedgerIds = invoiceLedgers.stream().map(InvoiceLedger::getId).collect(Collectors.toList());
+ }
+ invoiceLedgerMapper.delete(wrapperOne);
+ }
+ invoiceRegistrationProductMapper.delete(wrapper);
+ LambdaQueryWrapper<InvoiceRegistration> wrapperTwo = new LambdaQueryWrapper<>();
+ wrapperTwo.in(InvoiceRegistration::getSalesLedgerId, idList);
+ invoiceRegistrationMapper.delete(wrapperTwo);
+
+ if (CollectionUtils.isNotEmpty(invoiceLedgerIds)) {
+ LambdaQueryWrapper<ReceiptPayment> wrapperTree = new LambdaQueryWrapper<>();
+ wrapperTree.in(ReceiptPayment::getInvoiceLedgerId, invoiceLedgerIds);
+ receiptPaymentMapper.delete(wrapperTree);
+ }
+
+ // 鍒犻櫎鐢熶骇绠℃帶鏁版嵁
+ // 鍒犻櫎鐢熶骇璁㈠崟鏁版嵁
+ 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);
// 2. 鍐嶅垹闄や富琛ㄦ暟鎹�
return salesLedgerMapper.deleteBatchIds(idList);
}
@@ -338,7 +566,6 @@
SalesLedger salesLedger = convertToEntity(salesLedgerDto);
salesLedger.setCustomerName(customer.getCustomerName());
salesLedger.setTenantId(customer.getTenantId());
-
// 3. 鏂板鎴栨洿鏂颁富琛�
if (salesLedger.getId() == null) {
String contractNo = generateSalesContractNo();
@@ -415,12 +642,15 @@
try {
// 鎵ц鏂囦欢杩佺Щ锛堜娇鐢ㄥ師瀛愭搷浣滅‘淇濆畨鍏ㄦ�э級
- Files.move(
- Paths.get(tempFile.getTempPath()),
- formalFilePath,
- StandardCopyOption.REPLACE_EXISTING,
- StandardCopyOption.ATOMIC_MOVE
- );
+// Files.move(
+// Paths.get(tempFile.getTempPath()),
+// formalFilePath,
+// StandardCopyOption.REPLACE_EXISTING,
+// StandardCopyOption.ATOMIC_MOVE
+// );
+ // 鍘熷瓙绉诲姩澶辫触锛屼娇鐢ㄥ鍒�+鍒犻櫎
+ Files.copy(Paths.get(tempFile.getTempPath()), formalFilePath, StandardCopyOption.REPLACE_EXISTING);
+ Files.deleteIfExists(Paths.get(tempFile.getTempPath()));
log.info("鏂囦欢杩佺Щ鎴愬姛: {} -> {}", tempFile.getTempPath(), formalFilePath);
// 鏇存柊鏂囦欢璁板綍锛堝叧鑱斿埌涓氬姟ID锛�
@@ -465,10 +695,14 @@
// 鎵ц鎻掑叆鎿嶄綔
if (!insertList.isEmpty()) {
for (SalesLedgerProduct salesLedgerProduct : insertList) {
+ salesLedgerProduct.setRegisterDate(LocalDateTime.now());
salesLedgerProduct.setType(type);
salesLedgerProduct.setNoInvoiceNum(salesLedgerProduct.getQuantity());
salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxInclusiveTotalPrice());
+ salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice());
salesLedgerProductMapper.insert(salesLedgerProduct);
+ // 娣诲姞鐢熶骇鏁版嵁
+// salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct);
}
}
}
@@ -522,12 +756,12 @@
return datePart + String.format("%03d", nextSequence);
} finally {
- // 3. 閲婃斁閿侊紙浣跨敤Lua鑴氭湰淇濊瘉鍘熷瓙鎬э紝閬垮厤璇垹鍏朵粬绾跨▼鐨勯攣锛�
+ // 3. 閲婃斁閿�
String luaScript = "if redis.call('GET', KEYS[1]) == ARGV[1] then return redis.call('DEL', KEYS[1]) else return 0 end";
redisTemplate.execute(
new DefaultRedisScript<>(luaScript, Long.class),
Collections.singletonList(lockKey),
- lockValue // 鍙湁鎸佹湁鐩稿悓鍊肩殑绾跨▼鎵嶈兘鍒犻櫎閿�
+ lockValue
);
}
}
@@ -536,7 +770,7 @@
if (sequences.isEmpty()) {
return 1;
}
- // 鎺掑簭鍚庢煡鎵剧涓�涓己澶辩殑姝f暣鏁帮紙涓庡師閫昏緫涓�鑷达級
+ // 鎺掑簭鍚庢煡鎵剧涓�涓己澶辩殑姝f暣鏁�
sequences.sort(Integer::compareTo);
int next = 1;
for (int seq : sequences) {
@@ -566,14 +800,13 @@
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
- // 鏋勯�犱富琛ㄦ洿鏂板璞★紙鏀寔浠绘剰涓昏〃绫诲瀷锛�
+ // 鏋勯�犱富琛ㄦ洿鏂板璞�
try {
S entity = mainEntityClass.getDeclaredConstructor().newInstance();
Field idField = mainEntityClass.getDeclaredField("id");
idField.setAccessible(true);
idField.set(entity, mainId);
- // 璁剧疆 contractAmount 瀛楁锛屾敞鎰忚繖閲屽亣璁惧瓧娈靛悕涓� "contractAmount"
Field amountField = mainEntityClass.getDeclaredField("contractAmount");
amountField.setAccessible(true);
amountField.set(entity, totalAmount);
--
Gitblit v1.9.3