From 347d6cd62a33ae3362d456b08a192d91414c07f8 Mon Sep 17 00:00:00 2001 From: chenfang Date: Tue, 17 Oct 2023 08:57:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?ErrorCode=E4=BB=A3=E7=A0=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/win/module/wms/enums/ErrorCodeConstants.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java index d8886aef..525bd535 100644 --- a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java @@ -152,9 +152,15 @@ public interface ErrorCodeConstants { ErrorCode OWNER_CODE_NOT_EXISTS = new ErrorCode(1_000_055_002, "code不存在"); ErrorCode OWNER_SHORTNAME_NOT_EXISTS = new ErrorCode(1_000_055_003, "简称不存在"); ErrorCode OWNER_AVAILABLE_NOT_EXISTS = new ErrorCode(1_000_055_004, "是否可用不存在"); - - + //班次ErrorCode ErrorCode SHIFT_NOT_EXISTS = new ErrorCode(1_057_000_000, "班次不存在"); - + //班组ErrorCode ErrorCode TEAM_NOT_EXISTS = new ErrorCode(1_058_000_000, "班组不存在"); + //标签定义ErrorCode + ErrorCode LABLE_TYPE_NOT_EXISTS = new ErrorCode(1_000_059_000, "标签定义不存在"); + //条码片段ErrorCode + ErrorCode BARCODE_NOT_EXISTS = new ErrorCode(1_000_060_000, "条码片段不存在"); + //策略ErrorCode + ErrorCode STRATEGY_NOT_EXISTS = new ErrorCode(1_000_061_000, "策略不存在"); + } From c067f4e6e35c44238ede5daea7d5281d25361242 Mon Sep 17 00:00:00 2001 From: chenfang Date: Tue, 17 Oct 2023 11:34:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=9F=BA=E7=A1=80=E9=83=A8=E5=88=86=20=20?= =?UTF-8?q?=20=20=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/wms/enums/DictTypeConstants.java | 1 + .../module/wms/enums/ErrorCodeConstants.java | 9 + .../controller/barcode/BarcodeController.java | 138 ++++++++++++ .../controller/barcode/vo/BarcodeBaseVO.java | 61 +++++ .../barcode/vo/BarcodeCreateReqVO.java | 14 ++ .../controller/barcode/vo/BarcodeExcelVO.java | 53 +++++ .../barcode/vo/BarcodeExportReqVO.java | 46 ++++ .../barcode/vo/BarcodeImportExcelVo.java | 54 +++++ .../barcode/vo/BarcodePageReqVO.java | 51 +++++ .../controller/barcode/vo/BarcodeRespVO.java | 17 ++ .../barcode/vo/BarcodeUpdateReqVO.java | 20 ++ .../vo/DocumentsettingImportExcelVO.java | 1 - .../labeltype/LabeltypeController.java | 98 ++++++++ .../labeltype/vo/LabeltypeBaseVO.java | 77 +++++++ .../labeltype/vo/LabeltypeCreateReqVO.java | 12 + .../labeltype/vo/LabeltypeExcelVO.java | 69 ++++++ .../labeltype/vo/LabeltypeExportReqVO.java | 61 +++++ .../labeltype/vo/LabeltypeImportExcelVO.java | 70 ++++++ .../labeltype/vo/LabeltypePageReqVO.java | 64 ++++++ .../labeltype/vo/LabeltypeRespVO.java | 15 ++ .../labeltype/vo/LabeltypeUpdateReqVO.java | 18 ++ .../paramsetting/ParamsettingController.java | 2 + .../strategy/StrategyController.java | 99 ++++++++ .../strategy/vo/StrategyBaseVO.java | 43 ++++ .../strategy/vo/StrategyCreateReqVO.java | 12 + .../strategy/vo/StrategyExcelVO.java | 51 +++++ .../strategy/vo/StrategyExportReqVO.java | 44 ++++ .../strategy/vo/StrategyPageReqVO.java | 46 ++++ .../strategy/vo/StrategyRespVO.java | 19 ++ .../strategy/vo/StrategyUpdateReqVO.java | 12 + .../wms/convert/barcode/BarcodeConvert.java | 34 +++ .../convert/labeltype/LabeltypeConvert.java | 36 +++ .../wms/convert/strategy/StrategyConvert.java | 37 +++ .../wms/dal/dataobject/barcode/BarcodeDO.java | 76 +++++++ .../dal/dataobject/labeltype/LabeltypeDO.java | 96 ++++++++ .../dal/dataobject/strategy/StrategyDO.java | 113 ++++++++++ .../wms/dal/mysql/barcode/BarcodeMapper.java | 56 +++++ .../dal/mysql/labeltype/LabeltypeMapper.java | 65 ++++++ .../dal/mysql/strategy/StrategyMapper.java | 49 ++++ .../wms/service/barcode/BarcodeService.java | 73 ++++++ .../service/barcode/BarcodeServiceImpl.java | 198 ++++++++++++++++ .../service/labeltype/LabeltypeService.java | 75 +++++++ .../labeltype/LabeltypeServiceImpl.java | 85 +++++++ .../wms/service/strategy/StrategyService.java | 74 ++++++ .../service/strategy/StrategyServiceImpl.java | 85 +++++++ .../mapper/barcode/BarcodeMapper.xml | 12 + .../mapper/labeltype/LabeltypeMapper.xml | 12 + .../mapper/strategy/StrategyMapper.xml | 12 + .../strategy/StrategyServiceImplTest.java | 212 ++++++++++++++++++ 49 files changed, 2676 insertions(+), 1 deletion(-) create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/BarcodeController.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeBaseVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeCreateReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeExcelVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeExportReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeImportExcelVo.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodePageReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeRespVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeUpdateReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/LabeltypeController.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeBaseVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeCreateReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeExcelVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeExportReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeImportExcelVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypePageReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeRespVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeUpdateReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/StrategyController.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyBaseVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyCreateReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyExcelVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyExportReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyPageReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyRespVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyUpdateReqVO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/barcode/BarcodeConvert.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/labeltype/LabeltypeConvert.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/strategy/StrategyConvert.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/barcode/BarcodeDO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/labeltype/LabeltypeDO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/strategy/StrategyDO.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/barcode/BarcodeMapper.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/labeltype/LabeltypeMapper.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/strategy/StrategyMapper.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/barcode/BarcodeService.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/barcode/BarcodeServiceImpl.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/labeltype/LabeltypeService.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/labeltype/LabeltypeServiceImpl.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/strategy/StrategyService.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/strategy/StrategyServiceImpl.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/resources/mapper/barcode/BarcodeMapper.xml create mode 100644 win-module-wms/win-module-wms-biz/src/main/resources/mapper/labeltype/LabeltypeMapper.xml create mode 100644 win-module-wms/win-module-wms-biz/src/main/resources/mapper/strategy/StrategyMapper.xml create mode 100644 win-module-wms/win-module-wms-biz/src/test/java/com/win/module/wms/service/strategy/StrategyServiceImplTest.java diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/DictTypeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/DictTypeConstants.java index f1ed330e..9694eb63 100644 --- a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/DictTypeConstants.java +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/DictTypeConstants.java @@ -61,5 +61,6 @@ public interface DictTypeConstants { String OWNER_TYPE = "owner_type";//货主类型 String INTERFACE_TYPE = "interface_type";//接口类型 String REQUEST_MODE = "reqeust_mode";//申请模式 + String LABEL_TYPE = "label_type";//标签类型 } diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java index 525bd535..d33b5eb4 100644 --- a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java @@ -160,6 +160,15 @@ public interface ErrorCodeConstants { ErrorCode LABLE_TYPE_NOT_EXISTS = new ErrorCode(1_000_059_000, "标签定义不存在"); //条码片段ErrorCode ErrorCode BARCODE_NOT_EXISTS = new ErrorCode(1_000_060_000, "条码片段不存在"); + ErrorCode BARCODE_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_000_060_001, "导入条码片段不存在"); + ErrorCode BARCODE_CODE_EXISTS = new ErrorCode(1_000_060_002, "code已存在"); + ErrorCode BARCODE_CODE_NOT_EXISTS = new ErrorCode(1_000_060_003, "code不存在"); + ErrorCode BARCODE_ORDER_NOT_EXISTS = new ErrorCode(1_000_060_004, "顺序不存在"); + ErrorCode BARCODE_LENGTH_NOT_EXISTS = new ErrorCode(1_000_060_005, "长度不存在"); + ErrorCode BARCODE_PREFIX_LENGTH_NOT_EXISTS = new ErrorCode(1_000_060_006, "前缀长度不存在"); + ErrorCode BARCODE_ENTITY_PROPERTIES_NOT_EXISTS = new ErrorCode(1_000_060_007, "实体属性不存在"); + ErrorCode BARCODE_TRIM_END_NOT_EXISTS = new ErrorCode(1_000_060_008, "阶段尾部空格不存在"); + ErrorCode BARCODE_IS_ENCYPT_NOT_EXISTS = new ErrorCode(1_000_060_009, "是否加密不存在"); //策略ErrorCode ErrorCode STRATEGY_NOT_EXISTS = new ErrorCode(1_000_061_000, "策略不存在"); diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/BarcodeController.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/BarcodeController.java new file mode 100644 index 00000000..0ef2c4ba --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/BarcodeController.java @@ -0,0 +1,138 @@ +package com.win.module.wms.controller.barcode; + +import com.win.framework.common.pojo.CommonResult; +import com.win.framework.common.pojo.PageResult; +import com.win.framework.dict.core.util.DictFrameworkUtils; +import com.win.framework.excel.core.util.ExcelUtils; +import com.win.framework.operatelog.core.annotations.OperateLog; +import com.win.module.wms.controller.barcode.vo.*; +import com.win.module.wms.convert.barcode.BarcodeConvert; +import com.win.module.wms.dal.dataobject.barcode.BarcodeDO; +import com.win.module.wms.enums.DictTypeConstants; +import com.win.module.wms.service.barcode.BarcodeService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.*; + +import static com.win.framework.common.pojo.CommonResult.success; +import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +@Tag(name = "管理后台 - 条码片段") +@RestController +@RequestMapping("/label/barcode") +@Validated +public class BarcodeController { + + @Resource + private BarcodeService barcodeService; + + @PostMapping("/create") + @Operation(summary = "创建条码片段") + @PreAuthorize("@ss.hasPermission('label:barcode:create')") + public CommonResult createBarcode(@Valid @RequestBody BarcodeCreateReqVO createReqVO) { + return success(barcodeService.createBarcode(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新条码片段") + @PreAuthorize("@ss.hasPermission('label:barcode:update')") + public CommonResult updateBarcode(@Valid @RequestBody BarcodeUpdateReqVO updateReqVO) { + barcodeService.updateBarcode(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除条码片段") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('label:barcode:delete')") + public CommonResult deleteBarcode(@RequestParam("id") Long id) { + barcodeService.deleteBarcode(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得条码片段") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('label:barcode:query')") + public CommonResult getBarcode(@RequestParam("id") Long id) { + BarcodeDO barcode = barcodeService.getBarcode(id); + return success(BarcodeConvert.INSTANCE.convert(barcode)); + } + + @GetMapping("/list") + @Operation(summary = "获得条码片段列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('label:barcode:query')") + public CommonResult> getBarcodeList(@RequestParam("ids") Collection ids) { + List list = barcodeService.getBarcodeList(ids); + return success(BarcodeConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得条码片段分页") + @PreAuthorize("@ss.hasPermission('label:barcode:query')") + public CommonResult> getBarcodePage(@Valid BarcodePageReqVO pageVO) { + PageResult pageResult = barcodeService.getBarcodePage(pageVO); + return success(BarcodeConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出条码片段 Excel") + @PreAuthorize("@ss.hasPermission('label:barcode:export')") + @OperateLog(type = EXPORT) + public void exportBarcodeExcel(@Valid BarcodeExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = barcodeService.getBarcodeList(exportReqVO); + // 导出 Excel + List datas = BarcodeConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "条码片段.xls", "数据", BarcodeExcelVO.class, datas); + } + @GetMapping("/get-import-template") + @Operation(summary = "获得导入库区模板") + public void importTemplate(HttpServletResponse response) throws IOException { + // 手动创建导出 demo + List list = Arrays.asList(); + Map mapDropDown = new HashMap<>(); + String[] trimEnd = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(9, trimEnd); + String[] isEncypt = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(10, isEncypt); + // 输出 + ExcelUtils.write(response, "库区导入模板.xls", "库区列表", BarcodeImportExcelVo.class, list,mapDropDown); + } + + @PostMapping("/import") + @Operation(summary = "导入库区") + @Parameters({ + @Parameter(name = "file", description = "Excel 文件", required = true), + @Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"), + @Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true") + }) + @PreAuthorize("@ss.hasPermission('wms:barcode:import')") + public void importExcel(HttpServletResponse response, + @RequestParam("file") MultipartFile file, + @RequestParam(value = "mode") Integer mode, + @RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { + List list = ExcelUtils.read(file, BarcodeImportExcelVo.class); + List errorList = barcodeService.importBarcodeList(list, mode, updatePart); + Map returnMap = new HashMap<>(); + returnMap.put("errorCount", errorList.size()); + if(!errorList.isEmpty()) { + String url = ExcelUtils.writeLocalFile("库区导入错误数据" + LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) + ".xls", "错误列表", errorList); + returnMap.put("errorFile", url); + } + } +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeBaseVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeBaseVO.java new file mode 100644 index 00000000..9e683b12 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeBaseVO.java @@ -0,0 +1,61 @@ +package com.win.module.wms.controller.barcode.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * 条码片段 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class BarcodeBaseVO { + + @Schema(description = "id", example = "id") + private Long id; + + @Schema(description = "代码", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "代码不能为空") + private String code; + + @Schema(description = "名称", example = "张三") + private String name; + + @Schema(description = "描述", example = "你说的对") + private String description; + + @Schema(description = "顺序", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "顺序不能为空") + private Integer order; + + @Schema(description = "长度", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "长度不能为空") + private Integer length; + + @Schema(description = "前缀长度", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "前缀长度不能为空") + private Integer prefixLenght; + + @Schema(description = "前缀字符") + private String prefixChar; + + @Schema(description = "实体属性", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "实体属性不能为空") + private String entityProperties; + + @Schema(description = "加密方法") + private String encyptMethod; + + @Schema(description = "主表ID", example = "6060") + private Long masterId; + + @Schema(description = "截断尾部空格", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "截断尾部空格不能为空") + private String trimEnd; + + @Schema(description = "是否加密", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "是否加密不能为空") + private String isEncypt; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeCreateReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeCreateReqVO.java new file mode 100644 index 00000000..54c660c7 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeCreateReqVO.java @@ -0,0 +1,14 @@ +package com.win.module.wms.controller.barcode.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 条码片段创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class BarcodeCreateReqVO extends BarcodeBaseVO { + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeExcelVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeExcelVO.java new file mode 100644 index 00000000..7c73ee27 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeExcelVO.java @@ -0,0 +1,53 @@ +package com.win.module.wms.controller.barcode.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * 条码片段 Excel VO + * + * @author 超级管理员 + */ +@Data +public class BarcodeExcelVO { + + @ExcelProperty("id") + private Long id; + + @ExcelProperty("代码") + private String code; + + @ExcelProperty("名称") + private String name; + + @ExcelProperty("描述") + private String description; + + @ExcelProperty("顺序") + private Integer order; + + @ExcelProperty("长度") + private Integer length; + + @ExcelProperty("前缀长度") + private Integer prefixLenght; + + @ExcelProperty("前缀字符") + private String prefixChar; + + @ExcelProperty("实体属性") + private String entityProperties; + + @ExcelProperty("加密方法") + private String encyptMethod; + + @ExcelProperty("主表ID") + private Long masterId; + + @ExcelProperty("截断尾部空格") + private String trimEnd; + + @ExcelProperty("是否加密") + private String isEncypt; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeExportReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeExportReqVO.java new file mode 100644 index 00000000..3e3d2b37 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeExportReqVO.java @@ -0,0 +1,46 @@ +package com.win.module.wms.controller.barcode.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - 条码片段 Excel 导出 Request VO,参数和 BarcodePageReqVO 是一致的") +@Data +public class BarcodeExportReqVO { + + @Schema(description = "代码") + private String code; + + @Schema(description = "名称", example = "张三") + private String name; + + @Schema(description = "描述", example = "你说的对") + private String description; + + @Schema(description = "顺序") + private Integer order; + + @Schema(description = "长度") + private Integer length; + + @Schema(description = "前缀长度") + private Integer prefixLenght; + + @Schema(description = "前缀字符") + private String prefixChar; + + @Schema(description = "实体属性") + private String entityProperties; + + @Schema(description = "加密方法") + private String encyptMethod; + + @Schema(description = "主表ID", example = "6060") + private Long masterId; + + @Schema(description = "截断尾部空格") + private String trimEnd; + + @Schema(description = "是否加密") + private String isEncypt; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeImportExcelVo.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeImportExcelVo.java new file mode 100644 index 00000000..19fe9381 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeImportExcelVo.java @@ -0,0 +1,54 @@ +package com.win.module.wms.controller.barcode.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.win.framework.excel.core.annotations.DictFormat; +import com.win.framework.excel.core.convert.DictConvert; +import com.win.module.wms.enums.DictTypeConstants; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 +public class BarcodeImportExcelVo { + + @ExcelProperty("代码") + private String code; + + @ExcelProperty("名称") + private String name; + + @ExcelProperty("描述") + private String description; + + @ExcelProperty("顺序") + private Integer order; + + @ExcelProperty("长度") + private Integer length; + + @ExcelProperty("前缀长度") + private Integer prefixLenght; + + @ExcelProperty("前缀字符") + private String prefixChar; + + @ExcelProperty("实体属性") + private String entityProperties; + + @ExcelProperty("加密方法") + private String encyptMethod; + + @ExcelProperty(value = "截断尾部空格", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TRUE_FALSE) + private String trimEnd; + + @ExcelProperty(value = "是否加密", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TRUE_FALSE) + private String isEncypt; +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodePageReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodePageReqVO.java new file mode 100644 index 00000000..8a92876d --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodePageReqVO.java @@ -0,0 +1,51 @@ +package com.win.module.wms.controller.barcode.vo; + +import com.win.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 条码片段分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class BarcodePageReqVO extends PageParam { + + @Schema(description = "代码") + private String code; + + @Schema(description = "名称", example = "张三") + private String name; + + @Schema(description = "描述", example = "你说的对") + private String description; + + @Schema(description = "顺序") + private Integer order; + + @Schema(description = "长度") + private Integer length; + + @Schema(description = "前缀长度") + private Integer prefixLenght; + + @Schema(description = "前缀字符") + private String prefixChar; + + @Schema(description = "实体属性") + private String entityProperties; + + @Schema(description = "加密方法") + private String encyptMethod; + + @Schema(description = "主表ID", example = "6060") + private Long masterId; + + @Schema(description = "截断尾部空格") + private String trimEnd; + + @Schema(description = "是否加密") + private String isEncypt; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeRespVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeRespVO.java new file mode 100644 index 00000000..d3463ce3 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeRespVO.java @@ -0,0 +1,17 @@ +package com.win.module.wms.controller.barcode.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 条码片段 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class BarcodeRespVO extends BarcodeBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21607") + private Long id; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeUpdateReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeUpdateReqVO.java new file mode 100644 index 00000000..fd9870f3 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/barcode/vo/BarcodeUpdateReqVO.java @@ -0,0 +1,20 @@ +package com.win.module.wms.controller.barcode.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 条码片段更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class BarcodeUpdateReqVO extends BarcodeBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21607") + @NotNull(message = "id不能为空") + private Long id; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/documentsetting/vo/DocumentsettingImportExcelVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/documentsetting/vo/DocumentsettingImportExcelVO.java index c63687df..1479f68e 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/documentsetting/vo/DocumentsettingImportExcelVO.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/documentsetting/vo/DocumentsettingImportExcelVO.java @@ -34,7 +34,6 @@ public class DocumentsettingImportExcelVO { private String type; @ExcelProperty("业务类型") -// TODO 可能是字典 有带商榷 private String businessType; @ExcelProperty("号码前缀") diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/LabeltypeController.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/LabeltypeController.java new file mode 100644 index 00000000..5a5eff8d --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/LabeltypeController.java @@ -0,0 +1,98 @@ +package com.win.module.wms.controller.labeltype; + +import com.win.framework.common.pojo.CommonResult; +import com.win.framework.common.pojo.PageResult; +import com.win.framework.excel.core.util.ExcelUtils; +import com.win.framework.operatelog.core.annotations.OperateLog; +import com.win.module.wms.controller.labeltype.vo.*; +import com.win.module.wms.convert.labeltype.LabeltypeConvert; +import com.win.module.wms.dal.dataobject.labeltype.LabeltypeDO; +import com.win.module.wms.service.labeltype.LabeltypeService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import static com.win.framework.common.pojo.CommonResult.success; +import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +@Tag(name = "管理后台 - 标签定义") +@RestController +@RequestMapping("/wms/labeltype") +@Validated +public class LabeltypeController { + + @Resource + private LabeltypeService labeltypeService; + + @PostMapping("/create") + @Operation(summary = "创建标签定义") + @PreAuthorize("@ss.hasPermission('wms:labeltypeService:create')") + public CommonResult createlabeltype(@Valid @RequestBody LabeltypeCreateReqVO createReqVO) { + return success(labeltypeService.createLabeltype(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新标签定义") + @PreAuthorize("@ss.hasPermission('wms:LabeltypeService:update')") + public CommonResult updatetLabeltype(@Valid @RequestBody LabeltypeUpdateReqVO updateReqVO) { + labeltypeService.updateLabeltype(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除标签定义") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('wms:labeltypeService:delete')") + public CommonResult deleteLabeltype(@RequestParam("id") Long id) { + labeltypeService.deleteLabeltype(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得标签定义") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('wms:labeltypeService:query')") + public CommonResult gettype(@RequestParam("id") Long id) { + LabeltypeDO labeltypeDO = labeltypeService.getLabeltype(id); + return success(LabeltypeConvert.INSTANCE.convert(labeltypeDO)); + } + + @GetMapping("/list") + @Operation(summary = "获得标签定义列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('wms:labeltypeService:query')") + public CommonResult> getLabeltypeList(@RequestParam("ids") Collection ids) { + List list = labeltypeService.getLabeltypeList(ids); + return success(LabeltypeConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得标签定义分页") + @PreAuthorize("@ss.hasPermission('wms:labeltypeService:query')") + public CommonResult> gettypePage(@Valid LabeltypePageReqVO pageVO) { + PageResult pageResult = labeltypeService.getLabeltypePage(pageVO); + return success(LabeltypeConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出标签定义 Excel") + @PreAuthorize("@ss.hasPermission('wms:labeltypeService:export')") + @OperateLog(type = EXPORT) + public void exporttypeExcel(@Valid LabeltypeExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = labeltypeService.getLabeltypeList(exportReqVO); + // 导出 Excel + List datas = LabeltypeConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "标签定义.xls", "数据", LabeltypeExcelVO.class, datas); + } +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeBaseVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeBaseVO.java new file mode 100644 index 00000000..87a638e7 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeBaseVO.java @@ -0,0 +1,77 @@ +package com.win.module.wms.controller.labeltype.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import javax.validation.constraints.*; + +/** + * 标签定义 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class LabeltypeBaseVO { + + @Schema(description = "id", example = "id") + private Long id; + + @Schema(description = "标签类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @NotNull(message = "标签类型不能为空") + private String labelType; + + @Schema(description = "描述", example = "你猜") + private String description; + + @Schema(description = "数据协议", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "数据协议不能为空") + private String dataProtocol; + + @Schema(description = "拆分方法", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "拆分方法不能为空") + private String splitMehod; + + @Schema(description = "数据头") + private String header; + + @Schema(description = "版本号") + private String version; + + @Schema(description = "分隔符") + private String separators; + + @Schema(description = "校验方法", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "校验方法不能为空") + private String validateMethod; + + @Schema(description = "校验数") + private Integer validateNumber; + + @Schema(description = "加密方法") + private String encyptEthod; + + @Schema(description = "压缩方法") + private String compressMethod; + + @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") + @NotNull(message = "模板名称不能为空") + private String templateName; + + @Schema(description = "模板文件") + private String templateFile; + + @Schema(description = "List") + private String barcodeSegments; + + @Schema(description = "标签代码", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "标签代码不能为空") + private String labelCode; + + @Schema(description = "是否加密", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "是否加密不能为空") + private String isEncypt; + + @Schema(description = "是否压缩", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "是否压缩不能为空") + private String isCompress; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeCreateReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeCreateReqVO.java new file mode 100644 index 00000000..e703b639 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeCreateReqVO.java @@ -0,0 +1,12 @@ +package com.win.module.wms.controller.labeltype.vo; + +import lombok.*; +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "管理后台 - 标签定义创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class LabeltypeCreateReqVO extends LabeltypeBaseVO { + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeExcelVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeExcelVO.java new file mode 100644 index 00000000..65f5a0b1 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeExcelVO.java @@ -0,0 +1,69 @@ +package com.win.module.wms.controller.labeltype.vo; + +import lombok.*; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 标签定义 Excel VO + * + * @author 超级管理员 + */ +@Data +public class LabeltypeExcelVO { + + @ExcelProperty("id") + private Long id; + + @ExcelProperty("标签类型") + private String labelType; + + @ExcelProperty("描述") + private String description; + + @ExcelProperty("数据协议") + private String dataProtocol; + + @ExcelProperty("拆分方法") + private String splitMehod; + + @ExcelProperty("数据头") + private String header; + + @ExcelProperty("版本号") + private String version; + + @ExcelProperty("分隔符") + private String separators; + + @ExcelProperty("校验方法") + private String validateMethod; + + @ExcelProperty("校验数") + private Integer validateNumber; + + @ExcelProperty("加密方法") + private String encyptEthod; + + @ExcelProperty("压缩方法") + private String compressMethod; + + @ExcelProperty("模板名称") + private String templateName; + + @ExcelProperty("模板文件") + private String templateFile; + + @ExcelProperty("List") + private String barcodeSegments; + + @ExcelProperty("标签代码") + private String labelCode; + + @ExcelProperty("是否加密") + private String isEncypt; + + @ExcelProperty("是否压缩") + private String isCompress; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeExportReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeExportReqVO.java new file mode 100644 index 00000000..17f76aad --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeExportReqVO.java @@ -0,0 +1,61 @@ +package com.win.module.wms.controller.labeltype.vo; + +import lombok.*; +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "管理后台 - 标签定义 Excel 导出 Request VO,参数和 LabeltypePageReqVO 是一致的") +@Data +public class LabeltypeExportReqVO { + + @Schema(description = "标签类型", example = "2") + private String labelType; + + @Schema(description = "描述", example = "你猜") + private String description; + + @Schema(description = "数据协议") + private String dataProtocol; + + @Schema(description = "拆分方法") + private String splitMehod; + + @Schema(description = "数据头") + private String header; + + @Schema(description = "版本号") + private String version; + + @Schema(description = "分隔符") + private String separators; + + @Schema(description = "校验方法") + private String validateMethod; + + @Schema(description = "校验数") + private Integer validateNumber; + + @Schema(description = "加密方法") + private String encyptEthod; + + @Schema(description = "压缩方法") + private String compressMethod; + + @Schema(description = "模板名称", example = "张三") + private String templateName; + + @Schema(description = "模板文件") + private String templateFile; + + @Schema(description = "List") + private String barcodeSegments; + + @Schema(description = "标签代码") + private String labelCode; + + @Schema(description = "是否加密") + private String isEncypt; + + @Schema(description = "是否压缩") + private String isCompress; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeImportExcelVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeImportExcelVO.java new file mode 100644 index 00000000..dc42b9f0 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeImportExcelVO.java @@ -0,0 +1,70 @@ +package com.win.module.wms.controller.labeltype.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.win.framework.excel.core.annotations.DictFormat; +import com.win.framework.excel.core.convert.DictConvert; +import com.win.module.wms.enums.DictTypeConstants; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 +public class LabeltypeImportExcelVO { + + @ExcelProperty(value = "标签类型", converter = DictConvert.class) + @DictFormat(DictTypeConstants.LABEL_TYPE) + private String labelType; + + @ExcelProperty("描述") + private String description; + + @ExcelProperty("数据协议") + private String dataProtocol; + + @ExcelProperty("数据头") + private String header; + + @ExcelProperty("版本号") + private String version; + + @ExcelProperty("分隔符") + private String separators; + + @ExcelProperty("校验方法") + private String validateMethod; + + @ExcelProperty("校验数") + private Integer validateNumber; + + @ExcelProperty("加密方法") + private String encyptEthod; + + @ExcelProperty("压缩方法") + private String compressMethod; + + @ExcelProperty("模板名称") + private String templateName; + + @ExcelProperty("模板文件") + private String templateFile; + + @ExcelProperty("List") + private String barcodeSegments; + + @ExcelProperty("标签代码") + private Integer labelCode; + + @ExcelProperty(value = "是否加密", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TRUE_FALSE) + private String isEncypt; + + @ExcelProperty(value = "是否压缩", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TRUE_FALSE) + private String isCompress; +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypePageReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypePageReqVO.java new file mode 100644 index 00000000..ea236156 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypePageReqVO.java @@ -0,0 +1,64 @@ +package com.win.module.wms.controller.labeltype.vo; + +import lombok.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.win.framework.common.pojo.PageParam; + +@Schema(description = "管理后台 - 标签定义分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class LabeltypePageReqVO extends PageParam { + + @Schema(description = "标签类型", example = "2") + private String labelType; + + @Schema(description = "描述", example = "你猜") + private String description; + + @Schema(description = "数据协议") + private String dataProtocol; + + @Schema(description = "拆分方法") + private String splitMehod; + + @Schema(description = "数据头") + private String header; + + @Schema(description = "版本号") + private String version; + + @Schema(description = "分隔符") + private String separators; + + @Schema(description = "校验方法") + private String validateMethod; + + @Schema(description = "校验数") + private Integer validateNumber; + + @Schema(description = "加密方法") + private String encyptEthod; + + @Schema(description = "压缩方法") + private String compressMethod; + + @Schema(description = "模板名称", example = "张三") + private String templateName; + + @Schema(description = "模板文件") + private String templateFile; + + @Schema(description = "List") + private String barcodeSegments; + + @Schema(description = "标签代码") + private String labelCode; + + @Schema(description = "是否加密") + private String isEncypt; + + @Schema(description = "是否压缩") + private String isCompress; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeRespVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeRespVO.java new file mode 100644 index 00000000..2c289263 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeRespVO.java @@ -0,0 +1,15 @@ +package com.win.module.wms.controller.labeltype.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +@Schema(description = "管理后台 - 标签定义 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class LabeltypeRespVO extends LabeltypeBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "5848") + private Long id; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeUpdateReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeUpdateReqVO.java new file mode 100644 index 00000000..81d7c331 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/labeltype/vo/LabeltypeUpdateReqVO.java @@ -0,0 +1,18 @@ +package com.win.module.wms.controller.labeltype.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 标签定义更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class LabeltypeUpdateReqVO extends LabeltypeBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "5848") + @NotNull(message = "id不能为空") + private Long id; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/paramsetting/ParamsettingController.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/paramsetting/ParamsettingController.java index 8256891c..ae98a304 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/paramsetting/ParamsettingController.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/paramsetting/ParamsettingController.java @@ -106,6 +106,8 @@ public class ParamsettingController { // 手动创建导出 demo List list = Arrays.asList(); Map mapDropDown = new HashMap<>(); + String[] usableOpeartors = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.STRATEGY_PARAM_OPEARTOR); + mapDropDown.put(3, usableOpeartors); String[] currency = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.CURRENCY); mapDropDown.put(11, currency); String[] type = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.OWNER_TYPE); diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/StrategyController.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/StrategyController.java new file mode 100644 index 00000000..30720556 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/StrategyController.java @@ -0,0 +1,99 @@ +package com.win.module.wms.controller.strategy; + +import com.win.framework.common.pojo.CommonResult; +import com.win.framework.common.pojo.PageResult; +import com.win.framework.excel.core.util.ExcelUtils; +import com.win.framework.operatelog.core.annotations.OperateLog; +import com.win.module.wms.controller.strategy.vo.*; +import com.win.module.wms.convert.strategy.StrategyConvert; +import com.win.module.wms.dal.dataobject.strategy.StrategyDO; +import com.win.module.wms.service.strategy.StrategyService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import static com.win.framework.common.pojo.CommonResult.success; +import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +@Tag(name = "管理后台 - 策略") +@RestController +@RequestMapping("/wms/strategy") +@Validated +public class StrategyController { + + @Resource + private StrategyService strategyService; + + @PostMapping("/create") + @Operation(summary = "创建策略") + @PreAuthorize("@ss.hasPermission('wms:strategy:create')") + public CommonResult createStrategy(@Valid @RequestBody StrategyCreateReqVO createReqVO) { + return success(strategyService.createStrategy(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新策略") + @PreAuthorize("@ss.hasPermission('wms:strategy:update')") + public CommonResult updateStrategy(@Valid @RequestBody StrategyUpdateReqVO updateReqVO) { + strategyService.updateStrategy(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除策略") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('wms:strategy:delete')") + public CommonResult deleteStrategy(@RequestParam("id") Long id) { + strategyService.deleteStrategy(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得策略") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('wms:strategy:query')") + public CommonResult getStrategy(@RequestParam("id") Long id) { + StrategyDO strategy = strategyService.getStrategy(id); + return success(StrategyConvert.INSTANCE.convert(strategy)); + } + + @GetMapping("/list") + @Operation(summary = "获得策略列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('wms:strategy:query')") + public CommonResult> getStrategyList(@RequestParam("ids") Collection ids) { + List list = strategyService.getStrategyList(ids); + return success(StrategyConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得策略分页") + @PreAuthorize("@ss.hasPermission('wms:strategy:query')") + public CommonResult> getStrategyPage(@Valid StrategyPageReqVO pageVO) { + PageResult pageResult = strategyService.getStrategyPage(pageVO); + return success(StrategyConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出策略 Excel") + @PreAuthorize("@ss.hasPermission('wms:strategy:export')") + @OperateLog(type = EXPORT) + public void exportStrategyExcel(@Valid StrategyExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = strategyService.getStrategyList(exportReqVO); + // 导出 Excel + List datas = StrategyConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "策略.xls", "数据", StrategyExcelVO.class, datas); + } + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyBaseVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyBaseVO.java new file mode 100644 index 00000000..94b2ba5e --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyBaseVO.java @@ -0,0 +1,43 @@ +package com.win.module.wms.controller.strategy.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * 策略 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class StrategyBaseVO { + + @Schema(description = "id", example = "id") + private Long id; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "代码", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "代码不能为空") + private String code; + + @Schema(description = "名称") + private String name; + + @Schema(description = "描述") + private String description; + + @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "类型不能为空") + private String type; + + @Schema(description = "优先级", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "优先级不能为空") + private Integer priority; + + @Schema(description = "是否生效", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "是否生效不能为空") + private String isActive; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyCreateReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyCreateReqVO.java new file mode 100644 index 00000000..ab3954b3 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyCreateReqVO.java @@ -0,0 +1,12 @@ +package com.win.module.wms.controller.strategy.vo; + +import lombok.*; +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "管理后台 - 策略创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class StrategyCreateReqVO extends StrategyBaseVO { + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyExcelVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyExcelVO.java new file mode 100644 index 00000000..8a71061e --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyExcelVO.java @@ -0,0 +1,51 @@ +package com.win.module.wms.controller.strategy.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.win.framework.excel.core.annotations.DictFormat; +import com.win.framework.excel.core.convert.DictConvert; + + +/** + * 策略 Excel VO + * + * @author 超级管理员 + */ +@Data +public class StrategyExcelVO { + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private LocalDateTime creationTime; + + @ExcelProperty("创建者ID") + private String creatorId; + + @ExcelProperty("代码") + private String code; + + @ExcelProperty("名称") + private String name; + + @ExcelProperty("描述") + private String description; + + @ExcelProperty(value = "类型", converter = DictConvert.class) + @DictFormat("strategy_type") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private String type; + + @ExcelProperty("优先级") + private Integer priority; + + @ExcelProperty("是否生效") + private String isActive; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyExportReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyExportReqVO.java new file mode 100644 index 00000000..66184c23 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyExportReqVO.java @@ -0,0 +1,44 @@ +package com.win.module.wms.controller.strategy.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.win.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 策略 Excel 导出 Request VO,参数和 StrategyPageReqVO 是一致的") +@Data +public class StrategyExportReqVO { + + @Schema(description = "备注") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] creationTime; + + @Schema(description = "创建者ID") + private String creatorId; + + @Schema(description = "代码") + private String code; + + @Schema(description = "名称") + private String name; + + @Schema(description = "描述") + private String description; + + @Schema(description = "类型") + private String type; + + @Schema(description = "优先级") + private Integer priority; + + @Schema(description = "是否生效") + private String isActive; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyPageReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyPageReqVO.java new file mode 100644 index 00000000..46180072 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyPageReqVO.java @@ -0,0 +1,46 @@ +package com.win.module.wms.controller.strategy.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.win.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 策略分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class StrategyPageReqVO extends PageParam { + + @Schema(description = "备注") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] creationTime; + + @Schema(description = "创建者ID") + private String creatorId; + + @Schema(description = "代码") + private String code; + + @Schema(description = "名称") + private String name; + + @Schema(description = "描述") + private String description; + + @Schema(description = "类型") + private String type; + + @Schema(description = "优先级") + private Integer priority; + + @Schema(description = "是否生效") + private String isActive; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyRespVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyRespVO.java new file mode 100644 index 00000000..22403c5f --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyRespVO.java @@ -0,0 +1,19 @@ +package com.win.module.wms.controller.strategy.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 策略 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class StrategyRespVO extends StrategyBaseVO { + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime creationTime; + + @Schema(description = "创建者ID", requiredMode = Schema.RequiredMode.REQUIRED) + private String creatorId; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyUpdateReqVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyUpdateReqVO.java new file mode 100644 index 00000000..0a730663 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/strategy/vo/StrategyUpdateReqVO.java @@ -0,0 +1,12 @@ +package com.win.module.wms.controller.strategy.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +@Schema(description = "管理后台 - 策略更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class StrategyUpdateReqVO extends StrategyBaseVO { + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/barcode/BarcodeConvert.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/barcode/BarcodeConvert.java new file mode 100644 index 00000000..48a51e43 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/barcode/BarcodeConvert.java @@ -0,0 +1,34 @@ +package com.win.module.wms.convert.barcode; + +import com.win.framework.common.pojo.PageResult; +import com.win.module.wms.controller.barcode.vo.*; +import com.win.module.wms.dal.dataobject.barcode.BarcodeDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 条码片段 Convert + * + * @author 超级管理员 + */ +@Mapper +public interface BarcodeConvert { + + BarcodeConvert INSTANCE = Mappers.getMapper(BarcodeConvert.class); + + BarcodeDO convert(BarcodeCreateReqVO bean); + + BarcodeDO convert(BarcodeUpdateReqVO bean); + + BarcodeRespVO convert(BarcodeDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + + BarcodeDO convert(BarcodeImportExcelVo barcode); +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/labeltype/LabeltypeConvert.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/labeltype/LabeltypeConvert.java new file mode 100644 index 00000000..337ca086 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/labeltype/LabeltypeConvert.java @@ -0,0 +1,36 @@ +package com.win.module.wms.convert.labeltype; + +import com.win.framework.common.pojo.PageResult; +import com.win.module.wms.dal.dataobject.labeltype.LabeltypeDO; +import com.win.module.wms.controller.labeltype.vo.LabeltypeCreateReqVO; +import com.win.module.wms.controller.labeltype.vo.LabeltypeExcelVO; +import com.win.module.wms.controller.labeltype.vo.LabeltypeRespVO; +import com.win.module.wms.controller.labeltype.vo.LabeltypeUpdateReqVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 标签定义 Convert + * + * @author 超级管理员 + */ +@Mapper +public interface LabeltypeConvert { + + LabeltypeConvert INSTANCE = Mappers.getMapper(LabeltypeConvert.class); + + LabeltypeDO convert(LabeltypeCreateReqVO bean); + + LabeltypeDO convert(LabeltypeUpdateReqVO bean); + + LabeltypeRespVO convert(LabeltypeDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/strategy/StrategyConvert.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/strategy/StrategyConvert.java new file mode 100644 index 00000000..e132bc43 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/strategy/StrategyConvert.java @@ -0,0 +1,37 @@ +package com.win.module.wms.convert.strategy; + +import java.util.*; + +import com.win.framework.common.pojo.PageResult; + +import com.win.module.wms.controller.strategy.vo.StrategyCreateReqVO; +import com.win.module.wms.controller.strategy.vo.StrategyExcelVO; +import com.win.module.wms.controller.strategy.vo.StrategyRespVO; +import com.win.module.wms.controller.strategy.vo.StrategyUpdateReqVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import com.win.module.wms.dal.dataobject.strategy.StrategyDO; + +/** + * 策略 Convert + * + * @author 超级管理员 + */ +@Mapper +public interface StrategyConvert { + + StrategyConvert INSTANCE = Mappers.getMapper(StrategyConvert.class); + + StrategyDO convert(StrategyCreateReqVO bean); + + StrategyDO convert(StrategyUpdateReqVO bean); + + StrategyRespVO convert(StrategyDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/barcode/BarcodeDO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/barcode/BarcodeDO.java new file mode 100644 index 00000000..553ad2e6 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/barcode/BarcodeDO.java @@ -0,0 +1,76 @@ +package com.win.module.wms.dal.dataobject.barcode; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.win.framework.mybatis.core.dataobject.BaseDO; +import lombok.*; + +/** + * 条码片段 DO + * + * @author 超级管理员 + */ +@TableName("label_barcode") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BarcodeDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 代码 + */ + private String code; + /** + * 名称 + */ + private String name; + /** + * 描述 + */ + private String description; + /** + * 顺序 + */ + private Integer order; + /** + * 长度 + */ + private Integer length; + /** + * 前缀长度 + */ + private Integer prefixLenght; + /** + * 前缀字符 + */ + private String prefixChar; + /** + * 实体属性 + */ + private String entityProperties; + /** + * 加密方法 + */ + private String encyptMethod; + /** + * 主表ID + */ + private Long masterId; + /** + * 截断尾部空格 + */ + private String trimEnd; + /** + * 是否加密 + */ + private String isEncypt; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/labeltype/LabeltypeDO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/labeltype/LabeltypeDO.java new file mode 100644 index 00000000..2acb2c01 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/labeltype/LabeltypeDO.java @@ -0,0 +1,96 @@ +package com.win.module.wms.dal.dataobject.labeltype; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.win.framework.mybatis.core.dataobject.BaseDO; +import lombok.*; + +/** + * 标签定义 DO + * + * @author 超级管理员 + */ +@TableName("label_labeltype") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class LabeltypeDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 标签类型 + */ + private String labelType; + /** + * 描述 + */ + private String description; + /** + * 数据协议 + */ + private String dataProtocol; + /** + * 拆分方法 + */ + private String splitMehod; + /** + * 数据头 + */ + private String header; + /** + * 版本号 + */ + private String version; + /** + * 分隔符 + */ + private String separators; + /** + * 校验方法 + */ + private String validateMethod; + /** + * 校验数 + */ + private Integer validateNumber; + /** + * 加密方法 + */ + private String encyptEthod; + /** + * 压缩方法 + */ + private String compressMethod; + /** + * 模板名称 + */ + private String templateName; + /** + * 模板文件 + */ + private String templateFile; + /** + * List + */ + private String barcodeSegments; + /** + * 标签代码 + */ + private String labelCode; + /** + * 是否加密 + */ + private String isEncypt; + /** + * 是否压缩 + */ + private String isCompress; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/strategy/StrategyDO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/strategy/StrategyDO.java new file mode 100644 index 00000000..c1f13c52 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/strategy/StrategyDO.java @@ -0,0 +1,113 @@ +package com.win.module.wms.dal.dataobject.strategy; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import com.win.framework.mybatis.core.dataobject.BaseDO; + +/** + * 策略 DO + * + * @author 超级管理员 + */ +@TableName("strategy_strategy") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StrategyDO extends BaseDO { + + /** + * 数据主键 + */ + @TableId + private Long id; + /** + * 备注 + */ + private String remark; + /** + * 创建时间 + */ + private LocalDateTime creationTime; + /** + * 创建者ID + */ + private String creatorId; + /** + * 创建者姓名 + */ + private String creatorName; + /** + * 最后更新时间 + */ + private LocalDateTime lastModificationTime; + /** + * 最后更新者ID + */ + private String lastModifierId; + /** + * 最后更新者姓名 + */ + private String lastModifierName; + /** + * 删除时间 + */ + private LocalDateTime deletionTime; + /** + * 删除者ID + */ + private String deleterId; + /** + * 删除者姓名 + */ + private String deleterName; + /** + * 是否软删除 + */ + private String isSoftDeleted; + /** + * 扩展属性 + */ + private String extraProperties; + /** + * 并发乐观锁 + */ + private String concurrencyStamp; + /** + * 地点ID + */ + private String siteId; + /** + * 代码 + */ + private String code; + /** + * 名称 + */ + private String name; + /** + * 描述 + */ + private String description; + /** + * 类型 + * + * 枚举 {@link TODO strategy_type 对应的类} + */ + private String type; + /** + * 优先级 + */ + private Integer priority; + /** + * 是否生效 + */ + private String isActive; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/barcode/BarcodeMapper.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/barcode/BarcodeMapper.java new file mode 100644 index 00000000..38d180d2 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/barcode/BarcodeMapper.java @@ -0,0 +1,56 @@ +package com.win.module.wms.dal.mysql.barcode; + +import com.win.framework.common.pojo.PageResult; +import com.win.framework.mybatis.core.mapper.BaseMapperX; +import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.win.module.wms.controller.barcode.vo.BarcodeExportReqVO; +import com.win.module.wms.controller.barcode.vo.BarcodePageReqVO; +import com.win.module.wms.dal.dataobject.barcode.BarcodeDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 条码片段 Mapper + * + * @author 超级管理员 + */ +@Mapper +public interface BarcodeMapper extends BaseMapperX { + + default PageResult selectPage(BarcodePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(BarcodeDO::getCode, reqVO.getCode()) + .likeIfPresent(BarcodeDO::getName, reqVO.getName()) + .eqIfPresent(BarcodeDO::getDescription, reqVO.getDescription()) + .eqIfPresent(BarcodeDO::getOrder, reqVO.getOrder()) + .eqIfPresent(BarcodeDO::getLength, reqVO.getLength()) + .eqIfPresent(BarcodeDO::getPrefixLenght, reqVO.getPrefixLenght()) + .eqIfPresent(BarcodeDO::getPrefixChar, reqVO.getPrefixChar()) + .eqIfPresent(BarcodeDO::getEntityProperties, reqVO.getEntityProperties()) + .eqIfPresent(BarcodeDO::getEncyptMethod, reqVO.getEncyptMethod()) + .eqIfPresent(BarcodeDO::getMasterId, reqVO.getMasterId()) + .eqIfPresent(BarcodeDO::getTrimEnd, reqVO.getTrimEnd()) + .eqIfPresent(BarcodeDO::getIsEncypt, reqVO.getIsEncypt()) + .orderByDesc(BarcodeDO::getId)); + } + + default List selectList(BarcodeExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(BarcodeDO::getCode, reqVO.getCode()) + .likeIfPresent(BarcodeDO::getName, reqVO.getName()) + .eqIfPresent(BarcodeDO::getDescription, reqVO.getDescription()) + .eqIfPresent(BarcodeDO::getOrder, reqVO.getOrder()) + .eqIfPresent(BarcodeDO::getLength, reqVO.getLength()) + .eqIfPresent(BarcodeDO::getPrefixLenght, reqVO.getPrefixLenght()) + .eqIfPresent(BarcodeDO::getPrefixChar, reqVO.getPrefixChar()) + .eqIfPresent(BarcodeDO::getEntityProperties, reqVO.getEntityProperties()) + .eqIfPresent(BarcodeDO::getEncyptMethod, reqVO.getEncyptMethod()) + .eqIfPresent(BarcodeDO::getMasterId, reqVO.getMasterId()) + .eqIfPresent(BarcodeDO::getTrimEnd, reqVO.getTrimEnd()) + .eqIfPresent(BarcodeDO::getIsEncypt, reqVO.getIsEncypt()) + .orderByDesc(BarcodeDO::getId)); + } + + default BarcodeDO selectByCode(String code){return selectOne(BarcodeDO::getCode,code);}; +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/labeltype/LabeltypeMapper.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/labeltype/LabeltypeMapper.java new file mode 100644 index 00000000..f5db825b --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/labeltype/LabeltypeMapper.java @@ -0,0 +1,65 @@ +package com.win.module.wms.dal.mysql.labeltype; + +import com.win.framework.common.pojo.PageResult; +import com.win.framework.mybatis.core.mapper.BaseMapperX; +import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.win.module.wms.controller.labeltype.vo.LabeltypeExportReqVO; +import com.win.module.wms.controller.labeltype.vo.LabeltypePageReqVO; +import com.win.module.wms.dal.dataobject.labeltype.LabeltypeDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 标签定义 Mapper + * + * @author 超级管理员 + */ +@Mapper +public interface LabeltypeMapper extends BaseMapperX { + + default PageResult selectPage(LabeltypePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(LabeltypeDO::getLabelType, reqVO.getLabelType()) + .eqIfPresent(LabeltypeDO::getDescription, reqVO.getDescription()) + .eqIfPresent(LabeltypeDO::getDataProtocol, reqVO.getDataProtocol()) + .eqIfPresent(LabeltypeDO::getSplitMehod, reqVO.getSplitMehod()) + .eqIfPresent(LabeltypeDO::getHeader, reqVO.getHeader()) + .eqIfPresent(LabeltypeDO::getVersion, reqVO.getVersion()) + .eqIfPresent(LabeltypeDO::getSeparators, reqVO.getSeparators()) + .eqIfPresent(LabeltypeDO::getValidateMethod, reqVO.getValidateMethod()) + .eqIfPresent(LabeltypeDO::getValidateNumber, reqVO.getValidateNumber()) + .eqIfPresent(LabeltypeDO::getEncyptEthod, reqVO.getEncyptEthod()) + .eqIfPresent(LabeltypeDO::getCompressMethod, reqVO.getCompressMethod()) + .likeIfPresent(LabeltypeDO::getTemplateName, reqVO.getTemplateName()) + .eqIfPresent(LabeltypeDO::getTemplateFile, reqVO.getTemplateFile()) + .eqIfPresent(LabeltypeDO::getBarcodeSegments, reqVO.getBarcodeSegments()) + .eqIfPresent(LabeltypeDO::getLabelCode, reqVO.getLabelCode()) + .eqIfPresent(LabeltypeDO::getIsEncypt, reqVO.getIsEncypt()) + .eqIfPresent(LabeltypeDO::getIsCompress, reqVO.getIsCompress()) + .orderByDesc(LabeltypeDO::getId)); + } + + default List selectList(LabeltypeExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(LabeltypeDO::getLabelType, reqVO.getLabelType()) + .eqIfPresent(LabeltypeDO::getDescription, reqVO.getDescription()) + .eqIfPresent(LabeltypeDO::getDataProtocol, reqVO.getDataProtocol()) + .eqIfPresent(LabeltypeDO::getSplitMehod, reqVO.getSplitMehod()) + .eqIfPresent(LabeltypeDO::getHeader, reqVO.getHeader()) + .eqIfPresent(LabeltypeDO::getVersion, reqVO.getVersion()) + .eqIfPresent(LabeltypeDO::getSeparators, reqVO.getSeparators()) + .eqIfPresent(LabeltypeDO::getValidateMethod, reqVO.getValidateMethod()) + .eqIfPresent(LabeltypeDO::getValidateNumber, reqVO.getValidateNumber()) + .eqIfPresent(LabeltypeDO::getEncyptEthod, reqVO.getEncyptEthod()) + .eqIfPresent(LabeltypeDO::getCompressMethod, reqVO.getCompressMethod()) + .likeIfPresent(LabeltypeDO::getTemplateName, reqVO.getTemplateName()) + .eqIfPresent(LabeltypeDO::getTemplateFile, reqVO.getTemplateFile()) + .eqIfPresent(LabeltypeDO::getBarcodeSegments, reqVO.getBarcodeSegments()) + .eqIfPresent(LabeltypeDO::getLabelCode, reqVO.getLabelCode()) + .eqIfPresent(LabeltypeDO::getIsEncypt, reqVO.getIsEncypt()) + .eqIfPresent(LabeltypeDO::getIsCompress, reqVO.getIsCompress()) + .orderByDesc(LabeltypeDO::getId)); + } + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/strategy/StrategyMapper.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/strategy/StrategyMapper.java new file mode 100644 index 00000000..202d7fca --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/strategy/StrategyMapper.java @@ -0,0 +1,49 @@ +package com.win.module.wms.dal.mysql.strategy; + +import java.util.*; + +import com.win.framework.common.pojo.PageResult; +import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.win.framework.mybatis.core.mapper.BaseMapperX; +import com.win.module.wms.controller.strategy.vo.StrategyExportReqVO; +import com.win.module.wms.controller.strategy.vo.StrategyPageReqVO; +import com.win.module.wms.dal.dataobject.strategy.StrategyDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 策略 Mapper + * + * @author 超级管理员 + */ +@Mapper +public interface StrategyMapper extends BaseMapperX { + + default PageResult selectPage(StrategyPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(StrategyDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(StrategyDO::getCreationTime, reqVO.getCreationTime()) + .eqIfPresent(StrategyDO::getCreatorId, reqVO.getCreatorId()) + .eqIfPresent(StrategyDO::getCode, reqVO.getCode()) + .likeIfPresent(StrategyDO::getName, reqVO.getName()) + .eqIfPresent(StrategyDO::getDescription, reqVO.getDescription()) + .eqIfPresent(StrategyDO::getType, reqVO.getType()) + .eqIfPresent(StrategyDO::getPriority, reqVO.getPriority()) + .eqIfPresent(StrategyDO::getIsActive, reqVO.getIsActive()) + .orderByDesc(StrategyDO::getId)); + } + + default List selectList(StrategyExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(StrategyDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(StrategyDO::getCreationTime, reqVO.getCreationTime()) + .eqIfPresent(StrategyDO::getCreatorId, reqVO.getCreatorId()) + .eqIfPresent(StrategyDO::getCode, reqVO.getCode()) + .likeIfPresent(StrategyDO::getName, reqVO.getName()) + .eqIfPresent(StrategyDO::getDescription, reqVO.getDescription()) + .eqIfPresent(StrategyDO::getType, reqVO.getType()) + .eqIfPresent(StrategyDO::getPriority, reqVO.getPriority()) + .eqIfPresent(StrategyDO::getIsActive, reqVO.getIsActive()) + .orderByDesc(StrategyDO::getId)); + } + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/barcode/BarcodeService.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/barcode/BarcodeService.java new file mode 100644 index 00000000..55847e42 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/barcode/BarcodeService.java @@ -0,0 +1,73 @@ +package com.win.module.wms.service.barcode; + +import com.win.framework.common.pojo.PageResult; +import com.win.module.wms.controller.barcode.vo.*; +import com.win.module.wms.dal.dataobject.barcode.BarcodeDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + +/** + * 条码片段 Service 接口 + * + * @author 超级管理员 + */ +public interface BarcodeService { + + /** + * 创建条码片段 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createBarcode(@Valid BarcodeCreateReqVO createReqVO); + + /** + * 更新条码片段 + * + * @param updateReqVO 更新信息 + */ + void updateBarcode(@Valid BarcodeUpdateReqVO updateReqVO); + + /** + * 删除条码片段 + * + * @param id 编号 + */ + void deleteBarcode(Long id); + + /** + * 获得条码片段 + * + * @param id 编号 + * @return 条码片段 + */ + BarcodeDO getBarcode(Long id); + + /** + * 获得条码片段列表 + * + * @param ids 编号 + * @return 条码片段列表 + */ + List getBarcodeList(Collection ids); + + /** + * 获得条码片段分页 + * + * @param pageReqVO 分页查询 + * @return 条码片段分页 + */ + PageResult getBarcodePage(BarcodePageReqVO pageReqVO); + + /** + * 获得条码片段列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 条码片段列表 + */ + List getBarcodeList(BarcodeExportReqVO exportReqVO); + + List importBarcodeList(List barcodes, Integer mode, Boolean updatePart); +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/barcode/BarcodeServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/barcode/BarcodeServiceImpl.java new file mode 100644 index 00000000..926d9631 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/barcode/BarcodeServiceImpl.java @@ -0,0 +1,198 @@ +package com.win.module.wms.service.barcode; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.google.common.annotations.VisibleForTesting; +import com.win.framework.common.exception.ServiceException; +import com.win.framework.common.pojo.PageResult; +import com.win.framework.datapermission.core.util.DataPermissionUtils; +import com.win.module.wms.controller.barcode.vo.*; +import com.win.module.wms.convert.barcode.BarcodeConvert; +import com.win.module.wms.dal.dataobject.barcode.BarcodeDO; +import com.win.module.wms.dal.mysql.barcode.BarcodeMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.interceptor.TransactionAspectSupport; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.win.module.wms.enums.ErrorCodeConstants.BARCODE_NOT_EXISTS; +import static com.win.module.wms.enums.ErrorCodeConstants.*; + +/** + * 条码片段 Service 实现类 + * + * @author 超级管理员 + */ +@Service +@Validated +public class BarcodeServiceImpl implements BarcodeService { + + @Resource + private BarcodeMapper barcodeMapper; + + @Override + public Long createBarcode(BarcodeCreateReqVO createReqVO) { + validateBarcodeForCreateOrUpdate(createReqVO.getId(),createReqVO.getCode(),createReqVO.getOrder(), createReqVO.getLength(), + createReqVO.getPrefixLenght(),createReqVO.getEntityProperties(),createReqVO.getTrimEnd(),createReqVO.getIsEncypt()); + // 插入 + BarcodeDO barcode = BarcodeConvert.INSTANCE.convert(createReqVO); + barcodeMapper.insert(barcode); + // 返回 + return barcode.getId(); + } + + @Override + public void updateBarcode(BarcodeUpdateReqVO updateReqVO) { + // 校验存在 + validateBarcodeForCreateOrUpdate(updateReqVO.getId(),updateReqVO.getCode(),updateReqVO.getOrder(), updateReqVO.getLength(), + updateReqVO.getPrefixLenght(),updateReqVO.getEntityProperties(),updateReqVO.getTrimEnd(),updateReqVO.getIsEncypt()); + // 更新 + BarcodeDO updateObj = BarcodeConvert.INSTANCE.convert(updateReqVO); + barcodeMapper.updateById(updateObj); + } + + @Override + public void deleteBarcode(Long id) { + // 校验存在 + validateBarcodeExists(id); + // 删除 + barcodeMapper.deleteById(id); + } + + @Override + public BarcodeDO getBarcode(Long id) { + return barcodeMapper.selectById(id); + } + + @Override + public List getBarcodeList(Collection ids) { + return barcodeMapper.selectBatchIds(ids); + } + + @Override + public PageResult getBarcodePage(BarcodePageReqVO pageReqVO) { + return barcodeMapper.selectPage(pageReqVO); + } + + @Override + public List getBarcodeList(BarcodeExportReqVO exportReqVO) { + return barcodeMapper.selectList(exportReqVO); + } + + @Override + public List importBarcodeList(List barcodes, Integer mode, Boolean updatePart) { + if (CollUtil.isEmpty(barcodes)) { + throw exception(BARCODE_IMPORT_LIST_IS_EMPTY); + } + List errorList = new ArrayList<>(); + barcodes.forEach(barcode -> { + // 校验,判断是否有不符合的原因 + try { + if(mode == 2){ + validateBarcodeForCreateOrUpdate(null,barcode.getCode(),barcode.getOrder(), barcode.getLength(), + barcode.getPrefixLenght(),barcode.getEntityProperties(),barcode.getTrimEnd(),barcode.getIsEncypt()); + } + } catch (ServiceException ex) { + errorList.add(barcode); + return; + } + // 判断如果不存在,在进行插入 + BarcodeDO existAccountcalendar = barcodeMapper.selectByCode(barcode.getCode()); + if (existAccountcalendar == null&& mode != 3) { + barcodeMapper.insert(BarcodeConvert.INSTANCE.convert(barcode)); + } + else if (existAccountcalendar != null && mode != 2) {// 如果存在,判断是否允许更新 + BarcodeDO accountcalendarDO = BarcodeConvert.INSTANCE.convert(barcode); + accountcalendarDO.setId(existAccountcalendar.getId()); + barcodeMapper.updateById(accountcalendarDO); + } + }); + //错误不为空并非部分更新,手工回滚 + if(!errorList.isEmpty() && !updatePart) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + return errorList; + } + private void validateBarcodeForCreateOrUpdate(Long id,String code,Integer order,Integer length,Integer prefixLenght,String entityProperties,String trimEnd,String isEncypt) { + // 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确 + DataPermissionUtils.executeIgnore(() -> { + validateBarcodeExists(id); + // 校验code唯一 + validateCodeExists(id,code); + validateOrderExists(order); + validateLengthExists(length); + validatePrefixLenghtExists(prefixLenght); + validateEntityPropertiesExists(entityProperties); + validateTrimEndExists(trimEnd); + validateIsEncyptExists(isEncypt); + + }); + } + @VisibleForTesting + private void validateBarcodeExists(Long id) { + if (barcodeMapper.selectById(id) == null) { + throw exception(BARCODE_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateCodeExists(Long id,String code) { + if (code.isEmpty()) { + throw exception(BARCODE_CODE_NOT_EXISTS); + } + if (StrUtil.isBlank(code)) { + return; + } + BarcodeDO barcodeDO = barcodeMapper.selectByCode(code); + if (barcodeDO == null) { + return; + } + // 如果 id 为空,说明不用比较是否为相同 id 的用户 + if (id == null) { + throw exception(BARCODE_CODE_EXISTS); + } + if (!barcodeDO.getId().equals(id)) { + throw exception(BARCODE_CODE_EXISTS); + } + } + @VisibleForTesting + private void validateOrderExists(Integer order) { + if (order == 0) { + throw exception(BARCODE_ORDER_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateLengthExists(Integer length) { + if (length == 0) { + throw exception(BARCODE_LENGTH_NOT_EXISTS); + } + } + @VisibleForTesting + private void validatePrefixLenghtExists(Integer prefixLenght) { + if (prefixLenght == 0) { + throw exception(BARCODE_PREFIX_LENGTH_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateEntityPropertiesExists(String entityProperties) { + if (entityProperties.isEmpty()) { + throw exception(BARCODE_ENTITY_PROPERTIES_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateTrimEndExists(String trimEnd) { + if (trimEnd.isEmpty()) { + throw exception(BARCODE_TRIM_END_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateIsEncyptExists(String isEncypt) { + if (isEncypt.isEmpty()) { + throw exception(BARCODE_IS_ENCYPT_NOT_EXISTS); + } + } +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/labeltype/LabeltypeService.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/labeltype/LabeltypeService.java new file mode 100644 index 00000000..3434b86d --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/labeltype/LabeltypeService.java @@ -0,0 +1,75 @@ +package com.win.module.wms.service.labeltype; + +import com.win.framework.common.pojo.PageResult; +import com.win.module.wms.controller.labeltype.vo.LabeltypeCreateReqVO; +import com.win.module.wms.controller.labeltype.vo.LabeltypeExportReqVO; +import com.win.module.wms.controller.labeltype.vo.LabeltypePageReqVO; +import com.win.module.wms.controller.labeltype.vo.LabeltypeUpdateReqVO; +import com.win.module.wms.dal.dataobject.labeltype.LabeltypeDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + +/** + * 标签定义 Service 接口 + * + * @author 超级管理员 + */ +public interface LabeltypeService { + + /** + * 创建标签定义 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createLabeltype(@Valid LabeltypeCreateReqVO createReqVO); + + /** + * 更新标签定义 + * + * @param updateReqVO 更新信息 + */ + void updateLabeltype(@Valid LabeltypeUpdateReqVO updateReqVO); + + /** + * 删除标签定义 + * + * @param id 编号 + */ + void deleteLabeltype(Long id); + + /** + * 获得标签定义 + * + * @param id 编号 + * @return 标签定义 + */ + LabeltypeDO getLabeltype(Long id); + + /** + * 获得标签定义列表 + * + * @param ids 编号 + * @return 标签定义列表 + */ + List getLabeltypeList(Collection ids); + + /** + * 获得标签定义分页 + * + * @param pageReqVO 分页查询 + * @return 标签定义分页 + */ + PageResult getLabeltypePage(LabeltypePageReqVO pageReqVO); + + /** + * 获得标签定义列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 标签定义列表 + */ + List getLabeltypeList(LabeltypeExportReqVO exportReqVO); + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/labeltype/LabeltypeServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/labeltype/LabeltypeServiceImpl.java new file mode 100644 index 00000000..d0681b66 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/labeltype/LabeltypeServiceImpl.java @@ -0,0 +1,85 @@ +package com.win.module.wms.service.labeltype; + +import com.win.framework.common.pojo.PageResult; +import com.win.module.wms.controller.labeltype.vo.LabeltypeCreateReqVO; +import com.win.module.wms.controller.labeltype.vo.LabeltypeExportReqVO; +import com.win.module.wms.controller.labeltype.vo.LabeltypePageReqVO; +import com.win.module.wms.controller.labeltype.vo.LabeltypeUpdateReqVO; +import com.win.module.wms.convert.labeltype.LabeltypeConvert; +import com.win.module.wms.dal.dataobject.labeltype.LabeltypeDO; +import com.win.module.wms.dal.mysql.labeltype.LabeltypeMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.win.module.wms.enums.ErrorCodeConstants.BARCODE_NOT_EXISTS; + +/** + * 标签定义 Service 实现类 + * + wms* @author 超级管理员 + */ +@Service +@Validated +public class LabeltypeServiceImpl implements LabeltypeService { + + @Resource + private LabeltypeMapper labletypeMapper; + + @Override + public Long createLabeltype(LabeltypeCreateReqVO createReqVO) { + // 插入 + LabeltypeDO type = LabeltypeConvert.INSTANCE.convert(createReqVO); + labletypeMapper.insert(type); + // 返回 + return type.getId(); + } + + @Override + public void updateLabeltype(LabeltypeUpdateReqVO updateReqVO) { + // 校验存在 + validateLabeltypeExists(updateReqVO.getId()); + // 更新 + LabeltypeDO updateObj = LabeltypeConvert.INSTANCE.convert(updateReqVO); + labletypeMapper.updateById(updateObj); + } + + @Override + public void deleteLabeltype(Long id) { + // 校验存在 + validateLabeltypeExists(id); + // 删除 + labletypeMapper.deleteById(id); + } + + private void validateLabeltypeExists(Long id) { + if (labletypeMapper.selectById(id) == null) { + throw exception(BARCODE_NOT_EXISTS); + } + } + + @Override + public LabeltypeDO getLabeltype(Long id) { + return labletypeMapper.selectById(id); + } + + @Override + public List getLabeltypeList(Collection ids) { + return labletypeMapper.selectBatchIds(ids); + } + + @Override + public PageResult getLabeltypePage(LabeltypePageReqVO pageReqVO) { + return labletypeMapper.selectPage(pageReqVO); + } + + @Override + public List getLabeltypeList(LabeltypeExportReqVO exportReqVO) { + return labletypeMapper.selectList(exportReqVO); + } + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/strategy/StrategyService.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/strategy/StrategyService.java new file mode 100644 index 00000000..f3aafa37 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/strategy/StrategyService.java @@ -0,0 +1,74 @@ +package com.win.module.wms.service.strategy; + +import java.util.*; +import javax.validation.*; + +import com.win.module.wms.controller.strategy.vo.StrategyCreateReqVO; +import com.win.module.wms.controller.strategy.vo.StrategyExportReqVO; +import com.win.module.wms.controller.strategy.vo.StrategyPageReqVO; +import com.win.module.wms.controller.strategy.vo.StrategyUpdateReqVO; +import com.win.module.wms.dal.dataobject.strategy.StrategyDO; +import com.win.framework.common.pojo.PageResult; + +/** + * 策略 Service 接口 + * + * @author 超级管理员 + */ +public interface StrategyService { + + /** + * 创建策略 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createStrategy(@Valid StrategyCreateReqVO createReqVO); + + /** + * 更新策略 + * + * @param updateReqVO 更新信息 + */ + void updateStrategy(@Valid StrategyUpdateReqVO updateReqVO); + + /** + * 删除策略 + * + * @param id 编号 + */ + void deleteStrategy(Long id); + + /** + * 获得策略 + * + * @param id 编号 + * @return 策略 + */ + StrategyDO getStrategy(Long id); + + /** + * 获得策略列表 + * + * @param ids 编号 + * @return 策略列表 + */ + List getStrategyList(Collection ids); + + /** + * 获得策略分页 + * + * @param pageReqVO 分页查询 + * @return 策略分页 + */ + PageResult getStrategyPage(StrategyPageReqVO pageReqVO); + + /** + * 获得策略列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 策略列表 + */ + List getStrategyList(StrategyExportReqVO exportReqVO); + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/strategy/StrategyServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/strategy/StrategyServiceImpl.java new file mode 100644 index 00000000..fc3d75ee --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/strategy/StrategyServiceImpl.java @@ -0,0 +1,85 @@ +package com.win.module.wms.service.strategy; + +import com.win.framework.common.pojo.PageResult; +import com.win.module.wms.controller.strategy.vo.StrategyCreateReqVO; +import com.win.module.wms.controller.strategy.vo.StrategyExportReqVO; +import com.win.module.wms.controller.strategy.vo.StrategyPageReqVO; +import com.win.module.wms.controller.strategy.vo.StrategyUpdateReqVO; +import com.win.module.wms.convert.strategy.StrategyConvert; +import com.win.module.wms.dal.dataobject.strategy.StrategyDO; +import com.win.module.wms.dal.mysql.strategy.StrategyMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.win.module.wms.enums.ErrorCodeConstants.STRATEGY_NOT_EXISTS; + +/** + * 策略 Service 实现类 + * + * @author 超级管理员 + */ +@Service +@Validated +public class StrategyServiceImpl implements StrategyService { + + @Resource + private StrategyMapper strategyMapper; + + @Override + public Long createStrategy(StrategyCreateReqVO createReqVO) { + // 插入 + StrategyDO strategy = StrategyConvert.INSTANCE.convert(createReqVO); + strategyMapper.insert(strategy); + // 返回 + return strategy.getId(); + } + + @Override + public void updateStrategy(StrategyUpdateReqVO updateReqVO) { + // 校验存在 + validateStrategyExists(updateReqVO.getId()); + // 更新 + StrategyDO updateObj = StrategyConvert.INSTANCE.convert(updateReqVO); + strategyMapper.updateById(updateObj); + } + + @Override + public void deleteStrategy(Long id) { + // 校验存在 + validateStrategyExists(id); + // 删除 + strategyMapper.deleteById(id); + } + + private void validateStrategyExists(Long id) { + if (strategyMapper.selectById(id) == null) { + throw exception(STRATEGY_NOT_EXISTS); + } + } + + @Override + public StrategyDO getStrategy(Long id) { + return strategyMapper.selectById(id); + } + + @Override + public List getStrategyList(Collection ids) { + return strategyMapper.selectBatchIds(ids); + } + + @Override + public PageResult getStrategyPage(StrategyPageReqVO pageReqVO) { + return strategyMapper.selectPage(pageReqVO); + } + + @Override + public List getStrategyList(StrategyExportReqVO exportReqVO) { + return strategyMapper.selectList(exportReqVO); + } + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/resources/mapper/barcode/BarcodeMapper.xml b/win-module-wms/win-module-wms-biz/src/main/resources/mapper/barcode/BarcodeMapper.xml new file mode 100644 index 00000000..6edb3594 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/resources/mapper/barcode/BarcodeMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/win-module-wms/win-module-wms-biz/src/main/resources/mapper/labeltype/LabeltypeMapper.xml b/win-module-wms/win-module-wms-biz/src/main/resources/mapper/labeltype/LabeltypeMapper.xml new file mode 100644 index 00000000..8fc62ce4 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/resources/mapper/labeltype/LabeltypeMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/win-module-wms/win-module-wms-biz/src/main/resources/mapper/strategy/StrategyMapper.xml b/win-module-wms/win-module-wms-biz/src/main/resources/mapper/strategy/StrategyMapper.xml new file mode 100644 index 00000000..ac06aed6 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/resources/mapper/strategy/StrategyMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/win-module-wms/win-module-wms-biz/src/test/java/com/win/module/wms/service/strategy/StrategyServiceImplTest.java b/win-module-wms/win-module-wms-biz/src/test/java/com/win/module/wms/service/strategy/StrategyServiceImplTest.java new file mode 100644 index 00000000..d66008ed --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/test/java/com/win/module/wms/service/strategy/StrategyServiceImplTest.java @@ -0,0 +1,212 @@ +package com.win.module.wms.service.strategy; + +import com.win.module.wms.controller.strategy.vo.StrategyCreateReqVO; +import com.win.module.wms.controller.strategy.vo.StrategyExportReqVO; +import com.win.module.wms.controller.strategy.vo.StrategyPageReqVO; +import com.win.module.wms.controller.strategy.vo.StrategyUpdateReqVO; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import javax.annotation.Resource; + +import com.win.framework.test.core.ut.BaseDbUnitTest; + +import com.win.module.wms.dal.dataobject.strategy.StrategyDO; +import com.win.module.wms.dal.mysql.strategy.StrategyMapper; +import com.win.framework.common.pojo.PageResult; + +import org.springframework.context.annotation.Import; +import java.util.*; + +import static com.win.module.wms.enums.ErrorCodeConstants.*; +import static com.win.framework.test.core.util.AssertUtils.*; +import static com.win.framework.test.core.util.RandomUtils.*; +import static com.win.framework.common.util.date.LocalDateTimeUtils.*; +import static com.win.framework.common.util.object.ObjectUtils.*; +import static org.junit.jupiter.api.Assertions.*; + +/** + * {@link StrategyServiceImpl} 的单元测试类 + * + * @author 超级管理员 + */ +@Import(StrategyServiceImpl.class) +public class StrategyServiceImplTest extends BaseDbUnitTest { + + @Resource + private StrategyServiceImpl strategyService; + + @Resource + private StrategyMapper strategyMapper; + + @Test + public void testCreateStrategy_success() { + // 准备参数 + StrategyCreateReqVO reqVO = randomPojo(StrategyCreateReqVO.class); + + // 调用 + Long strategyId = strategyService.createStrategy(reqVO); + // 断言 + assertNotNull(strategyId); + // 校验记录的属性是否正确 + StrategyDO strategy = strategyMapper.selectById(strategyId); + assertPojoEquals(reqVO, strategy); + } + + @Test + public void testUpdateStrategy_success() { + // mock 数据 + StrategyDO dbStrategy = randomPojo(StrategyDO.class); + strategyMapper.insert(dbStrategy);// @Sql: 先插入出一条存在的数据 + // 准备参数 + StrategyUpdateReqVO reqVO = randomPojo(StrategyUpdateReqVO.class, o -> { + o.setId(dbStrategy.getId()); // 设置更新的 ID + }); + + // 调用 + strategyService.updateStrategy(reqVO); + // 校验是否更新正确 + StrategyDO strategy = strategyMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, strategy); + } + + @Test + public void testUpdateStrategy_notExists() { + // 准备参数 + StrategyUpdateReqVO reqVO = randomPojo(StrategyUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> strategyService.updateStrategy(reqVO), STRATEGY_NOT_EXISTS); + } + + @Test + public void testDeleteStrategy_success() { + // mock 数据 + StrategyDO dbStrategy = randomPojo(StrategyDO.class); + strategyMapper.insert(dbStrategy);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbStrategy.getId(); + + // 调用 + strategyService.deleteStrategy(id); + // 校验数据不存在了 + assertNull(strategyMapper.selectById(id)); + } + + @Test + public void testDeleteStrategy_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> strategyService.deleteStrategy(id), STRATEGY_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetStrategyPage() { + // mock 数据 + StrategyDO dbStrategy = randomPojo(StrategyDO.class, o -> { // 等会查询到 + o.setRemark(null); + o.setCreationTime(null); + o.setCreatorId(null); + o.setCode(null); + o.setName(null); + o.setDescription(null); + o.setType(null); + o.setPriority(null); + o.setIsActive(null); + }); + strategyMapper.insert(dbStrategy); + // 测试 remark 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setRemark(null))); + // 测试 creationTime 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setCreationTime(null))); + // 测试 creatorId 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setCreatorId(null))); + // 测试 code 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setCode(null))); + // 测试 name 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setName(null))); + // 测试 description 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setDescription(null))); + // 测试 type 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setType(null))); + // 测试 priority 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setPriority(null))); + // 测试 isActive 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setIsActive(null))); + // 准备参数 + StrategyPageReqVO reqVO = new StrategyPageReqVO(); + reqVO.setRemark(null); + reqVO.setCreationTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCreatorId(null); + reqVO.setCode(null); + reqVO.setName(null); + reqVO.setDescription(null); + reqVO.setType(null); + reqVO.setPriority(null); + reqVO.setIsActive(null); + + // 调用 + PageResult pageResult = strategyService.getStrategyPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbStrategy, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetStrategyList() { + // mock 数据 + StrategyDO dbStrategy = randomPojo(StrategyDO.class, o -> { // 等会查询到 + o.setRemark(null); + o.setCreationTime(null); + o.setCreatorId(null); + o.setCode(null); + o.setName(null); + o.setDescription(null); + o.setType(null); + o.setPriority(null); + o.setIsActive(null); + }); + strategyMapper.insert(dbStrategy); + // 测试 remark 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setRemark(null))); + // 测试 creationTime 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setCreationTime(null))); + // 测试 creatorId 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setCreatorId(null))); + // 测试 code 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setCode(null))); + // 测试 name 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setName(null))); + // 测试 description 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setDescription(null))); + // 测试 type 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setType(null))); + // 测试 priority 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setPriority(null))); + // 测试 isActive 不匹配 + strategyMapper.insert(cloneIgnoreId(dbStrategy, o -> o.setIsActive(null))); + // 准备参数 + StrategyExportReqVO reqVO = new StrategyExportReqVO(); + reqVO.setRemark(null); + reqVO.setCreationTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCreatorId(null); + reqVO.setCode(null); + reqVO.setName(null); + reqVO.setDescription(null); + reqVO.setType(null); + reqVO.setPriority(null); + reqVO.setIsActive(null); + + // 调用 + List list = strategyService.getStrategyList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbStrategy, list.get(0)); + } + +}