| | |
| | | public class OrganizationImportService extends AbstractBaseService implements IOrganizationImportService { |
| | | |
| | | |
| | | @Autowired |
| | | StaffManagerService staffManagerService; |
| | | @Autowired |
| | | StaffManagerService staffManagerService; |
| | | |
| | | private final String companyLevelSeparator = ">"; |
| | | private final String companyLevelSeparator = ">"; |
| | | |
| | | /** |
| | | * 导入公司 之前 数据处理 |
| | | * |
| | | * @param dt |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | public DataTableEntity importCompanyBefore(DataTableEntity dt) throws BaseException { |
| | | ImportErrorEntity errorEntity = new ImportErrorEntity(); |
| | | try { |
| | | /** |
| | | * 导入公司 之前 数据处理 |
| | | * |
| | | * @param dt |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | public DataTableEntity importCompanyBefore(DataTableEntity dt) throws BaseException { |
| | | ImportErrorEntity errorEntity = new ImportErrorEntity(); |
| | | try { |
| | | |
| | | SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | //管理员权限验证 |
| | | managerPermissionValidation(errorEntity, currentUser); |
| | | FieldSetEntity managerFieldSet = currentUser.getCurrentManager(); |
| | | String managerCompany = managerFieldSet.getString(CmnConst.ORG_LEVEL_UUID); |
| | | // 当前管理员管理的公司 |
| | | String managerCompanyUuids = currentUser.getCurrentCompany().getString(CmnConst.ORG_LEVEL_UUID); |
| | | if (!BaseUtil.dataTableIsEmpty(dt)) { |
| | | //数据验证结果 |
| | | Map<String, String> fieldType = Maps.newHashMap(); |
| | | fieldType.put(CmnConst.SEQUENCE, "int"); |
| | | errorEntity = fieldRequiredValidation(dt, new String[]{CmnConst.FIELD_ORG_LEVEL_NAME, CmnConst.FIELD_ORG_LEVEL_ALL, CmnConst.SEQUENCE}, null, f -> { |
| | | if (f != null && f[0] != null) { |
| | | FieldSetEntity fse = f[0]; |
| | | //公司名称 |
| | | String companyName = fse.getString(CmnConst.FIELD_ORG_LEVEL_NAME); |
| | | //公司全称 |
| | | String companyAllName = fse.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | //上级公司全称 |
| | | String parentAllName = companyAllName.replace(companyLevelSeparator + companyName, ""); |
| | | fse.setValue("parentAllName", parentAllName); |
| | | } |
| | | }); |
| | | DataTableEntity systemData = getBaseDao().listTable(CmnConst.TABLE_PRODUCT_SYS_ORG_LEVELS, " org_level_type=0 AND " |
| | | + BaseUtil.buildQuestionMarkFilter(CmnConst.ORG_LEVEL_UUID, managerCompanyUuids.split(","), true), new Object[]{}, "org_level_code"); |
| | | // 验证重复 & 合并错误信息 |
| | | errorEntity.mergeError(fieldRepeatValidation(dt, systemData, CmnConst.FIELD_ORG_LEVEL_ALL)); |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | List<FieldSetEntity> data = dt.getData(); |
| | | data.sort((a, b) -> { |
| | | String Aorg_level_all = a.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | String Borg_level_all = b.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | int lengthA = Aorg_level_all != null ? Aorg_level_all.length() : -1; |
| | | int lengthB = Borg_level_all != null ? Borg_level_all.length() : -1; |
| | | return lengthA - lengthB; |
| | | }); |
| | | // 获取当前管理管理公司以及子公司 |
| | | DataTableEntity allCompany = getBaseDao().listTable(CmnConst.TABLE_PRODUCT_SYS_ORG_LEVELS, " org_level_type=0 AND " |
| | | + BaseUtil.buildQuestionMarkFilter(CmnConst.ORG_LEVEL_UUID, managerCompanyUuids.split(","), true), new Object[]{}, "org_level_code"); |
| | | Map<String, String> levelCode = Maps.newHashMap(); |
| | | if (!BaseUtil.dataTableIsEmpty(allCompany)) { |
| | | for (int i = 0; i < allCompany.getRows(); i++) { |
| | | String org_level_all = allCompany.getString(i, CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | String org_level_code = allCompany.getString(i, CmnConst.FIELD_ORG_LEVEL_CODE); |
| | | // 将公司编码用全称存储 |
| | | levelCode.put(org_level_all, org_level_code); |
| | | } |
| | | } |
| | | for (FieldSetEntity fse : data) { |
| | | //当前行 |
| | | Integer rowIndex = fse.getInteger("~row~"); |
| | | //公司全称 |
| | | String companyAllName = fse.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | //上级组织机构全称 |
| | | String parentAllName = fse.getString("parentAllName"); |
| | | //上级机构编码 |
| | | String code = levelCode.get(parentAllName); |
| | | if (StringUtils.isEmpty(code)) { |
| | | errorEntity.addError(rowIndex, " 获取上级机构编码错误,请检查公司名称、全称是否正确,错误行号:").append(rowIndex + 1); |
| | | continue; |
| | | } |
| | | //初始化公司数据 |
| | | initOrganizationFieldSet(fse, currentUser.getClient_uuid(), code, 0); |
| | | // 将当前公司生成的org_level_code 放入map中 |
| | | levelCode.put(companyAllName, fse.getString(CmnConst.FIELD_ORG_LEVEL_CODE)); |
| | | String uuid = null; |
| | | try { |
| | | // 保存出错直接跳过该条数据 |
| | | getBaseDao().add(fse); |
| | | } catch (Exception e) { |
| | | continue; |
| | | } |
| | | if (null != uuid) { |
| | | // 导入时创建该公司的数据权限 |
| | | FieldSetEntity fs = new FieldSetEntity(); |
| | | fs.setTableName(CmnConst.TABLE_PRODUCT_SYS_DATA_STRATEGY_MASTER); |
| | | SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | //管理员权限验证 |
| | | managerPermissionValidation(errorEntity, currentUser); |
| | | FieldSetEntity managerFieldSet = currentUser.getCurrentManager(); |
| | | String managerCompany = managerFieldSet.getString(CmnConst.ORG_LEVEL_UUID); |
| | | // 当前管理员管理的公司 |
| | | String managerCompanyUuids = currentUser.getCurrentCompany().getString(CmnConst.ORG_LEVEL_UUID); |
| | | if (!BaseUtil.dataTableIsEmpty(dt)) { |
| | | //数据验证结果 |
| | | Map<String, String> fieldType = Maps.newHashMap(); |
| | | fieldType.put(CmnConst.SEQUENCE, "int"); |
| | | errorEntity = fieldRequiredValidation(dt, new String[]{CmnConst.FIELD_ORG_LEVEL_NAME, CmnConst.FIELD_ORG_LEVEL_ALL, CmnConst.SEQUENCE}, null, f -> { |
| | | if (f != null && f[0] != null) { |
| | | FieldSetEntity fse = f[0]; |
| | | //公司名称 |
| | | String companyName = fse.getString(CmnConst.FIELD_ORG_LEVEL_NAME); |
| | | //公司全称 |
| | | String companyAllName = fse.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | //上级公司全称 |
| | | String parentAllName = companyAllName.replace(companyLevelSeparator + companyName, ""); |
| | | fse.setValue("parentAllName", parentAllName); |
| | | } |
| | | }); |
| | | DataTableEntity systemData = getBaseDao().listTable(CmnConst.TABLE_PRODUCT_SYS_ORG_LEVELS, " org_level_type=0 AND " |
| | | + BaseUtil.buildQuestionMarkFilter(CmnConst.ORG_LEVEL_UUID, managerCompanyUuids.split(","), true), new Object[]{}, "org_level_code"); |
| | | // 验证重复 & 合并错误信息 |
| | | errorEntity.mergeError(fieldRepeatValidation(dt, systemData, CmnConst.FIELD_ORG_LEVEL_ALL)); |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | List<FieldSetEntity> data = dt.getData(); |
| | | data.sort((a, b) -> { |
| | | String Aorg_level_all = a.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | String Borg_level_all = b.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | int lengthA = Aorg_level_all != null ? Aorg_level_all.length() : -1; |
| | | int lengthB = Borg_level_all != null ? Borg_level_all.length() : -1; |
| | | return lengthA - lengthB; |
| | | }); |
| | | // 获取当前管理管理公司以及子公司 |
| | | DataTableEntity allCompany = getBaseDao().listTable(CmnConst.TABLE_PRODUCT_SYS_ORG_LEVELS, " org_level_type=0 AND " |
| | | + BaseUtil.buildQuestionMarkFilter(CmnConst.ORG_LEVEL_UUID, managerCompanyUuids.split(","), true), new Object[]{}, "org_level_code"); |
| | | Map<String, String> levelCode = Maps.newHashMap(); |
| | | if (!BaseUtil.dataTableIsEmpty(allCompany)) { |
| | | for (int i = 0; i < allCompany.getRows(); i++) { |
| | | String org_level_all = allCompany.getString(i, CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | String org_level_code = allCompany.getString(i, CmnConst.FIELD_ORG_LEVEL_CODE); |
| | | // 将公司编码用全称存储 |
| | | levelCode.put(org_level_all, org_level_code); |
| | | } |
| | | } |
| | | for (FieldSetEntity fse : data) { |
| | | //当前行 |
| | | Integer rowIndex = fse.getInteger("~row~"); |
| | | //公司全称 |
| | | String companyAllName = fse.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | //上级组织机构全称 |
| | | String parentAllName = fse.getString("parentAllName"); |
| | | //上级机构编码 |
| | | String code = levelCode.get(parentAllName); |
| | | if (StringUtils.isEmpty(code)) { |
| | | errorEntity.addError(rowIndex, " 获取上级机构编码错误,请检查公司名称、全称是否正确,错误行号:").append(rowIndex + 1); |
| | | continue; |
| | | } |
| | | //初始化公司数据 |
| | | initOrganizationFieldSet(fse, currentUser.getClient_uuid(), code, 0); |
| | | // 将当前公司生成的org_level_code 放入map中 |
| | | levelCode.put(companyAllName, fse.getString(CmnConst.FIELD_ORG_LEVEL_CODE)); |
| | | String uuid = null; |
| | | try { |
| | | // 保存出错直接跳过该条数据 |
| | | getBaseDao().add(fse); |
| | | } catch (Exception e) { |
| | | continue; |
| | | } |
| | | if (null != uuid) { |
| | | // 导入时创建该公司的数据权限 |
| | | FieldSetEntity fs = new FieldSetEntity(); |
| | | fs.setTableName(CmnConst.TABLE_PRODUCT_SYS_DATA_STRATEGY_MASTER); |
| | | // fs.setValue(CmnConst.ORG_LEVEL_UUID, uuid); |
| | | fs.setValue("property_uuid", "001"); |
| | | fs.setValue("is_used", "1"); |
| | | fs.setValue("effective_start_date", new Date()); |
| | | fs.setValue(CmnConst.CREATED_BY, currentUser.getUser_id()); |
| | | fs.setValue(CmnConst.CREATED_UTC_DATETIME, new Date()); |
| | | getBaseDao().add(fs); |
| | | } |
| | | } |
| | | // 回写到隐藏管理员所管理的公司 todo group_concat 太多会报错 |
| | | getBaseDao().executeUpdate("UPDATE product_sys_org_manager SET org_level_uuid =(SELECT group_concat(UUID) FROM product_sys_org_levels WHERE CLIENT_UUID =? AND ORG_LEVEL_TYPE =0) WHERE CLIENTS_UUID=? AND MANAGER_TYPE=? " |
| | | , new Object[]{currentUser.getClient_uuid(), currentUser.getClient_uuid(), 3}); |
| | | // 回写当前管理员管理的公司 |
| | | if (currentUser.getUserType() == 2 && dt.getUuids() != null) { |
| | | if (!StringUtils.isEmpty(managerCompany)) { |
| | | managerCompany += ","; |
| | | } else { |
| | | managerCompany = ""; |
| | | } |
| | | managerCompany += dt.getUuidsToString(); |
| | | String manager_uuid = managerFieldSet.getUUID(); |
| | | String sql = "update product_sys_org_manager set org_level_uuid=? where uuid=?"; |
| | | getBaseDao().executeUpdate(sql, new Object[]{managerCompany, manager_uuid}); |
| | | } |
| | | //抛出错误 |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | UpdateLoginUserInfoService loginUserInfoService = SpringBeanUtil.getBean("updateLoginUserInfoService", UpdateLoginUserInfoService.class); |
| | | loginUserInfoService.updateUserInfoByUserId(new Object[]{currentUser.getUser_id()}, false); |
| | | return dt; |
| | | } else { |
| | | errorEntity.newThrowBaseException("导入公司失败,未提取到数据"); |
| | | } |
| | | } catch (BaseException e) { |
| | | throw e; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | errorEntity.addError(0, "导入公司失败,未知错误 ," + e.getMessage()); |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | return null; |
| | | } |
| | | fs.setValue("property_uuid", "001"); |
| | | fs.setValue("is_used", "1"); |
| | | fs.setValue("effective_start_date", new Date()); |
| | | fs.setValue(CmnConst.CREATED_BY, currentUser.getUser_id()); |
| | | fs.setValue(CmnConst.CREATED_UTC_DATETIME, new Date()); |
| | | getBaseDao().add(fs); |
| | | } |
| | | } |
| | | // 回写到隐藏管理员所管理的公司 todo group_concat 太多会报错 |
| | | getBaseDao().executeUpdate("UPDATE product_sys_org_manager SET org_level_uuid =(SELECT group_concat(UUID) FROM product_sys_org_levels WHERE CLIENT_UUID =? AND ORG_LEVEL_TYPE =0) WHERE CLIENTS_UUID=? AND MANAGER_TYPE=? " |
| | | , new Object[]{currentUser.getClient_uuid(), currentUser.getClient_uuid(), 3}); |
| | | // 回写当前管理员管理的公司 |
| | | if (currentUser.getUserType() == 2 && dt.getUuids() != null) { |
| | | if (!StringUtils.isEmpty(managerCompany)) { |
| | | managerCompany += ","; |
| | | } else { |
| | | managerCompany = ""; |
| | | } |
| | | managerCompany += dt.getUuidsToString(); |
| | | String manager_uuid = managerFieldSet.getUUID(); |
| | | String sql = "update product_sys_org_manager set org_level_uuid=? where uuid=?"; |
| | | getBaseDao().executeUpdate(sql, new Object[]{managerCompany, manager_uuid}); |
| | | } |
| | | //抛出错误 |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | UpdateLoginUserInfoService loginUserInfoService = SpringBeanUtil.getBean("updateLoginUserInfoService", UpdateLoginUserInfoService.class); |
| | | loginUserInfoService.updateUserInfoByUserId(new Object[]{currentUser.getUser_id()}, false); |
| | | return dt; |
| | | } else { |
| | | errorEntity.newThrowBaseException("导入公司失败,未提取到数据"); |
| | | } |
| | | } catch (BaseException e) { |
| | | throw e; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | errorEntity.addError(0, "导入公司失败,未知错误 ," + e.getMessage()); |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 字段重复验证 |
| | | * |
| | | * @param errorEntity |
| | | * @param importData 导入数据 |
| | | * @param systemData 系统数据 (可选) |
| | | * @param fieldNames 字段名称 |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | protected ImportErrorEntity fieldRepeatValidation(ImportErrorEntity errorEntity, DataTableEntity importData, DataTableEntity systemData, String[] fieldNames) throws BaseException { |
| | | if (fieldNames == null || fieldNames.length <= 0) { |
| | | return errorEntity; |
| | | } |
| | | List<FieldSetEntity> dataList = importData.clones().getData(); |
| | | Map<String, Object> valueMap = Maps.newHashMap(); |
| | | if (!BaseUtil.dataTableIsEmpty(systemData)) { |
| | | for (int i = 0; i < systemData.getRows(); i++) { |
| | | for (String field : fieldNames) { |
| | | String value = systemData.getString(i, field); |
| | | if (!StringUtils.isEmpty(value)) { |
| | | valueMap.put(field + this.companyLevelSeparator + value, Boolean.FALSE); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | fieldRepeatValidation(errorEntity, dataList, valueMap, fieldNames); |
| | | return errorEntity; |
| | | } |
| | | /** |
| | | * 字段重复验证 |
| | | * |
| | | * @param errorEntity |
| | | * @param importData 导入数据 |
| | | * @param systemData 系统数据 (可选) |
| | | * @param fieldNames 字段名称 |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | protected ImportErrorEntity fieldRepeatValidation(ImportErrorEntity errorEntity, DataTableEntity importData, DataTableEntity systemData, String[] fieldNames) throws BaseException { |
| | | if (fieldNames == null || fieldNames.length <= 0) { |
| | | return errorEntity; |
| | | } |
| | | List<FieldSetEntity> dataList = importData.clones().getData(); |
| | | Map<String, Object> valueMap = Maps.newHashMap(); |
| | | if (!BaseUtil.dataTableIsEmpty(systemData)) { |
| | | for (int i = 0; i < systemData.getRows(); i++) { |
| | | for (String field : fieldNames) { |
| | | String value = systemData.getString(i, field); |
| | | if (!StringUtils.isEmpty(value)) { |
| | | valueMap.put(field + this.companyLevelSeparator + value, Boolean.FALSE); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | fieldRepeatValidation(errorEntity, dataList, valueMap, fieldNames); |
| | | return errorEntity; |
| | | } |
| | | |
| | | /** |
| | | * 字段重复验证 |
| | | * |
| | | * @param dataList 导入数据 |
| | | * @param valueMap |
| | | * @param fieldNames 字段名称 |
| | | * @throws BaseException |
| | | */ |
| | | protected void fieldRepeatValidation(ImportErrorEntity errorEntity, List<FieldSetEntity> dataList, Map<String, Object> valueMap, String[] fieldNames) throws BaseException { |
| | | /** |
| | | * 字段重复验证 |
| | | * |
| | | * @param dataList 导入数据 |
| | | * @param valueMap |
| | | * @param fieldNames 字段名称 |
| | | * @throws BaseException |
| | | */ |
| | | protected void fieldRepeatValidation(ImportErrorEntity errorEntity, List<FieldSetEntity> dataList, Map<String, Object> valueMap, String[] fieldNames) throws BaseException { |
| | | |
| | | for (FieldSetEntity fse : dataList) { |
| | | DataLocation dataLocation = getDataLocation(fse); |
| | | for (String fieldName : fieldNames) { |
| | | String value = fse.getString(fieldName); |
| | | if (!StringUtils.isEmpty(value)) { |
| | | if (valueMap.get(fieldName + this.companyLevelSeparator + value) != null) { |
| | | Object val = valueMap.get(fieldName + this.companyLevelSeparator + value); |
| | | if (val != null) { |
| | | String error; |
| | | if (val instanceof Boolean) { |
| | | // 系统中存在 |
| | | // 第 N 行,第 N 列,'表头名称' ('数据值') 数据重复,在系统中已存在 |
| | | error = "第 %s 行,第 %s 列 '%s', 数据重复,在系统中已存在"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(fieldName), dataLocation.getColName(fieldName), value); |
| | | } else { |
| | | FieldSetEntity fs = (FieldSetEntity) val; |
| | | DataLocation historyLocation = getDataLocation(fs); |
| | | // 第N行,第 N列,'表头名称' ('数据值') 数据和第 %s 行,第N行,第 N列,'表头名称' ('数据值') 数据重复 |
| | | error = "第 %s 行,第 %s 列 '%s', 数据和第 %s 行,第 %s 列 '%s' ,数据重复"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(fieldName), dataLocation.getColName(fieldName), value, |
| | | historyLocation.getRowIndex(), historyLocation.getColIndex(fieldName), historyLocation.getColName(fieldName), value); |
| | | } |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | } |
| | | } else { |
| | | valueMap.put(fieldName + this.companyLevelSeparator + value, fse); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | for (FieldSetEntity fse : dataList) { |
| | | DataLocation dataLocation = getDataLocation(fse); |
| | | for (String fieldName : fieldNames) { |
| | | String value = fse.getString(fieldName); |
| | | if (!StringUtils.isEmpty(value)) { |
| | | if (valueMap.get(fieldName + this.companyLevelSeparator + value) != null) { |
| | | Object val = valueMap.get(fieldName + this.companyLevelSeparator + value); |
| | | if (val != null) { |
| | | String error; |
| | | if (val instanceof Boolean) { |
| | | // 系统中存在 |
| | | // 第 N 行,第 N 列,'表头名称' ('数据值') 数据重复,在系统中已存在 |
| | | error = "第 %s 行,第 %s 列 '%s', 数据重复,在系统中已存在"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(fieldName), dataLocation.getColName(fieldName), value); |
| | | } else { |
| | | FieldSetEntity fs = (FieldSetEntity) val; |
| | | DataLocation historyLocation = getDataLocation(fs); |
| | | // 第N行,第 N列,'表头名称' ('数据值') 数据和第 %s 行,第N行,第 N列,'表头名称' ('数据值') 数据重复 |
| | | error = "第 %s 行,第 %s 列 '%s', 数据和第 %s 行,第 %s 列 '%s' ,数据重复"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(fieldName), dataLocation.getColName(fieldName), value, |
| | | historyLocation.getRowIndex(), historyLocation.getColIndex(fieldName), historyLocation.getColName(fieldName), value); |
| | | } |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | } |
| | | } else { |
| | | valueMap.put(fieldName + this.companyLevelSeparator + value, fse); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 字段重复验证 |
| | | * |
| | | * @param importData 导入数据 |
| | | * @param systemData 系统数据 (可选) |
| | | * @param fieldName 字段名称 |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | protected ImportErrorEntity fieldRepeatValidation(DataTableEntity importData, DataTableEntity |
| | | systemData, String fieldName) throws BaseException { |
| | | return fieldRepeatValidation(new ImportErrorEntity(), importData, systemData, new String[]{fieldName}); |
| | | } |
| | | /** |
| | | * 字段重复验证 |
| | | * |
| | | * @param importData 导入数据 |
| | | * @param systemData 系统数据 (可选) |
| | | * @param fieldName 字段名称 |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | protected ImportErrorEntity fieldRepeatValidation(DataTableEntity importData, DataTableEntity |
| | | systemData, String fieldName) throws BaseException { |
| | | return fieldRepeatValidation(new ImportErrorEntity(), importData, systemData, new String[]{fieldName}); |
| | | } |
| | | |
| | | /** |
| | | * 字段必填验证 |
| | | * |
| | | * @param dt |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | protected ImportErrorEntity fieldRequiredValidation(DataTableEntity dt, String[] |
| | | fieldNames, Map<String, String> fieldType, CallBack<FieldSetEntity> callBack) throws BaseException { |
| | | ImportErrorEntity errorEntity = new ImportErrorEntity(); |
| | | for (int i = 0; i < dt.getRows(); i++) { |
| | | FieldSetEntity fieldSetEntity = dt.getFieldSetEntity(i); |
| | | if (callBack != null) { |
| | | callBack.method(fieldSetEntity); |
| | | } |
| | | fieldRequiredValidation(errorEntity, fieldSetEntity, fieldNames, fieldType); |
| | | } |
| | | /** |
| | | * 字段必填验证 |
| | | * |
| | | * @param dt |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | protected ImportErrorEntity fieldRequiredValidation(DataTableEntity dt, String[] |
| | | fieldNames, Map<String, String> fieldType, CallBack<FieldSetEntity> callBack) throws BaseException { |
| | | ImportErrorEntity errorEntity = new ImportErrorEntity(); |
| | | for (int i = 0; i < dt.getRows(); i++) { |
| | | FieldSetEntity fieldSetEntity = dt.getFieldSetEntity(i); |
| | | if (callBack != null) { |
| | | callBack.method(fieldSetEntity); |
| | | } |
| | | fieldRequiredValidation(errorEntity, fieldSetEntity, fieldNames, fieldType); |
| | | } |
| | | |
| | | return errorEntity; |
| | | } |
| | | return errorEntity; |
| | | } |
| | | |
| | | /** |
| | | * 字段类型验证 |
| | | * 目前支持 int double dateTime |
| | | * |
| | | * @param errorEntity |
| | | * @param fse |
| | | * @param fieldTypeMap |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | protected boolean fieldTypeValidation(ImportErrorEntity errorEntity, FieldSetEntity |
| | | fse, Map<String, String> fieldTypeMap) throws BaseException { |
| | | boolean flag = true; |
| | | if (fieldTypeMap != null && fieldTypeMap.size() > 0 && fse != null) { |
| | | for (Map.Entry<String, String> v : fieldTypeMap.entrySet()) { |
| | | String fieldType = v.getValue(); |
| | | String key = v.getKey(); |
| | | Object value = fse.getObject(key); |
| | | if (value == null) { |
| | | continue; |
| | | } |
| | | String type = null; |
| | | String msg = ""; |
| | | try { |
| | | switch (fieldType) { |
| | | case "int": |
| | | type = "整数"; |
| | | fse.getInteger(key); |
| | | continue; |
| | | case "dateTime": |
| | | type = "日期"; |
| | | Date date = fse.getDate(key); |
| | | fse.setValue(key, date); |
| | | continue; |
| | | case "double": |
| | | type = "小数"; |
| | | fse.getDouble(key); |
| | | continue; |
| | | case "mobile_phone": |
| | | type = "移动电话"; |
| | | String phone = fse.getString(key); |
| | | // 验证是否为中国大陆 手机号 |
| | | if (!BaseUtil.isChinaPhoneLegal(phone)) { |
| | | throw new BaseException("", ""); |
| | | } |
| | | continue; |
| | | case "id_card": |
| | | type = "身份证号码"; |
| | | String idCard = fse.getString(key); |
| | | // 验证身份证号码是否合法 |
| | | if (IdcardUtils.validateCard(idCard)) { |
| | | msg = BaseUtil.idCardVerification(idCard); |
| | | throw new BaseException("", ""); |
| | | } |
| | | continue; |
| | | case "email": |
| | | type = "邮箱"; |
| | | String email = fse.getString(key); |
| | | // 邮箱验证 |
| | | if (!BaseUtil.isEmail(email)) { |
| | | throw new BaseException("", ""); |
| | | } |
| | | continue; |
| | | case "sex": |
| | | type = "性别"; |
| | | String sex = fse.getString(key); |
| | | // 邮箱验证 |
| | | if (!"男".equals(sex) && !"女".equals(sex)) { |
| | | throw new BaseException("", ""); |
| | | } |
| | | continue; |
| | | default: |
| | | } |
| | | } catch (BaseException e) { |
| | | DataLocation dataLocation = getDataLocation(fse); |
| | | String error = "第 %s 行,第 %s 列,数据类型错误" + (type != null ? ",请输入正确的 '%s'值" : ""); |
| | | if (type != null) { |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(key), type); |
| | | } else { |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(key)); |
| | | } |
| | | if (!StringUtils.isEmpty(msg)) { |
| | | error += "," + msg; |
| | | } |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | flag = false; |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 字段类型验证 |
| | | * 目前支持 int double dateTime |
| | | * |
| | | * @param errorEntity |
| | | * @param fse |
| | | * @param fieldTypeMap |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | protected boolean fieldTypeValidation(ImportErrorEntity errorEntity, FieldSetEntity |
| | | fse, Map<String, String> fieldTypeMap) throws BaseException { |
| | | boolean flag = true; |
| | | if (fieldTypeMap != null && fieldTypeMap.size() > 0 && fse != null) { |
| | | for (Map.Entry<String, String> v : fieldTypeMap.entrySet()) { |
| | | String fieldType = v.getValue(); |
| | | String key = v.getKey(); |
| | | Object value = fse.getObject(key); |
| | | if (value == null) { |
| | | continue; |
| | | } |
| | | String type = null; |
| | | String msg = ""; |
| | | try { |
| | | switch (fieldType) { |
| | | case "int": |
| | | type = "整数"; |
| | | fse.getInteger(key); |
| | | continue; |
| | | case "dateTime": |
| | | type = "日期"; |
| | | Date date = fse.getDate(key); |
| | | fse.setValue(key, date); |
| | | continue; |
| | | case "double": |
| | | type = "小数"; |
| | | fse.getDouble(key); |
| | | continue; |
| | | case "mobile_phone": |
| | | type = "移动电话"; |
| | | String phone = fse.getString(key); |
| | | // 验证是否为中国大陆 手机号 |
| | | if (!BaseUtil.isChinaPhoneLegal(phone)) { |
| | | throw new BaseException("", ""); |
| | | } |
| | | continue; |
| | | case "id_card": |
| | | type = "身份证号码"; |
| | | String idCard = fse.getString(key); |
| | | // 验证身份证号码是否合法 |
| | | if (IdcardUtils.validateCard(idCard)) { |
| | | msg = BaseUtil.idCardVerification(idCard); |
| | | throw new BaseException("", ""); |
| | | } |
| | | continue; |
| | | case "email": |
| | | type = "邮箱"; |
| | | String email = fse.getString(key); |
| | | // 邮箱验证 |
| | | if (!BaseUtil.isEmail(email)) { |
| | | throw new BaseException("", ""); |
| | | } |
| | | continue; |
| | | case "sex": |
| | | type = "性别"; |
| | | String sex = fse.getString(key); |
| | | // 邮箱验证 |
| | | if (!"男".equals(sex) && !"女".equals(sex)) { |
| | | throw new BaseException("", ""); |
| | | } |
| | | continue; |
| | | default: |
| | | } |
| | | } catch (BaseException e) { |
| | | DataLocation dataLocation = getDataLocation(fse); |
| | | String error = "第 %s 行,第 %s 列,数据类型错误" + (type != null ? ",请输入正确的 '%s'值" : ""); |
| | | if (type != null) { |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(key), type); |
| | | } else { |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(key)); |
| | | } |
| | | if (!StringUtils.isEmpty(msg)) { |
| | | error += "," + msg; |
| | | } |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | flag = false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return flag; |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 字段必填验证 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | private boolean fieldRequiredValidation(ImportErrorEntity errorEntity, FieldSetEntity fse, String[] |
| | | fieldNames, Map<String, String> fieldType) throws BaseException { |
| | | if (fse == null || fieldNames == null || fieldNames.length <= 0) { |
| | | return true; |
| | | } |
| | | DataLocation dataLocation = getDataLocation(fse); |
| | | boolean flag = true; |
| | | for (String fieldName : fieldNames) { |
| | | if (!StringUtils.isEmpty(fieldName)) { |
| | | String value = fse.getString(fieldName); |
| | | if (StringUtils.isEmpty(value)) { |
| | | String error = "第 %s 行,第 %s 列 '%s', 不能为空"; |
| | | Integer rowIndex = dataLocation.getRowIndex(); |
| | | String colIndex = dataLocation.getColIndex(fieldName); |
| | | String colName = dataLocation.getColName(fieldName); |
| | | error = String.format(error, rowIndex, colIndex, colName); |
| | | errorEntity.addError(rowIndex, error); |
| | | flag = false; |
| | | } |
| | | } |
| | | } |
| | | if (flag) { |
| | | return fieldTypeValidation(errorEntity, fse, fieldType); |
| | | } else { |
| | | fieldTypeValidation(errorEntity, fse, fieldType); |
| | | return false; |
| | | } |
| | | } |
| | | /** |
| | | * 字段必填验证 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | private boolean fieldRequiredValidation(ImportErrorEntity errorEntity, FieldSetEntity fse, String[] |
| | | fieldNames, Map<String, String> fieldType) throws BaseException { |
| | | if (fse == null || fieldNames == null || fieldNames.length <= 0) { |
| | | return true; |
| | | } |
| | | DataLocation dataLocation = getDataLocation(fse); |
| | | boolean flag = true; |
| | | for (String fieldName : fieldNames) { |
| | | if (!StringUtils.isEmpty(fieldName)) { |
| | | String value = fse.getString(fieldName); |
| | | if (StringUtils.isEmpty(value)) { |
| | | String error = "第 %s 行,第 %s 列 '%s', 不能为空"; |
| | | Integer rowIndex = dataLocation.getRowIndex(); |
| | | String colIndex = dataLocation.getColIndex(fieldName); |
| | | String colName = dataLocation.getColName(fieldName); |
| | | error = String.format(error, rowIndex, colIndex, colName); |
| | | errorEntity.addError(rowIndex, error); |
| | | flag = false; |
| | | } |
| | | } |
| | | } |
| | | if (flag) { |
| | | return fieldTypeValidation(errorEntity, fse, fieldType); |
| | | } else { |
| | | fieldTypeValidation(errorEntity, fse, fieldType); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导入部门 之前 数据处理 |
| | | * |
| | | * @param dt |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | public DataTableEntity importDeptBefore(DataTableEntity dt) throws BaseException { |
| | | ImportErrorEntity errorEntity = new ImportErrorEntity(); |
| | | if (!BaseUtil.dataTableIsEmpty(dt)) { |
| | | try { |
| | | SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | //管理员权限验证 |
| | | managerPermissionValidation(errorEntity, currentUser); |
| | | /** |
| | | * 导入部门 之前 数据处理 |
| | | * |
| | | * @param dt |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | public DataTableEntity importDeptBefore(DataTableEntity dt) throws BaseException { |
| | | ImportErrorEntity errorEntity = new ImportErrorEntity(); |
| | | if (!BaseUtil.dataTableIsEmpty(dt)) { |
| | | try { |
| | | SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | //管理员权限验证 |
| | | managerPermissionValidation(errorEntity, currentUser); |
| | | |
| | | Map<String, String> fieldType = Maps.newHashMap(); |
| | | fieldType.put(CmnConst.SEQUENCE, "int"); |
| | | //数据必填验证结果 |
| | | errorEntity = fieldRequiredValidation(dt, new String[]{CmnConst.FIELD_ORG_LEVEL_NAME, CmnConst.FIELD_ORG_LEVEL_ALL, CmnConst.SEQUENCE, CmnConst.ORG_LEVEL_UUID}, fieldType, null); |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | FieldSetEntity currentManager = currentUser.getCurrentManager(); |
| | | String managerCompanyUuids = currentManager.getString(CmnConst.ORG_LEVEL_UUID); |
| | | String uuidFilter = BaseUtil.buildQuestionMarkFilter("uuid", managerCompanyUuids.split(","), true); |
| | | StringBuilder sql = new StringBuilder(8); |
| | | sql.append(" select uuid,org_level_name,org_level_code, "); |
| | | sql.append(" org_level_code_parent,org_level_all,org_level_type "); |
| | | sql.append(" FROM product_sys_org_levels where client_uuid=? and ( "); |
| | | sql.append(" ( "); |
| | | sql.append(" ").append(uuidFilter); |
| | | sql.append(" AND org_level_type=0 ) "); |
| | | sql.append(" or ( "); |
| | | sql.append(" ").append(uuidFilter.replace("uuid", "org_level_uuid")); |
| | | sql.append(" AND org_level_type=1 ) "); |
| | | sql.append(" ) order by org_level_code,org_level_type"); |
| | | // 系统数据 |
| | | DataTableEntity systemData = getBaseDao().listTable(sql.toString(), new Object[]{currentUser.getClient_uuid()}); |
| | | importDeptBefore(dt, systemData, currentUser, errorEntity); |
| | | return dt; |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | throw e; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | errorEntity.addError(0, "导入部门失败,未知错误 ," + e.getMessage()); |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | } |
| | | errorEntity.newThrowBaseException("导入公司失败,未提取到数据"); |
| | | return null; |
| | | } |
| | | Map<String, String> fieldType = Maps.newHashMap(); |
| | | fieldType.put(CmnConst.SEQUENCE, "int"); |
| | | //数据必填验证结果 |
| | | errorEntity = fieldRequiredValidation(dt, new String[]{CmnConst.FIELD_ORG_LEVEL_NAME, CmnConst.FIELD_ORG_LEVEL_ALL, CmnConst.SEQUENCE, CmnConst.ORG_LEVEL_UUID}, fieldType, null); |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | FieldSetEntity currentManager = currentUser.getCurrentManager(); |
| | | String managerCompanyUuids = currentManager.getString(CmnConst.ORG_LEVEL_UUID); |
| | | String uuidFilter = BaseUtil.buildQuestionMarkFilter("uuid", managerCompanyUuids.split(","), true); |
| | | StringBuilder sql = new StringBuilder(8); |
| | | sql.append(" select uuid,org_level_name,org_level_code, "); |
| | | sql.append(" org_level_code_parent,org_level_all,org_level_type "); |
| | | sql.append(" FROM product_sys_org_levels where client_uuid=? and ( "); |
| | | sql.append(" ( "); |
| | | sql.append(" ").append(uuidFilter); |
| | | sql.append(" AND org_level_type=0 ) "); |
| | | sql.append(" or ( "); |
| | | sql.append(" ").append(uuidFilter.replace("uuid", "org_level_uuid")); |
| | | sql.append(" AND org_level_type=1 ) "); |
| | | sql.append(" ) order by org_level_code,org_level_type"); |
| | | // 系统数据 |
| | | DataTableEntity systemData = getBaseDao().listTable(sql.toString(), new Object[]{currentUser.getClient_uuid()}); |
| | | importDeptBefore(dt, systemData, currentUser, errorEntity); |
| | | return dt; |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | throw e; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | errorEntity.addError(0, "导入部门失败,未知错误 ," + e.getMessage()); |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | } |
| | | errorEntity.newThrowBaseException("导入公司失败,未提取到数据"); |
| | | return null; |
| | | } |
| | | |
| | | private void importDeptBefore(DataTableEntity dt, DataTableEntity systemData, SystemUser |
| | | user, ImportErrorEntity errorEntity) throws BaseException { |
| | | List<FieldSetEntity> data = dt.getData(); |
| | | // 机构全称排序 |
| | | data.sort(Comparator.comparing(a -> a.getString(CmnConst.FIELD_ORG_LEVEL_ALL))); |
| | | if (BaseUtil.dataTableIsEmpty(systemData)) { |
| | | errorEntity.newThrowBaseException("获取系统机构信息失败,请联系管理员 "); |
| | | } |
| | | List<FieldSetEntity> systemDataList = systemData.getData(); |
| | | // 公司 |
| | | Map<String, FieldSetEntity> companyMap = Maps.newHashMap(); |
| | | // 部门 |
| | | Map<String, FieldSetEntity> deptMap = Maps.newHashMap(); |
| | | for (FieldSetEntity fse : systemDataList) { |
| | | // 机构类型 |
| | | String orgLevelType = fse.getString(CmnConst.FIELD_ORG_LEVEL_TYPE); |
| | | // 机构全称 |
| | | String org_level_all = fse.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | Map<String, FieldSetEntity> map; |
| | | if ("0".equals(orgLevelType)) { |
| | | map = companyMap; |
| | | } else if ("1".equals(org_level_all)) { |
| | | map = deptMap; |
| | | } else { |
| | | continue; |
| | | } |
| | | map.put(org_level_all, fse); |
| | | } |
| | | for (int i = 0; i < dt.getRows(); i++) { |
| | | FieldSetEntity fse = dt.getFieldSetEntity(i); |
| | | // 公司全称 |
| | | String companyAllName = fse.getString(CmnConst.ORG_LEVEL_UUID); |
| | | // 部门全称 |
| | | String deptAllName = fse.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | // 部门名称 |
| | | String deptName = fse.getString(CmnConst.FIELD_ORG_LEVEL_NAME); |
| | | private void importDeptBefore(DataTableEntity dt, DataTableEntity systemData, SystemUser |
| | | user, ImportErrorEntity errorEntity) throws BaseException { |
| | | List<FieldSetEntity> data = dt.getData(); |
| | | // 机构全称排序 |
| | | data.sort(Comparator.comparing(a -> a.getString(CmnConst.FIELD_ORG_LEVEL_ALL))); |
| | | if (BaseUtil.dataTableIsEmpty(systemData)) { |
| | | errorEntity.newThrowBaseException("获取系统机构信息失败,请联系管理员 "); |
| | | } |
| | | List<FieldSetEntity> systemDataList = systemData.getData(); |
| | | // 公司 |
| | | Map<String, FieldSetEntity> companyMap = Maps.newHashMap(); |
| | | // 部门 |
| | | Map<String, FieldSetEntity> deptMap = Maps.newHashMap(); |
| | | for (FieldSetEntity fse : systemDataList) { |
| | | // 机构类型 |
| | | String orgLevelType = fse.getString(CmnConst.FIELD_ORG_LEVEL_TYPE); |
| | | // 机构全称 |
| | | String org_level_all = fse.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | Map<String, FieldSetEntity> map; |
| | | if ("0".equals(orgLevelType)) { |
| | | map = companyMap; |
| | | } else if ("1".equals(org_level_all)) { |
| | | map = deptMap; |
| | | } else { |
| | | continue; |
| | | } |
| | | map.put(org_level_all, fse); |
| | | } |
| | | for (int i = 0; i < dt.getRows(); i++) { |
| | | FieldSetEntity fse = dt.getFieldSetEntity(i); |
| | | // 公司全称 |
| | | String companyAllName = fse.getString(CmnConst.ORG_LEVEL_UUID); |
| | | // 部门全称 |
| | | String deptAllName = fse.getString(CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | // 部门名称 |
| | | String deptName = fse.getString(CmnConst.FIELD_ORG_LEVEL_NAME); |
| | | |
| | | DataLocation dataLocation = getDataLocation(fse); |
| | | FieldSetEntity companyFse = companyMap.get(companyAllName); |
| | | if (companyFse == null || StringUtils.isEmpty(companyFse.getUUID())) { |
| | | String error = "第 %s 行,上级机构获取失败,所属公司不存在,请检查' %s '是否正确:' %s '"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColName(CmnConst.ORG_LEVEL_UUID), companyAllName); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | continue; |
| | | } |
| | | String error = "第 %s 行,上级机构获取失败,上级部门不存在,请检查' %s '是否正确:' %s '"; |
| | | // 部门上级全称 |
| | | String parentDeptAllName = getParentAllName(deptAllName, deptName); |
| | | if (StringUtils.isEmpty(parentDeptAllName)) { |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColName(CmnConst.FIELD_ORG_LEVEL_ALL), deptAllName); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | continue; |
| | | } |
| | | // 上级编码 |
| | | String code; |
| | | // 上级机构的uuid |
| | | String parentUuid; |
| | | if (!parentDeptAllName.equals(companyAllName)) { |
| | | FieldSetEntity deptFse = deptMap.get(parentDeptAllName); |
| | | if (deptFse == null || StringUtils.isEmpty(deptFse.getUUID())) { |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColName(CmnConst.FIELD_ORG_LEVEL_ALL), deptAllName); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | continue; |
| | | } |
| | | // 取出上级部门的code作为上级编码 |
| | | code = deptFse.getString(CmnConst.FIELD_ORG_LEVEL_CODE); |
| | | DataLocation dataLocation = getDataLocation(fse); |
| | | FieldSetEntity companyFse = companyMap.get(companyAllName); |
| | | if (companyFse == null || StringUtils.isEmpty(companyFse.getUUID())) { |
| | | String error = "第 %s 行,上级机构获取失败,所属公司不存在,请检查' %s '是否正确:' %s '"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColName(CmnConst.ORG_LEVEL_UUID), companyAllName); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | continue; |
| | | } |
| | | String error = "第 %s 行,上级机构获取失败,上级部门不存在,请检查' %s '是否正确:' %s '"; |
| | | // 部门上级全称 |
| | | String parentDeptAllName = getParentAllName(deptAllName, deptName); |
| | | if (StringUtils.isEmpty(parentDeptAllName)) { |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColName(CmnConst.FIELD_ORG_LEVEL_ALL), deptAllName); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | continue; |
| | | } |
| | | // 上级编码 |
| | | String code; |
| | | // 上级机构的uuid |
| | | String parentUuid; |
| | | if (!parentDeptAllName.equals(companyAllName)) { |
| | | FieldSetEntity deptFse = deptMap.get(parentDeptAllName); |
| | | if (deptFse == null || StringUtils.isEmpty(deptFse.getUUID())) { |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColName(CmnConst.FIELD_ORG_LEVEL_ALL), deptAllName); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | continue; |
| | | } |
| | | // 取出上级部门的code作为上级编码 |
| | | code = deptFse.getString(CmnConst.FIELD_ORG_LEVEL_CODE); |
| | | |
| | | parentUuid = deptFse.getString(CmnConst.ORG_LEVEL_UUID); |
| | | } else { |
| | | // 取出上级公司的code作为上级编码 |
| | | code = companyFse.getString(CmnConst.FIELD_ORG_LEVEL_CODE); |
| | | parentUuid = companyFse.getUUID(); |
| | | } |
| | | initOrganizationFieldSet(fse, user.getClient_uuid(), code, 1); |
| | | fse.setValue(CmnConst.ORG_LEVEL_UUID, parentUuid); |
| | | getBaseDao().saveFieldSetEntity(fse); |
| | | deptMap.put(deptAllName, fse); |
| | | } |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | } |
| | | parentUuid = deptFse.getString(CmnConst.ORG_LEVEL_UUID); |
| | | } else { |
| | | // 取出上级公司的code作为上级编码 |
| | | code = companyFse.getString(CmnConst.FIELD_ORG_LEVEL_CODE); |
| | | parentUuid = companyFse.getUUID(); |
| | | } |
| | | initOrganizationFieldSet(fse, user.getClient_uuid(), code, 1); |
| | | fse.setValue(CmnConst.ORG_LEVEL_UUID, parentUuid); |
| | | getBaseDao().saveFieldSetEntity(fse); |
| | | deptMap.put(deptAllName, fse); |
| | | } |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | } |
| | | |
| | | private String getParentAllName(String allName, String name) { |
| | | if (!StringUtils.isEmpty(allName) && !StringUtils.isEmpty(name)) { |
| | | int index = allName.indexOf(this.companyLevelSeparator + name); |
| | | if (index > -1) { |
| | | return allName.substring(0, index); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | private String getParentAllName(String allName, String name) { |
| | | if (!StringUtils.isEmpty(allName) && !StringUtils.isEmpty(name)) { |
| | | int index = allName.indexOf(this.companyLevelSeparator + name); |
| | | if (index > -1) { |
| | | return allName.substring(0, index); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 导入岗位等级 之前 数据处理 |
| | | * |
| | | * @param dt |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | public DataTableEntity importPostLevelBefore(DataTableEntity dt) throws BaseException { |
| | | ImportErrorEntity errorEntity = new ImportErrorEntity(); |
| | | try { |
| | | if (!BaseUtil.dataTableIsEmpty(dt)) { |
| | | SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | //管理员权限验证 |
| | | managerPermissionValidation(errorEntity, currentUser); |
| | | // 当前管理员管理的公司 |
| | | String managerCompanyUuids = currentUser.getCurrentManager().getString(CmnConst.ORG_LEVEL_UUID); |
| | | Map<String, List<FieldSetEntity>> groupCompany = Maps.newHashMap(); |
| | | Map<String, String> fieldType = Maps.newHashMap(); |
| | | fieldType.put(CmnConst.SEQUENCE, "int"); |
| | | fieldType.put(CmnConst.FIELD_JOB_GRADE_CLASS, "int"); |
| | | StringBuilder sql = new StringBuilder(); |
| | | sql.append(" select concat( "); |
| | | sql.append(" org_level_uuid,'>',job_grade_name) uuid "); |
| | | sql.append(" FROM product_sys_job_post_grades where "); |
| | | sql.append(BaseUtil.buildQuestionMarkFilter("org_level_uuid", managerCompanyUuids.split(","), true)); |
| | | DataTableEntity systemData = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | Set<Object> systemDataSet = Sets.newHashSet(); |
| | | if (!BaseUtil.dataTableIsEmpty(systemData)) { |
| | | systemDataSet.addAll(Arrays.asList(systemData.getUuidsToString().split(","))); |
| | | } |
| | | for (int i = 0; i < dt.getRows(); i++) { |
| | | FieldSetEntity fse = dt.getFieldSetEntity(i); |
| | | // 字段必填验证 |
| | | boolean validation = fieldRequiredValidation(errorEntity, fse, new String[]{CmnConst.ORG_LEVEL_UUID, CmnConst.FIELD_JOB_GRADE_NAME, CmnConst.SEQUENCE, CmnConst.FIELD_JOB_GRADE_CLASS}, fieldType); |
| | | if (!validation) { |
| | | // 验证未通过 跳过该条数据 |
| | | continue; |
| | | } |
| | | // 公司全称 |
| | | String companyAllName = fse.getString(CmnConst.ORG_LEVEL_UUID); |
| | | /** |
| | | * 导入岗位等级 之前 数据处理 |
| | | * |
| | | * @param dt |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | public DataTableEntity importPostLevelBefore(DataTableEntity dt) throws BaseException { |
| | | ImportErrorEntity errorEntity = new ImportErrorEntity(); |
| | | try { |
| | | if (!BaseUtil.dataTableIsEmpty(dt)) { |
| | | SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | //管理员权限验证 |
| | | managerPermissionValidation(errorEntity, currentUser); |
| | | // 当前管理员管理的公司 |
| | | String managerCompanyUuids = currentUser.getCurrentManager().getString(CmnConst.ORG_LEVEL_UUID); |
| | | Map<String, List<FieldSetEntity>> groupCompany = Maps.newHashMap(); |
| | | Map<String, String> fieldType = Maps.newHashMap(); |
| | | fieldType.put(CmnConst.SEQUENCE, "int"); |
| | | fieldType.put(CmnConst.FIELD_JOB_GRADE_CLASS, "int"); |
| | | StringBuilder sql = new StringBuilder(); |
| | | sql.append(" select concat( "); |
| | | sql.append(" org_level_uuid,'>',job_grade_name) uuid "); |
| | | sql.append(" FROM product_sys_job_post_grades where "); |
| | | sql.append(BaseUtil.buildQuestionMarkFilter("org_level_uuid", managerCompanyUuids.split(","), true)); |
| | | DataTableEntity systemData = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | Set<Object> systemDataSet = Sets.newHashSet(); |
| | | if (!BaseUtil.dataTableIsEmpty(systemData)) { |
| | | systemDataSet.addAll(Arrays.asList(systemData.getUuidsToString().split(","))); |
| | | } |
| | | for (int i = 0; i < dt.getRows(); i++) { |
| | | FieldSetEntity fse = dt.getFieldSetEntity(i); |
| | | // 字段必填验证 |
| | | boolean validation = fieldRequiredValidation(errorEntity, fse, new String[]{CmnConst.ORG_LEVEL_UUID, CmnConst.FIELD_JOB_GRADE_NAME, CmnConst.SEQUENCE, CmnConst.FIELD_JOB_GRADE_CLASS}, fieldType); |
| | | if (!validation) { |
| | | // 验证未通过 跳过该条数据 |
| | | continue; |
| | | } |
| | | // 公司全称 |
| | | String companyAllName = fse.getString(CmnConst.ORG_LEVEL_UUID); |
| | | |
| | | List<FieldSetEntity> groupPostGradeList = groupCompany.get(companyAllName); |
| | | if (groupPostGradeList == null) { |
| | | groupPostGradeList = Lists.newArrayList(); |
| | | groupCompany.put(companyAllName, groupPostGradeList); |
| | | } |
| | | groupPostGradeList.add(fse); |
| | | } |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | Set<String> companyAllNames = groupCompany.keySet(); |
| | | sql = new StringBuilder(); |
| | | sql.append(" select uuid,org_level_all "); |
| | | sql.append(" FROM product_sys_org_levels "); |
| | | sql.append(" where "); |
| | | sql.append(BaseUtil.buildQuestionMarkFilter("uuid", managerCompanyUuids.split(","), true)); |
| | | sql.append(" AND "); |
| | | sql.append(BaseUtil.buildQuestionMarkFilter("org_level_all", companyAllNames.toArray(), true)); |
| | | // 根据用户上传的公司全称 & 该管理员管理的所有公司 进行查询公司的uuid |
| | | DataTableEntity companyInfo = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | // 定义没有找到公司的数据 写入错误方法 |
| | | CallBack<FieldSetEntity> callBack = (value) -> { |
| | | for (FieldSetEntity fs : value) { |
| | | DataLocation dataLocation = getDataLocation(fs); |
| | | String error = "第 %s 行,第 %s 数据错误,所属公司不存在,请检查列 '%s'"; |
| | | errorEntity.addError(dataLocation.getRowIndex(), String.format(error, |
| | | dataLocation.getRowIndex(), |
| | | dataLocation.getColIndex(CmnConst.ORG_LEVEL_UUID), |
| | | dataLocation.getColName(CmnConst.ORG_LEVEL_UUID))); |
| | | } |
| | | }; |
| | | // 没有查询到所有公司信息 |
| | | if (BaseUtil.dataTableIsEmpty(companyInfo)) { |
| | | for (List<FieldSetEntity> value : groupCompany.values()) { |
| | | // 循环写入错误 |
| | | callBack.method(value.toArray(new FieldSetEntity[]{})); |
| | | } |
| | | errorEntity.newThrowBaseException(); |
| | | } else { |
| | | // copy 公司全称 |
| | | Set<String> companyNames = Sets.newHashSet(); |
| | | companyNames.addAll(companyAllNames); |
| | | // 循环查询的公司结果 |
| | | for (int i = 0; i < companyInfo.getRows(); i++) { |
| | | String uuid = companyInfo.getString(i, CmnConst.UUID); |
| | | String org_level_all = companyInfo.getString(i, CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | if (companyNames.contains(org_level_all)) { |
| | | companyNames.remove(org_level_all); |
| | | } |
| | | List<FieldSetEntity> postGradeList = groupCompany.get(org_level_all); |
| | | if (postGradeList != null) { |
| | | for (FieldSetEntity fs : postGradeList) { |
| | | // 将公司uuid写入每条数据 |
| | | BaseUtil.createCreatorAndCreationTime(currentUser, fs); |
| | | fs.setValue(CmnConst.ORG_LEVEL_UUID, uuid); |
| | | fs.setValue(CmnConst.IS_USED, 1); |
| | | String job_grade_name = fs.getString(CmnConst.FIELD_JOB_GRADE_NAME); |
| | | List<FieldSetEntity> groupPostGradeList = groupCompany.get(companyAllName); |
| | | if (groupPostGradeList == null) { |
| | | groupPostGradeList = Lists.newArrayList(); |
| | | groupCompany.put(companyAllName, groupPostGradeList); |
| | | } |
| | | groupPostGradeList.add(fse); |
| | | } |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | Set<String> companyAllNames = groupCompany.keySet(); |
| | | sql = new StringBuilder(); |
| | | sql.append(" select uuid,org_level_all "); |
| | | sql.append(" FROM product_sys_org_levels "); |
| | | sql.append(" where "); |
| | | sql.append(BaseUtil.buildQuestionMarkFilter("uuid", managerCompanyUuids.split(","), true)); |
| | | sql.append(" AND "); |
| | | sql.append(BaseUtil.buildQuestionMarkFilter("org_level_all", companyAllNames.toArray(), true)); |
| | | // 根据用户上传的公司全称 & 该管理员管理的所有公司 进行查询公司的uuid |
| | | DataTableEntity companyInfo = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | // 定义没有找到公司的数据 写入错误方法 |
| | | CallBack<FieldSetEntity> callBack = (value) -> { |
| | | for (FieldSetEntity fs : value) { |
| | | DataLocation dataLocation = getDataLocation(fs); |
| | | String error = "第 %s 行,第 %s 数据错误,所属公司不存在,请检查列 '%s'"; |
| | | errorEntity.addError(dataLocation.getRowIndex(), String.format(error, |
| | | dataLocation.getRowIndex(), |
| | | dataLocation.getColIndex(CmnConst.ORG_LEVEL_UUID), |
| | | dataLocation.getColName(CmnConst.ORG_LEVEL_UUID))); |
| | | } |
| | | }; |
| | | // 没有查询到所有公司信息 |
| | | if (BaseUtil.dataTableIsEmpty(companyInfo)) { |
| | | for (List<FieldSetEntity> value : groupCompany.values()) { |
| | | // 循环写入错误 |
| | | callBack.method(value.toArray(new FieldSetEntity[]{})); |
| | | } |
| | | errorEntity.newThrowBaseException(); |
| | | } else { |
| | | // copy 公司全称 |
| | | Set<String> companyNames = Sets.newHashSet(); |
| | | companyNames.addAll(companyAllNames); |
| | | // 循环查询的公司结果 |
| | | for (int i = 0; i < companyInfo.getRows(); i++) { |
| | | String uuid = companyInfo.getString(i, CmnConst.UUID); |
| | | String org_level_all = companyInfo.getString(i, CmnConst.FIELD_ORG_LEVEL_ALL); |
| | | if (companyNames.contains(org_level_all)) { |
| | | companyNames.remove(org_level_all); |
| | | } |
| | | List<FieldSetEntity> postGradeList = groupCompany.get(org_level_all); |
| | | if (postGradeList != null) { |
| | | for (FieldSetEntity fs : postGradeList) { |
| | | // 将公司uuid写入每条数据 |
| | | BaseUtil.createCreatorAndCreationTime(currentUser, fs); |
| | | fs.setValue(CmnConst.ORG_LEVEL_UUID, uuid); |
| | | fs.setValue(CmnConst.IS_USED, 1); |
| | | String job_grade_name = fs.getString(CmnConst.FIELD_JOB_GRADE_NAME); |
| | | // String group_name = fs.getString(CmnConst.FIELD_GROUP_NAME); |
| | | String managerValue = uuid + this.companyLevelSeparator + job_grade_name; |
| | | String managerValue = uuid + this.companyLevelSeparator + job_grade_name; |
| | | |
| | | if (systemDataSet.contains(managerValue)) { |
| | | if (systemDataSet.contains(managerValue)) { |
| | | |
| | | DataLocation dataLocation = getDataLocation(fs); |
| | | String error = "第 %s 行,第 %s 列,数据重复"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_JOB_GRADE_NAME)); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | continue; |
| | | } |
| | | systemDataSet.add(managerValue); |
| | | } |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | } |
| | | } |
| | | // 判断有是否有公司没查询到 |
| | | if (companyNames != null && companyNames.size() > 0) { |
| | | List<FieldSetEntity> postGradeList = Lists.newArrayList(); |
| | | for (String companyName : companyNames) { |
| | | //将没查询到的公司所属岗位等级合并 |
| | | postGradeList.addAll(groupCompany.get(companyName)); |
| | | } |
| | | if (postGradeList.size() > 0) { |
| | | //调用错误组装回调 |
| | | callBack.method(postGradeList.toArray(new FieldSetEntity[]{})); |
| | | // 抛出错误 |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | } |
| | | // 保存所有数据 |
| | | getBaseDao().add(dt); |
| | | return dt; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | DataLocation dataLocation = getDataLocation(fs); |
| | | String error = "第 %s 行,第 %s 列,数据重复"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_JOB_GRADE_NAME)); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | continue; |
| | | } |
| | | systemDataSet.add(managerValue); |
| | | } |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | } |
| | | } |
| | | // 判断有是否有公司没查询到 |
| | | if (companyNames != null && companyNames.size() > 0) { |
| | | List<FieldSetEntity> postGradeList = Lists.newArrayList(); |
| | | for (String companyName : companyNames) { |
| | | //将没查询到的公司所属岗位等级合并 |
| | | postGradeList.addAll(groupCompany.get(companyName)); |
| | | } |
| | | if (postGradeList.size() > 0) { |
| | | //调用错误组装回调 |
| | | callBack.method(postGradeList.toArray(new FieldSetEntity[]{})); |
| | | // 抛出错误 |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | } |
| | | // 保存所有数据 |
| | | getBaseDao().add(dt); |
| | | return dt; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | |
| | | errorEntity.newThrowBaseException("导入岗位等级失败", e); |
| | | } |
| | | errorEntity.newThrowBaseException("导入岗位等级失败,未提取到数据"); |
| | | return null; |
| | | } |
| | | errorEntity.newThrowBaseException("导入岗位等级失败", e); |
| | | } |
| | | errorEntity.newThrowBaseException("导入岗位等级失败,未提取到数据"); |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 导入岗位 之前 数据处理 |
| | | * |
| | | * @param dt |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | public DataTableEntity importPostBefore(DataTableEntity dt) throws BaseException { |
| | | ImportErrorEntity errorEntity = new ImportErrorEntity(); |
| | | if (!BaseUtil.dataTableIsEmpty(dt)) { |
| | | SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | //管理员权限验证 |
| | | managerPermissionValidation(errorEntity, currentUser); |
| | | Map<String, String> fieldType = Maps.newHashMap(); |
| | | // 当前管理员管理的公司 |
| | | String managerCompanyUuids = currentUser.getCurrentManager().getString(CmnConst.ORG_LEVEL_UUID); |
| | | fieldType.put(CmnConst.SEQUENCE, "int"); |
| | | String companyFilter = BaseUtil.buildQuestionMarkFilter(CmnConst.ORG_LEVEL_UUID, managerCompanyUuids.split(","), true); |
| | | StringBuilder sql = new StringBuilder(8); |
| | | sql.append(" SELECT org_level_all uuid, uuid dept_uuid,org_level_uuid FROM product_sys_org_levels where org_level_type=1 and length(org_level_uuid)>0 "); |
| | | sql.append(" and "); |
| | | sql.append(companyFilter); |
| | | DataTableEntity deptData = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | if (BaseUtil.dataTableIsEmpty(deptData)) { |
| | | errorEntity.newThrowBaseException("您所管理的公司没有可供选择的部门,请核对部门数据"); |
| | | } |
| | | sql = new StringBuilder(8); |
| | | sql.append(" SELECT job_grade_name uuid,org_level_uuid,uuid grade_uuid "); |
| | | sql.append(" FROM product_sys_job_post_grades WHERE "); |
| | | sql.append(companyFilter); |
| | | // 查询当前管理管理公司所有的岗位等级 |
| | | DataTableEntity postGradeData = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | if (BaseUtil.dataTableIsEmpty(postGradeData)) { |
| | | /** |
| | | * 导入岗位 之前 数据处理 |
| | | * |
| | | * @param dt |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | public DataTableEntity importPostBefore(DataTableEntity dt) throws BaseException { |
| | | ImportErrorEntity errorEntity = new ImportErrorEntity(); |
| | | if (!BaseUtil.dataTableIsEmpty(dt)) { |
| | | SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | //管理员权限验证 |
| | | managerPermissionValidation(errorEntity, currentUser); |
| | | Map<String, String> fieldType = Maps.newHashMap(); |
| | | // 当前管理员管理的公司 |
| | | String managerCompanyUuids = currentUser.getCurrentManager().getString(CmnConst.ORG_LEVEL_UUID); |
| | | fieldType.put(CmnConst.SEQUENCE, "int"); |
| | | String companyFilter = BaseUtil.buildQuestionMarkFilter(CmnConst.ORG_LEVEL_UUID, managerCompanyUuids.split(","), true); |
| | | StringBuilder sql = new StringBuilder(8); |
| | | sql.append(" SELECT org_level_all uuid, uuid dept_uuid,org_level_uuid FROM product_sys_org_levels where org_level_type=1 and length(org_level_uuid)>0 "); |
| | | sql.append(" and "); |
| | | sql.append(companyFilter); |
| | | DataTableEntity deptData = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | if (BaseUtil.dataTableIsEmpty(deptData)) { |
| | | errorEntity.newThrowBaseException("您所管理的公司没有可供选择的部门,请核对部门数据"); |
| | | } |
| | | sql = new StringBuilder(8); |
| | | sql.append(" SELECT job_grade_name uuid,org_level_uuid,uuid grade_uuid "); |
| | | sql.append(" FROM product_sys_job_post_grades WHERE "); |
| | | sql.append(companyFilter); |
| | | // 查询当前管理管理公司所有的岗位等级 |
| | | DataTableEntity postGradeData = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | if (BaseUtil.dataTableIsEmpty(postGradeData)) { |
| | | // errorEntity.newThrowBaseException("您所管理的公司没有可供选择的岗位等级,请核对岗位等级数据"); |
| | | } |
| | | for (int i = 0; i < dt.getRows(); i++) { |
| | | FieldSetEntity fse = dt.getFieldSetEntity(i); |
| | | // 字段必填 & 类型验证 |
| | | boolean validationResult = fieldRequiredValidation(errorEntity, fse, new String[]{CmnConst.FIELD_DEPT_UUID, CmnConst.FIELD_JOB_POST_NAME, CmnConst.SEQUENCE}, fieldType); |
| | | if (!validationResult) { |
| | | // 验证未通过跳过 |
| | | continue; |
| | | } |
| | | // 部门全称 |
| | | String deptAllName = fse.getString(CmnConst.FIELD_DEPT_UUID); |
| | | // 岗位等级名称 |
| | | String[] gradeNames = BaseUtil.ifNull(fse.getString(CmnConst.FIELD_JOB_POST_GRADE), "").split(","); |
| | | List<FieldSetEntity> fieldSetEntity = deptData.getFieldSetEntity(deptAllName); |
| | | // 部门所在的公司 |
| | | String companyUuid = null; |
| | | // 错误标识 |
| | | boolean errorFlag = false; |
| | | DataLocation dataLocation = null; |
| | | if (fieldSetEntity == null || fieldSetEntity.size() < 1) { |
| | | dataLocation = getDataLocation(fse); |
| | | String error = "第 %s 行,第 %s 列,部门不存在,请核对 '%s' 数据在系统中是否存在"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_DEPT_UUID), dataLocation.getColName(CmnConst.FIELD_DEPT_UUID)); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | errorFlag = true; |
| | | } else { |
| | | FieldSetEntity fs = fieldSetEntity.get(0); |
| | | companyUuid = fs.getString(CmnConst.ORG_LEVEL_UUID); |
| | | fse.setValue(CmnConst.FIELD_DEPT_UUID, fs.getString(CmnConst.FIELD_DEPT_UUID)); |
| | | } |
| | | // 根据岗位等级名称取出相关数据 |
| | | List<FieldSetEntity> postGradeList = new ArrayList<>(); |
| | | for (String gradeName : gradeNames) { |
| | | if (!BaseUtil.dataTableIsEmpty(postGradeData) && postGradeData.getFieldSetEntity(gradeName) != null) { |
| | | postGradeList.addAll(postGradeData.getFieldSetEntity(gradeName)); |
| | | } |
| | | } |
| | | String error = "第 %s 行,第 %s 列,岗位等级不存在,请核对 '%s' 数据在系统中是否存在"; |
| | | // 判断岗位等级是否存在 默认不抛出错误 |
| | | if (postGradeList.size() < 1 && false) { |
| | | if (dataLocation == null) { |
| | | dataLocation = getDataLocation(fse); |
| | | } |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_JOB_POST_GRADE), dataLocation.getColName(CmnConst.FIELD_JOB_POST_GRADE)); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | errorFlag = true; |
| | | } else if (postGradeList.size() > 0) { |
| | | String gradeUuid = ""; |
| | | // 循环岗位等级 |
| | | for (FieldSetEntity fs : postGradeList) { |
| | | // 查找岗位等级与公司是否匹配 |
| | | if (companyUuid != null && companyUuid.equals(fs.getString(CmnConst.ORG_LEVEL_UUID))) { |
| | | if (!StringUtils.isEmpty(gradeUuid)) { |
| | | gradeUuid += ","; |
| | | } |
| | | gradeUuid += fs.getString("grade_uuid"); |
| | | } |
| | | } |
| | | // 没有匹配到该公司下有相应的岗位等级 |
| | | if (StringUtils.isEmpty(gradeUuid)) { |
| | | if (dataLocation == null) { |
| | | dataLocation = getDataLocation(fse); |
| | | } |
| | | error = "第 %s 行,第 %s 列,岗位等级在不存在,请核对 '%s' 数据在所属部门的公司中是否存在"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_JOB_POST_GRADE), dataLocation.getColName(CmnConst.FIELD_JOB_POST_GRADE)); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | errorFlag = true; |
| | | } else { |
| | | String[] gradeUuids = gradeUuid.split(","); |
| | | // 创建岗位与岗位等级的映射表 |
| | | DataTableEntity subGradeMapping = new DataTableEntity(); |
| | | for (String uuid : gradeUuids) { |
| | | FieldSetEntity gradeMappingFieldSet = new FieldSetEntity(); |
| | | gradeMappingFieldSet.setTableName(CmnConst.TABLE_PRODUCT_SYS_JOB_POSTS_GRADES_MAPPING); |
| | | gradeMappingFieldSet.setValue("job_grade_uuid", uuid); |
| | | BaseUtil.createCreatorAndCreationTime(gradeMappingFieldSet); |
| | | subGradeMapping.addFieldSetEntity(gradeMappingFieldSet); |
| | | } |
| | | fse.addSubDataTable(subGradeMapping); |
| | | fse.setValue(CmnConst.FIELD_JOB_POST_GRADE, null); |
| | | } |
| | | } |
| | | if (errorFlag) { |
| | | continue; |
| | | } |
| | | // 导入数据默认启用 |
| | | fse.setValue(CmnConst.IS_USED, 1); |
| | | } |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } else { |
| | | return dt; |
| | | } |
| | | } |
| | | errorEntity.newThrowBaseException("导入岗位等级失败,未提取到数据"); |
| | | return null; |
| | | } |
| | | } |
| | | for (int i = 0; i < dt.getRows(); i++) { |
| | | FieldSetEntity fse = dt.getFieldSetEntity(i); |
| | | // 字段必填 & 类型验证 |
| | | boolean validationResult = fieldRequiredValidation(errorEntity, fse, new String[]{CmnConst.FIELD_DEPT_UUID, CmnConst.FIELD_JOB_POST_NAME, CmnConst.SEQUENCE}, fieldType); |
| | | if (!validationResult) { |
| | | // 验证未通过跳过 |
| | | continue; |
| | | } |
| | | // 部门全称 |
| | | String deptAllName = fse.getString(CmnConst.FIELD_DEPT_UUID); |
| | | // 岗位等级名称 |
| | | String[] gradeNames = BaseUtil.ifNull(fse.getString(CmnConst.FIELD_JOB_POST_GRADE), "").split(","); |
| | | List<FieldSetEntity> fieldSetEntity = deptData.getFieldSetEntity(deptAllName); |
| | | // 部门所在的公司 |
| | | String companyUuid = null; |
| | | // 错误标识 |
| | | boolean errorFlag = false; |
| | | DataLocation dataLocation = null; |
| | | if (fieldSetEntity == null || fieldSetEntity.size() < 1) { |
| | | dataLocation = getDataLocation(fse); |
| | | String error = "第 %s 行,第 %s 列,部门不存在,请核对 '%s' 数据在系统中是否存在"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_DEPT_UUID), dataLocation.getColName(CmnConst.FIELD_DEPT_UUID)); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | errorFlag = true; |
| | | } else { |
| | | FieldSetEntity fs = fieldSetEntity.get(0); |
| | | companyUuid = fs.getString(CmnConst.ORG_LEVEL_UUID); |
| | | fse.setValue(CmnConst.FIELD_DEPT_UUID, fs.getString(CmnConst.FIELD_DEPT_UUID)); |
| | | } |
| | | // 根据岗位等级名称取出相关数据 |
| | | List<FieldSetEntity> postGradeList = new ArrayList<>(); |
| | | for (String gradeName : gradeNames) { |
| | | if (!BaseUtil.dataTableIsEmpty(postGradeData) && postGradeData.getFieldSetEntity(gradeName) != null) { |
| | | postGradeList.addAll(postGradeData.getFieldSetEntity(gradeName)); |
| | | } |
| | | } |
| | | String error = "第 %s 行,第 %s 列,岗位等级不存在,请核对 '%s' 数据在系统中是否存在"; |
| | | // 判断岗位等级是否存在 默认不抛出错误 |
| | | if (postGradeList.size() < 1 && false) { |
| | | if (dataLocation == null) { |
| | | dataLocation = getDataLocation(fse); |
| | | } |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_JOB_POST_GRADE), dataLocation.getColName(CmnConst.FIELD_JOB_POST_GRADE)); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | errorFlag = true; |
| | | } else if (postGradeList.size() > 0) { |
| | | String gradeUuid = ""; |
| | | // 循环岗位等级 |
| | | for (FieldSetEntity fs : postGradeList) { |
| | | // 查找岗位等级与公司是否匹配 |
| | | if (companyUuid != null && companyUuid.equals(fs.getString(CmnConst.ORG_LEVEL_UUID))) { |
| | | if (!StringUtils.isEmpty(gradeUuid)) { |
| | | gradeUuid += ","; |
| | | } |
| | | gradeUuid += fs.getString("grade_uuid"); |
| | | } |
| | | } |
| | | // 没有匹配到该公司下有相应的岗位等级 |
| | | if (StringUtils.isEmpty(gradeUuid)) { |
| | | if (dataLocation == null) { |
| | | dataLocation = getDataLocation(fse); |
| | | } |
| | | error = "第 %s 行,第 %s 列,岗位等级在不存在,请核对 '%s' 数据在所属部门的公司中是否存在"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_JOB_POST_GRADE), dataLocation.getColName(CmnConst.FIELD_JOB_POST_GRADE)); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | errorFlag = true; |
| | | } else { |
| | | String[] gradeUuids = gradeUuid.split(","); |
| | | // 创建岗位与岗位等级的映射表 |
| | | DataTableEntity subGradeMapping = new DataTableEntity(); |
| | | for (String uuid : gradeUuids) { |
| | | FieldSetEntity gradeMappingFieldSet = new FieldSetEntity(); |
| | | gradeMappingFieldSet.setTableName(CmnConst.TABLE_PRODUCT_SYS_JOB_POSTS_GRADES_MAPPING); |
| | | gradeMappingFieldSet.setValue("job_grade_uuid", uuid); |
| | | BaseUtil.createCreatorAndCreationTime(gradeMappingFieldSet); |
| | | subGradeMapping.addFieldSetEntity(gradeMappingFieldSet); |
| | | } |
| | | fse.addSubDataTable(subGradeMapping); |
| | | fse.setValue(CmnConst.FIELD_JOB_POST_GRADE, null); |
| | | } |
| | | } |
| | | if (errorFlag) { |
| | | continue; |
| | | } |
| | | // 导入数据默认启用 |
| | | fse.setValue(CmnConst.IS_USED, 1); |
| | | } |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } else { |
| | | return dt; |
| | | } |
| | | } |
| | | errorEntity.newThrowBaseException("导入岗位等级失败,未提取到数据"); |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 导入员工 之前 数据处理 |
| | | * |
| | | * @param fse |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | public DataTableEntity importStaffBefore(DataTableEntity fse) throws BaseException { |
| | | ImportStaffDataVo staffDataVo = new ImportStaffDataVo(fse); |
| | | staffDataVo.startImporting(); |
| | | return fse; |
| | | } |
| | | /** |
| | | * 导入员工 之前 数据处理 |
| | | * |
| | | * @param fse |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | public DataTableEntity importStaffBefore(DataTableEntity fse) throws BaseException { |
| | | ImportStaffDataVo staffDataVo = new ImportStaffDataVo(fse); |
| | | staffDataVo.startImporting(); |
| | | return fse; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 员工导入操作类 |
| | | */ |
| | | private class ImportStaffDataVo { |
| | | //导入的所有数据 |
| | | private DataTableEntity dt; |
| | | /** |
| | | * 错误处理类 |
| | | */ |
| | | private ImportErrorEntity errorEntity; |
| | | /** |
| | | * 系统中上级领导数据 |
| | | */ |
| | | DataTableEntity directLeaderData; |
| | | /** |
| | | * 部门数据 |
| | | */ |
| | | DataTableEntity deptData; |
| | | /** |
| | | * 角色数据 |
| | | */ |
| | | DataTableEntity roleData; |
| | | /** |
| | | * 岗位 & 岗位等级数据 |
| | | */ |
| | | DataTableEntity postData; |
| | | /** |
| | | * 员工表历史数据 |
| | | */ |
| | | DataTableEntity systemData; |
| | | /** |
| | | * 导入数据的所有领导(员工编码) |
| | | */ |
| | | Set<String> direct_leader_codes; |
| | | /** |
| | | * 导入的数据按部门分组 |
| | | */ |
| | | Map<String, List<FieldSetEntity>> deptGroupMap; |
| | | /** |
| | | * 当前用户 |
| | | */ |
| | | SystemUser currentUser; |
| | | /** |
| | | * 当前客户 |
| | | */ |
| | | String client_uuid; |
| | | /** |
| | | * 导入的数据以员工编码存放(员工编码是唯一的) |
| | | */ |
| | | Map<String, FieldSetEntity> staffCodeMap; |
| | | /** |
| | | * 导入数据类型验证 |
| | | */ |
| | | Map<String, String> fieldType; |
| | | /** |
| | | * 公司过滤条件 |
| | | */ |
| | | String companyFilter; |
| | | /** |
| | | * 分隔符 |
| | | */ |
| | | String separator = ">"; |
| | | /** |
| | | * 员工导入操作类 |
| | | */ |
| | | private class ImportStaffDataVo { |
| | | //导入的所有数据 |
| | | private DataTableEntity dt; |
| | | /** |
| | | * 错误处理类 |
| | | */ |
| | | private ImportErrorEntity errorEntity; |
| | | /** |
| | | * 系统中上级领导数据 |
| | | */ |
| | | DataTableEntity directLeaderData; |
| | | /** |
| | | * 部门数据 |
| | | */ |
| | | DataTableEntity deptData; |
| | | /** |
| | | * 角色数据 |
| | | */ |
| | | DataTableEntity roleData; |
| | | /** |
| | | * 岗位 & 岗位等级数据 |
| | | */ |
| | | DataTableEntity postData; |
| | | /** |
| | | * 员工表历史数据 |
| | | */ |
| | | DataTableEntity systemData; |
| | | /** |
| | | * 导入数据的所有领导(员工编码) |
| | | */ |
| | | Set<String> direct_leader_codes; |
| | | /** |
| | | * 导入的数据按部门分组 |
| | | */ |
| | | Map<String, List<FieldSetEntity>> deptGroupMap; |
| | | /** |
| | | * 当前用户 |
| | | */ |
| | | SystemUser currentUser; |
| | | /** |
| | | * 当前客户 |
| | | */ |
| | | String client_uuid; |
| | | /** |
| | | * 导入的数据以员工编码存放(员工编码是唯一的) |
| | | */ |
| | | Map<String, FieldSetEntity> staffCodeMap; |
| | | /** |
| | | * 导入数据类型验证 |
| | | */ |
| | | Map<String, String> fieldType; |
| | | /** |
| | | * 公司过滤条件 |
| | | */ |
| | | String companyFilter; |
| | | /** |
| | | * 分隔符 |
| | | */ |
| | | String separator = ">"; |
| | | |
| | | StringBuilder sql; |
| | | /** |
| | | * 初始密码 |
| | | * 来源于 properties 中的初始密码 如不存在默认为 '123' |
| | | */ |
| | | String init_pwd; |
| | | /** |
| | | * 部门全称存放的部门详情数据 |
| | | */ |
| | | private Map<String, FieldSetEntity> deptMap; |
| | | /** |
| | | * 员工管理service |
| | | * 定义该操作类中避免没必要的注入 进入构造时会初始化对应bean |
| | | */ |
| | | private StaffManagerService staffManagerService; |
| | | StringBuilder sql; |
| | | /** |
| | | * 初始密码 |
| | | * 来源于 properties 中的初始密码 如不存在默认为 '123' |
| | | */ |
| | | String init_pwd; |
| | | /** |
| | | * 部门全称存放的部门详情数据 |
| | | */ |
| | | private Map<String, FieldSetEntity> deptMap; |
| | | /** |
| | | * 员工管理service |
| | | * 定义该操作类中避免没必要的注入 进入构造时会初始化对应bean |
| | | */ |
| | | private StaffManagerService staffManagerService; |
| | | |
| | | /** |
| | | * 构造方法 用于clone 非必要不要自行调用此方法 |
| | | * |
| | | * @param currentData |
| | | * @param currentDeptData |
| | | */ |
| | | ImportStaffDataVo(FieldSetEntity currentData, FieldSetEntity currentDeptData) throws BaseException { |
| | | // 该构造用于 clone 方法 |
| | | // 非clone 方式调用会出现未知错误 |
| | | this.currentData = currentData; |
| | | this.currentDeptData = currentDeptData; |
| | | if (currentData == null || currentDeptData == null) { |
| | | try { |
| | | throw new RuntimeException("Constructor arguments cannot be null"); |
| | | } catch (RuntimeException e) { |
| | | throw new BaseException(e); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 构造方法 用于clone 非必要不要自行调用此方法 |
| | | * |
| | | * @param currentData |
| | | * @param currentDeptData |
| | | */ |
| | | ImportStaffDataVo(FieldSetEntity currentData, FieldSetEntity currentDeptData) throws BaseException { |
| | | // 该构造用于 clone 方法 |
| | | // 非clone 方式调用会出现未知错误 |
| | | this.currentData = currentData; |
| | | this.currentDeptData = currentDeptData; |
| | | if (currentData == null || currentDeptData == null) { |
| | | try { |
| | | throw new RuntimeException("Constructor arguments cannot be null"); |
| | | } catch (RuntimeException e) { |
| | | throw new BaseException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 无参构造 初始必要数据 |
| | | * |
| | | * @param dt |
| | | */ |
| | | public ImportStaffDataVo(DataTableEntity dt) throws BaseException { |
| | | errorEntity = new ImportErrorEntity(); |
| | | if (BaseUtil.dataTableIsEmpty(dt)) { |
| | | errorEntity.newThrowBaseException("导入员工失败,未提取到数据"); |
| | | } |
| | | this.staffManagerService = SpringBeanUtil.getBean("staffManagerService", StaffManagerService.class); |
| | | direct_leader_codes = Sets.newHashSet(); |
| | | fieldType = Maps.newHashMap(); |
| | | currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | client_uuid = currentUser.getClient_uuid(); |
| | | staffCodeMap = Maps.newHashMap(); |
| | | deptGroupMap = Maps.newHashMap(); |
| | | init_pwd = Global.getSystemConfig("initial.pwd", "123"); |
| | | this.dt = dt; |
| | | //管理员权限验证 |
| | | managerPermissionValidation(errorEntity, currentUser); |
| | | // 公司过滤条件 |
| | | companyFilter = BaseUtil.buildQuestionMarkFilter(CmnConst.ORG_LEVEL_UUID, currentUser.getCurrentManager().getString(CmnConst.ORG_LEVEL_UUID).split(","), true); |
| | | fieldType.put("id_number", "id_card"); |
| | | fieldType.put("birth_date", "dateTime"); |
| | | fieldType.put("entry_datetime", "dateTime"); |
| | | fieldType.put("mobile_phone", "mobile_phone"); |
| | | fieldType.put("staff_email", "email"); |
| | | fieldType.put("age", "int"); |
| | | } |
| | | /** |
| | | * 无参构造 初始必要数据 |
| | | * |
| | | * @param dt |
| | | */ |
| | | public ImportStaffDataVo(DataTableEntity dt) throws BaseException { |
| | | errorEntity = new ImportErrorEntity(); |
| | | if (BaseUtil.dataTableIsEmpty(dt)) { |
| | | errorEntity.newThrowBaseException("导入员工失败,未提取到数据"); |
| | | } |
| | | this.staffManagerService = SpringBeanUtil.getBean("staffManagerService", StaffManagerService.class); |
| | | direct_leader_codes = Sets.newHashSet(); |
| | | fieldType = Maps.newHashMap(); |
| | | currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | client_uuid = currentUser.getClient_uuid(); |
| | | staffCodeMap = Maps.newHashMap(); |
| | | deptGroupMap = Maps.newHashMap(); |
| | | init_pwd = Global.getSystemConfig("initial.pwd", "123"); |
| | | this.dt = dt; |
| | | //管理员权限验证 |
| | | managerPermissionValidation(errorEntity, currentUser); |
| | | // 公司过滤条件 |
| | | companyFilter = BaseUtil.buildQuestionMarkFilter(CmnConst.ORG_LEVEL_UUID, currentUser.getCurrentManager().getString(CmnConst.ORG_LEVEL_UUID).split(","), true); |
| | | fieldType.put("id_number", "id_card"); |
| | | fieldType.put("birth_date", "dateTime"); |
| | | fieldType.put("entry_datetime", "dateTime"); |
| | | fieldType.put("mobile_phone", "mobile_phone"); |
| | | fieldType.put("staff_email", "email"); |
| | | fieldType.put("age", "int"); |
| | | } |
| | | |
| | | /** |
| | | * 导入数据入口 |
| | | * 开始导入 |
| | | */ |
| | | public void startImporting() throws BaseException { |
| | | // 数据有效性验证 数据必填验证 & 数据有效性验证 & 数据分组 |
| | | this.requiredValidation(); |
| | | // 查询系统中已存在的员工 |
| | | findExistStaff(); |
| | | // 数据重复验证 |
| | | this.repeatValidation(); |
| | | this.throwError(); |
| | | // 初始化所需数据 |
| | | this.initializeSystemData(); |
| | | // 开始处理导入数据 |
| | | this.handleDataTable(); |
| | | } |
| | | /** |
| | | * 导入数据入口 |
| | | * 开始导入 |
| | | */ |
| | | public void startImporting() throws BaseException { |
| | | // 数据有效性验证 数据必填验证 & 数据有效性验证 & 数据分组 |
| | | this.requiredValidation(); |
| | | // 查询系统中已存在的员工 |
| | | findExistStaff(); |
| | | // 数据重复验证 |
| | | this.repeatValidation(); |
| | | this.throwError(); |
| | | // 初始化所需数据 |
| | | this.initializeSystemData(); |
| | | // 开始处理导入数据 |
| | | this.handleDataTable(); |
| | | } |
| | | |
| | | /** |
| | | * handleDataTable 遍历时的数据 |
| | | * 可能是通过 clone 对象赋值的 没有通过 handleDataTable 方法 |
| | | */ |
| | | private FieldSetEntity currentData; |
| | | /** |
| | | * handleDataTable 遍历数据对应的部门 |
| | | * 可能是通过 clone 对象赋值的 没有通过 handleDataTable 方法 |
| | | */ |
| | | private FieldSetEntity currentDeptData; |
| | | /** |
| | | * handleDataTable 遍历时的数据 |
| | | * 可能是通过 clone 对象赋值的 没有通过 handleDataTable 方法 |
| | | */ |
| | | private FieldSetEntity currentData; |
| | | /** |
| | | * handleDataTable 遍历数据对应的部门 |
| | | * 可能是通过 clone 对象赋值的 没有通过 handleDataTable 方法 |
| | | */ |
| | | private FieldSetEntity currentDeptData; |
| | | |
| | | /** |
| | | * 上级领导未找到 |
| | | */ |
| | | private void superStaffNotExist() throws BaseException { |
| | | DataLocation dataLocation = getDataLocation(this.currentData); |
| | | String error = "第 %s 行,第 %s 列,上级领导获取失败,请检查 %s 填写值是否正确,该列值应填写 %s 列对应的值"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_DIRECT_LEADER_CODE), dataLocation.getColName(CmnConst.FIELD_DIRECT_LEADER_CODE), dataLocation.getColName(CmnConst.FIELD_STAFF_CODE)); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | } |
| | | /** |
| | | * 上级领导未找到 |
| | | */ |
| | | private void superStaffNotExist() throws BaseException { |
| | | DataLocation dataLocation = getDataLocation(this.currentData); |
| | | String error = "第 %s 行,第 %s 列,上级领导获取失败,请检查 %s 填写值是否正确,该列值应填写 %s 列对应的值"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_DIRECT_LEADER_CODE), dataLocation.getColName(CmnConst.FIELD_DIRECT_LEADER_CODE), dataLocation.getColName(CmnConst.FIELD_STAFF_CODE)); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | } |
| | | |
| | | /** |
| | | * 处理所有记录 |
| | | */ |
| | | private void handleDataTable() throws BaseException { |
| | | for (Map.Entry<String, List<FieldSetEntity>> fieldSets : this.deptGroupMap.entrySet()) { |
| | | String deptAllName = fieldSets.getKey(); |
| | | currentDeptData = this.getStaffDept(deptAllName); |
| | | List<FieldSetEntity> values = fieldSets.getValue(); |
| | | if (currentDeptData == null) { |
| | | for (int i = 0; i < values.size(); i++) { |
| | | this.currentData = values.get(i); |
| | | DataLocation dataLocation = getDataLocation(this.currentData); |
| | | String error = "第 %s 行,第 %s 列,部门在系统或管理的公司中不存在,请检查列 '%s' 的值 '%s' 是否正确"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_DEPT_UUID), |
| | | dataLocation.getColName(CmnConst.FIELD_DEPT_UUID), deptAllName); |
| | | this.errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | } |
| | | continue; |
| | | } |
| | | for (FieldSetEntity value : values) { |
| | | if (value.getBoolean("~processed~")) { |
| | | continue; |
| | | } |
| | | this.currentData = value; |
| | | this.handleFieldSet(); |
| | | } |
| | | } |
| | | throwError(); |
| | | } |
| | | /** |
| | | * 处理所有记录 |
| | | */ |
| | | private void handleDataTable() throws BaseException { |
| | | for (Map.Entry<String, List<FieldSetEntity>> fieldSets : this.deptGroupMap.entrySet()) { |
| | | String deptAllName = fieldSets.getKey(); |
| | | currentDeptData = this.getStaffDept(deptAllName); |
| | | List<FieldSetEntity> values = fieldSets.getValue(); |
| | | if (currentDeptData == null) { |
| | | for (int i = 0; i < values.size(); i++) { |
| | | this.currentData = values.get(i); |
| | | DataLocation dataLocation = getDataLocation(this.currentData); |
| | | String error = "第 %s 行,第 %s 列,部门在系统或管理的公司中不存在,请检查列 '%s' 的值 '%s' 是否正确"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex(CmnConst.FIELD_DEPT_UUID), |
| | | dataLocation.getColName(CmnConst.FIELD_DEPT_UUID), deptAllName); |
| | | this.errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | } |
| | | continue; |
| | | } |
| | | for (FieldSetEntity value : values) { |
| | | if (value.getBoolean("~processed~")) { |
| | | continue; |
| | | } |
| | | this.currentData = value; |
| | | this.handleFieldSet(); |
| | | } |
| | | } |
| | | throwError(); |
| | | } |
| | | |
| | | /** |
| | | * 处理单条记录 |
| | | */ |
| | | private void handleFieldSet() throws BaseException { |
| | | if (this.currentData.getBoolean("~processed~")) { |
| | | return; |
| | | } |
| | | String dept_uuid = this.currentDeptData.getString(CmnConst.UUID); |
| | | String org_level_uuid = this.currentDeptData.getString(CmnConst.ORG_LEVEL_UUID); |
| | | this.currentData.setValue("~processed~", 1); |
| | | this.currentData.setValue("~dept_uuid~", dept_uuid); |
| | | this.currentData.setValue(CmnConst.FIELD_STAFF_CODE, this.currentData.getString("~temp_staff_code~")); |
| | | this.currentData.setValue(CmnConst.FIELD_DEPT_UUID, currentDeptData.getString(CmnConst.FIELD_DEPT_UUID)); |
| | | this.currentData.setValue(CmnConst.ORG_LEVEL_UUID, org_level_uuid); |
| | | this.currentData.setValue("status", 1); |
| | | /** |
| | | * 处理单条记录 |
| | | */ |
| | | private void handleFieldSet() throws BaseException { |
| | | if (this.currentData.getBoolean("~processed~")) { |
| | | return; |
| | | } |
| | | String dept_uuid = this.currentDeptData.getString(CmnConst.UUID); |
| | | String org_level_uuid = this.currentDeptData.getString(CmnConst.ORG_LEVEL_UUID); |
| | | this.currentData.setValue("~processed~", 1); |
| | | this.currentData.setValue("~dept_uuid~", dept_uuid); |
| | | this.currentData.setValue(CmnConst.FIELD_STAFF_CODE, this.currentData.getString("~temp_staff_code~")); |
| | | this.currentData.setValue(CmnConst.FIELD_DEPT_UUID, currentDeptData.getString(CmnConst.FIELD_DEPT_UUID)); |
| | | this.currentData.setValue(CmnConst.ORG_LEVEL_UUID, org_level_uuid); |
| | | this.currentData.setValue("status", 1); |
| | | |
| | | //取出配置中账户初始密码 |
| | | this.currentData.setValue(CmnConst.USER_PWD, this.init_pwd); |
| | | String sex = this.currentData.getString("sex"); |
| | | if (!StringUtils.isEmpty(sex)) { |
| | | // 性别不为空时 转换参照数据 性别验证已在上个方法中验证过 |
| | | this.currentData.setValue("sex", sex.equals("男") ? 0 : 1); |
| | | } |
| | | // 导入数据配置中 使用 staff_avatar 字段作为用户登录账户的载体 在此处转换回来 |
| | | this.currentData.setValue(CmnConst.USER_ACCOUNT, this.currentData.getString("staff_avatar")); |
| | | // 删除载体数据 |
| | | this.currentData.remove("staff_avatar"); |
| | | // 将show_name 字段(员工名称) 复制到 user表字段上 |
| | | this.currentData.setValue(CmnConst.USER_NAME, this.currentData.getString("show_name")); |
| | | String job_post_grade_uuid = this.currentData.getString(CmnConst.FIELD_JOB_POST_GRADE_UUID); |
| | | String job_post_name = this.currentData.getString("job_post_uuid"); |
| | | //取出配置中账户初始密码 |
| | | this.currentData.setValue(CmnConst.USER_PWD, this.init_pwd); |
| | | String sex = this.currentData.getString("sex"); |
| | | if (!StringUtils.isEmpty(sex)) { |
| | | // 性别不为空时 转换参照数据 性别验证已在上个方法中验证过 |
| | | this.currentData.setValue("sex", sex.equals("男") ? 0 : 1); |
| | | } |
| | | // 导入数据配置中 使用 staff_avatar 字段作为用户登录账户的载体 在此处转换回来 |
| | | this.currentData.setValue(CmnConst.USER_ACCOUNT, this.currentData.getString("staff_avatar")); |
| | | // 删除载体数据 |
| | | this.currentData.remove("staff_avatar"); |
| | | // 将show_name 字段(员工名称) 复制到 user表字段上 |
| | | this.currentData.setValue(CmnConst.USER_NAME, this.currentData.getString("show_name")); |
| | | String job_post_grade_uuid = this.currentData.getString(CmnConst.FIELD_JOB_POST_GRADE_UUID); |
| | | String job_post_name = this.currentData.getString("job_post_uuid"); |
| | | |
| | | // 岗位 & 岗位等级 |
| | | List<FieldSetEntity> postDataList = postData.getFieldSetEntity(this.currentData.getString("job_post_uuid")); |
| | | if (postDataList == null || postDataList.size() <= 0) { |
| | | // 没有岗位 |
| | | postNotExist.method(this.currentData, "job_post_uuid"); |
| | | } else { |
| | | // 记录找到的岗位等级uuid ,多个用逗号分隔 |
| | | String grade_uuid = ""; |
| | | // 岗位uuid |
| | | String post_uuid = null; |
| | | // 循环系统中岗位数据 |
| | | for (FieldSetEntity postFs : postDataList) { |
| | | // 判断岗位是否在部门下 & 岗位名称和导入数据的岗位名称是否相同 |
| | | if (currentDeptData.getString(CmnConst.FIELD_DEPT_UUID).equals(postFs.getString(CmnConst.FIELD_DEPT_UUID)) && job_post_name.equals(postFs.getUUID())) { |
| | | // 系统中岗位的uuid |
| | | String job_post_uuid = postFs.getString("job_post_uuid"); |
| | | // 岗位uuid不为空时 判断当前postFs 中的岗位uuid是否跟已找到的岗位相同 |
| | | if (post_uuid != null && !post_uuid.equals(job_post_uuid)) { |
| | | continue; |
| | | } |
| | | if (post_uuid == null) { |
| | | // 记录岗位uuid |
| | | post_uuid = job_post_uuid; |
| | | } |
| | | // 获取岗位中的岗位等级名称 |
| | | String job_grade_name = postFs.getString(CmnConst.FIELD_JOB_GRADE_NAME); |
| | | // 拆分循环导入岗位等级名称 |
| | | if (!BaseUtil.strIsNull(job_post_grade_uuid)) { |
| | | for (String grade_name : job_post_grade_uuid.split(",")) { |
| | | // 判断岗位等级名称和系统中相同 |
| | | if (job_grade_name.equals(grade_name)) { |
| | | if (!StringUtils.isEmpty(grade_uuid)) { |
| | | grade_uuid += ","; |
| | | } |
| | | grade_uuid += postFs.getString(CmnConst.FIELD_JOB_POST_GRADE); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // 岗位 & 岗位等级 |
| | | List<FieldSetEntity> postDataList = postData.getFieldSetEntity(this.currentData.getString("job_post_uuid")); |
| | | if (postDataList == null || postDataList.size() <= 0) { |
| | | // 没有岗位 |
| | | postNotExist.method(this.currentData, "job_post_uuid"); |
| | | } else { |
| | | // 记录找到的岗位等级uuid ,多个用逗号分隔 |
| | | String grade_uuid = ""; |
| | | // 岗位uuid |
| | | String post_uuid = null; |
| | | // 循环系统中岗位数据 |
| | | for (FieldSetEntity postFs : postDataList) { |
| | | // 判断岗位是否在部门下 & 岗位名称和导入数据的岗位名称是否相同 |
| | | if (currentDeptData.getString(CmnConst.FIELD_DEPT_UUID).equals(postFs.getString(CmnConst.FIELD_DEPT_UUID)) && job_post_name.equals(postFs.getUUID())) { |
| | | // 系统中岗位的uuid |
| | | String job_post_uuid = postFs.getString("job_post_uuid"); |
| | | // 岗位uuid不为空时 判断当前postFs 中的岗位uuid是否跟已找到的岗位相同 |
| | | if (post_uuid != null && !post_uuid.equals(job_post_uuid)) { |
| | | continue; |
| | | } |
| | | if (post_uuid == null) { |
| | | // 记录岗位uuid |
| | | post_uuid = job_post_uuid; |
| | | } |
| | | // 获取岗位中的岗位等级名称 |
| | | String job_grade_name = postFs.getString(CmnConst.FIELD_JOB_GRADE_NAME); |
| | | // 拆分循环导入岗位等级名称 |
| | | if (!BaseUtil.strIsNull(job_post_grade_uuid)) { |
| | | for (String grade_name : job_post_grade_uuid.split(",")) { |
| | | // 判断岗位等级名称和系统中相同 |
| | | if (job_grade_name.equals(grade_name)) { |
| | | if (!StringUtils.isEmpty(grade_uuid)) { |
| | | grade_uuid += ","; |
| | | } |
| | | grade_uuid += postFs.getString(CmnConst.FIELD_JOB_POST_GRADE); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | // 没有找到岗位 |
| | | if (StringUtils.isEmpty(post_uuid)) { |
| | | // 抛出岗位未找到错误 |
| | | postNotExist.method(this.currentData, "job_post_uuid"); |
| | | } else { |
| | | // 找到岗位 |
| | | this.currentData.setValue("job_post_uuid", post_uuid); |
| | | } |
| | | // 没有找到岗位等级 |
| | | if (!StringUtils.isEmpty(grade_uuid)) { |
| | | } |
| | | // 没有找到岗位 |
| | | if (StringUtils.isEmpty(post_uuid)) { |
| | | // 抛出岗位未找到错误 |
| | | postNotExist.method(this.currentData, "job_post_uuid"); |
| | | } else { |
| | | // 找到岗位 |
| | | this.currentData.setValue("job_post_uuid", post_uuid); |
| | | } |
| | | // 没有找到岗位等级 |
| | | if (!StringUtils.isEmpty(grade_uuid)) { |
| | | // postNotExist.method(this.currentData, CmnConst.FIELD_JOB_POST_GRADE_UUID); |
| | | // } else { |
| | | this.currentData.setValue(CmnConst.FIELD_JOB_POST_GRADE_UUID, grade_uuid); |
| | | } |
| | | } |
| | | // 导入数据中岗位名称 |
| | | String[] role_uuids = this.currentData.getString("role_uuids").split(","); |
| | | String roleUuid = ""; |
| | | // 角色处理 |
| | | roleFor: |
| | | // 循环角色名称 |
| | | for (String roleName : role_uuids) { |
| | | // 使用角色名称获取系统数据 |
| | | List<FieldSetEntity> roleList = roleData.getFieldSetEntity(roleName); |
| | | if (roleList != null && roleList.size() > 0) { |
| | | // 循环系统中的角色 |
| | | for (FieldSetEntity roleFs : roleList) { |
| | | // 因系统中角色所属公司可多选,在此处前后拼接逗号 |
| | | String roleCompany = "," + roleFs.getString(CmnConst.ORG_LEVEL_UUID) + ","; |
| | | // 判断角色是否有导入数据的公司 |
| | | if (roleCompany.contains("," + org_level_uuid + ",")) { |
| | | String role_uuid = roleFs.getString("role_uuid"); |
| | | if (!StringUtils.isEmpty(roleUuid)) { |
| | | roleUuid += ","; |
| | | } |
| | | roleUuid += role_uuid; |
| | | continue roleFor; |
| | | } |
| | | } |
| | | } |
| | | this.currentData.setValue(CmnConst.FIELD_JOB_POST_GRADE_UUID, grade_uuid); |
| | | } |
| | | } |
| | | // 导入数据中岗位名称 |
| | | String[] role_uuids = this.currentData.getString("role_uuids").split(","); |
| | | String roleUuid = ""; |
| | | // 角色处理 |
| | | roleFor: |
| | | // 循环角色名称 |
| | | for (String roleName : role_uuids) { |
| | | // 使用角色名称获取系统数据 |
| | | List<FieldSetEntity> roleList = roleData.getFieldSetEntity(roleName); |
| | | if (roleList != null && roleList.size() > 0) { |
| | | // 循环系统中的角色 |
| | | for (FieldSetEntity roleFs : roleList) { |
| | | // 因系统中角色所属公司可多选,在此处前后拼接逗号 |
| | | String roleCompany = "," + roleFs.getString(CmnConst.ORG_LEVEL_UUID) + ","; |
| | | // 判断角色是否有导入数据的公司 |
| | | if (roleCompany.contains("," + org_level_uuid + ",")) { |
| | | String role_uuid = roleFs.getString("role_uuid"); |
| | | if (!StringUtils.isEmpty(roleUuid)) { |
| | | roleUuid += ","; |
| | | } |
| | | roleUuid += role_uuid; |
| | | continue roleFor; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 没有找到角色数据 抛出错误 |
| | | roleNotExist.method(this.currentData, roleName); |
| | | // 没有找到角色数据 抛出错误 |
| | | roleNotExist.method(this.currentData, roleName); |
| | | |
| | | } |
| | | this.currentData.setValue("role_uuids", roleUuid); |
| | | //装载上级领导code |
| | | this.loadingSuperCode(); |
| | | if (staffManagerService == null) { |
| | | staffManagerService = SpringBeanUtil.getBean("staffManagerService", StaffManagerService.class); |
| | | } |
| | | staffManagerService.saveStaffInfo(this.currentData); |
| | | } |
| | | } |
| | | this.currentData.setValue("role_uuids", roleUuid); |
| | | //装载上级领导code |
| | | this.loadingSuperCode(); |
| | | if (staffManagerService == null) { |
| | | staffManagerService = SpringBeanUtil.getBean("staffManagerService", StaffManagerService.class); |
| | | } |
| | | staffManagerService.saveStaffInfo(this.currentData); |
| | | } |
| | | |
| | | /** |
| | | * 抛出错误 |
| | | * |
| | | * @throws BaseException |
| | | */ |
| | | void throwError() throws BaseException { |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | } |
| | | /** |
| | | * 抛出错误 |
| | | * |
| | | * @throws BaseException |
| | | */ |
| | | void throwError() throws BaseException { |
| | | if (errorEntity.isError) { |
| | | errorEntity.newThrowBaseException(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 装载上级领导编码 |
| | | * |
| | | * @return |
| | | */ |
| | | private boolean loadingSuperCode() throws BaseException { |
| | | // 上级领导(员工编码) |
| | | String direct_leader_code = this.currentData.getString(CmnConst.FIELD_DIRECT_LEADER_CODE); |
| | | String superCode = ""; |
| | | if (!StringUtils.isEmpty(direct_leader_code)) { |
| | | List<FieldSetEntity> fieldSetEntity = directLeaderData.getFieldSetEntity(direct_leader_code); |
| | | if (staffCodeMap.get(direct_leader_code) == null && (fieldSetEntity == null || fieldSetEntity.size() <= 0)) { |
| | | // 未找到上级领导 |
| | | this.superStaffNotExist(); |
| | | return false; |
| | | } else { |
| | | //上级领导在导入数据 或系统中已存在 |
| | | // 根据编码获取上级(导入数据) |
| | | FieldSetEntity superFs = staffCodeMap.get(direct_leader_code); |
| | | if (superFs == null && (fieldSetEntity == null || fieldSetEntity.size() <= 0)) { |
| | | // 未找到上级领导 |
| | | this.superStaffNotExist(); |
| | | return false; |
| | | } else if (superFs == null) { |
| | | // 在系统中拿出上级领导 |
| | | superFs = fieldSetEntity.get(0); |
| | | } |
| | | String user_id = superFs.getString(CmnConst.USER_ID); |
| | | if (StringUtils.isEmpty(user_id)) { |
| | | // user_id 不存在,该上级在导入数据中未保存过 |
| | | String deptAllName = superFs.getString(CmnConst.FIELD_DEPT_UUID); |
| | | if (superFs.getBoolean("~processed~")) { |
| | | deptAllName = superFs.getString("~" + CmnConst.FIELD_DEPT_UUID + "~"); |
| | | } |
| | | FieldSetEntity deptFs = getStaffDept(deptAllName); |
| | | if (deptFs == null) { |
| | | return false; |
| | | } |
| | | // 克隆当前对象 将父级的部门 & 员工表数据放入克隆对象中 |
| | | ImportStaffDataVo clone = this.clone(deptFs, superFs); |
| | | // 先让父级数据进行保存操作 |
| | | // 这里会出现递归操作 因为 handleFieldSet 方法调用了当前方法 父级的父级进入一致的判断会一直递归 clone并保存 |
| | | // 如果递归层数过多可能会出现 full gc |
| | | clone.handleFieldSet(); |
| | | } else { |
| | | //已保存过的数据 取出已生成的tricode |
| | | superCode = superFs.getString(CmnConst.TRICODE); |
| | | } |
| | | } |
| | | } |
| | | this.currentData.setValue(CmnConst.FIELD_DIRECT_LEADER_CODE, superCode); |
| | | return true; |
| | | } |
| | | /** |
| | | * 装载上级领导编码 |
| | | * |
| | | * @return |
| | | */ |
| | | private boolean loadingSuperCode() throws BaseException { |
| | | // 上级领导(员工编码) |
| | | String direct_leader_code = this.currentData.getString(CmnConst.FIELD_DIRECT_LEADER_CODE); |
| | | String superCode = ""; |
| | | if (!StringUtils.isEmpty(direct_leader_code)) { |
| | | List<FieldSetEntity> fieldSetEntity = directLeaderData.getFieldSetEntity(direct_leader_code); |
| | | if (staffCodeMap.get(direct_leader_code) == null && (fieldSetEntity == null || fieldSetEntity.size() <= 0)) { |
| | | // 未找到上级领导 |
| | | this.superStaffNotExist(); |
| | | return false; |
| | | } else { |
| | | //上级领导在导入数据 或系统中已存在 |
| | | // 根据编码获取上级(导入数据) |
| | | FieldSetEntity superFs = staffCodeMap.get(direct_leader_code); |
| | | if (superFs == null && (fieldSetEntity == null || fieldSetEntity.size() <= 0)) { |
| | | // 未找到上级领导 |
| | | this.superStaffNotExist(); |
| | | return false; |
| | | } else if (superFs == null) { |
| | | // 在系统中拿出上级领导 |
| | | superFs = fieldSetEntity.get(0); |
| | | } |
| | | String user_id = superFs.getString(CmnConst.USER_ID); |
| | | if (StringUtils.isEmpty(user_id)) { |
| | | // user_id 不存在,该上级在导入数据中未保存过 |
| | | String deptAllName = superFs.getString(CmnConst.FIELD_DEPT_UUID); |
| | | if (superFs.getBoolean("~processed~")) { |
| | | deptAllName = superFs.getString("~" + CmnConst.FIELD_DEPT_UUID + "~"); |
| | | } |
| | | FieldSetEntity deptFs = getStaffDept(deptAllName); |
| | | if (deptFs == null) { |
| | | return false; |
| | | } |
| | | // 克隆当前对象 将父级的部门 & 员工表数据放入克隆对象中 |
| | | ImportStaffDataVo clone = this.clone(deptFs, superFs); |
| | | // 先让父级数据进行保存操作 |
| | | // 这里会出现递归操作 因为 handleFieldSet 方法调用了当前方法 父级的父级进入一致的判断会一直递归 clone并保存 |
| | | // 如果递归层数过多可能会出现 full gc |
| | | clone.handleFieldSet(); |
| | | } else { |
| | | //已保存过的数据 取出已生成的tricode |
| | | superCode = superFs.getString(CmnConst.TRICODE); |
| | | } |
| | | } |
| | | } |
| | | this.currentData.setValue(CmnConst.FIELD_DIRECT_LEADER_CODE, superCode); |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 克隆对象 |
| | | * 克隆后 sql 成员变量未初始化 |
| | | * |
| | | * @param currentDeptData |
| | | * @param currentData |
| | | * @return |
| | | */ |
| | | private ImportStaffDataVo clone(FieldSetEntity currentDeptData, FieldSetEntity currentData) throws BaseException { |
| | | ImportStaffDataVo clone = new ImportStaffDataVo(currentData, currentDeptData); |
| | | clone.deptData = this.deptData; |
| | | clone.postData = this.postData; |
| | | clone.roleData = this.roleData; |
| | | clone.deptGroupMap = this.deptGroupMap; |
| | | clone.errorEntity = this.errorEntity; |
| | | clone.direct_leader_codes = this.direct_leader_codes; |
| | | clone.deptMap = this.deptMap; |
| | | clone.dt = this.dt; |
| | | clone.systemData = this.systemData; |
| | | clone.directLeaderData = this.directLeaderData; |
| | | clone.staffCodeMap = this.staffCodeMap; |
| | | clone.companyFilter = this.companyFilter; |
| | | clone.currentUser = this.currentUser; |
| | | clone.fieldType = this.fieldType; |
| | | clone.init_pwd = this.init_pwd; |
| | | clone.client_uuid = this.client_uuid; |
| | | return clone; |
| | | } |
| | | /** |
| | | * 克隆对象 |
| | | * 克隆后 sql 成员变量未初始化 |
| | | * |
| | | * @param currentDeptData |
| | | * @param currentData |
| | | * @return |
| | | */ |
| | | private ImportStaffDataVo clone(FieldSetEntity currentDeptData, FieldSetEntity currentData) throws BaseException { |
| | | ImportStaffDataVo clone = new ImportStaffDataVo(currentData, currentDeptData); |
| | | clone.deptData = this.deptData; |
| | | clone.postData = this.postData; |
| | | clone.roleData = this.roleData; |
| | | clone.deptGroupMap = this.deptGroupMap; |
| | | clone.errorEntity = this.errorEntity; |
| | | clone.direct_leader_codes = this.direct_leader_codes; |
| | | clone.deptMap = this.deptMap; |
| | | clone.dt = this.dt; |
| | | clone.systemData = this.systemData; |
| | | clone.directLeaderData = this.directLeaderData; |
| | | clone.staffCodeMap = this.staffCodeMap; |
| | | clone.companyFilter = this.companyFilter; |
| | | clone.currentUser = this.currentUser; |
| | | clone.fieldType = this.fieldType; |
| | | clone.init_pwd = this.init_pwd; |
| | | clone.client_uuid = this.client_uuid; |
| | | return clone; |
| | | } |
| | | |
| | | /** |
| | | * 根据部门全称获取部门详情 |
| | | * |
| | | * @param deptAllName |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | private FieldSetEntity getStaffDept(String deptAllName) throws BaseException { |
| | | if (deptMap == null) { |
| | | deptMap = Maps.newHashMap(); |
| | | } |
| | | if (deptMap.get(deptAllName) != null) { |
| | | return deptMap.get(deptAllName); |
| | | } |
| | | List<FieldSetEntity> deptDatList = deptData.getFieldSetEntity(deptAllName); |
| | | if (deptDatList == null || deptDatList.size() < 0) { |
| | | return null; |
| | | } |
| | | return deptDatList.get(0); |
| | | } |
| | | /** |
| | | * 根据部门全称获取部门详情 |
| | | * |
| | | * @param deptAllName |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | private FieldSetEntity getStaffDept(String deptAllName) throws BaseException { |
| | | if (deptMap == null) { |
| | | deptMap = Maps.newHashMap(); |
| | | } |
| | | if (deptMap.get(deptAllName) != null) { |
| | | return deptMap.get(deptAllName); |
| | | } |
| | | List<FieldSetEntity> deptDatList = deptData.getFieldSetEntity(deptAllName); |
| | | if (deptDatList == null || deptDatList.size() < 0) { |
| | | return null; |
| | | } |
| | | return deptDatList.get(0); |
| | | } |
| | | |
| | | /** |
| | | * 角色未找到错误回调 |
| | | */ |
| | | private CallBack<Object> roleNotExist = f -> { |
| | | FieldSetEntity fs = (FieldSetEntity) f[0]; |
| | | Object role_name = f[1]; |
| | | DataLocation dataLocation = getDataLocation(fs); |
| | | String error = "第 %s 行,第 %s 列,%s 在系统中不存在,请检查列值%s 是否正确"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex("role_uuids"), |
| | | dataLocation.getColName("role_uuids"), role_name); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | }; |
| | | /** |
| | | * 岗位 & 岗位等级未找到错误回调 |
| | | */ |
| | | private CallBack<Object> postNotExist = f -> { |
| | | FieldSetEntity fs = (FieldSetEntity) f[0]; |
| | | String fieldName = (String) f[1]; |
| | | DataLocation datLocation = getDataLocation(fs); |
| | | String error = "第 %s 行,第 %s 列,'%s' 数据在系统中不存在,请检查 '%s' 是否正确"; |
| | | error = String.format(error, datLocation.getRowIndex(), datLocation.getColIndex(fieldName), |
| | | datLocation.getColName(fieldName), fs.getString(fieldName)); |
| | | errorEntity.addError(datLocation.getRowIndex(), error); |
| | | }; |
| | | /** |
| | | * 角色未找到错误回调 |
| | | */ |
| | | private CallBack<Object> roleNotExist = f -> { |
| | | FieldSetEntity fs = (FieldSetEntity) f[0]; |
| | | Object role_name = f[1]; |
| | | DataLocation dataLocation = getDataLocation(fs); |
| | | String error = "第 %s 行,第 %s 列,%s 在系统中不存在,请检查列值%s 是否正确"; |
| | | error = String.format(error, dataLocation.getRowIndex(), dataLocation.getColIndex("role_uuids"), |
| | | dataLocation.getColName("role_uuids"), role_name); |
| | | errorEntity.addError(dataLocation.getRowIndex(), error); |
| | | }; |
| | | /** |
| | | * 岗位 & 岗位等级未找到错误回调 |
| | | */ |
| | | private CallBack<Object> postNotExist = f -> { |
| | | FieldSetEntity fs = (FieldSetEntity) f[0]; |
| | | String fieldName = (String) f[1]; |
| | | DataLocation datLocation = getDataLocation(fs); |
| | | String error = "第 %s 行,第 %s 列,'%s' 数据在系统中不存在,请检查 '%s' 是否正确"; |
| | | error = String.format(error, datLocation.getRowIndex(), datLocation.getColIndex(fieldName), |
| | | datLocation.getColName(fieldName), fs.getString(fieldName)); |
| | | errorEntity.addError(datLocation.getRowIndex(), error); |
| | | }; |
| | | |
| | | /** |
| | | * 初始化系统数据 |
| | | */ |
| | | private void initializeSystemData() throws BaseException { |
| | | //查询上级领导 |
| | | findDirectLeaderData(); |
| | | // 查询管理员管理的(公司下的)部门 |
| | | findDeptData(); |
| | | // 管理员管理的角色 |
| | | findRoleData(); |
| | | // 管理员管理的岗位 & 岗位等级 |
| | | findPostData(); |
| | | this.throwError(); |
| | | } |
| | | /** |
| | | * 初始化系统数据 |
| | | */ |
| | | private void initializeSystemData() throws BaseException { |
| | | //查询上级领导 |
| | | findDirectLeaderData(); |
| | | // 查询管理员管理的(公司下的)部门 |
| | | findDeptData(); |
| | | // 管理员管理的角色 |
| | | findRoleData(); |
| | | // 管理员管理的岗位 & 岗位等级 |
| | | findPostData(); |
| | | this.throwError(); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有岗位 & 岗位等级 |
| | | */ |
| | | private void findPostData() throws BaseException { |
| | | sql = new StringBuilder(); |
| | | sql.append(" select a.job_post_name uuid,a.uuid job_post_uuid,c.job_grade_name,c.uuid job_post_grades_uuid,a.dept_uuid FROM product_sys_job_posts a "); |
| | | sql.append(" LEFT join product_sys_job_posts_grades_mapping b on "); |
| | | sql.append(" a.dept_uuid in (select uuid FROM product_sys_org_levels where org_level_type=1 and "); |
| | | sql.append(companyFilter); |
| | | sql.append(" ) and a.uuid=b.job_post_uuid "); |
| | | sql.append(" LEFT join product_sys_job_post_grades c on b.job_grade_uuid=c.uuid "); |
| | | sql.append(" group by a.job_post_name,a.uuid ,c.job_grade_name,c.uuid,a.dept_uuid "); |
| | | // 查询岗位 & 岗位等级 |
| | | postData = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | if (BaseUtil.dataTableIsEmpty(roleData)) { |
| | | errorEntity.addError(0, "系统中没有可供选择的岗位或岗位等级"); |
| | | } |
| | | } |
| | | /** |
| | | * 查询所有岗位 & 岗位等级 |
| | | */ |
| | | private void findPostData() throws BaseException { |
| | | sql = new StringBuilder(); |
| | | sql.append(" select a.job_post_name uuid,a.uuid job_post_uuid,c.job_grade_name,c.uuid job_post_grades_uuid,a.dept_uuid FROM product_sys_job_posts a "); |
| | | sql.append(" LEFT join product_sys_job_posts_grades_mapping b on "); |
| | | sql.append(" a.dept_uuid in (select uuid FROM product_sys_org_levels where org_level_type=1 and "); |
| | | sql.append(companyFilter); |
| | | sql.append(" ) and a.uuid=b.job_post_uuid "); |
| | | sql.append(" LEFT join product_sys_job_post_grades c on b.job_grade_uuid=c.uuid "); |
| | | sql.append(" group by a.job_post_name,a.uuid ,c.job_grade_name,c.uuid,a.dept_uuid "); |
| | | // 查询岗位 & 岗位等级 |
| | | postData = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | if (BaseUtil.dataTableIsEmpty(roleData)) { |
| | | errorEntity.addError(0, "系统中没有可供选择的岗位或岗位等级"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询所有角色 |
| | | */ |
| | | private void findRoleData() throws BaseException { |
| | | sql = new StringBuilder(); |
| | | sql.append(" select role_name as uuid,uuid as role_uuid,org_level_uuid FROM product_sys_role "); |
| | | sql.append(" where is_used = 1 and "); |
| | | sql.append(companyFilter); |
| | | // 查询角色 |
| | | roleData = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | if (BaseUtil.dataTableIsEmpty(roleData)) { |
| | | errorEntity.addError(0, "系统中没有可供选择的角色"); |
| | | } |
| | | } |
| | | /** |
| | | * 查询所有角色 |
| | | */ |
| | | private void findRoleData() throws BaseException { |
| | | sql = new StringBuilder(); |
| | | sql.append(" select role_name as uuid,uuid as role_uuid,org_level_uuid FROM product_sys_role "); |
| | | sql.append(" where is_used = 1 and "); |
| | | sql.append(companyFilter); |
| | | // 查询角色 |
| | | roleData = getBaseDao().listTable(sql.toString(), new Object[]{}); |
| | | if (BaseUtil.dataTableIsEmpty(roleData)) { |
| | | errorEntity.addError(0, "系统中没有可供选择的角色"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询所有部门 |
| | | */ |
| | | private void findDeptData() throws BaseException { |
| | | // 查询部门 |
| | | sql = new StringBuilder(); |
| | | sql.append(" select org_level_all uuid,uuid as dept_uuid,org_level_uuid,org_level_code,org_level_code_parent FROM product_sys_org_levels "); |
| | | sql.append(" where org_level_type = 1 and "); |
| | | sql.append(BaseUtil.buildQuestionMarkFilter(CmnConst.FIELD_ORG_LEVEL_ALL, deptGroupMap.size(), true)); |
| | | sql.append(" and "); |
| | | sql.append(companyFilter); |
| | | // 查询部门 |
| | | deptData = getBaseDao().listTable(sql.toString(), deptGroupMap.keySet().toArray()); |
| | | if (BaseUtil.dataTableIsEmpty(deptData)) { |
| | | errorEntity.addError(0, "系统中没有可供选择的部门"); |
| | | } |
| | | } |
| | | /** |
| | | * 查询所有部门 |
| | | */ |
| | | private void findDeptData() throws BaseException { |
| | | // 查询部门 |
| | | sql = new StringBuilder(); |
| | | sql.append(" select org_level_all uuid,uuid as dept_uuid,org_level_uuid,org_level_code,org_level_code_parent FROM product_sys_org_levels "); |
| | | sql.append(" where org_level_type = 1 and "); |
| | | sql.append(BaseUtil.buildQuestionMarkFilter(CmnConst.FIELD_ORG_LEVEL_ALL, deptGroupMap.size(), true)); |
| | | sql.append(" and "); |
| | | sql.append(companyFilter); |
| | | // 查询部门 |
| | | deptData = getBaseDao().listTable(sql.toString(), deptGroupMap.keySet().toArray()); |
| | | if (BaseUtil.dataTableIsEmpty(deptData)) { |
| | | errorEntity.addError(0, "系统中没有可供选择的部门"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询导入数据所有的上级领导 |
| | | */ |
| | | private void findDirectLeaderData() throws BaseException { |
| | | sql = new StringBuilder(); |
| | | sql.append(" SELECT staff_code uuid,tricode,user_id FROM product_sys_staffs "); |
| | | sql.append(" where "); |
| | | sql.append(BaseUtil.buildQuestionMarkFilter(CmnConst.FIELD_STAFF_CODE, direct_leader_codes.size(), true)); |
| | | if (direct_leader_codes.size() > 0) { |
| | | sql.append(" and "); |
| | | } |
| | | sql.append(" org_level_uuid in (select uuid FROM product_sys_org_levels where org_level_type=0 and client_uuid=?) "); |
| | | // 暂时注释不用公司做限制 |
| | | /** |
| | | * 查询导入数据所有的上级领导 |
| | | */ |
| | | private void findDirectLeaderData() throws BaseException { |
| | | sql = new StringBuilder(); |
| | | sql.append(" SELECT staff_code uuid,tricode,user_id FROM product_sys_staffs "); |
| | | sql.append(" where "); |
| | | sql.append(BaseUtil.buildQuestionMarkFilter(CmnConst.FIELD_STAFF_CODE, direct_leader_codes.size(), true)); |
| | | if (direct_leader_codes.size() > 0) { |
| | | sql.append(" and "); |
| | | } |
| | | sql.append(" org_level_uuid in (select uuid FROM product_sys_org_levels where org_level_type=0 and client_uuid=?) "); |
| | | // 暂时注释不用公司做限制 |
| | | // sql.append(" and "); |
| | | // sql.append(companyFilter); |
| | | // 查询上级领导 |
| | | List<String> params = Lists.newArrayList(direct_leader_codes.iterator()); |
| | | params.add(currentUser.getClient_uuid()); |
| | | directLeaderData = getBaseDao().listTable(sql.toString(), params.toArray()); |
| | | } |
| | | // 查询上级领导 |
| | | List<String> params = Lists.newArrayList(direct_leader_codes.iterator()); |
| | | params.add(currentUser.getClient_uuid()); |
| | | directLeaderData = getBaseDao().listTable(sql.toString(), params.toArray()); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有员工编码以及user表中的账号 |
| | | */ |
| | | private void findExistStaff() throws BaseException { |
| | | sql = new StringBuilder(126); |
| | | sql.append(" select concat(b.client_uuid,'>',staff_code) staff_code,a.user_account as staff_avatar "); |
| | | sql.append(" FROM product_sys_users a left join product_sys_staffs b on (b.client_uuid=? or b.uuid is null) and a.user_id=b.user_id "); |
| | | systemData = getBaseDao().listTable(sql.toString(), new Object[]{client_uuid}); |
| | | } |
| | | /** |
| | | * 查询所有员工编码以及user表中的账号 |
| | | */ |
| | | private void findExistStaff() throws BaseException { |
| | | sql = new StringBuilder(126); |
| | | sql.append(" select concat(b.client_uuid,'>',staff_code) staff_code,a.user_account as staff_avatar "); |
| | | sql.append(" FROM product_sys_users a left join product_sys_staffs b on (b.client_uuid=? or b.uuid is null) and a.user_id=b.user_id "); |
| | | systemData = getBaseDao().listTable(sql.toString(), new Object[]{client_uuid}); |
| | | } |
| | | |
| | | /** |
| | | * 数据格式效验 |
| | | */ |
| | | private void repeatValidation() throws BaseException { |
| | | // 注 :staff_avatar 字段为 user表中 user_account 的载体 |
| | | fieldRepeatValidation(errorEntity, dt, systemData, new String[]{CmnConst.FIELD_STAFF_CODE, "staff_avatar"}); |
| | | } |
| | | /** |
| | | * 数据格式效验 |
| | | */ |
| | | private void repeatValidation() throws BaseException { |
| | | // 注 :staff_avatar 字段为 user表中 user_account 的载体 |
| | | fieldRepeatValidation(errorEntity, dt, systemData, new String[]{CmnConst.FIELD_STAFF_CODE, "staff_avatar"}); |
| | | } |
| | | |
| | | /** |
| | | * 必填效验 数据处理 |
| | | */ |
| | | private void requiredValidation() throws BaseException { |
| | | errorEntity.mergeError(fieldRequiredValidation(dt, new String[]{"show_name", "staff_avatar", CmnConst.FIELD_STAFF_CODE, |
| | | CmnConst.FIELD_DEPT_UUID, "job_post_uuid", "role_uuids"}, fieldType, (FieldSetEntity[] f) -> { |
| | | FieldSetEntity fs = f[0]; |
| | | //上级领导编码 |
| | | String direct_leader_code = fs.getString(CmnConst.FIELD_DIRECT_LEADER_CODE); |
| | | //工作部门全称 |
| | | String deptAllName = fs.getString(CmnConst.FIELD_DEPT_UUID); |
| | | String id_number = fs.getString("id_number"); |
| | | String age = fs.getString("age"); |
| | | Date birth_date = fs.getDate("birth_date"); |
| | | String sex = fs.getString("sex"); |
| | | String staff_code = fs.getString(CmnConst.FIELD_STAFF_CODE); |
| | | /** |
| | | * 必填效验 数据处理 |
| | | */ |
| | | private void requiredValidation() throws BaseException { |
| | | errorEntity.mergeError(fieldRequiredValidation(dt, new String[]{"show_name", "staff_avatar", CmnConst.FIELD_STAFF_CODE, |
| | | CmnConst.FIELD_DEPT_UUID, "job_post_uuid", "role_uuids"}, fieldType, (FieldSetEntity[] f) -> { |
| | | FieldSetEntity fs = f[0]; |
| | | //上级领导编码 |
| | | String direct_leader_code = fs.getString(CmnConst.FIELD_DIRECT_LEADER_CODE); |
| | | //工作部门全称 |
| | | String deptAllName = fs.getString(CmnConst.FIELD_DEPT_UUID); |
| | | String id_number = fs.getString("id_number"); |
| | | String age = fs.getString("age"); |
| | | Date birth_date = fs.getDate("birth_date"); |
| | | String sex = fs.getString("sex"); |
| | | String staff_code = fs.getString(CmnConst.FIELD_STAFF_CODE); |
| | | |
| | | if (!StringUtils.isEmpty(staff_code)) { |
| | | fs.setValue("~temp_staff_code~", staff_code); |
| | | fs.setValue(CmnConst.FIELD_STAFF_CODE, client_uuid + this.separator + staff_code); |
| | | staffCodeMap.put(staff_code, fs); |
| | | } |
| | | fs.setValue(CmnConst.CLIENT_UUID, client_uuid); |
| | | if (!StringUtils.isEmpty(direct_leader_code)) { |
| | | //将上级领导编码统一放入集合中 |
| | | // 上级领导编码 = 员工编码 |
| | | direct_leader_codes.add(direct_leader_code); |
| | | } |
| | | //按部门分组数据 |
| | | if (!StringUtils.isEmpty(deptAllName)) { |
| | | List<FieldSetEntity> fieldSets = deptGroupMap.get(deptAllName); |
| | | if (fieldSets == null) { |
| | | fieldSets = Lists.newArrayList(); |
| | | deptGroupMap.put(deptAllName, fieldSets); |
| | | } |
| | | fieldSets.add(fs); |
| | | } |
| | | if (!StringUtils.isEmpty(id_number)) { |
| | | try { |
| | | if (birth_date == null) { |
| | | // 根据身份证取出生日期 |
| | | fs.setValue("birth_date", BaseUtil.getBirthday(id_number)); |
| | | } |
| | | if (StringUtils.isEmpty(age)) { |
| | | // 根据身份证取出年龄 |
| | | fs.setValue("age", BaseUtil.getAge(id_number)); |
| | | } |
| | | if (StringUtils.isEmpty(sex)) { |
| | | // 根据身份证取出性别 |
| | | fs.setValue("sex", BaseUtil.getSex(id_number)); |
| | | } |
| | | } catch (Exception e) { |
| | | if (!StringUtils.isEmpty(staff_code)) { |
| | | fs.setValue("~temp_staff_code~", staff_code); |
| | | fs.setValue(CmnConst.FIELD_STAFF_CODE, client_uuid + this.separator + staff_code); |
| | | staffCodeMap.put(staff_code, fs); |
| | | } |
| | | fs.setValue(CmnConst.CLIENT_UUID, client_uuid); |
| | | if (!StringUtils.isEmpty(direct_leader_code)) { |
| | | //将上级领导编码统一放入集合中 |
| | | // 上级领导编码 = 员工编码 |
| | | direct_leader_codes.add(direct_leader_code); |
| | | } |
| | | //按部门分组数据 |
| | | if (!StringUtils.isEmpty(deptAllName)) { |
| | | List<FieldSetEntity> fieldSets = deptGroupMap.get(deptAllName); |
| | | if (fieldSets == null) { |
| | | fieldSets = Lists.newArrayList(); |
| | | deptGroupMap.put(deptAllName, fieldSets); |
| | | } |
| | | fieldSets.add(fs); |
| | | } |
| | | if (!StringUtils.isEmpty(id_number)) { |
| | | try { |
| | | if (birth_date == null) { |
| | | // 根据身份证取出生日期 |
| | | fs.setValue("birth_date", BaseUtil.getBirthday(id_number)); |
| | | } |
| | | if (StringUtils.isEmpty(age)) { |
| | | // 根据身份证取出年龄 |
| | | fs.setValue("age", BaseUtil.getAge(id_number)); |
| | | } |
| | | if (StringUtils.isEmpty(sex)) { |
| | | // 根据身份证取出性别 |
| | | fs.setValue("sex", BaseUtil.getSex(id_number)); |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | })); |
| | | })); |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 重载导入员工方法 |
| | | * 处理公司、部门、岗位、岗位等级、账号 相关数据 |
| | | * |
| | | * @param postData 系统岗位 & 岗位等级数据 |
| | | * @param roleData 系统角色数据 |
| | | * @param roleNotExist 角色不存在错误回调 |
| | | * @param postNotExist 岗位 & 岗位等级不存在错误回调 |
| | | * @param fs 导入数据 |
| | | * @param deptFieldSet 部门数据 |
| | | * @param deptAllName 部门全称 |
| | | * @throws BaseException |
| | | */ |
| | | private void importStaffBefore(DataTableEntity postData, DataTableEntity |
| | | roleData, CallBack<Object> roleNotExist, CallBack<Object> postNotExist, FieldSetEntity fs, FieldSetEntity deptFieldSet, String deptAllName) throws BaseException { |
| | | /** |
| | | * 重载导入员工方法 |
| | | * 处理公司、部门、岗位、岗位等级、账号 相关数据 |
| | | * |
| | | * @param postData 系统岗位&岗位等级数据 |
| | | * @param roleData 系统角色数据 |
| | | * @param roleNotExist 角色不存在错误回调 |
| | | * @param postNotExist 岗位&岗位等级不存在错误回调 |
| | | * @param fs 导入数据 |
| | | * @param deptFieldSet 部门数据 |
| | | * @param deptAllName 部门全称 |
| | | * @throws BaseException |
| | | */ |
| | | private void importStaffBefore(DataTableEntity postData, DataTableEntity |
| | | roleData, CallBack<Object> roleNotExist, CallBack<Object> postNotExist, FieldSetEntity fs, FieldSetEntity deptFieldSet, String deptAllName) throws BaseException { |
| | | |
| | | String dept_uuid = fs.getString(CmnConst.UUID); |
| | | String org_level_uuid = fs.getString(CmnConst.ORG_LEVEL_UUID); |
| | | fs.setValue(CmnConst.FIELD_STAFF_CODE, fs.getString("~temp_staff_code~")); |
| | | fs.setValue(CmnConst.FIELD_DEPT_UUID, dept_uuid); |
| | | fs.setValue(CmnConst.ORG_LEVEL_UUID, org_level_uuid); |
| | | String dept_uuid = fs.getString(CmnConst.UUID); |
| | | String org_level_uuid = fs.getString(CmnConst.ORG_LEVEL_UUID); |
| | | fs.setValue(CmnConst.FIELD_STAFF_CODE, fs.getString("~temp_staff_code~")); |
| | | fs.setValue(CmnConst.FIELD_DEPT_UUID, dept_uuid); |
| | | fs.setValue(CmnConst.ORG_LEVEL_UUID, org_level_uuid); |
| | | |
| | | String job_post_grade_uuid = fs.getString(CmnConst.FIELD_JOB_POST_GRADE); |
| | | String job_post_name = fs.getString("job_post_uuid"); |
| | | String job_post_grade_uuid = fs.getString(CmnConst.FIELD_JOB_POST_GRADE); |
| | | String job_post_name = fs.getString("job_post_uuid"); |
| | | |
| | | // 岗位 & 岗位等级 |
| | | List<FieldSetEntity> postDataList = postData.getFieldSetEntity(deptAllName); |
| | | if (postDataList == null || postDataList.size() <= 0) { |
| | | // 没有岗位 |
| | | postNotExist.method(fs, "job_post_uuid"); |
| | | } else { |
| | | // 记录找到的岗位等级uuid ,多个用逗号分隔 |
| | | String grade_uuid = ""; |
| | | // 岗位uuid |
| | | String post_uuid = null; |
| | | // 循环系统中岗位数据 |
| | | for (FieldSetEntity postFs : postDataList) { |
| | | // 判断岗位是否在部门下 & 岗位名称和导入数据的岗位名称是否相同 |
| | | if (dept_uuid.equals(postFs.getString(CmnConst.FIELD_DEPT_UUID)) && job_post_name.equals(postFs.getString(CmnConst.FIELD_JOB_POST_NAME))) { |
| | | // 系统中岗位的uuid |
| | | String job_post_uuid = postFs.getString("job_post_uuid"); |
| | | // 岗位uuid不为空时 判断当前postFs 中的岗位uuid是否跟已找到的岗位相同 |
| | | if (post_uuid != null && !post_uuid.equals(job_post_uuid)) { |
| | | continue; |
| | | } |
| | | if (post_uuid == null) { |
| | | // 记录岗位uuid |
| | | post_uuid = job_post_uuid; |
| | | } |
| | | // 获取岗位中的岗位等级名称 |
| | | String job_grade_name = postFs.getString(CmnConst.FIELD_JOB_GRADE_NAME); |
| | | // 拆分循环导入岗位等级名称 |
| | | for (String grade_name : job_post_grade_uuid.split(",")) { |
| | | // 判断岗位等级名称和系统中相同 |
| | | if (job_grade_name.equals(grade_name)) { |
| | | if (!StringUtils.isEmpty(grade_uuid)) { |
| | | grade_uuid += ","; |
| | | } |
| | | grade_uuid += postFs.getString(CmnConst.FIELD_JOB_POST_GRADE); |
| | | } |
| | | } |
| | | } |
| | | // 没有找到岗位 |
| | | if (StringUtils.isEmpty(post_uuid)) { |
| | | // 抛出岗位未找到错误 |
| | | postNotExist.method(fs, "job_post_uuid"); |
| | | } else { |
| | | // 找到岗位 |
| | | fs.setValue("job_post_uuid", post_uuid); |
| | | } |
| | | // 没有找到岗位等级 |
| | | if (StringUtils.isEmpty(grade_uuid)) { |
| | | postNotExist.method(fs, CmnConst.FIELD_JOB_POST_GRADE); |
| | | } else { |
| | | fs.setValue(CmnConst.FIELD_JOB_POST_GRADE, grade_uuid); |
| | | } |
| | | } |
| | | } |
| | | // 导入数据中岗位名称 |
| | | String[] role_uuids = (String[]) fs.getObject("role_uuids"); |
| | | String roleUuid = ""; |
| | | // 角色处理 |
| | | roleFor: |
| | | // 循环角色名称 |
| | | for (String roleName : role_uuids) { |
| | | // 使用角色名称获取系统数据 |
| | | List<FieldSetEntity> roleList = roleData.getFieldSetEntity(roleName); |
| | | // 在系统中没有找到角色名称一致的数据 |
| | | if (roleList == null || roleList.size() <= 0) { |
| | | roleNotExist.method(fs, roleName); |
| | | } else { |
| | | // 循环系统中的角色 |
| | | for (FieldSetEntity roleFs : roleList) { |
| | | // 因系统中角色所属公司可多选,在此处前后拼接逗号 |
| | | String roleCompany = "," + roleFs.getString(CmnConst.ORG_LEVEL_UUID) + ","; |
| | | // 判断角色是否有导入数据的公司 |
| | | if (roleCompany.contains("," + org_level_uuid + ",")) { |
| | | String role_uuid = roleFs.getString("role_uuid"); |
| | | if (!StringUtils.isEmpty(roleUuid)) { |
| | | roleUuid += ","; |
| | | } |
| | | roleUuid += role_uuid; |
| | | continue roleFor; |
| | | } |
| | | } |
| | | // 没有找到角色数据 抛出错误 |
| | | roleNotExist.method(fs, roleName); |
| | | } |
| | | // 岗位 & 岗位等级 |
| | | List<FieldSetEntity> postDataList = postData.getFieldSetEntity(deptAllName); |
| | | if (postDataList == null || postDataList.size() <= 0) { |
| | | // 没有岗位 |
| | | postNotExist.method(fs, "job_post_uuid"); |
| | | } else { |
| | | // 记录找到的岗位等级uuid ,多个用逗号分隔 |
| | | String grade_uuid = ""; |
| | | // 岗位uuid |
| | | String post_uuid = null; |
| | | // 循环系统中岗位数据 |
| | | for (FieldSetEntity postFs : postDataList) { |
| | | // 判断岗位是否在部门下 & 岗位名称和导入数据的岗位名称是否相同 |
| | | if (dept_uuid.equals(postFs.getString(CmnConst.FIELD_DEPT_UUID)) && job_post_name.equals(postFs.getString(CmnConst.FIELD_JOB_POST_NAME))) { |
| | | // 系统中岗位的uuid |
| | | String job_post_uuid = postFs.getString("job_post_uuid"); |
| | | // 岗位uuid不为空时 判断当前postFs 中的岗位uuid是否跟已找到的岗位相同 |
| | | if (post_uuid != null && !post_uuid.equals(job_post_uuid)) { |
| | | continue; |
| | | } |
| | | if (post_uuid == null) { |
| | | // 记录岗位uuid |
| | | post_uuid = job_post_uuid; |
| | | } |
| | | // 获取岗位中的岗位等级名称 |
| | | String job_grade_name = postFs.getString(CmnConst.FIELD_JOB_GRADE_NAME); |
| | | // 拆分循环导入岗位等级名称 |
| | | for (String grade_name : job_post_grade_uuid.split(",")) { |
| | | // 判断岗位等级名称和系统中相同 |
| | | if (job_grade_name.equals(grade_name)) { |
| | | if (!StringUtils.isEmpty(grade_uuid)) { |
| | | grade_uuid += ","; |
| | | } |
| | | grade_uuid += postFs.getString(CmnConst.FIELD_JOB_POST_GRADE); |
| | | } |
| | | } |
| | | } |
| | | // 没有找到岗位 |
| | | if (StringUtils.isEmpty(post_uuid)) { |
| | | // 抛出岗位未找到错误 |
| | | postNotExist.method(fs, "job_post_uuid"); |
| | | } else { |
| | | // 找到岗位 |
| | | fs.setValue("job_post_uuid", post_uuid); |
| | | } |
| | | // 没有找到岗位等级 |
| | | if (StringUtils.isEmpty(grade_uuid)) { |
| | | postNotExist.method(fs, CmnConst.FIELD_JOB_POST_GRADE); |
| | | } else { |
| | | fs.setValue(CmnConst.FIELD_JOB_POST_GRADE, grade_uuid); |
| | | } |
| | | } |
| | | } |
| | | // 导入数据中岗位名称 |
| | | String[] role_uuids = (String[]) fs.getObject("role_uuids"); |
| | | String roleUuid = ""; |
| | | // 角色处理 |
| | | roleFor: |
| | | // 循环角色名称 |
| | | for (String roleName : role_uuids) { |
| | | // 使用角色名称获取系统数据 |
| | | List<FieldSetEntity> roleList = roleData.getFieldSetEntity(roleName); |
| | | // 在系统中没有找到角色名称一致的数据 |
| | | if (roleList == null || roleList.size() <= 0) { |
| | | roleNotExist.method(fs, roleName); |
| | | } else { |
| | | // 循环系统中的角色 |
| | | for (FieldSetEntity roleFs : roleList) { |
| | | // 因系统中角色所属公司可多选,在此处前后拼接逗号 |
| | | String roleCompany = "," + roleFs.getString(CmnConst.ORG_LEVEL_UUID) + ","; |
| | | // 判断角色是否有导入数据的公司 |
| | | if (roleCompany.contains("," + org_level_uuid + ",")) { |
| | | String role_uuid = roleFs.getString("role_uuid"); |
| | | if (!StringUtils.isEmpty(roleUuid)) { |
| | | roleUuid += ","; |
| | | } |
| | | roleUuid += role_uuid; |
| | | continue roleFor; |
| | | } |
| | | } |
| | | // 没有找到角色数据 抛出错误 |
| | | roleNotExist.method(fs, roleName); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取数据位置对象 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | private DataLocation getDataLocation(FieldSetEntity fse) { |
| | | if (fse.getString("~dataLocation~") != null) { |
| | | return (DataLocation) fse.getObject("~dataLocation~"); |
| | | } else { |
| | | DataLocation dataLocation = new DataLocation(fse); |
| | | fse.setValue("~dataLocation~", dataLocation); |
| | | return dataLocation; |
| | | } |
| | | } |
| | | /** |
| | | * 获取数据位置对象 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | private DataLocation getDataLocation(FieldSetEntity fse) { |
| | | if (fse.getString("~dataLocation~") != null) { |
| | | return (DataLocation) fse.getObject("~dataLocation~"); |
| | | } else { |
| | | DataLocation dataLocation = new DataLocation(fse); |
| | | fse.setValue("~dataLocation~", dataLocation); |
| | | return dataLocation; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 初始化机构数据 |
| | | * |
| | | * @param fse |
| | | * @param level_type |
| | | */ |
| | | public void initOrganizationFieldSet(FieldSetEntity fse, String client_uuid, String parentCode, |
| | | int level_type) { |
| | | fse.setValue(CmnConst.FIELD_ORG_LEVEL_CODE_PARENT, parentCode); |
| | | fse.setValue(CmnConst.FIELD_ORG_LEVEL_CODE, BaseUtil.createCode(fse, CmnConst.TABLE_PRODUCT_SYS_ORG_LEVELS, CmnConst.FIELD_ORG_LEVEL_CODE, parentCode)); |
| | | BaseUtil.createCreatorAndCreationTime(fse); |
| | | fse.remove(CmnConst.ORG_LEVEL_UUID); |
| | | fse.setValue(CmnConst.CLIENT_UUID, client_uuid); |
| | | fse.setValue(CmnConst.FIELD_ORG_LEVEL_STATUS, 0); |
| | | fse.setValue(CmnConst.FIELD_ORG_LEVEL_TYPE, level_type); |
| | | fse.setCodeFieldUpdateFlat(CmnConst.FIELD_ORG_LEVEL_CODE, false); |
| | | } |
| | | /** |
| | | * 初始化机构数据 |
| | | * |
| | | * @param fse |
| | | * @param level_type |
| | | */ |
| | | public void initOrganizationFieldSet(FieldSetEntity fse, String client_uuid, String parentCode, |
| | | int level_type) { |
| | | fse.setValue(CmnConst.FIELD_ORG_LEVEL_CODE_PARENT, parentCode); |
| | | fse.setValue(CmnConst.FIELD_ORG_LEVEL_CODE, BaseUtil.createCode(fse, CmnConst.TABLE_PRODUCT_SYS_ORG_LEVELS, CmnConst.FIELD_ORG_LEVEL_CODE, parentCode)); |
| | | BaseUtil.createCreatorAndCreationTime(fse); |
| | | fse.remove(CmnConst.ORG_LEVEL_UUID); |
| | | fse.setValue(CmnConst.CLIENT_UUID, client_uuid); |
| | | fse.setValue(CmnConst.FIELD_ORG_LEVEL_STATUS, 0); |
| | | fse.setValue(CmnConst.FIELD_ORG_LEVEL_TYPE, level_type); |
| | | fse.setCodeFieldUpdateFlat(CmnConst.FIELD_ORG_LEVEL_CODE, false); |
| | | } |
| | | |
| | | public void managerPermissionValidation(ImportErrorEntity errorEntity, SystemUser user) throws |
| | | BaseException { |
| | | FieldSetEntity managerFieldSet = user.getCurrentManager(); |
| | | if (managerFieldSet == null || user.getUserType() != 2) { |
| | | errorEntity.newThrowBaseException("没有导入此数据的权限,请联系统管理员"); |
| | | } else if (StringUtils.isEmpty(managerFieldSet.getString(CmnConst.ORG_LEVEL_UUID))) { |
| | | errorEntity.newThrowBaseException("公司权限不存在,请联系统管理员"); |
| | | } |
| | | } |
| | | public void managerPermissionValidation(ImportErrorEntity errorEntity, SystemUser user) throws |
| | | BaseException { |
| | | FieldSetEntity managerFieldSet = user.getCurrentManager(); |
| | | if (managerFieldSet == null || user.getUserType() != 2) { |
| | | errorEntity.newThrowBaseException("没有导入此数据的权限,请联系统管理员"); |
| | | } else if (StringUtils.isEmpty(managerFieldSet.getString(CmnConst.ORG_LEVEL_UUID))) { |
| | | errorEntity.newThrowBaseException("公司权限不存在,请联系统管理员"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 错误位置 |
| | | */ |
| | | class DataLocation { |
| | | /** |
| | | * 错误位置 |
| | | */ |
| | | class DataLocation { |
| | | |
| | | //当前行 |
| | | private Integer rowIndex; |
| | | //列名 |
| | | private List<String> colNameList; |
| | | //字段列索引 |
| | | private Map<String, String> fieldIndex; |
| | | //当前行 |
| | | private Integer rowIndex; |
| | | //列名 |
| | | private List<String> colNameList; |
| | | //字段列索引 |
| | | private Map<String, String> fieldIndex; |
| | | |
| | | DataLocation(FieldSetEntity fse) { |
| | | //当前行 |
| | | this.rowIndex = fse.getInteger("~row~"); |
| | | //列名 |
| | | this.colNameList = (List<String>) fse.getObject("~colName~"); |
| | | //字段列索引 |
| | | this.fieldIndex = (Map<String, String>) fse.getObject("~fieldIndex~"); |
| | | } |
| | | DataLocation(FieldSetEntity fse) { |
| | | //当前行 |
| | | this.rowIndex = fse.getInteger("~row~"); |
| | | //列名 |
| | | this.colNameList = (List<String>) fse.getObject("~colName~"); |
| | | //字段列索引 |
| | | this.fieldIndex = (Map<String, String>) fse.getObject("~fieldIndex~"); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前行索引 |
| | | * |
| | | * @return |
| | | */ |
| | | public Integer getRowIndex() { |
| | | return rowIndex + 1; |
| | | } |
| | | /** |
| | | * 获取当前行索引 |
| | | * |
| | | * @return |
| | | */ |
| | | public Integer getRowIndex() { |
| | | return rowIndex + 1; |
| | | } |
| | | |
| | | /** |
| | | * 获取当前列索引 |
| | | * |
| | | * @param fieldName |
| | | * @return |
| | | */ |
| | | public String getColIndex(String fieldName) { |
| | | if (fieldIndex == null || StringUtils.isEmpty(fieldName)) { |
| | | return null; |
| | | } |
| | | String colIndex = fieldIndex.get(fieldName); |
| | | return !StringUtils.isEmpty(colIndex) ? String.valueOf(Integer.valueOf(colIndex) + 1) : "未知"; |
| | | } |
| | | /** |
| | | * 获取当前列索引 |
| | | * |
| | | * @param fieldName |
| | | * @return |
| | | */ |
| | | public String getColIndex(String fieldName) { |
| | | if (fieldIndex == null || StringUtils.isEmpty(fieldName)) { |
| | | return null; |
| | | } |
| | | String colIndex = fieldIndex.get(fieldName); |
| | | return !StringUtils.isEmpty(colIndex) ? String.valueOf(Integer.valueOf(colIndex) + 1) : "未知"; |
| | | } |
| | | |
| | | /** |
| | | * 获取当前列名称 |
| | | * |
| | | * @param fieldName |
| | | * @return |
| | | */ |
| | | public String getColName(String fieldName) { |
| | | String colIndex = getColIndex(fieldName); |
| | | if (this.colNameList == null || colIndex == null || "未知".equals(colIndex)) { |
| | | return "未知列名"; |
| | | } |
| | | return colNameList.get(Integer.valueOf(colIndex) - 1); |
| | | } |
| | | /** |
| | | * 获取当前列名称 |
| | | * |
| | | * @param fieldName |
| | | * @return |
| | | */ |
| | | public String getColName(String fieldName) { |
| | | String colIndex = getColIndex(fieldName); |
| | | if (this.colNameList == null || colIndex == null || "未知".equals(colIndex)) { |
| | | return "未知列名"; |
| | | } |
| | | return colNameList.get(Integer.valueOf(colIndex) - 1); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | static class ImportErrorEntity { |
| | | static class ImportErrorEntity { |
| | | |
| | | interface errorMsg { |
| | | errorMsg append(Object errorMsg); |
| | | } |
| | | interface errorMsg { |
| | | errorMsg append(Object errorMsg); |
| | | } |
| | | |
| | | private Map<Integer, String> errorMap; |
| | | private Map<Integer, String> errorMap; |
| | | |
| | | private boolean isError = false; |
| | | private boolean isError = false; |
| | | |
| | | /** |
| | | * 新增错误 自动换行 |
| | | * |
| | | * @param row |
| | | * @param errorMsg |
| | | * @return |
| | | */ |
| | | public errorMsg addError(int row, String errorMsg) { |
| | | if (errorMap == null) { |
| | | errorMap = Maps.newHashMap(); |
| | | } |
| | | isError = true; |
| | | String error = errorMap.get(row); |
| | | if (!StringUtils.isEmpty(error)) { |
| | | error += "\n"; |
| | | } else { |
| | | error = ""; |
| | | } |
| | | error += errorMsg; |
| | | errorMap.put(row, error); |
| | | return (emg) -> this.append(row, String.valueOf(emg)); |
| | | } |
| | | /** |
| | | * 新增错误 自动换行 |
| | | * |
| | | * @param row |
| | | * @param errorMsg |
| | | * @return |
| | | */ |
| | | public errorMsg addError(int row, String errorMsg) { |
| | | if (errorMap == null) { |
| | | errorMap = Maps.newHashMap(); |
| | | } |
| | | isError = true; |
| | | String error = errorMap.get(row); |
| | | if (!StringUtils.isEmpty(error)) { |
| | | error += "\n"; |
| | | } else { |
| | | error = ""; |
| | | } |
| | | error += errorMsg; |
| | | errorMap.put(row, error); |
| | | return (emg) -> this.append(row, String.valueOf(emg)); |
| | | } |
| | | |
| | | /** |
| | | * 合并错误 |
| | | * |
| | | * @param errorEntity |
| | | * @return |
| | | */ |
| | | public ImportErrorEntity mergeError(ImportErrorEntity errorEntity) { |
| | | Map<Integer, String> errorMap = errorEntity.errorMap; |
| | | if (errorEntity.isError) { |
| | | if (this.errorMap == null) { |
| | | this.errorMap = errorMap; |
| | | this.isError = true; |
| | | return this; |
| | | } else { |
| | | errorMap.forEach((k, v) -> { |
| | | String error = this.errorMap.get(k); |
| | | if (!StringUtils.isEmpty(error)) { |
| | | error += "\n"; |
| | | } else { |
| | | error = ""; |
| | | } |
| | | error += v; |
| | | this.isError = true; |
| | | this.errorMap.put(k, error); |
| | | }); |
| | | } |
| | | } |
| | | return this; |
| | | } |
| | | /** |
| | | * 合并错误 |
| | | * |
| | | * @param errorEntity |
| | | * @return |
| | | */ |
| | | public ImportErrorEntity mergeError(ImportErrorEntity errorEntity) { |
| | | Map<Integer, String> errorMap = errorEntity.errorMap; |
| | | if (errorEntity.isError) { |
| | | if (this.errorMap == null) { |
| | | this.errorMap = errorMap; |
| | | this.isError = true; |
| | | return this; |
| | | } else { |
| | | errorMap.forEach((k, v) -> { |
| | | String error = this.errorMap.get(k); |
| | | if (!StringUtils.isEmpty(error)) { |
| | | error += "\n"; |
| | | } else { |
| | | error = ""; |
| | | } |
| | | error += v; |
| | | this.isError = true; |
| | | this.errorMap.put(k, error); |
| | | }); |
| | | } |
| | | } |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * 拼接错误 |
| | | * |
| | | * @param row |
| | | * @param errorMsg |
| | | * @return |
| | | */ |
| | | public errorMsg append(int row, String errorMsg) { |
| | | if (errorMap == null) { |
| | | errorMap = Maps.newHashMap(); |
| | | } |
| | | isError = true; |
| | | String error = errorMap.get(row); |
| | | if (StringUtils.isEmpty(error)) { |
| | | error = ""; |
| | | } |
| | | error += errorMsg; |
| | | errorMap.put(row, error); |
| | | return (emg) -> this.append(row, String.valueOf(emg)); |
| | | } |
| | | /** |
| | | * 拼接错误 |
| | | * |
| | | * @param row |
| | | * @param errorMsg |
| | | * @return |
| | | */ |
| | | public errorMsg append(int row, String errorMsg) { |
| | | if (errorMap == null) { |
| | | errorMap = Maps.newHashMap(); |
| | | } |
| | | isError = true; |
| | | String error = errorMap.get(row); |
| | | if (StringUtils.isEmpty(error)) { |
| | | error = ""; |
| | | } |
| | | error += errorMsg; |
| | | errorMap.put(row, error); |
| | | return (emg) -> this.append(row, String.valueOf(emg)); |
| | | } |
| | | |
| | | public void newThrowBaseException() { |
| | | newThrowBaseException(null, null); |
| | | } |
| | | public void newThrowBaseException() { |
| | | newThrowBaseException(null, null); |
| | | } |
| | | |
| | | public void newThrowBaseException(String msg, Exception exception) { |
| | | if (!StringUtils.isEmpty(msg)) { |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), msg); |
| | | } else if (errorMap != null) { |
| | | List<Integer> es = Lists.newArrayList(errorMap.keySet().iterator()); |
| | | StringBuilder errorMsg = new StringBuilder(); |
| | | for (Integer e : es) { |
| | | String error = errorMap.get(e); |
| | | if (!StringUtils.isEmpty(error)) { |
| | | errorMsg.append(error).append("\n"); |
| | | } |
| | | } |
| | | if (errorMsg.length() > 0) { |
| | | if (exception != null) { |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), errorMsg.toString(), exception); |
| | | } else { |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), errorMsg.toString()); |
| | | } |
| | | } |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), " 未知错误,请联系管理员,error message is empty for 'throwExportDataError' Method "); |
| | | } |
| | | if (exception != null) { |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), " 未知错误,请联系管理员,error message is empty for 'throwExportDataError' Method ", exception); |
| | | } |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), " 未知错误,请联系管理员,error message is empty for 'throwExportDataError' Method "); |
| | | } |
| | | public void newThrowBaseException(String msg, Exception exception) { |
| | | if (!StringUtils.isEmpty(msg)) { |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), msg); |
| | | } else if (errorMap != null) { |
| | | List<Integer> es = Lists.newArrayList(errorMap.keySet().iterator()); |
| | | StringBuilder errorMsg = new StringBuilder(); |
| | | for (Integer e : es) { |
| | | String error = errorMap.get(e); |
| | | if (!StringUtils.isEmpty(error)) { |
| | | errorMsg.append(error).append("\n"); |
| | | } |
| | | } |
| | | if (errorMsg.length() > 0) { |
| | | if (exception != null) { |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), errorMsg.toString(), exception); |
| | | } else { |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), errorMsg.toString()); |
| | | } |
| | | } |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), " 未知错误,请联系管理员,error message is empty for 'throwExportDataError' Method "); |
| | | } |
| | | if (exception != null) { |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), " 未知错误,请联系管理员,error message is empty for 'throwExportDataError' Method ", exception); |
| | | } |
| | | throw new BaseException(CmnCode.UPLOAD_TEMPLATE_IMPORT_DATA_FAIL.getValue(), " 未知错误,请联系管理员,error message is empty for 'throwExportDataError' Method "); |
| | | } |
| | | |
| | | public void newThrowBaseException(String msg) { |
| | | newThrowBaseException(msg, null); |
| | | } |
| | | public void newThrowBaseException(String msg) { |
| | | newThrowBaseException(msg, null); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |