From 9f3a45da6d1dc9c71187f15131665eb9806f5588 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期二, 28 十月 2025 15:58:03 +0800
Subject: [PATCH] yys 1.修改配置文件 2.增加模板
---
src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesServiceImpl.java | 83 ++++++++++++-----------------------------
1 files changed, 24 insertions(+), 59 deletions(-)
diff --git a/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesServiceImpl.java b/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesServiceImpl.java
index 314be51..3d33d5c 100644
--- a/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesServiceImpl.java
+++ b/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesServiceImpl.java
@@ -9,6 +9,7 @@
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.warehouse.dto.WarehouseGoodsShelvesDto;
import com.ruoyi.warehouse.mapper.DocumentationMapper;
import com.ruoyi.warehouse.mapper.WarehouseGoodsShelvesMapper;
import com.ruoyi.warehouse.mapper.WarehouseGoodsShelvesRowcolMapper;
@@ -36,6 +37,7 @@
*/
@Service
@Slf4j
+@Transactional(rollbackFor = Exception.class)
public class WarehouseGoodsShelvesServiceImpl extends ServiceImpl<WarehouseGoodsShelvesMapper, WarehouseGoodsShelves>
implements WarehouseGoodsShelvesService {
@Autowired
@@ -48,34 +50,28 @@
private DocumentationService documentationService;
@Autowired
private DocumentationMapper documentationMapper;
- @Override
- public IPage<WarehouseGoodsShelves> listPage(Page page, WarehouseGoodsShelves warehouseGoodsShelves) {
- return warehouseGoodsShelvesMapper.listPage(page,warehouseGoodsShelves);
- }
@Override
- @Transactional(rollbackFor = Exception.class)
public boolean add(WarehouseGoodsShelves warehouseGoodsShelves) {
WarehouseGoodsShelves one = warehouseGoodsShelvesMapper.selectOne(new LambdaQueryWrapper<WarehouseGoodsShelves>().eq(WarehouseGoodsShelves::getId, warehouseGoodsShelves.getId()));
// 1. 妫�鏌ヨ揣鏋跺悕绉版槸鍚﹀凡瀛樺湪
if (one == null) {
- log.error("璐ф灦ID涓嶅瓨鍦�");
- int insert = warehouseGoodsShelvesMapper.insert(warehouseGoodsShelves);
- if (insert <= 0) {
- log.error("璐ф灦涓昏褰曟坊鍔犲け璐�");
- return false;
+ if(warehouseGoodsShelves.getRow() == null || warehouseGoodsShelves.getRow() == 0 && warehouseGoodsShelves.getCol() == null || warehouseGoodsShelves.getCol() == 0){
+ throw new IllegalArgumentException("灞傛暟鍜屽垪鏁颁笉鑳戒负绌�");
}
+ int insert = warehouseGoodsShelvesMapper.insert(warehouseGoodsShelves);
+ if (insert <= 0) return false;
}
Long shelvesId = warehouseGoodsShelves.getId();
Long warehouseId = warehouseGoodsShelves.getWarehouseId();
// 3. 鎵归噺鍒涘缓琛屽垪璁板綍
List<WarehouseGoodsShelvesRowcol> rowcolList = new ArrayList<>();
- for (long i = 1; i <= warehouseGoodsShelves.getStorey(); i++) {
- for (long j = 1; j <= warehouseGoodsShelves.getArrange(); j++) {
+ for (long i = 1; i <= warehouseGoodsShelves.getRow(); i++) {
+ for (long j = 1; j <= warehouseGoodsShelves.getCol(); j++) {
WarehouseGoodsShelvesRowcol rowcol = new WarehouseGoodsShelvesRowcol();
- rowcol.setStorey(i);
- rowcol.setArrange(j);
+ rowcol.setRow(i);
+ rowcol.setCol(j);
rowcol.setWarehouseGoodsShelvesId(shelvesId);
rowcolList.add(rowcol);
}
@@ -86,16 +82,10 @@
// 浣跨敤鎵归噺鎻掑叆鏂规硶鏇夸唬寰幆鍗曟潯鎻掑叆
warehouseGoodsShelvesRowcolService.saveBatch(rowcolList);
} catch (Exception e) {
- log.error("璐ф灦[{}]鐨勮鍒楄褰曟壒閲忔坊鍔犲け璐�", shelvesId, e);
// 鎶涘嚭寮傚父瑙﹀彂浜嬪姟鍥炴粴
throw e;
}
}
-
- log.info("璐ф灦[{}]娣诲姞鎴愬姛锛屽眰鏁�:{}锛屾帓鏁�:{}",
- warehouseGoodsShelves.getGoodsShelvesName(),
- warehouseGoodsShelves.getStorey(),
- warehouseGoodsShelves.getArrange());
return true;
}
/**
@@ -104,7 +94,6 @@
* @return 鏄惁鏇存柊鎴愬姛
*/
@Override
- @Transactional(rollbackFor = Exception.class)
public boolean updateRowcolById(WarehouseGoodsShelves warehouseGoodsShelves) {
Long shelvesId = warehouseGoodsShelves.getId();
@@ -120,25 +109,14 @@
Wrapper<Documentation> queryWrapper1 = new LambdaQueryWrapper<Documentation>()
.in(Documentation::getWarehouseGoodsShelvesRowcolId, rowcolIds);
List<Documentation> documentations = documentationMapper.selectList(queryWrapper1);
- if (!documentations.isEmpty()) {
- log.error("璐ф灦[ID:{}]涓婂瓨鍦ㄥ晢鍝侊紝绂佹鏇存柊", shelvesId);
- return false;
- }
+ if (!documentations.isEmpty()) throw new RuntimeException("璐ф灦涓嬫湁鍟嗗搧锛屼笉鑳藉垹闄�");
+
// 鍏堟洿鏂拌揣鏋朵富淇℃伅
- boolean isShelvesUpdated = updateById(warehouseGoodsShelves);
- if (!isShelvesUpdated) {
- log.warn("璐ф灦[{}]涓讳俊鎭洿鏂板け璐�", shelvesId);
- return false;
- }
+ updateById(warehouseGoodsShelves);
// 鍒犻櫎鏃х殑琛屽垪璁板綍
- boolean isOldRowcolRemoved = warehouseGoodsShelvesRowcolService.removeByIds(rowcolIds);
- if (!isOldRowcolRemoved) {
- log.error("璐ф灦[{}]鐨勬棫琛屽垪璁板綍鍒犻櫎澶辫触", shelvesId);
- return false;
- }
+ warehouseGoodsShelvesRowcolService.removeByIds(rowcolIds);
// 娣诲姞鏂扮殑琛屽垪璁板綍
add(warehouseGoodsShelves);
- log.info("璐ф灦[{}]鐨勮鍒椾俊鎭洿鏂版垚鍔�", shelvesId);
return true;
}
/**
@@ -147,14 +125,9 @@
* @return 鏄惁鍒犻櫎鎴愬姛
*/
@Override
- @Transactional(rollbackFor = Exception.class)
public boolean deleteByIds(List<Long> ids) {
// 1. 鍏堟煡璇㈡墍鏈夎鍒犻櫎鐨勮揣鏋朵俊鎭�
List<WarehouseGoodsShelves> shelvesList = warehouseGoodsShelvesMapper.selectBatchIds(ids);
- if (CollectionUtils.isEmpty(shelvesList)) {
- log.info("鏈煡璇㈠埌闇�鍒犻櫎鐨勮揣鏋讹紝ID鍒楄〃锛歿}", ids);
- return true; // 鏃犳暟鎹彲鍒狅紝瑙嗕负鎴愬姛
- }
// 2. 妫�鏌ユ墍鏈夎揣鏋舵槸鍚﹀瓨鍦ㄥ晢鍝侊紙鏈夊晢鍝佸垯涓嶅厑璁稿垹闄わ級
for (WarehouseGoodsShelves shelves : shelvesList) {
@@ -175,20 +148,13 @@
Wrapper<Documentation> queryWrapper1 = new LambdaQueryWrapper<Documentation>()
.in(Documentation::getWarehouseGoodsShelvesRowcolId, rowcolIds);
List<Documentation> documentations = documentationMapper.selectList(queryWrapper1);
- if (!documentations.isEmpty()) {
- log.error("璐ф灦[ID:{}]涓婂瓨鍦ㄥ晢鍝侊紝绂佹鍒犻櫎", shelvesId);
- return false; // 浠讳竴璐ф灦鏈夊晢鍝佸垯缁堟鍒犻櫎
- }
+ if (!documentations.isEmpty()) throw new RuntimeException("璐ф灦涓嬫湁鍟嗗搧锛屼笉鑳藉垹闄�"); // 浠讳竴璐ф灦鏈夊晢鍝佸垯缁堟鍒犻櫎
}
// 3. 鍏堝垹闄よ揣鏋朵富璁板綍
- boolean isShelvesDeleted = removeByIds(ids);
- if (!isShelvesDeleted) {
- log.error("璐ф灦涓昏褰曞垹闄ゅけ璐ワ紝ID鍒楄〃锛歿}", ids);
- return false;
- }
+ warehouseGoodsShelvesMapper.deleteBatchIds(ids);
- // 4. 鎵归噺鍒犻櫎鎵�鏈夊叧鑱旂殑琛屽垪璁板綍
+ // 4. 鎵归噺鍒犻櫎鎵�鏈夎鍒楄褰�
List<Long> allShelvesIds = shelvesList.stream()
.map(WarehouseGoodsShelves::getId)
.collect(Collectors.toList());
@@ -196,17 +162,16 @@
// 鏋勫缓鎵归噺鍒犻櫎鏉′欢
Wrapper<WarehouseGoodsShelvesRowcol> deleteWrapper = new LambdaQueryWrapper<WarehouseGoodsShelvesRowcol>()
.in(WarehouseGoodsShelvesRowcol::getWarehouseGoodsShelvesId, allShelvesIds);
-
- boolean isRowcolDeleted = warehouseGoodsShelvesRowcolService.remove(deleteWrapper);
- if (!isRowcolDeleted) {
- log.warn("璐ф灦鍏宠仈鐨勮鍒楄褰曞垹闄ゅけ璐ワ紝璐ф灦ID鍒楄〃锛歿}", allShelvesIds);
- // 姝ゅ鍙牴鎹笟鍔¢渶姹傚喅瀹氭槸鍚﹀洖婊氳揣鏋跺垹闄ゆ搷浣�
- }
-
- log.info("璐ф灦鎵归噺鍒犻櫎鎴愬姛锛孖D鍒楄〃锛歿}", ids);
+ warehouseGoodsShelvesRowcolService.remove(deleteWrapper);
return true;
}
+
+ @Override
+ public List<WarehouseGoodsShelvesDto> findList(WarehouseGoodsShelves warehouseGoodsShelves) {
+ return warehouseGoodsShelvesMapper.listAll(warehouseGoodsShelves);
+ }
+
}
--
Gitblit v1.9.3