From b33e6f53dd537abaebad066de12474580fcc33b2 Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期四, 21 八月 2025 15:03:14 +0800
Subject: [PATCH] Merge branch 'pim_ywx'

---
 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