forked from sfms3.0/sfms3.0
49 changed files with 2685 additions and 4 deletions
@ -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<Long> createBarcode(@Valid @RequestBody BarcodeCreateReqVO createReqVO) { |
|||
return success(barcodeService.createBarcode(createReqVO)); |
|||
} |
|||
|
|||
@PutMapping("/update") |
|||
@Operation(summary = "更新条码片段") |
|||
@PreAuthorize("@ss.hasPermission('label:barcode:update')") |
|||
public CommonResult<Boolean> 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<Boolean> 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<BarcodeRespVO> 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<List<BarcodeRespVO>> getBarcodeList(@RequestParam("ids") Collection<Long> ids) { |
|||
List<BarcodeDO> list = barcodeService.getBarcodeList(ids); |
|||
return success(BarcodeConvert.INSTANCE.convertList(list)); |
|||
} |
|||
|
|||
@GetMapping("/page") |
|||
@Operation(summary = "获得条码片段分页") |
|||
@PreAuthorize("@ss.hasPermission('label:barcode:query')") |
|||
public CommonResult<PageResult<BarcodeRespVO>> getBarcodePage(@Valid BarcodePageReqVO pageVO) { |
|||
PageResult<BarcodeDO> 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<BarcodeDO> list = barcodeService.getBarcodeList(exportReqVO); |
|||
// 导出 Excel
|
|||
List<BarcodeExcelVO> 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<BarcodeImportExcelVo> list = Arrays.asList(); |
|||
Map<Integer, String[]> 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<BarcodeImportExcelVo> list = ExcelUtils.read(file, BarcodeImportExcelVo.class); |
|||
List<BarcodeImportExcelVo> errorList = barcodeService.importBarcodeList(list, mode, updatePart); |
|||
Map<String, Object> 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); |
|||
} |
|||
} |
|||
} |
@ -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; |
|||
|
|||
} |
@ -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 { |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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<Long> createlabeltype(@Valid @RequestBody LabeltypeCreateReqVO createReqVO) { |
|||
return success(labeltypeService.createLabeltype(createReqVO)); |
|||
} |
|||
|
|||
@PutMapping("/update") |
|||
@Operation(summary = "更新标签定义") |
|||
@PreAuthorize("@ss.hasPermission('wms:LabeltypeService:update')") |
|||
public CommonResult<Boolean> 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<Boolean> 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<LabeltypeRespVO> 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<List<LabeltypeRespVO>> getLabeltypeList(@RequestParam("ids") Collection<Long> ids) { |
|||
List<LabeltypeDO> list = labeltypeService.getLabeltypeList(ids); |
|||
return success(LabeltypeConvert.INSTANCE.convertList(list)); |
|||
} |
|||
|
|||
@GetMapping("/page") |
|||
@Operation(summary = "获得标签定义分页") |
|||
@PreAuthorize("@ss.hasPermission('wms:labeltypeService:query')") |
|||
public CommonResult<PageResult<LabeltypeRespVO>> gettypePage(@Valid LabeltypePageReqVO pageVO) { |
|||
PageResult<LabeltypeDO> 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<LabeltypeDO> list = labeltypeService.getLabeltypeList(exportReqVO); |
|||
// 导出 Excel
|
|||
List<LabeltypeExcelVO> datas = LabeltypeConvert.INSTANCE.convertList02(list); |
|||
ExcelUtils.write(response, "标签定义.xls", "数据", LabeltypeExcelVO.class, datas); |
|||
} |
|||
} |
@ -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<BarcodeSegment>") |
|||
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; |
|||
|
|||
} |
@ -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 { |
|||
|
|||
} |
@ -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<BarcodeSegment>") |
|||
private String barcodeSegments; |
|||
|
|||
@ExcelProperty("标签代码") |
|||
private String labelCode; |
|||
|
|||
@ExcelProperty("是否加密") |
|||
private String isEncypt; |
|||
|
|||
@ExcelProperty("是否压缩") |
|||
private String isCompress; |
|||
|
|||
} |
@ -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<BarcodeSegment>") |
|||
private String barcodeSegments; |
|||
|
|||
@Schema(description = "标签代码") |
|||
private String labelCode; |
|||
|
|||
@Schema(description = "是否加密") |
|||
private String isEncypt; |
|||
|
|||
@Schema(description = "是否压缩") |
|||
private String isCompress; |
|||
|
|||
} |
@ -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<BarcodeSegment>") |
|||
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; |
|||
} |
@ -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<BarcodeSegment>") |
|||
private String barcodeSegments; |
|||
|
|||
@Schema(description = "标签代码") |
|||
private String labelCode; |
|||
|
|||
@Schema(description = "是否加密") |
|||
private String isEncypt; |
|||
|
|||
@Schema(description = "是否压缩") |
|||
private String isCompress; |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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<Long> createStrategy(@Valid @RequestBody StrategyCreateReqVO createReqVO) { |
|||
return success(strategyService.createStrategy(createReqVO)); |
|||
} |
|||
|
|||
@PutMapping("/update") |
|||
@Operation(summary = "更新策略") |
|||
@PreAuthorize("@ss.hasPermission('wms:strategy:update')") |
|||
public CommonResult<Boolean> 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<Boolean> 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<StrategyRespVO> 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<List<StrategyRespVO>> getStrategyList(@RequestParam("ids") Collection<Long> ids) { |
|||
List<StrategyDO> list = strategyService.getStrategyList(ids); |
|||
return success(StrategyConvert.INSTANCE.convertList(list)); |
|||
} |
|||
|
|||
@GetMapping("/page") |
|||
@Operation(summary = "获得策略分页") |
|||
@PreAuthorize("@ss.hasPermission('wms:strategy:query')") |
|||
public CommonResult<PageResult<StrategyRespVO>> getStrategyPage(@Valid StrategyPageReqVO pageVO) { |
|||
PageResult<StrategyDO> 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<StrategyDO> list = strategyService.getStrategyList(exportReqVO); |
|||
// 导出 Excel
|
|||
List<StrategyExcelVO> datas = StrategyConvert.INSTANCE.convertList02(list); |
|||
ExcelUtils.write(response, "策略.xls", "数据", StrategyExcelVO.class, datas); |
|||
} |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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 { |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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 { |
|||
|
|||
} |
@ -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<BarcodeRespVO> convertList(List<BarcodeDO> list); |
|||
|
|||
PageResult<BarcodeRespVO> convertPage(PageResult<BarcodeDO> page); |
|||
|
|||
List<BarcodeExcelVO> convertList02(List<BarcodeDO> list); |
|||
|
|||
BarcodeDO convert(BarcodeImportExcelVo barcode); |
|||
} |
@ -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<LabeltypeRespVO> convertList(List<LabeltypeDO> list); |
|||
|
|||
PageResult<LabeltypeRespVO> convertPage(PageResult<LabeltypeDO> page); |
|||
|
|||
List<LabeltypeExcelVO> convertList02(List<LabeltypeDO> list); |
|||
|
|||
} |
@ -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<StrategyRespVO> convertList(List<StrategyDO> list); |
|||
|
|||
PageResult<StrategyRespVO> convertPage(PageResult<StrategyDO> page); |
|||
|
|||
List<StrategyExcelVO> convertList02(List<StrategyDO> list); |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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<BarcodeSegment> |
|||
*/ |
|||
private String barcodeSegments; |
|||
/** |
|||
* 标签代码 |
|||
*/ |
|||
private String labelCode; |
|||
/** |
|||
* 是否加密 |
|||
*/ |
|||
private String isEncypt; |
|||
/** |
|||
* 是否压缩 |
|||
*/ |
|||
private String isCompress; |
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
@ -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<BarcodeDO> { |
|||
|
|||
default PageResult<BarcodeDO> selectPage(BarcodePageReqVO reqVO) { |
|||
return selectPage(reqVO, new LambdaQueryWrapperX<BarcodeDO>() |
|||
.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<BarcodeDO> selectList(BarcodeExportReqVO reqVO) { |
|||
return selectList(new LambdaQueryWrapperX<BarcodeDO>() |
|||
.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);}; |
|||
} |
@ -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<LabeltypeDO> { |
|||
|
|||
default PageResult<LabeltypeDO> selectPage(LabeltypePageReqVO reqVO) { |
|||
return selectPage(reqVO, new LambdaQueryWrapperX<LabeltypeDO>() |
|||
.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<LabeltypeDO> selectList(LabeltypeExportReqVO reqVO) { |
|||
return selectList(new LambdaQueryWrapperX<LabeltypeDO>() |
|||
.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)); |
|||
} |
|||
|
|||
} |
@ -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<StrategyDO> { |
|||
|
|||
default PageResult<StrategyDO> selectPage(StrategyPageReqVO reqVO) { |
|||
return selectPage(reqVO, new LambdaQueryWrapperX<StrategyDO>() |
|||
.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<StrategyDO> selectList(StrategyExportReqVO reqVO) { |
|||
return selectList(new LambdaQueryWrapperX<StrategyDO>() |
|||
.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)); |
|||
} |
|||
|
|||
} |
@ -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<BarcodeDO> getBarcodeList(Collection<Long> ids); |
|||
|
|||
/** |
|||
* 获得条码片段分页 |
|||
* |
|||
* @param pageReqVO 分页查询 |
|||
* @return 条码片段分页 |
|||
*/ |
|||
PageResult<BarcodeDO> getBarcodePage(BarcodePageReqVO pageReqVO); |
|||
|
|||
/** |
|||
* 获得条码片段列表, 用于 Excel 导出 |
|||
* |
|||
* @param exportReqVO 查询条件 |
|||
* @return 条码片段列表 |
|||
*/ |
|||
List<BarcodeDO> getBarcodeList(BarcodeExportReqVO exportReqVO); |
|||
|
|||
List<BarcodeImportExcelVo> importBarcodeList(List<BarcodeImportExcelVo> barcodes, Integer mode, Boolean updatePart); |
|||
} |
@ -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<BarcodeDO> getBarcodeList(Collection<Long> ids) { |
|||
return barcodeMapper.selectBatchIds(ids); |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<BarcodeDO> getBarcodePage(BarcodePageReqVO pageReqVO) { |
|||
return barcodeMapper.selectPage(pageReqVO); |
|||
} |
|||
|
|||
@Override |
|||
public List<BarcodeDO> getBarcodeList(BarcodeExportReqVO exportReqVO) { |
|||
return barcodeMapper.selectList(exportReqVO); |
|||
} |
|||
|
|||
@Override |
|||
public List<BarcodeImportExcelVo> importBarcodeList(List<BarcodeImportExcelVo> barcodes, Integer mode, Boolean updatePart) { |
|||
if (CollUtil.isEmpty(barcodes)) { |
|||
throw exception(BARCODE_IMPORT_LIST_IS_EMPTY); |
|||
} |
|||
List<BarcodeImportExcelVo> 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); |
|||
} |
|||
} |
|||
} |
@ -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<LabeltypeDO> getLabeltypeList(Collection<Long> ids); |
|||
|
|||
/** |
|||
* 获得标签定义分页 |
|||
* |
|||
* @param pageReqVO 分页查询 |
|||
* @return 标签定义分页 |
|||
*/ |
|||
PageResult<LabeltypeDO> getLabeltypePage(LabeltypePageReqVO pageReqVO); |
|||
|
|||
/** |
|||
* 获得标签定义列表, 用于 Excel 导出 |
|||
* |
|||
* @param exportReqVO 查询条件 |
|||
* @return 标签定义列表 |
|||
*/ |
|||
List<LabeltypeDO> getLabeltypeList(LabeltypeExportReqVO exportReqVO); |
|||
|
|||
} |
@ -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<LabeltypeDO> getLabeltypeList(Collection<Long> ids) { |
|||
return labletypeMapper.selectBatchIds(ids); |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<LabeltypeDO> getLabeltypePage(LabeltypePageReqVO pageReqVO) { |
|||
return labletypeMapper.selectPage(pageReqVO); |
|||
} |
|||
|
|||
@Override |
|||
public List<LabeltypeDO> getLabeltypeList(LabeltypeExportReqVO exportReqVO) { |
|||
return labletypeMapper.selectList(exportReqVO); |
|||
} |
|||
|
|||
} |
@ -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<StrategyDO> getStrategyList(Collection<Long> ids); |
|||
|
|||
/** |
|||
* 获得策略分页 |
|||
* |
|||
* @param pageReqVO 分页查询 |
|||
* @return 策略分页 |
|||
*/ |
|||
PageResult<StrategyDO> getStrategyPage(StrategyPageReqVO pageReqVO); |
|||
|
|||
/** |
|||
* 获得策略列表, 用于 Excel 导出 |
|||
* |
|||
* @param exportReqVO 查询条件 |
|||
* @return 策略列表 |
|||
*/ |
|||
List<StrategyDO> getStrategyList(StrategyExportReqVO exportReqVO); |
|||
|
|||
} |
@ -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<StrategyDO> getStrategyList(Collection<Long> ids) { |
|||
return strategyMapper.selectBatchIds(ids); |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<StrategyDO> getStrategyPage(StrategyPageReqVO pageReqVO) { |
|||
return strategyMapper.selectPage(pageReqVO); |
|||
} |
|||
|
|||
@Override |
|||
public List<StrategyDO> getStrategyList(StrategyExportReqVO exportReqVO) { |
|||
return strategyMapper.selectList(exportReqVO); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.win.module.label.dal.mysql.barcode.BarcodeMapper"> |
|||
|
|||
<!-- |
|||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
|||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 |
|||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
|||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
|||
--> |
|||
|
|||
</mapper> |
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.win.module.label.dal.mysql.labeltype.LabeltypeMapper"> |
|||
|
|||
<!-- |
|||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
|||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 |
|||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
|||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
|||
--> |
|||
|
|||
</mapper> |
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.win.module.wms.dal.mysql.strategy.StrategyMapper"> |
|||
|
|||
<!-- |
|||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
|||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 |
|||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
|||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
|||
--> |
|||
|
|||
</mapper> |
@ -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<StrategyDO> 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<StrategyDO> list = strategyService.getStrategyList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbStrategy, list.get(0)); |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue