package weaver.interfaces.htxc.contract.action;

import com.engine.common.util.ServiceUtil;
import com.engine.htxc.commonutil.db.DbTools;
import com.engine.htxc.commonutil.log.CustomizeLog;
import com.engine.htxc.workflow.create.service.CustomizeworkflowService;
import com.engine.htxc.workflow.create.service.impl.CustomizeworkflowServiceImpl;
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;

/**
 * @author K1810015
 * @version 1.0.0
 * @ClassName WrokFlowEnd.java
 * @createTime 2022年07月18日 09:47:00
 * @Remark 合同触发签订  --合同状态 待签订
 */
public class ContractApprovaltosingAction extends BaseBean implements Action{

    private CustomizeworkflowService customizeworkflowService=
            ServiceUtil.getService(CustomizeworkflowServiceImpl.class);

    @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;
        }

        Map<String,Object> map=new HashMap<>();
        map.put("requestid",requestid);
        map.put("creatorid",user.getUID());
        map.put("unkey","approvaltosign");
       int newdocid= customizeworkflowService.createContractEnd(map,user);
        if(newdocid>0){
            return Action.SUCCESS;
        }else{
            return Action.FAILURE_AND_CONTINUE;
        }
    }
}
