From eec479e2f3139286449005dcb05c014e4a60d255 Mon Sep 17 00:00:00 2001 From: cuilei <ray_tsu1@163.com> Date: 星期一, 18 八月 2025 16:59:25 +0800 Subject: [PATCH] 报工接口、产线线边库物料查询接口 --- src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java | 185 ++++++++++++++++++++------------------------- 1 files changed, 82 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..222c87a 100644 --- a/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java +++ b/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java @@ -1,5 +1,7 @@ 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; @@ -10,31 +12,31 @@ 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.Factory; import org.jeecg.modules.base.entity.LineSideWarehouse; +import org.jeecg.modules.base.enums.ProductionTypeEnum; +import org.jeecg.modules.base.service.IFactoryService; import org.jeecg.modules.base.service.ILineSideWarehouseService; import org.jeecg.modules.lsw.entity.LswMaterial; import org.jeecg.modules.lsw.entity.LswMaterialInventory; +import org.jeecg.modules.lsw.enums.MaterialCategoryEnum; 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 +50,7 @@ */ @Api(tags = "绾胯竟搴撶墿鏂欎俊鎭�") @RestController -@RequestMapping("/lswmaterial/lswMaterial") +@RequestMapping("/lsw/lswMaterial") @Slf4j public class LswMaterialController { @Autowired @@ -57,6 +59,8 @@ private ILswMaterialInventoryService lswMaterialInventoryService; @Autowired private ILineSideWarehouseService lineSideWarehouseService; + @Autowired + private IFactoryService factoryService; /** * 鍒嗛〉鍒楄〃鏌ヨ @@ -67,7 +71,6 @@ * @param req * @return */ - //@AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ") @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ", notes = "绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ") @GetMapping(value = "/list") public Result<IPage<LswMaterial>> queryPageList(LswMaterial lswMaterial, @@ -75,77 +78,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,13 +159,52 @@ 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()); } } return Result.OK(lswMaterialInventoryList); + } + + @AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃浜х嚎绫诲瀷鏌ヨ绾胯竟搴撶墿鏂�") + @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("浜х嚎绫诲瀷鏈缃紝鏃犳硶鏌ヨ鐩稿簲鐗╂枡淇℃伅锛�"); + } + 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); } /** @@ -226,47 +246,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