From 34580ceb745eaeaf6f8a6188a779c0746a23b02d Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期四, 04 九月 2025 23:18:33 +0800
Subject: [PATCH] art: 热处理入库相关接口

---
 src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java |  137 +++++++++++++++++----------------------------
 1 files changed, 51 insertions(+), 86 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 25b8af6..5eac9ed 100644
--- a/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java
+++ b/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java
@@ -1,40 +1,29 @@
 package org.jeecg.modules.lsw.controller;
 
+import cn.hutool.core.collection.CollectionUtil;
+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 io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-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;
-import org.jeecg.modules.base.entity.LineSideWarehouse;
-import org.jeecg.modules.base.service.ILineSideWarehouseService;
+import org.jeecg.modules.base.entity.Factory;
+import org.jeecg.modules.base.enums.ProductionTypeEnum;
+import org.jeecg.modules.base.service.IFactoryService;
 import org.jeecg.modules.lsw.entity.LswMaterial;
-import org.jeecg.modules.lsw.entity.LswMaterialInventory;
-import org.jeecg.modules.lsw.service.ILswMaterialInventoryService;
+import org.jeecg.modules.lsw.enums.MaterialCategoryEnum;
 import org.jeecg.modules.lsw.service.ILswMaterialService;
-import org.jeecg.modules.lsw.vo.LswMaterialPage;
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
-import org.jeecgframework.poi.excel.entity.ExportParams;
-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.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @Description: 绾胯竟搴撶墿鏂欎俊鎭�
@@ -50,9 +39,7 @@
     @Autowired
     private ILswMaterialService lswMaterialService;
     @Autowired
-    private ILswMaterialInventoryService lswMaterialInventoryService;
-    @Autowired
-    private ILineSideWarehouseService lineSideWarehouseService;
+    private IFactoryService factoryService;
 
     /**
      * 鍒嗛〉鍒楄〃鏌ヨ
@@ -139,75 +126,53 @@
 
     }
 
-    /**
-     * 閫氳繃id鏌ヨ
-     *
-     * @param id
-     * @return
-     */
-    //@AutoLog(value = "鐗╂枡搴撳瓨淇℃伅閫氳繃涓昏〃ID鏌ヨ")
-    @ApiOperation(value = "鐗╂枡搴撳瓨淇℃伅涓昏〃ID鏌ヨ", notes = "鐗╂枡搴撳瓨淇℃伅-閫氫富琛↖D鏌ヨ")
-    @GetMapping(value = "/queryLswMaterialInventoryByMainId")
-    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())) {
-                String warehouseId = lswMaterialInventory.getWarehouseId();
-                LineSideWarehouse warehouse = lineSideWarehouseService.getById(warehouseId);
-                lswMaterialInventory.setWarehouseName(warehouse.getWarehouseName());
-            }
+    @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃浜х嚎绫诲瀷鏌ヨ绾胯竟搴撶墿鏂�", notes = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃浜х嚎绫诲瀷鏌ヨ绾胯竟搴撶墿鏂�")
+    @GetMapping(value = "/queryLswMaterialByProductionType")
+    public Result<List<LswMaterial>> queryLswMaterialByProductionType(@RequestParam("factoryId") String factoryId) {
+        Factory factory = factoryService.getById(factoryId);
+        ProductionTypeEnum productionType = ProductionTypeEnum.fromName(factory.getProductionType());
+        List<LswMaterial> lswMaterialList = CollectionUtil.newArrayList();
+        if (productionType == null) {
+            throw new JeecgBootException("浜х嚎绫诲瀷鏈缃紝鏃犳硶鏌ヨ鐩稿簲鐗╂枡淇℃伅锛�");
         }
-        return Result.OK(lswMaterialInventoryList);
+        switch (productionType) {
+            case ASSEMBLE:
+                //瑁呴厤绾匡紝鏌ヨ鎴愬搧鐗╂枡
+                lswMaterialList = lswMaterialService.list(new LambdaQueryWrapper<LswMaterial>()
+                        .eq(LswMaterial::getMaterialCategory, MaterialCategoryEnum.FINISHED_PRODUCT.name())
+                        .eq(LswMaterial::getDelFlag, CommonConstant.DEL_FLAG_0)
+                        .eq(LswMaterial::getMaterialStatus, CommonConstant.STATUS_1)
+                        .orderByAsc(LswMaterial::getMaterialNumber));
+                break;
+            case INNERFLANGE:
+                //鍐呮硶鍏版満鍔犵嚎锛屾煡璇㈠唴娉曞叞鐗╂枡
+                lswMaterialList = lswMaterialService.list(new LambdaQueryWrapper<LswMaterial>()
+                        .eq(LswMaterial::getMaterialCategory, MaterialCategoryEnum.INNER_FLANGE.name())
+                        .eq(LswMaterial::getDelFlag, CommonConstant.DEL_FLAG_0)
+                        .eq(LswMaterial::getMaterialStatus, CommonConstant.STATUS_1)
+                        .orderByAsc(LswMaterial::getMaterialNumber));
+                break;
+            case OUTERFLANGE:
+                //澶栨硶鍏版満鍔犵嚎锛屾煡璇㈠娉曞叞鐗╂枡
+                lswMaterialList = lswMaterialService.list(new LambdaQueryWrapper<LswMaterial>()
+                        .eq(LswMaterial::getMaterialCategory, MaterialCategoryEnum.OUTER_FLANGE.name())
+                        .eq(LswMaterial::getDelFlag, CommonConstant.DEL_FLAG_0)
+                        .eq(LswMaterial::getMaterialStatus, CommonConstant.STATUS_1)
+                        .orderByAsc(LswMaterial::getMaterialNumber));
+                break;
+        }
+        return Result.OK(lswMaterialList);
     }
 
