数据编码服务中新增序列号生成逻辑
新增序列号生成服务,支持三种不同的编码规则: 1. 日期+递增数字(年月日或年月)。 2. 随机生成的8位序列号,包含大写字母和数字。 3. 默认规则,自增序列号。 实现具有不同前缀和后缀的序列号生成,包括年月日或年月作为前缀,校验位作为后缀。
This commit is contained in:
parent
da9145e29c
commit
302f28e57c
|
@ -5,11 +5,14 @@ import cn.hutool.core.util.ObjUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.workde.core.base.BaseService;
|
||||
import cn.workde.core.data.dto.Result;
|
||||
import cn.workde.module.drone.coding.entity.Attribute;
|
||||
import cn.workde.module.drone.coding.entity.AttributeClassification;
|
||||
import cn.workde.module.drone.coding.mapper.AttributeClassificationMapper;
|
||||
import cn.workde.module.drone.coding.vo.AttributeClassificationVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -23,6 +26,9 @@ import java.util.List;
|
|||
@Service("attributeClassificationService")
|
||||
public class AttributeClassificationService extends BaseService<AttributeClassificationMapper, AttributeClassification> {
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private AttributeService attributeService;
|
||||
private String check(String id, AttributeClassificationVo vo){
|
||||
String message = "";
|
||||
String attributeClassificationName = vo.getAttributeClassificationName();
|
||||
|
@ -63,6 +69,13 @@ public class AttributeClassificationService extends BaseService<AttributeClassif
|
|||
if (ObjUtil.isNull(this.getById(id))) {
|
||||
return Result.fail("数据不存在");
|
||||
}
|
||||
long count = attributeService.count(new QueryWrapper<Attribute>()
|
||||
.lambda()
|
||||
.eq(Attribute::getAttributeClassificationId, id)
|
||||
);
|
||||
if (count > 0) {
|
||||
return Result.fail("请先删除该分类下的属性");
|
||||
}
|
||||
return this.removeById(id) ? Result.success("操作成功") : Result.fail("操作失败");
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,14 @@ import cn.workde.core.data.dto.Result;
|
|||
import cn.workde.core.util.SpringUtil;
|
||||
import cn.workde.module.drone.coding.dto.AttributeDto;
|
||||
import cn.workde.module.drone.coding.entity.Attribute;
|
||||
import cn.workde.module.drone.coding.entity.AttributeValue;
|
||||
import cn.workde.module.drone.coding.mapper.AttributeMapper;
|
||||
import cn.workde.module.drone.coding.vo.AttributeVo;
|
||||
import cn.workde.module.drone.coding.wrapper.AttributeWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -26,6 +29,10 @@ import java.util.List;
|
|||
@Service("attributeService")
|
||||
public class AttributeService extends BaseService<AttributeMapper, Attribute> {
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private AttributeValueService attributeValueService;
|
||||
|
||||
private String check(String id, AttributeVo vo) {
|
||||
String message = "";
|
||||
AttributeClassificationService attributeClassificationService = SpringUtil.getBean(AttributeClassificationService.class);
|
||||
|
@ -70,6 +77,13 @@ public class AttributeService extends BaseService<AttributeMapper, Attribute> {
|
|||
if (ObjUtil.isNull(this.getById(id))) {
|
||||
return Result.fail("数据不存在");
|
||||
}
|
||||
long count = attributeValueService.count(new QueryWrapper<AttributeValue>()
|
||||
.lambda()
|
||||
.eq(AttributeValue::getAttributeId, id)
|
||||
);
|
||||
if (count > 0) {
|
||||
return Result.fail("该属性已绑定属性值,请先解除绑定");
|
||||
}
|
||||
return this.removeById(id) ? Result.success("操作成功") : Result.fail("操作失败");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue