From 7d188cc913d5ea547c5e99ae434ea3b1cf4e818a Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期五, 15 八月 2025 09:00:41 +0800
Subject: [PATCH] 仓库货架业务流程修改
---
src/main/java/com/ruoyi/warehouse/controller/WarehouseController.java | 9 +
src/main/java/com/ruoyi/warehouse/pojo/Documentation.java | 2
src/main/java/com/ruoyi/warehouse/controller/WarehouseGoodsShelvesRowcolController.java | 61 ++++++-----
src/main/java/com/ruoyi/warehouse/controller/WarehouseGoodsShelvesController.java | 9 -
src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesRowcolServiceImpl.java | 39 ++-----
src/main/java/com/ruoyi/warehouse/service/impl/WarehouseServiceImpl.java | 36 +++++-
src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesServiceImpl.java | 96 +++++++++---------
7 files changed, 134 insertions(+), 118 deletions(-)
diff --git a/src/main/java/com/ruoyi/warehouse/controller/WarehouseController.java b/src/main/java/com/ruoyi/warehouse/controller/WarehouseController.java
index 45fe997..64ad5c6 100644
--- a/src/main/java/com/ruoyi/warehouse/controller/WarehouseController.java
+++ b/src/main/java/com/ruoyi/warehouse/controller/WarehouseController.java
@@ -1,14 +1,16 @@
package com.ruoyi.warehouse.controller;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
-
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.ruoyi.warehouse.pojo.Warehouse;
+import com.ruoyi.warehouse.pojo.WarehouseGoodsShelves;
import com.ruoyi.warehouse.service.WarehouseGoodsShelvesService;
import com.ruoyi.warehouse.service.WarehouseService;
import io.swagger.annotations.Api;
@@ -26,7 +28,6 @@
@Autowired
private WarehouseService warehouseService;
-
@GetMapping("/listPage")
@ApiOperation("浠撳簱-鏌ヨ")
@Log(title = "浠撳簱-鏌ヨ", businessType = BusinessType.OTHER)
@@ -37,7 +38,7 @@
@ApiOperation("浠撳簱-娣诲姞")
@Log(title = "浠撳簱-娣诲姞", businessType = BusinessType.INSERT)
public AjaxResult add(@RequestBody Warehouse warehouse) {
- return warehouseService.save(warehouse) ? AjaxResult.success("娣诲姞鎴愬姛") : AjaxResult.error("娣诲姞澶辫触");
+ return AjaxResult.success(warehouseService.save(warehouse));
}
@PostMapping("/update")
@@ -52,6 +53,6 @@
@Log(title = "浠撳簱-鍒犻櫎", businessType = BusinessType.DELETE)
public AjaxResult delete(@RequestBody List<Long> ids) {
if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
- return warehouseService.deleteByIds(ids) ? AjaxResult.success("鍒犻櫎鎴愬姛") : AjaxResult.error("鍒犻櫎澶辫触");
+ return AjaxResult.success(warehouseService.deleteByIds(ids));
}
}
diff --git a/src/main/java/com/ruoyi/warehouse/controller/WarehouseGoodsShelvesController.java b/src/main/java/com/ruoyi/warehouse/controller/WarehouseGoodsShelvesController.java
index 64eefd2..f373b88 100644
--- a/src/main/java/com/ruoyi/warehouse/controller/WarehouseGoodsShelvesController.java
+++ b/src/main/java/com/ruoyi/warehouse/controller/WarehouseGoodsShelvesController.java
@@ -43,22 +43,19 @@
@ApiOperation("鍟嗗搧璐ф灦-娣诲姞")
@Log(title = "鍟嗗搧璐ф灦-娣诲姞", businessType = BusinessType.INSERT)
public AjaxResult add(@RequestBody WarehouseGoodsShelves warehouseGoodsShelves) {
- boolean save = warehouseGoodsShelvesService.add(warehouseGoodsShelves);
- return save ? AjaxResult.success("娣诲姞鎴愬姛") : AjaxResult.error("娣诲姞澶辫触");
+ return AjaxResult.success(warehouseGoodsShelvesService.add(warehouseGoodsShelves));
}
@PostMapping("/update")
@ApiOperation("鍟嗗搧璐ф灦-鏇存柊")
@Log(title = "鍟嗗搧璐ф灦-鏇存柊", businessType = BusinessType.UPDATE)
public AjaxResult update(@RequestBody WarehouseGoodsShelves warehouseGoodsShelves) {
- boolean update = warehouseGoodsShelvesService.updateRowcolById(warehouseGoodsShelves);
- return update ? AjaxResult.success("鏇存柊鎴愬姛") : AjaxResult.error("鏇存柊澶辫触");
+ return AjaxResult.success(warehouseGoodsShelvesService.updateRowcolById(warehouseGoodsShelves));
}
@DeleteMapping("/delete")
@ApiOperation("鍟嗗搧璐ф灦-鍒犻櫎")
@Log(title = "鍟嗗搧璐ф灦-鍒犻櫎", businessType = BusinessType.DELETE)
public AjaxResult delete(@RequestBody List<Long> ids) {
if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
- boolean remove = warehouseGoodsShelvesService.deleteByIds(ids);
- return remove ? AjaxResult.success("鍒犻櫎鎴愬姛") : AjaxResult.error("鍒犻櫎澶辫触");
+ return AjaxResult.success(warehouseGoodsShelvesService.deleteByIds(ids));
}
}
diff --git a/src/main/java/com/ruoyi/warehouse/controller/WarehouseGoodsShelvesRowcolController.java b/src/main/java/com/ruoyi/warehouse/controller/WarehouseGoodsShelvesRowcolController.java
index a0c7479..8f6c136 100644
--- a/src/main/java/com/ruoyi/warehouse/controller/WarehouseGoodsShelvesRowcolController.java
+++ b/src/main/java/com/ruoyi/warehouse/controller/WarehouseGoodsShelvesRowcolController.java
@@ -25,36 +25,39 @@
private WarehouseGoodsShelvesRowcolService warehouseGoodsShelvesRowcolService;
@Autowired
private WarehouseGoodsShelvesRowcolMapper warehouseGoodsShelvesRowcolMapper;
-
- @GetMapping("/listPage")
- @ApiOperation("鍟嗗搧璐ф灦琛屽垪-鍒嗛〉鏌ヨ")
- @Log(title = "鍟嗗搧璐ф灦琛屽垪-鍒嗛〉鏌ヨ", businessType = BusinessType.OTHER)
- public AjaxResult listPage(Page page, WarehouseGoodsShelvesRowcol warehouseGoodsShelvesRowcol) {
- IPage<WarehouseGoodsShelvesRowcol> listPage = warehouseGoodsShelvesRowcolService.listPage(page, warehouseGoodsShelvesRowcol);
- return AjaxResult.success(listPage);
+ @GetMapping("/list")
+ @ApiOperation("鍟嗗搧璐ф灦琛屽垪-鏌ヨ")
+ @Log(title = "鍟嗗搧璐ф灦琛屽垪-鏌ヨ", businessType = BusinessType.OTHER)
+ public AjaxResult list() {
+ List<WarehouseGoodsShelvesRowcol> list = warehouseGoodsShelvesRowcolService.list();
+ return AjaxResult.success(list);
}
- @PostMapping("/add")
- @ApiOperation("鍟嗗搧璐ф灦琛屽垪-娣诲姞")
- @Log(title = "鍟嗗搧璐ф灦琛屽垪-娣诲姞", businessType = BusinessType.INSERT)
- public AjaxResult add(@RequestBody WarehouseGoodsShelvesRowcol warehouseGoodsShelvesRowcol) {
- boolean save = warehouseGoodsShelvesRowcolService.save(warehouseGoodsShelvesRowcol);
- return save ? AjaxResult.success("娣诲姞鎴愬姛") : AjaxResult.error("娣诲姞澶辫触");
- }
- @PostMapping("/update")
- @ApiOperation("鍟嗗搧璐ф灦琛屽垪-鏇存柊")
- @Log(title = "鍟嗗搧璐ф灦琛屽垪-鏇存柊", businessType = BusinessType.UPDATE)
- public AjaxResult update(@RequestBody WarehouseGoodsShelvesRowcol warehouseGoodsShelvesRowcol) {
- boolean up = warehouseGoodsShelvesRowcolService.updateById(warehouseGoodsShelvesRowcol);
- return up ? AjaxResult.success("鏇存柊鎴愬姛") : AjaxResult.error("鏇存柊澶辫触");
- }
- @PostMapping("/delete")
- @ApiOperation("鍟嗗搧璐ф灦琛屽垪-鍒犻櫎")
- @Log(title = "鍟嗗搧璐ф灦琛屽垪-鍒犻櫎", businessType = BusinessType.DELETE)
- public AjaxResult delete(@RequestBody List<Long> ids) {
- if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
- boolean remove = warehouseGoodsShelvesRowcolService.deleteByIds(ids);
- return remove ? AjaxResult.success("鍒犻櫎鎴愬姛") : AjaxResult.error("鍒犻櫎澶辫触");
- }
+// @GetMapping("/listPage")
+// @ApiOperation("鍟嗗搧璐ф灦琛屽垪-鍒嗛〉鏌ヨ")
+// @Log(title = "鍟嗗搧璐ф灦琛屽垪-鍒嗛〉鏌ヨ", businessType = BusinessType.OTHER)
+// public AjaxResult listPage(Page page, WarehouseGoodsShelvesRowcol warehouseGoodsShelvesRowcol) {
+// IPage<WarehouseGoodsShelvesRowcol> listPage = warehouseGoodsShelvesRowcolService.listPage(page, warehouseGoodsShelvesRowcol);
+// return AjaxResult.success(listPage);
+// }
+// @PostMapping("/add")
+// @ApiOperation("鍟嗗搧璐ф灦琛屽垪-娣诲姞")
+// @Log(title = "鍟嗗搧璐ф灦琛屽垪-娣诲姞", businessType = BusinessType.INSERT)
+// public AjaxResult add(@RequestBody WarehouseGoodsShelvesRowcol warehouseGoodsShelvesRowcol) {
+// return AjaxResult.success(warehouseGoodsShelvesRowcolService.save(warehouseGoodsShelvesRowcol));
+// }
+// @PostMapping("/update")
+// @ApiOperation("鍟嗗搧璐ф灦琛屽垪-鏇存柊")
+// @Log(title = "鍟嗗搧璐ф灦琛屽垪-鏇存柊", businessType = BusinessType.UPDATE)
+// public AjaxResult update(@RequestBody WarehouseGoodsShelvesRowcol warehouseGoodsShelvesRowcol) {
+// return AjaxResult.success(warehouseGoodsShelvesRowcolService.updateById(warehouseGoodsShelvesRowcol));
+// }
+// @PostMapping("/delete")
+// @ApiOperation("鍟嗗搧璐ф灦琛屽垪-鍒犻櫎")
+// @Log(title = "鍟嗗搧璐ф灦琛屽垪-鍒犻櫎", businessType = BusinessType.DELETE)
+// public AjaxResult delete(@RequestBody List<Long> ids) {
+// if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
+// return AjaxResult.success(warehouseGoodsShelvesRowcolService.removeByIds(ids));
+// }
}
diff --git a/src/main/java/com/ruoyi/warehouse/pojo/Documentation.java b/src/main/java/com/ruoyi/warehouse/pojo/Documentation.java
index f6c58ec..8c50afa 100644
--- a/src/main/java/com/ruoyi/warehouse/pojo/Documentation.java
+++ b/src/main/java/com/ruoyi/warehouse/pojo/Documentation.java
@@ -6,6 +6,7 @@
import java.time.LocalDateTime;
import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -73,6 +74,7 @@
*/
@Excel(name = "鏂囨。鏃ユ湡")
@ApiModelProperty(value = "鏂囨。鏃ユ湡")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime docDate;
/**
diff --git a/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesRowcolServiceImpl.java b/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesRowcolServiceImpl.java
index 3a0f3cc..c564012 100644
--- a/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesRowcolServiceImpl.java
+++ b/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesRowcolServiceImpl.java
@@ -1,10 +1,14 @@
package com.ruoyi.warehouse.service.impl;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.warehouse.mapper.DocumentationMapper;
import com.ruoyi.warehouse.mapper.WarehouseGoodsShelvesRowcolMapper;
+import com.ruoyi.warehouse.pojo.Documentation;
import com.ruoyi.warehouse.pojo.WarehouseGoodsShelvesRowcol;
import com.ruoyi.warehouse.service.WarehouseGoodsShelvesRowcolService;
import lombok.extern.slf4j.Slf4j;
@@ -12,6 +16,7 @@
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.stream.Collectors;
/**
@@ -25,6 +30,8 @@
implements WarehouseGoodsShelvesRowcolService {
@Autowired
private WarehouseGoodsShelvesRowcolMapper warehouseGoodsShelvesRowcolMapper;
+ @Autowired
+ private DocumentationMapper documentationMapper;
@Override
public IPage<WarehouseGoodsShelvesRowcol> listPage(Page page, WarehouseGoodsShelvesRowcol warehouseGoodsShelvesRowcol) {
@@ -34,13 +41,13 @@
@Override
public boolean deleteByIds(List<Long> ids) {
- for (int i = 0; i < ids.size(); i++) {
- Long id = ids.get(i);
- WarehouseGoodsShelvesRowcol rowcol = warehouseGoodsShelvesRowcolMapper.selectById(id);
- if(rowcol.getDocumentationId()!=null && rowcol.getDocumentationId()!=0){
- log.error("璐ф灦涓婃湁鍟嗗搧,涓嶈兘鍒犻櫎");
- return false;
- }
+ // 3. 妫�鏌ユ槸鍚︽湁鍟嗗搧
+ Wrapper<Documentation> queryWrapper = new LambdaQueryWrapper<Documentation>()
+ .in(Documentation::getWarehouseGoodsShelvesRowcolId, ids);
+ List<Documentation> documentations = documentationMapper.selectList(queryWrapper);
+ if (!documentations.isEmpty()) {
+ log.error("璐ф灦[ID:{}]涓婂瓨鍦ㄥ晢鍝侊紝绂佹鍒犻櫎", ids);
+ return false;
}
int i = warehouseGoodsShelvesRowcolMapper.deleteBatchIds(ids);
if(i!=ids.size()){
@@ -49,24 +56,6 @@
}
return true;
}
-
-
-// @Override
-// public boolean add(WarehouseGoodsShelvesRowcol warehouseGoodsShelvesRowcol) {
-// for (int i = 0; i < warehouseGoodsShelvesRowcol.getRow(); i++) {
-// for (int j = 0; j < warehouseGoodsShelvesRowcol.getCol(); j++) {
-// WarehouseGoodsShelvesRowcol rowcol = new WarehouseGoodsShelvesRowcol();
-// rowcol.setRow((long) i);
-// rowcol.setCol((long) j);
-// rowcol.setWarehouseGoodsShelvesId(warehouseGoodsShelvesRowcol.getWarehouseGoodsShelvesId());
-// rowcol.setWarehouseId(warehouseGoodsShelvesRowcol.getWarehouseId());
-// rowcol.setCreateUser(warehouseGoodsShelvesRowcol.getCreateUser());
-// rowcol.setCreateTime(warehouseGoodsShelvesRowcol.getCreateTime());
-// warehouseGoodsShelvesRowcolMapper.insert(rowcol);
-// }
-// }
-// return true;
-// }
}
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 9de15d6..314be51 100644
--- a/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesServiceImpl.java
+++ b/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseGoodsShelvesServiceImpl.java
@@ -9,9 +9,12 @@
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.mapper.DocumentationMapper;
import com.ruoyi.warehouse.mapper.WarehouseGoodsShelvesMapper;
import com.ruoyi.warehouse.mapper.WarehouseGoodsShelvesRowcolMapper;
+import com.ruoyi.warehouse.pojo.Documentation;
import com.ruoyi.warehouse.pojo.WarehouseGoodsShelvesRowcol;
+import com.ruoyi.warehouse.service.DocumentationService;
import com.ruoyi.warehouse.service.WarehouseGoodsShelvesRowcolService;
import com.ruoyi.warehouse.service.WarehouseGoodsShelvesService;
import lombok.extern.slf4j.Slf4j;
@@ -41,6 +44,10 @@
private WarehouseGoodsShelvesRowcolMapper warehouseGoodsShelvesRowcolMapper;
@Autowired
private WarehouseGoodsShelvesMapper warehouseGoodsShelvesMapper;
+ @Autowired
+ private DocumentationService documentationService;
+ @Autowired
+ private DocumentationMapper documentationMapper;
@Override
public IPage<WarehouseGoodsShelves> listPage(Page page, WarehouseGoodsShelves warehouseGoodsShelves) {
return warehouseGoodsShelvesMapper.listPage(page,warehouseGoodsShelves);
@@ -49,11 +56,17 @@
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(WarehouseGoodsShelves warehouseGoodsShelves) {
- int insert = warehouseGoodsShelvesMapper.insert(warehouseGoodsShelves);
- if (insert <= 0) {
- log.error("璐ф灦涓昏褰曟坊鍔犲け璐�");
- return false;
+ 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;
+ }
}
+
Long shelvesId = warehouseGoodsShelves.getId();
Long warehouseId = warehouseGoodsShelves.getWarehouseId();
// 3. 鎵归噺鍒涘缓琛屽垪璁板綍
@@ -91,52 +104,38 @@
* @return 鏄惁鏇存柊鎴愬姛
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public boolean updateRowcolById(WarehouseGoodsShelves warehouseGoodsShelves) {
- // 鎻愬彇鍏抽敭ID锛屽噺灏戦噸澶嶈皟鐢�
Long shelvesId = warehouseGoodsShelves.getId();
- Long warehouseId = warehouseGoodsShelves.getWarehouseId();
+ // 鏋勫缓鏌ヨ鏉′欢锛氭煡璇㈣璐ф灦涓嬬殑鎵�鏈夎鍒楄褰�
+ Wrapper<WarehouseGoodsShelvesRowcol> queryWrapper = new LambdaQueryWrapper<WarehouseGoodsShelvesRowcol>()
+ .eq(WarehouseGoodsShelvesRowcol::getWarehouseGoodsShelvesId, shelvesId);
+ List<WarehouseGoodsShelvesRowcol> rowcolList = warehouseGoodsShelvesRowcolService.list(queryWrapper);
+ //鑾峰緱rowcolList涓墍鏈夌殑Id
+ List<Long> rowcolIds = rowcolList.stream()
+ .map(WarehouseGoodsShelvesRowcol::getId)
+ .collect(Collectors.toList());
+ // 3. 妫�鏌ユ槸鍚︽湁鍟嗗搧
+ 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;
+ }
// 鍏堟洿鏂拌揣鏋朵富淇℃伅
boolean isShelvesUpdated = updateById(warehouseGoodsShelves);
if (!isShelvesUpdated) {
log.warn("璐ф灦[{}]涓讳俊鎭洿鏂板け璐�", shelvesId);
return false;
}
-
- // 鏋勫缓鏌ヨ鏉′欢锛氭煡璇㈣璐ф灦涓嬬殑鎵�鏈夎鍒楄褰�
- WarehouseGoodsShelvesRowcol queryRowcol = new WarehouseGoodsShelvesRowcol();
- queryRowcol.setWarehouseGoodsShelvesId(shelvesId);
- queryRowcol.setWarehouseId(warehouseId);
-
- IPage<WarehouseGoodsShelvesRowcol> rowcolPage = warehouseGoodsShelvesRowcolService.listPage(new Page<>(), queryRowcol);
- List<WarehouseGoodsShelvesRowcol> oldRowcolList = rowcolPage.getRecords();
-
- // 濡傛灉娌℃湁鏃х殑琛屽垪璁板綍锛岀洿鎺ユ坊鍔犳柊璁板綍
- if (oldRowcolList.isEmpty()) {
- add(warehouseGoodsShelves);
- return true;
- }
-
- // 妫�鏌ヨ揣鏋朵笂鏄惁鏈夊晢鍝侊紙鏈夊晢鍝佸垯涓嶅厑璁告洿鏂帮級
- boolean hasGoodsOnShelves = oldRowcolList.stream()
- .anyMatch(rowcol -> rowcol.getDocumentationId() != null);
- if (hasGoodsOnShelves) {
- log.error("璐ф灦[{}]涓婂瓨鍦ㄥ晢鍝侊紝涓嶅厑璁告洿鏂拌鍒椾俊鎭�", shelvesId);
- return false;
- }
-
- // 鎻愬彇鏃ц鍒楄褰曠殑ID闆嗗悎锛岀敤浜庡垹闄ゆ搷浣�
- List<Long> oldRowcolIds = oldRowcolList.stream()
- .map(WarehouseGoodsShelvesRowcol::getId)
- .collect(Collectors.toList());
-
// 鍒犻櫎鏃х殑琛屽垪璁板綍
- boolean isOldRowcolRemoved = warehouseGoodsShelvesRowcolService.removeByIds(oldRowcolIds);
+ boolean isOldRowcolRemoved = warehouseGoodsShelvesRowcolService.removeByIds(rowcolIds);
if (!isOldRowcolRemoved) {
log.error("璐ф灦[{}]鐨勬棫琛屽垪璁板綍鍒犻櫎澶辫触", shelvesId);
return false;
}
-
// 娣诲姞鏂扮殑琛屽垪璁板綍
add(warehouseGoodsShelves);
log.info("璐ф灦[{}]鐨勮鍒椾俊鎭洿鏂版垚鍔�", shelvesId);
@@ -148,6 +147,7 @@
* @return 鏄惁鍒犻櫎鎴愬姛
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public boolean deleteByIds(List<Long> ids) {
// 1. 鍏堟煡璇㈡墍鏈夎鍒犻櫎鐨勮揣鏋朵俊鎭�
List<WarehouseGoodsShelves> shelvesList = warehouseGoodsShelvesMapper.selectBatchIds(ids);
@@ -159,21 +159,23 @@
// 2. 妫�鏌ユ墍鏈夎揣鏋舵槸鍚﹀瓨鍦ㄥ晢鍝侊紙鏈夊晢鍝佸垯涓嶅厑璁稿垹闄わ級
for (WarehouseGoodsShelves shelves : shelvesList) {
Long shelvesId = shelves.getId();
- Long warehouseId = shelves.getWarehouseId();
-
// 鏋勫缓鏌ヨ鏉′欢锛氭煡璇㈠綋鍓嶈揣鏋剁殑鎵�鏈夎鍒楄褰�
Wrapper<WarehouseGoodsShelvesRowcol> queryWrapper = new LambdaQueryWrapper<WarehouseGoodsShelvesRowcol>()
- .eq(WarehouseGoodsShelvesRowcol::getWarehouseGoodsShelvesId, shelvesId)
- .eq(WarehouseGoodsShelvesRowcol::getWarehouseId, warehouseId);
+ .eq(WarehouseGoodsShelvesRowcol::getWarehouseGoodsShelvesId, shelvesId);
- // 鏌ヨ琛屽垪璁板綍锛堜粎闇�鍒ゆ柇鏄惁鏈夊晢鍝侊紝鏃犻渶鍒嗛〉锛�
List<WarehouseGoodsShelvesRowcol> rowcolList = warehouseGoodsShelvesRowcolService.list(queryWrapper);
-
- // 妫�鏌ユ槸鍚︽湁鍟嗗搧
- boolean hasGoods = rowcolList.stream()
- .anyMatch(rowcol -> rowcol.getDocumentationId() != null && rowcol.getDocumentationId()!=0);
-
- if (hasGoods) {
+ if (CollectionUtils.isEmpty(rowcolList)) {
+ continue; // 鏃犲叧鑱旇褰曪紝璺宠繃妫�鏌�
+ }
+ //鑾峰緱rowcolList涓墍鏈夌殑Id
+ List<Long> rowcolIds = rowcolList.stream()
+ .map(WarehouseGoodsShelvesRowcol::getId)
+ .collect(Collectors.toList());
+ // 3. 妫�鏌ユ槸鍚︽湁鍟嗗搧
+ 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; // 浠讳竴璐ф灦鏈夊晢鍝佸垯缁堟鍒犻櫎
}
diff --git a/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseServiceImpl.java b/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseServiceImpl.java
index 4a98196..3a7b095 100644
--- a/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseServiceImpl.java
+++ b/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseServiceImpl.java
@@ -1,10 +1,13 @@
package com.ruoyi.warehouse.service.impl;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.AjaxResult;
import com.ruoyi.warehouse.mapper.WarehouseMapper;
import com.ruoyi.warehouse.pojo.Warehouse;
import com.ruoyi.warehouse.pojo.WarehouseGoodsShelves;
@@ -13,9 +16,11 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.sql.Array;
import java.util.List;
+import java.util.stream.Collectors;
/**
* @author 86151
@@ -36,18 +41,35 @@
return warehouseMapper.listPage( warehouse);
}
+// @Override
+// public boolean deleteByIds(List<Long> ids) {
+//
+// for (Long id : ids) {
+// List<WarehouseGoodsShelves> list = warehouseGoodsShelvesService.list(new QueryWrapper<WarehouseGoodsShelves>().lambda()
+// .eq(WarehouseGoodsShelves::getWarehouseId, id));
+// if(list.size()>0){
+// log.error("浠撳簱涓嬫湁璐ф灦,涓嶈兘鍒犻櫎 閲嶆柊閫夋嫨");
+// return false;
+// }
+// }
+// return removeByIds(ids);
+// }
@Override
+ @Transactional(rollbackFor = Exception.class)
public boolean deleteByIds(List<Long> ids) {
- for (Long id : ids) {
- List<WarehouseGoodsShelves> list = warehouseGoodsShelvesService.list(new QueryWrapper<WarehouseGoodsShelves>().lambda()
- .eq(WarehouseGoodsShelves::getWarehouseId, id));
- if(list.size()>0){
- log.error("浠撳簱涓嬫湁璐ф灦,涓嶈兘鍒犻櫎 閲嶆柊閫夋嫨");
- return false;
- }
+ // 1. 妫�鏌ユ槸鍚︽湁璐ф灦
+ Wrapper<WarehouseGoodsShelves> queryWrapper = new LambdaQueryWrapper<WarehouseGoodsShelves>()
+ .in(WarehouseGoodsShelves::getWarehouseId, ids);
+ List<WarehouseGoodsShelves> shelvesList = warehouseGoodsShelvesService.list(queryWrapper);
+ //鑾峰緱shelvesList涓墍鏈夌殑Id
+ List<Long> shelvesIds = shelvesList.stream().map(WarehouseGoodsShelves::getId).collect(Collectors.toList());
+ // 2. 鍒犻櫎璐ф灦
+ if (!shelvesIds.isEmpty()) {
+ warehouseGoodsShelvesService.deleteByIds(shelvesIds);
}
return removeByIds(ids);
}
+
}
--
Gitblit v1.9.3