|
@@ -52,99 +52,54 @@ public class InitProcessTask { |
|
|
@Value("${hostname}") |
|
|
@Value("${hostname}") |
|
|
private String HOST_NAME; |
|
|
private String HOST_NAME; |
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 40 17 12 6 ?") |
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 30 18 12 6 ?") |
|
|
public void doTask() throws UnknownHostException { |
|
|
public void doTask() throws UnknownHostException { |
|
|
//if (HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { |
|
|
|
|
|
log.info("=========== 初始化丽水二期 系统表单和流程配置 ======== 任务开始"); |
|
|
|
|
|
StopWatch stopWatch = new StopWatch(); |
|
|
|
|
|
stopWatch.start(); |
|
|
|
|
|
//1.查出丽水市下的 区县 分别去初始化 表单和流程配置数据 |
|
|
|
|
|
List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_LS, RegionConst.RL_CITY); |
|
|
|
|
|
|
|
|
|
|
|
if(CollUtil.isEmpty(regions)){ |
|
|
|
|
|
throw new BizException("丽水地区数据为空 任务结束!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Map<String, WflowForms> formsMap = Maps.newConcurrentMap(); |
|
|
|
|
|
//2.首先插入表单默认配置 |
|
|
|
|
|
for(RegionDTO region : regions){ |
|
|
|
|
|
log.info("当前初始化的是 【{}】 表单信息",region.getRegionName()); |
|
|
|
|
|
|
|
|
|
|
|
//WflowForms existsForm = formsService.getOne(Wrappers.lambdaQuery(WflowForms.class) |
|
|
|
|
|
// .eq(WflowForms::getRegionCode, region.getRegionCode()) |
|
|
|
|
|
// .last("limit 1")); |
|
|
|
|
|
//if(Objects.nonNull(existsForm)){ |
|
|
|
|
|
// log.info("当前区域 【{}】 已经有表单数据 不需要初始化",region.getRegionName()); |
|
|
|
|
|
// formsMap.put(existsForm.getRegionCode(),existsForm); |
|
|
|
|
|
// continue; |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
WflowForms wflowForms = new WflowForms(); |
|
|
|
|
|
wflowForms.setFormId("fm" + IdUtil.objectId()); |
|
|
|
|
|
wflowForms.setCreateOn(LocalDateTime.now()); |
|
|
|
|
|
wflowForms.setUpdateOn(LocalDateTime.now()); |
|
|
|
|
|
wflowForms.setFormName(TaskContant.Wflow.DEFAULT_FORM_NAME); |
|
|
|
|
|
wflowForms.setRegionCode(region.getRegionCode()); |
|
|
|
|
|
wflowForms.setRegionName(region.getRegionName()); |
|
|
|
|
|
if(formsService.save(wflowForms)){ |
|
|
|
|
|
log.info("当前区域 【{}】 表单数据已经保存成功",region.getRegionName()); |
|
|
|
|
|
formsMap.put(wflowForms.getRegionCode(),wflowForms); |
|
|
|
|
|
}else{ |
|
|
|
|
|
log.info("当前区域 【{}】 表单数据已经保存失败",region.getRegionName()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//3.接着插入流程默认配置 |
|
|
|
|
|
for(RegionDTO region : regions){ |
|
|
|
|
|
log.info("当前初始化的是 【{}】 流程配置",region.getRegionName()); |
|
|
|
|
|
|
|
|
|
|
|
//if(processModelService.count(Wrappers.lambdaQuery(WflowModels.class) |
|
|
|
|
|
// .eq(WflowModels::getRegionCode,region.getRegionCode())) > 0){ |
|
|
|
|
|
// log.info("当前区域 【{}】 已经有流程数据 不需要初始化",region.getRegionName()); |
|
|
|
|
|
// continue; |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
// WflowForms form = formsMap.get(region.getRegionCode()); |
|
|
|
|
|
// if(Objects.isNull(form)){ |
|
|
|
|
|
// log.info("此区域 【{}】 没有对应form 不进行 流程配置初始化",region.getRegionName()); |
|
|
|
|
|
// continue; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
//Integer[] processTypeList = TaskContant.Wflow.DEFAULT_PROCESS_TYPE_LIST; |
|
|
|
|
|
|
|
|
|
|
|
Integer[] processTypeList = TaskContant.Wflow.APPLY_PROCESS_TYPE_LIST; |
|
|
|
|
|
for(Integer processType : processTypeList){ |
|
|
|
|
|
String formName = ProjectProcessStageEnum.getDesc(processType); |
|
|
|
|
|
WflowModelHistorysInsertDto models = new WflowModelHistorysInsertDto(); |
|
|
|
|
|
// models.setFormId("wf" + IdUtil.objectId()); |
|
|
|
|
|
// models.setVersion(1); |
|
|
|
|
|
models.setGroupId(1); |
|
|
|
|
|
models.setProcessDefId("pd" + IdUtil.objectId()); |
|
|
|
|
|
models.setFormName(formName); |
|
|
|
|
|
models.setProcessType(processType); |
|
|
|
|
|
models.setRegionCode(region.getRegionCode()); |
|
|
|
|
|
String process = "{\"children\":{\"children\":{},\"id\":\"node_039152532706\",\"name\":\"审批人\",\"parentId\":\"root\",\"props\":{\"mode\":\"AND\",\"role\":[],\"refuse\":{\"type\":\"TO_END\",\"target\":\"\"},\"assignedOrg\":[{\"orgName\":\"数转办\",\"orgCode\":\"GO_3bc86256687a4884ae410af00682b762\",\"type\":\"DEFAULT\",\"processDefId\":\"\"}],\"sign\":false,\"assignedType\":\"ASSIGN_ORG\",\"assignedDept\":[]},\"type\":\"SUB\"},\"id\":\"root\",\"name\":\"发起人\",\"props\":{\"formPerms\":[],\"assignedUser\":[]},\"type\":\"ROOT\"}"; |
|
|
|
|
|
ProcessNode processNode = JSON.parseObject(process,ProcessNode.class); |
|
|
|
|
|
models.setProcess(processNode); |
|
|
|
|
|
models.setSettings("{\"sign\":false,\"admin\":[],\"notify\":{},\"commiter\":[]}"); |
|
|
|
|
|
models.setFormItems("[]"); |
|
|
|
|
|
|
|
|
|
|
|
String formId = processModelService.insertProcess(models); |
|
|
|
|
|
if(StringUtils.isNotBlank(formId)){ |
|
|
|
|
|
//初始的流程在部署表也存一份,用来查询 |
|
|
|
|
|
if(StringUtils.isNotBlank(processModelService.deployProcess(formId,null))){ |
|
|
|
|
|
log.info("当前区域 【{}】 流程名[{}] 流程数据已经保存成功",region.getRegionName(),formName); |
|
|
|
|
|
}else{ |
|
|
|
|
|
log.info("当前区域 【{}】 流程名[{}] 流程数据保存失败",region.getRegionName(),formName); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { |
|
|
|
|
|
log.info("=========== 初始化丽水二期 系统表单和流程配置 ======== 任务开始"); |
|
|
|
|
|
StopWatch stopWatch = new StopWatch(); |
|
|
|
|
|
stopWatch.start(); |
|
|
|
|
|
//1.查出丽水市下的 区县 分别去初始化 表单和流程配置数据 |
|
|
|
|
|
List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_LS, RegionConst.RL_CITY); |
|
|
|
|
|
|
|
|
|
|
|
if(CollUtil.isEmpty(regions)){ |
|
|
|
|
|
throw new BizException("丽水地区数据为空 任务结束!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for(RegionDTO region : regions){ |
|
|
|
|
|
log.info("当前初始化的是 【{}】 流程配置",region.getRegionName()); |
|
|
|
|
|
|
|
|
|
|
|
Integer[] processTypeList = TaskContant.Wflow.APPLY_PROCESS_TYPE_LIST; |
|
|
|
|
|
for(Integer processType : processTypeList){ |
|
|
|
|
|
String formName = ProjectProcessStageEnum.getDesc(processType); |
|
|
|
|
|
WflowModelHistorysInsertDto models = new WflowModelHistorysInsertDto(); |
|
|
|
|
|
|
|
|
|
|
|
models.setGroupId(1); |
|
|
|
|
|
models.setProcessDefId("pd" + IdUtil.objectId()); |
|
|
|
|
|
models.setFormName(formName); |
|
|
|
|
|
models.setProcessType(processType); |
|
|
|
|
|
models.setRegionCode(region.getRegionCode()); |
|
|
|
|
|
String process = "{\"children\":{\"children\":{},\"id\":\"node_039152532706\",\"name\":\"审批人\",\"parentId\":\"root\",\"props\":{\"mode\":\"AND\",\"role\":[],\"refuse\":{\"type\":\"TO_END\",\"target\":\"\"},\"assignedOrg\":[{\"orgName\":\"数转办\",\"orgCode\":\"GO_3bc86256687a4884ae410af00682b762\",\"type\":\"DEFAULT\",\"processDefId\":\"\"}],\"sign\":false,\"assignedType\":\"ASSIGN_ORG\",\"assignedDept\":[]},\"type\":\"SUB\"},\"id\":\"root\",\"name\":\"发起人\",\"props\":{\"formPerms\":[],\"assignedUser\":[]},\"type\":\"ROOT\"}"; |
|
|
|
|
|
ProcessNode processNode = JSON.parseObject(process,ProcessNode.class); |
|
|
|
|
|
models.setProcess(processNode); |
|
|
|
|
|
models.setSettings("{\"sign\":false,\"admin\":[],\"notify\":{},\"commiter\":[]}"); |
|
|
|
|
|
models.setFormItems("[]"); |
|
|
|
|
|
|
|
|
|
|
|
String formId = processModelService.insertProcess(models); |
|
|
|
|
|
if(StringUtils.isNotBlank(formId)){ |
|
|
|
|
|
//初始的流程在部署表也存一份,用来查询 |
|
|
|
|
|
if(StringUtils.isNotBlank(processModelService.deployProcess(formId,null))){ |
|
|
|
|
|
log.info("当前区域 【{}】 流程名[{}] 流程数据已经保存成功",region.getRegionName(),formName); |
|
|
}else{ |
|
|
}else{ |
|
|
log.info("当前区域 【{}】流程名[{}] 流程数据保存失败",region.getRegionName(),formName); |
|
|
|
|
|
|
|
|
log.info("当前区域 【{}】 流程名[{}] 流程数据保存失败",region.getRegionName(),formName); |
|
|
} |
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
log.info("当前区域 【{}】流程名[{}] 流程数据保存失败",region.getRegionName(),formName); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
stopWatch.stop(); |
|
|
|
|
|
log.info("=========== 初始化丽水二期 系统表单和流程配置 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds()); |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
stopWatch.stop(); |
|
|
|
|
|
log.info("=========== 初始化丽水二期 系统表单和流程配置 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |