@@ -7,7 +7,7 @@ import com.hz.pm.api.ding.task.GovBusinessStripsTask; | |||
import com.hz.pm.api.ding.task.OrganizationBatchGetTask; | |||
import com.hz.pm.api.irs.manage.AppIrsManage; | |||
import com.hz.pm.api.irs.model.dto.ForwardDTO; | |||
import com.hz.pm.api.organization.manage.ProcDefManage; | |||
import com.hz.pm.api.sys.manage.OrgProcDefManage; | |||
import com.hz.pm.api.projectdeclared.manage.IrsManage; | |||
import com.hz.pm.api.projectlib.model.dto.ProjectDTO; | |||
import com.hz.pm.api.projectlib.model.entity.Project; | |||
@@ -56,7 +56,7 @@ public class DingInfoPullController { | |||
private final GovBusinessStripsTask businessStripsTask; | |||
private final OrganizationBatchGetTask organizationBatchGetTask; | |||
private final ProcDefManage procDefManage; | |||
private final OrgProcDefManage orgProcDefManage; | |||
private final IrsManage irsManage; | |||
@@ -127,18 +127,6 @@ public class DingInfoPullController { | |||
return employeeBatchGetTask.getAuthToken(); | |||
} | |||
@ApiOperation(value = "系统流程配置初始化", notes = "系统流程配置初始化") | |||
@GetMapping("/init") | |||
public String init() { | |||
return procDefManage.init(); | |||
} | |||
@ApiOperation(value = "系统流程配置初始化按区域", notes = "系统流程配置初始化按区域") | |||
@GetMapping("/init/{areaCode}") | |||
public String initByArea(@PathVariable String areaCode) { | |||
return procDefManage.initByArea(areaCode); | |||
} | |||
@ApiOperation(value = "项目详情推送", notes = "项目详情推送") | |||
@GetMapping("/push-project") | |||
public String pushProject() throws Exception { | |||
@@ -274,12 +262,6 @@ public class DingInfoPullController { | |||
return "推送失败"; | |||
} | |||
@ApiOperation(value = "同步企业信息 条线", notes = "同步企业信息 条线") | |||
@GetMapping("/synchronouOrgBiz") | |||
public String synchronouOrgBiz() { | |||
return procDefManage.synchronouOrgBiz(); | |||
} | |||
@ApiOperation(value = "转发IRS请求", notes = "转发IRS请求 用于") | |||
@PostMapping("/forward") | |||
public String forward(@Valid @RequestBody ForwardDTO dto) { | |||
@@ -4,7 +4,7 @@ import com.hz.pm.api.common.util.StrUtils; | |||
import com.hz.pm.api.user.util.LoginUserUtil; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.log.annotation.WebLog; | |||
import com.hz.pm.api.organization.manage.ProcDefManage; | |||
import com.hz.pm.api.sys.manage.OrgProcDefManage; | |||
import com.wflow.bean.dto.WflowOrgProcdefDto; | |||
import com.wflow.bean.vo.OrgProcdefVo; | |||
import com.wflow.service.OrgProcdefService; | |||
@@ -34,7 +34,7 @@ public class ProcDefController { | |||
private final OrgProcessModelService orgProcessModelService; | |||
private final ProcDefManage procDefManage; | |||
private final OrgProcDefManage orgProcDefManage; | |||
@ApiOperation(value = "单位流程配置列表", notes = "单位流程配置列表") | |||
@GetMapping("/list") | |||
@@ -1,166 +0,0 @@ | |||
package com.hz.pm.api.organization.manage; | |||
import cn.hutool.core.util.IdUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.google.common.collect.Lists; | |||
import com.ningdatech.basic.model.GenericResult; | |||
import com.ningdatech.basic.util.StrPool; | |||
import com.hz.pm.api.ding.constants.DingOrganizationContant; | |||
import com.hz.pm.api.organization.model.entity.DingOrganization; | |||
import com.hz.pm.api.organization.service.IDingOrganizationService; | |||
import com.hz.pm.api.organization.constants.ProcDefContant; | |||
import com.ningdatech.zwdd.client.ZwddClient; | |||
import com.ningdatech.zwdd.model.dto.DingOrgInfoDTO; | |||
import com.wflow.bean.entity.WflowOrgModelHistorys; | |||
import com.wflow.bean.entity.WflowOrgModels; | |||
import com.wflow.enums.ProcessDefTypeEnum; | |||
import com.wflow.service.OrgProcdefHistoryService; | |||
import com.wflow.service.OrgProcdefService; | |||
import lombok.AllArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.springframework.stereotype.Component; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @Classname ProcDefManage | |||
* @Description | |||
* @Date 2023/7/10 17:48 | |||
* @Author PoffyZhang | |||
*/ | |||
@Component | |||
@Slf4j | |||
@AllArgsConstructor | |||
public class ProcDefManage { | |||
private final IDingOrganizationService organizationService; | |||
private final OrgProcdefService orgProcdefService; | |||
private final OrgProcdefHistoryService orgProcdefHistoryService; | |||
private final ZwddClient zwddClient; | |||
/** | |||
* 初始化 单位配置 | |||
* @return | |||
*/ | |||
public String init() { | |||
List<DingOrganization> orgs = organizationService.list(Wrappers.lambdaQuery(DingOrganization.class) | |||
.in(DingOrganization::getTypeCode, Lists.newArrayList( | |||
DingOrganizationContant.UNIT_TYPE,DingOrganizationContant.GOV_TEMPORARY | |||
))); | |||
log.info("需要处理初始化单位配置的企业 数量为{}",orgs.size()); | |||
for(DingOrganization org : orgs){ | |||
log.info("当前是 {}",org.getOrganizationName()); | |||
String orgCode = org.getOrganizationCode(); | |||
List<WflowOrgModels> models = orgProcdefService.list(Wrappers.lambdaQuery(WflowOrgModels.class) | |||
.eq(WflowOrgModels::getOrgCode, orgCode)); | |||
log.info("已经有的单位流程 {}", JSON.toJSONString(models)); | |||
List<String> types = models.stream().map(WflowOrgModels::getType).collect(Collectors.toList()); | |||
//默认流程 | |||
if(!types.contains(ProcessDefTypeEnum.DEFAULT.name())){ | |||
saveDef(org,ProcessDefTypeEnum.DEFAULT); | |||
} | |||
//盖章流程 | |||
if(!types.contains(ProcessDefTypeEnum.SEAL.name())){ | |||
saveDef(org,ProcessDefTypeEnum.SEAL); | |||
} | |||
//联审流程 | |||
if(!types.contains(ProcessDefTypeEnum.JOINT_REVIEW.name())){ | |||
saveDef(org,ProcessDefTypeEnum.JOINT_REVIEW); | |||
} | |||
} | |||
return "初始化成功"; | |||
} | |||
private void saveDef(DingOrganization org,ProcessDefTypeEnum defTypeEnum){ | |||
String procDefId = ProcDefContant.MODELS_ID_PREFIX + IdUtil.objectId(); | |||
WflowOrgModels defaultModel = new WflowOrgModels(); | |||
defaultModel.setProcessDefId(procDefId); | |||
defaultModel.setIsStop(Boolean.FALSE); | |||
defaultModel.setProcess(StrPool.BRACE); | |||
defaultModel.setCreated(LocalDateTime.now()); | |||
defaultModel.setIsDelete(Boolean.FALSE); | |||
defaultModel.setOrgCode(org.getOrganizationCode()); | |||
defaultModel.setOrgName(org.getOrganizationName()); | |||
defaultModel.setProcessDefName(defTypeEnum.getDesc()); | |||
defaultModel.setType(defTypeEnum.name()); | |||
defaultModel.setSort(1); | |||
defaultModel.setVersion(1); | |||
orgProcdefService.save(defaultModel); | |||
WflowOrgModelHistorys defaultHistory = new WflowOrgModelHistorys(); | |||
defaultHistory.setProcessDefId(procDefId); | |||
defaultHistory.setProcess(StrPool.BRACE); | |||
defaultHistory.setCreated(LocalDateTime.now()); | |||
defaultHistory.setOrgCode(org.getOrganizationCode()); | |||
defaultHistory.setOrgName(org.getOrganizationName()); | |||
defaultHistory.setProcessDefName(defTypeEnum.getDesc()); | |||
defaultHistory.setType(defTypeEnum.name()); | |||
defaultHistory.setVersion(0); | |||
orgProcdefHistoryService.save(defaultHistory); | |||
} | |||
public String initByArea(String areaCode) { | |||
List<DingOrganization> orgs = organizationService.list(Wrappers.lambdaQuery(DingOrganization.class) | |||
.in(DingOrganization::getTypeCode, Lists.newArrayList( | |||
DingOrganizationContant.UNIT_TYPE,DingOrganizationContant.GOV_TEMPORARY | |||
)) | |||
.eq(DingOrganization::getDivisionCode,areaCode)); | |||
log.info("{}地区 需要处理初始化单位配置的企业 数量为{}",areaCode,orgs.size()); | |||
for(DingOrganization org : orgs){ | |||
log.info("当前是 {}",org.getOrganizationName()); | |||
String orgCode = org.getOrganizationCode(); | |||
List<WflowOrgModels> models = orgProcdefService.list(Wrappers.lambdaQuery(WflowOrgModels.class) | |||
.eq(WflowOrgModels::getOrgCode, orgCode)); | |||
log.info("已经有的单位流程 {}", JSON.toJSONString(models)); | |||
List<String> types = models.stream().map(WflowOrgModels::getType).collect(Collectors.toList()); | |||
//默认流程 | |||
if(!types.contains(ProcessDefTypeEnum.DEFAULT.name())){ | |||
saveDef(org,ProcessDefTypeEnum.DEFAULT); | |||
} | |||
//盖章流程 | |||
if(!types.contains(ProcessDefTypeEnum.SEAL.name())){ | |||
saveDef(org,ProcessDefTypeEnum.SEAL); | |||
} | |||
//联审流程 | |||
if(!types.contains(ProcessDefTypeEnum.JOINT_REVIEW.name())){ | |||
saveDef(org,ProcessDefTypeEnum.JOINT_REVIEW); | |||
} | |||
} | |||
return "初始化成功"; | |||
} | |||
public String synchronouOrgBiz() { | |||
List<DingOrganization> orgs = organizationService.list(); | |||
//同步所有的 企业条线 | |||
for(DingOrganization org : orgs){ | |||
GenericResult<DingOrgInfoDTO> organization = zwddClient.getOrganizationByCode(org.getOrganizationCode()); | |||
if(organization.isSuccess()){ | |||
DingOrgInfoDTO data = organization.getData(); | |||
String businessStripCodes = data.getBusinessStripCodes(); | |||
if(StringUtils.isNotBlank(businessStripCodes)){ | |||
org.setBusinessStripCodes(businessStripCodes); | |||
organizationService.updateById(org); | |||
} | |||
} | |||
} | |||
return "更新完成"; | |||
} | |||
} |
@@ -1,5 +1,6 @@ | |||
package com.hz.pm.api.projectlib.model.enumeration; | |||
import io.swagger.models.auth.In; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Getter; | |||
import lombok.NoArgsConstructor; | |||
@@ -54,4 +55,9 @@ public enum WarningOperationTypeEnum { | |||
} | |||
return null; | |||
} | |||
public boolean eq(Integer code){ | |||
return this.getCode().equals(code); | |||
} | |||
} |
@@ -92,7 +92,7 @@ public class EarlyWarningInstanceNotStartTask { | |||
.eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.DECLARED_WARNING.getCode())); | |||
for (WflowEarlyWarning warning : warnings) { | |||
//2. 取出rule的数据 | |||
if (!warning.getIsOpen()) { | |||
if (Boolean.FALSE.equals(warning.getIsOpen())) { | |||
log.info(warning.getId() + " 此规则关闭了"); | |||
continue; | |||
} | |||
@@ -135,22 +135,22 @@ public class EarlyWarningInstanceNotStartTask { | |||
String path = flowTypeEnum.getPath(); | |||
//得出 对应待提交的项目状态 | |||
Integer projectStutas = flowTypeEnum.getProjectStutas(); | |||
Integer projectStatus = flowTypeEnum.getProjectStutas(); | |||
String areaCode = warning.getAreaCode(); | |||
//测试先用分钟 | |||
//查询 所有这个区域的项目 未提交的项目 | |||
List<Project> needNextProjects = projectService.list(Wrappers.lambdaQuery(Project.class) | |||
.eq(Project::getAreaCode, areaCode) | |||
.eq(Project::getNewest, Boolean.TRUE) | |||
.eq(Project::getStatus, projectStutas)); | |||
.eq(Project::getStatus, projectStatus)); | |||
Map<String, List<Integer>> noticeMap = Maps.newHashMap(); | |||
//需要发通知的项目 | |||
List<Project> needToWaringProjects = needNextProjects.stream() | |||
.filter(p -> { | |||
//判断 当状态在 建设中的时候 是不是要初验了 | |||
if (ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(projectStutas)) { | |||
List<Long> allVersionProjectId = projectService.allVersionProjectIds(p.getProjectCode()); | |||
if (ProjectStatusEnum.UNDER_CONSTRUCTION.eq(projectStatus)) { | |||
// List<Long> allVersionProjectId = projectService.allVersionProjectIds(p.getProjectCode()); | |||
//如果合同信息提交过了 才是 待初验状态 | |||
// TODO 初验提醒 | |||
/*if (StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials())) { | |||
@@ -261,7 +261,7 @@ public class EarlyWarningInstanceNotStartTask { | |||
.eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.OPERATION_WARNING.getCode())); | |||
for (WflowEarlyWarning warning : warnings) { | |||
//2. 取出rule的数据 | |||
if (!warning.getIsOpen()) { | |||
if (Boolean.FALSE.equals(warning.getIsOpen())) { | |||
log.info(warning.getId() + " 此规则关闭了"); | |||
continue; | |||
} | |||
@@ -321,8 +321,8 @@ public class EarlyWarningInstanceNotStartTask { | |||
List<Project> needToWaringProjects = needNextProjects.stream() | |||
.filter(p -> { | |||
//判断 当状态在 建设中的时候 是不是要初验了 | |||
if (ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(projectStatus)) { | |||
List<Long> allVersionProjectId = projectService.allVersionProjectIds(p.getProjectCode()); | |||
if (ProjectStatusEnum.UNDER_CONSTRUCTION.eq(projectStatus)) { | |||
// List<Long> allVersionProjectId = projectService.allVersionProjectIds(p.getProjectCode()); | |||
//如果合同信息提交过了 才是 待初验状态 | |||
// 初验提醒 | |||
/*if (StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials())) { | |||
@@ -340,7 +340,7 @@ public class EarlyWarningInstanceNotStartTask { | |||
Operation operation = operationMap.get(p.getProjectCode()); | |||
List<Integer> noticeTypes = Lists.newArrayList(); | |||
if (WarningOperationTypeEnum.CHUYAN.getCode().equals(biz)) { | |||
if (WarningOperationTypeEnum.CHUYAN.eq(biz)) { | |||
//初验 | |||
if (Objects.nonNull(time) && Duration.between(operation.getInitialInspectionDate(), LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 | |||
Duration.between(operation.getInitialInspectionDate(), LocalDateTime.now()).toMinutes() <= time * 60 + 1) { //time * 60 | |||
@@ -350,7 +350,7 @@ public class EarlyWarningInstanceNotStartTask { | |||
Duration.between(operation.getInitialInspectionDate(), LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1) { | |||
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.ADVENT.getCode()); | |||
} | |||
} else if (WarningOperationTypeEnum.ZHONGYAN.getCode().equals(biz)) { | |||
} else if (WarningOperationTypeEnum.ZHONGYAN.eq(biz)) { | |||
//终验 | |||
if (Objects.nonNull(time) && Duration.between(operation.getFinalInspectionDate(), LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 | |||
Duration.between(operation.getFinalInspectionDate(), LocalDateTime.now()).toMinutes() <= time * 60 + 1) { //time * 60 | |||
@@ -394,10 +394,7 @@ public class EarlyWarningInstanceNotStartTask { | |||
String username = needToWaringProject.getContactName(); | |||
String mobile = needToWaringProject.getContactPhone(); | |||
if (StrUtil.isAllNotBlank(username, mobile)) { | |||
UserInfo user = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) | |||
.eq(UserInfo::getUsername, username) | |||
.eq(UserInfo::getMobile, mobile) | |||
.last(BizConst.LIMIT_1)); | |||
UserInfo user = userInfoService.getByUserNameAndMobile(username, mobile); | |||
if (Objects.nonNull(user)) { | |||
employeeCode = user.getEmployeeCode(); | |||
} | |||
@@ -411,10 +408,7 @@ public class EarlyWarningInstanceNotStartTask { | |||
String username = needToWaringProject.getResponsibleMan(); | |||
String mobile = needToWaringProject.getResponsibleManMobile(); | |||
if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(mobile)) { | |||
UserInfo user = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) | |||
.eq(UserInfo::getUsername, username) | |||
.eq(UserInfo::getMobile, mobile) | |||
.last(BizConst.LIMIT_1)); | |||
UserInfo user = userInfoService.getByUserNameAndMobile(username, mobile); | |||
if (Objects.nonNull(user)) { | |||
employeeCode = user.getEmployeeCode(); | |||
} | |||
@@ -433,7 +427,7 @@ public class EarlyWarningInstanceNotStartTask { | |||
adventTime, time, biz, | |||
needToWaringProject.getUpdateOn(), Long.valueOf(employeeCode), needToWaringProject, | |||
WarningRuleTypeEnum.OPERATION_WARNING.getCode(), noticeType, path, | |||
batchEmployees.stream().collect(Collectors.joining(StrPool.COMMA)), null); | |||
String.join(StrPool.COMMA, batchEmployees), null); | |||
} | |||
} | |||
} | |||
@@ -468,7 +462,7 @@ public class EarlyWarningInstanceNotStartTask { | |||
.eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.RENEWAL_FUND.getCode())); | |||
for (WflowEarlyWarning warning : warnings) { | |||
//2. 取出rule的数据 | |||
if (!warning.getIsOpen()) { | |||
if (Boolean.FALSE.equals(warning.getIsOpen())) { | |||
log.info(warning.getId() + " 此规则关闭了"); | |||
continue; | |||
} | |||
@@ -491,7 +485,7 @@ public class EarlyWarningInstanceNotStartTask { | |||
JSONObject rJson = JSON.parseObject(JSON.toJSONString(r)); | |||
Integer time = rJson.getInteger("time"); | |||
Integer adventTime = rJson.getInteger("adventTime"); | |||
if ((Objects.isNull(time) && Objects.isNull(adventTime)) && Objects.isNull(adventTime)) { | |||
if (Objects.isNull(time) && Objects.isNull(adventTime)) { | |||
log.info("规则数据 错误 :{}", rJson); | |||
return; | |||
} | |||
@@ -1,101 +0,0 @@ | |||
package com.hz.pm.api.scheduler.task; | |||
import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.core.date.StopWatch; | |||
import cn.hutool.core.util.IdUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.hz.pm.api.common.model.constant.RegionConst; | |||
import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; | |||
import com.hz.pm.api.common.helper.RegionCacheHelper; | |||
import com.hz.pm.api.scheduler.contants.TaskContant; | |||
import com.hz.pm.api.sys.model.dto.RegionDTO; | |||
import com.hz.pm.api.sys.service.IRegionService; | |||
import com.wflow.bean.dto.WflowModelHistorysInsertDto; | |||
import com.wflow.workflow.bean.process.ProcessNode; | |||
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.beans.factory.annotation.Value; | |||
import org.springframework.scheduling.annotation.Scheduled; | |||
import org.springframework.stereotype.Component; | |||
import java.net.InetAddress; | |||
import java.net.UnknownHostException; | |||
import java.util.*; | |||
/** | |||
* @author ZPF | |||
* @description | |||
* @since 2023/1/18 08:54 | |||
*/ | |||
@Component | |||
@Slf4j | |||
@RequiredArgsConstructor | |||
public class InitProcessTask { | |||
private final IRegionService regionService; | |||
private final ProcessModelService processModelService; | |||
private final WflowFormsService formsService; | |||
private final RegionCacheHelper regionCacheHelper; | |||
@Value("${hostname}") | |||
private String HOST_NAME; | |||
@Scheduled(cron = "0 45 18 12 6 ?") | |||
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_HZ, 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 { | |||
log.info("当前区域 【{}】 流程名[{}] 流程数据保存失败", region.getRegionName(), formName); | |||
} | |||
} else { | |||
log.info("当前区域 【{}】流程名[{}] 流程数据保存失败", region.getRegionName(), formName); | |||
} | |||
} | |||
} | |||
stopWatch.stop(); | |||
log.info("=========== 初始化丽水二期 系统表单和流程配置 ======== 任务结束 {}s", stopWatch.getTotalTimeSeconds()); | |||
} | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
package com.hz.pm.api.sys.controller; | |||
import com.hz.pm.api.sys.manage.OrgProcDefManage; | |||
import io.swagger.annotations.ApiOperation; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* <p> | |||
* OrgProcDefController | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 21:33 2024/3/6 | |||
*/ | |||
@RestController | |||
@RequiredArgsConstructor | |||
@RequestMapping("/api/v1/org/procdef") | |||
public class OrgProcDefController { | |||
private final OrgProcDefManage orgProcDefManage; | |||
@ApiOperation(value = "单位流程配置初始化") | |||
@GetMapping("/init") | |||
public String init() { | |||
return orgProcDefManage.initAllUnits(); | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
package com.hz.pm.api.sys.controller; | |||
import com.hz.pm.api.common.model.constant.RegionConst; | |||
import com.hz.pm.api.sys.manage.InitProcessManage; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.log.annotation.WebLog; | |||
import com.wflow.bean.dto.WflowModelHistorysDto; | |||
@@ -14,6 +14,9 @@ import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.springframework.web.bind.annotation.*; | |||
import java.util.List; | |||
import java.util.Set; | |||
/** | |||
* @Classname SysProcdefController | |||
* @Description | |||
@@ -29,7 +32,7 @@ import org.springframework.web.bind.annotation.*; | |||
public class SysProcDefController { | |||
private final ModelGroupService modelGroupService; | |||
private final InitProcessManage initProcessManage; | |||
private final ProcessModelService processModelService; | |||
@ApiOperation(value = "系统流程配置列表", notes = "系统流程配置列表") | |||
@@ -67,4 +70,10 @@ public class SysProcDefController { | |||
public String deploy(@Validated @PathVariable String formId) { | |||
return processModelService.deployProcessLs(formId, null); | |||
} | |||
@GetMapping("/initProcessForUnits") | |||
public void initProcessForUnits(@RequestParam Set<Long> unitIds) { | |||
initProcessManage.initProcessForUnits(unitIds); | |||
} | |||
} |
@@ -0,0 +1,70 @@ | |||
package com.hz.pm.api.sys.manage; | |||
import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.core.util.IdUtil; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.wflow.bean.dto.WflowModelHistorysInsertDto; | |||
import com.wflow.bean.entity.WflowModels; | |||
import com.wflow.workflow.bean.process.ProcessNode; | |||
import com.wflow.workflow.service.ProcessModelService; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
/** | |||
* <p> | |||
* InitProcessManage | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 20:45 2024/3/6 | |||
*/ | |||
@Slf4j | |||
@Component | |||
@RequiredArgsConstructor | |||
public class InitProcessManage { | |||
private final ProcessModelService processModelService; | |||
@Transactional(rollbackFor = Exception.class) | |||
public void initProcessForUnits(Set<Long> unitIds) { | |||
if (CollUtil.isEmpty(unitIds)) { | |||
return; | |||
} | |||
List<String> strUnitIds = CollUtils.convert(unitIds, String::valueOf); | |||
ProjectProcessStageEnum[] stages = ProjectProcessStageEnum.values(); | |||
List<WflowModels> allModels = processModelService.list(Wrappers.lambdaQuery(WflowModels.class) | |||
.in(WflowModels::getRegionCode, strUnitIds)); | |||
Map<Integer, List<WflowModels>> modelsByType = CollUtils.group(allModels, WflowModels::getProcessType); | |||
for (ProjectProcessStageEnum stage : stages) { | |||
List<WflowModels> currModels = modelsByType.getOrDefault(stage.getCode(), Collections.emptyList()); | |||
Map<String, WflowModels> modelsByUnitId = CollUtils.listToMap(currModels, WflowModels::getRegionCode); | |||
for (String unitId : strUnitIds) { | |||
if (modelsByUnitId.containsKey(unitId)) { | |||
continue; | |||
} | |||
WflowModelHistorysInsertDto models = new WflowModelHistorysInsertDto(); | |||
models.setGroupId(1); | |||
models.setProcessDefId("pd" + IdUtil.objectId()); | |||
models.setFormName(stage.getDesc()); | |||
models.setProcessType(stage.getCode()); | |||
models.setRegionCode(unitId); | |||
models.setProcess(new ProcessNode()); | |||
models.setSettings("{\"sign\":false,\"admin\":[],\"notify\":{},\"commiter\":[]}"); | |||
models.setFormItems("[]"); | |||
String formId = processModelService.insertProcess(models); | |||
processModelService.deployProcess(formId, null); | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,105 @@ | |||
package com.hz.pm.api.sys.manage; | |||
import cn.hutool.core.util.IdUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.hz.pm.api.organization.constants.ProcDefContant; | |||
import com.hz.pm.api.user.model.entity.MhUnit; | |||
import com.hz.pm.api.user.service.IMhUnitService; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.basic.util.StrPool; | |||
import com.wflow.bean.entity.WflowOrgModelHistorys; | |||
import com.wflow.bean.entity.WflowOrgModels; | |||
import com.wflow.enums.ProcessDefTypeEnum; | |||
import com.wflow.service.OrgProcdefHistoryService; | |||
import com.wflow.service.OrgProcdefService; | |||
import lombok.AllArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* OrgProcDefManage | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 21:45 2024/3/6 | |||
*/ | |||
@Slf4j | |||
@Component | |||
@AllArgsConstructor | |||
public class OrgProcDefManage { | |||
private final IMhUnitService mhUnitService; | |||
private final OrgProcdefService orgProcdefService; | |||
private final OrgProcdefHistoryService orgProcdefHistoryService; | |||
/** | |||
* 初始化 单位配置 | |||
* | |||
* @return \ | |||
*/ | |||
@Transactional(rollbackFor = Exception.class) | |||
public String initAllUnits() { | |||
List<MhUnit> units = mhUnitService.list(); | |||
log.info("需要处理初始化单位配置的企业 数量为{}", units.size()); | |||
for (MhUnit unit : units) { | |||
log.info("当前是 {}", unit.getName()); | |||
String orgCode = String.valueOf(unit.getId()); | |||
Wrapper<WflowOrgModels> womQuery = Wrappers.lambdaQuery(WflowOrgModels.class) | |||
.select(WflowOrgModels::getType) | |||
.eq(WflowOrgModels::getOrgCode, orgCode); | |||
List<WflowOrgModels> models = orgProcdefService.list(womQuery); | |||
List<String> existsType = CollUtils.fieldList(models, WflowOrgModels::getType); | |||
log.info("已经有的单位流程 {}", JSON.toJSONString(existsType)); | |||
//默认流程 | |||
if (!existsType.contains(ProcessDefTypeEnum.DEFAULT.name())) { | |||
saveDef(unit, ProcessDefTypeEnum.DEFAULT); | |||
} | |||
//盖章流程 | |||
if (!existsType.contains(ProcessDefTypeEnum.SEAL.name())) { | |||
saveDef(unit, ProcessDefTypeEnum.SEAL); | |||
} | |||
//联审流程 | |||
if (!existsType.contains(ProcessDefTypeEnum.JOINT_REVIEW.name())) { | |||
saveDef(unit, ProcessDefTypeEnum.JOINT_REVIEW); | |||
} | |||
} | |||
return "初始化成功"; | |||
} | |||
private void saveDef(MhUnit unit, ProcessDefTypeEnum defType) { | |||
String procDefId = ProcDefContant.MODELS_ID_PREFIX + IdUtil.objectId(); | |||
WflowOrgModels defaultModel = new WflowOrgModels(); | |||
defaultModel.setProcessDefId(procDefId); | |||
defaultModel.setIsStop(Boolean.FALSE); | |||
defaultModel.setProcess(StrPool.BRACE); | |||
defaultModel.setCreated(LocalDateTime.now()); | |||
defaultModel.setIsDelete(Boolean.FALSE); | |||
defaultModel.setOrgCode(unit.getId().toString()); | |||
defaultModel.setOrgName(unit.getName()); | |||
defaultModel.setProcessDefName(defType.getDesc()); | |||
defaultModel.setType(defType.name()); | |||
defaultModel.setSort(1); | |||
defaultModel.setVersion(1); | |||
orgProcdefService.save(defaultModel); | |||
WflowOrgModelHistorys defaultHistory = new WflowOrgModelHistorys(); | |||
defaultHistory.setProcessDefId(procDefId); | |||
defaultHistory.setProcess(StrPool.BRACE); | |||
defaultHistory.setCreated(LocalDateTime.now()); | |||
defaultHistory.setOrgCode(unit.getId().toString()); | |||
defaultHistory.setOrgName(unit.getName()); | |||
defaultHistory.setProcessDefName(defType.getDesc()); | |||
defaultHistory.setType(defType.name()); | |||
defaultHistory.setVersion(0); | |||
orgProcdefHistoryService.save(defaultHistory); | |||
} | |||
} |
@@ -1,5 +1,6 @@ | |||
package com.hz.pm.api.todocenter; | |||
import cn.hutool.core.bean.BeanUtil; | |||
import cn.hutool.json.JSONUtil; | |||
import cn.hutool.poi.excel.ExcelUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
@@ -12,11 +13,15 @@ import com.hz.pm.api.user.service.IMhUnitService; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.wflow.bean.entity.WflowCcTasks; | |||
import com.wflow.bean.entity.WflowModelHistorys; | |||
import com.wflow.bean.entity.WflowModels; | |||
import com.wflow.mapper.WflowCcTasksMapper; | |||
import com.wflow.utils.CodeUtil; | |||
import com.wflow.workflow.bean.dto.ReqProcessHandlerDTO; | |||
import com.wflow.workflow.enums.ProcessHandlerEnum; | |||
import com.wflow.workflow.mapper.CustomHisActInstMapper; | |||
import com.wflow.workflow.service.ProcessModelHistorysService; | |||
import com.wflow.workflow.service.ProcessModelService; | |||
import com.wflow.workflow.utils.ProcessTaskUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.assertj.core.util.Lists; | |||
@@ -319,15 +324,19 @@ public class FlowableTest extends AppTests { | |||
private IMhUnitService mhUnitService; | |||
@Autowired | |||
private MhUnitCache mhUnitCache; | |||
@Autowired | |||
private ProcessModelService processModelService; | |||
@Autowired | |||
private ProcessModelHistorysService processModelHistorysService; | |||
@Test | |||
public void test() { | |||
List<Long> unitIdPaths = mhUnitCache.getUnitIdPaths(2894L); | |||
String orderSql = String.format(" order by field(id, %s) desc", CollUtils.joinByComma(unitIdPaths)); | |||
LambdaQueryWrapper<MhUnit> query = Wrappers.lambdaQuery(MhUnit.class) | |||
.in(MhUnit::getId, unitIdPaths) | |||
.last(orderSql + BizConst.LIMIT_1); | |||
System.out.println(mhUnitService.getOne(query)); | |||
List<WflowModels> wflowModels = processModelService.list(Wrappers.lambdaQuery(WflowModels.class) | |||
.ne(WflowModels::getRegionCode, "1")); | |||
for (WflowModels model : wflowModels) { | |||
WflowModelHistorys history = BeanUtil.copyProperties(model, WflowModelHistorys.class); | |||
processModelHistorysService.save(history); | |||
} | |||
} | |||
public static void main(String[] args) { | |||