package com.engine.htsc.zhfw.web;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.interfaces.htsc.comInfo.PropBean;
import weaver.workflow.request.wfAgentCondition;

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;
import java.util.*;

public class ZhFwControlAction {



    @GET
    @Path("/getJudgeSendZxms")
    @Produces({MediaType.TEXT_PLAIN})
    public String getJudgeSendZxms(@Context HttpServletRequest request, @Context HttpServletResponse response) {

        RecordSet rs = new RecordSet();
        BaseBean bb = new BaseBean();
        String requestid = Util.null2String(request.getParameter("requestid"));
        int sfty = 0;
        String nodenames = "" ;
        if(!"".equals(requestid)){
            String sql =" select l.*,p.nodename from (\n" +
                    "   select nodeid,logtype,row_number() over(partition by nodeid order by logid desc) as xh\n" +
                    "   from workflow_requestlog t\n" +
                    "   where requestid =" + requestid+
                    "   and nodeid in(select id from workflow_nodebase \n" +
                    "   where unnumber in('zhfw_sxcwg','zhfw_hgzj','zhfw_sxfxg'))\n" +
                    " ) l \n" +
                    " left join workflow_nodebase p on p.id = l.nodeid\n" +
                    " where l.xh=1 and logtype = 3 ";


            rs.execute(sql);
            while(rs.next()){
                nodenames += nodenames=="" ? Util.null2String(rs.getString("nodename")) : "、"+Util.null2String(rs.getString("nodename")) ;
                sfty++;
            }
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("sfty",sfty);
        jsonObject.put("nodenames",nodenames);

        return JSONObject.toJSONString(jsonObject);
    }



}
