package weaver.interfaces.htxc.contract.action;

import com.engine.htxc.commonutil.db.DbTools;
import com.engine.htxc.workflow.create.business.contract.util.ContracrtBaseUtil;
import com.engine.integration.util.StringUtils;
import com.weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

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

import static com.engine.htxc.workflow.create.business.contract.init.ContractType.ContractwaitSign;

/**
 * @author K1810015
 * @version 1.0.0
 * @ClassName ContractUpdatesignstatus.java
 * @createTime 2022年07月25日 15:51:00
 * @Remark 流程走向修改建模的用印状态
 */
public class ContractUpdatesignstatus extends BaseBean implements Action {

    public String getSigntype() {
        return signtype;
    }

    public void setSigntype(String signtype) {
        this.signtype = signtype;
    }

    public String signtype;


    @Override
    public String execute(RequestInfo requestInfo) {
        String requestid=requestInfo.getRequestid();
        User user =requestInfo.getRequestManager().getUser();

        if(StringUtils.isBlank(requestid) || user==null ){
            return Action.FAILURE_AND_CONTINUE;
        }
        try {
            updatestatus(requestid);
            return Action.SUCCESS;
        }catch (Exception e){
            return Action.FAILURE_AND_CONTINUE;
        }

    }

    public void updatestatus(String requestid){
        DbTools dbtools=new DbTools();
        Map<String,Object> mainmap=dbtools.getRequestidToMap(requestid,null);
        String xzhtlb= Util.null2String(mainmap.get("xzhtlb"));
        String htbb=Util.null2String(mainmap.get("htbb"));
        Map<String,Object> wheremap=new HashMap<>();
        wheremap.put("htbh",xzhtlb);
        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<>();
        wheremapmodel.put("id",contractmodeid);
        Map<String,String> setmap=new HashMap<>();
        setmap.put("yyjgdzt", signtype);
        dbtools.updateSql(tablename,setmap,wheremapmodel);
    }
}
