From d30e385951ce03335a5023f0775fd144da3c0b88 Mon Sep 17 00:00:00 2001 From: jinlin <jinlin> Date: 星期二, 18 三月 2025 11:18:31 +0800 Subject: [PATCH] 修改 --- src/main/java/com/example/server/DataSync/service/DataSyncService.java | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 41 insertions(+), 10 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..3a6f4a8 100644 --- a/src/main/java/com/example/server/DataSync/service/DataSyncService.java +++ b/src/main/java/com/example/server/DataSync/service/DataSyncService.java @@ -1,10 +1,16 @@ 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.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.CacheUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -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,7 +54,9 @@ @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]; @@ -53,15 +69,16 @@ 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); @@ -175,6 +199,8 @@ syncTable("dj_jdgz_track_record"); syncTable("dj_sys_oss"); syncTable("dj_jdgz_dismant_track"); + syncTable("dj_sys_teamgroup_class"); + syncTable("sys_user"); } } else if ("鍘傚".equals(mySite)) { syncTable("dj_jdgz_handover"); @@ -188,6 +214,11 @@ syncTable("dj_sys_oss"); 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 +281,7 @@ java.util.Date otherUpdateDate = dateFormat.parse(otherupdateDate); if (otherUpdateDate.after(mysqlUpdateDate)) { isUpdate = true; - }else { + } else { continue; } } -- Gitblit v1.9.1