From c06d295092de4d29b20a172172bc432110e5740c Mon Sep 17 00:00:00 2001 From: lijiaqi Date: Thu, 12 Sep 2024 09:57:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BC=96=E7=A0=81=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E4=B8=AD=E6=96=B0=E5=A2=9E=E5=BA=8F=E5=88=97=E5=8F=B7?= =?UTF-8?q?=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增序列号生成服务,支持三种不同的编码规则: 1. 日期+递增数字(年月日或年月)。 2. 随机生成的8位序列号,包含大写字母和数字。 3. 默认规则,自增序列号。 实现具有不同前缀和后缀的序列号生成,包括年月日或年月作为前缀,校验位作为后缀。 --- .../coding/controller/BatchesController.java | 37 +++++++++++++++ .../coding/controller/CodeController.java | 45 ++++++++++++++++++- .../drone/coding/service/BatchesService.java | 14 ++++++ .../drone/coding/service/CodeService.java | 22 +++++++-- 4 files changed, 114 insertions(+), 4 deletions(-) diff --git a/src/main/java/cn/workde/module/drone/coding/controller/BatchesController.java b/src/main/java/cn/workde/module/drone/coding/controller/BatchesController.java index d4f3f6c..4bfb3c9 100644 --- a/src/main/java/cn/workde/module/drone/coding/controller/BatchesController.java +++ b/src/main/java/cn/workde/module/drone/coding/controller/BatchesController.java @@ -6,6 +6,7 @@ import cn.workde.core.constant.GrapeConst; import cn.workde.core.data.dto.Result; import cn.workde.module.drone.coding.dto.AttributeValueDto; import cn.workde.module.drone.coding.dto.BatchesDto; +import cn.workde.module.drone.coding.dto.CodeDto; import cn.workde.module.drone.coding.service.BatchesService; import cn.workde.module.drone.coding.vo.AttributeValueVo2; import cn.workde.module.drone.coding.vo.BatchesVo; @@ -106,5 +107,41 @@ public class BatchesController extends _BaseController { return batchesService.editAttributeValueBatch(vo); } + @PostMapping("/generateCode") + @Operation(summary = "生成批次") + @Parameters({ + @Parameter(name = "batchesId", description = "批次ID", required = true), + @Parameter(name = "count", description = "数量", required = true) + }) + public Result generateCode(String batchesId, Integer count) { + return batchesService.generateCode(batchesId, count); + } + + @GetMapping("/codePage") + @Operation(summary = "获取编码分页列表") + @Parameters({ + @Parameter(name = "current", description = "当前页", required = true), + @Parameter(name = "size", description = "每页数量", required = true), + @Parameter(name = "batchesId", description = "批次ID", required = true), + @Parameter(name = "batchesCode", description = "批次编码"), + @Parameter(name = "mfcId", description = "MFC ID"), + @Parameter(name = "mfcCode", description = "MFC编码"), + @Parameter(name = "ruleId", description = "规则ID"), + @Parameter(name = "ruleCode", description = "规则编码"), + @Parameter(name = "code", description = "编码"), + @Parameter(name = "snCode", description = "序列号") + }) + public Result> codePage(String batchesId, + String batchesCode, + String mfcId, + String mfcCode, + String ruleId, + String ruleCode, + String code, + String snCode) { + return batchesService.getCodePageList(getPage(), batchesId, batchesCode, mfcId, mfcCode, ruleId, ruleCode, code, snCode); + } + + } diff --git a/src/main/java/cn/workde/module/drone/coding/controller/CodeController.java b/src/main/java/cn/workde/module/drone/coding/controller/CodeController.java index f0c603b..be10c4f 100644 --- a/src/main/java/cn/workde/module/drone/coding/controller/CodeController.java +++ b/src/main/java/cn/workde/module/drone/coding/controller/CodeController.java @@ -2,10 +2,18 @@ package cn.workde.module.drone.coding.controller; import cn.workde.core.constant.GrapeConst; +import cn.workde.core.data.dto.Result; +import cn.workde.module.drone.coding.dto.AttributeValueDto; +import cn.workde.module.drone.coding.dto.CodeDto; import cn.workde.module.drone.coding.service.CodeService; import cn.workde.module.upms.controller._BaseController; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +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 jakarta.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -25,5 +33,40 @@ public class CodeController extends _BaseController { @Resource private CodeService codeService; - } + @GetMapping("/getAttributeValueDetail") + @Operation(summary = "获取属性值详情") + @Parameters({ + @Parameter(name = "code", description = "无人机编码", required = true) + }) + public Result getAttributeValueDetail(String code) { + return codeService.getAttributeValueDetail(code); + } + + @GetMapping("/getCodePageList") + @Operation(summary = "获取编码分页列表") + @Parameters({ + @Parameter(name = "current", description = "当前页", required = true), + @Parameter(name = "size", description = "每页数量", required = true), + @Parameter(name = "batchesId", description = "批次ID"), + @Parameter(name = "batchesCode", description = "批次编码"), + @Parameter(name = "mfcId", description = "MFC ID"), + @Parameter(name ="mfcCode", description = "MFC编码"), + @Parameter(name = "ruleId", description = "规则ID"), + @Parameter(name = "ruleCode", description = "规则编码"), + @Parameter(name = "code", description = "无人机编码"), + @Parameter(name = "snCode", description = "无人机序列号") + }) + public Result> getCodePageList(String batchesId, + String batchesCode, + String mfcId, + String mfcCode, + String ruleId, + String ruleCode, + String code, + String snCode + ) { + return codeService.getCodePageList(getPage(), batchesId, batchesCode, mfcId, mfcCode, ruleId, ruleCode, code, snCode); + } + +} diff --git a/src/main/java/cn/workde/module/drone/coding/service/BatchesService.java b/src/main/java/cn/workde/module/drone/coding/service/BatchesService.java index a60490c..8fc3f39 100644 --- a/src/main/java/cn/workde/module/drone/coding/service/BatchesService.java +++ b/src/main/java/cn/workde/module/drone/coding/service/BatchesService.java @@ -8,6 +8,7 @@ import cn.workde.core.base.BaseService; import cn.workde.core.data.dto.Result; import cn.workde.module.drone.coding.dto.AttributeValueDto; import cn.workde.module.drone.coding.dto.BatchesDto; +import cn.workde.module.drone.coding.dto.CodeDto; import cn.workde.module.drone.coding.entity.*; import cn.workde.module.drone.coding.mapper.BatchesMapper; import cn.workde.module.drone.coding.vo.AttributeValueVo2; @@ -257,5 +258,18 @@ public class BatchesService extends BaseService { return Result.success("操作成功"); } + public Result> getCodePageList(Page page, + String batchesId, + String batchesCode, + String mfcId, + String mfcCode, + String ruleId, + String ruleCode, + String code, + String snCode + ) { + return codeService.getCodePageList(page, batchesId, batchesCode, mfcId, mfcCode, ruleId, ruleCode, code, snCode); + } + } diff --git a/src/main/java/cn/workde/module/drone/coding/service/CodeService.java b/src/main/java/cn/workde/module/drone/coding/service/CodeService.java index 837b2ba..d44139b 100644 --- a/src/main/java/cn/workde/module/drone/coding/service/CodeService.java +++ b/src/main/java/cn/workde/module/drone/coding/service/CodeService.java @@ -10,6 +10,7 @@ import cn.workde.module.drone.coding.dto.AttributeValueDto; import cn.workde.module.drone.coding.dto.CodeDto; import cn.workde.module.drone.coding.entity.Code; import cn.workde.module.drone.coding.mapper.CodeMapper; +import cn.workde.module.drone.coding.wrapper.CodeWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import jakarta.annotation.Resource; @@ -244,14 +245,29 @@ public class CodeService extends BaseService{ return batchesService.getAttributeValueDetail(batches.getBatchesId()); } - public Result> getCodePageList(Page page, String batchesId, String mfcId, String ruleId, String code) { + public Result> getCodePageList(Page page, + String batchesId, + String batchesCode, + String mfcId, + String mfcCode, + String ruleId, + String ruleCode, + String code, + String snCode + ) { Page paged = page(page, new QueryWrapper() .lambda() .eq(StrUtil.isNotBlank(batchesId), Code::getBatchesId, batchesId) .eq(StrUtil.isNotBlank(mfcId), Code::getMfcId, mfcId) .eq(StrUtil.isNotBlank(ruleId), Code::getRuleId, ruleId) - .like(StrUtil.isNotBlank(code), Code::getCode, code)); - return Result.data(null); + .like(StrUtil.isNotBlank(code), Code::getCode, code) + .like(StrUtil.isNotBlank(batchesCode), Code::getBatchesCode, batchesCode) + .like(StrUtil.isNotBlank(mfcCode), Code::getMfcCode, mfcCode) + .like(StrUtil.isNotBlank(ruleCode), Code::getRuleCode, ruleCode) + .like(StrUtil.isNotBlank(snCode), Code::getSnCode, snCode) + .orderByDesc(Code::getCreatedAt) + ); + return Result.data(CodeWrapper.INSTANCE.toDto(paged)); }