From 062b998ce57f4ef173b62229a8dfb9ed32b77ce6 Mon Sep 17 00:00:00 2001
From: "youHong.ai" <774495953@qq.com>
Date: Fri, 25 Nov 2022 13:25:29 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9cusBaseAction=EF=BC=8C?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BC=82=E5=B8=B8=E5=9B=9E=E8=B0=83=E6=96=B9?=
=?UTF-8?q?=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 2 +-
src/main/java/aiyh/utils/Util.java | 2 +-
.../java/aiyh/utils/action/CusBaseAction.java | 51 ++++++++++++-------
.../service/OrganizationAsyncService.java | 26 +++++++++-
.../java/youhong/ai/pcn/TestOrganization.java | 1 +
5 files changed, 60 insertions(+), 22 deletions(-)
diff --git a/.gitignore b/.gitignore
index 4a54ba7..371bcb7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,7 +31,7 @@ log
/src/test/resources/application.properties
/src/test/resources/application.xml
/src/main/resources/file
-
+/src/*/resources/ssl/
DirectoryV2.xml
diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java
index b5f3ed9..6b6df65 100644
--- a/src/main/java/aiyh/utils/Util.java
+++ b/src/main/java/aiyh/utils/Util.java
@@ -2885,7 +2885,7 @@ public class Util extends weaver.general.Util {
public static String actionFailException(RequestManager requestManager, String msg) {
requestManager.setMessageid(System.currentTimeMillis() + "");
requestManager.setMessagecontent(msg);
- throw new CustomerException(msg);
+ throw new CustomerException(msg, 500);
}
/**
diff --git a/src/main/java/aiyh/utils/action/CusBaseAction.java b/src/main/java/aiyh/utils/action/CusBaseAction.java
index 0eea3d6..cd3a68a 100644
--- a/src/main/java/aiyh/utils/action/CusBaseAction.java
+++ b/src/main/java/aiyh/utils/action/CusBaseAction.java
@@ -12,11 +12,7 @@ import weaver.workflow.request.RequestManager;
import weaver.workflow.workflow.WorkflowBillComInfo;
import weaver.workflow.workflow.WorkflowComInfo;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
*
基础的action,实现一些基础的参数
@@ -30,16 +26,12 @@ public abstract class CusBaseAction implements Action {
* 全局日志对象
*/
protected final Logger log = Util.getLogger();
-
+ private final Map actionHandleMethod = new HashMap<>();
/**
* 全局requestInfo对象
*/
protected RequestInfo requestInfo;
-
- private final Map actionHandleMethod = new HashMap<>();
-
-
/**
* 初始化流程默认的处理方法
*/
@@ -88,19 +80,40 @@ public abstract class CusBaseAction implements Action {
}
cusBaseActionHandleFunction.handle(requestId, billTable, workflowId, user, requestManager);
} catch (CustomerException e) {
- e.printStackTrace();
- Util.actionFail(requestManager, e.getMessage());
- return Action.FAILURE_AND_CONTINUE;
+ if (e.getCode() != null && e.getCode() == 500) {
+ Util.actionFail(requestManager, e.getMessage());
+ return Action.FAILURE_AND_CONTINUE;
+ }
+ if (this.exceptionCallback(e, requestManager)) {
+ return Action.FAILURE_AND_CONTINUE;
+ }
} catch (Exception e) {
- e.printStackTrace();
- log.error(Util.logStr("execute action fail, exception message is [{}], error stack trace msg is: \n{}",
- e.getMessage(), Util.getErrString(e)));
- Util.actionFail(requestManager, e.getMessage());
- return Action.FAILURE_AND_CONTINUE;
+ if (this.exceptionCallback(e, requestManager)) {
+ return Action.FAILURE_AND_CONTINUE;
+ }
}
return Action.SUCCESS;
}
+
+ /**
+ * 程序执行异常回调
+ *
+ * @param e 异常信息
+ * @param requestManager requestManager对象
+ * @return 是否阻止action往下提交,true- 阻止, false-放行
+ */
+ public boolean exceptionCallback(Exception e, RequestManager requestManager) {
+ e.printStackTrace();
+ log.error(Util.logStr("execute action fail, exception message is [{}], error stack trace msg is: \n{}",
+ e.getMessage(), Util.getErrString(e)));
+ Util.actionFail(requestManager, e.getMessage());
+ return true;
+ }
+
+ ;
+
+
/**
* 流程其他流转类型处理方法注册
*
@@ -243,7 +256,7 @@ public abstract class CusBaseAction implements Action {
for (Row row : rowArr) {
Cell[] cellArr = row.getCell();
Map rowData = new HashMap<>((int) Math.ceil(cellArr.length * (1 + 0.4)));
- rowData.put("id",row.getId());
+ rowData.put("id", row.getId());
for (Cell cell : cellArr) {
String fieldName = cell.getName();
String value = cell.getValue();
diff --git a/src/main/java/weaver/youhong/ai/pcn/hrorganization/service/OrganizationAsyncService.java b/src/main/java/weaver/youhong/ai/pcn/hrorganization/service/OrganizationAsyncService.java
index 2776e48..c727dcc 100644
--- a/src/main/java/weaver/youhong/ai/pcn/hrorganization/service/OrganizationAsyncService.java
+++ b/src/main/java/weaver/youhong/ai/pcn/hrorganization/service/OrganizationAsyncService.java
@@ -1,5 +1,12 @@
package weaver.youhong.ai.pcn.hrorganization.service;
+import aiyh.utils.Util;
+import ebu7common.youhong.ai.sftp.SftpConnectUtil;
+import weaver.general.GCONST;
+
+import java.io.File;
+import java.util.List;
+
/**
* 人员组织架构同步逻辑处理
*
@@ -11,4 +18,21 @@ package weaver.youhong.ai.pcn.hrorganization.service;
public class OrganizationAsyncService {
-}
+ /**
+ * csv文件数据
+ */
+ public List> getRemoteFileData(String fileName) {
+ String userName = Util.getCusConfigValue("sftpUserName");
+ String ipAddress = Util.getCusConfigValue("sftpIp");
+ String sftpPort = Util.getCusConfigValue("sftpPort");
+ SftpConnectUtil sftpConnectUtil = new SftpConnectUtil(
+ userName,
+ GCONST.getRootPath() + "sftp" + File.separatorChar + "HR_Digital_PROD.pem",
+ null,
+ ipAddress,
+ Integer.parseInt(sftpPort), 1000 * 100);
+ sftpConnectUtil.close();
+ return null;
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/youhong/ai/pcn/TestOrganization.java b/src/test/java/youhong/ai/pcn/TestOrganization.java
index 951c979..e728413 100644
--- a/src/test/java/youhong/ai/pcn/TestOrganization.java
+++ b/src/test/java/youhong/ai/pcn/TestOrganization.java
@@ -44,6 +44,7 @@ public class TestOrganization extends BaseTest {
@Test
public void testStaticLog() {
log.info("哈哈哈好的方式");
+ log.info(this.getClass().getResource("/"));
}