许鹏程
2024-05-28 e6720f333268682d11aedb3b3308fa2f2c3a40df
commit
已添加1个文件
已修改4个文件
747 ■■■■ 文件已修改
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 87 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
product-server-data-sync/src/main/java/com/product/data/sync/service/SyFeDataService.java 59 ●●●● 补丁 | 查看 | 原始文档 | 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 524 ●●●●● 补丁 | 查看 | 原始文档 | 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
@@ -77,6 +77,7 @@
    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";
@@ -102,15 +103,17 @@
            this.packInstitutionMap();
            //同步岗位等级和岗位
            this.synchronousPost();
            //同步角色
            this.synchronousRole();
//            //同步角色
//            this.synchronousRole();
            //同步管理员
            this.syncManager(clientUUID);
//            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;
@@ -118,6 +121,7 @@
    /**
     *     åˆå§‹åŒ–客户及客户角色(修改客户为FE的客户名称)
     *
     * @return
     * @throws SQLException
     * @throws ClassNotFoundException
@@ -173,6 +177,7 @@
    /**
     *  åŒæ­¥ç®¡ç†å‘˜
     *
     * @param managerData ç®¡ç†å‘˜ç”¨æˆ·æ•°æ®
     */
    public void syncManager(DataTableEntity managerData,String clientUUID){
@@ -257,6 +262,12 @@
            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("/"));
            //替换为一样的符号方便对比
@@ -390,6 +401,7 @@
    /**
     * é€’归获取上级公司uuid
     *
     * @param level_all ä¸Šçº§å…¬å¸å…¨ç§°
     * @return ä¿å­˜åŽè¿”回保存后的 fse
     */
@@ -414,6 +426,7 @@
    /**
     * ä¿å­˜å…¬å¸
     *
     * @param fse å…¬å¸fes
     * @param code_parent å…¬å¸ä¸Šçº§code
     * @return ä¿å­˜åŽè¿”回保存后的 fse
@@ -440,6 +453,7 @@
    /**
     * ä¿å­˜éƒ¨é—¨
     *
     * @param fse å…¬å¸fes
     * @param code_parent å…¬å¸ä¸Šçº§code
     * @return ä¿å­˜åŽè¿”回保存后的 fse
@@ -462,6 +476,7 @@
        service.addDepartment(levelsFs);
        return levelsFs;
    }
    /**
     * å°è£…公司部门全称 Map
     */
@@ -525,6 +540,23 @@
            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"));
            //性别转换
@@ -754,6 +786,9 @@
            //公司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");
            //查询岗位等级
@@ -775,6 +810,10 @@
                  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);
                      //添加岗位与岗位等级关系映射数据表
@@ -789,6 +828,9 @@
                  }
              }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");
                  //部门名称
@@ -798,9 +840,14 @@
                  //排序
                  departmentFse.setValue("sg00", fieldSetEntity1.getString("sequence") + "01");
                  //保存后的部门
                  FieldSetEntity newDeptFse = this.addDepartment(departmentFse,code,org_uuid);
                        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);
                  //添加岗位与岗位等级关系映射数据表
@@ -816,6 +863,10 @@
              //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);
                //添加岗位与岗位等级关系映射数据表
@@ -833,12 +884,14 @@
    /**
     * æ·»åŠ åˆ›å»ºäººå’Œåˆ›å»ºæ—¶é—´
     *
     * @param fieldSetEntity
     */
    public void userAndTime(FieldSetEntity fieldSetEntity){
        fieldSetEntity.setValue("created_by",SpringMVCContextHolder.getCurrentUserId());
        fieldSetEntity.setValue("created_utc_datetime",new Date());
    }
    /**
     * æ·»åŠ å²—ä½ç­‰çº§
     */
