Merge branch 'dev' of http://1.15.45.82:3000/ecology/ebu_ecology_dev1 into dev
commit
42f39f73b1
|
@ -134,7 +134,7 @@ window.Utils = {
|
|||
* @returns {*} 字段值
|
||||
*/
|
||||
getFiledValueByName: function (fieldName, rowIndex) {
|
||||
return WfForm.getFieldValue(Utils.convertNameObjToId(fieldName) + rowIndex ? '_' + rowIndex : '')
|
||||
return WfForm.getFieldValue(Utils.convertNameObjToId(fieldName) + (rowIndex ? '_' + rowIndex : ''))
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.*;
|
|||
*
|
||||
* @author EBU7-dev-1 aiyh
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class CusBaseAction implements Action {
|
||||
|
||||
|
||||
|
@ -40,13 +41,13 @@ public abstract class CusBaseAction implements Action {
|
|||
* <h2>初始化流程默认的处理方法</h2>
|
||||
*/
|
||||
private void initHandleMethod() {
|
||||
// 提交
|
||||
// 提交
|
||||
actionHandleMethod.put(ActionRunType.SUBMIT, this::doSubmit);
|
||||
// 退回
|
||||
// 退回
|
||||
actionHandleMethod.put(ActionRunType.REJECT, this::doReject);
|
||||
// 撤回
|
||||
// 撤回
|
||||
actionHandleMethod.put(ActionRunType.WITHDRAW, this::doWithdraw);
|
||||
// 强制收回
|
||||
// 强制收回
|
||||
actionHandleMethod.put(ActionRunType.DRAW_BACK, this::doDrawBack);
|
||||
}
|
||||
|
||||
|
@ -60,7 +61,7 @@ public abstract class CusBaseAction implements Action {
|
|||
String requestId = requestInfo.getRequestid();
|
||||
User user = requestInfo.getRequestManager().getUser();
|
||||
int workflowId = requestManager.getWorkflowid();
|
||||
// 操作类型 submit - 提交 reject - 退回 等
|
||||
// 操作类型 submit - 提交 reject - 退回 等
|
||||
String src = requestManager.getSrc();
|
||||
if ("".equals(billTable)) {
|
||||
WorkflowComInfo workflowComInfo = new WorkflowComInfo();
|
||||
|
@ -73,13 +74,13 @@ public abstract class CusBaseAction implements Action {
|
|||
if (StringUtils.isEmpty(src)) {
|
||||
src = "submit";
|
||||
}
|
||||
// 初始化默认的流程处理方法
|
||||
// 初始化默认的流程处理方法
|
||||
initHandleMethod();
|
||||
// 提供自定义注册处理方法
|
||||
// 提供自定义注册处理方法
|
||||
registerHandler(actionHandleMethod);
|
||||
// 获取流程对应的处理方法
|
||||
// 获取流程对应的处理方法
|
||||
CusBaseActionHandleFunction cusBaseActionHandleFunction = actionHandleMethod.get(src);
|
||||
// 默认没有直接成功不做拦截
|
||||
// 默认没有直接成功不做拦截
|
||||
if (null == cusBaseActionHandleFunction) {
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
@ -132,8 +133,7 @@ public abstract class CusBaseAction implements Action {
|
|||
/**
|
||||
* <h2>action 提交流程业务处理方法</h2>
|
||||
* <p>具体业务逻辑实现
|
||||
* 全局存在log成员变量,用于日志的输出
|
||||
* Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* </p>
|
||||
*
|
||||
* @param requestId 流程请求ID
|
||||
|
@ -150,8 +150,7 @@ public abstract class CusBaseAction implements Action {
|
|||
/**
|
||||
* <h2>action 退回流程业务处理方法</h2>
|
||||
* <p>具体业务逻辑实现
|
||||
* 全局存在log成员变量,用于日志的输出
|
||||
* Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* </p>
|
||||
*
|
||||
* @param requestId 流程请求ID
|
||||
|
@ -167,8 +166,7 @@ public abstract class CusBaseAction implements Action {
|
|||
/**
|
||||
* <h2>action 撤回、撤回流程流程业务处理方法</h2>
|
||||
* <p>具体业务逻辑实现
|
||||
* 全局存在log成员变量,用于日志的输出
|
||||
* Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* </p>
|
||||
*
|
||||
* @param requestId 流程请求ID
|
||||
|
@ -185,8 +183,7 @@ public abstract class CusBaseAction implements Action {
|
|||
/**
|
||||
* <h2>action 强制收回流程业务处理方法</h2>
|
||||
* <p>具体业务逻辑实现
|
||||
* 全局存在log成员变量,用于日志的输出
|
||||
* Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* </p>
|
||||
*
|
||||
* @param requestId 流程请求ID
|
||||
|
@ -207,7 +204,7 @@ public abstract class CusBaseAction implements Action {
|
|||
*/
|
||||
@Deprecated
|
||||
protected Map<String, String> getMainTableValue() {
|
||||
// 获取主表数据
|
||||
// 获取主表数据
|
||||
Property[] propertyArr = globalRequestInfo.getMainTableInfo().getProperty();
|
||||
return getStringMap(propertyArr);
|
||||
}
|
||||
|
@ -218,7 +215,7 @@ public abstract class CusBaseAction implements Action {
|
|||
* @return 流程主表数据
|
||||
*/
|
||||
protected Map<String, String> getMainTableValue(RequestInfo requestInfo) {
|
||||
// 获取主表数据
|
||||
// 获取主表数据
|
||||
Property[] propertyArr = requestInfo.getMainTableInfo().getProperty();
|
||||
return getStringMap(propertyArr);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import weaver.workflow.request.RequestManager;
|
|||
* <p>create: 2022-07-23 18:05</p>
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
@FunctionalInterface
|
||||
public interface CusBaseActionHandleFunction {
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,288 @@
|
|||
package aiyh.utils.action;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.*;
|
||||
import weaver.workflow.request.RequestManager;
|
||||
import weaver.workflow.workflow.WorkflowBillComInfo;
|
||||
import weaver.workflow.workflow.WorkflowComInfo;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <h1>基础的action,实现一些基础的参数</h1>
|
||||
*
|
||||
* @author EBU7-dev-1 aiyh
|
||||
*/
|
||||
public abstract class SafeCusBaseAction implements Action {
|
||||
|
||||
|
||||
/**
|
||||
* 全局日志对象
|
||||
*/
|
||||
protected final Logger log = Util.getLogger();
|
||||
private final Map<String, SafeCusBaseActionHandleFunction> actionHandleMethod = new HashMap<>();
|
||||
|
||||
/**
|
||||
* <h2>初始化流程默认的处理方法</h2>
|
||||
*/
|
||||
private void initHandleMethod() {
|
||||
// 提交
|
||||
actionHandleMethod.put(ActionRunType.SUBMIT, this::doSubmit);
|
||||
// 退回
|
||||
actionHandleMethod.put(ActionRunType.REJECT, this::doReject);
|
||||
// 撤回
|
||||
actionHandleMethod.put(ActionRunType.WITHDRAW, this::doWithdraw);
|
||||
// 强制收回
|
||||
actionHandleMethod.put(ActionRunType.DRAW_BACK, this::doDrawBack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final String execute(RequestInfo requestInfo) {
|
||||
RequestManager requestManager = requestInfo.getRequestManager();
|
||||
String billTable = requestManager.getBillTableName();
|
||||
String requestId = requestInfo.getRequestid();
|
||||
User user = requestInfo.getRequestManager().getUser();
|
||||
int workflowId = requestManager.getWorkflowid();
|
||||
// 操作类型 submit - 提交 reject - 退回 等
|
||||
String src = requestManager.getSrc();
|
||||
if ("".equals(billTable)) {
|
||||
WorkflowComInfo workflowComInfo = new WorkflowComInfo();
|
||||
String formId = workflowComInfo.getFormId(String.valueOf(workflowId));
|
||||
WorkflowBillComInfo workflowBillComInfo = new WorkflowBillComInfo();
|
||||
billTable = workflowBillComInfo.getTablename(formId);
|
||||
}
|
||||
try {
|
||||
Util.verifyRequiredField(this);
|
||||
if (StringUtils.isEmpty(src)) {
|
||||
src = "submit";
|
||||
}
|
||||
// 初始化默认的流程处理方法
|
||||
initHandleMethod();
|
||||
// 提供自定义注册处理方法
|
||||
registerHandler(actionHandleMethod);
|
||||
// 获取流程对应的处理方法
|
||||
SafeCusBaseActionHandleFunction cusBaseActionHandleFunction = actionHandleMethod.get(src);
|
||||
// 默认没有直接成功不做拦截
|
||||
if (null == cusBaseActionHandleFunction) {
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
cusBaseActionHandleFunction.handle(requestId, billTable, workflowId, user, requestInfo);
|
||||
} catch (CustomerException e) {
|
||||
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) {
|
||||
if (this.exceptionCallback(e, requestManager)) {
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>程序执行异常回调</h2>
|
||||
*
|
||||
* @param e 异常信息
|
||||
* @param requestManager requestManager对象
|
||||
* @return 是否阻止action往下提交,true- 阻止, false-放行
|
||||
*/
|
||||
public boolean exceptionCallback(Exception e, RequestManager requestManager) {
|
||||
e.printStackTrace();
|
||||
log.error(Util.logStr("getDataId 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>
|
||||
*
|
||||
* @param actionHandleMethod 处理方法对应map
|
||||
*/
|
||||
public void registerHandler(Map<String, SafeCusBaseActionHandleFunction> actionHandleMethod) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>action 提交流程业务处理方法</h2>
|
||||
* <p>具体业务逻辑实现
|
||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* </p>
|
||||
*
|
||||
* @param requestId 流程请求ID
|
||||
* @param billTable 流程对应主表名称
|
||||
* @param workflowId 流程对应流程ID
|
||||
* @param user 当前节点操作者用户
|
||||
* @param requestInfo 请求管理对象
|
||||
*/
|
||||
|
||||
public abstract void doSubmit(String requestId, String billTable, int workflowId,
|
||||
User user, RequestInfo requestInfo);
|
||||
|
||||
|
||||
/**
|
||||
* <h2>action 退回流程业务处理方法</h2>
|
||||
* <p>具体业务逻辑实现
|
||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* </p>
|
||||
*
|
||||
* @param requestId 流程请求ID
|
||||
* @param billTable 流程对应主表名称
|
||||
* @param workflowId 流程对应流程ID
|
||||
* @param user 当前节点操作者用户
|
||||
* @param requestInfo 请求管理对象
|
||||
*/
|
||||
public void doReject(String requestId, String billTable, int workflowId,
|
||||
User user, RequestInfo requestInfo) {
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>action 撤回、撤回流程流程业务处理方法</h2>
|
||||
* <p>具体业务逻辑实现
|
||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* </p>
|
||||
*
|
||||
* @param requestId 流程请求ID
|
||||
* @param billTable 流程对应主表名称
|
||||
* @param workflowId 流程对应流程ID
|
||||
* @param user 当前节点操作者用户
|
||||
* @param requestInfo 请求管理对象
|
||||
*/
|
||||
public void doWithdraw(String requestId, String billTable, int workflowId,
|
||||
User user, RequestInfo requestInfo) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>action 强制收回流程业务处理方法</h2>
|
||||
* <p>具体业务逻辑实现
|
||||
* 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败
|
||||
* </p>
|
||||
*
|
||||
* @param requestId 流程请求ID
|
||||
* @param billTable 流程对应主表名称
|
||||
* @param workflowId 流程对应流程ID
|
||||
* @param user 当前节点操作者用户
|
||||
* @param requestInfo 请求管理对象
|
||||
*/
|
||||
public void doDrawBack(String requestId, String billTable, int workflowId,
|
||||
User user, RequestInfo requestInfo) {
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>获取流程主表数据</h2>
|
||||
*
|
||||
* @return 流程主表数据
|
||||
*/
|
||||
protected Map<String, String> getMainTableValue(RequestInfo requestInfo) {
|
||||
// 获取主表数据
|
||||
Property[] propertyArr = requestInfo.getMainTableInfo().getProperty();
|
||||
return getStringMap(propertyArr);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<String, String> getStringMap(Property[] propertyArr) {
|
||||
if (null == propertyArr) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, String> mainTable = new HashMap<>((int) Math.ceil(propertyArr.length * 1.4));
|
||||
for (Property property : propertyArr) {
|
||||
String fieldName = property.getName();
|
||||
String value = property.getValue();
|
||||
mainTable.put(fieldName, value);
|
||||
}
|
||||
return mainTable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>获取所有明细数据</h2>
|
||||
*
|
||||
* @return 以明细表需要为键,以明细表数据为值的键值对明细数据信息
|
||||
*/
|
||||
protected Map<String, List<Map<String, String>>> getDetailTableValue(RequestInfo requestInfo) {
|
||||
DetailTable[] detailTableArr = requestInfo.getDetailTableInfo().getDetailTable();
|
||||
return getListMap(detailTableArr);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private Map<String, List<Map<String, String>>> getListMap(DetailTable[] detailTableArr) {
|
||||
Map<String, List<Map<String, String>>> detailDataList = new HashMap<>((int) Math.ceil(detailTableArr.length * 1.4));
|
||||
for (DetailTable detailTable : detailTableArr) {
|
||||
List<Map<String, String>> detailData = getDetailValue(detailTable);
|
||||
detailDataList.put(detailTable.getId(), detailData);
|
||||
}
|
||||
return detailDataList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>获取指定明细表的表数据</h2>
|
||||
*
|
||||
* @param detailNo 明细表编号
|
||||
* @return 明细数据
|
||||
*/
|
||||
protected List<Map<String, String>> getDetailTableValueByDetailNo(int detailNo, RequestInfo requestInfo) {
|
||||
DetailTable detailTable = requestInfo.getDetailTableInfo().getDetailTable(detailNo);
|
||||
return getDetailValue(detailTable);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>根据明细表信息获取明细表数据</h2>
|
||||
*
|
||||
* @param detailTable 明细表对象
|
||||
* @return 明细表数据
|
||||
*/
|
||||
@NotNull
|
||||
private List<Map<String, String>> getDetailValue(DetailTable detailTable) {
|
||||
Row[] rowArr = detailTable.getRow();
|
||||
List<Map<String, String>> detailData = new ArrayList<>(rowArr.length);
|
||||
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());
|
||||
for (Cell cell : cellArr) {
|
||||
String fieldName = cell.getName();
|
||||
String value = cell.getValue();
|
||||
rowData.put(fieldName, value);
|
||||
}
|
||||
detailData.add(rowData);
|
||||
}
|
||||
return detailData;
|
||||
}
|
||||
|
||||
|
||||
public static final class ActionRunType {
|
||||
/**
|
||||
* 退回
|
||||
*/
|
||||
public static final String REJECT = "reject";
|
||||
/**
|
||||
* 撤回
|
||||
*/
|
||||
public static final String WITHDRAW = "withdraw";
|
||||
/**
|
||||
* 强制收回
|
||||
*/
|
||||
public static final String DRAW_BACK = "drawBack";
|
||||
/**
|
||||
* 提交
|
||||
*/
|
||||
public static final String SUBMIT = "submit";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package aiyh.utils.action;
|
||||
|
||||
import weaver.hrm.User;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* <h1>流程类型处理方法</h1>
|
||||
*
|
||||
* @author EBU7-dev-1 aiyh
|
||||
* <p>create: 2022-07-23 18:05</p>
|
||||
*/
|
||||
|
||||
@FunctionalInterface
|
||||
public interface SafeCusBaseActionHandleFunction {
|
||||
/**
|
||||
* <h2>流程处理方法action</h2>
|
||||
*
|
||||
* @param requestId 流程请求ID
|
||||
* @param billTable 流程对应主表名称
|
||||
* @param workflowId 流程对应流程ID
|
||||
* @param user 当前节点操作者用户
|
||||
* @param requestInfo 请求管理对象
|
||||
*/
|
||||
void handle(String requestId, String billTable, int workflowId,
|
||||
User user, RequestInfo requestInfo);
|
||||
}
|
Loading…
Reference in New Issue