HrmWorkTimeOperation.jsp
10.7 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
227
228
229
230
231
232
233
234
235
236
<%@ page import="weaver.general.*" %>
<%@ page import="weaver.conn.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="RecordSet2" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="HrmTimeCardManage" class="weaver.hrm.schedule.HrmTimeCardManage" scope="page"/>
<jsp:useBean id="HrmKqSystemComInfo" class="weaver.hrm.schedule.HrmKqSystemComInfo" scope="page" />
<%
char separator = Util.getSeparator() ;
String procedurepara="";
String operation = Util.null2String(request.getParameter("operation")) ;
String workdate = Util.null2String(request.getParameter("workdate")) ; //
int salaryyear = Util.getIntValue(workdate.substring(0 , 4)) ;
int salarymonth = Util.getIntValue(workdate.substring(5 , 7)) ;
int salaryendday = Util.getIntValue(HrmKqSystemComInfo.getSalaryenddate(),31) ;
Calendar thedate = Calendar.getInstance ();
thedate.set( salaryyear , salarymonth-1, salaryendday) ;
String enddate = Util.add0(thedate.get(Calendar.YEAR) , 4) + "-" +
Util.add0(thedate.get(Calendar.MONTH) + 1 , 2) + "-" +
Util.add0(thedate.get(Calendar.DAY_OF_MONTH) , 2) ;
thedate.set( salaryyear , salarymonth-2, salaryendday) ;
thedate.add(Calendar.DATE , 1) ;
String startdate = Util.add0(thedate.get(Calendar.YEAR) , 4) + "-" +
Util.add0(thedate.get(Calendar.MONTH) + 1 , 2) + "-" +
Util.add0(thedate.get(Calendar.DAY_OF_MONTH) , 2) ;
// 获得所有的排班种类
ArrayList shiftids = new ArrayList() ;
ArrayList shiftcounts = new ArrayList() ;
RecordSet.executeSql("select id from HrmArrangeShift where ishistory='0' order by id ") ;
while ( RecordSet.next() ) {
String id = Util.null2String(RecordSet.getString("id")) ;
shiftids.add(id) ;
shiftcounts.add("") ;
}
shiftids.add("0") ; // 一般工作时间
shiftcounts.add("") ;
// 初始化计算表,
RecordSet.executeSql(" delete HrmWorkTimeCount where workdate = '" +workdate+ "' " ) ;
if( operation.equals("create") ) {
boolean initTimecardInfo = HrmTimeCardManage.initTimecardInfo(startdate,enddate) ;
if(!initTimecardInfo) {
response.sendRedirect("HrmWorkTimeList.jsp?workdate="+workdate+"&errmsg=1");
return ;
}
// 获得一般工作时间,判断休息日
String monstarttime1 = "" ;
String monendtime1 = "" ;
String monstarttime2 = "" ;
String monendtime2 = "" ;
String tuestarttime1 = "" ;
String tueendtime1 = "" ;
String tuestarttime2 = "" ;
String tueendtime2 = "" ;
String wedstarttime1 = "" ;
String wedendtime1 = "" ;
String wedstarttime2 = "" ;
String wedendtime2 = "" ;
String thustarttime1 = "" ;
String thuendtime1 = "" ;
String thustarttime2 = "" ;
String thuendtime2 = "" ;
String fristarttime1 = "" ;
String friendtime1 = "" ;
String fristarttime2 = "" ;
String friendtime2 = "" ;
String satstarttime1 = "" ;
String satendtime1 = "" ;
String satstarttime2 = "" ;
String satendtime2 = "" ;
String sunstarttime1 = "" ;
String sunendtime1 = "" ;
String sunstarttime2 = "" ;
String sunendtime2 = "" ;
ArrayList weekrestdays = new ArrayList() ;
RecordSet.executeProc("HrmSchedule_Select_Current" , startdate) ;
if( RecordSet.next() ) {
monstarttime1 = Util.null2String(RecordSet.getString("monstarttime1")) ;
monendtime1 = Util.null2String(RecordSet.getString("monendtime1")) ;
monstarttime2 = Util.null2String(RecordSet.getString("monstarttime2")) ;
monendtime2 = Util.null2String(RecordSet.getString("monendtime2")) ;
tuestarttime1 = Util.null2String(RecordSet.getString("tuestarttime1")) ;
tueendtime1 = Util.null2String(RecordSet.getString("tueendtime1")) ;
tuestarttime2 = Util.null2String(RecordSet.getString("tuestarttime2")) ;
tueendtime2 = Util.null2String(RecordSet.getString("tueendtime2")) ;
wedstarttime1 = Util.null2String(RecordSet.getString("wedstarttime1")) ;
wedendtime1 = Util.null2String(RecordSet.getString("wedendtime1")) ;
wedstarttime2 = Util.null2String(RecordSet.getString("wedstarttime2")) ;
wedendtime2 = Util.null2String(RecordSet.getString("wedendtime2")) ;
thustarttime1 = Util.null2String(RecordSet.getString("thustarttime1")) ;
thuendtime1 = Util.null2String(RecordSet.getString("thuendtime1")) ;
thustarttime2 = Util.null2String(RecordSet.getString("thustarttime2")) ;
thuendtime2 = Util.null2String(RecordSet.getString("thuendtime2")) ;
fristarttime1 = Util.null2String(RecordSet.getString("fristarttime1")) ;
friendtime1 = Util.null2String(RecordSet.getString("friendtime1")) ;
fristarttime2 = Util.null2String(RecordSet.getString("fristarttime2")) ;
friendtime2 = Util.null2String(RecordSet.getString("friendtime2")) ;
satstarttime1 = Util.null2String(RecordSet.getString("satstarttime1")) ;
satendtime1 = Util.null2String(RecordSet.getString("satendtime1")) ;
satstarttime2 = Util.null2String(RecordSet.getString("satstarttime2")) ;
satendtime2 = Util.null2String(RecordSet.getString("satendtime2")) ;
sunstarttime1 = Util.null2String(RecordSet.getString("sunstarttime1")) ;
sunendtime1 = Util.null2String(RecordSet.getString("sunendtime1")) ;
sunstarttime2 = Util.null2String(RecordSet.getString("sunstarttime2")) ;
sunendtime2 = Util.null2String(RecordSet.getString("sunendtime2")) ;
}
if( sunstarttime1.equals("") && sunendtime1.equals("") && sunstarttime2.equals("") && sunendtime2.equals("") ) weekrestdays.add("1") ;
if( monstarttime1.equals("") && monendtime1.equals("") && monstarttime2.equals("") && monendtime2.equals("") ) weekrestdays.add("2") ;
if( tuestarttime1.equals("") && tueendtime1.equals("") && tuestarttime2.equals("") && tueendtime2.equals("") ) weekrestdays.add("3") ;
if( wedstarttime1.equals("") && wedendtime1.equals("") && wedstarttime2.equals("") && wedendtime2.equals("") ) weekrestdays.add("4") ;
if( thustarttime1.equals("") && thuendtime1.equals("") && thustarttime2.equals("") && thuendtime2.equals("") ) weekrestdays.add("5") ;
if( fristarttime1.equals("") && friendtime1.equals("") && fristarttime2.equals("") && friendtime2.equals("") ) weekrestdays.add("6") ;
if( satstarttime1.equals("") && satendtime1.equals("") && satstarttime2.equals("") && satendtime2.equals("") ) weekrestdays.add("7") ;
// 获得当期的公众假日, 调整休息日,排除这些属于加班的出勤
ArrayList holidaydatetypes = new ArrayList() ; //公众假日和类型
RecordSet.executeSql("select holidaydate , changetype, relateweekday from HrmPubHoliday where holidaydate>='" + startdate + "' and holidaydate <= '" + enddate + "' ") ;
while( RecordSet.next() ) {
String holidaydate = Util.null2String(RecordSet.getString("holidaydate")) ;
String changetype = Util.null2String(RecordSet.getString("changetype")) ;
holidaydatetypes.add(holidaydate+"_"+changetype) ;
}
// 得到正常上班的日期
String realworkday = "" ;
int fromyear = Util.getIntValue(startdate.substring(0 , 4)) ;
int frommonth = Util.getIntValue(startdate.substring(5 , 7)) ;
int fromday = Util.getIntValue(startdate.substring(8 , 10)) ;
String fromtempdate = startdate ;
thedate.set(fromyear,frommonth - 1 , fromday) ;
while( fromtempdate.compareTo(enddate) <= 0 ) {
// 属于休息日并且没有被调整为工作日,不计入正常上班的日期
if( weekrestdays.indexOf("" + thedate.get(Calendar.DAY_OF_WEEK)) != -1 && holidaydatetypes.indexOf(fromtempdate+"_2") == -1 ) {
thedate.add(Calendar.DATE , 1) ;
fromtempdate = Util.add0(thedate.get(Calendar.YEAR) , 4) + "-" +
Util.add0(thedate.get(Calendar.MONTH) + 1 , 2) + "-" +
Util.add0(thedate.get(Calendar.DAY_OF_MONTH) , 2) ;
continue ;
}
// 如果被调整为假日或者休息日,不计入正常上班的日期
if( holidaydatetypes.indexOf(fromtempdate+"_1") != -1 && holidaydatetypes.indexOf(fromtempdate+"_3") != -1 ) {
thedate.add(Calendar.DATE , 1) ;
fromtempdate = Util.add0(thedate.get(Calendar.YEAR) , 4) + "-" +
Util.add0(thedate.get(Calendar.MONTH) + 1 , 2) + "-" +
Util.add0(thedate.get(Calendar.DAY_OF_MONTH) , 2) ;
continue ;
}
if( realworkday.equals("") ) realworkday = "'"+fromtempdate+"'" ;
else realworkday += ",'"+fromtempdate+"'" ;
thedate.add(Calendar.DATE , 1) ;
fromtempdate = Util.add0(thedate.get(Calendar.YEAR) , 4) + "-" +
Util.add0(thedate.get(Calendar.MONTH) + 1 , 2) + "-" +
Util.add0(thedate.get(Calendar.DAY_OF_MONTH) , 2) ;
}
// 获得所有当期的打卡信息
RecordSet.executeSql(" select count(resourceid) as shiftcount , resourceid, relateshiftid from HrmTimecardInfo where timecarddate >= '" + startdate + "' and timecarddate <= '"+ enddate + "' and " +
" ( (timecarddate in ("+ realworkday +") and relateshiftid = 0 ) or relateshiftid > 0 ) " +
" group by resourceid , relateshiftid " ) ;
while( RecordSet.next() ) {
String resourceid = Util.null2String(RecordSet.getString("resourceid")) ;
String shiftid = Util.null2String(RecordSet.getString("relateshiftid")) ;
String shiftcount = "" + Util.getIntValue(RecordSet.getString("shiftcount"), 0 ) ;
procedurepara= resourceid + separator + workdate + separator + shiftid + separator + shiftcount ;
RecordSet.executeProc("HrmWorkTimeCount_Insert",procedurepara) ;
}
}
else if( operation.equals("save") ) {
RecordSet.executeSql(" select id from Hrmresource where status in (0,1,2,3) and id in (select resourceid from HrmTimecardUser where usercode is not null and usercode != '' ) ") ;
while( RecordSet.next() ) {
String resourceid = Util.null2String(RecordSet.getString("id")) ;
for( int i = 0 ; i< shiftids.size() ; i++ ) {
String shiftid = (String)shiftids.get( i ) ;
String shiftcount = Util.null2String(request.getParameter(resourceid+"_"+shiftid)) ;
if( Util.getIntValue(shiftcount,0) == 0 ) continue ;
procedurepara= resourceid + separator + workdate + separator + shiftid + separator + shiftcount ;
RecordSet.executeProc("HrmWorkTimeCount_Insert",procedurepara) ;
}
}
}
response.sendRedirect("HrmWorkTimeList.jsp?workdate="+workdate);
%>