HrmTimecardOperation.jsp
4.84 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
<%@ page import="java.util.*,weaver.general.Util,weaver.file.*,weaver.systeminfo.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.hrm.*" %>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="ExcelFile" class="weaver.file.ExcelFile" scope="session"/>
<%
User user = HrmUserVarify.getUser (request , response);
if(user == null) return ;
ArrayList userdates = new ArrayList() ;
ArrayList intimes = new ArrayList() ;
ArrayList outtimes = new ArrayList() ;
String startdate = Util.null2String(request.getParameter("startdate")) ;
String enddate = Util.null2String(request.getParameter("enddate")) ;
Calendar thedate = Calendar.getInstance() ;
int fromyear = Util.getIntValue(startdate.substring(0 , 4)) ;
int frommonth = Util.getIntValue(startdate.substring(5 , 7)) ;
int fromday = Util.getIntValue(startdate.substring(8 , 10)) ;
int toyear = Util.getIntValue(enddate.substring(0 , 4)) ;
int tomonth = Util.getIntValue(enddate.substring(5 , 7)) ;
int today = Util.getIntValue(enddate.substring(8 , 10)) ;
String thestartdate = Util.add0(fromyear , 4) + Util.add0(frommonth , 2) + Util.add0(fromday , 2) ;
String theenddate = Util.add0(toyear , 4) + Util.add0(tomonth , 2) + Util.add0(today , 2) ;
String tempstartdate = thestartdate ;
thedate.set(toyear,tomonth - 1 , today) ;
thedate.add(Calendar.DATE ,1 ) ;
String tempenddate = 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(fromyear,frommonth - 1 , fromday) ;
while( tempstartdate.compareTo(tempenddate) <= 0 ) {
RecordSet.executeSql("select * from " + tempstartdate , "ecologydb" ) ;
while (RecordSet.next() ) {
String timerecoder = Util.null2String(RecordSet.getString("temp")) ;
if( timerecoder.length() < 28 ) continue ;
if( !timerecoder.equals("") ) {
String usercode = timerecoder.substring(18,28) ;
String tempdate = timerecoder.substring(3,11) ;
String temptime = timerecoder.substring(11,15) ;
String thedatestr = tempdate.substring(0,4) +"-"+
tempdate.substring(4,6) +"-"+
tempdate.substring(6,8) ;
if( tempdate.compareTo(thestartdate) >= 0 && tempdate.compareTo(theenddate) <= 0 ) {
String thetime = temptime.substring(0,2) +":"+
temptime.substring(2,4) ;
int usercodeindex = userdates.indexOf(usercode+"_"+thedatestr) ;
if( usercodeindex == -1 ) {
userdates.add(usercode+"_"+thedatestr) ;
if( thetime.compareTo("12:00") > 0 ) {
outtimes.add(thetime) ;
intimes.add("") ;
}
else {
intimes.add(thetime) ;
outtimes.add("") ;
}
}
else {
if( thetime.compareTo("12:00") > 0 ) outtimes.set(usercodeindex,thetime) ;
else intimes.set(usercodeindex,thetime) ;
}
}
}
}
thedate.add(Calendar.DATE , 1) ;
tempstartdate = Util.add0(thedate.get(Calendar.YEAR) , 4) +
Util.add0(thedate.get(Calendar.MONTH) + 1 , 2) +
Util.add0(thedate.get(Calendar.DAY_OF_MONTH) , 2) ;
}
ExcelFile.init ();
ExcelFile.setFilename(startdate+" - " + enddate) ;
ExcelStyle es = ExcelFile.newExcelStyle("Header") ;
es.setGroundcolor(ExcelStyle.WeaverHeaderGroundcolor) ;
es.setFontcolor(ExcelStyle.WeaverHeaderFontcolor) ;
es.setFontbold(ExcelStyle.WeaverHeaderFontbold) ;
es.setAlign(ExcelStyle.WeaverHeaderAlign) ;
ExcelSheet et = ExcelFile.newExcelSheet("Timecard") ;
et.addColumnwidth(8000) ;
et.addColumnwidth(8000) ;
et.addColumnwidth(8000) ;
et.addColumnwidth(8000) ;
ExcelRow er = null ;
er = et.newExcelRow() ;
er.addStringValue("Usercode","Header");
er.addStringValue("Date","Header");
er.addStringValue("Intime","Header");
er.addStringValue("Outtime","Header");
for( int i = 0 ; i< userdates.size() ; i++ ) {
String userdate = (String) userdates.get(i) ;
String userdatearr[] = Util.TokenizerString2(userdate,"_") ;
String usercode = userdatearr[0] ;
String thedatestr = userdatearr[1] ;
String intime = (String) intimes.get(i) ;
String outtime = (String) outtimes.get(i) ;
er = et.newExcelRow() ;
er.addStringValue(usercode);
er.addStringValue(thedatestr);
er.addStringValue(intime);
er.addStringValue(outtime);
}
%>
<br>
<%=SystemEnv.getHtmlLabelName(16723,user.getLanguage())%> <a href="/weaver/weaver.file.ExcelOut"><%=startdate%> - <%=enddate%>.xls</a>
<br>