add:源码阅读demo
This commit is contained in:
@@ -30,6 +30,11 @@
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<artifactId>liteflow-spring-boot-starter</artifactId>
|
||||
<version>2.10.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
@@ -58,6 +63,44 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Sa-Token 权限认证 安全框架, -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.31.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.12</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
<!-- Sa-Token 整合 jwt -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-jwt</artifactId>
|
||||
<version>1.31.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package nl.org.transactionaldemo;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("nl.org.transactionaldemo.server.源码阅读.db.dao.mapper")
|
||||
public class StartApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package nl.org.transactionaldemo.config;
|
||||
|
||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* @author: lyd
|
||||
* @description: sa-token的配置路由拦截
|
||||
* @Date: 2022-09-20
|
||||
*/
|
||||
@Configuration
|
||||
public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
static {
|
||||
System.out.println("加载SaTokenConfigure");
|
||||
}
|
||||
|
||||
// Sa-Token 整合 jwt (Simple 简单模式)
|
||||
@Bean
|
||||
public StpLogic getStpLogicJwt() {
|
||||
return new StpLogicJwtForSimple();
|
||||
}
|
||||
|
||||
// 注册 Sa-Token 拦截器,打开注解式鉴权功能
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
||||
.addPathPatterns("/**");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package nl.org.transactionaldemo.server.JDK新特性.CompletableFuture;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* 异步编程工具
|
||||
* @Date 2023/5/6 15:24
|
||||
*/
|
||||
public class CompletableDemo {
|
||||
public static void main(String[] args) {
|
||||
ThreadPoolExecutor executor = new ThreadPoolExecutor(4, 8, 30L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(50));
|
||||
ArrayList<Map> datas = new ArrayList();
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("NO:"+i, UUID.randomUUID().toString());
|
||||
datas.add(map);
|
||||
}
|
||||
List<List<Map>> partition = Lists.partition(datas, 200);
|
||||
//没有返回值的异步操作
|
||||
runasync(executor, partition);
|
||||
supplyAsync(executor, partition);
|
||||
}
|
||||
|
||||
private static void runasync(ThreadPoolExecutor executor, List<List<Map>> partition) {
|
||||
long res = partition.stream().map(item -> CompletableFuture.runAsync(() -> {
|
||||
for (Map data : item) {
|
||||
System.out.println(Thread.currentThread().getName()+"____"+data.keySet().toString());
|
||||
}
|
||||
}, executor)).parallel().map(CompletableFuture::join).count();//join.get会等待全部线程返回结果
|
||||
}
|
||||
|
||||
private static void supplyAsync(ThreadPoolExecutor executor, List<List<Map>> partition) {
|
||||
|
||||
List<Object> collect = partition.stream().map(item -> CompletableFuture.supplyAsync(() -> Thread.currentThread().getName()+"____"+item.stream().map(a->a.keySet().toString()).collect(Collectors.toList()).size(), executor)).parallel().map(CompletableFuture::join).collect(Collectors.toList());
|
||||
System.out.println(collect.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package nl.org.transactionaldemo.server.流程引擎.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/5/6 18:21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/flow")
|
||||
public class FlowController {
|
||||
|
||||
@Resource
|
||||
FlowExecutor flowExecutor;
|
||||
|
||||
@RequestMapping("/demo")
|
||||
public String flow(@RequestParam("way") Boolean way){
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("way",way);
|
||||
Future<LiteflowResponse> fullflow = flowExecutor.execute2Future("fullflow", param);
|
||||
return "sucess";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package nl.org.transactionaldemo.server.流程引擎.gateway;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yomahub.liteflow.core.NodeIfComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/5/6 17:56
|
||||
*/
|
||||
@Component()
|
||||
public class 专机网关 extends NodeIfComponent {
|
||||
@Override //x就是IF组件,为真,执行a,为假,执行b:
|
||||
public boolean processIf() throws Exception {
|
||||
System.out.println("执行网关");
|
||||
JSONObject data = (JSONObject)this.getRequestData();
|
||||
return data.getBoolean("way");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package nl.org.transactionaldemo.server.流程引擎.nodes;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/5/6 17:54
|
||||
*/
|
||||
@Component
|
||||
public class 推弯一体 extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
System.out.println("推弯一体");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package nl.org.transactionaldemo.server.流程引擎.nodes;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/5/6 17:54
|
||||
*/
|
||||
@Component
|
||||
public class 深坑储料仓 extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
System.out.println("深坑储料仓");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package nl.org.transactionaldemo.server.流程引擎.nodes;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/5/6 17:54
|
||||
*/
|
||||
@Component
|
||||
public class 激光下料机 extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
System.out.println("激光下料机");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package nl.org.transactionaldemo.server.流程引擎.nodes;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/5/6 17:54
|
||||
*/
|
||||
@Component
|
||||
public class 缓存线 extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
System.out.println("激光下料机");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package nl.org.transactionaldemo.server.流程引擎.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/5/6 18:21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sourcecode")
|
||||
public class ErrorDemo {
|
||||
|
||||
@RequestMapping("/demo")
|
||||
public String flow(@RequestParam("list") List<String> way){
|
||||
way.forEach(a->
|
||||
Integer.valueOf(a));
|
||||
return "sucess";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package nl.org.transactionaldemo.server.源码阅读;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import nl.org.transactionaldemo.server.源码阅读.db.ISchProcessRouteService;
|
||||
import nl.org.transactionaldemo.server.源码阅读.db.dao.SchProcessRoute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/5/6 18:21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/page")
|
||||
public class PageHelperDemoo {
|
||||
|
||||
@Resource
|
||||
ISchProcessRouteService routeService;
|
||||
|
||||
@RequestMapping("/demo")
|
||||
public String flow(@RequestParam("list") List<String> way){
|
||||
Page<Object> page = PageHelper.startPage(1, 2);
|
||||
List<SchProcessRoute> list = routeService.list();
|
||||
return "sucess";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package nl.org.transactionaldemo.server.源码阅读.db;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import nl.org.transactionaldemo.server.源码阅读.db.dao.SchProcessRoute;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 物料系列调度线路配置表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
public interface ISchProcessRouteService extends IService<SchProcessRoute> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package nl.org.transactionaldemo.server.源码阅读.db;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import nl.org.transactionaldemo.server.源码阅读.db.dao.SchProcessRoute;
|
||||
import nl.org.transactionaldemo.server.源码阅读.db.dao.mapper.SchProcessRouteMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 物料系列调度线路配置表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
@Service
|
||||
public class SchProcessRouteServiceImpl extends ServiceImpl<SchProcessRouteMapper, SchProcessRoute> implements ISchProcessRouteService {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package nl.org.transactionaldemo.server.源码阅读.db.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 物料系列调度线路配置表
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
@TableName("sch_process_route")
|
||||
public class SchProcessRoute implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 规则(物料系列/区域)
|
||||
*/
|
||||
@TableId(value ="rule_code" )
|
||||
private String rule_code;
|
||||
|
||||
/**
|
||||
* 袋唯一标识
|
||||
*/
|
||||
private String process_id;
|
||||
|
||||
private String process_name;
|
||||
|
||||
|
||||
public String getRule_code() {
|
||||
return rule_code;
|
||||
}
|
||||
|
||||
public void setRule_code(String rule_code) {
|
||||
this.rule_code = rule_code;
|
||||
}
|
||||
|
||||
public String getProcess_id() {
|
||||
return process_id;
|
||||
}
|
||||
|
||||
public void setProcess_id(String process_id) {
|
||||
this.process_id = process_id;
|
||||
}
|
||||
|
||||
public String getProcess_name() {
|
||||
return process_name;
|
||||
}
|
||||
|
||||
public void setProcess_name(String process_name) {
|
||||
this.process_name = process_name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package nl.org.transactionaldemo.server.源码阅读.db.dao.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import nl.org.transactionaldemo.server.源码阅读.db.dao.*;
|
||||
/**
|
||||
* <p>
|
||||
* 物料系列调度线路配置表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
public interface SchProcessRouteMapper extends BaseMapper<SchProcessRoute> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package nl.org.transactionaldemo.server.锁.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/12/5 14:45
|
||||
*/
|
||||
@Service
|
||||
public class PointService {
|
||||
|
||||
public String findPoint(){
|
||||
return "";
|
||||
};
|
||||
}
|
||||
21
transactional-demo/src/main/resources/flow.xml
Normal file
21
transactional-demo/src/main/resources/flow.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<nodes>
|
||||
<node id="推弯一体" class="nl.org.transactionaldemo.server.流程引擎.nodes.推弯一体"/>
|
||||
<node id="激光下料机" class="nl.org.transactionaldemo.server.流程引擎.nodes.激光下料机"/>
|
||||
<node id="深坑储料仓" class="nl.org.transactionaldemo.server.流程引擎.nodes.深坑储料仓"/>
|
||||
<node id="缓存线" class="nl.org.transactionaldemo.server.流程引擎.nodes.缓存线"/>
|
||||
<node id="专机网关" class="nl.org.transactionaldemo.server.流程引擎.gateway.专机网关"/>
|
||||
|
||||
</nodes>
|
||||
|
||||
<chain name="fullflow">
|
||||
THEN(激光下料机,
|
||||
IF(专机网关,缓存线,
|
||||
THEN(推弯一体,
|
||||
IF(专机网关,缓存线, 深坑储料仓)
|
||||
)
|
||||
)
|
||||
);
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user