package com.customization.htsc.jgxtlc;

/**
 * @author xf
 * @version 1.0.0
 * @ClassName JgxtlcRequestRemarkSubmitFjCmd.java
 * @createTime 2021年10月28日 19:51:00
 */

import com.engine.common.util.ParamUtil;
import com.engine.core.cfg.annotation.CommandDynamicProxy;
import com.engine.core.interceptor.AbstractCommandProxy;
import com.engine.core.interceptor.Command;
import com.engine.workflow.cmd.requestForm.RemarkSubmitCmd;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.htsc.GlobatTools.JAVATools;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@CommandDynamicProxy(target = RemarkSubmitCmd.class, desc = "监管协同流程流程提交更新主表附件")
public class JgxtlcRequestRemarkSubmitFjCmd extends AbstractCommandProxy<Map<String, Object>> {
    @Override
    public Map<String, Object> execute(Command<Map<String, Object>> command) {

        BaseBean bb = new BaseBean();
        JAVATools.SetCmdwritelog("RemarkSubmitCmd:ceshi");
        RecordSet rs = new RecordSet();
        RemarkSubmitCmd remarkSubmitCmd = (RemarkSubmitCmd) command;
        HttpServletRequest request = remarkSubmitCmd.getRequest(); //从request中可以取到参数，不用以前的方法了
        Map<String,Object> param = ParamUtil.request2Map(request);
        for (String key:param.keySet()){
            JAVATools.SetCmdwritelog("测试jgxt:"+key+param.get(key));
        }
        String requestid = Util.null2String(request.getParameter("requestid"));
        String workflowid = Util.null2String(request.getParameter("workflowid"));
        String nodeid = Util.null2String(request.getParameter("nodeid"));
        String formid = Util.null2String(request.getParameter("formid")) ;

        String src = Util.null2String(request.getParameter("src"));
        bb.writeLog("requestid:"+requestid);
        bb.writeLog("workflowid:"+workflowid );
        bb.writeLog("src:"+src);
        Map<String, Object> result  = nextExecute(command);;
        try{

            if(!"".equals(nodeid))
            {
                int current_nodeid = Util.getIntValue(nodeid);
                if("save".equals(src)  && current_nodeid < 0)
                {
                    bb.writeLog("3333333");
                    if(!"".equals(workflowid)){
                        String unnumber = "" ;
                        String sql = " select unnumber from workflow_base where id="+workflowid;
                        rs.execute(sql);
                        if(rs.next()){
                            unnumber = Util.null2String(rs.getString("unnumber"));
                        }
                        bb.writeLog("unnumber："+unnumber);
                        if("jgxtsq".equals(unnumber)){
                            sql = " update formtable_main_"+Math.abs(Util.getIntValue(formid))+" set fkfj='' where requestid="+requestid;
                            boolean flag = rs.execute(sql);
                            bb.writeLog("JgxtlcRequestSubmitUpdateFjCmd---flag:"+flag);
                        }
                    }
                }else{
                    bb.writeLog("4444444：");
                }
            }
        }catch (Exception e){
            bb.writeLog("JgxtlcRequestSubmitUpdateFjCmd："+e);
        }
        return result;
    }


}
