许鹏程
2024-05-28 e6720f333268682d11aedb3b3308fa2f2c3a40df
commit
已添加1个文件
已修改4个文件
2579 ■■■■■ 文件已修改
product-server-data-sync/src/main/java/com/product/data/sync/controller/SyFeDataController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
product-server-data-sync/src/main/java/com/product/data/sync/service/FeDataDSService.java 1793 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
product-server-data-sync/src/main/java/com/product/data/sync/service/SyFeDataService.java 63 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
product-server-data-sync/src/main/java/com/product/data/sync/util/BatchAddData.java 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
product-server-data-sync/src/main/java/com/product/data/sync/util/BusinessDataSync.java 646 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
product-server-data-sync/src/main/java/com/product/data/sync/controller/SyFeDataController.java
@@ -50,8 +50,10 @@
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            String uuid = syFeDataService.saveSyncFedata(fse);
            return OK();
        } catch (BaseException e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(e);
        } catch (Exception e) {
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;
    //公司和部门map   key ä¸ºå…¬å¸æˆ–部门全称
    Map<String, FieldSetEntity> institutionMap = Maps.newHashMap();
    public Connection getJDBC() throws SQLException, ClassNotFoundException {
        //获取jdbc连接
    private Integer sort = 0;
    //公司和部门map   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;
    }
    /**
     *     åˆå§‹åŒ–客户及客户角色(修改客户为FE的客户名称)
     * @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) {
    /**
     * åˆå§‹åŒ–客户及客户角色(修改客户为FE的客户名称)
     *
     * @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)user_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");
            //用户表id
            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)user_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");
            //用户表id
            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"));
            //通过全称获取单位和部门uuid
            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);
            //排序暂时存岗位id  æ–¹ä¾¿äººå‘˜æŸ¥è¯¢åˆ°å²—位id
            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"));
            //通过全称获取单位和部门uuid
            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");
            //获取公司的uuid
            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);
            //排序暂时存岗位id  æ–¹ä¾¿äººå‘˜æŸ¥è¯¢åˆ°å²—位id
            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");
            //获取公司的uuid
            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\\西宁市住房保障和房屋管理局需求整理V1.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);        //获取其file对象
        File[] fs = file.listFiles();
        if(fs == null){
            logger.info("未找到附件直接返回null");
            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);        //获取其file对象
        File[] fs = file.listFiles();
        if (fs == null) {
            logger.info("未找到附件直接返回null");
            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]});
                 //有人就保留岗位uuid
                   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]});
                    //有人就保留岗位uuid
                    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);");
    }
}
product-server-data-sync/src/main/java/com/product/data/sync/service/SyFeDataService.java
@@ -23,6 +23,7 @@
import com.product.data.sync.config.SystemCode;
import com.product.data.sync.service.ide.ISyFeDataService;
import com.product.data.sync.service.media.GdMediaUtil;
import com.product.data.sync.util.BatchAddData;
import com.product.data.sync.util.BusinessDataSync;
import com.product.data.sync.util.DataManipulationUtils;
import com.product.file.service.FileManagerService;
@@ -101,6 +102,8 @@
    //已同步表结构
    private JSONObject dataTableObject = new JSONObject();
    @Autowired
    private BatchAddData batchAddData;
    public Boolean isStr(String str) {
        boolean a = false;
@@ -112,22 +115,28 @@
        return a;
    }
    private Set<String> clearTable = new HashSet<>();
    //公告管理1  ç³»ç»Ÿå‚æ•°  é—®å·ç®¡ç†  è€ƒå‹¤ç®¡ç†  è½¦è¾†ç®¡ç†  ååŒåŠžå…¬
    @Override
    public String saveSyncFedata(FieldSetEntity fs) throws SQLException, ClassNotFoundException {
        //同步组织架构
        DataTableEntity dataTableEntity = baseDao.listTable("product_sys_users");
        String clientUUID = "remark";
        if (dataTableEntity.getRows() < 10) {
        String clientUUID = "4d4679ed-c4c3-41b8-abfe-451a66fd4043";
//        if (dataTableEntity.getRows() < 10) {
//            //迁移组织架构
//            String uuid = feDataDSService.FEDataMigration();
//            if (!BaseUtil.strIsNull(uuid)) {
//                clientUUID = uuid;
//            }
        String uuid = feDataDSService.FEDataMigration();
        if (!BaseUtil.strIsNull(uuid)) {
            clientUUID = uuid;
        }
//        }
        //封装两边人员关联和部门关联
//        packageDepartmentPersonnel();
        packageDepartmentPersonnel();
        String tricode_fun = Global.getSystemConfig("data.synchronism.function", "").replaceAll(" ", "");
        if (StringUtils.isEmpty(tricode_fun)) {
            tricode_fun = fs.getString("function_code");
        }
        if (BaseUtil.strIsNull(tricode_fun)) {
            return null;
        }
@@ -227,8 +236,8 @@
                //过滤arr中的null并转为字符串用逗号分隔
                defaultPosts = Arrays.stream(arr).filter(Objects::nonNull).collect(Collectors.joining(","));
            }
            if(!StringUtils.isEmpty(defaultUsers)){
                arr=defaultUsers.split(",");
            if (!StringUtils.isEmpty(defaultUsers)) {
                arr = defaultUsers.split(",");
                for (int j = 0; j < arr.length; j++) {
                    String uid = arr[j];
                    String uuid = userMapping.get(uid);
@@ -246,6 +255,7 @@
            node.setValue("default_depts", defaultDepts);
        }
        baseDao.update(nodes);
    }
@@ -254,18 +264,25 @@
//        String[] tricode_funs = fs.getString("tricode_fun").split(",");
        //封装本产品需赋权限的按钮uuid
//        this.packageButton();
//        Connection conn = functionSynchrService.getConnection(fs);
//        ConnectionInterface conn = functionSynchrService.getConnection(fs);
        //通过线程循环添加功能信息
        ExecutorService exec = Executors.newCachedThreadPool();
        List<Set<String>> clearAttachmentSets = new ArrayList<>();
        for (int i = 0; i < tricode_funs.length; i++) {
            //获取jdbc连接
            BusinessDataSync async = new BusinessDataSync(tricode_funs[i]);
            async.setBaseDao(baseDao);
            async.setClearTable(clearTable);
            async.setFileManagerService(fileManagerService);
            async.setSystemMenusService(systemMenusService);
            async.setFeDataDSService(feDataDSService);
            async.setGdMediaUtil(gdMediaUtil);
            async.setClientUUID(clientUUID);
            async.setBatchAddData(batchAddData);
            Set<String> clearAttachment = async.getClearAttachment();
            if (clearAttachment != null) {
                clearAttachmentSets.add(clearAttachment);
            }
            Thread t = new Thread(async);
            //调用线程run方法
            exec.submit(t);
@@ -310,6 +327,7 @@
            }
        }
        systemMenusService.initSystemMenu();
        //同步
        System.out.println("=================同步成功===============");
        return "OK";
@@ -2424,7 +2442,7 @@
            //同步消息
            try {
                this.synchronizingProcessMessages(conn, tricode_funs, stateMap);
            } catch (BaseException e) {
            } catch (Exception e) {
                e.printStackTrace();
            }
            //源数据id ä¸Ž æœ¬æ•°æ®uuid å…³è”
@@ -2779,7 +2797,7 @@
    /**
     * åŒæ­¥æµç¨‹æ¶ˆæ¯è¡¨
     */
    public void synchronizingProcessMessages(Connection conn, String tricode_funs, Map<String, String> stateMap) throws SQLException {
    public void synchronizingProcessMessages(Connection conn, String tricode_funs, Map<String, String> stateMap) throws Exception {
        DataTableEntity OrlDt = null;
        try {
            StringBuffer sql = new StringBuffer();
@@ -2795,6 +2813,8 @@
        String id = null;
        String message_uuid = null;
        String state = null;
        DataTableEntity dt = new DataTableEntity();
        DataTableEntity dt1 = new DataTableEntity();
        for (int i = 0; i < OrlDt.getRows(); i++) {
            FieldSetEntity fs = OrlDt.getFieldSetEntity(i);
            //流程节点id
@@ -2853,7 +2873,10 @@
                } else if ("2".equals(state)) {
                    message.setValue("url", "1621321824686868oKWL726?uuid=" + source_uuid);
                }
                message_uuid = baseDao.add(message);
                message_uuid = UUID.randomUUID().toString();
                message.setValue("uuid", message_uuid);
                dt1.addFieldSetEntity(message);
            }
            FieldSetEntity message_user = new FieldSetEntity();
@@ -2884,8 +2907,20 @@
                }
            }
            message_user.setValue("user_id", user_id);
            baseDao.add(message_user);
//            baseDao.add(message_user);
            dt.addFieldSetEntity(message_user);
            if (dt1.getRows() > 50000) {
                batchAddData.add(dt1);
                dt1 = new DataTableEntity();
            }
            if (dt.getRows() > 50000) {
                batchAddData.add(dt);
                dt = new DataTableEntity();
            }
        }
        batchAddData.add(dt1);
        batchAddData.add(dt);
    }
