activiti PROC_DEF_ID_超64位解决方案

默认得id是这样的

如果前面的code长了,就会出问题,而且手动修改activiti相关表里面的长度也不行,所有改采用雪花算法,把后面的uuid了,修改后

这也64的长度也够了,注意只对新发布的流程有效

<dependency>
    <groupId>com.github.yitter</groupId>
    <artifactId>yitter-idgenerator</artifactId>
    <version>1.0.6</version>
</dependency>
/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 */

package com.ruoyi.dingflow.config;

import com.github.yitter.contract.IdGeneratorOptions;
import com.github.yitter.idgen.YitIdHelper;
import com.ruoyi.common.utils.Snowflake;
import com.ruoyi.dingflow.job.CustomJobHandler;
import com.ruoyi.dingflow.job.IdWorkerIdGenerator;
import org.flowable.common.engine.impl.cfg.IdGenerator;
import org.flowable.engine.ProcessEngineConfiguration;
import org.flowable.engine.cfg.HttpClientConfig;
import org.flowable.engine.impl.cfg.DelegateExpressionFieldInjectionMode;
import org.flowable.job.service.JobHandler;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.transaction.PlatformTransactionManager;

import javax.annotation.Resource;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author
 * @date
 * @desc
 */
@Configuration
public class ActivitiConfig {
	@Resource
	private  DataSource dataSource;
	@Resource
	private  PlatformTransactionManager transactionManager;
	@Resource
	private IdWorkerIdGenerator idWorkerIdGenerator;
	@Resource
	private FlowableExConfig flowableExConfig;

	@Bean
	public SpringProcessEngineConfiguration getSpringProcessEngineConfiguration() {
// 创建 IdGeneratorOptions 对象,请在构造函数中输入 WorkerId:
	IdGeneratorOptions options = new IdGeneratorOptions((short) 1);
	// options.WorkerIdBitLength = 10; // WorkerIdBitLength 默认值6,支持的 WorkerId 最大值为2^6-1,若 WorkerId 超过64,可设置更大的 WorkerIdBitLength
	// ...... 其它参数设置参考 IdGeneratorOptions 定义,一般来说,只要再设置 WorkerIdBitLength (决定 WorkerId 的最大值)。
	// 保存参数(必须的操作,否则以上设置都不能生效):
	YitIdHelper.setIdGenerator(options);
	// 以上初始化过程只需全局一次,且必须在第2步之前设置。
	
		SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
				//config.setIdGenerator(idWorkerIdGenerator);
		//config.setAsyncExecutorActivate(Boolean.FALSE);//
		config.setIdGenerator(new IdGenerator() {
			@Override
			public String getNextId() {
				try {

					// 初始化以后,即可在任何需要生成ID的地方,调用以下方法:
					//long newId = YitIdHelper.nextId();
					return String.valueOf(YitIdHelper.nextId());
					//return Snowflake.getSnowflakeId(); //id生成方法
					//return IdUtils.generateShortUuid();
				}catch (Exception e) {
				}
				return null;
			}
		});
		
		return config;
	}

	@Bean
	@Primary
	public TaskExecutor primaryTaskExecutor() {
		return new ThreadPoolTaskExecutor();
	}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值