From e6720f333268682d11aedb3b3308fa2f2c3a40df Mon Sep 17 00:00:00 2001 From: 许鹏程 <1821349743@qq.com> Date: 星期二, 28 五月 2024 16:09:05 +0800 Subject: [PATCH] commit --- product-server-data-sync/src/main/java/com/product/data/sync/service/FeDataDSService.java | 1793 ++++++++++++++++++++++++++++++---------------------------- 1 files changed, 924 insertions(+), 869 deletions(-) diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/FeDataDSService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/FeDataDSService.java index 2470002..5afad7a 100644 --- a/product-server-data-sync/src/main/java/com/product/data/sync/service/FeDataDSService.java +++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/FeDataDSService.java @@ -45,245 +45,256 @@ @Component public class FeDataDSService extends AbstractBaseService { - @Autowired - public BaseDao baseDao; - @Autowired - private UserService userService; - @Autowired - private CodeService codeService; - @Autowired - private SystemOrgLevelsService systemOrgLevelsService; + @Autowired + public BaseDao baseDao; + @Autowired + private UserService userService; + @Autowired + private CodeService codeService; + @Autowired + private SystemOrgLevelsService systemOrgLevelsService; - @Autowired - public FunctionSynchrService functionSynchrService; - @Autowired - FileManagerService fileManagerService; + @Autowired + public FunctionSynchrService functionSynchrService; + @Autowired + FileManagerService fileManagerService; - //涓存椂鏂囦欢璺緞 - private static String TSPath = Global.getSystemConfig("new.filePackage",""); - private static String testString = "^(\\d{0,4}`)|(\\d{0,3}\\^\\d{0,4}`)"; - private static String startWith = "FE#ENC#"; - private int[] intPosition = new int[64]; - //鎴戜滑浜у搧鐨勫姛鑳芥潈闄� - private String[] functionCode = {"001-004-000-000","001-004-000-001","001-004-000-002","001-004-000-003","001-004-000-004", - "001-006-006-000","001-006-002-000","001-006-000-000","001-006-001-000", - "001-006-001-001","001-006-000-001", "001-006-002-001" ,"001-006-002-002","001-006-004-000", - "001-006-003-000","001-006-002-003","001-006-003-001","001-006-003-002","001-006-003-003", - "001-006-004-001","001-006-003-004","001-006-003-005","001-006-003-006","001-006-006-001", - "001-006-008-000","001-006-008-001","001-006-008-002", "001-006-008-003","001-006-008-004", - "001-006-008-005","001-006-008-006", "001-006-000-003", "001-006-011-000","001-006-011-001", - "001-008-001-001","001-008-001-000","001-008-001-003"}; + //涓存椂鏂囦欢璺緞 + private static String TSPath = Global.getSystemConfig("new.filePackage", ""); + private static String testString = "^(\\d{0,4}`)|(\\d{0,3}\\^\\d{0,4}`)"; + private static String startWith = "FE#ENC#"; + private int[] intPosition = new int[64]; + //鎴戜滑浜у搧鐨勫姛鑳芥潈闄� + private String[] functionCode = {"001-004-000-000", "001-004-000-001", "001-004-000-002", "001-004-000-003", "001-004-000-004", + "001-006-006-000", "001-006-002-000", "001-006-000-000", "001-006-001-000", + "001-006-001-001", "001-006-000-001", "001-006-002-001", "001-006-002-002", "001-006-004-000", + "001-006-003-000", "001-006-002-003", "001-006-003-001", "001-006-003-002", "001-006-003-003", + "001-006-004-001", "001-006-003-004", "001-006-003-005", "001-006-003-006", "001-006-006-001", + "001-006-008-000", "001-006-008-001", "001-006-008-002", "001-006-008-003", "001-006-008-004", + "001-006-008-005", "001-006-008-006", "001-006-000-003", "001-006-011-000", "001-006-011-001", + "001-008-001-001", "001-008-001-000", "001-008-001-003"}; - private Integer sort = 0; - //鍏徃鍜岄儴闂╩ap key 涓哄叕鍙告垨閮ㄩ棬鍏ㄧО - Map<String, FieldSetEntity> institutionMap = Maps.newHashMap(); - public Connection getJDBC() throws SQLException, ClassNotFoundException { - //鑾峰彇jdbc杩炴帴 + private Integer sort = 0; + //鍏徃鍜岄儴闂╩ap key 涓哄叕鍙告垨閮ㄩ棬鍏ㄧО + Map<String, FieldSetEntity> institutionMap = Maps.newHashMap(); + + public Connection getJDBC() throws SQLException, ClassNotFoundException { + //鑾峰彇jdbc杩炴帴 // String diver = "oracle.jdbc.driver.OracleDriver"; // String url = "jdbc:oracle:thin:@10.0.0.21:1521:orcl"; // return DataManipulationUtils.getConnection(diver, url, "FE_BASE5", "fe123"); - //鑾峰彇jdbc杩炴帴 - String diver = Global.getSystemConfig("data.synchronism.function.jdbc.diver", ""); - String url = Global.getSystemConfig("data.synchronism.function.jdbc.url", ""); - String name = Global.getSystemConfig("data.synchronism.function.jdbc.name", ""); - String password = Global.getSystemConfig("data.synchronism.function.jdbc.password", ""); - return DataManipulationUtils.getConnection(diver, url, name, password); - } + //鑾峰彇jdbc杩炴帴 + String diver = Global.getSystemConfig("data.synchronism.function.jdbc.diver", ""); + String url = Global.getSystemConfig("data.synchronism.function.jdbc.url", ""); + String name = Global.getSystemConfig("data.synchronism.function.jdbc.name", ""); + String password = Global.getSystemConfig("data.synchronism.function.jdbc.password", ""); + return DataManipulationUtils.getConnection(diver, url, name, password); + } - public String FEDataMigration(){ - String clientUUID = ""; - try { - //admin鍒濆鍖栧鎴峰強瑙掕壊 - clientUUID = this.initializeClients(); - //鍚屾鍏徃閮ㄩ棬 - this.syncDepartmentCompany(); - //灏佽鍏徃閮ㄩ棬map - this.packInstitutionMap(); - //鍚屾宀椾綅绛夌骇鍜屽矖浣� - this.synchronousPost(); - //鍚屾瑙掕壊 - this.synchronousRole(); - //鍚屾绠$悊鍛� - this.syncManager(clientUUID); - //鍚屾浜哄憳 - this.addEmployees(clientUUID); - } catch (SQLException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - return clientUUID; - } + public String FEDataMigration() { + String clientUUID = ""; + try { + //admin鍒濆鍖栧鎴峰強瑙掕壊 + clientUUID = this.initializeClients(); + //鍚屾鍏徃閮ㄩ棬 + this.syncDepartmentCompany(); + //灏佽鍏徃閮ㄩ棬map + this.packInstitutionMap(); + //鍚屾宀椾綅绛夌骇鍜屽矖浣� + this.synchronousPost(); +// //鍚屾瑙掕壊 +// this.synchronousRole(); + //鍚屾绠$悊鍛� +// this.syncManager(clientUUID); + //鍚屾浜哄憳 + this.addEmployees(clientUUID); + } catch (SQLException e) { + logger.error("FEDataMigration", e); + e.printStackTrace(); + } catch (ClassNotFoundException e) { + logger.error("FEDataMigration", e); + e.printStackTrace(); + } + return clientUUID; + } - /** - * 鍒濆鍖栧鎴峰強瀹㈡埛瑙掕壊(淇敼瀹㈡埛涓篎E鐨勫鎴峰悕绉�) - * @return - * @throws SQLException - * @throws ClassNotFoundException - */ - public String initializeClients() throws SQLException, ClassNotFoundException { - FieldSetEntity grouoFs = null; - Connection conn = this.getJDBC(); - try { - grouoFs = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.SYS_GROUP", "SG10=1", new Object[]{}); - } catch (Exception e) { - DataManipulationUtils.close(null, null, conn); - throw e; - } - //鏌ヨ鍘熷鎴� 鏀逛负瑗垮畞 - FieldSetEntity tableFs = baseDao.getFieldSetEntityByFilter("product_sys_clients", " client_code = ? ", new String[]{"001"},false); - if (tableFs==null) { + /** + * 鍒濆鍖栧鎴峰強瀹㈡埛瑙掕壊(淇敼瀹㈡埛涓篎E鐨勫鎴峰悕绉�) + * + * @return + * @throws SQLException + * @throws ClassNotFoundException + */ + public String initializeClients() throws SQLException, ClassNotFoundException { + FieldSetEntity grouoFs = null; + Connection conn = this.getJDBC(); + try { + grouoFs = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.SYS_GROUP", "SG10=1", new Object[]{}); + } catch (Exception e) { + DataManipulationUtils.close(null, null, conn); + throw e; + } + //鏌ヨ鍘熷鎴� 鏀逛负瑗垮畞 + FieldSetEntity tableFs = baseDao.getFieldSetEntityByFilter("product_sys_clients", " client_code = ? ", new String[]{"001"}, false); + if (tableFs == null) { throw new BaseException("500", "瀹㈡埛琛ㄦ病鏈�001鐨勬暟鎹�"); } - //鍘熷鎴峰悕绉� - String clientName = tableFs.getString("client_name"); - tableFs.setValue("client_name", grouoFs.getString("sg01")); - String clientUUID = tableFs.getUUID(); - //鏌ヨ鍘熷鎴风殑瑙掕壊 鏀逛负瑗垮畞 - FieldSetEntity roleFs = baseDao.getFieldSetEntityByFilter("product_sys_role", " role_name = ? ", new String[]{clientName}, false); - roleFs.setValue("role_name", grouoFs.getString("sg01")); - //淇敼瑙掕壊 - baseDao.update(roleFs); - //淇敼瀹㈡埛 + //鍘熷鎴峰悕绉� + String clientName = tableFs.getString("client_name"); + tableFs.setValue("client_name", grouoFs.getString("sg01")); + String clientUUID = tableFs.getUUID(); + //鏌ヨ鍘熷鎴风殑瑙掕壊 鏀逛负瑗垮畞 + FieldSetEntity roleFs = baseDao.getFieldSetEntityByFilter("product_sys_role", " role_name = ? ", new String[]{clientName}, false); + roleFs.setValue("role_name", grouoFs.getString("sg01")); + //淇敼瑙掕壊 + baseDao.update(roleFs); + //淇敼瀹㈡埛 // tableFs.setCodeFieldUpdateFlat("client_code", true); - baseDao.update(tableFs); - return clientUUID; - } + baseDao.update(tableFs); + return clientUUID; + } - /** - * 鍚屾鍗曚綅绠$悊鍛� - */ - public void syncManager(String clientUUID) throws SQLException, ClassNotFoundException { - Connection conn = this.getJDBC(); - DataTableEntity managerData; - try { - //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛� - StringBuffer sql = new StringBuffer(); - sql.append(" SELECT A.*,REPLACE(REPLACE(REPLACE(A.SU03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), ") - .append(" '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/'),'/','>') ASU03 FROM ") - .append(" FE_BASE5.SYS_USERS A WHERE A.SU31 = 2 "); - //浜哄憳鏁版嵁 - managerData = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{}); - this.syncManager(managerData, clientUUID); - } catch (Exception e) { - throw e; - } - } + /** + * 鍚屾鍗曚綅绠$悊鍛� + */ + public void syncManager(String clientUUID) throws SQLException, ClassNotFoundException { + Connection conn = this.getJDBC(); + DataTableEntity managerData; + try { + //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛� + StringBuffer sql = new StringBuffer(); + sql.append(" SELECT A.*,REPLACE(REPLACE(REPLACE(A.SU03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), ") + .append(" '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/'),'/','>') ASU03 FROM ") + .append(" FE_BASE5.SYS_USERS A WHERE A.SU31 = 2 "); + //浜哄憳鏁版嵁 + managerData = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{}); + this.syncManager(managerData, clientUUID); + } catch (Exception e) { + throw e; + } + } - /** - * 鍚屾绠$悊鍛� - * @param managerData 绠$悊鍛樼敤鎴锋暟鎹� - */ - public void syncManager(DataTableEntity managerData,String clientUUID){ - if(!BaseUtil.dataTableIsEmpty(managerData)) { - for (int i = 0; i < managerData.getRows(); i++) { - FieldSetEntity userFs = new FieldSetEntity(); - FieldSetEntity fse = managerData.getFieldSetEntity(i); - userFs.setTableName("product_sys_users"); - String su01 = fse.getString("su01"); - userFs.setValue("user_name", su01); - userFs.setValue("user_account",su01); - userFs.setValue("gender", 1); - userFs.setValue("user_pwd", userService.createPassWord(su01, "123")); - userFs.setValue("is_manager", 1); - userFs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id()); - userFs.setValue("created_utc_datetime", new Date()); - userFs.setValue("status", 1); + /** + * 鍚屾绠$悊鍛� + * + * @param managerData 绠$悊鍛樼敤鎴锋暟鎹� + */ + public void syncManager(DataTableEntity managerData, String clientUUID) { + if (!BaseUtil.dataTableIsEmpty(managerData)) { + for (int i = 0; i < managerData.getRows(); i++) { + FieldSetEntity userFs = new FieldSetEntity(); + FieldSetEntity fse = managerData.getFieldSetEntity(i); + userFs.setTableName("product_sys_users"); + String su01 = fse.getString("su01"); + userFs.setValue("user_name", su01); + userFs.setValue("user_account", su01); + userFs.setValue("gender", 1); + userFs.setValue("user_pwd", userService.createPassWord(su01, "123")); + userFs.setValue("is_manager", 1); + userFs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id()); + userFs.setValue("created_utc_datetime", new Date()); + userFs.setValue("status", 1); - //鏂板绠$悊鍛� - String usersUUID = baseDao.add(userFs); - FieldSetEntity users = baseDao.getFieldSetEntity("product_sys_users", usersUUID, false); - FieldSetEntity managerFs = new FieldSetEntity(); - managerFs.setTableName("product_sys_org_manager"); - managerFs.setValue("user_id", users.getString("user_id")); - //浼佷笟绠$悊鍛� - managerFs.setValue("manager_type", "2"); - managerFs.setValue("role_uuids", "eabb00f3-2118-4165-967b-a7d88f472f67-notchange"); - managerFs.setValue("is_used", 1); - managerFs.setValue("clients_uuid", clientUUID); - managerFs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id()); - managerFs.setValue("created_utc_datetime", new Date()); - //閲嶆柊缁勮鍚庣殑缁勭粐鍏ㄧО - String uuid = this.getSuperiorCompanyUuid(fse.getString("asu03")); - managerFs.setValue("org_level_uuid", uuid); - baseDao.add(managerFs); - } + //鏂板绠$悊鍛� + String usersUUID = baseDao.add(userFs); + FieldSetEntity users = baseDao.getFieldSetEntity("product_sys_users", usersUUID, false); + FieldSetEntity managerFs = new FieldSetEntity(); + managerFs.setTableName("product_sys_org_manager"); + managerFs.setValue("user_id", users.getString("user_id")); + //浼佷笟绠$悊鍛� + managerFs.setValue("manager_type", "2"); + managerFs.setValue("role_uuids", "eabb00f3-2118-4165-967b-a7d88f472f67-notchange"); + managerFs.setValue("is_used", 1); + managerFs.setValue("clients_uuid", clientUUID); + managerFs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id()); + managerFs.setValue("created_utc_datetime", new Date()); + //閲嶆柊缁勮鍚庣殑缁勭粐鍏ㄧО + String uuid = this.getSuperiorCompanyUuid(fse.getString("asu03")); + managerFs.setValue("org_level_uuid", uuid); + baseDao.add(managerFs); + } - } - } + } + } - /** - * 鍚屾鍏徃閮ㄩ棬 - */ - public void syncDepartmentCompany() throws SQLException, ClassNotFoundException { + /** + * 鍚屾鍏徃閮ㄩ棬 + */ + public void syncDepartmentCompany() throws SQLException, ClassNotFoundException { - //鍚屾缁勭粐鏈烘瀯鏁版嵁瀛樻斁闆嗗悎 - DataTableEntity groupLeadersFs; - Connection conn = this.getJDBC(); - try { - StringBuffer sql = new StringBuffer(); - sql.append("SELECT A.*,REPLACE(REPLACE(A.SG03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/') ASG03 FROM ( ") - .append( "SELECT * FROM FE_BASE5.SYS_GROUP WHERE length(SG10) > 3 or SG10 = '001' ORDER BY SG10) A ORDER BY SG10"); - //鑾峰彇闇�瑕佸悓姝ョ殑缁勭粐鏈烘瀯 - groupLeadersFs = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{}); - } catch (Exception e) { - throw e; - } - DataManipulationUtils.close(null, null, conn); - - //鍒涘缓椤剁骇鍏徃 - //鑾峰彇FE椤剁骇鍏徃 - FieldSetEntity topCompanies = groupLeadersFs.getFieldSetEntity(0); - //鑾峰彇浜у搧001椤剁骇鍏徃 - FieldSetEntity field = baseDao.getFieldSetEntityByFilter("product_sys_org_levels", " org_level_code = 001 ", null,false); - //鏇存柊鍏徃鍚嶇О锛屽叕鍙哥煭缂栫爜锛屽叕鍙告帓搴� - field.setValue("org_level_name", topCompanies.getString("sg01")); - field.setValue("org_level_shortcode", topCompanies.getString("sg10")); - field.setValue("sequence", topCompanies.getString("sg00")); + //鍚屾缁勭粐鏈烘瀯鏁版嵁瀛樻斁闆嗗悎 + DataTableEntity groupLeadersFs; + Connection conn = this.getJDBC(); + try { + StringBuffer sql = new StringBuffer(); + sql.append("SELECT A.*,REPLACE(REPLACE(A.SG03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/') ASG03 FROM ( ") + .append("SELECT * FROM FE_BASE5.SYS_GROUP WHERE length(SG10) > 3 or SG10 = '001' ORDER BY SG10) A ORDER BY SG10"); + //鑾峰彇闇�瑕佸悓姝ョ殑缁勭粐鏈烘瀯 + groupLeadersFs = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{}); + } catch (Exception e) { + throw e; + } + DataManipulationUtils.close(null, null, conn); + + //鍒涘缓椤剁骇鍏徃 + //鑾峰彇FE椤剁骇鍏徃 + FieldSetEntity topCompanies = groupLeadersFs.getFieldSetEntity(0); + //鑾峰彇浜у搧001椤剁骇鍏徃 + FieldSetEntity field = baseDao.getFieldSetEntityByFilter("product_sys_org_levels", " org_level_code = 001 ", null, false); + //鏇存柊鍏徃鍚嶇О锛屽叕鍙哥煭缂栫爜锛屽叕鍙告帓搴� + field.setValue("org_level_name", topCompanies.getString("sg01")); + field.setValue("org_level_shortcode", topCompanies.getString("sg10")); + field.setValue("sequence", topCompanies.getString("sg00")); // field.setCodeFieldUpdateFlat("org_level_code", true); - - //浜嬬墿璋冪敤锛屼繚瀛樺叕鍙镐俊鎭� - ISystemOrgLevelsService service=(ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService); - service.updateCompany(field); - + + //浜嬬墿璋冪敤锛屼繚瀛樺叕鍙镐俊鎭� + ISystemOrgLevelsService service = (ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService); + service.updateCompany(field); + // FieldSetEntity topField = this.addCompany(topCompanies,null, null); - institutionMap.put(field.getString("org_level_all"),field); - - //閬嶅巻fe鏋舵瀯鏁版嵁 瀛樺叆缁勭粐鏋舵瀯淇℃伅琛� - for (int i = 1; i < groupLeadersFs.getRows(); i++) { - - FieldSetEntity levelFs = groupLeadersFs.getFieldSetEntity(i); - //鑾峰彇FE琛ㄧ粍缁囨満鏋勫叏绉� - String asg03 = levelFs.getString("asg03"); - //鎴彇涓轰笂绾у叕鍙哥浉鍚岀殑鍏ㄧО - String level_all = asg03.substring(0,asg03.lastIndexOf("/")); - //鏇挎崲涓轰竴鏍风殑绗﹀彿鏂逛究瀵规瘮 - level_all = level_all.replace("/", ">"); - //鑾峰彇涓婄骇鍏徃鎴栭儴闂� - FieldSetEntity fieldSet = institutionMap.get(level_all); - //涓婄骇鍏徃uuid - String org_level_uuid = this.getSuperiorCompanyUuid(level_all); - if(fieldSet == null){ - throw new BaseException("涓婄骇涓虹┖","鏃犳硶鑾峰彇涓婄骇code"); - } - if(org_level_uuid == null){ - throw new BaseException("涓婄骇鍏徃涓虹┖","涓婄骇鍏徃uuid"); - } - //涓婄骇鍏徃code - String org_level_code = fieldSet.getString("org_level_code"); - FieldSetEntity fse; + institutionMap.put(field.getString("org_level_all"), field); + + //閬嶅巻fe鏋舵瀯鏁版嵁 瀛樺叆缁勭粐鏋舵瀯淇℃伅琛� + for (int i = 1; i < groupLeadersFs.getRows(); i++) { + + FieldSetEntity levelFs = groupLeadersFs.getFieldSetEntity(i); + //鑾峰彇FE琛ㄧ粍缁囨満鏋勫叏绉� + String asg03 = levelFs.getString("asg03"); + String levelAll = asg03.replaceAll("/", ">"); + levelFs = baseDao.getFieldSetByFilter("product_sys_org_levels", "org_level_all=?", new Object[]{levelAll}, false); + if (levelFs != null && !StringUtils.isEmpty(levelFs.getUUID())) { + institutionMap.put(levelFs.getString("org_level_all"), levelFs); + continue; + } + //鎴彇涓轰笂绾у叕鍙哥浉鍚岀殑鍏ㄧО + String level_all = asg03.substring(0, asg03.lastIndexOf("/")); + //鏇挎崲涓轰竴鏍风殑绗﹀彿鏂逛究瀵规瘮 + level_all = level_all.replace("/", ">"); + //鑾峰彇涓婄骇鍏徃鎴栭儴闂� + FieldSetEntity fieldSet = institutionMap.get(level_all); + //涓婄骇鍏徃uuid + String org_level_uuid = this.getSuperiorCompanyUuid(level_all); + if (fieldSet == null) { + throw new BaseException("涓婄骇涓虹┖", "鏃犳硶鑾峰彇涓婄骇code"); + } + if (org_level_uuid == null) { + throw new BaseException("涓婄骇鍏徃涓虹┖", "涓婄骇鍏徃uuid"); + } + //涓婄骇鍏徃code + String org_level_code = fieldSet.getString("org_level_code"); + FieldSetEntity fse; // levelFs.setCodeFieldUpdateFlat("org_level_code", true); - //杩涘叆鏂板鍏徃鏂规硶 - if(levelFs.getInteger("sg14") == 1){ - fse = this.addCompany(levelFs,org_level_code,org_level_uuid); - //杩涘叆鏂板閮ㄩ棬鏂规硶 - }else { - fse = this.addDepartment(levelFs, org_level_code, org_level_uuid); - } - institutionMap.put(fse.getString("org_level_all"), fse); - } + //杩涘叆鏂板鍏徃鏂规硶 + if (levelFs.getInteger("sg14") == 1) { + fse = this.addCompany(levelFs, org_level_code, org_level_uuid); + //杩涘叆鏂板閮ㄩ棬鏂规硶 + } else { + fse = this.addDepartment(levelFs, org_level_code, org_level_uuid); + } + institutionMap.put(fse.getString("org_level_all"), fse); + } // //鍒涘缓瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�涓嬮儴闂紙鍔炲叕瀹わ級 // FieldSetEntity fse = new FieldSetEntity(); @@ -295,374 +306,395 @@ // FieldSetEntity fieldSet = institutionMap.get("瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�"); // FieldSetEntity fs = this.addDepartment(fse,fieldSet.getString("org_level_code"), fieldSet.getUUID()); // institutionMap.put(fs.getString("org_level_all"), fs); - } + } - /** - * 鍚屾宀椾綅鍜屽矖浣嶇瓑绾� - */ - public void synchronousPost() throws SQLException, ClassNotFoundException { + /** + * 鍚屾宀椾綅鍜屽矖浣嶇瓑绾� + */ + public void synchronousPost() throws SQLException, ClassNotFoundException { - Connection conn = this.getJDBC(); - DataTableEntity groupLeadersFs; - try { - //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛� - StringBuffer sql = new StringBuffer(); - sql.append(" SELECT SR00,SR01,SR02,SR10, SR15, ") - .append(" REPLACE(REPLACE(REPLACE(SR03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), ") - .append(" '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/'),'/','>') ASR03 FROM fe_base5.SYS_ROLE "); - //1涓哄叕鍙� - groupLeadersFs = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{}); - } catch (Exception e) { + Connection conn = this.getJDBC(); + DataTableEntity groupLeadersFs; + try { + //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛� + StringBuffer sql = new StringBuffer(); + sql.append(" SELECT SR00,SR01,SR02,SR10, SR15, ") + .append(" REPLACE(REPLACE(REPLACE(SR03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), ") + .append(" '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/'),'/','>') ASR03 FROM fe_base5.SYS_ROLE "); + //1涓哄叕鍙� + groupLeadersFs = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{}); + } catch (Exception e) { - throw e; - } - DataManipulationUtils.close(null, null, conn); - //鍚屾宀椾綅绛夌骇 - this.postGrades(groupLeadersFs); - this.addPost(groupLeadersFs); - } + throw e; + } + DataManipulationUtils.close(null, null, conn); + //鍚屾宀椾綅绛夌骇 + this.postGrades(groupLeadersFs); + this.addPost(groupLeadersFs); + } - /** - * 鍚屾瑙掕壊 - */ - public void synchronousRole()throws SQLException, ClassNotFoundException{ - Connection conn = this.getJDBC(); - DataTableEntity roleData; - try { - //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛� - StringBuffer sql = new StringBuffer(); - sql.append(" select * from fe_base5.SYS_POPEDOM_TEMPLET a left join fe_base5.SYS_POPEDOM_TEMP_SUB b on a.SPT00=b.STS01 "); - //浜哄憳鏁版嵁 - roleData = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{}); + /** + * 鍚屾瑙掕壊 + */ + public void synchronousRole() throws SQLException, ClassNotFoundException { + Connection conn = this.getJDBC(); + DataTableEntity roleData; + try { + //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛� + StringBuffer sql = new StringBuffer(); + sql.append(" select * from fe_base5.SYS_POPEDOM_TEMPLET a left join fe_base5.SYS_POPEDOM_TEMP_SUB b on a.SPT00=b.STS01 "); + //浜哄憳鏁版嵁 + roleData = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{}); - } catch (Exception e) { - throw e; - } - DataManipulationUtils.close(null, null, conn); - this.synchronousRole(roleData); + } catch (Exception e) { + throw e; + } + DataManipulationUtils.close(null, null, conn); + this.synchronousRole(roleData); - } + } - /** - * 鍒濆鍖栧熀鏈潈闄� - */ - public void packageButton(String role_uuid){ - StringBuffer sql = new StringBuffer(); - String tricodeIn = BaseUtil.buildQuestionMarkFilter("tricode", this.functionCode, true); - sql.append(" SELECT function_uuid,group_concat(uuid SEPARATOR ',') button_uuid FROM product_sys_function_buttons WHERE function_uuid IN ( ") - .append(" SELECT uuid FROM product_sys_functions WHERE ") - .append(tricodeIn).append(" ) GROUP BY function_uuid "); - DataTableEntity dataTableEntity = baseDao.listTable(sql.toString(),new String[]{}); - for (int i = 0; i < dataTableEntity.getRows(); i++) { - FieldSetEntity fieldSetEntity = new FieldSetEntity(); - fieldSetEntity.setTableName("product_sys_function_permission"); - fieldSetEntity.setValue("function_uuid", dataTableEntity.getString(i,"function_uuid")); - fieldSetEntity.setValue("button_uuid", dataTableEntity.getString(i,"button_uuid")); - fieldSetEntity.setValue("role_uuid", role_uuid); - baseDao.add(fieldSetEntity); - } - } + /** + * 鍒濆鍖栧熀鏈潈闄� + */ + public void packageButton(String role_uuid) { + StringBuffer sql = new StringBuffer(); + String tricodeIn = BaseUtil.buildQuestionMarkFilter("tricode", this.functionCode, true); + sql.append(" SELECT function_uuid,group_concat(uuid SEPARATOR ',') button_uuid FROM product_sys_function_buttons WHERE function_uuid IN ( ") + .append(" SELECT uuid FROM product_sys_functions WHERE ") + .append(tricodeIn).append(" ) GROUP BY function_uuid "); + DataTableEntity dataTableEntity = baseDao.listTable(sql.toString(), new String[]{}); + for (int i = 0; i < dataTableEntity.getRows(); i++) { + FieldSetEntity fieldSetEntity = new FieldSetEntity(); + fieldSetEntity.setTableName("product_sys_function_permission"); + fieldSetEntity.setValue("function_uuid", dataTableEntity.getString(i, "function_uuid")); + fieldSetEntity.setValue("button_uuid", dataTableEntity.getString(i, "button_uuid")); + fieldSetEntity.setValue("role_uuid", role_uuid); + baseDao.add(fieldSetEntity); + } + } - /** - * 鍚屾浜哄憳 - */ - public void addEmployees(String clientUUID) throws SQLException, ClassNotFoundException { + /** + * 鍚屾浜哄憳 + */ + public void addEmployees(String clientUUID) throws SQLException, ClassNotFoundException { - Connection conn = this.getJDBC(); - DataTableEntity personnelData; - try { - //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛� - StringBuffer sql = new StringBuffer(); + Connection conn = this.getJDBC(); + DataTableEntity personnelData; + try { + //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛� + StringBuffer sql = new StringBuffer(); // sql.append(" SELECT A.*,REPLACE(REPLACE(REPLACE(A.SU03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), ") // .append(" '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/'),'/','>') ASU03 FROM ") // .append(" FE_BASE5.SYS_USERS A WHERE A.SU39 is not null and A.SU35 is not null AND A.SU03 IS NOT NULL "); - sql.append(" SELECT A.*,REPLACE(REPLACE(REPLACE(A.SU03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), ") - .append(" '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/'),'/','>') ASU03 FROM ") - .append(" FE_BASE5.SYS_USERS A WHERE SU39 IS NOT NULL"); - //浜哄憳鏁版嵁 - personnelData = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{}); - } catch (Exception e) { - throw e; - } - DataManipulationUtils.close(null, null, conn); - this.addEmployees(personnelData,clientUUID); - } + sql.append(" SELECT A.*,REPLACE(REPLACE(REPLACE(A.SU03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), ") + .append(" '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/'),'/','>') ASU03 FROM ") + .append(" FE_BASE5.SYS_USERS A WHERE SU39 IS NOT NULL"); + //浜哄憳鏁版嵁 + personnelData = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{}); + } catch (Exception e) { + throw e; + } + DataManipulationUtils.close(null, null, conn); + this.addEmployees(personnelData, clientUUID); + } - /** - * 閫掑綊鑾峰彇涓婄骇鍏徃uuid - * @param level_all 涓婄骇鍏徃鍏ㄧО - * @return 淇濆瓨鍚庤繑鍥炰繚瀛樺悗鐨� fse - */ - public String getSuperiorCompanyUuid(String level_all){ - FieldSetEntity fieldSet = institutionMap.get(level_all); - if(fieldSet == null){ - return null; - } - //涓婄骇涓哄叕鍙� - if("0".equals(fieldSet.getString("org_level_type"))){ - return fieldSet.getUUID(); - }else { - Integer index = level_all.lastIndexOf(">"); - if(index == -1){ - return null; - } - level_all = level_all.substring(0,index); - return this.getSuperiorCompanyUuid(level_all); - } - } + /** + * 閫掑綊鑾峰彇涓婄骇鍏徃uuid + * + * @param level_all 涓婄骇鍏徃鍏ㄧО + * @return 淇濆瓨鍚庤繑鍥炰繚瀛樺悗鐨� fse + */ + public String getSuperiorCompanyUuid(String level_all) { + FieldSetEntity fieldSet = institutionMap.get(level_all); + if (fieldSet == null) { + return null; + } + //涓婄骇涓哄叕鍙� + if ("0".equals(fieldSet.getString("org_level_type"))) { + return fieldSet.getUUID(); + } else { + Integer index = level_all.lastIndexOf(">"); + if (index == -1) { + return null; + } + level_all = level_all.substring(0, index); + return this.getSuperiorCompanyUuid(level_all); + } + } - /** - * 淇濆瓨鍏徃 - * @param fse 鍏徃fes - * @param code_parent 鍏徃涓婄骇code - * @return 淇濆瓨鍚庤繑鍥炰繚瀛樺悗鐨� fse - */ - public FieldSetEntity addCompany(FieldSetEntity fse, String code_parent, String org_level_uuid){ - FieldSetEntity levelsFs = new FieldSetEntity(); - levelsFs.setTableName("product_sys_org_levels"); - //閮ㄩ棬鍚嶇О,, - levelsFs.setValue("org_level_name", fse.getString("sg01")); + /** + * 淇濆瓨鍏徃 + * + * @param fse 鍏徃fes + * @param code_parent 鍏徃涓婄骇code + * @return 淇濆瓨鍚庤繑鍥炰繚瀛樺悗鐨� fse + */ + public FieldSetEntity addCompany(FieldSetEntity fse, String code_parent, String org_level_uuid) { + FieldSetEntity levelsFs = new FieldSetEntity(); + levelsFs.setTableName("product_sys_org_levels"); + //閮ㄩ棬鍚嶇О,, + levelsFs.setValue("org_level_name", fse.getString("sg01")); - //鍏徃娈电紪鐮� - levelsFs.setValue("org_level_shortcode", fse.getString("sg10")); - //鍏徃鎺掑簭 - levelsFs.setValue("sequence", ++sort); - //鏀惧叆涓婄骇code 鐢熸垚code - levelsFs.setValue("org_level_code_parent", code_parent); - //涓婄骇鍏徃uuid - levelsFs.setValue("org_level_uuid", org_level_uuid); - ISystemOrgLevelsService service=(ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService); + //鍏徃娈电紪鐮� + levelsFs.setValue("org_level_shortcode", fse.getString("sg10")); + //鍏徃鎺掑簭 + levelsFs.setValue("sequence", ++sort); + //鏀惧叆涓婄骇code 鐢熸垚code + levelsFs.setValue("org_level_code_parent", code_parent); + //涓婄骇鍏徃uuid + levelsFs.setValue("org_level_uuid", org_level_uuid); + ISystemOrgLevelsService service = (ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService); // levelsFs.setCodeFieldUpdateFlat("org_level_code", true); - service.addCompany(levelsFs); - return levelsFs; - } + service.addCompany(levelsFs); + return levelsFs; + } - /** - * 淇濆瓨閮ㄩ棬 - * @param fse 鍏徃fes - * @param code_parent 鍏徃涓婄骇code - * @return 淇濆瓨鍚庤繑鍥炰繚瀛樺悗鐨� fse - */ - public FieldSetEntity addDepartment(FieldSetEntity fse, String code_parent, String org_level_uuid){ - FieldSetEntity levelsFs = new FieldSetEntity(); - levelsFs.setTableName("product_sys_org_levels"); - //閮ㄩ棬鍚嶇О,, - levelsFs.setValue("org_level_name", fse.getString("sg01")); - //閮ㄩ棬缂栫爜 - levelsFs.setValue("org_level_shortcode", fse.getString("sg10")); - //鍏徃鎺掑簭 - levelsFs.setValue("sequence", fse.getString("sg00")); - //鏀惧叆涓婄骇code 鐢熸垚code - levelsFs.setValue("org_level_code_parent", code_parent); - //涓婄骇鍏徃uuid - levelsFs.setValue("org_level_uuid", org_level_uuid); - ISystemOrgLevelsService service=(ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService); + /** + * 淇濆瓨閮ㄩ棬 + * + * @param fse 鍏徃fes + * @param code_parent 鍏徃涓婄骇code + * @return 淇濆瓨鍚庤繑鍥炰繚瀛樺悗鐨� fse + */ + public FieldSetEntity addDepartment(FieldSetEntity fse, String code_parent, String org_level_uuid) { + FieldSetEntity levelsFs = new FieldSetEntity(); + levelsFs.setTableName("product_sys_org_levels"); + //閮ㄩ棬鍚嶇О,, + levelsFs.setValue("org_level_name", fse.getString("sg01")); + //閮ㄩ棬缂栫爜 + levelsFs.setValue("org_level_shortcode", fse.getString("sg10")); + //鍏徃鎺掑簭 + levelsFs.setValue("sequence", fse.getString("sg00")); + //鏀惧叆涓婄骇code 鐢熸垚code + levelsFs.setValue("org_level_code_parent", code_parent); + //涓婄骇鍏徃uuid + levelsFs.setValue("org_level_uuid", org_level_uuid); + ISystemOrgLevelsService service = (ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService); // levelsFs.setCodeFieldUpdateFlat("org_level_code", true); - service.addDepartment(levelsFs); - return levelsFs; - } - /** - * 灏佽鍏徃閮ㄩ棬鍏ㄧО Map - */ - public void packInstitutionMap()throws BaseException { - DataTableEntity dataTableEntity = baseDao.listTable("SELECT * FROM product_sys_org_levels WHERE org_level_code like ? ", new String[]{"%001%"}); - if(!BaseUtil.dataTableIsEmpty(dataTableEntity)) { - for (int i = 0; i < dataTableEntity.getRows(); i++) { - FieldSetEntity fieldSetEntity = dataTableEntity.getFieldSetEntity(i); - String org_level_all = fieldSetEntity.getString("org_level_all"); - institutionMap.put(org_level_all, fieldSetEntity); - } - }else { - throw new BaseException("鏈煡璇㈠埌鍗曚綅閮ㄩ棬鏁版嵁", "鏈煡璇㈠埌鍗曚綅閮ㄩ棬鏁版嵁"); - } - } + service.addDepartment(levelsFs); + return levelsFs; + } - /** - * 鍚屾瑙掕壊 - */ - public void synchronousRole(DataTableEntity data){ - for (int i = 0; i < data.getRows(); i++) { - FieldSetEntity rolesFs = data.getFieldSetEntity(i); - String sts02s = rolesFs.getString("sts02"); - FieldSetEntity levelsField = baseDao.getFieldSetEntityByFilter("product_sys_org_levels", " org_level_shortcode = ? ", new String[]{sts02s}, false); - //鏈変簺瑙掕壊鍏宠仈鐨勫崟浣嶆垨閮ㄩ棬宸茬粡琚垹闄ゆ帀,浣嗘槸瑙掕壊杩樹繚鐣欎粬鐨勭紪鐮� 鐩存帴璺宠繃 - if(levelsField == null){ - continue; - } - FieldSetEntity lxRoleFs = new FieldSetEntity(); - lxRoleFs.setTableName("product_sys_role"); - lxRoleFs.setValue("org_level_uuid",levelsField.getUUID()); - lxRoleFs.setValue("role_name", rolesFs.getString("spt01")); - lxRoleFs.setValue("role_description", rolesFs.getString("spt02")); - lxRoleFs.setValue("is_used", 1); - lxRoleFs.setValue("sequence", rolesFs.getInteger("spt00")); - this.userAndTime(lxRoleFs); - String role_uuid = baseDao.add(lxRoleFs); + /** + * 灏佽鍏徃閮ㄩ棬鍏ㄧО Map + */ + public void packInstitutionMap() throws BaseException { + DataTableEntity dataTableEntity = baseDao.listTable("SELECT * FROM product_sys_org_levels WHERE org_level_code like ? ", new String[]{"%001%"}); + if (!BaseUtil.dataTableIsEmpty(dataTableEntity)) { + for (int i = 0; i < dataTableEntity.getRows(); i++) { + FieldSetEntity fieldSetEntity = dataTableEntity.getFieldSetEntity(i); + String org_level_all = fieldSetEntity.getString("org_level_all"); + institutionMap.put(org_level_all, fieldSetEntity); + } + } else { + throw new BaseException("鏈煡璇㈠埌鍗曚綅閮ㄩ棬鏁版嵁", "鏈煡璇㈠埌鍗曚綅閮ㄩ棬鏁版嵁"); + } + } - //璇ヨ鑹插垵濮嬪寲鏉冮檺 - this.packageButton(role_uuid); - } - } - - /** - * 娣诲姞鐢ㄦ埛鍜屽憳宸� - */ - public void addEmployees(DataTableEntity data,String clientUUID){ - //fe 浜哄憳id 瀵瑰簲 userid - JSONObject idUserMap = new JSONObject(); - //鑾峰彇瀹㈡埛uuid - FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntityByFilter("product_sys_org_levels", " org_level_code = ? ", new String[]{"001"}, false); - String client_uuid = fieldSetEntity.getString("client_uuid"); - - Map<String, FieldSetEntity> staffsMap = Maps.newHashMap(); - for (int i = 0; i < data.getRows(); i++) { - FieldSetEntity userFs = data.getFieldSetEntity(i); - FieldSetEntity usersFs = new FieldSetEntity(); - //鍒涘缓 user 鏁版嵁 - usersFs.setTableName("product_sys_users"); - //鐢ㄦ埛鍚� - usersFs.setValue("user_name", userFs.getString("su02")); - //鎻忚堪 - usersFs.setValue("user_account", userFs.getString("su01")); - //閭 - usersFs.setValue("user_primary_email", userFs.getString("su11")); - //鎬у埆杞崲 - String su16 = userFs.getString("su16"); - String sex = null; - if (su16 != null) { - sex = su16.equals("鐢�") ? "0" : "1"; - } - usersFs.setValue("gender", sex); - //鐢ㄦ埛鐢佃瘽 - usersFs.setValue("user_mobile_number", userFs.getString("su10")); - //鍐呯嚎鐢佃瘽 - usersFs.setValue("inside_phone", userFs.getString("su13")); - //鍦板潃 - usersFs.setValue("contact_address", userFs.getString("su18")); - //鍒濆鍖栫敤鎴峰瘑鐮� - usersFs.setValue("user_pwd", userService.createPassWord(userFs.getString("su01"), "123")); - //鏄惁鏄鐞嗗憳 0:鍚� 1:鏄� - usersFs.setValue("is_manager", 0); - //鍔炲叕鐢佃瘽 - usersFs.setValue("office_phone", userFs.getString("su09")); - this.userAndTime(usersFs); - //鐘舵�� 0锛氱鐢� 1锛氭甯� - usersFs.setValue("status", userFs.getString("su08")); - //绛惧悕 - String su23 = userFs.getString("su23"); - if (!BaseUtil.strIsNull(su23)) { - usersFs.setValue("user_signature", this.signatureAndThumbnail(su23, clientUUID,"user_signature")); - } - //澶村儚 - String su28 = userFs.getString("su28"); - if (!BaseUtil.strIsNull(su28)) { - usersFs.setValue("thumbnail_img", this.signatureAndThumbnail(su28, clientUUID,"thumbnail_img")); - } - - String usersUUID = baseDao.add(usersFs); - FieldSetEntity users = baseDao.getFieldSetEntity("product_sys_users", usersUUID, false); - //fe鐢ㄦ埛id 鍏宠仈绯荤粺琛�"product_sys_users锛塽ser_id - idUserMap.put(userFs.getString("su00"), users.getString("user_id")); - - if (BaseUtil.strIsNull(userFs.getString("su03")) || BaseUtil.strIsNull(userFs.getString("su35")) || BaseUtil.strIsNull(userFs.getString("su39"))) { + /** + * 鍚屾瑙掕壊 + */ + public void synchronousRole(DataTableEntity data) { + for (int i = 0; i < data.getRows(); i++) { + FieldSetEntity rolesFs = data.getFieldSetEntity(i); + String sts02s = rolesFs.getString("sts02"); + FieldSetEntity levelsField = baseDao.getFieldSetEntityByFilter("product_sys_org_levels", " org_level_shortcode = ? ", new String[]{sts02s}, false); + //鏈変簺瑙掕壊鍏宠仈鐨勫崟浣嶆垨閮ㄩ棬宸茬粡琚垹闄ゆ帀,浣嗘槸瑙掕壊杩樹繚鐣欎粬鐨勭紪鐮� 鐩存帴璺宠繃 + if (levelsField == null) { continue; } - - FieldSetEntity staffsFs = new FieldSetEntity(); - //鍛樺伐琛� - staffsFs.setTableName("product_sys_staffs"); - //鐢ㄦ埛琛╥d - staffsFs.setValue("user_id", users.getString("user_id")); - //鏄剧ず鍚嶇О - staffsFs.setValue("show_name", userFs.getString("su02")); - //鍛樺伐鍚� - staffsFs.setValue("given_name", userFs.getString("su02")); - //鍛樺伐濮� - staffsFs.setValue("family_name", userFs.getString("su02")); - //閭 - staffsFs.setValue("email_address", userFs.getString("su11")); - //绉诲姩鐢佃瘽 - staffsFs.setValue("mobile_phone", userFs.getString("su10")); - //鍔炲叕鐢佃瘽 - staffsFs.setValue("office_telephone", userFs.getString("su09")); + FieldSetEntity lxRoleFs = new FieldSetEntity(); + lxRoleFs.setTableName("product_sys_role"); + lxRoleFs.setValue("org_level_uuid", levelsField.getUUID()); + lxRoleFs.setValue("role_name", rolesFs.getString("spt01")); + lxRoleFs.setValue("role_description", rolesFs.getString("spt02")); + lxRoleFs.setValue("is_used", 1); + lxRoleFs.setValue("sequence", rolesFs.getInteger("spt00")); + this.userAndTime(lxRoleFs); + String role_uuid = baseDao.add(lxRoleFs); - //鍛樺伐鎬у埆 - staffsFs.setValue("sex", sex); - //鍛樺伐閭 - String su11 = userFs.getString("su11"); - //閭涓虹┖鍏堣1 - if(BaseUtil.strIsNull(su11)){ - su11 = "1"; - } - staffsFs.setValue("staff_email", su11); - //鐘舵�侊細0鍑嗗鍏ヨ亴 1璇曠敤 2鍑嗗杞 3鍦ㄨ亴 4鍋滆亴 5鍑嗗绂昏亴 6绂昏亴 7閫�浼� - staffsFs.setValue("staff_status", 3); + //璇ヨ鑹插垵濮嬪寲鏉冮檺 + this.packageButton(role_uuid); + } + } - staffsFs.setValue("client_uuid", client_uuid); - //閲嶆柊缁勮鍚庣殑缁勭粐鍏ㄧО - FieldSetEntity fieldSet = institutionMap.get(userFs.getString("asu03")); - String uuid = this.getSuperiorCompanyUuid(userFs.getString("asu03")); - //鍏徃uuid - staffsFs.setValue("org_level_uuid", uuid); - //閮ㄩ棬uuid - staffsFs.setValue("dept_uuid", fieldSet.getUUID()); - - if (null == userFs.getString("su34")) { - //宀椾綅uuid - staffsFs.setValue("job_post_uuid", 1); - //宀椾綅绛夌骇uuid - staffsFs.setValue("job_post_grade_uuid",1); - } else { - //閫氳繃宀椾綅id鏌ヨ宀椾綅 - String su34 = userFs.getString("su34"); - FieldSetEntity fsePosts = baseDao.getFieldSetEntityByFilter("product_sys_job_posts", " sequence = ? ", new Integer[]{Integer.parseInt(su34)}, false); - if(fsePosts != null) { - staffsFs.setValue("job_post_uuid", fsePosts.getUUID()); - staffsFs.setValue("job_post_grade_uuid", fsePosts.getString("job_post_grades_uuid")); - }else { - throw new BaseException("鏈煡璇㈠埌宀椾綅","鏈煡璇㈠埌宀椾綅"); - } - } - //su35鍏宠仈鏉冮檺id, 鍏宠仈澶氫釜閫楀彿鍒嗛殧 - String su35 = userFs.getString("su35"); - String[] su35s = null; - if(!BaseUtil.strIsNull(su35)){ - su35s = su35.split(","); - for (int j = 0; j < su35s.length; j++) { - FieldSetEntity fse = baseDao.getFieldSetEntityByFilter("product_sys_role", " sequence = ? ", new Integer[]{Integer.parseInt(su35s[j])}, false); - su35s[j] = fse.getUUID(); - } - } - //鐩村睘棰嗗 - String su40 = userFs.getString("su40"); - //涓虹┖灏辨斁绌� - if(BaseUtil.strIsNull(su40)){ - su40 = ""; - }else { - //澶氫釜鐩村睘棰嗗 灏卞彇绗竴涓� - if(su40.contains(",")){ - su40 = su40.substring(0,su40.indexOf(",")); - } - } - staffsFs.setValue("direct_leader_code",su40); - if(su35s != null) { - staffsFs.setValue("role_uuids", StringUtils.join(su35s, ",")); - } - //鍛樺伐涓婁笅绾х紪鐮� - staffsFs.setValue("leader_tricode", codeService.createFixCode(CmnConst.PRODUCT_SYS_STAFFS, CmnConst.LEADER_TRICODE, "")); - //鍛樺伐缂栫爜 鍛樺伐鍘熸湰id 瀛樹负缂栫爜 - staffsFs.setValue("tricode",codeService.createFixCode(CmnConst.PRODUCT_SYS_STAFFS, CmnConst.TRICODE, fieldSet.getString("org_level_code"))); - String su00 = userFs.getString("su00"); - staffsFs.setValue("sequence", su00); - staffsFs.setValue("remark", su00); - this.userAndTime(staffsFs); - baseDao.add(staffsFs); - staffsMap.put(su00, staffsFs); - } - //sql淇敼鐩村睘棰嗗 - baseDao.executeUpdate(" UPDATE product_sys_staffs a INNER JOIN product_sys_staffs b ON a.remark = b.direct_leader_code SET b.direct_leader_code = a.tricode "); - //寰幆鍚屾鐩村睘棰嗗, 鑻ユ湁涓や釜鐩村睘棰嗗 鍙彇绗竴涓� + /** + * 娣诲姞鐢ㄦ埛鍜屽憳宸� + */ + public void addEmployees(DataTableEntity data, String clientUUID) { + //fe 浜哄憳id 瀵瑰簲 userid + JSONObject idUserMap = new JSONObject(); + //鑾峰彇瀹㈡埛uuid + FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntityByFilter("product_sys_org_levels", " org_level_code = ? ", new String[]{"001"}, false); + String client_uuid = fieldSetEntity.getString("client_uuid"); + + Map<String, FieldSetEntity> staffsMap = Maps.newHashMap(); + for (int i = 0; i < data.getRows(); i++) { + FieldSetEntity userFs = data.getFieldSetEntity(i); + FieldSetEntity usersFs = new FieldSetEntity(); + //鍒涘缓 user 鏁版嵁 + usersFs.setTableName("product_sys_users"); + //鐢ㄦ埛鍚� + usersFs.setValue("user_name", userFs.getString("su02")); + //鎻忚堪 + usersFs.setValue("user_account", userFs.getString("su01")); + FieldSetEntity fieldSetByFilter = baseDao.getFieldSetByFilter("product_sys_users", "user_account=?", new Object[]{userFs.getString("su01")}, false); + if (!FieldSetEntity.isEmpty(fieldSetByFilter)) { + fieldSetByFilter.setValue("status", userFs.getString("su08")); + //绛惧悕 + String su23 = userFs.getString("su23"); + if (!BaseUtil.strIsNull(su23)) { + usersFs.setValue("user_signature", this.signatureAndThumbnail(su23, clientUUID, "user_signature")); + } + //澶村儚 + String su28 = userFs.getString("su28"); + if (!BaseUtil.strIsNull(su28)) { + usersFs.setValue("thumbnail_img", this.signatureAndThumbnail(su28, clientUUID, "thumbnail_img")); + } + baseDao.executeUpdate("update product_sys_staffs set staff_status=? where user_id=?", new Object[]{userFs.getString("su08"), fieldSetByFilter.getString("user_id")}); + baseDao.saveFieldSetEntity(fieldSetByFilter); + continue; + } + //閭 + usersFs.setValue("user_primary_email", userFs.getString("su11")); + //鎬у埆杞崲 + String su16 = userFs.getString("su16"); + String sex = null; + if (su16 != null) { + sex = su16.equals("鐢�") ? "0" : "1"; + } + usersFs.setValue("gender", sex); + //鐢ㄦ埛鐢佃瘽 + usersFs.setValue("user_mobile_number", userFs.getString("su10")); + //鍐呯嚎鐢佃瘽 + usersFs.setValue("inside_phone", userFs.getString("su13")); + //鍦板潃 + usersFs.setValue("contact_address", userFs.getString("su18")); + //鍒濆鍖栫敤鎴峰瘑鐮� + usersFs.setValue("user_pwd", userService.createPassWord(userFs.getString("su01"), "123")); + //鏄惁鏄鐞嗗憳 0:鍚� 1:鏄� + usersFs.setValue("is_manager", 0); + //鍔炲叕鐢佃瘽 + usersFs.setValue("office_phone", userFs.getString("su09")); + this.userAndTime(usersFs); + //鐘舵�� 0锛氱鐢� 1锛氭甯� + usersFs.setValue("status", userFs.getString("su08")); + //绛惧悕 + String su23 = userFs.getString("su23"); + if (!BaseUtil.strIsNull(su23)) { + usersFs.setValue("user_signature", this.signatureAndThumbnail(su23, clientUUID, "user_signature")); + } + //澶村儚 + String su28 = userFs.getString("su28"); + if (!BaseUtil.strIsNull(su28)) { + usersFs.setValue("thumbnail_img", this.signatureAndThumbnail(su28, clientUUID, "thumbnail_img")); + } + + String usersUUID = baseDao.add(usersFs); + FieldSetEntity users = baseDao.getFieldSetEntity("product_sys_users", usersUUID, false); + //fe鐢ㄦ埛id 鍏宠仈绯荤粺琛�"product_sys_users锛塽ser_id + idUserMap.put(userFs.getString("su00"), users.getString("user_id")); + + if (BaseUtil.strIsNull(userFs.getString("su03")) || BaseUtil.strIsNull(userFs.getString("su35")) || BaseUtil.strIsNull(userFs.getString("su39"))) { + continue; + } + + FieldSetEntity staffsFs = new FieldSetEntity(); + //鍛樺伐琛� + staffsFs.setTableName("product_sys_staffs"); + //鐢ㄦ埛琛╥d + staffsFs.setValue("user_id", users.getString("user_id")); + //鏄剧ず鍚嶇О + staffsFs.setValue("show_name", userFs.getString("su02")); + //鍛樺伐鍚� + staffsFs.setValue("given_name", userFs.getString("su02")); + //鍛樺伐濮� + staffsFs.setValue("family_name", userFs.getString("su02")); + //閭 + staffsFs.setValue("email_address", userFs.getString("su11")); + //绉诲姩鐢佃瘽 + staffsFs.setValue("mobile_phone", userFs.getString("su10")); + //鍔炲叕鐢佃瘽 + staffsFs.setValue("office_telephone", userFs.getString("su09")); + + //鍛樺伐鎬у埆 + staffsFs.setValue("sex", sex); + //鍛樺伐閭 + String su11 = userFs.getString("su11"); + //閭涓虹┖鍏堣1 + if (BaseUtil.strIsNull(su11)) { + su11 = "1"; + } + staffsFs.setValue("staff_email", su11); + //鐘舵�侊細0鍑嗗鍏ヨ亴 1璇曠敤 2鍑嗗杞 3鍦ㄨ亴 4鍋滆亴 5鍑嗗绂昏亴 6绂昏亴 7閫�浼� + staffsFs.setValue("staff_status", 3); + + staffsFs.setValue("client_uuid", client_uuid); + //閲嶆柊缁勮鍚庣殑缁勭粐鍏ㄧО + FieldSetEntity fieldSet = institutionMap.get(userFs.getString("asu03")); + String uuid = this.getSuperiorCompanyUuid(userFs.getString("asu03")); + //鍏徃uuid + staffsFs.setValue("org_level_uuid", uuid); + //閮ㄩ棬uuid + staffsFs.setValue("dept_uuid", fieldSet.getUUID()); + + if (null == userFs.getString("su34")) { + //宀椾綅uuid + staffsFs.setValue("job_post_uuid", 1); + //宀椾綅绛夌骇uuid + staffsFs.setValue("job_post_grade_uuid", 1); + } else { + //閫氳繃宀椾綅id鏌ヨ宀椾綅 + String su34 = userFs.getString("su34"); + FieldSetEntity fsePosts = baseDao.getFieldSetEntityByFilter("product_sys_job_posts", " sequence = ? ", new Integer[]{Integer.parseInt(su34)}, false); + if (fsePosts != null) { + staffsFs.setValue("job_post_uuid", fsePosts.getUUID()); + staffsFs.setValue("job_post_grade_uuid", fsePosts.getString("job_post_grades_uuid")); + } else { + throw new BaseException("鏈煡璇㈠埌宀椾綅", "鏈煡璇㈠埌宀椾綅"); + } + } + //su35鍏宠仈鏉冮檺id, 鍏宠仈澶氫釜閫楀彿鍒嗛殧 + String su35 = userFs.getString("su35"); + String[] su35s = null; + if (!BaseUtil.strIsNull(su35)) { + su35s = su35.split(","); + for (int j = 0; j < su35s.length; j++) { + FieldSetEntity fse = baseDao.getFieldSetEntityByFilter("product_sys_role", " sequence = ? ", new Integer[]{Integer.parseInt(su35s[j])}, false); + su35s[j] = fse.getUUID(); + } + } + //鐩村睘棰嗗 + String su40 = userFs.getString("su40"); + //涓虹┖灏辨斁绌� + if (BaseUtil.strIsNull(su40)) { + su40 = ""; + } else { + //澶氫釜鐩村睘棰嗗 灏卞彇绗竴涓� + if (su40.contains(",")) { + su40 = su40.substring(0, su40.indexOf(",")); + } + } + staffsFs.setValue("direct_leader_code", su40); + if (su35s != null) { + staffsFs.setValue("role_uuids", StringUtils.join(su35s, ",")); + } + //鍛樺伐涓婁笅绾х紪鐮� + staffsFs.setValue("leader_tricode", codeService.createFixCode(CmnConst.PRODUCT_SYS_STAFFS, CmnConst.LEADER_TRICODE, "")); + //鍛樺伐缂栫爜 鍛樺伐鍘熸湰id 瀛樹负缂栫爜 + staffsFs.setValue("tricode", codeService.createFixCode(CmnConst.PRODUCT_SYS_STAFFS, CmnConst.TRICODE, fieldSet.getString("org_level_code"))); + String su00 = userFs.getString("su00"); + staffsFs.setValue("sequence", su00); + staffsFs.setValue("remark", su00); + this.userAndTime(staffsFs); + baseDao.add(staffsFs); + staffsMap.put(su00, staffsFs); + } + //sql淇敼鐩村睘棰嗗 + baseDao.executeUpdate(" UPDATE product_sys_staffs a INNER JOIN product_sys_staffs b ON a.remark = b.direct_leader_code SET b.direct_leader_code = a.tricode "); + //寰幆鍚屾鐩村睘棰嗗, 鑻ユ湁涓や釜鐩村睘棰嗗 鍙彇绗竴涓� // for(String su00 : staffsMap.keySet()){ // FieldSetEntity staffsFs = staffsMap.get(su00); // //鑾峰彇鐩村睘棰嗗 @@ -687,242 +719,268 @@ // } // } // } - } + } - public String signatureAndThumbnail(String su,String clientUUID, String field){ - try { - String[] path = su.split("="); - String filePath = path[1]; - String fileName = StringUtils.isEmpty(filePath) ? "" : filePath.substring(filePath.lastIndexOf("/") + 1); - String newPath = this.TSPath + File.separator + fileName; - File isField = new File(newPath); - //濡傛灉宸茬粡鏈夎鏂囦欢 鏀瑰彉鏂囦欢鐩綍 - Integer fileNum = 0; - while (isField.exists()) { - fileNum++; - newPath = this.TSPath + fileNum + File.separator + fileName; - isField = new File(newPath); - } - //澶嶅埗鍒颁复鏃剁洰褰曚笅 - if (this.copyFile(filePath, newPath)) { - RequestParameterEntity rpe = new RequestParameterEntity(); - Map<String, File> fileMap = Maps.newHashMap(); - //閫氳繃璺緞鑾峰彇File - File file = new File(newPath); - //鏂囦欢鍚� 鏂囦欢file - fileMap.put(fileName, file); - FieldSetEntity fieldSet = new FieldSetEntity(); - FieldMetaEntity f = new FieldMetaEntity(); - f.setTableName(new String[]{"product_sys_users"}); - fieldSet.setMeta(f); - fieldSet.setValue(field, fileName); - fieldSet.setValue("~field_name~", field); - //鏀惧叆瀹㈡埛uuid - fieldSet.setValue("client_uuid", clientUUID); - rpe.setFiles(fileMap); - rpe.setFormData(fieldSet); - try { - FieldSetEntity fileFse = fileManagerService.uploadFile(rpe); - return fileFse.getString(field); - } catch (Exception e) { - e.getStackTrace(); - SpringMVCContextHolder.getSystemLogger().error(e); - } - } - }catch (Exception e){ - e.getStackTrace(); - } - return null; - } + public String signatureAndThumbnail(String su, String clientUUID, String field) { + try { + String[] path = su.split("="); + String filePath = path[1]; + String fileName = StringUtils.isEmpty(filePath) ? "" : filePath.substring(filePath.lastIndexOf("/") + 1); + String newPath = this.TSPath + File.separator + fileName; + File isField = new File(newPath); + //濡傛灉宸茬粡鏈夎鏂囦欢 鏀瑰彉鏂囦欢鐩綍 + Integer fileNum = 0; + while (isField.exists()) { + fileNum++; + newPath = this.TSPath + fileNum + File.separator + fileName; + isField = new File(newPath); + } + //澶嶅埗鍒颁复鏃剁洰褰曚笅 + if (this.copyFile(filePath, newPath)) { + RequestParameterEntity rpe = new RequestParameterEntity(); + Map<String, File> fileMap = Maps.newHashMap(); + //閫氳繃璺緞鑾峰彇File + File file = new File(newPath); + //鏂囦欢鍚� 鏂囦欢file + fileMap.put(fileName, file); + FieldSetEntity fieldSet = new FieldSetEntity(); + FieldMetaEntity f = new FieldMetaEntity(); + f.setTableName(new String[]{"product_sys_users"}); + fieldSet.setMeta(f); + fieldSet.setValue(field, fileName); + fieldSet.setValue("~field_name~", field); + //鏀惧叆瀹㈡埛uuid + fieldSet.setValue("client_uuid", clientUUID); + rpe.setFiles(fileMap); + rpe.setFormData(fieldSet); + try { + FieldSetEntity fileFse = fileManagerService.uploadFile(rpe); + return fileFse.getString(field); + } catch (Exception e) { + e.getStackTrace(); + SpringMVCContextHolder.getSystemLogger().error(e); + } + } + } catch (Exception e) { + e.getStackTrace(); + } + return null; + } - /** - * 娣诲姞宀椾綅 - */ - public void addPost(DataTableEntity data){ - DataTableEntity dataTableEntity = new DataTableEntity(); - dataTableEntity.getMeta().setTableName(new String[]{"product_sys_job_posts"}); - for (int i = 0; i < data.getRows(); i++) { - FieldSetEntity fieldSetEntity = data.getFieldSetEntity(i); - FieldSetEntity field = new FieldSetEntity(); - field.setTableName("product_sys_job_posts"); - field.setValue("is_used", 1); - field.setValue("job_post_name", fieldSetEntity.getString("sr01")); - field.setValue("job_post_description", fieldSetEntity.getString("sr02")); - //閫氳繃鍏ㄧО鑾峰彇鍗曚綅鍜岄儴闂╱uid - String org_level_all = fieldSetEntity.getString("asr03"); - FieldSetEntity fieldSetEntity1 = institutionMap.get(org_level_all); - //鍏徃uuid - String org_level_uuid = this.getSuperiorCompanyUuid(org_level_all); - field.setValue("org_level_uuid",org_level_uuid); - //鏈烘瀯绫诲瀷 0 鍏徃 1閮ㄩ棬 - String orgLevelType = fieldSetEntity1.getString("org_level_type"); - //鏌ヨ宀椾綅绛夌骇 - String sr15 = fieldSetEntity.getString("sr15"); - FieldSetEntity fieldSet = baseDao.getFieldSetEntityByFilter("product_sys_job_post_grades", " org_level_uuid = ? and job_grade_class = ? ", new String[]{org_level_uuid,sr15},false); - //宀椾綅绛夌骇 - String postGradesUuid = fieldSet.getUUID(); - field.setValue("job_post_grades_uuid", postGradesUuid); - //鎺掑簭鏆傛椂瀛樺矖浣峣d 鏂逛究浜哄憳鏌ヨ鍒板矖浣峣d - Integer sequence = fieldSetEntity.getInteger("sr00"); - field.setValue("sequence",sequence); - this.userAndTime(field); - String org_uuid = fieldSetEntity1.getUUID(); - String code = fieldSetEntity1.getString("org_level_code"); - //0涓哄叕鍙� 鑻ヤ负鍏徃灏卞垱寤哄涓浉鍚屽矖浣嶆潵鍏宠仈鍏徃涓嬫墍鏈夐儴闂� - if("0".equals(orgLevelType)){ - DataTableEntity dataTable = baseDao.listTable("product_sys_org_levels", " org_level_type = 1 and org_level_uuid = ? ", new String[]{org_uuid}); - if(!BaseUtil.dataTableIsEmpty(dataTable)) { - for (int j = 0; j < dataTable.getRows(); j++) { - field.setValue("dept_uuid",dataTable.getString(j, "uuid")); - field.remove("uuid"); - //閫氳繃鏂板鏂规硶娣诲姞宀椾綅 - String uuid = baseDao.add(field); - //娣诲姞宀椾綅涓庡矖浣嶇瓑绾у叧绯绘槧灏勬暟鎹〃 - FieldSetEntity postsAndClass = new FieldSetEntity(); - postsAndClass.setTableName("product_sys_job_posts_grades_mapping"); - //宀椾綅绛夌骇uuid - postsAndClass.setValue("job_grade_uuid", postGradesUuid); - //宀椾綅uuid - postsAndClass.setValue("job_post_uuid", uuid); - this.userAndTime(postsAndClass); - baseDao.add(postsAndClass); - } - }else { - //鍗曚綅涓嬭嫢娌℃湁閮ㄩ棬 鍒涘缓涓�涓櫄鎷熼儴闂� - FieldSetEntity departmentFse = new FieldSetEntity(); - departmentFse.setTableName("product_sys_org_levels"); - //閮ㄩ棬鍚嶇О - departmentFse.setValue("sg01", fieldSetEntity1.getString("org_level_name") + "涓嬮儴闂�"); - //閮ㄩ棬缂栫爜 - departmentFse.setValue("sg10", fieldSetEntity1.getString("org_level_shortcode") + "01"); - //鎺掑簭 - departmentFse.setValue("sg00", fieldSetEntity1.getString("sequence") + "01"); - //淇濆瓨鍚庣殑閮ㄩ棬 - FieldSetEntity newDeptFse = this.addDepartment(departmentFse,code,org_uuid); - //鏀惧叆閮ㄩ棬uuid - field.setValue("dept_uuid",newDeptFse.getUUID()); - //閫氳繃鏂板鏂规硶娣诲姞宀椾綅 - String uuid = baseDao.add(field); - //娣诲姞宀椾綅涓庡矖浣嶇瓑绾у叧绯绘槧灏勬暟鎹〃 - FieldSetEntity postsAndClass = new FieldSetEntity(); - postsAndClass.setTableName("product_sys_job_posts_grades_mapping"); - //宀椾綅绛夌骇uuid - postsAndClass.setValue("job_grade_uuid", postGradesUuid); - //宀椾綅uuid - postsAndClass.setValue("job_post_uuid", uuid); - this.userAndTime(postsAndClass); - baseDao.add(postsAndClass); - } - //1涓洪儴闂� - }else{ - field.setValue("dept_uuid",org_uuid); - //閫氳繃鏂板鏂规硶娣诲姞宀椾綅 - String uuid = baseDao.add(field); - //娣诲姞宀椾綅涓庡矖浣嶇瓑绾у叧绯绘槧灏勬暟鎹〃 - FieldSetEntity postsAndClass = new FieldSetEntity(); - postsAndClass.setTableName("product_sys_job_posts_grades_mapping"); - //宀椾綅绛夌骇uuid - postsAndClass.setValue("job_grade_uuid", postGradesUuid); - //宀椾綅uuid - postsAndClass.setValue("job_post_uuid", uuid); - this.userAndTime(postsAndClass); - baseDao.add(postsAndClass); - } - } - } + /** + * 娣诲姞宀椾綅 + */ + public void addPost(DataTableEntity data) { + DataTableEntity dataTableEntity = new DataTableEntity(); + dataTableEntity.getMeta().setTableName(new String[]{"product_sys_job_posts"}); + for (int i = 0; i < data.getRows(); i++) { + FieldSetEntity fieldSetEntity = data.getFieldSetEntity(i); + FieldSetEntity field = new FieldSetEntity(); + field.setTableName("product_sys_job_posts"); + field.setValue("is_used", 1); + field.setValue("job_post_name", fieldSetEntity.getString("sr01")); + field.setValue("job_post_description", fieldSetEntity.getString("sr02")); + //閫氳繃鍏ㄧО鑾峰彇鍗曚綅鍜岄儴闂╱uid + String org_level_all = fieldSetEntity.getString("asr03"); + FieldSetEntity fieldSetEntity1 = institutionMap.get(org_level_all); + //鍏徃uuid + String org_level_uuid = this.getSuperiorCompanyUuid(org_level_all); + field.setValue("org_level_uuid", org_level_uuid); + //鍒ゆ柇绯荤粺涓槸鍚︽湁璇ヨ鑹� - /** - * 娣诲姞鍒涘缓浜哄拰鍒涘缓鏃堕棿 - * @param fieldSetEntity - */ - public void userAndTime(FieldSetEntity fieldSetEntity){ - fieldSetEntity.setValue("created_by",SpringMVCContextHolder.getCurrentUserId()); - fieldSetEntity.setValue("created_utc_datetime",new Date()); - } - /** - * 娣诲姞宀椾綅绛夌骇 - */ - public void postGrades(DataTableEntity data){ - //鍏徃uuid 宀椾綅灞傜骇闆� - Map<String,String> postHierarchyMap = Maps.newHashMap(); - //閫氳繃鍏徃uuid鏉ュ垝鍒嗗矖浣嶇瓑绾� - for (int i = 0; i < data.getRows(); i++) { - FieldSetEntity fieldSetEntity = data.getFieldSetEntity(i); - FieldSetEntity field = new FieldSetEntity(); - field.setTableName("product_sys_job_post_grades"); - //宀椾綅灞傜骇 瓒婂皬绛夌骇瓒婂ぇ - String sr15 = fieldSetEntity.getString("sr15"); - //杞崲鍚庨儴闂ㄦ垨鍏徃鍏ㄧО - String dcName = fieldSetEntity.getString("asr03"); - //鑾峰彇鍏徃鐨剈uid - String companyUuid = this.getSuperiorCompanyUuid(dcName); - String value = postHierarchyMap.get(companyUuid); - if(!BaseUtil.strIsNull(value)){ - if(value.contains(sr15)) { - continue; - }else { - postHierarchyMap.put(companyUuid, value+","+sr15); - } - }else { - postHierarchyMap.put(companyUuid, sr15); - } - FieldSetEntity levelsSet = baseDao.getFieldSetEntity("product_sys_org_levels",companyUuid,false); - //鍏徃鍚嶇О - String levelName = levelsSet.getString("org_level_name"); - //涓婄骇鍏徃uuid - field.setValue("org_level_uuid",companyUuid); - //宀椾綅绛夌骇 - field.setValue("job_grade_class", sr15); - field.setValue("is_used", 1); - //鍚嶇О - field.setValue("job_grade_name",sr15+"绾у矖浣�"); - //绾у埆鐭紪鐮� - field.setValue("job_grade_shortcode", sr15); - //璇存槑 - field.setValue("remark", levelName+"涓嬬殑"+sr15+"绾у矖浣�"); - field.setValue("sequence", sr15); - this.userAndTime(field); - baseDao.add(field); - } - } - /** 澶嶅埗鍗曚釜鏂囦欢 - * @param oldPath String 鍘熸枃浠惰矾寰� 濡傦細c:/fqf.txt - * @param newPath String 澶嶅埗鍚庤矾寰� 濡傦細f:/fqf.txt - * @return boolean - */ - public Boolean copyFile(String oldPath, String newPath) { - Boolean status = false; - try { - BufferedInputStream in = FileUtil.getInputStream(oldPath); - BufferedOutputStream out = FileUtil.getOutputStream(newPath); - IoUtil.copy(in, out, IoUtil.DEFAULT_BUFFER_SIZE); - status = true; - out.close(); - in.close(); - }catch (Exception e){ - e.getStackTrace(); - }finally { - return status; - } - } - /** 鍒犻櫎鍗曚釜鏂囦欢 - * @param fileName 琚垹闄ゆ枃浠剁殑鏂囦欢鍚� - * @return 鍗曚釜鏂囦欢鍒犻櫎鎴愬姛杩斿洖true,鍚﹀垯杩斿洖false - */ - public Boolean deleteFile(String fileName){ - File file = new File(fileName); - if(file.isFile()){ - file.delete(); - System.out.println("鍒犻櫎鍗曚釜鏂囦欢"+fileName+"鎴愬姛锛�"); - return true; - }else{ - System.out.println("鍒犻櫎鍗曚釜鏂囦欢"+fileName+"澶辫触锛�"); - return false; - } - } + //鏈烘瀯绫诲瀷 0 鍏徃 1閮ㄩ棬 + String orgLevelType = fieldSetEntity1.getString("org_level_type"); + //鏌ヨ宀椾綅绛夌骇 + String sr15 = fieldSetEntity.getString("sr15"); + FieldSetEntity fieldSet = baseDao.getFieldSetEntityByFilter("product_sys_job_post_grades", " org_level_uuid = ? and job_grade_class = ? ", new String[]{org_level_uuid, sr15}, false); + //宀椾綅绛夌骇 + String postGradesUuid = fieldSet.getUUID(); + field.setValue("job_post_grades_uuid", postGradesUuid); + //鎺掑簭鏆傛椂瀛樺矖浣峣d 鏂逛究浜哄憳鏌ヨ鍒板矖浣峣d + Integer sequence = fieldSetEntity.getInteger("sr00"); + field.setValue("sequence", sequence); + this.userAndTime(field); + String org_uuid = fieldSetEntity1.getUUID(); + String code = fieldSetEntity1.getString("org_level_code"); + //0涓哄叕鍙� 鑻ヤ负鍏徃灏卞垱寤哄涓浉鍚屽矖浣嶆潵鍏宠仈鍏徃涓嬫墍鏈夐儴闂� + if ("0".equals(orgLevelType)) { + DataTableEntity dataTable = baseDao.listTable("product_sys_org_levels", " org_level_type = 1 and org_level_uuid = ? ", new String[]{org_uuid}); + if (!BaseUtil.dataTableIsEmpty(dataTable)) { + for (int j = 0; j < dataTable.getRows(); j++) { + field.setValue("dept_uuid", dataTable.getString(j, "uuid")); + field.remove("uuid"); + FieldSetEntity fieldSetByFilter = baseDao.getFieldSetByFilter("product_sys_job_posts", " job_post_name = ? and org_level_uuid = ? and dept_uuid=?", new String[]{fieldSetEntity.getString("sr01"), org_level_uuid, field.getString("dept_uuid")}, false); + if (fieldSetByFilter != null && !StringUtils.isEmpty(fieldSetByFilter.getUUID())) { + continue; + } + //閫氳繃鏂板鏂规硶娣诲姞宀椾綅 + String uuid = baseDao.add(field); + //娣诲姞宀椾綅涓庡矖浣嶇瓑绾у叧绯绘槧灏勬暟鎹〃 + FieldSetEntity postsAndClass = new FieldSetEntity(); + postsAndClass.setTableName("product_sys_job_posts_grades_mapping"); + //宀椾綅绛夌骇uuid + postsAndClass.setValue("job_grade_uuid", postGradesUuid); + //宀椾綅uuid + postsAndClass.setValue("job_post_uuid", uuid); + this.userAndTime(postsAndClass); + baseDao.add(postsAndClass); + } + } else { + //鍗曚綅涓嬭嫢娌℃湁閮ㄩ棬 鍒涘缓涓�涓櫄鎷熼儴闂� + String orgLevelName = fieldSetEntity1.getString("org_level_name") + "涓嬮儴闂�"; + FieldSetEntity newDeptFse = baseDao.getFieldSetByFilter("product_sys_org_levels", "org_level_name = ? and org_level_type = 1 and org_level_uuid = ?", new String[]{orgLevelName, org_uuid}, false); + if (FieldSetEntity.isEmpty(newDeptFse)) { + FieldSetEntity departmentFse = new FieldSetEntity(); + departmentFse.setTableName("product_sys_org_levels"); + //閮ㄩ棬鍚嶇О + departmentFse.setValue("sg01", fieldSetEntity1.getString("org_level_name") + "涓嬮儴闂�"); + //閮ㄩ棬缂栫爜 + departmentFse.setValue("sg10", fieldSetEntity1.getString("org_level_shortcode") + "01"); + //鎺掑簭 + departmentFse.setValue("sg00", fieldSetEntity1.getString("sequence") + "01"); + //淇濆瓨鍚庣殑閮ㄩ棬 + newDeptFse = this.addDepartment(departmentFse, code, org_uuid); + } + //鏀惧叆閮ㄩ棬uuid + field.setValue("dept_uuid", newDeptFse.getUUID()); + FieldSetEntity fieldSetByFilter = baseDao.getFieldSetByFilter("product_sys_job_posts", " job_post_name = ? and org_level_uuid = ? and dept_uuid=?", new String[]{fieldSetEntity.getString("sr01"), org_level_uuid, field.getString("dept_uuid")}, false); + if (fieldSetByFilter != null && !StringUtils.isEmpty(fieldSetByFilter.getUUID())) { + continue; + } + //閫氳繃鏂板鏂规硶娣诲姞宀椾綅 + String uuid = baseDao.add(field); + //娣诲姞宀椾綅涓庡矖浣嶇瓑绾у叧绯绘槧灏勬暟鎹〃 + FieldSetEntity postsAndClass = new FieldSetEntity(); + postsAndClass.setTableName("product_sys_job_posts_grades_mapping"); + //宀椾綅绛夌骇uuid + postsAndClass.setValue("job_grade_uuid", postGradesUuid); + //宀椾綅uuid + postsAndClass.setValue("job_post_uuid", uuid); + this.userAndTime(postsAndClass); + baseDao.add(postsAndClass); + } + //1涓洪儴闂� + } else { + field.setValue("dept_uuid", org_uuid); + FieldSetEntity fieldSetByFilter = baseDao.getFieldSetByFilter("product_sys_job_posts", " job_post_name = ? and org_level_uuid = ? and dept_uuid=?", new String[]{fieldSetEntity.getString("sr01"), org_level_uuid, field.getString("dept_uuid")}, false); + if (fieldSetByFilter != null && !StringUtils.isEmpty(fieldSetByFilter.getUUID())) { + continue; + } + //閫氳繃鏂板鏂规硶娣诲姞宀椾綅 + String uuid = baseDao.add(field); + //娣诲姞宀椾綅涓庡矖浣嶇瓑绾у叧绯绘槧灏勬暟鎹〃 + FieldSetEntity postsAndClass = new FieldSetEntity(); + postsAndClass.setTableName("product_sys_job_posts_grades_mapping"); + //宀椾綅绛夌骇uuid + postsAndClass.setValue("job_grade_uuid", postGradesUuid); + //宀椾綅uuid + postsAndClass.setValue("job_post_uuid", uuid); + this.userAndTime(postsAndClass); + baseDao.add(postsAndClass); + } + } + } - public static void main(String[] args) { + /** + * 娣诲姞鍒涘缓浜哄拰鍒涘缓鏃堕棿 + * + * @param fieldSetEntity + */ + public void userAndTime(FieldSetEntity fieldSetEntity) { + fieldSetEntity.setValue("created_by", SpringMVCContextHolder.getCurrentUserId()); + fieldSetEntity.setValue("created_utc_datetime", new Date()); + } + + /** + * 娣诲姞宀椾綅绛夌骇 + */ + public void postGrades(DataTableEntity data) { + //鍏徃uuid 宀椾綅灞傜骇闆� + Map<String, String> postHierarchyMap = Maps.newHashMap(); + //閫氳繃鍏徃uuid鏉ュ垝鍒嗗矖浣嶇瓑绾� + for (int i = 0; i < data.getRows(); i++) { + FieldSetEntity fieldSetEntity = data.getFieldSetEntity(i); + FieldSetEntity field = new FieldSetEntity(); + field.setTableName("product_sys_job_post_grades"); + //宀椾綅灞傜骇 瓒婂皬绛夌骇瓒婂ぇ + String sr15 = fieldSetEntity.getString("sr15"); + //杞崲鍚庨儴闂ㄦ垨鍏徃鍏ㄧО + String dcName = fieldSetEntity.getString("asr03"); + //鑾峰彇鍏徃鐨剈uid + String companyUuid = this.getSuperiorCompanyUuid(dcName); + String value = postHierarchyMap.get(companyUuid); + if (!BaseUtil.strIsNull(value)) { + if (value.contains(sr15)) { + continue; + } else { + postHierarchyMap.put(companyUuid, value + "," + sr15); + } + } else { + postHierarchyMap.put(companyUuid, sr15); + } + FieldSetEntity levelsSet = baseDao.getFieldSetEntity("product_sys_org_levels", companyUuid, false); + //鍏徃鍚嶇О + String levelName = levelsSet.getString("org_level_name"); + //涓婄骇鍏徃uuid + field.setValue("org_level_uuid", companyUuid); + //宀椾綅绛夌骇 + field.setValue("job_grade_class", sr15); + field.setValue("is_used", 1); + //鍚嶇О + field.setValue("job_grade_name", sr15 + "绾у矖浣�"); + //绾у埆鐭紪鐮� + field.setValue("job_grade_shortcode", sr15); + //璇存槑 + field.setValue("remark", levelName + "涓嬬殑" + sr15 + "绾у矖浣�"); + field.setValue("sequence", sr15); + this.userAndTime(field); + baseDao.add(field); + } + } + + /** + * 澶嶅埗鍗曚釜鏂囦欢 + * + * @param oldPath String 鍘熸枃浠惰矾寰� 濡傦細c:/fqf.txt + * @param newPath String 澶嶅埗鍚庤矾寰� 濡傦細f:/fqf.txt + * @return boolean + */ + public Boolean copyFile(String oldPath, String newPath) { + Boolean status = false; + try { + BufferedInputStream in = FileUtil.getInputStream(oldPath); + BufferedOutputStream out = FileUtil.getOutputStream(newPath); + IoUtil.copy(in, out, IoUtil.DEFAULT_BUFFER_SIZE); + status = true; + out.close(); + in.close(); + } catch (Exception e) { + e.getStackTrace(); + } finally { + return status; + } + } + + /** + * 鍒犻櫎鍗曚釜鏂囦欢 + * + * @param fileName 琚垹闄ゆ枃浠剁殑鏂囦欢鍚� + * @return 鍗曚釜鏂囦欢鍒犻櫎鎴愬姛杩斿洖true, 鍚﹀垯杩斿洖false + */ + public Boolean deleteFile(String fileName) { + File file = new File(fileName); + if (file.isFile()) { + file.delete(); + System.out.println("鍒犻櫎鍗曚釜鏂囦欢" + fileName + "鎴愬姛锛�"); + return true; + } else { + System.out.println("鍒犻櫎鍗曚釜鏂囦欢" + fileName + "澶辫触锛�"); + return false; + } + } + + public static void main(String[] args) { // File file = new File("D:\\filePackage\\瑗垮畞甯備綇鎴夸繚闅滃拰鎴垮眿绠$悊灞�闇�姹傛暣鐞哣1.0.docx"); // File file2 = new File("D:\\filePackage\\瑗垮畞甯備綇鎴夸繚闅滃拰鎴垮眿绠$悊.docx"); // System.out.println(file.exists()); @@ -930,88 +988,85 @@ // FeDataDSService feDataDSService = new FeDataDSService(); // feDataDSService.copyFile("D:\\OA\\FEGOV\\Media\\2021\\12\\15\\20211215401901\\1`FE#ENC#DA126AF35BB8E57F55C2429BDF7DC7240DF6CC6E227B0B8E", "D:\\filePackage\\????????????????????????.doc"); // feDataDSService.getFilesFolder("D:\\OA\\FEGOV\\Media\\2021\\12\\15\\20211215401901"); - } + } - /** - * 鑾峰彇鏂囦欢鍚嶇О 鏈�鏂颁慨鏀规椂闂� map - * @param path - * @return - */ - public Map<String, String> getFilesFolder(String path){ - File file = new File(path); //鑾峰彇鍏秄ile瀵硅薄 - File[] fs = file.listFiles(); - if(fs == null){ - logger.info("鏈壘鍒伴檮浠剁洿鎺ヨ繑鍥瀗ull"); - return null; - } - Map<String, String> fileTimeName = Maps.newHashMap(); - for(File f:fs) - { - if(f.isFile()) - { - String fileName = f.toString().replace(path+"\\",""); - fileTimeName.put(this.set_fileInfo(f.toString()),fileName); - } - } - return fileTimeName; - } + /** + * 鑾峰彇鏂囦欢鍚嶇О 鏈�鏂颁慨鏀规椂闂� map + * + * @param path + * @return + */ + public Map<String, String> getFilesFolder(String path) { + File file = new File(path); //鑾峰彇鍏秄ile瀵硅薄 + File[] fs = file.listFiles(); + if (fs == null) { + logger.info("鏈壘鍒伴檮浠剁洿鎺ヨ繑鍥瀗ull"); + return null; + } + Map<String, String> fileTimeName = Maps.newHashMap(); + for (File f : fs) { + if (f.isFile()) { + String fileName = f.toString().replace(path + "\\", ""); + fileTimeName.put(this.set_fileInfo(f.toString()), fileName); + } + } + return fileTimeName; + } - /** - * 鑾峰彇鏂囦欢鏈�杩戜慨鏀规椂闂� - * @param file_name 鏂囦欢鍏ㄨ矾寰� - * @return - */ - public String set_fileInfo(String file_name) - { - Path path = Paths.get(file_name); - BasicFileAttributeView basicview = Files.getFileAttributeView(path, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS); - BasicFileAttributes attr; - String time = null; - try - { + /** + * 鑾峰彇鏂囦欢鏈�杩戜慨鏀规椂闂� + * + * @param file_name 鏂囦欢鍏ㄨ矾寰� + * @return + */ + public String set_fileInfo(String file_name) { + Path path = Paths.get(file_name); + BasicFileAttributeView basicview = Files.getFileAttributeView(path, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS); + BasicFileAttributes attr; + String time = null; + try { - attr = basicview.readAttributes(); - //鍒涘缓鏃堕棿 - Date CreateTimeDate= new Date(attr.creationTime().toMillis()); - //涓婃淇敼鏃堕棿 * - Date lastmodfiyTimeDate=new Date(attr.lastModifiedTime().toMillis()); - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - time = df.format(lastmodfiyTimeDate); - } catch (Exception e) - { - e.printStackTrace(); - } - return time; - } + attr = basicview.readAttributes(); + //鍒涘缓鏃堕棿 + Date CreateTimeDate = new Date(attr.creationTime().toMillis()); + //涓婃淇敼鏃堕棿 * + Date lastmodfiyTimeDate = new Date(attr.lastModifiedTime().toMillis()); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + time = df.format(lastmodfiyTimeDate); + } catch (Exception e) { + e.printStackTrace(); + } + return time; + } - public void clearJobList(){ - DataTableEntity dataTableEntity = baseDao.listTable("product_sys_flow_node"," default_posts is not null AND default_posts != '' ",new String[]{}); - for (int i = 0; i < dataTableEntity.getRows(); i++) { - FieldSetEntity fse = dataTableEntity.getFieldSetEntity(i); - String default_posts = fse.getString("default_posts"); - if(!BaseUtil.strIsNull(default_posts)){ - String[] postUuids = default_posts.split(","); - Set<String> postSet = Sets.newHashSet(); + public void clearJobList() { + DataTableEntity dataTableEntity = baseDao.listTable("product_sys_flow_node", " default_posts is not null AND default_posts != '' ", new String[]{}); + for (int i = 0; i < dataTableEntity.getRows(); i++) { + FieldSetEntity fse = dataTableEntity.getFieldSetEntity(i); + String default_posts = fse.getString("default_posts"); + if (!BaseUtil.strIsNull(default_posts)) { + String[] postUuids = default_posts.split(","); + Set<String> postSet = Sets.newHashSet(); // Set<String> postSet = Arrays.stream(postUuids).collect(Collectors.toSet()); - for (int j = 0; j < postUuids.length; j++) { - DataTableEntity staffsData = baseDao.listTable("product_sys_staffs"," job_post_uuid = ? ",new String[]{postUuids[j]}); - //鏈変汉灏变繚鐣欏矖浣島uid - if(!BaseUtil.dataTableIsEmpty(staffsData)){ - postSet.add(postUuids[j]); - } - } - if(postSet.size() > 0){ - fse.setValue("default_posts", StringUtils.join(postSet, ",")); - }else { - fse.setValue("default_posts", null); - } - baseDao.update(fse); - } - } - //娓呯┖澶氫綑鐨勫矖浣嶆暟鎹� - baseDao.executeUpdate("DELETE FROM product_sys_job_posts WHERE uuid not in (SELECT job_post_uuid FROM product_sys_staffs);"); - //宀椾綅鍏宠仈 - baseDao.executeUpdate("DELETE FROM product_sys_job_posts_grades_mapping WHERE job_post_uuid not in (SELECT job_post_uuid FROM product_sys_staffs);"); - } + for (int j = 0; j < postUuids.length; j++) { + DataTableEntity staffsData = baseDao.listTable("product_sys_staffs", " job_post_uuid = ? ", new String[]{postUuids[j]}); + //鏈変汉灏变繚鐣欏矖浣島uid + if (!BaseUtil.dataTableIsEmpty(staffsData)) { + postSet.add(postUuids[j]); + } + } + if (postSet.size() > 0) { + fse.setValue("default_posts", StringUtils.join(postSet, ",")); + } else { + fse.setValue("default_posts", null); + } + baseDao.update(fse); + } + } + //娓呯┖澶氫綑鐨勫矖浣嶆暟鎹� + baseDao.executeUpdate("DELETE FROM product_sys_job_posts WHERE uuid not in (SELECT job_post_uuid FROM product_sys_staffs);"); + //宀椾綅鍏宠仈 + baseDao.executeUpdate("DELETE FROM product_sys_job_posts_grades_mapping WHERE job_post_uuid not in (SELECT job_post_uuid FROM product_sys_staffs);"); + } } -- Gitblit v1.9.2