package com.engine.htxc.workflow.create.service.impl;

import com.engine.core.impl.Service;
import com.engine.htxc.workflow.create.cnum.Converclasspage;
import com.engine.htxc.workflow.create.cnum.Workflowenum;
import com.engine.integration.util.StringUtils;
import weaver.general.Util;
import weaver.hrm.User;
import java.lang.reflect.Method;
import java.util.Map;

/**
 * @author K1810015
 * @version 1.0.0
 * @ClassName CustomizeworkflowService.java
 * @createTime 2022年07月15日 09:50:00
 */
public class CustomizeworkflowServiceImpl extends Service implements com.engine.htxc.workflow.create.service.CustomizeworkflowService {

    @Override
    public int createContractEnd(Map<String,Object> map, User user) {
        String unkey= Util.null2String(map.get("unkey"));
        map.put("creatorid",user.getUID());
        Converclasspage converclasspage=new Converclasspage();
        Workflowenum workflowenum=converclasspage.selectClassPage(unkey);
        if(workflowenum==null || StringUtils.isBlank(workflowenum.getClassname()) || "-1".equals(workflowenum.getClassname())){
            return -1;
        }
        try {
            String pagevalue = workflowenum.getClasspackage();
            Class classvalue = Class.forName(pagevalue);
            Object ob= classvalue.getConstructor(Map.class).newInstance(map);
            Method m = classvalue.getMethod("create");
            Integer internum= (Integer) m.invoke(ob);
            return internum;
        }catch (Exception e){
            return -1;
        }

    }


}
