diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/base/controller/PointController.java b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/base/controller/PointController.java index 72199e2..0da6603 100644 --- a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/base/controller/PointController.java +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/base/controller/PointController.java @@ -12,9 +12,12 @@ import java.net.URLDecoder; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.cpte.modules.base.entity.Area; import org.cpte.modules.base.service.IAreaService; +import org.cpte.modules.constant.enums.AreaTypeEnum; +import org.cpte.modules.constant.enums.CommonStatusEnum; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; import org.cpte.modules.base.entity.Point; @@ -26,6 +29,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.system.base.controller.JeecgController; +import org.json.simple.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -195,4 +199,21 @@ public class PointController extends JeecgController { return super.importExcel(request, response, Point.class); } + @Operation(summary = "查询出库工作站") + @GetMapping(value = "/queryOutWorkStation") + public Result> queryOutWorkStation(@RequestParam(name = "areaId_dictText", required = true) String areaId_dictText) { + String areaCode=""; + if(AreaTypeEnum.CPCCQ.getDesc().equals(areaId_dictText)){ + areaCode=AreaTypeEnum.CK_DOCK.getValue(); + }else{ + areaCode=AreaTypeEnum.MJCK_DOCK.getValue(); + } + List points = pointService.queryPoints(null, CommonStatusEnum.FREE.getValue(), areaCode); + if (CollectionUtils.isEmpty(points)) { + return Result.error("未找到对应数据"); + } + List pointCodes = points.stream().map(Point::getPointCode).collect(Collectors.toList()); + return Result.OK(pointCodes); + } + } diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/count/controller/CountPlanController.java b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/count/controller/CountPlanController.java index 1dcf969..e039767 100644 --- a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/count/controller/CountPlanController.java +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/count/controller/CountPlanController.java @@ -53,259 +53,270 @@ import org.jeecg.common.aspect.annotation.AutoLog; import org.apache.shiro.authz.annotation.RequiresPermissions; - /** +/** * @Description: 盘点 * @author: cpte - * @Date: 2025-12-23 + * @Date: 2025-12-23 * @Version: V1.0 */ -@Tag(name="盘点") +@Tag(name = "盘点") @RestController @RequestMapping("/count/countPlan") @Slf4j public class CountPlanController { - @Autowired - private IItemService itemService; - @Autowired - private IPointService pointService; - @Autowired - private IStockService stockService; - @Autowired - private ICountPlanService countPlanService; - @Autowired - private ICountDetailService countDetailService; - - /** - * 分页列表查询 - * - * @param countPlan - * @param pageNo - * @param pageSize - * @param req - * @return - */ - //@AutoLog(value = "盘点-分页列表查询") - @Operation(summary="盘点-分页列表查询") - @GetMapping(value = "/list") - public Result> queryPageList(CountPlan countPlan, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(countPlan, req.getParameterMap()); - Page page = new Page(pageNo, pageSize); - IPage pageList = countPlanService.page(page, queryWrapper); - return Result.OK(pageList); - } - - /** - * 添加 - * - * @param countPlanPage - * @return - */ - @AutoLog(value = "盘点-添加") - @Operation(summary="盘点-添加") - @RequiresPermissions("count:data_count_plan:add") - @PostMapping(value = "/add") - public Result add(@RequestBody CountPlanPage countPlanPage) { - CountPlan countPlan = new CountPlan(); - BeanUtils.copyProperties(countPlanPage, countPlan); - countPlanService.saveMain(countPlan); - return Result.OK("添加成功!"); - } - - /** - * 编辑 - * - * @param countPlanPage - * @return - */ - @AutoLog(value = "盘点-编辑") - @Operation(summary="盘点-编辑") - @RequiresPermissions("count:data_count_plan:edit") - @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) - public Result edit(@RequestBody CountPlanPage countPlanPage) { - CountPlan existingCountPlan = countPlanService.getById(countPlanPage.getId()); - if(existingCountPlan==null) { - return Result.error("未找到对应数据"); - } - BeanUtils.copyProperties(countPlanPage, existingCountPlan); - countPlanService.updateMain(existingCountPlan, countPlanPage.getCountDetailList()); - return Result.OK("编辑成功!"); - } - - /** - * 通过id删除 - * - * @param id - * @return - */ - @AutoLog(value = "盘点-通过id删除") - @Operation(summary="盘点-通过id删除") - @RequiresPermissions("count:data_count_plan:delete") - @DeleteMapping(value = "/delete") - public Result delete(@RequestParam(name="id",required=true) Long id) { - countPlanService.delMain(id); - return Result.OK("删除成功!"); - } - - /** - * 批量删除 - * - * @param ids - * @return - */ - @AutoLog(value = "盘点-批量删除") - @Operation(summary="盘点-批量删除") - @RequiresPermissions("count:data_count_plan:deleteBatch") - @DeleteMapping(value = "/deleteBatch") - public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) { - this.countPlanService.delBatchMain(Arrays.asList(ids.split(","))); - return Result.OK("批量删除成功!"); - } - - /** - * 通过id查询 - * - * @param id - * @return - */ - //@AutoLog(value = "盘点-通过id查询") - @Operation(summary="盘点-通过id查询") - @GetMapping(value = "/queryById") - public Result queryById(@RequestParam(name="id",required=true) Long id) { - CountPlan countPlan = countPlanService.getById(id); - if(countPlan==null) { - return Result.error("未找到对应数据"); - } - return Result.OK(countPlan); - - } - - /** - * 通过id查询 - * - * @param id - * @return - */ - //@AutoLog(value = "盘点明细通过主表ID查询") - @Operation(summary="盘点明细主表ID查询") - @GetMapping(value = "/queryCountDetailByMainId") - public Result> queryCountDetailListByMainId(@RequestParam(name="id",required=true) Long id) { - List countDetailList = countDetailService.selectByMainId(id); - if(CollectionUtils.isNotEmpty(countDetailList)){ - //物料 - List itemIds=countDetailList.stream().map(CountDetail::getItemId).distinct().toList(); - Map itemMap=itemService.queryByItemIdsToMap(itemIds); - - //库位 - List pointIds=countDetailList.stream().map(CountDetail::getPointId).distinct().toList(); - Map pointMap=pointService.queryByPointIdsToMap(pointIds); - - //容器 - List stockIds=countDetailList.stream().map(CountDetail::getStockId).distinct().toList(); - Map stockMap=stockService.queryByStockIdsToMap(stockIds); - - for(CountDetail detail:countDetailList){ - Item item = itemMap.get(detail.getItemId()); - Point point = pointMap.get(detail.getPointId()); - Stock stock = stockMap.get(detail.getStockId()); - if(item!=null){ - detail.setItemCode(item.getItemCode()); - } - if(point!=null){ - detail.setPointCode(point.getPointCode()); - } - if(stock!=null){ - detail.setStockCode(stock.getStockCode()); - } - } - } - - return Result.OK(countDetailList); - } + @Autowired + private IItemService itemService; + @Autowired + private IPointService pointService; + @Autowired + private IStockService stockService; + @Autowired + private ICountPlanService countPlanService; + @Autowired + private ICountDetailService countDetailService; /** - * 导出excel - * - * @param request - * @param countPlan - */ + * 分页列表查询 + * + * @param countPlan + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "盘点-分页列表查询") + @Operation(summary = "盘点-分页列表查询") + @GetMapping(value = "/list") + public Result> queryPageList(CountPlan countPlan, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(countPlan, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + IPage pageList = countPlanService.page(page, queryWrapper); + return Result.OK(pageList); + } + + /** + * 添加 + * + * @param countPlanPage + * @return + */ + @AutoLog(value = "盘点-添加") + @Operation(summary = "盘点-添加") + @RequiresPermissions("count:data_count_plan:add") + @PostMapping(value = "/add") + public Result add(@RequestBody CountPlanPage countPlanPage) { + CountPlan countPlan = new CountPlan(); + BeanUtils.copyProperties(countPlanPage, countPlan); + countPlanService.saveMain(countPlan); + return Result.OK("添加成功!"); + } + + /** + * 编辑 + * + * @param countPlanPage + * @return + */ + @AutoLog(value = "盘点-编辑") + @Operation(summary = "盘点-编辑") + @RequiresPermissions("count:data_count_plan:edit") + @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) + public Result edit(@RequestBody CountPlanPage countPlanPage) { + CountPlan existingCountPlan = countPlanService.getById(countPlanPage.getId()); + if (existingCountPlan == null) { + return Result.error("未找到对应数据"); + } + BeanUtils.copyProperties(countPlanPage, existingCountPlan); + countPlanService.updateMain(existingCountPlan, countPlanPage.getCountDetailList()); + return Result.OK("编辑成功!"); + } + + /** + * 通过id删除 + * + * @param id + * @return + */ + @AutoLog(value = "盘点-通过id删除") + @Operation(summary = "盘点-通过id删除") + @RequiresPermissions("count:data_count_plan:delete") + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name = "id", required = true) Long id) { + countPlanService.delMain(id); + return Result.OK("删除成功!"); + } + + /** + * 批量删除 + * + * @param ids + * @return + */ + @AutoLog(value = "盘点-批量删除") + @Operation(summary = "盘点-批量删除") + @RequiresPermissions("count:data_count_plan:deleteBatch") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) { + this.countPlanService.delBatchMain(Arrays.asList(ids.split(","))); + return Result.OK("批量删除成功!"); + } + + /** + * 通过id查询 + * + * @param id + * @return + */ + //@AutoLog(value = "盘点-通过id查询") + @Operation(summary = "盘点-通过id查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name = "id", required = true) Long id) { + CountPlan countPlan = countPlanService.getById(id); + if (countPlan == null) { + return Result.error("未找到对应数据"); + } + return Result.OK(countPlan); + + } + + /** + * 通过id查询 + * + * @param id + * @return + */ + //@AutoLog(value = "盘点明细通过主表ID查询") + @Operation(summary = "盘点明细主表ID查询") + @GetMapping(value = "/queryCountDetailByMainId") + public Result> queryCountDetailListByMainId(@RequestParam(name = "id", required = true) Long id) { + List countDetailList = countDetailService.selectByMainId(id); + if (CollectionUtils.isNotEmpty(countDetailList)) { + //物料 + List itemIds = countDetailList.stream().map(CountDetail::getItemId).distinct().toList(); + Map itemMap = itemService.queryByItemIdsToMap(itemIds); + + //库位 + List pointIds = countDetailList.stream().map(CountDetail::getPointId).distinct().toList(); + Map pointMap = pointService.queryByPointIdsToMap(pointIds); + + //容器 + List stockIds = countDetailList.stream().map(CountDetail::getStockId).distinct().toList(); + Map stockMap = stockService.queryByStockIdsToMap(stockIds); + + for (CountDetail detail : countDetailList) { + Item item = itemMap.get(detail.getItemId()); + Point point = pointMap.get(detail.getPointId()); + Stock stock = stockMap.get(detail.getStockId()); + if (item != null) { + detail.setItemCode(item.getItemCode()); + } + if (point != null) { + detail.setPointCode(point.getPointCode()); + } + if (stock != null) { + detail.setStockCode(stock.getStockCode()); + } + } + } + + return Result.OK(countDetailList); + } + + /** + * 导出excel + * + * @param request + * @param countPlan + */ @RequiresPermissions("count:data_count_plan:exportXls") @RequestMapping(value = "/exportXls") public ModelAndView exportXls(HttpServletRequest request, CountPlan countPlan) { - // Step.1 组装查询条件查询数据 - QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(countPlan, request.getParameterMap()); - LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + // Step.1 组装查询条件查询数据 + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(countPlan, request.getParameterMap()); + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - //配置选中数据查询条件 - String selections = request.getParameter("selections"); - if(oConvertUtils.isNotEmpty(selections)) { - List selectionList = Arrays.asList(selections.split(",")); - queryWrapper.in("id",selectionList); - } - //Step.2 获取导出数据 - List countPlanList = countPlanService.list(queryWrapper); + //配置选中数据查询条件 + String selections = request.getParameter("selections"); + if (oConvertUtils.isNotEmpty(selections)) { + List selectionList = Arrays.asList(selections.split(",")); + queryWrapper.in("id", selectionList); + } + //Step.2 获取导出数据 + List countPlanList = countPlanService.list(queryWrapper); - // Step.3 组装pageList - List pageList = new ArrayList(); - for (CountPlan main : countPlanList) { - CountPlanPage vo = new CountPlanPage(); - BeanUtils.copyProperties(main, vo); - List countDetailList = countDetailService.selectByMainId(main.getId()); - vo.setCountDetailList(countDetailList); - pageList.add(vo); - } + // Step.3 组装pageList + List pageList = new ArrayList(); + for (CountPlan main : countPlanList) { + CountPlanPage vo = new CountPlanPage(); + BeanUtils.copyProperties(main, vo); + List countDetailList = countDetailService.selectByMainId(main.getId()); + vo.setCountDetailList(countDetailList); + pageList.add(vo); + } - // Step.4 AutoPoi 导出Excel - ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); - mv.addObject(NormalExcelConstants.FILE_NAME, "盘点列表"); - mv.addObject(NormalExcelConstants.CLASS, CountPlanPage.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, CountPlanPage.class); + mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("盘点数据", "导出人:" + sysUser.getRealname(), "盘点")); + mv.addObject(NormalExcelConstants.DATA_LIST, pageList); + return mv; } /** - * 通过excel导入数据 - * - * @param request - * @param response - * @return - */ + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ @RequiresPermissions("count:data_count_plan:importExcel") @RequestMapping(value = "/importExcel", method = RequestMethod.POST) public Result importExcel(HttpServletRequest request, HttpServletResponse response) { - MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; - Map fileMap = multipartRequest.getFileMap(); - for (Map.Entry entity : fileMap.entrySet()) { - // 获取上传文件对象 - MultipartFile file = entity.getValue(); - ImportParams params = new ImportParams(); - params.setTitleRows(2); - params.setHeadRows(1); - params.setNeedSave(true); - try { - List list = ExcelImportUtil.importExcel(file.getInputStream(), CountPlanPage.class, params); - for (CountPlanPage page : list) { - CountPlan po = new CountPlan(); - BeanUtils.copyProperties(page, po); - countPlanService.saveMain(po); - } - 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("文件导入失败!"); + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + ImportParams params = new ImportParams(); + params.setTitleRows(2); + params.setHeadRows(1); + params.setNeedSave(true); + try { + List list = ExcelImportUtil.importExcel(file.getInputStream(), CountPlanPage.class, params); + for (CountPlanPage page : list) { + CountPlan po = new CountPlan(); + BeanUtils.copyProperties(page, po); + countPlanService.saveMain(po); + } + 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("文件导入失败!"); + } + + @AutoLog(value = "盘点-任务下发") + @Operation(summary = "盘点-任务下发") + @RequiresPermissions("count:data_count_plan:countIssueTask") + @GetMapping(value = "/countIssueTask") + public Result countIssueTask(@RequestParam(name = "workStations", required = true) List workStations) { + for (String workStation : workStations){ + log.info("任务下发中,工作台:{}", workStation); + } + return Result.OK("任务下发成功"); } } diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/count/service/impl/CountPlanServiceImpl.java b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/count/service/impl/CountPlanServiceImpl.java index 6845f0c..7a7b783 100644 --- a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/count/service/impl/CountPlanServiceImpl.java +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/count/service/impl/CountPlanServiceImpl.java @@ -171,7 +171,6 @@ public class CountPlanServiceImpl extends ServiceImpl inventories) { List countDetails = new ArrayList<>(); - List inventoriesToUpdate = new ArrayList<>(); for (Inventory inventory : inventories) { // 创建盘点明细 @@ -180,14 +179,13 @@ public class CountPlanServiceImpl extends ServiceImpl SELECT inv.* FROM data_inventory inv - JOIN base_point point ON point.id = inv.point_id - AND point.area_id = #{areaId} - WHERE inv.status =1 - AND inv.quantity > 0 + INNER JOIN base_point point ON point.id = inv.point_id - JOIN base_item item ON item.id=inv.item_id - AND item.item_code IN + INNER JOIN base_item item ON item.id = inv.item_id + + + INNER JOIN base_stock stock ON stock.id = inv.stock_id + + + WHERE inv.status = 1 + AND inv.quantity > 0 + AND point.area_id = #{areaId} + + + AND item.item_code IN #{code} - JOIN base_stock stock ON stock.id=inv.stock_id - AND stock.stock_code IN + AND stock.stock_code IN #{code}