From 0e7cfb2e0657ef7efebfcc47c0d8cfe1f31acf61 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期四, 23 四月 2026 10:42:39 +0800
Subject: [PATCH] 导出销售台账送货单
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 309 ++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 241 insertions(+), 68 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 0ebfb5b..c5699b6 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -1,7 +1,11 @@
package com.ruoyi.sales.service.impl;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.write.metadata.WriteSheet;
+import com.alibaba.excel.write.metadata.fill.FillConfig;
+import com.alibaba.excel.write.metadata.fill.FillWrapper;
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;
@@ -9,38 +13,40 @@
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.deepoove.poi.XWPFTemplate;
+import com.deepoove.poi.config.Configure;
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.DateUtils;
+import com.ruoyi.common.utils.HackLoopTableRenderPolicy;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.device.execl.DeviceMaintenanceExeclDto;
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.production.service.ProductionProductMainService;
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.*;
import com.ruoyi.sales.mapper.*;
import com.ruoyi.sales.pojo.*;
import com.ruoyi.sales.service.ISalesLedgerProductService;
import com.ruoyi.sales.service.ISalesLedgerService;
+import com.ruoyi.stock.mapper.StockInventoryMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FilenameUtils;
@@ -53,11 +59,13 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
-import java.io.IOException;
-import java.io.InputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -65,11 +73,14 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.YearMonth;
+import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
/**
* 閿�鍞彴璐ervice涓氬姟灞傚鐞�
@@ -95,6 +106,12 @@
private final TempFileMapper tempFileMapper;
private final ReceiptPaymentMapper receiptPaymentMapper;
+
+ private final ShippingInfoServiceImpl shippingInfoServiceImpl;
+
+ private final CommonFileServiceImpl commonFileService;
+
+ private final ShippingInfoMapper shippingInfoMapper;
private final InvoiceLedgerMapper invoiceLedgerMapper;
@@ -127,6 +144,11 @@
private final QualityInspectMapper qualityInspectMapper;
+ private final StockInventoryMapper stockInventoryMapper;
+
+ private ISalesLedgerProductService salesLedgerProductService;
+
+
@Autowired
private SysDeptMapper sysDeptMapper;
@@ -145,6 +167,9 @@
private ProductMapper productMapper;
@Autowired
private ProductStructureMapper productStructureMapper;
+ @Autowired
+ private ProductionProductMainService productionProductMainService;
+ ;
@Override
public List<SalesLedger> selectSalesLedgerList(SalesLedgerDto salesLedgerDto) {
@@ -171,6 +196,17 @@
product.setTempNoInvoiceNum(product.getNoInvoiceNum());
product.setRegister(SecurityUtils.getLoginUser().getUser().getNickName());
product.setRegisterDate(LocalDateTime.now());
+ // 鍙戣揣淇℃伅
+ ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>()
+ .eq(ShippingInfo::getSalesLedgerProductId, product.getId())
+ .orderByDesc(ShippingInfo::getCreateTime)
+ .last("limit 1"));
+ if (shippingInfo != null) {
+ product.setShippingStatus(shippingInfo.getStatus());
+ }
+
+ ProductModel productModel = productModelMapper.selectById(product.getProductModelId());
+ product.setMaterialCode(productModel.getMaterialCode());
}
// 3.鏌ヨ涓婁紶鏂囦欢
@@ -188,6 +224,125 @@
resultDto.setSalesLedgerFiles(salesLedgerFiles);
}
return resultDto;
+ }
+
+ @Override
+ public void exportShippingNote(HttpServletResponse response, List<Long> ids) {
+ log.info("寮�濮嬪鍑洪�佽揣鍗曪紝鍙拌处ID鍒楄〃: {}", ids);
+
+ // 鍙傛暟鏍¢獙
+ if (ids == null || ids.isEmpty()) {
+ throw new BaseException("璇烽�夋嫨瑕佸鍑虹殑閿�鍞彴璐�");
+ }
+
+ List<SalesLedger> salesLedgerList = salesLedgerMapper.selectList(
+ Wrappers.<SalesLedger>lambdaQuery()
+ .in(SalesLedger::getId, ids)
+ );
+
+ if (salesLedgerList.isEmpty()) {
+ throw new BaseException("鏈壘鍒板搴旈攢鍞彴璐︽暟鎹�");
+ }
+
+ response.setContentType("application/zip");
+ response.setHeader("Content-Disposition", "attachment;filename=閫佽揣鍗�.zip");
+ response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
+
+ try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) {
+
+ for (SalesLedger ledger : salesLedgerList) {
+ log.info("澶勭悊鍚堝悓鍙�: {}", ledger.getSalesContractNo());
+
+ // 鏌ヨ鏄庣粏
+ SalesLedgerProduct cond = new SalesLedgerProduct();
+ cond.setSalesLedgerId(ledger.getId());
+ List<SalesLedgerProduct> productList = salesLedgerProductServiceImpl.selectSalesLedgerProductList(cond);
+
+ // 鑷姩搴忓彿+鐗╂枡缂栫爜璧嬪��
+ for (int i = 0; i < productList.size(); i++) {
+ SalesLedgerProduct product = productList.get(i);
+ if (product != null) {
+ product.setSerialNumber(i + 1);
+ product.setOrderNo(ledger.getSalesContractNo());
+ Long productModelId = product.getProductModelId();
+ if (productModelId != null) {
+ ProductModel productModel = productModelMapper.selectById(productModelId);
+ if (productModel != null) {
+ product.setMaterialCode(productModel.getMaterialCode());
+ }
+ }
+ }
+ }
+
+ // 鍏宠仈瀹㈡埛淇℃伅
+ Customer customer = customerMapper.selectById(ledger.getCustomerId());
+
+ // 璁$畻鎬诲悎璁�
+ BigDecimal totalQuantity = BigDecimal.ZERO;
+ for (SalesLedgerProduct product : productList) {
+ totalQuantity = totalQuantity.add(product.getQuantity() == null ? BigDecimal.ZERO : product.getQuantity());
+ }
+
+ // 缁勮椤堕儴闈欐�佹暟鎹�
+ Map<String, Object> dataMap = new HashMap<>();
+ dataMap.put("customerName", ledger.getCustomerName());
+ dataMap.put("companyAddress", customer.getCompanyAddress());
+ dataMap.put("contactPerson", customer.getContactPerson());
+ dataMap.put("contactPhone", customer.getContactPhone());
+ dataMap.put("companyPhone", customer.getCompanyPhone());
+ dataMap.put("salesContractNo", ledger.getSalesContractNo());
+ dataMap.put("deliveryDate", formatDate(LocalDate.now()));
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ InputStream templateIs = this.getClass().getResourceAsStream("/static/shipping-note.xlsx");
+
+ ExcelWriter writer = EasyExcel.write(bos).withTemplate(templateIs).build();
+ WriteSheet sheet = EasyExcel.writerSheet().build();
+
+ // 鍏堝~鍏呮暟鎹紙鍖呮嫭鍚堣锛�
+ Map<String, Object> totalMap = new HashMap<>();
+ totalMap.put("totalQuantity", totalQuantity);
+ dataMap.putAll(totalMap);
+ writer.fill(dataMap, sheet);
+
+ // 鍐嶅~鍏呬骇鍝佸垪琛�
+ if (!productList.isEmpty()) {
+ FillConfig fillConfig = FillConfig.builder()
+ .forceNewRow(Boolean.TRUE)
+ .build();
+ writer.fill(productList, fillConfig, sheet);
+ }
+
+ writer.finish();
+ templateIs.close();
+
+ // 鎵撳寘ZIP
+ String excelName = String.format("閫佽揣鍗昣%s.xlsx",
+ Optional.ofNullable(ledger.getSalesContractNo()).orElse(String.valueOf(ledger.getId())));
+ ZipEntry entry = new ZipEntry(excelName);
+ zos.putNextEntry(entry);
+ zos.write(bos.toByteArray());
+ zos.closeEntry();
+ bos.close();
+ }
+
+ zos.finish();
+ log.info("鎵归噺瀵煎嚭瀹屾垚锛屽叡{}浠介�佽揣鍗�", salesLedgerList.size());
+
+ } catch (BaseException e) {
+ log.error("瀵煎嚭澶辫触:{}", e.getMessage(), e);
+ throw e;
+ } catch (Exception e) {
+ log.error("瀵煎嚭寮傚父", e);
+ throw new BaseException("瀵煎嚭澶辫触锛�" + e.getMessage());
+ }
+ }
+
+ public static String formatDate(LocalDate date) {
+ if (date == null) {
+ return null;
+ }
+ return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
@Override
@@ -261,75 +416,51 @@
@Override
public List<MonthlyAmountDto> getAmountHalfYear(Integer type) {
+
LocalDate now = LocalDate.now();
- LocalDateTime currentDateTime = LocalDateTime.now();
-
- // 鏍规嵁 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++) {
- // 璁$畻褰撳墠鏃堕棿娈电殑璧峰鍜岀粨鏉熸椂闂�
- LocalDateTime endTime = currentDateTime.minusDays(i * daysPerPeriod);
- LocalDateTime startTime = endTime.minusDays(daysPerPeriod);
+ for (int i = 5; i >= 0; i--) {
+ YearMonth yearMonth = YearMonth.from(now.minusMonths(i));
+ LocalDateTime startTime = yearMonth.atDay(1).atStartOfDay();
+ LocalDateTime endTime = yearMonth.atEndOfMonth().atTime(23, 59, 59);
- // 鏌ヨ鍥炴閲戦
+ // 鍥炴閲戦
LambdaQueryWrapper<ReceiptPayment> receiptPaymentQuery = new LambdaQueryWrapper<>();
receiptPaymentQuery
.ge(ReceiptPayment::getCreateTime, startTime)
- .lt(ReceiptPayment::getCreateTime, endTime);
- List<ReceiptPayment> receiptPayments = receiptPaymentMapper.selectList(receiptPaymentQuery);
+ .le(ReceiptPayment::getCreateTime, endTime);
- // 鏌ヨ寮�绁ㄩ噾棰�
- LambdaQueryWrapper<InvoiceLedger> invoiceLedgerQuery = new LambdaQueryWrapper<>();
- invoiceLedgerQuery
- .ge(InvoiceLedger::getCreateTime, startTime)
- .lt(InvoiceLedger::getCreateTime, endTime);
- List<InvoiceLedger> invoiceLedgers = invoiceLedgerMapper.selectList(invoiceLedgerQuery);
+ List<ReceiptPayment> receiptPayments =
+ receiptPaymentMapper.selectList(receiptPaymentQuery);
- // 璁$畻鍥炴鎬婚
BigDecimal receiptAmount = receiptPayments.stream()
.map(ReceiptPayment::getReceiptPaymentAmount)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
- // 璁$畻寮�绁ㄦ�婚
+ // 寮�绁ㄩ噾棰�
+ LambdaQueryWrapper<InvoiceLedger> invoiceLedgerQuery = new LambdaQueryWrapper<>();
+ invoiceLedgerQuery
+ .ge(InvoiceLedger::getCreateTime, startTime)
+ .le(InvoiceLedger::getCreateTime, endTime);
+
+ List<InvoiceLedger> invoiceLedgers =
+ invoiceLedgerMapper.selectList(invoiceLedgerQuery);
+
BigDecimal invoiceAmount = invoiceLedgers.stream()
.map(InvoiceLedger::getInvoiceTotal)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
- // 鏋勯�犺繑鍥炵殑 DTO
MonthlyAmountDto dto = new MonthlyAmountDto();
- dto.setMonth(startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " ~ " +
- endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+ dto.setMonth(yearMonth.format(DateTimeFormatter.ofPattern("yyyy-MM")));
dto.setReceiptAmount(receiptAmount);
dto.setInvoiceAmount(invoiceAmount);
result.add(dto);
}
- // 鍙嶈浆鍒楄〃锛屼娇鏃堕棿椤哄簭浠庢棭鍒版櫄
- Collections.reverse(result);
return result;
}
@@ -364,11 +495,17 @@
// // 浜у搧澶х被鏁版嵁
// 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())));
for (SalesLedgerImportDto salesLedgerImportDto : salesLedgerImportDtoList) {
+ SalesLedger salesLedger1 = salesLedgerMapper.selectOne(new LambdaQueryWrapper<SalesLedger>()
+ .eq(SalesLedger::getSalesContractNo, salesLedgerImportDto.getSalesContractNo())
+ .last("LIMIT 1"));
+ if (salesLedger1 != null) {
+ continue;
+ }
SalesLedger salesLedger = new SalesLedger();
BeanUtils.copyProperties(salesLedgerImportDto, salesLedger);
salesLedger.setExecutionDate(DateUtils.toLocalDate(salesLedgerImportDto.getExecutionDate()));
@@ -391,13 +528,18 @@
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() + ",鏃犲搴斾骇鍝佹暟鎹紒");
+ salesLedger.setContractAmount(salesLedgerProductImportDtos.stream()
+ .map(SalesLedgerProductImportDto::getTaxInclusiveTotalPrice)
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
+ salesLedgerMapper.insert(salesLedger);
+
+
for (SalesLedgerProductImportDto salesLedgerProductImportDto : salesLedgerProductImportDtos) {
SalesLedgerProduct salesLedgerProduct = new SalesLedgerProduct();
BeanUtils.copyProperties(salesLedgerProductImportDto, salesLedgerProduct);
@@ -429,6 +571,8 @@
salesLedgerProduct.setApproveStatus(0);
salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProductImportDto.getTaxInclusiveTotalPrice());
salesLedgerProductMapper.insert(salesLedgerProduct);
+ // 娣诲姞鐢熶骇鏁版嵁
+ salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct);
}
}
@@ -551,20 +695,23 @@
wrapperTree.in(ReceiptPayment::getInvoiceLedgerId, invoiceLedgerIds);
receiptPaymentMapper.delete(wrapperTree);
}
+ // 鍒犻櫎鍙戣揣鍙拌处璁板綍
+ 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()));
+ }
+ // 鍒犻櫎闄勪欢琛�
+ 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);
}
@@ -595,7 +742,7 @@
// 4. 澶勭悊瀛愯〃鏁版嵁
List<SalesLedgerProduct> productList = salesLedgerDto.getProductData();
if (productList != null && !productList.isEmpty()) {
- handleSalesLedgerProducts(salesLedger.getId(), productList, salesLedgerDto.getType());
+ handleSalesLedgerProducts(salesLedger.getId(), productList, salesLedgerDto.getType(), salesLedgerDto.isProduce());
updateMainContractAmount(
salesLedger.getId(),
productList,
@@ -693,7 +840,7 @@
}
- private void handleSalesLedgerProducts(Long salesLedgerId, List<SalesLedgerProduct> products, Integer type) {
+ private void handleSalesLedgerProducts(Long salesLedgerId, List<SalesLedgerProduct> products, Integer type, boolean isProduce) {
// 鎸塈D鍒嗙粍锛屽尯鍒嗘柊澧炲拰鏇存柊鐨勮褰�
Map<Boolean, List<SalesLedgerProduct>> partitionedProducts = products.stream()
.peek(p -> p.setSalesLedgerId(salesLedgerId))
@@ -702,9 +849,26 @@
List<SalesLedgerProduct> updateList = partitionedProducts.get(true);
List<SalesLedgerProduct> insertList = partitionedProducts.get(false);
+// List<StockInventoryDto> stockInventoryDtos = stockInventoryMapper.selectProductList();
+
// 鎵ц鏇存柊鎿嶄綔
if (!updateList.isEmpty()) {
for (SalesLedgerProduct product : updateList) {
+// // 鏌ヨ搴撳瓨鏁伴噺
+// SalesLedgerProduct oldProduct = salesLedgerProductMapper.selectById(product.getId());
+// BigDecimal quantityChange = product.getQuantity().subtract(oldProduct.getQuantity());
+//
+// // 濡傛灉鏁伴噺澧炲姞浜嗭紝妫�鏌ュ簱瀛�
+// if (quantityChange.compareTo(BigDecimal.ZERO) > 0) {
+// for (StockInventoryDto stockInventoryDto : stockInventoryDtos) {
+// if (stockInventoryDto.getProductId().equals(product.getId())) {
+// if (quantityChange.compareTo(stockInventoryDto.getQualitity()) > 0) {
+// throw new RuntimeException("搴撳瓨涓嶈冻");
+// }
+// break;
+// }
+// }
+// }
product.setType(type);
salesLedgerProductMapper.updateById(product);
}
@@ -712,13 +876,22 @@
// 鎵ц鎻掑叆鎿嶄綔
if (!insertList.isEmpty()) {
for (SalesLedgerProduct salesLedgerProduct : insertList) {
+// for (StockInventoryDto stockInventoryDto : stockInventoryDtos) {
+// if (stockInventoryDto.getProductId().equals(salesLedgerProduct.getId())) {
+// if (salesLedgerProduct.getQuantity().compareTo(stockInventoryDto.getQualitity()) > 0) {
+// throw new RuntimeException("搴撳瓨涓嶈冻");
+// }
+// }
+// }
salesLedgerProduct.setType(type);
salesLedgerProduct.setNoInvoiceNum(salesLedgerProduct.getQuantity());
salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxInclusiveTotalPrice());
salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice());
salesLedgerProductMapper.insert(salesLedgerProduct);
// 娣诲姞鐢熶骇鏁版嵁
- salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct);
+ if (isProduce) {
+ salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct);
+ }
}
}
}
@@ -832,4 +1005,4 @@
throw new RuntimeException("鍔ㄦ�佹洿鏂颁富琛ㄩ噾棰濆け璐�", e);
}
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.3