package com.engine.htsc.dgtfw.web;

import com.alibaba.fastjson.JSONObject;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.htsc.comInfo.PropBean;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

public class DgtFwControlAction {

    /**
     * 查询人员待办
     * @param request
     * @param response
     * @return
     */
    @GET
    @Path("/getfsjdxybz")
    @Produces({MediaType.TEXT_PLAIN})
    public String getFsjdXybz(@Context HttpServletRequest request, @Context HttpServletResponse response){
        BaseBean bb = new BaseBean();
        PropBean pb = new PropBean();
        RecordSet rs = new RecordSet();
        JSONObject dataJson = new JSONObject();
        int requestid = Util.getIntValue(Util.null2String(request.getParameter("requestid")));//申报类型
        try{
            String dgtfw_twsj = pb.getPropName("dgtfw_twsj");
            String TWSJSHJD = pb.getNodeIdsByUnNumber(dgtfw_twsj);

            String dgtfw_ghzx = pb.getPropName("dgtfw_ghzx");
            String GHZXSHJD = pb.getNodeIdsByUnNumber(dgtfw_ghzx);

            String dgtfw_ldhq = pb.getPropName("dgtfw_ldhq");
            String LDHQJD = pb.getNodeIdsByUnNumber(dgtfw_ldhq);

            String dgtfw_dwfsj = pb.getPropName("dgtfw_dwfsj");
            String DWFSJSPJD = pb.getNodeIdsByUnNumber(dgtfw_dwfsj);

            String dgtfw_dwsj = pb.getPropName("dgtfw_dwsj");
            String DWSJSPJD = pb.getNodeIdsByUnNumber(dgtfw_dwsj);

            String dgtfw_pbbh = pb.getPropName("dgtfw_pbbh");
            String PBBHJD = pb.getNodeIdsByUnNumber(dgtfw_pbbh);

            bb.writeLog("TWSJSHJD:"+TWSJSHJD);

            String selectvalues = "0,2";
            String sql = " select logid from workflow_requestlog where requestid="+requestid + " and nodeid in("+TWSJSHJD+")" ;
            bb.writeLog("sql:"+sql);
            rs.executeQuery(sql);
            if(rs.next())
            {
                selectvalues = selectvalues + ",3";
            }

            sql = " select logid from workflow_requestlog where requestid="+requestid + " and nodeid in("+GHZXSHJD+")" ;
            bb.writeLog("sql:"+sql);
            rs.executeQuery(sql);
            if(rs.next())
            {
                selectvalues = selectvalues + ",4";
            }

            sql = " select logid from workflow_requestlog where requestid="+requestid + " and nodeid in("+LDHQJD+")" ;
            bb.writeLog("sql:"+sql);
            rs.executeQuery(sql);
            if(rs.next())
            {
                selectvalues = selectvalues + ",5";
            }

            sql = " select logid from workflow_requestlog where requestid="+requestid + " and nodeid in("+DWFSJSPJD+")" ;
            bb.writeLog("sql:"+sql);
            rs.executeQuery(sql);
            if(rs.next())
            {
                selectvalues = selectvalues + ",6";
            }

            sql = " select logid from workflow_requestlog where requestid="+requestid + " and nodeid in("+DWSJSPJD+")" ;
            bb.writeLog("sql:"+sql);
            rs.executeQuery(sql);
            if(rs.next())
            {
                selectvalues = selectvalues + ",7";
            }
            sql = " select logid from workflow_requestlog where requestid="+requestid + " and nodeid in("+PBBHJD+")" ;
            bb.writeLog("sql:"+sql);
            rs.executeQuery(sql);
            if(rs.next())
            {
                selectvalues = selectvalues + ",8";
            }
            dataJson.put("selectvalue",selectvalues);
        }catch (Exception e){
            bb.writeLog("e:"+e);
        }
        return dataJson.toJSONString();
    }

}
