leave_flow.jsp
11.9 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<%@ page import="com.alibaba.fastjson.JSON" %>
<%@ page import="com.engine.kq.timer.KQQueue" %>
<%@ page import="com.engine.kq.timer.KQTaskBean" %>
<%@ page import="com.engine.kq.wfset.util.SplitActionUtil" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="com.engine.kq.enums.KqSplitFlowTypeEnum" %>
<%@ page import="com.engine.kq.wfset.bean.SplitBean" %>
<%@ page import="com.engine.kq.biz.KQTimesArrayComInfo" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="com.engine.kq.enums.FlowReportTypeEnum" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="com.engine.kq.biz.KQFlowDataBiz" %>
<%@ page import="weaver.common.DateUtil" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
try {
String requestid = Util.null2String(request.getParameter("requestid"));
String userId = Util.null2String(request.getParameter("userId"));
String kqDate = Util.null2String(request.getParameter("kqDate"));
if(userId.length() == 0){
out.println("param userId is null:<br/>");
return ;
}
if(kqDate.length() == 0){
out.println("param kqDate is null:<br/>");
return ;
}
String kqDateNext = DateUtil.addDate(kqDate, 1);
Map<String,Object> flowMaps = new HashMap<>();
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
String tablename = "select a.* from "+ KqSplitFlowTypeEnum.LEAVE.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
String leaveSql = "select * from ("+tablename+") t where 1=1 and status <> 1 ";
String sqlWhere = "";
if(userId.length() > 0){
sqlWhere += " and resourceid in ( "+userId+" )";
}
if(requestid.length() > 0){
sqlWhere += " and requestid in ( "+requestid+" )";
}
if(kqDate.length() > 0 && kqDateNext.length() > 0){
sqlWhere += " and ( fromdate between '"+kqDate+"' and '"+kqDateNext+"' or todate between '"+kqDate+"' and '"+kqDateNext+"' )";
}else{
if(kqDate.length() > 0){
sqlWhere += " and fromdate between '"+kqDate+"' and '"+kqDate+"' ";
}
if(kqDateNext.length() > 0){
sqlWhere += " and todate between '"+kqDateNext+"' and '"+kqDateNext+"' ";
}
}
if(sqlWhere.length() > 0){
leaveSql += sqlWhere;
}
List<SplitBean> splitBeans = new ArrayList<>();
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
int[] initArrays = kqTimesArrayComInfo.getInitArr();
rs.execute(leaveSql);
out.println("param leaveSql is :"+leaveSql+"<br/>");
while(rs.next()){
SplitBean splitBean = new SplitBean();
String requestId= rs.getString("requestId");
String resourceid= rs.getString("resourceid");
String fromdate= rs.getString("fromdate");
String fromtime= rs.getString("fromtime");
String todate= rs.getString("todate");
String totime= rs.getString("totime");
String newleavetype= rs.getString("newleavetype");
String duration= rs.getString("duration");
String durationrule= rs.getString("durationrule");
String leavebackrequestid= Util.null2String(rs.getString("leavebackrequestid"));
if(Util.getDoubleValue(duration) <= 0){
continue;
}
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
Map<String,String> infoMap = new HashMap<>();
infoMap.put(newleavetype, duration);
infoMap.put("requestId", requestId);
infoMap.put("begintime", fromtime);
infoMap.put("endtime", totime);
infoMap.put("unitType", unitType);
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
infoMap.put("newleavetype", newleavetype);
String key = resourceid+"|"+fromdate;
if(flowMaps != null){
if(flowMaps.get(key) != null){
if(leavebackrequestid.length() > 0 && leavebackrequestid.startsWith(",")){
int fromTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
int toTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime);
Arrays.fill(initArrays, fromTimeIndex, toTimeIndex+1, 1);
leavebackrequestid = leavebackrequestid.substring(1);
String backSql = "select * from "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where "+Util.getSubINClause(leavebackrequestid, "requestid", "in")+" and fromdate= '"+fromdate+"'";
rs1.executeQuery(backSql);
while (rs1.next()){
String back_fromtime = rs1.getString("fromtime");
String back_totime = rs1.getString("totime");
if(back_fromtime.equalsIgnoreCase(fromtime)){
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
}else{
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
}
}
List<List<String>> backLists = new ArrayList<>();
List<String> backList = new ArrayList<>();
for(int i = fromTimeIndex ; i <= toTimeIndex ; i ++){
if(initArrays[i] == 1){
backList.add(kqTimesArrayComInfo.getTimesByArrayindex(i));
}else{
if(!backList.isEmpty()){
backLists.add(backList);
backList = new ArrayList<>();
}else{
continue;
}
}
}
if(!backList.isEmpty()){
backLists.add(backList);
}
if(backLists != null && !backLists.isEmpty()){
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
for(int j = 0 ; j < backLists.size() ;j++){
List<String> backListTmp = backLists.get(j);
String back_tmp_fromtime = backListTmp.get(0);
String back_tmp_totime = backListTmp.get(backListTmp.size()-1);
infoMap = new HashMap<>();
infoMap.put("requestId", requestId);
infoMap.put(newleavetype, duration);
infoMap.put("begintime", back_tmp_fromtime);
infoMap.put("endtime", back_tmp_totime);
infoMap.put("unitType", unitType);
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
infoMap.put("newleavetype", newleavetype);
time_list_tmp.add(infoMap);
}
}
}else{
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
time_list_tmp.add(infoMap);
}
}else{
if(leavebackrequestid.length() > 0 && leavebackrequestid.startsWith(",")){
int fromTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
int toTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime);
Arrays.fill(initArrays, fromTimeIndex, toTimeIndex+1, 1);
leavebackrequestid = leavebackrequestid.substring(1);
String backSql = "select * from "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where "+Util.getSubINClause(leavebackrequestid, "requestid", "in")+" and fromdate= '"+fromdate+"'";
rs1.executeQuery(backSql);
while (rs1.next()){
String back_fromtime = rs1.getString("fromtime");
String back_totime = rs1.getString("totime");
if(back_fromtime.equalsIgnoreCase(fromtime)){
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
}else{
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
}
}
List<List<String>> backLists = new ArrayList<>();
List<String> backList = new ArrayList<>();
for(int i = fromTimeIndex ; i <= toTimeIndex ; i ++){
if(initArrays[i] == 1){
backList.add(kqTimesArrayComInfo.getTimesByArrayindex(i));
}else{
if(!backList.isEmpty()){
backLists.add(backList);
backList = new ArrayList<>();
}else{
continue;
}
}
}
if(!backList.isEmpty()){
backLists.add(backList);
}
System.out.println("backLists::"+backLists);
if(backLists != null && !backLists.isEmpty()){
List<Map<String,String>> time_list = new ArrayList<>();
for(int j = 0 ; j < backLists.size() ;j++){
List<String> backListTmp = backLists.get(j);
String back_tmp_fromtime = backListTmp.get(0);
String back_tmp_totime = backListTmp.get(backListTmp.size()-1);
infoMap = new HashMap<>();
infoMap.put("requestId", requestId);
infoMap.put(newleavetype, duration);
infoMap.put("begintime", back_tmp_fromtime);
infoMap.put("endtime", back_tmp_totime);
infoMap.put("unitType", unitType);
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
infoMap.put("newleavetype", newleavetype);
time_list.add(infoMap);
}
flowMaps.put(key, time_list);
}
}else{
List<Map<String,String>> time_list = new ArrayList<>();
time_list.add(infoMap);
flowMaps.put(key, time_list);
}
}
}
}
out.print(flowMaps);
} catch (Exception e) {
e.printStackTrace();
out.print(e.getMessage());
}
%>