From 4bf554a886837d7cbd1424fc562ae5a6660d4f54 Mon Sep 17 00:00:00 2001 From: zhouz <> Date: Mon, 9 Nov 2026 09:09:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85=E4=BB=93=E5=82=A8?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E6=B5=81=E7=A8=8B=E4=B8=8E=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 12 + .../boxpackage/vo/BoxTypeBindingRespVO.java | 4 + .../packagepoint/PackagePdaServiceImpl.java | 1 + .../nl/module/task/api/TransportTaskApi.java | 2 +- .../task/dto/TransportTaskUpdateReqDTO.java | 6 + ...TransportTaskBusinessOperationManager.java | 10 +- .../TransportTaskServiceImpl.java | 5 +- .../wms/api/boxtype/dto/BoxTypeResp.java | 2 + .../wms/api/boxtype/BoxTypeApiImpl.java | 1 + .../admin/boxtype/BoxTypeController.java | 1 + .../admin/boxtype/vo/BoxTypeCreateReqVO.java | 4 + .../admin/boxtype/vo/BoxTypePageReqVO.java | 3 + .../admin/boxtype/vo/BoxTypeRespVO.java | 4 + .../admin/moveinv/MoveInvController.java | 33 ++- .../admin/moveinv/vo/MoveInvPageReqVO.java | 4 + .../ShippingAreaPickupController.java | 17 ++ .../wms/dal/dataobject/boxtype/BoxTypeDO.java | 1 + .../wms/dal/mysql/boxinfo/BoxInfoMapper.java | 6 + .../dal/mysql/iostorinv/IostorInvMapper.java | 8 + .../iostorinvdis/IostorinvDisMapper.java | 2 - .../iostorinvdtl/IostorinvDtlMapper.java | 10 +- .../wms/dal/mysql/moveinv/MoveInvMapper.java | 18 +- .../mysql/moveinvdtl/MoveInvDtlMapper.java | 2 + .../wms/dal/mysql/point/WmsPointMapper.java | 4 + .../service/boxtype/BoxTypeServiceImpl.java | 1 + .../emptyvehicle/EmptyVehicleServiceImpl.java | 12 + .../external/acs/AcsExternalServiceImpl.java | 4 +- .../iostorinv/InboundIostorInvService.java | 3 + .../InboundIostorInvServiceImpl.java | 81 +++++- .../service/iostorinv/IostorInvService.java | 3 + .../iostorinv/IostorInvServiceImpl.java | 263 +++++++++++++++--- .../iostorinv/OutboundPlacementPlanner.java | 37 +++ .../iostorinv/TrackSectionLocationSorter.java | 10 + .../WarehouseAllocationStrategyService.java | 14 +- .../wms/service/moveinv/MoveInvService.java | 10 +- .../service/moveinv/MoveInvServiceImpl.java | 178 +++++++++++- .../shippingarea/ShippingAreaService.java | 4 + .../shippingarea/ShippingAreaServiceImpl.java | 54 +++- .../code/nl/module/wms/task/ShipAreaTask.java | 25 +- .../src/main/resources/application.yaml | 3 + .../mapper/boxinfo/BoxInfoMapper.xml | 10 + .../mapper/boxtype/BoxTypeMapper.xml | 5 +- .../iostorinv/CuttingProcessService.xml | 39 +++ .../iostorinvdis/CuttingProcessService.xml | 7 - .../iostorinvdtl/CuttingProcessService.xml | 20 ++ .../moveinvdtl/CuttingProcessService.xml | 6 + .../resources/mapper/point/WmsPointMapper.xml | 47 ++++ .../moveinv/MoveInvServiceImplTest.java | 48 ++++ .../src/api/wms/boxtype/index.ts | 1 + .../src/api/wms/moveinv/index.ts | 31 ++- .../boxtype/components/BoxTypeSelectModal.vue | 10 + .../src/views/lms/boxtype/data.ts | 23 ++ .../src/views/wms/boxtype/data.ts | 2 + .../src/views/wms/moveinv/data.ts | 14 +- .../src/views/wms/moveinv/index.vue | 60 +++- .../src/views/wms/moveinv/modules/form.vue | 138 ++++++++- sql/mysql/wms_track_section_strategy.sql | 14 +- 57 files changed, 1205 insertions(+), 132 deletions(-) diff --git a/.gitignore b/.gitignore index d63cd7b2..1e0e9103 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,15 @@ application-my.yaml # Local Git worktrees .worktrees/ + +###################################################################### +# Local generated artifacts + +/.codex-spreadsheet-build/ +/outputs/ +/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/dist 2/ + +# Local or one-off database test data +/sql/mysql/*_test_data.sql +/sql/mysql/*_test_data_add_*.sql +/sql/mysql/wms_temp_*.sql diff --git a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/controller/pda/boxpackage/vo/BoxTypeBindingRespVO.java b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/controller/pda/boxpackage/vo/BoxTypeBindingRespVO.java index 9c822f4d..a65cef49 100644 --- a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/controller/pda/boxpackage/vo/BoxTypeBindingRespVO.java +++ b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/controller/pda/boxpackage/vo/BoxTypeBindingRespVO.java @@ -19,6 +19,10 @@ public class BoxTypeBindingRespVO { @Schema(description = "木箱规格名称") private String boxName; + /** 规格型号 */ + @Schema(description = "规格型号") + private String specificationModel; + /** 木箱长度 */ @Schema(description = "木箱长度") private Integer boxLength; diff --git a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/packagepoint/PackagePdaServiceImpl.java b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/packagepoint/PackagePdaServiceImpl.java index 23c04760..7252e87f 100644 --- a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/packagepoint/PackagePdaServiceImpl.java +++ b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/packagepoint/PackagePdaServiceImpl.java @@ -545,6 +545,7 @@ public class PackagePdaServiceImpl implements PackagePdaService { if (boxType != null) { response.setBoxType(boxType.getBoxType()); response.setBoxName(boxType.getBoxName()); + response.setSpecificationModel(boxType.getSpecificationModel()); response.setBoxLength(boxType.getBoxLength()); response.setBoxWidth(boxType.getBoxWidth()); response.setBoxHigh(boxType.getBoxHigh()); diff --git a/nl-module-task/nl-module-task-api/src/main/java/cn/code/nl/module/task/api/TransportTaskApi.java b/nl-module-task/nl-module-task-api/src/main/java/cn/code/nl/module/task/api/TransportTaskApi.java index 40ea167d..01403de3 100644 --- a/nl-module-task/nl-module-task-api/src/main/java/cn/code/nl/module/task/api/TransportTaskApi.java +++ b/nl-module-task/nl-module-task-api/src/main/java/cn/code/nl/module/task/api/TransportTaskApi.java @@ -113,7 +113,7 @@ public interface TransportTaskApi { CommonResult readyGroupTask(@RequestParam("taskGroupId") Long taskGroupId, @RequestParam("sortSeq") Long sortSeq); - @GetMapping(PREFIX + "/updateTransportTask") + @PostMapping(PREFIX + "/updateTransportTask") @Operation(summary = "更新搬运任务") CommonResult updateTransportTask(@RequestBody TransportTaskUpdateReqDTO transportTaskUpdateReqDTO); diff --git a/nl-module-task/nl-module-task-api/src/main/java/cn/code/nl/module/task/dto/TransportTaskUpdateReqDTO.java b/nl-module-task/nl-module-task-api/src/main/java/cn/code/nl/module/task/dto/TransportTaskUpdateReqDTO.java index 5b100c38..87dd89a0 100644 --- a/nl-module-task/nl-module-task-api/src/main/java/cn/code/nl/module/task/dto/TransportTaskUpdateReqDTO.java +++ b/nl-module-task/nl-module-task-api/src/main/java/cn/code/nl/module/task/dto/TransportTaskUpdateReqDTO.java @@ -16,9 +16,15 @@ public class TransportTaskUpdateReqDTO { private Long taskId; + @Schema(description = "任务编码") + private String taskCode; + @Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED) private String taskName; + @Schema(description = "任务状态") + private String taskStatus; + @Schema(description = "业务归属服务:LMS/WMS", requiredMode = Schema.RequiredMode.REQUIRED) private String ownerService; diff --git a/nl-module-task/nl-module-task-server/src/main/java/cn/code/nl/module/task/manage/TransportTaskBusinessOperationManager.java b/nl-module-task/nl-module-task-server/src/main/java/cn/code/nl/module/task/manage/TransportTaskBusinessOperationManager.java index d8ba7978..2cb60505 100644 --- a/nl-module-task/nl-module-task-server/src/main/java/cn/code/nl/module/task/manage/TransportTaskBusinessOperationManager.java +++ b/nl-module-task/nl-module-task-server/src/main/java/cn/code/nl/module/task/manage/TransportTaskBusinessOperationManager.java @@ -75,7 +75,10 @@ public class TransportTaskBusinessOperationManager { return buildResp(task, data); } catch (Exception ex) { log.error("[acsBusinessOperation][执行异常][lockKey={}]", task.getTaskId(), ex); - return buildResp(task, null); + if (ex instanceof RuntimeException runtimeException) { + throw runtimeException; + } + throw new IllegalStateException("ACS业务操作执行失败", ex); } finally { if (lock.isHeldByCurrentThread()) { lock.unlock(); @@ -110,13 +113,14 @@ public class TransportTaskBusinessOperationManager { /** * 处理二次请求 */ - private AcsApplyActionRespVO handleApplyAgain(TransportTaskDO task, AcsFeedbackReqDTO reqDTO) { + private Object handleApplyAgain(TransportTaskDO task, AcsFeedbackReqDTO reqDTO) { log.info("二次请求, taskId={}", task.getTaskId()); // 调用具体的服务去执行取货完成操作。 TaskCommonApi serverApi = taskCommonApiFactory.getByServerName(task.getOwnerService()); CommonResult result = serverApi.doHandleApplyAgain(buildReq(task, reqDTO)); - return result.getCheckedData(); + AcsApplyActionRespVO actionResp = result.getCheckedData(); + return actionResp == null ? null : actionResp.getData(); } /** diff --git a/nl-module-task/nl-module-task-server/src/main/java/cn/code/nl/module/task/service/transporttask/TransportTaskServiceImpl.java b/nl-module-task/nl-module-task-server/src/main/java/cn/code/nl/module/task/service/transporttask/TransportTaskServiceImpl.java index cb0f0c11..961d1abd 100644 --- a/nl-module-task/nl-module-task-server/src/main/java/cn/code/nl/module/task/service/transporttask/TransportTaskServiceImpl.java +++ b/nl-module-task/nl-module-task-server/src/main/java/cn/code/nl/module/task/service/transporttask/TransportTaskServiceImpl.java @@ -60,6 +60,8 @@ import static cn.code.nl.module.task.enums.ErrorCodeConstants.*; public class TransportTaskServiceImpl implements TransportTaskService { private static final String TASK_BIZ_CREATE_LOCK_KEY = "task:biz:create:"; + /** 发货区同一出库单允许按木箱创建多条并行搬运任务。 */ + private static final String SHIPPING_AREA_BIZ_TYPE = "SHIPPING_AREA"; /** 分切双桁架任务调度锁。 */ private static final String TRUSS_DISPATCH_LOCK_KEY = "task:slitting:truss:dispatch"; @@ -123,7 +125,8 @@ public class TransportTaskServiceImpl implements TransportTaskService { success = TASK_INFO_CREATE_BY_RPC) public Long createTransportTaskByRpc(TransportTaskCreateReqDTO reqDTO) { if (StrUtil.isBlank(reqDTO.getOwnerService()) || StrUtil.isBlank(reqDTO.getBizType()) - || StrUtil.isBlank(reqDTO.getBizId())) { + || StrUtil.isBlank(reqDTO.getBizId()) + || SHIPPING_AREA_BIZ_TYPE.equals(reqDTO.getBizType())) { return insertTransportTaskByRpc(reqDTO); } String lockKey = TASK_BIZ_CREATE_LOCK_KEY + reqDTO.getOwnerService() + ":" diff --git a/nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxtype/dto/BoxTypeResp.java b/nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxtype/dto/BoxTypeResp.java index b115867d..7c780f05 100644 --- a/nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxtype/dto/BoxTypeResp.java +++ b/nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/api/boxtype/dto/BoxTypeResp.java @@ -16,6 +16,8 @@ public class BoxTypeResp { private String boxType; /** 木箱描述。 */ private String boxName; + /** 规格型号。 */ + private String specificationModel; /** 捆扎模板。 */ private String lashNum; /** 一次捆扎次数。 */ diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/api/boxtype/BoxTypeApiImpl.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/api/boxtype/BoxTypeApiImpl.java index ef8c2cef..9fca25dd 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/api/boxtype/BoxTypeApiImpl.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/api/boxtype/BoxTypeApiImpl.java @@ -45,6 +45,7 @@ public class BoxTypeApiImpl implements BoxTypeApi { target.setId(source.getId()); target.setBoxType(source.getBoxType()); target.setBoxName(source.getBoxName()); + target.setSpecificationModel(source.getSpecificationModel()); target.setLashNum(source.getLashNum()); target.setLashNumOne(source.getLashNumOne()); target.setLashNumTwo(source.getLashNumTwo()); diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/BoxTypeController.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/BoxTypeController.java index 89a9d87c..04d9c833 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/BoxTypeController.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/BoxTypeController.java @@ -122,6 +122,7 @@ public class BoxTypeController { target.setId(source.getId()); target.setBoxType(source.getBoxType()); target.setBoxName(source.getBoxName()); + target.setSpecificationModel(source.getSpecificationModel()); target.setLashNum(source.getLashNum()); target.setLashNumOne(source.getLashNumOne()); target.setLashNumTwo(source.getLashNumTwo()); diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypeCreateReqVO.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypeCreateReqVO.java index a3de7f75..4cd5cd13 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypeCreateReqVO.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypeCreateReqVO.java @@ -23,6 +23,10 @@ public class BoxTypeCreateReqVO { @Size(max = 255, message = "木箱描述长度不能超过255个字符") private String boxName; + /** 规格型号。 */ + @Size(max = 50, message = "规格型号长度不能超过50个字符") + private String specificationModel; + /** 捆扎模板。 */ @Size(max = 1, message = "捆扎模板长度不能超过1个字符") private String lashNum; diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypePageReqVO.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypePageReqVO.java index 0842c815..5c052c71 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypePageReqVO.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypePageReqVO.java @@ -17,6 +17,9 @@ public class BoxTypePageReqVO extends PageParam { /** 木箱描述。 */ private String boxName; + /** 规格型号。 */ + private String specificationModel; + /** 是否一次捆扎。 */ private Boolean needLashOne; diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypeRespVO.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypeRespVO.java index 89389b32..a678ed05 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypeRespVO.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/boxtype/vo/BoxTypeRespVO.java @@ -26,6 +26,10 @@ public class BoxTypeRespVO { @ExcelProperty("木箱描述") private String boxName; + /** 规格型号。 */ + @ExcelProperty("规格型号") + private String specificationModel; + /** 捆扎模板。 */ @ExcelProperty("捆扎模板") private String lashNum; diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/moveinv/MoveInvController.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/moveinv/MoveInvController.java index 8c2ba01f..42b20d4b 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/moveinv/MoveInvController.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/moveinv/MoveInvController.java @@ -2,12 +2,15 @@ package cn.code.nl.module.wms.controller.admin.moveinv; import cn.code.nl.framework.common.pojo.CommonResult; import cn.code.nl.framework.common.pojo.PageResult; +import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvInventoryPageReqVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvInventoryRespVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvPageReqVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvRespVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvSaveReqVO; +import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvTargetStructPageReqVO; import cn.code.nl.module.wms.dal.dataobject.structAttr.StrucAttrDO; import cn.code.nl.module.wms.service.moveinv.MoveInvService; +import cn.code.nl.framework.security.core.util.SecurityFrameworkUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; @@ -23,7 +26,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.List; import org.dromara.core.trans.anno.TransMethodResult; import static cn.code.nl.framework.common.pojo.CommonResult.success; @@ -63,6 +65,22 @@ public class MoveInvController { return success(true); } + @PostMapping("/issue") + @Operation(summary = "下发移库任务") + @PreAuthorize("@ss.hasPermission('wms:movement-order:update')") + public CommonResult issue(@RequestParam("id") Long id) { + moveInvService.issue(id); + return success(true); + } + + @PostMapping("/force-complete") + @Operation(summary = "人工确认现场已完成并强制完成移库单") + @PreAuthorize("@ss.hasPermission('wms:movement-order:update')") + public CommonResult forceComplete(@RequestParam("id") Long id) { + moveInvService.forceComplete(id, SecurityFrameworkUtils.getLoginUserId()); + return success(true); + } + @GetMapping("/get") @TransMethodResult @Operation(summary = "查询移库单详情") @@ -82,17 +100,16 @@ public class MoveInvController { @GetMapping("/availableInventory") @Operation(summary = "查询移库可用库存") @PreAuthorize("@ss.hasPermission('wms:movement-order:query')") - public CommonResult> getAvailableInventory( - @RequestParam("storId") String storId, - @RequestParam(value = "sectId", required = false) String sectId) { - return success(moveInvService.getAvailableInventory(storId, sectId)); + public CommonResult> getAvailableInventory( + @Valid MoveInvInventoryPageReqVO reqVO) { + return success(moveInvService.getAvailableInventory(reqVO)); } @GetMapping("/availableTargetStructs") @Operation(summary = "查询同库区同层可用目标仓位") @PreAuthorize("@ss.hasPermission('wms:movement-order:query')") - public CommonResult> getAvailableTargetStructs( - @RequestParam("sourceStructCode") String sourceStructCode) { - return success(moveInvService.getAvailableTargetStructs(sourceStructCode)); + public CommonResult> getAvailableTargetStructs( + @Valid MoveInvTargetStructPageReqVO reqVO) { + return success(moveInvService.getAvailableTargetStructs(reqVO)); } } diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/moveinv/vo/MoveInvPageReqVO.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/moveinv/vo/MoveInvPageReqVO.java index 1dc59f17..00430836 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/moveinv/vo/MoveInvPageReqVO.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/moveinv/vo/MoveInvPageReqVO.java @@ -18,6 +18,10 @@ public class MoveInvPageReqVO extends PageParam { private String billType; private String storId; private String billStatus; + /** 木箱号,对应移库明细的载具编码。 */ + private String boxNo; + /** 卷号,对应移库明细的批次。 */ + private String rollNo; @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; } diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/shippingarea/ShippingAreaPickupController.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/shippingarea/ShippingAreaPickupController.java index dd639625..9044584f 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/shippingarea/ShippingAreaPickupController.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/controller/admin/shippingarea/ShippingAreaPickupController.java @@ -4,11 +4,13 @@ import cn.code.nl.framework.common.pojo.CommonResult; import cn.code.nl.module.wms.controller.admin.shippingarea.vo.ShippingAreaBoxReqVO; import cn.code.nl.module.wms.controller.admin.shippingarea.vo.ShippingAreaBillRespVO; import cn.code.nl.module.wms.controller.admin.shippingarea.vo.ShippingAreaPickupRespVO; +import cn.code.nl.module.wms.controller.admin.shippingarea.vo.ShippingAreaVisualizationRespVO; import cn.code.nl.module.wms.service.shippingarea.ShippingAreaService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import jakarta.annotation.security.PermitAll; +import org.springframework.security.access.prepost.PreAuthorize; import jakarta.validation.Valid; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; @@ -37,6 +39,21 @@ public class ShippingAreaPickupController { return success(shippingAreaService.getPickupBills()); } + @GetMapping("/visualization") + @Operation(summary = "查询发货区库存可视化") + @PreAuthorize("@ss.hasPermission('wms:shipping-area-map:query')") + public CommonResult getVisualization() { + return success(shippingAreaService.getVisualization()); + } + + @PostMapping("/visualization-unbind") + @Operation(summary = "从发货区可视化解绑已提走木箱") + @PreAuthorize("@ss.hasPermission('wms:shipping-area-map:unbind')") + public CommonResult unbindFromVisualization( + @Valid @RequestBody ShippingAreaBoxReqVO reqVO) { + return success(shippingAreaService.confirmPickup(reqVO.getBoxNo())); + } + @PostMapping("/pickup-query") @Operation(summary = "按木箱查询所属出库单及同单木箱") @PermitAll diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/dataobject/boxtype/BoxTypeDO.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/dataobject/boxtype/BoxTypeDO.java index 1c43c1b2..640289a9 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/dataobject/boxtype/BoxTypeDO.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/dataobject/boxtype/BoxTypeDO.java @@ -20,6 +20,7 @@ public class BoxTypeDO { private Long id; private String boxType; private String boxName; + private String specificationModel; private String lashNum; private Integer lashNumOne; private Integer lashNumTwo; diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/boxinfo/BoxInfoMapper.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/boxinfo/BoxInfoMapper.java index 041556b9..e1f59ec0 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/boxinfo/BoxInfoMapper.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/boxinfo/BoxInfoMapper.java @@ -9,6 +9,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.Collection; +import java.util.List; + /** * 木箱基础信息只读 Mapper。 */ @@ -38,6 +41,9 @@ public interface BoxInfoMapper { /** 按木箱编号精确查询木箱信息。 */ BoxInfoDO selectByBoxNo(@Param("boxNo") String boxNo); + /** 批量查询在库木箱规格,用于成品入库同规格同排优先。 */ + List selectByBoxNos(@Param("boxNos") Collection boxNos); + /** 替换在库空木箱编号。 */ int replaceBoxNo(@Param("oldBoxNo") String oldBoxNo, @Param("newBoxNo") String newBoxNo); diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinv/IostorInvMapper.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinv/IostorInvMapper.java index ba7c82ed..7a08d5d3 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinv/IostorInvMapper.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinv/IostorInvMapper.java @@ -39,6 +39,14 @@ public interface IostorInvMapper extends BaseMapperX { @Param("confirmTime") LocalDateTime confirmTime, @Param("confirmOptid") String confirmOptid); + /** 所有有效明细完成后,原子完成出库单。 */ + int completeOutboundIfDetailsFinished(@Param("iostorinvId") Long iostorinvId, + @Param("confirmTime") LocalDateTime confirmTime, + @Param("confirmOptid") String confirmOptid); + + /** 查询所有分配已完成但主单尚未完成的出库单。 */ + List selectPendingCompletedOutboundIds(@Param("limit") int limit); + /** 标记金蝶入库审核回传成功。 */ int markKingdeeUploaded(@Param("iostorinvId") Long iostorinvId, @Param("uploadOptid") String uploadOptid, diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinvdis/IostorinvDisMapper.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinvdis/IostorinvDisMapper.java index b96c533a..6072c126 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinvdis/IostorinvDisMapper.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinvdis/IostorinvDisMapper.java @@ -40,8 +40,6 @@ public interface IostorinvDisMapper extends BaseMapperX { int clearInboundTask(@Param("taskId") String taskId); - long countUnfinishedByDetailId(@Param("detailId") Long detailId); - /** 统计同一出库单内指定载具剩余的分配记录,排除其他单据(尤其是历史入库记录)的干扰。 */ long countByOrderAndVehicle(@Param("iostorinvId") Long iostorinvId, @Param("vehicleCode") String vehicleCode); diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinvdtl/IostorinvDtlMapper.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinvdtl/IostorinvDtlMapper.java index 2ff0673e..529b0a3c 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinvdtl/IostorinvDtlMapper.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/iostorinvdtl/IostorinvDtlMapper.java @@ -34,14 +34,8 @@ public interface IostorinvDtlMapper extends BaseMapperX { """) int physicallyDeleteByIostorinvId(@Param("iostorinvId") Long iostorinvId); - @Select(""" - SELECT COUNT(*) - FROM wms_iostorinvdtl - WHERE iostorinv_id = #{iostorinvId} - AND deleted = '0' - AND bill_status <> '99' - """) - long countUnfinishedByIostorinvId(@Param("iostorinvId") Long iostorinvId); + /** 将指定出库单下已无未完成分配的明细原子推进为完成。 */ + int completeEligibleOutboundDetails(@Param("iostorinvId") Long iostorinvId); /** 全部分配完成时原子完成入库明细。 */ int completeInboundDetailIfAllocationsFinished(@Param("iostorinvdtlId") Long iostorinvdtlId); diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/moveinv/MoveInvMapper.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/moveinv/MoveInvMapper.java index 017139b2..0e650cc2 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/moveinv/MoveInvMapper.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/moveinv/MoveInvMapper.java @@ -1,5 +1,6 @@ package cn.code.nl.module.wms.dal.mysql.moveinv; +import cn.hutool.core.util.StrUtil; import cn.code.nl.framework.common.pojo.PageResult; import cn.code.nl.framework.mybatis.core.mapper.BaseMapperX; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvPageReqVO; @@ -14,12 +15,23 @@ import org.apache.ibatis.annotations.Mapper; public interface MoveInvMapper extends BaseMapperX { default PageResult selectPage(MoveInvPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() + LambdaQueryWrapperX wrapper = new LambdaQueryWrapperX() .likeIfPresent(MoveInvDO::getBillCode, reqVO.getBillCode()) .eqIfPresent(MoveInvDO::getBillType, reqVO.getBillType()) .eqIfPresent(MoveInvDO::getStorId, reqVO.getStorId()) .eqIfPresent(MoveInvDO::getBillStatus, reqVO.getBillStatus()) - .betweenIfPresent(MoveInvDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MoveInvDO::getMoveinvId)); + .betweenIfPresent(MoveInvDO::getCreateTime, reqVO.getCreateTime()); + wrapper.apply(StrUtil.isNotBlank(reqVO.getBoxNo()), + "EXISTS (SELECT 1 FROM wms_moveinvdtl dtl " + + "WHERE dtl.moveinv_id = wms_moveinv.moveinv_id " + + "AND dtl.storagevehicle_code LIKE CONCAT('%', {0}, '%'))", + reqVO.getBoxNo()); + wrapper.apply(StrUtil.isNotBlank(reqVO.getRollNo()), + "EXISTS (SELECT 1 FROM wms_moveinvdtl dtl " + + "WHERE dtl.moveinv_id = wms_moveinv.moveinv_id " + + "AND dtl.pcsn LIKE CONCAT('%', {0}, '%'))", + reqVO.getRollNo()); + wrapper.orderByDesc(MoveInvDO::getMoveinvId); + return selectPage(reqVO, wrapper); } } diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/moveinvdtl/MoveInvDtlMapper.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/moveinvdtl/MoveInvDtlMapper.java index 78162165..4cf21ac7 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/moveinvdtl/MoveInvDtlMapper.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/moveinvdtl/MoveInvDtlMapper.java @@ -19,5 +19,7 @@ public interface MoveInvDtlMapper extends BaseMapperX { long countUnfinishedByMoveinvId(@Param("moveinvId") Long moveinvId); + long countUnissuedByMoveinvId(@Param("moveinvId") Long moveinvId); + int clearTaskId(@Param("taskId") Long taskId); } diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/point/WmsPointMapper.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/point/WmsPointMapper.java index 9c7f537e..928a2dfb 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/point/WmsPointMapper.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/dal/mysql/point/WmsPointMapper.java @@ -2,6 +2,7 @@ package cn.code.nl.module.wms.dal.mysql.point; import cn.code.nl.module.wms.dal.dataobject.point.ShippingPointRowCandidate; import cn.code.nl.module.wms.dal.dataobject.point.ShippingAreaPickupRow; +import cn.code.nl.module.wms.dal.dataobject.point.ShippingAreaPointViewRow; import cn.code.nl.module.wms.dal.dataobject.point.WmsPointDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -65,6 +66,9 @@ public interface WmsPointMapper { /** 查询仍有木箱在发货区或正在前往发货区的出库单木箱。 */ List selectActiveShippingBoxes(); + /** 查询发货区全部可视化点位及关联任务、出库单。 */ + List selectShippingAreaPointView(); + /** 将发货区内的指定木箱锁定,防止重复解绑。 */ WmsPointDO selectShippingPointByBoxNoForUpdate(@Param("boxNo") String boxNo); diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/boxtype/BoxTypeServiceImpl.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/boxtype/BoxTypeServiceImpl.java index 6a134ffe..e0694b90 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/boxtype/BoxTypeServiceImpl.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/boxtype/BoxTypeServiceImpl.java @@ -119,6 +119,7 @@ public class BoxTypeServiceImpl implements BoxTypeService { BoxTypeDO boxType = new BoxTypeDO(); boxType.setBoxType(reqVO.getBoxType()); boxType.setBoxName(reqVO.getBoxName()); + boxType.setSpecificationModel(reqVO.getSpecificationModel()); boxType.setLashNum(reqVO.getLashNum()); boxType.setLashNumOne(reqVO.getLashNumOne()); boxType.setLashNumTwo(reqVO.getLashNumTwo()); diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/emptyvehicle/EmptyVehicleServiceImpl.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/emptyvehicle/EmptyVehicleServiceImpl.java index 1c684991..ae09e0fd 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/emptyvehicle/EmptyVehicleServiceImpl.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/emptyvehicle/EmptyVehicleServiceImpl.java @@ -5,6 +5,8 @@ import cn.code.nl.module.base.api.codegen.dto.CodeGenerateReqDTO; import cn.code.nl.module.task.api.TransportTaskApi; import cn.code.nl.module.task.dto.TaskInfoDTO; import cn.code.nl.module.task.dto.TransportTaskCreateReqDTO; +import cn.code.nl.module.task.dto.UnfinishedTaskPointReqDTO; +import cn.code.nl.framework.common.exception.ServiceException; import cn.code.nl.module.wms.service.task.DenseStorageTaskConflictService; import cn.code.nl.module.wms.controller.admin.emptyvehicle.vo.EmptyVehicleTaskCreateReqVO; import cn.code.nl.module.wms.dal.dataobject.structAttr.StrucAttrDO; @@ -46,12 +48,22 @@ public class EmptyVehicleServiceImpl implements EmptyVehicleService { @Override @Transactional(rollbackFor = Exception.class) public EmptyVehicleTaskCreateResult createOutboundTask(String deviceCode) { + validateOutboundDeviceAvailable(deviceCode); EmptyVehicleTaskCreateReqVO reqVO = new EmptyVehicleTaskCreateReqVO(); reqVO.setDeviceCode(deviceCode); reqVO.setIoType("1"); return createTaskResult(reqVO); } + /** 同一设备点位存在未完成任务时,不再重复申请空托盘。 */ + void validateOutboundDeviceAvailable(String deviceCode) { + UnfinishedTaskPointReqDTO reqDTO = new UnfinishedTaskPointReqDTO(); + reqDTO.setPointCodes(List.of(deviceCode)); + if (Boolean.TRUE.equals(transportTaskApi.hasUnfinishedByPointCodes(reqDTO).getCheckedData())) { + throw new ServiceException(500, "存在未完成的任务"); + } + } + private EmptyVehicleTaskCreateResult createTaskResult(EmptyVehicleTaskCreateReqVO reqVO) { boolean inbound = INBOUND.equals(reqVO.getIoType()); // wms_structattr.task_code 长度为 20,临时预占码直接使用雪花 ID,避免带前缀后超长。 diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/external/acs/AcsExternalServiceImpl.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/external/acs/AcsExternalServiceImpl.java index 217e1532..7637f7b5 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/external/acs/AcsExternalServiceImpl.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/external/acs/AcsExternalServiceImpl.java @@ -439,7 +439,8 @@ public class AcsExternalServiceImpl implements AcsExternalService { StrucAttrDO targetStruct = null; String heightType = inboundIostorInvService.resolveInboundHeightType(boxNo); for (StrucAttrDO candidate : inboundIostorInvService - .getDefaultFinishedGoodsInboundStructs(INBOUND_LOCATION_LOCK_MAX_ATTEMPTS, heightType)) { + .getDefaultFinishedGoodsInboundStructs( + INBOUND_LOCATION_LOCK_MAX_ATTEMPTS, heightType, boxNo)) { if (strucAttrMapper.lockFinishedGoodsInbound( candidate.getStructId(), reservationCode, boxNo) == 1) { targetStruct = candidate; @@ -509,6 +510,7 @@ public class AcsExternalServiceImpl implements AcsExternalService { task.setPointCode1(reqVO.getDeviceCode()); task.setPointCode2(targetStruct.getStructCode()); task.setVehicleCode(boxNo); + task.setVehicleCode2(reqVO.getPalletNo()); task.setVehicleQty(1L); task.setMaterialId(firstMaterial.getMaterialId()); task.setMaterialCode(firstMaterial.getMaterialCode()); diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/InboundIostorInvService.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/InboundIostorInvService.java index 042c89ed..8c706482 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/InboundIostorInvService.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/InboundIostorInvService.java @@ -25,6 +25,9 @@ public interface InboundIostorInvService { List getDefaultFinishedGoodsInboundStructs(int maxAttempts); /** 按指定高度类型返回默认立体库候选货位。 */ List getDefaultFinishedGoodsInboundStructs(int maxAttempts, String heightType); + /** 按指定木箱规格及高度类型返回默认立体库候选货位。 */ + List getDefaultFinishedGoodsInboundStructs(int maxAttempts, String heightType, + String boxNo); /** 根据木箱高度解析入库货位高度类型。 */ String resolveInboundHeightType(String boxNo); void setInboundPoint(@Valid InboundSetPointReqVO reqVO); diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/InboundIostorInvServiceImpl.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/InboundIostorInvServiceImpl.java index f03b29f5..5abaa098 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/InboundIostorInvServiceImpl.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/InboundIostorInvServiceImpl.java @@ -217,7 +217,8 @@ public class InboundIostorInvServiceImpl implements InboundIostorInvService { if (Boolean.TRUE.equals(reqVO.getAutoAllocate())) { target = null; List candidates = getInboundAvailableStructs( - header.getStorId(), item.getSectId(), requiredHeightType); + header.getStorId(), item.getSectId(), requiredHeightType, + resolveInboundBoxType(vehicleCode)); int attempts = 0; for (StrucAttrDO candidate : candidates) { if (attempts++ >= INBOUND_LOCATION_LOCK_MAX_ATTEMPTS) { @@ -330,11 +331,12 @@ public class InboundIostorInvServiceImpl implements InboundIostorInvService { @Override public List getInboundAvailableStructs(String storId, String sectId) { - return getInboundAvailableStructs(storId, sectId, null); + return getInboundAvailableStructs(storId, sectId, null, null); } private List getInboundAvailableStructs(String storId, String sectId, - String heightType) { + String heightType, + String incomingBoxType) { List candidates = strucAttrMapper.selectList(new LambdaQueryWrapperX() .eq(StrucAttrDO::getStorId, storId) .eq(StrucAttrDO::getSectId, sectId) @@ -377,9 +379,15 @@ public class InboundIostorInvServiceImpl implements InboundIostorInvService { .collect(Collectors.toSet()); candidates.removeIf(candidate -> taskConflictScopes.contains( StorageLocationInventoryScope.keyOf(candidate))); - if (!candidates.isEmpty() && warehouseAllocationStrategyService.usesTrackSection( - candidates.get(0).getSectCode(), "1")) { - TrackSectionLocationSorter.sortFromCenter(candidates, allLocations); + if (!candidates.isEmpty()) { + String sectionCode = candidates.get(0).getSectCode(); + if (warehouseAllocationStrategyService.usesSmallColumnInLargeColumnOut( + sectionCode, "1")) { + TrackSectionLocationSorter.sortFromSmallColumn(candidates); + } else if (warehouseAllocationStrategyService.usesTrackSection(sectionCode, "1")) { + TrackSectionLocationSorter.sortFromCenter(candidates, allLocations); + } + preferSameBoxTypeScope(candidates, allLocations, incomingBoxType); } return candidates; } @@ -398,6 +406,12 @@ public class InboundIostorInvServiceImpl implements InboundIostorInvService { @Override public List getDefaultFinishedGoodsInboundStructs(int maxAttempts, String heightType) { + return getDefaultFinishedGoodsInboundStructs(maxAttempts, heightType, null); + } + + @Override + public List getDefaultFinishedGoodsInboundStructs(int maxAttempts, String heightType, + String boxNo) { if (maxAttempts <= 0) { return List.of(); } @@ -420,11 +434,57 @@ public class InboundIostorInvServiceImpl implements InboundIostorInvService { if (sect == null) { throw new ServiceException(500, "默认立体库未配置可用主存区"); } - return getInboundAvailableStructs(warehouse.getStorId(), sect.getSectId(), heightType).stream() + return getInboundAvailableStructs(warehouse.getStorId(), sect.getSectId(), heightType, + resolveInboundBoxType(boxNo)).stream() .limit(maxAttempts) .toList(); } + /** 相同规格优先同排;没有同规格可用排时优先启用尚无成品的新排。 */ + private void preferSameBoxTypeScope(List candidates, + List allLocations, + String incomingBoxType) { + if (StrUtil.isBlank(incomingBoxType)) { + return; + } + Set occupiedFinishedBoxNos = allLocations.stream() + .filter(location -> FINISHED_GOODS_INVENTORY_TYPE.equals(location.getInventoryType())) + .map(StrucAttrDO::getStoragevehicleCode) + .filter(StrUtil::isNotBlank) + .collect(Collectors.toSet()); + if (occupiedFinishedBoxNos.isEmpty()) { + return; + } + Map boxTypeByBoxNo = boxInfoMapper.selectByBoxNos(occupiedFinishedBoxNos) + .stream() + .filter(box -> StrUtil.isNotBlank(box.getBoxNo())) + .collect(Collectors.toMap(BoxInfoDO::getBoxNo, BoxInfoDO::getMaterialCode, + (left, right) -> left)); + FinishedGoodsBoxTypeLocationSorter.sort( + candidates, allLocations, incomingBoxType, boxTypeByBoxNo); + } + + private String resolveInboundBoxType(String boxNo) { + if (StrUtil.isBlank(boxNo)) { + return null; + } + BoxInfoDO box = boxInfoMapper.selectByBoxNo(boxNo); + if (box != null && StrUtil.isNotBlank(box.getMaterialCode())) { + return box.getMaterialCode().trim(); + } + CommonResult> result = subPackageRelationApi.listByBoxNo(boxNo); + List relations = result == null ? null : result.getCheckedData(); + if (relations == null) { + return null; + } + Set boxTypes = relations.stream() + .map(SubPackageRelationResp::getBoxType) + .filter(StrUtil::isNotBlank) + .map(String::trim) + .collect(Collectors.toCollection(LinkedHashSet::new)); + return boxTypes.size() == 1 ? boxTypes.iterator().next() : null; + } + @Override public String resolveInboundHeightType(String boxNo) { String heightValue = null; @@ -980,12 +1040,12 @@ public class InboundIostorInvServiceImpl implements InboundIostorInvService { GroupPlateDO group, long taskGroupId, long sortSeq, String bizId) { return createAndIssueInboundTask(sourcePoint, targetPoint, group, taskGroupId, - sortSeq, bizId, group.getVehicleCode()); + sortSeq, bizId, null); } private Long createAndIssueInboundTask(String sourcePoint, String targetPoint, GroupPlateDO group, long taskGroupId, - long sortSeq, String bizId, String transportVehicleCode) { + long sortSeq, String bizId, String palletCode) { denseStorageTaskConflictService.assertCanIssue(targetPoint, DenseStorageTaskConflictService.INBOUND); TransportTaskCreateReqDTO task = new TransportTaskCreateReqDTO(); @@ -999,7 +1059,8 @@ public class InboundIostorInvServiceImpl implements InboundIostorInvService { task.setAgvSystemType("1"); task.setPointCode1(sourcePoint); task.setPointCode2(targetPoint); - task.setVehicleCode(transportVehicleCode); + task.setVehicleCode(group.getVehicleCode()); + task.setVehicleCode2(palletCode); if (StrUtil.isNotBlank(group.getMaterialId())) { task.setMaterialId(Long.valueOf(group.getMaterialId())); } diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/IostorInvService.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/IostorInvService.java index 534d5689..201674ff 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/IostorInvService.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/IostorInvService.java @@ -26,6 +26,9 @@ public interface IostorInvService { /** 根据搬运任务完成对应出库单业务。 */ void completeOutboundTask(Long taskId, Long confirmUserId); + /** 补偿所有分配已完成但明细或主单状态未收敛的出库单。 */ + void reconcileCompletedOutboundOrders(); + /** 根据搬运任务取消对应出库分配。 */ void cancelOutboundTask(Long taskId); diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/IostorInvServiceImpl.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/IostorInvServiceImpl.java index 9304bbf8..0d50ac2c 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/IostorInvServiceImpl.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/IostorInvServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import cn.code.nl.framework.common.pojo.CommonResult; +import cn.code.nl.framework.common.exception.ServiceException; import cn.code.nl.framework.security.core.util.SecurityFrameworkUtils; import cn.code.nl.module.base.api.codegen.CodeGenApi; import cn.code.nl.module.base.api.codegen.dto.CodeGenerateReqDTO; @@ -18,14 +19,19 @@ import cn.code.nl.module.system.api.user.dto.AdminUserRespDTO; import cn.code.nl.module.wms.dal.dataobject.bsrealstorattr.BsrealStorAttrDO; import cn.code.nl.module.wms.dal.dataobject.iostorinvdtl.IostorinvDtlDO; import cn.code.nl.module.wms.dal.dataobject.moveinvdtl.MoveInvDtlDO; +import cn.code.nl.module.wms.dal.dataobject.storagevehicleext.StorageVehicleExtDO; import cn.code.nl.module.wms.service.moveinv.MoveInvService; import cn.code.nl.module.wms.service.task.DenseStorageTaskConflictService; import cn.code.nl.module.wms.dal.mysql.storagevehicleext.StorageVehicleExtMapper; import lombok.extern.slf4j.Slf4j; +import org.springframework.dao.DeadlockLoserDataAccessException; import org.springframework.stereotype.Service; import jakarta.annotation.Resource; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.TransactionDefinition; import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionTemplate; import java.math.BigDecimal; import java.util.*; @@ -69,6 +75,15 @@ import static cn.code.nl.module.wms.enums.ErrorCodeConstants.*; @Slf4j public class IostorInvServiceImpl implements IostorInvService { + /** 出库任务完成发生数据库死锁时的最大执行次数。 */ + private static final int OUTBOUND_COMPLETE_MAX_ATTEMPTS = 3; + + /** 出库任务完成死锁重试的基础等待毫秒数。 */ + private static final long OUTBOUND_COMPLETE_RETRY_INTERVAL_MILLIS = 100L; + + /** 单次补偿处理的最大出库单数量。 */ + private static final int OUTBOUND_RECONCILE_BATCH_SIZE = 100; + @Resource private IostorInvMapper iostorInvMapper; @@ -110,27 +125,88 @@ public class IostorInvServiceImpl implements IostorInvService { private WmsPointService wmsPointService; @Resource private StorageVehicleExtMapper storageVehicleExtMapper; + @Resource + private PlatformTransactionManager transactionManager; @Override - @Transactional(rollbackFor = Exception.class) public void completeOutboundTask(Long taskId, Long confirmUserId) { + TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); + transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); + for (int attempt = 1; attempt <= OUTBOUND_COMPLETE_MAX_ATTEMPTS; attempt++) { + try { + transactionTemplate.executeWithoutResult(status -> + completeOutboundTaskInTransaction(taskId, confirmUserId)); + return; + } catch (DeadlockLoserDataAccessException exception) { + if (attempt == OUTBOUND_COMPLETE_MAX_ATTEMPTS) { + log.error("出库任务完成发生数据库死锁,重试后仍失败,taskId={}, attempt={}", + taskId, attempt, exception); + throw exception; + } + long retryInterval = OUTBOUND_COMPLETE_RETRY_INTERVAL_MILLIS * attempt; + log.warn("出库任务完成发生数据库死锁,准备重试,taskId={}, attempt={}, retryInterval={}ms", + taskId, attempt, retryInterval); + try { + Thread.sleep(retryInterval); + } catch (InterruptedException interruptedException) { + Thread.currentThread().interrupt(); + throw new IllegalStateException("出库任务完成死锁重试被中断,taskId=" + taskId, + interruptedException); + } + } + } + } + + @Override + public void reconcileCompletedOutboundOrders() { + List headerIds = iostorInvMapper.selectPendingCompletedOutboundIds( + OUTBOUND_RECONCILE_BATCH_SIZE); + for (Long headerId : headerIds) { + TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); + transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); + transactionTemplate.executeWithoutResult(status -> { + int detailAffectedRows = iostorinvDtlMapper.completeEligibleOutboundDetails(headerId); + int headerAffectedRows = iostorInvMapper.completeOutboundIfDetailsFinished( + headerId, java.time.LocalDateTime.now(), null); + log.warn("出库单完成状态自动补偿,headerId={}, detailAffectedRows={}, headerAffectedRows={}", + headerId, detailAffectedRows, headerAffectedRows); + }); + } + } + + /** 在独立事务中完成出库任务,并收敛关联主单下的全部明细和主单状态。 */ + private void completeOutboundTaskInTransaction(Long taskId, Long confirmUserId) { String taskIdValue = String.valueOf(taskId); List allocations = iostorinvDisMapper.selectList( new LambdaQueryWrapperX() .eq(IostorinvDisDO::getTaskId, taskIdValue)); if (CollUtil.isEmpty(allocations)) { + log.error("[OUTBOUND_COMPLETE] 未找到任务分配记录, taskId={}, confirmUserId={}", + taskId, confirmUserId); throw new IllegalStateException("未找到出库任务对应的分配记录,taskId=" + taskId); } + log.info("[OUTBOUND_COMPLETE] 开始处理, taskId={}, confirmUserId={}, allocationCount={}, " + + "allocationIds={}, detailIds={}, vehicles={}, structs={}", + taskId, confirmUserId, allocations.size(), + allocations.stream().map(IostorinvDisDO::getIostorinvdisId).toList(), + allocations.stream().map(IostorinvDisDO::getIostorinvdtlId).distinct().toList(), + allocations.stream().map(IostorinvDisDO::getStoragevehicleCode).distinct().toList(), + allocations.stream().map(IostorinvDisDO::getStructCode).distinct().toList()); // 1. 同一任务可能关联同一载具下的多条分配记录,统一推进为完成。 - iostorinvDisMapper.completeOutboundAllocations(taskIdValue); + int completedAllocationCount = iostorinvDisMapper.completeOutboundAllocations(taskIdValue); + log.info("[OUTBOUND_COMPLETE] 分配记录完成, taskId={}, affectedRows={}, allocationCount={}", + taskId, completedAllocationCount, allocations.size()); // 2. 出库完成后释放起点仓位,同时移除仓位上的载具占用信息。 - allocations.stream() + int releasedStructCount = allocations.stream() .filter(item -> StrUtil.isNotBlank(item.getStructId())) .map(IostorinvDisDO::getStructId) .distinct() - .forEach(structId -> strucAttrMapper.completeOutboundTask(structId, taskIdValue)); + .mapToInt(structId -> strucAttrMapper.completeOutboundTask(structId, taskIdValue)) + .sum(); + log.info("[OUTBOUND_COMPLETE] 起点仓位释放, taskId={}, affectedRows={}", + taskId, releasedStructCount); // 3. 一个木箱可能对应多条组盘记录,全部更新为“出库”。 Set vehicleCodes = allocations.stream() @@ -140,46 +216,34 @@ public class IostorInvServiceImpl implements IostorInvService { if (CollUtil.isNotEmpty(vehicleCodes)) { GroupPlateDO groupUpdate = new GroupPlateDO(); groupUpdate.setStatus("03"); - groupPlateMapper.update(groupUpdate, new LambdaQueryWrapperX() + int completedGroupCount = groupPlateMapper.update(groupUpdate, new LambdaQueryWrapperX() .in(GroupPlateDO::getVehicleCode, vehicleCodes)); unbindPalletExtensions(vehicleCodes); + log.info("[OUTBOUND_COMPLETE] 组盘完成并解绑托盘扩展属性, taskId={}, vehicles={}, " + + "groupAffectedRows={}", + taskId, vehicleCodes, completedGroupCount); } - // 4. 分配全部完成后完成对应明细;明细全部完成后再完成主表。 - Set detailIds = allocations.stream() - .map(IostorinvDisDO::getIostorinvdtlId) + // 4. 按主单重新收敛全部明细,修复其他任务回调时序导致的明细状态遗漏。 + Set headerIds = allocations.stream() + .map(IostorinvDisDO::getIostorinvId) .filter(StrUtil::isNotBlank) .map(Long::valueOf) .collect(Collectors.toCollection(LinkedHashSet::new)); - Set headerIds = new LinkedHashSet<>(); - for (Long detailId : detailIds) { - IostorinvDtlDO detail = iostorinvDtlMapper.selectById(detailId); - if (detail == null) { - continue; - } - headerIds.add(detail.getIostorinvId()); - if (iostorinvDisMapper.countUnfinishedByDetailId(detailId) == 0) { - IostorinvDtlDO detailUpdate = new IostorinvDtlDO(); - detailUpdate.setIostorinvdtlId(detailId); - detailUpdate.setBillStatus("99"); - detailUpdate.setRealQty(Objects.requireNonNullElse(detail.getPlanQty(), BigDecimal.ZERO)); - iostorinvDtlMapper.updateById(detailUpdate); - } - } for (Long headerId : headerIds) { - if (iostorinvDtlMapper.countUnfinishedByIostorinvId(headerId) == 0) { - IostorInvDO headerUpdate = new IostorInvDO(); - headerUpdate.setIostorinvId(headerId); - headerUpdate.setBillStatus("99"); - headerUpdate.setConfirmTime(java.time.LocalDateTime.now()); - if (confirmUserId != null) { - // 主表完成人以最后一个出库任务完成时的登录上下文用户为准。 - headerUpdate.setConfirmOptid(String.valueOf(confirmUserId)); - } - iostorInvMapper.updateById(headerUpdate); - } + IostorInvDO header = iostorInvMapper.selectById(headerId); + int detailAffectedRows = iostorinvDtlMapper.completeEligibleOutboundDetails(headerId); + java.time.LocalDateTime confirmTime = java.time.LocalDateTime.now(); + int headerAffectedRows = iostorInvMapper.completeOutboundIfDetailsFinished( + headerId, confirmTime, confirmUserId == null ? null : String.valueOf(confirmUserId)); + log.info("[OUTBOUND_COMPLETE] 主单状态收敛, taskId={}, headerId={}, billCode={}, " + + "beforeStatus={}, detailAffectedRows={}, headerAffectedRows={}, confirmUserId={}", + taskId, headerId, header == null ? null : header.getBillCode(), + header == null ? null : header.getBillStatus(), detailAffectedRows, + headerAffectedRows, confirmUserId); } - log.info("出库任务完成业务处理成功, taskId={}, allocationCount={}", taskId, allocations.size()); + log.info("[OUTBOUND_COMPLETE] 处理成功, taskId={}, allocationCount={}, headerIds={}", + taskId, allocations.size(), headerIds); } @Override @@ -624,6 +688,9 @@ public class IostorInvServiceImpl implements IostorInvService { if (header == null) { throw exception(IOSTOR_INV_NOT_EXISTS); } + log.info("[OUTBOUND_ALLOCATION] 全部分配开始, headerId={}, billCode={}, sectId={}, " + + "beforeStatus={}", + header.getIostorinvId(), header.getBillCode(), reqVO.getSectId(), header.getBillStatus()); // 2. 按明细序号遍历整张出库单;库区未选择时不限制库区,选择后只匹配指定库区库存。 List details = iostorinvDtlMapper.selectList( new LambdaQueryWrapperX() @@ -635,6 +702,11 @@ public class IostorInvServiceImpl implements IostorInvService { // 3. 全部明细处理完成后,根据各明细已分配数统一回算主表状态。 refreshHeaderAllocationStatus(reqVO.getIostorinvId()); recordAllocationOperator(reqVO.getIostorinvId()); + IostorInvDO updatedHeader = iostorInvMapper.selectById(reqVO.getIostorinvId()); + log.info("[OUTBOUND_ALLOCATION] 全部分配结束, headerId={}, billCode={}, detailCount={}, " + + "afterStatus={}", + header.getIostorinvId(), header.getBillCode(), details.size(), + updatedHeader == null ? null : updatedHeader.getBillStatus()); } @Override @@ -645,11 +717,20 @@ public class IostorInvServiceImpl implements IostorInvService { throw exception(IOSTOR_INV_NOT_EXISTS); } IostorinvDtlDO detail = getOwnedDetail(reqVO.getIostorinvId(), reqVO.getIostorinvdtlId()); - if (allocateDetail(header, detail, reqVO.getSectId()).signum() == 0) { + log.info("[OUTBOUND_ALLOCATION] 明细自动分配开始, headerId={}, billCode={}, detailId={}, " + + "pcsn={}, materialCode={}, sectId={}, planQty={}, assignedQty={}", + header.getIostorinvId(), header.getBillCode(), detail.getIostorinvdtlId(), + detail.getPcsn(), detail.getMaterialCode(), reqVO.getSectId(), detail.getPlanQty(), + detail.getAssignQty()); + BigDecimal allocatedNow = allocateDetail(header, detail, reqVO.getSectId()); + if (allocatedNow.signum() == 0) { throw exception(IOSTOR_INV_NO_MATCHING_INVENTORY); } refreshHeaderAllocationStatus(reqVO.getIostorinvId()); recordAllocationOperator(reqVO.getIostorinvId()); + log.info("[OUTBOUND_ALLOCATION] 明细自动分配结束, headerId={}, billCode={}, detailId={}, " + + "allocatedNow={}", + header.getIostorinvId(), header.getBillCode(), detail.getIostorinvdtlId(), allocatedNow); } @Override @@ -823,6 +904,11 @@ public class IostorInvServiceImpl implements IostorInvService { if (CollUtil.isEmpty(pending)) { throw exception(IOSTOR_INV_NO_PENDING_ALLOCATION); } + log.info("[OUTBOUND_ALLOCATION] 任务规划开始, headerId={}, billCode={}, pendingCount={}, " + + "allocationIds={}, vehicles={}", + header.getIostorinvId(), header.getBillCode(), pending.size(), + pending.stream().map(IostorinvDisDO::getIostorinvdisId).toList(), + pending.stream().map(IostorinvDisDO::getStoragevehicleCode).distinct().toList()); // 3. 同一载具可能对应多个子卷分配,先按载具归组,后续一台载具只创建一个出库任务。 Map> allocationsByVehicle = pending.stream() @@ -864,11 +950,21 @@ public class IostorInvServiceImpl implements IostorInvService { item.getStoragevehicleCode(), targetStructIds.contains(item.getStructId()))) .toList(); // 8. 根据 placement_type 计算左出、右出或双向最少移库方案,结果已按执行顺序排列。 + boolean largeColumnOut = warehouseAllocationStrategyService + .usesSmallColumnInLargeColumnOut(sample.getSectCode(), "2"); boolean trackSection = warehouseAllocationStrategyService.usesTrackSection( sample.getSectCode(), "2"); - List actions = trackSection + List actions = largeColumnOut + ? OutboundPlacementPlanner.planFromLargeColumnSide( + sample.getPlacementType(), slots) + : trackSection ? OutboundPlacementPlanner.planByTrackSection(sample.getPlacementType(), slots) : OutboundPlacementPlanner.plan(sample.getPlacementType(), slots); + log.info("[OUTBOUND_ALLOCATION] 通道规划完成, headerId={}, billCode={}, groupKey={}, " + + "placementType={}, largeColumnOut={}, trackSection={}, targetStructs={}, actions={}", + header.getIostorinvId(), header.getBillCode(), placementGroupKey(sample), + sample.getPlacementType(), largeColumnOut, trackSection, + targets.stream().map(StrucAttrDO::getStructCode).toList(), actions); for (OutboundPlacementPlanner.Action action : actions) { // 目标箱可直接从映射获取;挡路箱不在分配记录中,需要从当前排仓位补充来源信息。 StrucAttrDO source = targetStructMap.get(action.structId()); @@ -893,6 +989,12 @@ public class IostorInvServiceImpl implements IostorInvService { "MOVE", String.valueOf(moveDetail.getMoveinvdtlId())); // 11. 将任务标识和下发状态回写移库明细,便于后续任务回调按明细处理移库完成。 moveInvService.bindTask(moveDetail.getMoveinvdtlId(), taskId); + log.info("[OUTBOUND_ALLOCATION] 挡路箱移库任务已下发, headerId={}, billCode={}, " + + "vehicle={}, source={}, destination={}, moveBillId={}, moveDetailId={}, " + + "taskId={}, taskGroupId={}, sortSeq={}", + header.getIostorinvId(), header.getBillCode(), action.vehicleCode(), + moveDetail.getTurnoutStructCode(), moveDetail.getTurninStructCode(), + moveResult.getMoveinvId(), moveDetail.getMoveinvdtlId(), taskId, taskGroupId, sortSeq); continue; } // 12. 非本次分配的载具只参与通道规划,不创建出库任务。 @@ -908,6 +1010,13 @@ public class IostorInvServiceImpl implements IostorInvService { taskAllocation.getMaterialCode(), taskGroupId, ++sortSeq, "OUT", taskAllocation.getIostorinvdisId()); destinationLoads[destinationPoint.equals(outboundPoints.highPoint()) ? 0 : 1]++; + log.info("[OUTBOUND_ALLOCATION] 出库任务已下发, headerId={}, billCode={}, vehicle={}, " + + "source={}, destination={}, layer={}, allocationIds={}, taskId={}, " + + "taskGroupId={}, sortSeq={}", + header.getIostorinvId(), header.getBillCode(), action.vehicleCode(), + source.getStructCode(), destinationPoint, source.getLayerNum(), + vehicleAllocations.stream().map(IostorinvDisDO::getIostorinvdisId).toList(), + taskId, taskGroupId, sortSeq); // 14. 同载具的全部分配记录关联同一个任务,并推进到“执行中/已下发”状态。 vehicleAllocations.forEach(allocation -> { IostorinvDisDO update = new IostorinvDisDO(); @@ -916,12 +1025,26 @@ public class IostorInvServiceImpl implements IostorInvService { update.setPointCode(destinationPoint); update.setWorkStatus("20"); update.setIsIssued("1"); - iostorinvDisMapper.updateById(update); + int allocationAffectedRows = iostorinvDisMapper.updateById(update); + log.info("[OUTBOUND_ALLOCATION] 分配记录绑定任务, headerId={}, billCode={}, " + + "allocationId={}, detailId={}, vehicle={}, taskId={}, " + + "destination={}, affectedRows={}", + header.getIostorinvId(), header.getBillCode(), + allocation.getIostorinvdisId(), allocation.getIostorinvdtlId(), + allocation.getStoragevehicleCode(), taskId, destinationPoint, + allocationAffectedRows); }); // 15. 锁定出库起点仓位,直到任务回调完成后再由后续流程释放。 - strucAttrMapper.lockForTask(source.getStructId(), String.valueOf(taskId)); + int structAffectedRows = strucAttrMapper.lockForTask(source.getStructId(), String.valueOf(taskId)); + log.info("[OUTBOUND_ALLOCATION] 出库仓位绑定任务, headerId={}, billCode={}, structCode={}, " + + "vehicle={}, taskId={}, affectedRows={}", + header.getIostorinvId(), header.getBillCode(), source.getStructCode(), + action.vehicleCode(), taskId, structAffectedRows); } } + log.info("[OUTBOUND_ALLOCATION] 任务规划结束, headerId={}, billCode={}, taskGroupId={}, " + + "taskCount={}", + header.getIostorinvId(), header.getBillCode(), taskGroupId, sortSeq); } private List selectFreeMoveLocations(String storId, Set excludedStructIds) { @@ -975,6 +1098,10 @@ public class IostorInvServiceImpl implements IostorInvService { String destinationPoint, String vehicleCode, String materialId, String materialCode, long taskGroupId, long sortSeq, String bizType, String bizId) { + log.info("[OUTBOUND_ALLOCATION] 创建搬运任务, bizType={}, bizId={}, taskType={}, vehicle={}, " + + "source={}, destination={}, materialCode={}, taskGroupId={}, sortSeq={}", + bizType, bizId, taskType, vehicleCode, sourcePoint, destinationPoint, + materialCode, taskGroupId, sortSeq); if ("MOVE".equals(bizType)) { denseStorageTaskConflictService.assertCanIssue(sourcePoint, DenseStorageTaskConflictService.MOVE_OUT); @@ -998,6 +1125,9 @@ public class IostorInvServiceImpl implements IostorInvService { task.setPointCode1(sourcePoint); task.setPointCode2(destinationPoint); task.setVehicleCode(vehicleCode); + if ("OUT".equals(bizType)) { + task.setVehicleCode2(resolvePalletCode(vehicleCode)); + } if (StrUtil.isNotBlank(materialId)) { task.setMaterialId(Long.valueOf(materialId)); } @@ -1009,9 +1139,23 @@ public class IostorInvServiceImpl implements IostorInvService { task.setIsCreateFinish(true); Long taskId = transportTaskApi.createTransportTask(task).getCheckedData(); transportTaskApi.issueTransportTaskRollBack(taskId).getCheckedData(); + log.info("[OUTBOUND_ALLOCATION] 搬运任务创建并下发成功, taskId={}, bizType={}, bizId={}, " + + "vehicle={}, source={}, destination={}, taskGroupId={}, sortSeq={}", + taskId, bizType, bizId, vehicleCode, sourcePoint, destinationPoint, taskGroupId, sortSeq); return taskId; } + /** 根据木箱绑定关系取得承载托盘,供出库任务写入载具编码2。 */ + private String resolvePalletCode(String boxNo) { + List bindings = storageVehicleExtMapper.selectList( + new LambdaQueryWrapperX() + .eq(StorageVehicleExtDO::getBoxNo, boxNo)); + if (bindings.size() > 1) { + throw new ServiceException(500, "木箱绑定了多个托盘:" + boxNo); + } + return bindings.isEmpty() ? null : bindings.get(0).getStorageVehicleCode(); + } + private void validateManualAllocationStatus(IostorinvDtlDO detail) { if (!Set.of("10", "20").contains(detail.getBillStatus())) { throw exception(IOSTOR_INV_MANUAL_STATUS_INVALID); @@ -1063,8 +1207,15 @@ public class IostorInvServiceImpl implements IostorInvService { BigDecimal assigned = Objects.requireNonNullElse(detail.getAssignQty(), BigDecimal.ZERO); BigDecimal remaining = detail.getPlanQty().subtract(assigned).max(BigDecimal.ZERO); BigDecimal allocatedNow = BigDecimal.ZERO; + log.info("[OUTBOUND_ALLOCATION] 明细分配计算开始, headerId={}, billCode={}, detailId={}, " + + "pcsn={}, materialCode={}, sectId={}, planQty={}, assignedQty={}, remainingQty={}", + header.getIostorinvId(), header.getBillCode(), detail.getIostorinvdtlId(), + detail.getPcsn(), detail.getMaterialCode(), sectId, detail.getPlanQty(), assigned, remaining); if (remaining.signum() == 0) { updateDetailAllocation(detail, assigned); + log.info("[OUTBOUND_ALLOCATION] 明细无需继续分配, headerId={}, billCode={}, detailId={}, " + + "assignedQty={}", + header.getIostorinvId(), header.getBillCode(), detail.getIostorinvdtlId(), assigned); return allocatedNow; } // 按物料、批次、来源单号匹配入库可用库存;sectId 有值时额外限制库区。 @@ -1072,6 +1223,11 @@ public class IostorInvServiceImpl implements IostorInvService { iostorinvDtlMapper.selectAllocationInventoryForUpdate( header.getStorId(), sectId, detail.getMaterialId(), detail.getPcsn(), detail.getSourceBillCode()); + log.info("[OUTBOUND_ALLOCATION] 可用库存查询完成, headerId={}, billCode={}, detailId={}, " + + "candidateCount={}, candidateVehicles={}", + header.getIostorinvId(), header.getBillCode(), detail.getIostorinvdtlId(), + candidates.size(), candidates.stream().map(AllocationInventoryRespVO::getVehicleCode) + .distinct().toList()); if (StrUtil.isNotBlank(detail.getSourceLoadPort())) { AllocationInventoryRespVO boxCandidate = candidates.stream() .filter(candidate -> detail.getSourceLoadPort().equals(candidate.getVehicleCode())) @@ -1121,6 +1277,10 @@ public class IostorInvServiceImpl implements IostorInvService { candidate.getStructId(), header.getBillType(), String.valueOf(header.getIostorinvId()), header.getBillCode()); if (locked == 0) { + log.error("[OUTBOUND_ALLOCATION] 仓位加出库锁失败, headerId={}, billCode={}, " + + "detailId={}, allocationId={}, vehicle={}, structCode={}", + header.getIostorinvId(), header.getBillCode(), detail.getIostorinvdtlId(), + allocation.getIostorinvdisId(), candidate.getVehicleCode(), candidate.getStructCode()); throw exception(IOSTOR_INV_INVENTORY_INVALID); } @@ -1130,7 +1290,13 @@ public class IostorInvServiceImpl implements IostorInvService { groupUpdate.setGroupId(candidate.getGroupId()); groupUpdate.setFrozenQty(Objects.requireNonNullElse(currentGroup.getFrozenQty(), BigDecimal.ZERO) .add(allocationQty)); - groupPlateMapper.updateById(groupUpdate); + int groupAffectedRows = groupPlateMapper.updateById(groupUpdate); + log.info("[OUTBOUND_ALLOCATION] 库存分配成功, headerId={}, billCode={}, detailId={}, " + + "allocationId={}, vehicle={}, structCode={}, groupId={}, allocationQty={}, " + + "lockAffectedRows={}, groupAffectedRows={}", + header.getIostorinvId(), header.getBillCode(), detail.getIostorinvdtlId(), + allocation.getIostorinvdisId(), candidate.getVehicleCode(), candidate.getStructCode(), + candidate.getGroupId(), allocationQty, locked, groupAffectedRows); assigned = assigned.add(allocationQty); allocatedNow = allocatedNow.add(allocationQty); @@ -1138,6 +1304,10 @@ public class IostorInvServiceImpl implements IostorInvService { } // 根据最终分配量更新明细的已分配数、未分配数及生成/分配中/分配完状态。 updateDetailAllocation(detail, assigned); + log.info("[OUTBOUND_ALLOCATION] 明细分配计算结束, headerId={}, billCode={}, detailId={}, " + + "allocatedNow={}, assignedQty={}, remainingQty={}", + header.getIostorinvId(), header.getBillCode(), detail.getIostorinvdtlId(), + allocatedNow, assigned, remaining); return allocatedNow; } @@ -1287,7 +1457,11 @@ public class IostorInvServiceImpl implements IostorInvService { update.setAssignQty(assigned); update.setUnassignQty(unassigned); update.setBillStatus(unassigned.signum() == 0 ? "30" : assigned.signum() > 0 ? "20" : "10"); - iostorinvDtlMapper.updateById(update); + int affectedRows = iostorinvDtlMapper.updateById(update); + log.info("[OUTBOUND_ALLOCATION] 明细分配状态更新, headerId={}, detailId={}, pcsn={}, " + + "beforeStatus={}, afterStatus={}, assignedQty={}, unassignedQty={}, affectedRows={}", + detail.getIostorinvId(), detail.getIostorinvdtlId(), detail.getPcsn(), + detail.getBillStatus(), update.getBillStatus(), assigned, unassigned, affectedRows); } private void refreshHeaderAllocationStatus(Long iostorinvId) { @@ -1301,7 +1475,12 @@ public class IostorInvServiceImpl implements IostorInvService { IostorInvDO update = new IostorInvDO(); update.setIostorinvId(iostorinvId); update.setBillStatus(allAllocated ? "30" : anyAllocated ? "20" : "10"); - iostorInvMapper.updateById(update); + int affectedRows = iostorInvMapper.updateById(update); + IostorInvDO header = iostorInvMapper.selectById(iostorinvId); + log.info("[OUTBOUND_ALLOCATION] 主单分配状态更新, headerId={}, billCode={}, afterStatus={}, " + + "detailCount={}, allAllocated={}, anyAllocated={}, affectedRows={}", + iostorinvId, header == null ? null : header.getBillCode(), update.getBillStatus(), + details.size(), allAllocated, anyAllocated, affectedRows); } private void recordAllocationOperator(Long iostorinvId) { diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/OutboundPlacementPlanner.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/OutboundPlacementPlanner.java index c92917f9..fee37bd2 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/OutboundPlacementPlanner.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/OutboundPlacementPlanner.java @@ -32,6 +32,43 @@ final class OutboundPlacementPlanner { return planFromSide(occupied, LARGE_COLUMN_ACCESS.equals(placementType)); } + /** + * 小列入库、大列出库策略:单通固定从大列号侧取货;双通两侧边界箱可直接出库, + * 中间箱仍固定从大列号侧移除挡路箱。 + */ + static List planFromLargeColumnSide(String placementType, List slots) { + List occupied = slots.stream() + .filter(slot -> slot.vehicleCode() != null && !slot.vehicleCode().isBlank()) + .sorted(Comparator.comparingInt(Slot::column)) + .toList(); + if (occupied.stream().noneMatch(Slot::target)) { + return List.of(); + } + if (DOUBLE_ACCESS.equals(placementType)) { + return planDoubleAccessWithDirectEdges(occupied); + } + return planFromSide(occupied, true); + } + + private static List planDoubleAccessWithDirectEdges(List occupied) { + Slot leftEdge = occupied.get(0); + Slot rightEdge = occupied.get(occupied.size() - 1); + List result = new ArrayList<>(); + List remaining = new ArrayList<>(occupied); + if (leftEdge.target()) { + result.add(new Action("OUT", leftEdge.structId(), leftEdge.vehicleCode())); + remaining.remove(leftEdge); + } + if (rightEdge != leftEdge && rightEdge.target()) { + result.add(new Action("OUT", rightEdge.structId(), rightEdge.vehicleCode())); + remaining.remove(rightEdge); + } + if (remaining.stream().anyMatch(Slot::target)) { + result.addAll(planFromSide(remaining, true)); + } + return result; + } + /** * 双轨策略:双侧可访问货位按上下半段分别从相邻轨道出库;单侧货位沿用原逻辑。 */ diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/TrackSectionLocationSorter.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/TrackSectionLocationSorter.java index 920cd1fe..f17e0675 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/TrackSectionLocationSorter.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/TrackSectionLocationSorter.java @@ -34,6 +34,16 @@ public final class TrackSectionLocationSorter { .thenComparing(StrucAttrDO::getStructId)); } + /** 不区分单双通,按同排同层内的小列号优先排列。 */ + public static void sortFromSmallColumn(List candidates) { + candidates.sort(Comparator + .comparingInt((StrucAttrDO item) -> value(item.getRowNum())) + .thenComparingInt(item -> value(item.getBlockNum())) + .thenComparingInt(item -> value(item.getLayerNum())) + .thenComparingInt(item -> value(item.getColNum())) + .thenComparing(StrucAttrDO::getStructId)); + } + /** * 查找双通区段中被库存从两侧夹住的空货位。此类货位已经破坏中心向两侧连续存放规则, * 四向车不可再将其作为正常入库目标。 diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/WarehouseAllocationStrategyService.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/WarehouseAllocationStrategyService.java index f839bd67..8eb6f0e5 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/WarehouseAllocationStrategyService.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/iostorinv/WarehouseAllocationStrategyService.java @@ -14,12 +14,24 @@ public class WarehouseAllocationStrategyService { public static final String STANDARD_ALLOCATION = "standardAllocation"; public static final String TRACK_SECTION_ALLOCATION = "trackSectionAllocation"; + public static final String SMALL_COLUMN_IN_LARGE_COLUMN_OUT_ALLOCATION = + "smallColumnInLargeColumnOutAllocation"; @Resource private WarehouseStrategyMapper warehouseStrategyMapper; /** 未配置或配置标准策略时沿用现有逻辑;显式配置轨道分段策略时启用新逻辑。 */ public boolean usesTrackSection(String sectionCode, String strategyType) { + return containsStrategy(sectionCode, strategyType, TRACK_SECTION_ALLOCATION); + } + + /** 入库从小列号开始、出库固定从大列号侧取货。 */ + public boolean usesSmallColumnInLargeColumnOut(String sectionCode, String strategyType) { + return containsStrategy(sectionCode, strategyType, + SMALL_COLUMN_IN_LARGE_COLUMN_OUT_ALLOCATION); + } + + private boolean containsStrategy(String sectionCode, String strategyType, String strategyCode) { if (sectionCode == null || sectionCode.isBlank()) { return false; } @@ -35,6 +47,6 @@ public class WarehouseAllocationStrategyService { } catch (RuntimeException ignored) { return false; } - return codes.contains(TRACK_SECTION_ALLOCATION); + return codes.contains(strategyCode); } } diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/moveinv/MoveInvService.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/moveinv/MoveInvService.java index d483fc4b..54ca8075 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/moveinv/MoveInvService.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/moveinv/MoveInvService.java @@ -3,10 +3,12 @@ package cn.code.nl.module.wms.service.moveinv; import cn.code.nl.framework.common.pojo.PageResult; import cn.code.nl.module.wms.api.moveinv.dto.MoveInvAutoCreateReqDTO; import cn.code.nl.module.wms.api.moveinv.dto.MoveInvAutoCreateRespDTO; +import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvInventoryPageReqVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvInventoryRespVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvPageReqVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvRespVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvSaveReqVO; +import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvTargetStructPageReqVO; import cn.code.nl.module.wms.dal.dataobject.structAttr.StrucAttrDO; import java.util.List; @@ -22,13 +24,17 @@ public interface MoveInvService { void delete(Long id); + void issue(Long id); + + void forceComplete(Long id, Long confirmUserId); + MoveInvRespVO get(Long id); PageResult getPage(MoveInvPageReqVO reqVO); - List getAvailableInventory(String storId, String sectId); + PageResult getAvailableInventory(MoveInvInventoryPageReqVO reqVO); - List getAvailableTargetStructs(String sourceStructCode); + PageResult getAvailableTargetStructs(MoveInvTargetStructPageReqVO reqVO); MoveInvAutoCreateRespDTO autoCreate(MoveInvAutoCreateReqDTO reqDTO); diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/moveinv/MoveInvServiceImpl.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/moveinv/MoveInvServiceImpl.java index 357db8a4..78f4e31e 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/moveinv/MoveInvServiceImpl.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/moveinv/MoveInvServiceImpl.java @@ -5,15 +5,20 @@ import cn.code.nl.framework.common.pojo.CommonResult; import cn.code.nl.framework.common.pojo.PageResult; import cn.code.nl.module.base.api.codegen.CodeGenApi; import cn.code.nl.module.base.api.codegen.dto.CodeGenerateReqDTO; +import cn.code.nl.module.task.api.TransportTaskApi; +import cn.code.nl.module.task.dto.TaskInfoDTO; +import cn.code.nl.module.task.dto.TransportTaskCreateReqDTO; import cn.code.nl.module.wms.api.moveinv.dto.MoveInvAutoCreateReqDTO; import cn.code.nl.module.wms.api.moveinv.dto.MoveInvAutoCreateRespDTO; import cn.code.nl.module.system.api.user.AdminUserApi; import cn.code.nl.module.system.api.user.dto.AdminUserRespDTO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvDetailSaveReqVO; +import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvInventoryPageReqVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvInventoryRespVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvPageReqVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvRespVO; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvSaveReqVO; +import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvTargetStructPageReqVO; import cn.code.nl.module.wms.dal.dataobject.moveinv.MoveInvDO; import cn.code.nl.module.wms.dal.dataobject.moveinvdtl.MoveInvDtlDO; import cn.code.nl.module.wms.dal.dataobject.structAttr.StrucAttrDO; @@ -25,7 +30,10 @@ import cn.code.nl.module.wms.dal.mysql.bsrealstorattr.BsrealStorAttrMapper; import cn.code.nl.module.wms.service.iostorinv.TrackSectionLocationSorter; import cn.code.nl.module.wms.service.iostorinv.StorageLocationInventoryScope; import cn.code.nl.module.wms.service.iostorinv.WarehouseAllocationStrategyService; +import cn.code.nl.module.wms.service.task.DenseStorageTaskConflictService; +import cn.code.nl.module.wms.enums.task.WmsTaskTypeEnum; import cn.code.nl.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.hutool.core.util.IdUtil; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -38,6 +46,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -76,6 +85,10 @@ public class MoveInvServiceImpl implements MoveInvService { private WarehouseAllocationStrategyService warehouseAllocationStrategyService; @Resource private GroupPlateMapper groupPlateMapper; + @Resource + private TransportTaskApi transportTaskApi; + @Resource + private DenseStorageTaskConflictService denseStorageTaskConflictService; /** * 创建移库单。 @@ -134,6 +147,86 @@ public class MoveInvServiceImpl implements MoveInvService { moveInvMapper.deleteById(id); } + @Override + @Transactional(rollbackFor = Exception.class) + public void issue(Long id) { + MoveInvDO moveInv = moveInvMapper.selectById(id); + if (moveInv == null) { + throw exception(MOVE_INV_NOT_EXISTS); + } + if (!GENERATED_STATUS.equals(moveInv.getBillStatus())) { + throw exception(MOVE_INV_STATUS_INVALID); + } + List details = moveInvDtlMapper.selectByMoveinvId(id); + if (details.isEmpty() || details.stream().anyMatch(detail -> detail.getTaskId() != null + || "1".equals(detail.getIsIssued()))) { + throw exception(MOVE_INV_STATUS_INVALID); + } + + long taskGroupId = IdUtil.getSnowflakeNextId(); + long sortSeq = 0; + for (MoveInvDtlDO detail : details) { + StrucAttrDO source = strucAttrMapper.selectByStructCode(detail.getTurnoutStructCode()); + if (source == null) { + throw exception(MOVE_INV_SOURCE_INVALID); + } + denseStorageTaskConflictService.assertCanIssue(detail.getTurnoutStructCode(), + DenseStorageTaskConflictService.MOVE_OUT); + denseStorageTaskConflictService.assertCanIssue(detail.getTurninStructCode(), + DenseStorageTaskConflictService.MOVE_IN); + + TransportTaskCreateReqDTO task = new TransportTaskCreateReqDTO(); + task.setTaskName("移库任务"); + task.setOwnerService("WMS"); + task.setBizType("MOVE"); + task.setBizId(String.valueOf(detail.getMoveinvdtlId())); + task.setHandleCode("MOVETASK"); + task.setTaskType("3".equals(source.getInventoryType()) + ? WmsTaskTypeEnum.EMPTY_BOX_MOVE.getCode() + : WmsTaskTypeEnum.FINISHED_GOODS_MOVE.getCode()); + task.setAcsTaskType("7"); + task.setAgvSystemType("1"); + task.setPointCode1(detail.getTurnoutStructCode()); + task.setPointCode2(detail.getTurninStructCode()); + task.setVehicleCode(detail.getStoragevehicleCode()); + task.setMaterialCode(detail.getMaterialCode()); + task.setTaskGroupId(taskGroupId); + task.setSortSeq(++sortSeq); + task.setIsAutoIssue("0"); + task.setProductArea("LK"); + task.setIsCreateFinish(true); + Long taskId = transportTaskApi.createTransportTask(task).getCheckedData(); + transportTaskApi.issueTransportTaskRollBack(taskId).getCheckedData(); + bindTask(detail.getMoveinvdtlId(), taskId); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void forceComplete(Long id, Long confirmUserId) { + MoveInvDO moveInv = moveInvMapper.selectById(id); + if (moveInv == null) { + throw exception(MOVE_INV_NOT_EXISTS); + } + if ("99".equals(moveInv.getBillStatus())) { + throw exception(MOVE_INV_STATUS_INVALID); + } + List details = moveInvDtlMapper.selectByMoveinvId(id); + if (details.isEmpty()) { + throw exception(MOVE_INV_STATUS_INVALID); + } + for (MoveInvDtlDO detail : details) { + if (detail.getTaskId() == null) { + continue; + } + TaskInfoDTO task = transportTaskApi.getTaskById(detail.getTaskId()).getCheckedData(); + if (task != null && !Set.of("79", "89", "99").contains(task.getTaskStatus())) { + throw new IllegalStateException("移库单存在未结束任务,不能强制完成:" + task.getTaskCode()); + } + } + completeMoveDetails(details, confirmUserId); + } + /** * 查询移库单详情。 */ @@ -185,24 +278,47 @@ public class MoveInvServiceImpl implements MoveInvService { * 查询移库可用库存。 */ @Override - public List getAvailableInventory(String storId, String sectId) { - return strucAttrMapper.selectMoveAvailableInventory(storId, sectId, null).stream() + public PageResult getAvailableInventory(MoveInvInventoryPageReqVO reqVO) { + List inventory = strucAttrMapper + .selectMoveAvailableInventory(reqVO.getStorId(), reqVO.getSectId(), null).stream() .filter(item -> { StrucAttrDO source = strucAttrMapper.selectByStructCode(item.getStructCode()); return source != null && isSourceAccessible(source); - }).toList(); + }) + .filter(item -> matchesInventoryKeyword(item, reqVO.getKeyword())) + .toList(); + return page(inventory, reqVO.getPageNo(), reqVO.getPageSize()); } /** * 查询来源仓位同库区同层的空闲目标仓位。 */ @Override - public List getAvailableTargetStructs(String sourceStructCode) { - StrucAttrDO source = strucAttrMapper.selectByStructCode(sourceStructCode); + public PageResult getAvailableTargetStructs(MoveInvTargetStructPageReqVO reqVO) { + StrucAttrDO source = strucAttrMapper.selectByStructCode(reqVO.getSourceStructCode()); if (source == null) { throw exception(MOVE_INV_SOURCE_INVALID); } - return prepareMoveTargetCandidates(source).candidates(); + List candidates = prepareMoveTargetCandidates(source).candidates().stream() + .filter(item -> StrUtil.isBlank(reqVO.getKeyword()) + || StrUtil.containsIgnoreCase(item.getStructCode(), reqVO.getKeyword()) + || StrUtil.containsIgnoreCase(item.getStructName(), reqVO.getKeyword())) + .toList(); + return page(candidates, reqVO.getPageNo(), reqVO.getPageSize()); + } + + private boolean matchesInventoryKeyword(MoveInvInventoryRespVO item, String keyword) { + return StrUtil.isBlank(keyword) + || StrUtil.containsIgnoreCase(item.getStoragevehicleCode(), keyword) + || StrUtil.containsIgnoreCase(item.getStructCode(), keyword) + || StrUtil.containsIgnoreCase(item.getMaterialCode(), keyword) + || StrUtil.containsIgnoreCase(item.getPcsn(), keyword); + } + + private PageResult page(List rows, Integer pageNo, Integer pageSize) { + int fromIndex = (int) Math.min((pageNo - 1) * pageSize, rows.size()); + int toIndex = (int) Math.min(fromIndex + pageSize, rows.size()); + return new PageResult<>(rows.subList(fromIndex, toIndex), (long) rows.size()); } /** @@ -257,12 +373,22 @@ public class MoveInvServiceImpl implements MoveInvService { */ @Override public void bindTask(Long moveinvdtlId, Long taskId) { + MoveInvDtlDO detail = moveInvDtlMapper.selectById(moveinvdtlId); + if (detail == null) { + throw exception(MOVE_INV_NOT_EXISTS); + } MoveInvDtlDO update = new MoveInvDtlDO(); update.setMoveinvdtlId(moveinvdtlId); update.setTaskId(taskId); update.setWorkStatus("20"); update.setIsIssued("1"); moveInvDtlMapper.updateById(update); + if (moveInvDtlMapper.countUnissuedByMoveinvId(detail.getMoveinvId()) == 0) { + MoveInvDO headerUpdate = new MoveInvDO(); + headerUpdate.setMoveinvId(detail.getMoveinvId()); + headerUpdate.setBillStatus("20"); + moveInvMapper.updateById(headerUpdate); + } } @Override @@ -275,8 +401,16 @@ public class MoveInvServiceImpl implements MoveInvService { throw new IllegalStateException("未找到移库任务对应的明细,taskId=" + taskId); } + completeMoveDetails(details, confirmUserId); + } + + private void completeMoveDetails(List details, Long confirmUserId) { Set moveInvIds = new HashSet<>(); for (MoveInvDtlDO detail : details) { + if ("99".equals(detail.getWorkStatus())) { + moveInvIds.add(detail.getMoveinvId()); + continue; + } String moveInvId = String.valueOf(detail.getMoveinvId()); StrucAttrDO sourceStruct = strucAttrMapper.selectByStructCode(detail.getTurnoutStructCode()); if (sourceStruct == null || "0".equals(sourceStruct.getInventoryType())) { @@ -468,16 +602,44 @@ public class MoveInvServiceImpl implements MoveInvService { } List candidates = strucAttrMapper.selectMoveTargetCandidates( source.getStorId(), source.getSectId(), source.getLayerNum()); - candidates.removeIf(item -> abnormalIds.contains(item.getStructId()) + candidates.removeIf(item -> isSameMoveScope(source, item) + || abnormalIds.contains(item.getStructId()) + || !isMoveInTaskCompatible(item, allLocations) || !isRowInventoryCompatible(item, source.getInventoryType(), allLocations)); + boolean smallColumnFirst = warehouseAllocationStrategyService + .usesSmallColumnInLargeColumnOut(source.getSectCode(), "1"); boolean trackSection = warehouseAllocationStrategyService.usesTrackSection( source.getSectCode(), "1"); - if (trackSection) { + if (smallColumnFirst) { + TrackSectionLocationSorter.sortFromSmallColumn(candidates); + } else if (trackSection) { TrackSectionLocationSorter.sortFromCenter(candidates, allLocations); } return new MoveTargetCandidates(candidates); } + /** 移入货位不能位于来源货位所在的同一块、同一排、同一层。 */ + boolean isSameMoveScope(StrucAttrDO source, StrucAttrDO target) { + return Objects.equals(source.getStorId(), target.getStorId()) + && Objects.equals(source.getSectId(), target.getSectId()) + && Objects.equals(source.getBlockNum(), target.getBlockNum()) + && Objects.equals(source.getRowNum(), target.getRowNum()) + && Objects.equals(source.getLayerNum(), target.getLayerNum()); + } + + /** 判断候选货位所在物理范围是否允许新增移入任务。 */ + boolean isMoveInTaskCompatible(StrucAttrDO target, List allLocations) { + StorageLocationInventoryScope.Key targetScope = StorageLocationInventoryScope.keyOf(target); + if (targetScope == null) { + return false; + } + List scopeLocations = allLocations.stream() + .filter(item -> targetScope.equals(StorageLocationInventoryScope.keyOf(item))) + .toList(); + return denseStorageTaskConflictService.isCompatible(scopeLocations, + DenseStorageTaskConflictService.MOVE_IN); + } + /** 按入库候选顺序选择移入仓位,避免按来源距离在其他排中间制造空位。 */ StrucAttrDO selectMoveTargetInInboundOrder(List candidates, Set excludedStructIds) { diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/shippingarea/ShippingAreaService.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/shippingarea/ShippingAreaService.java index 7456648b..439bf8e9 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/shippingarea/ShippingAreaService.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/shippingarea/ShippingAreaService.java @@ -4,6 +4,7 @@ import cn.code.nl.module.wms.controller.acs.vo.AcsShippingApplyReqVO; import cn.code.nl.module.wms.controller.acs.vo.AcsShippingApplyRespVO; import cn.code.nl.module.wms.controller.admin.shippingarea.vo.ShippingAreaPickupRespVO; import cn.code.nl.module.wms.controller.admin.shippingarea.vo.ShippingAreaBillRespVO; +import cn.code.nl.module.wms.controller.admin.shippingarea.vo.ShippingAreaVisualizationRespVO; import java.util.List; @@ -32,4 +33,7 @@ public interface ShippingAreaService { /** 查询父页面的发货区出库单。 */ List getPickupBills(); + + /** 查询发货区库存、点位状态和当前作业出库单。 */ + ShippingAreaVisualizationRespVO getVisualization(); } diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/shippingarea/ShippingAreaServiceImpl.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/shippingarea/ShippingAreaServiceImpl.java index 3ed4c014..5f91220b 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/shippingarea/ShippingAreaServiceImpl.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/service/shippingarea/ShippingAreaServiceImpl.java @@ -8,8 +8,11 @@ import cn.code.nl.module.wms.controller.acs.vo.AcsShippingApplyReqVO; import cn.code.nl.module.wms.controller.acs.vo.AcsShippingApplyRespVO; import cn.code.nl.module.wms.controller.admin.shippingarea.vo.ShippingAreaPickupRespVO; import cn.code.nl.module.wms.controller.admin.shippingarea.vo.ShippingAreaBillRespVO; +import cn.code.nl.module.wms.controller.admin.shippingarea.vo.ShippingAreaPointRespVO; +import cn.code.nl.module.wms.controller.admin.shippingarea.vo.ShippingAreaVisualizationRespVO; import cn.code.nl.module.wms.dal.dataobject.iostorinvdis.OutboundBillRef; import cn.code.nl.module.wms.dal.dataobject.point.ShippingAreaPickupRow; +import cn.code.nl.module.wms.dal.dataobject.point.ShippingAreaPointViewRow; import cn.code.nl.module.wms.dal.dataobject.point.ShippingPointRowCandidate; import cn.code.nl.module.wms.dal.dataobject.point.WmsPointDO; import cn.code.nl.module.wms.dal.mysql.iostorinvdis.IostorinvDisMapper; @@ -26,6 +29,7 @@ import java.util.stream.Collectors; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.Map; +import cn.hutool.core.util.StrUtil; /** * 发货区任务服务实现。 @@ -197,6 +201,54 @@ public class ShippingAreaServiceImpl implements ShippingAreaService { .collect(Collectors.toList()); } + @Override + public ShippingAreaVisualizationRespVO getVisualization() { + List points = wmsPointMapper.selectShippingAreaPointView().stream() + .map(this::toVisualizationPoint) + .toList(); + return new ShippingAreaVisualizationRespVO(points, getPickupBills()); + } + + private ShippingAreaPointRespVO toVisualizationPoint(ShippingAreaPointViewRow row) { + ShippingAreaPointRespVO point = new ShippingAreaPointRespVO(); + point.setPointCode(row.getPointCode()); + point.setPointName(row.getPointName()); + point.setPointStatus(row.getPointStatus()); + point.setIsUsed(row.getIsUsed()); + point.setRowNum(row.getRowNum()); + point.setColNum(row.getColNum()); + point.setBoxNo(StrUtil.blankToDefault(row.getVehicleCode(), row.getTaskVehicleCode())); + point.setVehicleQty(row.getVehicleQty()); + point.setIngTaskCode(row.getIngTaskCode()); + point.setTaskId(row.getTaskId()); + point.setTaskCode(row.getTaskCode()); + point.setTaskStatus(row.getTaskStatus()); + point.setOutboundBillId(row.getOutboundBillId()); + point.setOutboundBillCode(row.getOutboundBillCode()); + point.setCustomerName(row.getCustomerName()); + point.setDisplayStatus(resolveDisplayStatus(row)); + return point; + } + + private String resolveDisplayStatus(ShippingAreaPointViewRow row) { + if (!Boolean.TRUE.equals(row.getIsUsed())) { + return "DISABLED"; + } + if (StrUtil.isNotBlank(row.getVehicleCode())) { + return "OCCUPIED"; + } + if (StrUtil.startWith(row.getIngTaskCode(), "P")) { + return "PREALLOCATED"; + } + if (StrUtil.startWith(row.getIngTaskCode(), "B")) { + return "RESERVED"; + } + if (StrUtil.isNotBlank(row.getIngTaskCode())) { + return "IN_TRANSIT"; + } + return "AVAILABLE"; + } + private String normalizeBoxNo(String boxNo) { return boxNo == null ? "" : boxNo.trim().toUpperCase(Locale.ROOT); } @@ -276,7 +328,7 @@ public class ShippingAreaServiceImpl implements ShippingAreaService { task.setPointCode2(targetPointCode); task.setVehicleCode(reqVO.getBoxNo()); task.setIsAutoIssue("0"); - task.setProductArea("FH"); + task.setProductArea("LK"); task.setIsCreateFinish(true); return transportTaskApi.createTransportTask(task).getCheckedData(); } diff --git a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/task/ShipAreaTask.java b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/task/ShipAreaTask.java index b1f5cab5..329dd4bc 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/task/ShipAreaTask.java +++ b/nl-module-wms/nl-module-wms-server/src/main/java/cn/code/nl/module/wms/task/ShipAreaTask.java @@ -5,14 +5,14 @@ import cn.code.nl.framework.execute.core.AbstractTask; import cn.code.nl.framework.execute.core.dto.TaskExecuteDTO; import cn.code.nl.module.task.api.TransportTaskApi; import cn.code.nl.module.task.dto.TaskInfoDTO; -import cn.code.nl.module.task.dto.TransportTaskUpdateReqDTO; +import cn.code.nl.module.task.dto.TransportTaskDestinationAssignReq; import cn.code.nl.module.wms.service.shippingarea.ShippingAreaService; -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.util.StrUtil; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import java.util.Objects; + /** * 发货区任务状态处理器。 */ @@ -35,14 +35,19 @@ public class ShipAreaTask extends AbstractTask { String originalPointCode = task.getPointCode2(); String allocatedPointCode = shippingAreaService.allocateSecondPoint( task.getTaskId(), originalPointCode); - task.setPointCode2(allocatedPointCode); - String allocationRemark = "二次分配前点位:" + originalPointCode; - if (!StrUtil.contains(task.getRemark(), allocationRemark)) { - task.setRemark(StrUtil.isBlank(task.getRemark()) - ? allocationRemark : task.getRemark() + ";" + allocationRemark); + // ACS 可能因超时重复发送 APPLY-AGAIN。若任务终点已是本次分配结果,直接成功返回, + // 避免“更新值未变化”被数据库报告为 0 行后误判成更新失败。 + if (Objects.equals(originalPointCode, allocatedPointCode)) { + log.info("发货区任务二次分配无需更新, taskId={}, targetPoint={}", + task.getTaskId(), allocatedPointCode); + return allocatedPointCode; } - CommonResult result = transportTaskApi.updateTransportTask( - BeanUtil.toBean(task, TransportTaskUpdateReqDTO.class)); + TransportTaskDestinationAssignReq assignReq = new TransportTaskDestinationAssignReq(); + assignReq.setTaskId(task.getTaskId()); + assignReq.setPointCode2(allocatedPointCode); + assignReq.setExpectedTaskStatus(task.getTaskStatus()); + assignReq.setTargetTaskStatus(task.getTaskStatus()); + CommonResult result = transportTaskApi.assignDestination(assignReq); if (result.isError() || !Boolean.TRUE.equals(result.getData())) { // 具体点仍由当前任务锁定,ACS 重试时可以继续恢复任务终点。 throw new IllegalStateException("更新发货区任务二次分配点位失败"); diff --git a/nl-module-wms/nl-module-wms-server/src/main/resources/application.yaml b/nl-module-wms/nl-module-wms-server/src/main/resources/application.yaml index d571dc9b..d7e11aec 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/resources/application.yaml +++ b/nl-module-wms/nl-module-wms-server/src/main/resources/application.yaml @@ -139,6 +139,9 @@ nl: debug: false +wms: + outbound-completion-reconcile-cron: "0 */5 * * * ?" + # 金蝶 K3Cloud 配置。独立启动 WMS 时不会继承 nl-server 的配置,因此需在模块内声明。 kingdee: enabled: true diff --git a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/boxinfo/BoxInfoMapper.xml b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/boxinfo/BoxInfoMapper.xml index ee71c7f1..3cc787be 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/boxinfo/BoxInfoMapper.xml +++ b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/boxinfo/BoxInfoMapper.xml @@ -50,6 +50,16 @@ LIMIT 1 + + UPDATE wmw_boxinfo SET box_no = #{newBoxNo} diff --git a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/boxtype/BoxTypeMapper.xml b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/boxtype/BoxTypeMapper.xml index e5a8afab..8fff9a8e 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/boxtype/BoxTypeMapper.xml +++ b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/boxtype/BoxTypeMapper.xml @@ -4,7 +4,7 @@ - id, box_type, box_name, lash_num, lash_num_one, lash_num_two, + id, box_type, box_name, specification_model, lash_num, lash_num_one, lash_num_two, need_lash_one, need_lash_two, expend_width, box_structure, desiccant_num, box_length, box_width, box_high, max_num, deleted @@ -47,6 +47,9 @@ AND box_name LIKE CONCAT('%', #{reqVO.boxName}, '%') + + AND specification_model LIKE CONCAT('%', #{reqVO.specificationModel}, '%') + AND need_lash_one = #{reqVO.needLashOne} diff --git a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/iostorinv/CuttingProcessService.xml b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/iostorinv/CuttingProcessService.xml index 2e6275e2..7336f792 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/iostorinv/CuttingProcessService.xml +++ b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/iostorinv/CuttingProcessService.xml @@ -67,6 +67,45 @@ ) + + UPDATE wms_iostorinv + SET bill_status = '99', + confirm_time = #{confirmTime}, + confirm_optid = CASE WHEN #{confirmOptid} IS NULL THEN confirm_optid ELSE #{confirmOptid} END + WHERE iostorinv_id = #{iostorinvId} + AND io_type = '1' + AND deleted = 0 + AND bill_status <> '99' + AND NOT EXISTS ( + SELECT 1 + FROM wms_iostorinvdtl dtl + WHERE dtl.iostorinv_id = #{iostorinvId} + AND dtl.deleted = 0 + AND dtl.bill_status <> '99' + ) + + + + UPDATE wms_iostorinv SET is_upload = '1', diff --git a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/iostorinvdis/CuttingProcessService.xml b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/iostorinvdis/CuttingProcessService.xml index 9b417a99..d2c65a7e 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/iostorinvdis/CuttingProcessService.xml +++ b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/iostorinvdis/CuttingProcessService.xml @@ -89,13 +89,6 @@ WHERE task_id = #{taskId} - - + UPDATE wms_moveinvdtl diff --git a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/point/WmsPointMapper.xml b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/point/WmsPointMapper.xml index 11b71cba..95bdd7fa 100644 --- a/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/point/WmsPointMapper.xml +++ b/nl-module-wms/nl-module-wms-server/src/main/resources/mapper/point/WmsPointMapper.xml @@ -303,6 +303,53 @@ ORDER BY h.create_time, h.iostorinv_id, boxes.box_no + + UPDATE wms_point SET vehicle_code = NULL, diff --git a/nl-module-wms/nl-module-wms-server/src/test/java/cn/code/nl/module/wms/service/moveinv/MoveInvServiceImplTest.java b/nl-module-wms/nl-module-wms-server/src/test/java/cn/code/nl/module/wms/service/moveinv/MoveInvServiceImplTest.java index b529905d..fb28d264 100644 --- a/nl-module-wms/nl-module-wms-server/src/test/java/cn/code/nl/module/wms/service/moveinv/MoveInvServiceImplTest.java +++ b/nl-module-wms/nl-module-wms-server/src/test/java/cn/code/nl/module/wms/service/moveinv/MoveInvServiceImplTest.java @@ -3,6 +3,7 @@ package cn.code.nl.module.wms.service.moveinv; import cn.code.nl.module.wms.controller.admin.moveinv.vo.MoveInvInventoryRespVO; import cn.code.nl.module.wms.dal.dataobject.structAttr.StrucAttrDO; import cn.code.nl.module.wms.dal.mysql.groupplate.GroupPlateMapper; +import cn.code.nl.module.wms.service.task.DenseStorageTaskConflictService; import org.junit.jupiter.api.Test; import org.springframework.test.util.ReflectionTestUtils; @@ -11,6 +12,8 @@ import java.util.List; import java.util.Set; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; class MoveInvServiceImplTest { @@ -49,4 +52,49 @@ class MoveInvServiceImplTest { assertEquals("071203", service.selectMoveTargetInInboundOrder( List.of(inboundFirst, sameColumnButLater), Set.of()).getStructId()); } + + @Test + void shouldRejectMoveTargetInSameBlockRowAndLayer() { + MoveInvServiceImpl service = new MoveInvServiceImpl(); + StrucAttrDO source = location("stor-1", "sect-1", 1, 12, 3); + + assertTrue(service.isSameMoveScope(source, + location("stor-1", "sect-1", 1, 12, 3))); + assertFalse(service.isSameMoveScope(source, + location("stor-1", "sect-1", 4, 12, 3))); + assertFalse(service.isSameMoveScope(source, + location("stor-1", "sect-1", 1, 13, 3))); + assertFalse(service.isSameMoveScope(source, + location("stor-1", "sect-1", 1, 12, 2))); + } + + @Test + void shouldRejectMoveInTargetWhenSameScopeHasOutboundTask() { + MoveInvServiceImpl service = new MoveInvServiceImpl(); + ReflectionTestUtils.setField(service, "denseStorageTaskConflictService", + new DenseStorageTaskConflictService()); + StrucAttrDO target = location("stor-1", "sect-1", 7, 1, 3); + target.setLockType("1"); + StrucAttrDO sameScopeOutbound = location("stor-1", "sect-1", 7, 1, 3); + sameScopeOutbound.setLockType("3"); + sameScopeOutbound.setStoragevehicleCode("BOX-001"); + StrucAttrDO otherScopeOutbound = location("stor-1", "sect-1", 7, 2, 3); + otherScopeOutbound.setLockType("3"); + otherScopeOutbound.setStoragevehicleCode("BOX-002"); + + assertFalse(service.isMoveInTaskCompatible(target, + List.of(target, sameScopeOutbound, otherScopeOutbound))); + assertTrue(service.isMoveInTaskCompatible(target, + List.of(target, otherScopeOutbound))); + } + + private StrucAttrDO location(String storId, String sectId, int block, int row, int layer) { + StrucAttrDO location = new StrucAttrDO(); + location.setStorId(storId); + location.setSectId(sectId); + location.setBlockNum(block); + location.setRowNum(row); + location.setLayerNum(layer); + return location; + } } diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/boxtype/index.ts b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/boxtype/index.ts index 59341645..c3219c61 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/boxtype/index.ts +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/boxtype/index.ts @@ -10,6 +10,7 @@ export namespace WmsBoxTypeApi { id?: ApiId; boxType: string; boxName?: string; + specificationModel?: string; lashNum?: string; lashNumOne?: number; lashNumTwo?: number; diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/moveinv/index.ts b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/moveinv/index.ts index 09f43a79..46c32a2d 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/moveinv/index.ts +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/wms/moveinv/index.ts @@ -88,16 +88,35 @@ export function deleteMoveInv(id: string) { return requestClient.delete('/wms/move-inv/delete', { params: { id } }); } -export function getMoveAvailableInventory(storId: string, sectId?: string) { - return requestClient.get( +export function issueMoveInv(id: string) { + return requestClient.post('/wms/move-inv/issue', undefined, { + params: { id }, + }); +} + +export function forceCompleteMoveInv(id: string) { + return requestClient.post('/wms/move-inv/force-complete', undefined, { + params: { id }, + }); +} + +export function getMoveAvailableInventory(params: PageParam & { + keyword?: string; + sectId?: string; + storId: string; +}) { + return requestClient.get>( '/wms/move-inv/availableInventory', - { params: { storId, sectId } }, + { params }, ); } -export function getMoveTargetStructs(sourceStructCode: string) { - return requestClient.get( +export function getMoveTargetStructs(params: PageParam & { + keyword?: string; + sourceStructCode: string; +}) { + return requestClient.get>( '/wms/move-inv/availableTargetStructs', - { params: { sourceStructCode } }, + { params }, ); } diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/boxtype/components/BoxTypeSelectModal.vue b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/boxtype/components/BoxTypeSelectModal.vue index 9a4586c2..0284a807 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/boxtype/components/BoxTypeSelectModal.vue +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/boxtype/components/BoxTypeSelectModal.vue @@ -30,6 +30,7 @@ function handleCheckboxChange({ records }: { records: WmsBoxTypeApi.BoxType[] }) const baseColumns: VxeTableGridOptions['columns'] = [ { field: 'boxType', title: '木箱类型', minWidth: 120 }, { field: 'boxName', title: '木箱描述', minWidth: 180 }, + { field: 'specificationModel', title: '规格型号', minWidth: 150 }, { field: 'boxLength', title: '木箱长度', minWidth: 110 }, { field: 'boxWidth', title: '木箱宽度', minWidth: 110 }, { field: 'boxHigh', title: '木箱高度', minWidth: 110 }, @@ -75,6 +76,15 @@ const [Grid, gridApi] = useVbenVxeGrid({ placeholder: '请输入木箱描述', }, }, + { + fieldName: 'specificationModel', + label: '规格型号', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入规格型号', + }, + }, ], }, gridOptions: { diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/boxtype/data.ts b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/boxtype/data.ts index e9ebe98b..28149511 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/boxtype/data.ts +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/boxtype/data.ts @@ -34,6 +34,15 @@ export function useFormSchema(): VbenFormSchema[] { placeholder: '选择物料后自动带出', }, }, + { + fieldName: 'specificationModel', + label: '规格型号', + component: 'Input', + componentProps: { + maxlength: 50, + placeholder: '请输入规格型号', + }, + }, { fieldName: 'needLashOne', label: '是否一次捆扎', @@ -193,6 +202,15 @@ export function useGridFormSchema(): VbenFormSchema[] { placeholder: '请输入木箱描述', }, }, + { + fieldName: 'specificationModel', + label: '规格型号', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入规格型号', + }, + }, { fieldName: 'needLashOne', label: '是否一次捆扎', @@ -230,6 +248,11 @@ export function useGridColumns(): VxeTableGridOptions['co title: '木箱描述', minWidth: 120, }, + { + field: 'specificationModel', + title: '规格型号', + minWidth: 150, + }, { field: 'boxLength', title: '木箱长度', diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/boxtype/data.ts b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/boxtype/data.ts index efde043c..53ed4bb1 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/boxtype/data.ts +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/boxtype/data.ts @@ -6,6 +6,7 @@ export function useGridFormSchema(): VbenFormSchema[] { return [ { fieldName: 'boxType', label: '木箱类型', component: 'Input', componentProps: { allowClear: true, placeholder: '请输入木箱类型' } }, { fieldName: 'boxName', label: '木箱名称', component: 'Input', componentProps: { allowClear: true, placeholder: '请输入木箱名称' } }, + { fieldName: 'specificationModel', label: '规格型号', component: 'Input', componentProps: { allowClear: true, placeholder: '请输入规格型号' } }, ]; } @@ -13,6 +14,7 @@ export function useGridColumns(): VxeTableGridOptions['co return [ { field: 'boxType', title: '木箱类型', minWidth: 150, fixed: 'left' }, { field: 'boxName', title: '木箱名称', minWidth: 180 }, + { field: 'specificationModel', title: '规格型号', minWidth: 150 }, { field: 'boxLength', title: '长度', width: 100 }, { field: 'boxWidth', title: '宽度', width: 100 }, { field: 'boxHigh', title: '高度', width: 100 }, diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/moveinv/data.ts b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/moveinv/data.ts index 686af86c..b8d7e80b 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/moveinv/data.ts +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/moveinv/data.ts @@ -28,6 +28,18 @@ export function useGridFormSchema(): VbenFormSchema[] { fieldName: 'storId', label: '仓库', }, + { + component: 'Input', + componentProps: { allowClear: true, placeholder: '请输入木箱号' }, + fieldName: 'boxNo', + label: '木箱号', + }, + { + component: 'Input', + componentProps: { allowClear: true, placeholder: '请输入卷号' }, + fieldName: 'rollNo', + label: '卷号', + }, { component: 'Select', componentProps: { @@ -76,6 +88,6 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'creatorName', title: '创建人', width: 100 }, { field: 'createTime', formatter: 'formatDateTime', title: '创建时间', width: 170 }, { field: 'remark', title: '备注', minWidth: 160 }, - { field: 'actions', fixed: 'right', slots: { default: 'actions' }, title: '操作', width: 170 }, + { field: 'actions', fixed: 'right', slots: { default: 'actions' }, title: '操作', width: 300 }, ]; } diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/moveinv/index.vue b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/moveinv/index.vue index f7b35f8f..a283a672 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/moveinv/index.vue +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/wms/moveinv/index.vue @@ -2,12 +2,19 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { WmsMoveInvApi } from '#/api/wms/moveinv'; -import { Page, useVbenModal } from '@vben/common-ui'; +import { ref } from 'vue'; + +import { confirm, Page, useVbenModal } from '@vben/common-ui'; import { Button, message } from 'antdv-next'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; -import { deleteMoveInv, getMoveInvPage } from '#/api/wms/moveinv'; +import { + deleteMoveInv, + forceCompleteMoveInv, + getMoveInvPage, + issueMoveInv, +} from '#/api/wms/moveinv'; import { useGridColumns, useGridFormSchema } from './data'; import Detail from './modules/detail.vue'; @@ -42,6 +49,37 @@ function view(row: WmsMoveInvApi.MoveInv) { detailModalApi.setData(row).open(); } +const issuingId = ref(); +const forceCompletingId = ref(); + +async function issue(row: WmsMoveInvApi.MoveInv) { + await confirm( + `确认下发移库单 ${row.billCode || row.moveinvId} 的全部搬运任务吗?任务将按明细顺序下发。`, + ); + issuingId.value = row.moveinvId; + try { + await issueMoveInv(row.moveinvId!); + message.success('移库任务下发成功'); + refresh(); + } finally { + issuingId.value = undefined; + } +} + +async function forceComplete(row: WmsMoveInvApi.MoveInv) { + await confirm( + `确认强制完成移库单 ${row.billCode || row.moveinvId} 吗?请先确认所有木箱均已从移出仓位搬到对应移入仓位。存在未结束搬运任务时系统将拒绝操作。`, + ); + forceCompletingId.value = row.moveinvId; + try { + await forceCompleteMoveInv(row.moveinvId!); + message.success('移库单已强制完成'); + refresh(); + } finally { + forceCompletingId.value = undefined; + } +} + async function remove(row: WmsMoveInvApi.MoveInv) { if (row.billStatus !== '10') { message.warning('只有生成状态的移库单允许删除'); @@ -99,6 +137,24 @@ const [Grid, gridApi] = useVbenVxeGrid({