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;
|
import com.google.common.collect.Maps;
|
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;
|
import com.product.core.entity.DataTableEntity;
|
import com.product.core.entity.FieldMetaEntity;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.entity.RequestParameterEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.core.service.support.AbstractBaseService;
|
import com.product.core.spring.context.SpringMVCContextHolder;
|
import com.product.core.util.CodeUtil;
|
import com.product.data.sync.config.CmnConst;
|
import com.product.data.sync.config.SystemCode;
|
import com.product.data.sync.service.FeDataDSService;
|
import com.product.data.sync.service.SyFeDataService;
|
import com.product.data.sync.service.media.GdMediaUtil;
|
import com.product.file.service.FileManagerService;
|
import com.product.util.BaseDaoServiceImpl;
|
import com.product.util.BaseUtil;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import java.io.File;
|
import java.sql.Connection;
|
import java.sql.PreparedStatement;
|
import java.sql.SQLException;
|
import java.util.*;
|
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.Executors;
|
|
/**
|
* Copyright LX
|
*
|
* @Title: BusinessDataSync
|
* @Project: product-server
|
* @date: 2021-09-30 14:19
|
* @author: lx
|
* @Description: 线程同步业务数据
|
*/
|
public class BusinessDataSync extends AbstractBaseService implements Runnable {
|
private static Logger logger = LoggerFactory.getLogger(SyFeDataService.class);
|
public BaseDao baseDao;
|
|
BatchAddData batchAddData;
|
|
@Override
|
public BaseDao getBaseDao() {
|
return baseDao;
|
}
|
|
@Override
|
public void setBaseDao(BaseDao baseDao) {
|
this.baseDao = baseDao;
|
}
|
|
FileManagerService fileManagerService;
|
|
public FileManagerService getFileManagerService() {
|
return fileManagerService;
|
}
|
|
public void setFileManagerService(FileManagerService fileManagerService) {
|
this.fileManagerService = fileManagerService;
|
}
|
|
SystemMenusService systemMenusService;
|
|
public SystemMenusService getSystemMenusService() {
|
return systemMenusService;
|
}
|
|
public void setSystemMenusService(SystemMenusService systemMenusService) {
|
this.systemMenusService = systemMenusService;
|
}
|
|
private FeDataDSService feDataDSService;
|
|
public FeDataDSService getFeDataDSService() {
|
return feDataDSService;
|
}
|
|
public void setFeDataDSService(FeDataDSService feDataDSService) {
|
this.feDataDSService = feDataDSService;
|
}
|
|
@Autowired
|
public GdMediaUtil gdMediaUtil;
|
|
public GdMediaUtil getGdMediaUtil() {
|
return gdMediaUtil;
|
}
|
|
public void setGdMediaUtil(GdMediaUtil gdMediaUtil) {
|
this.gdMediaUtil = gdMediaUtil;
|
}
|
|
|
public void setBatchAddData(BatchAddData batchAddData) {
|
this.batchAddData = batchAddData;
|
}
|
|
//公司fe id 对应 产品uuid
|
Map<String, FieldSetEntity> OrgIdUUIDmap = Maps.newHashMap();
|
|
//fe 人员id 对应 userid
|
private JSONObject userIdJson = new JSONObject();
|
//user_id 与签名 uuid
|
private JSONObject userIdSignature = new JSONObject();
|
//用户userid 员工Fse
|
private JSONObject userIdStaffFse = new JSONObject();
|
//fe 部门id 对应 机构uuid
|
private JSONObject groupJson = new JSONObject();
|
//fe 部门id 对应 机构的公司uuid
|
private JSONObject orgLevelJson = new JSONObject();
|
//字段类型关联
|
private JSONObject fieldTypeJson = new JSONObject();
|
//流程nodes fe id 对应 产品uuid
|
private JSONObject nodesIdUUID = new JSONObject();
|
//源数据表名 本数据表名
|
private JSONObject originalTable = new JSONObject();
|
//源功能名称
|
private String functionName;
|
//唯一字段
|
private String pk;
|
//主表表名
|
private String masterTableName;
|
//源表名与uuid
|
private Map<String, String> originalUuid = Maps.newHashMap();
|
//协同办公 源流程数据PARENTGUID 对应本数据
|
private Map<String, DataTableEntity> parentGuidData = Maps.newHashMap();
|
//表唯一标识 和本表uuid
|
private JSONObject pxMap = new JSONObject();
|
//岗位id 岗位uuid
|
private JSONObject postJson = new JSONObject();
|
//附件字段
|
private String attachmentValue = "";
|
//已开发公共功能 公告管理 问卷管理 考勤管理 协同办公 会议管理
|
// 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;
|
}
|
|
public void setClientUUID(String clientUUID) {
|
this.clientUUID = clientUUID;
|
}
|
|
//方法Code
|
private String tricode_funs;
|
|
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;
|
for (int i = 0; i < this.funTable.size(); i++) {
|
if (str.equals(this.funTable.get(i))) {
|
a = true;
|
}
|
}
|
return a;
|
}
|
|
/**
|
* 封装单位部门 人员对应Json
|
*/
|
public void packageDepartmentPersonnel() {
|
DataTableEntity staffsData = baseDao.listTable("product_sys_staffs");
|
for (int i = 0; i < staffsData.getRows(); i++) {
|
//数据源用户id
|
userIdJson.put(staffsData.getString(i, "remark"), staffsData.getString(i, "user_id"));
|
//用户user_id 对应staffs uuid
|
userIdStaffFse.put(staffsData.getString(i, "user_id"), staffsData.getFieldSetEntity(i));
|
}
|
//查询有签名的用户
|
DataTableEntity userSignatureData = baseDao.listTable("SELECT * FROM product_sys_users WHERE user_signature is not null", new String[]{});
|
for (int i = 0; i < userSignatureData.getRows(); i++) {
|
userIdSignature.put(userSignatureData.getString(i, "user_id"), userSignatureData.getString(i, "user_signature"));
|
}
|
DataTableEntity orgData = baseDao.listTable("product_sys_org_levels");
|
for (int i = 0; i < orgData.getRows(); i++) {
|
//源数据id 部门uuid
|
groupJson.put(orgData.getString(i, "sequence"), orgData.getString(i, "uuid"));
|
//公司uuid
|
orgLevelJson.put(orgData.getString(i, "sequence"), orgData.getString(i, "org_level_uuid"));
|
}
|
DataTableEntity postData = baseDao.listTable("product_sys_job_posts");
|
for (int i = 0; i < orgData.getRows(); i++) {
|
//岗位id 岗位uuid
|
postJson.put(postData.getString(i, "sequence"), postData.getString(i, "uuid"));
|
}
|
}
|
|
/**
|
* 同步表及表数据
|
*
|
* @param conn 连接
|
* @param funCode 功能code
|
* @throws SQLException
|
*/
|
private String synchronizeTablesData(Connection conn, String funCode) throws SQLException {
|
FieldSetEntity Orlfs = null;
|
try {
|
logger.info("功能code:" + funCode);
|
Orlfs = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.SYS_FUNCTION", "SF05=?", new Object[]{funCode});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
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;
|
try {
|
//查询流程是否绑定表
|
modelFse = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.wf_model", "wm05=(SELECT se16 FROM fe_base5.SYS_EVENT where se01=? and se08 = 1)", new Object[]{funCode
|
});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
if (modelFse == null) {
|
return null;
|
}
|
String wm04 = modelFse.getString("wm04");
|
if (BaseUtil.strIsNull(wm04) || wm04.indexOf(".") == -1) {
|
return null;
|
} else {
|
sf28 = wm04;
|
}
|
}
|
//判断是否存在已开发功能的表
|
//如果是已开发功能定义 通过自己定义的数据关联 同步数据
|
String[] sf28s = sf28.split("\\.");
|
try {
|
this.syncTable(sf28s, !isStr(sf28), null, conn);
|
} catch (Exception e) {
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
logger.error("synchronizeTablesData", e);
|
}
|
|
return sf28;
|
}
|
|
/**
|
* 获取userId
|
* 解析多选人员,部门,岗位
|
*
|
* @param receivers 字段值
|
*/
|
public String getUserIds(Connection conn, String receivers) {
|
String[] receiversArr = receivers.split(",");
|
Set<String> extentArr = new HashSet<>();
|
try {
|
//查询公司部门表数据
|
for (int j = 0; j < receiversArr.length; j++) {
|
if (receiversArr[j].contains("[")) {
|
String companyId = receiversArr[j].replace("[", "").replace("]", "");
|
StringBuffer sql = new StringBuffer();
|
sql.append(" SELECT * FROM FE_BASE5.sys_users WHERE SU03 like CONCAT(CONCAT('%',(SELECT SG03 FROM fe_base5.sys_group WHERE SG00 = " + companyId + ")), '%') ");
|
//人员数据
|
DataTableEntity dataTableEntity = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{});
|
String[] remark = new String[dataTableEntity.getRows()];
|
for (int i = 0; i < dataTableEntity.getRows(); i++) {
|
remark[i] = dataTableEntity.getString(i, "su00");
|
}
|
|
DataTableEntity userData = baseDao.listTable("product_sys_staffs", BaseUtil.buildQuestionMarkFilter("remark", remark.length, true), remark);
|
|
if (!BaseUtil.dataTableIsEmpty(userData)) {
|
for (int i = 0; i < userData.getRows(); i++) {
|
extentArr.add(userData.getString(i, "user_id"));
|
}
|
}
|
//{岗位}
|
} else if (receiversArr[j].contains("{")) {
|
String postId = receiversArr[j].replace("{", "").replace("}", "");
|
StringBuffer sql = new StringBuffer();
|
sql.append(" SELECT * FROM FE_BASE5.sys_users WHERE SU34 = " + postId);
|
//人员数据
|
DataTableEntity dataTableEntity = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{});
|
String[] remark = new String[dataTableEntity.getRows()];
|
for (int i = 0; i < dataTableEntity.getRows(); i++) {
|
remark[i] = dataTableEntity.getString(i, "su00");
|
}
|
|
DataTableEntity userData = baseDao.listTable("product_sys_staffs", BaseUtil.buildQuestionMarkFilter("remark", remark.length, true), remark);
|
|
if (!BaseUtil.dataTableIsEmpty(userData)) {
|
for (int i = 0; i < userData.getRows(); i++) {
|
extentArr.add(userData.getString(i, "user_id"));
|
}
|
}
|
} else {
|
String userId = userIdJson.getString(receiversArr[j]);
|
if (null == userId) {
|
continue;
|
}
|
extentArr.add(userId);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
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);
|
}
|
}
|
|
/**
|
* 查询子表信息
|
*
|
* @param conn
|
* @param subTableName 子表名
|
* @param fieldName 字段名
|
* @param field 字段值
|
* @return
|
* @throws SQLException
|
*/
|
private DataTableEntity getSubDt(Connection conn, String subTableName, String fieldName, String field) throws SQLException {
|
DataTableEntity noticeDt = null;
|
try {
|
noticeDt = BaseDaoServiceImpl.getDataTable(conn, subTableName, fieldName + "=?", new Object[]{field});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
return noticeDt;
|
}
|
|
/**
|
* 同步问卷调查 0
|
*
|
* @param conn
|
* @param tableName
|
* @throws SQLException
|
*/
|
private void syncResearchTopic(Connection conn, String tableName) throws SQLException {
|
//判断是否是已经同步过的表
|
DataTableEntity dataTable = baseDao.listTable("product_oa_questionnaire");
|
if (!BaseUtil.dataTableIsEmpty(dataTable)) {
|
return;
|
}
|
DataTableEntity researchTopicDt = null;
|
try {
|
researchTopicDt = BaseDaoServiceImpl.getDataTable(conn, tableName, "", new Object[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
JSONObject qSubIdUUIDMap = new JSONObject();
|
JSONObject qSubOptionIdUUIDMap = new JSONObject();
|
|
for (int i = 0; i < researchTopicDt.getRows(); i++) {
|
FieldSetEntity feFs = researchTopicDt.getFieldSetEntity(i);
|
FieldSetEntity fs = new FieldSetEntity();
|
//问卷管理
|
fs.setTableName("product_oa_questionnaire");
|
//问卷标题
|
fs.setValue("questionnaire_title", feFs.getString("rt01"));
|
//问卷说明
|
fs.setValue("questionnaire_explain", feFs.getString("rt01"));
|
//问卷内容
|
fs.setValue("questionnaire_content", feFs.getString("rt02"));
|
//是否匿名(1.是、0.否)
|
fs.setValue("is_anonymous", feFs.getString("rt06"));
|
String[] RT13Arr = feFs.getString("rt13").split(",");
|
ArrayList<String> votersArr = new ArrayList<>();
|
for (int j = 0; j < RT13Arr.length; j++) {
|
RT13Arr[j] = RT13Arr[j].replace("[", "");
|
RT13Arr[j] = RT13Arr[j].replace("]", "");
|
String userId = userIdJson.getString(RT13Arr[j]);
|
}
|
if (votersArr.size() == 0) {
|
continue;
|
}
|
//参与投票人
|
fs.setValue("voters", StringUtils.join(votersArr, ","));
|
//调查截止日期
|
fs.setValue("deadline", feFs.getString("rt04"));
|
String[] RT15Arr = feFs.getString("rt15").split(",");
|
String[] resultViewerArr = new String[RT15Arr.length];
|
for (int j = 0; j < RT15Arr.length; j++) {
|
resultViewerArr[j] = userIdJson.getString(RT15Arr[j]);
|
}
|
//结果查看人
|
fs.setValue("result_viewer", StringUtils.join(resultViewerArr, ","));
|
//发布人
|
fs.setValue("publisher", userIdJson.getString(feFs.getString("rt08")));
|
//发布时间
|
fs.setValue("pubdate", feFs.getDate("rt03"));
|
//是否发布
|
fs.setValue("is_publish", feFs.getString("rt05"));
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
//主表uuid
|
String uuid = baseDao.add(fs);
|
DataTableEntity subFeFs = getSubDt(conn, "FE_BASE5.RESEARCH_SUB", "RS01", feFs.getString("rt00"));
|
for (int j = 0; j < subFeFs.getRows(); j++) {
|
FieldSetEntity feSubFs = subFeFs.getFieldSetEntity(i);
|
FieldSetEntity subFs = new FieldSetEntity();
|
//问卷管理子表
|
subFs.setTableName("product_oa_questionnaire_sub");
|
// 主表uuid
|
subFs.setValue("questionnaire_uuid", uuid);
|
//内容类型(1.单选题目、2.复选题目、3.简答题)
|
subFs.setValue("content_type", feSubFs.getInteger("rs04") + 1);
|
//选项题目
|
subFs.setValue("option_topic", feSubFs.getString("rs02"));
|
//题目说明
|
subFs.setValue("title_description", feSubFs.getString("rs03"));
|
//多选择类型(1.最多、2.最少、3.必选)
|
subFs.setValue("option_type", feSubFs.getString("rs07"));
|
//可选择项数
|
subFs.setValue("option_num", feSubFs.getString("rs06"));
|
String subUUID = baseDao.add(subFs);
|
qSubIdUUIDMap.put(subUUID, feSubFs.getString("rs00"));
|
if (feSubFs.getInteger("rs04") != 2) {
|
DataTableEntity subFeFsto = getSubDt(conn, "fe_base5.RESEARCH_OPTION", "RO01", feSubFs.getString("RS00"));
|
for (int k = 0; k < subFeFsto.getRows(); k++) {
|
FieldSetEntity feSubFsto = subFeFsto.getFieldSetEntity(i);
|
FieldSetEntity subFsto = new FieldSetEntity();
|
subFsto.setTableName("product_oa_questionnaire_sub_option");
|
//问卷管理子表uuid
|
subFsto.setValue("parent_uuid", subUUID);
|
//选项内容
|
subFsto.setValue("option_content", feSubFsto.getString("ro02"));
|
//是否可填(1.是、0.否)
|
subFsto.setValue("is_write", feSubFsto.getString("ro04"));
|
//选项序号
|
subFsto.setValue("option_num", numberToLetter(k + 1));
|
String subUUIDto = baseDao.add(subFsto);
|
qSubOptionIdUUIDMap.put(feSubFsto.getString("ro00"), subUUIDto);
|
}
|
}
|
}
|
DataTableEntity vFeFs = getSubDt(conn, "fe_base5.RESEARCH_VOTER", "rv01", feFs.getString("rt00"));
|
for (int j = 0; j < vFeFs.getRows(); j++) {
|
FieldSetEntity feSubFs = vFeFs.getFieldSetEntity(j);
|
FieldSetEntity subFs = new FieldSetEntity();
|
subFs.setTableName("product_oa_questionnaire_mine");
|
subFs.setValue("questionnaire_uuid", uuid);
|
subFs.setValue("voting_status", feSubFs.getString("rv06"));
|
logger.info("用户user_id:" + userIdJson.getString(feSubFs.getString("rv04")));
|
subFs.setValue("vote_user", userIdJson.getString(feSubFs.getString("rv04")));
|
subFs.setValue("subject_uuid", qSubIdUUIDMap.getString(feSubFs.getString("rv02")));
|
subFs.setValue("option_answer_uuid", qSubOptionIdUUIDMap.getString(feSubFs.getString("rv03")));
|
subFs.setValue("answer_contents", feSubFs.getString("rv07"));
|
baseDao.add(subFs);
|
}
|
}
|
}
|
|
//数字转字母 1-26 : A-Z
|
private String numberToLetter(int num) {
|
if (num <= 0) {
|
return null;
|
}
|
String letter = "";
|
num--;
|
do {
|
if (letter.length() > 0) {
|
num--;
|
}
|
letter = ((char) (num % 26 + (int) 'A')) + letter;
|
num = (int) ((num - num % 26) / 26);
|
} while (num > 0);
|
|
return letter;
|
}
|
|
//车辆基本信息表
|
private void syncCarInfo(Connection conn, String tableName) throws SQLException {
|
//判断是否是已经同步过的表
|
DataTableEntity dataTable = baseDao.listTable("product_oa_car_driver_info");
|
if (!BaseUtil.dataTableIsEmpty(dataTable)) {
|
return;
|
}
|
//同步司机信息
|
DataTableEntity driverInfoDt = null;
|
try {
|
driverInfoDt = BaseDaoServiceImpl.getDataTable(conn, "fe_app5.CHAUFFEUR_INFO", "", new Object[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
|
JSONObject driverIdUUIDMap = new JSONObject();
|
|
for (int i = 0; i < driverInfoDt.getRows(); i++) {
|
FieldSetEntity fsFe = driverInfoDt.getFieldSetEntity(i);
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName("product_oa_car_driver_info");
|
fs.setValue("name", fsFe.getString("CHAUFFEUR_NAME"));
|
fs.setValue("driver_license_num", fsFe.getString("LICENCE_NO"));
|
fs.setValue("IDCard_num", fsFe.getString("IDENTITY_CARD_NO"));
|
fs.setValue("driving_model", carType(fsFe.getString("DRIVE_CAR_MODEL")));
|
fs.setValue("driving_experience", fsFe.getString("DRIVE_YEAR"));
|
fs.setValue("phone_num", fsFe.getString("HANDSET_NO"));
|
fs.setValue("address", fsFe.getString("ADDRESS"));
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
String uuid = baseDao.add(fs);
|
driverIdUUIDMap.put("ID", uuid);
|
}
|
//同步车辆基本信息
|
DataTableEntity researchTopicDt = null;
|
try {
|
researchTopicDt = BaseDaoServiceImpl.getDataTable(conn, tableName, "", new Object[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
JSONObject carBrandUUIDMap = new JSONObject();
|
JSONObject carIdUUIDMap = new JSONObject();
|
|
for (int i = 0; i < researchTopicDt.getRows(); i++) {
|
FieldSetEntity fsFe = researchTopicDt.getFieldSetEntity(i);
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName("product_oa_car_info");
|
fs.setValue("plate_number", fsFe.getString("CAR_BRAND_NO"));
|
fs.setValue("vehicle_status", fsFe.getString("CAR_STATE"));
|
// fs.setValue("org_level_uuid", OrgIdUUIDmap.getString(fsFe.getString("CAR_BRAND_NO")));
|
fs.setValue("vehicle_type", carType(fsFe.getString("CAR_TYPE")));
|
fs.setValue("leaders", userIdJson.getString(fsFe.getString("FROM_LEADER")));
|
fs.setValue("purchase_date", fsFe.getDate("BUY_DATE"));
|
fs.setValue("brand_series", fsFe.getString("ROAD_BRIDGE_CHARGE"));
|
fs.setValue("purchase_price", fsFe.getString("BUY_PRICE"));
|
fs.setValue("vehicle_use", fsFe.getString("OIL_CHARGE"));
|
fs.setValue("seats_num", fsFe.getString("SEAT_AMOUNT"));
|
fs.setValue("fuel_type", fsFe.getString("OIL_TYPE"));
|
fs.setValue("owner_name", fsFe.getString("MASTER_NAME"));
|
fs.setValue("vehicle_certificate", fsFe.getString("CAR_PAPER"));
|
//附件
|
// fs.setValue("attachment_uuid",);
|
if (!fsFe.getString("DRIVER").isEmpty()) {
|
fs.setValue("driver_id", driverIdUUIDMap.getString(fsFe.getString("DRIVER")));
|
}
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
String uuid = baseDao.add(fs);
|
carBrandUUIDMap.put(fsFe.getString("CAR_BRAND_NO"), uuid);
|
carIdUUIDMap.put(fsFe.getString("ID"), uuid);
|
}
|
//同步车辆出险事故信息表
|
DataTableEntity carSlipDt = null;
|
try {
|
carSlipDt = BaseDaoServiceImpl.getDataTable(conn, "fe_app5.CAR_SLIP", "", new Object[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
for (int i = 0; i < carSlipDt.getRows(); i++) {
|
FieldSetEntity fsFe = carSlipDt.getFieldSetEntity(i);
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName("product_oa_car_accident_record");
|
fs.setValue("vehicle_info_uuid", carBrandUUIDMap.getString(fsFe.getString("CAR_BRAND_NO")));
|
fs.setValue("accident_time", fsFe.getDate("SLIP_DATE"));
|
fs.setValue("driver_info_uuid", driverIdUUIDMap.getString(fsFe.getString("DRIVE_PERSON")));
|
fs.setValue("accident_location", fsFe.getDate("SLIP_ADDRESS"));
|
fs.setValue("accident_cause", fsFe.getDate("SLIP_REASON"));
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
fs.setValue("flow_flag", 2);
|
baseDao.add(fs);
|
}
|
//同步车辆申请信息表
|
DataTableEntity carApplicationDt = null;
|
try {
|
carApplicationDt = BaseDaoServiceImpl.getDataTable(conn, "fe_app5.CAR_APPLICATION", "", new Object[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
for (int i = 0; i < carApplicationDt.getRows(); i++) {
|
FieldSetEntity fsFe = carApplicationDt.getFieldSetEntity(i);
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName("product_oa_car_application");
|
fs.setValue("applicant", userIdJson.getString(fsFe.getString("PROPOSER")));
|
// fs.setValue("org_level_uuid", OrgIdUUIDmap.getString(fsFe.getString("SECTION_DEPARTMENT")));
|
fs.setValue("applicattion_time", fsFe.getDate("APPLICATION_DATE"));
|
fs.setValue("start_place", fsFe.getString("START_END_ADDRESS"));
|
fs.setValue("person_board", fsFe.getString("FOLLOW_PERSON"));
|
fs.setValue("vehicle_line", fsFe.getString("CAR_LINE"));
|
fs.setValue("scheduled_start_time", fsFe.getDate("USE_START_DATE"));
|
fs.setValue("scheduled_end_time", fsFe.getDate("USE_END_DATE"));
|
fs.setValue("project_name", fsFe.getString("USE_END_DATE"));
|
fs.setValue("use_reason", fsFe.getString("USE_REASON"));
|
if (!fsFe.getString("DRIVER").isEmpty()) {
|
fs.setValue("driver_info_uuid", driverIdUUIDMap.getString(fsFe.getString("DRIVER")));
|
}
|
fs.setValue("status", fsFe.getString("STATUS"));
|
fs.setValue("driving_time", fsFe.getString("START_DATE"));
|
fs.setValue("return_time", fsFe.getString("RETURN_DATE"));
|
fs.setValue("actual_line", fsFe.getString("FACT_WAY"));
|
fs.setValue("repair_cost", fsFe.getString("id04"));
|
fs.setValue("fuel_charge", fsFe.getString("OIL_CHARGE"));
|
fs.setValue("toll", fsFe.getString("id05"));
|
fs.setValue("other_expenses", fsFe.getString("id01"));
|
fs.setValue("total_cost", fsFe.getString("id02"));
|
fs.setValue("manager_confirmation", fsFe.getString("id08"));
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
fs.setValue("flow_flag", 2);
|
baseDao.add(fs);
|
}
|
}
|
|
private String carType(String type) {
|
String reType = "";
|
switch (type) {
|
case "轿车":
|
reType = "1";
|
break;
|
case "货车":
|
reType = "2";
|
break;
|
default:
|
reType = "3";
|
}
|
return reType;
|
}
|
|
/**
|
* 同步已开发功能数据
|
*
|
* @param tableName 表名
|
* @return
|
* @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"});
|
}
|
//考勤表 需同步关联数据如请假表 外出表
|
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("=================考勤同步成功===============");
|
}
|
//协同办公
|
if (tableName.equals("FE_BASE5.SYS_COLLABORATIVE")) {
|
this.originalTable.put("SYS_COLLABORATIVE", "product_oa_cooperates");
|
//协同办公数据
|
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"});
|
System.out.println("=================协同办公同步成功===============");
|
}
|
//会议同步
|
if (tableName.equals("FE_APP5.BS_MEETING_FLOW")) {
|
//判断是否是已经同步过的表
|
DataTableEntity dataTable = baseDao.listTable("product_oa_conference_room_config");
|
if (!BaseUtil.dataTableIsEmpty(dataTable)) {
|
return;
|
}
|
//会议室同步
|
Map<String, String> map = this.meetingRoomSync(conn, "FE_APP5.BS_MEETINGROOM");
|
this.originalTable.put("BS_MEETINGROOM", "product_oa_conference_room_config");
|
//会议同步
|
this.meetingSynchronous(conn, tableName, map);
|
this.originalTable.put("BS_MEETING_FLOW", "product_oa_conference_apply");
|
//单独同步会议流程 待调整
|
FieldSetEntity user = baseDao.getFieldSetByFilter("product_sys_org_manager", " manager_type = ? ", new String[]{"2"}, false);
|
//同步会议流程
|
try {
|
this.attachmentValue = ",attachment,";
|
//迁移 wf_model流程模块表
|
String typeCode = this.syncModel("035-411-000", conn, "24917f78-c672-4432-b7a8-a7a2dbc9f45a", "FE_APP5.BS_MEETING_FLOW", null, 1, null, false);
|
//根据要求流程要同步两次 相同流程的typeCode相同
|
if (!BaseUtil.strIsNull(typeCode)) {
|
this.syncModel("035-411-000", conn, "24917f78-c672-4432-b7a8-a7a2dbc9f45a", "FE_APP5.BS_MEETING_FLOW", "00000000-0000-0000-0000-000000000000", user.getInteger("user_id"), typeCode, true);
|
}
|
//mvc 会议页面绑定新的流程
|
FieldSetEntity page = baseDao.getFieldSet("product_sys_mvc_page", "5ab3ef19-ba6d-4d47-8082-3e21fa1f0a0f", false);
|
page.setValue("flow_uuid", typeCode);
|
baseDao.update(page);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
System.out.println("=================会议管理同步成功===============");
|
}
|
}
|
|
/**
|
* 同步考勤
|
*
|
* @param conn
|
* @throws SQLException
|
*/
|
private void synchronousClock(Connection conn) throws Exception {
|
//同步请假 PLEASELEAVE
|
DataTableEntity pleaseleave = null;
|
try {
|
pleaseleave = BaseDaoServiceImpl.getDataTable(conn, "FE_APP5.PLEASELEAVE", "", new Object[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
try {
|
this.leaveApplyFor(pleaseleave);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
}
|
FieldSetEntity user = baseDao.getFieldSetByFilter("product_sys_org_manager", " manager_type = ? ", new String[]{"2"}, false);
|
//单独同步请假流程
|
try {
|
this.attachmentValue = ",accessory_uuid,";
|
//迁移 wf_model流程模块表
|
String typeCode = this.syncModel("019-015-000", conn, "66a6ff4b-1c60-4dfe-a544-4bac81d17efe", "FE_APP5.PLEASELEAVE", null, 1, null, false);
|
//根据要求流程要同步两次 相同流程的typeCode相同
|
if (!BaseUtil.strIsNull(typeCode)) {
|
this.syncModel("019-015-000", conn, "66a6ff4b-1c60-4dfe-a544-4bac81d17efe", "FE_APP5.PLEASELEAVE", "00000000-0000-0000-0000-000000000000", user.getInteger("user_id"), typeCode, true);
|
}
|
//mvc 会议页面绑定新的流程
|
FieldSetEntity page = baseDao.getFieldSet("product_sys_mvc_page", "77897853-4059-4b57-ac65-45ff8d6f4fe3", false);
|
page.setValue("flow_uuid", typeCode);
|
baseDao.update(page);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
//同步外出 FT_1_WCDJB00
|
//同步外出里面的数据 含外出 出差 请假
|
DataTableEntity wcdj = null;
|
try {
|
wcdj = BaseDaoServiceImpl.getDataTable(conn, "SELECT TO_NUMBER(to_date(to_char(A.F1W09,'yyyymmdd'),'yyyymmdd')- to_date(to_char(A.F1W08,'yyyymmdd'),'yyyymmdd')) + 1 as DAY,A.* FROM FE_APP5.FT_1_WCDJB00 A", new Object[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
this.goOutApplyFor(wcdj);
|
//同步考勤
|
DataTableEntity clockDt = null;
|
try {
|
clockDt = BaseDaoServiceImpl.getDataTable(conn, "FE_APP5.APP_KQLRB", "", new Object[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
this.synchronousClock(clockDt);
|
}
|
|
|
/**
|
* 同步请假申请
|
*
|
* @param pleaseleave 请假data数据
|
*/
|
private void leaveApplyFor(DataTableEntity pleaseleave) throws BaseException {
|
//同步请假数据
|
if (!BaseUtil.dataTableIsEmpty(pleaseleave)) {
|
for (int i = 0; i < pleaseleave.getRows(); i++) {
|
FieldSetEntity leaveFse = pleaseleave.getFieldSetEntity(i);
|
FieldSetEntity fieldSetEntity = new FieldSetEntity();
|
fieldSetEntity.setTableName("product_oa_ask_for_leave");
|
fieldSetEntity.setValue("id", leaveFse.getInteger("pl00"));
|
//PL11 请休假开始时间 fill_in_time 填单时间
|
String pl11 = leaveFse.getString("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");
|
if (BaseUtil.strIsNull(pl15)) {
|
if (BaseUtil.strIsNull(pl11)) {
|
continue;
|
} else {
|
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 请假原因
|
String pl09 = leaveFse.getString("pl09");
|
//PL10 请休假类别 leave_type 请假类型
|
String pl10 = leaveFse.getString("pl10");
|
if (BaseUtil.strIsNull(pl09)) {
|
if (BaseUtil.strIsNull(pl10)) {
|
continue;
|
} else {
|
pl09 = pl10;
|
}
|
}
|
fieldSetEntity.setValue("cause", pl09);
|
//PL01 申请人姓名 created_by 创建人
|
String userId = userIdJson.getString(leaveFse.getString("pl01"));
|
if (BaseUtil.strIsNull(userId)) {
|
continue;
|
}
|
fieldSetEntity.setValue("created_by", userId);
|
//staff_uuid 员工uuid
|
FieldSetEntity staff = (FieldSetEntity) this.userIdStaffFse.get(userId);
|
fieldSetEntity.setValue("staff_uuid", staff.getUUID());
|
//PL14 科室 org_level_uuid 公司uuid
|
String dept = leaveFse.getString("pl14");
|
String org_level_uuid = this.orgLevelJson.getString(dept);
|
if (BaseUtil.strIsNull(org_level_uuid)) {
|
continue;
|
}
|
fieldSetEntity.setValue("org_level_uuid", org_level_uuid);
|
//部门
|
fieldSetEntity.setValue("department_uuid", this.groupJson.getString(dept));
|
|
String leave_type;
|
if (BaseUtil.strIsNull(pl10)) {
|
//改为年假
|
leave_type = "7";
|
} else {
|
switch (pl10) {
|
case "产假":
|
leave_type = "5";
|
break;
|
//改为年假
|
case "休假":
|
leave_type = "7";
|
break;
|
case "事假":
|
leave_type = "1";
|
break;
|
case "婚假":
|
leave_type = "9";
|
break;
|
case "病假":
|
leave_type = "2";
|
break;
|
default:
|
//休假 改为年假
|
leave_type = "7";
|
}
|
}
|
fieldSetEntity.setValue("leave_type", leave_type);
|
fieldSetEntity.setValue("flow_flag", leaveFse.getString("status"));
|
String uuid = baseDao.add(fieldSetEntity);
|
pxMap.put("PLEASELEAVE" + leaveFse.getString("pl00"), uuid);
|
}
|
}
|
}
|
|
/**
|
* 同步外出申请 分别同步到外出申请 出差申请 请假申请
|
*
|
* @param wcdj 外出data数据
|
*/
|
private void goOutApplyFor(DataTableEntity wcdj) throws SQLException {
|
if (!BaseUtil.dataTableIsEmpty(wcdj)) {
|
for (int i = 0; i < wcdj.getRows(); i++) {
|
FieldSetEntity fse = wcdj.getFieldSetEntity(i);
|
//F1W05 外出类型
|
String f1w05 = fse.getString("f1w05");
|
if (!BaseUtil.strIsNull(f1w05)) {
|
switch (f1w05) {
|
//出差 同步外出里面出差数据
|
case "10":
|
this.syncEvection(fse);
|
break;
|
//外出开会 同步外出里面外出数据
|
case "11":
|
this.synchronousOut(fse, "0");
|
break;
|
//外勤
|
case "12":
|
this.synchronousOut(fse, "1");
|
break;
|
//调休
|
case "13":
|
this.synchronizationLeave(fse, "4", "调休");
|
break;
|
//休假
|
case "14":
|
this.synchronizationLeave(fse, "11", "休假");
|
break;
|
//病假
|
case "15":
|
this.synchronizationLeave(fse, "2", "病假");
|
break;
|
//事假
|
case "16":
|
this.synchronizationLeave(fse, "1", "事假");
|
break;
|
default:
|
break;
|
}
|
}
|
}
|
}
|
//同步外出数据
|
// if(!BaseUtil.dataTableIsEmpty(qjsq)){
|
// for (int i = 0; i < qjsq.getRows(); i++) {
|
|
// F1W01 登记人
|
// F1W02 送审标识
|
// F1W03 公司编码
|
// F1W04 申请人
|
|
// F1W06 外出事由
|
// F1W07 是否归来
|
// F1W08 外出时间
|
// F1W09 回来时间
|
// F1W10 时段
|
// F1W11 科室
|
// F1W12 备用
|
// fieldSetEntity.setTableName("product_oa_business_trip");
|
// }
|
// }
|
}
|
|
/**
|
* 外出数据同步到请假
|
*
|
* @param fse 请假数据
|
* @param type 请假类型
|
*/
|
private void synchronizationLeave(FieldSetEntity fse, String type, String typeString) {
|
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);
|
}
|
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 请假原因
|
String f1w06 = fse.getString("f1w06");
|
//若请假原因为空就用请假类型
|
if (BaseUtil.strIsNull(f1w06)) {
|
f1w06 = typeString;
|
}
|
fieldSetEntity.setValue("cause", f1w06);
|
//f1w01 登记人 created_by 创建人
|
String userId = userIdJson.getString(fse.getString("f1w01"));
|
if (BaseUtil.strIsNull(userId)) {
|
userId = userIdJson.getString(fse.getString("f1w04"));
|
if (BaseUtil.strIsNull(userId)) {
|
return;
|
}
|
}
|
fieldSetEntity.setValue("created_by", userId);
|
//staff_uuid 员工uuid
|
FieldSetEntity staff = (FieldSetEntity) this.userIdStaffFse.get(userId);
|
fieldSetEntity.setValue("staff_uuid", staff.getUUID());
|
//f1w11 科室 org_level_uuid 公司uuid
|
String dept = fse.getString("f1w11");
|
String org_level_uuid = this.orgLevelJson.getString(dept);
|
if (BaseUtil.strIsNull(org_level_uuid)) {
|
org_level_uuid = staff.getString("org_level_uuid");
|
}
|
fieldSetEntity.setValue("org_level_uuid", org_level_uuid);
|
//部门
|
String dept_uuid = this.groupJson.getString(dept);
|
if (BaseUtil.strIsNull(dept_uuid)) {
|
dept_uuid = staff.getString("dept_uuid");
|
}
|
fieldSetEntity.setValue("department_uuid", dept_uuid);
|
fieldSetEntity.setValue("leave_type", type);
|
fieldSetEntity.setValue("flow_flag", fse.getString("f1w02"));
|
try {
|
baseDao.add(fieldSetEntity);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 同步出差数据
|
*
|
* @param fse 出差数据
|
*/
|
private void syncEvection(FieldSetEntity fse) {
|
FieldSetEntity fieldSetEntity = new FieldSetEntity();
|
fieldSetEntity.setTableName("product_oa_business_trip");
|
//applicant 申请人员
|
String user_id = this.userIdJson.getString(fse.getString("f1w01"));
|
if (BaseUtil.strIsNull(user_id)) {
|
return;
|
}
|
fieldSetEntity.setValue("applicant", user_id);
|
//申请日期
|
String f1w08 = fse.getString("f1w08");
|
fieldSetEntity.setValue("application_time", f1w08);
|
//budget 预算金额
|
fieldSetEntity.setValue("budget", 0);
|
//结束时间
|
fieldSetEntity.setValue("business_last_time", fse.getString("f1w09"));
|
//出差时间
|
fieldSetEntity.setValue("business_start_time", f1w08);
|
//business_trip_place 出差地点 空
|
fieldSetEntity.setValue("business_trip_place", "[无出差地点]");
|
//创建人
|
String f1w04 = this.userIdJson.getString(fse.getString("f1w04"));
|
if (BaseUtil.strIsNull(f1w04)) {
|
f1w04 = user_id;
|
}
|
fieldSetEntity.setValue("created_by", f1w04);
|
//创建时间
|
fieldSetEntity.setValue("created_utc_datetime", f1w08);
|
// 申请部门 string 1
|
String dept = fse.getString("f1w11");
|
String department = this.groupJson.getString(dept);
|
FieldSetEntity staff = (FieldSetEntity) this.userIdStaffFse.get(user_id);
|
if (BaseUtil.strIsNull(department)) {
|
department = staff.getString("dept_uuid");
|
}
|
fieldSetEntity.setValue("department", department);
|
//documengt_number 单据编号
|
fieldSetEntity.setValue("documengt_number", "[无单据编号]");
|
//流程标识
|
fieldSetEntity.setValue("flow_flag", fse.getString("f1w02"));
|
//org_level_uuid 关联公司
|
String org_level_uuid = this.orgLevelJson.getString(dept);
|
if (BaseUtil.strIsNull(org_level_uuid)) {
|
org_level_uuid = staff.getString("org_level_uuid");
|
}
|
fieldSetEntity.setValue("org_level_uuid", org_level_uuid);
|
//post 职务(关联岗位信息表uuid)
|
fieldSetEntity.setValue("post", staff.getString("job_post_uuid"));
|
//出差天数
|
fieldSetEntity.setValue("total_days", fse.getString("day"));
|
//F1W06 外出事由
|
String f1w06 = fse.getString("f1w06");
|
if (BaseUtil.strIsNull(f1w06)) {
|
f1w06 = "出差";
|
}
|
fieldSetEntity.setValue("reasons_for_business", f1w06);
|
try {
|
baseDao.add(fieldSetEntity);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 同步外出数据
|
*
|
* @param fse 外出数据
|
*/
|
private void synchronousOut(FieldSetEntity fse, String out_type) {
|
FieldSetEntity fieldSetEntity = new FieldSetEntity();
|
fieldSetEntity.setTableName("product_oa_go_out_application");
|
//actual_start_time 实际开始时间
|
String f1w08 = fse.getString("f1w08");
|
fieldSetEntity.setValue("actual_start_time", f1w08);
|
//actual_end_time 实际结束时间
|
fieldSetEntity.setValue("actual_end_time", fse.getString("f1w09"));
|
//applicant 申请人
|
String user_id = this.userIdJson.getString(fse.getString("f1w01"));
|
//找不到员工直接退出
|
if (BaseUtil.strIsNull(user_id)) {
|
return;
|
}
|
FieldSetEntity staff = (FieldSetEntity) this.userIdStaffFse.get(user_id);
|
fieldSetEntity.setValue("applicant", user_id);
|
//applicat_time 申请时间
|
fieldSetEntity.setValue("applicat_time", f1w08);
|
//atual_time 实际用时
|
fieldSetEntity.setValue("applicat_time", fse.getString("day"));
|
//created_by 创建者,lx_sys_users表user_id
|
String f1w04 = this.userIdJson.getString(fse.getString("f1w04"));
|
if (BaseUtil.strIsNull(f1w04)) {
|
f1w04 = user_id;
|
}
|
fieldSetEntity.setValue("created_by", f1w04);
|
//created_utc_datetime 创建时间
|
fieldSetEntity.setValue("created_utc_datetime", f1w08);
|
//dept_uuid 部门
|
String dept = fse.getString("f1w11");
|
String dept_uuid = this.groupJson.getString(dept);
|
if (BaseUtil.strIsNull(dept_uuid)) {
|
dept_uuid = staff.getString("dept_uuid");
|
}
|
fieldSetEntity.setValue("dept_uuid", dept_uuid);
|
//flow_flag 流程送办默认字段,0-待发,1-在办,2-办结
|
fieldSetEntity.setValue("flow_flag", fse.getString("f1w02"));
|
//org_level_uuid 组织机构,lx_sys_org_levels表uuid
|
String org_level_uuid = this.orgLevelJson.getString(dept);
|
if (BaseUtil.strIsNull(org_level_uuid)) {
|
org_level_uuid = staff.getString("org_level_uuid");
|
}
|
fieldSetEntity.setValue("org_level_uuid", org_level_uuid);
|
fieldSetEntity.setValue("reason", fse.getString("f1w06"));
|
fieldSetEntity.setValue("out_type", out_type);
|
try {
|
baseDao.add(fieldSetEntity);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 同步考勤数据
|
*
|
* @param clockDt 外出data数据
|
*/
|
private void synchronousClock(DataTableEntity clockDt) throws Exception {
|
//同步考勤数据
|
if (!BaseUtil.dataTableIsEmpty(clockDt)) {
|
DataTableEntity dataTableEntity = new DataTableEntity();
|
FieldMetaEntity f = new FieldMetaEntity();
|
f.setTableName(new String[]{"product_oa_punch_record"});
|
dataTableEntity.setMeta(f);
|
for (int i = 0; i < clockDt.getRows(); i++) {
|
FieldSetEntity fse = clockDt.getFieldSetEntity(i);
|
FieldSetEntity fieldSetEntity = new FieldSetEntity();
|
fieldSetEntity.setTableName("product_oa_punch_record");
|
//部门id
|
String dept = fse.getString("dept");
|
fieldSetEntity.setValue("dept_uuid", this.groupJson.getString(dept));
|
String org_level_uuid = this.orgLevelJson.getString(dept);
|
if (BaseUtil.strIsNull(org_level_uuid)) {
|
org_level_uuid = this.groupJson.getString(dept);
|
}
|
//公司uuid
|
fieldSetEntity.setValue("org_level_uuid", org_level_uuid);
|
//上午上班打卡时间
|
String swdksj = fse.getString("swdksj");
|
fieldSetEntity.setValue("punch_time_one", swdksj);
|
//默认上午下班打卡时间
|
if (!BaseUtil.strIsNull(swdksj)) {
|
String defaultTime = swdksj.substring(0, 11) + "12:00:00";
|
fieldSetEntity.setValue("punch_time_three", defaultTime);
|
}
|
//上班考勤结果
|
fieldSetEntity.setValue("time_one_result", fse.getString("swkqjg"));
|
//上午mac地址
|
fieldSetEntity.setValue("mac_one", fse.getString("mac"));
|
//下午上班打卡时间
|
String xwdksj = fse.getString("xwdksj");
|
fieldSetEntity.setValue("punch_time_three", xwdksj);
|
//默认下午下班打卡时间
|
if (!BaseUtil.strIsNull(xwdksj)) {
|
String defaultTime = xwdksj.substring(0, 11) + "18:00:00";
|
fieldSetEntity.setValue("punch_time_four", defaultTime);
|
}
|
//下午mac1地址
|
fieldSetEntity.setValue("mac_two", fse.getString("mac1"));
|
//姓名
|
String userId = userIdJson.getString(fse.getString("name"));
|
if (BaseUtil.strIsNull(userId)) {
|
continue;
|
}
|
fieldSetEntity.setValue("created_by", userId);
|
//姓名
|
fieldSetEntity.setValue("created_utc_datetime", fse.getString("time01"));
|
|
//上班考勤结果
|
fieldSetEntity.setValue("time_one_result", fse.getString("swkqjg"));
|
// String swkqjg = fse.getString("swkqjg");
|
//下班考勤结果
|
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);
|
// }
|
//请休假放到请假表里面
|
// switch (xwkqjg){
|
// //正常
|
// case "0":
|
// //迟到
|
// case "1":
|
// //缺勤
|
// case "2":
|
// break;
|
// //出差 出差表
|
// case "10":
|
// break;
|
// //外出开会 外出表
|
// case "11":
|
// //外勤 外出表
|
// case "12":
|
// break;
|
// //调休 请假表
|
// case "13":
|
// //休假
|
// case "14":
|
// //病假
|
// case "15":
|
// //事假
|
// case "16":
|
// //请假
|
// case "3":
|
// //婚假
|
// case "4":
|
// //产假
|
// case "5":
|
// break;
|
// }
|
}
|
if (!BaseUtil.dataTableIsEmpty(dataTableEntity)) {
|
// baseDao.add(dataTableEntity);
|
batchAddData.add(dataTableEntity);
|
}
|
}
|
}
|
|
/**
|
* 会议室同步
|
*
|
* @param conn
|
* @param tableName
|
*/
|
private Map<String, String> meetingRoomSync(Connection conn, String tableName) throws SQLException {
|
//判断是否是已经同步过的表
|
DataTableEntity dataTable = baseDao.listTable("product_oa_conference_room_config");
|
Map<String, String> map = Maps.newHashMap();
|
if (!BaseUtil.dataTableIsEmpty(dataTable)) {
|
return map;
|
}
|
DataTableEntity meetingRoomDt = null;
|
try {
|
meetingRoomDt = BaseDaoServiceImpl.getDataTable(conn, tableName, "", new Object[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
if (!BaseUtil.dataTableIsEmpty(meetingRoomDt)) {
|
for (int i = 0; i < meetingRoomDt.getRows(); i++) {
|
FieldSetEntity fse = meetingRoomDt.getFieldSetEntity(i);
|
FieldSetEntity fieldSet = new FieldSetEntity();
|
fieldSet.setTableName("product_oa_conference_room_config");
|
//ADDRESS 地址
|
fieldSet.setValue("address", fse.getString("address"));
|
String recorded_man = userIdJson.getString(fse.getString("recorded_man"));
|
if (BaseUtil.strIsNull(recorded_man)) {
|
continue;
|
}
|
//ADMIN 管理员 manager_user 管理员
|
String admin = userIdJson.getString(fse.getString("admin"));
|
if (BaseUtil.strIsNull(admin)) {
|
admin = recorded_man;
|
}
|
fieldSet.setValue("manager_user", admin);
|
//APPLY_TIME_LIMIT 会议室申请时间限制 没有字段
|
fse.getString("apply_time_limit");
|
//ENABLED_TIME 启用时间
|
String enabled_time = fse.getString("enabled_time");
|
fieldSet.setValue("available_start_time", enabled_time);
|
//启用时间
|
fieldSet.setValue("enabled_time", enabled_time);
|
//EQUIPMENT 配置信息
|
fieldSet.setValue("equipment", fse.getString("equipment"));
|
//ID 顺序号 id 主键
|
String id = fse.getString("id");
|
fieldSet.setValue("id", id);
|
//RECORDED_DATE 录入时间 创建时间
|
fieldSet.setValue("created_utc_datetime", fse.getString("recorded_date"));
|
//RECORDED_MAN 录入人 created_by 创建人
|
fieldSet.setValue("created_by", recorded_man);
|
//REMARK 备注 remark 备注
|
fieldSet.setValue("remark", fse.getString("remark"));
|
//ROOMNAME 会议室名 room_name 会议室名称
|
fieldSet.setValue("room_name", fse.getString("roomname"));
|
//SEATS 座位数
|
fieldSet.setValue("seats", fse.getString("seats"));
|
//STATUS 会议室状态
|
int statusNum = 0;
|
if ("启用".equals(fse.getString("status"))) {
|
statusNum = 1;
|
}
|
fieldSet.setValue("status", statusNum);
|
FieldSetEntity staff = (FieldSetEntity) userIdStaffFse.get(recorded_man);
|
//org_level_uuid 所属公司
|
fieldSet.setValue("org_level_uuid", staff.getString("org_level_uuid"));
|
//available_end_time 启用结束时间
|
String uuid = baseDao.add(fieldSet);
|
map.put(id, uuid);
|
|
}
|
}
|
return map;
|
}
|
|
/**
|
* 会议同步
|
*
|
* @param conn
|
* @param tableName
|
*/
|
private void meetingSynchronous(Connection conn, String tableName, Map<String, String> map) throws SQLException {
|
//判断是否是已经同步过的表
|
DataTableEntity dataTable = baseDao.listTable("product_oa_conference_apply");
|
if (!BaseUtil.dataTableIsEmpty(dataTable)) {
|
return;
|
}
|
DataTableEntity meetingDt = null;
|
try {
|
meetingDt = BaseDaoServiceImpl.getDataTable(conn, tableName, "", new Object[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
|
Map<String, Integer> meetintTypeMap = Maps.newHashMap();
|
meetintTypeMap.put("周例会", 1);
|
meetintTypeMap.put("协调会", 2);
|
meetintTypeMap.put("座谈会", 3);
|
meetintTypeMap.put("培训", 4);
|
meetintTypeMap.put("例会", 5);
|
meetintTypeMap.put("研讨会", 6);
|
meetintTypeMap.put("沟通会", 7);
|
meetintTypeMap.put("局务会", 8);
|
meetintTypeMap.put("征求意见会", 9);
|
meetintTypeMap.put("工作洽谈会", 10);
|
meetintTypeMap.put("项目对接会", 11);
|
meetintTypeMap.put("拆迁纠纷协调会", 12);
|
meetintTypeMap.put("讨论", 13);
|
meetintTypeMap.put("物业管理", 14);
|
meetintTypeMap.put("省对市考核", 15);
|
meetintTypeMap.put("安排工作", 16);
|
meetintTypeMap.put("创城半年督查", 17);
|
meetintTypeMap.put("与郑州市征收办工作交流座谈", 18);
|
meetintTypeMap.put("信访工作会议", 19);
|
meetintTypeMap.put("业务讨论", 20);
|
meetintTypeMap.put("前期物业招投标", 21);
|
meetintTypeMap.put("会议、学习", 22);
|
meetintTypeMap.put("交办会", 23);
|
meetintTypeMap.put("审计汇总", 24);
|
meetintTypeMap.put("物业企业星级服务座谈会", 25);
|
|
if (!BaseUtil.dataTableIsEmpty(meetingDt)) {
|
DataTableEntity dataTableEntity = new DataTableEntity();
|
FieldMetaEntity f = new FieldMetaEntity();
|
f.setTableName(new String[]{"product_oa_conference_apply"});
|
dataTableEntity.setMeta(f);
|
for (int i = 0; i < meetingDt.getRows(); i++) {
|
FieldSetEntity fse = meetingDt.getFieldSetEntity(i);
|
FieldSetEntity applyFse = new FieldSetEntity();
|
applyFse.setTableName("product_oa_conference_apply");
|
//附件
|
String annex = fse.getString("annex");
|
//如果附件字段有值 同步附件
|
if (!BaseUtil.strIsNull(annex)) {
|
List<String> fileUuids = this.synchronizeCommonAccessories(conn, "attachment", "product_oa_conference_apply", annex);
|
//存入附件uuid
|
applyFse.setValue("attachment", StringUtils.join(fileUuids, ","));
|
}
|
//participator 参加者
|
String attendee = fse.getString("attendee");
|
applyFse.setValue("participator", this.getUserIds(conn, attendee));
|
//会议简要 会议纪要
|
applyFse.setValue("meeting_minutes", fse.getString("cotent"));
|
//结束时间 结束时间
|
applyFse.setValue("end_time", fse.getString("end_date"));
|
//送审标志 流程送办默认字段,0-待发,1-在办,2-办结
|
applyFse.setValue("flow_flag", fse.getString("flag"));
|
//顺序号 id 主键
|
String id = fse.getString("id");
|
applyFse.setValue("id", id);
|
//创建人
|
String userId = userIdJson.getString(fse.getString("recorded_man"));
|
if (BaseUtil.strIsNull(userId)) {
|
continue;
|
}
|
//所属部门 暂无字段 取当前人部门
|
FieldSetEntity staff = (FieldSetEntity) this.userIdStaffFse.get(userId);
|
String id01 = fse.getString("id01");
|
String dept_uuid = groupJson.getString(id01);
|
if (BaseUtil.strIsNull(dept_uuid)) {
|
dept_uuid = staff.getString("dept_uuid");
|
}
|
//部门uuid
|
applyFse.setValue("dept_uuid", dept_uuid);
|
//申请人 创建人
|
applyFse.setValue("created_by", userId);
|
//外来参会人员 暂无字段
|
applyFse.setValue("exotic_staff", fse.getString("id03"));
|
//申请人id02
|
applyFse.setValue("apply_user", userIdJson.getString(fse.getString("id02")));
|
//主持人 record_master 主持人
|
applyFse.setValue("record_master", userIdJson.getString(fse.getString("meeting_master")));
|
//会议室
|
applyFse.setValue("meeting_room", map.get(fse.getString("meeting_room")));
|
//会议类型 暂无字段 组合为参照
|
applyFse.setValue("meetint_type", meetintTypeMap.get(fse.getString("meetint_type")));
|
//录入时间 created_utc_datetime 创建时间
|
applyFse.setValue("created_utc_datetime", fse.getString("recorded_date"));
|
//会议记录人 记录人
|
applyFse.setValue("record_man", userIdJson.getString(fse.getString("record_man")));
|
//提醒时间 reminder_time 提醒时间
|
applyFse.setValue("reminder_time", fse.getString("remind_time"));
|
//需要资源
|
applyFse.setValue("meeting_resource", fse.getString("res"));
|
//开始时间
|
applyFse.setValue("start_time", fse.getString("start_date"));
|
//会议状态 0、待发 1、已发
|
applyFse.setValue("status", fse.getString("status"));
|
//会议主题
|
applyFse.setValue("meeting_topic", fse.getString("topics"));
|
//所属公司
|
applyFse.setValue("org_level_uuid", staff.getString("org_level_uuid"));
|
String uuid = baseDao.add(applyFse);
|
pxMap.put("BS_MEETING_FLOW" + id, uuid);
|
}
|
|
}
|
}
|
|
|
//同步协同办公
|
private void syncCcooperates(Connection conn, String tableName) throws SQLException {
|
//判断是否是已经同步过的表
|
DataTableEntity dataTable = baseDao.listTable("product_oa_cooperates");
|
if (!BaseUtil.dataTableIsEmpty(dataTable)) {
|
return;
|
}
|
DataTableEntity ccooperatesDt = null;
|
try {
|
ccooperatesDt = BaseDaoServiceImpl.getDataTable(conn, " SELECT A.*,(SELECT COUNT(*) FROM FE_BASE5.SYS_ATTACHMENT WHERE SA01 = A.RELATIONFLOW) AS FLOWS FROM FE_BASE5.SYS_COLLABORATIVE A ", new Object[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
DataTableEntity accessoryData = this.getTableNameAttachment(conn, tableName);
|
try {
|
//获取扩展消息
|
DataTableEntity ideamanageDt = BaseDaoServiceImpl.getDataTable(conn, "SELECT * FROM FE_BASE5.IDEAMANAGE ORDER BY ID06", new Object[]{});
|
Map<String, DataTableEntity> dataMap = Maps.newHashMap();
|
for (int i = 0; i < ideamanageDt.getRows(); i++) {
|
FieldSetEntity fse = ideamanageDt.getFieldSetEntity(i);
|
String id06 = fse.getString("id06");
|
DataTableEntity dataTableEntity1 = dataMap.get(id06);
|
if (BaseUtil.dataTableIsEmpty(dataTableEntity1)) {
|
DataTableEntity dataTableEntity2 = new DataTableEntity();
|
dataTableEntity2.addFieldSetEntity(fse);
|
dataMap.put(id06, dataTableEntity2);
|
} else {
|
dataTableEntity1.addFieldSetEntity(fse);
|
}
|
}
|
Map<String, FieldSetEntity> ccooperatesMaps = Maps.newHashMap();
|
for (int i = 0; i < ccooperatesDt.getRows(); i++) {
|
FieldSetEntity feFs = ccooperatesDt.getFieldSetEntity(i);
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName("product_oa_cooperates");
|
//标题
|
fs.setValue("title", feFs.getString("title"));
|
String content = feFs.getString("content");
|
if (BaseUtil.strIsNull(content)) {
|
content = "";
|
}
|
//内容
|
fs.setValue("content", content);
|
String important = feFs.getString("important");
|
if (!BaseUtil.strIsNull(important)) {
|
//紧急程度(1.平件、2.急件、3.特急、4.特提)
|
fs.setValue("emergency_degree", this.emergencyDegreeType(important));
|
} else {
|
//为空就放0
|
fs.setValue("emergency_degree", 1);
|
}
|
//附件hiddenidea
|
// fs.setValue("attachment",);
|
//发起时间
|
String stime = feFs.getString("stime");
|
fs.setValue("start_time", feFs.getString("stime"));
|
//是否允许转发(1.是、0.否)
|
fs.setValue("is_forward", feFs.getString("repeating"));
|
//是否允许加签(1.是、0.否)
|
fs.setValue("is_countersign", feFs.getString("modifyflow"));
|
//是否允许跟踪(1.是、0.否)
|
fs.setValue("is_track", feFs.getString("track"));
|
//是否隐藏回复意见(1.是、0.否)
|
fs.setValue("is_hide_comments", feFs.getString("hiddenidea"));
|
//状态(0.待发、1.已发)
|
Integer spflag = feFs.getInteger("spflag");
|
fs.setValue("status", (spflag == 0) ? 0 : 1);
|
String sman = this.userIdJson.getString(feFs.getString("sman"));
|
if (BaseUtil.strIsNull(sman)) {
|
continue;
|
}
|
//是否允许转邮件
|
fs.setValue("is_transfer_mail", 0);
|
fs.setValue("created_by", sman);
|
fs.setValue("created_utc_datetime", stime);
|
Map<String, List<String>> fileMaps = this.synchronizationAttachments(conn, accessoryData, feFs, fs.getTableName(), "attachment");
|
List<String> value = fileMaps.get("attachment");
|
//存入附件uuid
|
fs.setValue("attachment", StringUtils.join(value, ","));
|
String uuid = baseDao.add(fs);
|
//保存业务数据id 与本表uuid
|
String id = feFs.getString("id");
|
pxMap.put("SYS_COLLABORATIVE" + id, uuid);
|
ccooperatesMaps.put(id, fs);
|
//同步正文补充
|
this.synchronizeTextSupplement(conn, id, uuid);
|
String flowcode = feFs.getString("flowcode");
|
if (BaseUtil.strIsNull(flowcode)) {
|
//虚拟一个节点
|
FieldSetEntity subfse = new FieldSetEntity();
|
//源表名
|
subfse.setTableName("product_oa_cooperate_flow_node");
|
//办理人层级
|
subfse.setValue("grade", 1);
|
//关联协同表uuid
|
subfse.setValue("cooperate_uuid", uuid);
|
//接收人Id
|
subfse.setValue("receiver", sman);
|
//接收人姓名
|
FieldSetEntity staffFse = (FieldSetEntity) userIdStaffFse.get(sman);
|
String show_name = staffFse.getString("show_name");
|
subfse.setValue("receiver_name", show_name);
|
//0:暂存 1:加签 2:转发 3:退回4:送办 5:终止 6:撤销
|
subfse.setValue("type", 0);
|
subfse.setValue("sender", sman);
|
subfse.setValue("sender_name", null);
|
subfse.setValue("tricode", null);
|
baseDao.add(subfse);
|
//虚拟一个节点
|
FieldSetEntity subfse2 = new FieldSetEntity();
|
//源表名
|
subfse2.setTableName("product_oa_cooperate_flow_node");
|
//办理人层级
|
subfse2.setValue("grade", 2);
|
//关联协同表uuid
|
subfse2.setValue("cooperate_uuid", uuid);
|
//接收人Id
|
subfse2.setValue("receiver", sman);
|
//接收人姓名
|
subfse2.setValue("receiver_name", show_name);
|
//0:暂存 1:加签 2:转发 3:退回4:送办 5:终止 6:撤销
|
subfse2.setValue("type", 0);
|
subfse2.setValue("sender", sman);
|
subfse2.setValue("sender_name", show_name);
|
subfse2.setValue("tricode", sman);
|
baseDao.add(subfse2);
|
continue;
|
}
|
//同步协同流程
|
this.synchronousCooperator(conn, flowcode, uuid);
|
//同步infor
|
DataTableEntity ccooperatesInforDt = null;
|
ccooperatesInforDt = BaseDaoServiceImpl.getDataTable(conn, "SELECT * FROM FE_BASE5.WF_INFOR WHERE WI29 = ? AND WI28 = 'SYS_COLLABORATIVE' ORDER BY WI00", new Object[]{id});
|
Map<String, String[]> stateMap = this.syncCcooperatesInforDt(conn, ccooperatesInforDt, uuid, dataMap);
|
//同步消息
|
if (stateMap != null && stateMap.size() > 0) {
|
this.syncCollaborativeNews(conn, id, stateMap);
|
}
|
}
|
//同步关联事项 修改协同数据
|
//获取关联事项的协同
|
DataTableEntity relevanceTask = BaseDaoServiceImpl.getDataTable(conn, "SELECT * FROM FE_BASE5.WF_TASK WHERE WT03 = 'SYS_COLLABORATIVE'", new Object[]{});
|
Map<String, FieldSetEntity> task_maps = Maps.newHashMap();
|
for (int i = 0; i < relevanceTask.getRows(); i++) {
|
task_maps.put(relevanceTask.getString(i, "wt00"), relevanceTask.getFieldSetEntity(i));
|
}
|
//获取已同步流程task的关联事项
|
DataTableEntity flow_task = baseDao.listTable("select * from product_sys_flow_task", new String[]{});
|
Map<String, FieldSetEntity> flow_task_maps = Maps.newHashMap();
|
for (int i = 0; i < flow_task.getRows(); i++) {
|
//k为原 taskId
|
flow_task_maps.put(flow_task.getString(i, "id"), flow_task.getFieldSetEntity(i));
|
}
|
for (int i = 0; i < ccooperatesDt.getRows(); i++) {
|
Integer flows = ccooperatesDt.getInt(i, "flows");
|
//有关联事项
|
if (flows > 0) {
|
String relationflow = ccooperatesDt.getString(i, "relationflow");
|
String id = ccooperatesDt.getString(i, "id");
|
DataTableEntity relationflowData = BaseDaoServiceImpl.getDataTable(conn, "SELECT * FROM FE_BASE5.SYS_ATTACHMENT WHERE SA01 = ?", new Object[]{relationflow});
|
JSONArray relationJson = new JSONArray();
|
if (!BaseUtil.dataTableIsEmpty(relationflowData)) {
|
for (int j = 0; j < relationflowData.getRows(); j++) {
|
String sa02 = relationflowData.getString(j, "sa02");
|
//本库流程task数据
|
FieldSetEntity fse = flow_task_maps.get(sa02);
|
if (fse != null) {
|
JSONObject relationObject = new JSONObject();
|
String uuid = fse.getUUID();
|
String title = fse.getString("title");
|
relationObject.put("type", 0);
|
relationObject.put("uuid", uuid);
|
relationObject.put("label", title);
|
relationJson.add(relationObject);
|
}
|
//协同源数据
|
FieldSetEntity fse2 = task_maps.get(sa02);
|
if (fse2 != null) {
|
JSONObject relationObject = new JSONObject();
|
String wt04 = fse2.getString("wt04");
|
FieldSetEntity fieldSetEntity = ccooperatesMaps.get(wt04);
|
if (fieldSetEntity != null) {
|
String uuid = fieldSetEntity.getUUID();
|
String title = fieldSetEntity.getString("title");
|
relationObject.put("type", 1);
|
relationObject.put("uuid", uuid);
|
relationObject.put("label", title);
|
relationJson.add(relationObject);
|
}
|
}
|
}
|
if (relationJson.size() > 0) {
|
FieldSetEntity updateFse = ccooperatesMaps.get(id);
|
if (updateFse != null) {
|
updateFse.setValue("related_items", relationJson.toString());
|
baseDao.update(updateFse);
|
}
|
}
|
}
|
}
|
}
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
}
|
}
|
|
/**
|
* 同步协同正文补充
|
*/
|
public void synchronizeTextSupplement(Connection conn, String id, String cooperate_uuid) throws Exception {
|
try {
|
DataTableEntity dataTable = BaseDaoServiceImpl.getDataTable(conn, "SELECT * FROM FE_BASE5.WF_DOC_ADDITIONAL WHERE WDA05 = (SELECT WT00 FROM FE_BASE5.WF_TASK WHERE WT04 = ? AND WT03 = 'SYS_COLLABORATIVE')", new Object[]{id});
|
DataTableEntity cooperate_sub = new DataTableEntity();
|
FieldMetaEntity f = new FieldMetaEntity();
|
f.setTableName(new String[]{"product_oa_cooperate_sub"});
|
cooperate_sub.setMeta(f);
|
if (!BaseUtil.dataTableIsEmpty(dataTable)) {
|
DataTableEntity accessoryData = this.getTableNameAttachment(conn, "FE_BASE5.WF_DOC_ADDITIONAL");
|
for (int i = 0; i < dataTable.getRows(); i++) {
|
FieldSetEntity fse = dataTable.getFieldSetEntity(i);
|
FieldSetEntity fieldSetEntity = new FieldSetEntity();
|
fieldSetEntity.setTableName("product_oa_cooperate_sub");
|
//内容
|
String wda02 = fse.getString("wda02");
|
if (BaseUtil.strIsNull(wda02)) {
|
wda02 = "空";
|
}
|
fieldSetEntity.setValue("contents", wda02);
|
// attachment 附件
|
Map<String, List<String>> fileMaps = this.synchronizationAttachments(conn, accessoryData, fse, fieldSetEntity.getTableName(), "attachment");
|
List<String> value = fileMaps.get("attachment");
|
//存入附件uuid
|
fieldSetEntity.setValue("attachment", StringUtils.join(value, ","));
|
//主表uuid
|
fieldSetEntity.setValue("cooperate_uuid", cooperate_uuid);
|
String user_id = userIdJson.getString(fse.getString("wda01"));
|
if (BaseUtil.strIsNull(user_id)) {
|
continue;
|
}
|
//创建人
|
fieldSetEntity.setValue("created_by", user_id);
|
//创建时间
|
fieldSetEntity.setValue("created_utc_datetime", fse.getString("wda04"));
|
cooperate_sub.addFieldSetEntity(fieldSetEntity);
|
}
|
baseDao.add(cooperate_sub);
|
}
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
}
|
}
|
|
/**
|
* 同步协同模板
|
*/
|
public void syncCollaborativeTemplate(Connection conn) throws SQLException {
|
try {
|
DataTableEntity dataTable = BaseDaoServiceImpl.getDataTable(conn, "SELECT * FROM FE_BASE5.SYS_COLLABORATIVE_MOUDLE WHERE COL_MDL_CONTENT_TYPE = 0", new Object[]{});
|
if (!BaseUtil.dataTableIsEmpty(dataTable)) {
|
for (int i = 0; i < dataTable.getRows(); i++) {
|
FieldSetEntity fse = dataTable.getFieldSetEntity(i);
|
FieldSetEntity newFse = new FieldSetEntity();
|
newFse.setTableName("product_oa_cooperates_template");
|
//模板名称 也为协同名称
|
newFse.setValue("name", fse.getString("col_mdl_name"));
|
//创建人
|
String col_mdl_userid = fse.getString("col_mdl_userid");
|
String user_id = "";
|
//创建时间
|
String created_time = fse.getString("col_mdl_time");
|
//公共模板
|
if ("1".equals(col_mdl_userid)) {
|
newFse.setValue(CmnConst.CREATED_BY, 1);
|
//创建时间
|
newFse.setValue(CmnConst.CREATED_UTC_DATETIME, created_time);
|
//模板html内容
|
newFse.setValue("content", fse.getString("col_mdl_content"));
|
baseDao.add(newFse);
|
} else {
|
user_id = userIdJson.getString(col_mdl_userid);
|
if (BaseUtil.strIsNull(user_id)) {
|
continue;
|
}
|
newFse.setValue(CmnConst.CREATED_BY, user_id);
|
newFse.setValue(CmnConst.CREATED_UTC_DATETIME, created_time);
|
//模板html内容
|
newFse.setValue("content", fse.getString("col_mdl_content"));
|
//共享人员1 部门2 岗位3
|
String col_mdl_sharers = fse.getString("col_mdl_sharers");
|
if (!BaseUtil.strIsNull(col_mdl_sharers)) {
|
Set<String> userSet = Sets.newHashSet();
|
String[] sharers = col_mdl_sharers.split(",");
|
for (int j = 0; j < sharers.length; j++) {
|
String srt = sharers[j];
|
//人员
|
if (srt.contains("^_^1^_^")) {
|
String userId = srt.substring(0, srt.indexOf("^_^1^_^"));
|
userId = userIdJson.getString(userId);
|
if (!BaseUtil.strIsNull(userId)) {
|
userSet.add(userId);
|
}
|
//部门单位
|
} else if (srt.contains("^_^2^_^")) {
|
String levelId = srt.substring(0, srt.indexOf("^_^2^_^"));
|
String deptUuid = groupJson.getString(levelId);
|
DataTableEntity staffData = null;
|
if (BaseUtil.strIsNull(deptUuid)) {
|
deptUuid = orgLevelJson.getString(levelId);
|
if (!BaseUtil.strIsNull(deptUuid)) {
|
staffData = baseDao.listTable(CmnConst.PRODUCT_SYS_STAFFS, " org_level_uuid = ? ", new String[]{deptUuid});
|
}
|
} else {
|
staffData = baseDao.listTable(CmnConst.PRODUCT_SYS_STAFFS, " dept_uuid = ? or org_level_uuid = ? ", new String[]{deptUuid, deptUuid});
|
}
|
if (!BaseUtil.dataTableIsEmpty(staffData)) {
|
for (int k = 0; k < staffData.getRows(); k++) {
|
userSet.add(staffData.getString(k, "user_id"));
|
}
|
}
|
//岗位
|
} else if (srt.contains("^_^3^_^")) {
|
String postId = srt.substring(0, srt.indexOf("_|"));
|
String postUuid = postJson.getString(postId);
|
DataTableEntity staffData = baseDao.listTable(CmnConst.PRODUCT_SYS_STAFFS, " job_post_uuid = ? ", new String[]{postUuid});
|
if (!BaseUtil.dataTableIsEmpty(staffData)) {
|
for (int k = 0; k < staffData.getRows(); k++) {
|
userSet.add(staffData.getString(k, "user_id"));
|
}
|
}
|
}
|
}
|
if (userSet.size() > 0) {
|
//解析并存入用户
|
newFse.setValue("share_user", StringUtils.join(userSet, ","));
|
}
|
}
|
String uuid = baseDao.add(newFse);
|
//关联流程code
|
String col_mdl_flowcode = fse.getString("col_mdl_flowcode");
|
FieldSetEntity staffFse = (FieldSetEntity) userIdStaffFse.get(user_id);
|
String org_level_uuid = staffFse.getString("org_level_uuid");
|
if (!BaseUtil.strIsNull(col_mdl_flowcode) && !BaseUtil.strIsNull(org_level_uuid)) {
|
//同步协同模板流程
|
this.synchronousTemplateCooperator(conn, col_mdl_flowcode, uuid, user_id, created_time, org_level_uuid);
|
}
|
}
|
|
}
|
}
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
}
|
}
|
|
/**
|
* 同步协同模板人员 岗位 机构
|
*
|
* @param conn jdbc连接
|
* @param flowCode 流程节点标识
|
* @param uuid 协同uuid
|
* @return
|
*/
|
public DataTableEntity synchronousTemplateCooperator(Connection conn, String flowCode, String uuid, String user_id, String created_time, String org_level_uuid) throws SQLException {
|
DataTableEntity coNodeData = null;
|
try {
|
//flowcode 流程标识字段
|
coNodeData = BaseDaoServiceImpl.getDataTable(conn, "SELECT * FROM FE_BASE5.WF_CO_NODE WHERE MGUID = ? ORDER BY CREATETIME", new Object[]{flowCode});
|
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
if (!BaseUtil.dataTableIsEmpty(coNodeData)) {
|
FieldSetEntity fieldSetEntity = coNodeData.getFieldSetEntity(0);
|
coNodeData.removeFieldSetEntity(0);
|
DataTableEntity dataTable = new DataTableEntity();
|
FieldMetaEntity f = new FieldMetaEntity();
|
f.setTableName(new String[]{"product_oa_cooperate_flow_node_template"});
|
dataTable.setMeta(f);
|
String userId = userIdJson.getString(fieldSetEntity.getString("value"));
|
if (BaseUtil.strIsNull(userId)) {
|
return null;
|
}
|
FieldSetEntity subfse = new FieldSetEntity();
|
//源表名
|
subfse.setTableName("product_oa_cooperate_flow_node_template");
|
//办理人层级
|
subfse.setValue("grade", 1);
|
//关联协同模板表uuid
|
subfse.setValue("master_uuid", uuid);
|
//接收人Id
|
subfse.setValue("receiver", userId);
|
subfse.setValue("sender", null);
|
subfse.setValue("tricode", null);
|
subfse.setValue("org_level_uuid", org_level_uuid);
|
subfse.setValue(CmnConst.CREATED_BY, user_id);
|
subfse.setValue(CmnConst.CREATED_UTC_DATETIME, created_time);
|
dataTable.addFieldSetEntity(subfse);
|
try {
|
this.saveTemplateReceiver(fieldSetEntity, coNodeData, uuid, null, dataTable, 2, user_id, created_time, org_level_uuid);
|
baseDao.add(dataTable);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return dataTable;
|
}
|
return null;
|
}
|
|
/**
|
* 递归循环同步模板人员 部门岗位 数据
|
*
|
* @param fse 发送人fse
|
* @param dataTableEntity 剩余人Data
|
*/
|
private void saveTemplateReceiver(FieldSetEntity fse, DataTableEntity dataTableEntity, String uuid, String tricode, DataTableEntity dataTable, Integer grade, String user_id, String created_time, String org_level_uuid) throws Exception {
|
DataTableEntity dataTableEntity1 = new DataTableEntity();
|
DataTableEntity dataTableEntity2 = new DataTableEntity();
|
String sender = "";
|
//发送类型
|
String type2 = fse.getString("type");
|
if ("1".equals(type2)) {
|
sender = userIdJson.getString(fse.getString("value"));
|
if (BaseUtil.strIsNull(sender)) {
|
return;
|
}
|
}
|
for (int i = 0; i < dataTableEntity.getRows(); i++) {
|
FieldSetEntity fieldSetEntity = dataTableEntity.getFieldSetEntity(i);
|
String guid = fse.getString("guid");
|
String parentguid = fieldSetEntity.getString("parentguid");
|
if (guid.equals(parentguid)) {
|
dataTableEntity1.addFieldSetEntity(fieldSetEntity);
|
FieldSetEntity subfs = new FieldSetEntity();
|
//协同办公流程表
|
subfs.setTableName("product_oa_cooperate_flow_node_template");
|
subfs.setValue("grade", grade);
|
//关联协同表uuid
|
subfs.setValue("master_uuid", uuid);
|
//接收人(关联用户表id) 接收人一但是机构或部门节点 那就是最后节点
|
String type = fieldSetEntity.getString("type");
|
//发送人id
|
subfs.setValue("sender", sender);
|
//人员
|
if ("1".equals(type)) {
|
String userId = userIdJson.getString(fieldSetEntity.getString("value"));
|
if (BaseUtil.strIsNull(userId)) {
|
continue;
|
}
|
subfs.setValue("receiver", userId);
|
//若为部门公司
|
} else if ("2".equals(type)) {
|
String orgUuid = orgLevelJson.getString(fieldSetEntity.getString("value"));
|
if (BaseUtil.strIsNull(orgUuid)) {
|
continue;
|
}
|
if (!BaseUtil.strIsNull(orgUuid)) {
|
DataTableEntity staff = baseDao.listTable(" product_sys_staffs ", " dept_uuid = ? ", new String[]{orgUuid});
|
if (BaseUtil.dataTableIsEmpty(staff)) {
|
staff = baseDao.listTable(" product_sys_staffs ", " org_level_uuid = ? ", new String[]{orgUuid});
|
}
|
if (!BaseUtil.dataTableIsEmpty(staff)) {
|
tricode = dataTable.getString(dataTable.getRows() - 1, "tricode");
|
if (BaseUtil.strIsNull(tricode)) {
|
tricode = dataTable.getString(dataTable.getRows() - 1, "receiver");
|
}
|
this.addUserTemplateFlowNode(staff, grade, uuid, tricode, sender, dataTable, user_id, created_time, org_level_uuid);
|
}
|
continue;
|
}
|
//岗位
|
} else if ("3".equals(type)) {
|
String postUuid = postJson.getString(fieldSetEntity.getString("value"));
|
if (BaseUtil.strIsNull(postUuid)) {
|
continue;
|
}
|
if (!BaseUtil.strIsNull(postUuid)) {
|
DataTableEntity staff = baseDao.listTable(" product_sys_staffs ", " job_post_uuid = ? ", new String[]{postUuid});
|
if (!BaseUtil.dataTableIsEmpty(staff)) {
|
tricode = dataTable.getString(dataTable.getRows() - 1, "tricode");
|
if (BaseUtil.strIsNull(tricode)) {
|
tricode = dataTable.getString(dataTable.getRows() - 1, "receiver");
|
}
|
this.addUserTemplateFlowNode(staff, grade, uuid, tricode, sender, dataTable, user_id, created_time, org_level_uuid);
|
}
|
continue;
|
}
|
}
|
//triCode
|
if (BaseUtil.strIsNull(tricode)) {
|
subfs.setValue("tricode", sender);
|
fieldSetEntity.setValue("tricode", sender);
|
} else {
|
subfs.setValue("tricode", tricode + "-" + sender);
|
fieldSetEntity.setValue("tricode", tricode + "-" + sender);
|
}
|
|
//公司uuid
|
subfs.setValue("org_level_uuid", org_level_uuid);
|
//创建人
|
subfs.setValue(CmnConst.CREATED_BY, user_id);
|
//创建时间
|
subfs.setValue(CmnConst.CREATED_UTC_DATETIME, created_time);
|
dataTable.addFieldSetEntity(subfs);
|
} else {
|
dataTableEntity2.addFieldSetEntity(fieldSetEntity);
|
}
|
}
|
|
//办理人层级
|
grade++;
|
if (!BaseUtil.dataTableIsEmpty(dataTableEntity1) && !BaseUtil.dataTableIsEmpty(dataTableEntity2)) {
|
for (int i = 0; i < dataTableEntity1.getRows(); i++) {
|
this.saveTemplateReceiver(dataTableEntity1.getFieldSetEntity(i), dataTableEntity2, uuid, dataTableEntity1.getString(i, "tricode"), dataTable, grade, user_id, created_time, org_level_uuid);
|
}
|
}
|
}
|
|
/**
|
* 解析同步的岗位部门 解析为人再批量保存
|
*
|
* @param staff 通过部门岗位 查询出来的用户数据
|
* @param grade 层级
|
* @param uuid 主表uuid
|
* @param tricode 本级code
|
* @param user_id 发送人user_id
|
*/
|
public void addUserTemplateFlowNode(DataTableEntity staff, Integer grade, String uuid, String tricode, String user_id, DataTableEntity data, String created_by, String created_time, String org_level_uuid) {
|
for (int f = 0; f < staff.getRows(); f++) {
|
FieldSetEntity subfse = new FieldSetEntity();
|
//源表名
|
subfse.setTableName("product_oa_cooperate_flow_node_template");
|
//办理人层级
|
subfse.setValue("grade", grade);
|
//关联协同表uuid
|
subfse.setValue("master_uuid", uuid);
|
//接收人id
|
subfse.setValue("receiver", staff.getString(f, "user_id"));
|
//code
|
subfse.setValue("tricode", tricode);
|
//发送人id
|
subfse.setValue("sender", user_id);
|
subfse.setValue(CmnConst.CREATED_BY, created_by);
|
subfse.setValue(CmnConst.CREATED_UTC_DATETIME, created_time);
|
data.addFieldSetEntity(subfse);
|
}
|
}
|
|
/**
|
* 同步协同消息
|
*
|
* @param conn jdbc连接
|
* @param id 协同数据id
|
* @throws SQLException
|
*/
|
public void syncCollaborativeNews(Connection conn, String id, Map<String, String[]> stateMap) throws SQLException {
|
try {
|
DataTableEntity collaborativeNews = BaseDaoServiceImpl.getDataTable(conn, "SELECT * FROM FE_BASE5.MESSAGEINFOR WHERE ME14 IN ( SELECT WI00 FROM FE_BASE5.WF_INFOR WHERE WI29 = ? AND WI28 = 'SYS_COLLABORATIVE' AND WI13 = 0 ) ORDER BY ME14", new Object[]{id});
|
if (!BaseUtil.dataTableIsEmpty(collaborativeNews)) {
|
this.syncCollaborativeNews(collaborativeNews, stateMap, "product_oa_cooperates");
|
}
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
}
|
|
}
|
|
/**
|
* 同步协同流程消息表
|
*/
|
public void syncCollaborativeNews(DataTableEntity OrlDt, Map<String, String[]> stateMap, String tableName) throws Exception {
|
String id = null;
|
String message_uuid = null;
|
String[] state = null;
|
DataTableEntity dataTableEntity = new DataTableEntity();
|
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
|
String me14 = fs.getString("me14");
|
//获取当前节点状态
|
state = stateMap.get(me14);
|
if (state == null) {
|
continue;
|
}
|
String sendUserId;
|
//相同说明是同一消息 发送多个人
|
if (!me14.equals(id)) {
|
//不一样创建消息主表
|
id = me14;
|
FieldSetEntity message = new FieldSetEntity();
|
//消息主表
|
message.setTableName("product_sys_message");
|
//消息主题
|
message.setValue("title", fs.getString("me01"));
|
//消息内容
|
message.setValue("content", fs.getString("me02"));
|
//是否需要发送邮件
|
message.setValue("is_send_mail", 0);
|
//消息类型21 流程消息都为任务消息
|
message.setValue("message_type", 21);
|
//是否需要发送短信 0不发;1为强制;2为被动
|
message.setValue("is_send_sms", "0".equals(fs.getString("me20")) ? 0 : 1);
|
//发送时间
|
String me07 = fs.getString("me07");
|
message.setValue("send_time", me07);
|
//创建时间
|
message.setValue("created_utc_datetime", me07);
|
|
//发送人
|
sendUserId = userIdJson.getString(fs.getString("me03"));
|
if (BaseUtil.strIsNull(sendUserId)) {
|
//流程infor 数据创建人为发送人
|
sendUserId = state[2];
|
if (BaseUtil.strIsNull(sendUserId)) {
|
continue;
|
}
|
}
|
message.setValue("send_user_id", sendUserId);
|
//创建人及发送人
|
message.setValue("created_by", sendUserId);
|
// 业务表
|
message.setValue("source_table", tableName);
|
//url 业务地址
|
|
message.setValue("source_uuid", state[3]);
|
|
//查看详情
|
message.setValue("url", state[1]);
|
dt1.addFieldSetEntity(message);
|
message_uuid = UUID.randomUUID().toString();
|
message.setValue("uuid", message_uuid);
|
}
|
|
FieldSetEntity message_user = new FieldSetEntity();
|
message_user.setTableName("product_sys_message_user");
|
//关联lx_sys_message表UUID
|
message_user.setValue("message_uuid", message_uuid);
|
//mail_send 是否发送邮件
|
message_user.setValue("mail_send", 0);
|
// 是否阅读 节点状态为未读
|
//0未读
|
if ("0".equals(state[0])) {
|
message_user.setValue("read_type", 0);
|
} else {
|
message_user.setValue("read_type", 1);
|
}
|
//receive_time 接收时间 无字段
|
//sms_send 是否发送短信
|
message_user.setValue("sms_send", 0);
|
//user_id 消息接收人
|
String user_id = userIdJson.getString(fs.getString("me05"));
|
//找不到发送人就放接收人
|
if (BaseUtil.strIsNull(user_id)) {
|
user_id = userIdJson.getString(fs.getString("me03"));
|
if (BaseUtil.strIsNull(user_id)) {
|
continue;
|
}
|
}
|
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();
|
}
|
}
|
batchAddData.add(dt1);
|
batchAddData.add(dataTableEntity);
|
}
|
|
/**
|
* 同步协同留言数据
|
*
|
* @param ccooperatesInforDt infor数据uuid
|
*/
|
public Map<String, String[]> syncCcooperatesInforDt(Connection conn, DataTableEntity ccooperatesInforDt, String uuid, Map<String, DataTableEntity> dataMap) throws Exception {
|
Map<String, String[]> stateMap = Maps.newHashMap();
|
for (int i = 0; i < ccooperatesInforDt.getRows(); i++) {
|
FieldSetEntity inforFse = ccooperatesInforDt.getFieldSetEntity(i);
|
String userId = userIdJson.getString(inforFse.getString("wi05"));
|
//wi62 与节点表parentguid对应
|
DataTableEntity dataTableEntity = parentGuidData.get(inforFse.getString("wi62"));
|
if (BaseUtil.dataTableIsEmpty(dataTableEntity) || BaseUtil.strIsNull(userId)) {
|
continue;
|
}
|
for (int j = 0; j < dataTableEntity.getRows(); j++) {
|
FieldSetEntity fieldSetEntity = dataTableEntity.getFieldSetEntity(j);
|
String receiver = fieldSetEntity.getString("receiver");
|
fieldSetEntity.setValue("accept_time", inforFse.getString("wi08")); //接收时间
|
//相同就是一个人 赋办理状态 和留言
|
if (userId.equals(receiver)) {
|
String wi00 = inforFse.getString("wi00");
|
String nodeState = nodeDealType(inforFse.getString("wi13"));
|
fieldSetEntity.setValue("status", nodeState);
|
String wi20 = inforFse.getString("wi20");
|
//已办消息 并且消息为空 加上已阅
|
if (BaseUtil.strIsNull(wi20) && "2".equals(nodeState)) {
|
wi20 = "已阅";
|
}
|
//留言消息
|
fieldSetEntity.setValue("opinion", wi20);
|
fieldSetEntity.setValue("accept_time", inforFse.getString("wi08")); //接收时间
|
fieldSetEntity.setValue("handle_time", inforFse.getString("wi11")); //处理时间
|
String flow_node_uuid = fieldSetEntity.getUUID();
|
String created_by = userIdJson.getString(inforFse.getString("wi15"));
|
//扩展留言消息
|
String wi21 = inforFse.getString("wi21");
|
String attachmentsValue = inforFse.getString("attachment");
|
//如果附件字段有值 同步附件
|
if (!BaseUtil.strIsNull(attachmentsValue)) {
|
List<String> fileUuids = this.synchronizeCommonAccessories(conn, "attachments", "product_oa_cooperate_flow_node", attachmentsValue);
|
//存入附件uuid
|
fieldSetEntity.setValue("attachments", StringUtils.join(fileUuids, ","));
|
}
|
String url = "1623059056339697NPbV881?uuid=" + uuid + "&flow_node_uuid=" + flow_node_uuid;
|
DataTableEntity dataTableEntity1 = dataMap.get(wi21);
|
stateMap.put(wi00, new String[]{nodeState, url, created_by, uuid});
|
//有扩展留言
|
if (!BaseUtil.dataTableIsEmpty(dataTableEntity1)) {
|
for (int k = 0; k < dataTableEntity1.getRows(); k++) {
|
FieldSetEntity ideFse = dataTableEntity1.getFieldSetEntity(k);
|
//同步附件
|
String id08 = ideFse.getString("id08");
|
String reply_attachment = null;
|
String id07 = ideFse.getString("id07");
|
//回复内容
|
String id04 = ideFse.getString("id04");
|
//有附件 不等于0说明未额外留言
|
if (!BaseUtil.strIsNull(id08) && !"0".equals(id07)) {
|
// reply_attachment 回复附件,关联附件表uuid
|
List<String> attachment = this.synchronizeCommonAccessories(conn, "reply_attachment", "product_oa_cooperate_flow_reply", id08);
|
reply_attachment = StringUtils.join(attachment, ",");
|
//等于0说明 为处理数据
|
} else if (!BaseUtil.strIsNull(id08) && "0".equals(id07)) {
|
List<String> attachment = this.synchronizeCommonAccessories(conn, "attachments", "product_oa_cooperate_flow_node", id08);
|
reply_attachment = StringUtils.join(attachment, ",");
|
fieldSetEntity.setValue("opinion", id04);
|
fieldSetEntity.setValue("attachments", reply_attachment);
|
continue;
|
}
|
FieldSetEntity flowReply = new FieldSetEntity();
|
flowReply.setTableName("product_oa_cooperate_flow_reply");
|
|
//关联lx_oa_cooperate_flow_node表uuid
|
flowReply.setValue("parent_uuid", fieldSetEntity.getUUID());
|
//回复内容
|
flowReply.setValue("reply_content", id04);
|
//回复时间
|
flowReply.setValue("reply_datetime", ideFse.getString("id03"));
|
//回复人,关联user表id
|
String user_id = userIdJson.getString(ideFse.getString("id02"));
|
if (BaseUtil.strIsNull(user_id)) {
|
continue;
|
}
|
//回复人,关联user表id
|
flowReply.setValue("reply_user", user_id);
|
//上级id
|
flowReply.setValue("superior_id", ideFse.getString("id01"));
|
flowReply.setValue("reply_attachment", reply_attachment);
|
baseDao.add(flowReply);
|
}
|
}
|
baseDao.update(fieldSetEntity);
|
}
|
}
|
}
|
return stateMap;
|
}
|
|
/**
|
* 同步协同人员 岗位 机构
|
*
|
* @param conn jdbc连接
|
* @param flowCode 流程节点标识
|
* @param uuid 协同uuid
|
* @return
|
*/
|
public DataTableEntity synchronousCooperator(Connection conn, String flowCode, String uuid) throws SQLException {
|
DataTableEntity coNodeData = null;
|
try {
|
//flowcode 流程标识字段
|
coNodeData = BaseDaoServiceImpl.getDataTable(conn, "SELECT * FROM FE_BASE5.WF_CO_NODE WHERE MGUID = ? ORDER BY CREATETIME", new Object[]{flowCode});
|
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
if (!BaseUtil.dataTableIsEmpty(coNodeData)) {
|
FieldSetEntity fieldSetEntity = coNodeData.getFieldSetEntity(0);
|
coNodeData.removeFieldSetEntity(0);
|
DataTableEntity dataTable = new DataTableEntity();
|
FieldMetaEntity f = new FieldMetaEntity();
|
f.setTableName(new String[]{"product_oa_cooperate_flow_node"});
|
dataTable.setMeta(f);
|
String userId = userIdJson.getString(fieldSetEntity.getString("value"));
|
if (BaseUtil.strIsNull(userId)) {
|
return null;
|
}
|
FieldSetEntity subfse = new FieldSetEntity();
|
//源表名
|
subfse.setTableName("product_oa_cooperate_flow_node");
|
//办理人层级
|
subfse.setValue("grade", 1);
|
//关联协同表uuid
|
subfse.setValue("cooperate_uuid", uuid);
|
//接收人Id
|
subfse.setValue("receiver", userId);
|
//接收人姓名
|
subfse.setValue("receiver_name", fieldSetEntity.getString("name"));
|
//0:暂存 1:加签 2:转发 3:退回4:送办 5:终止 6:撤销
|
subfse.setValue("type", 0);
|
subfse.setValue("sender", null);
|
subfse.setValue("sender_name", null);
|
subfse.setValue("tricode", null);
|
DataTableEntity newDataTable = new DataTableEntity();
|
FieldMetaEntity f2 = new FieldMetaEntity();
|
f2.setTableName(new String[]{"product_oa_cooperate_flow_node"});
|
newDataTable.setMeta(f2);
|
newDataTable.addFieldSetEntity(subfse);
|
parentGuidData.put(fieldSetEntity.getString("guid"), newDataTable);
|
dataTable.addFieldSetEntity(subfse);
|
try {
|
this.saveReceiver(fieldSetEntity, coNodeData, uuid, null, dataTable, 2);
|
baseDao.add(dataTable);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return dataTable;
|
}
|
return null;
|
}
|
|
/**
|
* 递归循环同步人员 部门岗位 数据
|
*
|
* @param fse 发送人fse
|
* @param dataTableEntity 剩余人Data
|
*/
|
private void saveReceiver(FieldSetEntity fse, DataTableEntity dataTableEntity, String uuid, String tricode, DataTableEntity dataTable, Integer grade) throws Exception {
|
DataTableEntity dataTableEntity1 = new DataTableEntity();
|
DataTableEntity dataTableEntity2 = new DataTableEntity();
|
String sender = "";
|
//发送类型
|
String type2 = fse.getString("type");
|
if ("1".equals(type2)) {
|
sender = userIdJson.getString(fse.getString("value"));
|
if (BaseUtil.strIsNull(sender)) {
|
return;
|
}
|
}
|
for (int i = 0; i < dataTableEntity.getRows(); i++) {
|
FieldSetEntity fieldSetEntity = dataTableEntity.getFieldSetEntity(i);
|
String guid = fse.getString("guid");
|
String parentguid = fieldSetEntity.getString("parentguid");
|
if (guid.equals(parentguid)) {
|
dataTableEntity1.addFieldSetEntity(fieldSetEntity);
|
FieldSetEntity subfs = new FieldSetEntity();
|
//协同办公流程表
|
subfs.setTableName("product_oa_cooperate_flow_node");
|
subfs.setValue("grade", grade);
|
//关联协同表uuid
|
subfs.setValue("cooperate_uuid", uuid);
|
//接收人(关联用户表id) 接收人一但是机构或部门节点 那就是最后节点
|
String type = fieldSetEntity.getString("type");
|
//发送人id
|
subfs.setValue("sender", sender);
|
//人员
|
if ("1".equals(type)) {
|
String userId = userIdJson.getString(fieldSetEntity.getString("value"));
|
if (BaseUtil.strIsNull(userId)) {
|
continue;
|
}
|
subfs.setValue("receiver", userId);
|
//若为部门公司
|
} else if ("2".equals(type)) {
|
String orgUuid = orgLevelJson.getString(fieldSetEntity.getString("value"));
|
if (BaseUtil.strIsNull(orgUuid)) {
|
continue;
|
}
|
if (!BaseUtil.strIsNull(orgUuid)) {
|
DataTableEntity staff = baseDao.listTable(" product_sys_staffs ", " dept_uuid = ? ", new String[]{orgUuid});
|
if (BaseUtil.dataTableIsEmpty(staff)) {
|
staff = baseDao.listTable(" product_sys_staffs ", " org_level_uuid = ? ", new String[]{orgUuid});
|
}
|
if (!BaseUtil.dataTableIsEmpty(staff)) {
|
tricode = dataTable.getString(dataTable.getRows() - 1, "tricode");
|
if (BaseUtil.strIsNull(tricode)) {
|
tricode = dataTable.getString(dataTable.getRows() - 1, "receiver");
|
}
|
this.addUserFlowNode(staff, grade, uuid, fse, tricode, fieldSetEntity, sender, dataTable);
|
}
|
continue;
|
}
|
//岗位
|
} else if ("3".equals(type)) {
|
String postUuid = postJson.getString(fieldSetEntity.getString("value"));
|
if (BaseUtil.strIsNull(postUuid)) {
|
continue;
|
}
|
if (!BaseUtil.strIsNull(postUuid)) {
|
DataTableEntity staff = baseDao.listTable(" product_sys_staffs ", " job_post_uuid = ? ", new String[]{postUuid});
|
if (!BaseUtil.dataTableIsEmpty(staff)) {
|
tricode = dataTable.getString(dataTable.getRows() - 1, "tricode");
|
if (BaseUtil.strIsNull(tricode)) {
|
tricode = dataTable.getString(dataTable.getRows() - 1, "receiver");
|
}
|
this.addUserFlowNode(staff, grade, uuid, fse, tricode, fieldSetEntity, sender, dataTable);
|
}
|
continue;
|
}
|
}
|
//接收人姓名
|
subfs.setValue("receiver_name", fieldSetEntity.getString("name"));
|
//triCode
|
if (BaseUtil.strIsNull(tricode)) {
|
subfs.setValue("tricode", sender);
|
fieldSetEntity.setValue("tricode", sender);
|
} else {
|
subfs.setValue("tricode", tricode + "-" + sender);
|
fieldSetEntity.setValue("tricode", tricode + "-" + sender);
|
}
|
|
//发送人姓名
|
subfs.setValue("sender_name", fse.getString("name"));
|
//0:暂存 1:加签 2:转发 3:退回4:送办 5:终止 6:撤销
|
subfs.setValue("type", 0);
|
DataTableEntity newDataTable = new DataTableEntity();
|
FieldMetaEntity f2 = new FieldMetaEntity();
|
f2.setTableName(new String[]{"product_oa_cooperate_flow_node"});
|
newDataTable.setMeta(f2);
|
newDataTable.addFieldSetEntity(subfs);
|
parentGuidData.put(fieldSetEntity.getString("guid"), newDataTable);
|
dataTable.addFieldSetEntity(subfs);
|
} else {
|
dataTableEntity2.addFieldSetEntity(fieldSetEntity);
|
}
|
}
|
|
//办理人层级
|
grade++;
|
if (!BaseUtil.dataTableIsEmpty(dataTableEntity1) && !BaseUtil.dataTableIsEmpty(dataTableEntity2)) {
|
for (int i = 0; i < dataTableEntity1.getRows(); i++) {
|
this.saveReceiver(dataTableEntity1.getFieldSetEntity(i), dataTableEntity2, uuid, dataTableEntity1.getString(i, "tricode"), dataTable, grade);
|
}
|
}
|
}
|
|
/**
|
* 解析同步的岗位部门 解析为人再批量保存
|
*
|
* @param staff 通过部门岗位 查询出来的用户数据
|
* @param grade 层级
|
* @param uuid 主表uuid
|
* @param fse 源数据发送人信息
|
* @param tricode 本级code
|
* @param fieldSetEntity 接收信息
|
* @param user_id 发送人user_id
|
*/
|
public void addUserFlowNode(DataTableEntity staff, Integer grade, String uuid, FieldSetEntity fse, String tricode, FieldSetEntity fieldSetEntity, String user_id, DataTableEntity data) {
|
DataTableEntity newDataTable = new DataTableEntity();
|
FieldMetaEntity f2 = new FieldMetaEntity();
|
f2.setTableName(new String[]{"product_oa_cooperate_flow_node"});
|
newDataTable.setMeta(f2);
|
String guid = fieldSetEntity.getString("guid");
|
for (int f = 0; f < staff.getRows(); f++) {
|
FieldSetEntity subfse = new FieldSetEntity();
|
//源表名
|
subfse.setTableName("product_oa_cooperate_flow_node");
|
//办理人层级
|
subfse.setValue("grade", grade);
|
//关联协同表uuid
|
subfse.setValue("cooperate_uuid", uuid);
|
//接收人id
|
subfse.setValue("receiver", staff.getString(f, "user_id"));
|
//接收人姓名
|
subfse.setValue("receiver_name", staff.getString(f, "show_name"));
|
//code
|
subfse.setValue("tricode", tricode);
|
//发送人姓名
|
subfse.setValue("sender_name", fse.getString("name"));
|
//发送人id
|
subfse.setValue("sender", user_id);
|
//0:未收未办 1:已收未 2:已收已办
|
subfse.setValue("status", fieldSetEntity.getInteger("status") == 1 ? 2 : 0);
|
//0:暂存 1:加签 2:转发 3:退回4:送办 5:终止 6:撤销
|
subfse.setValue("type", 0);
|
//用于后面关联协同流程
|
newDataTable.addFieldSetEntity(subfse);
|
data.addFieldSetEntity(subfse);
|
}
|
//用于后面关联协同流程
|
parentGuidData.put(guid, newDataTable);
|
}
|
|
public String emergencyDegreeType(String type) {
|
String reType = "";
|
switch (type) {
|
case "平件":
|
reType = "1";
|
break;
|
case "特急":
|
reType = "2";
|
break;
|
case "加急":
|
reType = "3";
|
break;
|
default:
|
throw new BaseException(SystemCode.FIELD_TYPE_FIAL.getValue(), SystemCode.FIELD_TYPE_FIAL.getText() + "_" + type);
|
|
}
|
return reType;
|
}
|
|
/**
|
* 迁移功能权限许可
|
*
|
* @param conn JDBC连接
|
* @param funUUID 方法uuid
|
* @param funCode 功能code
|
* @param buttonMap 按钮map
|
* @throws SQLException
|
*/
|
public void syncFunctionPermission(Connection conn, String funUUID, String funCode, JSONObject buttonMap) throws SQLException {
|
DataTableEntity permissionDt = null;
|
try {
|
StringBuffer sql = new StringBuffer();
|
sql.append(" select spt.SPT00 FU01,sfu.FU04 from fe_base5.SYS_POPEDOM_TEMPLET spt ")
|
.append(" LEFT JOIN fe_base5.SYS_FUNCTION_USER sfu on spt.SPT00 = sfu.FU01 OR spt.SPT03 = sfu.FU05 ")
|
.append(" WHERE sfu.FU02 = ? AND sfu.FU03 = 'R' GROUP BY sfu.FU04,spt.SPT00 ");
|
permissionDt = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{funCode});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
//循环关联的角色权限
|
for (int i = 0; i < permissionDt.getRows(); i++) {
|
FieldSetEntity permissionFs = permissionDt.getFieldSetEntity(i);
|
//角色id
|
String fu01 = permissionFs.getString("fu01");
|
//获取角色数据
|
FieldSetEntity roleFse = baseDao.getFieldSetEntityByFilter("product_sys_role", " sequence = ? ", new String[]{fu01}, true);
|
//查不到就跳过
|
if (roleFse == null) {
|
continue;
|
}
|
//源数据功能勾选号
|
String fu04 = permissionFs.getString("fu04");
|
//获取权限里的按钮
|
this.buttonCheck(conn, funCode, funUUID, fu04, buttonMap, roleFse.getUUID());
|
}
|
//同步关联人的权限
|
this.createPersonalRights(conn, funCode, funUUID, buttonMap);
|
//同步每个功能权限后 还要同步客户权限
|
// this.customerPermission(funUUID, buttonMap);
|
}
|
|
/**
|
* 添加按钮勾选
|
*
|
* @param conn JDBC连接
|
* @param funCode 功能code
|
* @param funUUID 方法uuid
|
* @param fu04 源数据功能勾选号
|
* @param buttonMap 按钮map
|
* @param roleUuid
|
* @throws SQLException
|
*/
|
private void buttonCheck(Connection conn, String funCode, String funUUID, String fu04, JSONObject buttonMap, String roleUuid) throws SQLException {
|
List<String> buttonIdType = new ArrayList<>();
|
buttonIdType.add(funCode);
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName("product_sys_function_permission");
|
fs.setValue("role_uuid", roleUuid);
|
fs.setValue("function_uuid", funUUID);
|
for (int j = 0; j < fu04.length(); j++) {
|
String type = String.valueOf(fu04.charAt(j));
|
if (type.equals("1")) {
|
//放入值的下标
|
buttonIdType.add(this.buttonTypeRole(j));
|
}
|
}
|
if (buttonIdType.size() == 1) {
|
return;
|
}
|
DataTableEntity eventDt = null;
|
try {
|
StringBuffer where = new StringBuffer();
|
where.append(" SE01=? ").append(" and ( ").append(BaseUtil.buildQuestionMarkFilter("SE12", buttonIdType.size() - 1, true)).append(" or SE08=1) ");
|
eventDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.SYS_EVENT", where.toString(), buttonIdType.toArray());
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
List<String> buttonId = Lists.newArrayList();
|
for (int j = 0; j < eventDt.getRows(); j++) {
|
buttonId.add(buttonMap.getString(eventDt.getString(j, "se00")));
|
}
|
fs.setValue("button_uuid", StringUtils.join(buttonId, ","));
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
try {
|
baseDao.add(fs);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 给单个人权限单独创建角色
|
*
|
* @param conn
|
* @param funCode
|
* @throws SQLException
|
*/
|
public void createPersonalRights(Connection conn, String funCode, String funUUID, JSONObject buttonMap) throws SQLException {
|
DataTableEntity usePermissionDt;
|
try {
|
usePermissionDt = BaseDaoServiceImpl.getDataTable(conn, "FE_BASE5.SYS_FUNCTION_USER", " FU02 = ? AND FU03 = 'U' ", new Object[]{funCode});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
if (!BaseUtil.dataTableIsEmpty(usePermissionDt)) {
|
String fu04 = usePermissionDt.getFieldSetEntity(0).getString("fu04");
|
//创建角色
|
FieldSetEntity lxRoleFs = new FieldSetEntity();
|
lxRoleFs.setTableName("product_sys_role");
|
lxRoleFs.setValue("org_level_uuid", "00000000-0000-0000-0000-000000000000");
|
lxRoleFs.setValue("role_name", this.functionName + "的个人权限");
|
lxRoleFs.setValue("role_description", this.functionName + "的个人权限");
|
lxRoleFs.setValue("is_used", 1);
|
lxRoleFs.setValue("created_by", 1);
|
lxRoleFs.setValue("created_utc_datetime", new Date());
|
String uuid = baseDao.add(lxRoleFs);
|
//同步权限关联的按钮
|
this.buttonCheck(conn, funCode, funUUID, fu04, buttonMap, uuid);
|
//该权限管理的是用户表(SYS_USERS) 并非角色表
|
List<String> userid = Lists.newArrayList();
|
for (int i = 0; i < usePermissionDt.getRows(); i++) {
|
FieldSetEntity permissionFs = usePermissionDt.getFieldSetEntity(i);
|
//用户id
|
String id = this.userIdJson.getString(permissionFs.getString("fu01"));
|
if (!BaseUtil.strIsNull(id)) {
|
userid.add(id);
|
}
|
}
|
//人员绑定该权限
|
if (userid.size() > 0) {
|
String[] user = new String[userid.size()];
|
userid.toArray(user);
|
String filter = BaseUtil.buildQuestionMarkFilter("user_id", user, true);
|
baseDao.executeUpdate("UPDATE product_sys_staffs SET role_uuids = CONCAT(role_uuids, '," + uuid + "') WHERE " + filter);
|
}
|
}
|
}
|
|
/**
|
* 同步客户权限
|
*
|
* @param funUUID 功能权限
|
* @param buttonMap 案例uuid map
|
*/
|
public void customerPermission(String funUUID, JSONObject buttonMap) {
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName("product_sys_function_permission");
|
fs.setValue("function_uuid", funUUID);
|
//客户uuid
|
fs.setValue("role_uuid", "8dddd416-a790-4a4e-8418-8c032d5f2394");
|
List<String> buttonUuid = new ArrayList<>();
|
for (String key : buttonMap.keySet()) {
|
buttonUuid.add(buttonMap.getString(key));
|
}
|
//若没有按钮 直接退出
|
if (buttonUuid.size() == 0) {
|
return;
|
}
|
fs.setValue("button_uuid", StringUtils.join(buttonUuid, ","));
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
try {
|
baseDao.add(fs);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
}
|
|
}
|
|
/**
|
* 创建一个功能下的角色
|
* 把直接关联功能的用户放入角色下
|
*
|
* @param conn 连接
|
* @param map k 为按钮权限,u 为关联用户权限的data
|
* @param funUUID 功能uuid
|
* @param funCode 功能code
|
* @param buttonJson 按钮json
|
* @param orgLevelUuid 公司uuid
|
*/
|
public void newFunctionRole(Connection conn, Map<String, DataTableEntity> map, String funUUID, String funCode, JSONObject buttonJson, String orgLevelUuid) {
|
for (Map.Entry<String, DataTableEntity> m : map.entrySet()) {
|
List<String> buttonIdType = new ArrayList<>();
|
buttonIdType.add(funCode);
|
String key = m.getKey();
|
for (int j = 0; j < key.length(); j++) {
|
String type = String.valueOf(key.charAt(j));
|
if (type.equals("1")) {
|
//放入值的下标
|
buttonIdType.add(this.buttonTypeRole(j));
|
}
|
}
|
//查询这条功能数据
|
FieldSetEntity funFse = baseDao.getFieldSetEntity("product_sys_function", funUUID, false);
|
//功能名称
|
String functionName = funFse.getString("function_name");
|
//创建角色
|
FieldSetEntity lxRoleFs = new FieldSetEntity();
|
lxRoleFs.setTableName("product_sys_role");
|
if (BaseUtil.strIsNull(orgLevelUuid)) {
|
orgLevelUuid = SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid();
|
}
|
lxRoleFs.setValue("org_level_uuid", orgLevelUuid);
|
|
String name = functionName + "功能下角色";
|
lxRoleFs.setValue("role_name", name);
|
lxRoleFs.setValue("role_description", name);
|
lxRoleFs.setValue("is_used", 1);
|
feDataDSService.userAndTime(lxRoleFs);
|
baseDao.add(lxRoleFs);
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName("product_sys_function_permission");
|
fs.setValue("function_uuid", funUUID);
|
StringBuffer where = new StringBuffer();
|
where.append(" SE01=? ").append(" and ( ").append(BaseUtil.buildQuestionMarkFilter("SE12", buttonIdType.size() - 1, true)).append(" or SE08=1) ");
|
DataTableEntity eventDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.SYS_EVENT", where.toString(), buttonIdType.toArray());
|
List<String> buttonId = new ArrayList<>();
|
for (int j = 0; j < eventDt.getRows(); j++) {
|
buttonId.add(buttonJson.getString(eventDt.getString(j, "se00")));
|
}
|
fs.setValue("button_uuid", StringUtils.join(buttonId, ","));
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
//创建角色
|
String uuid = baseDao.add(fs);
|
//角色关联用户uuid
|
DataTableEntity dataTableEntity = map.get(key);
|
//获取关联用户
|
for (int i = 0; i < dataTableEntity.getRows(); i++) {
|
String userId = dataTableEntity.getString(i, "fu01");
|
//获取用户
|
FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntityByFilter("product_sys_staffs", " remark = ? ", new String[]{userId}, false);
|
String roleUuids = fieldSetEntity.getString("role_uuids");
|
if (BaseUtil.strIsNull(roleUuids)) {
|
fieldSetEntity.setValue("role_uuids", uuid);
|
} else {
|
roleUuids = roleUuids + "," + uuid;
|
fieldSetEntity.setValue("role_uuids", roleUuids);
|
}
|
//保存修改角色权限后的用户
|
baseDao.add(fieldSetEntity);
|
}
|
|
}
|
}
|
|
private String buttonTypeRole(int type) {
|
String button_category_uuid = "";
|
switch (type) {
|
case 0:
|
button_category_uuid = "01";
|
break;
|
case 1:
|
button_category_uuid = "02";
|
break;
|
case 2:
|
button_category_uuid = "03";
|
break;
|
case 3:
|
button_category_uuid = "04";
|
break;
|
case 4:
|
button_category_uuid = "05";
|
break;
|
case 5:
|
button_category_uuid = "06";
|
break;
|
case 6:
|
button_category_uuid = "07";
|
break;
|
case 7:
|
button_category_uuid = "08";
|
break;
|
case 8:
|
button_category_uuid = "09";
|
break;
|
case 9:
|
button_category_uuid = "10";
|
break;
|
case 10:
|
button_category_uuid = "11";
|
break;
|
case 11:
|
button_category_uuid = "12";
|
break;
|
default:
|
throw new BaseException(SystemCode.FIELD_TYPE_FIAL.getValue(), SystemCode.FIELD_TYPE_FIAL.getText() + "_" + type);
|
}
|
return button_category_uuid;
|
}
|
|
/**
|
* 迁移功能下的按钮页面
|
*
|
* @param conn
|
* @param funUUID
|
* @param funCode
|
* @throws SQLException
|
*/
|
public JSONObject syncButtonsPage(Connection conn, String funUUID, String funCode) throws SQLException {
|
DataTableEntity buttonsDt = null;
|
try {//获取显示按钮
|
buttonsDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.SYS_EVENT", "SE30 = '1' AND SE01= ? ", new Object[]{funCode});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
String flow_uuid = null;
|
String sendButton = null;
|
JSONObject map = new JSONObject();
|
//名字为k 的json
|
Map<String, FieldSetEntity> nameButtonMap = Maps.newHashMap();
|
for (int i = 0; i < buttonsDt.getRows(); i++) {
|
FieldSetEntity buttonsFs = buttonsDt.getFieldSetEntity(i);
|
FieldSetEntity fs = new FieldSetEntity();
|
//按钮表
|
fs.setTableName("product_sys_function_buttons");
|
fs.setValue("function_uuid", funUUID);
|
//按钮名称
|
fs.setValue("button_name", buttonsFs.getString("se02"));
|
//按钮标题 如果为空 就用描述
|
String buttonsFsString = buttonsFs.getString("se31");
|
if (BaseUtil.strIsNull(buttonsFsString) || " ".equals(buttonsFsString)) {
|
buttonsFsString = buttonsFs.getString("se09");
|
}
|
fs.setValue("button_title", buttonsFsString);
|
//按钮描述
|
fs.setValue("button_description", buttonsFs.getString("se09"));
|
//点击触发按钮事件的类型:1: 入口,2:普通按钮 若为入口可能会绑定流程
|
if (buttonsFs.getInteger("se08") == 1) {
|
fs.setValue("button_type", 1);
|
//绑定的流程
|
String se16 = buttonsFs.getString("se16");
|
//不为空 单独处理流程关联
|
if (!BaseUtil.strIsNull(se16)) {
|
flow_uuid = se16;
|
}
|
} else {
|
fs.setValue("button_type", 2);
|
}
|
fs.setValue("button_type", buttonsFs.getInteger("se08") == 1 ? 1 : 2);
|
//是否启用
|
fs.setValue("status_uuid", 1);
|
String type;
|
if (buttonsFs.getInteger("se08") == 1) {
|
//是否为功能入口,1=是,0=否
|
fs.setValue("is_main", 1);
|
type = "main";
|
} else {
|
type = buttonType(buttonsFs.getString("se12"));
|
fs.setValue("is_main", 0);
|
}
|
//按钮分类:关联字典表(新增,修改,删除,查看,列表,导入,导出,送审)
|
|
fs.setValue("button_category_uuid", type);
|
//是删除按钮 都多选
|
if ("delete".equals(type)) {
|
//是否多选 1 是
|
fs.setValue("multiple_choice", 1);
|
//是否提醒
|
fs.setValue("is_warn", 1);
|
} else {
|
//是否多选 1 是
|
fs.setValue("multiple_choice", 0);
|
fs.setValue("is_warn", 0);
|
}
|
//客户端类型:关联数据字典
|
fs.setValue("client_type_uuid", "Web");
|
//位置top
|
fs.setValue("top_location", buttonsFs.getInteger("se11") + "px");
|
//位置left
|
fs.setValue("left_location", buttonsFs.getInteger("se10") + "px");
|
//事件前 fron_event 1000
|
fs.setValue("fron_event", buttonsFs.getString("se03"));
|
//逻辑方法 logical_method 800
|
fs.setValue("logical_method", buttonsFs.getString("se04"));
|
//事件后 event_after 900
|
fs.setValue("event_after", buttonsFs.getString("se05"));
|
//脚本类型 event_type 250
|
fs.setValue("event_type", buttonsFs.getString("se15"));
|
//引入脚本 script_method 暂不插入
|
// System.out.println("se14:" + buttonsFs.getString("se14"));
|
// 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"))) {
|
sendButton = uuid;
|
}
|
map.put(buttonsFs.getString("se00"), uuid);
|
//名字唯一
|
nameButtonMap.put(buttonsFs.getString("se09"), fs);
|
}
|
|
DataTableEntity pageDt = null;
|
try {
|
pageDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.SYS_PAGE", "SP01=?", new Object[]{funCode});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
JSONObject pageMap = new JSONObject();
|
Map<String, FieldSetEntity> pageNameMap = Maps.newHashMap();
|
for (int i = 0; i < pageDt.getRows(); i++) {
|
FieldSetEntity pageFs = pageDt.getFieldSetEntity(i);
|
FieldSetEntity fs = new FieldSetEntity();
|
//页面表
|
fs.setTableName("product_sys_mvc_page");
|
fs.setValue("function_uuid", funUUID);
|
//页面名称
|
String sp02 = pageFs.getString("sp02");
|
fs.setValue("page_name", sp02);
|
//禁用页面元素
|
fs.setValue("page_element_disabled", 0);
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
//位置top
|
fs.setValue("top_location", pageFs.getString("sp07") + "px");
|
//位置left
|
fs.setValue("left_location", pageFs.getString("sp06") + "px");
|
//表单类型 名称带有列表都是列表类型
|
if (sp02.contains("列表")) {
|
fs.setValue("page_type", 1);
|
} else {
|
fs.setValue("page_type", 0);
|
}
|
//页面是否可修改
|
fs.setValue("page_element_disabled", pageFs.getInteger("sp08") == 1 ? 0 : 1);
|
//页面路径暂存 fe引入js代码路径
|
fs.setValue("page_url", pageFs.getString("sp09"));
|
//先存入流程id 迁移流程后再替换
|
fs.setValue("flow_uuid", pageFs.getString("sp09"));
|
//打开方式
|
fs.setValue("page_open_with", 0);
|
String uuid = baseDao.add(fs);
|
pageMap.put(pageFs.getString("sp00"), uuid);
|
pageNameMap.put(sp02, fs);
|
}
|
DataTableEntity pageButtonDt = null;
|
try {
|
pageButtonDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.SYS_EVENT_PAGE", "SEP06=?", new Object[]{funCode});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
for (int i = 0; i < pageButtonDt.getRows(); i++) {
|
FieldSetEntity pageButtonFs = pageButtonDt.getFieldSetEntity(i);
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName("product_sys_link");
|
fs.setValue("function_uuid", funUUID);
|
//连线类型
|
fs.setValue("link_type", 0);
|
//起始uuid
|
String pageUuid = pageMap.getString(pageButtonFs.getString("sep01"));
|
fs.setValue("line_from", pageUuid);
|
//起始类型 页面
|
fs.setValue("from_type", 2);
|
//截止uuid
|
String buttonUuid = map.getString(pageButtonFs.getString("sep02"));
|
//为空表示关联失效的按钮 ,就不搬
|
if (BaseUtil.strIsNull(buttonUuid)) {
|
continue;
|
}
|
fs.setValue("line_to", buttonUuid);
|
//相等说明为送办 找到页面uuid存入流程
|
if (!BaseUtil.strIsNull(flow_uuid) && buttonUuid != null && buttonUuid.equals(sendButton)) {
|
if (pageUuid != null) {
|
FieldSetEntity fse = baseDao.getFieldSetEntity("product_sys_mvc_page", pageUuid, false);
|
fse.setValue("flow_uuid", flow_uuid);
|
baseDao.update(fse);
|
}
|
}
|
//截止类型
|
fs.setValue("to_type", 1);
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
baseDao.add(fs);
|
}
|
DataTableEntity buttonPageDt = null;
|
try {
|
//按钮连页面 按钮连按钮
|
buttonPageDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.SYS_REDIRECT", "SR06=?", new Object[]{funCode});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
throw e;
|
}
|
for (int i = 0; i < buttonPageDt.getRows(); i++) {
|
FieldSetEntity buttonPageFs = buttonPageDt.getFieldSetEntity(i);
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName("product_sys_link");
|
fs.setValue("function_uuid", funUUID);
|
fs.setValue("link_type", 0);
|
//按钮与页面或者按钮与页面关系字段
|
String sr05 = buttonPageFs.getString("sr05");
|
String[] sr05s = sr05.split("-->");
|
FieldSetEntity buttonFse = nameButtonMap.get(sr05s[0]);
|
if (buttonFse == null) {
|
continue;
|
}
|
//判断是否是入口
|
if (1 == buttonFse.getInteger("is_main")) {
|
//起始类型 0 入口 1 按钮 2 页面
|
fs.setValue("from_type", 0);
|
} else {
|
//起始类型 0 入口 1 按钮 2 页面
|
fs.setValue("from_type", 1);
|
}
|
fs.setValue("line_from", buttonFse.getUUID());
|
//获取按钮信息
|
//连接类型 1按钮连按钮 0按钮连页面
|
Integer sr02 = buttonPageFs.getInteger("sr02");
|
//连接的是按钮
|
if (1 == sr02) {
|
//获取按钮fse 1
|
FieldSetEntity buttonFse2 = nameButtonMap.get(sr05s[1]);
|
if (buttonFse2 == null) {
|
continue;
|
}
|
//判断是否是入口
|
if (1 == buttonFse2.getInteger("is_main")) {
|
//结束类型 0 入口 1 按钮 2 页面
|
fs.setValue("to_type", 0);
|
} else {
|
fs.setValue("to_type", 1);
|
}
|
fs.setValue("line_to", buttonFse2.getUUID());
|
} else {
|
//连接的是页面
|
//获取页面fse 0
|
FieldSetEntity pageFse = pageNameMap.get(sr05s[1]);
|
if (pageFse == null) {
|
continue;
|
}
|
//页面类型
|
fs.setValue("to_type", 2);
|
//页面uuid
|
fs.setValue("line_to", pageFse.getUUID());
|
}
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
baseDao.add(fs);
|
}
|
return map;
|
}
|
|
/**
|
* 按钮类型转换
|
*
|
* @param type
|
* @return
|
*/
|
private String buttonType(String type) {
|
String button_category_uuid = "";
|
if (type == null) {
|
button_category_uuid = "main";
|
return button_category_uuid;
|
}
|
switch (type) {
|
case "01":
|
button_category_uuid = "add";
|
break;
|
case "02":
|
button_category_uuid = "update";
|
break;
|
case "03":
|
button_category_uuid = "delete";
|
break;
|
case "04":
|
button_category_uuid = "view";
|
break;
|
case "05":
|
button_category_uuid = "print";
|
break;
|
case "06":
|
button_category_uuid = "import";
|
break;
|
case "07":
|
button_category_uuid = "custom";
|
break;
|
case "08":
|
button_category_uuid = "custom";
|
break;
|
case "09":
|
button_category_uuid = "audit";
|
break;
|
case "10":
|
button_category_uuid = "custom";
|
break;
|
case "11":
|
button_category_uuid = "custom";
|
break;
|
case "12":
|
button_category_uuid = "custom";
|
break;
|
default:
|
button_category_uuid = "custom";
|
|
}
|
return button_category_uuid;
|
}
|
|
/**
|
* @param funFs
|
* @param moduleCode 模块code
|
* @throws SQLException
|
*/
|
public void syncFunctions(FieldSetEntity funFs, String moduleCode, String moduleUUID, String sf28) throws SQLException, ClassNotFoundException {
|
if (!BaseUtil.strIsNull(funFs.getString("sf28"))) {
|
sf28 = funFs.getString("sf28");
|
}
|
FieldSetEntity product_sys_datamodel_table = new FieldSetEntity();
|
String table = "";
|
if (!BaseUtil.strIsNull(sf28)) {
|
table = sf28.split("\\.")[1].toLowerCase();
|
product_sys_datamodel_table = baseDao.getFieldSetEntityByFilter("product_sys_datamodel_table", "table_name=?", new String[]{table}, false);
|
} else {
|
return;
|
}
|
|
//迁移功能
|
FieldSetEntity fs = new FieldSetEntity();
|
fs.setTableName("product_sys_functions");
|
//表uuid
|
fs.setValue("table_uuid", product_sys_datamodel_table.getString("uuid"));
|
//功能名称
|
this.functionName = funFs.getString("sf03");
|
fs.setValue("function_name", this.functionName);
|
//功能描述
|
fs.setValue("function_description", this.functionName);
|
//上级code 上级模块code
|
fs.setValue("tricode_parent", moduleCode);
|
//功能code
|
String funCode = CodeUtil.getNewCodeByTemp(CmnConst.PRODUCT_SYS_FUNCTIONS, CmnConst.TRICODE, moduleCode);
|
fs.setValue("tricode", funCode);
|
//功能短编码
|
fs.setValue("function_shortcode", "feqy");
|
fs.setValue("status_uuid", "1");
|
fs.setValue("function_type_uuid", "1");
|
fs.setValue("client_type_uuid", "Web");
|
fs.setValue("version_uuid", "001");
|
fs.setValue("created_by", 1);
|
fs.setValue("created_utc_datetime", new Date());
|
fs.setValue("data_type", 1);
|
String funUUID = "";
|
try {
|
funUUID = baseDao.add(fs);
|
} catch (BaseException e) {
|
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});
|
String sf05 = funFs.getString("sf05");
|
//获取jdbc连接
|
Connection conn = this.getJDBC();
|
//迁移MVC
|
JSONObject buttonMap = this.syncButtonsPage(conn, funUUID, sf05);
|
//迁移菜单
|
try {
|
this.synchronizationMenu(conn, funFs.getString("sf05"), funUUID);
|
} catch (Exception e) {
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
}
|
//迁移功能权限许可
|
this.syncFunctionPermission(conn, funUUID, sf05, buttonMap);
|
//关闭连接
|
DataManipulationUtils.close(null, null, conn);
|
}
|
|
/**
|
* 同步模块名称
|
*
|
* @param conn 连接
|
* @param funCode 功能code
|
*/
|
public String synchronizationModuleName(Connection conn, String funCode, String sf28) throws SQLException {
|
FieldSetEntity funFse = null;
|
try {
|
//通过
|
funFse = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.SYS_FUNCTION", " SF05 = ? ", new Object[]{funCode});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
if (funFse == null) {
|
return null;
|
}
|
//模块名称
|
String sf01 = funFse.getString("sf01");
|
|
//同步模块名称
|
FieldSetEntity moduleFs = baseDao.getFieldSetEntityByFilter("product_sys_functions", " function_name = ? ", new String[]{sf01}, false);
|
String moduleCode = null;
|
String moduleUUID = null;
|
if (moduleFs == null) {
|
moduleFs = new FieldSetEntity();
|
moduleFs.setTableName("product_sys_functions");
|
//产品uuid
|
moduleFs.setValue("table_uuid", "ff44dc40-5fa6-4b99-a0c6-463fd5fb5c5b85");
|
moduleFs.setValue("function_name", sf01);
|
moduleFs.setValue("function_description", sf01);
|
//产品code
|
moduleFs.setValue("tricode_parent", "001");
|
moduleCode = CodeUtil.getNewCodeByTemp(CmnConst.PRODUCT_SYS_FUNCTIONS, CmnConst.TRICODE, "001");
|
moduleFs.setValue("tricode", moduleCode);
|
moduleFs.setValue("function_shortcode", "feqymk");
|
moduleFs.setValue("status_uuid", "1");
|
moduleFs.setValue("function_type_uuid", "0");
|
moduleFs.setValue("function_icon", "0");
|
moduleFs.setValue("client_type_uuid", "Web");
|
moduleFs.setValue("version_uuid", "001");
|
moduleFs.setValue("created_by", 1);
|
moduleFs.setValue("created_utc_datetime", new Date());
|
moduleFs.setValue("data_type", 2);
|
//新增一个fe迁移总模块
|
try {
|
moduleUUID = baseDao.add(moduleFs);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
}
|
} else {
|
moduleCode = moduleFs.getString("tricode");
|
moduleUUID = moduleFs.getUUID();
|
}
|
//同步模块下的功能
|
try {
|
this.syncFunctions(funFse, moduleCode, moduleUUID, sf28);
|
} catch (ClassNotFoundException e) {
|
e.printStackTrace();
|
}
|
//同步菜单
|
return moduleUUID;
|
}
|
|
/**
|
* 同步菜单 如果没有上级目录 创建上级目录
|
*
|
* @param conn jdbc连接
|
* @param funCode 同步code
|
*/
|
public void synchronizationMenu(Connection conn, String funCode, String funUUID) throws SQLException, BaseException {
|
//根据功能code获取菜单
|
FieldSetEntity menuFse = null;
|
try {
|
//菜单信息
|
menuFse = BaseDaoServiceImpl.getFieldSet(conn, "FE_BASE5.DESKTOP_MENU_MANAGEMENT", " URL = ? ", new Object[]{funCode});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
//查询是否有菜单和目录名称
|
FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntityByFilter("product_sys_menus", " menu_name = ? ", new String[]{menuFse.getString("temp")}, false);
|
//创建菜单
|
FieldSetEntity fieldSet = new FieldSetEntity();
|
fieldSet.setTableName("product_sys_menus");
|
//是否目录 0否、1是
|
fieldSet.setValue("is_catalog", 0);
|
//是否显示 0:不显示、 1:显示
|
fieldSet.setValue("is_show", "1");
|
//关联功能
|
fieldSet.setValue("function_uuid", funUUID);
|
//菜单描述
|
fieldSet.setValue("menu_description", menuFse.getString("name"));
|
//菜单名称
|
fieldSet.setValue("menu_name", menuFse.getString("name"));
|
//排列顺序 方源菜单id
|
fieldSet.setValue("sequence", menuFse.getString("id"));
|
//图标
|
fieldSet.setValue("menu_icon", "form");
|
String menuCode;
|
//没有就创建菜单目录
|
if (fieldSetEntity == null) {
|
FieldSetEntity menuFieldSet = new FieldSetEntity();
|
menuFieldSet.setTableName("product_sys_menus");
|
//是否目录 0否、1是
|
menuFieldSet.setValue("is_catalog", 1);
|
//是否显示 0:不显示、 1:显示
|
menuFieldSet.setValue("is_show", "1");
|
//关联功能为空
|
menuFieldSet.setValue("function_uuid", "");
|
//图标
|
menuFieldSet.setValue("menu_icon", "clipboard");
|
//菜单描述
|
menuFieldSet.setValue("menu_description", menuFse.getString("temp"));
|
//菜单名称
|
menuFieldSet.setValue("menu_name", menuFse.getString("temp"));
|
//排列顺序 方源菜单目录id
|
menuFieldSet.setValue("sequence", menuFse.getString("fatherid"));
|
menuCode = CodeUtil.getNewCodeByTemp("product_sys_menus", "tricode", "");
|
//编码
|
menuFieldSet.setValue("tricode", menuCode);
|
//父级编码
|
menuFieldSet.setValue("tricode_parent", "");
|
try {
|
baseDao.add(menuFieldSet);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
}
|
|
} else {
|
menuCode = fieldSetEntity.getString("tricode");
|
}
|
//生成的菜单编码
|
fieldSet.setValue("tricode", CodeUtil.getNewCodeByTemp("product_sys_menus", "tricode", menuCode));
|
//父级编码
|
fieldSet.setValue("tricode_parent", menuCode);
|
try {
|
baseDao.add(fieldSet);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
}
|
}
|
|
private Set<String> clearAttachment = new HashSet<>();
|
|
/**
|
* 迁移业务数据表
|
*
|
* @param sf28s 库名和表名
|
* @param conn 连接
|
* @return
|
* @throws SQLException
|
*/
|
public void syncTable(String[] sf28s, boolean isNew, String subField, Connection conn) throws Exception {
|
FieldSetEntity Orlfs;
|
//表名
|
String taName = sf28s[1];
|
//获取主表的表名
|
if (sf28s.length == 3) {
|
this.masterTableName = sf28s[2];
|
}
|
try {
|
Orlfs = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.SYS_TABLE", "ST03=?", new Object[]{taName});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
Map<String, String> map;
|
Boolean syncAttachments;
|
DataTableEntity accessoryData;
|
//是否是新表
|
if (isNew) {
|
|
//判断是否是已经同步过的表
|
// FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntityByFilter("product_sys_datamodel_table", " table_name = ? ", new String[]{taName.toLowerCase()}, false);
|
// if (fieldSetEntity == null) {
|
//查询该表字有没有附件字段 media attachment
|
accessoryData = this.getTableFieldAttachment(conn, Orlfs.getString("st00"));
|
if (!BaseUtil.dataTableIsEmpty(accessoryData)) {
|
syncAttachments = true;
|
for (int i = 0; i < accessoryData.getRows(); i++) {
|
this.attachmentValue = this.attachmentValue + accessoryData.getString(i, "si04") + ",";
|
}
|
this.attachmentValue = "," + this.attachmentValue;
|
} else {
|
syncAttachments = false;
|
}
|
//同步表结构 及字段信息
|
map = this.syncTableField(conn, Orlfs, sf28s, subField);
|
//清空表数据
|
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;
|
}
|
//迁移表里面数据
|
DataTableEntity dataDt = null;
|
try {
|
dataDt = BaseDaoServiceImpl.getDataTable(conn, sf28s[0] + "." + sf28s[1], null, new String[]{});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
e.printStackTrace();
|
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 为数据源字段
|
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 (tableFs.getTableName().equalsIgnoreCase("sfgl")) {
|
tableFs.setValue("is_print", "0");
|
}
|
}
|
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();
|
}
|
}
|
//批量插入数据
|
batchAddData.add(dt);
|
//同步完一张表数据后清空json数据
|
fieldTypeJson.clear();
|
DataTableEntity subTble = null;
|
try {
|
//查询是否有子表
|
subTble = BaseDaoServiceImpl.getDataTable(conn, "SELECT a.SF01, a.SF10,b.ST02 ST02,b.ST03 ST03 FROM FE_BASE5.SYS_FIELD a INNER JOIN FE_BASE5.SYS_TABLE b on a.SF00=b.ST00 WHERE a.SF10 LIKE ? ", new String[]{"%." + taName + ".%"});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
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};
|
if (isStr(sf.getString("st02") + "\\." + sf.getString("st03"))) {
|
isNew = false;
|
}
|
this.syncTable(a, isNew, sf.getString("sf01").toLowerCase(), conn);
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
logger.error("syncTable", e);
|
}
|
}
|
|
/**
|
* 判断是否是引用数据 是就要转换(如人员id,机构id)
|
*
|
* @param tableName 表名点.字段名
|
* @return
|
*/
|
public String transformReferenceData(Connection conn, String tableName, String fieldName, FieldSetEntity fieldSetEntity) throws SQLException {
|
DataTableEntity dataTable;
|
try {
|
StringBuffer sql = new StringBuffer();
|
sql.append(" SELECT * FROM fe_base5.SYS_FACEITEM A FULL JOIN fe_base5.SYS_FACE B ")
|
.append(" ON A.SI01 = B.SF00 LEFT JOIN FE_BASE5.SYS_FACECTRLPROP C ON A.SI00 = C.SP00 ")
|
.append(" WHERE SI04 = ? AND B.SF01 = ( SELECT st00 FROM fe_base5.sys_table WHERE st03 = ?) AND C.SP01 = 'prompt' AND SP02 IN ('[100001]', '[100000]') ");
|
dataTable = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new String[]{fieldName, tableName});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
//是否是关联单个人员控件
|
if (BaseUtil.dataTableIsEmpty(dataTable)) {
|
try {
|
//是否是关联单个单位部门控件
|
StringBuffer sql = new StringBuffer();
|
sql.append(" SELECT * FROM fe_base5.SYS_FACEITEM A FULL JOIN fe_base5.SYS_FACE B ")
|
.append(" ON A.SI01 = B.SF00 LEFT JOIN FE_BASE5.SYS_FACECTRLPROP C ON A.SI00 = C.SP00 ")
|
.append(" WHERE SI04 = ? AND B.SF01 = ( SELECT st00 FROM fe_base5.sys_table WHERE st03 = ?) AND ((C.SP01 = 'orgtype' AND C.SP02 = 'A11') OR (C.SP01 = 'prompt' AND C.SP02 IN ('[010001]','[010000]'))) ");
|
|
dataTable = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new String[]{fieldName, tableName});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
if (BaseUtil.dataTableIsEmpty(dataTable)) {
|
try {
|
//是否是关联部门岗位人员多选控件
|
StringBuffer sql = new StringBuffer();
|
sql.append(" SELECT * FROM fe_base5.SYS_FACEITEM A FULL JOIN fe_base5.SYS_FACE B ")
|
.append(" ON A.SI01 = B.SF00 LEFT JOIN FE_BASE5.SYS_FACECTRLPROP C ON A.SI00 = C.SP00 ")
|
.append(" WHERE SI04 = ? AND B.SF01 = ( SELECT st00 FROM fe_base5.sys_table WHERE st03 = ?) AND C.SP01 = 'prompt' AND SP02 = '[111110]' ");
|
|
dataTable = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new String[]{fieldName, tableName});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
//如果是多选控件
|
if (!BaseUtil.dataTableIsEmpty(dataTable)) {
|
fieldTypeJson.put(fieldName.toLowerCase(), "USERSGROUPS");
|
return "800";
|
}
|
} else {
|
fieldTypeJson.put(fieldName.toLowerCase(), "GROUP");
|
//添加部门公司参照
|
fieldSetEntity.setValue("field_reference", "levels");
|
return "80";
|
}
|
} else {
|
//添加人员参照
|
fieldTypeJson.put(fieldName.toLowerCase(), "USER");
|
fieldSetEntity.setValue("field_reference", "user_name_by_user_id");
|
}
|
return null;
|
}
|
|
/**
|
* 同步附件
|
*
|
* @param accessoryData 附件字段data
|
* @param tableFs 数据值
|
*/
|
public Map<String, List<String>> synchronizationAttachments(Connection conn, DataTableEntity accessoryData, FieldSetEntity tableFs, String table, String myField) throws Exception {
|
Map<String, List<String>> filesMap = Maps.newHashMap();
|
for (int i = 0; i < accessoryData.getRows(); i++) {
|
//类型
|
String type = accessoryData.getString(i, "si02");
|
//字段
|
String field = accessoryData.getString(i, "si04").toLowerCase();
|
//获取附件值
|
String attachmentsValue = tableFs.getString(field);
|
if (!BaseUtil.strIsNull(myField)) {
|
field = myField;
|
}
|
if (!BaseUtil.strIsNull(attachmentsValue)) {
|
List<String> fileUuids = Lists.newArrayList();
|
//普通附件
|
if ("attachment".equals(type)) {
|
//取出附件表数据
|
fileUuids = this.synchronizeCommonAccessories(conn, field, table, attachmentsValue);
|
//金格附件
|
} else if ("media".equals(type)) {
|
//附件值
|
Map<String, File> mediaFiles = gdMediaUtil.getMediaFiles(attachmentsValue);
|
for (String name : mediaFiles.keySet()) {
|
File sourceFile = mediaFiles.get(name);
|
String newPath = this.TSPath + File.separator + name;
|
File isField = new File(newPath);
|
//如果已经有该文件 改变文件目录
|
Integer fileNum = 0;
|
while (isField.exists()) {
|
fileNum++;
|
newPath = this.TSPath + fileNum + File.separator + name;
|
isField = new File(newPath);
|
}
|
//源绝对路径
|
String path = sourceFile.getAbsolutePath();
|
if (feDataDSService.copyFile(path, newPath)) {
|
RequestParameterEntity rpe = new RequestParameterEntity();
|
Map<String, File> fileMap = Maps.newHashMap();
|
//通过路径获取File
|
File file = new File(newPath);
|
//文件名 文件file
|
fileMap.put(name, file);
|
FieldSetEntity fieldSetEntity = new FieldSetEntity();
|
FieldMetaEntity f = new FieldMetaEntity();
|
f.setTableName(new String[]{table});
|
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);
|
rpe.setFormData(fieldSetEntity);
|
try {
|
FieldSetEntity fileFse = fileManagerService.uploadFile(rpe);
|
fileUuids.add(fileFse.getString(field));
|
} catch (Exception e) {
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
logger.error("synchronizationAttachments", e);
|
}
|
}
|
}
|
}
|
if (fileUuids != null && fileUuids.size() > 0) {
|
filesMap.put(field, fileUuids);
|
}
|
}
|
}
|
return filesMap;
|
}
|
|
/**
|
* 同步普通附件方法
|
*
|
* @param conn 连接
|
* @param field 本字段名
|
* @param table 本表名
|
* @param attachmentsValue 源关联值
|
* @return
|
*/
|
public List<String> synchronizeCommonAccessories(Connection conn, String field, String table, String attachmentsValue) {
|
//取出附件表数据
|
DataTableEntity attachmentsData = this.getOrdinaryAttachments(conn, attachmentsValue);
|
if (!BaseUtil.dataTableIsEmpty(attachmentsData)) {
|
|
List<String> fileUuids = Lists.newArrayList();
|
for (int j = 0; j < attachmentsData.getRows(); j++) {
|
//保存名称
|
String sa02 = attachmentsData.getString(j, "sa02");
|
//显示名称
|
String sa03 = attachmentsData.getString(j, "sa03");
|
//保存路径
|
String sa04 = attachmentsData.getString(j, "sa04");
|
String filePath = sa04 + File.separator + sa02;
|
String newPath = this.TSPath + File.separator + sa03;
|
File isField = new File(newPath);
|
//如果已经有该文件 改变文件目录
|
Integer fileNum = 0;
|
while (isField.exists()) {
|
fileNum++;
|
newPath = this.TSPath + fileNum + File.separator + sa03;
|
isField = new File(newPath);
|
}
|
//复制到临时目录下
|
if (feDataDSService.copyFile(filePath, newPath)) {
|
RequestParameterEntity rpe = new RequestParameterEntity();
|
Map<String, File> fileMap = Maps.newHashMap();
|
//通过路径获取File
|
File file = new File(newPath);
|
//文件名 文件file
|
fileMap.put(sa03, file);
|
FieldSetEntity fieldSetEntity = new FieldSetEntity();
|
FieldMetaEntity f = new FieldMetaEntity();
|
f.setTableName(new String[]{table});
|
fieldSetEntity.setMeta(f);
|
fieldSetEntity.setValue(field, sa03);
|
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 {
|
FieldSetEntity fileFse = fileManagerService.uploadFile(rpe);
|
fileUuids.add(fileFse.getString(field));
|
} catch (Exception e) {
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
}
|
|
//成功之后删除临时文件
|
// feDataDSService.deleteFile(newPath);
|
}
|
}
|
return fileUuids;
|
} else {
|
return null;
|
}
|
}
|
|
/**
|
* 获取普通附件信息
|
*
|
* @param value 附件标识
|
* @return
|
*/
|
public DataTableEntity getOrdinaryAttachments(Connection conn, String value) {
|
DataTableEntity dataTableEntity = null;
|
StringBuffer sql = new StringBuffer();
|
sql.append(" SELECT * FROM FE_BASE5.SYS_ATTACHMENT WHERE SA01 = ? ");
|
dataTableEntity = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{value});
|
return dataTableEntity;
|
}
|
|
/**
|
* 获取金格附件信息
|
*
|
* @param value 附件标识
|
* @return
|
*/
|
public DataTableEntity getMediaSortInfo(Connection conn, String value) throws Exception {
|
DataTableEntity dataTableEntity = null;
|
StringBuffer sql = new StringBuffer();
|
sql.append(" SELECT * FROM FE_APP5.WF_MEDIA_SORT WHERE WMS02 = ? ");
|
dataTableEntity = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{value});
|
return dataTableEntity;
|
}
|
|
/**
|
* 通过表名获取同步的附件字段
|
*
|
* @param tableName 表名
|
* @return
|
*/
|
public DataTableEntity getTableNameAttachment(Connection conn, String tableName) {
|
DataTableEntity dataTableEntity = null;
|
String[] names = tableName.split("\\.");
|
StringBuffer sql = new StringBuffer();
|
sql.append(" SELECT A.SI02,A.SI04 FROM fe_base5.SYS_FACEITEM A FULL JOIN fe_base5.SYS_FACE B ")
|
.append(" ON A.SI01 = B.SF00 WHERE B.SF01 = ( SELECT st00 FROM fe_base5.sys_table WHERE st03 = ?) ")
|
.append("AND (A.SI02 = 'media' OR A.SI02 = 'attachment') GROUP BY A.SI04,A.SI02 ");
|
|
dataTableEntity = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{names[1]});
|
return dataTableEntity;
|
}
|
|
/**
|
* 通过表id获取同步的附件字段
|
*
|
* @param tableId 表id
|
* @return
|
*/
|
public DataTableEntity getTableFieldAttachment(Connection conn, String tableId) throws Exception {
|
DataTableEntity dataTableEntity = null;
|
StringBuffer sql = new StringBuffer();
|
sql.append(" SELECT A.SI02,A.SI04 FROM fe_base5.SYS_FACEITEM A FULL JOIN fe_base5.SYS_FACE B ")
|
.append(" ON A.SI01 = B.SF00 WHERE B.SF01 = ? AND (A.SI02 = 'media' OR A.SI02 = 'attachment') GROUP BY A.SI04,A.SI02 ");
|
dataTableEntity = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{tableId});
|
return dataTableEntity;
|
}
|
|
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);
|
}
|
|
/**
|
* 迁移"product_sys_datamodel_field 和"product_sys_datamodel_table表
|
*
|
* @throws SQLException
|
*/
|
public Map<String, String> syncTableField(Connection conn, FieldSetEntity Orlfs, String[] tableName, String subField) throws SQLException {
|
Map<String, String> map = Maps.newHashMap();
|
FieldSetEntity tableFs = new FieldSetEntity();
|
tableFs.setTableName("product_sys_datamodel_table");
|
String table_name = Orlfs.getString("st03");
|
this.originalTable.put(table_name, table_name.toLowerCase());
|
tableFs.setValue("table_name", table_name.toLowerCase());
|
tableFs.setValue("table_description", Orlfs.getString("st04"));
|
tableFs.setValue("table_primary_key", "uuid");
|
tableFs.setValue("table_type", "1");
|
tableFs.setValue("created_by", 1);
|
tableFs.setValue("created_utc_datetime", new Date());
|
tableFs.setValue("sequence", 1);
|
// baseDao.saveFieldSetEntity(tableFs);
|
DataTableEntity Orldt = null;
|
try {
|
Orldt = BaseDaoServiceImpl.getDataTable(conn, "select a.*,b.DATA_TYPE from SYS_FIELD a LEFT JOIN (select * from all_tab_columns where TABLE_NAME=? and OWNER =?) b on a.SF01=b.COLUMN_NAME where SF00=(select ST00 from SYS_TABLE where ST03=?)", new String[]{tableName[1], tableName[0], tableName[1]});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
DataTableEntity dt = new DataTableEntity();
|
String table_uuid = tableFs.getString("uuid");
|
//封装源表名与uuid
|
originalUuid.put(table_name, table_uuid);
|
boolean is_pk = false;
|
for (int i = 0; i < Orldt.getRows(); i++) {
|
FieldSetEntity rowFs = Orldt.getFieldSetEntity(i);
|
FieldSetEntity fieldFs = new FieldSetEntity();
|
fieldFs.setTableName("product_sys_datamodel_field");
|
fieldFs.setValue("table_uuid", table_uuid);
|
//判断字段是否引用了用户字段 或 单位部门字段
|
String sf01 = rowFs.getString("sf01");
|
// 判断是否是引用数据 是就要转换(如人员id,机构id)
|
String length = transformReferenceData(conn, table_name, sf01, fieldFs);
|
map.put(sf01.toLowerCase(), sf01.toLowerCase());
|
fieldFs.setValue("field_name", sf01.toLowerCase());
|
fieldFs.setValue("field_description", rowFs.getString("sf02"));
|
fieldFs.setValue("field_show_name", rowFs.getString("sf02"));
|
String sf03 = rowFs.getString("sf03");
|
String type = this.fieldTypeFE(sf03);
|
//是否有字段关联主表
|
if ("pk".equals(type)) {
|
//如果已经有pk
|
if (is_pk) {
|
type = "string";
|
} else {
|
this.pk = sf01.toLowerCase();
|
is_pk = true;
|
}
|
}
|
fieldFs.setValue("field_type", type);
|
if ("GUID".equals(sf03)) {
|
fieldFs.setValue("is_unique", 1);
|
} else {
|
fieldFs.setValue("is_unique", 0);
|
}
|
if ("NATIVE".equals(sf03)) {
|
fieldFs.setValue("NATIVE", 1);
|
}
|
if ("UNITCODE".equals(sf03)) {
|
fieldFs.setValue("UNITCODE", 1);
|
}
|
//如果是关联主表字段 长度改为64
|
if (subField != null && subField.equals(sf01.toLowerCase())) {
|
fieldFs.setValue("field_type", "string");
|
fieldFs.setValue("field_length", 64);
|
} else {
|
//如果为附件字段长度500
|
if ("ATTACHMENT".equals(sf01) || "IMAGE".equals(sf03) || "MEDIA".equals(sf03)) {
|
fieldFs.setValue("field_length", 500);
|
//时间字段长度赋0
|
} else if ("datetime".equals(type)) {
|
fieldFs.setValue("field_length", 0);
|
//多选控件添额外加字段长度
|
} else if (!BaseUtil.strIsNull(length)) {
|
fieldFs.setValue("field_length", length);
|
} else {
|
fieldFs.setValue("field_length", rowFs.getString("sf04"));
|
}
|
}
|
//包含就为附件字段
|
if (!BaseUtil.strIsNull(this.attachmentValue) && this.attachmentValue.contains("," + sf01 + ",")) {
|
fieldFs.setValue("field_type", "file");
|
fieldFs.setValue("field_length", 500);
|
}
|
//特殊表 附件扩大
|
if ("FWGZ".equals(table_name) && "FW12".equals(sf01)) {
|
fieldFs.setValue("field_length", 5000);
|
}
|
fieldFs.setValue("field_unit", rowFs.getString("sf05"));
|
fieldFs.setValue("is_required", 0);
|
fieldFs.setValue("is_filter", 0);
|
String sf10 = rowFs.getString("sf10");
|
if (!BaseUtil.strIsNull(this.masterTableName)) {
|
if (!BaseUtil.strIsNull(sf10) && sf10.contains(this.masterTableName)) {
|
fieldFs.setValue("field_type", "parentuuid");
|
fieldFs.setValue("field_relation_table", this.originalUuid.get(this.masterTableName));
|
}
|
}
|
// baseDao.saveFieldSetEntity(fieldFs);
|
dt.addFieldSetEntity(fieldFs);
|
}
|
|
//如果没有自增主键 创建一个
|
if (!is_pk) {
|
//添加自增主键
|
FieldSetEntity fieldFs = new FieldSetEntity();
|
fieldFs.setTableName("product_sys_datamodel_field");
|
fieldFs.setValue("table_uuid", table_uuid);
|
fieldFs.setValue("field_name", tableFs.getString("table_name") + "_id");
|
fieldFs.setValue("field_description", "自增主键");
|
fieldFs.setValue("field_type", "pk");
|
fieldFs.setValue("field_length", 11);
|
fieldFs.setValue("is_required", 0);
|
fieldFs.setValue("is_unique", 1);
|
fieldFs.setValue("is_international", 0);
|
fieldFs.setValue("created_by", 1);
|
fieldFs.setValue("created_utc_datetime", new Date());
|
fieldFs.setValue("field_show_name", "自增主键");
|
// baseDao.saveFieldSetEntity(fieldFs);
|
dt.addFieldSetEntity(fieldFs);
|
}
|
//添加uuid唯一标识
|
FieldSetEntity fieldFs = new FieldSetEntity();
|
fieldFs.setTableName("product_sys_datamodel_field");
|
fieldFs.setValue("table_uuid", table_uuid);
|
fieldFs.setValue("field_name", "uuid");
|
fieldFs.setValue("field_description", "唯一标识");
|
fieldFs.setValue("field_type", "string");
|
fieldFs.setValue("field_length", 80);
|
fieldFs.setValue("field_unit", 0);
|
fieldFs.setValue("is_required", 0);
|
fieldFs.setValue("is_unique", 0);
|
fieldFs.setValue("is_international", 0);
|
fieldFs.setValue("created_by", 1);
|
fieldFs.setValue("created_utc_datetime", new Date());
|
fieldFs.setValue("field_show_name", "唯一标识");
|
|
// baseDao.saveFieldSetEntity(fieldFs);
|
dt.addFieldSetEntity(fieldFs);
|
//创建表方法
|
StringBuilder createStatement = createTable(createFields(dt), Orlfs.getString("st03"), Orlfs.getString("st04"));
|
//创建表方法
|
// execute(createStatement.toString());
|
return map;
|
}
|
|
/**
|
* //迁移 wf_model流程模块表
|
*
|
* @param conn
|
* @throws SQLException
|
*/
|
public String syncModel(String tricode_funs, Connection conn, String module_uuid, String sf28, String org_level_uuid, int created_by, String typeCode, boolean flag) throws SQLException {
|
FieldSetEntity Orlfs = null;
|
try {
|
//通过
|
Orlfs = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.wf_model", " wm05=(SELECT se16 FROM fe_base5.SYS_EVENT where se01=? and se08 = 1) ", new Object[]{tricode_funs
|
});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
e.printStackTrace();
|
throw e;
|
}
|
if (Orlfs == null) {
|
//通过
|
Orlfs = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.wf_model", " WM04 = ? ", new Object[]{sf28});
|
if (Orlfs == null) {
|
return null;
|
}
|
}
|
//wm05 为流程编码 查询存有编码的mvc页面 改为流程uuid
|
String wm05 = Orlfs.getString("wm05");
|
String flowTitle = Orlfs.getString("wm01");
|
//查询表中是否有相同名称的流程
|
|
FieldSetEntity modelFs = new FieldSetEntity();
|
//flow流程表
|
modelFs.setTableName("product_sys_flow_model");
|
//名称
|
modelFs.setValue("title", Orlfs.getString("wm01"));
|
//描述
|
modelFs.setValue("flow_model_describe", Orlfs.getString("wm02"));
|
//关联模块表
|
modelFs.setValue("module_uuid", module_uuid);
|
//流程关联主表名称
|
String wm04 = Orlfs.getString("wm04");
|
//流程表没有就从功能表里面查询
|
if (BaseUtil.strIsNull(wm04) || wm04.indexOf(".") == -1) {
|
try {
|
//通过
|
FieldSetEntity funFse = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.SYS_FUNCTION", " SF05 = ? ", new Object[]{tricode_funs});
|
wm04 = funFse.getString("sf28");
|
if (BaseUtil.strIsNull(wm04) || wm04.indexOf(".") == -1) {
|
return null;
|
}
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
//如果功能表和流程表绑定的数据表不相同 以流程表为主
|
} else if (!wm04.equals(sf28)) {
|
String[] wm04s = wm04.split("\\.");
|
try {
|
this.syncTable(wm04s, false, null, conn);
|
} catch (Exception e) {
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
logger.error("syncModel", e);
|
}
|
|
}
|
|
String[] wm04s = wm04.split("\\.");
|
//主表表名
|
modelFs.setValue("table_uuid", this.originalTable.getString(wm04s[1]));
|
//生成uuid
|
if (BaseUtil.strIsNull(typeCode)) {
|
typeCode = UUID.randomUUID().toString();
|
}
|
modelFs.setValue("type_code", typeCode);
|
|
modelFs.setValue("org_level_uuid", org_level_uuid);
|
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 = ? 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);
|
if (mvcPageFse != null) {
|
//mvc页面绑定流程uuid
|
mvcPageFse.setValue("flow_uuid", typeCode);
|
baseDao.update(mvcPageFse);
|
}
|
|
|
String wm00 = Orlfs.getString("wm00");
|
//迁移WF_NODES 流程节点表
|
JSONObject nodesUUID = null;
|
if (FieldSetEntity.isEmpty(existFlow)) {
|
nodesUUID = this.syncNodes(wm00, conn, modelUuid);
|
//迁移WF_NODES 流程节点表 到"product_sys_flow_processor 处理器迁移
|
this.syncProcessor(wm00, conn, modelUuid);
|
//迁移WF_LINKS
|
this.syncLinks(wm00, conn, modelUuid);
|
} else {
|
DataTableEntity nodeMapping = baseDao.listTable("product_fe_flow_node_mapping", "flow_uuid=? ", new Object[]{existFlow.getUUID()});
|
nodesUUID = new JSONObject();
|
for (int i = 0; i < nodeMapping.getRows(); i++) {
|
nodesUUID.put(nodeMapping.getString(i, "wn53"), nodeMapping.getString(i, "node_uuid"));
|
}
|
}
|
|
if (flag) {
|
try {
|
//迁移 WF_TASK
|
Map<String, FieldSetEntity> taskFseMap = this.syncTask(tricode_funs, conn, modelUuid);
|
//迁移wf_infor 节点任务处理情况表
|
Map<String, String> stateMap = this.syncDetail(tricode_funs, conn, nodesUUID, sf28, modelUuid, taskFseMap);
|
//同步消息
|
try {
|
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);
|
}
|
}
|
return typeCode;
|
}
|
|
/**
|
* 迁移 flow处理器
|
*
|
* @throws SQLException
|
*/
|
public void syncProcessor(String wm00, Connection conn, String modelUUID) throws SQLException {
|
DataTableEntity OrlDt = null;
|
try {
|
OrlDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.wf_nodes", " WN01= ? and WN04 ='5'", new Object[]{wm00
|
});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
for (int i = 0; i < OrlDt.getRows(); i++) {
|
FieldSetEntity Orlfs = OrlDt.getFieldSetEntity(i);
|
FieldSetEntity processorFs = new FieldSetEntity();
|
// flow处理器
|
processorFs.setTableName("product_sys_flow_processor");
|
processorFs.setValue("created_by", 1);
|
processorFs.setValue("created_utc_datetime", new Date());
|
//标题
|
processorFs.setValue("title", Orlfs.getString("wn02"));
|
//类型:1-java,2-sql WN47 1 sql 2 java
|
processorFs.setValue("processor_type", Orlfs.getInteger("wn47") == 1 ? 2 : 1);
|
//详细内容
|
processorFs.setValue("content", Orlfs.getString("wn48"));
|
//关联"product_sys_flow_model
|
processorFs.setValue("flow_uuid", modelUUID);
|
//坐标,节点到上边界的垂直距离
|
processorFs.setValue("location_top", Orlfs.getInteger("wn38") + "px");
|
//坐标,节点到左边界的垂直距离
|
processorFs.setValue("location_left", Orlfs.getInteger("wn37") + "px");
|
String uuid = baseDao.add(processorFs);
|
//顺序号
|
nodesIdUUID.put(Orlfs.getString("wn00"), uuid);
|
}
|
}
|
|
/**
|
* 同步流程节点
|
*
|
* @param wm00 流程主表id
|
* @param conn
|
* @param modelUUID 模块uuid
|
* @return
|
* @throws SQLException
|
*/
|
public JSONObject syncNodes(String wm00, Connection conn, String modelUUID) throws SQLException {
|
DataTableEntity OrlDt = null;
|
try {
|
OrlDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.wf_nodes", " WN01 = ? and WN04 !='5' ", new Object[]{wm00
|
});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
JSONObject map = new JSONObject();
|
nodesIdUUID = new JSONObject();
|
try {
|
for (int i = 0; i < OrlDt.getRows(); i++) {
|
FieldSetEntity Orlfs = OrlDt.getFieldSetEntity(i);
|
FieldSetEntity nodeFs = new FieldSetEntity();
|
|
|
// WN62 关联表单字段 WN63 1 人员 2岗位
|
//flow节点表
|
nodeFs.setTableName("product_sys_flow_node");
|
//创建人
|
nodeFs.setValue("created_by", 1);
|
//创建时间
|
nodeFs.setValue("created_utc_datetime", new Date());
|
//标题
|
nodeFs.setValue("title", Orlfs.getString("wn02"));
|
//描述
|
nodeFs.setValue("flow_node_describe", Orlfs.getString("wn03"));
|
//组件类型:1-开始节点,2-处理节点,0-结束节点
|
//1开始 99结束; 3普通 4子任务 5处理器 6或处理7与处理8 会签
|
String module_type = "2";
|
if ("1".equals(Orlfs.getString("wn04"))) {
|
module_type = "1";
|
} else if ("99".equals(Orlfs.getString("wn04"))) {
|
module_type = "0";
|
}
|
nodeFs.setValue("module_type", module_type);
|
//是否多人处理
|
String wn26 = Orlfs.getString("wn26");
|
nodeFs.setValue("is_multiperson", wn26);
|
if ("1".equals(wn26)) {
|
//处理类型
|
String wn25 = Orlfs.getString("wn25");
|
// 类型:0-等待处理,1-竞争处理,2-顺序处理 先A 后b 。。。下一个节点
|
// WN25 0 无 1多人办理等待 2 竞争处理
|
if (!BaseUtil.strIsNull(wn25)) {
|
if ("2".equals(wn25)) {
|
nodeFs.setValue("deal_type", 1);
|
} else {
|
nodeFs.setValue("deal_type", 0);
|
}
|
}
|
} else if ("0".equals(wn26)) {
|
nodeFs.setValue("deal_type", 0);
|
}
|
|
//默认送直属领导
|
nodeFs.setValue("is_default_direct_supervisor", Orlfs.getString("wn34"));
|
//是否允许加签
|
nodeFs.setValue("is_allow_add", Orlfs.getString("wn15"));
|
//是否允许退回
|
nodeFs.setValue("is_allow_back", Orlfs.getString("wn13"));
|
|
//wn48 结束节点调用的方法
|
String wn48 = Orlfs.getString("wn48");
|
if (!BaseUtil.strIsNull(wn48)) {
|
//其他消息推送方法,调用java代码 暂存于此
|
nodeFs.setValue("msg_push_sp_func", wn48);
|
}
|
//节点权限关联表单字段同步
|
//WN62 关联表单字段
|
String wn62 = Orlfs.getString("wn62");
|
if (!BaseUtil.strIsNull(wn62)) {
|
//WN63 1 人员 2岗位
|
String wn63 = Orlfs.getString("wn63");
|
if (BaseUtil.strIsNull(wn63)) {
|
if ("1".equals(wn63)) {
|
//人员
|
nodeFs.setValue("default_form_field_user", wn62.toLowerCase());
|
} else {
|
//岗位
|
nodeFs.setValue("default_form_field_post", wn62.toLowerCase());
|
}
|
}
|
}
|
//获取人员岗位单位部门 存入流程节点的人员 岗位 单位部门权限设置
|
Map<String, String> map1 = this.syncNodeInstitutions(conn, Orlfs);
|
if (map1 != null && map1.size() > 0) {
|
String userSet = map1.get("userSet");
|
//人员id
|
if (!BaseUtil.strIsNull(userSet)) {
|
nodeFs.setValue("default_users", userSet);
|
}
|
String postSet = map1.get("postSet");
|
//岗位uuid
|
if (!BaseUtil.strIsNull(postSet)) {
|
nodeFs.setValue("default_posts", postSet);
|
}
|
String deptSet = map1.get("deptList");
|
//单位部门uuid
|
if (!BaseUtil.strIsNull(deptSet)) {
|
nodeFs.setValue("default_depts", deptSet);
|
}
|
}
|
//需要在数据源表里面插入一个部门 所有直接关联单位都改为这个部门
|
//坐标,节点到上边界的垂直距离
|
nodeFs.setValue("location_top", Orlfs.getInteger("wn38") + "px");
|
//坐标,节点到左边界的水平距离
|
nodeFs.setValue("location_left", Orlfs.getInteger("wn37") + "px");
|
//关联"product_sys_flow_model
|
nodeFs.setValue("flow_uuid", modelUUID);
|
//关联附件
|
nodeFs.setValue("node_attachment_upload", 1);
|
//下载附件
|
nodeFs.setValue("node_attachment_download", 0);
|
//预览附件
|
nodeFs.setValue("node_attachment_preview", 1);
|
//允许打印
|
nodeFs.setValue("allow_print", 1);
|
//是否允许套红
|
nodeFs.setValue("allow_nest_red", 1);
|
//如果有附件字段 添加下载预览权限
|
if (!BaseUtil.strIsNull(this.attachmentValue)) {
|
//允许删除
|
nodeFs.setValue("allow_delete", 0);
|
//允许下载
|
nodeFs.setValue("allow_download", 1);
|
//允许预览
|
nodeFs.setValue("allow_preview", 1);
|
//附件字段
|
String field = this.attachmentValue.substring(1, this.attachmentValue.length() - 1);
|
nodeFs.setValue("editable_field", field.toLowerCase());
|
}
|
String uuid = baseDao.add(nodeFs);
|
//节点唯一号
|
map.put(Orlfs.getString("wn53"), uuid);
|
//顺序号
|
nodesIdUUID.put(Orlfs.getString("wn00"), uuid);
|
}
|
} catch (BaseException e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
}
|
return map;
|
}
|
|
/**
|
* 同步节点配置的组织架构
|
*
|
* @param fieldSetEntity
|
*/
|
public Map<String, String> syncNodeInstitutions(Connection conn, FieldSetEntity fieldSetEntity) {
|
String wn00 = fieldSetEntity.getString("wn00");
|
DataTableEntity OrlDt = null;
|
try {
|
OrlDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.WF_ROLES", " WR01 = ? ", new Object[]{wn00});
|
} catch (Exception e) {
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
}
|
if (BaseUtil.dataTableIsEmpty(OrlDt)) {
|
return null;
|
}
|
//用户
|
Set<String> userSet = Sets.newHashSet();
|
//部门
|
Set<String> deptSet = Sets.newHashSet();
|
//岗位
|
Set<String> postSet = Sets.newHashSet();
|
for (int i = 0; i < OrlDt.getRows(); i++) {
|
FieldSetEntity fse = OrlDt.getFieldSetEntity(i);
|
String wr04 = fse.getString("wr04");
|
String wr03 = fse.getString("wr03");
|
//用户
|
if ("X".equals(wr04)) {
|
userSet.add(wr03);
|
//角色 岗位
|
} else if ("Y".equals(wr04)) {
|
postSet.add(wr03);
|
//机构
|
} else if ("Z".equals(wr04)) {
|
deptSet.add(wr03);
|
}
|
}
|
Map<String, String> map = Maps.newHashMap();
|
//查询人员
|
if (userSet.size() > 0) {
|
DataTableEntity staffData = baseDao.listTable("product_sys_staffs", BaseUtil.buildQuestionMarkFilter("remark", userSet.toArray(), true));
|
if (!BaseUtil.dataTableIsEmpty(staffData)) {
|
userSet.clear();
|
for (int i = 0; i < staffData.getRows(); i++) {
|
userSet.add(staffData.getString(i, "user_id"));
|
}
|
map.put("userSet", StringUtils.join(userSet, ","));
|
}
|
}
|
//查询岗位
|
if (postSet.size() > 0) {
|
DataTableEntity postData = baseDao.listTable("product_sys_job_posts", BaseUtil.buildQuestionMarkFilter("sequence", postSet.toArray(), true));
|
if (!BaseUtil.dataTableIsEmpty(postData)) {
|
//如果岗位uuid总计超过2000就取出岗位下的人
|
if ((postData.getRows() * 37) > 2000) {
|
DataTableEntity staffData = baseDao.listTable(" SELECT a.user_id FROM product_sys_staffs a LEFT JOIN product_sys_job_posts b on a.job_post_uuid = b.uuid where " + BaseUtil.buildQuestionMarkFilter("b.sequence", postSet.toArray(), true), new String[]{});
|
postSet.clear();
|
if (!BaseUtil.dataTableIsEmpty(staffData)) {
|
for (int i = 0; i < staffData.getRows(); i++) {
|
userSet.add(staffData.getString(i, "user_id"));
|
}
|
map.put("userSet", StringUtils.join(userSet, ","));
|
}
|
} else {
|
postSet.clear();
|
for (int i = 0; i < postData.getRows(); i++) {
|
postSet.add(postData.getString(i, "uuid"));
|
}
|
map.put("postSet", StringUtils.join(postSet, ","));
|
}
|
}
|
}
|
//查询机构(单位部门)
|
if (deptSet.size() > 0) {
|
DataTableEntity orgData = baseDao.listTable("product_sys_org_levels", BaseUtil.buildQuestionMarkFilter("sequence", deptSet.toArray(), true));
|
if (!BaseUtil.dataTableIsEmpty(orgData)) {
|
deptSet.clear();
|
for (int i = 0; i < orgData.getRows(); i++) {
|
deptSet.add(orgData.getString(i, "uuid"));
|
}
|
map.put("deptSet", StringUtils.join(deptSet, ","));
|
}
|
}
|
return map;
|
}
|
|
/**
|
* @param conn
|
* @param UUIDMap 流程节点node表fe uuid 对应 产品uuid
|
* @param tableName 表名
|
* @return
|
* @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;
|
|
try {
|
StringBuffer sql = new StringBuffer();
|
sql.append(" SELECT * FROM fe_base5.wf_infor where WI01 in (SELECT WT00 FROM fe_base5.wf_task where WT13= " +
|
"(SELECT se16 FROM fe_base5.SYS_EVENT WHERE SE08 = 1 AND SE01 = ?)) ORDER BY WI01,WI00 ");
|
OrlDt = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new String[]{tricode_funs});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
Map<String, String> stateMap = Maps.newHashMap();
|
DataTableEntity DetailData = new DataTableEntity();
|
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();
|
//flow明细表
|
DetailFs.setTableName("product_sys_flow_detail");
|
|
if (null == Orlfs.getString("wi02")) {
|
//标题
|
DetailFs.setValue("title", "无标题");
|
} else {
|
DetailFs.setValue("title", Orlfs.getString("wi02"));
|
}
|
String wi00 = Orlfs.getString("wi00");
|
//id一致
|
DetailFs.setValue("id", wi00);
|
//节点名称
|
DetailFs.setValue("node_title", Orlfs.getString("wi04"));
|
//预期处理人
|
DetailFs.setValue("expect_person", userIdJson.getString(Orlfs.getString("wi05")));
|
//接收时间
|
Date wi08 = Orlfs.getDate("wi08");
|
DetailFs.setValue("accept_time", wi08);
|
//创建时间
|
DetailFs.setValue("created_utc_datetime", wi08);
|
String wi12 = userIdJson.getString(Orlfs.getString("wi12"));
|
//实际处理人
|
DetailFs.setValue("actual_person", wi12);
|
//修改人为实际处理人
|
DetailFs.setValue("updated_by", wi12);
|
//处理时间
|
Date wi11 = Orlfs.getDate("wi11");
|
DetailFs.setValue("deal_time", wi11);
|
DetailFs.setValue("updated_utc_datetime", wi11);
|
//节点标识(0-普通,1-加签,2-退回)
|
DetailFs.setValue("node_sign", 0);
|
String node_uuid = UUIDMap.getString(Orlfs.getString("wi62"));
|
if (BaseUtil.strIsNull(node_uuid)) {
|
continue;
|
}
|
//源uuid,关联本表
|
String wi14 = Orlfs.getString("wi14");
|
//为空表示没有上一级节点
|
if (BaseUtil.strIsNull(wi14)) {
|
if (i > 0) {
|
FieldSetEntity priorFes = OrlDt.getFieldSetEntity(i - 1);
|
String priorWi00 = priorFes.getString("wi00");
|
FieldSetEntity priorFieldSet = OrgIdUUIDmap.get(priorWi00);
|
if (priorFieldSet != null) {
|
FieldSetEntity taskFse = taskFseMap.get(priorFes.getString("wi01"));
|
if (taskFse != null) {
|
taskFse.setValue("cur_node_uuid", node_uuid);
|
//添加当前节点记录
|
baseDao.update(taskFse);
|
}
|
}
|
}
|
} else {
|
FieldSetEntity fieldSetEntity = OrgIdUUIDmap.get(wi14);
|
if (fieldSetEntity != null) {
|
DetailFs.setValue("source_uuid", fieldSetEntity.getUUID());
|
}
|
}
|
//创建人 上个节点处理人
|
DetailFs.setValue("created_by", userIdJson.getString(Orlfs.getString("wi15")));
|
|
//关联节点表
|
DetailFs.setValue("node_uuid", node_uuid);
|
//预期处理时间(小时)
|
DetailFs.setValue("expect_deal_time", Orlfs.getString("wi09"));
|
//完成标识(0-未收,1-已收未办,2-已办,3-终止,4-竞争失败)
|
// DetailFs.setValue("node_deal_sign", nodeDealType(Orlfs.getString("wi07")));
|
//办理状态(0-未收,1-已收未办,2-已办,3-终止,4-竞争失败)
|
String nodeState = nodeDealType(Orlfs.getString("wi13"));
|
DetailFs.setValue("node_deal_sign", nodeState);
|
//意见
|
String wi20 = Orlfs.getString("wi20");
|
if ("2".equals(nodeState)) {
|
if (BaseUtil.strIsNull(wi20)) {
|
DetailFs.setValue("opinion", "已阅");
|
} else {
|
DetailFs.setValue("opinion", wi20);
|
}
|
//添加签名
|
String sign = userIdSignature.getString(wi12);
|
DetailFs.setValue("sign_attachment_uuid", sign);
|
}
|
//关联表
|
DetailFs.setValue("table_name", this.originalTable.getString(tableName));
|
//关联业务UUID
|
DetailFs.setValue("record_uuid", this.pxMap.getString(tableName + Orlfs.getString("wi29")));
|
//关联流程表uuid
|
DetailFs.setValue("flow_uuid", modelUUID);
|
FieldSetEntity taskFse = taskFseMap.get(Orlfs.getString("wi01"));
|
if (taskFse == null) {
|
continue;
|
}
|
String attachmentsValue = Orlfs.getString("attachment");
|
//如果附件字段有值 同步附件
|
if (!BaseUtil.strIsNull(attachmentsValue)) {
|
List<String> fileUuids = this.synchronizeCommonAccessories(conn, "flow_attachment", DetailFs.getTableName(), attachmentsValue);
|
//存入附件uuid
|
DetailFs.setValue("flow_attachment", StringUtils.join(fileUuids, ","));
|
}
|
//关联流程任务表
|
DetailFs.setValue("task_uuid", taskFse.getUUID());
|
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;
|
}
|
|
|
/**
|
* 查询流程消息表
|
*
|
* @param conn
|
* @param tricode_funs
|
* @param 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 ( ")
|
.append("SELECT WI00 FROM fe_base5.wf_infor where WI01 in (SELECT WT00 FROM fe_base5.wf_task where WT13= ")
|
.append("(SELECT se16 FROM fe_base5.SYS_EVENT WHERE SE08 = 1 AND SE01 = ?))) ORDER BY ME14");
|
|
DataTableEntity OrlDt = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new String[]{tricode_funs});
|
if (!BaseUtil.dataTableIsEmpty(OrlDt)) {
|
this.synchronizingProcessMessages(OrlDt, stateMap, "product_sys_flow_detail");
|
}
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
|
}
|
|
/**
|
* 同步流程消息表
|
*/
|
public void synchronizingProcessMessages(DataTableEntity OrlDt, Map<String, String> stateMap, String tableName) throws Exception {
|
String id = null;
|
String message_uuid = null;
|
String state = null;
|
DataTableEntity dataTableEntity = new DataTableEntity();
|
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
|
String me14 = fs.getString("me14");
|
String sendUserId;
|
//业务uuid
|
FieldSetEntity fieldSet = OrgIdUUIDmap.get(fs.getString("me14"));
|
String source_uuid = null;
|
if (fieldSet != null) {
|
source_uuid = fieldSet.getUUID();
|
} else {
|
continue;
|
}
|
//相同说明是同一消息 发送多个人
|
if (!me14.equals(id)) {
|
//不一样创建消息主表
|
id = me14;
|
FieldSetEntity message = new FieldSetEntity();
|
//消息主表
|
message.setTableName("product_sys_message");
|
//消息主题
|
message.setValue("title", fs.getString("me01"));
|
//消息内容
|
message.setValue("content", fs.getString("me02"));
|
//是否需要发送邮件
|
message.setValue("is_send_mail", 0);
|
//消息类型21 流程消息都为任务消息
|
message.setValue("message_type", 21);
|
//是否需要发送短信 0不发;1为强制;2为被动
|
message.setValue("is_send_sms", "0".equals(fs.getString("me20")) ? 0 : 1);
|
//发送时间
|
String me07 = fs.getString("me07");
|
message.setValue("send_time", me07);
|
//创建时间
|
message.setValue("created_utc_datetime", me07);
|
//发送人
|
sendUserId = userIdJson.getString(fs.getString("me03"));
|
if (BaseUtil.strIsNull(sendUserId)) {
|
//流程infor 数据创建人为发送人
|
sendUserId = fieldSet.getString("created_by");
|
if (BaseUtil.strIsNull(sendUserId)) {
|
continue;
|
}
|
}
|
message.setValue("send_user_id", sendUserId);
|
//创建人及发送人
|
message.setValue("created_by", sendUserId);
|
// 业务表
|
message.setValue("source_table", tableName);
|
|
message.setValue("source_uuid", source_uuid);
|
//url 业务地址
|
//获取当前节点状态
|
state = stateMap.get(fs.getString("me14"));
|
//办理页面
|
if ("0".equals(state) || "1".equals(state)) {
|
message.setValue("url", "162132180172861usZ0N439?uuid=" + source_uuid);
|
//查询原文页面
|
} else if ("2".equals(state)) {
|
message.setValue("url", "1621321824686868oKWL726?uuid=" + source_uuid);
|
}
|
message_uuid = UUID.randomUUID().toString();
|
message.setValue("uuid", message_uuid);
|
dt1.addFieldSetEntity(message);
|
}
|
|
FieldSetEntity message_user = new FieldSetEntity();
|
message_user.setTableName("product_sys_message_user");
|
//关联lx_sys_message表UUID
|
message_user.setValue("message_uuid", message_uuid);
|
//mail_send 是否发送邮件
|
message_user.setValue("mail_send", 0);
|
// 是否阅读 节点状态为未读
|
//0未读
|
if ("0".equals(state)) {
|
message_user.setValue("read_type", 0);
|
} else {
|
message_user.setValue("read_type", 1);
|
}
|
//read_time 阅读时间 暂时为空
|
|
//receive_time 接收时间 无字段
|
//sms_send 是否发送短信
|
message_user.setValue("sms_send", 0);
|
//user_id 消息接收人
|
String user_id = userIdJson.getString(fs.getString("me05"));
|
//找不到发送人就放接收人
|
if (BaseUtil.strIsNull(user_id)) {
|
user_id = userIdJson.getString(fs.getString("me03"));
|
if (BaseUtil.strIsNull(user_id)) {
|
continue;
|
}
|
}
|
message_user.setValue("user_id", user_id);
|
dataTableEntity.addFieldSetEntity(message_user);
|
// 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();
|
}
|
}
|
batchAddData.add(dt1);
|
if (!BaseUtil.dataTableIsEmpty(dataTableEntity)) {
|
batchAddData.add(dataTableEntity);
|
}
|
}
|
|
|
//迁移WF_LINKS 连线表
|
public void syncLinks(String wm00, Connection conn, String modelUUID) throws SQLException {
|
DataTableEntity OrlDt = null;
|
try {
|
StringBuilder sql = new StringBuilder();
|
sql.append("select a.WL04 WL04,a.WL05 WL05,a.WL06 WL06,(SELECT WN04 FROM fe_base5.WF_NODES where WN00=a.WL05) source_type,");
|
sql.append("(select wa01 from fe_base5.WF_ACTION where wa00=a.WL03) WL03S,(SELECT WN04 FROM fe_base5.WF_NODES where WN00=(select wa01 from fe_base5.WF_ACTION where wa00=a.WL03)) ");
|
sql.append(" target_type from fe_base5.wf_links a where WL05 in (select wn00 from fe_base5.wf_nodes where WN01= ? )");
|
|
OrlDt = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{wm00
|
});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw e;
|
}
|
for (int i = 0; i < OrlDt.getRows(); i++) {
|
FieldSetEntity Orlfs = OrlDt.getFieldSetEntity(i);
|
FieldSetEntity linksFs = new FieldSetEntity();
|
linksFs.setTableName("product_sys_flow_link");
|
linksFs.setValue("created_by", 1);
|
linksFs.setValue("created_utc_datetime", new Date());
|
//标题
|
linksFs.setValue("title", Orlfs.getString("wl04"));
|
//连线起始位置uuid"product_sys_flow_node uuid 若为空则跳过
|
if (Orlfs.getString("wl03s") == null) {
|
continue;
|
}
|
linksFs.setValue("source_uuid", nodesIdUUID.getString(Orlfs.getString("wl03s")));
|
//连线起点类型:1-节点,2-处理器
|
linksFs.setValue("source_type", "5".equals(Orlfs.getString("target_type")) ? 2 : 1);
|
//连线截止位置uuid"product_sys_flow_node uuid
|
linksFs.setValue("target_uuid", nodesIdUUID.getString(Orlfs.getString("wl05")));
|
//连线截止类型:1-节点,2-处理器
|
linksFs.setValue("target_type", "5".equals(Orlfs.getString("source_type")) ? 2 : 1);
|
//线的判定条件
|
linksFs.setValue("judge", Orlfs.getString("wl06"));
|
//关联"product_sys_flow_model
|
linksFs.setValue("flow_uuid", modelUUID);
|
baseDao.add(linksFs);
|
}
|
}
|
|
/**
|
* 通过数据源表序列号 获取当前员工user_id
|
*/
|
// public Integer getUserId(Integer id){
|
// FieldSetEntity userFse = baseDao.getFieldSetEntityByFilter("product_sys_staffs", " remark = ? ",new Integer[]{id},false);
|
// if(userFse == null){
|
// return null;
|
// }
|
// return userFse.getInteger("user_id");
|
// }
|
|
/**
|
* 同步task 表
|
*
|
* @param conn
|
* @param modelUUID 流程模块uuid
|
* @return
|
* @throws SQLException
|
*/
|
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
|
});
|
} catch (Exception e) {
|
DataManipulationUtils.close(null, null, conn);
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
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();
|
taskFs.setTableName("product_sys_flow_task");
|
if (null == Orlfs.getString("wt05")) {
|
//标题
|
taskFs.setValue("title", "无标题");
|
} else {
|
taskFs.setValue("title", Orlfs.getString("wt05"));
|
}
|
// 发起人
|
//wt07用户id 获取用户id
|
String id = userIdJson.getString(Orlfs.getString("wt07"));
|
//发送人为空 就跳过
|
if (id == null) {
|
continue;
|
}
|
taskFs.setValue("sender", id);
|
//发起时间
|
Date wt09 = Orlfs.getDate("wt09");
|
taskFs.setValue("send_time", wt09);
|
//结束时间
|
taskFs.setValue("finish_time", Orlfs.getDate("wt10"));
|
//关联流程表
|
taskFs.setValue("flow_uuid", modelUUID);
|
//完成标识(1-在办,2-正常结束,3-终止)
|
taskFs.setValue("finish_type", this.finishType(Orlfs.getString("wt16")));
|
//关联表
|
String tbName = Orlfs.getString("wt03").split("\\.")[1];
|
|
taskFs.setValue("table_name", this.originalTable.getString(tbName));
|
//当前环节节点uuid
|
taskFs.setValue("id", Orlfs.getString("wt00"));
|
//关联业务UUID
|
String record_uuid = pxMap.getString(tbName + Orlfs.getString("wt04"));
|
if (BaseUtil.strIsNull(record_uuid)) {
|
continue;
|
}
|
taskFs.setValue("record_uuid", record_uuid);
|
taskFs.setValue("created_by", id);
|
taskFs.setValue("created_utc_datetime", wt09);
|
taskFs.setValue("uuid", UUID.randomUUID().toString());
|
// baseDao.add(taskFs);
|
dt.addFieldSetEntity(taskFs);
|
map.put(Orlfs.getString("wt00"), taskFs);
|
}
|
|
batchAddData.add(dt);
|
|
|
return map;
|
}
|
|
/**
|
* 创建表语句
|
*
|
* @param sb
|
* @param table_name
|
* @param table_description
|
* @return
|
* @throws BaseException
|
*/
|
private StringBuilder createTable(StringBuilder sb, String table_name, String table_description) throws BaseException {
|
StringBuilder createStatement = new StringBuilder();
|
createStatement.append(" create table `" + table_name + "` ( ");
|
createStatement.append("\n");
|
createStatement.append(sb);
|
createStatement.append("\n");
|
createStatement.append(" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='" + table_description + "'");
|
return createStatement;
|
}
|
|
/**
|
* 组装字段信息
|
*
|
* @param dt
|
* @throws BaseException
|
*/
|
private StringBuilder createFields(DataTableEntity dt) throws BaseException {
|
StringBuilder table = new StringBuilder();
|
if (!BaseUtil.dataTableIsEmpty(dt)) {
|
for (int i = 0; i < dt.getRows(); i++) {
|
FieldSetEntity fse = dt.getFieldSetEntity(i);
|
//字段类型
|
String field_type = fse.getString(CmnConst.FIELD_TYPE);
|
//字段名
|
String field_name = fse.getString(CmnConst.FIELD_NAME);
|
//字段描述
|
String field_description = fse.getString(CmnConst.FIELD_DESCRIPTION);
|
//字段长度
|
Integer field_length = fse.getInteger(CmnConst.FIELD_LENGTH);
|
//小数位数
|
Integer field_unit = fse.getInteger(CmnConst.FIELD_UNIT);
|
//是否必填
|
Boolean is_required = fse.getBoolean(CmnConst.IS_REQUIRED);
|
//是否唯一
|
Boolean is_unique = fse.getBoolean(CmnConst.IS_UNIQUE);
|
|
//是否为主键
|
Boolean is_primary_key = "pk".equals(field_type) ? true : false;
|
String field = newField(field_name, field_description, field_type, is_required, field_length, field_unit, is_primary_key, is_unique);
|
if (table.length() > 0) {
|
table.append(",\n\t");
|
}
|
table.append(field);
|
}
|
}
|
return table;
|
}
|
|
/**
|
* 新字段组装
|
*
|
* @param field_name 字段名称
|
* @param field_description 字段描述
|
* @param field_type 字段类型
|
* @param is_required 是否必填
|
* @param field_length 字段长度
|
* @param field_unit 小数长度
|
* @param is_primary_key 是否自增主键
|
* @param is_unique 是否唯一
|
* @return
|
*/
|
private String newField(String field_name, String field_description, String field_type, boolean is_required, Integer field_length, Integer field_unit, boolean is_primary_key, boolean is_unique) {
|
StringBuilder sql = new StringBuilder();
|
sql.append(" `" + field_name + "` ");
|
sql.append(" " + fieldType(field_type));
|
sql.append(" (" + field_length);
|
if ("decimal".equals(field_type) && field_unit != null && field_unit > 0) {
|
sql.append("," + field_unit);
|
}
|
sql.append(") " + (!is_required && !is_primary_key ? " DEFAULT NULL " : " NOT NULL "));
|
if (is_primary_key) {
|
sql.append(" AUTO_INCREMENT ");
|
}
|
sql.append(" COMMENT '" + (field_description == null ? "" : field_description)).append("'");
|
if (is_primary_key) {
|
sql.append(" ,\t\n PRIMARY KEY (`" + field_name + "`) USING BTREE ");
|
} else if (CmnConst.UUID.equals(field_name) || is_unique) {
|
sql.append(" ,\t\nUNIQUE KEY `" + field_name + "` (`" + field_name + "`) USING BTREE");
|
}
|
return sql.toString();
|
}
|
|
/**
|
* 流程节点类型 1、开始 2、处理节点 0、结束
|
*
|
* @param field_type
|
* @return
|
*/
|
private String nodeType(String field_type) {
|
String type = "";
|
switch (field_type) {
|
case "1":
|
type = "1";
|
break;
|
case "99":
|
type = "0";
|
break;
|
case "5":
|
type = "2";
|
break;
|
case "3":
|
type = "3";
|
case "4":
|
type = "3";
|
break;
|
case "6":
|
type = "3";
|
break;
|
case "7":
|
type = "3";
|
break;
|
case "8":
|
type = "3";
|
break;
|
default:
|
throw new BaseException(SystemCode.FIELD_TYPE_FIAL.getValue(), SystemCode.FIELD_TYPE_FIAL.getText() + "_" + field_type);
|
}
|
return type;
|
}
|
|
/**
|
* 流程完成状态
|
*
|
* @param field_type
|
* @return
|
*/
|
private String finishType(String field_type) {
|
String finishType = "";
|
switch (field_type) {
|
case "0":
|
finishType = "1";
|
break;
|
case "1":
|
finishType = "2";
|
break;
|
case "2":
|
finishType = "3";
|
break;
|
case "3":
|
finishType = "3";
|
break;
|
|
default:
|
throw new BaseException(SystemCode.FIELD_TYPE_FIAL.getValue(), SystemCode.FIELD_TYPE_FIAL.getText() + "_" + field_type);
|
}
|
return finishType;
|
}
|
|
/**
|
* 办理状态
|
*
|
* @param field_type
|
* @return
|
*/
|
private String nodeDealType(String field_type) {
|
//源数据 0:已办;1:已收在办;2:未收未办;3 终止;4 冻结
|
//本数据 完成标识(0-未收,1-已收未办,2-已办,3-终止,4-竞争失败)
|
String finishType = "";
|
switch (field_type) {
|
case "0":
|
finishType = "2";
|
break;
|
case "1":
|
finishType = "1";
|
break;
|
case "2":
|
finishType = "0";
|
break;
|
case "3":
|
finishType = "3";
|
break;
|
case "4":
|
finishType = "3";
|
break;
|
default:
|
throw new BaseException(SystemCode.FIELD_TYPE_FIAL.getValue(), SystemCode.FIELD_TYPE_FIAL.getText() + "_" + field_type);
|
}
|
return finishType;
|
}
|
|
/**
|
* 字段类型对照
|
*
|
* @param field_type
|
* @return
|
*/
|
private String fieldType(String field_type) {
|
String mysql_field_type = "";
|
switch (field_type) {
|
case "string":
|
mysql_field_type = "varchar";
|
break;
|
case "code":
|
mysql_field_type = "varchar";
|
break;
|
case "flowsign":
|
mysql_field_type = "int";
|
break;
|
case "datetime":
|
mysql_field_type = "datetime";
|
break;
|
case "file":
|
mysql_field_type = "varchar";
|
break;
|
case "int":
|
mysql_field_type = "int";
|
break;
|
case "pk":
|
mysql_field_type = "bigint";
|
break;
|
case "parentuuid":
|
mysql_field_type = "varchar";
|
break;
|
case "uuid":
|
mysql_field_type = "varchar";
|
break;
|
case "userid":
|
mysql_field_type = "bigint";
|
break;
|
case "orgUuid":
|
mysql_field_type = "varchar";
|
break;
|
case "number":
|
mysql_field_type = "decimal";
|
break;
|
case "serialNumber":
|
mysql_field_type = "varchar";
|
break;
|
case "email":
|
mysql_field_type = "varchar";
|
break;
|
case "idcard":
|
mysql_field_type = "int";
|
break;
|
case "url":
|
mysql_field_type = "varchar";
|
break;
|
case "mac":
|
mysql_field_type = "varchar";
|
break;
|
case "table_name":
|
mysql_field_type = "varchar";
|
break;
|
case "field_name":
|
mysql_field_type = "varchar";
|
break;
|
case "text":
|
mysql_field_type = "text";
|
break;
|
default:
|
throw new BaseException(SystemCode.FIELD_TYPE_FIAL.getValue(), SystemCode.FIELD_TYPE_FIAL.getText() + "_" + field_type);
|
}
|
return mysql_field_type;
|
}
|
|
/**
|
* 字段类型对照
|
*
|
* @param field_type
|
* @return
|
*/
|
private String fieldTypeFE(String field_type) {
|
String mysql_field_type = "";
|
switch (field_type) {
|
//主键不设唯一不舍必填
|
case "AUTO":
|
mysql_field_type = "pk";
|
break;
|
case "NUMERIC":
|
mysql_field_type = "number";
|
break;
|
case "DATETIME":
|
mysql_field_type = "datetime";
|
break;
|
case "STRING":
|
mysql_field_type = "string";
|
break;
|
case "NATIVE":
|
mysql_field_type = "string";
|
break;
|
case "CDATETIME":
|
mysql_field_type = "datetime";
|
break;
|
case "PROMPT":
|
mysql_field_type = "string";
|
break;
|
case "SORT":
|
mysql_field_type = "string";
|
break;
|
case "MEDIA":
|
mysql_field_type = "file";
|
break;
|
case "SPFLAG":
|
mysql_field_type = "flowsign";
|
break;
|
case "IMAGE":
|
mysql_field_type = "file";
|
break;
|
case "TEXT":
|
mysql_field_type = "text";
|
break;
|
case "UNITCODE":
|
mysql_field_type = "string";
|
break;
|
case "FLOWCODE":
|
mysql_field_type = "string";
|
break;
|
case "GUID":
|
mysql_field_type = "string";
|
break;
|
default:
|
throw new BaseException(SystemCode.FIELD_TYPE_FIAL.getValue(), SystemCode.FIELD_TYPE_FIAL.getText() + "_" + field_type);
|
}
|
return mysql_field_type;
|
}
|
|
private synchronized void execute(String sql) throws BaseException {
|
try {
|
Connection connection = ConnectionManager.getInstance().getConnection();
|
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
preparedStatement.execute();
|
} catch (Exception e) {
|
e.getStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
throw new BaseException(SystemCode.SQL_START_FAILED.getValue(), SystemCode.SQL_START_FAILED.getText() + e.getMessage());
|
}
|
}
|
|
private String getMoudleByFunctionTricode(String tricode) {
|
if (!BaseUtil.strIsNull(tricode)) {
|
return baseDao.getFieldSetByFilter(CmnConst.PRODUCT_SYS_FUNCTIONS, "tricode=?", new Object[]{tricode.substring(0, tricode.lastIndexOf("-"))}, false).getUUID();
|
}
|
return null;
|
}
|
|
/**
|
* 线程操作(同步功能信息)
|
*/
|
@Override
|
public void run() {
|
//封装两边人员关联和部门关联
|
this.packageDepartmentPersonnel();
|
nodesIdUUID = new JSONObject();
|
//同步表及基础数据
|
String sf28 = null;
|
|
//创建jdbc连接
|
Connection conn = null;
|
try {
|
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;
|
//若已有表同步 mvc标识 表示从功能开始同步
|
if (tricode_funs.indexOf("mvc") != -1) { //mvc 要带上同表的多个功能
|
//只同步mvc
|
String[] funs = this.tricode_funs.split("mvc");
|
try {
|
sf28 = this.synchronizeTablesData(conn, funs[0]);
|
String tableName = sf28.split("\\.")[1];
|
this.originalTable.put(tableName, tableName.toLowerCase());
|
for (int i = 0; i < funs.length; i++) {
|
//当前功能
|
this.tricode_funs = funs[i];
|
//同步功能
|
// moduleUUID = this.synchronizationModuleName(conn, funs[i], sf28);
|
//查询模块uuid
|
|
//表名查询功能
|
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));
|
//修改已同步附件 添加 module_uuid function_uuid
|
//同步流程
|
this.syncFlow(conn, moduleUUID, sf28);
|
}
|
|
} 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)) {
|
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);
|
//修改已同步附件 添加 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});
|
}
|
try {
|
DataManipulationUtils.close(null, null, conn);
|
} catch (SQLException e) {
|
logger.error("run", e);
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
}
|
}
|
|
/**
|
* 同步流程
|
*
|
* @param conn jdbc连接
|
* @param moduleUUID 模块uuid
|
* @param sf28 表名
|
*/
|
public void syncFlow(Connection conn, String moduleUUID, String sf28) {
|
|
//查询主公司uuid
|
FieldSetEntity fieldSetEntity = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_SYS_ORG_LEVELS, " org_level_code = ? ", new String[]{"001"}, false);
|
FieldSetEntity user = baseDao.getFieldSetByFilter("product_sys_org_manager", " manager_type = ? ", new String[]{"2"}, false);
|
try {
|
//迁移 wf_model流程模块表
|
String typeCode = this.syncModel(tricode_funs, conn, moduleUUID, sf28, null, 1, null, false);
|
//根据要求流程要同步两次 相同流程的typeCode相同
|
if (!BaseUtil.strIsNull(typeCode)) {
|
this.syncModel(tricode_funs, conn, moduleUUID, sf28, fieldSetEntity.getUUID(), user.getInteger("user_id"), typeCode, true);
|
}
|
} catch (SQLException e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
logger.error("syncFlow", e);
|
}
|
//初始化菜单缓存
|
// systemMenusService.initSystemMenu();
|
System.out.println("=================" + tricode_funs + "同步成功===============");
|
}
|
|
}
|