From 1c38849eebe0179b7ebad1db30b3335a41cc47e9 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期六, 16 八月 2025 12:30:22 +0800
Subject: [PATCH] art: WebService服务端相关代码修改

---
 src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java |  138 +++++++++++----------------------------------
 1 files changed, 35 insertions(+), 103 deletions(-)

diff --git a/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java b/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java
index 3f0c60a..25b8af6 100644
--- a/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java
+++ b/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java
@@ -10,6 +10,8 @@
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.oConvertUtils;
@@ -20,21 +22,15 @@
 import org.jeecg.modules.lsw.service.ILswMaterialInventoryService;
 import org.jeecg.modules.lsw.service.ILswMaterialService;
 import org.jeecg.modules.lsw.vo.LswMaterialPage;
-import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
-import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -48,7 +44,7 @@
  */
 @Api(tags = "绾胯竟搴撶墿鏂欎俊鎭�")
 @RestController
-@RequestMapping("/lswmaterial/lswMaterial")
+@RequestMapping("/lsw/lswMaterial")
 @Slf4j
 public class LswMaterialController {
     @Autowired
@@ -67,7 +63,6 @@
      * @param req
      * @return
      */
-    //@AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ")
     @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ", notes = "绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ")
     @GetMapping(value = "/list")
     public Result<IPage<LswMaterial>> queryPageList(LswMaterial lswMaterial,
@@ -75,77 +70,55 @@
                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                     HttpServletRequest req) {
         QueryWrapper<LswMaterial> queryWrapper = QueryGenerator.initQueryWrapper(lswMaterial, req.getParameterMap());
-        Page<LswMaterial> page = new Page<LswMaterial>(pageNo, pageSize);
+        if (lswMaterial.isMaterialCategoryNull()) {
+            queryWrapper.isNull("material_category");
+        }
+        Page<LswMaterial> page = new Page<>(pageNo, pageSize);
         IPage<LswMaterial> pageList = lswMaterialService.page(page, queryWrapper);
         return Result.OK(pageList);
     }
 
     /**
-     * 娣诲姞
-     *
-     * @param lswMaterialPage
-     * @return
-     */
-    @AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-娣诲姞")
-    @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-娣诲姞", notes = "绾胯竟搴撶墿鏂欎俊鎭�-娣诲姞")
-    //@RequiresPermissions("org.jeecg.modules:lsw_material:add")
-    @PostMapping(value = "/add")
-    public Result<String> add(@RequestBody LswMaterialPage lswMaterialPage) {
-        LswMaterial lswMaterial = new LswMaterial();
-        BeanUtils.copyProperties(lswMaterialPage, lswMaterial);
-        lswMaterialService.saveMain(lswMaterial, lswMaterialPage.getLswMaterialInventoryList());
-        return Result.OK("娣诲姞鎴愬姛锛�");
-    }
-
-    /**
      * 缂栬緫
      *
-     * @param lswMaterialPage
+     * @param lswMaterial
      * @return
      */
     @AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-缂栬緫")
     @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-缂栬緫", notes = "绾胯竟搴撶墿鏂欎俊鎭�-缂栬緫")
-    //@RequiresPermissions("org.jeecg.modules:lsw_material:edit")
     @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
-    public Result<String> edit(@RequestBody LswMaterialPage lswMaterialPage) {
-        LswMaterial lswMaterial = new LswMaterial();
-        BeanUtils.copyProperties(lswMaterialPage, lswMaterial);
-        LswMaterial lswMaterialEntity = lswMaterialService.getById(lswMaterial.getId());
-        if (lswMaterialEntity == null) {
-            return Result.error("鏈壘鍒板搴旀暟鎹�");
+    public Result<String> edit(@RequestBody LswMaterial lswMaterial) {
+        boolean b = lswMaterialService.editMaterial(lswMaterial);
+        if (!b) {
+            return Result.error("缂栬緫澶辫触");
         }
-        lswMaterialService.updateMain(lswMaterial, lswMaterialPage.getLswMaterialInventoryList());
         return Result.OK("缂栬緫鎴愬姛!");
     }
 
-    /**
-     * 閫氳繃id鍒犻櫎
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃id鍒犻櫎")
-    @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃id鍒犻櫎", notes = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃id鍒犻櫎")
-    //@RequiresPermissions("org.jeecg.modules:lsw_material:delete")
-    @DeleteMapping(value = "/delete")
-    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
-        lswMaterialService.delMain(id);
-        return Result.OK("鍒犻櫎鎴愬姛!");
+    @AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-鍚敤")
+    @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-鍚敤", notes = "绾胯竟搴撶墿鏂欎俊鎭�-鍚敤")
+    @GetMapping("/active")
+    public Result<?> active(@RequestParam("id") String id) {
+        LswMaterial entity = lswMaterialService.getById(id);
+        if (entity == null) {
+            return Result.error("鏁版嵁涓嶅瓨鍦�");
+        }
+        entity.setMaterialStatus(CommonConstant.STATUS_1);
+        lswMaterialService.updateById(entity);
+        return Result.OK("鎿嶄綔鎴愬姛");
     }
 
-    /**
-     * 鎵归噺鍒犻櫎
-     *
-     * @param ids
-     * @return
-     */
-    @AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-鎵归噺鍒犻櫎")
-    @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-鎵归噺鍒犻櫎", notes = "绾胯竟搴撶墿鏂欎俊鎭�-鎵归噺鍒犻櫎")
-    //@RequiresPermissions("org.jeecg.modules:lsw_material:deleteBatch")
-    @DeleteMapping(value = "/deleteBatch")
-    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
-        this.lswMaterialService.delBatchMain(Arrays.asList(ids.split(",")));
-        return Result.OK("鎵归噺鍒犻櫎鎴愬姛锛�");
+    @AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-绂佺敤")
+    @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-绂佺敤", notes = "绾胯竟搴撶墿鏂欎俊鎭�-绂佺敤")
+    @GetMapping("/inactive")
+    public Result<?> inactive(@RequestParam("id") String id) {
+        LswMaterial entity = lswMaterialService.getById(id);
+        if (entity == null) {
+            return Result.error("鏁版嵁涓嶅瓨鍦�");
+        }
+        entity.setMaterialStatus(CommonConstant.STATUS_0);
+        lswMaterialService.updateById(entity);
+        return Result.OK("鎿嶄綔鎴愬姛");
     }
 
     /**
@@ -178,7 +151,7 @@
     public Result<List<LswMaterialInventory>> queryLswMaterialInventoryListByMainId(@RequestParam(name = "id", required = true) String id) {
         List<LswMaterialInventory> lswMaterialInventoryList = lswMaterialInventoryService.selectByMainId(id);
         for (LswMaterialInventory lswMaterialInventory : lswMaterialInventoryList) {
-            if(StringUtils.isNotEmpty(lswMaterialInventory.getWarehouseId())){
+            if (StringUtils.isNotEmpty(lswMaterialInventory.getWarehouseId())) {
                 String warehouseId = lswMaterialInventory.getWarehouseId();
                 LineSideWarehouse warehouse = lineSideWarehouseService.getById(warehouseId);
                 lswMaterialInventory.setWarehouseName(warehouse.getWarehouseName());
@@ -226,47 +199,6 @@
         mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("绾胯竟搴撶墿鏂欎俊鎭暟鎹�", "瀵煎嚭浜�:" + sysUser.getRealname(), "绾胯竟搴撶墿鏂欎俊鎭�"));
         mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
         return mv;
-    }
-
-    /**
-     * 閫氳繃excel瀵煎叆鏁版嵁
-     *
-     * @param request
-     * @param response
-     * @return
-     */
-    //@RequiresPermissions("org.jeecg.modules:lsw_material:importExcel")
-    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
-        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
-        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
-            // 鑾峰彇涓婁紶鏂囦欢瀵硅薄
-            MultipartFile file = entity.getValue();
-            ImportParams params = new ImportParams();
-            params.setTitleRows(2);
-            params.setHeadRows(1);
-            params.setNeedSave(true);
-            try {
-                List<LswMaterialPage> list = ExcelImportUtil.importExcel(file.getInputStream(), LswMaterialPage.class, params);
-                for (LswMaterialPage page : list) {
-                    LswMaterial po = new LswMaterial();
-                    BeanUtils.copyProperties(page, po);
-                    lswMaterialService.saveMain(po, page.getLswMaterialInventoryList());
-                }
-                return Result.OK("鏂囦欢瀵煎叆鎴愬姛锛佹暟鎹鏁�:" + list.size());
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                return Result.error("鏂囦欢瀵煎叆澶辫触:" + e.getMessage());
-            } finally {
-                try {
-                    file.getInputStream().close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return Result.OK("鏂囦欢瀵煎叆澶辫触锛�");
     }
 
     @GetMapping(value = "/searchlikeQuery")

--
Gitblit v1.9.3