package weaver.interfaces.htsc.tgpt;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.hrm.User;
import weaver.interfaces.htsc.GlobatTools.JAVATools;
import weaver.soa.workflow.request.DetailTableInfo;
import weaver.soa.workflow.request.MainTableInfo;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import weaver.interfaces.workflow.action.Action;
/**
 * @Title: ecology-9
 * @Company: 泛微软件
 * @author: K1810039
 * @version: 1.0
 * @CreateDate: 2022-08-19
 * @Description: 向建模写数据
 * @ModifyLog:
 **/
public class WriteDataToMode  extends BaseBean implements Action {


    @Override
    public String execute(RequestInfo requestinfo) {
        System.out.println("进入Action requestid="+requestinfo.getRequestid());
        String requestid = requestinfo.getRequestid();//请求ID
         String requestlevel = requestinfo.getRequestlevel();//请求紧急程度
         String src = requestinfo.getRequestManager().getSrc();  //当前操作类型 submit:提交/reject:退回
         String workflowid = requestinfo.getWorkflowid();//流程ID
         String tablename = requestinfo.getRequestManager().getBillTableName();//表单名称
         int billid = requestinfo.getRequestManager().getBillid();//表单数据ID
         User usr = requestinfo.getRequestManager().getUser();//获取当前操作用户对象
         String requestname = requestinfo.getRequestManager().getRequestname();//请求标题
         String remark = requestinfo.getRequestManager().getRemark();//当前用户提交时的签字意见
         int formid = requestinfo.getRequestManager().getFormid();//表单ID
         int isbill = requestinfo.getRequestManager().getIsbill();//是否是自定义表单
        try{
            RecordSet rs = new RecordSet();
            RecordSet dtrs = new RecordSet();
            String sql = "select * from  "+tablename +" where requestid = "+requestid;
            rs.execute(sql);
            rs.next();
            String jmid = rs.getString("jmid");
            String id= rs.getString("id");
            String dtSql = "select * from "+tablename+"_dt4 where mainid = "+id ;
            rs.execute(dtSql);
            while(rs.next()){
                String hfsj = rs.getString("hfsj");
                String wtda = rs.getString("wtda");
                String xgxzry = rs.getString("xgxzry");
                String insertSql = "insert into uf_ehd_dt1 (mainid,xgxzr,wtda,hfsj) values ('"+jmid+"','"+xgxzry+"','"+wtda+"','"+hfsj+"')";
                JAVATools.writelog("e互动保存明细表sql"+insertSql);
                dtrs.execute(insertSql);
            }

        }catch (Exception e){
            return Action.FAILURE_AND_CONTINUE;
        }
        return Action.SUCCESS;
    }
}
