Sfoglia il codice sorgente

开始初始化数据 任务

tags/24080901
PoffyZhang 1 anno fa
parent
commit
5e60f95ae6
2 ha cambiato i file con 61 aggiunte e 2 eliminazioni
  1. +4
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/contants/TaskContant.java
  2. +57
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/InitProcessTask.java

+ 4
- 0
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/contants/TaskContant.java Vedi File

@@ -16,4 +16,8 @@ public interface TaskContant {

public static final String HOST_207 = "iZbp13nwyvib53j4j1p2xoZ";
}

class Wflow {
public static final String DEFAULT_FORM_NAME = "丽水申报项目表单";
}
}

+ 57
- 2
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/InitProcessTask.java Vedi File

@@ -2,19 +2,27 @@ package com.ningdatech.pmapi.scheduler.task;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.StopWatch;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.pmapi.scheduler.contants.TaskContant;
import com.ningdatech.pmapi.sys.contants.RegionContant;
import com.ningdatech.pmapi.sys.entity.Region;
import com.ningdatech.pmapi.sys.service.IRegionService;
import com.wflow.bean.entity.WflowForms;
import com.wflow.bean.entity.WflowModelHistorys;
import com.wflow.bean.entity.WflowModels;
import com.wflow.workflow.service.ProcessModelService;
import com.wflow.workflow.service.WflowFormsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.util.List;

/**
@@ -29,6 +37,10 @@ public class InitProcessTask {

private final IRegionService regionService;

private final WflowFormsService formsService;

private final ProcessModelService processModelService;

// 定时更新车辆状态
@Scheduled(cron = "0 52 15 18 1 ?")
public void doTask() throws UnknownHostException {
@@ -47,12 +59,55 @@ public class InitProcessTask {

//2.首先插入表单默认配置
for(Region region : regions){
log.info("当前初始化的是 【{}】",region.getName());
log.info("当前初始化的是 【{}】 表单信息",region.getName());


if(formsService.count(Wrappers.lambdaQuery(WflowForms.class)
.eq(WflowForms::getRegionCode,region.getRegionCode())) > 0){
log.info("当前区域 【{}】 已经有表单数据 不需要初始化",region.getName());
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.getName());
if(formsService.save(wflowForms)){
log.info("当前区域 【{}】 已经有表单数据已经保存成功",region.getName());
}else{
log.info("当前区域 【{}】 已经有表单数据已经保存失败",region.getName());
}
}

//3.接着插入流程默认配置
for(Region region : regions){
log.info("当前初始化的是 【{}】 流程配置",region.getName());

if(processModelService.count(Wrappers.lambdaQuery(WflowModels.class)
.eq(WflowModels::getRegionCode,region.getRegionCode())) > 0){
log.info("当前区域 【{}】 已经有流程数据 不需要初始化",region.getName());
continue;
}

WflowForms form = formsService.getOne(Wrappers.lambdaQuery(WflowForms.class)
.eq(WflowForms::getRegionCode, region.getRegionCode())
.last("limit 1"));

WflowModelHistorys model = new WflowModelHistorys();
model.setFormId(form.getFormId());
// model.setProcess(LocalDateTime.now());
if(StringUtils.isNotBlank(processModelService.saveProcess(model))){
log.info("当前区域 【{}】 已经有流程数据已经保存成功",region.getName());
}else{
log.info("当前区域 【{}】 已经有流程数据已经保存失败",region.getName());
}
}

stopWatch.stop();
log.info("=========== 更新车辆在线状态 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds());
log.info("=========== 初始化丽水二期 系统表单和流程配置 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds());
}
}
}

Loading…
Annulla
Salva