From af67fb927c3f30fa70df834f0e97f0b4a91e6119 Mon Sep 17 00:00:00 2001
From: jinlin <jinlin>
Date: 星期四, 10 四月 2025 14:58:22 +0800
Subject: [PATCH] 修改
---
src/main/java/com/example/server/DataSync/service/DataSyncService.java | 73 ++++++++++++++++++++++++++++++------
1 files changed, 60 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/example/server/DataSync/service/DataSyncService.java b/src/main/java/com/example/server/DataSync/service/DataSyncService.java
index e096a1e..029b576 100644
--- a/src/main/java/com/example/server/DataSync/service/DataSyncService.java
+++ b/src/main/java/com/example/server/DataSync/service/DataSyncService.java
@@ -1,11 +1,17 @@
package com.example.server.DataSync.service;
import com.example.Application;
+import com.example.client.service.DataExportManageService;
+import com.example.client.service.DataImportManageService;
import com.example.client.utils.WaitUtil;
import com.example.server.DataSync.dto.IDUpdateDateDto;
import com.example.server.DataSync.dto.FieldTypeDto;
import com.example.server.mysql.dao.SysMysqlDao;
-import com.example.server.utils.CacheUtils;
+import com.example.server.progressTrack.dao.ExportRecordDao;
+import com.example.server.progressTrack.dao.ImportRecordDao;
+import com.example.server.progressTrack.model.ExportRecord;
+import com.example.server.progressTrack.model.ImportRecord;
+import com.example.server.utils.UserAndSiteUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -28,6 +34,14 @@
public class DataSyncService {
@Autowired
protected SysMysqlDao sysMysqlDao;
+ @Autowired
+ protected ExportRecordDao exportRecordDao;
+ @Autowired
+ protected ImportRecordDao importRecordDao;
+ @Autowired
+ DataExportManageService dataExportManageService;
+ @Autowired
+ DataImportManageService dataImportManageService;
@Value("${data.config-path}")
private String configPath2;
@@ -40,28 +54,31 @@
@Value("${spring.datasource.url}")
private String datasource;
- public void export() {
+
+ public void export(JTextArea tips) {
+ final String[] massage = {""};
String[] parts = datasource.split(":", 3);
// 瀹氫箟鏂囦欢璺緞
String dbPath = parts[2];
String configPath = configPath2;
String directoryPath = localPath + "life-protection";
- String mySite = (String) CacheUtils.get("site", "site");
+ String mySite = (String) UserAndSiteUtils.get("site", "site");
// 寮瑰嚭鏂囦欢閫夋嫨妗嗭紝璁╃敤鎴烽�夋嫨淇濆瓨ZIP鏂囦欢鐨勮矾寰�
String outputZipPath = showSaveFileDialog(mySite + "鍚屾鏁版嵁鍖�.zip");
if (outputZipPath == null) {
- System.out.println("鐢ㄦ埛鍙栨秷淇濆瓨锛岀▼搴忛��鍑恒��");
- }else{
+ massage[0] = "鐢ㄦ埛鍙栨秷淇濆瓨锛岀▼搴忛��鍑恒��"+ new Date();
+ tips.setText(tips.getText() + massage[0]);
+ } else {
final WaitUtil waitUtil = new WaitUtil(imgPath, "鏁版嵁姝e湪瀵煎叆锛岃绋嶅��");
// 寮�濮嬩笂浼犳枃浠剁殑寮傛浠诲姟
SwingWorker<String, Void> sw = new SwingWorker<String, Void>() {
@Override
protected String doInBackground() throws Exception {
- String flag = zipData(dbPath,configPath,directoryPath,outputZipPath);
+ String flag = zipData(dbPath, configPath, directoryPath, outputZipPath);
return flag;
}
@@ -74,9 +91,15 @@
// 鍒锋柊琛ㄦ牸鏁版嵁锛堝鏋滀笂浼犳垚鍔燂級
if (uploadSucceeded.equals("true")) {
waitUtil.dispose();
- System.out.println("瀵煎嚭鎴愬姛鏃堕棿" + new Date());
+ massage[0] = "瀵煎嚭鎴愬姛" + new Date();
+ exportRecordDao.insert(new ExportRecord());
+ List<ExportRecord> list = exportRecordDao.getList();
+ dataExportManageService.refresh(list);
+ tips.setText(tips.getText() + massage[0]);
} else {
waitUtil.dispose();
+ massage[0] = "瀵煎嚭澶辫触" + new Date();
+ tips.setText(tips.getText() + massage[0]);
JOptionPane.showMessageDialog(null, uploadSucceeded, "鎻愮ず", JOptionPane.ERROR_MESSAGE);
}
@@ -92,7 +115,7 @@
}
}
- public String zipData(String dbPath,String configPath,String directoryPath,String outputZipPath){
+ public String zipData(String dbPath, String configPath, String directoryPath, String outputZipPath) {
// 鍒涘缓ZIP鏂囦欢杈撳嚭娴�
FileOutputStream fos = null;
ZipOutputStream zos = null;
@@ -123,7 +146,8 @@
return "true";
}
- public void importData() {
+ public void importData(JTextArea tips) {
+ String massage = "";
InputStream inStream = null;
Properties properties = new Properties();
try {
@@ -137,8 +161,8 @@
// 閫掑綊澶嶅埗鏂囦欢澶�
copyDirectory(sourceDir, targetDir);
- System.out.println("鏂囦欢澶瑰鍒跺畬鎴愶紝鐩爣璺緞锛�" + targetDir);
-
+ massage = "鏂囦欢澶瑰鍒跺畬鎴愶紝鐩爣璺緞锛�" + targetDir;
+ tips.setText(tips.getText() + massage);
//璇诲彇閰嶇疆
inStream = new FileInputStream(UnzipPath + "config.properties");
properties.load(inStream);
@@ -147,23 +171,37 @@
e.printStackTrace();
}
- String mySite = (String) CacheUtils.get("site", "site");
+ String mySite = (String) UserAndSiteUtils.get("site", "site");
String otherSite = properties.get("site").toString();
if ("宸ヤ綔缁�".equals(mySite)) {
+ syncTable("dj_jdgz_network_level1");
+ syncTable("dj_jdgz_network_level1_list");
+ syncTable("dj_jdgz_network_level2");
+ syncTable("dj_jdgz_network_level2_list");
syncTable("dj_jdgz_handover");
syncTable("dj_jdgz_network_level3");
syncTable("dj_jdgz_network_level3_list");
syncTable("dj_jdgz_track_record");
syncTable("dj_sys_oss");
+ syncTable("dj_sys_teamgroup_class");
+ syncTable("sys_user");
syncTable("dj_jdgz_dismant_track");
+ syncTable("dj_jdgz_ship");
} else if (mySite.equals("TD")) {
if (otherSite.equals("TD")) {
+ syncTable("dj_jdgz_network_level1");
+ syncTable("dj_jdgz_network_level1_list");
+ syncTable("dj_jdgz_network_level2");
+ syncTable("dj_jdgz_network_level2_list");
syncTable("dj_jdgz_network_level3");
syncTable("dj_jdgz_network_level3_list");
syncTable("dj_jdgz_track_record");
syncTable("dj_sys_oss");
syncTable("dj_jdgz_dismant_track");
syncTable("dj_jdgz_handover");
+ syncTable("dj_sys_teamgroup_class");
+ syncTable("sys_user");
+ syncTable("dj_jdgz_ship");
} else if ("宸ヤ綔缁�".equals(otherSite)) {
syncTable("dj_jdgz_handover");
syncTable("dj_jdgz_network_level1");
@@ -175,6 +213,9 @@
syncTable("dj_jdgz_track_record");
syncTable("dj_sys_oss");
syncTable("dj_jdgz_dismant_track");
+ syncTable("dj_sys_teamgroup_class");
+ syncTable("sys_user");
+ syncTable("dj_jdgz_ship");
}
} else if ("鍘傚".equals(mySite)) {
syncTable("dj_jdgz_handover");
@@ -186,8 +227,14 @@
syncTable("dj_jdgz_network_level3_list");
syncTable("dj_jdgz_track_record");
syncTable("dj_sys_oss");
+ syncTable("dj_jdgz_ship");
syncTable("dj_jdgz_dismant_track");
}
+ ImportRecord data =new ImportRecord();
+ data.setImportSite(otherSite);
+ importRecordDao.insert(data);
+ List<ImportRecord> list = importRecordDao.getList();
+ dataImportManageService.refresh(list);
}
public void syncTable(String tableName) {
@@ -250,7 +297,7 @@
java.util.Date otherUpdateDate = dateFormat.parse(otherupdateDate);
if (otherUpdateDate.after(mysqlUpdateDate)) {
isUpdate = true;
- }else {
+ } else {
continue;
}
}
--
Gitblit v1.9.1