package com.ibiz.core.module.service.logic.impl;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

import com.ibiz.core.module.service.logic.IPSCreateAndStartIMLogic;
import com.ibiz.core.module.domain.PS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.KieContainer;

/**
 * 关系型数据实体[CreateAndStartIM] 对象
 */
@Service
public class PSCreateAndStartIMLogicImpl implements IPSCreateAndStartIMLogic{

    @Autowired
    private KieContainer kieContainer;

    @Autowired
    private com.ibiz.core.module.service.IPSService psservice;
    @Autowired
    private com.ibiz.core.module2.service.IIMService imservice;

    @Autowired
    private com.ibiz.core.module.service.IPSService iBzSysDefaultService;

    public void execute(PS et){

          KieSession kieSession = null;
        try{
           kieSession=kieContainer.newKieSession();
           kieSession.insert(et); 
           kieSession.setGlobal("pscreateandstartimdefault",et);
           com.ibiz.core.module2.domain.IM  pscreateandstartimim =new com.ibiz.core.module2.domain.IM();
           kieSession.insert(pscreateandstartimim); 
           kieSession.setGlobal("pscreateandstartimim",pscreateandstartimim);
           kieSession.setGlobal("psservice",psservice);
           kieSession.setGlobal("imservice",imservice);
           kieSession.setGlobal("iBzSysPsDefaultService",iBzSysDefaultService);
           kieSession.startProcess("com.ibiz.core.module.service.logic.pscreateandstartim");

        }catch(Exception e){
            throw new RuntimeException("执行[CreateAndStartIM]处理逻辑发生异常"+e);
        }finally {
            if(kieSession!=null)
            kieSession.destroy();
        }
    }

}
