Merge remote-tracking branch 'origin/feature/20260716/wms-module' into feature/20260716/wms-module
# Conflicts: # nl-module-wms/nl-module-wms-api/src/main/java/cn/code/nl/module/wms/enums/ErrorCodeConstants.java # nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/packages/constants/src/dict-enum.ts
This commit is contained in:
@@ -32,6 +32,16 @@
|
||||
<artifactId>nl-module-wms-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.nl.cloud</groupId>
|
||||
<artifactId>nl-module-system-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.nl.cloud</groupId>
|
||||
<artifactId>nl-module-task-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<dependency>
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package cn.code.nl.module.wms.controller.admin.warehousestrategy;
|
||||
|
||||
import org.dromara.core.trans.anno.TransMethodResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.code.nl.framework.common.pojo.PageParam;
|
||||
import cn.code.nl.framework.common.pojo.PageResult;
|
||||
import cn.code.nl.framework.common.pojo.CommonResult;
|
||||
import cn.code.nl.framework.common.util.object.BeanUtils;
|
||||
import static cn.code.nl.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.code.nl.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.code.nl.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.code.nl.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.code.nl.module.wms.controller.admin.warehousestrategy.vo.*;
|
||||
import cn.code.nl.module.wms.dal.dataobject.warehousestrategy.WarehouseStrategyDO;
|
||||
import cn.code.nl.module.wms.service.warehousestrategy.WarehouseStrategyService;
|
||||
|
||||
@Tag(name = "管理后台 - 出入库策略")
|
||||
@RestController
|
||||
@RequestMapping("/wms/warehouse-strategy")
|
||||
@Validated
|
||||
public class WarehouseStrategyController {
|
||||
|
||||
@Resource
|
||||
private WarehouseStrategyService warehouseStrategyService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建出入库策略")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy:create')")
|
||||
public CommonResult<Long> createWarehouseStrategy(@Valid @RequestBody WarehouseStrategySaveReqVO createReqVO) {
|
||||
return success(warehouseStrategyService.createWarehouseStrategy(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新出入库策略")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy:update')")
|
||||
public CommonResult<Boolean> updateWarehouseStrategy(@Valid @RequestBody WarehouseStrategySaveReqVO updateReqVO) {
|
||||
warehouseStrategyService.updateWarehouseStrategy(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除出入库策略")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy:delete')")
|
||||
public CommonResult<Boolean> deleteWarehouseStrategy(@RequestParam("id") Long id) {
|
||||
warehouseStrategyService.deleteWarehouseStrategy(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除出入库策略")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy:delete')")
|
||||
public CommonResult<Boolean> deleteWarehouseStrategyList(@RequestParam("ids") List<Long> ids) {
|
||||
warehouseStrategyService.deleteWarehouseStrategyListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得出入库策略")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy:query')")
|
||||
public CommonResult<WarehouseStrategyRespVO> getWarehouseStrategy(@RequestParam("id") Long id) {
|
||||
WarehouseStrategyDO warehouseStrategy = warehouseStrategyService.getWarehouseStrategy(id);
|
||||
return success(BeanUtils.toBean(warehouseStrategy, WarehouseStrategyRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得出入库策略分页")
|
||||
@TransMethodResult
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy:query')")
|
||||
public CommonResult<PageResult<WarehouseStrategyRespVO>> getWarehouseStrategyPage(@Valid WarehouseStrategyPageReqVO pageReqVO) {
|
||||
PageResult<WarehouseStrategyDO> pageResult = warehouseStrategyService.getWarehouseStrategyPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, WarehouseStrategyRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出出入库策略 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportWarehouseStrategyExcel(@Valid WarehouseStrategyPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<WarehouseStrategyDO> list = warehouseStrategyService.getWarehouseStrategyPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "出入库策略.xls", "数据", WarehouseStrategyRespVO.class,
|
||||
BeanUtils.toBean(list, WarehouseStrategyRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.code.nl.module.wms.controller.admin.warehousestrategy.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.code.nl.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.code.nl.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 出入库策略分页 Request VO")
|
||||
@Data
|
||||
public class WarehouseStrategyPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "库区编码")
|
||||
private String sectionCode;
|
||||
|
||||
@Schema(description = "规则")
|
||||
private String strategy;
|
||||
|
||||
@Schema(description = "策略类型", example = "1入库2出库")
|
||||
private String strategyType;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package cn.code.nl.module.wms.controller.admin.warehousestrategy.vo;
|
||||
|
||||
import cn.code.nl.module.system.api.user.AdminUserApi;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.dromara.core.trans.anno.Trans;
|
||||
import org.dromara.core.trans.constant.TransType;
|
||||
import org.dromara.core.trans.vo.VO;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import cn.idev.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 出入库策略 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class WarehouseStrategyRespVO implements VO {
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "库区编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("库区编码")
|
||||
private String sectionCode;
|
||||
|
||||
@Schema(description = "规则", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("规则")
|
||||
private String strategy;
|
||||
|
||||
@Schema(description = "策略类型", example = "1入库2出库")
|
||||
@ExcelProperty("策略类型")
|
||||
private String strategyType;
|
||||
|
||||
@Schema(description = "描述")
|
||||
@ExcelProperty("描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建者")
|
||||
@ExcelProperty("创建者")
|
||||
@Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "creatorName")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "创建者名称")
|
||||
private String creatorName;
|
||||
|
||||
@Schema(description = "更新者", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("更新者")
|
||||
private String updater;
|
||||
|
||||
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.code.nl.module.wms.controller.admin.warehousestrategy.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 出入库策略新增/修改 Request VO")
|
||||
@Data
|
||||
public class WarehouseStrategySaveReqVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "库区编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "库区编码不能为空")
|
||||
private String sectionCode;
|
||||
|
||||
@Schema(description = "规则", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "规则不能为空")
|
||||
private String strategy;
|
||||
|
||||
@Schema(description = "策略类型", example = "1入库2出库")
|
||||
private String strategyType;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package cn.code.nl.module.wms.controller.admin.warehousestrategyconfig;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.code.nl.framework.common.pojo.PageParam;
|
||||
import cn.code.nl.framework.common.pojo.PageResult;
|
||||
import cn.code.nl.framework.common.pojo.CommonResult;
|
||||
import cn.code.nl.framework.common.util.object.BeanUtils;
|
||||
import static cn.code.nl.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.code.nl.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.code.nl.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.code.nl.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.code.nl.module.wms.controller.admin.warehousestrategyconfig.vo.*;
|
||||
import cn.code.nl.module.wms.dal.dataobject.warehousestrategyconfig.WarehouseStrategyConfigDO;
|
||||
import cn.code.nl.module.wms.service.warehousestrategyconfig.WarehouseStrategyConfigService;
|
||||
|
||||
@Tag(name = "管理后台 - 仓储策略配置")
|
||||
@RestController
|
||||
@RequestMapping("/wms/warehouse-strategy-config")
|
||||
@Validated
|
||||
public class WarehouseStrategyConfigController {
|
||||
|
||||
@Resource
|
||||
private WarehouseStrategyConfigService warehouseStrategyConfigService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建仓储策略配置")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy-config:create')")
|
||||
public CommonResult<Long> createWarehouseStrategyConfig(@Valid @RequestBody WarehouseStrategyConfigSaveReqVO createReqVO) {
|
||||
return success(warehouseStrategyConfigService.createWarehouseStrategyConfig(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新仓储策略配置")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy-config:update')")
|
||||
public CommonResult<Boolean> updateWarehouseStrategyConfig(@Valid @RequestBody WarehouseStrategyConfigSaveReqVO updateReqVO) {
|
||||
warehouseStrategyConfigService.updateWarehouseStrategyConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除仓储策略配置")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy-config:delete')")
|
||||
public CommonResult<Boolean> deleteWarehouseStrategyConfig(@RequestParam("id") Long id) {
|
||||
warehouseStrategyConfigService.deleteWarehouseStrategyConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除仓储策略配置")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy-config:delete')")
|
||||
public CommonResult<Boolean> deleteWarehouseStrategyConfigList(@RequestParam("ids") List<Long> ids) {
|
||||
warehouseStrategyConfigService.deleteWarehouseStrategyConfigListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得仓储策略配置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy-config:query')")
|
||||
public CommonResult<WarehouseStrategyConfigRespVO> getWarehouseStrategyConfig(@RequestParam("id") Long id) {
|
||||
WarehouseStrategyConfigDO warehouseStrategyConfig = warehouseStrategyConfigService.getWarehouseStrategyConfig(id);
|
||||
return success(BeanUtils.toBean(warehouseStrategyConfig, WarehouseStrategyConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得仓储策略配置分页")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy-config:query')")
|
||||
public CommonResult<PageResult<WarehouseStrategyConfigRespVO>> getWarehouseStrategyConfigPage(@Valid WarehouseStrategyConfigPageReqVO pageReqVO) {
|
||||
PageResult<WarehouseStrategyConfigDO> pageResult = warehouseStrategyConfigService.getWarehouseStrategyConfigPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, WarehouseStrategyConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/list-all-simple", "/simple-list"})
|
||||
@Operation(summary = "获得仓储策略配置精简列表")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy-config:query')")
|
||||
public CommonResult<List<WarehouseStrategyConfigSimpleRespVO>> getSimpleWarehouseStrategyConfigList() {
|
||||
List<WarehouseStrategyConfigDO> list = warehouseStrategyConfigService.getWarehouseStrategyConfigList();
|
||||
return success(BeanUtils.toBean(list, WarehouseStrategyConfigSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出仓储策略配置 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('wms:warehouse-strategy-config:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportWarehouseStrategyConfigExcel(@Valid WarehouseStrategyConfigPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<WarehouseStrategyConfigDO> list = warehouseStrategyConfigService.getWarehouseStrategyConfigPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "仓储策略配置.xls", "数据", WarehouseStrategyConfigRespVO.class,
|
||||
BeanUtils.toBean(list, WarehouseStrategyConfigRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.code.nl.module.wms.controller.admin.warehousestrategyconfig.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.code.nl.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.code.nl.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 仓储策略配置分页 Request VO")
|
||||
@Data
|
||||
public class WarehouseStrategyConfigPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "策略编码")
|
||||
private String strategyCode;
|
||||
|
||||
@Schema(description = "策略名称", example = "赵六")
|
||||
private String strategyName;
|
||||
|
||||
@Schema(description = "策略类型", example = "1")
|
||||
private String strategyType;
|
||||
|
||||
@Schema(description = "类处理类型", example = "2")
|
||||
private String classType;
|
||||
|
||||
@Schema(description = "处理类")
|
||||
private String param;
|
||||
|
||||
@Schema(description = "描述", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean isUsed;
|
||||
|
||||
@Schema(description = "禁止操作")
|
||||
private Boolean ban;
|
||||
|
||||
@Schema(description = "限定参数")
|
||||
private String formData;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package cn.code.nl.module.wms.controller.admin.warehousestrategyconfig.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import cn.idev.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 仓储策略配置 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class WarehouseStrategyConfigRespVO {
|
||||
|
||||
private String id;
|
||||
|
||||
@Schema(description = "策略编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("策略编码")
|
||||
private String strategyCode;
|
||||
|
||||
@Schema(description = "策略名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@ExcelProperty("策略名称")
|
||||
private String strategyName;
|
||||
|
||||
@Schema(description = "策略类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("策略类型")
|
||||
private String strategyType;
|
||||
|
||||
@Schema(description = "类处理类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("类处理类型")
|
||||
private String classType;
|
||||
|
||||
@Schema(description = "处理类", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("处理类")
|
||||
private String param;
|
||||
|
||||
@Schema(description = "描述", example = "你说的对")
|
||||
@ExcelProperty("描述")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
@ExcelProperty("是否启用")
|
||||
private Boolean isUsed;
|
||||
|
||||
@Schema(description = "禁止操作")
|
||||
@ExcelProperty("禁止操作")
|
||||
private Boolean ban;
|
||||
|
||||
@Schema(description = "限定参数")
|
||||
@ExcelProperty("限定参数")
|
||||
private String formData;
|
||||
|
||||
@Schema(description = "创建者")
|
||||
@ExcelProperty("创建者")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新者")
|
||||
@ExcelProperty("更新者")
|
||||
private String updater;
|
||||
|
||||
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.code.nl.module.wms.controller.admin.warehousestrategyconfig.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 仓储策略配置新增/修改 Request VO")
|
||||
@Data
|
||||
public class WarehouseStrategyConfigSaveReqVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "策略编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "策略编码不能为空")
|
||||
private String strategyCode;
|
||||
|
||||
@Schema(description = "策略名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@NotEmpty(message = "策略名称不能为空")
|
||||
private String strategyName;
|
||||
|
||||
@Schema(description = "策略类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "策略类型不能为空")
|
||||
private String strategyType;
|
||||
|
||||
@Schema(description = "类处理类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotEmpty(message = "类处理类型不能为空")
|
||||
private String classType;
|
||||
|
||||
@Schema(description = "处理类", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "处理类不能为空")
|
||||
private String param;
|
||||
|
||||
@Schema(description = "描述", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean isUsed;
|
||||
|
||||
@Schema(description = "禁止操作")
|
||||
private Boolean ban;
|
||||
|
||||
@Schema(description = "限定参数")
|
||||
private String formData;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.code.nl.module.wms.controller.admin.warehousestrategyconfig.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 仓储策略配置精简 Response VO")
|
||||
@Data
|
||||
public class WarehouseStrategyConfigSimpleRespVO {
|
||||
|
||||
@Schema(description = "策略编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String strategyCode;
|
||||
|
||||
@Schema(description = "策略名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String strategyName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.code.nl.module.wms.dal.dataobject.warehousestrategy;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.code.nl.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 出入库策略 DO
|
||||
*
|
||||
* @author 诺力管理员
|
||||
*/
|
||||
@TableName("wms_warehouse_strategy")
|
||||
@KeySequence("wms_warehouse_strategy_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WarehouseStrategyDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 库区编码
|
||||
*/
|
||||
private String sectionCode;
|
||||
/**
|
||||
* 规则
|
||||
*/
|
||||
private String strategy;
|
||||
/**
|
||||
* 策略类型
|
||||
*/
|
||||
private String strategyType;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package cn.code.nl.module.wms.dal.dataobject.warehousestrategyconfig;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.code.nl.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 仓储策略配置 DO
|
||||
*
|
||||
* @author 诺力管理员
|
||||
*/
|
||||
@TableName("wms_warehouse_strategy_config")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WarehouseStrategyConfigDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 策略标识
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 策略编码
|
||||
*/
|
||||
private String strategyCode;
|
||||
/**
|
||||
* 策略名称
|
||||
*/
|
||||
private String strategyName;
|
||||
/**
|
||||
* 策略类型
|
||||
*/
|
||||
private String strategyType;
|
||||
/**
|
||||
* 类处理类型
|
||||
*/
|
||||
private String classType;
|
||||
/**
|
||||
* 处理类
|
||||
*/
|
||||
private String param;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean isUsed;
|
||||
/**
|
||||
* 禁止操作
|
||||
*/
|
||||
private Boolean ban;
|
||||
/**
|
||||
* 限定参数
|
||||
*/
|
||||
private String formData;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.code.nl.module.wms.dal.mysql.warehousestrategy;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.code.nl.framework.common.pojo.PageResult;
|
||||
import cn.code.nl.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.code.nl.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.code.nl.module.wms.dal.dataobject.warehousestrategy.WarehouseStrategyDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.code.nl.module.wms.controller.admin.warehousestrategy.vo.*;
|
||||
|
||||
/**
|
||||
* 出入库策略 Mapper
|
||||
*
|
||||
* @author 诺力管理员
|
||||
*/
|
||||
@Mapper
|
||||
public interface WarehouseStrategyMapper extends BaseMapperX<WarehouseStrategyDO> {
|
||||
|
||||
default PageResult<WarehouseStrategyDO> selectPage(WarehouseStrategyPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<WarehouseStrategyDO>()
|
||||
.eqIfPresent(WarehouseStrategyDO::getSectionCode, reqVO.getSectionCode())
|
||||
.eqIfPresent(WarehouseStrategyDO::getStrategy, reqVO.getStrategy())
|
||||
.eqIfPresent(WarehouseStrategyDO::getStrategyType, reqVO.getStrategyType())
|
||||
.betweenIfPresent(WarehouseStrategyDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(WarehouseStrategyDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package cn.code.nl.module.wms.dal.mysql.warehousestrategyconfig;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.code.nl.framework.common.pojo.PageResult;
|
||||
import cn.code.nl.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.code.nl.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.code.nl.module.wms.dal.dataobject.warehousestrategyconfig.WarehouseStrategyConfigDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.code.nl.module.wms.controller.admin.warehousestrategyconfig.vo.*;
|
||||
|
||||
/**
|
||||
* 仓储策略配置 Mapper
|
||||
*
|
||||
* @author 诺力管理员
|
||||
*/
|
||||
@Mapper
|
||||
public interface WarehouseStrategyConfigMapper extends BaseMapperX<WarehouseStrategyConfigDO> {
|
||||
|
||||
default List<WarehouseStrategyConfigDO> selectList() {
|
||||
return selectList(new LambdaQueryWrapperX<WarehouseStrategyConfigDO>()
|
||||
.eq(WarehouseStrategyConfigDO::getIsUsed, true)
|
||||
.orderByDesc(WarehouseStrategyConfigDO::getId));
|
||||
}
|
||||
|
||||
default PageResult<WarehouseStrategyConfigDO> selectPage(WarehouseStrategyConfigPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<WarehouseStrategyConfigDO>()
|
||||
.eqIfPresent(WarehouseStrategyConfigDO::getStrategyCode, reqVO.getStrategyCode())
|
||||
.likeIfPresent(WarehouseStrategyConfigDO::getStrategyName, reqVO.getStrategyName())
|
||||
.eqIfPresent(WarehouseStrategyConfigDO::getStrategyType, reqVO.getStrategyType())
|
||||
.eqIfPresent(WarehouseStrategyConfigDO::getClassType, reqVO.getClassType())
|
||||
.eqIfPresent(WarehouseStrategyConfigDO::getParam, reqVO.getParam())
|
||||
.eqIfPresent(WarehouseStrategyConfigDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(WarehouseStrategyConfigDO::getIsUsed, reqVO.getIsUsed())
|
||||
.eqIfPresent(WarehouseStrategyConfigDO::getBan, reqVO.getBan())
|
||||
.eqIfPresent(WarehouseStrategyConfigDO::getFormData, reqVO.getFormData())
|
||||
.betweenIfPresent(WarehouseStrategyConfigDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(WarehouseStrategyConfigDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.code.nl.module.wms.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/7/18 14:15
|
||||
*/
|
||||
@Getter
|
||||
public enum StrategyTypeEnum {
|
||||
|
||||
INBOUND_STRATEGY("1", "入库策略"),
|
||||
OUTBOUND_STRATEGY("2", "出库策略");
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
StrategyTypeEnum(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import org.springframework.security.config.annotation.web.configurers.AuthorizeH
|
||||
*
|
||||
* @author zhouz
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false, value = "baseSecurityConfiguration")
|
||||
@Configuration(proxyBeanMethods = false, value = "wmsSecurityConfiguration")
|
||||
public class SecurityConfiguration {
|
||||
|
||||
/*
|
||||
@@ -93,7 +93,7 @@ public class SecurityConfiguration {
|
||||
|
||||
3. 遵循了项目中每个模块定义各自安全配置的标准模式
|
||||
* */
|
||||
@Bean("baseAuthorizeRequestsCustomizer")
|
||||
@Bean("wmsAuthorizeRequestsCustomizer")
|
||||
public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() {
|
||||
return new AuthorizeRequestsCustomizer() {
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package cn.code.nl.module.wms.manage;
|
||||
|
||||
import cn.code.nl.framework.common.exception.ServiceException;
|
||||
import cn.code.nl.module.wms.dal.dataobject.warehousestrategyconfig.WarehouseStrategyConfigDO;
|
||||
import cn.code.nl.module.wms.dal.mysql.warehousestrategyconfig.WarehouseStrategyConfigMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 仓储策略决策器抽象基类
|
||||
* <p>
|
||||
* 子类通过 {@code @Service("策略编码")} 注册为 Spring Bean,
|
||||
* 启动时根据 Bean 名称自动从数据库加载对应的策略配置。
|
||||
*
|
||||
* @param <T> 返回类型:货位/库存数据类型
|
||||
* @param <P> 入参类型:决策参数类型
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/7/18 11:03
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class DecisionManage<T, P> implements InitializingBean, BeanNameAware {
|
||||
|
||||
/**
|
||||
* 当前策略的数据库配置,子类通过此字段读取策略参数
|
||||
*/
|
||||
public WarehouseStrategyConfigDO strategyConfig;
|
||||
|
||||
/**
|
||||
* Spring Bean 名称,即策略编码,对应 {@link WarehouseStrategyConfigDO#getStrategyCode()}
|
||||
*/
|
||||
private String beanName;
|
||||
|
||||
@Resource
|
||||
private WarehouseStrategyConfigMapper warehouseStrategyConfigMapper;
|
||||
|
||||
/**
|
||||
* 策略执行入口,由子类实现具体的货位分配逻辑
|
||||
*
|
||||
* @param list 候选货位/库存列表
|
||||
* @param param 决策参数(物料信息、出入库类型等)
|
||||
* @return 筛选/排序后的货位/库存列表
|
||||
*/
|
||||
public abstract List<T> handler(List<T> list, P param);
|
||||
|
||||
@Override
|
||||
public void setBeanName(@NonNull String name) {
|
||||
this.beanName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spring Bean 初始化时自动加载策略配置
|
||||
* <p>
|
||||
* 通过 BeanNameAware 获取策略编码,从数据库查询对应的策略配置记录。
|
||||
* 若数据库中无对应记录则抛出异常阻止启动,避免运行时才发现配置缺失。
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
this.strategyConfig = warehouseStrategyConfigMapper.selectOne(
|
||||
WarehouseStrategyConfigDO::getStrategyCode, beanName);
|
||||
if (this.strategyConfig == null) {
|
||||
log.error("策略 [{}] 初始化失败:数据库中未找到对应的策略配置记录", beanName);
|
||||
throw new ServiceException(500, "启动失败:当前策略 " + beanName + " 没有实例信息");
|
||||
}
|
||||
log.info("策略 [{}] 初始化成功,策略名称:{}", beanName, strategyConfig.getStrategyName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.code.nl.module.wms.manage;
|
||||
|
||||
import cn.code.nl.framework.common.exception.ServiceException;
|
||||
import cn.code.nl.module.wms.dal.dataobject.warehousestrategy.WarehouseStrategyDO;
|
||||
import cn.code.nl.module.wms.dal.mysql.warehousestrategy.WarehouseStrategyMapper;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 策略链执行器
|
||||
* <p>
|
||||
* 根据库区编码和策略类型加载策略链配置,从 Spring 容器中按名称精确获取策略处理器,
|
||||
* 按序执行,每个处理器的输出作为下一个处理器的输入。
|
||||
*
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/7/18
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class StrategyChainExecutor {
|
||||
|
||||
@Resource
|
||||
private WarehouseStrategyMapper warehouseStrategyMapper;
|
||||
|
||||
@Resource
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
/**
|
||||
* 执行策略链
|
||||
*
|
||||
* @param sectionCode 库区编码
|
||||
* @param strategyType 策略类型(1=入库,2=出库)
|
||||
* @param candidates 初始候选列表,入库时为可用货位列表,出库时传空列表由首个策略自行查询
|
||||
* @param param 决策参数,类型由调用方决定(入库通常传 JSONObject,出库通常传强类型实体)
|
||||
* @param <T> 货位/库存数据类型
|
||||
* @param <P> 决策参数类型,需与策略链中所有处理器的泛型参数一致
|
||||
* @return 策略链执行后的结果列表
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T, P> List<T> execute(String sectionCode, String strategyType, List<T> candidates, P param) {
|
||||
// 1. 查询库区策略链配置
|
||||
WarehouseStrategyDO strategy = warehouseStrategyMapper.selectOne(
|
||||
WarehouseStrategyDO::getSectionCode, sectionCode,
|
||||
WarehouseStrategyDO::getStrategyType, strategyType);
|
||||
if (strategy == null) {
|
||||
throw new ServiceException(500, "当前库区 " + sectionCode + " 未配置策略链");
|
||||
}
|
||||
|
||||
// 2. 解析策略编码列表
|
||||
List<String> strategyCodes = JSON.parseArray(strategy.getStrategy(), String.class);
|
||||
if (CollUtil.isEmpty(strategyCodes)) {
|
||||
throw new ServiceException(500, "当前库区 " + sectionCode + " 策略链为空");
|
||||
}
|
||||
|
||||
// 3. 按序执行策略链
|
||||
List<T> result = candidates;
|
||||
for (String strategyCode : strategyCodes) {
|
||||
DecisionManage<T, P> handler;
|
||||
try {
|
||||
handler = (DecisionManage<T, P>) applicationContext.getBean(strategyCode);
|
||||
} catch (Exception e) {
|
||||
log.error("策略 [{}] 未找到对应的处理器 Bean", strategyCode, e);
|
||||
throw new ServiceException(500, "策略 " + strategyCode + " 未注册");
|
||||
}
|
||||
|
||||
String strategyName = handler.strategyConfig.getStrategyName();
|
||||
int inputSize = result != null ? result.size() : 0;
|
||||
log.info("执行策略 [{}]:{},输入候选数量:{}", strategyCode, strategyName, inputSize);
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
result = handler.handler(result, param);
|
||||
long cost = System.currentTimeMillis() - startTime;
|
||||
|
||||
int outputSize = result != null ? result.size() : 0;
|
||||
log.info("策略 [{}] 执行完成,耗时:{}ms,输出数量:{}(过滤:{})",
|
||||
strategyCode, cost, outputSize, inputSize - outputSize);
|
||||
|
||||
if (CollUtil.isEmpty(result)) {
|
||||
throw new ServiceException(500, "策略 " + strategyName + " 执行后无可用货位");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.code.nl.module.wms.manage.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/7/18 14:12
|
||||
*/
|
||||
@Data
|
||||
public class AlleyAveHandleDTO {
|
||||
private String id;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.code.nl.module.wms.manage.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/7/18 14:12
|
||||
*/
|
||||
@Data
|
||||
public class AlleyAveHandleParam {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.code.nl.module.wms.manage.handle.base;
|
||||
|
||||
import cn.code.nl.module.wms.manage.DecisionManage;
|
||||
import cn.code.nl.module.wms.manage.dto.AlleyAveHandleDTO;
|
||||
import cn.code.nl.module.wms.manage.dto.AlleyAveHandleParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/7/18 13:39
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("alleyAve")
|
||||
public class AlleyAveRuleHandler extends DecisionManage<AlleyAveHandleDTO, AlleyAveHandleParam> {
|
||||
@Override
|
||||
public List<AlleyAveHandleDTO> handler(List<AlleyAveHandleDTO> list, AlleyAveHandleParam param) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 所有出入库的处理器
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/7/18 14:11
|
||||
*/
|
||||
package cn.code.nl.module.wms.manage.handle;
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.code.nl.module.wms.mq.consumer;
|
||||
|
||||
import cn.code.nl.framework.execute.core.AbstractTask;
|
||||
import cn.code.nl.framework.execute.core.TaskFactory;
|
||||
import cn.code.nl.framework.execute.core.dto.TaskExecuteDTO;
|
||||
import cn.code.nl.module.task.message.TaskEventMessage;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 监听任务状态变更,根据 handleCode 定位任务子类并执行完成/取消逻辑
|
||||
*
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/7/20 10:28
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RocketMQMessageListener(
|
||||
topic = "${rocketmq.consumer.wms-task-operate.topic}",
|
||||
consumerGroup = "${rocketmq.consumer.wms-task-operate.group}"
|
||||
)
|
||||
public class TaskStatusChangeConsumer implements RocketMQListener<TaskEventMessage> {
|
||||
|
||||
@Resource
|
||||
private TaskFactory taskFactory;
|
||||
|
||||
@Override
|
||||
public void onMessage(TaskEventMessage message) {
|
||||
String handleCode = message.getHandleCode();
|
||||
String eventType = message.getEventType();
|
||||
log.info("收到任务状态变更消息, handleCode={}, eventType={}, taskId={}", handleCode, eventType, message.getTaskId());
|
||||
|
||||
AbstractTask task = taskFactory.getTask(handleCode);
|
||||
if (task == null) {
|
||||
log.warn("未找到对应任务处理器, handleCode={}", handleCode);
|
||||
return;
|
||||
}
|
||||
|
||||
TaskExecuteDTO dto = new TaskExecuteDTO();
|
||||
dto.setTaskId(message.getTaskId());
|
||||
dto.setPayload(message.getPayload());
|
||||
|
||||
if (TaskEventMessage.EVENT_TYPE_FINISHED.equals(eventType)) {
|
||||
task.doHandleFinish(dto);
|
||||
} else if (TaskEventMessage.EVENT_TYPE_CANCELLED.equals(eventType)) {
|
||||
task.doHandleCancel(dto);
|
||||
} else {
|
||||
log.warn("未知事件类型, eventType={}, handleCode={}", eventType, handleCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 消息队列
|
||||
* @Author: liyongde
|
||||
* @Date: 2026/7/20 10:26
|
||||
*/
|
||||
package cn.code.nl.module.wms.mq;
|
||||
@@ -0,0 +1,62 @@
|
||||
package cn.code.nl.module.wms.service.warehousestrategy;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.code.nl.module.wms.controller.admin.warehousestrategy.vo.*;
|
||||
import cn.code.nl.module.wms.dal.dataobject.warehousestrategy.WarehouseStrategyDO;
|
||||
import cn.code.nl.framework.common.pojo.PageResult;
|
||||
import cn.code.nl.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 出入库策略 Service 接口
|
||||
*
|
||||
* @author 诺力管理员
|
||||
*/
|
||||
public interface WarehouseStrategyService {
|
||||
|
||||
/**
|
||||
* 创建出入库策略
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createWarehouseStrategy(@Valid WarehouseStrategySaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新出入库策略
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateWarehouseStrategy(@Valid WarehouseStrategySaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除出入库策略
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteWarehouseStrategy(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除出入库策略
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteWarehouseStrategyListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得出入库策略
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 出入库策略
|
||||
*/
|
||||
WarehouseStrategyDO getWarehouseStrategy(Long id);
|
||||
|
||||
/**
|
||||
* 获得出入库策略分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 出入库策略分页
|
||||
*/
|
||||
PageResult<WarehouseStrategyDO> getWarehouseStrategyPage(WarehouseStrategyPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cn.code.nl.module.wms.service.warehousestrategy;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.code.nl.module.wms.controller.admin.warehousestrategy.vo.*;
|
||||
import cn.code.nl.module.wms.dal.dataobject.warehousestrategy.WarehouseStrategyDO;
|
||||
import cn.code.nl.framework.common.pojo.PageResult;
|
||||
import cn.code.nl.framework.common.pojo.PageParam;
|
||||
import cn.code.nl.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.code.nl.module.wms.dal.mysql.warehousestrategy.WarehouseStrategyMapper;
|
||||
|
||||
import static cn.code.nl.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.code.nl.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.code.nl.framework.common.util.collection.CollectionUtils.diffList;
|
||||
import static cn.code.nl.module.wms.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 出入库策略 Service 实现类
|
||||
*
|
||||
* @author 诺力管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class WarehouseStrategyServiceImpl implements WarehouseStrategyService {
|
||||
|
||||
@Resource
|
||||
private WarehouseStrategyMapper warehouseStrategyMapper;
|
||||
|
||||
@Override
|
||||
public Long createWarehouseStrategy(WarehouseStrategySaveReqVO createReqVO) {
|
||||
// 插入
|
||||
WarehouseStrategyDO warehouseStrategy = BeanUtils.toBean(createReqVO, WarehouseStrategyDO.class);
|
||||
warehouseStrategyMapper.insert(warehouseStrategy);
|
||||
|
||||
// 返回
|
||||
return warehouseStrategy.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWarehouseStrategy(WarehouseStrategySaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateWarehouseStrategyExists(updateReqVO.getId());
|
||||
// 更新
|
||||
WarehouseStrategyDO updateObj = BeanUtils.toBean(updateReqVO, WarehouseStrategyDO.class);
|
||||
warehouseStrategyMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWarehouseStrategy(Long id) {
|
||||
// 校验存在
|
||||
validateWarehouseStrategyExists(id);
|
||||
// 删除
|
||||
warehouseStrategyMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWarehouseStrategyListByIds(List<Long> ids) {
|
||||
// 删除
|
||||
warehouseStrategyMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
private void validateWarehouseStrategyExists(Long id) {
|
||||
if (warehouseStrategyMapper.selectById(id) == null) {
|
||||
throw exception(WAREHOUSE_STRATEGY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WarehouseStrategyDO getWarehouseStrategy(Long id) {
|
||||
return warehouseStrategyMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<WarehouseStrategyDO> getWarehouseStrategyPage(WarehouseStrategyPageReqVO pageReqVO) {
|
||||
return warehouseStrategyMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package cn.code.nl.module.wms.service.warehousestrategyconfig;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.code.nl.module.wms.controller.admin.warehousestrategyconfig.vo.*;
|
||||
import cn.code.nl.module.wms.dal.dataobject.warehousestrategyconfig.WarehouseStrategyConfigDO;
|
||||
import cn.code.nl.framework.common.pojo.PageResult;
|
||||
import cn.code.nl.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 仓储策略配置 Service 接口
|
||||
*
|
||||
* @author 诺力管理员
|
||||
*/
|
||||
public interface WarehouseStrategyConfigService {
|
||||
|
||||
/**
|
||||
* 创建仓储策略配置
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createWarehouseStrategyConfig(@Valid WarehouseStrategyConfigSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新仓储策略配置
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateWarehouseStrategyConfig(@Valid WarehouseStrategyConfigSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除仓储策略配置
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteWarehouseStrategyConfig(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除仓储策略配置
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteWarehouseStrategyConfigListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得仓储策略配置
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 仓储策略配置
|
||||
*/
|
||||
WarehouseStrategyConfigDO getWarehouseStrategyConfig(Long id);
|
||||
|
||||
/**
|
||||
* 获得仓储策略配置分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 仓储策略配置分页
|
||||
*/
|
||||
PageResult<WarehouseStrategyConfigDO> getWarehouseStrategyConfigPage(WarehouseStrategyConfigPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得仓储策略配置列表(仅启用的)
|
||||
*
|
||||
* @return 仓储策略配置列表
|
||||
*/
|
||||
List<WarehouseStrategyConfigDO> getWarehouseStrategyConfigList();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cn.code.nl.module.wms.service.warehousestrategyconfig;
|
||||
|
||||
import cn.code.nl.framework.common.pojo.PageResult;
|
||||
import cn.code.nl.framework.common.util.object.BeanUtils;
|
||||
import cn.code.nl.module.wms.controller.admin.warehousestrategyconfig.vo.WarehouseStrategyConfigPageReqVO;
|
||||
import cn.code.nl.module.wms.controller.admin.warehousestrategyconfig.vo.WarehouseStrategyConfigSaveReqVO;
|
||||
import cn.code.nl.module.wms.dal.dataobject.warehousestrategyconfig.WarehouseStrategyConfigDO;
|
||||
import cn.code.nl.module.wms.dal.mysql.warehousestrategyconfig.WarehouseStrategyConfigMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.code.nl.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.code.nl.module.wms.enums.ErrorCodeConstants.WAREHOUSE_STRATEGY_CONFIG_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 仓储策略配置 Service 实现类
|
||||
*
|
||||
* @author 诺力管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class WarehouseStrategyConfigServiceImpl implements WarehouseStrategyConfigService {
|
||||
|
||||
@Resource
|
||||
private WarehouseStrategyConfigMapper warehouseStrategyConfigMapper;
|
||||
|
||||
@Override
|
||||
public Long createWarehouseStrategyConfig(WarehouseStrategyConfigSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
WarehouseStrategyConfigDO warehouseStrategyConfig = BeanUtils.toBean(createReqVO, WarehouseStrategyConfigDO.class);
|
||||
warehouseStrategyConfigMapper.insert(warehouseStrategyConfig);
|
||||
|
||||
// 返回
|
||||
return warehouseStrategyConfig.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWarehouseStrategyConfig(WarehouseStrategyConfigSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateWarehouseStrategyConfigExists(updateReqVO.getId());
|
||||
// 更新
|
||||
WarehouseStrategyConfigDO updateObj = BeanUtils.toBean(updateReqVO, WarehouseStrategyConfigDO.class);
|
||||
warehouseStrategyConfigMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWarehouseStrategyConfig(Long id) {
|
||||
// 校验存在
|
||||
validateWarehouseStrategyConfigExists(id);
|
||||
// 删除
|
||||
warehouseStrategyConfigMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWarehouseStrategyConfigListByIds(List<Long> ids) {
|
||||
// 删除
|
||||
warehouseStrategyConfigMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
private void validateWarehouseStrategyConfigExists(Long id) {
|
||||
if (warehouseStrategyConfigMapper.selectById(id) == null) {
|
||||
throw exception(WAREHOUSE_STRATEGY_CONFIG_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WarehouseStrategyConfigDO getWarehouseStrategyConfig(Long id) {
|
||||
return warehouseStrategyConfigMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<WarehouseStrategyConfigDO> getWarehouseStrategyConfigPage(WarehouseStrategyConfigPageReqVO pageReqVO) {
|
||||
return warehouseStrategyConfigMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WarehouseStrategyConfigDO> getWarehouseStrategyConfigList() {
|
||||
return warehouseStrategyConfigMapper.selectList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -75,11 +75,6 @@ spring:
|
||||
# password: 123456 # 密码,建议生产环境开启
|
||||
|
||||
--- #################### MQ 消息队列相关配置 ####################
|
||||
|
||||
# rocketmq 配置项,对应 RocketMQProperties 配置类
|
||||
rocketmq:
|
||||
name-server: 127.0.0.1:9876 # RocketMQ Namesrv
|
||||
|
||||
spring:
|
||||
# RabbitMQ 配置项,对应 RabbitProperties 配置类
|
||||
rabbitmq:
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
--- #################### MQ 消息队列相关配置 ####################
|
||||
# rocketmq 配置项,对应 RocketMQProperties 配置类
|
||||
rocketmq:
|
||||
name-server: 127.0.0.1:9876
|
||||
consumer:
|
||||
wms-task-operate:
|
||||
group: wms-task-status-change-dev-group
|
||||
topic: wms-task-status-change-dev-topic
|
||||
@@ -0,0 +1,8 @@
|
||||
--- #################### MQ 消息队列相关配置 ####################
|
||||
# rocketmq 配置项,对应 RocketMQProperties 配置类
|
||||
rocketmq:
|
||||
name-server: 127.0.0.1:9876
|
||||
consumer:
|
||||
wms-task-operate:
|
||||
group: wms-task-status-change-test-group
|
||||
topic: wms-task-status-change-test-topic
|
||||
@@ -13,6 +13,7 @@ spring:
|
||||
import:
|
||||
- optional:classpath:application-${spring.profiles.active}.yaml # 加载【本地】配置
|
||||
- optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml # 加载【Nacos】的配置
|
||||
- optional:classpath:application-mq-${spring.profiles.active}.yaml # 加载 MQ 配置
|
||||
|
||||
# Servlet 配置
|
||||
servlet:
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.code.nl.module.wms.dal.mysql.warehousestrategy.WarehouseStrategyMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.code.nl.module.wms.dal.mysql.warehousestrategyconfig.WarehouseStrategyConfigMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user