Browse Source

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

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

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

@ -286,23 +286,27 @@ 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是列名
for (int r = 1; r < totalRows; r++) {
Row row = sheet.getRow(r); Row row = sheet.getRow(r);
if (row == null) { if (row == null) {
continue; continue;
@ -312,50 +316,81 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
String secondClassNameCurrent = "";//本行二级分类 String secondClassNameCurrent = "";//本行二级分类
String thirdClassNameCurrent = "";//本行三级分类 String thirdClassNameCurrent = "";//本行三级分类
String fourthClassNameCurrent = "";//本行四级分类 String fourthClassNameCurrent = "";//本行四级分类
for (int c = 1; c < 5; c++) { for (int c = 0; c < 8; c++) {
Cell cell = row.getCell(c); Cell cell = row.getCell(c);
if (null != cell) { 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 = ""; firstClassNameCurrent = "";
String value = getCellContent(cell); String value = getCellContent(cell);
if(!"".equals(value)){ if(!"".equals(value) && !firstClassName.equals(value)){
firstClassName = value; firstClassName = value;
firstClassNameCurrent = value; firstClassNameCurrent = value;
firstClassId = getLongRandom(); firstClassId = getLongRandom();
firstClassSort++; firstClassSort++;
//重置子字段
secondClassSort = -1; secondClassSort = -1;
thirdClassSort = -1; thirdClassSort = -1;
fourthClassSort = -1; fourthClassSort = -1;
secondClassName = "大类2";
thirdClassName = "小类3";
fourthClassName = "细类4";
} }
}else if (c == 2) { }else if (c == 2) {
//大类列编号
String value = getCellContent(cell);
if(!"".equals(value) && !secondClassInfoCode.equals(value)){
secondClassInfoCode = value;
}
}else if (c == 3) {
//大类列 //大类列
secondClassNameCurrent = ""; secondClassNameCurrent = "";
String value = getCellContent(cell); String value = getCellContent(cell);
if(!"".equals(value)){ if(!"".equals(value) && !secondClassName.equals(value)){
secondClassName = value; secondClassName = value;
secondClassNameCurrent = value; secondClassNameCurrent = value;
secondClassId = getLongRandom(); secondClassId = getLongRandom();
secondClassSort++; secondClassSort++;
thirdClassSort = -1; thirdClassSort = -1;
fourthClassSort = -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 = ""; thirdClassNameCurrent = "";
String value = getCellContent(cell); String value = getCellContent(cell);
if(!"".equals(value)){ if(!"".equals(value) && !thirdClassName.equals(value)){
thirdClassName = value; thirdClassName = value;
thirdClassNameCurrent = value; thirdClassNameCurrent = value;
thirdClassId = getLongRandom(); thirdClassId = getLongRandom();
thirdClassSort++; thirdClassSort++;
fourthClassSort = -1; 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 = ""; fourthClassNameCurrent = "";
String value = getCellContent(cell); String value = getCellContent(cell);
if(!"".equals(value)){ if(!"".equals(value) && !fourthClassName.equals(value)){
fourthClassName = value; fourthClassName = value;
fourthClassNameCurrent = value; fourthClassNameCurrent = value;
fourthClassId = getLongRandom(); fourthClassId = getLongRandom();
@ -366,28 +401,28 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
} }
if(!"".equals(firstClassNameCurrent)){ if(!"".equals(firstClassNameCurrent)){
//领域 //领域
CategoryEntity insertEntity = getCategoryEntity(firstClassId,0L,"0",firstClassName, CategoryEntity insertEntity = getCategoryEntity(firstClassId,0L,"0",firstClassInfoCode,firstClassName,
firstClassId+"","0",firstClassSort,0,""); firstClassInfoCode,"0",firstClassSort,0,"");
list.add(insertEntity); list.add(insertEntity);
} }
if(!"".equals(secondClassNameCurrent)){ if(!"".equals(secondClassNameCurrent)){
//大类 //大类
CategoryEntity insertEntity = getCategoryEntity(secondClassId,firstClassId,firstClassId+"",secondClassName, CategoryEntity insertEntity = getCategoryEntity(secondClassId,firstClassId,firstClassId+"",secondClassInfoCode,secondClassName,
secondClassId+"","1",secondClassSort,0,firstClassName); firstClassInfoCode+secondClassInfoCode,"1",secondClassSort,0,firstClassName);
list.add(insertEntity); list.add(insertEntity);
} }
if(!"".equals(thirdClassNameCurrent)){ if(!"".equals(thirdClassNameCurrent)){
//小类 //小类
String pids = firstClassId + "," + secondClassId + ""; String pids = firstClassId + "," + secondClassId + "";
CategoryEntity insertEntity = getCategoryEntity(thirdClassId,secondClassId,pids,thirdClassName, CategoryEntity insertEntity = getCategoryEntity(thirdClassId,secondClassId,pids,thirdClassInfoCode,thirdClassName,
thirdClassId+"","2",thirdClassSort,0,secondClassName); firstClassInfoCode+secondClassInfoCode+thirdClassInfoCode,"2",thirdClassSort,0,secondClassName);
list.add(insertEntity); list.add(insertEntity);
} }
if(!"".equals(fourthClassNameCurrent)){ if(!"".equals(fourthClassNameCurrent)){
//细分类 //细分类
String pids = firstClassId + "," + secondClassId + "," + thirdClassId + ""; String pids = firstClassId + "," + secondClassId + "," + thirdClassId + "";
CategoryEntity insertEntity = getCategoryEntity(fourthClassId,thirdClassId,pids,fourthClassName, CategoryEntity insertEntity = getCategoryEntity(fourthClassId,thirdClassId,pids,fourthClassInfoCode,fourthClassName,
fourthClassId+"","3",fourthClassSort,0,thirdClassName); firstClassInfoCode+secondClassInfoCode+thirdClassInfoCode+fourthClassInfoCode,"3",fourthClassSort,0,thirdClassName);
list.add(insertEntity); list.add(insertEntity);
} }
} }
@ -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