diff --git a/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar b/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar index e9483c0f..74e8c295 100644 Binary files a/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar and b/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar differ diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/constant/PositionConstant.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/constant/PositionConstant.java index 3da40a14..15ff8657 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/constant/PositionConstant.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/constant/PositionConstant.java @@ -27,10 +27,10 @@ public class PositionConstant { public final static String TABLE_POSITION_NAME2 = "现在岗位名称2"; public final static String TABLE_POSITION_NAME3 = "现在岗位名称3"; public final static String TABLE_POSITION_NAME4 = "现在岗位名称4"; + public final static String TABLE_POSITION_NAME = "现在岗位名称"; - public final static String [] EXCEL_TITLE_ROW_ARR = new String [] {TABLE_PROCESS_NAME, TABLE_PROCESS_SHAPE_NAME, TABLE_TYPE_NAME, TABLE_NAME, TABLE_POSITION_NAME1, TABLE_POSITION_NAME2, TABLE_POSITION_NAME3, TABLE_POSITION_NAME4}; - public final static String EXCEL_TITLE_ROW = TABLE_PROCESS_NAME+ "、" +TABLE_PROCESS_SHAPE_NAME+ "、" +TABLE_TYPE_NAME+ "、" +TABLE_NAME+ "、" +TABLE_POSITION_NAME1+ "、" - +TABLE_POSITION_NAME2+ "、" +TABLE_POSITION_NAME3+ "、" +TABLE_POSITION_NAME4; - + // 固定列 + public final static String [] EXCEL_TITLE_ROW_FIXED_ARR = new String [] {TABLE_PROCESS_NAME, TABLE_PROCESS_SHAPE_NAME, TABLE_TYPE_NAME, TABLE_NAME, TABLE_POSITION_NAME1}; + public final static String EXCEL_TITLE_ROW_FIXED = TABLE_PROCESS_NAME+ "、" +TABLE_PROCESS_SHAPE_NAME+ "、" +TABLE_TYPE_NAME+ "、" +TABLE_NAME+ "、" +TABLE_POSITION_NAME1; } diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/model/PositionExcelModel.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/model/PositionExcelModel.java index 70113552..42ba4cfe 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/model/PositionExcelModel.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/model/PositionExcelModel.java @@ -1,5 +1,7 @@ package com.actionsoft.apps.coe.pal.datamigration.position.model; +import java.util.List; + /** * Excel数据model */ @@ -8,10 +10,7 @@ public class PositionExcelModel { private String processShapeName;// 活动名称 private String type;// 类别 private String roleName;// 名称(角色) - private String positionName1;// 岗位名称1 - private String positionName2;// 岗位名称2 - private String positionName3;// 岗位名称3 - private String positionName4;// 岗位名称4 + private List positionName;// 岗位名称 public String getProcessName() { return processName; @@ -45,35 +44,11 @@ public class PositionExcelModel { this.roleName = roleName; } - public String getPositionName1() { - return positionName1; + public List getPositionName() { + return positionName; } - public void setPositionName1(String positionName1) { - this.positionName1 = positionName1; - } - - public String getPositionName2() { - return positionName2; - } - - public void setPositionName2(String positionName2) { - this.positionName2 = positionName2; - } - - public String getPositionName3() { - return positionName3; - } - - public void setPositionName3(String positionName3) { - this.positionName3 = positionName3; - } - - public String getPositionName4() { - return positionName4; - } - - public void setPositionName4(String positionName4) { - this.positionName4 = positionName4; + public void setPositionName(List positionName) { + this.positionName = positionName; } } diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/web/PositionExcelImportWeb.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/web/PositionExcelImportWeb.java index 89a7fe85..d9a61dc0 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/web/PositionExcelImportWeb.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/position/web/PositionExcelImportWeb.java @@ -263,7 +263,7 @@ public class PositionExcelImportWeb extends ActionWeb { return ro.toString(); } // 解析xls内容 - List excelModelList = getExcelContent(sheet); + List excelModelList = getExcelContent(sheet, titleList); if (excelModelList.size() == 0) { msg = Constant.LOG_ERROR + "上传文件工作表中内容不能为空," + Constant.IMPORT_STOP_MSG; updateErrLog(msg, msg); @@ -356,17 +356,11 @@ public class PositionExcelImportWeb extends ActionWeb { model.setRoleName(roleName); List positionList = new ArrayList<>(); for (PositionExcelModel position : list) { - if (UtilString.isNotEmpty(position.getPositionName1()) && !positionList.contains(position.getPositionName1())) { - positionList.add(position.getPositionName1()); - } - if (UtilString.isNotEmpty(position.getPositionName2()) && !positionList.contains(position.getPositionName2())) { - positionList.add(position.getPositionName2()); - } - if (UtilString.isNotEmpty(position.getPositionName3()) && !positionList.contains(position.getPositionName3())) { - positionList.add(position.getPositionName3()); - } - if (UtilString.isNotEmpty(position.getPositionName4()) && !positionList.contains(position.getPositionName4())) { - positionList.add(position.getPositionName4()); + List postionStrList = position.getPositionName(); + for (String str : postionStrList) { + if (UtilString.isNotEmpty(str) && !positionList.contains(str)) { + positionList.add(str); + } } } model.setPositionList(positionList); @@ -447,9 +441,10 @@ public class PositionExcelImportWeb extends ActionWeb { /** * 获取Excel内容 * @param sheet + * @param titleList // titleList,除了固定列,扩展列若标题为null,则为无效数据 * @return */ - private List getExcelContent(Sheet sheet) { + private List getExcelContent(Sheet sheet, List titleList) { List list = new ArrayList<>(); for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) { Row row = sheet.getRow(i); @@ -466,18 +461,20 @@ public class PositionExcelImportWeb extends ActionWeb { // 角色名称 Cell cell4 = row.getCell(3); rowModel.setRoleName(POIUtil.getCellValueByCell(cell4)); + // 第5列是有岗位名称列的,标题算是固定列 + List postList = new ArrayList<>(); // 现在岗位名称1 Cell cell5 = row.getCell(4); - rowModel.setPositionName1(POIUtil.getCellValueByCell(cell5)); - // 现在岗位名称2 - Cell cell6 = row.getCell(5); - rowModel.setPositionName2(POIUtil.getCellValueByCell(cell6)); - // 现在岗位名称3 - Cell cell7 = row.getCell(6); - rowModel.setPositionName3(POIUtil.getCellValueByCell(cell7)); - // 现在岗位名称4 - Cell cell8 = row.getCell(7); - rowModel.setPositionName4(POIUtil.getCellValueByCell(cell8)); + postList.add(POIUtil.getCellValueByCell(cell5)); + // 扩展列数据 + for (int j = PositionConstant.EXCEL_TITLE_ROW_FIXED_ARR.length; j < titleList.size(); j++) { + if (titleList.get(j) == null) {// 无效标题 + continue; + } + Cell cell6 = row.getCell(j); + postList.add(POIUtil.getCellValueByCell(cell6)); + } + rowModel.setPositionName(postList); list.add(rowModel); } return list; @@ -490,16 +487,25 @@ public class PositionExcelImportWeb extends ActionWeb { */ private ResponseObject checkExcelTitle(List titleList) { ResponseObject ro = ResponseObject.newOkResponse(); - if (titleList.size() < PositionConstant.EXCEL_TITLE_ROW_ARR.length) { - ro.err("上传文件工作表中标题行错误,请按照" + PositionConstant.EXCEL_TITLE_ROW + "的格式填写,当前Excel列名:" + StringUtils.join(titleList, "、")); + if (titleList.size() < PositionConstant.EXCEL_TITLE_ROW_FIXED_ARR.length) {// 固定列不满足,校验失败 + ro.err("上传文件工作表中标题行错误,前" + PositionConstant.EXCEL_TITLE_ROW_FIXED_ARR.length + "列请按照" + PositionConstant.EXCEL_TITLE_ROW_FIXED + "的格式填写当前Excel列名:" + StringUtils.join(titleList, "、")); return ro; } - for (int i = 0; i < PositionConstant.EXCEL_TITLE_ROW_ARR.length; i++) { - if (!PositionConstant.EXCEL_TITLE_ROW_ARR[i].equals(titleList.get(i))) { - ro.err("上传文件工作表中标题行错误,请按照" + PositionConstant.EXCEL_TITLE_ROW + "的格式填写,若有隐藏列,请移动至最后,当前Excel列名:" + StringUtils.join(titleList, "、")); + // 固定列标题文本校验 + for (int i = 0; i < PositionConstant.EXCEL_TITLE_ROW_FIXED_ARR.length; i++) { + if (!PositionConstant.EXCEL_TITLE_ROW_FIXED_ARR[i].equals(titleList.get(i))) { + ro.err("上传文件工作表中标题行错误,前"+ PositionConstant.EXCEL_TITLE_ROW_FIXED_ARR.length +"列请按照" + PositionConstant.EXCEL_TITLE_ROW_FIXED + "的格式填写,若有隐藏列,请移动至最后,当前Excel列名:" + StringUtils.join(titleList, "、")); return ro; } } + // 固定列满足,扩展列所有没有PositionConstant.TABLE_POSITION_NAME字样的全部置为null + if (titleList.size() > PositionConstant.EXCEL_TITLE_ROW_FIXED_ARR.length) { + for (int i = PositionConstant.EXCEL_TITLE_ROW_FIXED_ARR.length; i < titleList.size(); i++) { + if (!titleList.get(i).contains(PositionConstant.TABLE_POSITION_NAME)) { + titleList.set(i, null); + } + } + } return ro; }