arenaLimit.jsp
2.67 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
<%--
Created by IntelliJ IDEA.
User: zhaiyaqi
Date: 2020/3/15
Time: 7:34 PM
To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="org.apache.commons.logging.Log" %>
<%@ page import="org.apache.commons.logging.LogFactory" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
response.setContentType("application/json;charset=utf-8");
out.clear();
writeLog("【开始调用test接口】:");
JSONObject result = new JSONObject(true);
User user = HrmUserVarify.getUser(request,response);
writeLog("user=========================" + JSONObject.toJSONString(user));
try {
int uid = user.getUID();
writeLog("uid============="+uid);
RecordSet recordSet = new RecordSet();
String sql = "select count(*) as num,max(tpsj) as maxTime from uf_tyjtgjdlkpb where tpr ="+uid+"" ;
recordSet.execute(sql);
while (recordSet.next()){
String num = recordSet.getString("num");
String maxTime = recordSet.getString("maxTime");
writeLog("num========"+num);
if (!num.equals("0")){
//已经投过票了哦
//判断是否本季度投票的
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");//设置日期格式
String date=df.format(new Date());
String MM=date.substring(4, 6);//截取系统月份
String substring = maxTime.substring(5, 7);
if (MM.equals(substring)){
result.put("code", 1);
result.put("message", "本季度已投过票");
}else{
result.put("code", 0);
result.put("message", "本季度暂未投票");
}
}else{
result.put("code", 0);
result.put("message", "本季度暂未投票");
}
}
} catch (Exception e) {
result.put("code", -1);
result.put("message", "接口处理异常"+e.getMessage());
}
out.print(result.toJSONString());
%>
<%!
private void writeLog(Object o) {
Log var3 = LogFactory.getLog(this.getClass().getName());
if(o instanceof Exception) {
var3.info(this.getClass().getName(), (Exception)o);
} else {
var3.info(o);
}
}
%>