<%@ page import="weaver.general.*" %>
<%@ page import="weaver.conn.RecordSet"%>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.ParseException" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>

<%
    BaseBean bb = new BaseBean();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String type = Util.null2String(request.getParameter("type"));
    Map<String,String> lastscop = new HashMap<String,String>();

    String startdate = "";
    String enddate = "";
    int currentYear = 0 ;
    int currentMonth = 0;
    int lastYear = 0;
    int lastMonth = 0 ;
    int last2Year = 0;
    int last2Month = 0 ;
    if("1".equals(type)){
        String year = Util.null2String(request.getParameter("year"));
        String month = Util.null2String(request.getParameter("month"));
        try {
            Calendar cal = Calendar.getInstance();
            cal.setTime(sdf.parse(year+"-"+month+"-01"));
            currentYear = cal.get(Calendar.YEAR);//获取年
            currentMonth = cal.get(Calendar.MONTH)+1;//获取月（月份从0开始，如果按照中国的习惯，需要加一）
        } catch (ParseException e) {
            e.printStackTrace();
        }

        try {
            Calendar cal = Calendar.getInstance();
            cal.setTime(sdf.parse(year+"-"+month+"-01"));
            cal.add(Calendar.MONTH, -1);
            lastYear = cal.get(Calendar.YEAR);//获取年
            lastMonth = cal.get(Calendar.MONTH)+1;//获取月（月份从0开始，如果按照中国的习惯，需要加一）
        } catch (ParseException e) {
            e.printStackTrace();
        }

        try {
            Calendar cal = Calendar.getInstance();
            cal.setTime(sdf.parse(year+"-"+month+"-01"));
            cal.add(Calendar.MONTH, -2);
            last2Year = cal.get(Calendar.YEAR);//获取年
            last2Month = cal.get(Calendar.MONTH)+1;//获取月（月份从0开始，如果按照中国的习惯，需要加一）
        } catch (ParseException e) {
            e.printStackTrace();
        }

        if(currentMonth == 1){
            startdate = (currentYear-1)+"-01-01";
            enddate = (currentYear-1)+"-12-31";
        }else{
            startdate = currentYear+"-01-01";
            enddate = currentYear+"-12-31";
        }

    }else{

        Calendar cal1 = Calendar.getInstance();
        currentYear = cal1.get(Calendar.YEAR);//获取年
        currentMonth = cal1.get(Calendar.MONTH)+1;//获取月（月份从0开始，如果按照中国的习惯，需要加一）


        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(new Date());
        cal2.add(Calendar.MONTH, -1);
        lastYear = cal2.get(Calendar.YEAR);//获取年
        lastMonth = cal2.get(Calendar.MONTH)+1;//获取月（月份从0开始，如果按照中国的习惯，需要加一）

        Calendar cal3 = Calendar.getInstance();
        cal3.setTime(new Date());
        cal3.add(Calendar.MONTH, -2);

        if(currentMonth == 1){
            startdate = (currentYear-1)+"-01-01";
            enddate = (currentYear-1)+"-12-31";
        }else{
            startdate = currentYear+"-01-01";
            enddate = currentYear+"-12-31";
        }
    }

    User user = HrmUserVarify.getUser(request , response);
    int userid = user.getUID();

    bb.writeLog("startdate:"+startdate);
    bb.writeLog("enddate:"+enddate);

    String scopid = "" ;
    String scorename = "" ;
    String year = "" ;
    String type1 = "" ;
    String type2 = "" ;
    String status = "" ;
    String isvalid = "" ;
    RecordSet rs = new RecordSet();
    String sql = " select * from GP_AccessScore t1 where t1.userid=? and year=? and type2=? ";
    out.print("sql:"+sql);
    bb.writeLog(sql);
    rs.executeQuery(sql,new Object[]{userid,lastYear,lastMonth});
    if(rs.next()){
        scopid = Util.null2String(rs.getString("id"));
        scorename = Util.null2String(rs.getString("scorename"));
        year = Util.null2String(rs.getString("year"));
        type1 = Util.null2String(rs.getString("type1"));
        type2 = Util.null2String(rs.getString("type2"));
        status = Util.null2String(rs.getString("status"));
        isvalid = Util.null2String(rs.getString("isvalid"));
    }

    out.print("scorename:"+scorename);
    out.print("scopid:"+scopid);
    out.print("year:"+year);
    out.print("type2:"+type2);
    out.print("type1:"+type1);
    out.print("status:"+status);
    out.print("isvalid:"+isvalid);

%>


<%!


%>


