|
@@ -1,5 +1,7 @@
|
|
|
package sys.sc.formplugin;
|
|
|
|
|
|
+import com.jcraft.jsch.*;
|
|
|
+import com.tongtech.jms.ra.core.Options;
|
|
|
import kd.bos.base.utils.msg.BaseMessage;
|
|
|
import kd.bos.base.utils.msg.OrgMessage;
|
|
|
import kd.bos.dataentity.entity.CloneUtils;
|
|
@@ -24,9 +26,11 @@ import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
import kd.epm.eb.common.model.DynamicInfoCollection;
|
|
|
import kd.imc.bdm.common.constant.BotpCallBackLogConstant;
|
|
|
+import sys.sc.opplugin.utils.SftpClient;
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
@@ -39,6 +43,35 @@ import java.util.*;
|
|
|
|
|
|
public class TestPlugin extends AbstractListPlugin {
|
|
|
|
|
|
+ public static String host="192.168.10.69";
|
|
|
+ public static String username="root";
|
|
|
+ public static int port = 22;
|
|
|
+ public static String password="Kd@86262007";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
public String getFileUrl(String urlcode) throws IOException {
|
|
|
|
|
@@ -63,18 +96,7 @@ public class TestPlugin extends AbstractListPlugin {
|
|
|
nckd_url="/home/kingdee/cosmic/nginx-appstatic/store/appstatic/";
|
|
|
}
|
|
|
|
|
|
- String realPath = nckd_url+datestr+"/"+nckd_filename;
|
|
|
- File file=new File(realPath);
|
|
|
-
|
|
|
- if (!file.exists()) {
|
|
|
- File parentDir = file.getParentFile();
|
|
|
- if (parentDir != null && !parentDir.exists()) {
|
|
|
- parentDir.mkdirs();
|
|
|
- }
|
|
|
- file.createNewFile();
|
|
|
- this.getView().showMessage(nckd_url+datestr+"路径下成功生成文件"+nckd_filename);
|
|
|
- }
|
|
|
-
|
|
|
+ String realPath = nckd_url+datestr+File.separator+nckd_filename;
|
|
|
return realPath;
|
|
|
}
|
|
|
|
|
@@ -279,7 +301,6 @@ public class TestPlugin extends AbstractListPlugin {
|
|
|
return;
|
|
|
}
|
|
|
String msg="";
|
|
|
-
|
|
|
for (DynamicObject personData : personDataArray) {
|
|
|
|
|
|
String id=personData.getString("id");
|
|
@@ -664,12 +685,14 @@ public class TestPlugin extends AbstractListPlugin {
|
|
|
List<String> selector = Arrays.asList(
|
|
|
"number", "name"
|
|
|
);
|
|
|
-
|
|
|
-
|
|
|
|
|
|
String bd_bebank="bd_bebank";
|
|
|
try {
|
|
|
+
|
|
|
String fileurl = getFileUrl("hmhhurl");
|
|
|
+
|
|
|
+ SftpClient sftpClient=new SftpClient(host,username,password,port);
|
|
|
+ sftpClient.connect();
|
|
|
|
|
|
DynamicObjectType dynamicObjectType = EntityMetadataCache.getDataEntityType(bd_bebank);
|
|
|
|
|
@@ -681,15 +704,14 @@ public class TestPlugin extends AbstractListPlugin {
|
|
|
DynamicObject[] existingData = BusinessDataServiceHelper
|
|
|
.load(dynamicObjectType.getName(), String.join(",", selector)+",enable,nckd_datasource", null);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
Map<String, DynamicObject> existingDataMap = new HashMap<>();
|
|
|
for (DynamicObject obj : existingData) {
|
|
|
|
|
|
existingDataMap.put(obj.getString(selector.get(0)), obj);
|
|
|
}
|
|
|
Set<String> processeddubilidSet = new HashSet<>();
|
|
|
- try (BufferedReader reader = new BufferedReader(new FileReader(fileurl))) {
|
|
|
+
|
|
|
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(sftpClient.fileInputStream(fileurl)))) {
|
|
|
String line;
|
|
|
while ((line = reader.readLine()) != null) {
|
|
|
|
|
@@ -744,6 +766,8 @@ public class TestPlugin extends AbstractListPlugin {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ sftpClient.disconnect();
|
|
|
|
|
|
DynamicObject[] autoData = BusinessDataServiceHelper
|
|
|
.load(dynamicObjectType.getName()
|
|
@@ -759,8 +783,6 @@ public class TestPlugin extends AbstractListPlugin {
|
|
|
|
|
|
}
|
|
|
SaveServiceHelper.save(autoData);
|
|
|
-
|
|
|
-
|
|
|
|
|
|
for (Map.Entry<String, DynamicObject> entry : existingDataMap.entrySet()) {
|
|
|
String dubil_id = entry.getKey();
|
|
@@ -770,8 +792,6 @@ public class TestPlugin extends AbstractListPlugin {
|
|
|
updatedataList.add(data);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
if (!createdataList.isEmpty()) {
|
|
|
SaveServiceHelper.save(dynamicObjectType, createdataList.toArray(new DynamicObject[0]));
|
|
@@ -784,9 +804,58 @@ public class TestPlugin extends AbstractListPlugin {
|
|
|
} catch (IOException ex) {
|
|
|
ex.printStackTrace();
|
|
|
this.getView().showMessage("读取文件时发生错误:" + ex.getMessage());
|
|
|
+ } catch (Exception ex) {
|
|
|
+ throw new RuntimeException(ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ if ("connect".equals(e.getOperateKey()))
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ FileCreat();
|
|
|
+ } catch (JSchException ex) {
|
|
|
+ throw new RuntimeException(ex);
|
|
|
+ } catch (IOException ex) {
|
|
|
+ throw new RuntimeException(ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ throw new RuntimeException(ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public void FileCreat() throws Exception {
|
|
|
+ SftpClient sftpClient=new SftpClient(host,username,password,port);
|
|
|
+
|
|
|
+ sftpClient.connect();
|
|
|
+ String remoteFilePath = "/home/kingdee/cosmic/nginx-appstatic/store/appstatic/20240908/zzry.dat";
|
|
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(sftpClient.fileInputStream(remoteFilePath)));
|
|
|
+ reader.readLine();
|
|
|
+
|
|
|
+ File file=new File(remoteFilePath);
|
|
|
+ FileInputStream fis = new FileInputStream(file);
|
|
|
+ if (!file.exists())
|
|
|
+ {
|
|
|
+ File parentDir = file.getParentFile();
|
|
|
+
|
|
|
+ if (parentDir != null && !parentDir.exists()) {
|
|
|
+ parentDir.mkdirs();
|
|
|
+ }
|
|
|
+
|
|
|
+ file.createNewFile();
|
|
|
+
|
|
|
+ sftpClient.getSftpChannel().put(fis,remoteFilePath);
|
|
|
+ this.getView().showMessage("成功生成文件");
|
|
|
+ }else {
|
|
|
+ this.getView().showMessage("已存在文件");
|
|
|
+ }
|
|
|
+
|
|
|
+ fis.close();
|
|
|
+ sftpClient.disconnect();
|
|
|
}
|
|
|
}
|
|
|
|