package weaver.interfaces.htxc.contract.action;

import com.engine.common.util.ServiceUtil;
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.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 ConvertionsAction.java
 * @createTime 2022年07月22日 11:14:00
 * @Remark 合同办结触发履约
 */
public class ConvertionsAction  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","convention");
        int newdocid= customizeworkflowService.createContractEnd(map,user);
        if(newdocid>0){
            return Action.SUCCESS;
        }else{
            return Action.FAILURE_AND_CONTINUE;
        }
    }
}
