From fd0c7c174d7b7313aa49061df05350405a3c1bf1 Mon Sep 17 00:00:00 2001
From: 354798ggg <1074825718@qq.com>
Date: 星期二, 29 八月 2023 15:56:11 +0800
Subject: [PATCH] Merge branch 'master' of http://nonxin.cn:8090/r/project/xnfg
---
product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IConnectionConfigurationService.java | 60
product-server-data-sync/src/main/java/com/product/data/sync/controller/ConnectionConfigurationController.java | 360 +
product-server-data-sync/src/main/java/com/product/data/sync/util/DataSaveSynchronization.java | 169
product-server-data-sync/src/main/java/com/product/data/sync/service/media/Encryption.java | 386 +
product-server-data-sync/src/main/java/com/product/data/sync/entity/SyncResultEntity.java | 72
product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyFeDataService.java | 10
product-server-data-sync/src/main/java/com/product/data/sync/util/ResultInfo.java | 31
product-server-web/src/main/java/com/product/Application.java | 1
product-server-data-sync/src/main/java/com/product/data/sync/service/media/GdMediaUtil.java | 453 +
product-server-data-sync/src/main/java/com/product/data/sync/util/ThreadSelectManager.java | 162
product-server-data-sync/src/main/java/com/product/data/sync/controller/FunctionSynchrController.java | 222
product-server-data-sync/src/main/java/com/product/data/sync/service/SyncConfigService.java | 163
product-server-data-sync/src/main/java/com/product/data/sync/util/DataAddSynchronization.java | 140
product-server-data-sync/src/main/java/com/product/data/sync/service/media/SysSetup.java | 87
product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyncConfigService.java | 33
product-server-web/src/main/resources/static/avatar/organization.png | 0
product-server-data-sync/src/test/java/com/product/data/sync/test/ConnectionConfigurationTest.java | 35
product-server-data-sync/src/main/java/com/product/data/sync/controller/SyncConfigController.java | 316 +
product-server-data-sync/src/main/java/com/product/data/sync/service/AvatarAndSignatureService.java | 118
product-server-web/src/main/resources/templates/webOffice.html | 20
product-server-data-sync/src/main/java/com/product/data/sync/util/DataManipulationUtils.java | 231
product-server-data-sync/src/main/java/com/product/data/sync/service/media/EncrypUtil.java | 49
product-server-data-sync/src/main/java/com/product/data/sync/util/CustomResultSet.java | 97
product-server-web/pom.xml | 111
home-server-admin/src/main/java/com/home/xining/service/AdvanceNoticeService.java | 133
product-server-data-sync/pom.xml | 48
product-server-data-sync/src/main/java/com/product/data/sync/config/SystemCode.java | 72
home-server-admin/src/main/java/com/home/xining/service/SendDocumentService.java | 135
product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IFunctionSynchrService.java | 9
product-server-data-sync/src/main/java/com/product/data/sync/service/ConnectionConfigurationService.java | 457 +
product-server-data-sync/src/main/java/com/product/data/sync/service/FeDataDSService.java | 1017 +++
product-server-data-sync/src/main/java/com/product/data/sync/service/SyFeDataService.java | 3347 ++++++++++
product-server-data-sync/src/test/java/com/product/data/sync/test/SyncConfigTest.java | 95
product-server-data-sync/src/main/java/com/product/data/sync/util/ConnectionManager.java | 81
product-server-web/src/main/resources/application-dev.properties | 260
product-server-data-sync/src/main/java/com/product/data/sync/util/DataSaveDeleteSynchronization.java | 175
product-server-data-sync/src/main/java/com/product/data/sync/util/ExceptionLog.java | 142
product-server-data-sync/src/main/java/com/product/data/sync/service/ViewDataProcessService.java | 509 +
pom.xml | 103
product-server-data-sync/src/main/java/com/product/data/sync/util/ScheduledTaskExecution.java | 2114 ++++++
product-server-data-sync/src/test/java/com/product/data/sync/test/ConnectionConfigureTest.java | 39
product-server-data-sync/src/test/java/com/product/data/sync/test/SyFeDataTest.java | 29
product-server-data-sync/pom.xml_bak | 71
product-server-data-sync/src/main/java/com/product/data/sync/util/BusinessDataSync.java | 5241 ++++++++++++++++
product-server-web/src/main/resources/license.xml | 14
product-server-data-sync/src/main/java/com/product/data/sync/controller/SyFeDataController.java | 76
product-server-data-sync/src/main/java/com/product/data/sync/util/BatchData.java | 741 ++
product-server-data-sync/src/test/java/com/product/data/sync/test/FunctionSyncTest.java | 53
product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IViewDataProcessService.java | 14
product-server-data-sync/src/main/java/com/product/data/sync/service/media/MD5Util.java | 45
product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyncDataService.java | 29
product-server-data-sync/src/main/java/com/product/data/sync/service/SyncDataService.java | 36
product-server-data-sync/src/main/java/com/product/data/sync/config/CmnConst.java | 106
product-server-data-sync/src/main/java/com/product/data/sync/service/FunctionSynchrService.java | 249
product-server-data-sync/src/main/java/com/product/data/sync/util/DataAddDeleteSynchronization.java | 169
55 files changed, 18,612 insertions(+), 323 deletions(-)
diff --git a/home-server-admin/src/main/java/com/home/xining/service/AdvanceNoticeService.java b/home-server-admin/src/main/java/com/home/xining/service/AdvanceNoticeService.java
index 2129ace..633dc9a 100644
--- a/home-server-admin/src/main/java/com/home/xining/service/AdvanceNoticeService.java
+++ b/home-server-admin/src/main/java/com/home/xining/service/AdvanceNoticeService.java
@@ -30,77 +30,78 @@
@Service
public class AdvanceNoticeService extends AbstractBaseService implements IAdvanceNoticeService {
- @Autowired
- public BaseDao baseDao;
- @Autowired
- PermissionService permissionService;
- @Autowired
- QueryFilterService queryFilterService;
+ @Autowired
+ public BaseDao baseDao;
+ @Autowired
+ PermissionService permissionService;
+ @Autowired
+ QueryFilterService queryFilterService;
- @Override
- public DataTableEntity listAdvanceNoticeg(FieldSetEntity fs) throws BaseException{
- String filter=fs.getString("filter");
- String dataFilter = permissionService.getDataFilter(fs.getTableName(),CmnConst.NO18);
+ @Override
+ public DataTableEntity listAdvanceNoticeg(FieldSetEntity fs) throws BaseException {
+ String filter = fs.getString("filter");
+ String dataFilter = permissionService.getDataFilter(fs.getTableName(), CmnConst.NO18);
- if(!StringUtils.isEmpty(dataFilter)){
- if(!StringUtils.isEmpty(filter)){
- filter += " and "+dataFilter;
- }else {
- filter = dataFilter;
- }
- }
- if(!BaseUtil.dataTableIsEmpty(fs.getSubDataTable("systemSeniorQueryString"))){
- filter = filter + " and " + queryFilterService.getQueryFilter(fs);
- }
+ if (!StringUtils.isEmpty(dataFilter)) {
+ if (!StringUtils.isEmpty(filter)) {
+ filter += " and " + dataFilter;
+ } else {
+ filter = dataFilter;
+ }
+ }
+ if (!BaseUtil.dataTableIsEmpty(fs.getSubDataTable("systemSeniorQueryString"))) {
+ filter = filter + " and " + queryFilterService.getQueryFilter(fs);
+ }
// fs.getInteger(CmnConst.PAGESIZE),fs.getInteger(CmnConst.CPAGE)
- DataTableEntity dt = baseDao.listTable(CmnConst.APP_NOTICE_PUNISHMENT,filter, null,null," no00 desc",fs.getInteger(CmnConst.PAGESIZE),fs.getInteger(CmnConst.CPAGE));
- baseDao.loadPromptData(dt);
- return dt;
- }
+ DataTableEntity dt = baseDao.listTable(CmnConst.APP_NOTICE_PUNISHMENT, filter, null, null, " no00 desc", fs.getInteger(CmnConst.PAGESIZE), fs.getInteger(CmnConst.CPAGE));
+ baseDao.loadPromptData(dt);
+ return dt;
+ }
- @Override
- public FieldSetEntity getAdvanceNotice(FieldSetEntity fs) {
- return baseDao.getFieldSet(CmnConst.APP_NOTICE_PUNISHMENT, fs.getUUID(), false);
- }
+ @Override
+ public FieldSetEntity getAdvanceNotice(FieldSetEntity fs) {
+ return baseDao.getFieldSet(CmnConst.APP_NOTICE_PUNISHMENT, fs.getUUID(), false);
+ }
- @Override
- @Transactional
- public String saveAdvanceNotice(FieldSetEntity fs)throws BaseException {
- String fsUUID = fs.getUUID();
- if(BaseUtil.strIsNull(fsUUID)){
- fsUUID = baseDao.add(fs);
- }else{
- baseDao.update(fs);
- }
- return fsUUID;
- }
+ @Override
+ @Transactional
+ public String saveAdvanceNotice(FieldSetEntity fs) throws BaseException {
+ String fsUUID = fs.getUUID();
+ if (BaseUtil.strIsNull(fsUUID)) {
+ fsUUID = baseDao.add(fs);
+ } else {
+ baseDao.update(fs);
+ }
+ return fsUUID;
+ }
- @Override
- @Transactional
- public String deleteAdvanceNotice(FieldSetEntity fs)throws BaseException {
- String uuids = fs.getString(CmnConst.UUID);
- String[] uuid = uuids.split(",");
- baseDao.delete(CmnConst.APP_NOTICE_PUNISHMENT, uuid);
- return uuids;
- }
+ @Override
+ @Transactional
+ public String deleteAdvanceNotice(FieldSetEntity fs) throws BaseException {
+ String uuids = fs.getString(CmnConst.UUID);
+ String[] uuid = uuids.split(",");
+ baseDao.delete(CmnConst.APP_NOTICE_PUNISHMENT, uuid);
+ return uuids;
+ }
- @Override
- @Transactional
- public void addTypeSize(FieldSetEntity fs) throws BaseException {
- String tableName = fs.getTableName();
- String yearNo = fs.getString("no01");
-
- //鏌ヨ鍚屽瓧鏁版嵁涓渶澶х殑鍙�
- FieldSetEntity fseMax =baseDao.getFieldSetEntityBySQL("SELECT IFNULL(MAX(no02),0)+1 no02 FROM "+tableName+" WHERE no01=?", new Object[] {yearNo}, false);
- if (fseMax!=null) {
- Integer maxNo = fseMax.getInteger("no02");
-
- //鏍煎紡鍖栧彿
- Format format = new DecimalFormat("000");
- String finalNo= format.format(maxNo);
-
- //淇敼鏁版嵁
- baseDao.executeUpdate("UPDATE "+ tableName +" SET no02 =? WHERE uuid=?", new Object[] {finalNo, fs.getUUID()});
- }
- }
+ @Override
+ @Transactional
+ public void addTypeSize(FieldSetEntity fs) throws BaseException {
+ String tableName = fs.getTableName();
+ String yearNo = fs.getString("no01");
+
+ //鏌ヨ鍚屽瓧鏁版嵁涓渶澶х殑鍙�
+ FieldSetEntity fseMax = baseDao.getFieldSetEntityBySQL("SELECT CONVERT(IFNULL(MAX(no02),0)+1,UNSIGNED INT ) no02 FROM " + tableName + " WHERE no01=?", new Object[]{yearNo}, false);
+ if (fseMax != null) {
+ Integer maxNo = fseMax.getInteger("no02");
+
+ //鏍煎紡鍖栧彿
+ Format format = new DecimalFormat("000");
+ String finalNo = format.format(maxNo);
+
+ //淇敼鏁版嵁
+ baseDao.executeUpdate("UPDATE " + tableName + " SET no02 =? WHERE uuid=?", new Object[]{finalNo, fs.getUUID()});
+ fs.setValue("no02", finalNo);
+ }
+ }
}
diff --git a/home-server-admin/src/main/java/com/home/xining/service/SendDocumentService.java b/home-server-admin/src/main/java/com/home/xining/service/SendDocumentService.java
index 66be2b4..872ddd9 100644
--- a/home-server-admin/src/main/java/com/home/xining/service/SendDocumentService.java
+++ b/home-server-admin/src/main/java/com/home/xining/service/SendDocumentService.java
@@ -24,77 +24,74 @@
@Component
public class SendDocumentService extends AbstractBaseService implements ISendDocumentService {
- @Autowired
- public BaseDao baseDao;
- @Autowired
- PermissionService permissionService;
- @Autowired
- QueryFilterService queryFilterService;
+ @Autowired
+ public BaseDao baseDao;
+ @Autowired
+ PermissionService permissionService;
+ @Autowired
+ QueryFilterService queryFilterService;
- public DataTableEntity getSendDocList(FieldSetEntity fs) throws BaseException {
- String filter=fs.getString("filter");
- String dataFilter = "" ;
- //鍒涘缓浜哄瓧娈�
- String created_by_field = fs.getString(CmnConst.CREATED_BY_FIELD);
- if(!BaseUtil.strIsNull(created_by_field)){
- dataFilter = permissionService.getDataFilter(fs.getTableName(),created_by_field);
- }
- if(!StringUtils.isEmpty(dataFilter)){
- if(!StringUtils.isEmpty(filter)){
- filter += " and "+dataFilter;
- }else {
- filter = dataFilter;
- }
- }
- if(!BaseUtil.dataTableIsEmpty(fs.getSubDataTable("systemSeniorQueryString"))){
- filter = filter + " and " + queryFilterService.getQueryFilter(fs);
- }
- DataTableEntity dt = baseDao.listTable(CmnConst.FWGZ,filter,null,null,"fw13 desc",fs.getInteger(CmnConst.PAGESIZE),fs.getInteger(CmnConst.CPAGE));
- baseDao.loadPromptData(dt);
- return dt;
- }
+ public DataTableEntity getSendDocList(FieldSetEntity fs) throws BaseException {
+ String filter = fs.getString("filter");
+ String dataFilter = "";
+ //鍒涘缓浜哄瓧娈�
+ String created_by_field = fs.getString(CmnConst.CREATED_BY_FIELD);
+ if (!BaseUtil.strIsNull(created_by_field)) {
+ dataFilter = permissionService.getDataFilter(fs.getTableName(), created_by_field);
+ }
+ if (!StringUtils.isEmpty(dataFilter)) {
+ if (!StringUtils.isEmpty(filter)) {
+ filter += " and " + dataFilter;
+ } else {
+ filter = dataFilter;
+ }
+ }
+ if (!BaseUtil.dataTableIsEmpty(fs.getSubDataTable("systemSeniorQueryString"))) {
+ filter = filter + " and " + queryFilterService.getQueryFilter(fs);
+ }
+ DataTableEntity dt = baseDao.listTable(CmnConst.FWGZ, filter, null, null, "fw13 desc", fs.getInteger(CmnConst.PAGESIZE), fs.getInteger(CmnConst.CPAGE));
+ baseDao.loadPromptData(dt);
+ return dt;
+ }
- /**
- * 鎵归噺褰掓。
- * @param fs
- * @throws BaseException
- */
- @Override
- @Transactional
- public boolean batchFile(FieldSetEntity fs)throws BaseException{
- String uuids = fs.getString("uuid");
- String[] uuid = uuids.split(",");
- for (int i = 0; i < uuid.length; i++) {
- FieldSetEntity fieldSetEntity = new FieldSetEntity();
- fieldSetEntity.setTableName(fs.getTableName());
- fieldSetEntity.setValue("uuid", uuid[i]);
- fieldSetEntity.setValue("pigeonhole",1);
- baseDao.update(fieldSetEntity);
- }
- return true;
- }
+ /**
+ * 鎵归噺褰掓。
+ *
+ * @param fs
+ * @throws BaseException
+ */
+ @Override
+ @Transactional
+ public boolean batchFile(FieldSetEntity fs) throws BaseException {
+ String uuids = fs.getString("uuid");
+ String[] uuid = uuids.split(",");
+ for (int i = 0; i < uuid.length; i++) {
+ FieldSetEntity fieldSetEntity = new FieldSetEntity();
+ fieldSetEntity.setTableName(fs.getTableName());
+ fieldSetEntity.setValue("uuid", uuid[i]);
+ fieldSetEntity.setValue("pigeonhole", 1);
+ baseDao.update(fieldSetEntity);
+ }
+ return true;
+ }
- /**
- * 浜哄憳楂樼骇鍙傜収瑙f瀽骞朵繚瀛�
- * @param fse
- * @throws BaseException
- */
- @Transactional
- @Override
- public String saveFieldSetEntity(FieldSetEntity fse) throws BaseException {
- String fw09 = fse.getString("fw09");
- String[] fw09s = fw09.split(",");
- DataTableEntity dataTableEntity = baseDao.listTable("product_sys_users", BaseUtil.buildQuestionMarkFilter("user_id",fw09s,true), new String[]{});
- String fw09_value = "";
- for (int i = 0; i < dataTableEntity.getRows(); i++) {
- String user_name = dataTableEntity.getString(i,"user_name");
- fw09_value = fw09_value + user_name + ",";
- }
- fw09_value = fw09_value.substring(0, fw09_value.length() - 1);
- fse.setValue("fw09_value", fw09_value);
- BaseUtil.createCreatorAndCreationTime(fse);
- baseDao.saveFieldSetEntity(fse);
- return fse.getUUID();
- }
+ /**
+ * 浜哄憳楂樼骇鍙傜収瑙f瀽骞朵繚瀛�
+ *
+ * @param fse
+ * @throws BaseException
+ */
+ @Transactional
+ @Override
+ public String saveFieldSetEntity(FieldSetEntity fse) throws BaseException {
+ try {
+ BaseUtil.createCreatorAndCreationTime(fse);
+ baseDao.saveFieldSetEntity(fse);
+ return fse.getUUID();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
}
diff --git a/pom.xml b/pom.xml
index 3df06ac..ae3d803 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,8 +14,18 @@
<name>product-server</name>
<description>product-server</description>
<modules>
- <module>product-server-web</module>
<module>home-server-admin</module>
+ <module>product-server-web</module>
+ <module>product-server-util</module>
+ <module>product-server-admin</module>
+ <module>product-server-org-admin</module>
+ <module>product-server-file</module>
+ <module>product-server-data-sync</module>
+ <module>product-server-common</module>
+ <module>product-server-print</module>
+ <module>product-server-tool-face</module>
+ <module>product-server-tool-table</module>
+ <module>product-server-tool-flow</module>
</modules>
<properties>
<skipTests>true</skipTests>
@@ -38,8 +48,10 @@
<UserAgentUtils.version>1.21</UserAgentUtils.version>
<thumbnailator.version>0.4.8</thumbnailator.version>
<twelvemonkeys.version>3.4.1</twelvemonkeys.version>
- <poi.version>3.16</poi.version>
+ <poi.version>4.1.2</poi.version>
<pinyin4j.version>2.5.1</pinyin4j.version>
+ <mybatis.version>3.4.6</mybatis.version>
+ <mybatis-spring.version>1.3.2</mybatis-spring.version>
<commons-fileupload.version>1.3.3</commons-fileupload.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.version>2.0.0-release</project.build.version>
@@ -86,6 +98,11 @@
<dependencies>
<!--瀛愭ā鍧楋細start-->
<dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-xining</artifactId>
+ <version>${product-module-version}</version>
+ </dependency>
+ <dependency>
<groupId>org.spring</groupId>
<artifactId>spring-server-master</artifactId>
<version>1.2.6.6</version>
@@ -95,14 +112,15 @@
<artifactId>product-server-core</artifactId>
<version>2.0.1</version>
</dependency>
+
<dependency>
<groupId>com.lx</groupId>
- <artifactId>product-server-xining</artifactId>
+ <artifactId>product-server-util</artifactId>
<version>${product-module-version}</version>
</dependency>
<dependency>
<groupId>com.lx</groupId>
- <artifactId>product-server-util</artifactId>
+ <artifactId>product-server-tool-face</artifactId>
<version>${product-module-version}</version>
</dependency>
<dependency>
@@ -227,17 +245,18 @@
</dependency>
<dependency>
<groupId>com.lx</groupId>
- <artifactId>product-server-tool-face</artifactId>
- <version>${product-module-version}</version>
- </dependency>
- <dependency>
- <groupId>com.lx</groupId>
- <artifactId>product-server-xining</artifactId>
+ <artifactId>product-server-datasource</artifactId>
<version>${product-module-version}</version>
</dependency>
<!--瀛愭ā鍧楋細end-->
<!--绗笁鏂逛緷璧栵細start-->
+
+ <dependency>
+ <groupId>com.deepoove</groupId>
+ <artifactId>poi-tl</artifactId>
+ <version>1.10.5</version>
+ </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
@@ -311,9 +330,62 @@
<version>${twelvemonkeys.version}</version>
</dependency>
<dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.2</version>
+ </dependency>
+ <!--logo4j-->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>2.15.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>2.15.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-to-slf4j</artifactId>
+ <version>2.15.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.itextpdf</groupId>
+ <artifactId>itextpdf</artifactId>
+ <version>5.5.13</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.pdfbox</groupId>
+ <artifactId>pdfbox</artifactId>
+ <version>2.0.25</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.pdfbox</groupId>
+ <artifactId>pdfbox-app</artifactId>
+ <version>2.0.25</version>
+ </dependency>
+ <dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
+ </dependency>
+ <!-- oracle jdbc -->
+ <dependency>
+ <groupId>com.oracle.database.nls</groupId>
+ <artifactId>orai18n</artifactId>
+ <version>19.7.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.oracle.database.jdbc</groupId>
+ <artifactId>ojdbc8</artifactId>
+ <version>21.1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
</dependency>
<!--绗笁鏂逛緷璧栵細end-->
@@ -343,17 +415,14 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
- <version>2.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
- <version>2.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
- <version>2.15.0</version>
</dependency>
<!--鏀寔浣跨敤 JDBC 璁块棶鏁版嵁搴� -->
@@ -441,7 +510,6 @@
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
- <version>3.2.2</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
@@ -581,7 +649,7 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
- <version>3.16</version>
+ <version>${poi.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
@@ -764,5 +832,10 @@
<artifactId>sigar</artifactId>
<version>1.6.4</version>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/product-server-data-sync/pom.xml b/product-server-data-sync/pom.xml
new file mode 100644
index 0000000..0cc46d5
--- /dev/null
+++ b/product-server-data-sync/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>product-server</artifactId>
+ <groupId>com.lx</groupId>
+ <version>2.0.0-release</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <version>2.0.0-release</version>
+ <artifactId>product-server-data-sync</artifactId>
+
+ <properties>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-file</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-admin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-org-admin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-quartz</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/product-server-data-sync/pom.xml_bak b/product-server-data-sync/pom.xml_bak
new file mode 100644
index 0000000..0ab62d0
--- /dev/null
+++ b/product-server-data-sync/pom.xml_bak
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server</artifactId>
+ <version>2.0.0-release</version>
+ </parent>
+ <artifactId>product-server-data-sync</artifactId>
+ <version>2.0.0-release</version>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-quartz</artifactId>
+ </dependency>
+ <!--releases -->
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-admin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-org-admin</artifactId>
+ </dependency>
+ <!-- 娣诲姞oracle jdbc driver -->
+ <dependency>
+ <groupId>com.oracle.database.jdbc</groupId>
+ <artifactId>ojdbc8</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>cn.easyproject</groupId>
+ <artifactId>orai18n</artifactId>
+ </dependency>
+ <!-- 娣诲姞sqlserver jdbc driver -->
+ <dependency>
+ <groupId>com.microsoft.sqlserver</groupId>
+ <artifactId>mssql-jdbc</artifactId>
+ <version>7.2.2.jre8</version>
+ </dependency>
+ <dependency>
+ <groupId>com.ibm.informix</groupId>
+ <artifactId>ifx-changestream-client</artifactId>
+ <version>1.1.1</version>
+ <classifier>sources</classifier>
+ <type>java-source</type>
+ </dependency>
+ <dependency>
+ <groupId>com.ibm.informix</groupId>
+ <artifactId>jdbc</artifactId>
+ <version>4.50.7.1</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/config/CmnConst.java b/product-server-data-sync/src/main/java/com/product/data/sync/config/CmnConst.java
new file mode 100644
index 0000000..b173040
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/config/CmnConst.java
@@ -0,0 +1,106 @@
+package com.product.data.sync.config;
+
+/**
+ * Copyright LX-BASE
+ *
+ * @Title: CmnConst
+ * @Project: LX-BASE-SERVER
+ * @Date: 2020-06-15 11锛�47
+ * @Author: LiuChao
+ * @Description: 鏂囦欢绠$悊-甯搁噺
+ */
+public class CmnConst {
+ //鍏叡甯搁噺瀹氫箟
+ public static final String ID = "id"; // id 鑷涓婚敭
+ public static final String UUID = "uuid"; //uuid
+ public static final String USER_ID = "user_id"; // 鐢ㄦ埛id
+ public static final String UPDATED_BY = "updated_by"; //鍒涘缓鑰�
+ public static final String UPDATED_UTC_DATETIME = "updated_utc_datetime"; //鍒涘缓鏃堕棿
+ public static final String CREATED_BY = "created_by"; //鍒涘缓鑰�
+ public static final String CREATED_UTC_DATETIME = "created_utc_datetime"; //鍒涘缓鏃堕棿
+
+
+ //鏁版嵁搴撹繛鎺ラ厤缃〃
+ public static final String PRODUCT_SYS_DATABASE_CONNECTION_CONFIG = "product_sys_database_connection_config";
+ public static final String DATABASE_TYPE = "database_type";
+ public static final String IP_ADDRESS = "ip_address";
+ public static final String CONNECT_NAME = "connect_name";
+ public static final String DATABASE_NAME = "database_name";
+ public static final String PORT_NUMBER = "port_number";
+ public static final String USER_NAME = "user_name";
+ public static final String USER_PASSWORD = "user_password";
+ public static final String INSTANTIATION = "instantiation"; //瀹炰緥鍚�
+
+ //鏁版嵁搴撳悓姝ヨ〃閰嶇疆
+ public static final String PRODUCT_SYS_DATABASE_SYNC_CONFIG = "product_sys_database_sync_config";
+ //鏁版嵁婧愬悓姝ラ厤缃〃
+ public static final String DATA_ORIGIN_NAME = "data_origin_name";//鏁版嵁婧愯〃鍚�
+ public static final String SYSTEM_TABLE_NAME = "system_table_name";//鏁版嵁婧愯〃鍚�
+ public static final String SAVE_PRE_EVENT = "save_pre_event";//淇濆瓨鍓嶅鐞�
+ public static final String POST_SAVE_EVENT = "post_save_event";//淇濆瓨鍚庡鐞�
+ public static final String SYNC_CONDITION = "sync_condition";//鏌ヨ鏉′欢
+ public static final String SYNC_TYPE = "sync_type";//鍚屾绫诲瀷 1澧為噺 2瑕嗙洊
+ public static final String IS_UPDATE = "is_update";//鏄惁淇敼 1 鏄� 0 鍚�
+ public static final String IS_DELETE = "is_delete";//鏄惁鍒犻櫎 1 鏄� 0 鍚�
+ public static final String DELETE_VALUE = "delete_value"; //鍒犻櫎鏍囪瘑
+
+ //鏁版嵁婧愰厤缃瓙琛�
+ public static final String PRODUCT_SYS_DATABASE_SYNC_CONFIG_SUB = "product_sys_database_sync_config_sub";
+ public static final String IS_SOLE = "is_sole";
+ public static final String SYSTEM_FIELD = "system_field"; //绯荤粺琛�
+ public static final String DATA_ORIGIN_FIELD = "data_origin_field"; //鏁版嵁婧愬瓧娈佃〃
+ //鏁版嵁搴撹〃鍚嶄俊鎭〃
+ public static final String TABLE_NAME = "table_name";
+ public static final String PRODUCT_SYS_DATABASE_TABLENAME_FIELD = "product_sys_database_tablename_field";
+ public static final String FIELD_NAME = "field_name";
+ public static final String FIELD_DESCRIPTION = "field_description";//涓枃鎻忚堪
+ public static final String FIELD_TYPE = "field_type";//瀛楁绫诲瀷
+ public static final String FIELD_LENGTH = "field_length";//瀛楁闀垮害
+ public static final String FIELD_UNIT = "field_unit";//灏忔暟浣嶆暟
+ public static final String IS_REQUIRED = "is_required";//鏄惁蹇呭~ 0:闈炵┖ 1:蹇呭~
+ public static final String IS_UNIQUE = "is_unique";//鏄惁鍞竴 0:涓嶅敮涓�1:鍞竴
+ public static final String DATABASE_CONFIG_UUID = "database_config_uuid";
+
+ public static final String PRODUCT_SYS_DATABASE_SYNC_CONFIG_LOG = "product_sys_database_sync_config_log";
+ public static final String ADD_NUM = "add_num"; //澧炲姞鏉℃暟
+ public static final String UPDATE_NUM = "update_num"; //鏇存柊鏉℃暟
+ public static final String DELETE_NUM = "delete_num"; //鍒犻櫎鏉℃暟
+ public static final String ERR_INFO = "err_info"; //閿欒淇℃伅
+ public static final String FAIL_NUM = "fail_num"; //澶辫触鏁伴噺
+ public static final String TOTAL_NUMBER = "total_number"; //鎬绘潯鏁�
+
+ public static final String PRODUCT_SYS_ORG_LEVELS = "product_sys_org_levels";
+ public static final String ORG_LEVEL_CODE = "org_level_code";
+
+
+ //鏃ュ織瀛愯〃
+ public static final String PRODUCT_SYS_DATABASE_SYNC_CONFIG_LOG_SUB = "product_sys_database_sync_config_log_sub";
+ //閿欒淇℃伅
+ public static final String ERROR_INFO = "error_info";
+ //鏃ュ織涓昏〃uuid
+ public static final String SYNC_CONFIG_LOG_UUID = "sync_config_log_uuid";
+ //澶氫釜鏍囪瘑閫楀彿鍒嗛殧
+ public static final String WRONG_DATA_KEY = "wrong_data_key";
+
+ public static final String SYNC_CONFIG_UUID = "sync_config_uuid"; //鍚屾閰嶇疆涓昏〃.PRODUCT_SYS_database_sync_config)uuid
+ public static final String SYNC_TIME = "sync_time"; //鍚屾鏃堕棿
+
+ public static final String PRODUCT_SYS_DATABASE_SYNC_FUNCTION = "product_sys_database_sync_function"; //鍚屾鍔熻兘琛�
+
+ public static final String PRODUCT_SYS_FUNCTIONS = "product_sys_functions"; //鍔熻兘琛�
+
+ public static final String PRODUCT_SYS_STAFFS="product_sys_staffs"; //鍛樺伐
+ public static final String LEADER_TRICODE="leader_tricode"; //鍛樺伐涓婁笅绾х紪鐮�
+ public static final String TRICODE="tricode"; //鍛樺伐涓婁笅绾х紪鐮�
+
+
+ //鍒嗛〉甯搁噺瀹氫箟
+ public static final String CPAGE = "cpage"; //椤垫暟
+
+ // 鍒嗛〉甯搁噺瀹氫箟
+ public static final String PAGESIZE = "pagesize"; // 姣忛〉鏉℃暟
+
+
+
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/config/SystemCode.java b/product-server-data-sync/src/main/java/com/product/data/sync/config/SystemCode.java
new file mode 100644
index 0000000..8b3f02d
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/config/SystemCode.java
@@ -0,0 +1,72 @@
+package com.product.data.sync.config;
+
+import com.product.common.enums.IEnum;
+import com.product.common.enums.ModuleEnum;
+
+/**
+ * Copyright LX
+ *
+ * @Title: SystemCode
+ * @Project: product-server
+ * @date: 2021-08-11 9:19
+ * @author: ZhouJie
+ * @Description:
+ */
+
+public enum SystemCode implements IEnum {
+
+ SYSTEM_OPERATION_SUCCESS("鎴愬姛", "200"),
+ SYSTEM_FORM_COUNT("璇锋眰鍙傛暟鏈夎", ModuleEnum.SYSTEM.getValue() + "998"),
+ SYSTEM_TABLE_NODATA("璇锋眰琛ㄥ悕鏈夎", ModuleEnum.SYSTEM.getValue() + "997"),
+ SYSTEM_ACQUIRE_PARAM_FAIL("鑾峰彇鍙傛暟澶辫触", ModuleEnum.SYSTEM.getValue() + "996"),
+ SYSTEM_CPAGES_NOT_NULL("鍒嗛〉鍙傛暟涓嶈兘涓虹┖", ModuleEnum.SYSTEM.getValue() + "995"),
+ SYSTEM_FORM_NODATA("璇锋眰鍙傛暟涓虹┖", ModuleEnum.ORGSYSTEM.getValue() + "001"),
+ SYSTEM_USER_ACQUIRE_FAIL("鑾峰彇鐢ㄦ埛澶辫触", ModuleEnum.ORGSYSTEM.getValue() + "002"),
+ SQL_START_FAILED("SQL鎵ц澶辫触", ModuleEnum.TOOL_TABLE.getValue() + "004"),
+
+
+ SYSTEM_SAVE_CONNECT_CONFIGURE_FAIL("淇濆瓨鏁版嵁搴撹繛鎺ラ厤缃け璐�!", ModuleEnum.ADMINISTRAT.getValue() + "003"),
+ SYSTEM_DELETE_CONNECT_CONFIGURE_FAIL("鍒犻櫎鏁版嵁搴撹繛鎺ラ厤缃け璐�!", ModuleEnum.ADMINISTRAT.getValue() + "004"),
+ SYSTEM_LIST_CONNECT_CONFIGURE_FAIL("鑾峰彇鏁版嵁搴撹繛鎺ラ厤缃垪琛ㄥけ璐�!", ModuleEnum.ADMINISTRAT.getValue() + "005"),
+ SYSTEM_GET_CONNECT_CONFIGURE_FAIL("鏌ヨ鏁版嵁搴撹繛鎺ラ厤缃鎯呭け璐�!", ModuleEnum.ADMINISTRAT.getValue() + "006"),
+
+ SYSTEM_SAVE_SYNC_CONFIG_FAIL("淇濆瓨鏁版嵁搴撳悓姝ラ厤缃け璐�!", ModuleEnum.ADMINISTRAT.getValue() + "007"),
+ SYSTEM_DELETE_SYNC_CONFIG_FAIL("鍒犻櫎鏁版嵁搴撳悓姝ラ厤缃け璐�!", ModuleEnum.ADMINISTRAT.getValue() + "008"),
+ SYSTEM_LIST_SYNC_CONFIG_FAIL("鑾峰彇鏁版嵁搴撳悓姝ラ厤缃垪琛ㄥけ璐�!", ModuleEnum.ADMINISTRAT.getValue() + "009"),
+ SYSTEM_GET_SYNC_CONFIG_FAIL("鏌ヨ鏁版嵁搴撳悓姝ラ厤缃鎯呭け璐�!", ModuleEnum.ADMINISTRAT.getValue() + "010"),
+ SYSTEM_RUN_CONNECT_CONFIGURE_FAIL("鏁版嵁搴撹繛鎺ュけ璐�", ModuleEnum.ADMINISTRAT.getValue() + "011"),
+ SYSTEM_UNKNOWN_DATABASE_TYPE("鏈煡鏁版嵁搴撶被鍨�", ModuleEnum.ADMINISTRAT.getValue() + "012"),
+ GET_JDBC_CONNECT_FAIL("鑾峰彇JDBC杩炴帴澶辫触", ModuleEnum.ADMINISTRAT.getValue() + "013"),
+ GET_DATA_SOURCE_FAIL("鏌ヨ鏁版嵁婧愬け璐�", ModuleEnum.ADMINISTRAT.getValue() + "014"),
+ GET_SYNC_LOG_FAIL("鑾峰彇鏁版嵁鍚屾鏃ュ織澶辫触", ModuleEnum.ADMINISTRAT.getValue() + "015"),
+
+ GET_SYNC_DATA_SOURCE_FAIL("鑾峰彇鍚屾鏁版嵁搴撳姛鑳芥暟鎹け璐�", ModuleEnum.ADMINISTRAT.getValue() + "016"),
+ SYNC_FUNCTION_DATA_SOURCE_FAIL("鏁版嵁搴撳姛鑳藉悓姝ュけ璐�", ModuleEnum.ADMINISTRAT.getValue() + "017"),
+ SYNC_FUNCTION_DATA_CODE_TYPE_ERR("鍚屾鍔熻兘鏁版嵁搴撳墠闇�瑕佷慨鏀筽roduct_sys_modules product_sys_functions product_sys_products 鐨則ricode瀛楁绫诲瀷", ModuleEnum.ADMINISTRAT.getValue() + "018"),
+ SYNC_EXISTING_CONFIGURATION_FAIL("璇ヨ繛鎺ュ凡鏈夊悓姝ラ厤缃棤娉曞垹闄�", ModuleEnum.ADMINISTRAT.getValue() + "019"),
+ FIELD_TYPE_FIAL("瀛楁绫诲瀷閿欒", ModuleEnum.TOOL_TABLE.getValue() + "021"),
+ GET_RESULTSET_COLUMN_COUNT_FAIL("鑾峰彇鏁版嵁闆嗗垪鏁伴噺閿欒", ModuleEnum.TOOL_TABLE.getValue() + "022"),
+ GET_RESULTSET_COLUMN_NAME_FAIL("鑾峰彇鏁版嵁闆嗗垪鍚嶉敊璇�", ModuleEnum.TOOL_TABLE.getValue() + "023"),
+ GET_TABLE_CACHE_FAIL("鑾峰彇绯荤粺琛ㄥけ璐ワ紝琛ㄤ笉瀛樺湪", ModuleEnum.TOOL_TABLE.getValue() + "024"),
+ GET_FIELD_CACHE_FAIL("鑾峰彇绯荤粺琛ㄥ瓧娈靛け璐ワ紝瀛楁涓嶅瓨鍦�", ModuleEnum.TOOL_TABLE.getValue() + "024"),
+
+ ;
+
+
+ private String text;
+ private String value;
+
+ private SystemCode(String text, String value) {
+ this.text = text;
+ this.value = value;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/controller/ConnectionConfigurationController.java b/product-server-data-sync/src/main/java/com/product/data/sync/controller/ConnectionConfigurationController.java
new file mode 100644
index 0000000..3d52fce
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/controller/ConnectionConfigurationController.java
@@ -0,0 +1,360 @@
+package com.product.data.sync.controller;
+
+import com.alibaba.fastjson.JSONArray;
+import com.product.common.lang.StringUtils;
+import com.product.core.config.CoreConst;
+import com.product.core.controller.support.AbstractBaseController;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.entity.RequestParameterEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.data.sync.config.CmnConst;
+import com.product.data.sync.config.SystemCode;
+import com.product.data.sync.service.ConnectionConfigurationService;
+import com.product.data.sync.service.ide.IConnectionConfigurationService;
+import com.product.data.sync.util.ResultInfo;
+import com.product.data.sync.util.ScheduledTaskExecution;
+import com.product.module.sys.version.ApiVersion;
+import com.product.util.BaseUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.sql.Connection;
+
+
+/**
+ * Copyright LX-BASE
+ *
+ * @Title: ConnectionConfigurationController
+ * @Project: LX-BASE-SERVER
+ * @Date: 2021-08-10 11:30:48
+ * @Author: luoxin
+ * @Description: 鏁版嵁搴撹繛鎺ラ厤缃瓹onstoller
+ *
+ */
+@RequestMapping("/api/connectionConfiguration")
+@RestController
+public class ConnectionConfigurationController extends AbstractBaseController {
+ @Autowired
+ public ConnectionConfigurationService connectionConfigurationService;
+ @Autowired
+ public ScheduledTaskExecution scheduledTaskExecution;
+ /**
+ * 淇濆瓨鏁版嵁搴撹繛鎺ラ厤缃�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/save-connectConfigure/{version}", method = RequestMethod.POST)
+ public String saveConnectionConfiguration(HttpServletRequest request) {
+ try {
+ //鑾峰彇鍙傛暟
+ FieldSetEntity fse=null;
+ Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if(bean != null){
+ RequestParameterEntity reqp=(RequestParameterEntity)bean;
+ fse = reqp.getFormData();
+ }
+ //鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if(bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ //鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ IConnectionConfigurationService service = (IConnectionConfigurationService) getProxyInstance(connectionConfigurationService);
+ String uuid = service.saveConnectionConfiguration(fse);
+ if (!BaseUtil.strIsNull(uuid)) {
+ return OK_Add(uuid);
+ }
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_SAVE_CONNECT_CONFIGURE_FAIL.getValue(), SystemCode.SYSTEM_SAVE_CONNECT_CONFIGURE_FAIL.getText());
+ return error(SystemCode.SYSTEM_SAVE_CONNECT_CONFIGURE_FAIL.getValue(), SystemCode.SYSTEM_SAVE_CONNECT_CONFIGURE_FAIL.getText());
+ }catch(BaseException e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ }catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_SAVE_CONNECT_CONFIGURE_FAIL.getValue(), SystemCode.SYSTEM_SAVE_CONNECT_CONFIGURE_FAIL.getText());
+ }
+ }
+
+ /**
+ * 鍒犻櫎鏁版嵁搴撹繛鎺ラ厤缃�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/delete-connectConfigure/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String delConnectionConfiguration(HttpServletRequest request) {
+ try {
+ //鑾峰彇鍙傛暟
+ FieldSetEntity fse=null;
+ Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if(bean != null) {
+ RequestParameterEntity reqp=(RequestParameterEntity)bean;
+ fse = reqp.getFormData();
+ }
+ //鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if(bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ //鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ //鍒ゆ柇uuid鏄惁涓虹┖
+ if (StringUtils.isEmpty(fse.getString("uuid"))) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
+ return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
+ }
+ IConnectionConfigurationService service = (IConnectionConfigurationService) getProxyInstance(connectionConfigurationService);
+ boolean success=service.delConnectionConfiguration(fse);
+ if(success) {
+ return OK();
+ }
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_DELETE_CONNECT_CONFIGURE_FAIL.getValue(),SystemCode.SYSTEM_DELETE_CONNECT_CONFIGURE_FAIL.getText());
+ return error(SystemCode.SYSTEM_DELETE_CONNECT_CONFIGURE_FAIL.getValue(),SystemCode.SYSTEM_DELETE_CONNECT_CONFIGURE_FAIL.getText());
+ }catch(BaseException e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ }catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_DELETE_CONNECT_CONFIGURE_FAIL.getValue(),SystemCode.SYSTEM_DELETE_CONNECT_CONFIGURE_FAIL.getText());
+ }
+ }
+
+ /**
+ * 鑾峰彇鏁版嵁搴撹繛鎺ラ厤缃垪琛�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/list-connectConfigure/{version}", method = RequestMethod.POST)
+ public String listConnectionConfiguration(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ // 鍒ゆ柇鍒嗛〉鍙傛暟
+ if (fse.getString(CmnConst.PAGESIZE) == null || fse.getString(CmnConst.CPAGE) == null) {
+ return this.error(SystemCode.SYSTEM_CPAGES_NOT_NULL.getValue(),
+ SystemCode.SYSTEM_CPAGES_NOT_NULL.getText());
+ }
+ DataTableEntity dt = connectionConfigurationService.listConnectionConfiguration(fse);
+ return OK_List(dt);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_LIST_CONNECT_CONFIGURE_FAIL.getValue(),
+ SystemCode.SYSTEM_LIST_CONNECT_CONFIGURE_FAIL.getText());
+ }
+ }
+
+ /**
+ * 鏌ヨ鏁版嵁搴撹繛鎺ラ厤缃鎯�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/get-connectConfigure/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String getConnectionConfiguration(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
+ SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ // 鍒ゆ柇uuid鏄惁涓虹┖
+ if (StringUtils.isEmpty(fse.getString("uuid"))) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
+ }
+ FieldSetEntity fs = connectionConfigurationService.getConnectionConfiguration(fse);
+ return OK_List(fs);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_GET_CONNECT_CONFIGURE_FAIL.getValue(),
+ SystemCode.SYSTEM_GET_CONNECT_CONFIGURE_FAIL.getText());
+ }
+ }
+ /**
+ * 杩愯鏁版嵁搴撹繛鎺ラ厤缃�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/run-connectConfigure/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String runConnectionConfiguration(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
+ SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ Connection conn = connectionConfigurationService.runConnectionConfiguration(fse);
+ if(conn != null){
+ conn.close();
+ return OK();
+ }
+ return this.error(SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getValue(),
+ SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getText());
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getValue(),
+ SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getText());
+ }
+ }
+
+ /**
+ * 鑾峰彇骞朵繚瀛樺瓧娈�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/saveField/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String saveField(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
+ SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ if(connectionConfigurationService.saveField(fse)){
+ return OK();
+ }
+ return this.error(SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getValue(),
+ SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getText());
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getValue(),
+ SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getText());
+ }
+ }
+
+ /**
+ * 鑾峰彇鏁版嵁鍚屾閰嶇疆鏍�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/tree/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String getTree(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
+ SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ JSONArray array = connectionConfigurationService.getSyncTree();
+ return ResultInfo.success(array);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getValue(),
+ SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getText());
+ }
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/controller/FunctionSynchrController.java b/product-server-data-sync/src/main/java/com/product/data/sync/controller/FunctionSynchrController.java
new file mode 100644
index 0000000..aa47c36
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/controller/FunctionSynchrController.java
@@ -0,0 +1,222 @@
+package com.product.data.sync.controller;
+
+import com.product.core.config.CoreConst;
+import com.product.core.controller.support.AbstractBaseController;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.entity.RequestParameterEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.data.sync.config.CmnConst;
+import com.product.data.sync.config.SystemCode;
+import com.product.data.sync.service.FunctionSynchrService;
+import com.product.data.sync.service.ide.IFunctionSynchrService;
+import com.product.module.sys.version.ApiVersion;
+import com.product.util.BaseUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.sql.Connection;
+
+/**
+ * Copyright LX
+ *
+ * @Title: FunctionSynchrController
+ * @Project: product-server
+ * @date: 2021-08-30 14:20
+ * @author: ZhouJie
+ * @Description: 寮�鍙戝簱鍔熻兘鍚屾
+ */
+@RequestMapping("/api/functionsync")
+@RestController
+public class FunctionSynchrController extends AbstractBaseController {
+ @Autowired
+ public FunctionSynchrService functionSynchrService;
+
+ /**
+ * 鑾峰彇JDBC杩炴帴
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/get-connect/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String getConnection(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
+ SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_SYNC_FUNCTION.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ Connection conn = functionSynchrService.getConnection(fse);
+ if(conn != null){
+ conn.close();
+ return OK();
+ }
+ return this.error(SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getValue(),
+ SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getText());
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getValue(),
+ SystemCode.SYSTEM_RUN_CONNECT_CONFIGURE_FAIL.getText());
+ }
+ }
+
+ /**
+ * 寮�鍙戝簱鐨勬ā鍧楀姛鑳芥爲
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/get-synctree/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String getSyncTree(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
+ SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_FUNCTIONS.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ DataTableEntity dt = functionSynchrService.getSyncTree(fse);
+ return BaseUtil.success(BaseUtil.dataTableToTreeData(dt,"tricode","tricode_parent",null,true),null);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.GET_SYNC_DATA_SOURCE_FAIL.getValue(),
+ SystemCode.GET_SYNC_DATA_SOURCE_FAIL.getText());
+ }
+ }
+
+ /**
+ * 褰撳墠搴撶殑妯″潡鍔熻兘鏍�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/get-nowtree/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String getNowTree(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
+ SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_FUNCTIONS.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ DataTableEntity dt = functionSynchrService.getNowTree(fse);
+ return BaseUtil.success(BaseUtil.dataTableToTreeData(dt,"tricode","tricode_parent",null,true),null);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.GET_SYNC_DATA_SOURCE_FAIL.getValue(),
+ SystemCode.GET_SYNC_DATA_SOURCE_FAIL.getText());
+ }
+ }
+
+ /**
+ * 鍔熻兘鍚屾
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/sync-function/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String syncFuntion(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
+ SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_FUNCTIONS.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ //鍚屾鍓嶅繀椤讳慨.PRODUCT_SYS_products.PRODUCT_SYS_modules.PRODUCT_SYS_functions 鐨則ricode瀛楁绫诲瀷
+ if (!functionSynchrService.verificationCode()) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYNC_FUNCTION_DATA_CODE_TYPE_ERR.getValue(),
+ SystemCode.SYNC_FUNCTION_DATA_CODE_TYPE_ERR.getText());
+ return this.error(SystemCode.SYNC_FUNCTION_DATA_CODE_TYPE_ERR.getValue(), SystemCode.SYNC_FUNCTION_DATA_CODE_TYPE_ERR.getText());
+ }
+ IFunctionSynchrService service = (IFunctionSynchrService)getProxyInstance(functionSynchrService);
+
+ service.syncFuntion(fse);
+ return OK();
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYNC_FUNCTION_DATA_SOURCE_FAIL.getValue(),
+ SystemCode.SYNC_FUNCTION_DATA_SOURCE_FAIL.getText());
+ }
+ }
+
+
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/controller/SyFeDataController.java b/product-server-data-sync/src/main/java/com/product/data/sync/controller/SyFeDataController.java
new file mode 100644
index 0000000..2b59210
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/controller/SyFeDataController.java
@@ -0,0 +1,76 @@
+package com.product.data.sync.controller;
+
+import com.product.core.config.CoreConst;
+import com.product.core.controller.support.AbstractBaseController;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.entity.RequestParameterEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.spring.context.SpringMVCContextHolder;
+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.module.sys.version.ApiVersion;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+
+@RestController
+@RequestMapping("/api/syncfe")
+public class SyFeDataController extends AbstractBaseController {
+ @Autowired
+ public SyFeDataService syFeDataService;
+
+ @Autowired
+ public FeDataDSService feDataDSService;
+
+ @RequestMapping(value = "/sy-oracle-fun/{version}", method = RequestMethod.POST)
+ public String saveSyncConfig(HttpServletRequest request) {
+ try {
+ //鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ //鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ //鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_FUNCTIONS.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ String uuid = syFeDataService.saveSyncFedata(fse);
+ return OK();
+ } catch (BaseException e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_SAVE_SYNC_CONFIG_FAIL.getValue(), SystemCode.SYSTEM_SAVE_SYNC_CONFIG_FAIL.getText());
+ }
+ }
+
+
+ @PostMapping("/flow-sync/{version}")
+ @ApiVersion(1)
+ public String flowSync() {
+ try {
+ syFeDataService.flowPermission();
+ return OK();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return error(new BaseException(e));
+ }
+ }
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/controller/SyncConfigController.java b/product-server-data-sync/src/main/java/com/product/data/sync/controller/SyncConfigController.java
new file mode 100644
index 0000000..bf74f83
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/controller/SyncConfigController.java
@@ -0,0 +1,316 @@
+package com.product.data.sync.controller;
+
+import com.product.core.config.CoreConst;
+import com.product.core.controller.support.AbstractBaseController;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.entity.RequestParameterEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.data.sync.config.CmnConst;
+import com.product.data.sync.config.SystemCode;
+import com.product.data.sync.service.SyncConfigService;
+import com.product.data.sync.service.ide.ISyncConfigService;
+import com.product.module.sys.version.ApiVersion;
+import com.product.util.BaseUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Copyright LX
+ *
+ * @Title: SyncConfigController
+ * @Project: product-server
+ * @date: 2021-08-11 16:35
+ * @author: ZhouJie
+ * @Description: 鏁版嵁搴撳悓姝ラ厤缃�
+ */
+@RequestMapping("/api/sync")
+@RestController
+public class SyncConfigController extends AbstractBaseController {
+
+ @Autowired
+ public SyncConfigService syncConfigService;
+
+ /**
+ * 淇濆瓨鏁版嵁搴撳悓姝ラ厤缃�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/save-syncconfig/{version}", method = RequestMethod.POST)
+ public String saveSyncConfig(HttpServletRequest request) {
+ try {
+ //鑾峰彇鍙傛暟
+ FieldSetEntity fse=null;
+ Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if(bean != null){
+ RequestParameterEntity reqp=(RequestParameterEntity)bean;
+ fse = reqp.getFormData();
+ }
+ //鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if(bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ //鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ ISyncConfigService service = (ISyncConfigService)getProxyInstance(syncConfigService);
+ String uuid = service.saveSyncConfig(fse);
+ if (!BaseUtil.strIsNull(uuid)) {
+ return OK_Add(uuid);
+ }
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_SAVE_SYNC_CONFIG_FAIL.getValue(), SystemCode.SYSTEM_SAVE_SYNC_CONFIG_FAIL.getText());
+ return error(SystemCode.SYSTEM_SAVE_SYNC_CONFIG_FAIL.getValue(), SystemCode.SYSTEM_SAVE_SYNC_CONFIG_FAIL.getText());
+ }catch(BaseException e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ }catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_SAVE_SYNC_CONFIG_FAIL.getValue(), SystemCode.SYSTEM_SAVE_SYNC_CONFIG_FAIL.getText());
+ }
+ }
+
+ /**
+ * 鍒犻櫎鏁版嵁搴撳悓姝ラ厤缃�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/delete-syncconfig/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String delSyncConfig(HttpServletRequest request) {
+ try {
+ //鑾峰彇鍙傛暟
+ FieldSetEntity fse=null;
+ Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if(bean != null) {
+ RequestParameterEntity reqp=(RequestParameterEntity)bean;
+ fse = reqp.getFormData();
+ }
+ //鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if(bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ //鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ //鍒ゆ柇uuid鏄惁涓虹┖
+ if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString("uuid"))) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
+ return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
+ }
+ ISyncConfigService service = (ISyncConfigService) getProxyInstance(syncConfigService);
+ boolean success=service.delSyncConfig(fse);
+ if(success) {
+ return OK();
+ }
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_DELETE_SYNC_CONFIG_FAIL.getValue(),SystemCode.SYSTEM_DELETE_SYNC_CONFIG_FAIL.getText());
+ return error(SystemCode.SYSTEM_DELETE_SYNC_CONFIG_FAIL.getValue(),SystemCode.SYSTEM_DELETE_SYNC_CONFIG_FAIL.getText());
+ }catch(BaseException e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ }catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_DELETE_SYNC_CONFIG_FAIL.getValue(),SystemCode.SYSTEM_DELETE_SYNC_CONFIG_FAIL.getText());
+ }
+ }
+
+ /**
+ * 鑾峰彇鏁版嵁搴撳悓姝ラ厤缃垪琛�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/list-syncconfig/{version}", method = RequestMethod.POST)
+ public String listSyncConfig(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ // 鍒ゆ柇鍒嗛〉鍙傛暟
+ if (fse.getString(CmnConst.PAGESIZE) == null || fse.getString(CmnConst.CPAGE) == null) {
+ return this.error(SystemCode.SYSTEM_CPAGES_NOT_NULL.getValue(),
+ SystemCode.SYSTEM_CPAGES_NOT_NULL.getText());
+ }
+ DataTableEntity dt = syncConfigService.listSyncConfig(fse);
+ return OK_List(dt);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_LIST_SYNC_CONFIG_FAIL.getValue(),
+ SystemCode.SYSTEM_LIST_SYNC_CONFIG_FAIL.getText());
+ }
+ }
+
+ /**
+ * 鏌ヨ鏁版嵁搴撳悓姝ラ厤缃鎯�
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/get-syncconfig/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String getSyncConfigSyncConfig(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
+ SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ // 鍒ゆ柇uuid鏄惁涓虹┖
+ if (BaseUtil.strIsNull(fse.getString("uuid"))) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
+ }
+ FieldSetEntity fs = syncConfigService.getSyncConfig(fse);
+ return OK_List(fs);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.SYSTEM_GET_SYNC_CONFIG_FAIL.getValue(),
+ SystemCode.SYSTEM_GET_SYNC_CONFIG_FAIL.getText());
+ }
+ }
+
+ /**
+ * 鑾峰彇鏁版嵁鍚屾鏃ュ織
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/getSyncLog/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String getSyncLog(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
+ SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ // 鍒ゆ柇uuid鏄惁涓虹┖
+ if (BaseUtil.strIsNull(fse.getString("uuid"))) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
+ }
+ DataTableEntity dataTableEntity = syncConfigService.getSyncLog(fse);
+ return OK_List(dataTableEntity);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.GET_SYNC_LOG_FAIL.getValue(),
+ SystemCode.GET_SYNC_LOG_FAIL.getText());
+ }
+ }
+
+ /**
+ * 鑾峰彇鏁版嵁鍚屾鏃ュ織閿欒瀛愯〃
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/getSyncLogSub/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String getSyncLogSub(HttpServletRequest request) {
+ try {
+ // 鑾峰彇鍙傛暟
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ if (bean != null) {
+ RequestParameterEntity reqp = (RequestParameterEntity) bean;
+ fse = reqp.getFormData();
+ }
+ // 鍒ゆ柇鍙傛暟鏄惁涓虹┖
+ if (bean == null || fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
+ SystemCode.SYSTEM_FORM_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
+ }
+ // 鍒ゆ柇琛ㄥ悕鏄惁姝e父
+ if (!CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_LOG.equals(fse.getTableName())) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
+ }
+ // 鍒ゆ柇uuid鏄惁涓虹┖
+ if (BaseUtil.strIsNull(fse.getString("uuid"))) {
+ SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
+ SystemCode.SYSTEM_TABLE_NODATA.getText());
+ return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
+ }
+ DataTableEntity dataTableEntity = syncConfigService.getSyncLogSub(fse);
+ return OK_List(dataTableEntity);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(SystemCode.GET_SYNC_LOG_FAIL.getValue(),
+ SystemCode.GET_SYNC_LOG_FAIL.getText());
+ }
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/entity/SyncResultEntity.java b/product-server-data-sync/src/main/java/com/product/data/sync/entity/SyncResultEntity.java
new file mode 100644
index 0000000..428fb27
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/entity/SyncResultEntity.java
@@ -0,0 +1,72 @@
+package com.product.data.sync.entity;
+
+/**
+ * @Author cheng
+ * @Date 2022/1/27 14:12
+ * @Desc 鍚屾缁撴灉
+ */
+public class SyncResultEntity {
+
+
+ private int insertNumber = 0;
+
+ private int updateNumber = 0;
+
+ private int deleteNumber = 0;
+
+ private int errorNumber = 0;
+
+
+ public int getSuccessNumber() {
+ return insertNumber + updateNumber + deleteNumber;
+ }
+
+ public int getInsertNumber() {
+ return insertNumber;
+ }
+
+ public int getUpdateNumber() {
+ return updateNumber;
+ }
+
+ public int getDeleteNumber() {
+ return deleteNumber;
+ }
+
+ public int getErrorNumber() {
+ return errorNumber;
+ }
+
+ public void addNumber() {
+ insertNumber++;
+ }
+
+ public void addNumber(int number) {
+ insertNumber += number;
+ }
+
+ public void updateNumber() {
+ updateNumber++;
+ }
+
+ public void updateNumber(int number) {
+ updateNumber += number;
+ }
+
+
+ public void deleteNumber() {
+ deleteNumber++;
+ }
+
+ public void deleteNumber(int number) {
+ deleteNumber += number;
+ }
+
+ public void errorNumber() {
+ errorNumber++;
+ }
+
+ public void errorNumber(int number) {
+ errorNumber += number;
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/AvatarAndSignatureService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/AvatarAndSignatureService.java
new file mode 100644
index 0000000..a7e8852
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/AvatarAndSignatureService.java
@@ -0,0 +1,118 @@
+package com.product.data.sync.service;
+
+import com.google.common.collect.Maps;
+import com.product.common.lang.StringUtils;
+import com.product.core.config.Global;
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.entity.RequestParameterEntity;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.file.service.FileManagerService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.Map;
+
+/**
+ * Copyright 漏 6c
+ *
+ * @Date: 2022-04-06 10:55
+ * @Author: 6c
+ * @Description: 澶村儚鍜岀鍚�
+ */
+@Service
+public class AvatarAndSignatureService extends AbstractBaseService {
+ @Autowired
+ public BaseDao baseDao;
+ @Autowired
+ FileManagerService fileManagerService;
+
+ public void test() {
+ DataTableEntity sourceUserDte = new DataTableEntity();
+ FieldSetEntity sourceUserFse = new FieldSetEntity();
+ sourceUserFse.setTableName("tempTable");
+ sourceUserFse.setValue("SU00", "66");
+ sourceUserFse.setValue("SU28", "/servlet/ShowImageServlet?imagePath=D:/OA/FEGOV/Media/attachment/images/upload/users/test_avatar.png");
+ sourceUserFse.setValue("SU23", "/servlet/ShowImageServlet?imagePath=D:/OA/FEGOV/Media/attachment/images/upload/users/test_signature.png");
+ sourceUserDte.addFieldSetEntity(sourceUserFse);
+
+ Map<String, String> userMap = Maps.newHashMap();
+ userMap.put("66", "5849da43-ad80-44fc-b325-3a6a65ebe229");
+
+ String clientUUID = "1a7eb366-cf57-4ab0-818e-d2a13abf971d";
+
+ sync(sourceUserDte, userMap, clientUUID);
+ }
+
+ /**
+ * 鍚屾
+ * @param sourceUserDte 鏁版嵁婧愬簱鐨剈ser琛ㄦ暟鎹泦鍚�
+ * @param userMap 浜哄憳鏄犲皠锛孧ap<FE_BASE5.SYS_USERS.SU00,product_sys_users.uuid>
+ * @param clientUUID 瀹㈡埛uuid
+ */
+ public void sync(DataTableEntity sourceUserDte, Map<String, String> userMap, String clientUUID) {
+ FieldSetEntity sourceUserFse;
+ FieldSetEntity aimUserFse;
+ String avatarFileName;
+ String signatureFileName;
+ FieldSetEntity tempFse;
+ for (int i = 0;i < sourceUserDte.getRows();i++) {
+ sourceUserFse = sourceUserDte.getFieldSetEntity(i);
+
+ aimUserFse = new FieldSetEntity();
+ aimUserFse.setTableName("product_sys_users");
+ aimUserFse.setValue("uuid", userMap.get(sourceUserFse.getString("SU00")));
+
+ avatarFileName = getFileName(sourceUserFse.getString("SU28"));
+ tempFse = uploadFile(clientUUID, avatarFileName, "thumbnail_img");
+ aimUserFse.setValue("thumbnail_img", tempFse.getString("thumbnail_img"));
+
+ signatureFileName = getFileName(sourceUserFse.getString("SU23"));
+ tempFse = uploadFile(clientUUID, signatureFileName, "user_signature");
+ aimUserFse.setValue("user_signature", tempFse.getString("user_signature"));
+
+ baseDao.saveFieldSetEntity(aimUserFse);
+ }
+
+
+ }
+
+ /**
+ * 閫氳繃璺緞鑾峰彇鏂囦欢鍚嶇О
+ * @param path
+ * @return
+ */
+ public String getFileName(String path) {
+ return StringUtils.isEmpty(path) ? "" : path.substring(path.lastIndexOf("/") + 1);
+ }
+
+ /**
+ * 涓婁紶鏂囦欢
+ * @param clientUUID
+ * @param fileName
+ * @param aimFieldName
+ * @return
+ */
+ public FieldSetEntity uploadFile(String clientUUID, String fileName, String aimFieldName) {
+ String defaultDir = Global.getSystemConfig("avatar.signature.default.dir","");
+ File file = new File(defaultDir + File.separator + fileName);
+ FieldSetEntity aimUserFse;
+ RequestParameterEntity rpe = new RequestParameterEntity();
+ Map<String, File> fileMap;
+ // 琛ㄥ崟鏁版嵁
+ aimUserFse = new FieldSetEntity();
+ aimUserFse.setTableName("product_sys_users");
+ aimUserFse.setValue(aimFieldName, fileName);
+ aimUserFse.setValue("~field_name~", aimFieldName);
+ aimUserFse.setValue("client_uuid", clientUUID);
+ rpe.setFormData(aimUserFse);
+ // 鏂囦欢
+ fileMap = Maps.newHashMap();
+ fileMap.put(fileName, file);
+ rpe.setFiles(fileMap);
+ // 涓婁紶
+ return fileManagerService.uploadFile(rpe);
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/ConnectionConfigurationService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/ConnectionConfigurationService.java
new file mode 100644
index 0000000..dd18655
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/ConnectionConfigurationService.java
@@ -0,0 +1,457 @@
+package com.product.data.sync.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
+import com.product.common.lang.StringUtils;
+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.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.permission.PermissionService;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.core.service.support.QueryFilterService;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.core.transfer.Transactional;
+import com.product.data.sync.config.CmnConst;
+import com.product.data.sync.config.SystemCode;
+import com.product.data.sync.service.ide.IConnectionConfigurationService;
+import com.product.data.sync.util.DataManipulationUtils;
+import com.product.util.BaseUtil;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Copyright LX
+ *
+ * @Title: ConnectionConfigurationService
+ * @Project: product-server
+ * @date: 2021-08-11 16:35
+ * @author: luoxin
+ * @Description: 鏁版嵁搴撳悓姝ラ厤缃�
+ */
+@Service
+public class ConnectionConfigurationService extends AbstractBaseService implements IConnectionConfigurationService {
+ @Autowired
+ public BaseDao baseDao;
+ @Autowired
+ PermissionService permissionService;
+ @Autowired
+ QueryFilterService queryFilterService;
+
+ /**
+ * 鏁版嵁鍚屾杩炴帴閰嶇疆 --鏈湴鍚屾
+ *
+ * @param fse
+ * @throws BaseException
+ */
+ private void currentConnectionConfigTables(FieldSetEntity fse, String condition) throws BaseException {
+ BaseUtil.createCreatorAndCreationTime(fse);
+ baseDao.saveFieldSetEntity(fse);
+ String uuid = fse.getUUID();
+ DataTableEntity dt = baseDao.listTable("SELECT table_name,? as database_config_uuid from product_sys_datamodel_table_field_v where length(table_name)>0 " + condition + " GROUP BY table_name ", new Object[]{uuid});
+ dt.getMeta().setTableName(new Object[]{CmnConst.PRODUCT_SYS_DATABASE_TABLENAME_FIELD});
+ add(dt);
+ }
+
+
+ /**
+ * 鍚屾鏈簱瀛楁鍚�
+ *
+ * @param fse
+ * @param tableName 琛ㄥ悕
+ * @throws BaseException
+ */
+ private void currentConnectionConfigFields(FieldSetEntity fse, String tableName) throws BaseException {
+ BaseUtil.createCreatorAndCreationTime(fse);
+ if (!StringUtils.isEmpty(fse.getUUID())) {
+ // 鍒犻櫎宸插瓨鍦ㄧ殑閰嶇疆 閲嶆柊鎻掑叆鏈�鏂伴厤缃�
+ baseDao.delete(CmnConst.PRODUCT_SYS_DATABASE_TABLENAME_FIELD, "database_config_uuid=?", new Object[]{fse.getUUID()});
+ }
+ baseDao.saveFieldSetEntity(fse);
+ String uuid = fse.getUUID();
+
+ DataTableEntity dt = baseDao.listTable("SELECT table_name,field_name,? as database_config_uuid from product_sys_datamodel_table_field_v where table_name = ? ", new Object[]{uuid, tableName});
+ dt.getMeta().setTableName(new Object[]{CmnConst.PRODUCT_SYS_DATABASE_TABLENAME_FIELD});
+ add(dt);
+ }
+
+ @Override
+ @Transactional
+ public String saveConnectionConfiguration(FieldSetEntity fs) throws BaseException, SQLException, ClassNotFoundException {
+ String uuid = fs.getUUID();
+ Connection conn = this.runConnectionConfiguration(fs);
+ String sourceType = Global.getSystemConfig("data.source.type", "");
+ if (BaseUtil.strIsNull(uuid)) {
+ //鏁版嵁搴撶被鍨嬬浉鍚�
+ if (sourceType != null && sourceType.equalsIgnoreCase(fs.getString(CmnConst.DATABASE_TYPE))) {
+ if ("/".equals(fs.getString(CmnConst.IP_ADDRESS))) {
+ // 淇敼浜� product_sys_database_tablename_field 鐨勮〃缁撴瀯闇�瑕佷慨鏀� 姝ゆ柟娉�
+ this.currentConnectionConfigTables(fs, "");
+ return fs.getUUID();
+ }
+ }
+ fs.setValue("org_level_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());
+ fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fs.setValue("created_utc_datetime", new Date());
+
+ uuid = baseDao.add(fs);
+ if (conn != null) {
+ this.saveTableName(conn, fs, null);
+ } else {
+ throw new BaseException(SystemCode.GET_JDBC_CONNECT_FAIL.getValue(), SystemCode.GET_JDBC_CONNECT_FAIL.getText());
+ }
+ } else {
+ DataTableEntity sync_config = baseDao.listTable(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG, " database_config_uuid = ? ", new String[]{uuid});
+ if (BaseUtil.dataTableIsEmpty(sync_config)) {
+ //鐩存帴鍒犻櫎琛� 浠庢柊淇濆瓨琛ㄥ悕
+ baseDao.delete(CmnConst.PRODUCT_SYS_DATABASE_TABLENAME_FIELD, " database_config_uuid = ? ", new String[]{uuid});
+ //鏁版嵁搴撶被鍨嬬浉鍚�
+ if (sourceType != null && sourceType.equalsIgnoreCase(fs.getString(CmnConst.DATABASE_TYPE))) {
+ if ("/".equals(fs.getString(CmnConst.IP_ADDRESS))) {
+ // 淇敼浜� product_sys_database_tablename_field 鐨勮〃缁撴瀯闇�瑕佷慨鏀� 姝ゆ柟娉�
+ this.currentConnectionConfigTables(fs, "");
+ return fs.getUUID();
+ }
+ }
+ if (conn != null) {
+ this.saveTableName(conn, fs, null);
+ } else {
+ throw new BaseException(SystemCode.GET_JDBC_CONNECT_FAIL.getValue(), SystemCode.GET_JDBC_CONNECT_FAIL.getText());
+ }
+ fs.setValue("updated_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fs.setValue("updated_utc_datetime", new Date());
+ baseDao.update(fs);
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ throw new BaseException(e.toString(), "");
+ }
+ } else {
+ //宸插垱寤哄悓姝ョ殑琛ㄤ笉鏇存柊
+ List<String> originName = Lists.newArrayList();
+ for (int i = 0; i < sync_config.getRows(); i++) {
+ FieldSetEntity syncFse = sync_config.getFieldSetEntity(i);
+ originName.add(syncFse.getString(CmnConst.DATA_ORIGIN_NAME));
+ }
+ String and = BaseUtil.buildQuestionMarkFilter("", originName.toArray(), false);
+ //鍏堝垹闄ゅ叾浠栬〃
+ baseDao.delete(CmnConst.PRODUCT_SYS_DATABASE_TABLENAME_FIELD, " database_config_uuid = ? AND table_name " + and, new String[]{uuid});
+ //鏁版嵁搴撶被鍨嬬浉鍚�
+ if (sourceType != null && sourceType.equalsIgnoreCase(fs.getString(CmnConst.DATABASE_TYPE))) {
+ if ("/".equals(fs.getString(CmnConst.IP_ADDRESS))) {
+ // 淇敼浜� product_sys_database_tablename_field 鐨勮〃缁撴瀯闇�瑕佷慨鏀� 姝ゆ柟娉�
+ this.currentConnectionConfigTables(fs, " and table_name " + and);
+ return fs.getUUID();
+ }
+ }
+ if (conn != null) {
+ this.saveTableName(conn, fs, and);
+ } else {
+ throw new BaseException(SystemCode.GET_JDBC_CONNECT_FAIL.getValue(), SystemCode.GET_JDBC_CONNECT_FAIL.getText());
+ }
+ }
+ baseDao.update(fs);
+ }
+ return uuid;
+ }
+
+ //鑾峰彇琛ㄥ悕鍜屽瓧娈靛悕
+ public void saveTableNameAndFieldName(Connection con, FieldSetEntity fs) throws BaseException {
+ String uuid = fs.getString(CmnConst.UUID);
+ String databaseType = fs.getString(CmnConst.DATABASE_TYPE);//鏁版嵁搴撶被鍨�
+ String sql;
+ if ("mysql".equals(databaseType)) { //鏁版嵁搴撳悕绉�
+ sql = "select TABLE_NAME,COLUMN_NAME from information_schema.COLUMNS WHERE TABLE_SCHEMA = '" + fs.getString(CmnConst.DATABASE_NAME) + "'";
+ } else if ("oracle".equals(databaseType)) { //鐢ㄦ埛鍚� 鍒嗗ぇ灏忓啓
+ sql = "select TABLE_NAME,COLUMN_NAME from all_tab_columns";
+ } else if ("sqlserver".equals(databaseType)) { //鏁版嵁搴撳悕绉�
+ sql = "SELECT a.name TABLE_NAME,b.name COLUMN_NAME FROM " + fs.getString(CmnConst.DATABASE_NAME) + "..SysObjects a " +
+ "LEFT JOIN " + fs.getString(CmnConst.DATABASE_NAME) + "..SysColumns b ON a.id = b.id Where a.XType='U' " +
+ "ORDER BY a.name ";
+ } else if ("informix".equals(databaseType)) { //鏁版嵁搴撳悕绉�
+ sql = "SELECT t.tabname TABLE_NAME,c.colname COLUMN_NAME" +
+ " FROM \"informix\".systables AS t\n" +
+ " JOIN \"informix\".syscolumns AS c ON t.tabid = c.tabid\n" +
+ " WHERE t.tabtype = 'T'\n" +
+ " AND t.tabid >= 100\n" +
+ " ORDER BY t.tabname,c.colno;";
+ } else {
+ throw new BaseException(SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getValue(), SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getText());
+ }
+ try {
+ PreparedStatement ps = con.prepareStatement(sql);
+ ResultSet resultSet = ps.executeQuery();
+ while (resultSet.next()) {
+ FieldSetEntity field = new FieldSetEntity();
+ field.setTableName(CmnConst.PRODUCT_SYS_DATABASE_TABLENAME_FIELD);
+ field.setValue(CmnConst.DATABASE_CONFIG_UUID, uuid);
+ //琛ㄥ悕
+ field.setValue(CmnConst.TABLE_NAME, resultSet.getString("TABLE_NAME"));
+ //瀛楁鍚�
+ field.setValue(CmnConst.FIELD_NAME, resultSet.getString("COLUMN_NAME"));
+ baseDao.add(field);
+ }
+ } catch (SQLException e) {
+ try {
+ con.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new BaseException(SystemCode.GET_DATA_SOURCE_FAIL.getValue(), SystemCode.GET_DATA_SOURCE_FAIL.getText() + ex.getMessage());
+ }
+ throw new BaseException(SystemCode.GET_DATA_SOURCE_FAIL.getValue(), SystemCode.GET_DATA_SOURCE_FAIL.getText() + e.getMessage());
+ }
+ }
+
+ //鑾峰彇骞朵繚瀛樿〃鍚�
+ public void saveTableName(Connection con, FieldSetEntity fs, String condition) throws BaseException {
+ String uuid = fs.getString(CmnConst.UUID);
+ String databaseType = fs.getString(CmnConst.DATABASE_TYPE);//鏁版嵁搴撶被鍨�
+ String sql;
+ if ("mysql".equals(databaseType)) { //鏁版嵁搴撳悕绉�
+ if (!BaseUtil.strIsNull(condition)) {
+ condition = " AND TABLE_NAME " + condition;
+ }
+ sql = "select TABLE_NAME from information_schema.COLUMNS WHERE TABLE_SCHEMA = '" + fs.getString(CmnConst.DATABASE_NAME) + "' " + condition + " GROUP BY TABLE_NAME";
+ } else if ("oracle".equals(databaseType)) { //鐢ㄦ埛鍚� 鍒嗗ぇ灏忓啓
+ if (!BaseUtil.strIsNull(condition)) {
+ condition = " AND TABLE_NAME " + condition;
+ }
+ sql = "select TABLE_NAME from all_tab_columns WHERE OWNER = '" + fs.getString(CmnConst.USER_NAME) + "' " + condition + " GROUP BY TABLE_NAME ";
+ } else if ("sqlserver".equals(databaseType)) { //鏁版嵁搴撳悕绉�
+ if (!BaseUtil.strIsNull(condition)) {
+ condition = " AND name" + condition;
+ }
+ sql = "SELECT name TABLE_NAME FROM " + fs.getString(CmnConst.DATABASE_NAME) + "..SysObjects Where XType='U' " + condition;
+ } else if ("informix".equals(databaseType)) { //鏁版嵁搴撳悕绉�
+ if (!BaseUtil.strIsNull(condition)) {
+ condition = " AND tabname " + condition;
+ }
+ sql = "SELECT tabname TABLE_NAME FROM \"informix\".systables WHERE tabtype = 'T' AND tabid >= 100 " + condition;
+ } else {
+ throw new BaseException(SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getValue(), SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getText());
+ }
+ try {
+ PreparedStatement ps = con.prepareStatement(sql);
+ SpringMVCContextHolder.getSystemLogger().info("鎵цsql:\n\t" + sql);
+ ResultSet resultSet = ps.executeQuery();
+ while (resultSet.next()) {
+ FieldSetEntity field = new FieldSetEntity();
+ field.setTableName(CmnConst.PRODUCT_SYS_DATABASE_TABLENAME_FIELD);
+ field.setValue(CmnConst.DATABASE_CONFIG_UUID, uuid);
+ //鍙彇琛ㄥ悕
+ field.setValue(CmnConst.TABLE_NAME, resultSet.getString("TABLE_NAME"));
+ //瀛楁鍚�
+// field.setValue(CmnConst.FIELD_NAME,resultSet.getString("COLUMN_NAME"));
+ baseDao.add(field);
+ }
+ } catch (SQLException e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ SpringMVCContextHolder.getSystemLogger().info("鎵цsql閿欒:\n\t" + sql);
+ try {
+ con.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new BaseException(SystemCode.GET_DATA_SOURCE_FAIL.getValue(), SystemCode.GET_DATA_SOURCE_FAIL.getText() + ex.getMessage());
+ }
+ throw new BaseException(SystemCode.GET_DATA_SOURCE_FAIL.getValue(), SystemCode.GET_DATA_SOURCE_FAIL.getText() + e.getMessage());
+ }
+ }
+
+ /**
+ * 鏌ヨ鏁版嵁婧愬簱 鑾峰彇骞朵繚瀛樺瓧娈靛悕
+ *
+ * @param fs
+ * @return
+ * @throws BaseException
+ */
+ @Transactional
+ @Override
+ public Boolean saveField(FieldSetEntity fs) throws BaseException, SQLException, ClassNotFoundException {
+ //琛ㄥ悕
+ String tableName = fs.getString(CmnConst.TABLE_NAME);
+ //鏁版嵁搴撹繛鎺uid
+ String databaseConfigUuid = fs.getString(CmnConst.DATABASE_CONFIG_UUID);
+ //鑾峰彇杩炴帴閰嶇疆
+ FieldSetEntity configField = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG, databaseConfigUuid, false);
+ //鏁版嵁搴撶被鍨�
+ String databaseType = configField.getString(CmnConst.DATABASE_TYPE);
+ //鑾峰彇鏁版嵁婧愯繛鎺�
+ Connection con = this.runConnectionConfiguration(configField);
+ String sourceType = Global.getSystemConfig("data.source.type", "");
+ if (sourceType != null && sourceType.equalsIgnoreCase(configField.getString(CmnConst.DATABASE_TYPE))) {
+ if ("/".equals(configField.getString(CmnConst.IP_ADDRESS))) {
+ // 淇敼浜� product_sys_database_tablename_field 鐨勮〃缁撴瀯闇�瑕佷慨鏀� 姝ゆ柟娉�
+ this.currentConnectionConfigFields(configField, tableName);
+ return true;
+ }
+ }
+ String sql;
+ if ("mysql".equals(databaseType)) { //鏁版嵁搴撳悕绉�
+ sql = "select COLUMN_NAME from information_schema.COLUMNS WHERE TABLE_SCHEMA = '" + configField.getString(CmnConst.DATABASE_NAME) + "' AND TABLE_NAME = '" + tableName + "'";
+ } else if ("oracle".equals(databaseType)) { //鐢ㄦ埛鍚� 鍒嗗ぇ灏忓啓
+ sql = "select COLUMN_NAME from all_tab_columns WHERE OWNER = '" + configField.getString(CmnConst.USER_NAME) + "' AND TABLE_NAME = '" + tableName + "'";
+ } else if ("sqlserver".equals(databaseType)) {
+ //鏁版嵁搴撳悕绉�
+ sql = "SELECT name TABLE_NAME FROM " + fs.getString(CmnConst.DATABASE_NAME) + "..SysColumns WHERE id = ( " +
+ " SELECT id FROM " + fs.getString(CmnConst.DATABASE_NAME) + "..SysObjects WHERE XType='U' and name = '" + tableName + "')";
+ } else if ("informix".equals(databaseType)) { //鏁版嵁搴撳悕绉�
+ sql = " SELECT colname COLUMN_NAME from \"informix\".syscolumns where tabid = ( " +
+ " SELECT tabid FROM \"informix\".systables WHERE tabname = '" + tableName + "'); ";
+ } else {
+ throw new BaseException(SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getValue(), SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getText());
+ }
+
+ try {
+ PreparedStatement ps = con.prepareStatement(sql);
+ ResultSet resultSet = ps.executeQuery();
+ //鍒ゆ柇鏀硅〃鍚嶆槸鍚﹂渶瑕佹坊鍔犲瓧娈�
+// if(resultSet.getRow() > 0) {
+ //鍏堝垹闄や箣鍓嶇殑鏁版嵁
+ baseDao.delete(CmnConst.PRODUCT_SYS_DATABASE_TABLENAME_FIELD, " database_config_uuid = ? and table_name = ? ", new String[]{databaseConfigUuid, tableName});
+ while (resultSet.next()) {
+// String fieldName = fs.getString(CmnConst.FIELD_NAME);
+// if (BaseUtil.strIsNull(fieldName)) {
+// fs.setValue(CmnConst.FIELD_NAME, resultSet.getString("COLUMN_NAME"));
+// baseDao.update(fs);
+// continue;
+// }
+ FieldSetEntity field = new FieldSetEntity();
+ field.setTableName(CmnConst.PRODUCT_SYS_DATABASE_TABLENAME_FIELD);
+ field.setValue(CmnConst.DATABASE_CONFIG_UUID, databaseConfigUuid);
+ //琛ㄥ悕
+ field.setValue(CmnConst.TABLE_NAME, tableName);
+ //瀛楁鍚�
+ field.setValue(CmnConst.FIELD_NAME, resultSet.getString("COLUMN_NAME"));
+ //鍐嶆坊鍔犳柊鐨勬暟鎹�
+ baseDao.add(field);
+ }
+// }
+ } catch (SQLException e) {
+ try {
+ con.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new BaseException(SystemCode.GET_DATA_SOURCE_FAIL.getValue(), SystemCode.GET_DATA_SOURCE_FAIL.getText() + ex.getMessage());
+ }
+ throw new BaseException(SystemCode.GET_DATA_SOURCE_FAIL.getValue(), SystemCode.GET_DATA_SOURCE_FAIL.getText() + e.getMessage());
+ }
+ return true;
+ }
+
+ @Override
+ public DataTableEntity listConnectionConfiguration(FieldSetEntity fs) throws BaseException {
+ String queryFilter;
+ if (BaseUtil.dataTableIsEmpty(fs.getSubDataTable("systemSeniorQueryString"))) {
+ queryFilter = "";
+ } else {
+ queryFilter = queryFilterService.getQueryFilter(fs);
+ }
+ DataTableEntity dt = baseDao.listTable(CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG, queryFilter, null, null, null, fs.getInteger(CmnConst.PAGESIZE), fs.getInteger(CmnConst.CPAGE));
+
+ return dt;
+ }
+
+ @Override
+ public FieldSetEntity getConnectionConfiguration(FieldSetEntity fs) throws BaseException {
+ return baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG, fs.getUUID(), false);
+ }
+
+ @Override
+ @Transactional
+ public boolean delConnectionConfiguration(FieldSetEntity fs) throws BaseException {
+ String uuid = fs.getUUID();
+ String[] uuids = uuid.split(",");
+ DataTableEntity dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG, BaseUtil.buildQuestionMarkFilter(CmnConst.DATABASE_CONFIG_UUID, uuids.length, true), uuids);
+ if (BaseUtil.dataTableIsEmpty(dataTableEntity)) {
+ //鍒犻櫎璇ヨ繛鎺ュ搴旂殑琛ㄥ悕璺熷瓧娈靛悕
+ baseDao.delete(CmnConst.PRODUCT_SYS_DATABASE_TABLENAME_FIELD, BaseUtil.buildQuestionMarkFilter(CmnConst.DATABASE_CONFIG_UUID, uuids.length, true), uuids);
+ //鍒犻櫎杩炴帴閰嶇疆
+ return baseDao.delete(CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG, uuids);
+ } else {
+ throw new BaseException(SystemCode.SYNC_EXISTING_CONFIGURATION_FAIL.getValue(), SystemCode.SYNC_EXISTING_CONFIGURATION_FAIL.getText());
+ }
+ }
+
+ public Connection runConnectionConfiguration(FieldSetEntity fs) throws BaseException, SQLException, ClassNotFoundException {
+ String databaseType = fs.getString(CmnConst.DATABASE_TYPE);//鏁版嵁搴撶被鍨�
+ String ipAddress = fs.getString(CmnConst.IP_ADDRESS);//ip鍦板潃
+ String databaseName = fs.getString(CmnConst.DATABASE_NAME);//鏁版嵁搴撳悕绉�
+ String portNumber = fs.getString(CmnConst.PORT_NUMBER);//绔彛鍙�
+ String userName = fs.getString(CmnConst.USER_NAME);//鐢ㄦ埛鍚�
+ String userPassword = fs.getString(CmnConst.USER_PASSWORD);//瀵嗙爜
+ String instantiation = fs.getString(CmnConst.INSTANTIATION);//瀹炰緥鍚�
+ String url;
+ String diver;
+ String sourceType = Global.getSystemConfig("data.source.type", "");
+ if (sourceType != null && sourceType.equalsIgnoreCase(fs.getString(CmnConst.DATABASE_TYPE))) {
+ if ("/".equals(fs.getString(CmnConst.IP_ADDRESS))) {
+ return ConnectionManager.getConnection();
+ }
+ }
+// if("null".equals(databaseType) && !BaseUtil.strIsNull(jdbcConnect)){
+// url = jdbcConnect;
+// if(jdbcConnect.contains("mysql")){
+// diver = "com.mysql.cj.jdbc.Driver";
+// }else if(jdbcConnect.contains("oracle")){
+// diver = "oracle.jdbc.driver.OracleDriver";
+// }else if(jdbcConnect.contains("sqlserver")){
+// diver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
+// }else{
+// throw new BaseException("", "");
+// }
+// }else
+ if ("mysql".equals(databaseType)) {
+ diver = "com.mysql.cj.jdbc.Driver";
+ url = "jdbc:mysql://" + ipAddress + ":" + portNumber + "/" + databaseName + "?useSSL=false&serverTimezone=UTC";
+ } else if ("oracle".equals(databaseType)) {
+ diver = "oracle.jdbc.driver.OracleDriver";
+ url = "jdbc:oracle:thin:@" + ipAddress + ":" + portNumber + ":orcl";
+ } else if ("sqlserver".equals(databaseType)) {
+ diver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
+ url = "jdbc:sqlserver://" + ipAddress + ":" + portNumber + ";DataBaseName=" + databaseName;
+ } else if ("informix".equals(databaseType)) {
+ diver = "com.informix.jdbc.IfxDriver";
+ url = "jdbc:informix-sqli://" + ipAddress + ":" + portNumber + "/" + databaseName + ":informixserver=" + instantiation;
+ } else {
+ throw new BaseException(SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getValue(), SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getText());
+ }
+
+ //鑾峰彇jdbc杩炴帴
+ return DataManipulationUtils.getConnection(diver, url, userName, userPassword);
+ }
+
+ public JSONArray getSyncTree() throws BaseException {
+ DataTableEntity dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG);
+ JSONArray linkArray = new JSONArray();
+ for (int i = 0; i < dataTableEntity.getRows(); i++) {
+ JSONObject configObject = new JSONObject();
+ FieldSetEntity fieldSetEntity = dataTableEntity.getFieldSetEntity(i);
+ String uuid = fieldSetEntity.getUUID();
+ configObject.put("uuid", uuid);//uuid
+ configObject.put("label", fieldSetEntity.getString("connect_name"));//杩炴帴鍚嶇О
+
+ JSONArray syncArray = new JSONArray();
+ DataTableEntity syncData = baseDao.listTable(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG, " database_config_uuid = ? ", new String[]{uuid});
+ for (int j = 0; j < syncData.getRows(); j++) {
+ JSONObject jsonObject = new JSONObject();
+ FieldSetEntity syncField = syncData.getFieldSetEntity(j);
+ jsonObject.put("uuid", syncField.getString("uuid"));
+ jsonObject.put("label", syncField.getString("system_table_name"));
+ syncArray.add(jsonObject);
+ }
+ configObject.put("children", syncArray);
+ linkArray.add(configObject);
+ }
+ return linkArray;
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/FeDataDSService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/FeDataDSService.java
new file mode 100644
index 0000000..2470002
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/FeDataDSService.java
@@ -0,0 +1,1017 @@
+package com.product.data.sync.service;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.io.IoUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.product.admin.service.CodeService;
+import com.product.common.lang.StringUtils;
+import com.product.core.config.Global;
+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.data.sync.config.CmnConst;
+import com.product.data.sync.util.DataManipulationUtils;
+import com.product.file.service.FileManagerService;
+import com.product.module.sys.service.UserService;
+import com.product.org.admin.service.SystemOrgLevelsService;
+import com.product.org.admin.service.idel.ISystemOrgLevelsService;
+import com.product.util.BaseDaoServiceImpl;
+import com.product.util.BaseUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributeView;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Component
+public class FeDataDSService extends AbstractBaseService {
+
+ @Autowired
+ public BaseDao baseDao;
+ @Autowired
+ private UserService userService;
+ @Autowired
+ private CodeService codeService;
+ @Autowired
+ private SystemOrgLevelsService systemOrgLevelsService;
+
+ @Autowired
+ public FunctionSynchrService functionSynchrService;
+ @Autowired
+ FileManagerService fileManagerService;
+
+ //涓存椂鏂囦欢璺緞
+ private static String TSPath = Global.getSystemConfig("new.filePackage","");
+ private static String testString = "^(\\d{0,4}`)|(\\d{0,3}\\^\\d{0,4}`)";
+ private static String startWith = "FE#ENC#";
+ private int[] intPosition = new int[64];
+ //鎴戜滑浜у搧鐨勫姛鑳芥潈闄�
+ private String[] functionCode = {"001-004-000-000","001-004-000-001","001-004-000-002","001-004-000-003","001-004-000-004",
+ "001-006-006-000","001-006-002-000","001-006-000-000","001-006-001-000",
+ "001-006-001-001","001-006-000-001", "001-006-002-001" ,"001-006-002-002","001-006-004-000",
+ "001-006-003-000","001-006-002-003","001-006-003-001","001-006-003-002","001-006-003-003",
+ "001-006-004-001","001-006-003-004","001-006-003-005","001-006-003-006","001-006-006-001",
+ "001-006-008-000","001-006-008-001","001-006-008-002", "001-006-008-003","001-006-008-004",
+ "001-006-008-005","001-006-008-006", "001-006-000-003", "001-006-011-000","001-006-011-001",
+ "001-008-001-001","001-008-001-000","001-008-001-003"};
+
+ private Integer sort = 0;
+ //鍏徃鍜岄儴闂╩ap key 涓哄叕鍙告垨閮ㄩ棬鍏ㄧО
+ Map<String, FieldSetEntity> institutionMap = Maps.newHashMap();
+ public Connection getJDBC() throws SQLException, ClassNotFoundException {
+ //鑾峰彇jdbc杩炴帴
+// String diver = "oracle.jdbc.driver.OracleDriver";
+// String url = "jdbc:oracle:thin:@10.0.0.21:1521:orcl";
+// return DataManipulationUtils.getConnection(diver, url, "FE_BASE5", "fe123");
+ //鑾峰彇jdbc杩炴帴
+ String diver = Global.getSystemConfig("data.synchronism.function.jdbc.diver", "");
+ String url = Global.getSystemConfig("data.synchronism.function.jdbc.url", "");
+ String name = Global.getSystemConfig("data.synchronism.function.jdbc.name", "");
+ String password = Global.getSystemConfig("data.synchronism.function.jdbc.password", "");
+ return DataManipulationUtils.getConnection(diver, url, name, password);
+ }
+
+
+ public String FEDataMigration(){
+ String clientUUID = "";
+ try {
+ //admin鍒濆鍖栧鎴峰強瑙掕壊
+ clientUUID = this.initializeClients();
+ //鍚屾鍏徃閮ㄩ棬
+ this.syncDepartmentCompany();
+ //灏佽鍏徃閮ㄩ棬map
+ this.packInstitutionMap();
+ //鍚屾宀椾綅绛夌骇鍜屽矖浣�
+ this.synchronousPost();
+ //鍚屾瑙掕壊
+ this.synchronousRole();
+ //鍚屾绠$悊鍛�
+ this.syncManager(clientUUID);
+ //鍚屾浜哄憳
+ this.addEmployees(clientUUID);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ return clientUUID;
+ }
+
+ /**
+ * 鍒濆鍖栧鎴峰強瀹㈡埛瑙掕壊(淇敼瀹㈡埛涓篎E鐨勫鎴峰悕绉�)
+ * @return
+ * @throws SQLException
+ * @throws ClassNotFoundException
+ */
+ public String initializeClients() throws SQLException, ClassNotFoundException {
+ FieldSetEntity grouoFs = null;
+ Connection conn = this.getJDBC();
+ try {
+ grouoFs = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.SYS_GROUP", "SG10=1", new Object[]{});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ //鏌ヨ鍘熷鎴� 鏀逛负瑗垮畞
+ FieldSetEntity tableFs = baseDao.getFieldSetEntityByFilter("product_sys_clients", " client_code = ? ", new String[]{"001"},false);
+ if (tableFs==null) {
+ throw new BaseException("500", "瀹㈡埛琛ㄦ病鏈�001鐨勬暟鎹�");
+ }
+ //鍘熷鎴峰悕绉�
+ String clientName = tableFs.getString("client_name");
+ tableFs.setValue("client_name", grouoFs.getString("sg01"));
+ String clientUUID = tableFs.getUUID();
+ //鏌ヨ鍘熷鎴风殑瑙掕壊 鏀逛负瑗垮畞
+ FieldSetEntity roleFs = baseDao.getFieldSetEntityByFilter("product_sys_role", " role_name = ? ", new String[]{clientName}, false);
+ roleFs.setValue("role_name", grouoFs.getString("sg01"));
+ //淇敼瑙掕壊
+ baseDao.update(roleFs);
+ //淇敼瀹㈡埛
+// tableFs.setCodeFieldUpdateFlat("client_code", true);
+ baseDao.update(tableFs);
+ return clientUUID;
+ }
+
+ /**
+ * 鍚屾鍗曚綅绠$悊鍛�
+ */
+ public void syncManager(String clientUUID) throws SQLException, ClassNotFoundException {
+ Connection conn = this.getJDBC();
+ DataTableEntity managerData;
+ try {
+ //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛�
+ StringBuffer sql = new StringBuffer();
+ sql.append(" SELECT A.*,REPLACE(REPLACE(REPLACE(A.SU03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), ")
+ .append(" '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/'),'/','>') ASU03 FROM ")
+ .append(" FE_BASE5.SYS_USERS A WHERE A.SU31 = 2 ");
+ //浜哄憳鏁版嵁
+ managerData = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{});
+ this.syncManager(managerData, clientUUID);
+ } catch (Exception e) {
+ throw e;
+ }
+ }
+
+ /**
+ * 鍚屾绠$悊鍛�
+ * @param managerData 绠$悊鍛樼敤鎴锋暟鎹�
+ */
+ public void syncManager(DataTableEntity managerData,String clientUUID){
+ if(!BaseUtil.dataTableIsEmpty(managerData)) {
+ for (int i = 0; i < managerData.getRows(); i++) {
+ FieldSetEntity userFs = new FieldSetEntity();
+ FieldSetEntity fse = managerData.getFieldSetEntity(i);
+ userFs.setTableName("product_sys_users");
+ String su01 = fse.getString("su01");
+ userFs.setValue("user_name", su01);
+ userFs.setValue("user_account",su01);
+ userFs.setValue("gender", 1);
+ userFs.setValue("user_pwd", userService.createPassWord(su01, "123"));
+ userFs.setValue("is_manager", 1);
+ userFs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ userFs.setValue("created_utc_datetime", new Date());
+ userFs.setValue("status", 1);
+
+ //鏂板绠$悊鍛�
+ String usersUUID = baseDao.add(userFs);
+ FieldSetEntity users = baseDao.getFieldSetEntity("product_sys_users", usersUUID, false);
+ FieldSetEntity managerFs = new FieldSetEntity();
+ managerFs.setTableName("product_sys_org_manager");
+ managerFs.setValue("user_id", users.getString("user_id"));
+ //浼佷笟绠$悊鍛�
+ managerFs.setValue("manager_type", "2");
+ managerFs.setValue("role_uuids", "eabb00f3-2118-4165-967b-a7d88f472f67-notchange");
+ managerFs.setValue("is_used", 1);
+ managerFs.setValue("clients_uuid", clientUUID);
+ managerFs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ managerFs.setValue("created_utc_datetime", new Date());
+ //閲嶆柊缁勮鍚庣殑缁勭粐鍏ㄧО
+ String uuid = this.getSuperiorCompanyUuid(fse.getString("asu03"));
+ managerFs.setValue("org_level_uuid", uuid);
+ baseDao.add(managerFs);
+ }
+
+ }
+ }
+
+
+ /**
+ * 鍚屾鍏徃閮ㄩ棬
+ */
+ public void syncDepartmentCompany() throws SQLException, ClassNotFoundException {
+
+ //鍚屾缁勭粐鏈烘瀯鏁版嵁瀛樻斁闆嗗悎
+ DataTableEntity groupLeadersFs;
+ Connection conn = this.getJDBC();
+ try {
+ StringBuffer sql = new StringBuffer();
+ sql.append("SELECT A.*,REPLACE(REPLACE(A.SG03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/') ASG03 FROM ( ")
+ .append( "SELECT * FROM FE_BASE5.SYS_GROUP WHERE length(SG10) > 3 or SG10 = '001' ORDER BY SG10) A ORDER BY SG10");
+ //鑾峰彇闇�瑕佸悓姝ョ殑缁勭粐鏈烘瀯
+ groupLeadersFs = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{});
+ } catch (Exception e) {
+ throw e;
+ }
+ DataManipulationUtils.close(null, null, conn);
+
+ //鍒涘缓椤剁骇鍏徃
+ //鑾峰彇FE椤剁骇鍏徃
+ FieldSetEntity topCompanies = groupLeadersFs.getFieldSetEntity(0);
+ //鑾峰彇浜у搧001椤剁骇鍏徃
+ FieldSetEntity field = baseDao.getFieldSetEntityByFilter("product_sys_org_levels", " org_level_code = 001 ", null,false);
+ //鏇存柊鍏徃鍚嶇О锛屽叕鍙哥煭缂栫爜锛屽叕鍙告帓搴�
+ field.setValue("org_level_name", topCompanies.getString("sg01"));
+ field.setValue("org_level_shortcode", topCompanies.getString("sg10"));
+ field.setValue("sequence", topCompanies.getString("sg00"));
+// field.setCodeFieldUpdateFlat("org_level_code", true);
+
+ //浜嬬墿璋冪敤锛屼繚瀛樺叕鍙镐俊鎭�
+ ISystemOrgLevelsService service=(ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService);
+ service.updateCompany(field);
+
+// FieldSetEntity topField = this.addCompany(topCompanies,null, null);
+ institutionMap.put(field.getString("org_level_all"),field);
+
+ //閬嶅巻fe鏋舵瀯鏁版嵁 瀛樺叆缁勭粐鏋舵瀯淇℃伅琛�
+ for (int i = 1; i < groupLeadersFs.getRows(); i++) {
+
+ FieldSetEntity levelFs = groupLeadersFs.getFieldSetEntity(i);
+ //鑾峰彇FE琛ㄧ粍缁囨満鏋勫叏绉�
+ String asg03 = levelFs.getString("asg03");
+ //鎴彇涓轰笂绾у叕鍙哥浉鍚岀殑鍏ㄧО
+ String level_all = asg03.substring(0,asg03.lastIndexOf("/"));
+ //鏇挎崲涓轰竴鏍风殑绗﹀彿鏂逛究瀵规瘮
+ level_all = level_all.replace("/", ">");
+ //鑾峰彇涓婄骇鍏徃鎴栭儴闂�
+ FieldSetEntity fieldSet = institutionMap.get(level_all);
+ //涓婄骇鍏徃uuid
+ String org_level_uuid = this.getSuperiorCompanyUuid(level_all);
+ if(fieldSet == null){
+ throw new BaseException("涓婄骇涓虹┖","鏃犳硶鑾峰彇涓婄骇code");
+ }
+ if(org_level_uuid == null){
+ throw new BaseException("涓婄骇鍏徃涓虹┖","涓婄骇鍏徃uuid");
+ }
+ //涓婄骇鍏徃code
+ String org_level_code = fieldSet.getString("org_level_code");
+ FieldSetEntity fse;
+// levelFs.setCodeFieldUpdateFlat("org_level_code", true);
+ //杩涘叆鏂板鍏徃鏂规硶
+ if(levelFs.getInteger("sg14") == 1){
+ fse = this.addCompany(levelFs,org_level_code,org_level_uuid);
+ //杩涘叆鏂板閮ㄩ棬鏂规硶
+ }else {
+ fse = this.addDepartment(levelFs, org_level_code, org_level_uuid);
+ }
+ institutionMap.put(fse.getString("org_level_all"), fse);
+ }
+
+// //鍒涘缓瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�涓嬮儴闂紙鍔炲叕瀹わ級
+// FieldSetEntity fse = new FieldSetEntity();
+// //閮ㄩ棬鍚嶇О,,
+// fse.setValue("org_level_name", "鍔炲叕瀹�");
+// //閮ㄩ棬缂栫爜
+// fse.setValue("org_level_shortcode", "001002");
+// //鑾峰彇涓婄骇鍏徃鎴栭儴闂�
+// FieldSetEntity fieldSet = institutionMap.get("瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�");
+// FieldSetEntity fs = this.addDepartment(fse,fieldSet.getString("org_level_code"), fieldSet.getUUID());
+// institutionMap.put(fs.getString("org_level_all"), fs);
+ }
+
+ /**
+ * 鍚屾宀椾綅鍜屽矖浣嶇瓑绾�
+ */
+ public void synchronousPost() throws SQLException, ClassNotFoundException {
+
+ Connection conn = this.getJDBC();
+ DataTableEntity groupLeadersFs;
+ try {
+ //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛�
+ StringBuffer sql = new StringBuffer();
+ sql.append(" SELECT SR00,SR01,SR02,SR10, SR15, ")
+ .append(" REPLACE(REPLACE(REPLACE(SR03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), ")
+ .append(" '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/'),'/','>') ASR03 FROM fe_base5.SYS_ROLE ");
+ //1涓哄叕鍙�
+ groupLeadersFs = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{});
+ } catch (Exception e) {
+
+ throw e;
+ }
+ DataManipulationUtils.close(null, null, conn);
+ //鍚屾宀椾綅绛夌骇
+ this.postGrades(groupLeadersFs);
+ this.addPost(groupLeadersFs);
+ }
+
+ /**
+ * 鍚屾瑙掕壊
+ */
+ public void synchronousRole()throws SQLException, ClassNotFoundException{
+ Connection conn = this.getJDBC();
+ DataTableEntity roleData;
+ try {
+ //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛�
+ StringBuffer sql = new StringBuffer();
+ sql.append(" select * from fe_base5.SYS_POPEDOM_TEMPLET a left join fe_base5.SYS_POPEDOM_TEMP_SUB b on a.SPT00=b.STS01 ");
+ //浜哄憳鏁版嵁
+ roleData = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{});
+
+ } catch (Exception e) {
+ throw e;
+ }
+ DataManipulationUtils.close(null, null, conn);
+ this.synchronousRole(roleData);
+
+ }
+
+ /**
+ * 鍒濆鍖栧熀鏈潈闄�
+ */
+ public void packageButton(String role_uuid){
+ StringBuffer sql = new StringBuffer();
+ String tricodeIn = BaseUtil.buildQuestionMarkFilter("tricode", this.functionCode, true);
+ sql.append(" SELECT function_uuid,group_concat(uuid SEPARATOR ',') button_uuid FROM product_sys_function_buttons WHERE function_uuid IN ( ")
+ .append(" SELECT uuid FROM product_sys_functions WHERE ")
+ .append(tricodeIn).append(" ) GROUP BY function_uuid ");
+ DataTableEntity dataTableEntity = baseDao.listTable(sql.toString(),new String[]{});
+ for (int i = 0; i < dataTableEntity.getRows(); i++) {
+ FieldSetEntity fieldSetEntity = new FieldSetEntity();
+ fieldSetEntity.setTableName("product_sys_function_permission");
+ fieldSetEntity.setValue("function_uuid", dataTableEntity.getString(i,"function_uuid"));
+ fieldSetEntity.setValue("button_uuid", dataTableEntity.getString(i,"button_uuid"));
+ fieldSetEntity.setValue("role_uuid", role_uuid);
+ baseDao.add(fieldSetEntity);
+ }
+ }
+
+ /**
+ * 鍚屾浜哄憳
+ */
+ public void addEmployees(String clientUUID) throws SQLException, ClassNotFoundException {
+
+ Connection conn = this.getJDBC();
+ DataTableEntity personnelData;
+ try {
+ //鑾峰彇宀椾綅 淇敼/ 涓�> 鏂逛究閫傞厤鎴戜滑鏁版嵁琛�
+ StringBuffer sql = new StringBuffer();
+// sql.append(" SELECT A.*,REPLACE(REPLACE(REPLACE(A.SU03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), ")
+// .append(" '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/'),'/','>') ASU03 FROM ")
+// .append(" FE_BASE5.SYS_USERS A WHERE A.SU39 is not null and A.SU35 is not null AND A.SU03 IS NOT NULL ");
+ sql.append(" SELECT A.*,REPLACE(REPLACE(REPLACE(A.SU03, '/瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�', ''), ")
+ .append(" '瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/灞�灞炲悇鍗曚綅/','瑗垮畞甯備綇鎴夸繚闅滃拰鎴夸骇绠$悊灞�/'),'/','>') ASU03 FROM ")
+ .append(" FE_BASE5.SYS_USERS A WHERE SU39 IS NOT NULL");
+ //浜哄憳鏁版嵁
+ personnelData = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{});
+ } catch (Exception e) {
+ throw e;
+ }
+ DataManipulationUtils.close(null, null, conn);
+ this.addEmployees(personnelData,clientUUID);
+ }
+
+ /**
+ * 閫掑綊鑾峰彇涓婄骇鍏徃uuid
+ * @param level_all 涓婄骇鍏徃鍏ㄧО
+ * @return 淇濆瓨鍚庤繑鍥炰繚瀛樺悗鐨� fse
+ */
+ public String getSuperiorCompanyUuid(String level_all){
+ FieldSetEntity fieldSet = institutionMap.get(level_all);
+ if(fieldSet == null){
+ return null;
+ }
+ //涓婄骇涓哄叕鍙�
+ if("0".equals(fieldSet.getString("org_level_type"))){
+ return fieldSet.getUUID();
+ }else {
+ Integer index = level_all.lastIndexOf(">");
+ if(index == -1){
+ return null;
+ }
+ level_all = level_all.substring(0,index);
+ return this.getSuperiorCompanyUuid(level_all);
+ }
+ }
+
+
+ /**
+ * 淇濆瓨鍏徃
+ * @param fse 鍏徃fes
+ * @param code_parent 鍏徃涓婄骇code
+ * @return 淇濆瓨鍚庤繑鍥炰繚瀛樺悗鐨� fse
+ */
+ public FieldSetEntity addCompany(FieldSetEntity fse, String code_parent, String org_level_uuid){
+ FieldSetEntity levelsFs = new FieldSetEntity();
+ levelsFs.setTableName("product_sys_org_levels");
+ //閮ㄩ棬鍚嶇О,,
+ levelsFs.setValue("org_level_name", fse.getString("sg01"));
+
+ //鍏徃娈电紪鐮�
+ levelsFs.setValue("org_level_shortcode", fse.getString("sg10"));
+ //鍏徃鎺掑簭
+ levelsFs.setValue("sequence", ++sort);
+ //鏀惧叆涓婄骇code 鐢熸垚code
+ levelsFs.setValue("org_level_code_parent", code_parent);
+ //涓婄骇鍏徃uuid
+ levelsFs.setValue("org_level_uuid", org_level_uuid);
+ ISystemOrgLevelsService service=(ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService);
+// levelsFs.setCodeFieldUpdateFlat("org_level_code", true);
+ service.addCompany(levelsFs);
+ return levelsFs;
+ }
+
+ /**
+ * 淇濆瓨閮ㄩ棬
+ * @param fse 鍏徃fes
+ * @param code_parent 鍏徃涓婄骇code
+ * @return 淇濆瓨鍚庤繑鍥炰繚瀛樺悗鐨� fse
+ */
+ public FieldSetEntity addDepartment(FieldSetEntity fse, String code_parent, String org_level_uuid){
+ FieldSetEntity levelsFs = new FieldSetEntity();
+ levelsFs.setTableName("product_sys_org_levels");
+ //閮ㄩ棬鍚嶇О,,
+ levelsFs.setValue("org_level_name", fse.getString("sg01"));
+ //閮ㄩ棬缂栫爜
+ levelsFs.setValue("org_level_shortcode", fse.getString("sg10"));
+ //鍏徃鎺掑簭
+ levelsFs.setValue("sequence", fse.getString("sg00"));
+ //鏀惧叆涓婄骇code 鐢熸垚code
+ levelsFs.setValue("org_level_code_parent", code_parent);
+ //涓婄骇鍏徃uuid
+ levelsFs.setValue("org_level_uuid", org_level_uuid);
+ ISystemOrgLevelsService service=(ISystemOrgLevelsService) getProxyInstance(systemOrgLevelsService);
+// levelsFs.setCodeFieldUpdateFlat("org_level_code", true);
+ service.addDepartment(levelsFs);
+ return levelsFs;
+ }
+ /**
+ * 灏佽鍏徃閮ㄩ棬鍏ㄧО Map
+ */
+ public void packInstitutionMap()throws BaseException {
+ DataTableEntity dataTableEntity = baseDao.listTable("SELECT * FROM product_sys_org_levels WHERE org_level_code like ? ", new String[]{"%001%"});
+ if(!BaseUtil.dataTableIsEmpty(dataTableEntity)) {
+ for (int i = 0; i < dataTableEntity.getRows(); i++) {
+ FieldSetEntity fieldSetEntity = dataTableEntity.getFieldSetEntity(i);
+ String org_level_all = fieldSetEntity.getString("org_level_all");
+ institutionMap.put(org_level_all, fieldSetEntity);
+ }
+ }else {
+ throw new BaseException("鏈煡璇㈠埌鍗曚綅閮ㄩ棬鏁版嵁", "鏈煡璇㈠埌鍗曚綅閮ㄩ棬鏁版嵁");
+ }
+ }
+
+ /**
+ * 鍚屾瑙掕壊
+ */
+ public void synchronousRole(DataTableEntity data){
+ for (int i = 0; i < data.getRows(); i++) {
+ FieldSetEntity rolesFs = data.getFieldSetEntity(i);
+ String sts02s = rolesFs.getString("sts02");
+ FieldSetEntity levelsField = baseDao.getFieldSetEntityByFilter("product_sys_org_levels", " org_level_shortcode = ? ", new String[]{sts02s}, false);
+ //鏈変簺瑙掕壊鍏宠仈鐨勫崟浣嶆垨閮ㄩ棬宸茬粡琚垹闄ゆ帀,浣嗘槸瑙掕壊杩樹繚鐣欎粬鐨勭紪鐮� 鐩存帴璺宠繃
+ if(levelsField == null){
+ continue;
+ }
+ FieldSetEntity lxRoleFs = new FieldSetEntity();
+ lxRoleFs.setTableName("product_sys_role");
+ lxRoleFs.setValue("org_level_uuid",levelsField.getUUID());
+ lxRoleFs.setValue("role_name", rolesFs.getString("spt01"));
+ lxRoleFs.setValue("role_description", rolesFs.getString("spt02"));
+ lxRoleFs.setValue("is_used", 1);
+ lxRoleFs.setValue("sequence", rolesFs.getInteger("spt00"));
+ this.userAndTime(lxRoleFs);
+ String role_uuid = baseDao.add(lxRoleFs);
+
+ //璇ヨ鑹插垵濮嬪寲鏉冮檺
+ this.packageButton(role_uuid);
+ }
+ }
+
+ /**
+ * 娣诲姞鐢ㄦ埛鍜屽憳宸�
+ */
+ public void addEmployees(DataTableEntity data,String clientUUID){
+ //fe 浜哄憳id 瀵瑰簲 userid
+ JSONObject idUserMap = new JSONObject();
+ //鑾峰彇瀹㈡埛uuid
+ FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntityByFilter("product_sys_org_levels", " org_level_code = ? ", new String[]{"001"}, false);
+ String client_uuid = fieldSetEntity.getString("client_uuid");
+
+ Map<String, FieldSetEntity> staffsMap = Maps.newHashMap();
+ for (int i = 0; i < data.getRows(); i++) {
+ FieldSetEntity userFs = data.getFieldSetEntity(i);
+ FieldSetEntity usersFs = new FieldSetEntity();
+ //鍒涘缓 user 鏁版嵁
+ usersFs.setTableName("product_sys_users");
+ //鐢ㄦ埛鍚�
+ usersFs.setValue("user_name", userFs.getString("su02"));
+ //鎻忚堪
+ usersFs.setValue("user_account", userFs.getString("su01"));
+ //閭
+ usersFs.setValue("user_primary_email", userFs.getString("su11"));
+ //鎬у埆杞崲
+ String su16 = userFs.getString("su16");
+ String sex = null;
+ if (su16 != null) {
+ sex = su16.equals("鐢�") ? "0" : "1";
+ }
+ usersFs.setValue("gender", sex);
+ //鐢ㄦ埛鐢佃瘽
+ usersFs.setValue("user_mobile_number", userFs.getString("su10"));
+ //鍐呯嚎鐢佃瘽
+ usersFs.setValue("inside_phone", userFs.getString("su13"));
+ //鍦板潃
+ usersFs.setValue("contact_address", userFs.getString("su18"));
+ //鍒濆鍖栫敤鎴峰瘑鐮�
+ usersFs.setValue("user_pwd", userService.createPassWord(userFs.getString("su01"), "123"));
+ //鏄惁鏄鐞嗗憳 0:鍚� 1:鏄�
+ usersFs.setValue("is_manager", 0);
+ //鍔炲叕鐢佃瘽
+ usersFs.setValue("office_phone", userFs.getString("su09"));
+ this.userAndTime(usersFs);
+ //鐘舵�� 0锛氱鐢� 1锛氭甯�
+ usersFs.setValue("status", userFs.getString("su08"));
+ //绛惧悕
+ String su23 = userFs.getString("su23");
+ if (!BaseUtil.strIsNull(su23)) {
+ usersFs.setValue("user_signature", this.signatureAndThumbnail(su23, clientUUID,"user_signature"));
+ }
+ //澶村儚
+ String su28 = userFs.getString("su28");
+ if (!BaseUtil.strIsNull(su28)) {
+ usersFs.setValue("thumbnail_img", this.signatureAndThumbnail(su28, clientUUID,"thumbnail_img"));
+ }
+
+ String usersUUID = baseDao.add(usersFs);
+ FieldSetEntity users = baseDao.getFieldSetEntity("product_sys_users", usersUUID, false);
+ //fe鐢ㄦ埛id 鍏宠仈绯荤粺琛�"product_sys_users锛塽ser_id
+ idUserMap.put(userFs.getString("su00"), users.getString("user_id"));
+
+ if (BaseUtil.strIsNull(userFs.getString("su03")) || BaseUtil.strIsNull(userFs.getString("su35")) || BaseUtil.strIsNull(userFs.getString("su39"))) {
+ continue;
+ }
+
+ FieldSetEntity staffsFs = new FieldSetEntity();
+ //鍛樺伐琛�
+ staffsFs.setTableName("product_sys_staffs");
+ //鐢ㄦ埛琛╥d
+ staffsFs.setValue("user_id", users.getString("user_id"));
+ //鏄剧ず鍚嶇О
+ staffsFs.setValue("show_name", userFs.getString("su02"));
+ //鍛樺伐鍚�
+ staffsFs.setValue("given_name", userFs.getString("su02"));
+ //鍛樺伐濮�
+ staffsFs.setValue("family_name", userFs.getString("su02"));
+ //閭
+ staffsFs.setValue("email_address", userFs.getString("su11"));
+ //绉诲姩鐢佃瘽
+ staffsFs.setValue("mobile_phone", userFs.getString("su10"));
+ //鍔炲叕鐢佃瘽
+ staffsFs.setValue("office_telephone", userFs.getString("su09"));
+
+ //鍛樺伐鎬у埆
+ staffsFs.setValue("sex", sex);
+ //鍛樺伐閭
+ String su11 = userFs.getString("su11");
+ //閭涓虹┖鍏堣1
+ if(BaseUtil.strIsNull(su11)){
+ su11 = "1";
+ }
+ staffsFs.setValue("staff_email", su11);
+ //鐘舵�侊細0鍑嗗鍏ヨ亴 1璇曠敤 2鍑嗗杞 3鍦ㄨ亴 4鍋滆亴 5鍑嗗绂昏亴 6绂昏亴 7閫�浼�
+ staffsFs.setValue("staff_status", 3);
+
+ staffsFs.setValue("client_uuid", client_uuid);
+ //閲嶆柊缁勮鍚庣殑缁勭粐鍏ㄧО
+ FieldSetEntity fieldSet = institutionMap.get(userFs.getString("asu03"));
+ String uuid = this.getSuperiorCompanyUuid(userFs.getString("asu03"));
+ //鍏徃uuid
+ staffsFs.setValue("org_level_uuid", uuid);
+ //閮ㄩ棬uuid
+ staffsFs.setValue("dept_uuid", fieldSet.getUUID());
+
+ if (null == userFs.getString("su34")) {
+ //宀椾綅uuid
+ staffsFs.setValue("job_post_uuid", 1);
+ //宀椾綅绛夌骇uuid
+ staffsFs.setValue("job_post_grade_uuid",1);
+ } else {
+ //閫氳繃宀椾綅id鏌ヨ宀椾綅
+ String su34 = userFs.getString("su34");
+ FieldSetEntity fsePosts = baseDao.getFieldSetEntityByFilter("product_sys_job_posts", " sequence = ? ", new Integer[]{Integer.parseInt(su34)}, false);
+ if(fsePosts != null) {
+ staffsFs.setValue("job_post_uuid", fsePosts.getUUID());
+ staffsFs.setValue("job_post_grade_uuid", fsePosts.getString("job_post_grades_uuid"));
+ }else {
+ throw new BaseException("鏈煡璇㈠埌宀椾綅","鏈煡璇㈠埌宀椾綅");
+ }
+ }
+ //su35鍏宠仈鏉冮檺id, 鍏宠仈澶氫釜閫楀彿鍒嗛殧
+ String su35 = userFs.getString("su35");
+ String[] su35s = null;
+ if(!BaseUtil.strIsNull(su35)){
+ su35s = su35.split(",");
+ for (int j = 0; j < su35s.length; j++) {
+ FieldSetEntity fse = baseDao.getFieldSetEntityByFilter("product_sys_role", " sequence = ? ", new Integer[]{Integer.parseInt(su35s[j])}, false);
+ su35s[j] = fse.getUUID();
+ }
+ }
+ //鐩村睘棰嗗
+ String su40 = userFs.getString("su40");
+ //涓虹┖灏辨斁绌�
+ if(BaseUtil.strIsNull(su40)){
+ su40 = "";
+ }else {
+ //澶氫釜鐩村睘棰嗗 灏卞彇绗竴涓�
+ if(su40.contains(",")){
+ su40 = su40.substring(0,su40.indexOf(","));
+ }
+ }
+ staffsFs.setValue("direct_leader_code",su40);
+ if(su35s != null) {
+ staffsFs.setValue("role_uuids", StringUtils.join(su35s, ","));
+ }
+ //鍛樺伐涓婁笅绾х紪鐮�
+ staffsFs.setValue("leader_tricode", codeService.createFixCode(CmnConst.PRODUCT_SYS_STAFFS, CmnConst.LEADER_TRICODE, ""));
+ //鍛樺伐缂栫爜 鍛樺伐鍘熸湰id 瀛樹负缂栫爜
+ staffsFs.setValue("tricode",codeService.createFixCode(CmnConst.PRODUCT_SYS_STAFFS, CmnConst.TRICODE, fieldSet.getString("org_level_code")));
+ String su00 = userFs.getString("su00");
+ staffsFs.setValue("sequence", su00);
+ staffsFs.setValue("remark", su00);
+ this.userAndTime(staffsFs);
+ baseDao.add(staffsFs);
+ staffsMap.put(su00, staffsFs);
+ }
+ //sql淇敼鐩村睘棰嗗
+ baseDao.executeUpdate(" UPDATE product_sys_staffs a INNER JOIN product_sys_staffs b ON a.remark = b.direct_leader_code SET b.direct_leader_code = a.tricode ");
+ //寰幆鍚屾鐩村睘棰嗗, 鑻ユ湁涓や釜鐩村睘棰嗗 鍙彇绗竴涓�
+// for(String su00 : staffsMap.keySet()){
+// FieldSetEntity staffsFs = staffsMap.get(su00);
+// //鑾峰彇鐩村睘棰嗗
+// String direct_leader_code = staffsFs.getString("direct_leader_code");
+// if(!BaseUtil.strIsNull(direct_leader_code)){
+// FieldSetEntity staffs1;
+// if(direct_leader_code.contains(",")){
+// String su001 = direct_leader_code.substring(0,direct_leader_code.indexOf(","));
+// staffs1 = staffsMap.get(su001);
+// }else {
+// staffs1 = staffsMap.get(direct_leader_code);
+// }
+// if(staffs1 != null){
+// String tricode = staffs1.getString("tricode");
+// if(!BaseUtil.strIsNull(tricode)){
+// staffsFs.setValue("direct_leader_code",tricode);
+// baseDao.update(staffsFs);
+// }
+// }else {
+// staffsFs.setValue("direct_leader_code","");
+// baseDao.update(staffsFs);
+// }
+// }
+// }
+ }
+
+ public String signatureAndThumbnail(String su,String clientUUID, String field){
+ try {
+ String[] path = su.split("=");
+ String filePath = path[1];
+ String fileName = StringUtils.isEmpty(filePath) ? "" : filePath.substring(filePath.lastIndexOf("/") + 1);
+ String newPath = this.TSPath + File.separator + fileName;
+ File isField = new File(newPath);
+ //濡傛灉宸茬粡鏈夎鏂囦欢 鏀瑰彉鏂囦欢鐩綍
+ Integer fileNum = 0;
+ while (isField.exists()) {
+ fileNum++;
+ newPath = this.TSPath + fileNum + File.separator + fileName;
+ isField = new File(newPath);
+ }
+ //澶嶅埗鍒颁复鏃剁洰褰曚笅
+ if (this.copyFile(filePath, newPath)) {
+ RequestParameterEntity rpe = new RequestParameterEntity();
+ Map<String, File> fileMap = Maps.newHashMap();
+ //閫氳繃璺緞鑾峰彇File
+ File file = new File(newPath);
+ //鏂囦欢鍚� 鏂囦欢file
+ fileMap.put(fileName, file);
+ FieldSetEntity fieldSet = new FieldSetEntity();
+ FieldMetaEntity f = new FieldMetaEntity();
+ f.setTableName(new String[]{"product_sys_users"});
+ fieldSet.setMeta(f);
+ fieldSet.setValue(field, fileName);
+ fieldSet.setValue("~field_name~", field);
+ //鏀惧叆瀹㈡埛uuid
+ fieldSet.setValue("client_uuid", clientUUID);
+ rpe.setFiles(fileMap);
+ rpe.setFormData(fieldSet);
+ try {
+ FieldSetEntity fileFse = fileManagerService.uploadFile(rpe);
+ return fileFse.getString(field);
+ } catch (Exception e) {
+ e.getStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ }
+ }
+ }catch (Exception e){
+ e.getStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * 娣诲姞宀椾綅
+ */
+ public void addPost(DataTableEntity data){
+ DataTableEntity dataTableEntity = new DataTableEntity();
+ dataTableEntity.getMeta().setTableName(new String[]{"product_sys_job_posts"});
+ for (int i = 0; i < data.getRows(); i++) {
+ FieldSetEntity fieldSetEntity = data.getFieldSetEntity(i);
+ FieldSetEntity field = new FieldSetEntity();
+ field.setTableName("product_sys_job_posts");
+ field.setValue("is_used", 1);
+ field.setValue("job_post_name", fieldSetEntity.getString("sr01"));
+ field.setValue("job_post_description", fieldSetEntity.getString("sr02"));
+ //閫氳繃鍏ㄧО鑾峰彇鍗曚綅鍜岄儴闂╱uid
+ String org_level_all = fieldSetEntity.getString("asr03");
+ FieldSetEntity fieldSetEntity1 = institutionMap.get(org_level_all);
+ //鍏徃uuid
+ String org_level_uuid = this.getSuperiorCompanyUuid(org_level_all);
+ field.setValue("org_level_uuid",org_level_uuid);
+ //鏈烘瀯绫诲瀷 0 鍏徃 1閮ㄩ棬
+ String orgLevelType = fieldSetEntity1.getString("org_level_type");
+ //鏌ヨ宀椾綅绛夌骇
+ String sr15 = fieldSetEntity.getString("sr15");
+ FieldSetEntity fieldSet = baseDao.getFieldSetEntityByFilter("product_sys_job_post_grades", " org_level_uuid = ? and job_grade_class = ? ", new String[]{org_level_uuid,sr15},false);
+ //宀椾綅绛夌骇
+ String postGradesUuid = fieldSet.getUUID();
+ field.setValue("job_post_grades_uuid", postGradesUuid);
+ //鎺掑簭鏆傛椂瀛樺矖浣峣d 鏂逛究浜哄憳鏌ヨ鍒板矖浣峣d
+ Integer sequence = fieldSetEntity.getInteger("sr00");
+ field.setValue("sequence",sequence);
+ this.userAndTime(field);
+ String org_uuid = fieldSetEntity1.getUUID();
+ String code = fieldSetEntity1.getString("org_level_code");
+ //0涓哄叕鍙� 鑻ヤ负鍏徃灏卞垱寤哄涓浉鍚屽矖浣嶆潵鍏宠仈鍏徃涓嬫墍鏈夐儴闂�
+ if("0".equals(orgLevelType)){
+ DataTableEntity dataTable = baseDao.listTable("product_sys_org_levels", " org_level_type = 1 and org_level_uuid = ? ", new String[]{org_uuid});
+ if(!BaseUtil.dataTableIsEmpty(dataTable)) {
+ for (int j = 0; j < dataTable.getRows(); j++) {
+ field.setValue("dept_uuid",dataTable.getString(j, "uuid"));
+ field.remove("uuid");
+ //閫氳繃鏂板鏂规硶娣诲姞宀椾綅
+ String uuid = baseDao.add(field);
+ //娣诲姞宀椾綅涓庡矖浣嶇瓑绾у叧绯绘槧灏勬暟鎹〃
+ FieldSetEntity postsAndClass = new FieldSetEntity();
+ postsAndClass.setTableName("product_sys_job_posts_grades_mapping");
+ //宀椾綅绛夌骇uuid
+ postsAndClass.setValue("job_grade_uuid", postGradesUuid);
+ //宀椾綅uuid
+ postsAndClass.setValue("job_post_uuid", uuid);
+ this.userAndTime(postsAndClass);
+ baseDao.add(postsAndClass);
+ }
+ }else {
+ //鍗曚綅涓嬭嫢娌℃湁閮ㄩ棬 鍒涘缓涓�涓櫄鎷熼儴闂�
+ FieldSetEntity departmentFse = new FieldSetEntity();
+ departmentFse.setTableName("product_sys_org_levels");
+ //閮ㄩ棬鍚嶇О
+ departmentFse.setValue("sg01", fieldSetEntity1.getString("org_level_name") + "涓嬮儴闂�");
+ //閮ㄩ棬缂栫爜
+ departmentFse.setValue("sg10", fieldSetEntity1.getString("org_level_shortcode") + "01");
+ //鎺掑簭
+ departmentFse.setValue("sg00", fieldSetEntity1.getString("sequence") + "01");
+ //淇濆瓨鍚庣殑閮ㄩ棬
+ FieldSetEntity newDeptFse = this.addDepartment(departmentFse,code,org_uuid);
+ //鏀惧叆閮ㄩ棬uuid
+ field.setValue("dept_uuid",newDeptFse.getUUID());
+ //閫氳繃鏂板鏂规硶娣诲姞宀椾綅
+ String uuid = baseDao.add(field);
+ //娣诲姞宀椾綅涓庡矖浣嶇瓑绾у叧绯绘槧灏勬暟鎹〃
+ FieldSetEntity postsAndClass = new FieldSetEntity();
+ postsAndClass.setTableName("product_sys_job_posts_grades_mapping");
+ //宀椾綅绛夌骇uuid
+ postsAndClass.setValue("job_grade_uuid", postGradesUuid);
+ //宀椾綅uuid
+ postsAndClass.setValue("job_post_uuid", uuid);
+ this.userAndTime(postsAndClass);
+ baseDao.add(postsAndClass);
+ }
+ //1涓洪儴闂�
+ }else{
+ field.setValue("dept_uuid",org_uuid);
+ //閫氳繃鏂板鏂规硶娣诲姞宀椾綅
+ String uuid = baseDao.add(field);
+ //娣诲姞宀椾綅涓庡矖浣嶇瓑绾у叧绯绘槧灏勬暟鎹〃
+ FieldSetEntity postsAndClass = new FieldSetEntity();
+ postsAndClass.setTableName("product_sys_job_posts_grades_mapping");
+ //宀椾綅绛夌骇uuid
+ postsAndClass.setValue("job_grade_uuid", postGradesUuid);
+ //宀椾綅uuid
+ postsAndClass.setValue("job_post_uuid", uuid);
+ this.userAndTime(postsAndClass);
+ baseDao.add(postsAndClass);
+ }
+ }
+ }
+
+ /**
+ * 娣诲姞鍒涘缓浜哄拰鍒涘缓鏃堕棿
+ * @param fieldSetEntity
+ */
+ public void userAndTime(FieldSetEntity fieldSetEntity){
+ fieldSetEntity.setValue("created_by",SpringMVCContextHolder.getCurrentUserId());
+ fieldSetEntity.setValue("created_utc_datetime",new Date());
+ }
+ /**
+ * 娣诲姞宀椾綅绛夌骇
+ */
+ public void postGrades(DataTableEntity data){
+ //鍏徃uuid 宀椾綅灞傜骇闆�
+ Map<String,String> postHierarchyMap = Maps.newHashMap();
+ //閫氳繃鍏徃uuid鏉ュ垝鍒嗗矖浣嶇瓑绾�
+ for (int i = 0; i < data.getRows(); i++) {
+ FieldSetEntity fieldSetEntity = data.getFieldSetEntity(i);
+ FieldSetEntity field = new FieldSetEntity();
+ field.setTableName("product_sys_job_post_grades");
+ //宀椾綅灞傜骇 瓒婂皬绛夌骇瓒婂ぇ
+ String sr15 = fieldSetEntity.getString("sr15");
+ //杞崲鍚庨儴闂ㄦ垨鍏徃鍏ㄧО
+ String dcName = fieldSetEntity.getString("asr03");
+ //鑾峰彇鍏徃鐨剈uid
+ String companyUuid = this.getSuperiorCompanyUuid(dcName);
+ String value = postHierarchyMap.get(companyUuid);
+ if(!BaseUtil.strIsNull(value)){
+ if(value.contains(sr15)) {
+ continue;
+ }else {
+ postHierarchyMap.put(companyUuid, value+","+sr15);
+ }
+ }else {
+ postHierarchyMap.put(companyUuid, sr15);
+ }
+ FieldSetEntity levelsSet = baseDao.getFieldSetEntity("product_sys_org_levels",companyUuid,false);
+ //鍏徃鍚嶇О
+ String levelName = levelsSet.getString("org_level_name");
+ //涓婄骇鍏徃uuid
+ field.setValue("org_level_uuid",companyUuid);
+ //宀椾綅绛夌骇
+ field.setValue("job_grade_class", sr15);
+ field.setValue("is_used", 1);
+ //鍚嶇О
+ field.setValue("job_grade_name",sr15+"绾у矖浣�");
+ //绾у埆鐭紪鐮�
+ field.setValue("job_grade_shortcode", sr15);
+ //璇存槑
+ field.setValue("remark", levelName+"涓嬬殑"+sr15+"绾у矖浣�");
+ field.setValue("sequence", sr15);
+ this.userAndTime(field);
+ baseDao.add(field);
+ }
+ }
+ /** 澶嶅埗鍗曚釜鏂囦欢
+ * @param oldPath String 鍘熸枃浠惰矾寰� 濡傦細c:/fqf.txt
+ * @param newPath String 澶嶅埗鍚庤矾寰� 濡傦細f:/fqf.txt
+ * @return boolean
+ */
+ public Boolean copyFile(String oldPath, String newPath) {
+ Boolean status = false;
+ try {
+ BufferedInputStream in = FileUtil.getInputStream(oldPath);
+ BufferedOutputStream out = FileUtil.getOutputStream(newPath);
+ IoUtil.copy(in, out, IoUtil.DEFAULT_BUFFER_SIZE);
+ status = true;
+ out.close();
+ in.close();
+ }catch (Exception e){
+ e.getStackTrace();
+ }finally {
+ return status;
+ }
+ }
+
+ /** 鍒犻櫎鍗曚釜鏂囦欢
+ * @param fileName 琚垹闄ゆ枃浠剁殑鏂囦欢鍚�
+ * @return 鍗曚釜鏂囦欢鍒犻櫎鎴愬姛杩斿洖true,鍚﹀垯杩斿洖false
+ */
+ public Boolean deleteFile(String fileName){
+ File file = new File(fileName);
+ if(file.isFile()){
+ file.delete();
+ System.out.println("鍒犻櫎鍗曚釜鏂囦欢"+fileName+"鎴愬姛锛�");
+ return true;
+ }else{
+ System.out.println("鍒犻櫎鍗曚釜鏂囦欢"+fileName+"澶辫触锛�");
+ return false;
+ }
+ }
+
+ public static void main(String[] args) {
+// File file = new File("D:\\filePackage\\瑗垮畞甯備綇鎴夸繚闅滃拰鎴垮眿绠$悊灞�闇�姹傛暣鐞哣1.0.docx");
+// File file2 = new File("D:\\filePackage\\瑗垮畞甯備綇鎴夸繚闅滃拰鎴垮眿绠$悊.docx");
+// System.out.println(file.exists());
+// System.out.println(file2.exists());
+// FeDataDSService feDataDSService = new FeDataDSService();
+// feDataDSService.copyFile("D:\\OA\\FEGOV\\Media\\2021\\12\\15\\20211215401901\\1`FE#ENC#DA126AF35BB8E57F55C2429BDF7DC7240DF6CC6E227B0B8E", "D:\\filePackage\\????????????????????????.doc");
+// feDataDSService.getFilesFolder("D:\\OA\\FEGOV\\Media\\2021\\12\\15\\20211215401901");
+ }
+
+ /**
+ * 鑾峰彇鏂囦欢鍚嶇О 鏈�鏂颁慨鏀规椂闂� map
+ * @param path
+ * @return
+ */
+ public Map<String, String> getFilesFolder(String path){
+ File file = new File(path); //鑾峰彇鍏秄ile瀵硅薄
+ File[] fs = file.listFiles();
+ if(fs == null){
+ logger.info("鏈壘鍒伴檮浠剁洿鎺ヨ繑鍥瀗ull");
+ return null;
+ }
+ Map<String, String> fileTimeName = Maps.newHashMap();
+ for(File f:fs)
+ {
+ if(f.isFile())
+ {
+ String fileName = f.toString().replace(path+"\\","");
+ fileTimeName.put(this.set_fileInfo(f.toString()),fileName);
+ }
+ }
+ return fileTimeName;
+ }
+
+ /**
+ * 鑾峰彇鏂囦欢鏈�杩戜慨鏀规椂闂�
+ * @param file_name 鏂囦欢鍏ㄨ矾寰�
+ * @return
+ */
+ public String set_fileInfo(String file_name)
+ {
+ Path path = Paths.get(file_name);
+ BasicFileAttributeView basicview = Files.getFileAttributeView(path, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
+ BasicFileAttributes attr;
+ String time = null;
+ try
+ {
+
+ attr = basicview.readAttributes();
+ //鍒涘缓鏃堕棿
+ Date CreateTimeDate= new Date(attr.creationTime().toMillis());
+ //涓婃淇敼鏃堕棿 *
+ Date lastmodfiyTimeDate=new Date(attr.lastModifiedTime().toMillis());
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ time = df.format(lastmodfiyTimeDate);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return time;
+ }
+
+ public void clearJobList(){
+ DataTableEntity dataTableEntity = baseDao.listTable("product_sys_flow_node"," default_posts is not null AND default_posts != '' ",new String[]{});
+ for (int i = 0; i < dataTableEntity.getRows(); i++) {
+ FieldSetEntity fse = dataTableEntity.getFieldSetEntity(i);
+ String default_posts = fse.getString("default_posts");
+ if(!BaseUtil.strIsNull(default_posts)){
+ String[] postUuids = default_posts.split(",");
+ Set<String> postSet = Sets.newHashSet();
+// Set<String> postSet = Arrays.stream(postUuids).collect(Collectors.toSet());
+ for (int j = 0; j < postUuids.length; j++) {
+ DataTableEntity staffsData = baseDao.listTable("product_sys_staffs"," job_post_uuid = ? ",new String[]{postUuids[j]});
+ //鏈変汉灏变繚鐣欏矖浣島uid
+ if(!BaseUtil.dataTableIsEmpty(staffsData)){
+ postSet.add(postUuids[j]);
+ }
+ }
+ if(postSet.size() > 0){
+ fse.setValue("default_posts", StringUtils.join(postSet, ","));
+ }else {
+ fse.setValue("default_posts", null);
+ }
+ baseDao.update(fse);
+ }
+ }
+ //娓呯┖澶氫綑鐨勫矖浣嶆暟鎹�
+ baseDao.executeUpdate("DELETE FROM product_sys_job_posts WHERE uuid not in (SELECT job_post_uuid FROM product_sys_staffs);");
+ //宀椾綅鍏宠仈
+ baseDao.executeUpdate("DELETE FROM product_sys_job_posts_grades_mapping WHERE job_post_uuid not in (SELECT job_post_uuid FROM product_sys_staffs);");
+ }
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/FunctionSynchrService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/FunctionSynchrService.java
new file mode 100644
index 0000000..fb0be28
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/FunctionSynchrService.java
@@ -0,0 +1,249 @@
+package com.product.data.sync.service;
+
+import com.alibaba.fastjson.JSONObject;
+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.exception.BaseException;
+import com.product.core.permission.PermissionService;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.core.service.support.QueryFilterService;
+import com.product.core.transfer.Transactional;
+import com.product.data.sync.config.SystemCode;
+import com.product.data.sync.service.ide.IFunctionSynchrService;
+import com.product.data.sync.util.DataManipulationUtils;
+import com.product.util.BaseDaoServiceImpl;
+import com.product.util.BaseUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+
+/**
+ * Copyright LX
+ *
+ * @Title: FunctionSynchrService
+ * @Project: product-server
+ * @date: 2021-08-30 14:19
+ * @author: ZhouJie
+ * @Description: 寮�鍙戝簱鍔熻兘鍚屾
+ */
+@Service
+public class FunctionSynchrService extends AbstractBaseService implements IFunctionSynchrService {
+
+ @Autowired
+ public BaseDao baseDao;
+ @Autowired
+ PermissionService permissionService;
+ @Autowired
+ QueryFilterService queryFilterService;
+
+ /**
+ * 鑾峰彇JDBC杩炴帴
+ *
+ * @param fs
+ * @return
+ * @throws BaseException
+ */
+ public Connection getConnection(FieldSetEntity fs) throws BaseException, SQLException, ClassNotFoundException {
+ String databaseType = fs.getString("type");//鏁版嵁搴撶被鍨�
+ String ipAddress = fs.getString("IP");//ip鍦板潃
+ String databaseName = fs.getString("database_name");//鏁版嵁搴撳悕绉�
+ String portNumber = fs.getString("port");//绔彛鍙�
+ String userName = fs.getString("username");//鐢ㄦ埛鍚�
+ String userPassword = fs.getString("password");//瀵嗙爜
+ String instantiation = fs.getString("");//瀹炰緥鍚�
+ String url;
+ String diver;
+ if ("mysql".equals(databaseType)) {
+ diver = "com.mysql.cj.jdbc.Driver";
+ url = "jdbc:mysql://" + ipAddress + ":" + portNumber + "/" + databaseName + "?useSSL=false&serverTimezone=UTC";
+ } else if ("oracle".equals(databaseType)) {
+ diver = "oracle.jdbc.driver.OracleDriver";
+ url = "jdbc:oracle:thin:@" + ipAddress + ":" + portNumber + ":orcl";
+ } else if ("sqlserver".equals(databaseType)) {
+ diver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
+ url = "jdbc:sqlserver://" + ipAddress + ":" + portNumber + ";DataBaseName=" + databaseName;
+ } else if ("informix".equals(databaseType)) {
+ diver = "com.informix.jdbc.IfxDriver";
+ url = "jdbc:informix-sqli://" + ipAddress + ":" + portNumber + "/" + databaseName + ":informixserver=" + instantiation;
+ } else {
+ throw new BaseException(SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getValue(), SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getText());
+ }
+ //鑾峰彇jdbc杩炴帴
+ return DataManipulationUtils.getConnection(diver, url, userName, userPassword);
+ }
+
+ /**
+ * 寮�鍙戝簱鐨勬ā鍧楀姛鑳芥爲
+ *
+ * @return
+ * @throws BaseException
+ */
+ public DataTableEntity getSyncTree(FieldSetEntity fse) throws BaseException, SQLException, ClassNotFoundException {
+ StringBuilder str = new StringBuilder();
+// str.append(" SELECT uuid,product_name `name`,tricode,null tricode_parent,1 type,concat(tricode,'_',1) only_key FROM product_sys_products ");
+// str.append(" union all select a.uuid,`name`,b.tricode,b.tricode_parent,type,only_key from ( ");
+// str.append(" select uuid,function_name `name`,2 type,concat(tricode,'_',2) only_key FROM product_sys_functions WHERE data_type=2 ");
+// str.append(" union all select uuid,function_name `name`,3 type,concat(tricode,'_',3) only_key FROM product_sys_functions where data_type=1) a join ");
+// str.append(""product_sys_module_function_code b on (( a.type=2 and b.data_type=1 ) or (a.type=3 and b.data_type=2)) and a.uuid=b.data_uuid ");
+// str.append(" ORDER BY type ,tricode_parent asc,tricode,length(tricode) asc ");
+ str.append(" SELECT uuid,product_name `name`,tricode,null tricode_parent,1 type,concat(tricode,'_',1) only_key FROM product_sys_products ");
+ str.append(" union all select a.uuid,`name`,tricode,tricode_parent,type,only_key from ( ");
+ str.append(" select uuid,tricode,tricode_parent,function_name `name`,2 type,concat(tricode,'_',2) only_key FROM product_sys_functions WHERE data_type=2 ");
+ str.append(" union all select uuid,tricode,tricode_parent,function_name `name`,3 type,concat(tricode,'_',3) only_key FROM product_sys_functions where data_type=1) a ");
+ str.append(" ORDER BY type ,tricode_parent asc,tricode,length(tricode) asc ");
+ Connection conn = getConnection(fse);
+ DataTableEntity dt = null;
+ try {
+ dt = BaseDaoServiceImpl.getDataTable(conn, str.toString(), new Object[]{});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ return dt;
+ }
+
+ /**
+ * 褰撳墠搴撶殑妯″潡鍔熻兘鏍�
+ *
+ * @return
+ * @throws BaseException
+ */
+ public DataTableEntity getNowTree(FieldSetEntity fse) throws BaseException, SQLException, ClassNotFoundException {
+ StringBuilder str = new StringBuilder();
+// str.append(" SELECT uuid,product_name `name`,tricode,null tricode_parent,1 type,concat(tricode,'_',1) only_key FROM product_sys_products ");
+// str.append(" union all select a.uuid,`name`,b.tricode,b.tricode_parent,type,only_key from ( ");
+// str.append(" select uuid,function_name `name`,2 type,concat(tricode,'_',2) only_key FROM product_sys_functions WHERE data_type=2 ");
+// str.append(" union all select uuid,function_name `name`,3 type,concat(tricode,'_',3) only_key FROM product_sys_functions where data_type=1 ) a join ");
+// str.append(""product_sys_module_function_code b on (( a.type=2 and b.data_type=1 ) or (a.type=3 and b.data_type=2)) and a.uuid=b.data_uuid ");
+// str.append(" ORDER BY type ,tricode_parent asc,tricode,length(tricode) asc ");
+ str.append(" SELECT uuid,product_name `name`,tricode,null tricode_parent,1 type,concat(tricode,'_',1) only_key FROM product_sys_products ");
+ str.append(" union all select a.uuid,`name`,tricode,tricode_parent,type,only_key from ( ");
+ str.append(" select uuid,tricode,tricode_parent,function_name `name`,2 type,concat(tricode,'_',2) only_key FROM product_sys_functions WHERE data_type=2 ");
+ str.append(" union all select uuid,tricode,tricode_parent,function_name `name`,3 type,concat(tricode,'_',3) only_key FROM product_sys_functions where data_type=1) a ");
+ str.append(" ORDER BY type ,tricode_parent asc,tricode,length(tricode) asc ");
+ DataTableEntity dt = baseDao.listTable(str.toString(), new Object[]{});
+ return dt;
+ }
+
+
+ public boolean verificationCode() {
+ String b = baseDao.getFieldSetEntityByFilter("product_sys_datamodel_field", "table_uuid='product_sys_functions' and field_name='tricode'", new String[]{}, false).getString("field_type");
+ String c = baseDao.getFieldSetEntityByFilter("product_sys_datamodel_field", "table_uuid='product_sys_products' and field_name='tricode'", new String[]{}, false).getString("field_type");
+ if ( b.equals("string") && c.equals("string")) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * 鍔熻兘鍚屾
+ *
+ * @return
+ * @throws BaseException
+ */
+ @Transactional
+ public FieldSetEntity syncFuntion(FieldSetEntity fse) throws BaseException, SQLException, ClassNotFoundException {
+ DataTableEntity dt = fse.getSubDataTable("function_info");
+ if (dt != null) {
+ JSONObject products_uuid = new JSONObject();
+ JSONObject modules_uuid = new JSONObject();
+ JSONObject functions_uuid = new JSONObject();
+ for (int i = 0; i < dt.getRows(); i++) {
+ FieldSetEntity fsub = dt.getFieldSetEntity(i);
+ if ("1".equals(fsub.getString("type"))) {
+ products_uuid.put(fsub.getString("tricode"), fsub.getString("upADD"));
+ } else if ("2".equals(fsub.getString("type"))) {
+ modules_uuid.put(fsub.getString("tricode"), fsub.getString("upADD"));
+ } else if ("3".equals(fsub.getString("type"))) {
+ functions_uuid.put(fsub.getString("tricode"), fsub.getString("upADD"));
+ }
+ }
+ ArrayList<String> products_uuid_list = new ArrayList<>();
+ ArrayList<String> modules_uuid_list = new ArrayList<>();
+ ArrayList<String> functions_uuid_list = new ArrayList<>();
+ for (String str : products_uuid.keySet()) {
+
+ products_uuid_list.add(str);
+ }
+ for (String str : modules_uuid.keySet()) {
+ modules_uuid_list.add(str);
+ }
+ for (String str : functions_uuid.keySet()) {
+ functions_uuid_list.add(str);
+ }
+ Connection conn = getConnection(fse);
+ DataTableEntity productsDt = null;
+ if (products_uuid_list.size() > 0) {
+ productsDt = BaseDaoServiceImpl.getDataTable(conn, "product_sys_products", BaseUtil.buildQuestionMarkFilter("tricode", products_uuid_list.size(), true), products_uuid_list.toArray());
+ }
+ DataTableEntity modulesDt = null;
+ if (modules_uuid_list.size() > 0) {
+ modulesDt = BaseDaoServiceImpl.getDataTable(conn, "product_sys_functions","data_type=2 and" +BaseUtil.buildQuestionMarkFilter("tricode", modules_uuid_list.size(), true), modules_uuid_list.toArray());
+// FieldMetaEntity f = new FieldMetaEntity();
+// f.setTableName(new Object[] { "product_sys_modules" });
+// modulesDt.setMeta(f);
+ }
+ DataTableEntity functionsDt = null;
+ if (functions_uuid_list.size() > 0) {
+ functionsDt = BaseDaoServiceImpl.getDataTable(conn, "product_sys_functions","data_type=1 and" + BaseUtil.buildQuestionMarkFilter("tricode", functions_uuid_list.size(), true), functions_uuid_list.toArray());
+ }
+ saveDataDT(productsDt, products_uuid);
+ saveDataDT(modulesDt, modules_uuid);
+ saveDataDT(functionsDt, functions_uuid);
+
+ }
+ return fse;
+ }
+
+ public void saveDataDT(DataTableEntity dt, JSONObject js) {
+ if (dt != null) {
+ for (int i = 0; i < dt.getRows(); i++) {
+ FieldSetEntity fs = dt.getFieldSetEntity(i);
+ if ("1".equals(js.getString(fs.getString("tricode")))) {
+ if ("琛屾斂鍔炲叕".equals(fs.getString("module_name"))) {
+ System.out.println(111);
+ }
+ fs.setValue("uuid", null);
+ if ("product_sys_products".equals(fs.getTableName())) {
+ fs.setValue("product_id", null);
+ baseDao.add(fs);
+ continue;
+ } else if ("product_sys_functions".equals(fs.getTableName())) {
+ fs.setValue("function_id", null);
+// String version_uuid = productsMap.getString(fs.getString("version_uuid"));
+// if (null != version_uuid) {
+// fs.setValue("product_uuid", version_uuid);
+// }
+ baseDao.add(fs);
+// modulesMap.put(fs.getString("tricode"), fs.getString("uuid"));
+ continue;
+ }
+// else if ("product_sys_functions".equals(fs.getTableName())&&"1".equals(fs.getString("data_type"))) {
+// fs.setValue("function_id", null);
+// String tricode = fs.getString("tricode");
+// String modules_uuid = modulesMap.getString(tricode.substring(0, tricode.length() - 4));
+// if (null != modules_uuid) {
+// fs.setValue("module_uuid", modules_uuid);
+// }
+// baseDao.add(fs);
+// continue;
+ }
+ }
+// baseDao.update(fs);
+// }
+ }
+ }
+
+ public static void main(String[] args) {
+ String code = "001-017-000";
+ String substring = code.substring(0, code.length() - 4);
+ System.out.println(substring);
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/SyFeDataService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/SyFeDataService.java
new file mode 100644
index 0000000..1b806e4
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/SyFeDataService.java
@@ -0,0 +1,3347 @@
+package com.product.data.sync.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.product.admin.config.CmnCode;
+import com.product.admin.service.CodeService;
+import com.product.admin.service.OrganizationCacheService;
+import com.product.admin.service.SystemMenusService;
+import com.product.common.lang.StringUtils;
+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.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.ide.ISyFeDataService;
+import com.product.data.sync.service.media.GdMediaUtil;
+import com.product.data.sync.util.BusinessDataSync;
+import com.product.data.sync.util.DataManipulationUtils;
+import com.product.file.service.FileManagerService;
+import com.product.file.util.CreateDocumentIndexThread;
+import com.product.module.sys.service.UserService;
+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 org.springframework.stereotype.Service;
+
+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;
+import java.util.stream.Collectors;
+
+/**
+ * Copyright LX
+ *
+ * @Title: SyFeDataService
+ * @Project: product-server
+ * @date: 2021-09-30 14:19
+ * @author: zm
+ * @Description: fe鏁版嵁绉绘鍒颁骇鍝�
+ */
+@Service
+public class SyFeDataService extends AbstractBaseService implements ISyFeDataService {
+ private static Logger logger = LoggerFactory.getLogger(SyFeDataService.class);
+ @Autowired
+ public BaseDao baseDao;
+ @Autowired
+ public FunctionSynchrService functionSynchrService;
+ @Autowired
+ FileManagerService fileManagerService;
+ @Autowired
+ SystemMenusService systemMenusService;
+ @Autowired
+ GdMediaUtil gdMediaUtil;
+ //鍏徃fe id 瀵瑰簲 浜у搧uuid
+ Map<String, FieldSetEntity> OrgIdUUIDmap = Maps.newHashMap();
+ //閲戞牸涓荤洰褰�
+ String jinGePath = "D:\\OA\\FEGOV\\Media";
+ //鏆傚瓨鏂囦欢鐩綍
+ String TSPath = "D:\\filePackage";
+ @Autowired
+ private UserService userService;
+ @Autowired
+ private CodeService codeService;
+ @Autowired
+ private FeDataDSService feDataDSService;
+ //fe 浜哄憳id 瀵瑰簲 userid
+ private JSONObject userIdJson = new JSONObject();
+ //fe 鍏徃閮ㄩ棬id 瀵瑰簲 鏈烘瀯uuid
+ private JSONObject groupJson = new JSONObject();
+ //瀛楁绫诲瀷鍏宠仈
+ private JSONObject fieldTypeJson = new JSONObject();
+ //娴佺▼nodes fe id 瀵瑰簲 浜у搧uuid
+ private JSONObject nodesIdUUID = new JSONObject();
+ //婧愭暟鎹〃鍚� 鏈暟鎹〃鍚�
+ private JSONObject originalTable = new JSONObject();
+ //鍞竴瀛楁
+ private String pk;
+ //琛ㄥ敮涓�鏍囪瘑 鍜屾湰琛╱uid
+ private JSONObject pxMap = new JSONObject();
+ //宸插紑鍙戝叕鍏卞姛鑳� 鍏憡绠$悊 绯荤粺鍙傛暟(娌℃湁) 闂嵎绠$悊 鑰冨嫟绠$悊 杞﹁締绠$悊 鍗忓悓鍔炲叕
+ private String[] funTable = {"FE_APP5.PUB_NOTICE", "FE_BASE5.RESEARCH_TOPIC", "FE_APP5.HR_ATTENDANCE", "FE_APP5.CAR_INFO", "FE_BASE5.SYS_COLLABORATIVE"};
+ //鎴戜滑浜у搧鐨勫姛鑳芥潈闄�
+ private String[] functionCode = {"001-004-000-000", "001-004-000-001", "001-004-000-002"};
+ //鏈骇鍝佹寜閽畊uid
+ private List<String> buttonUuid = Lists.newArrayList();
+
+ //宸插悓姝ヨ〃缁撴瀯
+ private JSONObject dataTableObject = new JSONObject();
+
+ public Boolean isStr(String str) {
+ boolean a = false;
+ for (int i = 0; i < funTable.length; i++) {
+ if (str.equals(funTable[i])) {
+ a = true;
+ }
+ }
+ return a;
+ }
+
+ //鍏憡绠$悊1 绯荤粺鍙傛暟 闂嵎绠$悊 鑰冨嫟绠$悊 杞﹁締绠$悊 鍗忓悓鍔炲叕
+ @Override
+ public String saveSyncFedata(FieldSetEntity fs) throws SQLException, ClassNotFoundException {
+ //鍚屾缁勭粐鏋舵瀯
+ DataTableEntity dataTableEntity = baseDao.listTable("product_sys_users");
+ String clientUUID = "remark";
+ if (dataTableEntity.getRows() < 10) {
+// //杩佺Щ缁勭粐鏋舵瀯
+// String uuid = feDataDSService.FEDataMigration();
+// if (!BaseUtil.strIsNull(uuid)) {
+// clientUUID = uuid;
+// }
+ }
+ //灏佽涓よ竟浜哄憳鍏宠仈鍜岄儴闂ㄥ叧鑱�
+// packageDepartmentPersonnel();
+ String tricode_fun = Global.getSystemConfig("data.synchronism.function", "").replaceAll(" ", "");
+ if (BaseUtil.strIsNull(tricode_fun)) {
+ return null;
+ }
+ String[] split = tricode_fun.split(";");
+ for (String s : split) {
+ saveSyncFeData(s.split(","), clientUUID);
+ }
+ return "ok";
+ }
+
+ public void flowPermission() {
+ DataTableEntity oldOrg = baseDao.listTable("product_sys_org_levels_copy1");
+ DataTableEntity orgDataStatic = baseDao.listTable("product_sys_org_levels");
+ Map<String, String> systemOrgMap = Maps.newHashMap();
+ for (int i = 0; i < orgDataStatic.getRows(); i++) {
+ systemOrgMap.put(orgDataStatic.getString(i, com.product.admin.config.CmnConst.ORG_LEVEL_ALL), orgDataStatic.getFieldSetEntity(i).getUUID());
+ }
+ Map<String, String> oldMapping = Maps.newHashMap();
+ for (int i = 0; i < oldOrg.getRows(); i++) {
+ String orgLevelAll = oldOrg.getString(i, com.product.admin.config.CmnConst.ORG_LEVEL_ALL);
+ String newUid = systemOrgMap.get(orgLevelAll);
+ if (StringUtils.isEmpty(newUid)) {
+ continue;
+ }
+ oldMapping.put(oldOrg.getFieldSetEntity(i).getUUID(), newUid);
+// oldSystemOrgMap.put(oldOrg.getFieldSetEntity(i).getUUID(), oldOrg.getString(i, com.product.admin.config.CmnConst.ORG_LEVEL_ALL));
+ }
+ DataTableEntity dataTableEntity = baseDao.listTable("product_sys_job_posts_copy1");
+ DataTableEntity systemPosts = baseDao.listTable("product_sys_job_posts");
+ //鏃у矖浣島uid 瀵瑰簲 鏂板矖浣島uid
+ Map<String, String> postMapping = new HashMap<>();
+ for (int i = 0; i < dataTableEntity.getRows(); i++) {
+ String postName = dataTableEntity.getString(i, com.product.admin.config.CmnConst.JOB_POST_NAME);
+ String orgLevel = dataTableEntity.getString(i, com.product.admin.config.CmnConst.DEPT_UUID);
+ String uuid = dataTableEntity.getFieldSetEntity(i).getUUID();
+ String newOrgUid = oldMapping.get(orgLevel);
+ if (StringUtils.isEmpty(newOrgUid)) {
+ continue;
+ }
+ for (int j = 0; j < systemPosts.getRows(); j++) {
+ String postName1 = systemPosts.getString(j, com.product.admin.config.CmnConst.JOB_POST_NAME);
+ String orgLevel1 = systemPosts.getString(j, com.product.admin.config.CmnConst.DEPT_UUID);
+ if (postName1.equals(postName) && newOrgUid.equals(orgLevel1)) {
+ postMapping.put(uuid, systemPosts.getFieldSetEntity(j).getUUID());
+ break;
+ }
+ }
+ }
+
+ dataTableEntity = baseDao.listTable("product_sys_users_copy1");
+ DataTableEntity systemUser = baseDao.listTable("product_sys_users");
+ Map<String, String> userMapping = Maps.newHashMap();
+ for (int i = 0; i < dataTableEntity.getRows(); i++) {
+ String userAccount = dataTableEntity.getString(i, com.product.admin.config.CmnConst.USER_ACCOUNT);
+ String userId = dataTableEntity.getFieldSetEntity(i).getString(CmnConst.USER_ID);
+ for (int j = 0; j < systemUser.getRows(); j++) {
+ String userAccount1 = systemUser.getString(j, com.product.admin.config.CmnConst.USER_ACCOUNT);
+ if (userAccount.equals(userAccount1)) {
+ userMapping.put(userId, systemUser.getFieldSetEntity(j).getString(CmnConst.USER_ID));
+ break;
+ }
+ }
+ }
+
+ DataTableEntity nodes = baseDao.listTable("product_sys_flow_node", "length(default_posts)>0 or length(default_users)>0 or length(default_depts)>0");
+ for (int i = 0; i < nodes.getRows(); i++) {
+ FieldSetEntity node = nodes.getFieldSetEntity(i);
+ String defaultPosts = node.getString("default_posts");
+ String defaultUsers = node.getString("default_users");
+ String defaultDepts = node.getString("default_depts");
+ String arr[];
+ if (!StringUtils.isEmpty(defaultDepts)) {
+ arr = defaultDepts.split(",");
+ for (int j = 0; j < arr.length; j++) {
+ String uid = arr[j];
+ String uuid = oldMapping.get(uid);
+ if (StringUtils.isEmpty(uuid)) {
+ arr[j] = null;
+ continue;
+ }
+ arr[j] = uuid;
+ }
+ //杩囨护arr涓殑null骞惰浆涓哄瓧绗︿覆鐢ㄩ�楀彿鍒嗛殧
+ defaultDepts = Arrays.stream(arr).filter(Objects::nonNull).collect(Collectors.joining(","));
+ }
+ if (!StringUtils.isEmpty(defaultPosts)) {
+ arr = defaultPosts.split(",");
+ for (int j = 0; j < arr.length; j++) {
+ String uid = arr[j];
+ String uuid = postMapping.get(uid);
+ if (StringUtils.isEmpty(uuid)) {
+ arr[j] = null;
+ continue;
+ }
+ arr[j] = uuid;
+ }
+ //杩囨护arr涓殑null骞惰浆涓哄瓧绗︿覆鐢ㄩ�楀彿鍒嗛殧
+ defaultPosts = Arrays.stream(arr).filter(Objects::nonNull).collect(Collectors.joining(","));
+ }
+ if(!StringUtils.isEmpty(defaultUsers)){
+ arr=defaultUsers.split(",");
+ for (int j = 0; j < arr.length; j++) {
+ String uid = arr[j];
+ String uuid = userMapping.get(uid);
+ if (StringUtils.isEmpty(uuid)) {
+ arr[j] = null;
+ continue;
+ }
+ arr[j] = uuid;
+ }
+ //杩囨护arr涓殑null骞惰浆涓哄瓧绗︿覆鐢ㄩ�楀彿鍒嗛殧
+ defaultUsers = Arrays.stream(arr).filter(Objects::nonNull).collect(Collectors.joining(","));
+ }
+ node.setValue("default_posts", defaultPosts);
+ node.setValue("default_users", defaultUsers);
+ node.setValue("default_depts", defaultDepts);
+
+ }
+ baseDao.update(nodes);
+ }
+
+ public String saveSyncFeData(String[] tricodeFunction, String clientUUID) {
+ String[] tricode_funs = tricodeFunction;
+// String[] tricode_funs = fs.getString("tricode_fun").split(",");
+ //灏佽鏈骇鍝侀渶璧嬫潈闄愮殑鎸夐挳uuid
+// this.packageButton();
+// Connection conn = functionSynchrService.getConnection(fs);
+ //閫氳繃绾跨▼寰幆娣诲姞鍔熻兘淇℃伅
+ ExecutorService exec = Executors.newCachedThreadPool();
+ for (int i = 0; i < tricode_funs.length; i++) {
+ //鑾峰彇jdbc杩炴帴
+ BusinessDataSync async = new BusinessDataSync(tricode_funs[i]);
+ async.setBaseDao(baseDao);
+ async.setFileManagerService(fileManagerService);
+ async.setSystemMenusService(systemMenusService);
+ async.setFeDataDSService(feDataDSService);
+ async.setGdMediaUtil(gdMediaUtil);
+ async.setClientUUID(clientUUID);
+ Thread t = new Thread(async);
+ //璋冪敤绾跨▼run鏂规硶
+ exec.submit(t);
+// nodesIdUUID = new JSONObject();
+// //鍚屾琛ㄥ強鍩虹鏁版嵁
+// String sf28 = this.synchronizeTablesData(conn, tricode_funs[i]);
+// String table_name = sf28.split("\\.")[1];
+// String moduleUUID;
+// if (!isStr(sf28)) {
+// //鍚屾mvc
+// moduleUUID = this.synchronizationModuleName(conn, tricode_funs[i], sf28);
+// } 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[]{this.originalTable.getString(table_name)}, false);
+// moduleUUID = fieldSetEntity.getUUID();
+// }
+// //杩佺Щ wf_model娴佺▼妯″潡琛�
+//// this.syncModel(tricode_funs[i], conn, moduleUUID, sf28, null, SpringMVCContextHolder.getCurrentUser().getUser_id(), false);
+// //鏍规嵁瑕佹眰娴佺▼瑕佸悓姝ヤ袱娆�
+// //鏌ヨ涓诲叕鍙竨uid
+// 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);
+// this.syncModel(tricode_funs[i], conn, moduleUUID, sf28, fieldSetEntity.getUUID(), user.getInteger("user_id"), true);
+ }
+ //鍚屾椂寮�濮嬫墽琛�
+ exec.shutdown();
+ while (true) {
+ if (exec.isTerminated()) {
+ //System.out.println("鎵�鏈夌殑瀛愮嚎绋嬮兘缁撴潫浜嗭紒");
+ break;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ systemMenusService.initSystemMenu();
+ System.out.println("=================鍚屾鎴愬姛===============");
+
+ return "OK";
+ }
+
+ /**
+ * 闄勪欢娣诲姞绱㈠紩
+ */
+ public void dataSyncCreateIndexUtil() {
+ String sql = "SELECT uuid attachment_uuid,function_uuid FROM product_sys_attachments WHERE function_uuid IS NOT NULL AND function_uuid!=''";
+ DataTableEntity dtAttachment = baseDao.listTable(sql, new Object[]{});
+ if (!BaseUtil.dataTableIsEmpty(dtAttachment)) {
+ for (int i = 0; i < dtAttachment.getRows(); i++) {
+ FieldSetEntity fseAttachment = dtAttachment.getFieldSetEntity(i);
+ CreateDocumentIndexThread.getInstance().appendAttaInfo(fseAttachment);
+ }
+ }
+ }
+
+ /**
+ * 灏佽鍗曚綅閮ㄩ棬 浜哄憳瀵瑰簲Json
+ */
+ public void packageDepartmentPersonnel() {
+ DataTableEntity staffsData = baseDao.listTable("product_sys_staffs");
+ for (int i = 0; i < staffsData.getRows(); i++) {
+ //鏁版嵁婧愮敤鎴穒d
+ userIdJson.put(staffsData.getString(i, "remark"), staffsData.getString(i, "user_id"));
+ }
+ DataTableEntity orgData = baseDao.listTable("product_sys_org_levels");
+ for (int i = 0; i < orgData.getRows(); i++) {
+ //婧愭暟鎹甶d
+ groupJson.put(orgData.getString(i, "sequence"), orgData.getString(i, "uuid"));
+ }
+ }
+
+ /**
+ * 灏佽鏈骇鍝佺殑鎸夐挳uuid
+ */
+ public void packageButton() {
+ StringBuffer sql = new StringBuffer();
+ String tricodeIn = BaseUtil.buildQuestionMarkFilter("tricode", this.functionCode, true);
+ sql.append(" SELECT uuid FROM product_sys_function_buttons WHERE function_uuid IN ( ")
+ .append(" SELECT uuid FROM product_sys_functions WHERE ")
+ .append(tricodeIn).append(" ) ");
+ DataTableEntity dataTableEntity = baseDao.listTable(sql.toString(), new String[]{});
+ for (int i = 0; i < dataTableEntity.getRows(); i++) {
+ this.buttonUuid.add(dataTableEntity.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");
+ //鍔熻兘濡傛灉鏈叧鑱斿熀纭�琛� 鏌ヨ娴佺▼琛�
+ 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("\\.");
+ boolean flag = true;
+ if (isStr(sf28)) {
+ flag = false;
+ }
+ this.syncTable(sf28s, flag, null, conn);
+ return sf28;
+ }
+
+ /**
+ * 鍚屾鍏憡琛ㄦ暟鎹�
+ *
+ * @param conn
+ * @param tableName
+ * @throws SQLException
+ */
+ private void syncNotice(Connection conn, String tableName) throws SQLException {
+ //鍒ゆ柇鏄惁鏄凡缁忓悓姝ヨ繃鐨勮〃
+ DataTableEntity dataTable = baseDao.listTable("product_oa_announcement");
+ if (!BaseUtil.dataTableIsEmpty(dataTable)) {
+ return;
+ }
+ DataTableEntity noticeDt = null;
+ try {
+ noticeDt = BaseDaoServiceImpl.getDataTable(conn, tableName, "", new Object[]{});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ for (int i = 0; i < noticeDt.getRows(); i++) {
+ FieldSetEntity feFs = noticeDt.getFieldSetEntity(i);
+ FieldSetEntity fs = new FieldSetEntity();
+ fs.setTableName("product_oa_announcement");
+ fs.setValue("title", feFs.getString("title"));
+ fs.setValue("content", feFs.getString("content"));
+ fs.setValue("type", feFs.getString("notice_category"));
+ //Set 杞崲涓哄瓧绗︿覆閫楀彿鍒嗛殧
+ //鍐欐柟娉曞垽鏂槸澶氫汉杩樻槸閮ㄩ棬锛岃嫢鏄儴闂ㄨ浆鎹负浜�
+ fs.setValue("extent", this.getUserIds(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"));
+ fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fs.setValue("created_utc_datetime", new Date());
+
+ String uuid = baseDao.add(fs);
+ //閲嶆柊鑾峰彇jdbc杩炴帴
+ Connection connection = null;
+ try {
+ connection = feDataDSService.getJDBC();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ DataTableEntity subFeFs = getSubDt(connection, "FE_APP5.PUB_NOTICE_RECEIVER", "NOTICE_ID", feFs.getString("id"));
+ 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);
+ baseDao.add(fsSub);
+ }
+ DataManipulationUtils.close(null, null, connection);
+ }
+ }
+
+ /**
+ * 鑾峰彇userId
+ *
+ * @param receivers 瀛楁鍊�
+ */
+ public String getUserIds(String receivers) throws SQLException {
+ String[] receiversArr = receivers.split(",");
+ Connection conn = null;
+ Set<String> extentArr = new HashSet<>();
+ try {
+ //鏌ヨ鍏徃閮ㄩ棬琛ㄦ暟鎹�
+ conn = feDataDSService.getJDBC();
+ 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());
+ }
+ DataManipulationUtils.close(null, null, conn);
+ return StringUtils.join(extentArr, ",");
+ }
+
+ /**
+ * 鏌ヨ瀛愯〃淇℃伅
+ *
+ * @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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ 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 SQLException {
+ //鍏憡琛�
+ if (tableName.equals("FE_APP5.PUB_NOTICE")) {
+ syncNotice(conn, tableName);
+ //涓や釜琛ㄥ缓绔嬪叧鑱�
+ this.originalTable.put("PUB_NOTICE", "product_oa_announcement");
+ }
+ //鍚屾闂嵎璋冩煡
+ if (tableName.equals("FE_BASE5.RESEARCH_TOPIC")) {
+ syncResearchTopic(conn, tableName);
+ this.originalTable.put("RESEARCH_TOPIC", "product_oa_questionnaire");
+ }
+ //鑰冨嫟琛�
+ if (tableName.equals("FE_APP5.APP_KQLRB")) {
+ this.synchronousClock(conn, tableName);
+ }
+ //杞﹁締鍩烘湰淇℃伅琛� 涓虹┖
+ if (tableName.equals("FE_APP5.CAR_INFO")) {
+ syncCarInfo(conn, tableName);
+ this.originalTable.put("CAR_INFO", "product_oa_car_driver_info");
+ }
+ //鍗忓悓鍔炲叕 涓嶇
+ if (tableName.equals("FE_BASE5.SYS_COLLABORATIVE")) {
+ syncCcooperates(conn, tableName);
+ this.originalTable.put("SYS_COLLABORATIVE", "product_oa_cooperates");
+ }
+
+ //浼氳瀹ょ敵璇�
+ if (tableName.equals("FE_APP5.BS_MEETING_FLOW")) {
+
+ }
+ //浼氳瀹ょ鐞�
+ if (tableName.equals("FE_APP5.BS_MEETINGROOM")) {
+
+ }
+ }
+
+ /**
+ * 鍚屾鑰冨嫟鏁版嵁
+ */
+ private void synchronousClock(Connection conn, String tableName) throws SQLException {
+ DataTableEntity clockDt = null;
+ try {
+ clockDt = BaseDaoServiceImpl.getDataTable(conn, tableName, "", new Object[]{});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ if (!BaseUtil.dataTableIsEmpty(clockDt)) {
+ 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");
+
+ //mac鍦板潃
+ String mac = fse.getString("mac");
+ }
+ }
+
+ }
+
+ /**
+ * 浼氳瀹ょ敵璇�
+ *
+ * @param conn
+ * @param tableName
+ */
+ private void ConferenceRoomApplication(Connection conn, String tableName) throws SQLException {
+ //鍒ゆ柇鏄惁鏄凡缁忓悓姝ヨ繃鐨勮〃
+ DataTableEntity dataTable = baseDao.listTable("product_oa_conference_apply");
+ if (!BaseUtil.dataTableIsEmpty(dataTable)) {
+ return;
+ }
+ DataTableEntity ccooperatesDt = null;
+ try {
+ ccooperatesDt = BaseDaoServiceImpl.getDataTable(conn, tableName, "", new Object[]{});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ }
+
+ //鍚屾鍗忓悓鍔炲叕
+ 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, tableName, "", new Object[]{});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+
+ DataTableEntity accessoryData = this.getTableNameAttachment(conn, tableName);
+ 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", emergencyDegreeType(important));
+ } else {
+ //涓虹┖灏辨斁0
+ fs.setValue("emergency_degree", 0);
+ }
+ //闄勪欢hiddenidea
+ // fs.setValue("attachment",);
+ //鍙戣捣鏃堕棿
+ 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.宸插彂锛�
+ fs.setValue("status", 1);
+ fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fs.setValue("created_utc_datetime", new Date());
+ Map<String, List<String>> fileMaps = this.synchronizationAttachments(conn, accessoryData, feFs, fs.getTableName());
+ List<String> value = fileMaps.get("COL_MDL_CONTENT_MEDIA");
+ //瀛樺叆闄勪欢uuid
+ fs.setValue("attachment", StringUtils.join(value, ","));
+ String uuid = baseDao.add(fs);
+
+ DataTableEntity coNodeDt = null;
+ try {
+ //flowcode 娴佺▼瀛楁
+ coNodeDt = BaseDaoServiceImpl.getDataTable(conn, "SELECT a.NAME receiver_name,a.VALUE receiver,b.NAME sender_name,b.VALUE sender,a.STATUS ,a.PARENTGUID PARENTGUID ,a.MGUID MGUID FROM WF_CO_NODE a LEFT JOIN WF_CO_NODE b on a.PARENTGUID=b.GUID where a.MGUID=?", new Object[]{feFs.getString("flowcode")});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ JSONObject grade = new JSONObject();
+ for (int j = 0; j < coNodeDt.getRows(); j++) {
+ FieldSetEntity subfsFe = coNodeDt.getFieldSetEntity(j);
+ FieldSetEntity subfs = new FieldSetEntity();
+ //鍗忓悓鍔炲叕娴佺▼琛�
+ subfs.setTableName("product_oa_cooperate_flow_node");
+ grade.put(subfsFe.getString("guid"), 1);
+ //鍔炵悊浜哄眰绾�
+ subfs.setValue("grade", 1);
+ //鍏宠仈鍗忓悓琛╱uid
+ subfs.setValue("cooperate_uuid", uuid);
+ //鎺ユ敹浜猴紙鍏宠仈鐢ㄦ埛琛╥d锛�
+ subfs.setValue("receiver", subfsFe.getString("receiver"));
+ //鎺ユ敹浜哄鍚�
+ subfs.setValue("receiver_name", subfsFe.getString("receiver_name"));
+ //鍙戦�佷汉锛堝叧鑱旂敤鎴疯〃id锛�
+ subfs.setValue("sender", subfsFe.getString("sender"));
+ //鍙戦�佷汉濮撳悕
+ subfs.setValue("sender_name", subfsFe.getString("sender_name"));
+ //0:鏈敹鏈姙 1:宸叉敹鏈� 2:宸叉敹宸插姙
+ subfs.setValue("status", subfsFe.getInteger("status") == 1 ? 2 : 0);
+ //0:鏆傚瓨 1:鍔犵 2:杞彂 3:閫�鍥�4:閫佸姙 5:缁堟 6:鎾ら攢
+ subfs.setValue("type", 0);
+
+
+ String uuids = baseDao.add(subfs);
+// DataTableEntity IDEAMANAGEDt = null;
+// try {
+// IDEAMANAGEDt = BaseDaoServiceImpl.getDataTable(conn, "select c.ID02 ID02,c.ID03 ID03,c.ID04 ID04,c.ID08 ID08 from FE_BASE5.WF_TASK a JOIN FE_BASE5.WF_INFOR b on a.WT00=b.WI01 JOIN FE_BASE5.IDEAMANAGE c on b.WI21= c.ID06 where a. WT13=? ", new Object[]{subfsFe.getString("mguid")});
+// } catch (Exception e) {
+// DataManipulationUtils.close(null, null, conn);
+// throw e;
+// }
+// for (int k = 0; k < IDEAMANAGEDt.getRows(); k++) {
+// FieldSetEntity subfsFeto = coNodeDt.getFieldSetEntity(i);
+// FieldSetEntity subfsto = new FieldSetEntity();
+// //鍗忓悓鍔炲叕鐣欒█琛�
+// subfsto.setTableName("product_oa_cooperate_flow_reply");
+// //鍏宠仈product_oa_cooperate_flow_node琛╱uid
+// subfsto.setValue("parent_uuid", uuids);
+// //鍥炲鍐呭
+// subfsto.setValue("reply_content", subfsFeto.getString("id04"));
+// //鍥炲鏃堕棿
+// subfsto.setValue("reply_datetime", subfsFeto.getString("id03"));
+// //鍥炲浜猴紝鍏宠仈user琛╥d
+// subfsto.setValue("reply_user", this.getUserId(subfsFeto.getInteger("id02")));
+// baseDao.add(subfsto);
+// //闄勪欢
+//// subfsto.setValue("reply_attachment",);
+// }
+ }
+ }
+ }
+
+ private String emergencyDegreeType(String type) {
+ String reType = "";
+ switch (type) {
+ case "骞充欢":
+ reType = "1";
+ break;
+ case "鍔犳��":
+ reType = "2";
+ break;
+ case "鐗规��":
+ reType = "3";
+ break;
+ case "鐗规彁":
+ reType = "4";
+ 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 {
+ permissionDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.SYS_FUNCTION_USER", "FU02=?", new Object[]{funCode});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ Map<String, DataTableEntity> funUsers = Maps.newHashMap();
+ for (int i = 0; i < permissionDt.getRows(); i++) {
+ FieldSetEntity permissionFs = permissionDt.getFieldSetEntity(i);
+ FieldSetEntity fs = new FieldSetEntity();
+ fs.setTableName("product_sys_function_permission");
+ fs.setValue("function_uuid", funUUID);
+ //瑙掕壊id
+ String fu01 = permissionFs.getString("fu01");
+ //璇ユ潈闄愮鐞嗙殑鏄敤鎴疯〃锛圫YS_USERS锛� 骞堕潪瑙掕壊琛�
+ if ("U".equals(permissionFs.getString("fu03"))) {
+ String fu04 = permissionFs.getString("fu04");
+ DataTableEntity data = funUsers.get(fu04);
+ if (BaseUtil.dataTableIsEmpty(data)) {
+ data = new DataTableEntity();
+ }
+ data.addFieldSetEntity(permissionFs);
+ funUsers.put(fu04, data);
+ continue;
+ }
+ //鑾峰彇瑙掕壊鏁版嵁
+ FieldSetEntity roleFse = baseDao.getFieldSetEntityByFilter("product_sys_role", " sequence = ? ", new String[]{fu01}, true);
+// String orgLevelUuid = roleFse.getString("org_level_uuid");
+ fs.setValue("role_uuid", roleFse.getUUID());
+ String fu04 = permissionFs.getString("fu04");
+ //鑾峰彇鏉冮檺閲岀殑鎸夐挳
+ List<String> buttonIdType = new ArrayList<>();
+ buttonIdType.add(funCode);
+ for (int j = 0; j < fu04.length(); j++) {
+ String type = String.valueOf(fu04.charAt(j));
+ if (type.equals("1")) {
+ //鏀惧叆鍊肩殑涓嬫爣
+ buttonIdType.add(buttonTypeRole(j));
+ }
+ }
+ if (buttonIdType.size() == 1) {
+ continue;
+ }
+ 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 = new ArrayList<>();
+ for (int j = 0; j < eventDt.getRows(); j++) {
+ buttonId.add(buttonMap.getString(eventDt.getString(j, "se00")));
+ }
+ buttonId.addAll(this.buttonUuid);
+ fs.setValue("button_uuid", StringUtils.join(buttonId, ","));
+ fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fs.setValue("created_utc_datetime", new Date());
+ baseDao.add(fs);
+ }
+ //鍚屾姣忎釜鍔熻兘鏉冮檺鍚� 杩樿鍚屾瀹㈡埛鏉冮檺
+ this.customerPermission(funUUID, buttonMap);
+ }
+
+ /**
+ * 鍚屾瀹㈡埛鏉冮檺
+ *
+ * @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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fs.setValue("created_utc_datetime", new Date());
+ baseDao.add(fs);
+ }
+
+ /**
+ * 鍒涘缓涓�涓姛鑳戒笅鐨勮鑹�
+ * 鎶婄洿鎺ュ叧鑱斿姛鑳界殑鐢ㄦ埛鏀惧叆瑙掕壊涓�
+ *
+ * @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(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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ 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();
+ //鍚嶅瓧涓簁 鐨刯son
+ 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) {
+ //鏄惁涓哄姛鑳藉叆鍙o紝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());
+ 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fs.setValue("created_utc_datetime", new Date());
+ //浣嶇疆top
+ fs.setValue("top_location", pageFs.getString("sp07"));
+ //浣嶇疆left
+ fs.setValue("left_location", pageFs.getString("sp06"));
+ //琛ㄥ崟绫诲瀷 鍚嶇О甯︽湁鍒楄〃閮芥槸鍒楄〃绫诲瀷
+ 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浠g爜璺緞
+ fs.setValue("page_url", pageFs.getString("sp09"));
+ //鍏堝瓨鍏ユ祦绋媔d 杩佺Щ娴佺▼鍚庡啀鏇挎崲
+ 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ 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 sf28) throws SQLException, ClassNotFoundException {
+ System.out.println(funFs.getString("sf28"));
+ if (!BaseUtil.strIsNull(funFs.getString("sf28"))) {
+ sf28 = funFs.getString("sf28");
+ }
+ String table = sf28.split("\\.")[1].toLowerCase();
+ FieldSetEntity product_sys_datamodel_table = baseDao.getFieldSetEntityByFilter("product_sys_datamodel_table", "table_name=?", new String[]{table}, false);
+ //杩佺Щ鍔熻兘
+ FieldSetEntity fs = new FieldSetEntity();
+ fs.setTableName("product_sys_functions");
+ //琛╱uid
+ fs.setValue("table_uuid", product_sys_datamodel_table.getString("uuid"));
+ //鍔熻兘鍚嶇О
+ fs.setValue("function_name", funFs.getString("sf03"));
+ //鍔熻兘鎻忚堪
+ fs.setValue("function_description", funFs.getString("sf03"));
+ //涓婄骇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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fs.setValue("created_utc_datetime", new Date());
+ fs.setValue("data_type", 1);
+ String funUUID = baseDao.add(fs);
+
+ String sf05 = funFs.getString("sf05");
+ //鑾峰彇jdbc杩炴帴
+ Connection conn = feDataDSService.getJDBC();
+ //杩佺ЩMVC
+ JSONObject buttonMap = this.syncButtonsPage(conn, funUUID, sf05);
+ //杩佺Щ鑿滃崟
+ try {
+ this.synchronizationMenu(conn, funFs.getString("sf05"), funUUID);
+ } catch (Exception e) {
+ e.getStackTrace();
+ }
+ //杩佺Щ鍔熻兘鏉冮檺璁稿彲
+ 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);
+ 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ moduleFs.setValue("created_utc_datetime", new Date());
+ moduleFs.setValue("data_type", 2);
+ //鏂板涓�涓猣e杩佺Щ鎬绘ā鍧�
+ moduleUUID = baseDao.add(moduleFs);
+ } else {
+ moduleCode = moduleFs.getString("tricode");
+ moduleUUID = moduleFs.getUUID();
+ }
+ //鍚屾妯″潡涓嬬殑鍔熻兘
+ try {
+ this.syncFunctions(funFse, moduleCode, 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);
+ 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", "");
+ baseDao.add(menuFieldSet);
+ } else {
+ menuCode = fieldSetEntity.getString("tricode");
+ }
+ //鐢熸垚鐨勮彍鍗曠紪鐮�
+ fieldSet.setValue("tricode", CodeUtil.getNewCodeByTemp("product_sys_menus", "tricode", menuCode));
+ //鐖剁骇缂栫爜
+ fieldSet.setValue("tricode_parent", menuCode);
+ baseDao.add(fieldSet);
+ }
+
+ /**
+ * 杩佺Щ涓氬姟鏁版嵁琛�
+ *
+ * @param sf28s 搴撳悕鍜岃〃鍚�
+ * @param conn 杩炴帴
+ * @return
+ * @throws SQLException
+ */
+ public void syncTable(String[] sf28s, boolean isNew, String subField, Connection conn) throws SQLException {
+ FieldSetEntity Orlfs;
+ //琛ㄥ悕
+ String taName = sf28s[1];
+ String masterTableName = "";
+ //鑾峰彇涓昏〃鐨勮〃鍚�
+ if (sf28s.length == 3) {
+ masterTableName = sf28s[2];
+ }
+ try {
+ Orlfs = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.SYS_TABLE", "ST03=?", new Object[]{taName});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ Map<String, String> map = null;
+
+ //鏄惁鏄柊琛�
+ if (isNew) {
+ //鍒ゆ柇鏄惁鏄凡缁忓悓姝ヨ繃鐨勮〃
+ FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntityByFilter("product_sys_datamodel_table", " table_name = ? ", new String[]{taName.toLowerCase()}, false);
+ if (fieldSetEntity == null) {
+ //鍚屾琛ㄧ粨鏋� 鍙婂瓧娈典俊鎭�
+ map = this.syncTableField(conn, Orlfs, sf28s, subField);
+ //鍒锋柊table 琛�
+ DataPoolRefreshCache.getInstance().put("product_sys_datamodel_table");
+ //鍒锋柊field 琛�
+ DataPoolRefreshCache.getInstance().put("product_sys_datamodel_field");
+ try {
+ Thread.sleep(7000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ } else {
+ return;
+ }
+ } else {
+ //宸叉湁琛�
+ 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);
+ throw e;
+ }
+ //鏌ヨ璇ヨ〃瀛楁湁娌℃湁闄勪欢瀛楁 media attachment
+ DataTableEntity accessoryData = this.getTableFieldAttachment(Orlfs.getString("st00"));
+ Boolean syncAttachments = false;
+ if (!BaseUtil.dataTableIsEmpty(accessoryData)) {
+ syncAttachments = true;
+ }
+
+ //涓氬姟琛� fe鐨刬d 瀵瑰簲UUID
+ for (int i = 0; i < dataDt.getRows(); i++) {
+ FieldSetEntity dataFs = dataDt.getFieldSetEntity(i);
+ FieldSetEntity tableFs = new FieldSetEntity();
+ tableFs.setTableName(this.originalTable.getString(taName));
+ //key 涓烘湰琛ㄥ瓧娈� value 涓烘暟鎹簮瀛楁
+ for (String key : map.keySet()) {
+ //鍗曞叧鑱旂殑鐢ㄦ埛user_id
+ if ("USER".equals(fieldTypeJson.getString(key))) {
+ tableFs.setValue(key, userIdJson.getString(dataFs.getString(map.get(key))));
+ //鍗曞叧鑱旂殑缁勭粐鏋舵瀯uuid
+ } else if ("GROUP".equals(fieldTypeJson.getString(key))) {
+ tableFs.setValue(key, groupJson.get(dataFs.getString(map.get(key))));
+ //澶氶�夌粍缁囨灦鏋� 杞崲涓虹敤鎴穟ser_ids
+ } else if ("USERSGROUPS".equals(fieldTypeJson.getString(map.get(key)))) {
+ tableFs.setValue(key, this.getUserIds(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 (syncAttachments) {
+ Map<String, List<String>> fileMaps = this.synchronizationAttachments(conn, accessoryData, dataFs, taName);
+ if (fileMaps.size() > 0) {
+ for (String fieldName : fileMaps.keySet()) {
+ List<String> value = fileMaps.get(fieldName);
+ tableFs.setValue(fieldName, StringUtils.join(value, ","));
+ }
+ }
+ }
+// if("app_notice_urge".equals(tableFs.getTableName())){
+// try {
+// Thread.sleep(1000);
+// } catch (InterruptedException e) {
+// e.printStackTrace();
+// }
+// }
+ String uuid = baseDao.add(tableFs);
+ //琛ㄥ敮涓�id 瀵瑰簲uuid
+ pxMap.put(taName + dataFs.getString(this.pk), uuid);
+ }
+ //鍚屾瀹屼竴寮犺〃鏁版嵁鍚庢竻绌簀son鏁版嵁
+ 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[]{"%" + sf28s[1] + "%"});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ for (int i = 0; i < subTble.getRows(); i++) {
+ FieldSetEntity sf = subTble.getFieldSetEntity(i);
+ String a[] = {sf.getString("st02"), sf.getString("st03"), taName};
+ if (isStr(sf.getString("st02") + "\\." + sf.getString("st03"))) {
+ isNew = false;
+ }
+ this.syncTable(a, isNew, sf.getString("sf01").toLowerCase(), conn);
+ }
+ }
+
+ /**
+ * 鍒ゆ柇鏄惁鏄紩鐢ㄦ暟鎹� 鏄氨瑕佽浆鎹紙濡備汉鍛榠d锛屾満鏋刬d锛�
+ *
+ * @param tableName 琛ㄥ悕鐐�.瀛楁鍚�
+ * @return
+ */
+ public void 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 = '[100001]' ");
+ dataTable = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new String[]{fieldName, tableName});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ 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 SP02 = 'A11' ");
+
+ dataTable = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new String[]{tableName, fieldName});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ 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[]{tableName, fieldName});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ //濡傛灉鏄閫夋帶浠�
+ if (!BaseUtil.dataTableIsEmpty(dataTable)) {
+ fieldTypeJson.put(fieldName.toLowerCase(), "USERSGROUPS");
+ }
+ } else {
+ fieldTypeJson.put(fieldName.toLowerCase(), "GROUP");
+ }
+ } else {
+ fieldTypeJson.put(fieldName.toLowerCase(), "USER");
+ fieldSetEntity.setValue("field_reference", "user_name_by_user_id");
+ }
+ }
+
+ /**
+ * 鍚屾闄勪欢
+ *
+ * @param accessoryData 闄勪欢瀛楁data
+ * @param tableFs 鏁版嵁鍊�
+ */
+ public Map<String, List<String>> synchronizationAttachments(Connection conn, DataTableEntity accessoryData, FieldSetEntity tableFs, String table) {
+ 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(attachmentsValue)) {
+ List<String> fileUuids = Lists.newArrayList();
+ //鏅�氶檮浠�
+ if ("attachment".equals(type)) {
+ //鍙栧嚭闄勪欢琛ㄦ暟鎹�
+ fileUuids = this.synchronizeCommonAccessories(conn, field, table, attachmentsValue);
+ //閲戞牸闄勪欢
+ } else if ("media".equals(type)) {
+ //闄勪欢鍊�
+ //閫氳繃閲戞牸鏍囪瘑鎷艰鍏ㄨ矾寰則his.jinGePath
+ String path1 = attachmentsValue.substring(0, 4);
+ String path2 = attachmentsValue.substring(4, 6);
+ String path3 = attachmentsValue.substring(6, 8);
+ String path4 = attachmentsValue.substring(0, 14);
+ StringBuffer fullPath = new StringBuffer();
+ fullPath.append(this.jinGePath).append("\\")
+ .append(path1).append("\\")
+ .append(path2).append("\\")
+ .append(path3).append("\\")
+ .append(path4);
+ Map<String, String> fileTimeName = feDataDSService.getFilesFolder(fullPath.toString());
+ if (fileTimeName == null) {
+ //鏈壘鍒伴檮浠剁洿鎺ヨ烦杩�
+ continue;
+ }
+ DataTableEntity mediaSortInfo = this.getMediaSortInfo(attachmentsValue);
+ //寰幆閲戞牸鎺т欢琛ㄦ暟鎹� 涓庢枃浠舵暟鎹厤缃�
+ if (!BaseUtil.dataTableIsEmpty(mediaSortInfo)) {
+ fileUuids = Lists.newArrayList();
+ for (int j = 0; j < mediaSortInfo.getRows(); j++) {
+ //鏈�鏂颁慨鏀规椂闂�
+ String time = mediaSortInfo.getString(j, "wms04");
+ //鍒涘缓鏃堕棿
+ String name = mediaSortInfo.getString(j, "wms01");
+ //鑾峰彇瑕佺Щ鍔ㄧ殑鏂囦欢鍚嶇О
+ String fileName = fileTimeName.get(time);
+ if (BaseUtil.strIsNull(fileName)) {
+ continue;
+ }
+ String filePath = fullPath.toString() + "\\" + fileName;
+ String newPath = this.TSPath + "\\" + name;
+ //澶嶅埗鍒颁复鏃剁洰褰曚笅
+ if (feDataDSService.copyFile(filePath, newPath)) {
+ //閫氳繃璺緞鑾峰彇File
+ File file = new File(newPath);
+ RequestParameterEntity rpe = new RequestParameterEntity();
+ Map<String, File> fileMap = Maps.newHashMap();
+ //鏂囦欢鍚� 鏂囦欢file
+ fileMap.put(name, file);
+ FieldSetEntity fieldSetEntity = new FieldSetEntity();
+ fieldSetEntity.setTableName(tableFs.getTableName());
+ fieldSetEntity.setValue(field, name);
+ rpe.setFiles(fileMap);
+ rpe.setFormData(fieldSetEntity);
+ FieldSetEntity fileFse = fileManagerService.uploadFile(rpe);
+ fileUuids.add(fileFse.getUUID());
+ }
+ }
+ }
+ }
+ 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 + "\\" + sa02;
+ String newPath = this.TSPath + "\\" + sa03;
+ //澶嶅埗鍒颁复鏃剁洰褰曚笅
+ 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();
+ fieldSetEntity.setTableName(table);
+ fieldSetEntity.setValue(field, sa03);
+ rpe.setFiles(fileMap);
+ rpe.setFormData(fieldSetEntity);
+ FieldSetEntity fileFse = fileManagerService.uploadFile(rpe);
+ fileUuids.add(fileFse.getUUID());
+ }
+ }
+ 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 = ? ");
+ System.out.println(value);
+ dataTableEntity = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{value});
+ return dataTableEntity;
+ }
+
+ /**
+ * 鑾峰彇閲戞牸闄勪欢淇℃伅
+ *
+ * @param value 闄勪欢鏍囪瘑
+ * @return
+ */
+ public DataTableEntity getMediaSortInfo(String value) {
+ DataTableEntity dataTableEntity = null;
+ Connection conn = null;
+ try {
+ conn = feDataDSService.getJDBC();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ StringBuffer sql = new StringBuffer();
+ sql.append(" SELECT * FROM FE_APP5.WF_MEDIA_SORT WHERE WMS02 = ? ");
+ dataTableEntity = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{value});
+ try {
+ DataManipulationUtils.close(null, null, conn);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ 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;
+ }
+
+ /**
+ * 閫氳繃琛╥d鑾峰彇鍚屾鐨勯檮浠跺瓧娈�
+ *
+ * @param tableId 琛╥d
+ * @return
+ */
+ public DataTableEntity getTableFieldAttachment(String tableId) {
+ DataTableEntity dataTableEntity = null;
+ Connection conn = null;
+ try {
+ conn = feDataDSService.getJDBC();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ 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});
+ try {
+ DataManipulationUtils.close(null, null, conn);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return dataTableEntity;
+ }
+
+ /**
+ * 杩佺Щ"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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ 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);
+ throw e;
+ }
+ DataTableEntity dt = new DataTableEntity();
+ String table_uuid = tableFs.getString("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");
+ // 鍒ゆ柇鏄惁鏄紩鐢ㄦ暟鎹� 鏄氨瑕佽浆鎹紙濡備汉鍛榠d锛屾満鏋刬d锛�
+ 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 type = this.fieldTypeFE(rowFs.getString("sf03"));
+ //鏄惁鏈夊瓧娈靛叧鑱斾富琛�
+ if ("pk".equals(type)) {
+ //濡傛灉宸茬粡鏈塸k
+ if (is_pk) {
+ type = "string";
+ } else {
+ this.pk = sf01.toLowerCase();
+ is_pk = true;
+ }
+ }
+ fieldFs.setValue("field_type", type);
+ if ("GUID".equals(rowFs.getString("sf03"))) {
+ fieldFs.setValue("is_unique", 1);
+ } else {
+ fieldFs.setValue("is_unique", 0);
+ }
+ if ("NATIVE".equals(rowFs.getString("sf03"))) {
+ fieldFs.setValue("NATIVE", 1);
+ }
+ if ("UNITCODE".equals(rowFs.getString("sf03"))) {
+ fieldFs.setValue("UNITCODE", 1);
+ }
+ //濡傛灉鏄叧鑱斾富琛ㄥ瓧娈� 闀垮害鏀逛负64
+ if (subField != null && subField.equals(sf01.toLowerCase())) {
+ fieldFs.setValue("field_type", "string");
+ fieldFs.setValue("field_length", 64);
+ } else {
+ fieldFs.setValue("field_length", rowFs.getString("sf04"));
+ }
+ fieldFs.setValue("field_unit", rowFs.getString("sf05"));
+ fieldFs.setValue("is_required", 0);
+ fieldFs.setValue("is_filter", 1);
+ if (null != rowFs.getString("sf10") && "".equals(rowFs.getString("sf10"))) {
+ fieldFs.setValue("field_type", "parentuuid");
+ fieldFs.setValue("field_relation_table", rowFs.getString("sf10").split("\\.")[1]);
+ }
+ 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 void syncModel(String tricode_funs, Connection conn, String module_uuid, String sf28, String org_level_uuid, int created_by, 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);
+ throw e;
+ }
+ if (Orlfs == null) {
+ return;
+ }
+ 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;
+ }
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ //濡傛灉鍔熻兘琛ㄥ拰娴佺▼琛ㄧ粦瀹氱殑鏁版嵁琛ㄤ笉鐩稿悓 浠ユ祦绋嬭〃涓轰富
+ } else if (!wm04.equals(sf28)) {
+ String[] wm04s = wm04.split("\\.");
+ this.syncTable(wm04s, false, null, conn);
+ }
+
+ String[] wm04s = wm04.split("\\.");
+ String table_name = wm04s[1].toLowerCase();
+ //涓昏〃琛ㄥ悕
+ modelFs.setValue("table_uuid", table_name);
+ //鐢熸垚uuid
+ String 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 = baseDao.add(modelFs);
+ //wm05 涓烘祦绋嬬紪鐮� 鏌ヨ瀛樻湁缂栫爜鐨刴vc椤甸潰 鏀逛负娴佺▼uuid
+ String wm05 = Orlfs.getString("wm05");
+ 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);
+ }
+
+ //杩佺ЩWF_NODES 娴佺▼鑺傜偣琛�
+ JSONObject nodesUUID = this.syncNodes(tricode_funs, conn, modelUuid);
+ //杩佺ЩWF_NODES 娴佺▼鑺傜偣琛� 鍒�"product_sys_flow_processor 澶勭悊鍣ㄨ縼绉�
+ this.syncProcessor(tricode_funs, conn, modelUuid);
+ //杩佺ЩWF_LINKS
+ this.syncLinks(tricode_funs, conn, modelUuid);
+ if (flag) {
+ //杩佺Щ WF_TASK
+ JSONObject taskIdUUID = this.syncTask(tricode_funs, conn, modelUuid);
+ //杩佺Щwf_infor 鑺傜偣浠诲姟澶勭悊鎯呭喌琛�
+ Map<String, String> stateMap = this.syncDetail(tricode_funs, conn, nodesUUID, sf28, modelUuid, taskIdUUID);
+ //鍚屾娑堟伅
+ try {
+ this.synchronizingProcessMessages(conn, tricode_funs, stateMap);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ }
+ //婧愭暟鎹甶d 涓� 鏈暟鎹畊uid 鍏宠仈
+ pxMap.clear();
+ }
+ }
+
+ /**
+ * 杩佺Щ flow澶勭悊鍣�
+ *
+ * @throws SQLException
+ */
+ public void syncProcessor(String tricode_funs, Connection conn, String modelUUID) throws SQLException {
+ DataTableEntity OrlDt = null;
+ try {
+ OrlDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.wf_nodes", " WN01=(select wm00 from fe_base5.wf_model where wm05=(SELECT se16 FROM fe_base5.SYS_EVENT where se01=? and se08 = 1)) and WN04 ='5'", new Object[]{tricode_funs
+ });
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ 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);
+ }
+ }
+
+ public JSONObject syncNodes(String tricode_funs, Connection conn, String modelUUID) throws SQLException {
+ DataTableEntity OrlDt = null;
+ try {
+ OrlDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.wf_nodes", " WN01=(select wm00 from fe_base5.wf_model where wm05=(SELECT se16 FROM fe_base5.SYS_EVENT where se01=? and se08 = 1)) and WN04 !='5'", new Object[]{tricode_funs
+ });
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ JSONObject map = new JSONObject();
+ nodesIdUUID = new JSONObject();
+
+ 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ //鍒涘缓鏃堕棿
+ 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-椤哄簭澶勭悊 鍏圓 鍚巄 銆傘�傘�備笅涓�涓妭鐐�
+ // 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浠g爜 鏆傚瓨浜庢
+ 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(Orlfs);
+ if (map1 != null && map1.size() > 0) {
+ String userList = map1.get("userList");
+ //浜哄憳id
+ if (!BaseUtil.strIsNull(userList)) {
+ nodeFs.setValue("default_users", userList);
+ }
+ String postList = map1.get("postList");
+ //宀椾綅uuid
+ if (!BaseUtil.strIsNull(postList)) {
+ nodeFs.setValue("default_posts", postList);
+ }
+ String deptList = map1.get("deptList");
+ //鍗曚綅閮ㄩ棬uuid
+ if (!BaseUtil.strIsNull(deptList)) {
+ nodeFs.setValue("default_depts", deptList);
+ }
+ }
+ //闇�瑕佸湪鏁版嵁婧愯〃閲岄潰鎻掑叆涓�涓儴闂� 鎵�鏈夌洿鎺ュ叧鑱斿崟浣嶉兘鏀逛负杩欎釜閮ㄩ棬
+ //鍧愭爣锛岃妭鐐瑰埌涓婅竟鐣岀殑鍨傜洿璺濈
+ 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);
+ String uuid = baseDao.add(nodeFs);
+ //鑺傜偣鍞竴鍙�
+ map.put(Orlfs.getString("wn53"), uuid);
+ //椤哄簭鍙�
+ nodesIdUUID.put(Orlfs.getString("wn00"), uuid);
+ }
+ return map;
+ }
+
+ /**
+ * 鍚屾鑺傜偣閰嶇疆鐨勭粍缁囨灦鏋�
+ *
+ * @param fieldSetEntity
+ */
+ public Map<String, String> syncNodeInstitutions(FieldSetEntity fieldSetEntity) {
+ String wn00 = fieldSetEntity.getString("wn00");
+ DataTableEntity OrlDt = null;
+ try {
+ Connection conn = feDataDSService.getJDBC();
+ OrlDt = BaseDaoServiceImpl.getDataTable(conn, "fe_base5.WF_ROLES", " WR01 = ? ", new Object[]{wn00});
+ DataManipulationUtils.close(null, null, conn);
+ } catch (Exception e) {
+ e.getStackTrace();
+ }
+ if (BaseUtil.dataTableIsEmpty(OrlDt)) {
+ return null;
+ }
+ //鐢ㄦ埛
+ List<String> userList = Lists.newArrayList();
+ //閮ㄩ棬
+ List<String> deptList = Lists.newArrayList();
+ //宀椾綅
+ List<String> postList = Lists.newArrayList();
+ 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)) {
+ userList.add(wr03);
+ //瑙掕壊 宀椾綅
+ } else if ("Y".equals(wr04)) {
+ postList.add(wr03);
+ //鏈烘瀯
+ } else if ("Z".equals(wr04)) {
+ deptList.add(wr03);
+ }
+ }
+ Map<String, String> map = Maps.newHashMap();
+ //鏌ヨ浜哄憳
+ if (userList.size() > 0) {
+ DataTableEntity staffData = baseDao.listTable("product_sys_staffs", BaseUtil.buildQuestionMarkFilter("remark", userList.toArray(), true));
+ if (!BaseUtil.dataTableIsEmpty(staffData)) {
+ userList.clear();
+ for (int i = 0; i < staffData.getRows(); i++) {
+ userList.add(staffData.getString(i, "user_id"));
+ }
+ map.put("userList", StringUtils.join(userList, ","));
+ }
+ }
+ //鏌ヨ宀椾綅
+ if (postList.size() > 0) {
+ DataTableEntity postData = baseDao.listTable("product_sys_job_posts", BaseUtil.buildQuestionMarkFilter("sequence", postList.toArray(), true));
+ if (!BaseUtil.dataTableIsEmpty(postData)) {
+ postList.clear();
+ for (int i = 0; i < postData.getRows(); i++) {
+ postList.add(postData.getString(i, "uuid"));
+ }
+ map.put("postList", StringUtils.join(postList, ","));
+ }
+ }
+ //鏌ヨ鏈烘瀯(鍗曚綅閮ㄩ棬)
+ if (deptList.size() > 0) {
+ DataTableEntity orgData = baseDao.listTable("product_sys_org_levels", BaseUtil.buildQuestionMarkFilter("sequence", deptList.toArray(), true));
+ if (!BaseUtil.dataTableIsEmpty(orgData)) {
+ deptList.clear();
+ for (int i = 0; i < orgData.getRows(); i++) {
+ deptList.add(orgData.getString(i, "uuid"));
+ }
+ map.put("deptList", StringUtils.join(deptList, ","));
+ }
+ }
+ return map;
+ }
+
+ /**
+ * @param conn
+ * @param UUIDMap 娴佺▼鑺傜偣node琛╢e uuid 瀵瑰簲 浜у搧uuid
+ * @param tableName 琛ㄥ悕
+ * @return
+ * @throws SQLException
+ */
+ public Map<String, String> syncDetail(String tricode_funs, Connection conn, JSONObject UUIDMap, String tableName, String modelUUID, JSONObject taskIdUUID) throws SQLException {
+ 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);
+ throw e;
+ }
+ Map<String, String> stateMap = Maps.newHashMap();
+ 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"));
+ }
+ //鑺傜偣鍚嶇О
+ 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);
+ //婧恥uid锛屽叧鑱旀湰琛�
+ FieldSetEntity fieldSetEntity = OrgIdUUIDmap.get(Orlfs.getString("wi14"));
+ if (fieldSetEntity != null) {
+ DetailFs.setValue("source_uuid", fieldSetEntity.getUUID());
+ }
+ //鍒涘缓浜� 涓婁釜鑺傜偣澶勭悊浜�
+ DetailFs.setValue("created_by", userIdJson.getString(Orlfs.getString("wi15")));
+ //鑺傜偣鏍囪瘑锛�0-鏅�氾紝1-鍔犵锛�2-閫�鍥烇級
+ DetailFs.setValue("node_sign", 0);
+ String node_uuid = UUIDMap.getString(Orlfs.getString("wi62"));
+ if (BaseUtil.strIsNull(node_uuid)) {
+ continue;
+ }
+ //鍏宠仈鑺傜偣琛�
+ DetailFs.setValue("node_uuid", node_uuid);
+ //鎰忚
+ DetailFs.setValue("opinion", Orlfs.getString("wi20"));
+ //棰勬湡澶勭悊鏃堕棿锛堝皬鏃讹級
+ 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);
+ //鍏宠仈琛�
+ DetailFs.setValue("table_name", this.originalTable.getString(tableName));
+ //鍏宠仈涓氬姟UUID
+ DetailFs.setValue("record_uuid", this.pxMap.getString(tableName + Orlfs.getString("wi29")));
+ //鍏宠仈娴佺▼琛╱uid
+ DetailFs.setValue("flow_uuid", modelUUID);
+ String task_uuid = taskIdUUID.getString(Orlfs.getString("wi01"));
+ if (BaseUtil.strIsNull(task_uuid)) {
+ 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", task_uuid);
+ baseDao.add(DetailFs);
+ String wi00 = Orlfs.getString("wi00");
+ OrgIdUUIDmap.put(wi00, DetailFs);
+ stateMap.put(wi00, nodeState);
+ }
+ return stateMap;
+ }
+
+ /**
+ * 鍚屾娴佺▼娑堟伅琛�
+ */
+ public void synchronizingProcessMessages(Connection conn, String tricode_funs, Map<String, String> stateMap) throws SQLException {
+ DataTableEntity OrlDt = null;
+ 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");
+
+ OrlDt = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new String[]{tricode_funs});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ String id = null;
+ String message_uuid = null;
+ String state = null;
+ 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涓鸿鍔�
+ System.out.println(fs.getString("me20"));
+ 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");
+ }
+ message.setValue("send_user_id", sendUserId);
+ //鍒涘缓浜哄強鍙戦�佷汉
+ message.setValue("created_by", sendUserId);
+ // 涓氬姟琛�
+ message.setValue("source_table", "product_sys_flow_detail");
+
+ 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 = baseDao.add(message);
+ }
+
+ FieldSetEntity message_user = new FieldSetEntity();
+ message_user.setTableName("product_sys_message_user");
+ //鍏宠仈lx_sys_message琛║UID
+ 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);
+ baseDao.add(message_user);
+ }
+ }
+
+
+ //杩佺ЩWF_LINKS 杩炵嚎琛�
+ public void syncLinks(String tricode_funs, 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=(select wm00 from fe_base5.wf_model where wm05=(SELECT se16 FROM fe_base5.SYS_EVENT where se01=? and se08 = 1)))");
+
+ OrlDt = BaseDaoServiceImpl.getDataTable(conn, sql.toString(), new Object[]{tricode_funs
+ });
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ 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
+ System.out.println(Orlfs.getString("wl05"));
+ System.out.println(nodesIdUUID.getString(Orlfs.getString("wl05")));
+ 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 JSONObject syncTask(String tricode_funs, Connection conn, String modelUUID) throws SQLException {
+ 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);
+ throw e;
+ }
+ JSONObject map = new JSONObject();
+
+ 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);
+ //鍙戣捣鏃堕棿
+ taskFs.setValue("send_time", Orlfs.getDate("wt09"));
+ //缁撴潫鏃堕棿
+ taskFs.setValue("finish_time", Orlfs.getDate("wt10"));
+ //鍏宠仈娴佺▼琛�
+ taskFs.setValue("flow_uuid", modelUUID);
+ //瀹屾垚鏍囪瘑锛�1-鍦ㄥ姙锛�2-姝e父缁撴潫锛�3-缁堟锛�
+ taskFs.setValue("finish_type", finishType(Orlfs.getString("wt16")));
+ //鍏宠仈琛�
+ String tbName = Orlfs.getString("wt03").split("\\.")[1];
+
+ taskFs.setValue("table_name", this.originalTable.getString(tbName));
+ //褰撳墠鐜妭鑺傜偣uuid
+ taskFs.setValue("cur_node_uuid", 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", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ taskFs.setValue("created_utc_datetime", new Date());
+ String uuid = baseDao.add(taskFs);
+ map.put(Orlfs.getString("wt00"), uuid);
+ }
+ 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=utf8 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 = "string";
+ break;
+ case "PROMPT":
+ mysql_field_type = "string";
+ break;
+ case "SORT":
+ mysql_field_type = "string";
+ break;
+ case "MEDIA":
+ mysql_field_type = "string";
+ break;
+ case "SPFLAG":
+ mysql_field_type = "flowsign";
+ break;
+ case "IMAGE":
+ mysql_field_type = "text";
+ 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) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ throw new BaseException(SystemCode.SQL_START_FAILED.getValue(), SystemCode.SQL_START_FAILED.getText() + e.getMessage());
+ }
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/SyncConfigService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/SyncConfigService.java
new file mode 100644
index 0000000..54d0557
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/SyncConfigService.java
@@ -0,0 +1,163 @@
+package com.product.data.sync.service;
+
+import com.product.common.exception.job.TaskException;
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.permission.PermissionService;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.core.service.support.QueryFilterService;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.core.transfer.Transactional;
+import com.product.data.sync.config.CmnConst;
+import com.product.data.sync.service.ide.ISyncConfigService;
+import com.product.quartz.service.impl.SysJobService;
+import com.product.util.BaseUtil;
+import org.quartz.SchedulerException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+/**
+ * Copyright LX
+ *
+ * @Title: SyncConfigService
+ * @Project: product-server
+ * @date: 2021-08-11 16:35
+ * @author: ZhouJie
+ * @Description: 鏁版嵁搴撳悓姝ラ厤缃�
+ */
+@Service
+public class SyncConfigService extends AbstractBaseService implements ISyncConfigService {
+
+ @Autowired
+ public BaseDao baseDao;
+ @Autowired
+ PermissionService permissionService;
+ @Autowired
+ QueryFilterService queryFilterService;
+ @Autowired
+ SysJobService sysJobService;
+
+ @Override
+ @Transactional
+ public String saveSyncConfig(FieldSetEntity fs) throws BaseException, TaskException, SchedulerException {
+ FieldSetEntity fsjob = new FieldSetEntity();
+ fsjob.setTableName("product_sys_timed_task");
+ //鍞竴鏍囪瘑
+ String uuid = fs.getUUID();
+ //鐘舵��
+ String status = fs.getString("status");
+ String dataOriginName = fs.getString("data_origin_name");
+ String cron_expression = fs.getString("cron_expression");
+ if (BaseUtil.strIsNull(uuid)) {
+ fs.setValue("org_level_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());
+ fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fs.setValue("created_utc_datetime", new Date());
+ uuid = baseDao.add(fs);
+ //鑷姩鐢熸垚瀹氭椂浠诲姟
+ fsjob.setValue("job_name", dataOriginName + "琛ㄦ暟鎹悓姝�");//浠诲姟鍚嶇О
+ fsjob.setValue("job_group", "system");//鍒嗙粍
+ fsjob.setValue("invoke_target", "scheduledTaskExecution.getDataSync('" + fs.getUUID() + "')");//璋冪敤鐩爣瀛楃涓�
+ fsjob.setValue("cron_expression", cron_expression);//cron琛ㄨ揪寮�
+ fsjob.setValue("misfire_policy", "2");//閿欒鎵ц绛栫暐 鍙墽琛屼竴娆�
+ fsjob.setValue("concurrent", 1);//涓嶅苟鍙�
+ fsjob.setValue("remark", dataOriginName + "琛ㄦ暟鎹悓姝�");
+ fsjob.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fsjob.setValue("created_utc_datetime", new Date());
+ fsjob.setValue("status", status);
+ fsjob.setValue("is_conceal", 1);
+ sysJobService.insertJob(fsjob);
+ } else {
+ fs.setValue("updated_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fs.setValue("updated_utc_datetime", new Date());
+ DataTableEntity deleteSub = fs.getSubDataTable("deleteSub");
+ if (!BaseUtil.dataTableIsEmpty(deleteSub)) {
+ for (int i = 0; i < deleteSub.getRows(); i++) {
+ String deUuid = deleteSub.getString(i, "uuid");
+ baseDao.delete(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_SUB, new String[]{deUuid});
+ }
+ }
+ baseDao.update(fs);
+ //淇敼瀹氭椂浠诲姟涓殑cron琛ㄨ揪寮�
+ FieldSetEntity fsupjob = baseDao.getFieldSetEntityByFilter("product_sys_timed_task", "invoke_target like concat('%',?,'%')", new Object[]{fs.getUUID()}, true);
+ boolean isInert = false;
+ if (fsupjob == null) {
+ isInert = true;
+ fsupjob = new FieldSetEntity();
+ fsupjob.setTableName("product_sys_timed_task");
+ fsupjob.setValue("job_name", dataOriginName + "琛ㄦ暟鎹悓姝�");//浠诲姟鍚嶇О
+ fsupjob.setValue("job_group", "system");//鍒嗙粍
+ fsupjob.setValue("invoke_target", "scheduledTaskExecution.getDataSync('" + fs.getUUID() + "')");//璋冪敤鐩爣瀛楃涓�
+ fsupjob.setValue("misfire_policy", "2");//閿欒鎵ц绛栫暐 鍙墽琛屼竴娆�
+ fsupjob.setValue("concurrent", 1);//涓嶅苟鍙�
+ fsupjob.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fsupjob.setValue("created_utc_datetime", new Date());
+ fsupjob.setValue("is_conceal", 1);
+ }
+ fsupjob.setValue("job_name", dataOriginName + "琛ㄦ暟鎹悓姝�");//浠诲姟
+ fsupjob.setValue("remark", dataOriginName + "琛ㄦ暟鎹悓姝�");
+ fsupjob.setValue("cron_expression", cron_expression);
+ fsupjob.setValue("updated_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
+ fsupjob.setValue("updated_utc_datetime", new Date());
+ fsupjob.setValue("status", status);
+ isInert = !isInert ? sysJobService.updateJob(fsupjob) : sysJobService.insertJob(fsupjob);
+ }
+ return uuid;
+ }
+
+
+ public DataTableEntity listSyncConfig(FieldSetEntity fs) throws BaseException {
+ String queryFilter;
+ if (BaseUtil.dataTableIsEmpty(fs.getSubDataTable("systemSeniorQueryString"))) {
+ queryFilter = "";
+ } else {
+ queryFilter = queryFilterService.getQueryFilter(fs);
+ }
+ DataTableEntity dt = baseDao.listTable(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG, queryFilter, null, null, null, fs.getInteger(CmnConst.PAGESIZE), fs.getInteger(CmnConst.CPAGE));
+
+ return dt;
+ }
+
+ /**
+ * 鑾峰彇鏁版嵁鍚屾鏃ュ織
+ *
+ * @param fse
+ * @return
+ * @throws BaseException
+ */
+ public DataTableEntity getSyncLog(FieldSetEntity fse) throws BaseException {
+ return baseDao.listTable(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_LOG, "sync_config_uuid = ?", new String[]{fse.getUUID()}, " sync_time desc ");
+ }
+
+ /**
+ * 鑾峰彇鏁版嵁鍚屾鏃ュ織瀛愯〃
+ *
+ * @param fse
+ * @return
+ * @throws BaseException
+ */
+ public DataTableEntity getSyncLogSub(FieldSetEntity fse) throws BaseException {
+ return baseDao.listTable(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_LOG_SUB, " sync_config_log_uuid = ? ", new String[]{fse.getUUID()});
+ }
+
+ public FieldSetEntity getSyncConfig(FieldSetEntity fs) throws BaseException {
+ return baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG, fs.getUUID(), true);
+ }
+
+ @Override
+ @Transactional
+ public boolean delSyncConfig(FieldSetEntity fs) throws BaseException, SchedulerException {
+ String uuid = fs.getUUID();
+ FieldSetEntity fstask = baseDao.getFieldSetEntityByFilter("product_sys_timed_task", "invoke_target like concat('%',?,'%')", new Object[]{uuid}, false);
+ //瀹氭椂浠诲姟涓嶄负绌�
+ if (fstask != null) {
+ sysJobService.deleteJobByIds(new String[]{fstask.getUUID()});
+ }
+ //鍒犻櫎鏃ュ織鍙婃棩蹇楀瓙琛�
+ baseDao.delete(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_LOG, " sync_config_uuid = ? ", new String[]{uuid});
+ return baseDao.delete(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG, new String[]{uuid});
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/SyncDataService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/SyncDataService.java
new file mode 100644
index 0000000..3a0a2f5
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/SyncDataService.java
@@ -0,0 +1,36 @@
+package com.product.data.sync.service;
+
+import com.product.core.exception.BaseException;
+import com.product.data.sync.entity.SyncResultEntity;
+import com.product.data.sync.service.ide.ISyncDataService;
+
+/**
+ * @Author cheng
+ * @Date 2022/1/27 14:18
+ * @Desc
+ */
+public class SyncDataService implements ISyncDataService {
+ /**
+ * 瑕嗙洊鍚屾
+ *
+ * @return
+ * @throws BaseException
+ */
+ @Override
+ public SyncResultEntity coveringSyncData() throws BaseException {
+
+ return null;
+ }
+
+ /**
+ * 澧為噺鍚屾
+ *
+ * @return
+ * @throws BaseException
+ */
+ @Override
+ public SyncResultEntity incrementalSyncData() throws BaseException {
+ return null;
+ }
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/ViewDataProcessService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/ViewDataProcessService.java
new file mode 100644
index 0000000..4fa98bf
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/ViewDataProcessService.java
@@ -0,0 +1,509 @@
+package com.product.data.sync.service;
+
+import com.google.common.base.Joiner;
+import com.product.admin.service.OrganizationCacheService;
+import com.product.core.cache.DataPoolCacheImpl;
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.core.transfer.Transactional;
+import com.product.data.sync.config.CmnConst;
+import com.product.data.sync.service.ide.IViewDataProcessService;
+import com.product.data.sync.util.BatchData;
+import com.product.util.SystemParamReplace;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 鎶婅鍥句腑鐨勬暟鎹悓姝ュ埌瀹炰綋琛ㄤ腑
+ * 澶栭儴鏁版嵁鍚屾瀹氭椂浠诲姟鎵ц瀹屾垚鍚庤皟鐢ㄦ绫荤殑鏂规硶锛屽弬瑙�
+ *
+ * @author Administrator
+ */
+@Service
+public class ViewDataProcessService implements IViewDataProcessService {
+ @Autowired
+ public BaseDao baseDao;
+
+
+ /**
+ * 1銆佷粠杩滅▼鏁版嵁鍚屾鍒版湰鍦板簱
+ * 2銆佹煡鎵炬暟鎹鐞嗚〃product_sys_database_sync_processing_config涓叧鑱旇〃瀛楁鍚湁鍚屾琛ㄧ殑涓旂埗uuid瀛楁绛夌┖鐨勫鐞嗛厤缃俊鎭�
+ * 锛屾姝ヤ负鎶婄浉鍏宠〃杩涜鍏宠仈鏌ヨ锛屽鐞嗛儴闂ㄣ�佸叕鍙搞�佷汉鍛樹俊鎭紝姝ゆ涓哄閲忓鐞�
+ * 3銆佸啀鐢ㄧ埗uuid瀛楁绛夌┖杩欐潯璁板綍鍘绘壘涓嬩竴姝ュ鐞嗚锛屼緷娆℃槸鐢熸垚浜哄憳淇℃伅銆侀儴闂ㄤ俊鎭�佸叕鍙镐俊鎭�傛姝ヤ负鍏ㄩ噺澶勭悊
+ * product_sys_database_sync_processing_config涓殑鎵�鏈夐厤缃鐞嗘柟寮忛兘鏄粠view sql涓煡璇㈠嚭鏉ユ彃鍏ュ埌瀹炰綋琛ㄤ腑
+ * 瑙嗗浘sql鏌ヨ鍑烘潵鐨勫瓧娈典笌瀹炰綋琛ㄤ腑鐨勫瓧娈靛悕蹇呴』涓�鑷�
+ *
+ * @param aimTable
+ */
+ @Override
+ @Transactional
+ public void copyViewDataToTable(String aimTable) {
+ OrgDataMap orgDataMap = null;
+ if (StringUtils.isEmpty(aimTable.trim())) {
+ return;
+ }
+ ExecutorService executorService = null;
+ DataTableEntity dt = baseDao.listTable("product_sys_database_sync_processing_config", "concat(',',relevance_table,',') like concat('%,',?,',%') and (parent_uuid is null or parent_uuid ='')", new Object[]{aimTable});
+ if (!dt.isEmpty()) {
+ for (int i = 0; i < dt.getRows(); i++) {
+ FieldSetEntity fs = dt.getFieldSetEntity(i);
+ String basic_table = fs.getString("relevance_table");
+ if (!StringUtils.isEmpty(basic_table.trim())) {
+ String bts[] = basic_table.split(",");
+ //瀵瑰簲鍒悕
+ Map<String, String> aliash = new HashMap<String, String>();
+ if (!StringUtils.isEmpty(fs.getString("table_alias"))) {
+ String alias[] = fs.getString("table_alias").split(",");
+ for (int k = 0; k < bts.length; k++) {
+ if (alias.length > k) {
+ if (alias[k] == null) {
+ continue;
+ }
+ aliash.put(bts[k], alias[k]);
+ }
+ }
+ }
+ Integer num = fs.getInteger("execute_count");
+ if (bts.length == num.intValue() && !StringUtils.isEmpty(fs.getString("template_sql"))) {//鐩哥瓑璇存槑涓変釜琛ㄩ兘鏇存柊瀹�
+ DataTableEntity sdt = baseDao.listTable("product_sys_database_sync_processing_config_sub", "main_uuid =? ", new String[]{fs.getUUID()});
+ FieldSetEntity table_filter = new FieldSetEntity();
+ table_filter.setTableName("temp");
+ StringBuilder b = new StringBuilder();
+ for (int j = 0; j < sdt.getRows(); j++) {
+ FieldSetEntity fss = sdt.getFieldSetEntity(j);
+ String pkf = baseDao.getPKField(fss.getString("table_name"));//鑾峰彇琛ㄧ殑pk瀛楁
+ if (pkf != null) {
+ if (!StringUtils.isEmpty(aliash.get(fss.getString("table_name")))) {
+ pkf = aliash.get(fss.getString("table_name")) + "." + pkf;
+ }
+ if (!StringUtils.isEmpty(fss.getString("update_ids"))) {//鏈変慨鏀逛簡鏁版嵁
+ if (b.length() > 0) {
+ b.append(" or ");
+ }
+ b.append(pkf).append(" in (").append(fss.getString("update_ids")).append(")");
+ }
+ if (!StringUtils.isEmpty(fss.getString("add_scope_id"))) {//鏈夋柊澧炴暟鎹�
+ if (b.length() > 0) {
+ b.append(" or ");
+ }
+ String scope[] = fss.getString("add_scope_id").split("~");
+ b.append(pkf).append(" between ").append(scope[0]).append(" and ").append(scope[1]);
+ }
+ } else {
+ //娌℃湁涓婚敭瀛楁锛屾槸鍚︽姏閿�
+ SpringMVCContextHolder.getSystemLogger().error("銆�" + fss.getString("table_name") + "銆戣〃娌℃湁閰嶇疆PK瀛楁銆�");
+ }
+ }
+ //鐢熸垚涓�涓�荤殑鏉′欢琛ㄨ揪寮忥紝濡傛灉娌℃湁锛屽垯continue;
+ if (b.length() > 0) {
+ table_filter.setValue("sync_data_process_data_filter", b.toString());
+ } else {
+// continue;
+ table_filter.setValue("sync_data_process_data_filter", "1=1");
+ }
+ //寮�濮嬫浛鎹iew璇彞涓殑鏉′欢琛ㄨ揪寮�
+ String sql = SystemParamReplace.formParamsReplace(fs.getString("template_sql"), table_filter);
+ if (executorService == null) {
+ executorService = Executors.newFixedThreadPool(2);
+ }
+ if (orgDataMap == null) {
+ orgDataMap = new OrgDataMap();
+ }
+ OrgDataMap finalOrgDataMap = orgDataMap;
+ executorService.execute(() -> {
+ BatchData batchData = new BatchData(sql, fs.getString("basic_table"), 50000, 2000);
+ batchData.getDefaultValueMap().put("organization_type", 4);
+ batchData.getDefaultValueMap().put("dept_code", null);
+
+ fs.setValue("execute_count", 0);
+ baseDao.update(fs);
+ //寮�濮嬪鐞嗘暟鎹敓鎴愪汉鍛�,浠庡悓姝ヨ〃鍒版姤琛ㄥ熀纭�琛�
+ batchData.batchImprovedCoverage(fs.getBoolean("delete_data"), (obj) -> {
+ Map<String, Object> map = (Map<String, Object>) obj[0];
+ String user_id = null;
+ if (map.get("user_id") != null) {
+ user_id = String.valueOf(map.get("user_id"));
+ }
+ if (map.get(CmnConst.ORG_LEVEL_CODE) != null && map.containsKey(CmnConst.USER_ID) && map.containsKey("dept_code")) {
+ String code = (String) map.get(CmnConst.ORG_LEVEL_CODE);
+ if (finalOrgDataMap.isCompany(code)) {
+ if (user_id != null) {
+ String deptCode = finalOrgDataMap.getDeptCodeByUser(user_id);
+ if (!StringUtils.isEmpty(deptCode)) {
+ map.put("dept_code", deptCode);
+ }
+ }
+ } else if (finalOrgDataMap.isDept(code)) {
+ String companyCode = finalOrgDataMap.getCompanyCode(code);
+ if (StringUtils.isEmpty(companyCode)) {
+ companyCode = finalOrgDataMap.getCompanyCodeByUser(user_id);
+ }
+ if (!StringUtils.isEmpty(companyCode)) {
+ map.put(CmnConst.ORG_LEVEL_CODE, companyCode);
+ map.put("dept_code", code);
+ }
+ }
+ }
+ });
+ batchData.closeConnection();
+ //澶勭悊鏁版嵁鐢熸垚浜哄憳鏁版嵁锛屼粠鍚屾琛ㄥ埌鎶ヨ〃鍩虹琛紝鍐嶇敓鎴愰儴闂ㄣ�佸叕鍙告暟鎹紝鎶ヨ〃鍩虹琛ㄥ唴瀹瑰鐞�
+ lastProcessData(fs.getUUID());
+ baseDao.delete("product_sys_database_sync_processing_config_sub", "main_uuid=?", new Object[]{fs.getUUID()});
+ });
+
+ }
+ }
+ }
+ if (executorService != null) {
+ executorService.shutdown();
+ try {
+ executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().error("鍚屾澶勭悊鏁版嵁瀹屾垚锛侊紒锛�");
+ }
+ }
+
+
+ public class OrgDataMap {
+
+ private Map<String, FieldSetEntity> companyMap = new HashMap<>();
+
+ private Map<String, FieldSetEntity> deptMap = new HashMap<>();
+
+ private Map<String, String> staffDeptMap = new HashMap<>();
+
+ private Map<String, String> staffCompanyMap = new HashMap<>();
+
+ public OrgDataMap() {
+ //鍒濆鍖栫粍缁囨満鏋勮〃鏁版嵁
+ DataPoolCacheImpl dataPoolCache = DataPoolCacheImpl.getInstance();
+// DataTableEntity companyDt = dataPoolCache.getCacheData("鎵�鏈夊叕鍙镐俊鎭�");
+ DataTableEntity companyDt = OrganizationCacheService.getOrgDataStatic("1");
+ readRecord(companyDt, this.companyMap);
+// DataTableEntity deptDt = dataPoolCache.getCacheData("鍏徃-閮ㄩ棬");
+ DataTableEntity deptDt = OrganizationCacheService.getOrgDataStatic("2");
+ readRecord(deptDt, this.deptMap);
+ DataTableEntity dt = baseDao.listTable("SELECT user_id,l.org_level_code dept_code,l1.org_level_code company_code FROM `product_sys_staffs` s join product_sys_org_levels l on s.dept_uuid=l.uuid \n" +
+ "join product_sys_org_levels l1 on s.org_level_uuid=l1.uuid ", new Object[]{});
+ if (!DataTableEntity.isEmpty(dt)) {
+ DataTableEntity clones = dt.clones();
+ for (int i = 0; i < clones.getRows(); i++) {
+ this.staffDeptMap.put(clones.getString(i, "user_id"), clones.getString(i, "dept_code"));
+ this.staffCompanyMap.put(clones.getString(i, "user_id"), clones.getString(i, "company_code"));
+ }
+ }
+ }
+
+ /**
+ * 鏍规嵁userid鎵鹃儴闂╟ode
+ *
+ * @param userId
+ * @return
+ */
+ public String getDeptCodeByUser(String userId) {
+ return this.staffDeptMap.get(userId);
+ }
+
+ /**
+ * 鏍规嵁userid鎵鹃儴闂╟ode
+ *
+ * @param userId
+ * @return
+ */
+ public String getCompanyCodeByUser(String userId) {
+ return this.staffCompanyMap.get(userId);
+ }
+
+ /**
+ * 鑾峰彇鍏徃缂栫爜鏍规嵁閮ㄩ棬缂栫爜
+ *
+ * @param deptCode
+ * @return
+ */
+ public String getCompanyCode(String deptCode) {
+ if (isExist(deptCode, this.deptMap)) {
+ FieldSetEntity fs = this.deptMap.get(deptCode);
+ String parentCode = fs.getString("org_level_code_parent");
+ String[] code = parentCode.split("-");
+ for (int i = 0; i < code.length; i++) {
+ parentCode = "";
+ for (int j = 0; j < code.length - i; j++) {
+ parentCode = (j > 0 ? parentCode + "-" : parentCode) + code[j];
+ }
+ if (isExist(parentCode, this.companyMap)) {
+ return this.companyMap.get(parentCode).getString(CmnConst.ORG_LEVEL_CODE);
+ }
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * 鍒ゆ柇鏄惁涓洪儴闂�
+ *
+ * @param code
+ * @return
+ */
+ public boolean isDept(String code) {
+ return isExist(code, this.deptMap);
+ }
+
+ /**
+ * 鍒ゆ柇鏄惁涓哄叕鍙�
+ *
+ * @param code
+ * @return
+ */
+ public boolean isCompany(String code) {
+ return isExist(code, this.companyMap);
+ }
+
+ /**
+ * 鏄惁瀛樺湪
+ *
+ * @param code 閿�
+ * @param map 鏄惁瀛樺湪姝ap
+ * @return
+ */
+ private boolean isExist(String code, Map<String, FieldSetEntity> map) {
+ return code != null ? map.get(code) != null : false;
+ }
+
+
+ }
+
+
+ private void readRecord(DataTableEntity dt, Map<String, FieldSetEntity> map) {
+ if (DataTableEntity.isEmpty(dt) || map == null) return;
+ for (int i = 0; i < dt.getRows(); i++) {
+ FieldSetEntity fs = dt.getFieldSetEntity(i);
+ String code = fs.getString(CmnConst.ORG_LEVEL_CODE);
+ map.put(code, fs.clones());
+ }
+ }
+
+ /**
+ * 浜屾澶勭悊鏁版嵁鏍规嵁宸插鐞嗙殑鍩虹琛�
+ */
+
+ public void firstProcessData() {
+ DataTableEntity dt = baseDao.listTable("product_sys_database_sync_processing_config", " (parent_uuid is null or parent_uuid ='')", new Object[]{});
+ OrgDataMap orgDataMap = new OrgDataMap();
+ FieldSetEntity table_filter = new FieldSetEntity();
+ table_filter.setTableName("temp");
+ table_filter.setValue("sync_data_process_data_filter", "1=1");
+ ExecutorService executorService = Executors.newFixedThreadPool(10);
+ for (int i = 0; i < dt.getRows(); i++) {
+ int finalI = i;
+ executorService.execute(() -> {
+ FieldSetEntity fs = dt.getFieldSetEntity(finalI);
+ String sql = SystemParamReplace.formParamsReplace(fs.getString("template_sql"), table_filter);
+ BatchData batchData = new BatchData(sql, fs.getString("basic_table"), 100000, 2000);
+ batchData.getDefaultValueMap().put("organization_type", 4);
+ batchData.getDefaultValueMap().put("dept_code", null);
+ OrgDataMap finalOrgDataMap = orgDataMap;
+ //寮�濮嬪鐞嗘暟鎹敓鎴愪汉鍛�,浠庡悓姝ヨ〃鍒版姤琛ㄥ熀纭�琛�
+ batchData.batchImprovedCoverage(fs.getBoolean("delete_data"), (obj) -> {
+ Map<String, Object> map = (Map<String, Object>) obj[0];
+ String user_id = null;
+ if (map.get("user_id") != null) {
+ user_id = String.valueOf(map.get("user_id"));
+ }
+ if (map.get(CmnConst.ORG_LEVEL_CODE) != null && map.containsKey(CmnConst.USER_ID) && map.containsKey("dept_code")) {
+ String code = (String) map.get(CmnConst.ORG_LEVEL_CODE);
+ if (finalOrgDataMap.isCompany(code)) {
+ if (user_id != null) {
+ String deptCode = finalOrgDataMap.getDeptCodeByUser(user_id);
+ if (StringUtils.isEmpty(deptCode)) {
+ map.put("dept_code", deptCode);
+ }
+ }
+ } else if (finalOrgDataMap.isDept(code)) {
+ String companyCode = finalOrgDataMap.getCompanyCode(code);
+ if (StringUtils.isEmpty(companyCode)) {
+ companyCode = finalOrgDataMap.getCompanyCodeByUser(user_id);
+ }
+ if (!StringUtils.isEmpty(companyCode)) {
+ map.put(CmnConst.ORG_LEVEL_CODE, companyCode);
+ map.put("dept_code", code);
+ }
+ }
+ }
+ });
+ batchData.closeConnection();
+ //澶勭悊鏁版嵁鐢熸垚浜哄憳鏁版嵁锛屼粠鍚屾琛ㄥ埌鎶ヨ〃鍩虹琛紝鍐嶇敓鎴愰儴闂ㄣ�佸叕鍙告暟鎹紝鎶ヨ〃鍩虹琛ㄥ唴瀹瑰鐞�
+ lastProcessData(fs.getUUID());
+ });
+
+ }
+ executorService.shutdown();
+ while (!executorService.isTerminated()) {
+
+ }
+ SpringMVCContextHolder.getSystemLogger().info("缁撴潫浠诲姟firstProcessData锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒");
+ }
+
+ /**
+ * 鏍规嵁 product_sys_database_sync_processing_config.uuid 鎵ц鏁版嵁澶勭悊
+ */
+
+ public void firstProcessData(String parent_uuid) {
+ FieldSetEntity fs = baseDao.getFieldSetByFilter("product_sys_database_sync_processing_config", "parent_uuid=?", new Object[]{parent_uuid}, false);
+ if (fs != null) {
+ firstProcessData(fs);
+ }
+ }
+
+ /**
+ * 鏍规嵁 product_sys_database_sync_processing_config琛ㄤ俊鎭� 鎵ц鏁版嵁澶勭悊
+ */
+
+ public void firstProcessData(FieldSetEntity fs) {
+ if (fs == null) {
+ return;
+ }
+ OrgDataMap orgDataMap = new OrgDataMap();
+ BatchData batchData = new BatchData(fs.getString("template_sql"), fs.getString("basic_table"), 100000, 2000);
+ batchData.getDefaultValueMap().put("organization_type", 4);
+ if (orgDataMap == null) {
+ orgDataMap = new OrgDataMap();
+ }
+ OrgDataMap finalOrgDataMap = orgDataMap;
+ batchData.getDefaultValueMap().put("dept_code", null);
+ batchData.batchImprovedCoverage(true, (obj) -> {
+ Map<String, Object> map = (Map<String, Object>) obj[0];
+ String user_id = null;
+ if (map.get("user_id") != null) {
+ user_id = String.valueOf(map.get("user_id"));
+ }
+
+ if (map.get(CmnConst.ORG_LEVEL_CODE) != null && map.containsKey(CmnConst.USER_ID) && map.containsKey("dept_code")) {
+ String code = (String) map.get(CmnConst.ORG_LEVEL_CODE);
+ if (finalOrgDataMap.isCompany(code)) {
+ if (user_id != null) {
+ String deptCode = finalOrgDataMap.getDeptCodeByUser(user_id);
+ if (StringUtils.isEmpty(deptCode)) {
+ map.put("dept_code", deptCode);
+ }
+ }
+ } else if (finalOrgDataMap.isDept(code)) {
+
+ String companyCode = finalOrgDataMap.getCompanyCode(code);
+ if (StringUtils.isEmpty(companyCode)) {
+ companyCode = finalOrgDataMap.getCompanyCodeByUser(user_id);
+ }
+ if (!StringUtils.isEmpty(companyCode)) {
+ map.put(CmnConst.ORG_LEVEL_CODE, companyCode);
+ map.put("dept_code", code);
+ }
+ }
+ }
+ });
+ batchData.closeConnection();
+ lastProcessData(fs.getUUID());
+ baseDao.update(fs);
+ baseDao.delete("product_sys_database_sync_processing_config_sub", "main_uuid=?", new Object[]{fs.getUUID()});
+ }
+
+ public void lastProcessData(String parentUuid) {
+ DataTableEntity dt = baseDao.listTable("product_sys_database_sync_processing_config", "parent_uuid=?", new Object[]{parentUuid});
+ for (int i = 0; i < dt.getRows(); i++) {
+ FieldSetEntity ff = dt.getFieldSetEntity(i);
+ if (ff != null && ff.getUUID() != null) {
+ this.executeDataProcess(ff.getString("template_sql"), ff.getString("basic_table"), ff.getBoolean("delete_data"));
+ this.lastProcessData(ff.getUUID());
+ }
+ }
+ }
+
+
+ private void executeDataProcess(String sql, String basic_table, boolean deleteData) {
+ BatchData batchData = new BatchData(sql, basic_table, 50000, 2000);
+ batchData.batchImprovedCoverage(deleteData, null);
+ batchData.closeConnection();
+ }
+
+ /**
+ * 鏇存柊鍚屾璁板綍
+ *
+ * @param tableName 鍚屾鐩爣琛�
+ * @param add_ids 鍚屾淇敼鎴栨柊澧炵殑鏁版嵁ids
+ * @param updateIds 鏇存柊鏁版嵁鐨刬ds 閫楀彿鍒嗛殧
+ */
+ @Override
+ @Transactional
+ public void updateSyncRecord(String tableName, Integer[] add_ids, String updateIds) throws BaseException {
+ DataTableEntity dt = baseDao.listTable("product_sys_database_sync_processing_config", "concat(',',relevance_table,',') like concat('%,',?,',%') and (parent_uuid is null or parent_uuid ='')", new Object[]{tableName});
+ if (!DataTableEntity.isEmpty(dt)) {
+ for (int i = 0; i < dt.getRows(); i++) {
+ if (!StringUtils.isEmpty(updateIds) || (add_ids != null && add_ids.length > 0)) {
+ FieldSetEntity fs = new FieldSetEntity();
+ fs.setTableName("product_sys_database_sync_processing_config_sub");
+ fs.setValue(CmnConst.TABLE_NAME, tableName);
+ if (add_ids != null && add_ids.length > 0) {
+ List<String> idScope = summaryRanges(add_ids);
+ fs.setValue("add_scope_id", Joiner.on(",").join(idScope.toArray()));
+ }
+ fs.setValue("update_ids", updateIds);
+
+ DataTableEntity dataTableEntity = new DataTableEntity();
+ dataTableEntity.addFieldSetEntity(fs);
+ dt.getFieldSetEntity(i).addSubDataTable(dataTableEntity);
+ }
+ //鎵ц娆℃暟+1
+ Integer execute_count = dt.getInt(i, "execute_count");
+ if (execute_count == null) {
+ execute_count = 1;
+ } else {
+ execute_count++;
+ }
+ dt.setFieldValue(i, "execute_count", execute_count);
+ baseDao.update(dt.getFieldSetEntity(i));
+ }
+ }
+ this.copyViewDataToTable(tableName);
+ }
+
+ /**
+ * 鑾峰彇鏁扮粍涓暟瀛楃殑鑼冨洿
+ *
+ * @param nums 鏁扮粍
+ * @return
+ */
+ public static List<String> summaryRanges(Integer[] nums) {
+ Arrays.sort(nums);
+ List<String> list = new ArrayList<>();
+ if (nums.length == 0) {
+ return list;
+ }
+ int begin = Integer.MIN_VALUE;
+ int end = Integer.MIN_VALUE;
+ for (int i = 0; i < nums.length; i++) {
+ if (i == 0) {
+ begin = nums[i];
+ } else if (nums[i - 1] < nums[i] - 1) {
+ list.add(begin + "~" + end);
+ begin = nums[i];
+ }
+ end = nums[i];
+ if (i == nums.length - 1) {
+ list.add(begin + "~" + end);
+ }
+ }
+ return list;
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IConnectionConfigurationService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IConnectionConfigurationService.java
new file mode 100644
index 0000000..ab1c159
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IConnectionConfigurationService.java
@@ -0,0 +1,60 @@
+package com.product.data.sync.service.ide;
+
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+
+import java.sql.SQLException;
+
+/**
+ * Copyright LX-BASE
+ *
+ * @Title: IConnectionConfigurationService
+ * @Project: LX-BASE-SERVER
+ * @Date: 2021-08-18 11:30:48
+ * @Author: luoxin
+ * @Description: 鏁版嵁婧愯繛鎺ユ帴鍙�
+ */
+public interface IConnectionConfigurationService {
+
+
+ /**
+ * 淇濆瓨鏁版嵁搴撻厤缃繛鎺�
+ * @param
+ * @return
+ * @throws BaseException
+ */
+ String saveConnectionConfiguration(FieldSetEntity fieldSetEntity) throws BaseException, SQLException, ClassNotFoundException;
+
+ /**
+ * 鑾峰彇鏁版嵁搴撻厤缃繛鎺ュ垪琛�
+ * @param
+ * @return
+ * @throws BaseException
+ */
+ DataTableEntity listConnectionConfiguration(FieldSetEntity fieldSetEntity) throws BaseException;
+
+ /**
+ * 鑾峰彇鏁版嵁搴撻厤缃繛鎺ヨ鎯�
+ * @param
+ * @return
+ * @throws BaseException
+ */
+ FieldSetEntity getConnectionConfiguration(FieldSetEntity fieldSetEntity) throws BaseException;
+
+ /**
+ * 鍒犻櫎鏁版嵁搴撻厤缃繛鎺ヨ鎯�
+ * @param
+ * @return
+ * @throws BaseException
+ */
+ boolean delConnectionConfiguration(FieldSetEntity fieldSetEntity) throws BaseException;
+
+ /**
+ * 閫氳繃琛ㄥ悕鎴栬�呭瓧娈碉紝鍐嶄繚瀛樹负鍙傜収
+ * @param
+ * @return
+ * @throws BaseException
+ */
+ Boolean saveField(FieldSetEntity fieldSetEntity) throws BaseException, SQLException, ClassNotFoundException;
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IFunctionSynchrService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IFunctionSynchrService.java
new file mode 100644
index 0000000..b5ecf34
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IFunctionSynchrService.java
@@ -0,0 +1,9 @@
+package com.product.data.sync.service.ide;
+
+import com.product.core.entity.FieldSetEntity;
+
+import java.sql.SQLException;
+
+public interface IFunctionSynchrService {
+ FieldSetEntity syncFuntion(FieldSetEntity fse) throws SQLException, ClassNotFoundException;
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyFeDataService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyFeDataService.java
new file mode 100644
index 0000000..44fc72f
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyFeDataService.java
@@ -0,0 +1,10 @@
+package com.product.data.sync.service.ide;
+
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.transfer.Transactional;
+
+import java.sql.SQLException;
+
+public interface ISyFeDataService {
+ String saveSyncFedata(FieldSetEntity fs) throws SQLException, ClassNotFoundException;
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyncConfigService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyncConfigService.java
new file mode 100644
index 0000000..aae6e07
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyncConfigService.java
@@ -0,0 +1,33 @@
+package com.product.data.sync.service.ide;
+
+import com.product.common.exception.job.TaskException;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import org.quartz.SchedulerException;
+
+/**
+ * @author: ZhouJie
+ * @date: 2021/8/11 16:36
+ * @description: 鏁版嵁搴撳悓姝ラ厤缃�
+ */
+public interface ISyncConfigService {
+
+ /**
+ * 淇濆瓨鏁版嵁搴撳悓姝ラ厤缃�
+ * @param
+ * @return
+ * @throws BaseException
+ */
+ String saveSyncConfig(FieldSetEntity fieldSetEntity) throws BaseException, TaskException, SchedulerException;
+
+
+ /**
+ * 鍒犻櫎鏁版嵁搴撳悓姝ラ厤缃�
+ * @param
+ * @return
+ * @throws BaseException
+ */
+ boolean delSyncConfig(FieldSetEntity fieldSetEntity) throws BaseException, SchedulerException;
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyncDataService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyncDataService.java
new file mode 100644
index 0000000..7080887
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/ISyncDataService.java
@@ -0,0 +1,29 @@
+package com.product.data.sync.service.ide;
+
+import com.product.core.exception.BaseException;
+import com.product.data.sync.entity.SyncResultEntity;
+
+/**
+ * @Author cheng
+ * @Date 2022/1/27 10:15
+ * @Desc
+ */
+public interface ISyncDataService {
+ /**
+ * 瑕嗙洊鍚屾
+ *
+ * @return
+ * @throws BaseException
+ */
+ SyncResultEntity coveringSyncData() throws BaseException;
+
+ /**
+ * 澧為噺鍚屾
+ *
+ * @return
+ * @throws BaseException
+ */
+ SyncResultEntity incrementalSyncData() throws BaseException;
+
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IViewDataProcessService.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IViewDataProcessService.java
new file mode 100644
index 0000000..1ee9c4b
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/ide/IViewDataProcessService.java
@@ -0,0 +1,14 @@
+package com.product.data.sync.service.ide;
+
+import com.product.core.exception.BaseException;
+
+/**
+ * @author: ZhouJie
+ * @date: 2021/8/11 16:36
+ * @description: 鏁版嵁鍚屾澶勭悊
+ */
+public interface IViewDataProcessService {
+ public void copyViewDataToTable(String aimTable) throws BaseException;
+
+ void updateSyncRecord(String tableName, Integer[] add_ids, String updateIds) throws BaseException;
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/media/EncrypUtil.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/media/EncrypUtil.java
new file mode 100644
index 0000000..0279da6
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/media/EncrypUtil.java
@@ -0,0 +1,49 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package com.product.data.sync.service.media;
+
+
+public class EncrypUtil {
+ public static String password = "123456";
+
+ public EncrypUtil() {
+ }
+
+ public static String setFingerprint(String text) {
+ String value = MD5Util.digest(text);
+ return text + value;
+ }
+
+ public static boolean isFingerprint(String text) {
+ if (text != null && !text.equals("")) {
+ if (text.length() < 33) {
+ return false;
+ } else {
+ String value = text.substring(0, text.length() - 32);
+ return text.equals(setFingerprint(value));
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public static String getFingerValue(String text) {
+ if (text != null && !text.equals("")) {
+ return text.length() < 33 ? null : text.substring(0, text.length() - 32);
+ } else {
+ return null;
+ }
+ }
+
+ public static void main(String[] args) {
+ String v = setFingerprint("6A0C140A");
+ System.out.println(v);
+ boolean v1 = isFingerprint(v);
+ String v2 = getFingerValue(v);
+ System.out.println(v1);
+ System.out.println(v2);
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/media/Encryption.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/media/Encryption.java
new file mode 100644
index 0000000..64cb0a4
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/media/Encryption.java
@@ -0,0 +1,386 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package com.product.data.sync.service.media;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.UnsupportedEncodingException;
+
+public class Encryption {
+ private int intPrivateKey = 0;
+ private static final long MaxInt = (long)Math.pow(2.0D, 32.0D);
+ private int[] intConstKey = new int[]{1556696929, 1266038903, 1265722019, 1265722531, 1265658509, 1265282947, 1263528397, 1263599759, 1263487033, 1263648241, 1262235517, 1262210177, 1261371079, 1261525493, 1261118363, 1260675071, 1260706169, 1260299731, 1260230359, 1259026997, 1258887283, 1258865891, 1258626371, 1258503781, 1258482227, 1258579643, 1258190971, 1258098757, 1257611279, 1257724121, 1257273319, 1257361279, 1256913187, 1256892151, 1256455111, 1256408429, 1060988843, 1028046497, 1059548141, 1059702103, 1059282011, 1057910353, 1057261279, 1056410731, 1027302959, 1056241757, 1053532217, 1053109769, 1052145631, 1052156549, 1052311109, 1052138359, 1051307749, 1051455023, 1030905121, 1030546703, 1030613851, 1030517641, 1029296581, 1029412469, 1028968387, 1028847733, 1028118731, 1028044769};
+ private int[] intUserKey = new int[64];
+ private int[] intPosition = new int[64];
+ private static int encryptionInfo = 3;
+ private static long readTimer = 0L;
+ public static final long lngREMAINTIMER = 600000L;
+ public static final long abc = Long.parseLong("7776000000");
+
+ public Encryption(String strKey) {
+ int[] intData = this.getStringLong(strKey);
+ this.intPrivateKey = 0;
+ int i;
+ if (intData != null) {
+ for(i = 0; i < intData.length; ++i) {
+ this.intPrivateKey ^= intData[i];
+ }
+ }
+
+ intData = this.getStringLong(String.valueOf(this.intPrivateKey));
+
+ for(i = 0; i < intData.length; ++i) {
+ this.intPrivateKey ^= intData[i];
+ }
+
+ this.processKeyGene();
+ }
+
+ public Encryption() {
+ }
+
+ public int[] getStringLong(String strString) {
+ byte[] byteString = strString.getBytes();
+ int intI = 0;
+ int intIndex = -1;
+ if (byteString.length == 0) {
+ return null;
+ } else {
+ int[] intData;
+ int intByte;
+ for(intData = new int[(byteString.length - 1) / 4 + 1]; intI < byteString.length; intData[intIndex] = (intData[intIndex] << 8) + intByte) {
+ if (intI % 4 == 0) {
+ ++intIndex;
+ intData[intIndex] = 0;
+ }
+
+ intByte = byteString[intI++];
+ if (intByte < 0) {
+ intByte += 256;
+ }
+ }
+
+ return intData;
+ }
+ }
+
+ public String getLongString(int[] intData) {
+ String strData = "";
+ if (intData != null) {
+ int[] intLocation = new int[]{-16777216, 16711680, 65280, 255};
+ int[] intMove = new int[]{24, 16, 8, 0};
+ int intIndex = 0;
+ int intI = 0;
+ int intLen = (intData.length - 1) * 4 + 1;
+ int tmp = intData[intData.length - 1];
+ if (tmp < 0) {
+ intLen += 3;
+ } else {
+ while(tmp > 255) {
+ ++intLen;
+ tmp >>= 8;
+ }
+ }
+
+ byte[] bytString = new byte[intLen];
+ intLen = 0;
+
+ while(intI < intData.length - 1) {
+ bytString[intLen++] = (byte)((intData[intI] & intLocation[intIndex]) >> intMove[intIndex]);
+ ++intIndex;
+ if (intIndex > 3) {
+ ++intI;
+ intIndex = 0;
+ }
+ }
+
+ tmp = intData[intData.length - 1];
+
+ for(intI = bytString.length - 1; intI >= intLen; --intI) {
+ bytString[intI] = (byte)(tmp & 255);
+ tmp >>= 8;
+ }
+ try {
+ //榛樿宸ヤ綔绌洪棿瀛楃闆�
+ strData = new String(bytString,"GBK");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ }
+
+ return strData;
+ }
+
+ public int[] getHexLong(String strHex) {
+ if (strHex.length() == 0) {
+ return null;
+ } else {
+ int[] intData = new int[(strHex.length() - 1) / 8 + 1];
+ String strSubHex = "";
+
+ for(int i = 0; i < strHex.length(); i += 8) {
+ if (i + 8 < strHex.length()) {
+ strSubHex = strHex.substring(i, i + 8);
+ } else {
+ strSubHex = strHex.substring(i);
+ }
+
+ intData[i / 8] = (int)Long.parseLong(strSubHex, 16);
+ }
+
+ return intData;
+ }
+ }
+
+ public String getLongHex(int[] intData) {
+ String strHex = "";
+ String strSubHex = "";
+ if (intData != null) {
+ for(int i = 0; i < intData.length - 1; ++i) {
+ strSubHex = Integer.toHexString(intData[i]).toUpperCase();
+
+ for(int j = strSubHex.length(); j < 8; ++j) {
+ strSubHex = "0" + strSubHex;
+ }
+
+ strHex = strHex + strSubHex;
+ }
+
+ strSubHex = Integer.toHexString(intData[intData.length - 1]).toUpperCase();
+ if (strSubHex.length() % 2 != 0) {
+ strSubHex = "0" + strSubHex;
+ }
+
+ strHex = strHex + strSubHex;
+ }
+
+ return strHex;
+ }
+
+ private void processKeyGene() {
+ boolean[] blnInGene = new boolean[64];
+ int intGCount = -1;
+ int[] intGene = new int[64];
+ String strPrivateKey = String.valueOf(this.intPrivateKey);
+
+ int i;
+ for(i = 0; i < 64; ++i) {
+ this.intUserKey[i] = this.intConstKey[i];
+ blnInGene[i] = false;
+ this.intPosition[i] = i;
+ intGene[i] = -1;
+ }
+
+ int intG;
+ for(i = 0; i < strPrivateKey.length(); ++i) {
+ if (strPrivateKey.substring(i, i + 1).equals("-")) {
+ intG = 0;
+ } else {
+ intG = Integer.parseInt(strPrivateKey.substring(i, i + 1));
+ }
+
+ if (!blnInGene[intG]) {
+ blnInGene[intG] = true;
+ this.intPrivateKey ^= this.intUserKey[intG];
+ ++intGCount;
+ intGene[intGCount] = intG;
+ }
+ }
+
+ int intCount = intGCount;
+
+ int j;
+ for(i = 0; i <= intCount; ++i) {
+ if (intGene[i] > 0 && intGene[i] < 7) {
+ for(j = 0; j <= intCount; ++j) {
+ intG = intGene[i] * 10 + intGene[j];
+ if (intG < 64 && !blnInGene[intG]) {
+ ++intGCount;
+ intGene[intGCount] = intG;
+ this.intPrivateKey ^= this.intUserKey[intG];
+ }
+ }
+ }
+ }
+
+ ++intGCount;
+
+ for(i = 0; i < 64; ++i) {
+ j = (int)((double)intGene[i % intGCount] * Math.pow((double)i, 2.0D)) & 31;
+ intG = this.intUserKey[i];
+ this.intUserKey[i] = this.intUserKey[j];
+ this.intUserKey[j] = intG;
+ intG = this.intPosition[i];
+ this.intPosition[i] = this.intPosition[j];
+ this.intPosition[j] = intG;
+ }
+
+ }
+
+ public String encryptString(String strString, boolean blnGetHex) {
+ if (EncrypUtil.isFingerprint(strString)) {
+ return EncrypUtil.getFingerValue(strString);
+ } else {
+ return blnGetHex ? this.getLongHex(this.encryptData(this.getStringLong(strString), true)) : this.getLongString(this.encryptData(this.getStringLong(strString), true));
+ }
+ }
+
+ public String encryptString(String strString) {
+ return this.getLongString(this.encryptData(this.getStringLong(strString), true));
+ }
+
+ public String decryptionString(String strString, boolean blnIsHex) {
+ return blnIsHex ? this.getLongString(this.encryptData(this.getHexLong(strString), false)) : this.getLongString(this.encryptData(this.getStringLong(strString), false));
+ }
+
+ public String decryptionString(String strString) {
+ return this.getLongString(this.encryptData(this.getStringLong(strString), false));
+ }
+
+ public int[] encryptData(int[] intData, boolean blnEncryption) {
+ if (intData == null) {
+ return null;
+ } else {
+ int intLen = intData.length;
+ int[] intEncryptData = new int[intLen];
+ int[] intModPosition = (int[])null;
+ int intMod = intLen & 63;
+ int i;
+ int j;
+ if (intMod > 0) {
+ intModPosition = new int[intMod];
+ i = -1;
+
+ for(j = 0; j < 64; ++j) {
+ if (this.intPosition[j] < intMod) {
+ ++i;
+ intModPosition[i] = this.intPosition[j];
+ }
+ }
+ }
+
+ if (blnEncryption) {
+ for(i = 0; i < intLen; ++i) {
+ if (intLen - i > 63) {
+ for(j = 0; j < 64; ++j) {
+ intEncryptData[i + j] = intData[i + this.intPosition[j]] ^ this.intPrivateKey ^ this.intUserKey[j];
+ }
+
+ i += 63;
+ } else {
+ for(j = 0; j < intLen - i; ++j) {
+ intEncryptData[i + j] = intData[i + intModPosition[j]] ^ this.intPrivateKey ^ this.intUserKey[j];
+ }
+
+ i = intLen;
+ }
+ }
+ } else {
+ for(i = 0; i < intData.length; ++i) {
+ if (intLen - i > 63) {
+ for(j = 0; j < 64; ++j) {
+ intEncryptData[i + this.intPosition[j]] = intData[i + j] ^ this.intPrivateKey ^ this.intUserKey[j];
+ }
+
+ i += 63;
+ } else {
+ for(j = 0; j < intLen - i; ++j) {
+ intEncryptData[i + intModPosition[j]] = intData[i + j] ^ this.intPrivateKey ^ this.intUserKey[j];
+ }
+
+ i = intLen;
+ }
+ }
+ }
+
+ return intEncryptData;
+ }
+ }
+
+ public static int getEncryptionMachineInfo() {
+ return encryptionInfo;
+ }
+
+ public byte[] decryptionFile(String strFileName) {
+ byte[] bytData = (byte[])null;
+ File file = new File(strFileName);
+ int fleLen = (int)file.length();
+ if (fleLen > 8) {
+ try {
+ FileInputStream in = new FileInputStream(file);
+ int srcLength = 0;
+ bytData = new byte[4];
+
+ int intIndex;
+ for(int i = 0; i < 2; ++i) {
+ in.read(bytData);
+
+ for(intIndex = 3; intIndex >= 0; --intIndex) {
+ if (bytData[intIndex] < 0) {
+ srcLength = (srcLength << 8) + 256 + bytData[intIndex];
+ } else {
+ srcLength = (srcLength << 8) + bytData[intIndex];
+ }
+ }
+ }
+
+ fleLen -= 8;
+ bytData = new byte[fleLen];
+ in.read(bytData);
+ in.close();
+ if (fleLen % 4 == 0) {
+ fleLen /= 4;
+ } else {
+ fleLen = fleLen / 4 + 1;
+ }
+
+ int[] intData = new int[fleLen];
+ intIndex = 0;
+
+ int i;
+ for(i = 0; i < fleLen; ++i) {
+ intIndex += 4;
+
+ for(int j = 1; j < 5; ++j) {
+ int index = intIndex - j;
+ if (index < bytData.length) {
+ if (bytData[index] < 0) {
+ intData[i] = (intData[i] << 8) + 256 + bytData[index];
+ } else {
+ intData[i] = (intData[i] << 8) + bytData[index];
+ }
+ }
+ }
+ }
+
+ intData = this.encryptData(intData, false);
+ bytData = new byte[srcLength];
+ intIndex = 0;
+
+ for(i = 0; i < fleLen; ++i) {
+ long lngData = intData[i] < 0 ? MaxInt + (long)intData[i] : (long)intData[i];
+ intIndex += 4;
+
+ for(int j = 4; j > 0; --j) {
+ int index = intIndex - j;
+ if (index < srcLength) {
+ bytData[intIndex - j] = (byte)((int)(lngData & 255L));
+ lngData >>= 8;
+ }
+ }
+ }
+ } catch (Exception var14) {
+ var14.printStackTrace();
+ }
+ }
+
+ return bytData;
+ }
+
+ public static void main(String[] args) {
+ Encryption en = new Encryption("199678B2");
+ System.out.print(en.encryptString("199678B2", true));
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/media/GdMediaUtil.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/media/GdMediaUtil.java
new file mode 100644
index 0000000..5bf24a0
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/media/GdMediaUtil.java
@@ -0,0 +1,453 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package com.product.data.sync.service.media;
+
+import com.product.core.service.support.AbstractBaseService;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.Collator;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+@Service
+public class GdMediaUtil extends AbstractBaseService{
+ private static String root = "D:/Media/";
+ private static String testString = "^(\\d{0,4}`)|(\\d{0,3}\\^\\d{0,4}`)";
+ private static String startWith = "FE#ENC#";
+ private static String key = "fe520";
+ public String templete = "TemplateOfCreate";
+ public String taohongTemplete = "TemplateOfTaohong";
+ public String faceTempLate = "FaceTempLate";
+ static Encryption encryption;
+
+ static {
+ encryption = new Encryption(key);
+ root = SysSetup.getMediaParameter("MEDIA_PATH");
+ if (root == null) {
+ root = "D:\\OA\\FEGOV\\Media\\";
+ }
+
+ }
+
+ public GdMediaUtil() {
+ }
+
+ private String getPath(String code) {
+ if (code.length() < 15) {
+ return null;
+ } else {
+ code = code.substring(0, 14);
+ return code.substring(0, 4) + "/" + code.substring(4, 6) + "/" + code.substring(6, 8) + "/" + code;
+ }
+ }
+
+ private String getRoot(String code) {
+ String out = root + "/" + this.getPath(code) + "/";
+ this.mvdir(out);
+ return out;
+ }
+
+ public static boolean mvdir(String path) {
+ if (path != null && !path.equals("")) {
+ path = path.replace(File.separatorChar, '/');
+ boolean allFolder = false;
+ if (path.endsWith("/")) {
+ allFolder = true;
+ }
+
+ String[] folders = path.split("/");
+ boolean success = true;
+ String root = null;
+ int index = allFolder ? folders.length : folders.length - 1;
+
+ for(int i = 0; i < index; ++i) {
+ if (root == null) {
+ root = folders[0];
+ } else {
+ root = root + "/" + folders[i];
+ }
+
+ File file = new File(root);
+ if (!file.exists()) {
+ success = file.mkdir();
+ }
+
+ if (!success) {
+ return success;
+ }
+ }
+
+ return success;
+ } else {
+ return false;
+ }
+ }
+
+ public File[] getMediaTemplete() {
+ return this.getMediaTemplete((String)null);
+ }
+
+ public File[] getMediaTemplete(String parent) {
+ File file = null;
+ if (parent != null && !parent.equals("")) {
+ file = new File(parent);
+ } else {
+ file = new File(root + "/" + this.templete);
+ }
+
+ if (!file.exists()) {
+ file.mkdir();
+ }
+
+ return file.listFiles();
+ }
+
+ public String getParent(String filepath) {
+ if (filepath == null) {
+ return null;
+ } else {
+ File file = new File(root + "/" + this.templete);
+ File file1 = new File(filepath);
+ return file.equals(file1) ? null : file1.getParent().replaceAll("\\\\", "/");
+ }
+ }
+
+ public String getRelationDir(String filepath) {
+ if (filepath == null) {
+ return "";
+ } else {
+ filepath = filepath.replaceAll("\\\\", "/");
+ int i = filepath.indexOf(this.templete);
+ return i < 0 ? filepath : filepath.substring(i + this.templete.length() + 1);
+ }
+ }
+
+ public File[] getTaohongTemplete() {
+ return this.getTaohongTemplete("");
+ }
+
+ public File[] getTaohongTemplete(String subfloder) {
+ File file = new File(root + "/" + this.taohongTemplete + "/" + subfloder);
+ if (!file.exists()) {
+ file.mkdir();
+ }
+
+ File[] allfile = file.listFiles();
+ this.sort(allfile);
+ return allfile;
+ }
+
+ private void sort(File[] files) {
+ Arrays.sort(files, new Comparator<File>() {
+ public int compare(File arg0, File arg1) {
+ if (arg0.isDirectory() && arg1.isDirectory()) {
+ return GdMediaUtil.this.compareByName(arg0, arg1);
+ } else if (arg0.isDirectory() && !arg1.isDirectory()) {
+ return -1;
+ } else {
+ return !arg0.isDirectory() && arg1.isDirectory() ? 1 : GdMediaUtil.this.compareByName(arg0, arg1);
+ }
+ }
+ });
+ }
+
+ private int compareByName(File object1, File object2) {
+ Comparator<Object> cmp = Collator.getInstance(Locale.CHINA);
+ return cmp.compare(object1.getName(), object2.getName());
+ }
+
+ public File[] getFaceTempLate() {
+ File file = new File(root + "/" + this.faceTempLate + "/");
+ if (!file.exists()) {
+ file.mkdir();
+ }
+
+ return file.listFiles();
+ }
+
+ public File getTemplateFile(String name, String path) {
+ File file = null;
+ if (path != null && path.length() > 0) {
+ file = new File(root + "/" + path + "/" + name);
+ } else {
+ file = new File(root + "/" + this.templete + "/" + name);
+ }
+
+ return file;
+ }
+
+ public static void main(String[] args) {
+ GdMediaUtil gdMediaUtil = new GdMediaUtil();
+ gdMediaUtil.getMediaFiles("2022032535010101");
+ }
+
+ public Map<String, File> getMediaFiles(String code) {
+ int c = this.getVersion(code);
+ File file = new File(this.getRoot(code));
+ if (file.exists()) {
+ File[] files = file.listFiles();
+ Map<String, Integer> map = new HashMap();
+ Map<String, File> filemap = new LinkedHashMap();
+
+ for(int i = 0; i < files.length; ++i) {
+ GdMediaUtil.MediaFile mediaFile = new GdMediaUtil.MediaFile(files[i].getAbsolutePath());
+ if (!mediaFile.isDirectory()) {
+ int version = mediaFile.getVersion();
+ if (version <= c) {
+ String filename = mediaFile.getName();
+ if (filename.indexOf(".") != 0) {
+ Integer integer = (Integer)map.get(filename);
+ if (integer == null) {
+ map.put(filename, new Integer(version));
+ if (!mediaFile.isDelete()) {
+ filemap.put(filename, mediaFile);
+ }
+ } else if (integer <= version) {
+ map.put(filename, new Integer(version));
+ if (!mediaFile.isDelete()) {
+ if (integer == version) {
+ GdMediaUtil.MediaFile omediaFile = (GdMediaUtil.MediaFile)filemap.get(filename);
+ if (omediaFile != null && omediaFile.lastModified() < mediaFile.lastModified()) {
+ filemap.put(filename, mediaFile);
+ }
+ } else {
+ filemap.put(filename, mediaFile);
+ }
+ } else if (integer != version) {
+ filemap.remove(filename);
+ }
+ }
+ }
+ }
+ }
+ }
+ return filemap;
+ } else {
+ return null;
+ }
+ }
+
+ public boolean deleteMediaFile(String code, String name) {
+ File file = new File(this.getRoot(code));
+ int c = this.getVersion(code);
+ if (file.exists()) {
+ File[] files = file.listFiles();
+ int maxVersion = 0;
+ GdMediaUtil.MediaFile currentMediaFile = null;
+
+ for(int i = 0; i < files.length; ++i) {
+ String filename = files[i].getName();
+ if (filename.indexOf(".") != 0) {
+ GdMediaUtil.MediaFile mediaFile = new GdMediaUtil.MediaFile(files[i].getAbsolutePath());
+ if (!mediaFile.isDelete() && mediaFile.getName().equals(name)) {
+ int thisv = mediaFile.getVersion();
+ if (thisv <= c && maxVersion < thisv) {
+ maxVersion = thisv;
+ currentMediaFile = mediaFile;
+ }
+ }
+ }
+ }
+
+ if (currentMediaFile == null) {
+ return true;
+ } else if (maxVersion == c) {
+ return currentMediaFile.delete();
+ } else {
+ return currentMediaFile.delete(c);
+ }
+ } else {
+ return true;
+ }
+ }
+
+ public File createMediaFile(String code, String name) {
+ int c = this.getVersion(code);
+ name = this.encryptFileName(name);
+ name = c + "`" + name;
+ File file = new GdMediaUtil.MediaFile(this.getRoot(code) + "/" + name);
+ return file;
+ }
+
+
+
+ public String encryptFileName(String fileName) {
+ String version = "";
+ String nfileName = "";
+ Pattern p = Pattern.compile(testString);
+ Matcher m = p.matcher(fileName);
+ if (m.find()) {
+ version = m.group();
+ nfileName = fileName.substring(m.end());
+ } else {
+ nfileName = fileName;
+ }
+
+ if (nfileName.startsWith(startWith)) {
+ return fileName;
+ } else {
+ nfileName = startWith + encryption.encryptString(nfileName, true);
+ return version + nfileName;
+ }
+ }
+
+ public String decryptFileName(String fileName) {
+ String version = "";
+ String nfileName = "";
+ Pattern p = Pattern.compile(testString);
+ Matcher m = p.matcher(fileName);
+ if (m.find()) {
+ version = m.group();
+ nfileName = fileName.substring(m.end());
+ } else {
+ nfileName = fileName;
+ }
+ if (nfileName.startsWith(startWith)) {
+ nfileName = encryption.decryptionString(nfileName.substring(startWith.length()), true);
+ return version + nfileName;
+ } else {
+ return fileName;
+ }
+ }
+
+ public String getRoot() {
+ return root;
+ }
+
+ public void setRoot(String root) {
+ GdMediaUtil.root = root;
+ }
+
+ private int getVersion(String code) {
+ if (code.length() < 15) {
+ return 0;
+ } else {
+ String ban = code.substring(14);
+ int c = 0;
+
+ try {
+ c = this.converFiftyInt(ban);
+ } catch (Exception var5) {
+ }
+
+ return c;
+ }
+ }
+
+ public static int converFiftyInt(String iData) {
+ int value = 0;
+
+ for(int i = iData.length() - 1; i > -1; --i) {
+ value = (int)((double)value + (double)"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ()[]{}_+-=!@#$%&".indexOf(iData.charAt(i)) * Math.pow((double)"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ()[]{}_+-=!@#$%&".length(), (double)(iData.length() - i - 1)));
+ }
+
+ return value;
+ }
+ public String getTemplete() {
+ return this.templete;
+ }
+
+ public void setTemplete(String templete) {
+ this.templete = templete;
+ }
+
+ class MediaFile extends File {
+ private static final long serialVersionUID = -5914321855770345214L;
+
+ public MediaFile(String path) {
+ super(path);
+ }
+
+ public String getName() {
+ String name = this.getRealName();
+ name = GdMediaUtil.this.decryptFileName(name);
+ return name.replaceFirst(GdMediaUtil.testString, "");
+ }
+
+ public String getRealName() {
+ return super.getName();
+ }
+
+ public int getVersion() {
+ String name = this.getRealName();
+ int index = name.indexOf("`");
+ String tempCode = name.substring(0, index);
+ int index1 = tempCode.indexOf("^");
+ if (index1 > 0) {
+ tempCode = tempCode.substring(0, index1);
+ }
+
+ boolean var5 = false;
+
+ try {
+ int v = Integer.parseInt(tempCode);
+ return v;
+ } catch (Exception var7) {
+ return 0;
+ }
+ }
+
+ public boolean isDelete() {
+ return this.getRealName().indexOf("^") > -1;
+ }
+
+ public boolean delete() {
+ return this.delete(this.getVersion());
+ }
+
+ public boolean delete(int version) {
+ File newFile;
+ if (version == 1) {
+ newFile = new File(this.getParentFile().getAbsolutePath() + "/" + this.getRealName());
+ return newFile.exists() ? newFile.delete() : false;
+ } else {
+ newFile = new File(this.getParentFile().getAbsolutePath() + "/" + version + "^" + this.getRealName());
+
+ try {
+ if (version != this.getVersion()) {
+ return newFile.createNewFile();
+ }
+
+ if (!newFile.exists()) {
+ return this.renameTo(newFile);
+ }
+
+ newFile = new File(this.getAbsolutePath());
+ if (newFile.isFile() && newFile.exists()) {
+ newFile.delete();
+ }
+ } catch (IOException var4) {
+ }
+
+ return false;
+ }
+ }
+
+ public boolean rename(String name) {
+ String oldName = this.getRealName();
+ int start = oldName.indexOf("`");
+ if (start < 0) {
+ return false;
+ } else {
+ int stop = oldName.lastIndexOf(".");
+ if (stop < 0) {
+ stop = oldName.length();
+ }
+
+ String newName = oldName.substring(0, start + 1) + name + oldName.substring(stop);
+ File newFile = new File(this.getParentFile().getAbsolutePath() + "/" + newName);
+ return this.renameTo(newFile);
+ }
+ }
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/media/MD5Util.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/media/MD5Util.java
new file mode 100644
index 0000000..75f619b
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/media/MD5Util.java
@@ -0,0 +1,45 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package com.product.data.sync.service.media;
+
+import java.security.MessageDigest;
+
+public class MD5Util {
+ private static final char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+ public MD5Util() {
+ }
+
+ public static final String digest(String s) {
+ return digest(s, 1);
+ }
+
+ public static final String digest(String s, int bit) {
+ try {
+ byte[] strTemp = s.getBytes();
+ MessageDigest mdTemp = MessageDigest.getInstance("MD5");
+ mdTemp.update(strTemp);
+ byte[] md = mdTemp.digest();
+ int j = md.length;
+ char[] str = new char[j * 2 / bit];
+ int k = 0;
+
+ for(int i = 0; i < j; i += bit) {
+ byte byte0 = md[i];
+ str[k++] = hexDigits[byte0 >>> 4 & 15];
+ str[k++] = hexDigits[byte0 & 15];
+ }
+
+ return new String(str);
+ } catch (Exception var10) {
+ return null;
+ }
+ }
+
+ public static void main(String[] args) {
+ System.out.println(digest("a", 1));
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/service/media/SysSetup.java b/product-server-data-sync/src/main/java/com/product/data/sync/service/media/SysSetup.java
new file mode 100644
index 0000000..00c9916
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/service/media/SysSetup.java
@@ -0,0 +1,87 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package com.product.data.sync.service.media;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class SysSetup {
+ private static Map<String, Object> parameter = new HashMap();
+ private static Map<String, String> mailParameter = new HashMap();
+ private static Map<String, String> mediaParameter = new HashMap();
+ private static Map<String, String> menuParameter = new HashMap();
+ private static Map<String, String> versionParameter = new HashMap();
+ private static Map<String, String> indexSearchUrlParameter = new HashMap();
+ private static Map<String, String> emailSetParameter = new HashMap();
+
+ static {
+ versionParameter.put("00", "寮�鍙戠増");
+ versionParameter.put("01", "鏍囧噯鐗�");
+ versionParameter.put("02", "浼佷笟鐗�");
+ versionParameter.put("03", "闆嗗洟鐗�");
+ versionParameter.put("04", "鏀垮姟鐗�");
+ versionParameter.put("05", "鏀垮姟鐗�");
+ }
+
+ public SysSetup() {
+ }
+
+ public Map<String, Object> getParameter() {
+ return parameter;
+ }
+
+ public void setMailParameter(Map<String, String> parameter) {
+ mailParameter = parameter;
+ }
+
+ public static String getMailParameter(String value) {
+ return (String)mailParameter.get(value);
+ }
+
+ public void setParameter(Map<String, Object> parameter1) {
+ parameter.putAll(parameter1);
+ }
+
+ public static void setParameter(String key, String value) {
+ parameter.put(key, value);
+ }
+
+ public static Object getParameter(String value) {
+ return parameter.get(value);
+ }
+
+ public void setMediaParameter(Map<String, String> parameter) {
+ mediaParameter = parameter;
+ }
+
+ public static String getMediaParameter(String value) {
+ return (String)mediaParameter.get(value);
+ }
+
+ public void setMenuParameter(Map<String, String> parameter) {
+ menuParameter = parameter;
+ }
+
+ public static String getMenuParameter(String value) {
+ return (String)menuParameter.get(value);
+ }
+
+ public void setIndexSearchUrlParameter(Map<String, String> parameter) {
+ indexSearchUrlParameter = parameter;
+ }
+
+ public static String getIndexSearchUrlParameter(String value) {
+ return (String)indexSearchUrlParameter.get(value);
+ }
+
+ public static String getEmailSetParameter(String value) {
+ return (String)emailSetParameter.get(value);
+ }
+
+ public void setEmailSetParameter(Map<String, String> parameter) {
+ emailSetParameter = parameter;
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/BatchData.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/BatchData.java
new file mode 100644
index 0000000..b15782e
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/BatchData.java
@@ -0,0 +1,741 @@
+package com.product.data.sync.util;
+
+import cn.hutool.core.util.IdUtil;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.product.common.lang.DateUtils;
+import com.product.common.lang.StringUtils;
+import com.product.common.utils.spring.SpringUtils;
+import com.product.core.cache.DataPoolCacheImpl;
+import com.product.core.config.Global;
+import com.product.core.dao.BaseDao;
+import com.product.core.dao.support.BaseDaoImpl;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.data.sync.config.CmnConst;
+import com.product.data.sync.config.SystemCode;
+import com.product.util.CallBack;
+import com.product.util.CallBackValue;
+
+import java.sql.*;
+import java.util.*;
+
+/**
+ * @desc 鎵瑰鐞嗘暟鎹�
+ * @Author cheng
+ * @Date 2022/1/19 10:17
+ * @Desc
+ */
+public class BatchData {
+
+ private Map<String, Object> defaultValueMap = new HashMap<>();
+ /**
+ * 褰撳墠杩炴帴
+ */
+ private Connection currentConnection;
+ /**
+ * 鏉ユ簮杩炴帴
+ */
+ private Connection sourceConnection;
+
+ /**
+ * 鎵瑰鐞嗘潯鏁�
+ */
+ private int batchCount;
+ /**
+ * 姣忛〉鏌ヨ鏉℃暟
+ */
+ private int pageSize;
+
+ private BaseDao baseDao;
+
+ private ExceptionLog exceptionLog;
+ /**
+ * 绯荤粺琛�
+ */
+ private String systemTable;
+ /**
+ * 鏁版嵁鏉ユ簮琛�
+ */
+ private String sourceTable;
+
+ private boolean isUpdate;
+
+ private boolean isDelete;
+
+ private FieldSetEntity syncFieldSet;
+ /**
+ * 瑕佹坊鍔犵殑瀛楁缁撳悎
+ */
+ private String[] columnNames;
+
+ private String templateSql;
+
+ private int currentPage = 1;
+
+ private boolean threadSelect = false;
+
+
+ private String mainTableName;
+
+
+ private ThreadSelectManager threadSelectManager;
+
+
+ private boolean totalNumberSelect = false;
+
+ private int totalPage = -1;
+
+ public Connection getCurrentConnection() {
+ return currentConnection;
+ }
+
+ public Connection getSourceConnection() {
+ return sourceConnection;
+ }
+
+ public BaseDao getBaseDao() {
+ return baseDao;
+ }
+
+ public String getSystemTable() {
+ return systemTable;
+ }
+
+ public String getSourceTable() {
+ return sourceTable;
+ }
+
+ public int getCurrentPage() {
+ return currentPage;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public Map<String, Object> getDefaultValueMap() {
+ return defaultValueMap;
+ }
+
+ public String[] getColumnNames() {
+ return columnNames;
+ }
+
+ public void setColumnNames(String[] columnNames) {
+ this.columnNames = columnNames;
+ }
+
+
+ public int getTotalPage() {
+ return totalPage;
+ }
+
+
+ /**
+ * 榛樿鏋勯��
+ * 鎵瑰鐞� 2000
+ * 姣忛〉鏌ヨ 100000
+ */
+ public BatchData(FieldSetEntity syncConfig) {
+ initOperation(syncConfig);
+ currentConnection = ConnectionManager.getConnection();
+ pageSize = 100000;
+ batchCount = 2000;
+ }
+
+
+ /**
+ * 鍒濆鏋勯��
+ * 鍒濆鍖栬繛鎺�
+ *
+ * @param batchCount 鎵瑰鐞嗘潯鏁�
+ * @param pageSize 姣忛〉鏌ヨ鏉℃暟
+ */
+ public BatchData(FieldSetEntity syncConfig, int batchCount, int pageSize) {
+ initOperation(syncConfig);
+ currentConnection = ConnectionManager.getConnection();
+ this.batchCount = batchCount;
+ this.pageSize = pageSize;
+ }
+
+ /**
+ * 鍒濆鍖栭粯璁ゅ��
+ */
+ private void initOperation(FieldSetEntity syncConfig) {
+ this.syncFieldSet = syncConfig;
+ defaultValueMap.put(CmnConst.CREATED_BY, 1);
+ defaultValueMap.put(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime());
+ defaultValueMap.put("org_level_uuid", "00000000-0000-0000-0000-000000000000");
+ CallBackValue<String> getUuidMethod = (o) -> IdUtil.randomUUID();
+ defaultValueMap.put("uuid", getUuidMethod);
+ this.baseDao = SpringUtils.getBean(BaseDaoImpl.class);
+ this.exceptionLog = SpringUtils.getBean(ExceptionLog.class);
+ getSyncParams();
+ }
+
+ /**
+ * 鎵瑰鐞嗘坊鍔�
+ * 鑷姩鐢熸垚uuid 榛樿瀛楁
+ *
+ * @param resultSet 缁撴灉闆�
+ * @param fieldNames 瑕佹彃鍏ョ殑瀛楁闆嗗悎 锛堝彲閫夛級 涓嶄紶鍏ヨ鍙傛暟鍒欐坊鍔犳煡璇㈢粨鏋滈泦涓墍鏈夌殑瀛楁 骞堕獙璇佽瀛楁鍦ㄧ郴缁熻〃涓槸鍚﹀瓨鍦紙product_sys_datamodel_field)琛�
+ */
+ public void batchAdd(ResultSet resultSet, Collection<String> fieldNames) {
+ if (resultSet != null && StringUtils.isEmpty(systemTable)) {
+ // 瀛楁set
+ List<String> fieldNameList = fieldNames == null ? Lists.newArrayList() : Lists.newArrayList(fieldNames.iterator());
+ if (fieldNameList == null || fieldNameList.size() <= 0) {
+ String[] columnNames = getColumnNames(resultSet);
+ Map<String, Map<Object, Object>> systemFieldMap = getSystemFieldByCache(systemTable);
+ //姣旇緝瀛楁鍦ㄧ紦瀛樹腑鏄惁瀛樺湪
+ this.comparisonFieldName(systemTable, columnNames, fieldNameList, systemFieldMap);
+ //娣诲姞榛樿瀛楁
+ defaultValueMap.forEach((k, v) -> {
+ //鍒ゆ柇榛樿瀛楁鏄惁鍦ㄧ紦瀛樹腑 鎴栧瓧娈垫槸宸插湪鏌ヨ缁撴灉涓�
+ if (systemFieldMap.get(k) != null) {
+ fieldNameList.add(k);
+ }
+ });
+ }
+ try {
+
+ // 鍒ゆ柇鏄惁鏈夊緟娣诲姞鐨勫瓧娈�
+ if (fieldNameList.size() > 0) {
+ String templateSql = getInsertTemplateSql(systemTable, fieldNameList);
+ //灏嗙粨鏋滈泦绉诲埌鏈�鍚庝竴琛�
+ resultSet.last();
+ //璁板綍鎬昏鏁�
+ int totalRow = resultSet.getRow();
+ //鍐嶈缁撴灉闆嗙Щ鍒扮涓�琛�
+ resultSet.first();
+ while (resultSet.next()) {
+
+ }
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+ /**
+ * 鑾峰彇鎻掑叆瀛楁
+ *
+ * @param resultSet
+ * @param fieldNameList
+ * @return
+ */
+ private List<String> getInsertFieldNames(CustomResultSet resultSet, List<String> fieldNameList) {
+ if (fieldNameList == null) {
+ fieldNameList = new ArrayList<>();
+ }
+ if (this.columnNames == null || this.columnNames.length <= 0) {
+ String[] columnNames = getColumnNames(resultSet.getResultSet());
+ this.columnNames = columnNames;
+ }
+ Map<String, Map<Object, Object>> systemFieldMap = getSystemFieldByCache(systemTable);
+ //姣旇緝瀛楁鍦ㄧ紦瀛樹腑鏄惁瀛樺湪
+ this.comparisonFieldName(systemTable, columnNames, fieldNameList, systemFieldMap);
+ //娣诲姞榛樿瀛楁
+ List<String> finalFieldNameList = fieldNameList;
+ List<String> deleteDefaultKey = new ArrayList<>();
+ for (Map.Entry<String, Object> v : defaultValueMap.entrySet()) {
+ //鍒ゆ柇榛樿瀛楁鏄惁鍦ㄧ紦瀛樹腑 鎴栧瓧娈垫槸宸插湪鏌ヨ缁撴灉涓�
+ if (systemFieldMap.get(v.getKey()) != null) {
+ finalFieldNameList.add(v.getKey());
+ } else {
+ deleteDefaultKey.add(v.getKey());
+ }
+ }
+ if (deleteDefaultKey.size() > 0) {
+ for (String key : deleteDefaultKey) {
+ defaultValueMap.remove(key);
+ }
+
+ }
+ return finalFieldNameList;
+ }
+
+ private String getInsertTemplateSql(String systemTable, List<String> fieldNameList) {
+ StringBuilder sqlTemplate = new StringBuilder();
+ sqlTemplate.append(" INSERT INTO `").append(systemTable).append("` (");
+ int i = 0;
+ Iterator<String> iterator = fieldNameList.iterator();
+ // 瀛楁
+ StringBuilder fieldTemplate = new StringBuilder();
+ //鍗犱綅绗�
+ StringBuilder placeholderTemplate = new StringBuilder();
+ while (iterator.hasNext()) {
+ String fieldName = iterator.next();
+ if (i > 0) {
+ fieldTemplate.append(",");
+ placeholderTemplate.append(",");
+ } else {
+ i++;
+ }
+ placeholderTemplate.append("?");
+ fieldTemplate.append("`").append(fieldName).append("`");
+ }
+ sqlTemplate.append(fieldTemplate).append(") values (").append(placeholderTemplate).append(")");
+ return sqlTemplate.toString();
+ }
+
+ private void readResultSet(ResultSet resultSet, List<String> columnNames) {
+ }
+
+ /**
+ * 姣旇緝瀛楁鍦ㄧ郴缁熶腑鏄惁瀛樺湪
+ *
+ * @param columnNames 闇�瑕佹瘮瀵圭殑瀛楁
+ * @param fieldNameList 姣旇緝鍚庤繑鍥炵殑缁撴灉瀛楁闆嗗悎
+ * @param systemFieldMap 绯荤粺瀛楁map 瀛楁鍚嶄负 key value 涓篺ield缂撳瓨琛ㄧ殑璁板綍 瀵规瘮鍚庝細鍒犻櫎鎴愬姛瀵规瘮鐨勫瓧娈�
+ */
+ private void comparisonFieldName(String systemTable, String[] columnNames, List<String> fieldNameList, Map<String, Map<Object, Object>> systemFieldMap) {
+ for (String columnName : columnNames) {
+ if (systemFieldMap.get(columnName) == null) {
+ SpringMVCContextHolder.getSystemLogger().info("璀﹀憡:鏌ヨ缁撴灉鍒楀湪绯荤粺琛ㄤ腑涓嶅瓨鍦紝璺宠繃璇ュ瓧娈�:" + systemTable + "." + columnName);
+ continue;
+ } else if (!fieldNameList.contains(columnName)) {
+ //瀛楁鍦ㄩ泦鍚堜腑涓嶅瓨鍦�
+ fieldNameList.add(columnName);
+ }
+ defaultValueMap.remove(columnName);
+ systemFieldMap.remove(columnName);
+ }
+ }
+
+ /**
+ * 鑾峰彇瀛楁缂撳瓨鏍规嵁琛ㄥ悕
+ *
+ * @param tableName 琛ㄥ悕
+ * @return
+ * @throws BaseException
+ */
+ private Map<String, Map<Object, Object>> getSystemFieldByCache(String tableName) throws BaseException {
+ DataPoolCacheImpl dataPoolCache = DataPoolCacheImpl.getInstance();
+ DataTableEntity tableInfo = dataPoolCache.getCacheData("鎵�鏈夎〃淇℃伅", new String[]{tableName});
+ if (DataTableEntity.isEmpty(tableInfo) || StringUtils.isEmpty(tableInfo.getString(0, CmnConst.UUID))) {
+ throw new BaseException(SystemCode.GET_TABLE_CACHE_FAIL.getValue(), SystemCode.GET_TABLE_CACHE_FAIL.getText());
+ }
+ String table_uuid = tableInfo.getString(0, CmnConst.UUID);
+ DataTableEntity fieldInfo = dataPoolCache.getCacheData("琛ㄥ瓧娈典俊鎭�", new String[]{table_uuid});
+ if (DataTableEntity.isEmpty(fieldInfo)) {
+ throw new BaseException(SystemCode.GET_FIELD_CACHE_FAIL.getValue(), SystemCode.GET_FIELD_CACHE_FAIL.getText());
+ }
+ Map<String, Map<Object, Object>> resultMap = new HashMap<>();
+ for (int i = 0; i < fieldInfo.getRows(); i++) {
+ FieldSetEntity fs = fieldInfo.getFieldSetEntity(i);
+ Map<Object, Object> values = fs.getValues();
+ String field_name = fs.getString(CmnConst.FIELD_NAME);
+ resultMap.put(field_name, Maps.newHashMap(values));
+ }
+
+ return resultMap;
+ }
+
+ /**
+ * 鑾峰彇缁撴灉闆嗘墍鏈夌殑鍒楀悕
+ *
+ * @param resultSet 缁撴灉闆�
+ * @return
+ * @throws BaseException
+ */
+ public static String[] getColumnNames(ResultSet resultSet) throws BaseException {
+ try {
+ ResultSetMetaData metaData = resultSet.getMetaData();
+ if (metaData != null) {
+ int columnCount = getColumnCount(resultSet);
+ String[] fieldName = new String[columnCount];
+ for (int i = 1; i <= columnCount; i++) {
+ String columnName = metaData.getColumnLabel(i);
+ fieldName[i - 1] = columnName;
+ }
+ return fieldName;
+ }
+ throw new BaseException(SystemCode.GET_RESULTSET_COLUMN_NAME_FAIL.getValue(), SystemCode.GET_RESULTSET_COLUMN_NAME_FAIL.getText());
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ throw new BaseException(SystemCode.GET_RESULTSET_COLUMN_NAME_FAIL.getValue(), SystemCode.GET_RESULTSET_COLUMN_NAME_FAIL.getText() + (e.getMessage() != null ? "," + e.getMessage() : ""));
+ }
+ }
+
+ /**
+ * 鑾峰彇缁撴灉闆嗕腑鍒楃殑鏁伴噺
+ *
+ * @param resultSet 缁撴灉闆�
+ * @return
+ * @throws BaseException
+ */
+ public static int getColumnCount(ResultSet resultSet) throws BaseException {
+ try {
+ ResultSetMetaData metaData = resultSet.getMetaData();
+ if (metaData != null) {
+ return metaData.getColumnCount();
+ }
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ throw new BaseException(SystemCode.GET_RESULTSET_COLUMN_COUNT_FAIL.getValue(), SystemCode.GET_RESULTSET_COLUMN_COUNT_FAIL.getText() + (e.getMessage() != null ? "," + e.getMessage() : ""));
+ }
+ return 0;
+ }
+
+
+ private void getSyncParams() {
+ DataTableEntity dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_SUB, "sync_config_uuid = ?", new String[]{});
+ String idField = dataTableEntity.getString(0, CmnConst.DATA_ORIGIN_FIELD);
+ //鏁版嵁婧愯〃鍚�
+ String dataOriginName = syncFieldSet.getString(CmnConst.DATA_ORIGIN_NAME);
+ this.sourceTable = dataOriginName;
+ //鑾峰彇绯荤粺琛�
+ String tableName = syncFieldSet.getString(CmnConst.SYSTEM_TABLE_NAME);
+ this.systemTable = tableName;
+ //淇濆瓨鍓嶈皟鐢ㄧ殑鏂规硶
+ String savePreEvent = syncFieldSet.getString(CmnConst.SAVE_PRE_EVENT);
+ //淇濆瓨鍚庤皟鐢ㄧ殑鏂规硶
+ String postSaveEvent = syncFieldSet.getString(CmnConst.POST_SAVE_EVENT);
+ //鏌ヨ鏉′欢
+ String syncCondition = syncFieldSet.getString(CmnConst.SYNC_CONDITION);
+ //鏄惁淇敼
+ this.isUpdate = syncFieldSet.getBoolean(CmnConst.IS_UPDATE);
+ //鏄惁鍒犻櫎
+ this.isUpdate = syncFieldSet.getBoolean(CmnConst.IS_DELETE);
+// //鍒犻櫎鏍囪瘑鍊�
+// String deleteValue = syncFieldSet.getString(CmnConst.DELETE_VALUE);
+ //鑾峰彇鏁版嵁搴撹繛鎺ヤ俊鎭�
+// String configUuid = syncFieldSet.getString(CmnConst.DATABASE_CONFIG_UUID);
+ String databaseType = syncFieldSet.getString(CmnConst.DATABASE_TYPE);//鏁版嵁搴撶被鍨�
+ String ipAddress = syncFieldSet.getString(CmnConst.IP_ADDRESS);//ip鍦板潃
+ String databaseName = syncFieldSet.getString(CmnConst.DATABASE_NAME);//鏁版嵁搴撳悕绉�
+ String portNumber = syncFieldSet.getString(CmnConst.PORT_NUMBER);//绔彛鍙�
+ String userName = syncFieldSet.getString(CmnConst.USER_NAME);//鐢ㄦ埛鍚�
+ String userPassword = syncFieldSet.getString(CmnConst.USER_PASSWORD);//瀵嗙爜
+ String instantiation = syncFieldSet.getString(CmnConst.INSTANTIATION);//瀹炰緥鍚�
+ String url;
+ String driver;
+ //鍒涘缓鏃ュ織
+ String logUuid = exceptionLog.addExceptionLog(syncFieldSet.getUUID(), dataOriginName, tableName);
+ StringBuilder sql = new StringBuilder();
+ if ("mysql".equals(databaseType)) {
+ driver = "com.mysql.cj.jdbc.Driver";
+ url = "jdbc:mysql://" + ipAddress + ":" + portNumber + "/" + databaseName + "?useSSL=false&serverTimezone=UTC";
+
+ if (StringUtils.isEmpty(syncCondition)) {
+ sql.append("SELECT ? FROM ? LIMIT ?,?");//鍙傛暟澶辫触 鏀逛负瀛楃涓叉嫾鎺�
+ } else {
+ sql.append("SELECT ? FROM ? ").append(" WHERE ").append(syncCondition).append(" LIMIT ?,?");//鍙傛暟澶辫触 鏀逛负瀛楃涓叉嫾鎺�
+ }
+ } else if ("oracle".equals(databaseType)) {
+ driver = "oracle.jdbc.driver.OracleDriver";
+ url = "jdbc:oracle:thin:@" + ipAddress + ":" + portNumber + ":orcl";
+ if (StringUtils.isEmpty(syncCondition)) {
+ sql.append("SELECT ? FROM (SELECT ROWNUM AS rowno, t.* FROM ? t WHERE ROWNUM <= ?) t2 WHERE t2.rowno > ?");
+ } else {
+ sql.append("SELECT ? FROM (SELECT ROWNUM AS rowno, t.* FROM ? t WHERE ").append(syncCondition).append("AND ROWNUM <= ?) t2 WHERE t2.rowno > ?");
+ }
+ } else if ("informix".equals(databaseType)) {
+ driver = "com.informix.jdbc.IfxDriver";
+ url = "jdbc:informix-sqli://" + ipAddress + ":" + portNumber + "/" + databaseName + ":informixserver=" + instantiation;
+ if (StringUtils.isEmpty(syncCondition)) {
+ //璺宠繃?琛岋紝鑾峰彇?琛� 瀛楁鍚� 琛ㄥ悕
+ sql.append(" SELECT SKIP ? FIRST ? ? FROM ? ");
+ } else {
+ sql.append(" SELECT SKIP ? FIRST ? ? FROM ? WHERE ").append(syncCondition);
+ }
+ } else if ("sqlserver".equals(databaseType)) {
+
+ SpringMVCContextHolder.getSystemLogger().error("鍞竴瀛楁鑾峰彇涓嶄弗璋細" + idField);
+ driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
+ url = "jdbc:sqlserver://" + ipAddress + ":" + portNumber + ";DataBaseName=" + databaseName;
+ if (StringUtils.isEmpty(syncCondition)) {
+ //? 鏌ヨ鏉℃暟 ? 鏌ヨ瀛楁 ? 琛ㄥ悕 idField 鍞竴瀛楁鍚� ? 寮�濮嬩綅缃� idField 鍞竴瀛楁鍚� ? 琛ㄥ悕
+ sql.append("SELECT TOP ? ? FROM ? WHERE ").append(idField).append(" NOT IN(SELECT TOP ? ").append(idField).append(" FROM ?)");
+ } else {
+ sql.append("SELECT TOP ? ? FROM ? WHERE ").append(idField).append(" NOT IN(SELECT TOP ? ").append(idField).append(" FROM ? WHERE ").append(syncCondition).append(" ) AND ").append(syncCondition);
+ }
+ } else {
+ BaseException baseException = new BaseException(SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getValue(), SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getText());
+ exceptionLog.upExceptionLog(null, logUuid, baseException, 0, 0, 0, 0, 0);
+ throw baseException;
+ }
+ this.sourceConnection = this.getSourceConnection(driver, ipAddress, url, userName, userPassword);
+ }
+
+ private Connection getSourceConnection(String driver, String ipAddress, String url, String userName, String userPassword) {
+ // 鍒ゆ柇 ip鍦板潃鏄惁涓� / 褰搃p鍦板潃 = / 鏃� 鍒欒涓烘湰鍦板悓姝�
+ String sourceType = Global.getSystemConfig("data.source.type", "");
+ if (sourceType != null && "/".equals(ipAddress)) {
+ driver = Global.getSystemConfig("data.source.driver", "");
+ url = Global.getSystemConfig("data.source.url", "");
+ userName = Global.getSystemConfig("data.source.user", "");
+ userPassword = Global.getSystemConfig("data.source.password", "");
+ }
+ // 杩滅▼鍦板潃鑾峰彇鏁版嵁搴撹繛鎺�
+ return ConnectionManager.getConnection(driver, url, userName, userPassword);
+ }
+
+
+ /**
+ * @param sql 闇�瑕佹煡璇㈢殑sql
+ * @param systemTable 鐩爣琛�
+ * @param pageSize 姣忛〉鏌ヨ鏉℃暟
+ * @param batchCount 姣忔壒娆″鐞嗘暟閲�
+ */
+ public BatchData(String sql, String systemTable, int pageSize, int batchCount) {
+ this.pageSize = pageSize;
+ this.batchCount = batchCount;
+ this.currentConnection = ConnectionManager.getConnection();
+ this.sourceConnection = ConnectionManager.getConnection();
+ this.templateSql = sql;
+ this.systemTable = systemTable;
+ defaultValueMap.put(CmnConst.CREATED_BY, 1);
+ defaultValueMap.put(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime());
+ defaultValueMap.put("org_level_uuid", "00000000-0000-0000-0000-000000000000");
+ CallBackValue getUuidMethod = (o) -> IdUtil.randomUUID();
+ defaultValueMap.put("uuid", getUuidMethod);
+ }
+
+ /**
+ * 鑾峰彇鍒嗛〉
+ *
+ * @param currentPage
+ * @return
+ */
+ private String getMysqlLimit(int currentPage) {
+ return " limit " + (currentPage == 1 ? 0 : (currentPage - 1) * this.pageSize) + "," + this.pageSize;
+ }
+
+
+ public static void main(String[] args) {
+ String sql = "SELECT * FROM TABLE [[TABLE_NAME]]";
+ String substring = sql.substring(sql.indexOf("[[") + 2, sql.indexOf("]]"));
+ System.out.println(substring);
+ }
+
+ /**
+ * 鑾峰彇鏌ヨsql
+ *
+ * @param currentPage
+ * @return
+ */
+ public String getQuerySql(int currentPage) {
+ String mysqlLimit = this.getMysqlLimit(currentPage);
+ if (!StringUtils.isEmpty(this.templateSql)) {
+ int startIndex = this.templateSql.indexOf("[[");
+ if (startIndex != -1 && this.templateSql.indexOf("]]") > startIndex) {
+ this.mainTableName = this.templateSql.substring(startIndex + 2, this.templateSql.indexOf("]]") - "_limit".length());
+ return this.templateSql.replace("[[" + mainTableName + "_limit" + "]]", mysqlLimit);
+ }
+ }
+ return templateSql + mysqlLimit;
+ }
+
+
+ /**
+ * 鎵瑰鐞嗗鍏ユ暟鎹� 鐢ㄤ簬鏁版嵁鍚屾缁撴潫鍚庢暟鎹鐞嗘柟娉�
+ *
+ * @param isDelete 鏄惁鍒犻櫎鐩爣琛ㄦ暟鎹�
+ * @param callBack 鑷畾涔夊洖璋� 浼犲叆姣忔潯鏁版嵁鐨� map key=瀛楁鍚嶇О value=鍊� 涓嶅彲鏀瑰彉map涓殑key 锛堝鍔犳垨淇敼锛� 鍙兘鏀瑰彉鍊�
+ */
+ public void batchImprovedCoverage(boolean isDelete, CallBack<Object> callBack) {
+ long startTime = System.currentTimeMillis();
+ SpringMVCContextHolder.getSystemLogger().info("寮�濮嬪鐞嗗悓姝ヨ〃鏁版嵁锛屽噯澶囨彃鍏ユ暟鎹〃锛�" + this.systemTable);
+ int pageDataNumber;
+ String templateSql = null;
+ int totalCount = -1;
+ List<String> insertFieldNames = null;
+ try {
+ if (isDelete) {
+ PreparedStatement preparedStatement = this.currentConnection.prepareStatement("truncate table " + this.systemTable);
+ preparedStatement.execute();
+ preparedStatement.close();
+ }
+ this.currentConnection.setAutoCommit(false);
+ PreparedStatement pst = null;
+ int dataNumber = 0;
+ List<String> fieldNames = new ArrayList<>();
+ do {
+ pageDataNumber = 0;
+ if ((this.currentPage - 1) % 3 == 0) {
+ this.sourceConnection.close();
+ this.sourceConnection = ConnectionManager.getConnection();
+ }
+ String query_sql = getQuerySql(this.currentPage);
+ if (totalCount == -1 && this.mainTableName != null) {
+ //寮�鍚叧鑱斾富琛ㄥ垎椤垫煡璇�
+ ResultSet resultSet = this.currentConnection.prepareStatement("SELECT ifnull(COUNT(1),0) totalCount FROM " + this.mainTableName).executeQuery();
+ if (resultSet != null) {
+ if (resultSet.next()) {
+ //鏌ヨ鍒版�绘潯鏁�
+ totalCount = resultSet.getInt("totalCount");
+ if (totalCount > 0) {
+ double v = totalCount / Double.valueOf(this.pageSize);
+ this.totalPage = (int) Math.ceil(v);
+ if (this.totalPage > 0) {
+ //鑳藉鑾峰彇鍒版�婚〉鏁板垯寮�鍚嚎绋嬫煡璇�
+ this.totalNumberSelect = true;
+// threadSelectManager = new ThreadSelectManager(this);
+// if (threadSelectManager.startQuery()) {
+// this.threadSelect = true;
+// }
+ }
+ }
+ }
+ }
+ }
+ long s = System.currentTimeMillis();
+ CustomResultSet resultSet;
+ if (!this.threadSelect) {
+ SpringMVCContextHolder.getSystemLogger().info("鏌ヨ绗� " + this.currentPage + " 椤垫暟鎹�");
+ SpringMVCContextHolder.getSystemLogger().info("鏌ヨsql锛�" + query_sql);
+ resultSet = new CustomResultSet(this.sourceConnection.prepareStatement(query_sql).executeQuery());
+ SpringMVCContextHolder.getSystemLogger().info("鏌ヨ绗� " + this.currentPage + " 椤垫暟鎹粨鏉燂紝鑰楁椂锛�" + (System.currentTimeMillis() - s) + "ms");
+
+ } else {
+ resultSet = threadSelectManager.getNext();
+ SpringMVCContextHolder.getSystemLogger().info("鑾峰彇涓嬩竴椤甸〉鏁版嵁缁撴潫锛岃�楁椂锛�" + (System.currentTimeMillis() - s) + "ms");
+ }
+ if (resultSet != null) {
+ if (templateSql == null) {
+ // 鑾峰彇娣诲姞瀛楁
+ insertFieldNames = getInsertFieldNames(resultSet, null);
+ // 鑾峰彇鎻掑叆鐨剆ql妯℃澘
+ templateSql = getInsertTemplateSql(systemTable, insertFieldNames);
+ if (StringUtils.isEmpty(templateSql)) {
+ // 娌℃湁鑾峰彇鍒癷nsert 璇彞
+ throw new BaseException(new Exception(""));
+ }
+ pst = this.currentConnection.prepareStatement(templateSql);
+ }
+ if (this.columnNames == null || this.columnNames.length < 0) {
+ SpringMVCContextHolder.getSystemLogger().error("閿欒锛岃幏鍙栨彃鍏ュ瓧娈甸泦鍚堝け璐�");
+ throw new Exception("閿欒锛岃幏鍙栨彃鍏ュ瓧娈甸泦鍚堝け璐�");
+ }
+ while (resultSet.next()) {
+ pageDataNumber++;
+ dataNumber++;
+ int i = 1;
+ Map<String, Object> values = callBack != null ? new HashMap<>() : null;
+ //鏄惁闇�瑕佹彃鍏ュ瓧娈靛埌闆嗗悎涓� 鍥炶皟涓嶄负绌烘椂
+ boolean isInsertField = fieldNames.size() >= 0 && callBack != null;
+ for (; i <= this.columnNames.length; i++) {
+ // 鏄惁鎻掑叆瀛楁鍒伴泦鍚�
+ if (isInsertField) {
+ fieldNames.add(this.columnNames[i - 1]);
+ }
+ // 濡傛灉鍥炶皟 涓嶆槸绌哄皢value鏀惧叆map
+ if (callBack != null) {
+ values.put(this.columnNames[i - 1], resultSet.getObject(this.columnNames[i - 1]));
+ } else {
+ pst.setObject(i, resultSet.getObject(this.columnNames[i - 1]));
+ }
+ }
+ for (Map.Entry<String, Object> v : defaultValueMap.entrySet()) {
+ Object value = v.getValue();
+ if (v.getValue() instanceof CallBackValue) {
+ CallBackValue<String> callback = (CallBackValue<String>) value;
+ value = callback.method(v.getKey());
+ }
+ // 濡傛灉鍥炶皟 涓嶆槸绌哄皢value鏀惧叆map
+ if (callBack == null) {
+ pst.setObject(i, value);
+ } else {
+ values.put(v.getKey(), value);
+ }
+ i++;
+ }
+ if (callBack != null) {
+ int paramSize = values.size();
+ callBack.method(values);
+ if (values.size() != paramSize) {
+ throw new Exception("鎵ц鑷畾涔夊洖璋冨悗鍙傛暟鏁伴噺涓嶄竴鑷�,鎵ц鍓嶅弬鏁版暟閲忥細" + paramSize + ",鎵ц鍚庡弬鏁版暟閲忥細" + values.size() + "\n\t" + values);
+ }
+ int j = 1;
+ //鍥炶皟缁撴潫鍚庡皢鎻掑叆鐨勫�煎啓鍏�
+ for (; j <= insertFieldNames.size(); j++) {
+ Object o = values.get(insertFieldNames.get(j - 1));
+ pst.setObject(j, o);
+ }
+ }
+ pst.addBatch();
+ //宸查亶鍘嗙殑鏁伴噺鏄惁绗﹀悎姣忔壒娆℃彁浜ょ殑鏁伴噺
+ if (dataNumber % this.batchCount == 0) {
+ try {
+ long l2 = System.currentTimeMillis();
+ //鎻愪氦鎵瑰鐞�
+ pst.executeBatch();
+ this.currentConnection.commit();
+ pst.clearBatch();
+ System.out.println("娓呯悊");
+ SpringMVCContextHolder.getSystemLogger().info("鎵ц鎵瑰鐞嗗苟鎻愪氦鎴愬姛锛屽叡鑰楁椂锛�" + (System.currentTimeMillis() - l2) + "ms");
+ dataNumber = 0;
+ } catch (Exception e) {
+ //鎵瑰鐞嗛敊璇�
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ SpringMVCContextHolder.getSystemLogger().error("鎵ц鎵瑰鐞嗗苟鎻愪氦閿欒锛屾彃鍏ョ洰鏍�:" + systemTable);
+ }
+ }
+ }
+ totalCount -= pageDataNumber;
+ //鏌ヨ椤垫暟+1
+ if (resultSet != null && resultSet.getResultSet() != null && !resultSet.getResultSet().isClosed()) {
+
+ resultSet.getResultSet().close();
+ }
+ if (!this.threadSelect) {
+ this.currentPage++;
+ }
+ } else {
+ if (this.totalPage == -1) {
+ break;
+ } else {
+ this.currentPage++;
+ }
+ }
+ } while ((this.totalNumberSelect == true && (totalPage - currentPage) >= 0) || (this.totalNumberSelect != true && (pageDataNumber > 0 && pageDataNumber % this.pageSize == 0)));
+ try {
+ //灏嗕笉瓒虫瘡鎵规鎻愪氦鐨勬暟鎹渶鍚庡仛鎻愪氦澶勭悊
+ //鎻愪氦鎵瑰鐞�
+ pst.executeBatch();
+ this.currentConnection.commit();
+ pst.clearBatch();
+ SpringMVCContextHolder.getSystemLogger().info("澶勭悊鏁版嵁瀹屾垚锛屾彃鍏ョ洰鏍�:" + systemTable + ",鍏辫�楁椂锛�" + (System.currentTimeMillis() - startTime) + "ms");
+ } catch (Exception e) {
+ //鎵瑰鐞嗛敊璇�
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ SpringMVCContextHolder.getSystemLogger().error("澶勭悊鏁版嵁閿欒锛屾彃鍏ョ洰鏍�:" + systemTable);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ SpringMVCContextHolder.getSystemLogger().error("澶勭悊鏁版嵁閿欒锛屾彃鍏ョ洰鏍�:" + systemTable);
+
+ }
+
+// String[] columnNames = getColumnNames(resultSet);
+// Map<String, Map<Object, Object>> systemFieldMap = getSystemFieldByCache(systemTable);
+// //姣旇緝瀛楁鍦ㄧ紦瀛樹腑鏄惁瀛樺湪
+// this.comparisonFieldName(systemTable, columnNames, fieldNameList, systemFieldMap);
+ }
+
+ public void closeConnection() {
+ try {
+ if (this.currentConnection != null && !this.currentConnection.isClosed()) {
+ this.currentConnection.close();
+ }
+ if (this.sourceConnection != null && !this.sourceConnection.isClosed()) {
+ this.sourceConnection.close();
+ }
+ } catch (Exception e) {
+
+ }
+ }
+
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/BusinessDataSync.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/BusinessDataSync.java
new file mode 100644
index 0000000..f9fde2a
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/BusinessDataSync.java
@@ -0,0 +1,5241 @@
+package com.product.data.sync.util;
+
+import cn.hutool.core.collection.CollectionUtil;
+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.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.*;
+
+/**
+ * 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);
+ @Autowired
+ public BaseDao baseDao;
+
+ @Override
+ public BaseDao getBaseDao() {
+ return baseDao;
+ }
+
+ @Override
+ public void setBaseDao(BaseDao baseDao) {
+ this.baseDao = baseDao;
+ }
+
+ @Autowired
+ FileManagerService fileManagerService;
+
+ public FileManagerService getFileManagerService() {
+ return fileManagerService;
+ }
+
+ public void setFileManagerService(FileManagerService fileManagerService) {
+ this.fileManagerService = fileManagerService;
+ }
+
+ @Autowired
+ SystemMenusService systemMenusService;
+
+ public SystemMenusService getSystemMenusService() {
+ return systemMenusService;
+ }
+
+ public void setSystemMenusService(SystemMenusService systemMenusService) {
+ this.systemMenusService = systemMenusService;
+ }
+
+ @Autowired
+ 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;
+ }
+
+ //鍏徃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 瀵瑰簲 鏈烘瀯鐨勫叕鍙竨uid
+ 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();
+ //鍗忓悓鍔炲叕 婧愭祦绋嬫暟鎹甈ARENTGUID 瀵瑰簲鏈暟鎹�
+ private Map<String, DataTableEntity> parentGuidData = Maps.newHashMap();
+ //琛ㄥ敮涓�鏍囪瘑 鍜屾湰琛╱uid
+ 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 String clientUUID;
+
+ 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;
+ }
+
+ public String TSPath = Global.getSystemConfig("new.filePackage", "");
+
+ 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++) {
+ //鏁版嵁婧愮敤鎴穒d
+ 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++) {
+ //婧愭暟鎹甶d 閮ㄩ棬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");
+ //鍔熻兘濡傛灉鏈叧鑱斿熀纭�琛� 鏌ヨ娴佺▼琛�
+ 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);
+ }
+
+ return sf28;
+ }
+
+ /**
+ * 鍚屾鍏憡琛ㄦ暟鎹�
+ *
+ * @param conn
+ * @param tableName
+ * @throws SQLException
+ */
+ private void syncNotice(Connection conn, String tableName) throws SQLException {
+ //鍒ゆ柇鏄惁鏄凡缁忓悓姝ヨ繃鐨勮〃
+ DataTableEntity dataTable = baseDao.listTable("product_oa_announcement");
+ if (!BaseUtil.dataTableIsEmpty(dataTable)) {
+ return;
+ }
+ DataTableEntity noticeDt = null;
+ try {
+ noticeDt = BaseDaoServiceImpl.getDataTable(conn, tableName, "", new Object[]{});
+ } catch (Exception e) {
+ DataManipulationUtils.close(null, null, conn);
+ throw e;
+ }
+ for (int i = 0; i < noticeDt.getRows(); i++) {
+ FieldSetEntity feFs = noticeDt.getFieldSetEntity(i);
+ FieldSetEntity fs = new FieldSetEntity();
+ fs.setTableName("product_oa_announcement");
+ fs.setValue("title", feFs.getString("title"));
+ fs.setValue("content", feFs.getString("content"));
+ fs.setValue("type", feFs.getString("notice_category"));
+ fs.setValue("annex", feFs.getString("annex"));
+ DataTableEntity accessoryData = new DataTableEntity();
+ FieldSetEntity accessoryFs = new FieldSetEntity("temp");
+ accessoryFs.setValue("si02", "attachment");
+ accessoryFs.setValue("si04", "ANNEX");
+ accessoryData.addFieldSetEntity(accessoryFs);
+ if (!BaseUtil.dataTableIsEmpty(accessoryData)) {
+ try {
+ Map<String, List<String>> stringListMap = this.synchronizationAttachments(conn, accessoryData, fs, "product_oa_announcement", "annex");
+ fs.setValue("annex", CollectionUtil.join(stringListMap.get("annex"), ","));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+ //Set 杞崲涓哄瓧绗︿覆閫楀彿鍒嗛殧
+ //鍐欐柟娉曞垽鏂槸澶氫汉杩樻槸閮ㄩ棬锛岃嫢鏄儴闂ㄨ浆鎹负浜�
+ fs.setValue("extent", this.getUserIds(conn, feFs.getString("receivers")));
+ fs.setValue("expiration_date", feFs.getDate("displayed_date"));
+ fs.setValue("status", feFs.getString("is_reminded"));
+ fs.setValue("publish_status", feFs.getString("status"));
+ String publisher = this.userIdJson.getString(feFs.getString("publisher"));
+ if (BaseUtil.strIsNull(publisher)) {
+ continue;
+ }
+ fs.setValue("created_by", publisher);
+ fs.setValue("created_utc_datetime", feFs.getDate("publish_date"));
+
+ String uuid = baseDao.add(fs);
+// //閲嶆柊鑾峰彇jdbc杩炴帴
+// Connection connection = null;
+// try {
+// connection = this.getJDBC();
+// } catch (ClassNotFoundException e) {
+// e.printStackTrace();
+// }
+ DataTableEntity subFeFs = getSubDt(conn, "FE_APP5.PUB_NOTICE_RECEIVER", "NOTICE_ID", feFs.getString("id"));
+ DataTableEntity subData = new DataTableEntity();
+ FieldMetaEntity f = new FieldMetaEntity();
+ f.setTableName(new String[]{"product_oa_announcement_role"});
+ subData.setMeta(f);
+ for (int j = 0; j < subFeFs.getRows(); j++) {
+ FieldSetEntity fsSubFe = subFeFs.getFieldSetEntity(j);
+ FieldSetEntity fsSub = new FieldSetEntity();
+ fsSub.setTableName("product_oa_announcement_role");
+ String userId = userIdJson.getString(fsSubFe.getString("receiver"));
+ if (null == userId) {
+ continue;
+ }
+ //鑾峰彇鎵�灞為儴闂�
+ fsSub.setValue("user_id", userId);
+ fsSub.setValue("status", fsSubFe.getString("readed"));
+ fsSub.setValue("announcement_uuid", uuid);
+ subData.addFieldSetEntity(fsSub);
+ }
+ baseDao.add(subData);
+// DataManipulationUtils.close(null, null, connection);
+ }
+ }
+
+ /**
+ * 鑾峰彇userId
+ * 瑙f瀽澶氶�変汉鍛�,閮ㄩ棬,宀椾綅
+ *
+ * @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 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 SQLException {
+ //鍏憡琛�
+ 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);
+ //鏍规嵁瑕佹眰娴佺▼瑕佸悓姝ヤ袱娆� 鐩稿悓娴佺▼鐨則ypeCode鐩稿悓
+ 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 SQLException {
+ //鍚屾璇峰亣 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);
+ //鏍规嵁瑕佹眰娴佺▼瑕佸悓姝ヤ袱娆� 鐩稿悓娴佺▼鐨則ypeCode鐩稿悓
+ 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");
+ fieldSetEntity.setValue("fill_in_time", pl11);
+ //PL11 璇蜂紤鍋囧紑濮嬫椂闂� start_time 寮�濮嬫椂闂�
+ 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;
+ }
+ }
+ 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");
+ //f1w08 璇蜂紤鍋囧紑濮嬫椂闂� fill_in_time 濉崟鏃堕棿
+ fieldSetEntity.setValue("fill_in_time", f1w08);
+ //f1w08 璇蜂紤鍋囧紑濮嬫椂闂� start_time 寮�濮嬫椂闂�
+ fieldSetEntity.setValue("start_time", f1w08);
+ //f1w09 璇蜂紤鍋囩粨鏉熸椂闂� end_time 缁撴潫鏃堕棿
+ fieldSetEntity.setValue("end_time", fse.getString("f1w09"));
+ //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琛╱ser_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 缁勭粐鏈烘瀯锛宭x_sys_org_levels琛╱uid
+ 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 SQLException {
+ //鍚屾鑰冨嫟鏁版嵁
+ 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){
+// //姝e父
+// 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);
+ }
+ }
+ }
+
+ /**
+ * 浼氳瀹ゅ悓姝�
+ *
+ * @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("鍒涘煄鍗婂勾鐫f煡", 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"));
+ //鐢宠浜篿d02
+ 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 涓庢湰琛╱uid
+ String id = feFs.getString("id");
+ pxMap.put("SYS_COLLABORATIVE" + id, uuid);
+ ccooperatesMaps.put(id, fs);
+ //鍚屾姝f枃琛ュ厖
+ 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);
+ //鍏宠仈鍗忓悓琛╱uid
+ subfse.setValue("cooperate_uuid", uuid);
+ //鎺ユ敹浜篒d
+ 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);
+ //鍏宠仈鍗忓悓琛╱uid
+ subfse2.setValue("cooperate_uuid", uuid);
+ //鎺ユ敹浜篒d
+ 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));
+ }
+ //鑾峰彇宸插悓姝ユ祦绋媡ask鐨勫叧鑱斾簨椤�
+ 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);
+ }
+ }
+
+ /**
+ * 鍚屾鍗忓悓姝f枃琛ュ厖
+ */
+ 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) {
+ //瑙f瀽骞跺瓨鍏ョ敤鎴�
+ 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);
+ //鍏宠仈鍗忓悓妯℃澘琛╱uid
+ subfse.setValue("master_uuid", uuid);
+ //鎺ユ敹浜篒d
+ 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 鍓╀綑浜篋ata
+ */
+ 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);
+ //鍏宠仈鍗忓悓琛╱uid
+ subfs.setValue("master_uuid", uuid);
+ //鎺ユ敹浜猴紙鍏宠仈鐢ㄦ埛琛╥d锛� 鎺ユ敹浜轰竴浣嗘槸鏈烘瀯鎴栭儴闂ㄨ妭鐐� 閭e氨鏄渶鍚庤妭鐐�
+ 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);
+ }
+ }
+ }
+
+ /**
+ * 瑙f瀽鍚屾鐨勫矖浣嶉儴闂� 瑙f瀽涓轰汉鍐嶆壒閲忎繚瀛�
+ *
+ * @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);
+ //鍏宠仈鍗忓悓琛╱uid
+ subfse.setValue("master_uuid", uuid);
+ //鎺ユ敹浜篿d
+ 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) {
+ 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);
+ 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]);
+ message_uuid = baseDao.add(message);
+ }
+
+ FieldSetEntity message_user = new FieldSetEntity();
+ message_user.setTableName("product_sys_message_user");
+ //鍏宠仈lx_sys_message琛║UID
+ 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);
+ }
+ baseDao.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琛╱uid
+ flowReply.setValue("parent_uuid", fieldSetEntity.getUUID());
+ //鍥炲鍐呭
+ flowReply.setValue("reply_content", id04);
+ //鍥炲鏃堕棿
+ flowReply.setValue("reply_datetime", ideFse.getString("id03"));
+ //鍥炲浜猴紝鍏宠仈user琛╥d
+ String user_id = userIdJson.getString(ideFse.getString("id02"));
+ if (BaseUtil.strIsNull(user_id)) {
+ continue;
+ }
+ //鍥炲浜猴紝鍏宠仈user琛╥d
+ 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);
+ //鍏宠仈鍗忓悓琛╱uid
+ subfse.setValue("cooperate_uuid", uuid);
+ //鎺ユ敹浜篒d
+ 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 鍓╀綑浜篋ata
+ */
+ 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);
+ //鍏宠仈鍗忓悓琛╱uid
+ subfs.setValue("cooperate_uuid", uuid);
+ //鎺ユ敹浜猴紙鍏宠仈鐢ㄦ埛琛╥d锛� 鎺ユ敹浜轰竴浣嗘槸鏈烘瀯鎴栭儴闂ㄨ妭鐐� 閭e氨鏄渶鍚庤妭鐐�
+ 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);
+ }
+ }
+ }
+
+ /**
+ * 瑙f瀽鍚屾鐨勫矖浣嶉儴闂� 瑙f瀽涓轰汉鍐嶆壒閲忎繚瀛�
+ *
+ * @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);
+ //鍏宠仈鍗忓悓琛╱uid
+ subfse.setValue("cooperate_uuid", uuid);
+ //鎺ユ敹浜篿d
+ 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);
+ //璇ユ潈闄愮鐞嗙殑鏄敤鎴疯〃锛圫YS_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();
+ //鍚嶅瓧涓簁 鐨刯son
+ 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) {
+ //鏄惁涓哄姛鑳藉叆鍙o紝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());
+
+ 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浠g爜璺緞
+ fs.setValue("page_url", pageFs.getString("sp09"));
+ //鍏堝瓨鍏ユ祦绋媔d 杩佺Щ娴佺▼鍚庡啀鏇挎崲
+ 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");
+ //琛╱uid
+ 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);
+ //鏂板涓�涓猣e杩佺Щ鎬绘ā鍧�
+ 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();
+ }
+ }
+
+ /**
+ * 杩佺Щ涓氬姟鏁版嵁琛�
+ *
+ * @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 = null;
+ Boolean syncAttachments = false;
+ 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;
+ }
+ //鍚屾琛ㄧ粨鏋� 鍙婂瓧娈典俊鎭�
+ map = this.syncTableField(conn, Orlfs, sf28s, subField);
+ //鍒锋柊table 琛�
+// DataPoolCacheImpl.getInstance().cacheDataByTable("product_sys_datamodel_table");;
+ //鍒锋柊field 琛�
+// DataPoolCacheImpl.getInstance().cacheDataByTable("product_sys_datamodel_field");
+// try {
+// Thread.sleep(7000);
+// } catch (InterruptedException e) {
+// e.printStackTrace();
+// SpringMVCContextHolder.getSystemLogger().error(e);
+// }
+// } else {
+// return;
+// }
+
+ } else {
+ //宸叉湁琛�
+ 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;
+ }
+
+ //涓氬姟琛� fe鐨刬d 瀵瑰簲UUID
+ for (int i = 0; i < dataDt.getRows(); i++) {
+ FieldSetEntity dataFs = dataDt.getFieldSetEntity(i);
+ FieldSetEntity tableFs = new FieldSetEntity();
+ tableFs.setTableName(this.originalTable.getString(taName));
+ //key 涓烘湰琛ㄥ瓧娈� value 涓烘暟鎹簮瀛楁
+ for (String key : map.keySet()) {
+ //鍗曞叧鑱旂殑鐢ㄦ埛user_id
+ if ("USER".equals(fieldTypeJson.getString(key))) {
+ tableFs.setValue(key, userIdJson.getString(dataFs.getString(map.get(key))));
+ //鍗曞叧鑱旂殑缁勭粐鏋舵瀯uuid
+ } else if ("GROUP".equals(fieldTypeJson.getString(key))) {
+ tableFs.setValue(key, groupJson.get(dataFs.getString(map.get(key))));
+ //澶氶�夌粍缁囨灦鏋� 杞崲涓虹敤鎴穟ser_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("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 = "";
+ try {
+ uuid = baseDao.add(tableFs);
+ } catch (BaseException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ }
+ //琛ㄥ敮涓�id 瀵瑰簲uuid
+ pxMap.put(taName + dataFs.getString(this.pk), uuid);
+ }
+ //鍚屾瀹屼竴寮犺〃鏁版嵁鍚庢竻绌簀son鏁版嵁
+ 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;
+ }
+ 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);
+ }
+ }
+
+ /**
+ * 鍒ゆ柇鏄惁鏄紩鐢ㄦ暟鎹� 鏄氨瑕佽浆鎹紙濡備汉鍛榠d锛屾満鏋刬d锛�
+ *
+ * @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);
+ //鏀惧叆瀹㈡埛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);
+ }
+ }
+ }
+ }
+ 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);
+ 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;
+ }
+
+ /**
+ * 閫氳繃琛╥d鑾峰彇鍚屾鐨勯檮浠跺瓧娈�
+ *
+ * @param tableId 琛╥d
+ * @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");
+ // 鍒ゆ柇鏄惁鏄紩鐢ㄦ暟鎹� 鏄氨瑕佽浆鎹紙濡備汉鍛榠d锛屾満鏋刬d锛�
+ 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)) {
+ //濡傛灉宸茬粡鏈塸k
+ 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);
+ throw e;
+ }
+ if (Orlfs == null) {
+ //閫氳繃
+ Orlfs = BaseDaoServiceImpl.getFieldSet(conn, "fe_base5.wf_model", " WM04 = ? ", new Object[]{sf28});
+ if (Orlfs == null) {
+ return null;
+ }
+ }
+ //wm05 涓烘祦绋嬬紪鐮� 鏌ヨ瀛樻湁缂栫爜鐨刴vc椤甸潰 鏀逛负娴佺▼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);
+ }
+
+ }
+
+ 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 = ?", new Object[]{flowTitle}, 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");
+ } else {
+ modelUuid = baseDao.add(modelFs);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ 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();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ }
+ } catch (Exception e) {
+ e.getStackTrace();
+ 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-椤哄簭澶勭悊 鍏圓 鍚巄 銆傘�傘�備笅涓�涓妭鐐�
+ // 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浠g爜 鏆傚瓨浜庢
+ 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琛╢e 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 SQLException {
+ 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);
+ 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;
+ }
+ //婧恥uid锛屽叧鑱旀湰琛�
+ 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")));
+ //鍏宠仈娴佺▼琛╱uid
+ 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());
+ baseDao.add(DetailFs);
+ OrgIdUUIDmap.put(wi00, DetailFs);
+ stateMap.put(wi00, nodeState);
+ }
+ return stateMap;
+ }
+
+
+ /**
+ * 鏌ヨ娴佺▼娑堟伅琛�
+ *
+ * @param conn
+ * @param tricode_funs
+ * @param stateMap
+ * @throws SQLException
+ */
+ public void synchronizingProcessMessages(Connection conn, String tricode_funs, Map<String, String> stateMap) throws SQLException {
+ 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) {
+ 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);
+ 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 = baseDao.add(message);
+ }
+
+ FieldSetEntity message_user = new FieldSetEntity();
+ message_user.setTableName("product_sys_message_user");
+ //鍏宠仈lx_sys_message琛║UID
+ 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 (!BaseUtil.dataTableIsEmpty(dataTableEntity)) {
+ baseDao.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 SQLException, BaseException {
+ 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();
+
+ 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-姝e父缁撴潫锛�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);
+ baseDao.add(taskFs);
+ map.put(Orlfs.getString("wt00"), taskFs);
+ }
+ 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();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ }
+ String moduleUUID = null;
+ //鑻ュ凡鏈夎〃鍚屾 mvc鏍囪瘑 琛ㄧず浠庡姛鑳藉紑濮嬪悓姝�
+ if (tricode_funs.indexOf("mvc") != -1) { //mvc 瑕佸甫涓婂悓琛ㄧ殑澶氫釜鍔熻兘
+ //鍙悓姝vc
+ 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));
+ String functionUuid = fse.getUUID();
+ //淇敼宸插悓姝ラ檮浠� 娣诲姞 module_uuid function_uuid
+ baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{moduleUUID, functionUuid, tableName.toLowerCase()});
+ //鍚屾娴佺▼
+ this.syncFlow(conn, moduleUUID, sf28);
+ }
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ }
+ } else {
+ try {
+ //鍚屾琛ㄥ拰琛ㄦ暟鎹�
+ sf28 = this.synchronizeTablesData(conn, this.tricode_funs);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ }
+ String table_name = sf28.split("\\.")[1];
+ String myTableName = this.originalTable.getString(table_name);
+ if (!isStr(sf28)) {
+ //鍚屾mvc
+ try {
+ moduleUUID = this.synchronizationModuleName(conn, this.tricode_funs, sf28);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ }
+ } else {
+ //宸叉湁鍔熻兘鐨勮〃灏变笉鍚屾mvc 鏌ヨ璇ュ姛鑳界殑妯″潡uuid
+ StringBuffer sql = new StringBuffer();
+ sql.append(" tricode = (\n")
+ .append("SELECT tricode_parent FROM product_sys_functions a LEFT JOIN \n")
+ .append("product_sys_datamodel_table b on a.table_uuid = b.uuid \n")
+ .append("WHERE b.table_name = ? GROUP BY tricode_parent\n")
+ .append(") AND function_type_uuid = 0");
+
+ FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntityByFilter("product_sys_functions", sql.toString(), new String[]{myTableName}, false);
+ moduleUUID = fieldSetEntity.getUUID();
+ }
+ if (!isStr(sf28)) {
+ this.syncFlow(conn, moduleUUID, sf28);
+ }
+ //琛ㄥ悕鏌ヨ鍔熻兘
+ FieldSetEntity fse = baseDao.getFieldSetBySQL("SELECT a.* FROM product_sys_functions a LEFT JOIN product_sys_datamodel_table b on a.table_uuid = b.uuid WHERE b.table_name = ?", new String[]{myTableName}, false);
+ String functionUuid = fse.getUUID();
+ //淇敼宸插悓姝ラ檮浠� 娣诲姞 module_uuid function_uuid
+ baseDao.executeUpdate(" UPDATE product_sys_attachments SET module_uuid = ?, function_uuid = ? WHERE attachment_data_table = ? AND function_uuid is null ", new String[]{moduleUUID, functionUuid, myTableName});
+ }
+ try {
+ DataManipulationUtils.close(null, null, conn);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ }
+ }
+
+ /**
+ * 鍚屾娴佺▼
+ *
+ * @param conn jdbc杩炴帴
+ * @param moduleUUID 妯″潡uuid
+ * @param sf28 琛ㄥ悕
+ */
+ public void syncFlow(Connection conn, String moduleUUID, String sf28) {
+
+ //鏌ヨ涓诲叕鍙竨uid
+ 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);
+ //鏍规嵁瑕佹眰娴佺▼瑕佸悓姝ヤ袱娆� 鐩稿悓娴佺▼鐨則ypeCode鐩稿悓
+ 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);
+ }
+ //鍒濆鍖栬彍鍗曠紦瀛�
+// systemMenusService.initSystemMenu();
+ System.out.println("=================" + tricode_funs + "鍚屾鎴愬姛===============");
+ }
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/ConnectionManager.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/ConnectionManager.java
new file mode 100644
index 0000000..14a88a0
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/ConnectionManager.java
@@ -0,0 +1,81 @@
+package com.product.data.sync.util;
+
+import com.product.core.config.Global;
+import com.product.core.exception.BaseException;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+/**
+ * @Author cheng
+ * @Date 2022/1/18 15:09
+ * @Desc 鑾峰彇褰撳墠鏁版嵁搴撹繛鎺�
+ */
+public class ConnectionManager {
+ private static ConnectionManager connectionManager = new ConnectionManager();
+
+ private String url;
+
+ private String userName;
+
+ private String password;
+
+ private String driver;
+
+ private String databaseType;
+
+ public ConnectionManager() {
+ System.out.println(this);
+ this.url = Global.getSystemConfig("data.source.url", "");
+ this.userName = Global.getSystemConfig("data.source.user", "");
+ this.password = Global.getSystemConfig("data.source.password", "");
+ this.driver = Global.getSystemConfig("data.source.driver", "");
+ this.databaseType = Global.getSystemConfig("data.source.type", "");
+ }
+
+ /**
+ * 鑾峰彇jdbc杩炴帴
+ *
+ * @param diver jdbc杩炴帴绫诲瀷
+ * @param jdbc 杩炴帴url
+ * @param user 鐢ㄦ埛鍚�
+ * @param pwd 瀵嗙爜
+ * @return JDBC杩炴帴
+ * @throws BaseException
+ */
+ public static Connection getConnection(String diver, String jdbc, String user, String pwd) throws BaseException {
+ try {
+ Class.forName(diver);
+ Connection connection = DriverManager.getConnection(jdbc, user, pwd);
+ return connection;
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ throw new BaseException(e);
+ }
+ }
+
+ /**
+ * 鑾峰彇鏁版嵁搴撹繛鎺�
+ *
+ * @return
+ * @throws BaseException
+ */
+ public final static Connection getConnection() throws BaseException {
+ try {
+ Class.forName(connectionManager.driver);
+ return DriverManager.getConnection(connectionManager.url, connectionManager.userName, connectionManager.password);
+ } catch (SQLException | ClassNotFoundException e) {
+ throw new BaseException(e);
+ }
+ }
+
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/CustomResultSet.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/CustomResultSet.java
new file mode 100644
index 0000000..3668605
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/CustomResultSet.java
@@ -0,0 +1,97 @@
+package com.product.data.sync.util;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 鑷畾涔夋煡璇㈢粨鏋�
+ */
+public class CustomResultSet {
+ /**
+ * 缁撴灉闆�
+ */
+ private ResultSet resultSet;
+ /**
+ * 鏄惁鑷畾涔夌粨鏋滈泦
+ */
+ private boolean isCustom;
+ /**
+ * next 涓嬭〃
+ */
+ private int currentIndex = -1;
+ /**
+ * 缁撴灉闆嗕腑鐨勫垪鍚�
+ */
+ private String[] columnNames;
+ /**
+ * 鑷畾涔夌粨鏋滈泦鏃跺瓨鍌ㄦ瘡鏉℃暟鎹殑闆嗗悎
+ */
+ private List<Map<String, Object>> values;
+
+ /**
+ * 鏋勯�犲嚱鏁�
+ * java.sql.ResultSet
+ *
+ * @param resultSet
+ */
+ public CustomResultSet(ResultSet resultSet) {
+ this.resultSet = resultSet;
+ this.isCustom = false;
+ }
+
+ /**
+ * 鑷畾涔夌粨鏋滈泦鏋勯��
+ *
+ * @param resultSet
+ * @param columnNames
+ * @throws SQLException
+ */
+ public CustomResultSet(ResultSet resultSet, String[] columnNames) throws SQLException {
+ this.resultSet = resultSet;
+ this.columnNames = columnNames;
+ if (this.columnNames == null || this.columnNames.length <= 0) {
+ this.columnNames = BatchData.getColumnNames(resultSet);
+ }
+ this.isCustom = true;
+ values = new ArrayList<>();
+ while (resultSet.next()) {
+ Map<String, Object> value = new HashMap<>();
+ for (String columnName : this.columnNames) {
+ value.put(columnName, resultSet.getObject(columnName));
+ }
+ values.add(value);
+ }
+ this.resultSet.close();
+ this.resultSet=null;
+ }
+
+
+ public boolean next() throws SQLException {
+ if (isCustom && currentIndex >= 0 && this.values.get(currentIndex) != null) {
+ this.values.get(currentIndex).clear();
+ }
+ currentIndex++;
+ return !isCustom ? resultSet.next() : this.values.size() - 1 >= currentIndex;
+ }
+
+ public Object getObject(String columnLabel) throws SQLException {
+ if (isCustom && this.values.get(this.currentIndex) != null) {
+ return this.values.get(this.currentIndex).get(columnLabel);
+ } else if (!isCustom) {
+ return resultSet.getObject(columnLabel);
+ }
+ return null;
+ }
+
+ public ResultSet getResultSet() {
+ return isCustom ? null : resultSet;
+ }
+
+ public String[] getColumnNames() {
+ return columnNames;
+ }
+}
\ No newline at end of file
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/DataAddDeleteSynchronization.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/DataAddDeleteSynchronization.java
new file mode 100644
index 0000000..3f09016
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/DataAddDeleteSynchronization.java
@@ -0,0 +1,169 @@
+package com.product.data.sync.util;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.product.common.collect.ListUtils;
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.data.sync.config.CmnConst;
+import com.product.util.BaseUtil;
+import com.product.util.CallBack;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.lang.reflect.InvocationTargetException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class DataAddDeleteSynchronization extends AbstractBaseService implements Runnable {
+ @Autowired
+ public ExceptionLog exceptionLog;
+
+ public ExceptionLog getExceptionLog() {
+ return exceptionLog;
+ }
+
+ public void setExceptionLog(ExceptionLog exceptionLog) {
+ this.exceptionLog = exceptionLog;
+ }
+
+ @Autowired
+ public BaseDao baseDao;
+
+ @Override
+ public BaseDao getBaseDao() {
+ return baseDao;
+ }
+
+ @Override
+ public void setBaseDao(BaseDao baseDao) {
+ this.baseDao = baseDao;
+ }
+
+ private ResultSet resultSet;
+ private Map<String, String> map;
+ private Map<String, String> syncMap;
+ private Map<String, String> sileMap;
+ private Map<String, String> deleteMap;
+ private CallBack callBack;
+
+ public DataAddDeleteSynchronization(ResultSet resultSet, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap, Map<String, String> deleteMap) {
+ this.resultSet = resultSet;
+ this.map = map;
+ this.syncMap = syncMap;
+ this.sileMap = sileMap;
+ this.deleteMap = deleteMap;
+ }
+
+ public void setCallBack(CallBack callBack) {
+ this.callBack = callBack;
+ }
+
+ @Override
+ public void run() {
+ //绯荤粺琛ㄥ悕
+ String tableName = map.get("tableName");
+ //鏃ュ織uuid
+ String logUuid = map.get("logUuid");
+ //浜嬩欢鍓嶈皟鐢�
+ String savePreEvent = map.get("savePreEvent");
+ //浜嬩欢鍚庤皟鐢�
+ String postSaveEvent = map.get("postSaveEvent");
+ //杩唬鏁伴噺
+ Integer resultRow = 0;
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //鍒犻櫎鏁伴噺
+ Integer deleteNumber = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+
+ List<String> addDataRecord = new ArrayList<>();
+ List<String> deleteDataRecord = new ArrayList<>();
+ List<String> list = ListUtils.newArrayList();
+ while (true) {
+ try {
+ if (!resultSet.next()) break;
+ } catch (SQLException e) {
+ exceptionLog.upExceptionLog(logUuid, e);
+ break;
+ }
+ try {
+ FieldSetEntity fieldSet = new FieldSetEntity();
+ fieldSet.setTableName(tableName);
+ resultRow++;
+ //鏄惁鏄垹闄ゆ暟鎹�
+ Boolean is_delete = false;
+ StringBuffer condition = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ fieldSet.setValue(syncMap.get(key), resultSet.getString(key));
+ }
+ for (String key : deleteMap.keySet()) {
+ //鍒犻櫎楠岃瘉鍊�
+ String deleteValue = map.get("deleteValue");
+ //鍊肩浉鍚屽氨鍒犻櫎鎴栬�呬笉鏂板
+ if (deleteValue.equals(resultSet.getString(key))) {
+ is_delete = true;
+ }
+ }
+ list.clear();
+ for (String key : sileMap.keySet()) {
+ String value = resultSet.getString(key);
+ String fieldName = sileMap.get(key);
+ fieldSet.setValue(fieldName, value);
+ condition.append(fieldName).append(" = ? AND ");
+ list.add(value);
+ }
+ //璋冪敤淇濆瓨鍓嶆柟娉�
+ if (!BaseUtil.strIsNull(savePreEvent) && savePreEvent.indexOf(".") != -1) {
+ DataManipulationUtils.codeCalls(savePreEvent, fieldSet);
+ }
+ String term = condition.substring(0, condition.length() - 4);
+ FieldSetEntity fieldSetEntityByFilter = baseDao.getFieldSetEntityByFilter(tableName, term, list.toArray(new String[]{}), false);
+
+ if (is_delete) {
+ if (fieldSetEntityByFilter != null) {
+ baseDao.delete(tableName, new String[]{fieldSetEntityByFilter.getString(CmnConst.UUID)});
+ deleteDataRecord.add(fieldSetEntityByFilter.getUUID());
+ }
+ deleteNumber++;
+ } else {
+ //濡傛灉鏈煡鍒版暟鎹氨鏂板
+ if (fieldSetEntityByFilter == null) {
+ baseDao.add(fieldSet);
+ addDataRecord.add(fieldSet.getUUID());
+ addNum++;
+ } else {
+ errorNum++;
+ }
+ }
+ //璋冪敤淇濆瓨鍚庢柟娉�
+ if (!BaseUtil.strIsNull(postSaveEvent) && postSaveEvent.indexOf(".") != -1) {
+ DataManipulationUtils.codeCalls(postSaveEvent, fieldSet);
+ }
+ } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | BaseException | SQLException e) {
+ errorNum++;
+ exceptionLog.addSubExceptionLog(logUuid, list, e);
+ continue;
+ }
+ }
+ Map<String, Object> map = Maps.newHashMap();
+ //杩唬鏁伴噺
+ map.put("resultRow", (resultRow));
+ //鏂板鏁伴噺
+ map.put("addNum", (addNum));
+ //鍒犻櫎鏁伴噺
+ map.put("deleteNumber", (deleteNumber));
+ //閿欒鏁伴噺
+ map.put("errorNum", (errorNum));
+ map.put("changeDataKeys", Lists.newArrayList(addDataRecord, null, deleteDataRecord));
+ //鍥炶皟鍑芥暟
+ if (this.callBack != null) {
+ callBack.method(map);
+ }
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/DataAddSynchronization.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/DataAddSynchronization.java
new file mode 100644
index 0000000..99e0445
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/DataAddSynchronization.java
@@ -0,0 +1,140 @@
+package com.product.data.sync.util;
+
+import com.beust.jcommander.internal.Lists;
+import com.google.common.collect.Maps;
+import com.product.common.collect.ListUtils;
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.util.BaseUtil;
+import com.product.util.CallBack;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.lang.reflect.InvocationTargetException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class DataAddSynchronization extends AbstractBaseService implements Runnable {
+ @Autowired
+ public ExceptionLog exceptionLog;
+
+ public ExceptionLog getExceptionLog() {
+ return exceptionLog;
+ }
+
+ public void setExceptionLog(ExceptionLog exceptionLog) {
+ this.exceptionLog = exceptionLog;
+ }
+
+ @Autowired
+ public BaseDao baseDao;
+
+ @Override
+ public BaseDao getBaseDao() {
+ return baseDao;
+ }
+
+ @Override
+ public void setBaseDao(BaseDao baseDao) {
+ this.baseDao = baseDao;
+ }
+
+ private ResultSet resultSet;
+ private Map<String, String> map;
+ private Map<String, String> syncMap;
+ private Map<String, String> sileMap;
+ private CallBack callBack;
+
+ public DataAddSynchronization(ResultSet resultSet, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap) {
+ this.resultSet = resultSet;
+ this.map = map;
+ this.syncMap = syncMap;
+ this.sileMap = sileMap;
+ }
+
+ public void setCallBack(CallBack callBack) {
+ this.callBack = callBack;
+ }
+
+ @Override
+ public void run() {
+ //绯荤粺琛ㄥ悕
+ String tableName = map.get("tableName");
+ //鏃ュ織uuid
+ String logUuid = map.get("logUuid");
+ //浜嬩欢鍓嶈皟鐢�
+ String savePreEvent = map.get("savePreEvent");
+ //浜嬩欢鍚庤皟鐢�
+ String postSaveEvent = map.get("postSaveEvent");
+ //杩唬鏁伴噺
+ Integer resultRow = 0;
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ List<String> addDataRecord = new ArrayList<>();
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ List<String> list = ListUtils.newArrayList();
+ while (true) {
+ try {
+ if (!resultSet.next()) break;
+ } catch (SQLException e) {
+ exceptionLog.upExceptionLog(logUuid, e);
+ break;
+ }
+ try {
+ FieldSetEntity fieldSet = new FieldSetEntity();
+ fieldSet.setTableName(tableName);
+ resultRow++;
+ StringBuffer condition = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ fieldSet.setValue(syncMap.get(key), resultSet.getString(key));
+ }
+ list.clear();
+ for (String key : sileMap.keySet()) {
+ String value = resultSet.getString(key);
+ String fieldName = sileMap.get(key);
+ fieldSet.setValue(fieldName, value);
+ condition.append(fieldName).append(" = ? AND ");
+ list.add(value);
+ }
+ //璋冪敤淇濆瓨鍓嶆柟娉�
+ if (!BaseUtil.strIsNull(savePreEvent) && savePreEvent.indexOf(".") != -1) {
+ DataManipulationUtils.codeCalls(savePreEvent, fieldSet);
+ }
+ String term = condition.substring(0, condition.length() - 4);
+ FieldSetEntity fieldSetEntityByFilter = baseDao.getFieldSetEntityByFilter(tableName, term, list.toArray(new String[]{}), false);
+ //濡傛灉鏈煡鍒版暟鎹氨鏂板
+ if (fieldSetEntityByFilter == null) {
+ baseDao.add(fieldSet);
+ addNum++;
+ } else {
+ errorNum++;
+ }
+ //璋冪敤淇濆瓨鍚庢柟娉�
+ if (!BaseUtil.strIsNull(postSaveEvent) && postSaveEvent.indexOf(".") != -1) {
+ DataManipulationUtils.codeCalls(postSaveEvent, fieldSet);
+ }
+ } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | BaseException | SQLException e) {
+ errorNum++;
+ exceptionLog.addSubExceptionLog(logUuid, list, e);
+ continue;
+ }
+ }
+ Map<String, Object> map = Maps.newHashMap();
+ //杩唬鏁伴噺
+ map.put("resultRow", (resultRow));
+ //鏂板鏁伴噺
+ map.put("addNum", (addNum));
+ //閿欒鏁伴噺
+ map.put("errorNum", (errorNum));
+ map.put("changeDataKeys", Lists.newArrayList(addDataRecord));
+ //鍥炶皟鍑芥暟
+ if (this.callBack != null) {
+ callBack.method(map);
+ }
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/DataManipulationUtils.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/DataManipulationUtils.java
new file mode 100644
index 0000000..142c167
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/DataManipulationUtils.java
@@ -0,0 +1,231 @@
+package com.product.data.sync.util;
+
+import cn.hutool.core.util.IdUtil;
+import com.product.common.utils.spring.SpringUtils;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.data.sync.config.SystemCode;
+import com.product.util.BaseUtil;
+import org.apache.commons.lang3.StringUtils;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.*;
+import java.util.*;
+import java.util.Date;
+
+public class DataManipulationUtils {
+
+ /**
+ * 鑾峰彇jdbc杩炴帴
+ *
+ * @param diver jdbc杩炴帴绫诲瀷
+ * @param jdbc 杩炴帴url
+ * @param user 鐢ㄦ埛鍚�
+ * @param pwd 瀵嗙爜
+ * @return JDBC杩炴帴
+ * @throws BaseException
+ */
+ public static Connection getConnection(String diver, String jdbc, String user, String pwd) throws ClassNotFoundException, SQLException {
+ Class.forName(diver);
+ Connection connection = DriverManager.getConnection(jdbc, user, pwd);
+ return connection;
+ }
+
+ /**
+ * 鍏抽棴鏁版嵁搴撶殑杩炴帴
+ *
+ * @param rs 缁撴灉闆�
+ * @param stmt 鎵цsql鐨勭被
+ * @param con JDBC杩炴帴
+ * @throws SQLException
+ */
+ public static void close(ResultSet rs, Statement stmt, Connection con) throws SQLException {
+ if (rs != null)
+ rs.close();
+ if (stmt != null)
+ stmt.close();
+ if (con != null && !con.isClosed())
+ con.close();
+ }
+
+ /**
+ * 鏌ヨ鏁版嵁鎬绘潯鏁�
+ * 涓昏閫氳繃map閲岄潰琛ㄥ悕鍜屾潯浠舵煡璇㈡潯鏁�
+ *
+ * @param com 杩炴帴
+ * @param map 鍙傛暟map
+ * @return 鏁版嵁鎬绘潯鏁�
+ * @throws SQLException
+ */
+ public static Integer getResultSetRow(Connection com, Map<String, String> map) throws SQLException {
+ StringBuffer sql = new StringBuffer();
+ //婧愭暟鎹〃鍚�
+ String dataOriginName = map.get("dataOriginName");
+ //鏌ヨ鏉′欢
+ String syncCondition = map.get("syncCondition");
+ sql.append(" SELECT count(*) FROM ").append(dataOriginName);
+ if (!BaseUtil.strIsNull(syncCondition)) {
+ sql.append(" WHERE ").append(syncCondition);//鍙傛暟澶辫触 鏀逛负瀛楃涓叉嫾鎺�
+ }
+ PreparedStatement ps = com.prepareStatement(sql.toString());
+ ResultSet rs = ps.executeQuery();
+ while (rs.next()) {
+ return rs.getInt(1);
+ }
+ return 0;
+ }
+
+ /**
+ * 鏌ヨ鏁版嵁
+ *
+ * @param com JDBC杩炴帴
+ * @param map 鏌ヨ蹇呭鐨凪ap
+ * @return
+ * @throws SQLException
+ */
+ public static ResultSet getResultSet(Connection com, Map<String, String> map) throws SQLException {
+ String type = map.get("databaseType");
+ if ("mysql".equals(type)) {
+ return DataManipulationUtils.getMysqlResultSet(com, map);
+ } else if ("oracle".equals(type)) {
+ return DataManipulationUtils.getOracleResultSet(com, map);
+ } else if ("sqlserver".equals(type)) {
+ return DataManipulationUtils.getSqlServerResultSet(com, map);
+ } else if ("informix".equals(type)) {
+ return DataManipulationUtils.getInforMixResultSet(com, map);
+ } else {
+ throw new SQLException(SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getValue(), SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getText());
+ }
+ }
+
+ public static void main(String[] args) {
+ long l = System.currentTimeMillis();
+ Set<String> uuids = new HashSet<>();
+ int data = 1;
+ for (int i = 0; i < 10000; i++) {
+ String s = IdUtil.randomUUID();
+ uuids.add(s);
+ data++;
+ if (data % 1000 == 0) {
+ System.out.println(System.currentTimeMillis() - l);
+ l = System.currentTimeMillis();
+ }
+ }
+ System.out.println(uuids.size());
+ }
+
+ /**
+ * MySql鏌ヨ鏁版嵁
+ *
+ * @param con 杩炴帴
+ * @param map 琛ㄥ悕闆嗗弬鏁�
+ * @return 鏁版嵁闆�
+ * @throws SQLException
+ */
+ public static ResultSet getMysqlResultSet(Connection con, Map<String, String> map) throws SQLException {
+ String sql = map.get("sql");
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ Integer pageSize = Integer.parseInt(map.get("pageSize"));
+ Integer start = (currentPage - 1) * pageSize;
+ sql = sql.replaceFirst("[?]", map.get("fileName"));
+ sql = sql.replaceFirst("[?]", map.get("dataOriginName"));
+ sql = sql.replaceFirst("[?]", String.valueOf(start));
+ sql = sql.replaceFirst("[?]", String.valueOf(pageSize));
+ SpringMVCContextHolder.getSystemLogger().info(sql);
+ PreparedStatement ps = con.prepareStatement(sql);
+ ResultSet resultSet = ps.executeQuery();
+ return resultSet;
+ }
+
+ /**
+ * SqlServer鏌ヨ鏁版嵁
+ *
+ * @param con 杩炴帴
+ * @param map 琛ㄥ悕闆嗗弬鏁�
+ * @return 鏁版嵁闆�
+ * @throws SQLException
+ */
+ public static ResultSet getSqlServerResultSet(Connection con, Map<String, String> map) throws SQLException {
+ String sql = map.get("sql");
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ Integer pageSize = Integer.parseInt(map.get("pageSize"));
+ Integer start = (currentPage - 1) * pageSize;
+ sql = sql.replaceFirst("[?]", String.valueOf(pageSize));
+ sql = sql.replaceFirst("[?]", map.get("fileName"));
+ sql = sql.replaceFirst("[?]", map.get("dataOriginName"));
+
+ sql = sql.replaceFirst("[?]", String.valueOf(start));
+ sql = sql.replaceFirst("[?]", map.get("dataOriginName"));
+ SpringMVCContextHolder.getSystemLogger().info(sql);
+ PreparedStatement ps = con.prepareStatement(sql);
+ return ps.executeQuery();
+ }
+
+ /**
+ * InforMix鏌ヨ鏁版嵁
+ *
+ * @param con 杩炴帴
+ * @param map 琛ㄥ悕闆嗗弬鏁�
+ * @return 鏁版嵁闆�
+ * @throws SQLException
+ */
+ public static ResultSet getInforMixResultSet(Connection con, Map<String, String> map) throws SQLException {
+ String sql = map.get("sql");
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ Integer pageSize = Integer.parseInt(map.get("pageSize"));
+ Integer start = (currentPage - 1) * pageSize;
+ sql = sql.replaceFirst("[?]", String.valueOf(start));
+ sql = sql.replaceFirst("[?]", String.valueOf(pageSize));
+ sql = sql.replaceFirst("[?]", map.get("fileName"));
+ sql = sql.replaceFirst("[?]", map.get("dataOriginName"));
+ SpringMVCContextHolder.getSystemLogger().info(sql);
+ PreparedStatement ps = con.prepareStatement(sql);
+ return ps.executeQuery();
+ }
+
+ /**
+ * Oracle鏌ヨ鏁版嵁
+ *
+ * @param con 杩炴帴
+ * @param map 琛ㄥ悕闆嗗弬鏁�
+ * @return 鏁版嵁闆�
+ * @throws SQLException
+ */
+ public static ResultSet getOracleResultSet(Connection con, Map<String, String> map) throws SQLException {
+ String sql = map.get("sql");
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ Integer pageSize = Integer.parseInt(map.get("pageSize"));
+ Integer start = (currentPage - 1) * pageSize;
+ Integer end = currentPage * pageSize;
+ sql = sql.replaceFirst("[?]", map.get("fileName"));
+ sql = sql.replaceFirst("[?]", map.get("dataOriginName"));
+ sql = sql.replaceFirst("[?]", String.valueOf(end));
+ sql = sql.replaceFirst("[?]", String.valueOf(start));
+ SpringMVCContextHolder.getSystemLogger().info(sql);
+ PreparedStatement ps = con.prepareStatement(sql);
+ return ps.executeQuery();
+ }
+
+ //浜嬩欢鍓嶆柟娉�
+
+ /**
+ * 鍙嶅皠璋冪敤鏂规硶
+ *
+ * @param invokeTarget 璋冪敤Bean鐨勬柟娉� bean.fun
+ * @param fse 浼犲叆鐨� FieldSetEntity
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ * @throws IllegalAccessException
+ */
+ public static void codeCalls(String invokeTarget, FieldSetEntity fse) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+ //鑾峰彇bean
+ String beanName = StringUtils.substringBeforeLast(invokeTarget, ".");
+ Object bean = SpringUtils.getBean(beanName);
+ //鑾峰彇鏂规硶鍚�
+ String methodName = StringUtils.substringAfterLast(invokeTarget, ".");
+ Method method = bean.getClass().getDeclaredMethod(methodName, FieldSetEntity.class);
+ method.invoke(bean, fse);
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/DataSaveDeleteSynchronization.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/DataSaveDeleteSynchronization.java
new file mode 100644
index 0000000..335d37d
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/DataSaveDeleteSynchronization.java
@@ -0,0 +1,175 @@
+package com.product.data.sync.util;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.product.common.collect.ListUtils;
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.data.sync.config.CmnConst;
+import com.product.util.BaseUtil;
+import com.product.util.CallBack;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.lang.reflect.InvocationTargetException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+
+public class DataSaveDeleteSynchronization extends AbstractBaseService implements Runnable {
+ @Autowired
+ public ExceptionLog exceptionLog;
+
+ public ExceptionLog getExceptionLog() {
+ return exceptionLog;
+ }
+
+ public void setExceptionLog(ExceptionLog exceptionLog) {
+ this.exceptionLog = exceptionLog;
+ }
+
+ @Autowired
+ public BaseDao baseDao;
+
+ @Override
+ public BaseDao getBaseDao() {
+ return baseDao;
+ }
+
+ @Override
+ public void setBaseDao(BaseDao baseDao) {
+ this.baseDao = baseDao;
+ }
+
+ private ResultSet resultSet;
+ private Map<String, String> map;
+ private Map<String, String> syncMap;
+ private Map<String, String> sileMap;
+ private Map<String, String> deleteMap;
+ private CallBack callBack;
+
+ public DataSaveDeleteSynchronization(ResultSet resultSet, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap, Map<String, String> deleteMap) {
+ this.resultSet = resultSet;
+ this.map = map;
+ this.syncMap = syncMap;
+ this.sileMap = sileMap;
+ this.deleteMap = deleteMap;
+ }
+
+ public void setCallBack(CallBack callBack) {
+ this.callBack = callBack;
+ }
+
+ @Override
+ public void run() {
+ //绯荤粺琛ㄥ悕
+ String tableName = map.get("tableName");
+ //鏃ュ織uuid
+ String logUuid = map.get("logUuid");
+ //浜嬩欢鍓嶈皟鐢�
+ String savePreEvent = map.get("savePreEvent");
+ //浜嬩欢鍚庤皟鐢�
+ String postSaveEvent = map.get("postSaveEvent");
+ //杩唬鏁伴噺
+ Integer resultRow = 0;
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //鍒犻櫎鏁伴噺
+ Integer deleteNum = 0;
+ //淇敼鏁伴噺
+ Integer upNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ List<String> list = ListUtils.newArrayList();
+ List<String> addUuid = Lists.newArrayList();
+ List<String> updateUuid = Lists.newArrayList();
+ List<String> deleteUuid = Lists.newArrayList();
+ while (true) {
+ try {
+ if (!resultSet.next()) break;
+ } catch (SQLException e) {
+ exceptionLog.upExceptionLog(logUuid, e);
+ break;
+ }
+ try {
+ FieldSetEntity fieldSet = new FieldSetEntity();
+ fieldSet.setTableName(tableName);
+ resultRow++;
+ //鏄惁鏄垹闄ゆ暟鎹�
+ Boolean is_delete = false;
+ StringBuffer condition = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ fieldSet.setValue(syncMap.get(key), resultSet.getString(key));
+ }
+ for (String key : deleteMap.keySet()) {
+ //鍒犻櫎楠岃瘉鍊�
+ String deleteValue = map.get("deleteValue");
+ //鍊肩浉鍚屽氨鍒犻櫎鎴栬�呬笉鏂板
+ if (deleteValue.equals(resultSet.getString(key))) {
+ is_delete = true;
+ }
+ }
+ list.clear();
+ for (String key : sileMap.keySet()) {
+ String value = resultSet.getString(key);
+ String fieldName = sileMap.get(key);
+ fieldSet.setValue(fieldName, value);
+ condition.append(fieldName).append(" = ? AND ");
+ list.add(value);
+ }
+ //璋冪敤淇濆瓨鍓嶆柟娉�
+ if (!BaseUtil.strIsNull(savePreEvent) && savePreEvent.indexOf(".") != -1) {
+ DataManipulationUtils.codeCalls(savePreEvent, fieldSet);
+ }
+ String term = condition.substring(0, condition.length() - 4);
+ FieldSetEntity fieldSetEntityByFilter = baseDao.getFieldSetEntityByFilter(tableName, term, list.toArray(new String[]{}), false);
+
+ if (is_delete) {
+ if (fieldSetEntityByFilter != null) {
+ baseDao.delete(tableName, new String[]{fieldSetEntityByFilter.getString(CmnConst.UUID)});
+ }
+ deleteUuid.add(fieldSetEntityByFilter.getUUID());
+ deleteNum++;
+ } else {
+ //濡傛灉鏈煡鍒版暟鎹氨鏂板
+ if (fieldSetEntityByFilter == null) {
+ baseDao.add(fieldSet);
+ addNum++;
+ addUuid.add(fieldSet.getUUID());
+ } else {
+ fieldSet.setValue(CmnConst.UUID, fieldSetEntityByFilter.getString(CmnConst.UUID));
+ baseDao.update(fieldSet);
+ updateUuid.add(fieldSet.getUUID());
+ upNum++;
+ }
+ }
+ //璋冪敤淇濆瓨鍚庢柟娉�
+ if (!BaseUtil.strIsNull(postSaveEvent) && postSaveEvent.indexOf(".") != -1) {
+ DataManipulationUtils.codeCalls(postSaveEvent, fieldSet);
+ }
+ } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | BaseException | SQLException e) {
+ errorNum++;
+ exceptionLog.addSubExceptionLog(logUuid, list, e);
+ continue;
+ }
+ }
+ Map<String, Object> map = Maps.newHashMap();
+ //杩唬鏁伴噺
+ map.put("resultRow", (resultRow));
+ //鏂板鏁伴噺
+ map.put("addNum", (addNum));
+ //淇敼鏁伴噺
+ map.put("upNum", (upNum));
+ //鍒犻櫎鏁伴噺
+ map.put("deleteNum", (deleteNum));
+ //閿欒鏁伴噺
+ map.put("errorNum", (errorNum));
+ map.put("changeDataKeys", Lists.newArrayList(addUuid, updateUuid, deleteUuid));
+ //鍥炶皟鍑芥暟
+ if (this.callBack != null) {
+ callBack.method(map);
+ }
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/DataSaveSynchronization.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/DataSaveSynchronization.java
new file mode 100644
index 0000000..97c8f4d
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/DataSaveSynchronization.java
@@ -0,0 +1,169 @@
+package com.product.data.sync.util;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.product.common.collect.ListUtils;
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.data.sync.config.CmnConst;
+import com.product.util.BaseUtil;
+import com.product.util.CallBack;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.lang.reflect.InvocationTargetException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+
+public class DataSaveSynchronization extends AbstractBaseService implements Runnable {
+ @Autowired
+ public ExceptionLog exceptionLog;
+
+ public ExceptionLog getExceptionLog() {
+ return exceptionLog;
+ }
+
+ public void setExceptionLog(ExceptionLog exceptionLog) {
+ this.exceptionLog = exceptionLog;
+ }
+
+ @Autowired
+ public BaseDao baseDao;
+
+ @Override
+ public BaseDao getBaseDao() {
+ return baseDao;
+ }
+
+ @Override
+ public void setBaseDao(BaseDao baseDao) {
+ this.baseDao = baseDao;
+ }
+
+ private ResultSet resultSet;
+ private Map<String, String> map;
+ private Map<String, String> syncMap;
+ private Map<String, String> sileMap;
+ private CallBack callBack;
+
+ public DataSaveSynchronization(ResultSet resultSet, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap) {
+ this.resultSet = resultSet;
+ this.map = map;
+ this.syncMap = syncMap;
+ this.sileMap = sileMap;
+ }
+
+ public void setCallBack(CallBack callBack) {
+ this.callBack = callBack;
+ }
+
+ @Override
+ public void run() {
+ //绯荤粺琛ㄥ悕
+ String tableName = map.get("tableName");
+ //鏃ュ織uuid
+ String logUuid = map.get("logUuid");
+ //浜嬩欢鍓嶈皟鐢�
+ String savePreEvent = map.get("savePreEvent");
+ //浜嬩欢鍚庤皟鐢�
+ String postSaveEvent = map.get("postSaveEvent");
+ //鍚屾绫诲瀷
+ String syncType = map.get(CmnConst.SYNC_TYPE);
+ //鏄惁鏈塽uid
+ Boolean is_uuid = Boolean.valueOf(map.get("is_uuid"));
+ //杩唬鏁伴噺
+ Integer resultRow = 0;
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //淇敼鏁伴噺
+ Integer upNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ List<String> list = ListUtils.newArrayList();
+ List<String> addUuid = Lists.newArrayList();
+ List<String> updateUuid = Lists.newArrayList();
+ while (true) {
+ try {
+ if (!resultSet.next()) break;
+ } catch (SQLException e) {
+ exceptionLog.upExceptionLog(logUuid, e);
+ break;
+ }
+ try {
+ FieldSetEntity fieldSet = new FieldSetEntity();
+ fieldSet.setTableName(tableName);
+ resultRow++;
+ StringBuffer condition = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ fieldSet.setValue(syncMap.get(key), resultSet.getString(key));
+ }
+ list.clear();
+ for (String key : sileMap.keySet()) {
+ String value = resultSet.getString(key);
+ String fieldName = sileMap.get(key);
+ fieldSet.setValue(fieldName, value);
+ condition.append(fieldName).append(" = ? AND ");
+ list.add(value);
+ }
+ //鎷兼帴淇敼璇彞 濡傛灉鏈慨鏀规垚鍔熻褰� 灏辨妸鏁版嵁鏀惧叆鏂板鐨刣ataTableEntity
+ boolean is_update = false;
+
+ //璋冪敤淇濆瓨鍓嶆柟娉�
+ if (!BaseUtil.strIsNull(savePreEvent) && savePreEvent.indexOf(".") != -1) {
+ DataManipulationUtils.codeCalls(savePreEvent, fieldSet);
+ }
+
+ if ("1".equals(syncType)) {
+ String term = condition.substring(0, condition.length() - 4);
+ FieldSetEntity fieldSetEntityByFilter = baseDao.getFieldSetEntityByFilter(tableName, term, list.toArray(new String[]{}), false);
+ //鍚湁uuid
+ if (is_uuid) {
+ is_update = baseDao.update(fieldSet);
+ updateUuid.add(fieldSet.getUUID());
+ //濡傛灉鏌ュ嚭浜嗙郴缁熷師鏁版嵁
+ } else if (fieldSetEntityByFilter != null) {
+ fieldSet.setValue("uuid", fieldSetEntityByFilter.getString("uuid"));
+ is_update = baseDao.update(fieldSet);
+ updateUuid.add(fieldSet.getUUID());
+ // 娌℃湁uuid 骞朵笖娌℃湁婧愭暟鎹氨鏂板
+ } else {
+ is_update = false;
+ }
+ }
+ //淇敼涓嶆垚鍔�
+ if (!is_update) {
+ baseDao.add(fieldSet);
+ addNum++;
+ } else {
+ //淇敼鎴愬姛璁℃暟鍔犱竴
+ upNum++;
+ }
+ //璋冪敤淇濆瓨鍚庢柟娉�
+ if (!BaseUtil.strIsNull(postSaveEvent) && postSaveEvent.indexOf(".") != -1) {
+ DataManipulationUtils.codeCalls(postSaveEvent, fieldSet);
+ }
+ } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | BaseException | SQLException e) {
+ errorNum++;
+ exceptionLog.addSubExceptionLog(logUuid, list, e);
+ continue;
+ }
+ }
+ Map<String, Object> map = Maps.newHashMap();
+ //杩唬鏁伴噺
+ map.put("resultRow", (resultRow));
+ //鏂板鏁伴噺
+ map.put("addNum", (addNum));
+ //淇敼鏁伴噺
+ map.put("upNum", (upNum));
+ //閿欒鏁伴噺
+ map.put("errorNum", (errorNum));
+ map.put("changeDataKeys", Lists.newArrayList(addUuid, updateUuid));
+ //鍥炶皟鍑芥暟
+ if (this.callBack != null) {
+ callBack.method(map);
+ }
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/ExceptionLog.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/ExceptionLog.java
new file mode 100644
index 0000000..7d17ac4
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/ExceptionLog.java
@@ -0,0 +1,142 @@
+package com.product.data.sync.util;
+
+import com.product.common.lang.StringUtils;
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.data.sync.config.CmnConst;
+import com.product.util.BaseUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class ExceptionLog extends AbstractBaseService {
+ @Autowired
+ public BaseDao baseDao;
+
+ @Override
+ public BaseDao getBaseDao() {
+ return baseDao;
+ }
+
+ @Override
+ public void setBaseDao(BaseDao baseDao) {
+ this.baseDao = baseDao;
+ }
+
+ /**
+ * 鏂板淇敼澶辫触淇敼鏃ュ織,娣诲姞閿欒璇︽儏瀛愯〃
+ * @param sync_config_log_uuid 鏃ュ織涓昏〃uuid
+ * @param list 閿欒鏁版嵁鍞竴鏍囪瘑闆嗗悎
+ * @param e 寮傚父
+ */
+ public void addSubExceptionLog(String sync_config_log_uuid, List<String> list, Exception e) {
+ FieldSetEntity subException = new FieldSetEntity();
+ subException.setTableName(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_LOG_SUB);
+ subException.setValue(CmnConst.SYNC_CONFIG_LOG_UUID, sync_config_log_uuid);
+ subException.setValue(CmnConst.ERROR_INFO, e.getMessage());
+ //鐩存帴寮�闆嗗悎骞跺幓鎺夋嫭鍙�
+ subException.setValue(CmnConst.WRONG_DATA_KEY, StringUtils.strip(list.toString(), "[]"));
+ baseDao.add(subException);
+ }
+
+ /**
+ * 鏂板淇敼澶辫触淇敼鏃ュ織,娣诲姞閿欒璇︽儏瀛愯〃
+ * @param sync_config_log_uuid 鏃ュ織涓昏〃uuid
+ * @param e 寮傚父
+ * @param currentPage 鍚敊璇暟鎹殑椤垫暟
+ */
+ public void addSubExceptionLog(String sync_config_log_uuid, Exception e, Integer currentPage) {
+ FieldSetEntity subException = new FieldSetEntity();
+ subException.setTableName(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_LOG_SUB);
+ subException.setValue(CmnConst.SYNC_CONFIG_LOG_UUID, sync_config_log_uuid);
+ subException.setValue(CmnConst.ERROR_INFO, e.getMessage());
+ Integer startIndex = (currentPage - 1) * 1000;
+ Integer endIndex = currentPage * 1000;
+ //鐩存帴寮�闆嗗悎骞跺幓鎺夋嫭鍙�
+ subException.setValue(CmnConst.WRONG_DATA_KEY, "[" + startIndex + "-" + endIndex + "]");
+ //娣诲姞鏃堕棿
+ subException.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
+ baseDao.add(subException);
+ }
+
+ /**
+ * 鍚姩鏁版嵁鍚屾榛樿鍒涘缓鏃ュ織
+ * @param configUuid 鍚屾閰嶇疆uuid
+ * @param data_origin_name 鏁版嵁婧愯〃鍚�
+ * @param system_table_name 绯荤粺琛ㄥ悕
+ * @return 鏃ュ織uuid
+ */
+ public String addExceptionLog(String configUuid, String data_origin_name, String system_table_name) {
+ FieldSetEntity exceptionLog = new FieldSetEntity();
+ exceptionLog.setTableName(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_LOG);
+ exceptionLog.setValue(CmnConst.SYNC_CONFIG_UUID, configUuid);
+ exceptionLog.setValue(CmnConst.DATA_ORIGIN_NAME, data_origin_name);
+ exceptionLog.setValue(CmnConst.SYNC_TIME, new Date());
+ exceptionLog.setValue(CmnConst.SYSTEM_TABLE_NAME, system_table_name);
+ return baseDao.add(exceptionLog);
+ }
+
+ /**
+ * 鏌ヨ鎴愬姛鎴栦腑閫斿け璐ヤ慨鏀瑰悓姝ユ棩蹇�
+ * @param conn 鏁版嵁婧愯繛鎺�
+ * @param uuid 鏃ュ織uuid
+ * @param e 鏌ヨ鏃跺紓甯�
+ * @param addNum 鏂板鏉℃暟
+ * @param upNum 淇敼鏉℃暟
+ * @param errorNum 閿欒鏉℃暟
+ * @param totalNumber 鎬绘潯鏁�
+ */
+ public void upExceptionLog(Connection conn, String uuid, Exception e, Integer addNum, Integer upNum, Integer deleteNumber, Integer errorNum, Integer totalNumber) {
+ StringBuffer exception = new StringBuffer();
+ if (e != null) {
+ exception.append(e.getMessage());
+ }
+ if (conn != null) {
+ try {
+ conn.close();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ exception.append("\n");
+ exception.append(ex.getMessage());
+ }
+ }
+ FieldSetEntity exceptionLog = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_LOG, uuid, false);
+ String errInfo = exceptionLog.getString(CmnConst.ERR_INFO);
+ if(!BaseUtil.strIsNull(errInfo)){
+ exception.append("\n").append(errInfo);
+ }
+ exceptionLog.setValue(CmnConst.ERR_INFO, exception.toString());
+ exceptionLog.setValue(CmnConst.SYNC_TIME, new Date());
+ exceptionLog.setValue(CmnConst.ADD_NUM, addNum);
+ exceptionLog.setValue(CmnConst.UPDATE_NUM, upNum);
+ exceptionLog.setValue(CmnConst.DELETE_NUM, deleteNumber);
+ exceptionLog.setValue(CmnConst.FAIL_NUM, errorNum);
+ exceptionLog.setValue(CmnConst.TOTAL_NUMBER, totalNumber);
+ baseDao.update(exceptionLog);
+ }
+
+ /**
+ * 淇敼鏃ュ織
+ * @param uuid 鏃ュ織uuid
+ * @param e 鏌ヨ鏃跺紓甯�
+ */
+ public void upExceptionLog(String uuid, Exception e) {
+ StringBuffer exception = new StringBuffer();
+ if (e != null) {
+ exception.append(e.getMessage());
+ }
+ FieldSetEntity exceptionLog = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_LOG, uuid, false);
+ String errInfo = exceptionLog.getString(CmnConst.ERR_INFO);
+ if(!BaseUtil.strIsNull(errInfo)){
+ exception.append("\n").append(errInfo);
+ }
+ exceptionLog.setValue(CmnConst.ERR_INFO, exception.toString());
+ baseDao.update(exceptionLog);
+ }
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/ResultInfo.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/ResultInfo.java
new file mode 100644
index 0000000..228fe3e
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/ResultInfo.java
@@ -0,0 +1,31 @@
+package com.product.data.sync.util;
+
+import com.alibaba.fastjson.JSON;
+import com.product.data.sync.config.SystemCode;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ResultInfo {
+
+ /**
+ * 杩斿洖鎴愬姛
+ *
+ * @param data 杩斿洖鏁版嵁
+ * @throws
+ */
+ public static String success(Object data) {
+ Map<String, Object> resultMap = new HashMap<>();
+ resultMap.put("code", SystemCode.SYSTEM_OPERATION_SUCCESS.getValue());
+ resultMap.put("msg", SystemCode.SYSTEM_OPERATION_SUCCESS.getText());
+ resultMap.put("status", "success");
+ resultMap.put("data", data);
+ if (data == null) {
+ resultMap.put("data", new String[]{});
+ }
+ return JSON.toJSONString(resultMap);
+ }
+
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/ScheduledTaskExecution.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/ScheduledTaskExecution.java
new file mode 100644
index 0000000..4105e3c
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/ScheduledTaskExecution.java
@@ -0,0 +1,2114 @@
+package com.product.data.sync.util;
+
+import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.NumberUtil;
+import com.google.common.collect.Lists;
+import com.product.common.collect.ListUtils;
+import com.product.common.collect.MapUtils;
+import com.product.common.lang.DateUtils;
+import com.product.common.lang.StringUtils;
+import com.product.core.config.Global;
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.exception.BaseException;
+import com.product.core.service.support.AbstractBaseService;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.data.sync.config.CmnConst;
+import com.product.data.sync.config.SystemCode;
+import com.product.data.sync.service.ViewDataProcessService;
+import com.product.data.sync.service.ide.IViewDataProcessService;
+import com.product.util.BaseUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.lang.reflect.InvocationTargetException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 瀹氭椂鎵ц 鍚屾鏁版嵁鐨勭被
+ */
+@Service
+public class ScheduledTaskExecution extends AbstractBaseService {
+
+ @Autowired
+ public ExceptionLog exceptionLog;
+ @Autowired
+ public BaseDao baseDao;
+
+ @Override
+ public BaseDao getBaseDao() {
+ return baseDao;
+ }
+
+ @Override
+ public void setBaseDao(BaseDao baseDao) {
+ this.baseDao = baseDao;
+ }
+
+ @Autowired
+ IViewDataProcessService iViewDataProcessService;
+
+ public static void main(String[] args) {
+ String driver = "com.mysql.cj.jdbc.Driver";
+ String ipAddress = "127.0.0.1";
+ String portNumber = "3306";
+ String databaseName = "product_db_v2.0.0";
+ String instantiation = "";
+ String user = "root";
+ String pwd = "root123";
+ String url = "jdbc:mysql://127.0.0.1:3306/product_db_picc?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai";
+ try {
+ Connection connection = DataManipulationUtils.getConnection(driver, url, user, pwd);
+ connection.setAutoCommit(false);
+ PreparedStatement pst = connection.prepareStatement("delete from picc_sync_wf_t_task where taskid=? ");
+ Thread.currentThread().sleep(1000);
+ for (int i = 0; i < 60; i++) {
+ pst.setObject(1, i + "sd");
+ pst.addBatch();
+ }
+ pst.executeBatch();
+ connection.commit();
+ System.out.println(1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 鏁版嵁鍚屾柟娉�
+ *
+ * @param uuid 杩炴帴鐨勬暟鎹簱琛ㄥ悕淇℃伅琛╱uid
+ */
+ public void getDataSync(String uuid) throws SQLException {
+ System.out.println(Thread.currentThread().getId());
+ logger.info("瀹氭椂浠诲姟绾跨▼id锛�" + Thread.currentThread().getId());
+ //鑾峰彇琛ㄦ槑淇℃伅琛�
+ FieldSetEntity syncField = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG, uuid, false);
+ String syncUuid = syncField.getUUID();
+
+ //sync_config_uuid
+ DataTableEntity dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_SYS_DATABASE_SYNC_CONFIG_SUB, "sync_config_uuid = ?", new String[]{syncUuid});
+ Map<String, String> sileMap = MapUtils.newHashMap();
+ Map<String, String> syncMap = MapUtils.newHashMap();
+ Map<String, String> deleteMap = MapUtils.newHashMap();
+ //鏄惁鏈塽uid
+ boolean is_uuid = false;
+ //sqlServer 绗竴涓瓙琛ㄥ瓧娈典负ID瀛楁
+ String idField = dataTableEntity.getFieldSetEntity(0).getString(CmnConst.DATA_ORIGIN_FIELD);
+ for (int i = 0; i < dataTableEntity.getRows(); i++) {
+ FieldSetEntity fse = dataTableEntity.getFieldSetEntity(i);
+ String isSole = fse.getString(CmnConst.IS_SOLE);
+ String systemField = fse.getString(CmnConst.SYSTEM_FIELD); //鏈郴缁熻〃瀛楁
+ String dataOriginField = fse.getString(CmnConst.DATA_ORIGIN_FIELD); //澶栭儴鏁版嵁婧愯〃瀛楁
+ //鏄惁鍒犻櫎
+ if ("1".equals(syncField.getString(CmnConst.IS_DELETE))) {
+ //鏄惁鏄垹闄ゅ瓧娈�
+ if ("1".equals(fse.getString(CmnConst.IS_DELETE))) {
+ deleteMap.put(dataOriginField, systemField);
+ }
+ }
+ if ("uuid".equals(systemField)) {
+ is_uuid = true;
+ }
+ //1 鏄敮涓�瀛楁
+ if ("1".equals(isSole)) {
+ sileMap.put(dataOriginField, systemField);
+ } else {
+ syncMap.put(dataOriginField, systemField);
+ }
+ }
+ this.runDataSync(syncField, sileMap, syncMap, deleteMap, is_uuid, idField);
+ }
+
+
+ /**
+ * @param syncField 鍚屾閰嶇疆琛�
+ * @param sileMap 鍞竴瀛楁
+ * @param syncMap 鍚屾瀛楁
+ * @param is_uuid 鏄惁鏈塽uid
+ */
+ public void runDataSync(FieldSetEntity syncField, Map<String, String> sileMap, Map<String, String> syncMap, Map<String, String> deleteMap, boolean is_uuid, String idField) {
+ //鏁版嵁婧愯〃鍚�
+ String dataOriginName = syncField.getString(CmnConst.DATA_ORIGIN_NAME);
+ //鑾峰彇绯荤粺琛�
+ String tableName = syncField.getString(CmnConst.SYSTEM_TABLE_NAME);
+ //淇濆瓨鍓嶈皟鐢ㄧ殑鏂规硶
+ String savePreEvent = syncField.getString(CmnConst.SAVE_PRE_EVENT);
+ //淇濆瓨鍚庤皟鐢ㄧ殑鏂规硶
+ String postSaveEvent = syncField.getString(CmnConst.POST_SAVE_EVENT);
+ //鏌ヨ鏉′欢
+ String syncCondition = syncField.getString(CmnConst.SYNC_CONDITION);
+ //鏄惁淇敼
+ String isUpdate = syncField.getString(CmnConst.IS_UPDATE);
+ //鏄惁鍒犻櫎
+ String isDelete = syncField.getString(CmnConst.IS_DELETE);
+ //鍒犻櫎鏍囪瘑鍊�
+ String deleteValue = syncField.getString(CmnConst.DELETE_VALUE);
+ //鑾峰彇鏁版嵁搴撹繛鎺ヤ俊鎭�
+ String configUuid = syncField.getString(CmnConst.DATABASE_CONFIG_UUID);
+ //鍚屾绫诲瀷 1澧為噺 2瑕嗙洊
+ String syncType = syncField.getString(CmnConst.SYNC_TYPE);
+ FieldSetEntity configField = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_DATABASE_CONNECTION_CONFIG, configUuid, false);
+ String databaseType = configField.getString(CmnConst.DATABASE_TYPE);//鏁版嵁搴撶被鍨�
+ String ipAddress = configField.getString(CmnConst.IP_ADDRESS);//ip鍦板潃
+ String databaseName = configField.getString(CmnConst.DATABASE_NAME);//鏁版嵁搴撳悕绉�
+ String portNumber = configField.getString(CmnConst.PORT_NUMBER);//绔彛鍙�
+ String userName = configField.getString(CmnConst.USER_NAME);//鐢ㄦ埛鍚�
+ String userPassword = configField.getString(CmnConst.USER_PASSWORD);//瀵嗙爜
+ String instantiation = configField.getString(CmnConst.INSTANTIATION);//瀹炰緥鍚�
+ String fileName = "";
+ //鍒涘缓鏃ュ織
+ String logUuid = exceptionLog.addExceptionLog(syncField.getUUID(), dataOriginName, tableName);
+ //鑾峰彇鏌ヨ鐨勫瓧娈�
+ for (String key : sileMap.keySet()) {
+ fileName = fileName + key + ",";
+ }
+ for (String key : syncMap.keySet()) {
+ fileName = fileName + key + ",";
+ }
+ fileName = fileName.substring(0, fileName.length() - 1);
+ //杩炴帴绫�
+ String diver;
+ //杩炴帴url
+ String url;
+ //缂栬緫sql
+ StringBuffer sql = new StringBuffer();
+ //鍙傛暟
+ Map<String, String> map = Collections.synchronizedMap(new HashMap<>());
+ map.put("syncCondition", syncCondition);
+ if ("mysql".equals(databaseType)) {
+ diver = "com.mysql.cj.jdbc.Driver";
+ url = "jdbc:mysql://" + ipAddress + ":" + portNumber + "/" + databaseName + "?useSSL=false&serverTimezone=UTC";
+
+ if (BaseUtil.strIsNull(syncCondition)) {
+ sql.append("SELECT ? FROM ? LIMIT ?,?");//鍙傛暟澶辫触 鏀逛负瀛楃涓叉嫾鎺�
+ } else {
+ sql.append("SELECT ? FROM ? ").append(" WHERE ").append(syncCondition).append(" LIMIT ?,?");//鍙傛暟澶辫触 鏀逛负瀛楃涓叉嫾鎺�
+ }
+ } else if ("oracle".equals(databaseType)) {
+ diver = "oracle.jdbc.driver.OracleDriver";
+ url = "jdbc:oracle:thin:@" + ipAddress + ":" + portNumber + ":orcl";
+ if (BaseUtil.strIsNull(syncCondition)) {
+ sql.append("SELECT ? FROM (SELECT ROWNUM AS rowno, t.* FROM ? t WHERE ROWNUM <= ?) t2 WHERE t2.rowno > ?");
+ } else {
+ sql.append("SELECT ? FROM (SELECT ROWNUM AS rowno, t.* FROM ? t WHERE ").append(syncCondition).append("AND ROWNUM <= ?) t2 WHERE t2.rowno > ?");
+ }
+ } else if ("informix".equals(databaseType)) {
+ diver = "com.informix.jdbc.IfxDriver";
+ url = "jdbc:informix-sqli://" + ipAddress + ":" + portNumber + "/" + databaseName + ":informixserver=" + instantiation;
+ if (BaseUtil.strIsNull(syncCondition)) {
+ //璺宠繃?琛岋紝鑾峰彇?琛� 瀛楁鍚� 琛ㄥ悕
+ sql.append(" SELECT SKIP ? FIRST ? ? FROM ? ");
+ } else {
+ sql.append(" SELECT SKIP ? FIRST ? ? FROM ? WHERE ").append(syncCondition);
+ }
+ } else if ("sqlserver".equals(databaseType)) {
+ SpringMVCContextHolder.getSystemLogger().error("鍞竴瀛楁鑾峰彇涓嶄弗璋細" + idField);
+ diver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
+ url = "jdbc:sqlserver://" + ipAddress + ":" + portNumber + ";DataBaseName=" + databaseName;
+ if (BaseUtil.strIsNull(syncCondition)) {
+ //? 鏌ヨ鏉℃暟 ? 鏌ヨ瀛楁 ? 琛ㄥ悕 idField 鍞竴瀛楁鍚� ? 寮�濮嬩綅缃� idField 鍞竴瀛楁鍚� ? 琛ㄥ悕
+ sql.append("SELECT TOP ? ? FROM ? WHERE ").append(idField).append(" NOT IN(SELECT TOP ? ").append(idField).append(" FROM ?)");
+ } else {
+ sql.append("SELECT TOP ? ? FROM ? WHERE ").append(idField).append(" NOT IN(SELECT TOP ? ").append(idField).append(" FROM ? WHERE ").append(syncCondition).append(" ) AND ").append(syncCondition);
+ }
+ } else {
+ BaseException baseException = new BaseException(SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getValue(), SystemCode.SYSTEM_UNKNOWN_DATABASE_TYPE.getText());
+ exceptionLog.upExceptionLog(null, logUuid, baseException, 0, 0, 0, 0, 0);
+ return;
+ }
+ //1澧為噺鍚屾 2瑕嗙洊鍚屾
+// if ("2".equals(syncType)) {
+// //鍒犻櫎琛ㄦ墍鏈夋暟鎹�
+// baseDao.executeUpdate("delete from " + tableName);
+// }
+ //1澧為噺鎴�2瑕嗙洊鍚屾
+ map.put(CmnConst.SYNC_TYPE, syncType);
+ map.put("databaseType", databaseType);
+ map.put("url", url);
+ map.put("sql", sql.toString());
+ map.put("fileName", fileName);
+ map.put("tableName", tableName);
+ map.put("dataOriginName", dataOriginName);
+ map.put("deleteValue", deleteValue);
+ Integer currentPage = 1;
+ map.put("currentPage", String.valueOf(currentPage));
+ map.put("pageSize", "1000");
+ map.put("logUuid", logUuid);
+
+ Connection conn = null;
+ //鑾峰彇jdbc杩炴帴
+ try {
+ // 鍒ゆ柇 ip鍦板潃鏄惁涓� / 褰搃p鍦板潃 = / 鏃� 鍒欒涓烘湰鍦板悓姝�
+ String sourceType = Global.getSystemConfig("data.source.type", "");
+ if (sourceType != null && sourceType.equalsIgnoreCase(databaseType) && "/".equals(ipAddress)) {
+ diver = Global.getSystemConfig("data.source.driver", "");
+ url = Global.getSystemConfig("data.source.url", "");
+ userName = Global.getSystemConfig("data.source.user", "");
+ userPassword = Global.getSystemConfig("data.source.password", "");
+ }
+ // 杩滅▼鍦板潃鑾峰彇鏁版嵁搴撹繛鎺�
+ conn = DataManipulationUtils.getConnection(diver, url, userName, userPassword);
+ } catch (BaseException | ClassNotFoundException | SQLException e) {
+ exceptionLog.upExceptionLog(null, logUuid, e, 0, 0, 0, 0, 0);
+ return;
+ }
+ List<Object> changeDataRecord = null;
+ //鏂板鍚屾椂杩樿淇敼鍜屽垹闄�
+ if ("1".equals(isUpdate) && "1".equals(isDelete) && deleteMap.size() > 0) {
+ if (!BaseUtil.strIsNull(savePreEvent) || !BaseUtil.strIsNull(postSaveEvent)) {
+ this.runnableBatchSaveDeleteFieldSetData(conn, map, sileMap, syncMap, deleteMap, savePreEvent, postSaveEvent, is_uuid);
+ } else {
+ try {
+ //TODO
+ changeDataRecord = this.batchSaveDeleteData(conn, map, sileMap, syncMap, deleteMap);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ //鏂板鍚屾椂杩樿淇敼
+ } else if ("1".equals(isUpdate)) {
+ //savePreEvent 淇濆瓨鍓�
+ //postSaveEvent 淇濆瓨鍚�
+ if (!BaseUtil.strIsNull(savePreEvent) || !BaseUtil.strIsNull(postSaveEvent)) {
+// this.batchSaveFieldSetData(conn, map, sileMap, syncMap, savePreEvent, postSaveEvent, is_uuid);
+ //todo
+ changeDataRecord = this.runnableBatchSaveFieldSetData(conn, map, sileMap, syncMap, savePreEvent, postSaveEvent, is_uuid);
+ } else {
+ // 鏄庡ぉ澶勭悊 2022骞�1鏈�13鏃�21:59:11 锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒锛侊紒
+ changeDataRecord = this.batchSaveData(conn, map, sileMap, syncMap);
+ }
+ //鏂板鍚屾椂杩樿鍒犻櫎
+ } else if ("1".equals(isDelete) && deleteMap.size() > 0) {
+ if (!BaseUtil.strIsNull(savePreEvent) || !BaseUtil.strIsNull(postSaveEvent)) {
+ changeDataRecord = this.runnableBatchAddDeleteFieldSetData(conn, map, sileMap, syncMap, deleteMap, savePreEvent, postSaveEvent, is_uuid);
+ } else {
+ changeDataRecord = this.batchAddDeleteData(conn, map, sileMap, syncMap, deleteMap);
+ }
+ //鏂板
+ } else {
+ if (!BaseUtil.strIsNull(savePreEvent) || !BaseUtil.strIsNull(postSaveEvent)) {
+ changeDataRecord = this.runnableBatchAddFieldSetData(conn, map, sileMap, syncMap, savePreEvent, postSaveEvent, is_uuid);
+ } else {
+ if ("2".equals(syncType)) {
+ changeDataRecord = this.batchAddData(conn, map, sileMap, syncMap);
+ } else {
+ changeDataRecord = this.batchAddData(conn, map, sileMap, syncMap, syncType);
+ }
+
+ }
+ }
+ if (changeDataRecord != null && changeDataRecord.size() > 0) {
+ syncDataAfterDispose(changeDataRecord, tableName);
+ }
+ }
+
+ /**
+ * 鍚屾鏁版嵁涔嬪悗澶勭悊
+ *
+ * @throws BaseException
+ */
+ private void syncDataAfterDispose(List<Object> recordList, String tableName) throws BaseException {
+ //recordList 姝ゅ彉閲忔渶澶ч暱搴︿负 3 鍏朵腑 涓嬫爣 0 = 鏂板鐨勬暟鎹� 1 = 淇敼鐨勬暟鎹� 2 = 鍒犻櫎鐨勬暟鎹�
+ try {
+ if (recordList != null) {
+ // 鏂板鎴栦慨鏀圭殑鏁版嵁 uuid
+ List<String> changeDataList = new ArrayList<>();
+ List<Integer> changeDataIds = new ArrayList<>();
+ // 淇敼鏁版嵁鐨勬潯浠� (鏍规嵁姝ゆ潯浠跺幓鏌ヨ淇敼杩囨暟鎹殑uuid)
+ StringBuffer updateDataFilter = new StringBuffer();
+ // 閬嶅巻璁板綍
+ for (int i = 0; i < recordList.size(); i++) {
+ Object object = recordList.get(i);
+ //鍒ゆ柇璁板綍绫诲瀷鏄负 List (浼犲叆鐨勬椂鍊欏簲涓篖ist)
+ if (object instanceof List) {
+ List<Object> objects = (List<Object>) object;
+ // 鍒ゆ柇objects 涓硾鍨嬬殑鏁版嵁绫诲瀷
+ if (objects != null && objects.size() > 0) {
+ Object objectValue = null;
+ // 寰幆鍙栧�� 褰撳彇鍒扮殑鍊间笉涓虹┖鏃惰祴鍊� 鍋滄寰幆
+ for (int j = 0; j < objects.size(); j++) {
+ if (objects.get(j) != null) {
+ objectValue = objects.get(j);
+ break;
+ }
+ }
+ // 娌℃湁鍙栧埌鍊� 璺宠繃
+ if (objectValue == null) {
+ continue;
+ }
+ // 鍒ゆ柇鍙栧�肩殑绫诲瀷
+ if (objectValue instanceof String) {
+ // 鏍规嵁uuid 鏂板銆佷慨鏀广�佸垹闄ょ殑鏁版嵁
+ if (i < 2) {
+ // 鏍规嵁uuid 淇敼鎴栨柊澧炵殑鏁版嵁
+ for (Object o : recordList) {
+ if (o == null) {
+ continue;
+ }
+ changeDataList.addAll((List<String>) o);
+ }
+ } else {
+ // 棰勭暀鍒犻櫎鐨勬暟鎹鐞�
+ }
+ } else if (objectValue instanceof Integer) {
+ //浼犲叆鐨勫氨鏄痠d
+ // 鏍规嵁uuid 鏂板銆佷慨鏀广�佸垹闄ょ殑鏁版嵁
+ if (i < 2) {
+ // 鏍规嵁uuid 淇敼鎴栨柊澧炵殑鏁版嵁
+ for (Object o : recordList) {
+ if (o == null) {
+ continue;
+ }
+ List<Integer> o1 = (List<Integer>) o;
+ changeDataIds.addAll(o1);
+// String[] objects1 = o1.toArray(new String[]{});
+// changeDataList.addAll(Arrays.asList(objects1));
+ }
+ } else {
+ // 棰勭暀鍒犻櫎鐨勬暟鎹鐞�
+ }
+ } else if (objectValue instanceof Map) {
+ // 鏍规嵁鏉′欢鏇存柊鐨勬暟鎹垨鍒犻櫎鐨勬暟鎹�
+ if (i == 1) {
+ for (Object o : recordList) {
+ // 鏍规嵁鏉′欢淇敼鐨勬暟鎹煡璇㈡潯浠�
+ Map<String, Object> filterMap = (Map<String, Object>) o;
+ if (filterMap == null) {
+ continue;
+ }
+ String filter = getFilterByMap(filterMap);
+ if (updateDataFilter.length() > 0) {
+ updateDataFilter.append(" OR ");
+ }
+ updateDataFilter.append(" ( ").append(filter).append(" ) ");
+ }
+
+ } else if (i == 2) {
+ //棰勭暀鍒犻櫎鐨勬暟鎹鐞�
+ }
+ }
+ }
+ }
+ }
+ String pkField = baseDao.getPKField(tableName);
+ if (StringUtils.isEmpty(pkField)) {
+ return;
+ }
+ String updateIds = "";
+ if (updateDataFilter.length() > 0) {
+ DataTableEntity dt = baseDao.listTable(tableName, updateDataFilter.toString(), new Object[]{}, new Object[]{pkField + " as uuid"});
+ if (!DataTableEntity.isEmpty(dt)) {
+ updateIds = dt.getUuidsToString();
+ }
+ }
+ List<Integer> add_ids = null;
+ if (changeDataList.size() > 0) {
+ DataTableEntity dataTableEntity = baseDao.listTable(tableName, new Object[]{pkField + " as uuid"}, changeDataList.toArray());
+ if (!DataTableEntity.isEmpty(dataTableEntity)) {
+ Object[] uuids = dataTableEntity.getUuids();
+ add_ids = new ArrayList<>();
+ for (int i = 0; i < uuids.length; i++) {
+ String pkValue = (String) uuids[i];
+ if (NumberUtil.isNumber(pkValue)) {
+ add_ids.add(NumberUtil.parseInt(pkValue));
+ }
+ }
+ }
+ }
+ if (changeDataIds != null && changeDataIds.size() > 0) {
+ if (add_ids == null) {
+ add_ids = new ArrayList<>();
+ }
+ add_ids.addAll(changeDataIds);
+
+ }
+ IViewDataProcessService iViewDataProcessService = (IViewDataProcessService) getProxyInstance(this.iViewDataProcessService);
+ iViewDataProcessService.updateSyncRecord(tableName, add_ids.toArray(new Integer[]{}), updateIds);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ }
+ }
+
+ private String getFilterByMap(Map<String, Object> filterMap) {
+ StringBuffer filter = new StringBuffer();
+ if (filterMap != null) {
+ filterMap.forEach((k, v) -> {
+ if (filter.length() > 0) {
+ filter.append(" AND ");
+ }
+ if (v == null) {
+ filter.append(" ( `").append(k).append("` is null ) ");
+ } else {
+ filter.append(" ( `").append(k).append("` = '").append(v).append("') ");
+ }
+ });
+ }
+ return filter.insert(0, " ( ").append(" ) ").toString();
+ }
+
+
+ public int getMaxIdValue(String tableName) {
+ String pkField = baseDao.getPKField(tableName);
+ if (!StringUtils.isEmpty(pkField)) {
+ StringBuilder sql = new StringBuilder("SELECT ");
+ sql.append("IFNULL(MAX(").append(pkField).append("),0) maxId FROM ").append(tableName);
+ FieldSetEntity fieldSetBySQL = baseDao.getFieldSetBySQL(sql.toString(), new Object[]{}, false);
+ if (fieldSetBySQL != null) {
+ Integer maxId = fieldSetBySQL.getInteger("maxId");
+ return maxId == null ? -1 : maxId.intValue();
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * 鍘熺敓sql鎵归噺鎻掑叆
+ * 瑕嗙洊鍚屾
+ *
+ * @param conn 鏁版嵁搴撹繛鎺�
+ * @param map 鍚屾閰嶇疆琛ㄧ殑鏁版嵁
+ * @param sileMap 鍞竴鏍囪瘑瀛楁
+ * @param syncMap 鍚屾瀛楁
+ * @Auth cheng 2022骞�1鏈�17鏃�21:29:42
+ */
+ public List<Object> batchAddData(Connection conn, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap) {
+ //绯荤粺琛ㄥ悕
+ String tableName = map.get("tableName");
+ //姣忛〉鏌ヨ鏉℃暟
+ final int pageSize = 100000;
+ //鎵瑰鐞嗘潯鏁�
+ final int batchCount = 5000;
+ map.put("pageSize", pageSize + "");
+ //鏃ュ織缁勮〃uuid
+ String logUuid = map.get("logUuid");
+ SpringMVCContextHolder.getSystemLogger().info("寮�濮嬫壒閲忓悓姝ユ暟鎹紝姣忔鏌ヨ鏉℃暟锛�" + pageSize + ",鎵瑰鐞嗘潯鏁帮細" + batchCount);
+ List<Integer> addDataRecord = new ArrayList<>();
+// int maxIdValue = getMaxIdValue(tableName);
+ Connection currentConn = null;
+ try {
+ //褰撳墠鏁版嵁搴撹繛鎺�
+ currentConn = ConnectionManager.getConnection();
+ System.out.println(new Date().getTime());
+ currentConn.prepareStatement("truncate table " + tableName).execute();
+ System.out.println(new Date().getTime());
+ currentConn.setAutoCommit(false);
+ //姝ゅ彉閲忔彃鍏ラ『搴忎笉鍙洿鏀�
+ List<String> fieldSet = new ArrayList<>();
+ fieldSet.addAll(syncMap.keySet());
+ fieldSet.addAll(sileMap.keySet());
+ map.put("fileName", ArrayUtil.join(fieldSet.toArray(), ","));
+ Map<String, Object> insertDefaultValues = getInsertDefaultValues(tableName, syncMap, sileMap);
+ fieldSet.addAll(insertDefaultValues.keySet());
+ fieldSet.add(CmnConst.UUID);
+ StringBuilder sqlTemplate = new StringBuilder();
+ sqlTemplate.append(" INSERT INTO `").append(tableName).append("` (");
+ int i = 0;
+ Iterator<String> iterator = fieldSet.iterator();
+ // 瀛楁
+ StringBuilder fieldTemplate = new StringBuilder();
+ //鍗犱綅绗�
+ StringBuilder placeholderTemplate = new StringBuilder();
+ while (iterator.hasNext()) {
+ String fieldName = iterator.next();
+ if (i > 0) {
+ fieldTemplate.append(",");
+ placeholderTemplate.append(",");
+ } else {
+ i++;
+ }
+ placeholderTemplate.append("?");
+ fieldTemplate.append("`").append(fieldName).append("`");
+ }
+ sqlTemplate.append(fieldTemplate).append(") values (").append(placeholderTemplate).append(")");
+// fieldTemplate.setLength(0);
+ placeholderTemplate.setLength(0);
+ System.out.println(sqlTemplate);
+ //鏁版嵁鏉℃暟 褰撹揪鍒版壒澶勭悊鎻愪氦鐨勬暟閲忔椂浼氬綊闆�
+ int dataNumber = 0;
+ //褰撳墠椤�
+ int currentPage = 1;
+ //鎬绘潯鏁�
+ int totalCount = 0;
+ int errorCount = 0;
+ PreparedStatement pst = currentConn.prepareStatement(sqlTemplate.toString());
+ long currentPageStart = System.currentTimeMillis();
+ do {
+ dataNumber = 0;
+// ResultSet resultSet = conn.prepareStatement("SELECT " + fieldTemplate.toString() + " FROM " + sourceTable).executeQuery();
+ long l = System.currentTimeMillis();
+ ResultSet resultSet = DataManipulationUtils.getResultSet(conn, map);
+ SpringMVCContextHolder.getSystemLogger().info("缁撴潫鏌ヨ鏁版嵁锛屽綋鍓嶉〉锛�" + currentPage + ",鑰楁椂锛�" + (System.currentTimeMillis() - l) + "ms");
+// List<String> uuidList = new ArrayList<>();
+ if (resultSet != null) {
+ int columnCount = -1;
+ while (resultSet.next()) {
+ if (columnCount == -1) {
+ columnCount = resultSet.getMetaData().getColumnCount();
+ }
+ int j = 1;
+ for (; j <= columnCount; j++) {
+ Object value = resultSet.getObject(j);
+ pst.setObject(j, value);
+ }
+ for (Map.Entry<String, Object> v : insertDefaultValues.entrySet()) {
+ pst.setObject(j, v.getValue());
+ j++;
+ }
+ pst.setObject(j, IdUtil.randomUUID());
+ pst.addBatch();
+ //鏁版嵁鏉℃暟+1
+ dataNumber++;
+ if (dataNumber % batchCount == 0) {
+ try {
+ //鎵ц鎵瑰鐞�
+ pst.executeBatch();
+ //鎻愪氦鏁版嵁
+ currentConn.commit();
+ totalCount += batchCount;
+ SpringMVCContextHolder.getSystemLogger().info("鎵ц鎵瑰鐞嗗苟鎻愪氦锛岃�楁椂锛�" + (System.currentTimeMillis() - currentPageStart) + "ms");
+ currentPageStart = System.currentTimeMillis();
+// addDataRecord.addAll(uuidList);
+ } catch (SQLException e) {
+ // 璁板綍鎻愪氦鎵规鐨勬暟閲�
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error("鎵ц鎵瑰鐞嗗苟鎻愪氦锛岄敊璇�," + e.getMessage());
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ errorCount += batchCount;
+ exceptionLog.addSubExceptionLog(logUuid, e, currentPage);
+ }
+ } else {
+ //璁板綍鏂板鎵规鐨剈uid
+// addDataRecord.addAll(uuidList);
+ }
+
+ }
+ SpringMVCContextHolder.getSystemLogger().info("鎵ц" + currentPage + "椤碉紝鑰楁椂锛�" + (System.currentTimeMillis() - l) + "ms");
+ currentPageStart = System.currentTimeMillis();
+ currentPage++;
+ map.put("currentPage", currentPage + "");
+ try {
+ resultSet.close();
+ } catch (SQLException e) {
+ }
+ }
+ } while (dataNumber == pageSize);
+ totalCount += (dataNumber % batchCount);
+ try {
+ pst.executeBatch();
+ currentConn.commit();
+ exceptionLog.upExceptionLog(conn, logUuid, null, totalCount - errorCount, 0, 0, errorCount, totalCount);
+ } catch (SQLException e) {
+ e.printStackTrace();
+// addDataRecord = addDataRecord.subList(0, addDataRecord.size() - 2 - dataNumber);
+ SpringMVCContextHolder.getSystemLogger().error("鎵ц鎵瑰鐞嗗苟鎻愪氦锛岄敊璇�," + e.getMessage());
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ errorCount += dataNumber % batchCount;
+ exceptionLog.addSubExceptionLog(logUuid, e, currentPage - 1);
+ }
+ for (int j = 1; j <= totalCount; j++) {
+ addDataRecord.add(j);
+ }
+ exceptionLog.upExceptionLog(conn, logUuid, null, totalCount - errorCount, 0, 0, errorCount, totalCount);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error("鎵ц鏁版嵁鍚屾瑕嗙洊閿欒," + e.getMessage());
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ exceptionLog.upExceptionLog(conn, logUuid, null, 0, 0, 0, 0, 0);
+ } finally {
+ try {
+ if (currentConn == null) {
+ conn.close();
+ }
+ } catch (Exception e) {
+
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().info("鎵瑰鐞嗗悓姝ユ暟鎹墽琛屽畬鎴愶紒锛�");
+ return Lists.newArrayList(addDataRecord, null, null);
+ }
+
+ private Map<String, Object> getInsertDefaultValues(String tableName, Map<String, String> syncMap, Map<String, String> sileMap) {
+ // 榛樿鍊糾ap 鐢ㄤ簬鎻掑叆鏁版嵁鏃堕粯璁ゆ彃鍏ュ瓧娈� key=瀛楁 value=榛樿鍊�
+ Map<String, Object> defaultValueMap = new HashMap<>();
+ defaultValueMap.put(CmnConst.CREATED_BY, 1);
+ defaultValueMap.put(CmnConst.CREATED_UTC_DATETIME, DateUtils.getDateTime());
+ defaultValueMap.put("org_level_uuid", "00000000-0000-0000-0000-000000000000");
+ //鑾峰彇缂撳瓨涓� 琛ㄤ俊鎭鎯�
+ FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅", new String[]{tableName});
+ Iterator<String> iterator = defaultValueMap.keySet().iterator();
+ // 寰幆鍒ゆ柇鏄惁闇�瑕佸鍔犻粯璁ゅ�煎瓧娈�
+ while (iterator.hasNext()) {
+ String field = iterator.next();
+ // 鍒ゆ柇榛樿鍊糼ey 鏄惁鍦ㄥ悓姝ュ瓧娈典腑
+ if (syncMap.containsKey(field) || sileMap.containsKey(field)) {
+ // 瀛樺湪鍒欏垹闄ら粯璁ゅ��
+ iterator.remove();
+ continue;
+ } else {
+ // 妫�鏌ラ粯璁ゅ瓧娈靛湪绯荤粺琛ㄤ腑鏄惁瀛樺湪
+ FieldSetEntity fieldInfo = BaseUtil.getSingleInfoByCache("琛ㄥ瓧娈典俊鎭�", new String[]{tableInfo.getUUID(), field});
+ if (fieldInfo == null || !fieldInfo.getBoolean("is_required")) {
+ //涓嶅瓨鍦�
+ iterator.remove();
+ }
+ }
+ }
+ return defaultValueMap;
+ }
+
+ /**
+ * 鍘熺敓sql鎵归噺鎻掑叆
+ * 鍙柊澧炴暟鎹�,鎻掑叆鎵归噺 INSERT INTO璇彞
+ *
+ * @param conn 鏁版嵁搴撹繛鎺�
+ * @param map 鍚屾閰嶇疆琛ㄧ殑鏁版嵁
+ * @param sileMap 鍞竴鏍囪瘑瀛楁
+ * @param syncMap 鍚屾瀛楁
+ * @param syncType 1澧為噺鎴�2瑕嗙洊鍚屾
+ */
+ public List<Object> batchAddData(Connection conn, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap, String syncType) {
+ Integer resultRow = 0;
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ //鎬绘潯鏁�
+ Integer totalNumber = 0;
+ //绯荤粺琛ㄥ悕
+ String tableName = map.get("tableName");
+ //褰撳墠椤�
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ //鏃ュ織缁勮〃uuid
+ String logUuid = map.get("logUuid");
+ //鑾峰彇榛樿鍊�
+ Map<String, Object> defaultValueMap = getInsertDefaultValues(tableName, syncMap, sileMap);
+ List<String> addDataRecord = new ArrayList<>();
+ PreparedStatement mySqlPs = null;
+ //淇敼褰卞搷琛屾暟
+ int result = 0;
+ try {
+ //mysql 杩炴帴
+ Connection mysqlCon = null;
+ do {
+ //鍒ゆ柇杩炴帴鏄惁涓虹┖鎴栨槸鍚﹁鍏抽棴 cheng 2022骞�1鏈�13鏃�16:11:49
+ if (mysqlCon == null || mysqlCon.isClosed()) {
+ mysqlCon = ConnectionManager.getConnection();
+ }
+ ResultSet resultSet = DataManipulationUtils.getResultSet(conn, map);
+ //鏂板鐨凞ataTableEntity
+ resultRow = 0;
+ StringBuffer insertSql = new StringBuffer();
+ Integer insert = 0;
+ //鏂板璁℃暟
+ Integer addNumber = 0;
+ long l = System.currentTimeMillis();
+ while (resultSet.next()) {
+ resultRow++;
+ //瑕嗙洊鍚屾鍙鏂板
+ if ("2".equals(syncType)) {
+ //閫氳繃鍞竴瀛楁鏌ヨ鏁版嵁
+ //鏈煡璇㈠埌鐩稿悓鏁版嵁灏辨柊澧炴暟鎹�,鏌ヨ鍒板氨璺宠繃鏁版嵁
+ StringBuffer selectSql = new StringBuffer();
+ selectSql.append(" select count(*) from `").append(tableName).append("` where ");
+ for (String key : sileMap.keySet()) {
+ String keys = resultSet.getString(key);
+ if (keys == null) {
+ selectSql.append("`").append(key).append("` = ").append(keys).append(" AND ");
+ } else {
+ selectSql.append("`").append(key).append("` = \"").append(keys).append("\" AND ");
+ }
+ }
+ String sql = selectSql.substring(0, selectSql.length() - 4);
+ PreparedStatement ps = mysqlCon.prepareStatement(sql);
+ ResultSet resultNumber = ps.executeQuery();
+ // 濡傛灉鏌ュ埌灏卞ぇ浜�0
+ while (resultNumber.next()) {
+ result = resultNumber.getInt(1);
+ }
+ }
+ // 澶т簬0 灏变笉鏂板
+ if (result == 0) {
+ addNumber++;
+ StringBuffer valueSql = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ String value = resultSet.getString(key);
+ if (value == null) {
+ valueSql.append(value).append(",");
+ } else {
+ valueSql.append("\"").append(value).append("\",");
+ }
+ }
+ for (String key : sileMap.keySet()) {
+ String value = resultSet.getString(key);
+ if (value == null) {
+ valueSql.append(value).append(",");
+ } else {
+ valueSql.append("\"").append(value).append("\",");
+ }
+ }
+ // 鏂板鎻掑叆榛樿鍊� cheng 2022骞�1鏈�13鏃�16:08:34
+ for (Map.Entry<String, Object> value : defaultValueMap.entrySet()) {
+ valueSql.append("\"").append(value.getValue()).append("\",");
+ }
+ String uuid = UUID.randomUUID().toString();
+ valueSql.append("\"").append(uuid).append("\",");
+ addDataRecord.add(uuid);
+ valueSql.deleteCharAt(valueSql.length() - 1);
+ if (insertSql.length() > 0) {
+ insertSql.append(",(").append(valueSql).append(")");
+ } else {
+ StringBuffer keySql = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ keySql.append("`").append(syncMap.get(key)).append("`,");
+ }
+ for (String key : sileMap.keySet()) {
+ keySql.append("`").append(sileMap.get(key)).append("`,");
+ }
+ // 鏂板鎻掑叆榛樿key cheng 2022骞�1鏈�13鏃�16:08:34
+ for (Map.Entry<String, Object> value : defaultValueMap.entrySet()) {
+ keySql.append("`").append(value.getKey()).append("`,");
+ }
+ keySql.append("`uuid`");
+ insertSql.append(" INSERT INTO `").append(tableName).append("`(").append(keySql)
+ .append(") VALUES (").append(valueSql).append(")");
+ }
+ } else {
+ //鏌ュ埌鏁版嵁,鏃犳硶鏂板
+ errorNum++;
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().info("缁撴潫鎷兼帴Inert into 璇彞锛屽叡鑰楁椂:" + (System.currentTimeMillis() - l) + "ms");
+ if (!BaseUtil.strIsNull(insertSql.toString())) {
+ try {
+ insertSql.append(";");
+ l = System.currentTimeMillis();
+ mySqlPs = mysqlCon.prepareStatement(insertSql.toString());
+ insert = mySqlPs.executeUpdate();
+ SpringMVCContextHolder.getSystemLogger().info("缁撴潫杩愯鎻掑叆锛屽叡鑰楁椂:" + (System.currentTimeMillis() - l) + "ms");
+ addNum = addNum + insert;
+ } catch (SQLException | BaseException e) {
+ e.printStackTrace();
+ addDataRecord.clear();
+ errorNum = errorNum + addNumber;
+ exceptionLog.addSubExceptionLog(logUuid, e, currentPage);
+ }
+ }
+ //鍏抽棴缁撴灉灏�
+ //DataManipulationUtils.close(resultSet, null, null);
+ totalNumber = totalNumber + resultRow;
+ currentPage++;
+ map.put("currentPage", String.valueOf(currentPage));
+ //濡傛灉鏉℃暟灏忎簬1000灏辩粨鏉熸煡璇�
+ //鍏抽棴mysql 娉ㄩ噴 cheng 2022骞�1鏈�13鏃�15:34:52
+ DataManipulationUtils.close(resultSet, mySqlPs, null);
+ } while (resultRow == 1000);
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, null, addNum, 0, 0, errorNum, totalNumber);
+ //鍏抽棴鏁版嵁婧愯繛鎺�
+ DataManipulationUtils.close(null, null, mysqlCon);
+ DataManipulationUtils.close(null, null, conn);
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, e, addNum, 0, 0, errorNum, totalNumber);
+ }
+ return Lists.newArrayList(addDataRecord);
+ }
+
+
+ /**
+ * 鍘熺敓sql鎵归噺鎻掑叆
+ * 鍙柊澧炴暟鎹�,鎻掑叆鎵归噺 INSERT INTO璇彞
+ * 鏍规嵁鍒犻櫎瀛楁鍒犻櫎鏁版嵁
+ *
+ * @param conn 鏁版嵁搴撹繛鎺�
+ * @param map 鍚屾閰嶇疆琛ㄧ殑鏁版嵁
+ * @param sileMap 鍞竴鏍囪瘑瀛楁
+ * @param syncMap 鍚屾瀛楁
+ */
+ public List<Object> batchAddDeleteData(Connection conn, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap, Map<String, String> deleteMap) {
+ Integer resultRow = 0;
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ //鎬绘潯鏁�
+ Integer totalNumber = 0;
+ //鍒犻櫎鏉℃暟
+ Integer deleteNumber = 0;
+ //绯荤粺琛ㄥ悕
+ String tableName = map.get("tableName");
+ //褰撳墠椤�
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ //鏃ュ織缁勮〃uuid
+ String logUuid = map.get("logUuid");
+ List<String> addDataRecord = new ArrayList<>();
+ List<Map<String, Object>> deleteDataRecord = new ArrayList<>();
+ PreparedStatement mySqlPs = null;
+
+ //淇敼褰卞搷琛屾暟
+ int result = 0;
+ try {
+ do {
+ //mysql 杩炴帴
+ Connection mysqlCon = ConnectionManager.getConnection();
+ ResultSet resultSet = DataManipulationUtils.getResultSet(conn, map);
+ //鏂板鐨凞ataTableEntity
+ resultRow = 0;
+ StringBuffer insertSql = new StringBuffer();
+ Integer insert = 0;
+ //鏂板璁℃暟
+ while (resultSet.next()) {
+ //鏄惁鏄垹闄ゆ暟鎹�
+ Boolean is_delete = false;
+ resultRow++;
+ //鏈�浼樺厛鍒ゆ柇鍒犻櫎鏍囪瘑
+ for (String key : deleteMap.keySet()) {
+ //鍒犻櫎楠岃瘉鍊�
+ String deleteValue = map.get("deleteValue");
+ //鍊肩浉鍚屽氨鍒犻櫎鎴栬�呬笉鏂板
+ if (deleteValue.equals(resultSet.getString(key))) {
+ is_delete = true;
+ }
+ }
+ //閫氳繃鍞竴瀛楁鏌ヨ鏁版嵁
+ //鏈煡璇㈠埌鐩稿悓鏁版嵁灏辨柊澧炴暟鎹�,鏌ヨ鍒板氨璺宠繃鏁版嵁
+ StringBuffer selectSql = new StringBuffer();
+ selectSql.append(" select count(*) from `").append(tableName).append("` where ");
+ for (String key : sileMap.keySet()) {
+ String keys = resultSet.getString(key);
+ if (keys == null) {
+ selectSql.append("`").append(key).append("` = ").append(keys).append(" AND ");
+ } else {
+ selectSql.append("`").append(key).append("` = \"").append(keys).append("\" AND ");
+ }
+ }
+ String sql = selectSql.substring(0, selectSql.length() - 4);
+ PreparedStatement ps = mysqlCon.prepareStatement(sql);
+ ResultSet resultNumber = ps.executeQuery();
+ // 濡傛灉鏌ュ埌灏卞ぇ浜�0
+ while (resultNumber.next()) {
+ result = resultNumber.getInt(1);
+ }
+ // 澶т簬0 鎴栬�呮槸闇�瑕佸垹闄ょ殑鏁版嵁
+ if (result == 0) {
+ //濡傛灉鏄鍒犻櫎鐨勬暟鎹� 灏变笉鏂板
+ if (is_delete) {
+ deleteNumber++;
+ continue;
+ }
+ StringBuffer valueSql = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ String value = resultSet.getString(key);
+ if (value == null) {
+ valueSql.append(value).append(",");
+ } else {
+ valueSql.append("\"").append(value).append("\",");
+ }
+ }
+ for (String key : sileMap.keySet()) {
+ String value = resultSet.getString(key);
+ if (value == null) {
+ valueSql.append(value).append(",");
+ } else {
+ valueSql.append("\"").append(value).append("\",");
+ }
+ }
+ String uuid = UUID.randomUUID().toString();
+ valueSql.append("\"").append(uuid).append("\",");
+ addDataRecord.add(uuid);
+ valueSql.deleteCharAt(valueSql.length() - 1);
+ if (insertSql.length() > 0) {
+ insertSql.append(",(").append(valueSql).append(")");
+ } else {
+ StringBuffer keySql = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ keySql.append("`").append(syncMap.get(key)).append("`,");
+ }
+ for (String key : sileMap.keySet()) {
+ keySql.append("`").append(sileMap.get(key)).append("`,");
+ }
+ keySql.append("`uuid`");
+ insertSql.append(" INSERT INTO `").append(tableName).append("`(").append(keySql)
+ .append(") VALUES (").append(valueSql).append(")");
+ }
+ //鏌ュ嚭杩欐潯鏁版嵁,浣嗚鎵ц鍒犻櫎
+ } else {
+ //鎵ц鍒犻櫎鏂规硶
+ if (is_delete) {
+ StringBuffer deleteSql = new StringBuffer();
+ deleteSql.append(" delete from `").append(tableName).append("` where ");
+ Map<String, Object> filterMap = new HashMap<>();
+ for (String key : sileMap.keySet()) {
+ String keys = resultSet.getString(key);
+ filterMap.put(key, resultSet.getString(key));
+ if (keys == null) {
+ deleteSql.append("`").append(key).append("` = ").append(keys).append(" AND ");
+ } else {
+ deleteSql.append("`").append(key).append("` = \"").append(keys).append("\" AND ");
+ }
+ }
+ String delSql = deleteSql.substring(0, deleteSql.length() - 4);
+ PreparedStatement delps = mysqlCon.prepareStatement(delSql);
+ deleteNumber = deleteNumber + delps.executeUpdate();
+ deleteDataRecord.add(filterMap);
+ } else {
+ addNum++;
+ }
+ }
+ }
+ if (!BaseUtil.strIsNull(insertSql.toString())) {
+ try {
+ insertSql.append(";");
+ mySqlPs = mysqlCon.prepareStatement(insertSql.toString());
+ insert = mySqlPs.executeUpdate();
+ addNum = addNum + insert;
+ } catch (SQLException | BaseException e) {
+ errorNum = errorNum + insert;
+ exceptionLog.addSubExceptionLog(logUuid, e, currentPage);
+ addDataRecord.clear();
+ }
+ }
+ //鍏抽棴缁撴灉灏�
+ //DataManipulationUtils.close(resultSet, null, null);
+ totalNumber = totalNumber + resultRow;
+ currentPage++;
+ map.put("currentPage", String.valueOf(currentPage));
+ //濡傛灉鏉℃暟灏忎簬1000灏辩粨鏉熸煡璇�
+ //鍏抽棴mysql
+ DataManipulationUtils.close(null, mySqlPs, mysqlCon);
+ } while (resultRow == 1000);
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("鍒犻櫎鏁版嵁" + deleteNumber);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, null, addNum, 0, deleteNumber, errorNum, totalNumber);
+ //鍏抽棴鏁版嵁婧愯繛鎺�
+ DataManipulationUtils.close(null, null, conn);
+ } catch (SQLException e) {
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("鍒犻櫎鏁版嵁" + deleteNumber);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, e, addNum, 0, deleteNumber, errorNum, totalNumber);
+ }
+ return Lists.newArrayList(addDataRecord, null, deleteDataRecord);
+ }
+
+ /**
+ * 鍘熺敓sql鎵归噺鎻掑叆
+ * 淇敼涓哄崟鏉′慨鏀�,淇敼涓嶆垚鍔熺殑璇彞鎻掑叆鎵归噺 INSERT INTO璇彞
+ * 鏂板淇敼鏁版嵁,淇敼澶辫触灏辨柊澧�
+ *
+ * @param conn 鏁版嵁搴撹繛鎺�
+ * @param map 鍚屾閰嶇疆琛ㄧ殑鏁版嵁
+ * @param sileMap 鍞竴鏍囪瘑瀛楁
+ * @param syncMap 鍚屾瀛楁
+ */
+ public List<Object> batchSaveData(Connection conn, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap) {
+ Integer resultRow = 0;
+ List<String> list = ListUtils.newArrayList();
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //淇敼鏁伴噺
+ Integer upNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ //鎬绘潯鏁�
+ Integer totalNumber = 0;
+ //绯荤粺琛ㄥ悕
+ String tableName = map.get("tableName");
+ //褰撳墠椤�
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ //鏃ュ織缁勮〃uuid
+ String logUuid = map.get("logUuid");
+ //1澧為噺鎴�2瑕嗙洊鍚屾
+ String syncType = map.get(CmnConst.SYNC_TYPE);
+ List<String> addDataRecord = new ArrayList<>();
+ List<Map<String, Object>> updateDataRecord = new ArrayList<>();
+ PreparedStatement mySqlPs = null;
+
+ //淇敼褰卞搷琛屾暟
+ int result = 0;
+ try {
+ do {
+ //mysql 杩炴帴
+ Connection mysqlCon = ConnectionManager.getConnection();
+ ResultSet resultSet = DataManipulationUtils.getResultSet(conn, map);
+ //鑾峰彇鎬诲垪鏁�
+// ResultSetMetaData rsmd = resultSet.getMetaData();
+// resultRow = rsmd.getColumnCount();
+ //鏂板鐨凞ataTableEntity
+ resultRow = 0;
+ StringBuffer insertSql = new StringBuffer();
+ Integer insert = 0;
+ //鏂板璁℃暟
+ Integer addNumber = 0;
+ while (resultSet.next()) {
+ resultRow++;
+ if ("1".equals(syncType)) {
+ StringBuffer updateSql = new StringBuffer();
+ updateSql.append(" update `").append(tableName).append("` set ");
+ for (String key : syncMap.keySet()) {
+ String keys = resultSet.getString(key);
+ if (keys == null) {
+ updateSql.append("`").append(syncMap.get(key)).append("` = ").append(keys).append(",");
+ } else {
+ updateSql.append("`").append(syncMap.get(key)).append("` = \"").append(keys).append("\",");
+ }
+ }
+ updateSql = updateSql.deleteCharAt(updateSql.length() - 1);
+ updateSql.append(" where ");
+ list.clear();
+ Map<String, Object> filterMap = new HashMap<>();
+ for (String key : sileMap.keySet()) {
+ String value = resultSet.getString(key);
+ filterMap.put(key, value);
+ list.add(value);
+ if (value == null) {
+ updateSql.append("`").append(sileMap.get(key)).append("` = ").append(value).append(" AND ");
+ } else {
+ updateSql.append("`").append(sileMap.get(key)).append("` = \"").append(value).append("\" AND ");
+ }
+ }
+ updateSql = updateSql.delete(updateSql.length() - 5, updateSql.length());
+ updateSql.append(";");
+
+ try {
+ mySqlPs = mysqlCon.prepareStatement(updateSql.toString());
+ result = mySqlPs.executeUpdate();// 杩斿洖鍊间唬琛ㄦ敹鍒板奖鍝嶇殑琛屾暟
+ if (result > 0) {
+ updateDataRecord.add(filterMap);
+ }
+ } catch (SQLException | BaseException e) {
+ errorNum++;
+ exceptionLog.addSubExceptionLog(logUuid, list, e);
+ continue;
+ }
+ }
+ //淇敼涓嶆垚鍔� 鎷艰鎵归噺INSERT 璇彞
+ if (result == 0) {
+ addNumber++;
+ StringBuffer valueSql = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ String value = resultSet.getString(key);
+ if (value == null) {
+ valueSql.append(value).append(",");
+ } else {
+ valueSql.append("\"").append(value).append("\",");
+ }
+ }
+ list.clear();
+ for (String key : sileMap.keySet()) {
+ String value = resultSet.getString(key);
+ if (value == null) {
+ valueSql.append(value).append(",");
+ } else {
+ valueSql.append("\"").append(value).append("\",");
+ }
+ list.add(value);
+ }
+ String uuid = UUID.randomUUID().toString();
+ valueSql.append("\"").append(uuid).append("\",");
+ addDataRecord.add(uuid);
+ valueSql.deleteCharAt(valueSql.length() - 1);
+ if (insertSql.length() > 0) {
+ insertSql.append(",(").append(valueSql).append(")");
+ } else {
+ StringBuffer keySql = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ keySql.append("`").append(syncMap.get(key)).append("`,");
+ }
+ for (String key : sileMap.keySet()) {
+ keySql.append("`").append(sileMap.get(key)).append("`,");
+ }
+ keySql.append("`uuid`");
+ insertSql.append(" INSERT INTO `").append(tableName).append("`(").append(keySql)
+ .append(") VALUES (").append(valueSql).append(")");
+ }
+ } else {
+ //淇敼鎴愬姛璁℃暟鍔犱竴
+ upNum++;
+ }
+ }
+ if (!BaseUtil.strIsNull(insertSql.toString())) {
+ try {
+ insertSql.append(";");
+ mySqlPs = mysqlCon.prepareStatement(insertSql.toString());
+ insert = mySqlPs.executeUpdate();
+ addNum = addNum + insert;
+ } catch (SQLException | BaseException e) {
+ errorNum = errorNum + addNumber;
+ addDataRecord.clear();
+ exceptionLog.addSubExceptionLog(logUuid, e, currentPage);
+ }
+ }
+ //鍏抽棴缁撴灉灏�
+ //DataManipulationUtils.close(resultSet, null, null);
+ totalNumber = totalNumber + resultRow;
+ currentPage++;
+ map.put("currentPage", String.valueOf(currentPage));
+ //濡傛灉鏉℃暟灏忎簬1000灏辩粨鏉熸煡璇�
+ //鍏抽棴mysql
+ DataManipulationUtils.close(null, mySqlPs, mysqlCon);
+ } while (resultRow == 1000);
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("淇敼鏁版嵁" + upNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, null, addNum, upNum, 0, errorNum, totalNumber);
+ //鍏抽棴鏁版嵁婧愯繛鎺�
+ DataManipulationUtils.close(null, null, conn);
+
+ } catch (SQLException e) {
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("淇敼鏁版嵁" + upNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, e, addNum, upNum, 0, errorNum, totalNumber);
+ }
+ return Lists.newArrayList(addDataRecord, updateDataRecord);
+ }
+
+ /**
+ * 鍘熺敓sql鎵归噺鎻掑叆
+ * 淇敼涓哄崟鏉′慨鏀�,淇敼涓嶆垚鍔熺殑璇彞鎻掑叆鎵归噺 INSERT INTO璇彞
+ * 鍏堝垽鏂槸鍚﹁鍒犻櫎, 瑕佸垹闄ゅ厛鍒犻櫎,鐒跺悗鏂板淇敼鏁版嵁,淇敼澶辫触灏辨柊澧�
+ *
+ * @param conn 鏁版嵁搴撹繛鎺�
+ * @param map 鍚屾閰嶇疆琛ㄧ殑鏁版嵁
+ * @param sileMap 鍞竴鏍囪瘑瀛楁
+ * @param syncMap 鍚屾瀛楁
+ * @param deleteMap 鍒犻櫎瀛楁
+ */
+ public List<Object> batchSaveDeleteData(Connection conn, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap, Map<String, String> deleteMap) throws Exception {
+ Integer resultRow = 0;
+ List<String> list = ListUtils.newArrayList();
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ //鎬绘潯鏁�
+ Integer totalNumber = 0;
+ //淇敼鏁伴噺
+ Integer upNum = 0;
+ //鍒犻櫎鏉℃暟
+ Integer deleteNumber = 0;
+ //绯荤粺琛ㄥ悕
+ String tableName = map.get("tableName");
+ //褰撳墠椤�
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ //鏃ュ織缁勮〃uuid
+ String logUuid = map.get("logUuid");
+ // 褰撳墠鎿嶄綔琛ㄤ富閿嚜澧烇紙id)瀛楁
+ if (true) {
+ //鎷縤d瀛楁 鍐嶅垹闄ゆ浠g爜
+ //todo
+ throw new Exception("鎷縤d瀛楁 鍐嶅垹闄ゆ浠g爜");
+ }
+ String pkField = "";
+ List<Map<String, String>> deleteDataRecord = new ArrayList<>();
+ List<Map<String, String>> updateDataRecord = new ArrayList<>();
+ List<String> addDataRecord = new ArrayList<>();
+ PreparedStatement mySqlPs = null;
+
+ //淇敼褰卞搷琛屾暟
+ int result = 0;
+ try {
+ do {
+ //mysql 杩炴帴
+ Connection mysqlCon = ConnectionManager.getConnection();
+ ResultSet resultSet = DataManipulationUtils.getResultSet(conn, map);
+ //鏂板鐨凞ataTableEntity
+ resultRow = 0;
+ StringBuffer insertSql = new StringBuffer();
+ Integer insert = 0;
+ //鏂板璁℃暟
+ Integer addNumber = 0;
+ while (resultSet.next()) {
+ //鏄惁鏄垹闄ゆ暟鎹�
+ Boolean is_delete = false;
+ resultRow++;
+ //鏈�浼樺厛鍒ゆ柇鍒犻櫎鏍囪瘑
+ for (String key : deleteMap.keySet()) {
+ //鍒犻櫎楠岃瘉鍊�
+ String deleteValue = map.get("deleteValue");
+ //鍊肩浉鍚屽氨鍒犻櫎鎴栬�呬笉鏂板
+ if (deleteValue.equals(resultSet.getString(key))) {
+ is_delete = true;
+ }
+ }
+ //閫氳繃鍞竴瀛楁鏌ヨ鏁版嵁
+ //鏈煡璇㈠埌鐩稿悓鏁版嵁灏辨柊澧炴暟鎹�,鏌ヨ鍒板氨璺宠繃鏁版嵁
+ StringBuffer selectSql = new StringBuffer();
+ selectSql.append(" select count(*) from `").append(tableName).append("` where ");
+ for (String key : sileMap.keySet()) {
+ String keys = resultSet.getString(key);
+ if (keys == null) {
+ selectSql.append("`").append(key).append("` = ").append(keys).append(" AND ");
+ } else {
+ selectSql.append("`").append(key).append("` = \"").append(keys).append("\" AND ");
+ }
+ }
+ String sql = selectSql.substring(0, selectSql.length() - 4);
+ PreparedStatement ps = mysqlCon.prepareStatement(sql);
+ ResultSet resultNumber = ps.executeQuery();
+ // 濡傛灉鏌ュ埌灏卞ぇ浜�0
+ while (resultNumber.next()) {
+ result = resultNumber.getInt(1);
+ }
+ // 澶т簬0 鎴栬�呮槸闇�瑕佸垹闄ょ殑鏁版嵁
+ if (result == 0) {
+ //濡傛灉鏄鍒犻櫎鐨勬暟鎹� 灏变笉鏂板
+ if (is_delete) {
+ deleteNumber++;
+ continue;
+ }
+ addNumber++;
+ StringBuffer valueSql = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ String value = resultSet.getString(key);
+ if (value == null) {
+ valueSql.append(value).append(",");
+ } else {
+ valueSql.append("\"").append(value).append("\",");
+ }
+ }
+ list.clear();
+ for (String key : sileMap.keySet()) {
+ String value = resultSet.getString(key);
+ if (value == null) {
+ valueSql.append(value).append(",");
+ } else {
+ valueSql.append("\"").append(value).append("\",");
+ }
+ list.add(value);
+ }
+ UUID uuid = UUID.randomUUID();
+ valueSql.append("\"").append(uuid).append("\",");
+ addDataRecord.add(uuid.toString());
+ valueSql.deleteCharAt(valueSql.length() - 1);
+ if (insertSql.length() > 0) {
+ insertSql.append(",(").append(valueSql).append(")");
+ } else {
+ StringBuffer keySql = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ keySql.append("`").append(syncMap.get(key)).append("`,");
+ }
+ for (String key : sileMap.keySet()) {
+ keySql.append("`").append(sileMap.get(key)).append("`,");
+ }
+ keySql.append("`uuid`");
+ insertSql.append(" INSERT INTO `").append(tableName).append("`(").append(keySql)
+ .append(") VALUES (").append(valueSql).append(")");
+ }
+ //鏌ュ嚭杩欐潯鏁版嵁,浣嗚鎵ц鍒犻櫎
+ } else {
+ //鎵ц鍒犻櫎鏂规硶
+ if (is_delete) {
+ StringBuffer deleteSql = new StringBuffer();
+ deleteSql.append(" delete from `").append(tableName).append("` where ");
+ Map<String, String> record = new HashMap<>();
+ for (String key : sileMap.keySet()) {
+ String keys = resultSet.getString(key);
+ record.put(key, keys);
+ if (keys == null) {
+ deleteSql.append("`").append(key).append("` = ").append(keys).append(" AND ");
+ } else {
+ deleteSql.append("`").append(key).append("` = \"").append(keys).append("\" AND ");
+ }
+ }
+ deleteDataRecord.add(record);
+
+ String delSql = deleteSql.substring(0, deleteSql.length() - 4);
+ PreparedStatement delps = mysqlCon.prepareStatement(delSql);
+ deleteNumber = deleteNumber + delps.executeUpdate();
+ deleteDataRecord.add(record);
+ //鏌ュ埌浜嗘暟鎹�,骞朵笖涓嶅垹闄ゃ�傞偅鏇存柊璇ユ潯鏁版嵁
+ } else {
+ StringBuffer updateSql = new StringBuffer();
+ updateSql.append(" update `").append(tableName).append("` set ");
+ for (String key : syncMap.keySet()) {
+ String keys = resultSet.getString(key);
+ if (keys == null) {
+ updateSql.append("`").append(syncMap.get(key)).append("` = ").append(keys).append(",");
+ } else {
+ updateSql.append("`").append(syncMap.get(key)).append("` = \"").append(keys).append("\",");
+ }
+ }
+ updateSql = updateSql.deleteCharAt(updateSql.length() - 1);
+ updateSql.append(" where ");
+ list.clear();
+ Map<String, String> record = new HashMap<>();
+ for (String key : sileMap.keySet()) {
+ String value = resultSet.getString(key);
+ record.put(key, value);
+ list.add(value);
+ if (value == null) {
+ updateSql.append("`").append(sileMap.get(key)).append("` = ").append(value).append(" AND ");
+ } else {
+ updateSql.append("`").append(sileMap.get(key)).append("` = \"").append(value).append("\" AND ");
+ }
+ }
+ updateSql = updateSql.delete(updateSql.length() - 5, updateSql.length());
+ updateSql.append(";");
+
+ try {
+ mySqlPs = mysqlCon.prepareStatement(updateSql.toString());
+ result = mySqlPs.executeUpdate();// 杩斿洖鍊间唬琛ㄦ敹鍒板奖鍝嶇殑琛屾暟
+ upNum++;
+ updateDataRecord.add(record);
+ } catch (SQLException | BaseException e) {
+ errorNum++;
+ exceptionLog.addSubExceptionLog(logUuid, list, e);
+ continue;
+
+ }
+ }
+ }
+ }
+ if (!BaseUtil.strIsNull(insertSql.toString())) {
+ try {
+ insertSql.append(";");
+ mySqlPs = mysqlCon.prepareStatement(insertSql.toString());
+ insert = mySqlPs.executeUpdate();
+ addNum = addNum + insert;
+ } catch (SQLException | BaseException e) {
+ errorNum = errorNum + addNumber;
+ addDataRecord.clear();
+ exceptionLog.addSubExceptionLog(logUuid, e, currentPage);
+ }
+ }
+ //鍏抽棴缁撴灉灏�
+ //DataManipulationUtils.close(resultSet, null, null);
+ totalNumber = totalNumber + resultRow;
+ currentPage++;
+ map.put("currentPage", String.valueOf(currentPage));
+ //濡傛灉鏉℃暟灏忎簬1000灏辩粨鏉熸煡璇�
+ //鍏抽棴mysql
+ DataManipulationUtils.close(null, mySqlPs, mysqlCon);
+ } while (resultRow == 1000);
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("淇敼鏁版嵁" + upNum);
+ SpringMVCContextHolder.getSystemLogger().error("鍒犻櫎鏁版嵁" + deleteNumber);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, null, addNum, upNum, deleteNumber, errorNum, totalNumber);
+ //鍏抽棴鏁版嵁婧愯繛鎺�
+ DataManipulationUtils.close(null, null, conn);
+
+ } catch (SQLException e) {
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("淇敼鏁版嵁" + upNum);
+ SpringMVCContextHolder.getSystemLogger().error("鍒犻櫎鏁版嵁" + deleteNumber);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, e, addNum, upNum, deleteNumber, errorNum, totalNumber);
+ }
+ return Lists.newArrayList(addDataRecord, updateDataRecord, deleteDataRecord);
+ }
+
+
+ /**
+ * FieldSetEntity 鍗曟潯淇濆瓨,姣忔潯淇濆瓨鍓嶆垨淇濆瓨鍚庡彲鍗曠嫭璋冪敤鍑芥暟銆傞敊璇棩蹇楀崟鏉¤褰曘��
+ *
+ * @param conn 鏁版嵁搴撹繛鎺�
+ * @param map 鍚屾閰嶇疆琛ㄧ殑鏁版嵁
+ * @param sileMap 鍞竴瀛楁
+ * @param syncMap 鍚屾瀛楁
+ * @param savePreEvent 淇濆瓨鍓嶈皟鐢ㄦ柟娉�
+ * @param postSaveEvent 淇濆瓨鍚庤皟鐢ㄦ柟娉�
+ * @param is_uuid 鏄惁鏈塽uid瀛楁
+ */
+ public void batchSaveFieldSetData(Connection conn, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap, String savePreEvent, String postSaveEvent, boolean is_uuid) {
+ Integer resultRow = 0;
+ List<String> list = ListUtils.newArrayList();
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //淇敼鏁伴噺
+ Integer upNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ //鎬绘潯鏁�
+ Integer totalNumber = 0;
+ //绯荤粺琛ㄥ悕
+ String tableName = map.get("tableName");
+ //褰撳墠椤�
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ //鏃ュ織缁勮〃uuid
+ String logUuid = map.get("logUuid");
+ //1澧為噺鎴�2瑕嗙洊鍚屾
+ String syncType = map.get(CmnConst.SYNC_TYPE);
+ try {
+ do {
+ ResultSet resultSet = DataManipulationUtils.getResultSet(conn, map);
+ resultRow = 0;
+ while (resultSet.next()) {
+ FieldSetEntity fieldSet = new FieldSetEntity();
+ fieldSet.setTableName(tableName);
+ resultRow++;
+ StringBuffer condition = new StringBuffer();
+ for (String key : syncMap.keySet()) {
+ fieldSet.setValue(syncMap.get(key), resultSet.getString(key));
+ }
+ list.clear();
+ for (String key : sileMap.keySet()) {
+ String value = resultSet.getString(key);
+ String fieldName = sileMap.get(key);
+ fieldSet.setValue(fieldName, value);
+ condition.append(fieldName).append(" = ? AND ");
+ list.add(value);
+ }
+ //鎷兼帴淇敼璇彞 濡傛灉鏈慨鏀规垚鍔熻褰� 灏辨妸鏁版嵁鏀惧叆鏂板鐨刣ataTableEntity
+ boolean is_update = false;
+ try {
+ //璋冪敤淇濆瓨鍓嶆柟娉�
+ if (!BaseUtil.strIsNull(savePreEvent) && savePreEvent.indexOf(".") != -1) {
+ try {
+ DataManipulationUtils.codeCalls(savePreEvent, fieldSet);
+ } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
+ e.printStackTrace();
+ exceptionLog.addSubExceptionLog(logUuid, list, e);
+ }
+ }
+ String term = condition.substring(0, condition.length() - 4);
+ if ("1".equals(syncType)) {
+ FieldSetEntity fieldSetEntityByFilter = baseDao.getFieldSetEntityByFilter(tableName, term, list.toArray(new String[]{}), false);
+ //鍚湁uuid
+ if (is_uuid) {
+ is_update = baseDao.update(fieldSet);
+ //濡傛灉鏌ュ嚭浜嗙郴缁熷師鏁版嵁
+ } else if (fieldSetEntityByFilter != null) {
+ fieldSet.setValue("uuid", fieldSetEntityByFilter.getString("uuid"));
+ is_update = baseDao.update(fieldSet);
+ // 娌℃湁uuid 骞朵笖娌℃湁婧愭暟鎹氨鏂板
+ } else {
+ is_update = false;
+ }
+ }
+ } catch (BaseException e) {
+ errorNum++;
+ exceptionLog.addSubExceptionLog(logUuid, list, e);
+ continue;
+ }
+ //淇敼涓嶆垚鍔�
+ if (!is_update) {
+ addNum++;
+ baseDao.add(fieldSet);
+ } else {
+ //淇敼鎴愬姛璁℃暟鍔犱竴
+ upNum++;
+ }
+ //璋冪敤淇濆瓨鍚庢柟娉�
+ if (!BaseUtil.strIsNull(postSaveEvent) && postSaveEvent.indexOf(".") != -1) {
+ try {
+ DataManipulationUtils.codeCalls(postSaveEvent, fieldSet);
+ } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
+ e.printStackTrace();
+ exceptionLog.addSubExceptionLog(logUuid, list, e);
+ }
+ }
+ }
+ totalNumber = totalNumber + resultRow;
+ currentPage++;
+ map.put("currentPage", String.valueOf(currentPage));
+ //濡傛灉鏉℃暟灏忎簬1000灏辩粨鏉熸煡璇�
+ } while (resultRow == 1000);
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("淇敼鏁版嵁" + upNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, null, addNum, upNum, 0, errorNum, totalNumber);
+ } catch (SQLException e) {
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("淇敼鏁版嵁" + upNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, e, addNum, upNum, 0, errorNum, totalNumber);
+ }
+ }
+
+ /**
+ * FieldSetEntity 閫氳繃绾跨▼鍗曟潯淇濆瓨,姣忔潯淇濆瓨鍓嶆垨淇濆瓨鍚庡彲鍗曠嫭璋冪敤鍑芥暟銆傞敊璇棩蹇楀崟鏉¤褰曘��
+ * 鏌ヨ鍒�1000鏉℃暟鎹紑涓�涓嚎绋嬪鐞�,鍒涘缓鍙紦瀛樼嚎绋嬫睜
+ * 鏂板鍚屾,鍙仛鏂板鎿嶄綔
+ *
+ * @param conn 鏁版嵁搴撹繛鎺�
+ * @param map 鍚屾閰嶇疆琛ㄧ殑鏁版嵁
+ * @param sileMap 鍞竴瀛楁
+ * @param syncMap 鍚屾瀛楁
+ * @param savePreEvent 淇濆瓨鍓嶈皟鐢ㄦ柟娉�
+ * @param postSaveEvent 淇濆瓨鍚庤皟鐢ㄦ柟娉�
+ * @param is_uuid 鏄惁鏈塽uid瀛楁
+ */
+ public List<Object> runnableBatchAddFieldSetData(Connection conn, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap, String savePreEvent, String postSaveEvent, boolean is_uuid) {
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ //褰撳墠椤�
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ //鏃ュ織缁勮〃uuid
+ String logUuid = map.get("logUuid");
+ //淇濆瓨鍓嶈皟鐢�
+ map.put("savePreEvent", savePreEvent);
+ //淇濆瓨鍚庤皟鐢�
+ map.put("postSaveEvent", postSaveEvent);
+ //鏄惁鏈塽uid瀛楁
+ map.put("is_uuid", String.valueOf(is_uuid));
+ List<String> addDataRecord = new ArrayList<>();
+ Integer totalNumber = 0;
+ //绾跨▼瀹夊叏鐨凩ist
+ List<Map<String, Object>> result = Collections.synchronizedList(Lists.newArrayList());
+ try {
+ ExecutorService exec = Executors.newCachedThreadPool();
+ //鏌ヨ鏁版嵁鏉℃暟
+ Integer number = DataManipulationUtils.getResultSetRow(conn, map);
+ totalNumber = number;
+ do {
+ ResultSet resultSet = DataManipulationUtils.getResultSet(conn, map);
+ DataAddSynchronization async = new DataAddSynchronization(resultSet, map, sileMap, syncMap);
+ async.setExceptionLog(exceptionLog);
+ async.setBaseDao(baseDao);
+ //鍥炶皟鍐欐硶
+ async.setCallBack((Object[] t) -> {
+ if (t != null && t[0] != null) {
+ result.add((Map<String, Object>) t[0]);
+ }
+ });
+ Thread t = new Thread(async);
+ number = number - 1000;
+ currentPage++;
+ map.put("currentPage", String.valueOf(currentPage));
+ //鏀惧叆鐢ㄤ簬鑾峰彇绾跨▼鐘舵�� 骞舵墽琛宼.start();
+ exec.submit(t);
+ //濡傛灉鏉℃暟灏忎簬1000灏辩粨鏉熸煡璇�
+ } while (number > 0);
+ exec.shutdown();
+ while (true) {
+ if (exec.isTerminated()) {
+ //System.out.println("鎵�鏈夌殑瀛愮嚎绋嬮兘缁撴潫浜嗭紒");
+ break;
+ }
+ Thread.sleep(1000);
+ }
+ //idea 鍐欐硶
+// int numberC = result.stream().map(m -> m.get("resultRow")).filter(n -> n != null && n > 0).mapToInt(n -> n).sum();
+ for (int i = 0; i < result.size(); i++) {
+ Map<String, Object> m = result.get(i);
+ addNum = addNum + Integer.valueOf((String) m.get("addNum"));
+ errorNum = errorNum + Integer.valueOf((String) m.get("errorNum"));
+ List<List<String>> changeDataKeys = (List<List<String>>) m.get("changeDataKeys");
+ if (changeDataKeys != null && changeDataKeys.size() > 0) {
+ addDataRecord.addAll(changeDataKeys.get(0));
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, null, addNum, 0, 0, errorNum, totalNumber);
+ } catch (SQLException | InterruptedException e) {
+ for (int i = 0; i < result.size(); i++) {
+ Map<String, Object> m = result.get(i);
+ addNum = addNum + Integer.valueOf((String) m.get("addNum"));
+ errorNum = errorNum + Integer.valueOf((String) m.get("errorNum"));
+ List<List<String>> changeDataKeys = (List<List<String>>) m.get("changeDataKeys");
+ if (changeDataKeys != null && changeDataKeys.size() > 0) {
+ addDataRecord.addAll(changeDataKeys.get(0));
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, e, addNum, 0, 0, errorNum, totalNumber);
+ }
+ return Lists.newArrayList(addDataRecord);
+ }
+
+ /**
+ * FieldSetEntity 閫氳繃绾跨▼鍗曟潯淇濆瓨,姣忔潯淇濆瓨鍓嶆垨淇濆瓨鍚庡彲鍗曠嫭璋冪敤鍑芥暟銆傞敊璇棩蹇楀崟鏉¤褰曘��
+ * 鏌ヨ鍒�1000鏉℃暟鎹紑涓�涓嚎绋嬪鐞�,鍒涘缓鍙紦瀛樼嚎绋嬫睜
+ * 鏂板淇敼鍚屾,淇敼澶辫触灏辨柊澧�
+ *
+ * @param conn 鏁版嵁搴撹繛鎺�
+ * @param map 鍚屾閰嶇疆琛ㄧ殑鏁版嵁
+ * @param sileMap 鍞竴瀛楁
+ * @param syncMap 鍚屾瀛楁
+ * @param deleteMap 鍒犻櫎瀛楁
+ * @param savePreEvent 淇濆瓨鍓嶈皟鐢ㄦ柟娉�
+ * @param postSaveEvent 淇濆瓨鍚庤皟鐢ㄦ柟娉�
+ * @param is_uuid 鏄惁鏈塽uid瀛楁
+ */
+ public List<List<Object>> runnableBatchSaveDeleteFieldSetData(Connection conn, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap, Map<String, String> deleteMap, String savePreEvent, String postSaveEvent, boolean is_uuid) {
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //淇敼鏁伴噺
+ Integer upNum = 0;
+ //鍒犻櫎鏉℃暟
+ Integer deleteNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ // 鏂板銆佷慨鏀广�佸垹闄� 瀵瑰簲鐨剈uid 椤哄簭瀵瑰簲闆嗗悎涓殑涓嬭〃 2022骞�1鏈�13鏃�21:24:53 cheng
+ List<List<Object>> executeDataKeys = Lists.newArrayList(new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
+ //褰撳墠椤�
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ //鏃ュ織缁勮〃uuid
+ String logUuid = map.get("logUuid");
+ //淇濆瓨鍓嶈皟鐢�
+ map.put("savePreEvent", savePreEvent);
+ //淇濆瓨鍚庤皟鐢�
+ map.put("postSaveEvent", postSaveEvent);
+ //鏄惁鏈塽uid瀛楁
+ map.put("is_uuid", String.valueOf(is_uuid));
+ Integer totalNumber = 0;
+ //绾跨▼瀹夊叏鐨凩ist
+ List<Map<String, Object>> result = Collections.synchronizedList(Lists.newArrayList());
+ try {
+ ExecutorService exec = Executors.newCachedThreadPool();
+ //鏌ヨ鏁版嵁鏉℃暟
+ Integer number = DataManipulationUtils.getResultSetRow(conn, map);
+ totalNumber = number;
+ do {
+ ResultSet resultSet = DataManipulationUtils.getResultSet(conn, map);
+ DataSaveDeleteSynchronization async = new DataSaveDeleteSynchronization(resultSet, map, sileMap, syncMap, deleteMap);
+ async.setExceptionLog(exceptionLog);
+ async.setBaseDao(baseDao);
+ //鍥炶皟鍐欐硶
+ async.setCallBack((Object[] t) -> {
+ if (t != null && t[0] != null) {
+ result.add((Map<String, Object>) t[0]);
+ }
+ });
+ Thread t = new Thread(async);
+ number = number - 1000;
+ currentPage++;
+ map.put("currentPage", String.valueOf(currentPage));
+ //鏀惧叆鐢ㄤ簬鑾峰彇绾跨▼鐘舵�� 骞舵墽琛宼.start();
+ exec.submit(t);
+ //濡傛灉鏉℃暟灏忎簬1000灏辩粨鏉熸煡璇�
+ } while (number > 0);
+ exec.shutdown();
+ while (true) {
+ if (exec.isTerminated()) {
+ //System.out.println("鎵�鏈夌殑瀛愮嚎绋嬮兘缁撴潫浜嗭紒");
+ break;
+ }
+ Thread.sleep(1000);
+ }
+ //idea 鍐欐硶
+ for (int i = 0; i < result.size(); i++) {
+ Map<String, Object> m = result.get(i);
+ addNum = addNum + Integer.valueOf((String) m.get("addNum"));
+ upNum = upNum + Integer.valueOf((String) m.get("upNum"));
+ deleteNum = deleteNum + Integer.valueOf((String) m.get("deleteNum"));
+ errorNum = errorNum + Integer.valueOf((String) m.get("errorNum"));
+ List<Object> changeDataKeys = (List<Object>) m.get("changeDataKeys");
+ if (changeDataKeys != null) {
+ for (int j = 0; j < changeDataKeys.size(); j++) {
+ List<Object> objects = executeDataKeys.get(j);
+ if (objects == null) {
+ objects = new ArrayList<>();
+ }
+ objects.addAll((List) changeDataKeys.get(j));
+ }
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("淇敼鏁版嵁" + upNum);
+ SpringMVCContextHolder.getSystemLogger().error("鍒犻櫎鏁版嵁" + deleteNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, null, addNum, upNum, deleteNum, errorNum, totalNumber);
+ } catch (SQLException | InterruptedException e) {
+ for (int i = 0; i < result.size(); i++) {
+ Map<String, Object> m = result.get(i);
+ addNum = addNum + Integer.valueOf((String) m.get("addNum"));
+ upNum = upNum + Integer.valueOf((String) m.get("upNum"));
+ deleteNum = deleteNum + Integer.valueOf((String) m.get("deleteNum"));
+ errorNum = errorNum + Integer.valueOf((String) m.get("errorNum"));
+ List<Object> changeDataKeys = (List<Object>) m.get("changeDataKeys");
+ if (changeDataKeys != null) {
+ for (int j = 0; j < changeDataKeys.size(); j++) {
+ List<Object> objects = executeDataKeys.get(j);
+ if (objects == null) {
+ objects = new ArrayList<>();
+ }
+ objects.addAll((List) changeDataKeys.get(j));
+ }
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("淇敼鏁版嵁" + upNum);
+ SpringMVCContextHolder.getSystemLogger().error("鍒犻櫎鏁版嵁" + deleteNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, e, addNum, upNum, deleteNum, errorNum, totalNumber);
+ }
+ return executeDataKeys;
+ }
+
+ /**
+ * FieldSetEntity 閫氳繃绾跨▼鍗曟潯淇濆瓨,姣忔潯淇濆瓨鍓嶆垨淇濆瓨鍚庡彲鍗曠嫭璋冪敤鍑芥暟銆傞敊璇棩蹇楀崟鏉¤褰曘��
+ * 鏌ヨ鍒�1000鏉℃暟鎹紑涓�涓嚎绋嬪鐞�,鍒涘缓鍙紦瀛樼嚎绋嬫睜
+ * 鏂板淇敼鍚屾,淇敼澶辫触灏辨柊澧�
+ *
+ * @param conn 鏁版嵁搴撹繛鎺�
+ * @param map 鍚屾閰嶇疆琛ㄧ殑鏁版嵁
+ * @param sileMap 鍞竴瀛楁
+ * @param syncMap 鍚屾瀛楁
+ * @param savePreEvent 淇濆瓨鍓嶈皟鐢ㄦ柟娉�
+ * @param postSaveEvent 淇濆瓨鍚庤皟鐢ㄦ柟娉�
+ * @param is_uuid 鏄惁鏈塽uid瀛楁
+ */
+ public List<Object> runnableBatchSaveFieldSetData(Connection conn, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap, String savePreEvent, String postSaveEvent, boolean is_uuid) {
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //淇敼鏁伴噺
+ Integer upNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ //婧愭暟鎹〃鍚�
+ String dataOriginName = map.get("dataOriginName");
+ //褰撳墠椤�
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ //鏃ュ織缁勮〃uuid
+ String logUuid = map.get("logUuid");
+ //淇濆瓨鍓嶈皟鐢�
+ map.put("savePreEvent", savePreEvent);
+ //淇濆瓨鍚庤皟鐢�
+ map.put("postSaveEvent", postSaveEvent);
+ //鏄惁鏈塽uid瀛楁
+ map.put("is_uuid", String.valueOf(is_uuid));
+
+ // 鏂板銆佷慨鏀广�佸垹闄� 瀵瑰簲鐨剈uid 椤哄簭瀵瑰簲闆嗗悎涓殑涓嬭〃 2022骞�1鏈�13鏃�21:24:53 cheng
+ List<Object> executeDataKeys = Lists.newArrayList(new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
+ Integer totalNumber = 0;
+ //绾跨▼瀹夊叏鐨凩ist
+ List<Map<String, Object>> result = Collections.synchronizedList(Lists.newArrayList());
+ try {
+ ExecutorService exec = Executors.newCachedThreadPool();
+ //鏌ヨ鏁版嵁鏉℃暟
+ Integer number = DataManipulationUtils.getResultSetRow(conn, map);
+ totalNumber = number;
+ do {
+ ResultSet resultSet = DataManipulationUtils.getResultSet(conn, map);
+ DataSaveSynchronization async = new DataSaveSynchronization(resultSet, map, sileMap, syncMap);
+ async.setExceptionLog(exceptionLog);
+ async.setBaseDao(baseDao);
+ //鍥炶皟鍐欐硶
+ async.setCallBack((Object[] t) -> {
+ if (t != null && t[0] != null) {
+ result.add((Map<String, Object>) t[0]);
+ }
+ });
+ Thread t = new Thread(async);
+ number = number - 1000;
+ currentPage++;
+ map.put("currentPage", String.valueOf(currentPage));
+ //鏀惧叆鐢ㄤ簬鑾峰彇绾跨▼鐘舵�� 骞舵墽琛宼.start();
+ exec.submit(t);
+ //濡傛灉鏉℃暟灏忎簬1000灏辩粨鏉熸煡璇�
+ } while (number > 0);
+ exec.shutdown();
+ while (true) {
+ if (exec.isTerminated()) {
+ //System.out.println("鎵�鏈夌殑瀛愮嚎绋嬮兘缁撴潫浜嗭紒");
+ break;
+ }
+ Thread.sleep(1000);
+ }
+ //idea 鍐欐硶
+// int numberC = result.stream().map(m -> m.get("resultRow")).filter(n -> n != null && n > 0).mapToInt(n -> n).sum();
+ for (int i = 0; i < result.size(); i++) {
+
+ Map<String, Object> m = result.get(i);
+ addNum = addNum + Integer.valueOf((String) m.get("addNum"));
+ upNum = upNum + Integer.valueOf((String) m.get("upNum"));
+ errorNum = errorNum + Integer.valueOf((String) m.get("errorNum"));
+ List<Object> changeDataKeys = (List<Object>) m.get("changeDataKeys");
+ if (changeDataKeys != null) {
+ for (int j = 0; j < changeDataKeys.size(); j++) {
+ List<Object> objects = (List<Object>) executeDataKeys.get(j);
+ if (objects == null) {
+ objects = new ArrayList<>();
+ }
+ objects.addAll((List) changeDataKeys.get(j));
+ }
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("淇敼鏁版嵁" + upNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, null, addNum, upNum, 0, errorNum, totalNumber);
+ } catch (SQLException | InterruptedException e) {
+ for (int i = 0; i < result.size(); i++) {
+ Map<String, Object> m = result.get(i);
+ addNum = addNum + Integer.valueOf((String) m.get("addNum"));
+ upNum = upNum + Integer.valueOf((String) m.get("upNum"));
+ errorNum = errorNum + Integer.valueOf((String) m.get("errorNum"));
+ List<Object> changeDataKeys = (List<Object>) m.get("changeDataKeys");
+ if (changeDataKeys != null) {
+ for (int j = 0; j < changeDataKeys.size(); j++) {
+ List<Object> objects = (List<Object>) executeDataKeys.get(j);
+ if (objects == null) {
+ objects = new ArrayList<>();
+ }
+ objects.addAll((List) changeDataKeys.get(j));
+ }
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("淇敼鏁版嵁" + upNum);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, e, addNum, upNum, 0, errorNum, totalNumber);
+ }
+ return executeDataKeys;
+ }
+
+ /**
+ * FieldSetEntity 閫氳繃绾跨▼鍗曟潯淇濆瓨,姣忔潯淇濆瓨鍓嶆垨淇濆瓨鍚庡彲鍗曠嫭璋冪敤鍑芥暟銆傞敊璇棩蹇楀崟鏉¤褰曘��
+ * 鏌ヨ鍒�1000鏉℃暟鎹紑涓�涓嚎绋嬪鐞�,鍒涘缓鍙紦瀛樼嚎绋嬫睜
+ * 鏂板鍚屾,鍙仛鏂板鎿嶄綔
+ *
+ * @param conn 鏁版嵁搴撹繛鎺�
+ * @param map 鍚屾閰嶇疆琛ㄧ殑鏁版嵁
+ * @param sileMap 鍞竴瀛楁
+ * @param syncMap 鍚屾瀛楁
+ * @param deleteMap 鍒犻櫎瀛楁
+ * @param savePreEvent 淇濆瓨鍓嶈皟鐢ㄦ柟娉�
+ * @param postSaveEvent 淇濆瓨鍚庤皟鐢ㄦ柟娉�
+ * @param is_uuid 鏄惁鏈塽uid瀛楁
+ */
+ public List<Object> runnableBatchAddDeleteFieldSetData(Connection conn, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap, Map<String, String> deleteMap, String savePreEvent, String postSaveEvent, boolean is_uuid) {
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ //鍒犻櫎鏁伴噺
+ Integer deleteNumber = 0;
+ //褰撳墠椤�
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ //鏃ュ織缁勮〃uuid
+ String logUuid = map.get("logUuid");
+ //淇濆瓨鍓嶈皟鐢�
+ map.put("savePreEvent", savePreEvent);
+ //淇濆瓨鍚庤皟鐢�
+ map.put("postSaveEvent", postSaveEvent);
+ //鏄惁鏈塽uid瀛楁
+ map.put("is_uuid", String.valueOf(is_uuid));
+ Integer totalNumber = 0;
+ //绾跨▼瀹夊叏鐨凩ist
+ List<Map<String, Object>> result = Collections.synchronizedList(Lists.newArrayList());
+ List<Object> resultChangeRecord = Lists.newArrayList(Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList());
+ try {
+ ExecutorService exec = Executors.newCachedThreadPool();
+ //鏌ヨ鏁版嵁鏉℃暟
+ Integer number = DataManipulationUtils.getResultSetRow(conn, map);
+ totalNumber = number;
+ do {
+ ResultSet resultSet = DataManipulationUtils.getResultSet(conn, map);
+ DataAddDeleteSynchronization async = new DataAddDeleteSynchronization(resultSet, map, sileMap, syncMap, deleteMap);
+ async.setExceptionLog(exceptionLog);
+ async.setBaseDao(baseDao);
+ //鍥炶皟鍐欐硶
+ async.setCallBack((Object[] t) -> {
+ if (t != null && t[0] != null) {
+ result.add((Map<String, Object>) t[0]);
+ }
+ });
+ Thread t = new Thread(async);
+ number = number - 1000;
+ currentPage++;
+ map.put("currentPage", String.valueOf(currentPage));
+ //鏀惧叆鐢ㄤ簬鑾峰彇绾跨▼鐘舵�� 骞舵墽琛宼.start();
+ exec.submit(t);
+ //濡傛灉鏉℃暟灏忎簬1000灏辩粨鏉熸煡璇�
+ } while (number > 0);
+ exec.shutdown();
+ while (true) {
+ if (exec.isTerminated()) {
+ //System.out.println("鎵�鏈夌殑瀛愮嚎绋嬮兘缁撴潫浜嗭紒");
+ break;
+ }
+ Thread.sleep(1000);
+ }
+ //idea 鍐欐硶
+// int numberC = result.stream().map(m -> m.get("resultRow")).filter(n -> n != null && n > 0).mapToInt(n -> n).sum();
+ for (int i = 0; i < result.size(); i++) {
+ Map<String, Object> m = result.get(i);
+ addNum = addNum + Integer.valueOf((String) m.get("addNum"));
+ errorNum = errorNum + Integer.valueOf((String) m.get("errorNum"));
+ deleteNumber = deleteNumber + Integer.valueOf((String) m.get("deleteNumber"));
+ List<Object> changeKeys = (List<Object>) m.get("changeKeys");
+ if (changeKeys != null && changeKeys.size() > 0) {
+ for (int j = 0; j < changeKeys.size(); j++) {
+ List<Object> list = (List) resultChangeRecord.get(j);
+ list.addAll((List) changeKeys.get(j));
+ resultChangeRecord.set(i, list);
+ }
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("鍒犻櫎鏁版嵁" + deleteNumber);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, null, addNum, 0, deleteNumber, errorNum, totalNumber);
+ } catch (SQLException | InterruptedException e) {
+ for (int i = 0; i < result.size(); i++) {
+ Map<String, Object> m = result.get(i);
+ addNum = addNum + Integer.valueOf((String) m.get("addNum"));
+ errorNum = errorNum + Integer.valueOf((String) m.get("errorNum"));
+ deleteNumber = deleteNumber + Integer.valueOf((String) m.get("deleteNumber"));
+ List<Object> changeKeys = (List<Object>) m.get("changeKeys");
+ if (changeKeys != null && changeKeys.size() > 0) {
+ for (int j = 0; j < changeKeys.size(); j++) {
+ List<Object> list = (List) resultChangeRecord.get(j);
+ list.addAll((List) changeKeys.get(j));
+ resultChangeRecord.set(i, list);
+ }
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("鍒犻櫎鏁版嵁" + deleteNumber);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, e, addNum, 0, deleteNumber, errorNum, totalNumber);
+ }
+ return resultChangeRecord;
+ }
+
+ /**
+ * FieldSetEntity 閫氳繃绾跨▼鍗曟潯淇濆瓨,姣忔潯淇濆瓨鍓嶆垨淇濆瓨鍚庡彲鍗曠嫭璋冪敤鍑芥暟銆傞敊璇棩蹇楀崟鏉¤褰曘��
+ * 鏌ヨ鍒�1000鏉℃暟鎹紑涓�涓嚎绋嬪鐞�,鍒涘缓鍙紦瀛樼嚎绋嬫睜
+ * 鏂板鍚屾,鍙仛鏂板鎿嶄綔
+ *
+ * @param conn 鏁版嵁搴撹繛鎺�
+ * @param map 鍚屾閰嶇疆琛ㄧ殑鏁版嵁
+ * @param sileMap 鍞竴瀛楁
+ * @param syncMap 鍚屾瀛楁
+ * @param deleteMap 鍒犻櫎瀛楁
+ * @param savePreEvent 淇濆瓨鍓嶈皟鐢ㄦ柟娉�
+ * @param postSaveEvent 淇濆瓨鍚庤皟鐢ㄦ柟娉�
+ * @param is_uuid 鏄惁鏈塽uid瀛楁
+ */
+ public List<Object> runnableBatcSaveDeleteFieldSetData(Connection conn, Map<String, String> map, Map<String, String> sileMap, Map<String, String> syncMap, Map<String, String> deleteMap, String savePreEvent, String postSaveEvent, boolean is_uuid) {
+ //鏂板鏁伴噺
+ Integer addNum = 0;
+ //閿欒鏁伴噺
+ Integer errorNum = 0;
+ //鍒犻櫎鏁伴噺
+ Integer deleteNumber = 0;
+ //褰撳墠椤�
+ Integer currentPage = Integer.parseInt(map.get("currentPage"));
+ //鏃ュ織缁勮〃uuid
+ String logUuid = map.get("logUuid");
+ //淇濆瓨鍓嶈皟鐢�
+ map.put("savePreEvent", savePreEvent);
+ //淇濆瓨鍚庤皟鐢�
+ map.put("postSaveEvent", postSaveEvent);
+ //鏄惁鏈塽uid瀛楁
+ map.put("is_uuid", String.valueOf(is_uuid));
+ Integer totalNumber = 0;
+ List<Object> resultChangeRecord = Lists.newArrayList(Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList());
+ //绾跨▼瀹夊叏鐨凩ist
+ List<Map<String, Object>> result = Collections.synchronizedList(Lists.newArrayList());
+ try {
+ ExecutorService exec = Executors.newCachedThreadPool();
+ //鏌ヨ鏁版嵁鏉℃暟
+ Integer number = DataManipulationUtils.getResultSetRow(conn, map);
+ totalNumber = number;
+ do {
+ ResultSet resultSet = DataManipulationUtils.getResultSet(conn, map);
+ DataAddDeleteSynchronization async = new DataAddDeleteSynchronization(resultSet, map, sileMap, syncMap, deleteMap);
+ async.setExceptionLog(exceptionLog);
+ async.setBaseDao(baseDao);
+ //鍥炶皟鍐欐硶
+ async.setCallBack((Object[] t) -> {
+ if (t != null && t[0] != null) {
+ result.add((Map<String, Object>) t[0]);
+ }
+ });
+ Thread t = new Thread(async);
+ number = number - 1000;
+ currentPage++;
+ map.put("currentPage", String.valueOf(currentPage));
+ //鏀惧叆鐢ㄤ簬鑾峰彇绾跨▼鐘舵�� 骞舵墽琛宼.start();
+ exec.submit(t);
+ //濡傛灉鏉℃暟灏忎簬1000灏辩粨鏉熸煡璇�
+ } while (number > 0);
+ exec.shutdown();
+ while (true) {
+ if (exec.isTerminated()) {
+ //System.out.println("鎵�鏈夌殑瀛愮嚎绋嬮兘缁撴潫浜嗭紒");
+ break;
+ }
+ Thread.sleep(1000);
+ }
+ //idea 鍐欐硶
+// int numberC = result.stream().map(m -> m.get("resultRow")).filter(n -> n != null && n > 0).mapToInt(n -> n).sum();
+ for (int i = 0; i < result.size(); i++) {
+ Map<String, Object> m = result.get(i);
+ addNum = addNum + Integer.valueOf((String) m.get("addNum"));
+ errorNum = errorNum + Integer.valueOf((String) m.get("errorNum"));
+ deleteNumber = deleteNumber + Integer.valueOf((String) m.get("deleteNumber"));
+ List<Object> changeKeys = (List<Object>) m.get("changeKeys");
+ if (changeKeys != null && changeKeys.size() > 0) {
+ for (int j = 0; j < changeKeys.size(); j++) {
+ List<Object> list = (List) resultChangeRecord.get(j);
+ list.addAll((List) changeKeys.get(j));
+ resultChangeRecord.set(i, list);
+ }
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("鍒犻櫎鏁版嵁" + deleteNumber);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, null, addNum, 0, deleteNumber, errorNum, totalNumber);
+ } catch (SQLException | InterruptedException e) {
+ for (int i = 0; i < result.size(); i++) {
+ Map<String, Object> m = result.get(i);
+ addNum = addNum + Integer.valueOf((String) m.get("addNum"));
+ errorNum = errorNum + Integer.valueOf((String) m.get("errorNum"));
+ deleteNumber = deleteNumber + Integer.valueOf((String) m.get("deleteNumber"));
+ List<Object> changeKeys = (List<Object>) m.get("changeKeys");
+ if (changeKeys != null && changeKeys.size() > 0) {
+ for (int j = 0; j < changeKeys.size(); j++) {
+ List<Object> list = (List) resultChangeRecord.get(j);
+ list.addAll((List) changeKeys.get(j));
+ resultChangeRecord.set(i, list);
+ }
+ }
+ }
+ SpringMVCContextHolder.getSystemLogger().error("鏂板鏁版嵁" + addNum);
+ SpringMVCContextHolder.getSystemLogger().error("鍒犻櫎鏁版嵁" + deleteNumber);
+ SpringMVCContextHolder.getSystemLogger().error("閿欒鏁版嵁" + errorNum);
+ SpringMVCContextHolder.getSystemLogger().error("鎬绘暟鎹�" + totalNumber);
+ exceptionLog.upExceptionLog(conn, logUuid, e, addNum, 0, deleteNumber, errorNum, totalNumber);
+ }
+ return resultChangeRecord;
+ }
+
+ public void testDataDispose(FieldSetEntity fse) {
+ fse.setValue("su01", "銆�" + fse.getString("su01") + "銆�");
+ }
+
+}
diff --git a/product-server-data-sync/src/main/java/com/product/data/sync/util/ThreadSelectManager.java b/product-server-data-sync/src/main/java/com/product/data/sync/util/ThreadSelectManager.java
new file mode 100644
index 0000000..7b201a9
--- /dev/null
+++ b/product-server-data-sync/src/main/java/com/product/data/sync/util/ThreadSelectManager.java
@@ -0,0 +1,162 @@
+package com.product.data.sync.util;
+
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.util.CallBack;
+import com.product.util.CallBackValue;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+class ThreadSelectManager {
+
+ private Map<Integer, CustomResultSet> pageResultSet = new HashMap<>();
+ /**
+ * 寮�濮嬫煡璇㈤〉鏁�
+ */
+ private int startPage;
+
+ private ExecutorService executorService;
+
+ private Connection sourceConnection;
+
+ private CallBackValue<String> getQuerySql;
+
+ private int totalPage = 0;
+
+ private CallBack<Object> setColumnNames;
+
+ private CallBackValue<String[]> getColumnNames;
+
+
+ public ThreadSelectManager(BatchData batchData) {
+ this.getQuerySql = (o) -> batchData.getQuerySql((int) o);
+ this.setColumnNames = (o) -> {
+ batchData.setColumnNames((String[]) o);
+ };
+ this.getColumnNames = (o) -> batchData.getColumnNames();
+ this.sourceConnection = ConnectionManager.getConnection();
+ this.totalPage = batchData.getTotalPage();
+ this.currentResult = 1;
+ }
+
+ /**
+ * 褰撳墠浠ヨ幏鍙栫鍑犻〉
+ */
+ private int currentResult = -1;
+
+ private boolean openLog = true;
+
+ /**
+ * 寮�濮嬫煡璇�
+ *
+ * @return
+ */
+ public boolean startQuery() {
+ //涓嶈兘閲嶅寮�濮嬫煡璇�
+ if (this.pageResultSet.size() <= 0 && this.executorService == null) {
+ this.executorService = Executors.newFixedThreadPool(1);
+ this.queryData();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 鑾峰彇涓嬩竴椤垫暟鎹�
+ *
+ * @return
+ */
+ public CustomResultSet getNext() {
+ if (this.currentResult == -1) {
+ return null;
+ }
+ int page = this.currentResult;
+ if (this.pageResultSet.get(page) != null) {
+ this.currentResult++;
+ return this.pageResultSet.get(page);
+ } else {
+ if (!this.executorService.isTerminated()) {
+ try {
+ outPutLog("绛夊緟绾跨▼涓煡璇㈡暟鎹�....", 1);
+ Thread.currentThread().sleep(1500);
+ return this.getNext();
+ } catch (Exception e) {
+ outPutLog("绛夊緟绾跨▼涓煡璇㈡暟鎹紝鍑洪敊....", 2);
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return null;
+ }
+ } else {
+ this.currentResult++;
+ outPutLog("鏌ヨ鏁版嵁绾跨▼宸茬粨鏉燂紝娌℃湁 " + page + " 鏁版嵁", 1);
+ return null;
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ int total = 3313;
+ int i1 = total / 3;
+ String[] ints = new String[3];
+ for (int i = 1; i <= 3; i++) {
+ }
+ }
+
+ /**
+ * 鏌ヨ鏁版嵁
+ */
+ private void queryData() {
+ outPutLog("寮�濮嬬嚎绋嬫煡璇㈡暟鎹紝闇�瑕佹煡璇細" + totalPage + " 椤垫暟鎹�", 1);
+// for (int i = 0; i < 3; i++) {
+ this.executorService.execute(() -> {
+ try {
+ int currentPage = 1;
+ while (totalPage > 0) {
+ outPutLog("寮�濮嬫煡璇㈤〉鏁帮細" + currentPage, 1);
+ String querySql = getQuerySql.method(currentPage);
+ outPutLog("鏌ヨsql锛歕n\t" + querySql, 1);
+ PreparedStatement pst = sourceConnection.prepareStatement(querySql);
+ ResultSet resultSet = pst.executeQuery();
+ if (resultSet != null) {
+ String[] columnNames = this.getColumnNames.method(null);
+ CustomResultSet customResultSet = new CustomResultSet(resultSet, columnNames);
+ if (columnNames == null || columnNames.length <= 0) {
+ this.setColumnNames.method(customResultSet.getColumnNames());
+ }
+ this.pageResultSet.put(currentPage, customResultSet);
+ }
+ currentPage++;
+ this.totalPage--;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ outPutLog("绾跨▼绾跨▼鏌ヨ鏁版嵁锛屽嚭閿�....", 2);
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ }
+ });
+// }
+ this.executorService.shutdown();
+ }
+
+ /**
+ * 杈撳嚭鏃ュ織
+ *
+ * @param msg 娑堟伅
+ * @param type 绫诲瀷 1 info 2 error
+ */
+ private void outPutLog(String msg, int type) {
+ if (this.openLog) {
+ if (type == 1) {
+ SpringMVCContextHolder.getSystemLogger().info(msg);
+ } else if (type == 2) {
+ SpringMVCContextHolder.getSystemLogger().error(msg);
+ }
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/product-server-data-sync/src/test/java/com/product/data/sync/test/ConnectionConfigurationTest.java b/product-server-data-sync/src/test/java/com/product/data/sync/test/ConnectionConfigurationTest.java
new file mode 100644
index 0000000..7e1c4b4
--- /dev/null
+++ b/product-server-data-sync/src/test/java/com/product/data/sync/test/ConnectionConfigurationTest.java
@@ -0,0 +1,35 @@
+package com.product.data.sync.test;
+
+
+import com.product.common.utils.HttpTest;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Copyright LX-BASE
+ *
+ * @Title: 鍚屾鏁版嵁娴嬭瘯绫�
+ * @Project: LX-BASE-SERVER
+ * @Date: 2020-11-13 10:15:47
+ * @Author: luoxin
+ * @Description:
+ */
+public class ConnectionConfigurationTest extends HttpTest {
+ public static void main(String[] args) {
+ dataSync();
+
+ }
+
+ //鏂板鏂囨。鐩綍
+ public static void dataSync() {
+ Map<String, Object> map = new HashMap<>();
+ map.put("url/api", "/api/connectionConfiguration/get-connectConfigure/v1");
+ map.put("~table~", "product_sys_database_connection_config");
+ //鏂囨。鐩綍鍚嶇О
+ map.put("uuid", "weqe32ewrw-qwe98qwei-dfv9df099");
+ testPost(map);
+ }
+}
\ No newline at end of file
diff --git a/product-server-data-sync/src/test/java/com/product/data/sync/test/ConnectionConfigureTest.java b/product-server-data-sync/src/test/java/com/product/data/sync/test/ConnectionConfigureTest.java
new file mode 100644
index 0000000..6d3fbc2
--- /dev/null
+++ b/product-server-data-sync/src/test/java/com/product/data/sync/test/ConnectionConfigureTest.java
@@ -0,0 +1,39 @@
+package com.product.data.sync.test;
+
+import com.product.common.utils.HttpTest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author: ZhouJie
+ * @date: 2021/8/12 9:29
+ * @description:
+ */
+
+public class ConnectionConfigureTest extends HttpTest {
+
+ public static void main(String[] args) {
+ saveConnectConfigure();
+ }
+ //淇濆瓨鏁版嵁搴撹繛鎺ラ厤缃�
+ public static void saveConnectConfigure() {
+ Map<String, Object> m = new HashMap<>();
+ m.put("url/api", "/api/connectionConfiguration/save-connectConfigure/v1");
+ m.put("~table~","product_sys_database_connection_config");
+ //m.put("uuid", "f7839460-2c5c-4edc-97bb-c4bc473e8c2b");//浼爑uid鏄慨鏀� 涓嶄紶鏂板
+ m.put("connect_name","杩炴帴鍚嶏紙娴嬭瘯锛�");
+ m.put("ip_address","127.0.0.1");
+ m.put("database_type","mysql");
+ m.put("port_number","3306");
+ m.put("database_name","dbname");
+ m.put("user_name","sa");
+ m.put("user_password","123456");
+
+ testPost(m);
+ }
+
+
+
+
+}
diff --git a/product-server-data-sync/src/test/java/com/product/data/sync/test/FunctionSyncTest.java b/product-server-data-sync/src/test/java/com/product/data/sync/test/FunctionSyncTest.java
new file mode 100644
index 0000000..2cf1f99
--- /dev/null
+++ b/product-server-data-sync/src/test/java/com/product/data/sync/test/FunctionSyncTest.java
@@ -0,0 +1,53 @@
+package com.product.data.sync.test;
+
+import com.alibaba.fastjson.JSONObject;
+import com.product.common.utils.HttpTest;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author: ZhouJie
+ * @date: 2021/8/30 15:47
+ * @description:
+ */
+
+public class FunctionSyncTest extends HttpTest {
+
+ public static void main(String[] args) {
+ //getConnct();
+ getTree();
+
+ }
+ public static void getConnct() {
+ Map<String, Object> m = new HashMap<>();
+ m.put("url/api", "/api/functionsync/get-connect/v1");
+ m.put("~table~","product_sys_database_sync_function");
+ //m.put("uuid", "5507c128-368b-4143-a4e1-7e81aeac349d");//浼爑uid鏄慨鏀� 涓嶄紶鏂板
+ m.put("type","mysql");
+ m.put("IP","192.168.0.200");
+ m.put("database_name","product_product_db-dev");
+ m.put("port","3306");
+ m.put("username","root");
+ m.put("password","root123");
+ m.put("instance","");
+
+ testPost(m);
+ }
+
+
+ public static void getTree() {
+ Map<String, Object> m = new HashMap<String, Object>();
+ String str = "{\"product_sys_function_permission\":[{\"function_uuid\":\"4698b03b-a2ae-4bd6-827f-020689c88673\",\"button_uuid\":\"61e5834d-82dd-43a3-afc6-02f729552878,957dc120-a18b-4165-a3c5-1ca65281cab8,9d32d005-7f0d-4fd7-8469-498f67ff5231\"},{\"function_uuid\":\"f341b8e2-02e4-4012-83fe-c83d2b6b975e\",\"button_uuid\":\"703b223f-ae01-41c0-9b98-f1327f6eb038,d15ff74f-da0d-4eba-bc31-a6f2596b5289,3d078133-5555-42bb-850e-7c9974c61081\"},{\"function_uuid\":\"97779f8b-9657-47e7-8915-2f51113210fe\",\"button_uuid\":\"8631353f-1c1d-4d63-a620-c3b36e915bf1,8a3596c5-181f-4681-a47a-f7b7f966331e,d694dd23-1180-4622-a510-76a238c0be2e\"}],\"client_tel_area_code\":\"0825\",\"~table~\":\"product_sys_clients\",\"product_sys_client_language\":[{\"is_default_language\":0,\"~table~\":\"product_sys_client_language\",\"client_language_code\":\"绻佷綋涓枃\"},{\"is_default_language\":0,\"~table~\":\"product_sys_client_language\",\"client_language_code\":\"绠�浣撲腑鏂嘰"},{\"is_default_language\":1,\"~table~\":\"product_sys_client_language\",\"client_language_code\":\"English\"}],\"client_address_line_one\":\"18302888785\",\"light_mode_icon\":[{}],\"client_containers\":[{\"talbe_name\":\"product_sys_prompt\"},{\"talbe_name\":\"product_sys_products\"},{\"talbe_name\":\"product_sys_modules\"},{\"talbe_name\":\"product_sys_clients\"},{\"talbe_name\":\"product_sys_client_language\"},{\"talbe_name\":\"product_sys_params_setting\"},{\"talbe_name\":\"product_sys_message_template\"},{\"talbe_name\":\"product_sys_timed_task\"},{\"talbe_name\":\"product_sys_company_exchange_rate\"},{\"talbe_name\":\"product_sys_company_time_zone\"},{\"talbe_name\":\"product_sys_password_security\"},{\"talbe_name\":\"product_sys_company_property\"},{\"talbe_name\":\"product_sys_timed_task_log\"}],\"client_address_country_id\":\"30\",\"token\":\"eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJhZG1pbiIsImlhdCI6MTU5MjU0NjI2Niwic3ViIjoic2hpX2Nob25nZnVAMTYzLmNvbSIsImlzcyI6Ind3dy5tcmMuY29tIiwiZXhwIjoxNTkyNjE4MjY2fQ.5AS-IXKuExqoh1xFRYP6DWx-_uCtAwiB8pmqeCwOKPY\",\"client_address_zip_code\":\"621556558\",\"copy_client_uuid\":\"06f959c8-4f41-407c-9bcc-8137a8b22f50\",\"client_address_line_two\":\"18302888785\",\"product_sys_client_whitelist_email\":[{\"~table~\":\"product_sys_client_whitelist_email\",\"client_whitelist_email\":\"18302888785@qq.com\"}],\"copy_org_level_uuid\":\"06f959c8-4f41-407c-9bcc-8137a8b22f50\",\"client_address_line_three\":\"18302888785\",\"client_short_code\":\"6656150\",\"client_browser\":\"18302888785\",\"client_industry\":\"\",\"client_address_city_id\":\"20\",\"product_sys_client_contacts\":[{\"client_contact_phone_number\":\"18302888785\",\"contact_middle_name\":\"sasa\",\"client_contact_email\":\"18302888785@qq.com\",\"contact_job_position\":\"涓庨偅涓猏",\"client_contact_phone_area_code\":\"082\",\"contact_preferred_name\":\"18302888785\",\"~table~\":\"product_sys_client_contacts\",\"client_contact_company_phone\":\"18302888785\",\"client_contact_company_area_code\":\"081\",\"contact_last_name\":\"sasa\",\"contact_first_name\":\"sas\",\"client_contact_status\":\"0\"}],\"client_remark\":\"18302888785\",\"client_tel\":\"18302888785\",\"client_name\":\"鐪媔濂藉搰\"}";
+ str = "{\"IP\":\"192.168.0.200\",\"port\":\"3306\",\"username\":\"root\",\"password\":\"root123\",\"type\":\"mysql\",\"database_name\":\"product_product_db-dev\",\"~table~\":\"product_sys_functions\"}";
+ m = JSONObject.parseObject(str);
+ m.put("url/api", "/api/functionsync/get-synctree/v1");
+ m.put("~table~", "product_sys_functions");
+
+ testPost(m);
+ }
+
+
+}
diff --git a/product-server-data-sync/src/test/java/com/product/data/sync/test/SyFeDataTest.java b/product-server-data-sync/src/test/java/com/product/data/sync/test/SyFeDataTest.java
new file mode 100644
index 0000000..3d79c9b
--- /dev/null
+++ b/product-server-data-sync/src/test/java/com/product/data/sync/test/SyFeDataTest.java
@@ -0,0 +1,29 @@
+package com.product.data.sync.test;
+
+import com.product.common.utils.HttpTest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class SyFeDataTest extends HttpTest {
+ public static void main(String[] args) {
+ saveSyncFedata();
+
+ }
+ public static void saveSyncFedata() {
+ Map<String, Object> m = new HashMap<>();
+ m.put("url/api", "/api/syncfe/sy-oracle-fun/v1");
+ m.put("~table~","product_sys_functions");
+ //m.put("uuid", "5507c128-368b-4143-a4e1-7e81aeac349d");//浼爑uid鏄慨鏀� 涓嶄紶鏂板
+// m.put("type","oracle");
+// m.put("IP","127.0.0.1");
+// m.put("port","1521");
+// m.put("username","fe_base5");
+// m.put("password","fe123");
+// //021-013-000
+// m.put("tricode_fun","021-013-000,006-009-000,007-004-000,505-004-000,044-008-001,003-006-000");//闇�瑕佽绉绘鐨勫姛鑳界紪鐮�
+// m.put("module_uuid","9bb14c2f-9e02-4965-af58-109849259ee1");//
+ testPost(m);
+ System.out.println("");
+ }
+}
diff --git a/product-server-data-sync/src/test/java/com/product/data/sync/test/SyncConfigTest.java b/product-server-data-sync/src/test/java/com/product/data/sync/test/SyncConfigTest.java
new file mode 100644
index 0000000..6c3a649
--- /dev/null
+++ b/product-server-data-sync/src/test/java/com/product/data/sync/test/SyncConfigTest.java
@@ -0,0 +1,95 @@
+package com.product.data.sync.test;
+
+import com.alibaba.fastjson.JSONObject;
+import com.product.common.utils.HttpTest;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author: ZhouJie
+ * @date: 2021/8/12 9:29
+ * @description:
+ */
+
+public class SyncConfigTest extends HttpTest {
+ private static String URL_STRING[] = {
+ "jdbc:informix-sqli://localhost:9092/test:informixserver=demores",
+// "jdbc:ids://9.123.147.100:10000/sysmaster"
+ };
+ private static String USER = "informix";
+ private static String PASSWORD = "123456";
+
+ public static void main(String[] args) {
+ try {
+ connectInForMix();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+// saveSync();
+// delSync();
+ }
+
+ //淇濆瓨鏁版嵁搴撳悓姝ラ厤缃�
+ public static void saveSync() {
+ Map<String, Object> m = new HashMap<>();
+ m.put("url/api", "/api/sync/save-syncconfig/v1");
+ m.put("~table~", "product_sys_database_sync_config");
+ //m.put("uuid", "5507c128-368b-4143-a4e1-7e81aeac349d");//浼爑uid鏄慨鏀� 涓嶄紶鏂板
+ m.put("database_config_uuid", "test002-sdfqwe45w-4jhn4n-qweqwe");
+ m.put("corn", "0/10 * * * * ?");
+
+ List sub = new ArrayList();
+ Map sub1 = new HashMap();
+ sub1.put("created_by", "100");
+ sub1.put("created_utc_datetime", "2021-08-13 09:00:09");
+ sub1.put("updated_by", "100");
+ sub1.put("updated_utc_datetime", "2021-08-13 09:00:09");
+ sub1.put("org_level_uuid", "test801021test002");
+ sub.add(sub1);
+ m.put("product_sys_database_sync_config_sub", sub);
+ System.out.println(new JSONObject(m).toJSONString());
+
+ testPost(m);
+ }
+
+ //鍒犻櫎鏁版嵁搴撳悓姝ラ厤缃�
+ public static void delSync() {
+ Map<String, Object> m = new HashMap<>();
+ m.put("url/api", "/api/sync/delete-syncconfig/v1");
+ m.put("~table~", "product_sys_database_sync_config");
+ m.put("uuid", "7b9be61c-c15e-4915-b1fd-d7f4ee9b9134,414315de-59c6-4d87-ae7e-b4ef30c20ca3");
+
+ }
+
+ public static void connectInForMix() throws ClassNotFoundException {
+ Connection conn;
+ Class.forName("com.informix.jdbc.IfxDriver");
+// Class.forName("com.ibm.db2.jcc.DB2Driver");
+ try {
+ System.out.println("Testing JDBC URL: " + URL_STRING[0]);
+ conn = DriverManager.getConnection(URL_STRING[0], USER, PASSWORD);
+ Integer num = 0;
+ for (int j = 0; j < 50; j++) {
+ StringBuffer insertSql = new StringBuffer();
+ for (int i = 0; i < 1000; i++) {
+ insertSql.append(" INSERT INTO test_project(name,money,describe)VALUES");
+ insertSql.append("('name").append(i).append("',").append(i).append(",'").append("describe").append(i).append("');");
+ }
+ PreparedStatement ps = conn.prepareStatement(insertSql.toString());
+
+ num = num + ps.executeUpdate();
+ }
+ System.out.println("鏂板鏁版嵁" + num + "鏉°��");
+ conn.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return;
+ }
+}
diff --git a/product-server-web/pom.xml b/product-server-web/pom.xml
index fd5e793..6c89e87 100644
--- a/product-server-web/pom.xml
+++ b/product-server-web/pom.xml
@@ -21,29 +21,46 @@
<activation>
<activeByDefault>true</activeByDefault>
</activation>
+
</profile>
+
<profile>
<id>test</id>
<properties>
<profileActive>test</profileActive>
</properties>
</profile>
+
<profile>
<id>prod</id>
<properties>
<profileActive>prod</profileActive>
</properties>
</profile>
+
</profiles>
<dependencies>
+ <!--瑗垮畞鎴跨灞�涓氬姟妯″潡-->
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-xining</artifactId>
+ </dependency>
+ <!--閫氱敤妯″潡锛坲til)-->
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-common</artifactId>
</dependency>
+ <!--鏁版嵁婧�-->
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-datasource</artifactId>
+ </dependency>
+ <!--鎵撳嵃锛坵ord鏇挎崲锛�-->
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-print</artifactId>
</dependency>
+ <!--util-->
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-util</artifactId>
@@ -69,59 +86,57 @@
<groupId>com.lx</groupId>
<artifactId>product-server-mq</artifactId>
</dependency>
+ <!--闄勪欢绠$悊銆佹枃妗g鐞�-->
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-file</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.lx</groupId>
- <artifactId>product-server-email</artifactId>
</dependency>
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-lucene</artifactId>
</dependency>
- <!-- release -->
+ <!-- releases -->
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-core</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
- <groupId>com.sendgrid</groupId>
- <artifactId>sendgrid-java</artifactId>
- <version>4.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-collections4</artifactId>
- <version>4.1</version>
</dependency>
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-report</artifactId>
</dependency>
+ <!--鏁版嵁瀵煎叆瀵煎嚭-->
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-data-export-import</artifactId>
</dependency>
-
+ <!--寮�鍙戝伐鍏�-->
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-tool-dev</artifactId>
+ </dependency>
+ <!--娴佺▼寤烘ā-->
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-tool-flow</artifactId>
</dependency>
+ <!--鍔熻兘寤烘ā-->
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-tool-mvc</artifactId>
</dependency>
+ <!-- 琛ㄥ崟寤烘ā-->
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-tool-face</artifactId>
</dependency>
+ <!--鏁版嵁寤烘ā-->
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-tool-table</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-data-sync</artifactId>
</dependency>
<dependency>
<groupId>com.lx</groupId>
@@ -143,11 +158,18 @@
<groupId>com.lx</groupId>
<artifactId>product-server-data-center</artifactId>
</dependency>
- <dependency>
- <groupId>org.spring</groupId>
- <artifactId>spring-server-master</artifactId>
- <version>1.2.6.6</version>
- </dependency>
+
+ <!--椤圭洰绠$悊妯″潡-->
+ <!-- <dependency>-->
+ <!-- <groupId>com.lx</groupId>-->
+ <!-- <artifactId>product-project-server-base</artifactId>-->
+ <!-- <version>1.0.0-SNAPSHOT</version>-->
+ <!-- </dependency>-->
+ <!-- <dependency>-->
+ <!-- <groupId>com.lx</groupId>-->
+ <!-- <artifactId>product-project-server-contract</artifactId>-->
+ <!-- <version>1.0.0-SNAPSHOT</version>-->
+ <!-- </dependency>-->
<dependency>
<groupId>com.lx</groupId>
<artifactId>product-server-customer</artifactId>
@@ -157,8 +179,19 @@
<artifactId>product-server-task</artifactId>
</dependency>
<dependency>
- <groupId>com.lx</groupId>
- <artifactId>product-server-xining</artifactId>
+ <groupId>org.spring</groupId>
+ <artifactId>spring-server-master</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sendgrid</groupId>
+ <artifactId>sendgrid-java</artifactId>
+ <version>4.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
+ <version>4.1</version>
</dependency>
</dependencies>
<build>
@@ -276,12 +309,12 @@
<goal>run</goal>
</goals>
<configuration>
- <target description="run the bat">
+ <!-- <target description="run the bat">
<echo>寮�濮嬭繍琛宲acked.bat鍛戒护琛�</echo>
- <exec dir="D:/product/lxworkspaces/product-web" executable="cmd.exe">
+ <exec dir="D:/product/lxworkspaces/product-web" executable="cmd.exe">
<arg line="packed.bat"></arg>
</exec>
- </target>
+ </target> -->
</configuration>
</execution>
</executions>
@@ -295,15 +328,15 @@
<id>copy</id>
<phase>package</phase>
<configuration>
- <!--
<tasks>
- <copy todir="D:/product/lxworkspaces/product-server-install/resources/product-server/lib">
+ <copy todir="D:/product/workspace/product-server-install/resources/product-server/lib">
<fileset dir="${project.build.directory}/lib">
<include name="*.jar"/>
<exclude name="product-server-core-1.0.0-SNAPSHOT.jar"/>
+ <exclude name="product-server-core-2.0.0-SNAPSHOT.jar"/>
</fileset>
</copy>
- <copy todir="D:/product/lxworkspaces/product-server-install/resources/product-server/resources">
+ <copy todir="D:/product/workspace/product-server-install/resources/product-server/resources">
<fileset dir="${project.build.directory}/resources">
<include name="application-prod.properties"/>
<include name="cache-prod.properties"/>
@@ -311,16 +344,16 @@
<include name="*.xml"/>
</fileset>
</copy>
- <copy todir="D:/product/lxworkspaces/product-server-install/resources/product-server/web">
- <fileset dir="D:/product/lxworkspaces/product-web/dist">
- <include name="*.*"/>
- </fileset>
- </copy>
- <copy file="${project.build.directory}/product-server-web-1.0.0-SNAPSHOT.jar"
- tofile="D:/product/lxworkspaces/product-server-install/resources/product-server/product-server-web-1.0.0-SNAPSHOT.jar"
+ <!-- <copy todir="D:/product/workspace/product-server-install/resources/product-server/webapp/web">-->
+ <!-- <fileset dir="D:/product/workspace3.0/WEB/V3.0.0/dist">-->
+ <!-- <include name="*.*"/>-->
+ <!-- </fileset>-->
+ <!-- </copy>-->
+ <copy file="${project.build.directory}/product-server-web-2.0.0-release.jar"
+ tofile="D:/product/workspace/product-server-install/resources/product-server/product-server-web-2.0.0-release.jar"
overwrite="true"/>
</tasks>
- -->
+
</configuration>
<goals>
<goal>run</goal>
diff --git a/product-server-web/src/main/java/com/product/Application.java b/product-server-web/src/main/java/com/product/Application.java
index b79b3b9..27e7d81 100644
--- a/product-server-web/src/main/java/com/product/Application.java
+++ b/product-server-web/src/main/java/com/product/Application.java
@@ -3,7 +3,6 @@
import com.product.core.spring.context.SpringBeanUtil;
import com.product.customer.service.CreateSignatureFile;
import com.product.file.util.PdfConcurrenceUtil;
-
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
diff --git a/product-server-web/src/main/resources/application-dev.properties b/product-server-web/src/main/resources/application-dev.properties
index a3db447..e3261a5 100644
--- a/product-server-web/src/main/resources/application-dev.properties
+++ b/product-server-web/src/main/resources/application-dev.properties
@@ -1,84 +1,85 @@
#======================================#
-#=============\u7cfb\u7edf\u53c2\u6570 \u76f8\u5173\u914d\u7f6e==============#
+#=============\u7CFB\u7EDF\u53C2\u6570 \u76F8\u5173\u914D\u7F6E==============#
#======================================#
-#\u4e0a\u4f20\u6587\u4ef6\u8def\u5f84,\u7edd\u5bf9
-#\u542f\u7528\u65e5\u5fd7\u6253\u5370
+#\u4E0A\u4F20\u6587\u4EF6\u8DEF\u5F84,\u7EDD\u5BF9
+#\u542F\u7528\u65E5\u5FD7\u6253\u5370
logger.isEnable=true
-#\u65e5\u5fd7\u6253\u5370\u6307\u5b9a\u63a5\u53e3\uff0c*\u8868\u793a\u5168\u90e8\u6253\u5370\uff0c\u7a7a\u8868\u793a\u5168\u90e8\u4e0d\u6253\u5370\uff0c\u6307\u5b9a\u591a\u4e2a\u63a5\u53e3\u9017\u53f7\u5206\u9694
+#\u65E5\u5FD7\u6253\u5370\u6307\u5B9A\u63A5\u53E3\uFF0C*\u8868\u793A\u5168\u90E8\u6253\u5370\uFF0C\u7A7A\u8868\u793A\u5168\u90E8\u4E0D\u6253\u5370\uFF0C\u6307\u5B9A\u591A\u4E2A\u63A5\u53E3\u9017\u53F7\u5206\u9694
logger.print.api=*
-#\u662f\u5426\u7acb\u5373\u6253\u5370\uff0cfalse\uff1a\u63a5\u53e3\u6700\u540e\u4e00\u6b21\u6027\u6253\u5370 true\uff1a\u8c03\u7528\u5373\u6253\u5370
+#\u662F\u5426\u7ACB\u5373\u6253\u5370\uFF0Cfalse\uFF1A\u63A5\u53E3\u6700\u540E\u4E00\u6B21\u6027\u6253\u5370 true\uFF1A\u8C03\u7528\u5373\u6253\u5370
logger.print.isAtOnce=true
-#\u662f\u5426\u542f\u7528\u767b\u5f55\u63a5\u53e3\u7528\u6237\u540d\u5bc6\u7801\u52a0\u5bc6
+#\u662F\u5426\u542F\u7528\u767B\u5F55\u63A5\u53E3\u7528\u6237\u540D\u5BC6\u7801\u52A0\u5BC6
login.ecc.isEnable=true
-#\u662f\u5426\u542f\u7528\u63a5\u53e3\u7b7e\u540d\u8ba4\u8bc1
+#\u662F\u5426\u542F\u7528\u63A5\u53E3\u7B7E\u540D\u8BA4\u8BC1
signature.isEnable=true
-#\u5728\u542f\u7528\u63a5\u53e3\u7b7e\u540d\u8ba4\u8bc1\u65f6\uff0c\u6392\u9664\u6307\u5b9a\u63a5\u53e3\u65e0\u9700\u7b7e\u540d\u8ba4\u8bc1
-signature.exclude.path=/api/rsa/getKey/v1,/api/token/refresh/v1,/api/mobile/network/check/v1,/api/system/config/info/v1,/api/fileManager/get-static-file,/static/**
-#\u7b7e\u540d\u8ba4\u8bc1Key
+#\u5728\u542F\u7528\u63A5\u53E3\u7B7E\u540D\u8BA4\u8BC1\u65F6\uFF0C\u6392\u9664\u6307\u5B9A\u63A5\u53E3\u65E0\u9700\u7B7E\u540D\u8BA4\u8BC1
+signature.exclude.path=/api/rsa/getKey/v1,/api/token/refresh/v1,/api/mobile/network/check/v1,/api/system/config/info/v1,/api/fileManager/get-static-file,/static/**,/api/system-user/avatar/v1/*,/api/office/save-office/v1
+#\u7B7E\u540D\u8BA4\u8BC1Key
signature.key=299cb5bb4c9040a29c58304c25001d72
-#\u63a5\u53e3\u7b7e\u540d\u8ba4\u8bc1\u6709\u6548\u671f\uff0c\u5355\u4f4d\u79d2,0\u8868\u793a\u4e0d\u9a8c\u8bc1
+#\u63A5\u53E3\u7B7E\u540D\u8BA4\u8BC1\u6709\u6548\u671F\uFF0C\u5355\u4F4D\u79D2,0\u8868\u793A\u4E0D\u9A8C\u8BC1
signature.expire=0
-#token\u8fc7\u671f\u65f6\u95f4\uff0c\u5c0f\u65f6 6\u5206\u949f
+#token\u8FC7\u671F\u65F6\u95F4\uFF0C\u5C0F\u65F6 6\u5206\u949F
token.expiration=1000
-#\u5fd8\u8bb0\u5bc6\u7801\u90ae\u4ef6\u4e2dToken\u7684\u8fc7\u671f\u65f6\u95f4
+#\u5FD8\u8BB0\u5BC6\u7801\u90AE\u4EF6\u4E2DToken\u7684\u8FC7\u671F\u65F6\u95F4
mail.token.expiration=1
-#\u63a5\u53e3token\u8fc7\u671f\uff0c\u5237\u65b0token\u7684\u63a5\u53e3\u4f7f\u7528\u7684Token\u8fc7\u671f\u65f6\u95f4
+#\u63A5\u53E3token\u8FC7\u671F\uFF0C\u5237\u65B0token\u7684\u63A5\u53E3\u4F7F\u7528\u7684Token\u8FC7\u671F\u65F6\u95F4
refresh.token.expiration=12
-#token\u9a8c\u8bc1\u3001\u767b\u5f55\u9a8c\u8bc1\uff0c\u6392\u9664URL,\u9017\u53f7\u5206\u9694
+#token\u9A8C\u8BC1\u3001\u767B\u5F55\u9A8C\u8BC1\uFF0C\u6392\u9664URL,\u9017\u53F7\u5206\u9694
token.exclude.path=/api/token/refresh/v1,/login,/login/v1,/api/personalcenter/send-updatePwdEmail/v1,/api/language/login-language/v1,/api/lable_internationalization/list_lable_internation/v1,/api/lable_internationalization/list-label-internation-web/v1,/api/personalcenter/check-token/v1,/api/rsa/getKey/v1,/api/mobile/network/check/v1,/api/system/config/info/v1,/api/fileManager/get-static-file,/static/**
-#\u662f\u5426\u542f\u7528\u6570\u636e\u64cd\u4f5c\u6743\u9650\u9a8c\u8bc1!
+#\u662F\u5426\u542F\u7528\u6570\u636E\u64CD\u4F5C\u6743\u9650\u9A8C\u8BC1!
data.handle.valid.isEnable=false
-#\u662f\u5426\u542f\u7528\u529f\u80fd\u6743\u9650\u9a8c\u8bc1
+#\u662F\u5426\u542F\u7528\u529F\u80FD\u6743\u9650\u9A8C\u8BC1
url.valid.isEnable=false
-#\u4e0d\u9700\u8981\u6743\u9650\u9a8c\u8bc1\u63a5\u53e3\u5730\u5740,\u4e0d\u80fd\u914d/v1\u3001v2\u7b49
+#\u4E0D\u9700\u8981\u6743\u9650\u9A8C\u8BC1\u63A5\u53E3\u5730\u5740,\u4E0D\u80FD\u914D/v1\u3001v2\u7B49
url.valid.pass=/api/prompt/business/findPrompt,/api/dictionary/list-dictionary-byname,/logout,/api/functions/onload-button,/api/language/login-language/v1,/api/fileManager/get-file-info,/api/language/list-international-fields,/api/user/language/update-language,/api/staff-manager/upload_staff_avatar,api/rsa/getKey,/api/mobile/network/check,/api/system/config/info,/api/fileManager/get-static-file,/static/**
-#\u662f\u5426\u6253\u5370\u9519\u8bef\u4fe1\u606f
+#\u662F\u5426\u6253\u5370\u9519\u8BEF\u4FE1\u606F
info.print=true
error.info.print=true
-#\u662f\u5426\u6253\u5370\u9519\u8bef\u5806\u690e\u4fe1\u606f
+#\u662F\u5426\u6253\u5370\u9519\u8BEF\u5806\u690E\u4FE1\u606F
error.stack.trace.print=true
-#\u662f\u5426\u4fdd\u5b58\u9519\u8bef\u4fe1\u606f
+#\u662F\u5426\u4FDD\u5B58\u9519\u8BEF\u4FE1\u606F
error.info.save=true
-#\u662f\u5426\u542f\u7528SQL\u76d1\u63a7,\u9ed8\u8ba4\u4e0d\u542f\u7528,\u662f\u5426\u5728\u540e\u53f0\u6253\u5370sql\u8bed\u53e5
+#\u662F\u5426\u542F\u7528SQL\u76D1\u63A7,\u9ED8\u8BA4\u4E0D\u542F\u7528,\u662F\u5426\u5728\u540E\u53F0\u6253\u5370sql\u8BED\u53E5
isMonitorSQL=true
-#\u67e5\u8be2\u65f6\u95f4\u8d85\u8fc7\u591a\u5c11\u79d2\u7684sql\u8bed\u53e5\u8bb0\u5f55\u5230\u5206\u6790\u6570\u636e\u5e93\u4e2d\uff0c\u65f6\u95f4\u5355\u4f4d\uff1a\u79d2
+#\u67E5\u8BE2\u65F6\u95F4\u8D85\u8FC7\u591A\u5C11\u79D2\u7684sql\u8BED\u53E5\u8BB0\u5F55\u5230\u5206\u6790\u6570\u636E\u5E93\u4E2D\uFF0C\u65F6\u95F4\u5355\u4F4D\uFF1A\u79D2
monitorSQLTime=3
-#\u662f\u5426\u542f\u7528\u7cfb\u7edf\u54cd\u5e94
+#\u662F\u5426\u542F\u7528\u7CFB\u7EDF\u54CD\u5E94
isMonitorRequest=false
-#\u7cfb\u7edf\u54cd\u5e94\u65f6\u95f4\u8d85\u8fc7\u591a\u5c11\u79d2\uff0c\u8bb0\u5f55\u5230\u76d1\u63a7\u6570\u636e\u5e93\u4e2d
+#\u7CFB\u7EDF\u54CD\u5E94\u65F6\u95F4\u8D85\u8FC7\u591A\u5C11\u79D2\uFF0C\u8BB0\u5F55\u5230\u76D1\u63A7\u6570\u636E\u5E93\u4E2D
monitorRequestTime=4
-#\u56fe\u5f62\u9a8c\u8bc1\u7801\u751f\u6210\u7684\u56fe\u7247\u8def\u5f84
+#\u56FE\u5F62\u9A8C\u8BC1\u7801\u751F\u6210\u7684\u56FE\u7247\u8DEF\u5F84
#upload.file.temp.path=./lx_file/aptcha
-#\u4e0b\u62c9\u9009\u62e9\u663e\u793a\u6761\u6570
+#\u4E0B\u62C9\u9009\u62E9\u663E\u793A\u6761\u6570
prompt.show.rows=20
-#\u662f\u5426\u4fdd\u5b58\u501f\u8bef\u4fe1\u606f
+#\u662F\u5426\u4FDD\u5B58\u501F\u8BEF\u4FE1\u606F
error.message.save=true
-#\u4e0a\u4f20\u6587\u4ef6\u5b58\u653e\u76ee\u5f55
+#\u4E0A\u4F20\u6587\u4EF6\u5B58\u653E\u76EE\u5F55
upload.file.path=./attachment/upload
-#license\u6587\u4ef6\u8def\u5f84
+#license\u6587\u4EF6\u8DEF\u5F84
license.path=./resources
-#\u4e0a\u4f20\u6587\u4ef6\u5b58\u653e\u4e34\u65f6\u76ee\u5f55
+#\u4E0A\u4F20\u6587\u4EF6\u5B58\u653E\u4E34\u65F6\u76EE\u5F55
upload.file.temp.path=./attachment/temp
-#\u4e0a\u4f20\u5355\u4e2a\u6587\u4ef6\u5927\u5c0f(\u9ed8\u8ba41M)
+#\u4E0A\u4F20\u5355\u4E2A\u6587\u4EF6\u5927\u5C0F(\u9ED8\u8BA41M)
upload.file.max.size=1048576
-#\u4e0a\u4f20\u603b\u6587\u4ef6\u5927\u5c0f(\u9ed8\u8ba410M)
+#\u4E0A\u4F20\u603B\u6587\u4EF6\u5927\u5C0F(\u9ED8\u8BA410M)
upload.max.size=10485760
-#\u7cfb\u7edf\u7f13\u5b58\u5237\u65b0\u9891\u7387\uff0c\u6beb\u79d2
+#\u7CFB\u7EDF\u7F13\u5B58\u5237\u65B0\u9891\u7387\uFF0C\u6BEB\u79D2
cache.refresh.rate=6000
#======================================#
-#==============\u9ed8\u8ba4\u6570\u636e\u6e90\u8bbe\u7f6e ==============#
+#==============\u9ED8\u8BA4\u6570\u636E\u6E90\u8BBE\u7F6E ==============#
#======================================#
-#\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u7c7b\u578b druid\u3001c3p0
+#\u6570\u636E\u5E93\u8FDE\u63A5\u6C60\u7C7B\u578B druid\u3001c3p0
data.source.pool.type=druid
- data.source.name=default
+data.source.name=default
data.source.type=mysql
data.source.driver=com.mysql.jdbc.Driver
#################local###############################
#data.source.url=jdbc:mysql://222.209.31.230:9092/ch_kt_mes_apply?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useNewIO=true&useSSL=false&serverTimezone=Asia/Shanghai
#data.source.url=jdbc:mysql://127.0.0.1:3306/product_db_v2.0.0?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useNewIO=true&useSSL=false&serverTimezone=Asia/Shanghai
-data.source.url=jdbc:mysql://192.168.0.200:3308/product_db_xn?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useNewIO=true&useSSL=false&serverTimezone=Asia/Shanghai
+#data.source.url=jdbc:mysql://127.0.0.1:3308/product_db_xn?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useNewIO=true&useSSL=false&serverTimezone=Asia/Shanghai
#data.source.url=jdbc:mysql://localhost:3306/product_db_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useNewIO=true&useSSL=false&serverTimezone=Asia/Shanghai
#data.source.url=jdbc:mysql://192.168.0.200:3306/product_db_xn2?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useNewIO=true&useSSL=false&serverTimezone=Asia/Shanghai
+data.source.url=jdbc:mysql://10.0.0.21:3306/product_db_xn?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useNewIO=true&useSSL=false&serverTimezone=Asia/Shanghai
#data.source.url=jdbc:mysql://127.0.0.1:3306/product_db?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useNewIO=true&useSSL=false&serverTimezone=Asia/Shanghai
#data.source.url=jdbc:mysql://222.209.31.230:9092/product_db_v2.0.0?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useNewIO=true&useSSL=false&serverTimezone=Asia/Shanghai
#data.source.url=jdbc:mysql://64.145.32.26:3306/product_db_picc?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useNewIO=true&useSSL=false&serverTimezone=Asia/Shanghai
@@ -86,42 +87,42 @@
data.source.user=root
data.source.password=root123
##################local###############################
-#-------------------------druid\u8fde\u63a5\u6c60\u7684\u914d\u7f6e\u4fe1\u606f------------------------
-# \u521d\u59cb\u5316\u5927\u5c0f\uff0c\u6700\u5c0f\uff0c\u6700\u5927
+#-------------------------druid\u8FDE\u63A5\u6C60\u7684\u914D\u7F6E\u4FE1\u606F------------------------
+# \u521D\u59CB\u5316\u5927\u5C0F\uFF0C\u6700\u5C0F\uFF0C\u6700\u5927
druid.datasource.initialSize=5
-#\u6700\u5c0f\u8fde\u63a5\u6c60\u6570\u91cf
+#\u6700\u5C0F\u8FDE\u63A5\u6C60\u6570\u91CF
druid.datasource.minIdle=5
-#\u6700\u5927\u8fde\u63a5\u6c60\u6570\u91cf
+#\u6700\u5927\u8FDE\u63A5\u6C60\u6570\u91CF
druid.datasource.maxActive=200
-# \u914d\u7f6e\u83b7\u53d6\u8fde\u63a5\u7b49\u5f85\u8d85\u65f6\u7684\u65f6\u95f4 1\u5206\u949f
+# \u914D\u7F6E\u83B7\u53D6\u8FDE\u63A5\u7B49\u5F85\u8D85\u65F6\u7684\u65F6\u95F4 1\u5206\u949F
druid.datasource.maxWait=60000
-# \u914d\u7f6e\u95f4\u9694\u591a\u4e45\u624d\u8fdb\u884c\u4e00\u6b21\u68c0\u6d4b\uff0c\u68c0\u6d4b\u9700\u8981\u5173\u95ed\u7684\u7a7a\u95f2\u8fde\u63a5\uff0c\u5355\u4f4d\u662f\u6beb\u79d2 10\u5206\u949f\u5c0f\u65f6\u68c0\u67e5
+# \u914D\u7F6E\u95F4\u9694\u591A\u4E45\u624D\u8FDB\u884C\u4E00\u6B21\u68C0\u6D4B\uFF0C\u68C0\u6D4B\u9700\u8981\u5173\u95ED\u7684\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2 10\u5206\u949F\u5C0F\u65F6\u68C0\u67E5
druid.datasource.timeBetweenEvictionRunsMillis=600000
-# \u914d\u7f6e\u4e00\u4e2a\u8fde\u63a5\u5728\u6c60\u4e2d\u6700\u5c0f\u751f\u5b58\u7684\u65f6\u95f4\uff0c\u5355\u4f4d\u662f\u6beb\u79d2 \u8fde\u63a5\u4fdd\u6301\u7a7a\u95f2\u800c\u4e0d\u88ab\u9a71\u9010\u7684\u6700\u5c0f\u65f6\u95f4
+# \u914D\u7F6E\u4E00\u4E2A\u8FDE\u63A5\u5728\u6C60\u4E2D\u6700\u5C0F\u751F\u5B58\u7684\u65F6\u95F4\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2 \u8FDE\u63A5\u4FDD\u6301\u7A7A\u95F2\u800C\u4E0D\u88AB\u9A71\u9010\u7684\u6700\u5C0F\u65F6\u95F4
druid.datasource.minEvictableIdleTimeMillis=1800000
-#\u7528\u6765\u68c0\u6d4b\u8fde\u63a5\u662f\u5426\u6709\u6548\u7684sql\uff0c\u8981\u6c42\u662f\u4e00\u4e2a\u67e5\u8be2\u8bed\u53e5
+#\u7528\u6765\u68C0\u6D4B\u8FDE\u63A5\u662F\u5426\u6709\u6548\u7684sql\uFF0C\u8981\u6C42\u662F\u4E00\u4E2A\u67E5\u8BE2\u8BED\u53E5
druid.datasource.validationQuery=SELECT 1
-#\u5efa\u8bae\u914d\u7f6e\u4e3atrue\uff0c\u4e0d\u5f71\u54cd\u6027\u80fd\uff0c\u5e76\u4e14\u4fdd\u8bc1\u5b89\u5168\u6027\u3002\u7533\u8bf7\u8fde\u63a5\u7684\u65f6\u5019\u68c0\u6d4b\uff0c\u5982\u679c\u7a7a\u95f2\u65f6\u95f4\u5927\u4e8etimeBetweenEvictionRunsMillis\uff0c\u6267\u884cvalidationQuery\u68c0\u6d4b\u8fde\u63a5\u662f\u5426\u6709\u6548\u3002
+#\u5EFA\u8BAE\u914D\u7F6E\u4E3Atrue\uFF0C\u4E0D\u5F71\u54CD\u6027\u80FD\uFF0C\u5E76\u4E14\u4FDD\u8BC1\u5B89\u5168\u6027\u3002\u7533\u8BF7\u8FDE\u63A5\u7684\u65F6\u5019\u68C0\u6D4B\uFF0C\u5982\u679C\u7A7A\u95F2\u65F6\u95F4\u5927\u4E8EtimeBetweenEvictionRunsMillis\uFF0C\u6267\u884CvalidationQuery\u68C0\u6D4B\u8FDE\u63A5\u662F\u5426\u6709\u6548\u3002
druid.datasource.testWhileIdle=true
-#\u7533\u8bf7\u8fde\u63a5\u65f6\u6267\u884cvalidationQuery\u68c0\u6d4b\u8fde\u63a5\u662f\u5426\u6709\u6548\uff0c\u505a\u4e86\u8fd9\u4e2a\u914d\u7f6e\u4f1a\u964d\u4f4e\u6027\u80fd\u3002
+#\u7533\u8BF7\u8FDE\u63A5\u65F6\u6267\u884CvalidationQuery\u68C0\u6D4B\u8FDE\u63A5\u662F\u5426\u6709\u6548\uFF0C\u505A\u4E86\u8FD9\u4E2A\u914D\u7F6E\u4F1A\u964D\u4F4E\u6027\u80FD\u3002
druid.datasource.testOnBorrow=true
-#\u5f52\u8fd8\u8fde\u63a5\u65f6\u6267\u884cvalidationQuery\u68c0\u6d4b\u8fde\u63a5\u662f\u5426\u6709\u6548\uff0c\u505a\u4e86\u8fd9\u4e2a\u914d\u7f6e\u4f1a\u964d\u4f4e\u6027\u80fd\u3002
+#\u5F52\u8FD8\u8FDE\u63A5\u65F6\u6267\u884CvalidationQuery\u68C0\u6D4B\u8FDE\u63A5\u662F\u5426\u6709\u6548\uFF0C\u505A\u4E86\u8FD9\u4E2A\u914D\u7F6E\u4F1A\u964D\u4F4E\u6027\u80FD\u3002
druid.datasource.testOnReturn=false
-#\uff0c\u589e\u5f3atimeBetweenEvictionRunsMillis\u7684\u5468\u671f\u6027\u8fde\u63a5\u68c0\u67e5\uff0cminIdle\u5185\u7684\u7a7a\u95f2\u8fde\u63a5\uff0c\u6bcf\u6b21\u68c0\u67e5\u5f3a\u5236\u9a8c\u8bc1\u8fde\u63a5\u6709\u6548\u6027
+#\uFF0C\u589E\u5F3AtimeBetweenEvictionRunsMillis\u7684\u5468\u671F\u6027\u8FDE\u63A5\u68C0\u67E5\uFF0CminIdle\u5185\u7684\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u6BCF\u6B21\u68C0\u67E5\u5F3A\u5236\u9A8C\u8BC1\u8FDE\u63A5\u6709\u6548\u6027
druid.datasource.keepAlive=true
-#\u8fde\u63a5\u6cc4\u9732\u68c0\u67e5\uff0c\u6253\u5f00removeAbandoned\u529f\u80fd , \u8fde\u63a5\u4ece\u8fde\u63a5\u6c60\u501f\u51fa\u540e\uff0c\u957f\u65f6\u95f4\u4e0d\u5f52\u8fd8\uff0c\u5c06\u89e6\u53d1\u5f3a\u5236\u56de\u8fde\u63a5\u3002
-#\u56de\u6536\u5468\u671f\u968ftimeBetweenEvictionRunsMillis\u8fdb\u884c\uff0c\u5982\u679c\u8fde\u63a5\u4e3a\u4ece\u8fde\u63a5\u6c60\u501f\u51fa\u72b6\u6001\uff0c\u5e76\u4e14\u672a\u6267\u884c\u4efb\u4f55sql\uff0c\u5e76\u4e14\u4ece\u501f\u51fa\u65f6\u95f4\u8d77\u5df2\u8d85\u8fc7removeAbandonedTimeout\u65f6\u95f4\uff0c
-#\u5219\u5f3a\u5236\u5f52\u8fd8\u8fde\u63a5\u5230\u8fde\u63a5\u6c60\u4e2d\u3002
+#\u8FDE\u63A5\u6CC4\u9732\u68C0\u67E5\uFF0C\u6253\u5F00removeAbandoned\u529F\u80FD , \u8FDE\u63A5\u4ECE\u8FDE\u63A5\u6C60\u501F\u51FA\u540E\uFF0C\u957F\u65F6\u95F4\u4E0D\u5F52\u8FD8\uFF0C\u5C06\u89E6\u53D1\u5F3A\u5236\u56DE\u8FDE\u63A5\u3002
+#\u56DE\u6536\u5468\u671F\u968FtimeBetweenEvictionRunsMillis\u8FDB\u884C\uFF0C\u5982\u679C\u8FDE\u63A5\u4E3A\u4ECE\u8FDE\u63A5\u6C60\u501F\u51FA\u72B6\u6001\uFF0C\u5E76\u4E14\u672A\u6267\u884C\u4EFB\u4F55sql\uFF0C\u5E76\u4E14\u4ECE\u501F\u51FA\u65F6\u95F4\u8D77\u5DF2\u8D85\u8FC7removeAbandonedTimeout\u65F6\u95F4\uFF0C
+#\u5219\u5F3A\u5236\u5F52\u8FD8\u8FDE\u63A5\u5230\u8FDE\u63A5\u6C60\u4E2D\u3002
druid.datasource.removeAbandoned=true
-#\u8fde\u63a5\u56de\u6536\u7684\u8d85\u65f6\u65f6\u95f4\uff1b\u5355\u4f4d\u4e3a\u6beb\u79d2,5\u5206\u949f
+#\u8FDE\u63A5\u56DE\u6536\u7684\u8D85\u65F6\u65F6\u95F4\uFF1B\u5355\u4F4D\u4E3A\u6BEB\u79D2,5\u5206\u949F
druid.datasource.removeAbandonedTimeout=300000
-# \u6253\u5f00PSCache\uff0c\u5e76\u4e14\u6307\u5b9a\u6bcf\u4e2a\u8fde\u63a5\u4e0aPSCache\u7684\u5927\u5c0f
+# \u6253\u5F00PSCache\uFF0C\u5E76\u4E14\u6307\u5B9A\u6BCF\u4E2A\u8FDE\u63A5\u4E0APSCache\u7684\u5927\u5C0F
druid.datasource.poolPreparedStatements=true
-#\u662f\u5426\u7f13\u5b58preparedStatement\uff0c\u4e5f\u5c31\u662fPSCache\u3002PSCache\u5bf9\u652f\u6301\u6e38\u6807\u7684\u6570\u636e\u5e93\u6027\u80fd\u63d0\u5347\u5de8\u5927\uff0c\u6bd4\u5982\u8bf4oracle\u3002\u5728mysql\u4e0b\u5efa\u8bae\u5173\u95ed\u3002
+#\u662F\u5426\u7F13\u5B58preparedStatement\uFF0C\u4E5F\u5C31\u662FPSCache\u3002PSCache\u5BF9\u652F\u6301\u6E38\u6807\u7684\u6570\u636E\u5E93\u6027\u80FD\u63D0\u5347\u5DE8\u5927\uFF0C\u6BD4\u5982\u8BF4oracle\u3002\u5728mysql\u4E0B\u5EFA\u8BAE\u5173\u95ED\u3002
druid.datasource.maxPoolPreparedStatementPerConnectionSize=100
-# \u914d\u7f6e\u76d1\u63a7\u7edf\u8ba1\u62e6\u622a\u7684filters\uff0c\u53bb\u6389\u540e\u76d1\u63a7\u754c\u9762sql\u65e0\u6cd5\u7edf\u8ba1\uff0c'wall'\u7528\u4e8e\u9632\u706b\u5899
+# \u914D\u7F6E\u76D1\u63A7\u7EDF\u8BA1\u62E6\u622A\u7684filters\uFF0C\u53BB\u6389\u540E\u76D1\u63A7\u754C\u9762sql\u65E0\u6CD5\u7EDF\u8BA1\uFF0C'wall'\u7528\u4E8E\u9632\u706B\u5899
druid.datasource.filters=stat,wall,log4j
-# \u901a\u8fc7connectProperties\u5c5e\u6027\u6765\u6253\u5f00mergeSql\u529f\u80fd\uff1b\u6162SQL\u8bb0\u5f55
+# \u901A\u8FC7connectProperties\u5C5E\u6027\u6765\u6253\u5F00mergeSql\u529F\u80FD\uFF1B\u6162SQL\u8BB0\u5F55
druid.datasource.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
#======================================#
#========== Server settings ===========#
@@ -133,7 +134,7 @@
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8
-#\u8bbe\u7f6esession\u8d85\u65f6\u65f6\u95f4
+#\u8BBE\u7F6Esession\u8D85\u65F6\u65F6\u95F4
server.servlet.session.timeout=72000
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
#email
@@ -149,159 +150,172 @@
#parse_resume
parse_resume.username=u100220
parse_resume.password=
-#\u6307\u5b9a\u5730\u7406\u4f4d\u7f6e\u7684Path
+#\u6307\u5B9A\u5730\u7406\u4F4D\u7F6E\u7684Path
assign.geoPath=1,7
-# \u53d1\u9001\u90ae\u4ef6\u914d\u7f6e
+# \u53D1\u9001\u90AE\u4EF6\u914D\u7F6E
spring.mail.host=smtp.qq.com
spring.mail.port=465
spring.mail.username=929633676@qq.com
spring.mail.password=longxin665348
-#\u521b\u5efa\u8d26\u53f7\u521d\u59cb\u5bc6\u7801
+#\u521B\u5EFA\u8D26\u53F7\u521D\u59CB\u5BC6\u7801
initial.pwd=123456
-#\u91cd\u7f6e\u5bc6\u7801\u7684\u65b9\u5f0f(mail=\u5bc6\u7801\u53d1\u9001\u5230\u90ae\u4ef6,default=\u4e0d\u53d1\u9001\u90ae\u4ef6\uff0c\u9ed8\u8ba4\u521d\u59cb\u5bc6\u7801)
+#\u91CD\u7F6E\u5BC6\u7801\u7684\u65B9\u5F0F(mail=\u5BC6\u7801\u53D1\u9001\u5230\u90AE\u4EF6,default=\u4E0D\u53D1\u9001\u90AE\u4EF6\uFF0C\u9ED8\u8BA4\u521D\u59CB\u5BC6\u7801)
resetpwd.model=default
-#\u91cd\u7f6e\u5bc6\u7801url
-#\u7ba1\u7406\u5458\u8df3\u8f6c\u5730\u5740
+#\u91CD\u7F6E\u5BC6\u7801url
+#\u7BA1\u7406\u5458\u8DF3\u8F6C\u5730\u5740
resetpwd.lxurl=http://192.168.0.200:3000/#/reset-password
-#\u666e\u901a\u5458\u5de5\u8df3\u8f6c\u5730\u5740
+#\u666E\u901A\u5458\u5DE5\u8DF3\u8F6C\u5730\u5740
resetpwd.lxeurl=http://192.168.0.200:3000/#/reset-password
-#\u7ba1\u7406\u5458\u767b\u5f55\u5730\u5740
+#\u7BA1\u7406\u5458\u767B\u5F55\u5730\u5740
resetpwd.lxlogin_url=http://192.168.0.200:3000/#/login
-#\u5458\u5de5\u767b\u5f55\u5730\u5740
+#\u5458\u5DE5\u767B\u5F55\u5730\u5740
resetpwd.esslogin_url=http://192.168.0.200:3000/#/login
-#SendGrid\u8d26\u6237\u548c\u5bc6\u94a5
+#SendGrid\u8D26\u6237\u548C\u5BC6\u94A5
sendGrid.mail.user=no-reply@essencehr.io
sendGrid.mail.key=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
-#mailgun\u7cfb\u7edf\u90ae\u4ef6\u914d\u7f6e
+#mailgun\u7CFB\u7EDF\u90AE\u4EF6\u914D\u7F6E
mailgun.mail.user=mail.purtato.com
mailgun.mail.key=8d52b0a748b20c61331587fa9a3fe6fc-cb3791c4-8cf158ef
-#\u53bb\u9644\u4ef6\u5bb9\u5668\u7ba1\u7406\uff0c\u81ea\u52a8\u521b\u5efa\u5bb9\u5668\u7684\u63a5\u53e3\u5730\u5740,\u7ba1\u7406\u8d26\u53f7\u8fdb\u53bb\u751f\u6210
+#\u53BB\u9644\u4EF6\u5BB9\u5668\u7BA1\u7406\uFF0C\u81EA\u52A8\u521B\u5EFA\u5BB9\u5668\u7684\u63A5\u53E3\u5730\u5740,\u7BA1\u7406\u8D26\u53F7\u8FDB\u53BB\u751F\u6210
upload.url=https://lx.blob.core.windows.net/?sv=2019-12-12&ss=bfqt&srt=sco&sp=rwdlacupx&se=2026-09-01T15:26:10Z&st=2020-10-17T07:26:10Z&spr=https,http&sig=S8%2BKqeGPYfWHLUG5E2N99lY1MG4noWoTsWqp%2FUHBji0%3D
-#\u53bb\u9644\u4ef6\u5bb9\u5668\u7ba1\u7406\uff0c\u81ea\u52a8\u521b\u5efa\u5bb9\u5668\u7684\u4e0a\u4f20\u7684key\uff0c\u5728\u7ba1\u7406\u8d26\u53f7\u4e2d\u521b\u5efa
+#\u53BB\u9644\u4EF6\u5BB9\u5668\u7BA1\u7406\uFF0C\u81EA\u52A8\u521B\u5EFA\u5BB9\u5668\u7684\u4E0A\u4F20\u7684key\uFF0C\u5728\u7BA1\u7406\u8D26\u53F7\u4E2D\u521B\u5EFA
upload.key=?sv=2019-12-12&ss=bfqt&srt=sco&sp=rwdlacupx&se=2026-09-01T15:26:10Z&st=2020-10-17T07:26:10Z&spr=https,http&sig=S8%2BKqeGPYfWHLUG5E2N99lY1MG4noWoTsWqp%2FUHBji0%3D
upload.connection_string=DefaultEndpointsProtocol=https;AccountName=lx;AccountKey=ulFYmOyQUA+8K8M5JUgMs2heohRW1dIkkdLtbl9L1+60AY9ySIbx7uxVrMY5UAdu9fm6qhBaslyBlCgWGS+dUA==;EndpointSuffix=core.windows.net
-#\u6d88\u606f\u670d\u52a1\u5668\u5730\u5740\uff0c\u6b63\u5f0f\u670d\u52a1\u5668\u4e0d\u80fd\u914d\u7f6e\u6210127\uff0c\u5982\u679c\u53ea\u662f\u672c\u673a\u8bbf\u95ee\u53ef\u4ee5\u914d\u6210127
+#\u6D88\u606F\u670D\u52A1\u5668\u5730\u5740\uFF0C\u6B63\u5F0F\u670D\u52A1\u5668\u4E0D\u80FD\u914D\u7F6E\u6210127\uFF0C\u5982\u679C\u53EA\u662F\u672C\u673A\u8BBF\u95EE\u53EF\u4EE5\u914D\u6210127
message.server.ip=127.0.0.1
-#\u6d88\u606f\u670d\u52a1\u5668\u7aef\u53e3
+#\u6D88\u606F\u670D\u52A1\u5668\u7AEF\u53E3
message.server.port=9998
-#\u6587\u4ef6\u4e0a\u4f20
+#\u6587\u4EF6\u4E0A\u4F20
source_domain=https://www.baidu.com
default_domain=https://lx.blob.core.windows.net
-allowed_file_type=doc,docx,xls,xlsx,ppt,pptx,jpg,png,bmp,csv,pdf,txt,dat,wps,wpt,et,eet,p12
-# \u662f\u5426\u9700\u8981\u4e0a\u4f20\u5230\u6587\u4ef6\u670d\u52a1\u5668
+allowed_file_type=doc,docx,xls,xlsx,ppt,pptx,jpg,png,gif,bmp,csv,pdf,txt,dat,wps,wpt,et,eet,p12,rar,zip,7z,gd
+# \u662F\u5426\u9700\u8981\u4E0A\u4F20\u5230\u6587\u4EF6\u670D\u52A1\u5668
upload.server=false
-# \u662f\u5426\u9700\u8981\u6587\u4ef6\u52a0\u5bc6
+# \u662F\u5426\u9700\u8981\u6587\u4EF6\u52A0\u5BC6
file.encrypt=false
-# \u662f\u5426\u9700\u8981\u5728\u7ebf\u9884\u89c8
+# \u662F\u5426\u9700\u8981\u5728\u7EBF\u9884\u89C8
file.view.online=true
-# \u5141\u8bb8\u4e0d\u8ba4\u8bc1\u7684\u9759\u6001\u8d44\u6e90 tableName.fieldName \u591a\u4e2a\u9017\u53f7\u5206\u9694
+# \u5141\u8BB8\u4E0D\u8BA4\u8BC1\u7684\u9759\u6001\u8D44\u6E90 tableName.fieldName \u591A\u4E2A\u9017\u53F7\u5206\u9694
file.static=product_sys_app_nav_bar.nav_bar_img
-# \u6587\u4ef6\u670d\u52a1\u5668\u4fe1\u606f
+# \u6587\u4EF6\u670D\u52A1\u5668\u4FE1\u606F
ftp.server.ip=192.168.0.198
ftp.server.port=21
ftp.server.username=cheng
ftp.server.password=082600..
ftp.server.encode=utf-8
-# \u5728\u7ebf\u9884\u89c8\u8f6c\u6362\u670d\u52a1
-open.office.home=D:/worksoft/openoffice/home
+# \u5728\u7EBF\u9884\u89C8\u8F6C\u6362\u670D\u52A1
+open.office.isEnable=false
+open.office.home=D:/work/tool/OpenOffice 4
open.office.port.info=8100,8101
-# \u5355\u4e2a\u4efb\u52a1\u6267\u884c\u8d85\u65f6\u65f6\u95f4\uff0c\u5355\u4f4d\uff1a\u6beb\u79d2
+# \u5355\u4E2A\u4EFB\u52A1\u6267\u884C\u8D85\u65F6\u65F6\u95F4\uFF0C\u5355\u4F4D\uFF1A\u6BEB\u79D2
open.office.task.timeout=300000
-# \u5355\u4e2a\u4efb\u52a1\u6392\u961f\u8d85\u65f6\u65f6\u95f4\uff0c\u5355\u4f4d\uff1a\u6beb\u79d2
+# \u5355\u4E2A\u4EFB\u52A1\u6392\u961F\u8D85\u65F6\u65F6\u95F4\uFF0C\u5355\u4F4D\uFF1A\u6BEB\u79D2
open.office.queue.timeout=86400000
# \u672C\u5730\u4E34\u65F6\u8DEF\u5F84
temp.dir=./attachment/temp
# \u672C\u5730\u5B58\u653E\u8DEF\u5F84
local.dir=./attachment/upload
-
-# \u80fd\u591f\u8f6c\u6362\u7684\u683c\u5f0f
+# \u80FD\u591F\u8F6C\u6362\u7684\u683C\u5F0F
can.transfer.format=docx,doc,xlsx,xls,pptx,ppt,txt,wps
-# \u65e0\u9700\u8f6c\u6362\u80fd\u591f\u5728\u7ebf\u9884\u89c8\u7684\u683c\u5f0f
-can.direct.view.online.format=jpg,png,bmp,ico,html,pdf#\u5728\u7ebf\u7f16\u8f91\u662f\u5426\u5f00\u542f
-enable.online.edit=false
-# \u80fd\u5728\u7ebf\u7f16\u8f91\u7684\u6587\u4ef6\u683c\u5f0f
+# \u65E0\u9700\u8F6C\u6362\u80FD\u591F\u5728\u7EBF\u9884\u89C8\u7684\u683C\u5F0F
+can.direct.view.online.format=jpg,png,bmp,ico,html,pdf#\u5728\u7EBF\u7F16\u8F91\u662F\u5426\u5F00\u542F
+enable.online.edit=true
+# \u80FD\u5728\u7EBF\u7F16\u8F91\u7684\u6587\u4EF6\u683C\u5F0F
can.web.online.edit=doc,docx,xls,xlsx,ppt,pptx,wps,cvs,wps,wpt,et,eet
-#\u89c6\u56fe\u89e3\u6790\u5668\u914d\u7f6e
-#\u4e0d\u7f13\u5b58\u9875\u9762\uff08\u4fee\u6539\u4e86\u5c31\u80fd\u7acb\u9a6c\u751f\u6548\u4e0d\u7528\u91cd\u542f\uff09dev \u73af\u5883
+#\u89C6\u56FE\u89E3\u6790\u5668\u914D\u7F6E
+#\u4E0D\u7F13\u5B58\u9875\u9762\uFF08\u4FEE\u6539\u4E86\u5C31\u80FD\u7ACB\u9A6C\u751F\u6548\u4E0D\u7528\u91CD\u542F\uFF09dev \u73AF\u5883
spring.thymeleaf.cache=false
-#\u9759\u6001\u8d44\u6e90\u8def\u5f84
+#\u9759\u6001\u8D44\u6E90\u8DEF\u5F84
spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:/static/
##==============================================================
##Configure Main Scheduler Properties
##==============================================================
-##\u8c03\u5ea6\u6807\u8bc6\u540d \u96c6\u7fa4\u4e2d\u6bcf\u4e00\u4e2a\u5b9e\u4f8b\u90fd\u5fc5\u987b\u4f7f\u7528\u76f8\u540c\u7684\u540d\u79f0
+##\u8C03\u5EA6\u6807\u8BC6\u540D \u96C6\u7FA4\u4E2D\u6BCF\u4E00\u4E2A\u5B9E\u4F8B\u90FD\u5FC5\u987B\u4F7F\u7528\u76F8\u540C\u7684\u540D\u79F0
#spring.quartz.properties.org.quartz.scheduler.instanceName = QuartzScheduler
-## #ID\u8bbe\u7f6e\u4e3a\u81ea\u52a8\u83b7\u53d6 \u6bcf\u4e00\u4e2a\u5fc5\u987b\u4e0d\u540c. \u5982\u9700\u8981\u518d\u540c\u4e00\u53f0\u7535\u8111\u90e8\u7f72\u96c6\u7fa4 \u540c\u4e00\u53f0\u7535\u8111\u5b9a\u65f6\u4efb\u52a1\u914d\u7f6e\u7684instanceId \u4e0d\u80fd\u4e00\u6837\u3002
+## #ID\u8BBE\u7F6E\u4E3A\u81EA\u52A8\u83B7\u53D6 \u6BCF\u4E00\u4E2A\u5FC5\u987B\u4E0D\u540C. \u5982\u9700\u8981\u518D\u540C\u4E00\u53F0\u7535\u8111\u90E8\u7F72\u96C6\u7FA4 \u540C\u4E00\u53F0\u7535\u8111\u5B9A\u65F6\u4EFB\u52A1\u914D\u7F6E\u7684instanceId \u4E0D\u80FD\u4E00\u6837\u3002
#spring.quartz.properties.org.quartz.scheduler.instanceId = AUTO
#
##==============================================================
##Configure JobStore
##==============================================================
-##\u6570\u636e\u4fdd\u5b58\u65b9\u5f0f\u4e3a\u6570\u636e\u5e93\u6301\u4e45\u5316
+##\u6570\u636E\u4FDD\u5B58\u65B9\u5F0F\u4E3A\u6570\u636E\u5E93\u6301\u4E45\u5316
#spring.quartz.properties.org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
-##\u8868\u7684\u524d\u7f00\uff0c\u9ed8\u8ba4QRTZ_
+##\u8868\u7684\u524D\u7F00\uFF0C\u9ED8\u8BA4QRTZ_
#spring.quartz.properties.org.quartz.jobStore.tablePrefix = QRTZ_
-##\u6570\u636e\u5e93\u522b\u540d \u968f\u4fbf\u53d6
+##\u6570\u636E\u5E93\u522B\u540D \u968F\u4FBF\u53D6
#spring.quartz.properties.org.quartz.jobStore.dataSource = myDS
-##\u662f\u5426\u52a0\u5165\u96c6\u7fa4
+##\u662F\u5426\u52A0\u5165\u96C6\u7FA4
#spring.quartz.properties.org.quartz.jobStore.isClustered = true
-##\u8c03\u5ea6\u5b9e\u4f8b\u5931\u6548\u7684\u68c0\u67e5\u65f6\u95f4\u95f4\u9694
+##\u8C03\u5EA6\u5B9E\u4F8B\u5931\u6548\u7684\u68C0\u67E5\u65F6\u95F4\u95F4\u9694
#spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval = 1000
#spring.quartz.properties.org.quartz.jobStore.maxMisfiresToHandleAtATime = 20
-## \u4fe1\u606f\u4fdd\u5b58\u65f6\u95f4 \u9ed8\u8ba4\u503c60\u79d2
+## \u4FE1\u606F\u4FDD\u5B58\u65F6\u95F4 \u9ED8\u8BA4\u503C60\u79D2
#spring.quartz.properties.org.quartz.jobStore.misfireThreshold = 60000
#spring.quartz.properties.org.quartz.jobStore.txIsolationLevelSerializable = true
##==============================================================
##Configure ThreadPool
##==============================================================
-##\u7ebf\u7a0b\u6c60\u7684\u5b9e\u73b0\u7c7b\uff08\u4e00\u822c\u4f7f\u7528SimpleThreadPool\u5373\u53ef\u6ee1\u8db3\u51e0\u4e4e\u6240\u6709\u7528\u6237\u7684\u9700\u6c42\uff09
+##\u7EBF\u7A0B\u6C60\u7684\u5B9E\u73B0\u7C7B\uFF08\u4E00\u822C\u4F7F\u7528SimpleThreadPool\u5373\u53EF\u6EE1\u8DB3\u51E0\u4E4E\u6240\u6709\u7528\u6237\u7684\u9700\u6C42\uFF09
#spring.quartz.properties.org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
-##\u6307\u5b9a\u7ebf\u7a0b\u6570\uff0c\u81f3\u5c11\u4e3a1\uff08\u65e0\u9ed8\u8ba4\u503c\uff09(\u4e00\u822c\u8bbe\u7f6e\u4e3a1-100\u76f4\u63a5\u7684\u6574\u6570\u5408\u9002)
+##\u6307\u5B9A\u7EBF\u7A0B\u6570\uFF0C\u81F3\u5C11\u4E3A1\uFF08\u65E0\u9ED8\u8BA4\u503C\uFF09(\u4E00\u822C\u8BBE\u7F6E\u4E3A1-100\u76F4\u63A5\u7684\u6574\u6570\u5408\u9002)
#spring.quartz.properties.org.quartz.threadPool.threadCount = 20
-##\u8bbe\u7f6e\u7ebf\u7a0b\u7684\u4f18\u5148\u7ea7\uff08\u6700\u5927\u4e3ajava.lang.Thread.MAX_PRIORITY 10\uff0c\u6700\u5c0f\u4e3aThread.MIN_PRIORITY 1\uff0c\u9ed8\u8ba4\u4e3a5\uff09
+##\u8BBE\u7F6E\u7EBF\u7A0B\u7684\u4F18\u5148\u7EA7\uFF08\u6700\u5927\u4E3Ajava.lang.Thread.MAX_PRIORITY 10\uFF0C\u6700\u5C0F\u4E3AThread.MIN_PRIORITY 1\uFF0C\u9ED8\u8BA4\u4E3A5\uFF09
#spring.quartz.properties.org.quartz.threadPool.threadPriority = 5
#spring.quartz.properties.org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
##============================================================================
## Configure Datasources
##============================================================================
-##\u6570\u636e\u5e93\u4ee3\u7406\u7c7b\uff0c\u4e00\u822corg.quartz.impl.jdbcjobstore.StdJDBCDelegate\u53ef\u4ee5\u6ee1\u8db3\u5927\u90e8\u5206\u6570\u636e\u5e93
+##\u6570\u636E\u5E93\u4EE3\u7406\u7C7B\uFF0C\u4E00\u822Corg.quartz.impl.jdbcjobstore.StdJDBCDelegate\u53EF\u4EE5\u6EE1\u8DB3\u5927\u90E8\u5206\u6570\u636E\u5E93
#spring.quartz.properties.org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
#spring.quartz.properties.org.quartz.dataSource.myDS.driver =com.mysql.jdbc.Driver
#spring.quartz.properties.org.quartz.dataSource.myDS.URL = jdbc:mysql://192.168.0.199:3306/lx_product_db?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useNewIO=true&useSSL=false&serverTimezone=GMT
#spring.quartz.properties.org.quartz.dataSource.myDS.user = root
#spring.quartz.properties.org.quartz.dataSource.myDS.password = root123
#spring.quartz.properties.org.quartz.dataSource.myDS.maxConnections = 30
-## \u662f\u53ef\u9009\u7684SQL\u67e5\u8be2\u5b57\u7b26\u4e32\uff0cDataSource\u53ef\u7528\u4e8e\u68c0\u6d4b\u548c\u66ff\u6362\u5931\u8d25/\u635f\u574f\u7684\u8fde\u63a5\u3002
+## \u662F\u53EF\u9009\u7684SQL\u67E5\u8BE2\u5B57\u7B26\u4E32\uFF0CDataSource\u53EF\u7528\u4E8E\u68C0\u6D4B\u548C\u66FF\u6362\u5931\u8D25/\u635F\u574F\u7684\u8FDE\u63A5\u3002
#spring.quartz.properties.org.quartz.dataSource.myDS.validationQuery= select 1
-# \u7b49\u4e8etrue \u5b9a\u65f6\u4efb\u52a1\u624d\u80fd\u542f\u52a8
+# \u7B49\u4E8Etrue \u5B9A\u65F6\u4EFB\u52A1\u624D\u80FD\u542F\u52A8
org.quartz.task.isEnable=true
-# \u63a5\u53e3\u8c03\u7528\uff0c\u628aheader\u4e2d\u7684\u53c2\u6570copy\u5230formdata\u4e2d
+# \u63A5\u53E3\u8C03\u7528\uFF0C\u628Aheader\u4E2D\u7684\u53C2\u6570copy\u5230formdata\u4E2D
header.copy.paras=
-#\u662f\u5426\u542f\u7528\u5728\u6307\u5b9a\u65f6\u95f4\u5185\u5141\u8bb8\u8bbf\u95ee\u7cfb\u7edf\u7684\u6307\u5b9a\u5730\u5740\u7684\u6b21\u6570\u9650\u5236
+#\u662F\u5426\u542F\u7528\u5728\u6307\u5B9A\u65F6\u95F4\u5185\u5141\u8BB8\u8BBF\u95EE\u7CFB\u7EDF\u7684\u6307\u5B9A\u5730\u5740\u7684\u6B21\u6570\u9650\u5236
allow.access.isEnable=false
-#\u8981\u9650\u5b9a\u8bbf\u95ee\u6b21\u6570\u7684\u5730\u5740\uff0c\u591a\u4e2a\u9017\u53f7\u5206\u9694
+#\u8981\u9650\u5B9A\u8BBF\u95EE\u6B21\u6570\u7684\u5730\u5740\uFF0C\u591A\u4E2A\u9017\u53F7\u5206\u9694
allow.access.apis=/login/v1
-#\u5141\u8bb8\u8bbf\u95ee\u6b21\u6570\uff0c\u6307\u5b9a\u65f6\u5185\uff0c\u6574\u6570,\u4e00\u4e2a\u63a5\u53e3\u5730\u5740\u5bf9\u5e94\u4e00\u4e2a\u6b21\u6570\uff0c\u7528\u9017\u53f7\u5206\u9694
+#\u5141\u8BB8\u8BBF\u95EE\u6B21\u6570\uFF0C\u6307\u5B9A\u65F6\u5185\uFF0C\u6574\u6570,\u4E00\u4E2A\u63A5\u53E3\u5730\u5740\u5BF9\u5E94\u4E00\u4E2A\u6B21\u6570\uFF0C\u7528\u9017\u53F7\u5206\u9694
allow.access.number.times=5
-#\u5141\u8bb8\u8bbf\u95ee\u7cfb\u7edf\u63a5\u53e3\u7684\u65f6\u95f4\u8303\u56f4\u503c\uff0c\u5355\u4f4d\uff1a\u6beb\u79d2\uff0c\u4e00\u4e2a\u63a5\u53e3\u5730\u5740\u5bf9\u5e94\u4e00\u4e2a\u65f6\u95f4,\u7528\u9017\u53f7\u5206\u9694 ,1\u5206\u949f
+#\u5141\u8BB8\u8BBF\u95EE\u7CFB\u7EDF\u63A5\u53E3\u7684\u65F6\u95F4\u8303\u56F4\u503C\uFF0C\u5355\u4F4D\uFF1A\u6BEB\u79D2\uFF0C\u4E00\u4E2A\u63A5\u53E3\u5730\u5740\u5BF9\u5E94\u4E00\u4E2A\u65F6\u95F4,\u7528\u9017\u53F7\u5206\u9694 ,1\u5206\u949F
allow.access.time.frame=360000
-#\u662f\u5426\u542f\u7528\u90ae\u4ef6\u4e8c\u6b21\u9a8c\u8bc1
+#\u662F\u5426\u542F\u7528\u90AE\u4EF6\u4E8C\u6B21\u9A8C\u8BC1
mail.auth.isEnable=false
#psswordSecurity
password.security.day=3
-#\u62a5\u8868\u6570\u636e\u5904\u7406\uff0c [\u89c6\u56fe\uff0c\u5b9e\u4f53\u8868]\uff0c\u5b9a\u65f6\u4efb\u52a1\u628a\u89c6\u56fe\u6570\u636e\u63d2\u5165\u5230\u5b9e\u4f53\u8868\u4e2d \u4e24\u8005\u8868\u5b57\u6bb5\u4e00\u81f4
+#\u62A5\u8868\u6570\u636E\u5904\u7406\uFF0C [\u89C6\u56FE\uFF0C\u5B9E\u4F53\u8868]\uFF0C\u5B9A\u65F6\u4EFB\u52A1\u628A\u89C6\u56FE\u6570\u636E\u63D2\u5165\u5230\u5B9E\u4F53\u8868\u4E2D \u4E24\u8005\u8868\u5B57\u6BB5\u4E00\u81F4
report.data.process.config=[a,b][c,d]
-# \u65e5\u5fd7\u8bb0\u5f55
+# \u65E5\u5FD7\u8BB0\u5F55
logger.info.save=false
-# \u540c\u6b65-\u5934\u50cf\u7b7e\u540d\u9ed8\u8ba4\u7684\u6587\u4ef6\u5939
-avatar.signature.default.dir=E:/\u56fe\u6807/test
-# \u8865\u4e01\u62bd\u53d6\u8def\u5f84
+# \u540C\u6B65-\u5934\u50CF\u7B7E\u540D\u9ED8\u8BA4\u7684\u6587\u4EF6\u5939
+avatar.signature.default.dir=E:/\u56FE\u6807/test
+# \u8865\u4E01\u62BD\u53D6\u8DEF\u5F84
patch.extract.dir=D:/worksoft/IDEA/workspace/product-server_v2.0.0/product-server-patch/patch
-#\u624b\u673a\u7aef \u524d\u7aef\u670d\u52a1\u5730\u5740
+#\u624B\u673A\u7AEF \u524D\u7AEF\u670D\u52A1\u5730\u5740
web.server.url=http://192.168.0.198:7005/app
-#\u662f\u5426\u542f\u7528\u5f3a\u5236\u9a8c\u8bc1\u767b\u5f55APP\u7684mac
+#\u662F\u5426\u542F\u7528\u5F3A\u5236\u9A8C\u8BC1\u767B\u5F55APP\u7684mac
mobile.mac.valid.isEnable=false
-# \u8bc1\u4e66\u4f4d\u7f6e
+# \u8BC1\u4E66\u4F4D\u7F6E
sign.dir.path=D:/test/lx-server/sign
-
+# \u884C\u653F\u5904\u7F5A\u4E8B\u5148\u544A\u77E5\u4E66,\u884C\u653F\u5904\u7F5A\u542C\u8BC1\u544A\u77E5\u4E66,\u884C\u653F\u5904\u7F5A\u50AC\u544A\u4E66,\u884C\u653F\u5904\u7F5A\u51B3\u5B9A\u4E66,\u4E0D\u4E88\u884C\u653F\u5904\u7F5A\u901A\u77E5\u4E66,\u884C\u653F\u5904\u7F5A\u542C\u8BC1\u901A\u77E5\u4E66,\u4E0D\u4E88\u884C\u653F\u542C\u8BC1\u901A\u77E5\u4E66,\u81EA\u7531\u884C\u6587\u5355,\u516C\u6587\u6536\u6587\u5904\u7406\u5355(\u6536\u6587\u7BA1\u7406),\u516C\u6587\u53D1\u6587\u5355\uFF08\u897F\u5B81\u5E02\u623F\u4EA7\u7BA1\u7406\u5C40\u53D1\u6587\u7A3F\u7EB8\uFF09,\u529E\u516C\u7ECF\u8D39\u4F7F\u7528\u5BA1\u6279\u8868,\u529E\u516C\u7528\u54C1\u9886\u7528\u8868
+#data.synchronism.function = 600-008-000mvc,600-010-000mvc,600-016-000mvc,600-013-000mvc,600-009-000mvc,600-011-000mvc,600-012-000mvc,001-011-000mvc,001-006-000mvc,001-012-000mvc,019-025-000mvc019-021-000
+# \u529E\u516C\u5BA4\u7528\u54C1\u91C7\u8D2D\u5355,\u4EBA\u5458\u51FA\u5DEE\uFF08\u57F9\u8BAD\uFF09\u5BA1\u6279\u5355,\u516C\u52A1\u63A5\u5F85\u5BA1\u6279\u8868,\u884C\u653F\u6267\u6CD5\u5BA1\u6279\u8868,\u53D1\u6587\u5B50\u8868\u5355,\u516C\u544A\u7BA1\u7406,\u8003\u52E4,\u4F1A\u8BAE
+#data.synchronism.function =
+# \u534F\u540C\u529E\u516C
+#data.synchronism.function=019-025-000mvc
+#data.synchronism.function = 600-008-000mvc,600-010-000mvc,600-016-000mvc,600-013-000mvc,600-009-000mvc,600-011-000mvc,600-012-000mvc,001-011-000mvc,001-006-000mvc,001-012-000mvc,019-025-000mvc;019-021-000;600-014-000mvc,600-015-000mvc,019-017-000mvc,021-016-000mvc,019-018-000mvc,019-023-000mvc,021-012-000mvc,006-009-000mvc,601-001-000mvc,035-411-000mvc;003-006-000mvc
+# oracle\u6E90\u6570\u636E\u5E93\u94FE\u63A5
+data.synchronism.function.jdbc.diver=oracle.jdbc.driver.OracleDriver
+data.synchronism.function.jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
+data.synchronism.function.jdbc.name=FE_BASE5
+data.synchronism.function.jdbc.password=fe123
+# \u9644\u4EF6\u540C\u6B65\u4E34\u65F6\u6587\u4EF6\u5939\u4F4D\u7F6E
+new.filePackage=D:/filePackage
diff --git a/product-server-web/src/main/resources/license.xml b/product-server-web/src/main/resources/license.xml
new file mode 100644
index 0000000..a895df6
--- /dev/null
+++ b/product-server-web/src/main/resources/license.xml
@@ -0,0 +1,14 @@
+<License>
+ <Data>
+ <Products>
+ <Product>Aspose.Total for Java</Product>
+ <Product>Aspose.Words for Java</Product>
+ </Products>
+ <EditionType>Enterprise</EditionType>
+ <SubscriptionExpiry>20991231</SubscriptionExpiry>
+ <LicenseExpiry>20991231</LicenseExpiry>
+ <SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber>
+ </Data>
+ <Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=
+ </Signature>
+</License>
\ No newline at end of file
diff --git a/product-server-web/src/main/resources/static/avatar/organization.png b/product-server-web/src/main/resources/static/avatar/organization.png
new file mode 100644
index 0000000..e852890
--- /dev/null
+++ b/product-server-web/src/main/resources/static/avatar/organization.png
Binary files differ
diff --git a/product-server-web/src/main/resources/templates/webOffice.html b/product-server-web/src/main/resources/templates/webOffice.html
index 520706f..107cb94 100644
--- a/product-server-web/src/main/resources/templates/webOffice.html
+++ b/product-server-web/src/main/resources/templates/webOffice.html
@@ -121,11 +121,12 @@
* @param formData
*/
function planEditDocument() {
+ console.log(formData)
if (readOnly != 1) {
$.post("/lx/api/office/document-edit-plan/v1", {
'signature': signature,
- 'formData': encodeURI(formData)
+ 'formData': formData
}, function (data, status) {
if (data && data.code == 200) {
setTimeout(openOffice, 500)
@@ -262,11 +263,13 @@
WebOffice.HttpAddPostString('~table~', 'product_sys_attachments');
WebOffice.HttpAddPostString('formData', formData);
WebOffice.HttpAddPostCurrFile("docfile", "");//姝ゅ彞涓哄浐瀹氳鍙ワ紝涓嶇鏄繚瀛榳ord杩樻槸excel,ppt绛夐兘杩欐牱鍐�
-
- //strResults鐢ㄤ簬鑾峰緱缃戦〉鎻愪氦鍚庣殑杩斿洖鏁版嵁锛屽彲鐢ㄤ互璋冭瘯鏈嶅姟鍣ㄧ浠g爜銆�
var strResults = WebOffice.HttpPost(strSaveUrl);
- console.log(strResults)
- if (strResults) {
+
+ if (strResults) { //灏唖trResults杞崲涓哄皬鍐� 鍒ゆ柇瀛楃涓叉槸鍚﹀寘鍚玜ctive 鍜宔vent
+ if (strResults.toLowerCase().indexOf('active') != -1 && strResults.toLowerCase().indexOf('event') != -1) {
+ //淇濆瓨鎴愬姛
+ return;
+ }
var res = JSON.parse(strResults);
if (res && res.code != 200) {
if (res.code == "90021" || res.code == '90044') {
@@ -277,14 +280,11 @@
}
alert(res.msg);
}
- // alert(strResults)
- // JSON.parse()
}
- // alert(strResults);//鐢╝lert璇彞鍙互鏄剧ず鏈嶅姟鍣ㄧ缃戦〉杩斿洖鐨勬暟鎹�
- // strResults;//濡傛灉淇濆瓨鎴愬姛锛岀紪绋嬫椂璁╂湇鍔″櫒鎺ユ敹浠g爜濡倁pload.jsp,upload.aspx,upload.php绛夎繑鍥炵┖鍊兼垨OK瀛椾覆銆�
} catch (e) {
console.error(e);
- alert('鍙戠敓閿欒锛佽浣跨敤鏌ラ槄杩斿洖鍊硷紒');
+ //鑾峰彇閿欒淇℃伅
+ alert('鍙戠敓閿欒锛佽浣跨敤鏌ラ槄杩斿洖鍊硷紒' + e.message);
}
}
--
Gitblit v1.9.2