From 8c945d42c6610abd9ef17bc153114024175bec2a Mon Sep 17 00:00:00 2001 From: houshuai <17802598606@163.com> Date: 星期四, 03 七月 2025 19:43:12 +0800 Subject: [PATCH] 线边库和订单 基本搭建 --- src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java | 423 +++++++++++++++++++++++++++------------------------- 1 files changed, 222 insertions(+), 201 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 a9c9e20..3f0c60a 100644 --- a/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java +++ b/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java @@ -6,12 +6,15 @@ 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.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.lsw.entity.LswMaterial; import org.jeecg.modules.lsw.entity.LswMaterialInventory; import org.jeecg.modules.lsw.service.ILswMaterialInventoryService; @@ -38,223 +41,241 @@ import java.util.Map; /** -* @Description: 绾胯竟搴撶墿鏂欎俊鎭� -* @Author: jeecg-boot -* @Date: 2025-06-30 -* @Version: V1.0 -*/ -@Api(tags="绾胯竟搴撶墿鏂欎俊鎭�") + * @Description: 绾胯竟搴撶墿鏂欎俊鎭� + * @Author: jeecg-boot + * @Date: 2025-06-30 + * @Version: V1.0 + */ +@Api(tags = "绾胯竟搴撶墿鏂欎俊鎭�") @RestController @RequestMapping("/lswmaterial/lswMaterial") @Slf4j public class LswMaterialController { - @Autowired - private ILswMaterialService lswMaterialService; - @Autowired - private ILswMaterialInventoryService lswMaterialInventoryService; + @Autowired + private ILswMaterialService lswMaterialService; + @Autowired + private ILswMaterialInventoryService lswMaterialInventoryService; + @Autowired + private ILineSideWarehouseService lineSideWarehouseService; - /** - * 鍒嗛〉鍒楄〃鏌ヨ - * - * @param lswMaterial - * @param pageNo - * @param pageSize - * @param req - * @return - */ - //@AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ") - @ApiOperation(value="绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ", notes="绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ") - @GetMapping(value = "/list") - public Result<IPage<LswMaterial>> queryPageList(LswMaterial lswMaterial, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @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); - IPage<LswMaterial> pageList = lswMaterialService.page(page, queryWrapper); - return Result.OK(pageList); - } + /** + * 鍒嗛〉鍒楄〃鏌ヨ + * + * @param lswMaterial + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ") + @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ", notes = "绾胯竟搴撶墿鏂欎俊鎭�-鍒嗛〉鍒楄〃鏌ヨ") + @GetMapping(value = "/list") + public Result<IPage<LswMaterial>> queryPageList(LswMaterial lswMaterial, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @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); + 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 + * @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 - * @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("鏈壘鍒板搴旀暟鎹�"); - } - lswMaterialService.updateMain(lswMaterial, lswMaterialPage.getLswMaterialInventoryList()); - return Result.OK("缂栬緫鎴愬姛!"); - } + /** + * 缂栬緫 + * + * @param lswMaterialPage + * @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("鏈壘鍒板搴旀暟鎹�"); + } + 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("鍒犻櫎鎴愬姛!"); - } + /** + * 閫氳繃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("鍒犻櫎鎴愬姛!"); + } - /** - * 鎵归噺鍒犻櫎 - * - * @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("鎵归噺鍒犻櫎鎴愬姛锛�"); - } + /** + * 鎵归噺鍒犻櫎 + * + * @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("鎵归噺鍒犻櫎鎴愬姛锛�"); + } - /** - * 閫氳繃id鏌ヨ - * - * @param id - * @return - */ - //@AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃id鏌ヨ") - @ApiOperation(value="绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃id鏌ヨ", notes="绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃id鏌ヨ") - @GetMapping(value = "/queryById") - public Result<LswMaterial> queryById(@RequestParam(name="id",required=true) String id) { - LswMaterial lswMaterial = lswMaterialService.getById(id); - if(lswMaterial==null) { - return Result.error("鏈壘鍒板搴旀暟鎹�"); - } - return Result.OK(lswMaterial); + /** + * 閫氳繃id鏌ヨ + * + * @param id + * @return + */ + //@AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃id鏌ヨ") + @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃id鏌ヨ", notes = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃id鏌ヨ") + @GetMapping(value = "/queryById") + public Result<LswMaterial> queryById(@RequestParam(name = "id", required = true) String id) { + LswMaterial lswMaterial = lswMaterialService.getById(id); + if (lswMaterial == null) { + return Result.error("鏈壘鍒板搴旀暟鎹�"); + } + return Result.OK(lswMaterial); - } + } - /** - * 閫氳繃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); - return Result.OK(lswMaterialInventoryList); - } + /** + * 閫氳繃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()); + } + } + return Result.OK(lswMaterialInventoryList); + } - /** - * 瀵煎嚭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(); + /** + * 瀵煎嚭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 鑾峰彇瀵煎嚭鏁版嵁 - List<LswMaterial> lswMaterialList = lswMaterialService.list(queryWrapper); + //閰嶇疆閫変腑鏁版嵁鏌ヨ鏉′欢 + String selections = request.getParameter("selections"); + if (oConvertUtils.isNotEmpty(selections)) { + List<String> selectionList = Arrays.asList(selections.split(",")); + queryWrapper.in("id", selectionList); + } + //Step.2 鑾峰彇瀵煎嚭鏁版嵁 + 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.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; - } + // 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; + } - /** - * 閫氳繃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("鏂囦欢瀵煎叆澶辫触锛�"); - } + /** + * 閫氳繃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") + 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