From 43721e95b3bb75e5a90a18120aaf12e0b632360a Mon Sep 17 00:00:00 2001
From: verou <857149855@qq.com>
Date: 星期二, 25 三月 2025 15:08:48 +0800
Subject: [PATCH] 11

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocController.java |   71 +++++++++++++++++++++++++++++++++--
 1 files changed, 67 insertions(+), 4 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocController.java
index 83cadf6..3a91dc6 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocController.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocController.java
@@ -1,5 +1,6 @@
 package com.vincent.rsf.server.manager.controller;
 
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.vincent.rsf.framework.common.Cools;
@@ -18,8 +19,10 @@
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
@@ -65,10 +68,26 @@
     @OperationLog("Create 搴撲綅淇℃伅琛�")
     @PostMapping("/loc/save")
     public R save(@RequestBody Loc loc) {
+        if (Objects.isNull(loc.getWarehouseId())) {
+            throw new CoolException("浠撳簱ID涓嶈兘涓虹┖锛侊紒");
+        }
+        if (Objects.isNull(loc.getAreaId())) {
+            throw new CoolException("浠撳簱ID涓嶈兘涓虹┖锛侊紒");
+        }
+        if (Objects.isNull(loc.getTypeIds())) {
+            throw new CoolException("搴撲綅绫诲瀷涓嶈兘涓虹┖锛侊紒");
+        }
+        String join = StringUtils.join(loc.getTypeIds(), ",");
+        loc.setType(join);
+
         loc.setCreateBy(getLoginUserId());
         loc.setUpdateBy(getLoginUserId());
         if (!locService.save(loc)) {
             return R.error("Save Fail");
+        }
+
+        if (!locService.saveType(loc)) {
+            throw new CoolException("搴撲綅绫诲瀷鍏宠仈鍏崇郴淇濆瓨澶辫触锛侊紒");
         }
         return R.ok("Save Success").add(loc);
     }
@@ -76,11 +95,19 @@
     @PreAuthorize("hasAuthority('manager:loc:update')")
     @OperationLog("Update 搴撲綅淇℃伅琛�")
     @PostMapping("/loc/update")
+    @Transactional(rollbackFor = Exception.class)
     public R update(@RequestBody Loc loc) {
         loc.setUpdateBy(getLoginUserId());
-        loc.setUpdateTime(new Date());
+        String join = StringUtils.join(loc.getTypeIds(), ",");
+        loc.setType(join);
+        if (Objects.isNull(loc.getTypeIds())) {
+            throw new CoolException("搴撲綅绫诲瀷涓嶈兘涓虹┖锛侊紒");
+        }
         if (!locService.updateById(loc)) {
             return R.error("Update Fail");
+        }
+        if (!locService.updateLoc(loc)) {
+            throw new CoolException("搴撲綅绫诲瀷鍏宠仈鍏崇郴淇敼澶辫触!@锛�");
         }
         return R.ok("Update Success").add(loc);
     }
@@ -132,18 +159,54 @@
         return locService.modifyLocs(locs);
     }
 
+    @PreAuthorize("hasAuthority('manager:loc:update')")
+    @PostMapping("/loc/batch/area")
+    @ApiOperation("搴撲綅鎵归噺鍒嗗尯")
+    public R batchLocArea(@RequestBody LocModifyParams locs) {
+        if (Objects.isNull(locs)) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        locs.setCreateBy(getLoginUserId());
+        locs.setUpdateBy(getLoginUserId());
+        return locService.batchBindLocs(locs);
+    }
+
 
     @PreAuthorize("hasAuthority('manager:loc:update')")
     @ApiOperation("搴撲綅鍒濆鍖�")
     @PostMapping("/loc/init")
     public R initLocInfo(@Valid @RequestBody LocMastInitParam param) {
         if (Objects.isNull(param)) {
-            throw new CoolException("鍒濆鍖栦俊鎭笉鑳戒负绌猴紒锛�");
+            return R.error("鍒濆鍖栦俊鎭笉鑳戒负绌猴紒锛�");
+        }
+        if (Objects.isNull(param.getTypeIds()) && param.getTypeIds().isEmpty()) {
+            return R.error("搴撲綅绫诲瀷涓嶈兘涓虹┖锛侊紒");
+        }
+        if (Objects.isNull(param.getWarehouseId())) {
+            return R.error("浠撳簱ID涓嶈兘涓虹┖锛侊紒");
         }
         if (Objects.isNull(param.getAreaId())) {
-            throw new CoolException("搴撳尯ID涓嶈兘涓虹┖锛侊紒");
+            return R.error("搴撳尯ID涓嶈兘涓虹┖锛侊紒");
         }
-        return locService.initLocs(param);
+        if (Objects.isNull(param.getStartRow())) {
+            return R.error("璧峰鎺掍笉鑳戒负绌猴紒锛�");
+        }
+        if (Objects.isNull(param.getEndRow())) {
+            return R.error("缁堟鎺掍笉鑳戒负绌猴紒锛�");
+        }
+        if (Objects.isNull(param.getStartBay())) {
+            return R.error("璧峰鍒椾笉鑳戒负绌猴紒锛�");
+        }
+        if (Objects.isNull(param.getEndBay())) {
+            return R.error("缁堟鍒椾笉鑳戒负绌猴紒锛�");
+        }
+        if (Objects.isNull(param.getStartLev())) {
+            return R.error("璧峰灞備笉鑳戒负绌猴紒锛�");
+        }
+        if (Objects.isNull(param.getEndLev())) {
+            return R.error("缁堟灞備笉鑳戒负绌猴紒锛�");
+        }
+        return locService.initLocs(param, getLoginUserId());
     }
 
 }

--
Gitblit v1.9.1