Browse Source

Merge remote-tracking branch 'origin/dev_1118' into dev_1118

dev
尹作梅 6 years ago
parent
commit
0af3ac8c8b
  1. 232
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/impl/CategoryServiceImpl.java

232
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/impl/CategoryServiceImpl.java

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

Loading…
Cancel
Save