From cf6b1cf6fa8f7784c6d7c64b7326d4662bc3d4b3 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期二, 14 十月 2025 17:39:06 +0800
Subject: [PATCH] yys 1.智能排产 2.物料看板 3.报表分析
---
main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java | 58 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 42 insertions(+), 16 deletions(-)
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java
index ed6177c..ff3ec62 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java
@@ -1,7 +1,6 @@
package com.ruoyi.business.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -15,6 +14,7 @@
import com.ruoyi.business.mapper.PendingInventoryMapper;
import com.ruoyi.business.mapper.PurchaseRegistrationMapper;
import com.ruoyi.business.service.PurchaseRegistrationService;
+import com.ruoyi.business.utils.OrderUtils;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
@@ -24,7 +24,10 @@
import org.springframework.util.Assert;
import java.time.LocalDate;
+import java.util.Arrays;
+import java.util.List;
import java.util.Objects;
+import java.util.stream.Collectors;
/**
* <p>
@@ -48,16 +51,29 @@
private final SupplyMapper supplyMapper;
@Override
- public IPage<PurchaseRegistration> selectPurchaseRegistrationList(Page page, PurchaseRegistrationDto purchaseRegistrationDto) {
+ public IPage<PurchaseRegistration> selectPurchaseRegistrationList(Page<PurchaseRegistration> page, PurchaseRegistrationDto dto) {
LambdaQueryWrapper<PurchaseRegistration> queryWrapper = new LambdaQueryWrapper<>();
- if (StringUtils.isNotBlank(purchaseRegistrationDto.getSearchAll())){
- queryWrapper.and(wrapper -> wrapper
- .like(PurchaseRegistration::getCoal, purchaseRegistrationDto.getSearchAll())
- .or()
- .like(PurchaseRegistration::getSupplierName, purchaseRegistrationDto.getSearchAll())
- );
+
+ String keyword = dto.getSearchAll();
+ if (StringUtils.isNotBlank(keyword)) {
+ // 鏌ヨ鐓ょ鍚嶇О涓ā绯婂尮閰嶇殑coalId鍒楄〃
+ List<Long> matchedCoalIds = coalInfoMapper.selectList(
+ new LambdaQueryWrapper<CoalInfo>().like(CoalInfo::getCoal, keyword)
+ ).stream()
+ .map(CoalInfo::getId)
+ .collect(Collectors.toList());
+
+ // 缁勮鏌ヨ鏉′欢锛氱叅绉岻D鍦ㄥ尮閰嶇殑鍒楄〃涓�
+ queryWrapper.and(w -> {
+ if (!matchedCoalIds.isEmpty()) {
+ w.in(PurchaseRegistration::getCoalId, matchedCoalIds).or();
+ }
+ w.like(PurchaseRegistration::getSupplierName, keyword);
+ });
}
+
queryWrapper.orderByDesc(PurchaseRegistration::getCreateTime);
+
return purchaseRegistrationMapper.selectPage(page, queryWrapper);
}
@@ -74,13 +90,15 @@
if (coalInfo == null) {
throw new BaseException("鐓ょ淇℃伅涓嶅瓨鍦�");
}
- purchaseRegistration.setCoal(coalInfo.getCoal());
Supply supply = supplyMapper.selectById(purchaseRegistrationDto.getSupplierId());
if (supply == null) {
throw new BaseException("渚涘簲鍟嗕俊鎭笉瀛樺湪");
}
purchaseRegistration.setSupplierName(supply.getSupplierName());
if (Objects.isNull(purchaseRegistrationDto.getId())) {
+ // 鐢熸垚閲囪喘鍗曞彿
+ String pr = OrderUtils.countTodayByCreateTime(purchaseRegistrationMapper, "PR");
+ purchaseRegistration.setPurchaseNumber(pr);
// 鏂板閲囪喘鐧昏
purchaseRegistration.setRegistrationDate(LocalDate.now());
int insertCount = purchaseRegistrationMapper.insert(purchaseRegistration);
@@ -88,6 +106,7 @@
// 閲囪喘鐧昏鎴愬姛锛屽悓姝ュ垱寤哄緟鍏ュ簱璁板綍
PendingInventory pendingInventory = createPendingInventory(purchaseRegistration);
pendingInventory.setSupplierName(supply.getSupplierName());
+ pendingInventory.setPurchaseNumber(pr);
return pendingInventoryMapper.insert(pendingInventory);
}
return insertCount;
@@ -109,21 +128,28 @@
BeanUtils.copyProperties(purchaseRegistration, pendingInventory);
// 璁剧疆寰呭叆搴撹褰曠壒鏈夌殑灞炴�э紙濡傛灉鏈夛級
+ pendingInventory.setId(null);
+ pendingInventory.setPurchaseId(purchaseRegistration.getId());
+ pendingInventory.setCoalId(purchaseRegistration.getCoalId());
pendingInventory.setInventoryQuantity(purchaseRegistration.getPurchaseQuantity());
+ pendingInventory.setType(purchaseRegistration.getType());
return pendingInventory;
}
@Override
+ @Transactional(rollbackFor = Exception.class)
public int delByIds(Long[] ids) {
- // 妫�鏌ュ弬鏁�
if (ids == null || ids.length == 0) {
return 0;
}
- // 鏋勯�犳洿鏂版潯浠�
- UpdateWrapper<PurchaseRegistration> updateWrapper = new UpdateWrapper<>();
- updateWrapper.in("id", ids)
- .set("deleted", 1); // 璁剧疆 deleted 涓� 1 琛ㄧず宸插垹闄�
- // 鎵ц鎵归噺閫昏緫鍒犻櫎
- return purchaseRegistrationMapper.update(null, updateWrapper);
+
+ // 1. 鍒犻櫎鍏宠仈鐨凱endingInventory璁板綍
+ LambdaQueryWrapper<PendingInventory> wrapper = new LambdaQueryWrapper<>();
+ wrapper.in(PendingInventory::getPurchaseId, Arrays.asList(ids));
+ pendingInventoryMapper.delete(wrapper); // 鏀逛负delete鎿嶄綔
+
+ // 2. 鎵归噺鍒犻櫎閲囪喘娉ㄥ唽璁板綍
+ return purchaseRegistrationMapper.deleteByIds(Arrays.asList(ids));
}
+
}
--
Gitblit v1.9.3