@@ -885,7 +938,10 @@
            baseDao.add(field);
        }
    }
    /** å¤åˆ¶å•个文件
    /**
     * å¤åˆ¶å•个文件
     *
     * @param oldPath String åŽŸæ–‡ä»¶è·¯å¾„ å¦‚:c:/fqf.txt
     * @param newPath String å¤åˆ¶åŽè·¯å¾„ å¦‚:f:/fqf.txt
     * @return boolean
@@ -906,7 +962,9 @@
        }
    }
    /** åˆ é™¤å•个文件
    /**
     * åˆ é™¤å•个文件
     *
     * @param   fileName    è¢«åˆ é™¤æ–‡ä»¶çš„æ–‡ä»¶å
     * @return å•个文件删除成功返回true,否则返回false
     */
@@ -934,6 +992,7 @@
    /**
     * èŽ·å–æ–‡ä»¶åç§°  æœ€æ–°ä¿®æ”¹æ—¶é—´ map
     *
     * @param path
     * @return
     */
@@ -945,10 +1004,8 @@
            return null;
        }
        Map<String, String> fileTimeName = Maps.newHashMap();
        for(File f:fs)
        {
            if(f.isFile())
            {
        for (File f : fs) {
            if (f.isFile()) {
                String fileName = f.toString().replace(path+"\\","");
                fileTimeName.put(this.set_fileInfo(f.toString()),fileName);
            }
@@ -958,17 +1015,16 @@
    /**
     * èŽ·å–æ–‡ä»¶æœ€è¿‘ä¿®æ”¹æ—¶é—´
     *
     * @param file_name æ–‡ä»¶å…¨è·¯å¾„
     * @return
     */
    public String set_fileInfo(String file_name)
    {
    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
        {
        try {
            attr = basicview.readAttributes();
            //创建时间
@@ -977,8 +1033,7 @@
            Date lastmodfiyTimeDate=new Date(attr.lastModifiedTime().toMillis());
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            time = df.format(lastmodfiyTimeDate);
        } catch (Exception e)
        {
        } catch (Exception e) {
            e.printStackTrace();
        }
        return time;
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;
        }
@@ -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;
                    }
                }
                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");
        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);
        //f1w09    è¯·ä¼‘假结束时间                end_time    ç»“束时间
        }
        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();
        }
        baseDao.add(dataTableEntity);
            if (dataTableEntity.getRows() > 50000) {
                batchAddData.add(dataTableEntity);
                dataTableEntity = new 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,10 +3545,14 @@
            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);
            try {
            FieldSetEntity tableFs = new FieldSetEntity();
            tableFs.setTableName(this.originalTable.getString(taName));
            //key ä¸ºæœ¬è¡¨å­—段   value ä¸ºæ•°æ®æºå­—段
@@ -3452,7 +3576,11 @@
                    }
                }
                if(StringUtils.isEmpty(tableFs.getString(key))){
                    tableFs.setValue(key,dataFs.getString(map.get(key)));
                    }
                    if (tableFs.getTableName().equalsIgnoreCase("sfgl")) {
                        tableFs.setValue("is_print", "0");
                }
            }
            if("bgyplyb".equals(tableFs.getTableName()) && "1208".equals(dataFs.getString("bg00"))){
@@ -3468,16 +3596,39 @@
                    }
                }
            }
            String uuid = "";
                String uuid = UUID.randomUUID().toString();
            try {
                uuid = baseDao.add(tableFs);
                    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();
            }
        }
        //批量插入数据
        batchAddData.add(dt);
        //同步完一张表数据后清空json数据
        fieldTypeJson.clear();
        DataTableEntity subTble = null;
@@ -3489,6 +3640,7 @@
            SpringMVCContextHolder.getSystemLogger().error(e);
            throw e;
        }
        try {
        for (int i = 0; i < subTble.getRows(); i++) {
            FieldSetEntity sf = subTble.getFieldSetEntity(i);
            String a[] = {sf.getString("st02"), sf.getString("st03"), taName};
@@ -3496,6 +3648,11 @@
                isNew = false;
            }
            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,26 +5360,31 @@
            } 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);
                System.out.println(1);
                }
            } else {
//            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")
@@ -5192,19 +5395,19 @@
                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();