|
@@ -6,6 +6,7 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
+import org.apache.poi.poifs.property.Child;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -102,25 +103,39 @@ public class JtBusinessServiceImpl extends BaseMybatisDao<JtBusinessProjectMapp
|
|
|
if(jtBusinessCategory.getSuperId()!=null && jtBusinessCategory.getLayer().intValue()==1)return -2;
|
|
if(jtBusinessCategory.getSuperId()!=null && jtBusinessCategory.getLayer().intValue()==1)return -2;
|
|
|
String number="BC";
|
|
String number="BC";
|
|
|
if(jtBusinessCategory.getLayer().intValue()==2) {
|
|
if(jtBusinessCategory.getLayer().intValue()==2) {
|
|
|
|
|
+ //2层,先加第一层
|
|
|
|
|
+ //找到当前品类父级品类
|
|
|
JtBusinessCategory sp=jtBusinessCategoryMapper.selectByPrimaryKey(jtBusinessCategory.getSuperId());
|
|
JtBusinessCategory sp=jtBusinessCategoryMapper.selectByPrimaryKey(jtBusinessCategory.getSuperId());
|
|
|
if(sp==null || sp.getLayer()!=1) {
|
|
if(sp==null || sp.getLayer()!=1) {
|
|
|
|
|
+ //找到的父级品类层数不是1 或者未找到
|
|
|
return -2;
|
|
return -2;
|
|
|
}
|
|
}
|
|
|
- //加前前层
|
|
|
|
|
|
|
+ //加前层
|
|
|
|
|
+ //父级品类层数为1的情况下 第一层编号为父级sort序号
|
|
|
int size1=sp.getSort();
|
|
int size1=sp.getSort();
|
|
|
- if(size1>99)return -size1;
|
|
|
|
|
|
|
+ if(size1>99)return -1;
|
|
|
if(size1<10)number+="0";
|
|
if(size1<10)number+="0";
|
|
|
number+=size1;
|
|
number+=size1;
|
|
|
}
|
|
}
|
|
|
- //加前层
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //加层
|
|
|
|
|
+ int size2;
|
|
|
|
|
+ //通过父级id获取当前层列表
|
|
|
List<JtBusinessCategory>businessCategories =jtBusinessCategoryMapper.getBusinessCategoryBySuperId(jtBusinessCategory.getSuperId(), null);
|
|
List<JtBusinessCategory>businessCategories =jtBusinessCategoryMapper.getBusinessCategoryBySuperId(jtBusinessCategory.getSuperId(), null);
|
|
|
- int size2=businessCategories.size()+1;
|
|
|
|
|
|
|
+ //列表为0,当前层编号size2设置为1,大于0 设置为当前最大sort+1
|
|
|
|
|
+ if(businessCategories.size()>0)
|
|
|
|
|
+ size2=businessCategories.get(businessCategories.size()-1).getSort()+1;
|
|
|
|
|
+ else size2=1;
|
|
|
|
|
+ //每层最多99个
|
|
|
if(size2>99)return -1;
|
|
if(size2>99)return -1;
|
|
|
|
|
+ //增加0
|
|
|
if(size2<10)number+="0";
|
|
if(size2<10)number+="0";
|
|
|
|
|
+ //完成编号
|
|
|
number+=size2;
|
|
number+=size2;
|
|
|
jtBusinessCategory.setNumber(number);
|
|
jtBusinessCategory.setNumber(number);
|
|
|
- if(businessCategories==null )jtBusinessCategory.setSort(1);
|
|
|
|
|
- else jtBusinessCategory.setSort(businessCategories.size()+1);
|
|
|
|
|
|
|
+ //设置sort序号
|
|
|
|
|
+ jtBusinessCategory.setSort(size2);
|
|
|
jtBusinessCategory.setCreateTime(new Date());
|
|
jtBusinessCategory.setCreateTime(new Date());
|
|
|
jtBusinessCategory.setId(UUID.randomUUID().toString());
|
|
jtBusinessCategory.setId(UUID.randomUUID().toString());
|
|
|
return jtBusinessCategoryMapper.insertSelective(jtBusinessCategory);
|
|
return jtBusinessCategoryMapper.insertSelective(jtBusinessCategory);
|
|
@@ -129,6 +144,17 @@ public class JtBusinessServiceImpl extends BaseMybatisDao<JtBusinessProjectMapp
|
|
|
@Override
|
|
@Override
|
|
|
public int deleteCategoryById(String id) {
|
|
public int deleteCategoryById(String id) {
|
|
|
// TODO Auto-generated method stub
|
|
// TODO Auto-generated method stub
|
|
|
|
|
+ //查找品类
|
|
|
|
|
+ JtBusinessCategory sp=jtBusinessCategoryMapper.selectByPrimaryKey(id);
|
|
|
|
|
+ //查找子品类 存在子品类不允许删除
|
|
|
|
|
+ List<JtBusinessCategory> chidren=jtBusinessCategoryMapper.getBusinessCategoryBySuperId(sp.getId(), null);
|
|
|
|
|
+ if(chidren.size()>0) {
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<JtBusinessProject> childrenProject=jtBusinessProjectMapper.getBusinessProjectByCategoryId(id, 100);
|
|
|
|
|
+ if(childrenProject!= null && childrenProject.size()>0) {
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
return jtBusinessCategoryMapper.deleteByPrimaryKey(id);
|
|
return jtBusinessCategoryMapper.deleteByPrimaryKey(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -164,5 +190,37 @@ public class JtBusinessServiceImpl extends BaseMybatisDao<JtBusinessProjectMapp
|
|
|
return params;
|
|
return params;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int insertProject(JtBusinessProject jtBusinessProject) {
|
|
|
|
|
+ // TODO Auto-generated method stub
|
|
|
|
|
+ jtBusinessProject.setCreateTime(new Date());
|
|
|
|
|
+ jtBusinessProject.setId(UUID.randomUUID().toString());
|
|
|
|
|
+ List<JtBusinessProject>projects=jtBusinessProjectMapper.findProjectOrderByNumber();
|
|
|
|
|
+ int cSize = 1;
|
|
|
|
|
+ if(projects!=null && projects.size()>0)
|
|
|
|
|
+ {
|
|
|
|
|
+ String number=projects.get(projects.size()-1).getNumber();
|
|
|
|
|
+ if(number!=null && number.length()==6)
|
|
|
|
|
+ {
|
|
|
|
|
+ String nbString=number.substring(2);
|
|
|
|
|
+ try {
|
|
|
|
|
+ cSize=Integer.parseInt(nbString)+1;}catch (Exception e) {
|
|
|
|
|
+ // TODO: handle exception
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else cSize=1;
|
|
|
|
|
+ }
|
|
|
|
|
+ else cSize=1;
|
|
|
|
|
+
|
|
|
|
|
+ String nbString="BP";
|
|
|
|
|
+ String sizeString="000"+cSize;
|
|
|
|
|
+ sizeString=sizeString.substring(sizeString.length()-4);
|
|
|
|
|
+ nbString+=sizeString;
|
|
|
|
|
+ jtBusinessProject.setNumber(nbString);
|
|
|
|
|
+ jtBusinessProjectMapper.insertSelective(jtBusinessProject);
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|