|
|
@ -286,23 +286,27 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn |
|
|
|
numm -= 1; |
|
|
|
} |
|
|
|
//一级分类
|
|
|
|
String firstClassName = ""; |
|
|
|
String firstClassName = "领域1"; |
|
|
|
Long firstClassId = 0L; |
|
|
|
Integer firstClassSort = Integer.parseInt(numm+""); |
|
|
|
String firstClassInfoCode = "-1"; |
|
|
|
//二级分类
|
|
|
|
String secondClassName = ""; |
|
|
|
String secondClassName = "大类2"; |
|
|
|
Long secondClassId = 0L; |
|
|
|
Integer secondClassSort = -1; |
|
|
|
String secondClassInfoCode = "-1"; |
|
|
|
//三级分类
|
|
|
|
String thirdClassName = ""; |
|
|
|
String thirdClassName = "小类3"; |
|
|
|
Long thirdClassId = 0L; |
|
|
|
Integer thirdClassSort = -1; |
|
|
|
String thirdClassInfoCode = "-1"; |
|
|
|
//四级分类
|
|
|
|
String fourthClassName = ""; |
|
|
|
String fourthClassName = "细类4"; |
|
|
|
Long fourthClassId = 0L; |
|
|
|
Integer fourthClassSort = -1; |
|
|
|
// 循环Excel行数(不要表头,从2开始) ;0是excle表头、1是列名
|
|
|
|
for (int r = 2; r < totalRows; r++) { |
|
|
|
String fourthClassInfoCode = "-1"; |
|
|
|
// 循环Excel行数(不要列名,从1开始) ;0是列名
|
|
|
|
for (int r = 1; r < totalRows; r++) { |
|
|
|
Row row = sheet.getRow(r); |
|
|
|
if (row == null) { |
|
|
|
continue; |
|
|
@ -312,50 +316,81 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn |
|
|
|
String secondClassNameCurrent = "";//本行二级分类
|
|
|
|
String thirdClassNameCurrent = "";//本行三级分类
|
|
|
|
String fourthClassNameCurrent = "";//本行四级分类
|
|
|
|
for (int c = 1; c < 5; c++) { |
|
|
|
for (int c = 0; c < 8; c++) { |
|
|
|
Cell cell = row.getCell(c); |
|
|
|
if (null != cell) { |
|
|
|
if (c == 1) { |
|
|
|
if (c == 0) { |
|
|
|
//领域列编号
|
|
|
|
String value = getCellContent(cell); |
|
|
|
if(!"".equals(value) && !firstClassInfoCode.equals(value)){ |
|
|
|
firstClassInfoCode = value; |
|
|
|
} |
|
|
|
}else if (c == 1) { |
|
|
|
//领域列
|
|
|
|
firstClassNameCurrent = ""; |
|
|
|
String value = getCellContent(cell); |
|
|
|
if(!"".equals(value)){ |
|
|
|
if(!"".equals(value) && !firstClassName.equals(value)){ |
|
|
|
firstClassName = value; |
|
|
|
firstClassNameCurrent = value; |
|
|
|
firstClassId = getLongRandom(); |
|
|
|
firstClassSort++; |
|
|
|
//重置子字段
|
|
|
|
secondClassSort = -1; |
|
|
|
thirdClassSort = -1; |
|
|
|
fourthClassSort = -1; |
|
|
|
secondClassName = "大类2"; |
|
|
|
thirdClassName = "小类3"; |
|
|
|
fourthClassName = "细类4"; |
|
|
|
} |
|
|
|
}else if (c == 2) { |
|
|
|
//大类列编号
|
|
|
|
String value = getCellContent(cell); |
|
|
|
if(!"".equals(value) && !secondClassInfoCode.equals(value)){ |
|
|
|
secondClassInfoCode = value; |
|
|
|
} |
|
|
|
}else if (c == 3) { |
|
|
|
//大类列
|
|
|
|
secondClassNameCurrent = ""; |
|
|
|
String value = getCellContent(cell); |
|
|
|
if(!"".equals(value)){ |
|
|
|
if(!"".equals(value) && !secondClassName.equals(value)){ |
|
|
|
secondClassName = value; |
|
|
|
secondClassNameCurrent = value; |
|
|
|
secondClassId = getLongRandom(); |
|
|
|
secondClassSort++; |
|
|
|
thirdClassSort = -1; |
|
|
|
fourthClassSort = -1; |
|
|
|
thirdClassName = "小类3"; |
|
|
|
fourthClassName = "细类4"; |
|
|
|
} |
|
|
|
} else if (c == 3) { |
|
|
|
} else if (c == 4) { |
|
|
|
//小类列编号
|
|
|
|
String value = getCellContent(cell); |
|
|
|
if(!"".equals(value) && !thirdClassInfoCode.equals(value)){ |
|
|
|
thirdClassInfoCode = value; |
|
|
|
} |
|
|
|
}else if (c == 5) { |
|
|
|
//小类列
|
|
|
|
thirdClassNameCurrent = ""; |
|
|
|
String value = getCellContent(cell); |
|
|
|
if(!"".equals(value)){ |
|
|
|
if(!"".equals(value) && !thirdClassName.equals(value)){ |
|
|
|
thirdClassName = value; |
|
|
|
thirdClassNameCurrent = value; |
|
|
|
thirdClassId = getLongRandom(); |
|
|
|
thirdClassSort++; |
|
|
|
fourthClassSort = -1; |
|
|
|
fourthClassName = "细类4"; |
|
|
|
} |
|
|
|
} else if (c == 4) { |
|
|
|
}else if (c == 6) { |
|
|
|
//细类名称列编号
|
|
|
|
String value = getCellContent(cell); |
|
|
|
if(!"".equals(value) && !fourthClassInfoCode.equals(value)){ |
|
|
|
fourthClassInfoCode = value; |
|
|
|
} |
|
|
|
} else if (c == 7) { |
|
|
|
//细类名称列
|
|
|
|
fourthClassNameCurrent = ""; |
|
|
|
String value = getCellContent(cell); |
|
|
|
if(!"".equals(value)){ |
|
|
|
if(!"".equals(value) && !fourthClassName.equals(value)){ |
|
|
|
fourthClassName = value; |
|
|
|
fourthClassNameCurrent = value; |
|
|
|
fourthClassId = getLongRandom(); |
|
|
@ -366,28 +401,28 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn |
|
|
|
} |
|
|
|
if(!"".equals(firstClassNameCurrent)){ |
|
|
|
//领域
|
|
|
|
CategoryEntity insertEntity = getCategoryEntity(firstClassId,0L,"0",firstClassName, |
|
|
|
firstClassId+"","0",firstClassSort,0,""); |
|
|
|
CategoryEntity insertEntity = getCategoryEntity(firstClassId,0L,"0",firstClassInfoCode,firstClassName, |
|
|
|
firstClassInfoCode,"0",firstClassSort,0,""); |
|
|
|
list.add(insertEntity); |
|
|
|
} |
|
|
|
if(!"".equals(secondClassNameCurrent)){ |
|
|
|
//大类
|
|
|
|
CategoryEntity insertEntity = getCategoryEntity(secondClassId,firstClassId,firstClassId+"",secondClassName, |
|
|
|
secondClassId+"","1",secondClassSort,0,firstClassName); |
|
|
|
CategoryEntity insertEntity = getCategoryEntity(secondClassId,firstClassId,firstClassId+"",secondClassInfoCode,secondClassName, |
|
|
|
firstClassInfoCode+secondClassInfoCode,"1",secondClassSort,0,firstClassName); |
|
|
|
list.add(insertEntity); |
|
|
|
} |
|
|
|
if(!"".equals(thirdClassNameCurrent)){ |
|
|
|
//小类
|
|
|
|
String pids = firstClassId + "," + secondClassId + ""; |
|
|
|
CategoryEntity insertEntity = getCategoryEntity(thirdClassId,secondClassId,pids,thirdClassName, |
|
|
|
thirdClassId+"","2",thirdClassSort,0,secondClassName); |
|
|
|
CategoryEntity insertEntity = getCategoryEntity(thirdClassId,secondClassId,pids,thirdClassInfoCode,thirdClassName, |
|
|
|
firstClassInfoCode+secondClassInfoCode+thirdClassInfoCode,"2",thirdClassSort,0,secondClassName); |
|
|
|
list.add(insertEntity); |
|
|
|
} |
|
|
|
if(!"".equals(fourthClassNameCurrent)){ |
|
|
|
//细分类
|
|
|
|
String pids = firstClassId + "," + secondClassId + "," + thirdClassId + ""; |
|
|
|
CategoryEntity insertEntity = getCategoryEntity(fourthClassId,thirdClassId,pids,fourthClassName, |
|
|
|
fourthClassId+"","3",fourthClassSort,0,thirdClassName); |
|
|
|
CategoryEntity insertEntity = getCategoryEntity(fourthClassId,thirdClassId,pids,fourthClassInfoCode,fourthClassName, |
|
|
|
firstClassInfoCode+secondClassInfoCode+thirdClassInfoCode+fourthClassInfoCode,"3",fourthClassSort,0,thirdClassName); |
|
|
|
list.add(insertEntity); |
|
|
|
} |
|
|
|
} |
|
|
@ -424,9 +459,9 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn |
|
|
|
value = cell.getStringCellValue(); |
|
|
|
} |
|
|
|
//内容超过25个字进行长度限制,否则数据库会超限
|
|
|
|
if(value.length() > 25){ |
|
|
|
/*if(value.length() > 25){ |
|
|
|
value = value.substring(0,25) + "..."; |
|
|
|
} |
|
|
|
}*/ |
|
|
|
return value; |
|
|
|
} |
|
|
|
|
|
|
@ -460,12 +495,13 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn |
|
|
|
* @param delFlag 删除标识 0:未删除 1:删除 |
|
|
|
* @param parentName 上级部门名称 |
|
|
|
*/ |
|
|
|
public CategoryEntity getCategoryEntity(Long id,Long pid,String pids,String categoryName,String categoryCode, |
|
|
|
public CategoryEntity getCategoryEntity(Long id,Long pid,String pids,String InfoCode,String categoryName,String categoryCode, |
|
|
|
String categoryType,Integer sort,Integer delFlag,String parentName) { |
|
|
|
CategoryEntity entity = new CategoryEntity(); |
|
|
|
Long userId = SecurityUser.getUserId(); |
|
|
|
entity.setId(id); |
|
|
|
entity.setPid(pid); |
|
|
|
entity.setInfoCode(InfoCode); |
|
|
|
entity.setPids(pids); |
|
|
|
entity.setCategoryName(categoryName);//分类名称
|
|
|
|
entity.setCategoryCode(categoryCode);//分类编码(暂时使用ID)
|
|
|
|