arenaLimit.jsp 2.67 KB
<%--
  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);
        }
    }

%>