package com.engine.htsc.zbtybx.dao;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;

import java.util.HashMap;
import java.util.Map;

public class YdbxModeDataCMD extends AbstractCommonCommand<Map<String, Object>> {
    @Override
    public BizLogContext getLogContext() {
        return null;
    }
    public YdbxModeDataCMD(User user, Map<String,Object> params){
        this.user = user;
        this.params = params;
    }

    @Override
    public Map<String, Object> execute(CommandContext commandContext) {

        RecordSet rs = new RecordSet();
        Map<String, Object> back = new HashMap<>();
        BaseBean bb = new BaseBean();
        bb.writeLog("=======================YdbxModeDataCMD============================");
        String ids = Util.null2String(params.get("ids"));
        //requestid
        String requid = "";
        Boolean flag = false;
        String reqsql = "select reqid from uf_zfmx where id in (?)";
        rs.executeQuery(reqsql,ids);
        bb.writeLog("执行的sql=========================="+reqsql);
        StringBuffer stb = new StringBuffer();
        while (rs.next()){
            requid = Util.null2String(rs.getString("reqid"));
            if (stb.length() > 0) {
                stb.append(",");
            }
            stb.append(requid);
        }
        if (stb.length()>0){
            String delsql = "delete from uf_ydbxxx where requid in (?)";
            flag = rs.executeUpdate(delsql,stb.toString());
            bb.writeLog("执行的sql---------------------------"+delsql+"结果------------"+flag);
        }
        if(flag){
            back.put("result",true);
            return back;
        }else {
            back.put("result",false);
            return back;
        }
    }
}
