Commit 254eba39 authored by chenzhao's avatar chenzhao

工作流变更

parent 59ab010a
package com.yeejoin.amos.boot.biz.config;
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.extension.injector.methods.additional.InsertBatchSomeColumn;
import java.util.List;
/**
* @apiNote 解决集成seata后,InsertBatchSomeColumn报错问题
* @author LiuLin
* @date 2024-05-15
*/
public class MybatisSqlInjector extends DefaultSqlInjector {
@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
List<AbstractMethod> methodList = super.getMethodList(mapperClass);
methodList.add(new InsertBatchSomeColumn());
return methodList;
}
}
\ No newline at end of file
......@@ -62,6 +62,35 @@
<version>1.10.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo</artifactId>
<version>2.24.0</version>
</dependency>
<dependency>
<groupId>de.javakaffee</groupId>
<artifactId>kryo-serializers</artifactId>
<version>0.45</version>
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>cn.com.vastdata</groupId>
<artifactId>vastbase-jdbc</artifactId>
<version>2.7p</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring-boot-starter</artifactId>
<version>1.8.0</version>
</dependency>
</dependencies>
<build>
......
package com.yeejoin.amos.boot.module.hygf.biz.config;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.yeejoin.amos.boot.biz.config.MetaHandler;
import com.yeejoin.amos.boot.biz.config.MybatisSqlInjector;
import com.zaxxer.hikari.HikariDataSource;
import io.seata.rm.datasource.DataSourceProxy;
import javax.sql.DataSource;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
/**
* 数据源代理
*
* @author LiuLin
*/
@Configuration
public class DataSourceConfiguration {
@Autowired
private DataSourceProperties dsp;
@Bean(name = "hikariDataSource")
public HikariDataSource hikariDataSource() {
HikariDataSource hds = new HikariDataSource();
hds.setSchema(dsp.getSchema().get(0));
hds.setUsername(dsp.getUsername());
hds.setPassword(dsp.getPassword());
hds.setJdbcUrl(dsp.getUrl());
hds.setDriverClassName(dsp.getDriverClassName());
hds.setConnectionTimeout(3000);
hds.setMaximumPoolSize(30);
hds.setMinimumIdle(10);
return hds;
}
@Primary
@Bean("dataSource")
public DataSourceProxy dataSourceProxy(@Qualifier("dataSource") DataSource hikariDataSource) {
return new DataSourceProxy(hikariDataSource);
}
@Bean(name = "sqlSessionFactory")
@Autowired
public SqlSessionFactory sqlSessionFactoryBean(@Qualifier("dataSource") DataSource dataSourceProxy, PaginationInterceptor paginationInterceptor, MetaHandler metaHandler) throws Exception {
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
bean.setDataSource(dataSourceProxy);
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
bean.setMapperLocations(resolver.getResources("classpath*:mapper/*.xml"));
GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setSqlInjector(new MybatisSqlInjector());
globalConfig.setMetaObjectHandler(metaHandler);
bean.setGlobalConfig(globalConfig);
Interceptor[] plugins = {paginationInterceptor};
bean.setPlugins(plugins);
return bean.getObject();
}
@Bean
public MetaHandler metaHandler() {
return new MetaHandler();
}
}
package com.yeejoin.amos.boot.module.hygf.biz.feign;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.workflow.model.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@FeignClient(name = "AMOS-API-WORKFLOW", path = "workflow", configuration = {XidFeignConfiguration.class})
public interface WorkFlowFeignService {
/***
* 根据task_id 获取节点信息
*
* */
@RequestMapping(value = "/history/task/nodeInfo", method = RequestMethod.GET)
FeignClientResult<JSONObject> getNodeInfo(@RequestParam(value = "taskId") String taskId);
/***
*
* 查询当前流程对应的可执行任务,无权限级别
* */
@RequestMapping(value = "/task/getTaskNoAuth/{processInstanceId}", method = RequestMethod.GET)
JSONObject getTaskNoAuth(@PathVariable(value = "processInstanceId") String processInstanceId);
/***
*
* 获取流程审批日志
* */
@RequestMapping(value = "/task/flowLogger/{procInsId}", method = RequestMethod.GET)
FeignClientResult<Map<String, Object>> getFlowLogger(@PathVariable(value = "procInsId") String procInsId);
@RequestMapping(value = "/history/task/nodeInfo", method = RequestMethod.GET)
FeignClientResult<JSONObject> getNodeInfotoken(
@RequestHeader(name = "appKey", required = true) String appKey,
@RequestHeader(name = "product", required = true) String product,
@RequestHeader(name = "token", required = true) String token,
@RequestParam(value = "taskId") String taskId);
/***
*
* 查询当前流程对应的可执行任务,无权限级别
* */
@RequestMapping(value = "/task/getTaskNoAuth/{processInstanceId}", method = RequestMethod.GET)
JSONObject getTaskNoAuthtoken(
@RequestHeader(name = "appKey", required = true) String appKey,
@RequestHeader(name = "product", required = true) String product,
@RequestHeader(name = "token", required = true) String token,
@PathVariable(value = "processInstanceId") String processInstanceId);
@RequestMapping(value = "/v2/task/rollBack/{processInstanceId}", method = RequestMethod.POST)
JSONObject rollBack(@PathVariable(value = "processInstanceId") String processInstanceId);
/**
* 工作流启动接口
*
* @param params 业务参数
* @return ProcessTaskDTO
* @throws Exception e
*/
@RequestMapping(value = "/v2/task/start/batch", method = RequestMethod.POST)
FeignClientResult<List<ProcessTaskDTO>> startForBatch(@RequestBody ActWorkflowBatchDTO params) throws Exception;
/**
* 工作流驳回任务接口
*
* @param taskId 任务Id
* @param data 业务参数
* @return ProcessTaskDTO
* @throws Exception e
*/
@RequestMapping(value = "/v2/task/reject/{taskId}", method = RequestMethod.POST)
FeignClientResult<ProcessTaskDTO> reject(@PathVariable("taskId") String taskId, @RequestBody TaskResultDTO data) throws Exception;
/**
* 工作流完成任务接口
*
* @param taskId 任务Id
* @param data 业务参数
* @return ProcessTaskDTO
* @throws Exception e
*/
@RequestMapping(value = "/v2/task/complete/standard/{taskId}", method = RequestMethod.POST)
FeignClientResult<ProcessTaskDTO> completeByTaskFroStandard(@PathVariable("taskId") String taskId, @RequestBody TaskResultDTO data) throws Exception;
/**
* 工作流撤回
*
* @param processInstanceId processInstanceId
* @return ProcessTaskDTO
*/
@PostMapping(value = "/v2/task/rollBack/standard/{processInstanceId}")
FeignClientResult<ProcessTaskDTO> rollBackTask(@PathVariable("processInstanceId") String processInstanceId);
/**
* 转办任务
*
* @param flowTaskVo flowTaskVo
* @return ProcessTaskDTO
*/
@PostMapping(value = "/v2/task/assign")
FeignClientResult<ProcessTaskDTO> assign(@RequestBody FlowTaskVo flowTaskVo);
/**
* 终止流程
*
* @param processInstanceId processInstanceId
* @return ProcessInstanceDTO
* @throws Exception e
*/
@DeleteMapping(value = "/v2/task/stopProcess/{processInstanceId}")
FeignClientResult<ProcessInstanceDTO> stopProcess(@PathVariable("processInstanceId") String processInstanceId, @RequestParam(required = false, value = "stopReason") String stopReason) throws Exception;
}
......@@ -12,7 +12,7 @@ import java.util.List;
import java.util.Map;
@FeignClient(name = "${workflow.feign.name:AMOS-API-WORKFLOW}", path = "workflow", configuration = {MultipartSupportConfig.class})
@FeignClient(name = "${workflow.feign.name:AMOS-API-WORKFLOW}", path = "workflow", configuration = {XidFeignConfiguration.class})
public interface WorkflowFeignClient {
/***
......
package com.yeejoin.amos.boot.module.hygf.biz.feign;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import io.seata.core.context.RootContext;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextListener;
@Configuration
public class XidFeignConfiguration implements RequestInterceptor {
@Autowired
private ObjectFactory<HttpMessageConverters> messageConverters;
@Bean
public Encoder feignFormEncoder() {
return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
/**
* 创建Feign请求拦截器,在发送请求前设置认证的token,各个微服务将token设置到环境变量中来达到通用
* @return
*/
@Bean
public RequestContextListener requestInterceptor() {
return new RequestContextListener();
}
@Override
public void apply(RequestTemplate template) {
String xid = RootContext.getXID();
if(StringUtils.hasText(xid)){
template.header(RootContext.KEY_XID, xid);
}
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.hygf.api.dto.WorkflowResultDto;
import com.yeejoin.amos.boot.module.hygf.biz.feign.WorkFlowFeignService;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.workflow.Workflow;
......@@ -19,7 +20,8 @@ import java.util.stream.Collectors;
@Service
@Slf4j
public class WorkFlowService {
@Autowired
private WorkFlowFeignService workFlowFeignService;
/***
* 开启并执行一步 支持批量
......@@ -29,7 +31,7 @@ public class WorkFlowService {
List<ProcessTaskDTO> processTasks;
try {
log.info("开始前请求工作流启动接口:/start/batch,请求参数:{}", JSONObject.toJSONString(params));
processTasks = FeignUtil.remoteCall(() -> Workflow.taskV2Client.startForBatch(params));
processTasks = workFlowFeignService.startForBatch(params).getResult();
} catch (Exception e) {
log.error("调用工作流批量启动失败", e);
throw new RuntimeException("调用工作流批量启动失败");
......@@ -42,7 +44,7 @@ public class WorkFlowService {
ProcessInstanceDTO processInstanceDTO ;
try {
log.info("开始前请求工作流停止接口:stopProcess,请求参数:{}", processInstanceId);
processInstanceDTO = FeignUtil.remoteCall(() -> Workflow.taskV2Client.stopProcess(processInstanceId));
processInstanceDTO = workFlowFeignService.stopProcess(processInstanceId,null).getResult();
} catch (Exception e) {
log.error("调用工作流批量停止失败", e);
throw new RuntimeException("调用工作流批量停止失败");
......@@ -59,7 +61,7 @@ public class WorkFlowService {
ProcessTaskDTO processTaskDTO;
try {
log.info("开始前请求工作流完成任务接口:/complete/standard/{taskId},请求参数:{},{}", taskId, JSONObject.toJSONString(data));
processTaskDTO = FeignUtil.remoteCall(() -> Workflow.taskV2Client.completeByTaskFroStandard(taskId, data));
processTaskDTO = workFlowFeignService.completeByTaskFroStandard(taskId, data).getResult();
} catch (Exception e) {
log.error("调用工作流完成任务接口失败", e);
throw new RuntimeException("调用工作流完成任务接口失败");
......
......@@ -226,4 +226,8 @@ cheduled.crons=0 10 0 * * ?
dealer.appcode.manage=studio_normalapp_5155413,studio_normalapp_5133538
dealer.appcode.role=1767363928842571777
dealer.amosDealerId=1767820997374775298
\ No newline at end of file
dealer.amosDealerId=1767820997374775298
#Seata Config
seata.tx-service-group= jxiop-seata
seata.service.grouplist.jxiop-seata=47.92.234.253:8091
\ No newline at end of file
......@@ -2,7 +2,7 @@ spring.application.name=AMOS-HYGF-CAOTAO
server.servlet.context-path=/hygf
server.port=33330
server.uri-encoding=UTF-8
spring.profiles.active=dev1
spring.profiles.active=dev
spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
logging.config=classpath:logback-${spring.profiles.active}.xml
......@@ -56,4 +56,7 @@ amos.system.user.user-name=hygf_admin08
amos.system.user.password=a1234560
amos.system.user.product=AMOS_STUDIO_WEB
amos.system.user.app-key=AMOS_STUDIO
workflow.feign.name=AMOS-API-WORKFLOW
\ No newline at end of file
workflow.feign.name=AMOS-API-WORKFLOW
feign.okhttp.enabled= true
\ No newline at end of file
transport {
# tcp udt unix-domain-socket
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = true
# the client batch send request enable
enableClientBatchSendRequest = true
#thread factory for netty
threadFactory {
bossThreadPrefix = "NettyBoss"
workerThreadPrefix = "NettyServerNIOWorker"
serverExecutorThread-prefix = "NettyServerBizHandler"
shareBossWorker = false
clientSelectorThreadPrefix = "NettyClientSelector"
clientSelectorThreadSize = 1
clientWorkerThreadPrefix = "NettyClientWorkerThread"
# netty boss thread size,will not be used for UDT
bossThreadSize = 1
#auto default pin or 8
workerThreadSize = "8"
}
shutdown {
# when destroy server, wait seconds
wait = 3
}
serialization = "seata"
compressor = "none"
}
service {
#transaction service group mapping
vgroupMapping.tzs-seata = "jxiop-seata"
#only support when registry.type=file, please don't set multiple addresses
default.grouplist = "47.92.234.253:8091"
#degrade, current not support
enableDegrade = false
#disable seata
disableGlobalTransaction = false
}
client {
rm {
asyncCommitBufferLimit = 10000
lock {
retryInterval = 10
retryTimes = 30
retryPolicyBranchRollbackOnConflict = true
}
reportRetryCount = 5
tableMetaCheckEnable = false
reportSuccessEnable = false
}
tm {
commitRetryCount = 5
rollbackRetryCount = 5
default-global-transaction-timeout = 600 # 600秒
}
undo {
dataValidation = true
logSerialization = "protostuff"
logTable = "undo_log"
}
log {
exceptionRate = 100
}
}
\ No newline at end of file
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "eureka"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
eureka {
serviceUrl = "http://admin:a1234560@47.92.234.253:10001/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
password = ""
cluster = "default"
timeout = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
username = ""
password = ""
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
etcd3 {
cluster = "default"
serverAddr = "http://localhost:2379"
}
sofa {
serverAddr = "127.0.0.1:9603"
application = "default"
region = "DEFAULT_ZONE"
datacenter = "DefaultDataCenter"
cluster = "default"
group = "SEATA_GROUP"
addressWaitTime = "3000"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3、springCloudConfig
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
group = "SEATA_GROUP"
}
consul {
serverAddr = "127.0.0.1:8500"
}
apollo {
app.id = "seata-server"
apollo.meta = "http://localhost:8801"
namespace = "application"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
username = ""
password = ""
}
etcd3 {
serverAddr = "http://localhost:2379"
}
file {
name = "file.conf"
}
}
......@@ -91,11 +91,6 @@
</exclusions>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.18</version>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment