新增MES库区管理功能,包含免密接口、数据处理逻辑及相关控制器、服务和实体的实现。支持库区的增删改查操作,优化用户体验并增强系统的实时数据同步能力。
This commit is contained in:
@@ -31,7 +31,6 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
||||
|
||||
@Override
|
||||
public void addSysCategory(SysCategory sysCategory) {
|
||||
String categoryCode = "";
|
||||
String categoryPid = ISysCategoryService.ROOT_PID_VALUE;
|
||||
String parentCode = null;
|
||||
if(oConvertUtils.isNotEmpty(sysCategory.getPid())){
|
||||
@@ -47,11 +46,23 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
||||
}
|
||||
}
|
||||
}
|
||||
// 代码逻辑说明: 分类字典编码规则生成器做成公用配置
|
||||
JSONObject formData = new JSONObject();
|
||||
formData.put("pid",categoryPid);
|
||||
categoryCode = (String) FillRuleUtil.executeRule(FillRuleConstant.CATEGORY,formData);
|
||||
sysCategory.setCode(categoryCode);
|
||||
// 编码处理:
|
||||
// ① 前端传入了编码 → 使用前端传入值(允许用户自定义编码);
|
||||
// ② 前端未传 → 按规则自动生成(保留原行为);
|
||||
// ③ 防止重复:自定义编码先查一次是否已存在,存在则抛业务异常。
|
||||
if(oConvertUtils.isEmpty(sysCategory.getCode())){
|
||||
JSONObject formData = new JSONObject();
|
||||
formData.put("pid",categoryPid);
|
||||
String categoryCode = (String) FillRuleUtil.executeRule(FillRuleConstant.CATEGORY,formData);
|
||||
sysCategory.setCode(categoryCode);
|
||||
} else {
|
||||
String customCode = sysCategory.getCode().trim();
|
||||
long exists = this.count(new LambdaQueryWrapper<SysCategory>().eq(SysCategory::getCode, customCode));
|
||||
if(exists > 0){
|
||||
throw new JeecgBootException("分类编码【"+customCode+"】已存在,请更换!");
|
||||
}
|
||||
sysCategory.setCode(customCode);
|
||||
}
|
||||
sysCategory.setPid(categoryPid);
|
||||
baseMapper.insert(sysCategory);
|
||||
}
|
||||
@@ -68,6 +79,18 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
||||
baseMapper.updateById(parent);
|
||||
}
|
||||
}
|
||||
// 编辑模式编码重复校验:用户改成已存在的编码(非自身记录)时拒绝保存。
|
||||
// 编码为空时跳过校验(保留旧值由数据库层面控制)。
|
||||
if(oConvertUtils.isNotEmpty(sysCategory.getCode())){
|
||||
String newCode = sysCategory.getCode().trim();
|
||||
long exists = this.count(new LambdaQueryWrapper<SysCategory>()
|
||||
.eq(SysCategory::getCode, newCode)
|
||||
.ne(SysCategory::getId, sysCategory.getId()));
|
||||
if(exists > 0){
|
||||
throw new JeecgBootException("分类编码【"+newCode+"】已存在,请更换!");
|
||||
}
|
||||
sysCategory.setCode(newCode);
|
||||
}
|
||||
baseMapper.updateById(sysCategory);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user