votingCheckVote.jsp
4.24 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
<%@ page language="java" contentType="json; charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.Timestamp" %>
<%@ page import="weaver.hrm.*" %>
<%@ page import="weaver.systeminfo.setting.HrmUserSettingComInfo" %>
<jsp:useBean id="VotingManager" class="weaver.voting.VotingManager" scope="page" />
<%@ page import="weaver.systeminfo.*" %>
<%@ page import="weaver.general.StaticObj,
weaver.general.Util" %>
<%@ page import="net.sf.json.*,com.sap.mw.jco.JCO" %>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="signRs" class="weaver.conn.RecordSet" scope="page"/>
<%
response.setHeader("cache-control", "no-cache");
response.setHeader("pragma", "no-cache");
response.setHeader("expires", "Mon 1 Jan 1990 00:00:00 GMT");
String agent=request.getHeader("User-Agent").toLowerCase();
if(agent.indexOf("firefox")>0){
response.setContentType("application/json");
}
%>
<%
User user = HrmUserVarify.getUser (request , response) ;
if(user == null) return ;
HrmUserSettingComInfo userSetting=new HrmUserSettingComInfo();
String belongtoshow = userSetting.getBelongtoshowByUserId(user.getUID()+"");
String belongtoids = user.getBelongtoids();
String account_type = user.getAccount_type();
String voteids="";
String voteshows="";
String forcevotes="";
boolean isSys=true;
RecordSet.executeSql("select 1 from hrmresource where id="+user.getUID());
if(RecordSet.next()){
isSys=false;
}
Date votingnewdate = new Date() ;
long votingdatetime = votingnewdate.getTime() ;
Timestamp votingtimestamp = new Timestamp(votingdatetime) ;
String votingCurrentDate = (votingtimestamp.toString()).substring(0,4) + "-" + (votingtimestamp.toString()).substring(5,7) + "-" +(votingtimestamp.toString()).substring(8,10);
String votingCurrentTime = (votingtimestamp.toString()).substring(11,13) + ":" + (votingtimestamp.toString()).substring(14,16);
String votingsql="";
//主次账号各自弹出各自的
if(false && belongtoshow.equals("1")&&account_type.equals("0")&&!belongtoids.equals("")){
belongtoids +=","+user.getUID();
votingsql="select distinct t1.id,t1.autoshowvote,t1.forcevote from voting t1 where t1.status=1 "+
" and (t1.beginDate<'"+votingCurrentDate+"' or (t1.beginDate='"+votingCurrentDate+"' and (t1.beginTime is null or t1.beginTime='' or t1.beginTime<='"+votingCurrentTime+"'))) ";
votingsql +=" and (";
String[] votingshareids=Util.TokenizerString2(belongtoids,",");
for(int i=0;i<votingshareids.length;i++){
User tmptUser=VotingManager.getUser(Util.getIntValue(votingshareids[i]));
if(i==0){
votingsql += " ( id not in (select votingid from VotingRemark where resourceid="+tmptUser.getUID()+")" +
" and id in(select distinct votingid from VotingShareDetail where resourceid="+tmptUser.getUID()+")";
} else {
votingsql += " or ( id not in (select votingid from VotingRemark where resourceid="+tmptUser.getUID()+")" +
" and id in(select distinct votingid from VotingShareDetail where resourceid="+tmptUser.getUID()+")";
}
}
votingsql +=")";
}else{
votingsql="select distinct t1.id,t1.autoshowvote,t1.forcevote from voting t1 where t1.status=1 "+
" and t1.id not in (select distinct votingid from VotingRemark where resourceid ="+user.getUID()+")"+
" and (t1.beginDate<'"+votingCurrentDate+"' or (t1.beginDate='"+votingCurrentDate+"' and (t1.beginTime is null or t1.beginTime='' or t1.beginTime<='"+votingCurrentTime+"')))"+
" and t1.id in(select distinct votingid from VotingShareDetail where resourceid="+user.getUID()+")";
}
if(isSys){
votingsql +=" and 1=2";
}
//signRs.writeLog("###abc:"+votingsql);
signRs.executeSql(votingsql);
while(signRs.next()){
String votingid = signRs.getString("id");
String voteshow = signRs.getString("autoshowvote");
String forcevote = signRs.getString("forcevote");
if(voteids.equals("")){
voteids = votingid;
voteshows = voteshow;
forcevotes = forcevote;
}else{
voteids =voteids + "," + votingid;
voteshows =voteshows + "," + voteshow;
forcevotes =forcevotes + "," + forcevote;
}
}
JSONObject jsa = new JSONObject();
jsa.put("voteids", voteids);
jsa.put("voteshows", voteshows);
jsa.put("forcevotes", forcevotes);
jsa.put("title", SystemEnv.getHtmlLabelName(17599,user.getLanguage()));
out.print(jsa.toString());
%>