ProjectFilingPreRuleAction.java
3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package com.cntytz;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
/**
* 工程备案流程前置控制规则
* 主规则:根据工程名称,同一工程创建超过3次的,将不再被允许创建
* 分支规则:被驳回的将失去资格,计数减一
*
* @author tjx
* @date 2020/4/15
*/
public class ProjectFilingPreRuleAction extends BaseBean implements Action {
Log logger = LogFactory.getLog(ProjectFilingPreRuleAction.class);
/**
* 判断次数
*/
private Integer times = 3;
/**
* 表单名称,比如: formtable_main_16
* 参数
*/
private String tableName;
/**
* 表单字段,比如gcmc
* 参数
*/
private String colName;
/**
* 错误提示信息
*/
private String errorMsg;
/**
* 流程ID
* 参数
*/
private String flowId;
/**
* 调试模式 D:debug;R:release
*/
private String debug = "R";
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getColName() {
return colName;
}
public void setColName(String colName) {
this.colName = colName;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public String getFlowId() {
return flowId;
}
public void setFlowId(String flowId) {
this.flowId = flowId;
}
public Integer getTimes() {
return times;
}
public void setTimes(Integer times) {
this.times = times;
}
/**
* 执行器
*
* @param requestInfo
* @return
*/
@Override
public String execute(RequestInfo requestInfo) {
if ("D".equals(this.debug.toUpperCase())) {
logger.debug("参数设置为:tableName:" + tableName + " colName: " + colName + " flowId: " + flowId + " times: " + times + " errorMsg: " + errorMsg);
}
RecordSet record = new RecordSet();
String sql = getRuleSql(requestInfo);
if ("D".equals(this.debug.toUpperCase())) {
logger.debug("sql: " + sql);
}
record.execute(sql);
while (record.next()) {
int count = record.getInt("num");
if (count >= times) {
requestInfo.getRequestManager().setMessagecontent(errorMsg);
return FAILURE_AND_CONTINUE;
} else {
return SUCCESS;
}
}
return SUCCESS;
}
/**
* 获取判断sql
*
* @param requestInfo
* @return sql
*/
private String getRuleSql(RequestInfo requestInfo) {
String ruleSql = "select count(1) as num from " + tableName + " f inner join workflow_requestbase wr on wr.REQUESTID = f.requestId where wr.WORKFLOWID = " + flowId + " and wr.CURRENTNODETYPE in (1,3)and f." + colName + " = '";
Property[] properties = requestInfo.getMainTableInfo().getProperty();
for (Property property : properties) {
if (property.getName().equals(colName.trim())) {
if (property.getValue() == null || property.getValue().length() == 0) {
return "";
}
String value = property.getValue().trim();
ruleSql += value + "'";
return ruleSql;
}
}
return "";
}
}