product-server-data-sync/src/main/java/com/product/data/sync/util/BatchAddData.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,75 @@
package com.product.data.sync.util;
import cn.hutool.core.lang.UUID;
import com.product.common.lang.StringUtils;
import com.product.core.cache.DataPoolCacheImpl;
import com.product.core.connection.ConnectionManager;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldMetaEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.datasource.dao.Dao;
import com.product.datasource.dao.impl.MysqlDaoImpl;
import com.product.util.BaseUtil;
import org.springframework.stereotype.Service;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
public class BatchAddData {
    public void add(DataTableEntity dt) throws Exception {
        Dao dao = new MysqlDaoImpl(() -> ConnectionManager.getConnection());
        if (DataTableEntity.isEmpty(dt)) {
            return;
        }
        FieldMetaEntity meta = dt.getMeta();
        String tableName = dt.getTableName().toString();
        //在缓存表中获取该表的所有字段
//        DataPoolCacheImpl.getInstance().getCacheData("")
        FieldSetEntity tableMeta = BaseUtil.getSingleInfoByCache("所有表信息", new String[]{tableName});
        String tableUuid = tableMeta.getString("uuid");
        //表字段
        DataTableEntity fieldTableMeta = DataPoolCacheImpl.getInstance().getCacheData("所有字段信息并按表分组", new String[]{tableUuid});
        List<String> fields = new ArrayList<>();
        for (int i = 0; i < fieldTableMeta.getRows(); i++) {
            FieldSetEntity fieldMeta = fieldTableMeta.getFieldSetEntity(i);
            String fieldType = fieldMeta.getString("field_type");
            String fieldName = fieldMeta.getString("field_name");
            if (!"pk".equalsIgnoreCase(fieldType)) {
                fields.add(fieldName);
            }
        }
        DataTableEntity addDt = new DataTableEntity();
        List<DataTableEntity> addDtList = new ArrayList<>();
        for (int i = 0; i < dt.getRows(); i++) {
            if(FieldSetEntity.isEmpty(dt.getFieldSetEntity(i))){
                continue;
            }
            if (i == 5000) {
                addDtList.add(addDt);
                addDt = new DataTableEntity();
            }
            FieldSetEntity ff = new FieldSetEntity(tableName);
            for (String field : fields) {
                ff.setValue(field, dt.getObject(i, field));
            }
            if (StringUtils.isEmpty(ff.getString("uuid"))) {
                ff.setValue("uuid", UUID.randomUUID().toString());
                dt.setFieldValue(i, "uuid", ff.getString("uuid"));
            }
            addDt.addFieldSetEntity(ff);
        }
        addDtList.add(addDt);
        for (DataTableEntity dataTableEntity : addDtList) {
            dao.addBatch(dataTableEntity);
        }
        dao.closeConnection();
    }
}
product-server-data-sync/src/main/java/com/product/data/sync/util/BusinessDataSync.java
@@ -1,6 +1,8 @@
package com.product.data.sync.util;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
@@ -8,6 +10,8 @@
import com.google.common.collect.Sets;
import com.product.admin.service.SystemMenusService;
import com.product.common.lang.StringUtils;
import com.product.core.cache.DataPoolCacheImpl;
import com.product.core.cache.DataPoolRefreshCache;
import com.product.core.config.Global;
import com.product.core.connection.ConnectionManager;
import com.product.core.dao.BaseDao;
@@ -36,6 +40,8 @@
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
 * Copyright LX
@@ -48,8 +54,9 @@
 */
