mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-12 21:49:01 +08:00
Merge branch 'leng_dev' into greenwich
# Conflicts: # pigx-auth/pom.xml # pigx-common/pigx-common-core/pom.xml # pigx-common/pigx-common-data/pom.xml # pigx-common/pigx-common-gateway/pom.xml # pigx-common/pigx-common-job/pom.xml # pigx-common/pigx-common-log/pom.xml # pigx-common/pigx-common-minio/pom.xml # pigx-common/pigx-common-security/pom.xml # pigx-common/pigx-common-swagger/pom.xml # pigx-common/pigx-common-transaction/pom.xml # pigx-common/pom.xml # pigx-config/pom.xml # pigx-config/src/main/resources/config/pigx-upms-biz-dev.yml # pigx-eureka/pom.xml # pigx-gateway/pom.xml # pigx-upms/pigx-upms-api/pom.xml # pigx-upms/pigx-upms-biz/pom.xml # pigx-upms/pom.xml # pigx-visual/pigx-activiti/pom.xml # pigx-visual/pigx-codegen/pom.xml # pigx-visual/pigx-daemon/pom.xml # pigx-visual/pigx-monitor/pom.xml # pigx-visual/pigx-sso-client-demo/pom.xml # pigx-visual/pigx-tx-manager/pom.xml # pigx-visual/pom.xml # pom.xml
This commit is contained in:
commit
2b2507a068
85 files changed
+1423
-629
No files matched your search
+10
-1
@@ -21,6 +21,9 @@ import lombok.AllArgsConstructor;
|
||||
import org.activiti.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.sql.DataSource;
|
||||
@@ -39,7 +42,7 @@ public class ActivitiConfig {
|
||||
@Bean
|
||||
public SpringProcessEngineConfiguration getProcessEngineConfiguration() {
|
||||
SpringProcessEngineConfiguration config =
|
||||
new SpringProcessEngineConfiguration();
|
||||
new SpringProcessEngineConfiguration();
|
||||
// 流程图字体设置
|
||||
config.setActivityFontName("宋体");
|
||||
config.setAnnotationFontName("宋体");
|
||||
@@ -51,4 +54,10 @@ public class ActivitiConfig {
|
||||
config.setDatabaseSchemaUpdate("true");
|
||||
return config;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public TaskExecutor primaryTaskExecutor() {
|
||||
return new ThreadPoolTaskExecutor();
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.pig4cloud.pigx.act.config;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.simp.config.ChannelRegistration;
|
||||
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||
import org.springframework.messaging.simp.stomp.StompCommand;
|
||||
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.messaging.support.MessageHeaderAccessor;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
||||
import org.springframework.security.oauth2.provider.token.RemoteTokenServices;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
||||
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
||||
|
||||
/**
|
||||
* @author new
|
||||
* <p>
|
||||
* WebSocket配置类
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@AllArgsConstructor
|
||||
@EnableWebSocketMessageBroker
|
||||
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
|
||||
private RemoteTokenServices tokenService;
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry.addEndpoint("/ws")
|
||||
.setAllowedOrigins("*")
|
||||
.withSockJS();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureMessageBroker(MessageBrokerRegistry registry) {
|
||||
registry.setUserDestinationPrefix("/task/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureClientInboundChannel(ChannelRegistration registration) {
|
||||
registration.interceptors(new ChannelInterceptor() {
|
||||
@Override
|
||||
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
||||
if (StompCommand.CONNECT.equals(accessor.getCommand())) {
|
||||
String tokens = accessor.getFirstNativeHeader("Authorization");
|
||||
log.info("webSocket token is {}", tokens);
|
||||
if (StrUtil.isBlank(tokens)) {
|
||||
return null;
|
||||
}
|
||||
OAuth2Authentication auth2Authentication = tokenService.loadAuthentication(tokens.split(" ")[1]);
|
||||
SecurityContextHolder.getContext().setAuthentication(auth2Authentication);
|
||||
accessor.setUser(() -> (String) auth2Authentication.getPrincipal());
|
||||
}
|
||||
return message;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+11
@@ -22,11 +22,14 @@ import com.pig4cloud.pigx.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pigx.admin.api.feign.RemoteUserService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.core.util.SpringContextHolder;
|
||||
import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.engine.delegate.DelegateTask;
|
||||
import org.activiti.engine.delegate.TaskListener;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -45,18 +48,26 @@ public class LeaveProcessTaskListener implements TaskListener {
|
||||
*/
|
||||
@Override
|
||||
public void notify(DelegateTask delegateTask) {
|
||||
SimpMessagingTemplate simpMessagingTemplate = SpringContextHolder.getBean(SimpMessagingTemplate.class);
|
||||
RemoteUserService userService = SpringContextHolder.getBean(RemoteUserService.class);
|
||||
|
||||
R<List<SysUser>> result = userService.ancestorUsers(SecurityUtils.getUsername());
|
||||
List<String> remindUserList = new ArrayList<>();
|
||||
|
||||
if (CollUtil.isEmpty(result.getData())) {
|
||||
log.info("用户 {} 不存在上级,任务单由当前用户审批", SecurityUtils.getUsername());
|
||||
delegateTask.addCandidateUser(SecurityUtils.getUsername());
|
||||
remindUserList.add(SecurityUtils.getUsername());
|
||||
} else {
|
||||
List<String> userList = result.getData().stream().map(SysUser::getUsername).collect(Collectors.toList());
|
||||
log.info("当前任务 {},由 {}处理", delegateTask.getId(), userList);
|
||||
delegateTask.addCandidateUsers(userList);
|
||||
remindUserList.addAll(userList);
|
||||
}
|
||||
|
||||
remindUserList.forEach(user -> {
|
||||
String target = String.format("%s-%s", SecurityUtils.getUsername(), TenantContextHolder.getTenantId());
|
||||
simpMessagingTemplate.convertAndSendToUser(target, "/remind", delegateTask.getName());
|
||||
});
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -23,6 +23,7 @@ import com.pig4cloud.pigx.codegen.entity.GenConfig;
|
||||
import com.pig4cloud.pigx.codegen.service.SysGeneratorService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -55,13 +56,14 @@ public class SysGeneratorController {
|
||||
/**
|
||||
* 生成代码
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/code")
|
||||
public void generatorCode(@RequestBody GenConfig genConfig, HttpServletResponse response) throws IOException {
|
||||
public void generatorCode(@RequestBody GenConfig genConfig, HttpServletResponse response) {
|
||||
byte[] data = sysGeneratorService.generatorCode(genConfig);
|
||||
|
||||
response.reset();
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=%s.zip", genConfig.getTableName()));
|
||||
response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length));
|
||||
response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length));
|
||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||
|
||||
IoUtil.write(response.getOutputStream(), Boolean.TRUE, data);
|
||||
|
||||
+7
-3
@@ -25,6 +25,7 @@ import com.pig4cloud.pigx.manager.model.ModelInfo;
|
||||
import com.pig4cloud.pigx.manager.model.ModelName;
|
||||
import com.pig4cloud.pigx.manager.model.TxState;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -89,18 +90,21 @@ public class AdminController {
|
||||
return apiAdminService.modelInfos(path);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@RequestMapping(value = "/compensate", method = RequestMethod.GET)
|
||||
public boolean compensate(@RequestParam("path") String path) throws ServiceException {
|
||||
public boolean compensate(@RequestParam("path") String path) {
|
||||
return apiAdminService.compensate(path);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@RequestMapping(value = "/delCompensate", method = RequestMethod.GET)
|
||||
public boolean delCompensate(@RequestParam("path") String path) throws ServiceException {
|
||||
public boolean delCompensate(@RequestParam("path") String path) {
|
||||
return apiAdminService.delCompensate(path);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@RequestMapping(value = "/hasCompensate", method = RequestMethod.GET)
|
||||
public boolean hasCompensate() throws ServiceException {
|
||||
public boolean hasCompensate() {
|
||||
return apiAdminService.hasCompensate();
|
||||
}
|
||||
}
|
||||
+1
@@ -21,6 +21,7 @@ import com.lorne.core.framework.exception.ServiceException;
|
||||
import com.pig4cloud.pigx.manager.compensate.model.TxModel;
|
||||
import com.pig4cloud.pigx.manager.model.ModelName;
|
||||
import com.pig4cloud.pigx.manager.model.TxState;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
+3
-1
@@ -28,6 +28,7 @@ import com.pig4cloud.pigx.manager.model.ModelName;
|
||||
import com.pig4cloud.pigx.manager.model.TxState;
|
||||
import com.pig4cloud.pigx.manager.redis.RedisServerService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -108,7 +109,8 @@ public class ApiAdminServiceImpl implements ApiAdminService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compensate(String path) throws ServiceException {
|
||||
@SneakyThrows
|
||||
public boolean compensate(String path) {
|
||||
return compensateService.executeCompensate(path);
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -36,6 +36,7 @@ import com.pig4cloud.pigx.manager.model.ModelInfo;
|
||||
import com.pig4cloud.pigx.manager.model.ModelName;
|
||||
import com.pig4cloud.pigx.manager.netty.model.TxGroup;
|
||||
import com.pig4cloud.pigx.manager.netty.model.TxInfo;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -309,7 +310,8 @@ public class CompensateServiceImpl implements CompensateService {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean executeCompensate(String path) throws ServiceException {
|
||||
@SneakyThrows
|
||||
public boolean executeCompensate(String path) {
|
||||
|
||||
String json = compensateDao.getCompensate(path);
|
||||
if (json == null) {
|
||||
@@ -326,8 +328,8 @@ public class CompensateServiceImpl implements CompensateService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean executeCompensateMethod(String json) throws ServiceException {
|
||||
@SneakyThrows
|
||||
private boolean executeCompensateMethod(String json) {
|
||||
JSONObject jsonObject = JSON.parseObject(json);
|
||||
|
||||
String model = jsonObject.getString("model");
|
||||
|
||||
+5
-13
@@ -301,19 +301,11 @@ public class TxManagerSenderServiceImpl implements TxManagerSenderService {
|
||||
|
||||
|
||||
private ScheduledFuture schedule(final String key, int delayTime) {
|
||||
ScheduledFuture future = executorService.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Task task = ConditionUtils.getInstance().getTask(key);
|
||||
if (task != null && !task.isNotify()) {
|
||||
task.setBack(new IBack() {
|
||||
@Override
|
||||
public Object doing(Object... objs) throws Throwable {
|
||||
return "-2";
|
||||
}
|
||||
});
|
||||
task.signalTask();
|
||||
}
|
||||
ScheduledFuture future = executorService.schedule(() -> {
|
||||
Task task = ConditionUtils.getInstance().getTask(key);
|
||||
if (task != null && !task.isNotify()) {
|
||||
task.setBack(objs -> "-2");
|
||||
task.signalTask();
|
||||
}
|
||||
}, delayTime, TimeUnit.SECONDS);
|
||||
|
||||
|
||||
+2
-12
@@ -64,22 +64,12 @@ public class ChannelSender {
|
||||
final String res = HttpUtils.post(url, "msg=" + msg + "&model=" + modelName);
|
||||
if (StringUtils.isNotEmpty(res)) {
|
||||
if (task != null) {
|
||||
task.setBack(new IBack() {
|
||||
@Override
|
||||
public Object doing(Object... objs) throws Throwable {
|
||||
return res;
|
||||
}
|
||||
});
|
||||
task.setBack(objs -> res);
|
||||
task.signalTask();
|
||||
}
|
||||
} else {
|
||||
if (task != null) {
|
||||
task.setBack(new IBack() {
|
||||
@Override
|
||||
public Object doing(Object... objs) throws Throwable {
|
||||
return "-2";
|
||||
}
|
||||
});
|
||||
task.setBack(objs -> "-2");
|
||||
task.signalTask();
|
||||
}
|
||||
}
|
||||
|
||||
+10
-12
@@ -32,6 +32,7 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.handler.timeout.IdleState;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -62,15 +63,10 @@ public class TxCoreServerHandler extends ChannelInboundHandlerAdapter { // (1)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(final ChannelHandlerContext ctx, Object msg) {
|
||||
final String json = SocketUtils.getJson(msg);
|
||||
logger.debug("request->" + json);
|
||||
threadPool.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
service(json, ctx);
|
||||
}
|
||||
});
|
||||
threadPool.execute(() -> service(json, ctx));
|
||||
}
|
||||
|
||||
private void service(String json, ChannelHandlerContext ctx) {
|
||||
@@ -95,7 +91,8 @@ public class TxCoreServerHandler extends ChannelInboundHandlerAdapter { // (1)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
|
||||
@SneakyThrows
|
||||
public void channelRegistered(ChannelHandlerContext ctx) {
|
||||
|
||||
//是否到达最大上线连接数
|
||||
if (SocketManager.getInstance().isAllowConnection()) {
|
||||
@@ -107,7 +104,8 @@ public class TxCoreServerHandler extends ChannelInboundHandlerAdapter { // (1)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
|
||||
@SneakyThrows
|
||||
public void channelUnregistered(ChannelHandlerContext ctx) {
|
||||
|
||||
SocketManager.getInstance().removeClient(ctx.channel());
|
||||
String modelName = ctx.channel().remoteAddress().toString();
|
||||
@@ -118,18 +116,18 @@ public class TxCoreServerHandler extends ChannelInboundHandlerAdapter { // (1)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
cause.printStackTrace();
|
||||
//ctx.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
|
||||
//心跳配置
|
||||
if (IdleStateEvent.class.isAssignableFrom(evt.getClass())) {
|
||||
IdleStateEvent event = (IdleStateEvent) evt;
|
||||
|
||||
+1
-6
@@ -32,12 +32,7 @@ public class BaseSignalTaskService {
|
||||
final String data = params.getString("d");
|
||||
Task task = ConditionUtils.getInstance().getTask(key);
|
||||
if (task != null) {
|
||||
task.setBack(new IBack() {
|
||||
@Override
|
||||
public Object doing(Object... objs) throws Throwable {
|
||||
return data;
|
||||
}
|
||||
});
|
||||
task.setBack(objs -> data);
|
||||
task.signalTask();
|
||||
}
|
||||
return res;
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ public class NettyServerServiceImpl implements NettyServerService, DisposableBea
|
||||
.handler(new LoggingHandler(LogLevel.INFO))
|
||||
.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
public void initChannel(SocketChannel ch) {
|
||||
ch.pipeline().addLast("timeout", new IdleStateHandler(heartTime, heartTime, heartTime, TimeUnit.SECONDS));
|
||||
|
||||
ch.pipeline().addLast(new LengthFieldPrepender(4, false));
|
||||
@@ -113,7 +113,7 @@ public class NettyServerServiceImpl implements NettyServerService, DisposableBea
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
public void destroy() {
|
||||
close();
|
||||
threadPool.shutdown();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user