数据编码服务中新增序列号生成逻辑
新增序列号生成服务,支持三种不同的编码规则: 1. 日期+递增数字(年月日或年月)。 2. 随机生成的8位序列号,包含大写字母和数字。 3. 默认规则,自增序列号。 实现具有不同前缀和后缀的序列号生成,包括年月日或年月作为前缀,校验位作为后缀。
This commit is contained in:
parent
4df8eb13ca
commit
c06d295092
|
@ -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<Page<CodeDto>> 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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<AttributeValueDto> 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<Page<CodeDto>> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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<BatchesMapper, Batches> {
|
|||
return Result.success("操作成功");
|
||||
}
|
||||
|
||||
public Result<Page<CodeDto>> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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<CodeMapper, Code>{
|
|||
return batchesService.getAttributeValueDetail(batches.getBatchesId());
|
||||
}
|
||||
|
||||
public Result<Page<CodeDto>> getCodePageList(Page page, String batchesId, String mfcId, String ruleId, String code) {
|
||||
public Result<Page<CodeDto>> getCodePageList(Page page,
|
||||
String batchesId,
|
||||
String batchesCode,
|
||||
String mfcId,
|
||||
String mfcCode,
|
||||
String ruleId,
|
||||
String ruleCode,
|
||||
String code,
|
||||
String snCode
|
||||
) {
|
||||
Page<Code> paged = page(page, new QueryWrapper<Code>()
|
||||
.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));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue