From ffe4413db421aabb7446007ff76d4e9943c6fc84 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期五, 24 四月 2026 14:53:14 +0800
Subject: [PATCH] 删除废弃文件上传接口
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 279 insertions(+), 21 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
index c397b9f..cf333a2 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -1,19 +1,46 @@
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.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.framework.web.domain.R;
+import com.ruoyi.procurementrecord.utils.StockUtils;
+import com.ruoyi.production.mapper.*;
+import com.ruoyi.production.pojo.ProductionPlan;
+import com.ruoyi.production.service.ProductionOrderService;
+import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
+import com.ruoyi.purchase.pojo.PurchaseLedger;
+import com.ruoyi.quality.mapper.QualityInspectMapper;
+import com.ruoyi.sales.dto.InvoiceRegistrationProductDto;
+import com.ruoyi.sales.dto.SalesLedgerProductDto;
+import com.ruoyi.sales.mapper.InvoiceRegistrationProductMapper;
import com.ruoyi.sales.mapper.SalesLedgerMapper;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
+import com.ruoyi.sales.mapper.ShippingInfoMapper;
import com.ruoyi.sales.pojo.SalesLedger;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
+import com.ruoyi.sales.pojo.ShippingInfo;
import com.ruoyi.sales.service.ISalesLedgerProductService;
-import lombok.AllArgsConstructor;
+import com.ruoyi.stock.mapper.StockInventoryMapper;
+import com.ruoyi.stock.pojo.StockInventory;
+import com.ruoyi.technology.bean.vo.TechnologyBomStructureVo;
+import com.ruoyi.technology.mapper.TechnologyBomStructureMapper;
+import com.ruoyi.technology.mapper.TechnologyRoutingMapper;
+import com.ruoyi.technology.pojo.TechnologyRouting;
+import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
import java.lang.reflect.Field;
import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@@ -28,12 +55,27 @@
* @date 2025-05-08
*/
@Service
-@AllArgsConstructor
+@RequiredArgsConstructor
public class SalesLedgerProductServiceImpl extends ServiceImpl<SalesLedgerProductMapper, SalesLedgerProduct> implements ISalesLedgerProductService {
- private SalesLedgerProductMapper salesLedgerProductMapper;
-
- private SalesLedgerMapper salesLedgerMapper;
+ private final SalesLedgerProductMapper salesLedgerProductMapper;
+ private final ProductionAccountMapper productionAccountMapper;
+ private final SalesLedgerMapper salesLedgerMapper;
+ private final PurchaseLedgerMapper purchaseLedgerMapper;
+ private final ProductionPlanMapper productionPlanMapper;
+ private final ProductionOperationTaskMapper productionOperationTaskMapper;
+ private final ProductionOrderService productionOrderService;
+ private final TechnologyRoutingMapper technologyRoutingMapper;
+ private final TechnologyBomStructureMapper technologyBomStructureMapper;
+ private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
+ private final ProductionProductMainMapper productionProductMainMapper;
+ private final ProductionProductOutputMapper productionProductOutputMapper;
+ private final ProductionProductInputMapper productionProductInputMapper;
+ private final QualityInspectMapper qualityInspectMapper;
+ private final ShippingInfoMapper shippingInfoMapper;
+ private final ShippingInfoServiceImpl shippingInfoService;
+ private final StockUtils stockUtils;
+ private final StockInventoryMapper stockInventoryMapper;
@Override
public SalesLedgerProduct selectSalesLedgerProductById(Long id) {
@@ -42,9 +84,55 @@
@Override
public List<SalesLedgerProduct> selectSalesLedgerProductList(SalesLedgerProduct salesLedgerProduct) {
- LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(SalesLedgerProduct::getSalesLedgerId,salesLedgerProduct.getSalesLedgerId());
- return salesLedgerProductMapper.selectList(queryWrapper);
+// LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>();
+// queryWrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedgerProduct.getSalesLedgerId())
+// .eq(SalesLedgerProduct::getType, salesLedgerProduct.getType());
+ List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectSalesLedgerProductList(salesLedgerProduct);
+ if(!CollectionUtils.isEmpty(salesLedgerProducts)){
+ salesLedgerProducts.forEach(item -> {
+ // 鍙戣揣淇℃伅
+ ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>()
+ .eq(ShippingInfo::getSalesLedgerProductId, item.getId())
+ .orderByDesc(ShippingInfo::getCreateTime)
+ .last("limit 1"));
+ if(shippingInfo != null){
+ item.setShippingDate(shippingInfo.getShippingDate());
+ item.setShippingCarNumber(shippingInfo.getShippingCarNumber());
+ item.setShippingStatus(shippingInfo.getStatus());
+ item.setExpressCompany(shippingInfo.getExpressCompany());
+ item.setExpressNumber(shippingInfo.getExpressNumber());
+ }
+ });
+ // 寮�绁�
+ InvoiceRegistrationProductDto invoiceRegistrationProductDto = new InvoiceRegistrationProductDto();
+ invoiceRegistrationProductDto.setSalesLedgerId(salesLedgerProduct.getSalesLedgerId().intValue());
+ List<InvoiceRegistrationProductDto> invoiceRegistrationProductDtoList = invoiceRegistrationProductMapper.invoiceRegistrationProductList(invoiceRegistrationProductDto);
+ // 缁熻寮�绁ㄧ櫥璁颁骇鍝佺殑宸插紑绁ㄦ暟/宸插紑绁ㄩ噾棰�
+ if (!CollectionUtils.isEmpty(invoiceRegistrationProductDtoList)) {
+ for (SalesLedgerProduct ledgerProduct : salesLedgerProducts) {
+ BigDecimal invoiceNum = BigDecimal.ZERO;
+ BigDecimal invoiceAmount = BigDecimal.ZERO;
+ BigDecimal noInvoiceNum = BigDecimal.ZERO;
+ BigDecimal noInvoiceAmount = BigDecimal.ZERO;
+ for (InvoiceRegistrationProductDto registrationProductDto : invoiceRegistrationProductDtoList) {
+ if(ledgerProduct.getId().intValue() == registrationProductDto.getSalesLedgerProductId()){
+ invoiceNum = invoiceNum.add(registrationProductDto.getInvoiceNum());
+ invoiceAmount = invoiceAmount.add(registrationProductDto.getInvoiceAmount());
+ }
+ }
+ noInvoiceNum = ledgerProduct.getQuantity().subtract(invoiceNum);
+ noInvoiceAmount = ledgerProduct.getTaxInclusiveTotalPrice().subtract(invoiceAmount);
+ ledgerProduct.setInvoiceNum(invoiceNum);
+ ledgerProduct.setInvoiceAmount(invoiceAmount);
+ ledgerProduct.setNoInvoiceNum(noInvoiceNum);
+ ledgerProduct.setNoInvoiceAmount(noInvoiceAmount);
+
+
+ }
+ }
+
+ }
+ return salesLedgerProducts;
}
@Override
@@ -59,8 +147,14 @@
if (deletedProducts.isEmpty()) {
return 0; // 娌℃湁鍙垹闄ょ殑鏁版嵁
}
+ //鍒犻櫎鍙戣揣淇℃伅
+ List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>()
+ .in(ShippingInfo::getSalesLedgerProductId, Arrays.asList(ids)));
+ if(!CollectionUtils.isEmpty(shippingInfos)){
+ shippingInfoService.delete(shippingInfos.stream().map(ShippingInfo::getId).collect(Collectors.toList()));
+ }
- // 鍙兘灞炰簬澶氫釜涓昏〃锛堜絾閫氬父涓�涓帴鍙e彧澶勭悊涓�涓富琛級
+ // 鍙兘灞炰簬澶氫釜涓昏〃
Set<Long> mainIds = deletedProducts.stream()
.map(SalesLedgerProduct::getSalesLedgerId)
.filter(Objects::nonNull)
@@ -68,6 +162,8 @@
// 2. 鎵ц鍒犻櫎鎿嶄綔
int result = salesLedgerProductMapper.deleteBatchIds(Arrays.asList(ids));
+ //鍒犻櫎瀵瑰簲鐨勭敓浜ц鍗�
+ deleteProductionData(Arrays.asList(ids));
// 3. 瀵规瘡涓富琛↖D杩涜閲戦鏇存柊
for (Long salesLedgerId : mainIds) {
@@ -90,33 +186,130 @@
@Override
@Transactional(rollbackFor = Exception.class)
public int addOrUpdateSalesLedgerProduct(SalesLedgerProduct salesLedgerProduct) {
+ // 寰呭洖娆撅紝浠樻
+ if(salesLedgerProduct.getType().equals(1)){
+ salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getInvoiceTotal()));
+ //鏈紑绁ㄦ暟閲�+閲戦
+ salesLedgerProduct.setNoInvoiceNum(salesLedgerProduct.getQuantity());
+ salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxInclusiveTotalPrice());
+ }else{
+ salesLedgerProduct.setPendingTicketsTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getTicketsTotal()));
+ // 鏈潵绁ㄦ暟閲�+閲戦
+ salesLedgerProduct.setFutureTickets(salesLedgerProduct.getQuantity());
+ salesLedgerProduct.setFutureTicketsAmount(salesLedgerProduct.getTaxInclusiveTotalPrice());
+ }
+
int result;
Long salesLedgerId = salesLedgerProduct.getSalesLedgerId();
-
if (salesLedgerProduct.getId() == null) {
+ salesLedgerProduct.setRegisterDate(LocalDateTime.now());
result = salesLedgerProductMapper.insert(salesLedgerProduct);
+ addProductionData(salesLedgerProduct);
} else {
+ //鏌ヨ鍘熸湰鐨勪骇鍝佸瀷鍙穒d
+ salesLedgerProduct.setFutureTickets(salesLedgerProduct.getQuantity());
result = salesLedgerProductMapper.updateById(salesLedgerProduct);
+ /*鍒犻櫎瀵瑰簲鐨勭敓浜ф暟鎹苟閲嶆柊鏂板*/
+ deleteProductionData(Arrays.asList(salesLedgerProduct.getId()));
+ // 鍒犻櫎鐢熶骇鏍哥畻鏁版嵁
+
+ addProductionData(salesLedgerProduct);
}
// 濡傛灉鎻掑叆鎴栨洿鏂版垚鍔燂紝骞朵笖鏈� salesLedgerId锛屾墠缁х画鏇存柊涓昏〃閲戦
if (result > 0 && salesLedgerId != null) {
// 鏌ヨ璇ヤ富琛ㄤ笅鐨勬墍鏈夊瓙琛ㄦ暟鎹�
LambdaQueryWrapper<SalesLedgerProduct> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedgerId);
+ wrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedgerId)
+ .eq(SalesLedgerProduct::getType, salesLedgerProduct.getType());
List<SalesLedgerProduct> productList = salesLedgerProductMapper.selectList(wrapper);
-
- // 璋冪敤閫氱敤鏂规硶鏇存柊涓昏〃閲戦
- updateMainContractAmount(
- salesLedgerId,
- productList,
- SalesLedgerProduct::getTaxInclusiveTotalPrice,
- salesLedgerMapper,
- SalesLedger.class
- );
+ if (salesLedgerProduct.getType() == 1) {
+ // 璋冪敤閫氱敤鏂规硶鏇存柊涓昏〃閲戦
+ updateMainContractAmount(
+ salesLedgerId,
+ productList,
+ SalesLedgerProduct::getTaxInclusiveTotalPrice,
+ salesLedgerMapper,
+ SalesLedger.class
+ );
+ } else {
+ // 璋冪敤閫氱敤鏂规硶鏇存柊涓昏〃閲戦
+ updateMainContractAmount(
+ salesLedgerId,
+ productList,
+ SalesLedgerProduct::getTaxInclusiveTotalPrice,
+ purchaseLedgerMapper,
+ PurchaseLedger.class
+ );
+ }
}
-
return result;
+ }
+
+ /**
+ * 鏂板鐢熶骇鏁版嵁
+ */
+ public void addProductionData(SalesLedgerProduct salesLedgerProduct) {
+ //鍏堝垽鏂浜у搧鏄惁闇�瑕佺敓浜�
+ if (!salesLedgerProduct.getIsProduction()) {
+ return;
+ }
+ ProductionPlan productionPlan = new ProductionPlan();
+ productionPlan.setSalesLedgerId(salesLedgerProduct.getSalesLedgerId());
+ productionPlan.setSalesLedgerProductId(salesLedgerProduct.getId());
+ productionPlan.setMpsNo(generateNextPlanNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))));
+ productionPlan.setProductModelId(salesLedgerProduct.getProductModelId());
+ productionPlan.setQtyRequired(salesLedgerProduct.getQuantity());
+ productionPlan.setSource("閿�鍞�");
+ productionPlan.setStatus(0);
+ productionPlanMapper.insert(productionPlan);
+
+ }
+
+ /**
+ * 鍒犻櫎鐢熶骇璁″垝
+ */
+ public void deleteProductionData(List<Long> productIds) {
+ List<ProductionPlan> productionPlans = productionPlanMapper.selectList(
+ new LambdaQueryWrapper<ProductionPlan>()
+ .in(ProductionPlan::getSalesLedgerProductId, productIds.stream().map(Long::intValue).collect(Collectors.toList())));
+ if (org.springframework.util.CollectionUtils.isEmpty(productionPlans)) {
+ return;
+ }
+ //濡傛灉鐢熶骇璁″垝宸蹭笅鍙戝垯涓嶈兘鍒犻櫎
+ if (productionPlans.stream().anyMatch(productionPlan -> productionPlan.getStatus() != 0)) {
+ throw new RuntimeException("鐢熶骇璁″垝宸蹭笅鍙戯紝涓嶈兘鍒犻櫎璇ラ攢鍞骇鍝�");
+ }
+ List<Long> ids = productionPlans.stream().map(ProductionPlan::getId).collect(Collectors.toList());
+ productionPlanMapper.deleteByIds(ids);
+ }
+
+ @Override
+ public IPage<SalesLedgerProductDto> listPage(Page page, SalesLedgerProductDto salesLedgerProduct) {
+ IPage<SalesLedgerProductDto> salesLedgerProductDtoIPage = salesLedgerProductMapper.listPage(page, salesLedgerProduct);
+ salesLedgerProductDtoIPage.getRecords().forEach(item -> {
+ // 鍒ゆ柇鐘舵��
+ if(item.getTaxInclusiveTotalPrice().compareTo(item.getInvoiceTotal()) == 0){
+ item.setStatusName("宸插畬鎴愪粯娆�");
+ }else{
+ item.setStatusName("鏈畬鎴愪粯娆�");
+ }
+ });
+ return salesLedgerProductDtoIPage;
+ }
+
+ @Override
+ public IPage<SalesLedgerProductDto> listPagePurchaseLedger(Page page, SalesLedgerProductDto salesLedgerProduct) {
+ IPage<SalesLedgerProductDto> salesLedgerProductDtoIPage = salesLedgerProductMapper.listPagePurchaseLedger(page, salesLedgerProduct);
+ salesLedgerProductDtoIPage.getRecords().forEach(item -> {
+ // 鍒ゆ柇鐘舵��
+ if(item.getTaxInclusiveTotalPrice().compareTo(item.getTicketsTotal()) == 0){
+ item.setStatusName("宸插畬鎴愪粯娆�");
+ }else{
+ item.setStatusName("鏈畬鎴愪粯娆�");
+ }
+ });
+ return salesLedgerProductDtoIPage;
}
/**
@@ -153,4 +346,69 @@
throw new RuntimeException("鍔ㄦ�佹洿鏂颁富琛ㄩ噾棰濆け璐�", e);
}
}
+ @Override
+ public R judgmentInventory(SalesLedgerProduct salesLedgerProduct) {
+ TechnologyRouting routing = technologyRoutingMapper.selectOne(
+ new QueryWrapper<TechnologyRouting>().lambda()
+ .eq(TechnologyRouting::getProductModelId, salesLedgerProduct.getProductModelId())
+ .orderByDesc(TechnologyRouting::getCreateTime)
+ .last("LIMIT 1"));
+ if (routing == null) {
+ return R.fail("璇峰厛璁剧疆宸ヨ壓璺嚎");
+ }
+ List<TechnologyBomStructureVo> structureList = technologyBomStructureMapper.listByBomId(routing.getBomId().longValue());
+ if (structureList == null || structureList.isEmpty()) {
+ return R.fail("璇峰厛璁剧疆浜у搧缁撴瀯");
+ }
+ int count = 0;
+ StringBuilder stringBuffer = new StringBuilder();
+ for (TechnologyBomStructureVo structure : structureList) {
+ if (structure.getParentId() == null) {
+ continue;
+ }
+ StockInventory stockInventory = stockInventoryMapper.selectOne(
+ new QueryWrapper<StockInventory>().lambda().eq(StockInventory::getProductModelId, structure.getProductModelId()));
+ if (stockInventory == null) {
+ count++;
+ stringBuffer.append(structure.getProductName()).append("-").append(structure.getModel()).append("搴撳瓨涓嶈冻").append(System.lineSeparator());
+ continue;
+ }
+ BigDecimal required = salesLedgerProduct.getQuantity().multiply(structure.getUnitQuantity() == null ? BigDecimal.ZERO : structure.getUnitQuantity());
+ BigDecimal remain = stockInventory.getQualitity()
+ .subtract(stockInventory.getLockedQuantity())
+ .subtract(required)
+ .divide(BigDecimal.ONE, 2, RoundingMode.CEILING);
+ if (remain.compareTo(BigDecimal.ZERO) < 0) {
+ count++;
+ stringBuffer.append(structure.getProductName())
+ .append("-")
+ .append(structure.getModel())
+ .append("搴撳瓨涓嶈冻锛屽皯")
+ .append(remain.abs())
+ .append(System.lineSeparator());
+ }
+ }
+ if (count > 0) {
+ return R.fail(stringBuffer.toString());
+ }
+ return R.ok();
+ }
+
+ private String generateNextPlanNo(String datePrefix) {
+ QueryWrapper<ProductionPlan> queryWrapper = new QueryWrapper<>();
+ queryWrapper.likeRight("mps_no", "JH" + datePrefix);
+ queryWrapper.orderByDesc("mps_no");
+ queryWrapper.last("LIMIT 1");
+ ProductionPlan latestPlan = productionPlanMapper.selectOne(queryWrapper);
+ int sequence = 1;
+ if (latestPlan != null && latestPlan.getMpsNo() != null && !latestPlan.getMpsNo().isEmpty()) {
+ String sequenceStr = latestPlan.getMpsNo().substring(("JH" + datePrefix).length());
+ try {
+ sequence = Integer.parseInt(sequenceStr) + 1;
+ } catch (NumberFormatException e) {
+ sequence = 1;
+ }
+ }
+ return "JH" + datePrefix + String.format("%04d", sequence);
+ }
}
--
Gitblit v1.9.3