修改cusBaseAction,新增异常回调方法

main
youHong.ai 2022-11-25 13:25:29 +08:00
parent 665107e3cf
commit 062b998ce5
5 changed files with 60 additions and 22 deletions

2
.gitignore vendored
View File

@ -31,7 +31,7 @@ log
/src/test/resources/application.properties
/src/test/resources/application.xml
/src/main/resources/file
/src/*/resources/ssl/
DirectoryV2.xml

View File

@ -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);
}
/**

View File

@ -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.*;
/**
* <h1>action</h1>
@ -30,16 +26,12 @@ public abstract class CusBaseAction implements Action {
*
*/
protected final Logger log = Util.getLogger();
private final Map<String, CusBaseActionHandleFunction> actionHandleMethod = new HashMap<>();
/**
* requestInfo
*/
protected RequestInfo requestInfo;
private final Map<String, CusBaseActionHandleFunction> actionHandleMethod = new HashMap<>();
/**
* <h2></h2>
*/
@ -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;
}
/**
* <h2></h2>
*
* @param e
* @param requestManager requestManager
* @return actiontrue- 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;
}
;
/**
* <h2></h2>
*
@ -243,7 +256,7 @@ public abstract class CusBaseAction implements Action {
for (Row row : rowArr) {
Cell[] cellArr = row.getCell();
Map<String, String> 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();

View File

@ -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;
/**
* <h1></h1>
*
@ -11,4 +18,21 @@ package weaver.youhong.ai.pcn.hrorganization.service;
public class OrganizationAsyncService {
}
/**
* csv
*/
public List<List<String>> 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;
}
}

View File

@ -44,6 +44,7 @@ public class TestOrganization extends BaseTest {
@Test
public void testStaticLog() {
log.info("哈哈哈好的方式");
log.info(this.getClass().getResource("/"));
}