public class BusinessDataSync extends AbstractBaseService implements Runnable {
    private static Logger logger = LoggerFactory.getLogger(SyFeDataService.class);
    @Autowired
    public BaseDao baseDao;
    BatchAddData batchAddData;
    @Override
    public BaseDao getBaseDao() {
@@ -61,7 +68,6 @@
        this.baseDao = baseDao;
    }
    @Autowired
    FileManagerService fileManagerService;
    public FileManagerService getFileManagerService() {
@@ -72,7 +78,6 @@
        this.fileManagerService = fileManagerService;
    }
    @Autowired
    SystemMenusService systemMenusService;
    public SystemMenusService getSystemMenusService() {
@@ -83,7 +88,6 @@
        this.systemMenusService = systemMenusService;
    }
    @Autowired
    private FeDataDSService feDataDSService;
    public FeDataDSService getFeDataDSService() {
@@ -103,6 +107,11 @@
    public void setGdMediaUtil(GdMediaUtil gdMediaUtil) {
        this.gdMediaUtil = gdMediaUtil;
    }
    public void setBatchAddData(BatchAddData batchAddData) {
        this.batchAddData = batchAddData;
    }
    //公司fe id å¯¹åº” äº§å“uuid
@@ -144,7 +153,14 @@
//    private List<String> funTable = Lists.newArrayList("FE_APP5.PUB_NOTICE","FE_BASE5.RESEARCH_TOPIC","FE_APP5.APP_KQLRB","FE_BASE5.SYS_COLLABORATIVE","FE_APP5.BS_MEETING_FLOW");
    private List<String> funTable = Lists.newArrayList("FE_APP5.PUB_NOTICE", "FE_BASE5.RESEARCH_TOPIC", "FE_APP5.APP_KQLRB", "FE_BASE5.SYS_COLLABORATIVE", "FE_APP5.BS_MEETING_FLOW");
    private Set<String> clearTable = new HashSet<>();
    private String clientUUID;
    public void setClearTable(Set<String> clearTable) {
        this.clearTable = clearTable;
    }
    public String getClientUUID() {
        return clientUUID;
@@ -159,9 +175,45 @@
    public BusinessDataSync(String tricode_funs) {
        this.tricode_funs = tricode_funs;
        this.functionUuid = this.feFunctionCodeByFunctionUuid.get(tricode_funs.trim().replace("mvc", "").replaceAll(",", ""));
    }
    public String TSPath = Global.getSystemConfig("new.filePackage", "");
    private String functionUuid;
    public Set<String> getClearAttachment() {
        return clearAttachment;
    }
    Map<String, String> feFunctionCodeByFunctionUuid = MapUtil
            .builder("035-411-000", "f7c4dd7d-3e17-4f67-b1cb-b36704f3f896")//会议室申请
            .put("006-009-000", "ed86d09a-23be-4d8c-8cb2-be8622fe50f4")//发布公告
            .put("001-006-000", "df981440-327c-4c9f-9395-f98ad067986e")//收文管理
            .put("001-011-000", "0245268a-8da3-47d5-aab1-4dd85b162904")//自由行文
            .put("019-021-000", "8a7c615a-1c4c-4eca-8d83-f04415128267")//办公用品领用表
            .put("021-012-000", "a3222fac-6203-407b-92c7-3aa2d459c62b")//发文子表单
            .put("021-016-000", "39358718-fe36-44c3-832d-74fae9487922")//工作人员出差(培训)审批单
            .put("019-018-000", "243e5c53-72d7-4419-85cf-acc09db68756")//公务接待审批
            .put("019-017-000", "d7e76a76-5650-4499-a941-23faf64ca3c8")//办公室用品采购单
            .put("001-012-000", "18cbe376-1d7a-4d0c-bd6f-6fd4c5390474")//西宁市房产管理局发文稿纸
            .put("600-008-000", "1d0b60d3-6497-4600-aafb-189ac1c1cdf0")//行政处罚事先告知书
            .put("600-009-000", "9c5b0b79-e801-4a03-a3fa-19974b6c1e67")//行政处罚不予
            .put("600-010-000", "409673e2-bdc3-46f0-adeb-067be4938618")//行政处罚听证告知书
            .put("600-011-000", "19fda013-4950-44e9-b276-2ecbdae1fa55")//行政处罚听证通知书
            .put("600-012-000", "64876b1a-d13d-492c-a488-2f243a837486")//行政处罚不予听证通知书
            .put("600-013-000", "540a3469-5d6f-41b7-807e-0ac44f46303a")//行政处罚决定书
            .put("600-014-000", "5509387d-de73-4a66-a42a-fbeff23fd3f0")//调查终结报告
            .put("600-015-000", "3c9f9d0a-5a5e-465c-9433-b5541cc7a075")//行政案件立案审批表
            .put("600-016-000", "8c7c34c5-5dca-4544-a6e4-0fbb7b80eb1f")//行政处罚催告书
            .put("019-023-000", "8c9d0806-28ba-43b4-b2cf-dcb81a10ce65")//行政执法审批表
            .put("601-001-000", "")//考勤录入
            .put("019-025-000", "30cea2ef-92b1-46c1-8785-5d34755ee803")//办公经费使用审批单
            .put("003-006-000", "6e587365-8ebd-4ab5-bade-dd3b1bf640f8")//协同办公
            .map();
    public Boolean isStr(String str) {
        boolean a = false;
@@ -220,6 +272,36 @@
            throw e;
        }
        String sf28 = Orlfs.getString("sf28");
        //查询本系统中的功能uuid
        String feFunctionName = Orlfs.getString("sf02");
        //SF09
        String functionId = Orlfs.getString("sf00");
        DataTableEntity dataTable = BaseDaoServiceImpl.getDataTable(conn, "select * from WF_MODEL where WM05=(SELECT SF09 FROM SYS_FACE WHERE SF00 IN (\n" +
                "\n" +
                "select SP04 FROM SYS_PAGE where sp01='001-012-000' and sp04 !='0' and sp04!=' ' GROUP BY SP04\n" +
                ") AND SF09 IS NOT NULL AND  LENGTH(SF09)>0 AND SF09!=' ' and ROWNUM=1)", new Object[]{});
//        if (!DataTableEntity.isEmpty(dataTable)) {
//            String feFlowTitle = dataTable.getString(0, "wm01");
//            String feTable = dataTable.getString(0, "wm04").split("\\.")[1];
//
//            //本系统表名
//            String tableName = this.originalTable.getString(feTable);
//            if (StringUtils.isEmpty(tableName)) {
//                //转换为产品表名
//                tableName = feTable.toLowerCase();
//            }
//            FieldSetEntity existFlow = baseDao.getFieldSetEntityByFilter("product_sys_flow_model", "title = ? or table_uuid=?", new Object[]{feFlowTitle, tableName}, false);
//            if (!FieldSetEntity.isEmpty(existFlow)) {
//                //拿流程uuid找mvcpage
//                String flowUuid = existFlow.getString("type_code");
//                FieldSetEntity mvcPage = baseDao.getFieldSetEntityByFilter("product_sys_mvc_page", "flow_uuid = ?", new Object[]{flowUuid}, false);
//                if (!FieldSetEntity.isEmpty(mvcPage)) {
//                    functionUuid = mvcPage.getString("function_uuid");
//                }
//            }
//        }
        //功能如果未关联基础表 æŸ¥è¯¢æµç¨‹è¡¨
        if (BaseUtil.strIsNull(sf28) || sf28.indexOf(".") == -1) {
            FieldSetEntity modelFse;
@@ -249,96 +331,10 @@
        } catch (Exception e) {
            e.getStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            logger.error("synchronizeTablesData", e);
        }
        return sf28;
    }
    /**
     * åŒæ­¥å…¬å‘Šè¡¨æ•°æ®
     *
     * @param conn
     * @param tableName
     * @throws SQLException
     */
    private void syncNotice(Connection conn, String tableName) throws SQLException {
        //判断是否是已经同步过的表
        DataTableEntity dataTable = baseDao.listTable("product_oa_announcement");
        if (!BaseUtil.dataTableIsEmpty(dataTable)) {
            return;
        }
        DataTableEntity noticeDt = null;
        try {
            noticeDt = BaseDaoServiceImpl.getDataTable(conn, tableName, "", new Object[]{});
        } catch (Exception e) {
            DataManipulationUtils.close(null, null, conn);
            throw e;
        }
        for (int i = 0; i < noticeDt.getRows(); i++) {
            FieldSetEntity feFs = noticeDt.getFieldSetEntity(i);
            FieldSetEntity fs = new FieldSetEntity();
            fs.setTableName("product_oa_announcement");
            fs.setValue("title", feFs.getString("title"));
            fs.setValue("content", feFs.getString("content"));
            fs.setValue("type", feFs.getString("notice_category"));
            fs.setValue("annex", feFs.getString("annex"));
            DataTableEntity accessoryData = new DataTableEntity();
            FieldSetEntity accessoryFs = new FieldSetEntity("temp");
            accessoryFs.setValue("si02", "attachment");
            accessoryFs.setValue("si04", "ANNEX");
            accessoryData.addFieldSetEntity(accessoryFs);
            if (!BaseUtil.dataTableIsEmpty(accessoryData)) {
                try {
                    Map<String, List<String>> stringListMap = this.synchronizationAttachments(conn, accessoryData, fs, "product_oa_announcement", "annex");
                    fs.setValue("annex", CollectionUtil.join(stringListMap.get("annex"), ","));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            //Set è½¬æ¢ä¸ºå­—符串逗号分隔
            //写方法判断是多人还是部门,若是部门转换为人
            fs.setValue("extent", this.getUserIds(conn, feFs.getString("receivers")));
            fs.setValue("expiration_date", feFs.getDate("displayed_date"));
            fs.setValue("status", feFs.getString("is_reminded"));
            fs.setValue("publish_status", feFs.getString("status"));
            String publisher = this.userIdJson.getString(feFs.getString("publisher"));
            if (BaseUtil.strIsNull(publisher)) {
                continue;
            }
            fs.setValue("created_by", publisher);
            fs.setValue("created_utc_datetime", feFs.getDate("publish_date"));
            String uuid = baseDao.add(fs);
//            //重新获取jdbc连接
//            Connection connection = null;
//            try {
//                connection = this.getJDBC();
//            } catch (ClassNotFoundException e) {
//                e.printStackTrace();
//            }
            DataTableEntity subFeFs = getSubDt(conn, "FE_APP5.PUB_NOTICE_RECEIVER", "NOTICE_ID", feFs.getString("id"));
            DataTableEntity subData = new DataTableEntity();
            FieldMetaEntity f = new FieldMetaEntity();
            f.setTableName(new String[]{"product_oa_announcement_role"});
            subData.setMeta(f);
            for (int j = 0; j < subFeFs.getRows(); j++) {
                FieldSetEntity fsSubFe = subFeFs.getFieldSetEntity(j);
                FieldSetEntity fsSub = new FieldSetEntity();
                fsSub.setTableName("product_oa_announcement_role");
                String userId = userIdJson.getString(fsSubFe.getString("receiver"));
                if (null == userId) {
                    continue;
                }
                //获取所属部门
                fsSub.setValue("user_id", userId);
                fsSub.setValue("status", fsSubFe.getString("readed"));
                fsSub.setValue("announcement_uuid", uuid);
                subData.addFieldSetEntity(fsSub);
            }
            baseDao.add(subData);
//            DataManipulationUtils.close(null, null, connection);
        }
    }
    /**
@@ -403,6 +399,93 @@
            throw new BaseException(e.getMessage(), e.toString());
        }
        return StringUtils.join(extentArr, ",");
    }
    /**
     * åŒæ­¥å…¬å‘Šè¡¨æ•°æ®
     *
     * @param conn
     * @param tableName
     * @throws SQLException
     */
    private void syncNotice(Connection conn, String tableName) throws SQLException {
        //判断是否是已经同步过的表
        DataTableEntity dataTable = baseDao.listTable("product_oa_announcement");
        if (!BaseUtil.dataTableIsEmpty(dataTable)) {
            return;
        }
        DataTableEntity noticeDt = null;
        try {
            noticeDt = BaseDaoServiceImpl.getDataTable(conn, tableName, "", new Object[]{});
        } catch (Exception e) {
            DataManipulationUtils.close(null, null, conn);
            throw e;
        }
        for (int i = 0; i < noticeDt.getRows(); i++) {
            FieldSetEntity feFs = noticeDt.getFieldSetEntity(i);
            FieldSetEntity fs = new FieldSetEntity();
            fs.setTableName("product_oa_announcement");
            fs.setValue("title", feFs.getString("title"));
            fs.setValue("content", feFs.getString("content"));
            fs.setValue("type", feFs.getString("notice_category"));
            fs.setValue("annex", feFs.getString("annex"));
            DataTableEntity accessoryData = new DataTableEntity();
            FieldSetEntity accessoryFs = new FieldSetEntity("temp");
            accessoryFs.setValue("si02", "attachment");
            accessoryFs.setValue("si04", "ANNEX");
            accessoryData.addFieldSetEntity(accessoryFs);
            if (!BaseUtil.dataTableIsEmpty(accessoryData)) {
                try {
                    Map<String, List<String>> stringListMap = this.synchronizationAttachments(conn, accessoryData, fs, "product_oa_announcement", "annex");
                    fs.setValue("annex", CollectionUtil.join(stringListMap.get("annex"), ","));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            //Set è½¬æ¢ä¸ºå­—符串逗号分隔
            //写方法判断是多人还是部门,若是部门转换为人
            fs.setValue("extent", this.getUserIds(conn, feFs.getString("receivers")));
            fs.setValue("expiration_date", feFs.getDate("displayed_date"));
            fs.setValue("status", feFs.getString("is_reminded"));
            fs.setValue("publish_status", feFs.getString("status"));
            String publisher = this.userIdJson.getString(feFs.getString("publisher"));
            if (BaseUtil.strIsNull(publisher)) {
                continue;
            }
            fs.setValue("created_by", publisher);
            fs.setValue("created_utc_datetime", feFs.getDate("publish_date"));
            String uuid = baseDao.add(fs);
//            //重新获取jdbc连接
//            ConnectionInterface connection = null;
//            try {
//                connection = this.getJDBC();
//            } catch (ClassNotFoundException e) {
//                e.printStackTrace();
//            }
            DataTableEntity subFeFs = getSubDt(conn, "FE_APP5.PUB_NOTICE_RECEIVER", "NOTICE_ID", feFs.getString("id"));
            DataTableEntity subData = new DataTableEntity();
            FieldMetaEntity f = new FieldMetaEntity();
            f.setTableName(new String[]{"product_oa_announcement_role"});
            subData.setMeta(f);
            for (int j = 0; j < subFeFs.getRows(); j++) {
                FieldSetEntity fsSubFe = subFeFs.getFieldSetEntity(j);
                FieldSetEntity fsSub = new FieldSetEntity();
                fsSub.setTableName("product_oa_announcement_role");
                String userId = userIdJson.getString(fsSubFe.getString("receiver"));
                if (null == userId) {
                    continue;
                }
                //获取所属部门
                fsSub.setValue("user_id", userId);
                fsSub.setValue("status", fsSubFe.getString("readed"));
                fsSub.setValue("announcement_uuid", uuid);
                subData.addFieldSetEntity(fsSub);
            }
            baseDao.add(subData);
//            DataManipulationUtils.close(null, null, connection);
        }
    }
    /**
@@ -726,20 +809,21 @@
     * @return
     * @throws SQLException
     */
    private void syncFunTable(Connection conn, String tableName) throws SQLException {
    private void syncFunTable(Connection conn, String tableName) throws Exception {
        //公告表
        if (tableName.equals("FE_APP5.PUB_NOTICE")) {
            //两个表建立关联
            this.originalTable.put("PUB_NOTICE", "product_oa_announcement");
            syncNotice(conn, tableName);
            //修改已同步附件 æ·»åŠ  module_uuid function_uuid
            baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{"036ccacd-47da-4f6e-9cf7-972211717e6e", "ed86d09a-23be-4d8c-8cb2-be8622fe50f4", "product_oa_announcement"});
//            baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{"036ccacd-47da-4f6e-9cf7-972211717e6e", "ed86d09a-23be-4d8c-8cb2-be8622fe50f4", "product_oa_announcement"});
        }
        //考勤表 éœ€åŒæ­¥å…³è”数据如请假表 å¤–出表
        if (tableName.equals("FE_APP5.APP_KQLRB")) {
            this.originalTable.put("APP_KQLRB", "product_oa_punch_record");
            this.originalTable.put("PLEASELEAVE", "product_oa_ask_for_leave");
            this.originalTable.put("FT_1_WCDJB00", "product_oa_business_trip");
            //同步考勤
            this.synchronousClock(conn);
            System.out.println("=================考勤同步成功===============");
@@ -751,11 +835,11 @@
            this.syncCcooperates(conn, tableName);
            //协同模板数据
            this.syncCollaborativeTemplate(conn);
            baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{"127c3f55-a7b4-4a77-a097-a65ba95b76f0", "6e587365-8ebd-4ab5-bade-dd3b1bf640f8", "product_oa_cooperates"});
            baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{"127c3f55-a7b4-4a77-a097-a65ba95b76f0", "6e587365-8ebd-4ab5-bade-dd3b1bf640f8", "product_oa_cooperate_flow_node"});
            baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{"127c3f55-a7b4-4a77-a097-a65ba95b76f0", "6e587365-8ebd-4ab5-bade-dd3b1bf640f8", "product_oa_cooperate_flow_reply"});
//            baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{"127c3f55-a7b4-4a77-a097-a65ba95b76f0", "6e587365-8ebd-4ab5-bade-dd3b1bf640f8", "product_oa_cooperates"});
//
//            baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{"127c3f55-a7b4-4a77-a097-a65ba95b76f0", "6e587365-8ebd-4ab5-bade-dd3b1bf640f8", "product_oa_cooperate_flow_node"});
//
//            baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{"127c3f55-a7b4-4a77-a097-a65ba95b76f0", "6e587365-8ebd-4ab5-bade-dd3b1bf640f8", "product_oa_cooperate_flow_reply"});
            System.out.println("=================协同办公同步成功===============");
        }
        //会议同步
@@ -799,7 +883,7 @@
     * @param conn
     * @throws SQLException
     */
    private void synchronousClock(Connection conn) throws SQLException {
    private void synchronousClock(Connection conn) throws Exception {
        //同步请假 PLEASELEAVE
        DataTableEntity pleaseleave = null;
        try {
@@ -867,8 +951,15 @@
                fieldSetEntity.setValue("id", leaveFse.getInteger("pl00"));
                //PL11    è¯·ä¼‘假开始时间            fill_in_time    å¡«å•æ—¶é—´
                String pl11 = leaveFse.getString("pl11");
                fieldSetEntity.setValue("fill_in_time", pl11);
                //PL11    è¯·ä¼‘假开始时间                 start_time    å¼€å§‹æ—¶é—´
                if (!StringUtils.isEmpty(pl11)) {
                    //判断是否为日期格式
                    fieldSetEntity.setValue("fill_in_time", DateUtil.parse(pl11).toJdkDate());
                    fieldSetEntity.setValue("start_time", fieldSetEntity.getObject("fill_in_time"));
                } else {
                    fieldSetEntity.setValue("fill_in_time", pl11);
                    fieldSetEntity.setValue("start_time", pl11);
                }
                fieldSetEntity.setValue("start_time", pl11);
                //PL15    è¯·ä¼‘假结束时间                end_time    ç»“束时间
                String pl15 = leaveFse.getString("pl15");
@@ -879,7 +970,12 @@
                        pl15 = pl11;
                    }
                }
                fieldSetEntity.setValue("end_time", pl15);
                if (!StringUtils.isEmpty(pl15)) {
                    //判断是否为日期格式
                    fieldSetEntity.setValue("fill_in_time", DateUtil.parse(pl15).toJdkDate());
                } else {
                    fieldSetEntity.setValue("end_time", pl15);
                }
                //PL12    è¯·ä¼‘假天数 day    è¯·å‡å¤©æ•°
                fieldSetEntity.setValue("day", leaveFse.getString("pl12"));
                //PL09    è¯·ä¼‘假原因 cause    è¯·å‡åŽŸå› 
@@ -1026,12 +1122,25 @@
        FieldSetEntity fieldSetEntity = new FieldSetEntity();
        fieldSetEntity.setTableName("product_oa_ask_for_leave");
        String f1w08 = fse.getString("f1w08");
        //f1w08    è¯·ä¼‘假开始时间    fill_in_time    å¡«å•æ—¶é—´
        fieldSetEntity.setValue("fill_in_time", f1w08);
        //f1w08    è¯·ä¼‘假开始时间                 start_time    å¼€å§‹æ—¶é—´
        fieldSetEntity.setValue("start_time", f1w08);
        //f1w09    è¯·ä¼‘假结束时间                end_time    ç»“束时间
        fieldSetEntity.setValue("end_time", fse.getString("f1w09"));
        if (!StringUtils.isEmpty(f1w08)) {
            //判断是否为日期格式
            //f1w08    è¯·ä¼‘假开始时间    fill_in_time    å¡«å•æ—¶é—´
            fieldSetEntity.setValue("fill_in_time", DateUtil.parse(f1w08).toJdkDate());
            //f1w08    è¯·ä¼‘假开始时间                 start_time    å¼€å§‹æ—¶é—´
            fieldSetEntity.setValue("start_time", fieldSetEntity.getObject("fill_in_time"));
        } else {
            //f1w08    è¯·ä¼‘假开始时间    fill_in_time    å¡«å•æ—¶é—´
            fieldSetEntity.setValue("fill_in_time", f1w08);
            //f1w08    è¯·ä¼‘假开始时间                 start_time    å¼€å§‹æ—¶é—´
            fieldSetEntity.setValue("start_time", f1w08);
        }
        String f1w09 = fse.getString("f1w09");
        if (!StringUtils.isEmpty(f1w09)) {
            //判断是否为日期格式
            fieldSetEntity.setValue("end_time", DateUtil.parse(f1w09).toJdkDate());
        } else {
            fieldSetEntity.setValue("end_time", fse.getString("f1w09"));
        }
        //day    è¯·ä¼‘假天数 day    è¯·å‡å¤©æ•°
        fieldSetEntity.setValue("day", fse.getString("day"));
        //f1w06    è¯·ä¼‘假原因 cause    è¯·å‡åŽŸå› 
@@ -1205,7 +1314,7 @@
     *
     * @param clockDt å¤–出data数据
     */
    private void synchronousClock(DataTableEntity clockDt) throws SQLException {
    private void synchronousClock(DataTableEntity clockDt) throws Exception {
        //同步考勤数据
        if (!BaseUtil.dataTableIsEmpty(clockDt)) {
            DataTableEntity dataTableEntity = new DataTableEntity();
@@ -1263,11 +1372,11 @@
                fieldSetEntity.setValue("time_four_result", fse.getString("xwkqjg"));
//                String xwkqjg = fse.getString("xwkqjg");
                dataTableEntity.addFieldSetEntity(fieldSetEntity);
                if (dataTableEntity.getRows() == 1000) {
                    baseDao.add(dataTableEntity);
                    dataTableEntity = new DataTableEntity();
                    dataTableEntity.setMeta(f);
                }
//                if (dataTableEntity.getRows() == 1000) {
//                    baseDao.add(dataTableEntity);
//                    dataTableEntity = new DataTableEntity();
//                    dataTableEntity.setMeta(f);
//                }
                //请休假放到请假表里面
//                switch (xwkqjg){
//                        //正常
@@ -1303,7 +1412,8 @@
//                }
            }
            if (!BaseUtil.dataTableIsEmpty(dataTableEntity)) {
                baseDao.add(dataTableEntity);
//                baseDao.add(dataTableEntity);
                batchAddData.add(dataTableEntity);
            }
        }
    }
@@ -2090,7 +2200,7 @@
    /**
     * åŒæ­¥ååŒæµç¨‹æ¶ˆæ¯è¡¨
     */
    public void syncCollaborativeNews(DataTableEntity OrlDt, Map<String, String[]> stateMap, String tableName) {
    public void syncCollaborativeNews(DataTableEntity OrlDt, Map<String, String[]> stateMap, String tableName) throws Exception {
        String id = null;
        String message_uuid = null;
        String[] state = null;
@@ -2098,6 +2208,7 @@
        FieldMetaEntity f = new FieldMetaEntity();
        f.setTableName(new String[]{"product_sys_message_user"});
        dataTableEntity.setMeta(f);
        DataTableEntity dt1 = new DataTableEntity();
        for (int i = 0; i < OrlDt.getRows(); i++) {
            FieldSetEntity fs = OrlDt.getFieldSetEntity(i);
            //流程节点id
@@ -2151,7 +2262,9 @@
                //查看详情
                message.setValue("url", state[1]);
                message_uuid = baseDao.add(message);
                dt1.addFieldSetEntity(message);
                message_uuid = UUID.randomUUID().toString();
                message.setValue("uuid", message_uuid);
            }
            FieldSetEntity message_user = new FieldSetEntity();
@@ -2181,8 +2294,17 @@
            }
            message_user.setValue("user_id", user_id);
            dataTableEntity.addFieldSetEntity(message_user);
            if (dt1.getRows() > 50000) {
                batchAddData.add(dt1);
                dt1 = new DataTableEntity();
            }
            if (dataTableEntity.getRows() > 50000) {
                batchAddData.add(dataTableEntity);
                dataTableEntity = new DataTableEntity();
            }
        }
        baseDao.add(dataTableEntity);
        batchAddData.add(dt1);
        batchAddData.add(dataTableEntity);
    }
    /**
@@ -2918,7 +3040,7 @@
//            fs.setValue("script_method", buttonsFs.getString("se14"));
            //路由名称
            fs.setValue("route_name", BaseUtil.getPageCode());
            fs.setValue("terminal_type", 1);
            String uuid = baseDao.add(fs);
            //09为送办按钮
            if ("09".equals(buttonsFs.getString("se12")) && !BaseUtil.strIsNull(buttonsFs.getString("se14"))) {
@@ -3185,7 +3307,7 @@
            e.printStackTrace();
        }
        //修改已同步附件 æ·»åŠ  module_uuid function_uuid
        baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{moduleUUID, funUUID, table});
//        baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{moduleUUID, funUUID, table});
        String sf05 = funFs.getString("sf05");
        //获取jdbc连接
        Connection conn = this.getJDBC();
@@ -3352,6 +3474,8 @@
        }
    }
    private Set<String> clearAttachment = new HashSet<>();
    /**
     * è¿ç§»ä¸šåŠ¡æ•°æ®è¡¨
     *
@@ -3376,8 +3500,8 @@
            SpringMVCContextHolder.getSystemLogger().error(e);
            throw e;
        }
        Map<String, String> map = null;
        Boolean syncAttachments = false;
        Map<String, String> map;
        Boolean syncAttachments;
        DataTableEntity accessoryData;
        //是否是新表
        if (isNew) {
@@ -3393,24 +3517,20 @@
                    this.attachmentValue = this.attachmentValue + accessoryData.getString(i, "si04") + ",";
                }
                this.attachmentValue = "," + this.attachmentValue;
            } else {
                syncAttachments = false;
            }
            //同步表结构  åŠå­—段信息
            map = this.syncTableField(conn, Orlfs, sf28s, subField);
            //刷新table è¡¨
//                DataPoolCacheImpl.getInstance().cacheDataByTable("product_sys_datamodel_table");;
            //刷新field è¡¨
//                DataPoolCacheImpl.getInstance().cacheDataByTable("product_sys_datamodel_field");
//                try {
//                    Thread.sleep(7000);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                    SpringMVCContextHolder.getSystemLogger().error(e);
//                }
//            } else {
//                return;
//            }
            //清空表数据
            String clearTableName = Orlfs.getString("st03").toLowerCase();
            if (!clearTable.contains(clearTableName)) {
                baseDao.executeUpdate("truncate table " + clearTableName);
                clearTable.add(clearTableName);
            }
        } else {
            map = null;
            syncAttachments = false;
            //已有表
            this.syncFunTable(conn, sf28s[0] + '.' + sf28s[1]);
            return;
@@ -3425,59 +3545,90 @@
            SpringMVCContextHolder.getSystemLogger().error(e);
            throw e;
        }
        //创建10个固定线程
        DataTableEntity dt = new DataTableEntity();
        //业务表 fe的id  å¯¹åº”UUID
        for (int i = 0; i < dataDt.getRows(); i++) {
            //将循环中的数据放入线程池
            FieldSetEntity dataFs = dataDt.getFieldSetEntity(i);
            FieldSetEntity tableFs = new FieldSetEntity();
            tableFs.setTableName(this.originalTable.getString(taName));
            //key ä¸ºæœ¬è¡¨å­—段   value ä¸ºæ•°æ®æºå­—段
            for (String key : map.keySet()) {
                //单关联的用户user_id
                if ("USER".equals(fieldTypeJson.getString(key))) {
                    tableFs.setValue(key, userIdJson.getString(dataFs.getString(map.get(key))));
                    //单关联的组织架构uuid
                } else if ("GROUP".equals(fieldTypeJson.getString(key))) {
                    tableFs.setValue(key, groupJson.get(dataFs.getString(map.get(key))));
                    //多选组织架构  è½¬æ¢ä¸ºç”¨æˆ·user_ids
                } else if ("USERSGROUPS".equals(fieldTypeJson.getString(map.get(key)))) {
                    tableFs.setValue(key, this.getUserIds(conn, dataFs.getString(map.get(key))));
                } else {
                    //是否有字段关联主表
                    if (subField != null && subField.equals(map.get(key))) {
                        //表名加下标 å”¯ä¸€
                        tableFs.setValue(key, pxMap.getString(masterTableName + dataFs.getString(map.get(key))));
            try {
                FieldSetEntity tableFs = new FieldSetEntity();
                tableFs.setTableName(this.originalTable.getString(taName));
                //key ä¸ºæœ¬è¡¨å­—段   value ä¸ºæ•°æ®æºå­—段
                for (String key : map.keySet()) {
                    //单关联的用户user_id
                    if ("USER".equals(fieldTypeJson.getString(key))) {
                        tableFs.setValue(key, userIdJson.getString(dataFs.getString(map.get(key))));
                        //单关联的组织架构uuid
                    } else if ("GROUP".equals(fieldTypeJson.getString(key))) {
                        tableFs.setValue(key, groupJson.get(dataFs.getString(map.get(key))));
                        //多选组织架构  è½¬æ¢ä¸ºç”¨æˆ·user_ids
                    } else if ("USERSGROUPS".equals(fieldTypeJson.getString(map.get(key)))) {
                        tableFs.setValue(key, this.getUserIds(conn, dataFs.getString(map.get(key))));
                    } else {
                        //是否有字段关联主表
                        if (subField != null && subField.equals(map.get(key))) {
                            //表名加下标 å”¯ä¸€
                            tableFs.setValue(key, pxMap.getString(masterTableName + dataFs.getString(map.get(key))));
                        } else {
                            tableFs.setValue(key, dataFs.getString(map.get(key)));
                        }
                    }
                    if (StringUtils.isEmpty(tableFs.getString(key))) {
                        tableFs.setValue(key, dataFs.getString(map.get(key)));
                    }
                }
                if(StringUtils.isEmpty(tableFs.getString(key))){
                    tableFs.setValue(key,dataFs.getString(map.get(key)));
                }
            }
            if("bgyplyb".equals(tableFs.getTableName()) && "1208".equals(dataFs.getString("bg00"))){
                System.out.println(1);
            }
            //同步附件
            if (syncAttachments) {
                Map<String, List<String>> fileMaps = this.synchronizationAttachments(conn, accessoryData, dataFs, tableFs.getTableName(), null);
                if (fileMaps.size() > 0) {
                    for (String fieldName : fileMaps.keySet()) {
                        List<String> value = fileMaps.get(fieldName);
                        tableFs.setValue(fieldName, StringUtils.join(value, ","));
                    if (tableFs.getTableName().equalsIgnoreCase("sfgl")) {
                        tableFs.setValue("is_print", "0");
                    }
                }
            }
            String uuid = "";
            try {
                uuid = baseDao.add(tableFs);
            } catch (BaseException e) {
                if ("bgyplyb".equals(tableFs.getTableName()) && "1208".equals(dataFs.getString("bg00"))) {
                    System.out.println(1);
                }
                //同步附件
                if (syncAttachments) {
                    Map<String, List<String>> fileMaps = this.synchronizationAttachments(conn, accessoryData, dataFs, tableFs.getTableName(), null);
                    if (fileMaps.size() > 0) {
                        for (String fieldName : fileMaps.keySet()) {
                            List<String> value = fileMaps.get(fieldName);
                            tableFs.setValue(fieldName, StringUtils.join(value, ","));
                        }
                    }
                }
                String uuid = UUID.randomUUID().toString();
                try {
                    tableFs.setValue("uuid", uuid);
//                uuid = baseDao.add(tableFs);
                    if (StringUtils.isEmpty(tableFs.getString("created_by"))) {
                        tableFs.setValue("created_by", 1);
                        tableFs.setValue("created_utc_datetime", new Date());
                    }
                    if ("fwgz".equalsIgnoreCase(tableFs.getTableName())) {
                        tableFs.setValue("print_sign", tableFs.getString("fw22"));
                    }
                    dt.addFieldSetEntity(tableFs);
                } catch (BaseException e) {
                    e.printStackTrace();
                    SpringMVCContextHolder.getSystemLogger().error(e);
                    logger.error("syncTable", e);
                    throw e;
                } catch (Exception e) {
                    e.printStackTrace();
                    SpringMVCContextHolder.getSystemLogger().error(e);
                    logger.error("syncTable", e);
                    throw e;
                }
                synchronized (pxMap) {
                    //表唯一id  å¯¹åº”uuid
                    pxMap.put(taName + dataFs.getString(this.pk), uuid);
                }
            } catch (Exception e) {
                e.printStackTrace();
                SpringMVCContextHolder.getSystemLogger().error(e);
            }
            //表唯一id  å¯¹åº”uuid
            pxMap.put(taName + dataFs.getString(this.pk), uuid);
        }
        //批量插入数据
        batchAddData.add(dt);
        //同步完一张表数据后清空json数据
        fieldTypeJson.clear();
        DataTableEntity subTble = null;
@@ -3489,13 +3640,19 @@
            SpringMVCContextHolder.getSystemLogger().error(e);
            throw e;
        }
        for (int i = 0; i < subTble.getRows(); i++) {
            FieldSetEntity sf = subTble.getFieldSetEntity(i);
            String a[] = {sf.getString("st02"), sf.getString("st03"), taName};
            if (isStr(sf.getString("st02") + "\\." + sf.getString("st03"))) {
                isNew = false;
        try {
            for (int i = 0; i < subTble.getRows(); i++) {
                FieldSetEntity sf = subTble.getFieldSetEntity(i);
                String a[] = {sf.getString("st02"), sf.getString("st03"), taName};
                if (isStr(sf.getString("st02") + "\\." + sf.getString("st03"))) {
                    isNew = false;
                }
                this.syncTable(a, isNew, sf.getString("sf01").toLowerCase(), conn);
            }
            this.syncTable(a, isNew, sf.getString("sf01").toLowerCase(), conn);
        } catch (Exception e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            logger.error("syncTable", e);
        }
    }
@@ -3620,6 +3777,7 @@
                            fieldSetEntity.setMeta(f);
                            fieldSetEntity.setValue(field, name);
                            fieldSetEntity.setValue("~field_name~", field);
                            fieldSetEntity.setValue("function_uuid", this.functionUuid);
                            //放入客户uuid
                            fieldSetEntity.setValue("client_uuid", this.clientUUID);
                            rpe.setFiles(fileMap);
@@ -3630,6 +3788,7 @@
                            } catch (Exception e) {
                                e.getStackTrace();
                                SpringMVCContextHolder.getSystemLogger().error(e);
                                logger.error("synchronizationAttachments", e);
                            }
                        }
                    }
@@ -3690,6 +3849,7 @@
                    fieldSetEntity.setValue("~field_name~", field);
                    //放入客户uuid
                    fieldSetEntity.setValue("client_uuid", this.clientUUID);
                    fieldSetEntity.setValue("function_uuid", this.functionUuid);
                    rpe.setFiles(fileMap);
                    rpe.setFormData(fieldSetEntity);
                    try {
@@ -3953,6 +4113,7 @@
        } catch (Exception e) {
            DataManipulationUtils.close(null, null, conn);
            SpringMVCContextHolder.getSystemLogger().error(e);
            e.printStackTrace();
            throw e;
        }
        if (Orlfs == null) {
@@ -4000,6 +4161,7 @@
            } catch (Exception e) {
                e.getStackTrace();
                SpringMVCContextHolder.getSystemLogger().error(e);
                logger.error("syncModel", e);
            }
        }
@@ -4017,21 +4179,30 @@
        modelFs.setValue("created_by", created_by);
        modelFs.setValue("created_utc_datetime", new Date());
        String modelUuid = null;
        FieldSetEntity existFlow = baseDao.getFieldSetEntityByFilter("product_sys_flow_model", "title = ?", new Object[]{flowTitle}, false);
        if (!FieldSetEntity.isEmpty(existFlow) && !flag) {
            return existFlow.getString("type_code");
        }
        FieldSetEntity existFlow = baseDao.getFieldSetEntityByFilter("product_sys_flow_model", "title = ? or table_uuid=?", new Object[]{flowTitle, this.originalTable.getString(wm04s[1])}, false);
//        if (!FieldSetEntity.isEmpty(existFlow) && !flag) {
//            return existFlow.getString("type_code");
//        }
        try {
            if (!FieldSetEntity.isEmpty(existFlow)) {
                FieldSetEntity mvcPageFse = baseDao.getFieldSetEntityByFilter("product_sys_mvc_page", " flow_uuid = ?", new String[]{wm05}, false);
                typeCode = existFlow.getString("type_code");
                modelFs = existFlow;
                modelUuid = existFlow.getString("uuid");
//                functionUuid = mvcPageFse.getString("function_uuid");
            } else {
                if (modelFs.getString("table_uuid").equalsIgnoreCase("APP_ADMINISTRATIVE_CASES") || modelFs.getString("table_uuid").equalsIgnoreCase("APP_FINAL_SURVEY_REPORT")) {
                    modelFs.setValue("module_uuid", "7070362e-6010-4b53-b773-b68b209ad67e");
                }
                modelUuid = baseDao.add(modelFs);
            }
        } catch (Exception e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            logger.error("syncModel", e);
            return typeCode;
        }
        FieldSetEntity mvcPageFse = baseDao.getFieldSetEntityByFilter("product_sys_mvc_page", " flow_uuid = ?", new String[]{wm05}, false);
@@ -4070,10 +4241,12 @@
                    this.synchronizingProcessMessages(conn, tricode_funs, stateMap);
                } catch (BaseException e) {
                    e.printStackTrace();
                    logger.error(e.getMessage(), e);
                    SpringMVCContextHolder.getSystemLogger().error(e);
                }
            } catch (Exception e) {
                e.getStackTrace();
                logger.error("syncModel", e);
                SpringMVCContextHolder.getSystemLogger().error(e);
            }
        }
@@ -4370,7 +4543,7 @@
     * @return
     * @throws SQLException
     */
    public Map<String, String> syncDetail(String tricode_funs, Connection conn, JSONObject UUIDMap, String tableName, String modelUUID, Map<String, FieldSetEntity> taskFseMap) throws SQLException {
    public Map<String, String> syncDetail(String tricode_funs, Connection conn, JSONObject UUIDMap, String tableName, String modelUUID, Map<String, FieldSetEntity> taskFseMap) throws Exception {
        tableName = tableName.split("\\.")[1];
        OrgIdUUIDmap = Maps.newHashMap();
        DataTableEntity OrlDt = null;
@@ -4390,6 +4563,8 @@
        FieldMetaEntity f = new FieldMetaEntity();
        f.setTableName(new String[]{"product_sys_flow_detail"});
        DetailData.setMeta(f);
        DataTableEntity dt = new DataTableEntity();
        for (int i = 0; i < OrlDt.getRows(); i++) {
            FieldSetEntity Orlfs = OrlDt.getFieldSetEntity(i);
            FieldSetEntity DetailFs = new FieldSetEntity();
@@ -4495,10 +4670,15 @@
            }
            //关联流程任务表
            DetailFs.setValue("task_uuid", taskFse.getUUID());
            baseDao.add(DetailFs);
            String uuid = UUID.randomUUID().toString();
            DetailFs.setValue("uuid", uuid);
            DetailFs.setValue("~type~", "add");
//            baseDao.add(DetailFs);
            dt.addFieldSetEntity(DetailFs);
            OrgIdUUIDmap.put(wi00, DetailFs);
            stateMap.put(wi00, nodeState);
        }
        batchAddData.add(dt);
        return stateMap;
    }
@@ -4511,7 +4691,7 @@
     * @param stateMap
     * @throws SQLException
     */
    public void synchronizingProcessMessages(Connection conn, String tricode_funs, Map<String, String> stateMap) throws SQLException {
    public void synchronizingProcessMessages(Connection conn, String tricode_funs, Map<String, String> stateMap) throws Exception {
        try {
            StringBuffer sql = new StringBuffer();
            sql.append(" SELECT * FROM FE_BASE5.MESSAGEINFOR WHERE ME14 IN ( ")
@@ -4533,7 +4713,7 @@
    /**
     * åŒæ­¥æµç¨‹æ¶ˆæ¯è¡¨
     */
    public void synchronizingProcessMessages(DataTableEntity OrlDt, Map<String, String> stateMap, String tableName) {
    public void synchronizingProcessMessages(DataTableEntity OrlDt, Map<String, String> stateMap, String tableName) throws Exception {
        String id = null;
        String message_uuid = null;
        String state = null;
@@ -4541,6 +4721,7 @@
        FieldMetaEntity f = new FieldMetaEntity();
        f.setTableName(new String[]{"product_sys_message"});
        dataTableEntity.setMeta(f);
        DataTableEntity dt1 = new DataTableEntity();
        for (int i = 0; i < OrlDt.getRows(); i++) {
            FieldSetEntity fs = OrlDt.getFieldSetEntity(i);
            //流程节点id
@@ -4602,7 +4783,9 @@
                } else if ("2".equals(state)) {
                    message.setValue("url", "1621321824686868oKWL726?uuid=" + source_uuid);
                }
                message_uuid = baseDao.add(message);
                message_uuid = UUID.randomUUID().toString();
                message.setValue("uuid", message_uuid);
                dt1.addFieldSetEntity(message);
            }
            FieldSetEntity message_user = new FieldSetEntity();
@@ -4634,14 +4817,23 @@
            }
            message_user.setValue("user_id", user_id);
            dataTableEntity.addFieldSetEntity(message_user);
            if (dataTableEntity.getRows() == 1000) {
                baseDao.add(dataTableEntity);
//            if (dataTableEntity.getRows() == 1000) {
//                baseDao.add(dataTableEntity);
//                dataTableEntity = new DataTableEntity();
//                dataTableEntity.setMeta(f);
//            }
            if (dt1.getRows() > 50000) {
                batchAddData.add(dt1);
                dt1 = new DataTableEntity();
            }
            if (dataTableEntity.getRows() > 50000) {
                batchAddData.add(dataTableEntity);
                dataTableEntity = new DataTableEntity();
                dataTableEntity.setMeta(f);
            }
        }
        batchAddData.add(dt1);
        if (!BaseUtil.dataTableIsEmpty(dataTableEntity)) {
            baseDao.add(dataTableEntity);
            batchAddData.add(dataTableEntity);
        }
    }
@@ -4708,7 +4900,7 @@
     * @return
     * @throws SQLException
     */
    public Map<String, FieldSetEntity> syncTask(String tricode_funs, Connection conn, String modelUUID) throws SQLException, BaseException {
    public Map<String, FieldSetEntity> syncTask(String tricode_funs, Connection conn, String modelUUID) throws Exception {
        DataTableEntity OrlDt = null;
        try {
            OrlDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.WF_TASK", "WT13=(SELECT se16  FROM fe_base5.SYS_EVENT where se01=? and se08 = 1)", new Object[]{tricode_funs
@@ -4719,7 +4911,7 @@
            throw e;
        }
        Map<String, FieldSetEntity> map = Maps.newHashMap();
        DataTableEntity dt = new DataTableEntity();
        for (int i = 0; i < OrlDt.getRows(); i++) {
            FieldSetEntity Orlfs = OrlDt.getFieldSetEntity(i);
            FieldSetEntity taskFs = new FieldSetEntity();
@@ -4761,9 +4953,15 @@
            taskFs.setValue("record_uuid", record_uuid);
            taskFs.setValue("created_by", id);
            taskFs.setValue("created_utc_datetime", wt09);
            baseDao.add(taskFs);
            taskFs.setValue("uuid", UUID.randomUUID().toString());
//            baseDao.add(taskFs);
            dt.addFieldSetEntity(taskFs);
            map.put(Orlfs.getString("wt00"), taskFs);
        }
        batchAddData.add(dt);
        return map;
    }
@@ -5128,9 +5326,11 @@
            conn = this.getJDBC();
        } catch (SQLException e) {
            e.printStackTrace();
            logger.error("run", e);
            SpringMVCContextHolder.getSystemLogger().error(e);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            logger.error("run", e);
            SpringMVCContextHolder.getSystemLogger().error(e);
        }
        String moduleUUID = null;
@@ -5152,9 +5352,7 @@
                    //表名查询功能
                    FieldSetEntity fse = baseDao.getFieldSetBySQL("SELECT a.* FROM product_sys_functions a LEFT JOIN product_sys_datamodel_table b on a.table_uuid = b.uuid WHERE b.table_name = ?", new String[]{tableName.toLowerCase()}, false);
                    moduleUUID = this.getMoudleByFunctionTricode(fse.getString(CmnConst.TRICODE));
                    String functionUuid = fse.getUUID();
                    //修改已同步附件 æ·»åŠ  module_uuid function_uuid
                    baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{moduleUUID, functionUuid, tableName.toLowerCase()});
                    //同步流程
                    this.syncFlow(conn, moduleUUID, sf28);
                }
@@ -5162,49 +5360,54 @@
            } catch (SQLException e) {
                e.printStackTrace();
                SpringMVCContextHolder.getSystemLogger().error(e);
                logger.error("run", e);
            }
        } else {
            try {
                //同步表和表数据
                sf28 = this.synchronizeTablesData(conn, this.tricode_funs);
            } catch (SQLException e) {
                logger.error("run", e);
                e.printStackTrace();
                SpringMVCContextHolder.getSystemLogger().error(e);
            }
            String table_name = sf28.split("\\.")[1];
            String myTableName = this.originalTable.getString(table_name);
            if (!isStr(sf28)) {
                //同步mvc
                try {
                    moduleUUID = this.synchronizationModuleName(conn, this.tricode_funs, sf28);
                } catch (SQLException e) {
                    e.printStackTrace();
                    SpringMVCContextHolder.getSystemLogger().error(e);
                }
            } else {
                //已有功能的表就不同步mvc  æŸ¥è¯¢è¯¥åŠŸèƒ½çš„æ¨¡å—uuid
                StringBuffer sql = new StringBuffer();
                sql.append(" tricode = (\n")
                        .append("SELECT tricode_parent FROM product_sys_functions a LEFT JOIN \n")
                        .append("product_sys_datamodel_table b on a.table_uuid = b.uuid \n")
                        .append("WHERE b.table_name = ? GROUP BY tricode_parent\n")
                        .append(") AND function_type_uuid = 0");
                FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntityByFilter("product_sys_functions", sql.toString(), new String[]{myTableName}, false);
                moduleUUID = fieldSetEntity.getUUID();
                System.out.println(1);
            }
//            if (!isStr(sf28)) {
//                //同步mvc
//                try {
//                    moduleUUID = this.synchronizationModuleName(conn, this.tricode_funs, sf28);
//                } catch (SQLException e) {
//                    e.printStackTrace();
//                    SpringMVCContextHolder.getSystemLogger().error(e);
//                }
//            } else {
            //已有功能的表就不同步mvc  æŸ¥è¯¢è¯¥åŠŸèƒ½çš„æ¨¡å—uuid
            StringBuffer sql = new StringBuffer();
            sql.append(" tricode = (\n")
                    .append("SELECT tricode_parent FROM product_sys_functions a LEFT JOIN \n")
                    .append("product_sys_datamodel_table b on a.table_uuid = b.uuid \n")
                    .append("WHERE b.table_name = ? GROUP BY tricode_parent\n")
                    .append(") AND function_type_uuid = 0");
            FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntityByFilter("product_sys_functions", sql.toString(), new String[]{myTableName}, false);
            moduleUUID = fieldSetEntity.getUUID();
//            }
            if (!isStr(sf28)) {
                this.syncFlow(conn, moduleUUID, sf28);
            }
            //表名查询功能
            FieldSetEntity fse = baseDao.getFieldSetBySQL("SELECT a.* FROM product_sys_functions a LEFT JOIN product_sys_datamodel_table b on a.table_uuid = b.uuid WHERE b.table_name = ?", new String[]{myTableName}, false);
            String functionUuid = fse.getUUID();
            //修改已同步附件 æ·»åŠ  module_uuid function_uuid
            baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{moduleUUID, functionUuid, myTableName});
//            baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{moduleUUID, functionUuid, myTableName});
        }
        try {
            DataManipulationUtils.close(null, null, conn);
        } catch (SQLException e) {
            logger.error("run", e);
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
        }
@@ -5232,6 +5435,7 @@
        } catch (SQLException e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            logger.error("syncFlow", e);
        }
        //初始化菜单缓存
//        systemMenusService.initSystemMenu();