|
@@ -146,7 +146,8 @@ public class JtBusinessServiceImpl extends BaseMybatisDao<JtBusinessProjectMapp
|
|
|
// TODO Auto-generated method stub
|
|
// TODO Auto-generated method stub
|
|
|
// jtBusinessCategoryMapper.autoIncreaseSort(jtBusinessCategory.getLayer(),jtBusinessCategory.getSort());
|
|
// jtBusinessCategoryMapper.autoIncreaseSort(jtBusinessCategory.getLayer(),jtBusinessCategory.getSort());
|
|
|
if(jtBusinessCategory.getSuperId()!=null && jtBusinessCategory.getLayer().intValue()==1 && jtBusinessCategory.getSuperId().length()>0)return -2;
|
|
if(jtBusinessCategory.getSuperId()!=null && jtBusinessCategory.getLayer().intValue()==1 && jtBusinessCategory.getSuperId().length()>0)return -2;
|
|
|
- String number="BC";
|
|
|
|
|
|
|
+ //String number="BC";
|
|
|
|
|
+ String number=BusinessCategoryModule.getStatus(jtBusinessCategory.getModule()).toString();
|
|
|
if(jtBusinessCategory.getLayer().intValue()==2) {
|
|
if(jtBusinessCategory.getLayer().intValue()==2) {
|
|
|
//2层,先加第一层
|
|
//2层,先加第一层
|
|
|
//找到当前品类父级品类
|
|
//找到当前品类父级品类
|
|
@@ -224,67 +225,66 @@ public class JtBusinessServiceImpl extends BaseMybatisDao<JtBusinessProjectMapp
|
|
|
boolean moduleChange = null != jtBusinessCategory.getModule() ? !jtBusinessCategory.getModule().equals(jtBusinessCategory.getNextModule()) : false;
|
|
boolean moduleChange = null != jtBusinessCategory.getModule() ? !jtBusinessCategory.getModule().equals(jtBusinessCategory.getNextModule()) : false;
|
|
|
//是否有上级id
|
|
//是否有上级id
|
|
|
boolean existSuperId = StringUtils.isNotBlank(jtBusinessCategory.getSuperId());
|
|
boolean existSuperId = StringUtils.isNotBlank(jtBusinessCategory.getSuperId());
|
|
|
|
|
+ //获得更改前的自己的number
|
|
|
|
|
+ String oldNumber = jtBusinessCategoryMapper.selectByPrimaryKey(jtBusinessCategory.getId()).getNumber();
|
|
|
|
|
+ String number = null;
|
|
|
//一级更换模块
|
|
//一级更换模块
|
|
|
if(moduleChange && !existSuperId){
|
|
if(moduleChange && !existSuperId){
|
|
|
|
|
+ jtBusinessCategory.setLayer(1);
|
|
|
//根据模块获得字母前缀
|
|
//根据模块获得字母前缀
|
|
|
String prefix = BusinessCategoryModule.getStatus(jtBusinessCategory.getNextModule()).toString();
|
|
String prefix = BusinessCategoryModule.getStatus(jtBusinessCategory.getNextModule()).toString();
|
|
|
- //获得当前更改后模块的最大值
|
|
|
|
|
-
|
|
|
|
|
- //将最大值加一
|
|
|
|
|
- //得到sort
|
|
|
|
|
- //将模块前面字母替换
|
|
|
|
|
|
|
+ jtBusinessCategory.setNumber(prefix + "__");
|
|
|
|
|
+ number = prefix;
|
|
|
|
|
+ category.setModule(jtBusinessCategory.getNextModule());
|
|
|
|
|
+ jtBusinessCategory.setModule(jtBusinessCategory.getNextModule());
|
|
|
}
|
|
}
|
|
|
//存在上级说明是二级修改到不同模块的某品类中
|
|
//存在上级说明是二级修改到不同模块的某品类中
|
|
|
if(existSuperId){
|
|
if(existSuperId){
|
|
|
|
|
+ JtBusinessCategory b = jtBusinessCategoryMapper.selectByPrimaryKey(jtBusinessCategory.getSuperId());
|
|
|
|
|
+ category.setModule(b.getModule());
|
|
|
|
|
+ jtBusinessCategory.setLayer(2);
|
|
|
|
|
+ jtBusinessCategory.setModule(b.getModule());
|
|
|
|
|
|
|
|
- //根据更改后的上级id获得模块,得到对应的字母
|
|
|
|
|
- //获得当前更改后模块的最大值
|
|
|
|
|
- //将最大值加一
|
|
|
|
|
- //得到sort
|
|
|
|
|
- //将模块前面字母替换
|
|
|
|
|
|
|
+ number = b.getNumber();
|
|
|
|
|
+ //获得前缀
|
|
|
|
|
+ String prefix = BusinessCategoryModule.getStatus(b.getModule()).toString();
|
|
|
|
|
+ number = prefix + number.substring(prefix.length()) ;
|
|
|
|
|
+ jtBusinessCategory.setNumber(number + "__");
|
|
|
|
|
+ category.setSuperId(jtBusinessCategory.getSuperId());//上级id也要修改
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //获得上级id
|
|
|
|
|
- //只修改基本数据
|
|
|
|
|
- //jtBusinessCategoryMapper.updateByPrimaryKeySelective(jtBusinessCategory);
|
|
|
|
|
- if(StringUtils.isNotBlank(jtBusinessCategory.getSuperId()) && StringUtils.isNotBlank(jtBusinessCategory.getOldSuperId())){
|
|
|
|
|
- //获得修改前品类id
|
|
|
|
|
- //获得修改后品类id
|
|
|
|
|
- //修改前后id不相等执行以下操作
|
|
|
|
|
- if(!jtBusinessCategory.getSuperId().equals(jtBusinessCategory.getOldSuperId())){
|
|
|
|
|
- //获得修改前品类number1
|
|
|
|
|
- String oldNumber = jtBusinessCategoryMapper.selectByPrimaryKey(jtBusinessCategory.getOldSuperId()).getNumber();
|
|
|
|
|
- //获得修改后品类number2
|
|
|
|
|
- String number = jtBusinessCategoryMapper.selectByPrimaryKey(jtBusinessCategory.getSuperId()).getNumber();
|
|
|
|
|
- //根据修改后的品类id获得最大同级number
|
|
|
|
|
- String newNumber = jtBusinessCategoryMapper.getCurrentMaxNumber(number);
|
|
|
|
|
- Integer n = null != newNumber ? Integer.valueOf(newNumber.substring(newNumber.length() - 2)) : 0;
|
|
|
|
|
- if(n < 99){
|
|
|
|
|
- n += 1;
|
|
|
|
|
- newNumber = newNumber.substring(0,newNumber.length() - 3) + (n<10? "0"+ n : n);
|
|
|
|
|
- } else {
|
|
|
|
|
- newNumber = jtBusinessCategoryMapper.getCurrentMinNumber(number);
|
|
|
|
|
- n = Integer.valueOf(newNumber.substring(newNumber.length() - 2));
|
|
|
|
|
- if(n == 1 || n == 01){
|
|
|
|
|
- return -1;
|
|
|
|
|
- }
|
|
|
|
|
- n -= 1;
|
|
|
|
|
- newNumber = newNumber.substring(0,newNumber.length() - 3) + (n<10? "0"+ n : n);
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- //更新数据
|
|
|
|
|
- jtBusinessCategory.setNumber(oldNumber);
|
|
|
|
|
- jtBusinessCategory.setSort(number.length() + 1);
|
|
|
|
|
- jtBusinessCategory.setName(newNumber);
|
|
|
|
|
- //jtBusinessCategoryMapper.updateNumberPrefix(jtBusinessCategory);
|
|
|
|
|
|
|
+ if((!moduleChange && !existSuperId) && !existSuperId){
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ //获得当前更改后模块的最大值
|
|
|
|
|
+ String newNumber = jtBusinessCategoryMapper.getCurrentMaxNumber(jtBusinessCategory);
|
|
|
|
|
+ Integer n = null != newNumber ? Integer.valueOf(newNumber.substring(newNumber.length() - 2)) : 0;
|
|
|
|
|
+ if(n < 99){
|
|
|
|
|
+ //将最大值加一
|
|
|
|
|
+ n += 1;
|
|
|
|
|
+ newNumber = number + (n<10? "0"+ n : n);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ newNumber = jtBusinessCategoryMapper.getCurrentMaxNumber(jtBusinessCategory);
|
|
|
|
|
+ n = Integer.valueOf(newNumber.substring(newNumber.length() - 2));
|
|
|
|
|
+ if(n == 1 || n == 01){
|
|
|
|
|
+ return -1;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ //将最小值减一
|
|
|
|
|
+ n -= 1;
|
|
|
|
|
+ newNumber = number + (n<10? "0"+ n : n);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //修改自己和自己下级的前缀
|
|
|
|
|
+ jtBusinessCategory.setLayer(newNumber.length() + 1);//截取前缀的长度位置
|
|
|
|
|
+ jtBusinessCategory.setNumber(oldNumber + "%");
|
|
|
|
|
+ jtBusinessCategory.setName(newNumber );
|
|
|
|
|
+ //将模块前面字母替换
|
|
|
|
|
+ jtBusinessCategoryMapper.updateNumberPrefix(jtBusinessCategory);
|
|
|
|
|
+ //得到sort
|
|
|
|
|
+ category.setSort(n);
|
|
|
|
|
+ //修改自己的number
|
|
|
|
|
+ category.setNumber(newNumber);
|
|
|
|
|
+ //修改自己的模块
|
|
|
|
|
+ jtBusinessCategoryMapper.updateByPrimaryKeySelective(category);
|
|
|
return 1;//jtBusinessCategoryMapper.updateByPrimaryKeySelective(jtBusinessCategory);
|
|
return 1;//jtBusinessCategoryMapper.updateByPrimaryKeySelective(jtBusinessCategory);
|
|
|
}
|
|
}
|
|
|
|
|
|