From a76e1d17d67641993dea6335cb8e1465a94df58d Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 21 五月 2026 15:39:05 +0800
Subject: [PATCH] feat(stock): 优化库存管理和成品树结构功能 1- 为ApproveProcessMapper.xml和ProductBomMapper.xml添加排序功能 2- 在ProductionProductMainDto中新增bomInputQty字段用于产品结构投入数量 3- 修改ProductionProductMainServiceImpl中投入数量计算逻辑,使用前端传入的bomInputQty值 4- 在ProductWorkOrderDto中添加bomInputQty字段并在服务实现中计算标准投入数量 5- 更新SalesLedgerMapper.xml查询逻辑,从product_summary获取电压信息 6- 为SalesLedgerProduct添加stockId字段并修改库存扣减逻辑使用具体库存ID 7- 重构StockInventoryController中的成品库存树查询接口和导入导出功能 8- 新增成品和非成品库存导入导出的数据模型和Excel工具类 9- 优化StockInventoryServiceImpl中的库存扣减逻辑,支持按特定库存ID操作 10- 更新库存导入导出功能,区分成品和非成品类型并提供相应模板
---
src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 54 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
index 104a712..8e18058 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
@@ -6,7 +6,16 @@
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.approve.pojo.ApproveProcess;
+import com.ruoyi.approve.service.IApproveProcessService;
+import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl;
+import com.ruoyi.approve.vo.ApproveGetAndUpdateVo;
+import com.ruoyi.approve.vo.ApproveProcessVO;
+import com.ruoyi.common.utils.OrderUtils;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
+import com.ruoyi.common.utils.uuid.UUID;
+import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.sales.dto.SalesQuotationDto;
import com.ruoyi.sales.mapper.SalesQuotationMapper;
import com.ruoyi.sales.mapper.SalesQuotationProductMapper;
@@ -19,6 +28,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.time.LocalDate;
+import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -31,6 +42,9 @@
private SalesQuotationProductMapper salesQuotationProductMapper;
@Autowired
private SalesQuotationProductService salesQuotationProductService;
+
+ @Autowired
+ private ApproveProcessServiceImpl approveProcessService;
@Override
public IPage<SalesQuotationDto> listPage(Page page, SalesQuotationDto salesQuotationDto) {
IPage<SalesQuotationDto> salesQuotationDtoIPage = salesQuotationMapper.listPage(page, salesQuotationDto);
@@ -46,29 +60,49 @@
@Override
public boolean add(SalesQuotationDto salesQuotationDto) {
+ LoginUser loginUser = SecurityUtils.getLoginUser();
SalesQuotation salesQuotation = new SalesQuotation();
BeanUtils.copyProperties(salesQuotationDto, salesQuotation);
- String quotationNo = salesQuotation.getQuotationNo();
+ String quotationNo = OrderUtils.countTodayByCreateTime(salesQuotationMapper, "QT");
+ salesQuotation.setQuotationNo(quotationNo);
+ salesQuotation.setStatus("寰呭鎵�");
salesQuotationMapper.insert(salesQuotation);
-// if(salesQuotationMapper.insert(salesQuotation)!=1){
-// return false;
-// }
if(CollectionUtils.isEmpty(salesQuotationDto.getProducts())){
return true;
}
List<SalesQuotationProduct> products = salesQuotationDto.getProducts().stream().map(product -> {
SalesQuotationProduct salesQuotationProduct = new SalesQuotationProduct();
BeanUtils.copyProperties(product, salesQuotationProduct);
- salesQuotationProduct.setSalesQuotationId(salesQuotationMapper.selectOne(new LambdaQueryWrapper<SalesQuotation>().eq(SalesQuotation::getQuotationNo, quotationNo)).getId());
+ salesQuotationProduct.setSalesQuotationId(salesQuotation.getId());
return salesQuotationProduct;
}).collect(Collectors.toList());
salesQuotationProductService.saveBatch(products);
+ // 鎶ヤ环瀹℃壒
+ ApproveProcessVO approveProcessVO = new ApproveProcessVO();
+ approveProcessVO.setApproveType(6);
+ approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
+ approveProcessVO.setApproveReason(quotationNo);
+ approveProcessVO.setApproveUserIds(salesQuotationDto.getApproveUserIds());
+ approveProcessVO.setApproveUser(loginUser.getUserId());
+ approveProcessVO.setApproveTime(LocalDate.now().toString());
+ approveProcessVO.setPrice(salesQuotationDto.getTotalAmount());
+ try {
+ approveProcessService.addApprove(approveProcessVO);
+ }catch (Exception e){
+ log.error("SalesQuotationServiceImpl error:{}", e);
+ throw new RuntimeException("瀹℃壒澶辫触");
+ }
return true;
}
@Override
public boolean edit(SalesQuotationDto salesQuotationDto) {
SalesQuotation salesQuotation = new SalesQuotation();
BeanUtils.copyProperties(salesQuotationDto, salesQuotation);
+ ApproveGetAndUpdateVo vo = new ApproveGetAndUpdateVo();
+ if("鎷掔粷".equals(salesQuotationDto.getStatus())){
+ vo.setApproveStatus(0);
+ salesQuotation.setStatus("寰呭鎵�");
+ }
if(salesQuotationMapper.updateById(salesQuotation)!=1){
return false;
}
@@ -82,13 +116,28 @@
salesQuotationProduct.setSalesQuotationId(salesQuotation.getId());
return salesQuotationProduct;
}).collect(Collectors.toList());
+
salesQuotationProductService.saveBatch(products);
+ // 淇敼鎶ヤ环瀹℃壒
+ vo.setApproveUserIds(salesQuotationDto.getApproveUserIds());
+ vo.setApproveType(6);
+ vo.setApproveReason(salesQuotationDto.getQuotationNo());
+ approveProcessService.updateApproveUser(vo);
return true;
}
@Override
public boolean delete(Long id) {
+ SalesQuotation salesQuotation = salesQuotationMapper.selectById(id);
+ if(salesQuotation==null) return false;
salesQuotationMapper.deleteById(id);
salesQuotationProductMapper.delete(new LambdaQueryWrapper<SalesQuotationProduct>().eq(SalesQuotationProduct::getSalesQuotationId, id));
+ // 鍒犻櫎鎶ヤ环瀹℃壒
+ ApproveProcess one = approveProcessService.getOne(new LambdaQueryWrapper<ApproveProcess>()
+ .eq(ApproveProcess::getApproveType, 6)
+ .eq(ApproveProcess::getApproveReason, salesQuotation.getQuotationNo()));
+ if(one != null){
+ approveProcessService.delByIds(Collections.singletonList(one.getId()));
+ }
return true;
}
--
Gitblit v1.9.3