-    /**
-     * 瀵煎嚭excel
-     *
-     * @param request
-     * @param lswMaterial
-     */
-    //@RequiresPermissions("org.jeecg.modules:lsw_material:exportXls")
-    @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, LswMaterial lswMaterial) {
-        // Step.1 缁勮鏌ヨ鏉′欢鏌ヨ鏁版嵁
-        QueryWrapper<LswMaterial> queryWrapper = QueryGenerator.initQueryWrapper(lswMaterial, request.getParameterMap());
-        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-
-        //閰嶇疆閫変腑鏁版嵁鏌ヨ鏉′欢
-        String selections = request.getParameter("selections");
-        if (oConvertUtils.isNotEmpty(selections)) {
-            List<String> selectionList = Arrays.asList(selections.split(","));
-            queryWrapper.in("id", selectionList);
-        }
-        //Step.2 鑾峰彇瀵煎嚭鏁版嵁
+    @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-鏍规嵁鐗╂枡绫诲瀷鏌ヨ", notes = "绾胯竟搴撶墿鏂欎俊鎭�-鏍规嵁鐗╂枡绫诲瀷鏌ヨ")
+    @GetMapping(value = "/queryByMaterialCategory")
+    public Result<List<LswMaterial>> queryByMaterialCategory(@RequestParam("materialCategory") String materialCategory) {
+        LambdaQueryWrapper<LswMaterial> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(LswMaterial::getMaterialCategory, materialCategory);
+        queryWrapper.eq(LswMaterial::getDelFlag, CommonConstant.DEL_FLAG_0);
+        queryWrapper.eq(LswMaterial::getMaterialStatus, CommonConstant.STATUS_1);
+        queryWrapper.orderByAsc(LswMaterial::getMaterialNumber);
         List<LswMaterial> lswMaterialList = lswMaterialService.list(queryWrapper);
-
-        // Step.3 缁勮pageList
-        List<LswMaterialPage> pageList = new ArrayList<LswMaterialPage>();
-        for (LswMaterial main : lswMaterialList) {
-            LswMaterialPage vo = new LswMaterialPage();
-            BeanUtils.copyProperties(main, vo);
-            List<LswMaterialInventory> lswMaterialInventoryList = lswMaterialInventoryService.selectByMainId(main.getId());
-            vo.setLswMaterialInventoryList(lswMaterialInventoryList);
-            pageList.add(vo);
-        }
-
-        // Step.4 AutoPoi 瀵煎嚭Excel
-        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
-        mv.addObject(NormalExcelConstants.FILE_NAME, "绾胯竟搴撶墿鏂欎俊鎭垪琛�");
-        mv.addObject(NormalExcelConstants.CLASS, LswMaterialPage.class);
-        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("绾胯竟搴撶墿鏂欎俊鎭暟鎹�", "瀵煎嚭浜�:" + sysUser.getRealname(), "绾胯竟搴撶墿鏂欎俊鎭�"));
-        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
-        return mv;
+        return Result.ok(lswMaterialList);
     }
-
-    @GetMapping(value = "/searchlikeQuery")
-    public Result<?> searchlikeQuery(LswMaterial lswMaterial,
-                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                     HttpServletRequest req) {
-        IPage<Map<String, Object>> pageList = lswMaterialService.getLswMaterialListData(pageNo, pageSize, req);
-        return Result.OK(pageList);
-    }
-
 }

--
Gitblit v1.9.3