feat:策略
This commit is contained in:
@@ -4,4 +4,10 @@ import cn.code.nl.framework.common.exception.ErrorCode;
|
||||
|
||||
public interface ErrorCodeConstants {
|
||||
ErrorCode BSREAL_STOR_ATTR_NOT_EXISTS = new ErrorCode(1, "实物库属性不存在");
|
||||
|
||||
|
||||
// ================ 仓储策略相关错误码 =================
|
||||
ErrorCode WAREHOUSE_STRATEGY_CONFIG_NOT_EXISTS = new ErrorCode(6_000_1, "仓储策略配置不存在");
|
||||
|
||||
ErrorCode WAREHOUSE_STRATEGY_NOT_EXISTS = new ErrorCode(6_000_2, "出入库策略不存在");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package cn.code.nl.module.wms.controller.admin.warehousestrategy;
|
||||
|
||||
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 = "获得出入库策略分页")
|
||||
@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,47 @@
|
||||
package cn.code.nl.module.wms.controller.admin.warehousestrategy.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 WarehouseStrategyRespVO {
|
||||
|
||||
@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("创建者")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@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,104 @@
|
||||
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("/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,67 @@
|
||||
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 {
|
||||
|
||||
@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,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,35 @@
|
||||
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 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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,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,62 @@
|
||||
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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
@@ -0,0 +1,58 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace WmsWarehouseStrategyApi {
|
||||
/** 出入库策略信息 */
|
||||
export interface WarehouseStrategy {
|
||||
sectionCode?: string; // 库区编码
|
||||
strategy?: string; // 规则
|
||||
strategyType: string; // 策略类型
|
||||
description: string; // 描述
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询出入库策略分页 */
|
||||
export function getWarehouseStrategyPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<WmsWarehouseStrategyApi.WarehouseStrategy>>(
|
||||
'/wms/warehouse-strategy/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询出入库策略详情 */
|
||||
export function getWarehouseStrategy(id: number) {
|
||||
return requestClient.get<WmsWarehouseStrategyApi.WarehouseStrategy>(
|
||||
`/wms/warehouse-strategy/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增出入库策略 */
|
||||
export function createWarehouseStrategy(data: WmsWarehouseStrategyApi.WarehouseStrategy) {
|
||||
return requestClient.post('/wms/warehouse-strategy/create', data);
|
||||
}
|
||||
|
||||
/** 修改出入库策略 */
|
||||
export function updateWarehouseStrategy(data: WmsWarehouseStrategyApi.WarehouseStrategy) {
|
||||
return requestClient.put('/wms/warehouse-strategy/update', data);
|
||||
}
|
||||
|
||||
/** 删除出入库策略 */
|
||||
export function deleteWarehouseStrategy(id: number) {
|
||||
return requestClient.delete(`/wms/warehouse-strategy/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除出入库策略 */
|
||||
export function deleteWarehouseStrategyList(ids: number[]) {
|
||||
return requestClient.delete(
|
||||
`/wms/warehouse-strategy/delete-list?ids=${ids.join(',')}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出出入库策略 */
|
||||
export function exportWarehouseStrategy(params: any) {
|
||||
return requestClient.download('/wms/warehouse-strategy/export-excel', { params });
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace WmsWarehouseStrategyConfigApi {
|
||||
/** 仓储策略配置信息 */
|
||||
export interface WarehouseStrategyConfig {
|
||||
id?: string;
|
||||
strategyCode?: string; // 策略编码
|
||||
strategyName?: string; // 策略名称
|
||||
strategyType?: string; // 策略类型
|
||||
classType?: string; // 类处理类型
|
||||
param?: string; // 处理类
|
||||
remark: string; // 描述
|
||||
isUsed: boolean; // 是否启用
|
||||
ban: boolean; // 禁止操作
|
||||
formData: string; // 限定参数
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询仓储策略配置分页 */
|
||||
export function getWarehouseStrategyConfigPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>>(
|
||||
'/wms/warehouse-strategy-config/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询仓储策略配置详情 */
|
||||
export function getWarehouseStrategyConfig(id: number) {
|
||||
return requestClient.get<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>(
|
||||
`/wms/warehouse-strategy-config/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增仓储策略配置 */
|
||||
export function createWarehouseStrategyConfig(data: WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig) {
|
||||
return requestClient.post('/wms/warehouse-strategy-config/create', data);
|
||||
}
|
||||
|
||||
/** 修改仓储策略配置 */
|
||||
export function updateWarehouseStrategyConfig(data: WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig) {
|
||||
return requestClient.put('/wms/warehouse-strategy-config/update', data);
|
||||
}
|
||||
|
||||
/** 删除仓储策略配置 */
|
||||
export function deleteWarehouseStrategyConfig(id: number) {
|
||||
return requestClient.delete(`/wms/warehouse-strategy-config/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除仓储策略配置 */
|
||||
export function deleteWarehouseStrategyConfigList(ids: number[]) {
|
||||
return requestClient.delete(
|
||||
`/wms/warehouse-strategy-config/delete-list?ids=${ids.join(',')}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出仓储策略配置 */
|
||||
export function exportWarehouseStrategyConfig(params: any) {
|
||||
return requestClient.download('/wms/warehouse-strategy-config/export-excel', { params });
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { WmsWarehouseStrategyApi } from '#/api/wms/warehousestrategy';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
import {getDictOptions} from "@vben/hooks";
|
||||
import {DICT_TYPE} from "@vben/constants";
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sectionCode',
|
||||
label: '库区编码',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入库区编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyType',
|
||||
label: '策略类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.WMS_OUT_IN_STRATEGY_TYPE),
|
||||
placeholder: '请选择策略类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategy',
|
||||
label: '规则',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入规则',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'description',
|
||||
label: '描述',
|
||||
component: 'TextArea',
|
||||
componentProps: {
|
||||
placeholder: '请输入描述',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'sectionCode',
|
||||
label: '库区编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入库区编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategy',
|
||||
label: '规则',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入规则',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyType',
|
||||
label: '策略类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.WMS_STRATEGY_TYPE),
|
||||
placeholder: '请选择策略类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<WmsWarehouseStrategyApi.WarehouseStrategy>['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
field: 'sectionCode',
|
||||
title: '库区编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'strategy',
|
||||
title: '规则',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'strategyType',
|
||||
title: '策略类型',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'description',
|
||||
title: '描述',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'creator',
|
||||
title: '创建者',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 120,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'updater',
|
||||
title: '更新者',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
minWidth: 120,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { WmsWarehouseStrategyApi } from '#/api/wms/warehousestrategy';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { confirm, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteWarehouseStrategy,
|
||||
deleteWarehouseStrategyList,
|
||||
exportWarehouseStrategy,
|
||||
getWarehouseStrategyPage,
|
||||
} from '#/api/wms/warehousestrategy';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建出入库策略 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑出入库策略 */
|
||||
function handleEdit(row: WmsWarehouseStrategyApi.WarehouseStrategy) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除出入库策略 */
|
||||
async function handleDelete(row: WmsWarehouseStrategyApi.WarehouseStrategy) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteWarehouseStrategy(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量删除出入库策略 */
|
||||
async function handleDeleteBatch() {
|
||||
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deletingBatch'),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteWarehouseStrategyList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
function handleRowCheckboxChange({
|
||||
records,
|
||||
}: {
|
||||
records: WmsWarehouseStrategyApi.WarehouseStrategy[];
|
||||
}) {
|
||||
checkedIds.value = records.map((item) => item.id!);
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportWarehouseStrategy(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '出入库策略.xls', source: data });
|
||||
}
|
||||
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getWarehouseStrategyPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<WmsWarehouseStrategyApi.WarehouseStrategy>,
|
||||
gridEvents: {
|
||||
checkboxAll: handleRowCheckboxChange,
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid table-title="出入库策略列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['出入库策略']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['wms:warehouse-strategy:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['wms:warehouse-strategy:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:warehouse-strategy:delete'],
|
||||
disabled: isEmpty(checkedIds),
|
||||
onClick: handleDeleteBatch,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['wms:warehouse-strategy:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:warehouse-strategy:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,82 @@
|
||||
<script lang="ts" setup>
|
||||
import type { WmsWarehouseStrategyApi } from '#/api/wms/warehousestrategy';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createWarehouseStrategy, getWarehouseStrategy, updateWarehouseStrategy } from '#/api/wms/warehousestrategy';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<WmsWarehouseStrategyApi.WarehouseStrategy>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', ['出入库策略'])
|
||||
: $t('ui.actionTitle.create', ['出入库策略']);
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as WmsWarehouseStrategyApi.WarehouseStrategy;
|
||||
try {
|
||||
await (formData.value?.id ? updateWarehouseStrategy(data) : createWarehouseStrategy(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<WmsWarehouseStrategyApi.WarehouseStrategy>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getWarehouseStrategy(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,282 @@
|
||||
import {type VbenFormSchema, z} from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { WmsWarehouseStrategyConfigApi } from '#/api/wms/warehousestrategyconfig';
|
||||
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
import {CommonStatusEnum, DICT_TYPE} from "@vben/constants";
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
const strategyTypeOptions = getDictOptions(DICT_TYPE.WMS_STRATEGY_TYPE, 'string');
|
||||
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyCode',
|
||||
label: '策略编码',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入策略编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyName',
|
||||
label: '策略名称',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入策略名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyType',
|
||||
label: '策略类型',
|
||||
rules: 'required',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: strategyTypeOptions,
|
||||
placeholder: '请选择策略类型',
|
||||
},
|
||||
defaultValue: strategyTypeOptions[0]?.value,
|
||||
},
|
||||
{
|
||||
fieldName: 'classType',
|
||||
label: '类处理类型',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请选择类处理类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'param',
|
||||
label: '参数',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入参数',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '描述',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入描述',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'isUsed',
|
||||
label: '是否启用',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||
},
|
||||
{
|
||||
fieldName: 'ban',
|
||||
label: '禁止操作',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.DISABLE),
|
||||
},
|
||||
{
|
||||
fieldName: 'formData',
|
||||
label: '限定参数',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入限定参数',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'strategyCode',
|
||||
label: '策略编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入策略编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyName',
|
||||
label: '策略名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入策略名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyType',
|
||||
label: '策略类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.WMS_STRATEGY_TYPE),
|
||||
placeholder: '请选择策略类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'classType',
|
||||
label: '类处理类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: [],
|
||||
placeholder: '请选择类处理类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'param',
|
||||
label: '处理类',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入处理类',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '描述',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入描述',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'isUsed',
|
||||
label: '是否启用',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: [],
|
||||
placeholder: '请选择是否启用',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
field: 'strategyCode',
|
||||
title: '策略编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'strategyName',
|
||||
title: '策略名称',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'strategyType',
|
||||
title: '策略类型',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.WMS_STRATEGY_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'classType',
|
||||
title: '类处理类型',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'param',
|
||||
title: '处理类',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '描述',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'isUsed',
|
||||
title: '是否启用',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_TRUE_FALSE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'ban',
|
||||
title: '是否禁止操作',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_TRUE_FALSE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'formData',
|
||||
title: '限定参数',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'creator',
|
||||
title: '创建者',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 120,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'updater',
|
||||
title: '更新者',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
minWidth: 120,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { WmsWarehouseStrategyConfigApi } from '#/api/wms/warehousestrategyconfig';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { confirm, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteWarehouseStrategyConfig,
|
||||
deleteWarehouseStrategyConfigList,
|
||||
exportWarehouseStrategyConfig,
|
||||
getWarehouseStrategyConfigPage,
|
||||
} from '#/api/wms/warehousestrategyconfig';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建仓储策略配置 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑仓储策略配置 */
|
||||
function handleEdit(row: WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除仓储策略配置 */
|
||||
async function handleDelete(row: WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteWarehouseStrategyConfig(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量删除仓储策略配置 */
|
||||
async function handleDeleteBatch() {
|
||||
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deletingBatch'),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteWarehouseStrategyConfigList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
function handleRowCheckboxChange({
|
||||
records,
|
||||
}: {
|
||||
records: WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig[];
|
||||
}) {
|
||||
checkedIds.value = records.map((item) => item.id!);
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportWarehouseStrategyConfig(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '仓储策略配置.xls', source: data });
|
||||
}
|
||||
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getWarehouseStrategyConfigPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>,
|
||||
gridEvents: {
|
||||
checkboxAll: handleRowCheckboxChange,
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid table-title="仓储策略配置列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['仓储策略配置']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['wms:warehouse-strategy-config:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['wms:warehouse-strategy-config:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:warehouse-strategy-config:delete'],
|
||||
disabled: isEmpty(checkedIds),
|
||||
onClick: handleDeleteBatch,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['wms:warehouse-strategy-config:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:warehouse-strategy-config:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,82 @@
|
||||
<script lang="ts" setup>
|
||||
import type { WmsWarehouseStrategyConfigApi } from '#/api/wms/warehousestrategyconfig';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createWarehouseStrategyConfig, getWarehouseStrategyConfig, updateWarehouseStrategyConfig } from '#/api/wms/warehousestrategyconfig';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', ['仓储策略配置'])
|
||||
: $t('ui.actionTitle.create', ['仓储策略配置']);
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig;
|
||||
try {
|
||||
await (formData.value?.id ? updateWarehouseStrategyConfig(data) : createWarehouseStrategyConfig(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getWarehouseStrategyConfig(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -4,7 +4,8 @@ const COMMON_DICT = {
|
||||
COMMON_STATUS: 'common_status',
|
||||
TERMINAL: 'terminal', // 终端
|
||||
DATE_INTERVAL: 'date_interval', // 数据间隔
|
||||
PRODUCT_AREA: 'product_area'
|
||||
PRODUCT_AREA: 'product_area',
|
||||
COMMON_TRUE_FALSE: 'common_true_false',
|
||||
} as const;
|
||||
|
||||
/** ========== SYSTEM - 系统模块 ========== */
|
||||
@@ -279,6 +280,8 @@ const WMS_DICT = {
|
||||
WMS_ORDER_STATUS: 'wms_order_status', // WMS 单据状态
|
||||
WMS_RECEIPT_ORDER_TYPE: 'wms_receipt_order_type', // WMS 入库单类型
|
||||
WMS_SHIPMENT_ORDER_TYPE: 'wms_shipment_order_type', // WMS 出库单类型
|
||||
WMS_STRATEGY_TYPE: 'wms_strategy_type', // WMS策略类型
|
||||
WMS_OUT_IN_STRATEGY_TYPE: 'wms_out_in_strategy_type', // WMS出入库策略类型
|
||||
} as const;
|
||||
|
||||
/** ========== TASK - 任务管理模块 ========== */
|
||||
|
||||
Reference in New Issue
Block a user