32 changed files with 204 additions and 160 deletions
@ -0,0 +1,86 @@ |
|||||
|
package io.sc.engine.rule.server.common.initializer; |
||||
|
|
||||
|
import io.sc.engine.rule.server.common.service.RuleEngineServerConfigurationService; |
||||
|
import io.sc.platform.core.Environment; |
||||
|
import io.sc.platform.core.initializer.ApplicationInitializer; |
||||
|
import io.sc.platform.core.initializer.ApplicationInitializerExecuteException; |
||||
|
import io.sc.platform.flowable.enums.ProcessStatus; |
||||
|
import io.sc.platform.flowable.jpa.entity.ProcessEntity; |
||||
|
import io.sc.platform.flowable.service.ProcessEntityService; |
||||
|
import io.sc.platform.util.FileUtil; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.context.ApplicationContext; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.util.List; |
||||
|
import java.util.Locale; |
||||
|
|
||||
|
public class RateUpdateWorkFlowInitializer implements ApplicationInitializer{ |
||||
|
public static final String RRATE_UPDATE_CANCEL_WORKFLOW_CATEGORY ="WORK_FLOW"; |
||||
|
public static final String RATE_UPDATE_CANCEL_WORKFLOW_KEY ="RATE_UPDATE_CANCEL_APPROVING"; |
||||
|
private static final Logger log =LoggerFactory.getLogger(RateUpdateWorkFlowInitializer.class); |
||||
|
private Boolean isInitialized =null; |
||||
|
private ApplicationContext applicationContext; |
||||
|
private ProcessEntityService processEntityService; |
||||
|
|
||||
|
@Override |
||||
|
public void init(ApplicationContext applicationContext) { |
||||
|
this.processEntityService =applicationContext.getBean(ProcessEntityService.class); |
||||
|
this.applicationContext =applicationContext; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int getOrder() { |
||||
|
return 1200; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public synchronized boolean isInitialized() { |
||||
|
if(isInitialized!=null) { |
||||
|
return isInitialized; |
||||
|
} |
||||
|
List<ProcessEntity> entities =processEntityService.getRepository().findByKey(RATE_UPDATE_CANCEL_WORKFLOW_KEY); |
||||
|
if(entities==null || entities.isEmpty()){ |
||||
|
isInitialized =false; |
||||
|
}else { |
||||
|
isInitialized = true; |
||||
|
} |
||||
|
return isInitialized; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void execute() throws ApplicationInitializerExecuteException { |
||||
|
try { |
||||
|
ProcessEntity entity = new ProcessEntity(); |
||||
|
entity.setCategory(RATE_UPDATE_CANCEL_WORKFLOW_KEY); |
||||
|
entity.setKey(RATE_UPDATE_CANCEL_WORKFLOW_KEY); |
||||
|
entity.setName(applicationContext.getMessage(RRATE_UPDATE_CANCEL_WORKFLOW_CATEGORY + "." + RATE_UPDATE_CANCEL_WORKFLOW_KEY, null, Locale.getDefault())); |
||||
|
entity.setStatus(ProcessStatus.RELEASE); |
||||
|
entity.setVersion(1); |
||||
|
entity.setCanClaimTask(false); |
||||
|
entity.setXml(getRateUpdateCancelWorkflowXmlContent()); |
||||
|
entity.setBusinessDescriptionSql( |
||||
|
"select\n" + |
||||
|
" CONCAT(CODE_,':',VERSION_) BUSINESS_KEY,\n" + |
||||
|
" '模型发布审批' BUSINESS_TYPE,\n" + |
||||
|
" NAME_ CUST_NO,\n" + |
||||
|
" CONCAT('V',VERSION_) CUST_NAME,\n" + |
||||
|
" NULL PROCESS_STATUS\n" + |
||||
|
"from RE_RESOURCE\n" + |
||||
|
"where CONCAT(CODE_,':',VERSION_) = '${businessKey}'" |
||||
|
); |
||||
|
entity.setTaskHandFrontendModelName("io.sc.engine.rule.frontend"); |
||||
|
entity.setTaskHandFrontendComponentName("io.sc.engine.rule.frontend.workflow.ApprovalComponent"); |
||||
|
entity = processEntityService.add(entity); |
||||
|
processEntityService.deploy(entity.getId()); |
||||
|
}catch (Exception e){ |
||||
|
log.error("",e); |
||||
|
throw new ApplicationInitializerExecuteException(e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private String getRateUpdateCancelWorkflowXmlContent() throws IOException { |
||||
|
return FileUtil.readString("classpath:/workflow/io/sc/engine/rule/Sample.bpmn", Environment.DEFAULT_CHARSET_NAME); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue