package weaver.interfaces.htxc.contract.action;
import com.engine.htxc.commonutil.db.DbTools;
import com.engine.htxc.commonutil.log.CustomizeLog;
import com.engine.htxc.workflow.create.business.contract.util.ContracrtBaseUtil;
import com.weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>流程审批节点用印审批完之后修改状态</p>
 * @author K1810015
 * @version 1.0.0
 * @ClassName ContractEsealAfterAction.java
 * @createTime 2022年08月5日 00:09:12
 */
public class ContractEsealAfterAction  extends BaseBean implements Action {

    @Override
    public String execute(RequestInfo requestInfo) {
        CustomizeLog.printLog("合同审批节点：流程审批节点用印审批完之后修改状态-开始");
        String requestid=requestInfo.getRequestid();
        updatemodeinfo(requestid);
        CustomizeLog.printLog("合同审批节点：流程审批节点用印审批完之后修改状态-结束："+requestid);
        return Action.SUCCESS;
    }
    public void updatemodeinfo(String requestid){
        DbTools dbtools=new DbTools();
        Map<String,Object> mainmap=dbtools.getRequestidToMap(requestid,null);
        List<Map<String,Object>> listmap=dbtools.gettableall(requestid,4);
        if(listmap==null || listmap.size()<=0 || mainmap==null || mainmap.size()<=0){
            return ;
        }
        listmap.forEach((item)->{
            Map<String,String> dtmap=(HashMap) item;
            String htbh=Util.null2String(dtmap.get("htbh"));
            String htbb=Util.null2String(dtmap.get("htbb"));
            Map<String,Object> wheremap=new HashMap<>(2);
            wheremap.put("htbh",htbh);
            wheremap.put("htbb",htbb);
            Map<String,Object> requestnamemap= ContracrtBaseUtil.getufhtqcmap(wheremap);
            String contractmodeid=Util.null2String(requestnamemap.get("id"));
            String tablename="uf_htqc";
            Map<String,String> wheremapmodel=new HashMap<>(1);
            wheremapmodel.put("id",contractmodeid);
            Map<String,String> setmap=new HashMap<>(4);
            setmap.put("lkrqsfytsyq", Util.null2String(mainmap.get("lkrqsfytsyq")));
            setmap.put("yyrq", Util.null2String(mainmap.get("yyrq")));
            setmap.put("gdlx", Util.null2String(mainmap.get("gdlx")));
            setmap.put("tsyqms", Util.null2String(mainmap.get("tsyqms")));
            dbtools.updateSql(tablename,setmap,wheremapmodel);
        });

    }
}
