1
This commit is contained in:
@@ -20,6 +20,18 @@
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aivfo</groupId>
|
||||
<artifactId>aivfo-element-base</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.wyl.delayqueue.sms;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Auther humingbo
|
||||
* @Date 2022-09-14 11:19
|
||||
* @desc 短信参数dto
|
||||
*/
|
||||
@Data
|
||||
public class SmsDto implements Serializable {
|
||||
|
||||
/**
|
||||
* 短信模板编码
|
||||
*/
|
||||
private String smsCode;
|
||||
|
||||
/**
|
||||
* 发送短信号码
|
||||
*/
|
||||
private String tel;
|
||||
|
||||
|
||||
/**
|
||||
* 发送方式 0为短信,1为电话语音
|
||||
* 默认为短信
|
||||
*/
|
||||
private String sendWay;
|
||||
|
||||
private Map<String, String> maps = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 发送的加密内容
|
||||
*/
|
||||
private String sendMsg;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.wyl.delayqueue.sms;
|
||||
|
||||
import com.aivfo.el.starter.base.utils.JsonUtils;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Test {
|
||||
/**
|
||||
* 加解密key
|
||||
*/
|
||||
private static String key = "deiloplowsdcjiue";
|
||||
|
||||
/**
|
||||
* 加解密偏移量
|
||||
*/
|
||||
private static String iv = "seiloplowsdcjiue";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SmsDto smsDto = new SmsDto();
|
||||
smsDto.setSmsCode("123");
|
||||
smsDto.setTel("17793132945");
|
||||
smsDto.setSendWay("0");
|
||||
Map<String, String> objectObjectHashMap = new HashMap<>();
|
||||
objectObjectHashMap.put("1", "123");
|
||||
smsDto.setMaps(objectObjectHashMap);
|
||||
String s = encryptAES(JsonUtils.toJson(smsDto), key, iv);
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
public static String encryptAES(String data, String key, String iv) throws Exception {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
|
||||
int blockSize = cipher.getBlockSize();
|
||||
byte[] dataBytes = data.getBytes();
|
||||
int plaintextLength = dataBytes.length;
|
||||
if (plaintextLength % blockSize != 0) {
|
||||
plaintextLength = plaintextLength + (blockSize - (plaintextLength % blockSize));
|
||||
}
|
||||
byte[] plaintext = new byte[plaintextLength];
|
||||
System.arraycopy(dataBytes, 0, plaintext, 0, dataBytes.length);
|
||||
SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");
|
||||
IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());
|
||||
cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
|
||||
byte[] encrypted = cipher.doFinal(plaintext);
|
||||
return encode(encrypted).trim();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*
|
||||
* @param byteArray
|
||||
* @return
|
||||
*/
|
||||
public static String encode(byte[] byteArray) {
|
||||
return new String(new Base64().encode(byteArray));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.wyl.delayqueue.system;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(LocalDate.now().getYear());
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,10 @@
|
||||
<version>2.6.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.wyl.socket.client;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class SocketReceiveTimeoutExample {
|
||||
public static void main(String[] args) {
|
||||
String serverAddress = "127.0.0.1";
|
||||
int serverPort = 9999;
|
||||
int timeoutMillis = 5000; // 设置接收数据的超时时间为5秒
|
||||
|
||||
try {
|
||||
Socket socket = new Socket(serverAddress, serverPort);
|
||||
socket.setSoTimeout(timeoutMillis);
|
||||
OutputStream dout = socket.getOutputStream();
|
||||
String str = "数据传输------";
|
||||
dout.write(str.getBytes());
|
||||
|
||||
// 获取输入流
|
||||
InputStream inputStream = socket.getInputStream();
|
||||
byte[] outPut = new byte[4096];
|
||||
while (inputStream.read(outPut) > 0) {
|
||||
String result = new String(outPut);
|
||||
System.out.println("服务端反回的的消息是:" + result);
|
||||
}
|
||||
// 设置接收数据的超时时间
|
||||
|
||||
// 进行数据接收操作,例如使用 inputStream.read()
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("接收数据超时");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,39 @@
|
||||
package com.wyl.socket.client;
|
||||
|
||||
import java.io.InputStream;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
* 客户端
|
||||
*
|
||||
* @author 刘正
|
||||
*
|
||||
* @author 刘正
|
||||
*/
|
||||
public class clienttextnet {
|
||||
public static String _pattern = "yyyy-MM-dd HH:mm:ss SSS";
|
||||
public static SimpleDateFormat format = new SimpleDateFormat(_pattern);
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
while (true) {
|
||||
// 与服务端建立连接
|
||||
Socket socket = new Socket("127.0.0.1", 9999);
|
||||
ThreadUtil.execute(() -> {
|
||||
try {
|
||||
Socket sock = new Socket();
|
||||
sock.setSoTimeout(2000);
|
||||
sock.setReuseAddress(true);
|
||||
sock.connect(new InetSocketAddress("127.0.0.1", 9999), 10000);
|
||||
// 获得输出流,给服务端发送信息
|
||||
OutputStream dout = socket.getOutputStream();
|
||||
OutputStream dout = sock.getOutputStream();
|
||||
String str = "数据传输------";
|
||||
dout.write(str.getBytes());
|
||||
// 通过shutdownOutput高速服务器已经发送完数据,后续只能接受数据
|
||||
socket.shutdownOutput();
|
||||
|
||||
// 接收服务端发送的消息
|
||||
InputStream din = socket.getInputStream();
|
||||
byte[] outPut = new byte[4096];
|
||||
while (din.read(outPut) > 0) {
|
||||
String result = new String(outPut);
|
||||
System.out.println("服务端反回的的消息是:" + result);
|
||||
while (true) {
|
||||
dout.write(str.getBytes());
|
||||
}
|
||||
din.close();
|
||||
dout.close();
|
||||
socket.close();
|
||||
Thread.sleep(3000);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 与服务端建立连接
|
||||
// Socket sock = new Socket("127.0.0.1", 9999);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,50 +2,58 @@ package com.wyl.socket.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* 服务端
|
||||
* @author 刘正
|
||||
*
|
||||
* @author 刘正
|
||||
*/
|
||||
public class servernettext {
|
||||
public static String _pattern = "yyyy-MM-dd HH:mm:ss SSS";
|
||||
public static SimpleDateFormat format = new SimpleDateFormat(_pattern);
|
||||
// 设置超时间
|
||||
public static int _sec = 0;
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
|
||||
|
||||
//监听指定的端口
|
||||
ServerSocket server=new ServerSocket(9999);
|
||||
ServerSocket server = new ServerSocket(9999);
|
||||
while (true) {
|
||||
//建立连接
|
||||
Socket soket=server.accept();
|
||||
System.out.println(format.format(new Date()));
|
||||
System.out.println("建立了链接\n");
|
||||
//接收客户端消息(从socket中获取输入流,并建立缓冲区进行读取)
|
||||
InputStream din=soket.getInputStream();
|
||||
System.out.println("客户端ip地址是:"+soket.getInetAddress());
|
||||
System.out.println("客户端端口号是:"+soket.getPort());
|
||||
System.out.println("本地端口号是:"+soket.getLocalPort());
|
||||
byte[] outPut=new byte[4096];
|
||||
while (din.read(outPut)>0) {
|
||||
//注意指定编码格式,发送方和接收方一定要统一,建议使用UTF-8
|
||||
String result=new String(outPut);
|
||||
System.out.println("客户端的消息是:"+result);
|
||||
try {
|
||||
Socket soket = server.accept();
|
||||
System.out.println(format.format(new Date()));
|
||||
System.out.println("建立了链接\n");
|
||||
//接收客户端消息(从socket中获取输入流,并建立缓冲区进行读取)
|
||||
InputStream din = soket.getInputStream();
|
||||
System.out.println("客户端ip地址是:" + soket.getInetAddress());
|
||||
System.out.println("客户端端口号是:" + soket.getPort());
|
||||
System.out.println("本地端口号是:" + soket.getLocalPort());
|
||||
byte[] outPut = new byte[4096];
|
||||
while (din.read(outPut) > 0) {
|
||||
//注意指定编码格式,发送方和接收方一定要统一,建议使用UTF-8
|
||||
String result = new String(outPut);
|
||||
System.out.println("客户端的消息是:" + result);
|
||||
}
|
||||
Thread.sleep(1000000L);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
//给客户端发送消息
|
||||
OutputStream dout=soket.getOutputStream();
|
||||
dout.write("已收到你发来的消息!!".getBytes());
|
||||
// OutputStream dout = soket.getOutputStream();
|
||||
// dout.write("已收到你发来的消息!!".getBytes());
|
||||
|
||||
din.close();
|
||||
dout.close();
|
||||
soket.close();
|
||||
// din.close();
|
||||
// dout.close();
|
||||
// soket.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>JavaBasiceDemo</artifactId>
|
||||
<groupId>com.wyl.example</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cache</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine -->
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>3.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jasypt</groupId>
|
||||
<artifactId>jasypt</artifactId>
|
||||
<version>1.9.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.wyl.cache;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CaffeineTest {
|
||||
public static void main(String[] args) {
|
||||
Cache<String, String> cache = Caffeine.newBuilder().maximumSize(1000).expireAfterAccess(1, TimeUnit.HOURS).build();
|
||||
cache.get("k", o -> CaffeineTest.buildLoader(o));
|
||||
}
|
||||
|
||||
private static String buildLoader(String k) {
|
||||
return k + "+default";
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package com.wyl.cache;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Solution {
|
||||
public static List<String> commonChars(String[] words) {
|
||||
List<String> res = new ArrayList<>();
|
||||
Map<String, Long> collect = Arrays.asList(words[0].split("")).stream().collect(Collectors.groupingBy(s -> s, Collectors.counting()));
|
||||
for (int i = 1; i < words.length; i++) {
|
||||
Map<String, Long> tmp1 = new HashMap<>();
|
||||
Map<String, Long> tmp = Arrays.asList(words[i].split("")).stream().collect(Collectors.groupingBy(s -> s, Collectors.counting()));
|
||||
Map<String, Long> finalCollect = collect;
|
||||
tmp.entrySet().stream().forEach(entry -> {
|
||||
if (finalCollect.containsKey(entry.getKey())) {
|
||||
tmp1.put(entry.getKey(), Math.min(finalCollect.get(entry.getKey()), entry.getValue()));
|
||||
}
|
||||
});
|
||||
collect = tmp1;
|
||||
}
|
||||
collect.entrySet().stream().forEach(o -> {
|
||||
for (Long i = 0L; i < o.getValue(); i++) {
|
||||
res.add(o.getKey());
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public static int largestSumAfterKNegations(int[] nums, int k) {
|
||||
int sum = 0;
|
||||
int minIndex = -1;
|
||||
Map<Integer, Integer> map = new HashMap<>();
|
||||
for (int i = 0; i < k; i++) {
|
||||
int min = Integer.MAX_VALUE;
|
||||
for (int j = 0; j < nums.length; j++) {
|
||||
if (min > nums[j]) {
|
||||
minIndex = j;
|
||||
min = nums[j];
|
||||
}
|
||||
}
|
||||
nums[minIndex] = -nums[minIndex];
|
||||
}
|
||||
for (int i = 0; i < nums.length; i++) {
|
||||
sum += nums[i];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
public static boolean canThreePartsEqualSum(int[] arr) {
|
||||
int sum = Arrays.stream(arr).sum();
|
||||
if (sum % 3 != 0) {
|
||||
return false;
|
||||
}
|
||||
int avg = sum / 3;
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
int tmp = avg - arr[i];
|
||||
if (tmp > 0) {
|
||||
} else if (tmp == 0) {
|
||||
|
||||
for (int j = i + 1; j < arr.length; j++) {
|
||||
tmp = avg - arr[i + 1];
|
||||
tmp = tmp - arr[j];
|
||||
if (tmp > 0) {
|
||||
|
||||
}
|
||||
if (tmp == 0) {
|
||||
return true;
|
||||
}
|
||||
if (tmp < 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[] a = new int[]{3, 3, 6, 5, -2, 2, 5, 1, -9, 4};
|
||||
System.out.println(canThreePartsEqualSum(a));
|
||||
}
|
||||
}
|
||||
+1111
File diff suppressed because it is too large
Load Diff
+29
@@ -0,0 +1,29 @@
|
||||
package com.wyl.cache;
|
||||
|
||||
public class leetCode {
|
||||
public static int maxRepeating(String sequence, String word) {
|
||||
byte[] bytes = sequence.getBytes();
|
||||
byte[] bytes1 = word.getBytes();
|
||||
int a = 0;
|
||||
int num = 0;
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
byte aByte = bytes[i];
|
||||
byte b = bytes1[a];
|
||||
if (aByte == b) {
|
||||
if (a == (bytes1.length - 1)) {
|
||||
a = 0;
|
||||
num++;
|
||||
} else {
|
||||
a++;
|
||||
}
|
||||
} else {
|
||||
a = 0;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(maxRepeating("aaabaaaabaaabaaaabaaaabaaaabaaaaba", "aaaba"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package concurrent.pool;
|
||||
|
||||
import cn.hutool.core.thread.NamedThreadFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MyThreadFactory extends NamedThreadFactory {
|
||||
private final List<Thread> threads = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param prefix 线程名前缀
|
||||
* @param isDaemon 是否守护线程
|
||||
*/
|
||||
public MyThreadFactory(String prefix, boolean isDaemon) {
|
||||
super(prefix, isDaemon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param prefix 线程名前缀
|
||||
* @param threadGroup 线程组,可以为null
|
||||
* @param isDaemon 是否守护线程
|
||||
*/
|
||||
public MyThreadFactory(String prefix, ThreadGroup threadGroup, boolean isDaemon) {
|
||||
super(prefix, threadGroup, isDaemon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param prefix 线程名前缀
|
||||
* @param threadGroup 线程组,可以为null
|
||||
* @param isDaemon 是否守护线程
|
||||
* @param handler 未捕获异常处理
|
||||
*/
|
||||
public MyThreadFactory(String prefix, ThreadGroup threadGroup, boolean isDaemon, Thread.UncaughtExceptionHandler handler) {
|
||||
super(prefix, threadGroup, isDaemon, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread thread = new Thread(r);
|
||||
threads.add(thread);
|
||||
return thread;
|
||||
}
|
||||
|
||||
public List<Thread> getThreads() {
|
||||
return threads;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package concurrent.pool;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Pool {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// 使用自定义线程工厂创建线程池
|
||||
MyThreadFactory threadFactory = new MyThreadFactory("123", false);
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(10, threadFactory);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int finalI = i;
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
boolean a = finalI / 2 > 0 ? true : false;
|
||||
while (a) {
|
||||
System.out.println(1);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
ThreadUtil.sleep(1000L);
|
||||
List<Runnable> runnables = executorService.shutdownNow();
|
||||
boolean b = executorService.awaitTermination(10, TimeUnit.SECONDS);
|
||||
System.out.println(b);
|
||||
List<Thread> threads = threadFactory.getThreads();
|
||||
for (Thread thread : threads) {
|
||||
if (thread.isAlive()) {
|
||||
thread.stop();
|
||||
}
|
||||
}
|
||||
// ThreadUtil.sleep(100000000000L);
|
||||
}
|
||||
}
|
||||
@@ -1,139 +1,135 @@
|
||||
package concurrent.ttl;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import com.alibaba.ttl.TtlCallable;
|
||||
import com.alibaba.ttl.TtlRunnable;
|
||||
import concurrent.ttl.context.ContextUtil;
|
||||
import concurrent.ttl.task.CallableTask;
|
||||
import concurrent.ttl.task.RunnableTask;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class TransmittableThreadLocalTest {
|
||||
|
||||
static ExecutorService executorService;
|
||||
static AtomicInteger atomicInteger;
|
||||
|
||||
@BeforeAll
|
||||
public static void before() {
|
||||
ContextUtil.setThreadLocal("wyl-01");
|
||||
ContextUtil.setTransmittableThreadLocal("wyl-02");
|
||||
executorService = ThreadUtil.newExecutor(3);
|
||||
atomicInteger = new AtomicInteger(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 不修改值
|
||||
*
|
||||
* @param
|
||||
* @return void
|
||||
* @Date 2022/8/7
|
||||
* @Author wangyl
|
||||
*/
|
||||
@Test
|
||||
public void runnableTest() throws InterruptedException {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
RunnableTask runnableTask = new RunnableTask();
|
||||
executorService.execute(runnableTask);
|
||||
}
|
||||
Thread.sleep(10000L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改值 线程池里值用的旧值
|
||||
*
|
||||
* @param
|
||||
* @return void
|
||||
* @Date 2022/8/7
|
||||
* @Author wangyl
|
||||
*/
|
||||
@Test
|
||||
public void runnableChangeErrorTest() throws InterruptedException {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
RunnableTask runnableTask = new RunnableTask();
|
||||
ContextUtil.setTransmittableThreadLocal("wyl-02-" + atomicInteger.incrementAndGet());
|
||||
executorService.execute(runnableTask);
|
||||
}
|
||||
Thread.sleep(10000L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改值线程池用的新值
|
||||
*
|
||||
* @param
|
||||
* @return void
|
||||
* @Date 2022/8/7
|
||||
* @Author wangyl
|
||||
*/
|
||||
@Test
|
||||
public void runnableChangeRightTest() throws InterruptedException {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
RunnableTask runnableTask = new RunnableTask();
|
||||
ContextUtil.setTransmittableThreadLocal("wyl-02-" + atomicInteger.incrementAndGet());
|
||||
TtlRunnable ttlRunnable = TtlRunnable.get(runnableTask);
|
||||
executorService.execute(ttlRunnable);
|
||||
}
|
||||
Thread.sleep(10000L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 不修改值
|
||||
*
|
||||
* @param
|
||||
* @return void
|
||||
* @Date 2022/8/7
|
||||
* @Author wangyl
|
||||
*/
|
||||
@Test
|
||||
public void callableTest() throws InterruptedException {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
CallableTask runnableTask = new CallableTask();
|
||||
executorService.submit(runnableTask);
|
||||
}
|
||||
Thread.sleep(10000L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改值线程池用的旧值
|
||||
*
|
||||
* @param
|
||||
* @return void
|
||||
* @Date 2022/8/7
|
||||
* @Author wangyl
|
||||
*/
|
||||
@Test
|
||||
public void callableChangeErrorTest() throws InterruptedException {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
CallableTask runnableTask = new CallableTask();
|
||||
ContextUtil.setTransmittableThreadLocal("wyl-02-" + atomicInteger.incrementAndGet());
|
||||
executorService.submit(runnableTask);
|
||||
}
|
||||
Thread.sleep(10000L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改值线程池里用的新值
|
||||
*
|
||||
* @param
|
||||
* @return void
|
||||
* @Date 2022/8/7
|
||||
* @Author wangyl
|
||||
*/
|
||||
@Test
|
||||
public void callableChangeRightTest() throws InterruptedException {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
CallableTask runnableTask = new CallableTask();
|
||||
ContextUtil.setTransmittableThreadLocal("wyl-02-" + atomicInteger.incrementAndGet());
|
||||
TtlCallable<String> stringTtlCallable = TtlCallable.get(runnableTask);
|
||||
executorService.submit(stringTtlCallable);
|
||||
}
|
||||
Thread.sleep(10000L);
|
||||
}
|
||||
|
||||
}
|
||||
//package concurrent.ttl;
|
||||
//
|
||||
//import cn.hutool.core.thread.ThreadUtil;
|
||||
//import com.alibaba.ttl.TtlCallable;
|
||||
//import com.alibaba.ttl.TtlRunnable;
|
||||
//import concurrent.ttl.task.CallableTask;
|
||||
//import concurrent.ttl.task.RunnableTask;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.junit.jupiter.api.BeforeAll;
|
||||
//import org.junit.jupiter.api.Test;
|
||||
//
|
||||
//import java.util.concurrent.ExecutorService;
|
||||
//import java.util.concurrent.atomic.AtomicInteger;
|
||||
//
|
||||
//
|
||||
//@Slf4j
|
||||
//public class TransmittableThreadLocalTest {
|
||||
//
|
||||
// static ExecutorService executorService;
|
||||
// static AtomicInteger atomicInteger;
|
||||
//
|
||||
// @BeforeAll
|
||||
// public static void before() {
|
||||
// executorService = ThreadUtil.newExecutor(3);
|
||||
// atomicInteger = new AtomicInteger(0);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 不修改值
|
||||
// *
|
||||
// * @param
|
||||
// * @return void
|
||||
// * @Date 2022/8/7
|
||||
// * @Author wangyl
|
||||
// */
|
||||
// @Test
|
||||
// public void runnableTest() throws InterruptedException {
|
||||
// for (int i = 0; i < 1000; i++) {
|
||||
// RunnableTask runnableTask = new RunnableTask();
|
||||
// executorService.execute(runnableTask);
|
||||
// }
|
||||
// Thread.sleep(10000L);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改值 线程池里值用的旧值
|
||||
// *
|
||||
// * @param
|
||||
// * @return void
|
||||
// * @Date 2022/8/7
|
||||
// * @Author wangyl
|
||||
// */
|
||||
// @Test
|
||||
// public void runnableChangeErrorTest() throws InterruptedException {
|
||||
// for (int i = 0; i < 1000; i++) {
|
||||
// RunnableTask runnableTask = new RunnableTask();
|
||||
// executorService.execute(runnableTask);
|
||||
// }
|
||||
// Thread.sleep(10000L);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改值线程池用的新值
|
||||
// *
|
||||
// * @param
|
||||
// * @return void
|
||||
// * @Date 2022/8/7
|
||||
// * @Author wangyl
|
||||
// */
|
||||
// @Test
|
||||
// public void runnableChangeRightTest() throws InterruptedException {
|
||||
// for (int i = 0; i < 1000; i++) {
|
||||
// RunnableTask runnableTask = new RunnableTask();
|
||||
// ContextUtil.setTransmittableThreadLocal("wyl-02-" + atomicInteger.incrementAndGet());
|
||||
// TtlRunnable ttlRunnable = TtlRunnable.get(runnableTask);
|
||||
// executorService.execute(ttlRunnable);
|
||||
// }
|
||||
// Thread.sleep(10000L);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 不修改值
|
||||
// *
|
||||
// * @param
|
||||
// * @return void
|
||||
// * @Date 2022/8/7
|
||||
// * @Author wangyl
|
||||
// */
|
||||
// @Test
|
||||
// public void callableTest() throws InterruptedException {
|
||||
// for (int i = 0; i < 1000; i++) {
|
||||
// CallableTask runnableTask = new CallableTask();
|
||||
// executorService.submit(runnableTask);
|
||||
// }
|
||||
// Thread.sleep(10000L);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改值线程池用的旧值
|
||||
// *
|
||||
// * @param
|
||||
// * @return void
|
||||
// * @Date 2022/8/7
|
||||
// * @Author wangyl
|
||||
// */
|
||||
// @Test
|
||||
// public void callableChangeErrorTest() throws InterruptedException {
|
||||
// for (int i = 0; i < 1000; i++) {
|
||||
// CallableTask runnableTask = new CallableTask();
|
||||
// ContextUtil.setTransmittableThreadLocal("wyl-02-" + atomicInteger.incrementAndGet());
|
||||
// executorService.submit(runnableTask);
|
||||
// }
|
||||
// Thread.sleep(10000L);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改值线程池里用的新值
|
||||
// *
|
||||
// * @param
|
||||
// * @return void
|
||||
// * @Date 2022/8/7
|
||||
// * @Author wangyl
|
||||
// */
|
||||
// @Test
|
||||
// public void callableChangeRightTest() throws InterruptedException {
|
||||
// for (int i = 0; i < 1000; i++) {
|
||||
// CallableTask runnableTask = new CallableTask();
|
||||
// ContextUtil.setTransmittableThreadLocal("wyl-02-" + atomicInteger.incrementAndGet());
|
||||
// TtlCallable<String> stringTtlCallable = TtlCallable.get(runnableTask);
|
||||
// executorService.submit(stringTtlCallable);
|
||||
// }
|
||||
// Thread.sleep(10000L);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
<artifactId>minio</artifactId>
|
||||
<version>8.4.3</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.13.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.wyl.file.sequence;
|
||||
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* @author <a href="Tastill@**.cn">Tastill</a>
|
||||
* @version 2019/1/24 14:55
|
||||
* @description FileListener
|
||||
*/
|
||||
@Slf4j
|
||||
public class FileListener extends FileAlterationListenerAdaptor {
|
||||
|
||||
/**
|
||||
* @param
|
||||
* @return
|
||||
* @description 文件创建
|
||||
* @version 2.0, 2019/1/24 14:59
|
||||
* @author <a href="Tastill@**.cn">Tastill</a>
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void onFileCreate(File file) {
|
||||
// String s = Files.readString(Paths.get(file.getAbsolutePath()));
|
||||
// log.info("有新文件生成:" + s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.wyl.file.sequence;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class FileRead {
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
File file = new File("C:\\Users\\95981\\Desktop\\2\\视频11.mp4");
|
||||
InputStream inStream = new FileInputStream(file);
|
||||
byte[] bs = new byte[1024];
|
||||
int i = 0;
|
||||
try {
|
||||
while ((i = inStream.read(bs)) != -1) {
|
||||
System.out.println(i);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.wyl.file.sequence;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
|
||||
public class FolderWatcher {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
// 指定要监控的文件夹路径
|
||||
Path folderToWatch = Paths.get("C:\\Users\\95981\\Desktop\\ai\\result");
|
||||
|
||||
// 创建WatchService
|
||||
WatchService watchService = FileSystems.getDefault().newWatchService();
|
||||
|
||||
// 注册要监控的文件夹以及子文件夹
|
||||
folderToWatch.register(watchService, StandardWatchEventKinds.ENTRY_CREATE);
|
||||
|
||||
System.out.println("Watching folder: " + folderToWatch);
|
||||
|
||||
// 启动无限循环以监控文件夹事件
|
||||
while (true) {
|
||||
WatchKey key;
|
||||
try {
|
||||
// 获取下一个文件系统事件
|
||||
key = watchService.take();
|
||||
} catch (InterruptedException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理文件系统事件
|
||||
for (WatchEvent<?> event : key.pollEvents()) {
|
||||
WatchEvent.Kind<?> kind = event.kind();
|
||||
|
||||
// 获取事件发生的文件路径
|
||||
Path eventPath = (Path) event.context();
|
||||
Path fullPath = folderToWatch.resolve(eventPath);
|
||||
|
||||
if (kind == StandardWatchEventKinds.ENTRY_CREATE) {
|
||||
// 处理文件新增事件
|
||||
System.out.println("File created: " + fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
// 重置WatchKey以便继续监控
|
||||
boolean valid = key.reset();
|
||||
if (!valid) {
|
||||
// 如果WatchKey不再有效,退出循环
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.wyl.file.sequence;
|
||||
|
||||
import org.apache.commons.io.filefilter.FileFilterUtils;
|
||||
import org.apache.commons.io.monitor.FileAlterationMonitor;
|
||||
import org.apache.commons.io.monitor.FileAlterationObserver;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class IOtest {
|
||||
public static void main(String[] args) {
|
||||
String rootDir = "C:\\Users\\95981\\Desktop\\ai\\result";
|
||||
// 轮询间隔 5 秒
|
||||
Integer time = 1;
|
||||
long interval = TimeUnit.SECONDS.toMillis(time);
|
||||
// 创建一个文件观察器用于处理文件的格式,
|
||||
// FileFilterUtils.suffixFileFilter(".txt")
|
||||
// FileAlterationObserver _observer = new FileAlterationObserver(
|
||||
// rootDir,
|
||||
// FileFilterUtils.and(
|
||||
// FileFilterUtils.fileFileFilter()), //过滤文件格式
|
||||
// null);
|
||||
FileAlterationObserver observer = new FileAlterationObserver(rootDir);
|
||||
observer.addListener(new FileListener()); //设置文件变化监听器
|
||||
//创建文件变化监听器
|
||||
FileAlterationMonitor monitor = new FileAlterationMonitor(interval, observer);
|
||||
// 开始监控
|
||||
try {
|
||||
monitor.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,359 +0,0 @@
|
||||
package generator.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 算法实验记录表
|
||||
* @TableName abtest_experiment_algorithm
|
||||
*/
|
||||
@TableName(value ="abtest_experiment_algorithm")
|
||||
public class AbtestExperimentAlgorithm implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 参数列表,json格式的字符串,如[{key:value},]
|
||||
*/
|
||||
private String parametersList;
|
||||
|
||||
/**
|
||||
* 分流模式
|
||||
*/
|
||||
private String shuntType;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* abtest_experiment_group表中的id,关联实验状态信息
|
||||
*/
|
||||
private Integer abtestExperimentGroupId;
|
||||
|
||||
/**
|
||||
* 实验细节描述
|
||||
*/
|
||||
private String detailsDescription;
|
||||
|
||||
/**
|
||||
* 分流字段
|
||||
*/
|
||||
private String shuntKey;
|
||||
|
||||
/**
|
||||
* 分流比例
|
||||
*/
|
||||
private Integer shuntProportion;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private String employeeName;
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
private String employeeWorkCode;
|
||||
|
||||
/**
|
||||
* 已删除 1 未删除 0
|
||||
*/
|
||||
private Integer deleted;
|
||||
|
||||
/**
|
||||
* etl更新时间
|
||||
*/
|
||||
private LocalDateTime beidouEtlTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数列表,json格式的字符串,如[{key:value},]
|
||||
*/
|
||||
public String getParametersList() {
|
||||
return parametersList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数列表,json格式的字符串,如[{key:value},]
|
||||
*/
|
||||
public void setParametersList(String parametersList) {
|
||||
this.parametersList = parametersList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分流模式
|
||||
*/
|
||||
public String getShuntType() {
|
||||
return shuntType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分流模式
|
||||
*/
|
||||
public void setShuntType(String shuntType) {
|
||||
this.shuntType = shuntType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
public void setVersion(Integer version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* abtest_experiment_group表中的id,关联实验状态信息
|
||||
*/
|
||||
public Integer getAbtestExperimentGroupId() {
|
||||
return abtestExperimentGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* abtest_experiment_group表中的id,关联实验状态信息
|
||||
*/
|
||||
public void setAbtestExperimentGroupId(Integer abtestExperimentGroupId) {
|
||||
this.abtestExperimentGroupId = abtestExperimentGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实验细节描述
|
||||
*/
|
||||
public String getDetailsDescription() {
|
||||
return detailsDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实验细节描述
|
||||
*/
|
||||
public void setDetailsDescription(String detailsDescription) {
|
||||
this.detailsDescription = detailsDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分流字段
|
||||
*/
|
||||
public String getShuntKey() {
|
||||
return shuntKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分流字段
|
||||
*/
|
||||
public void setShuntKey(String shuntKey) {
|
||||
this.shuntKey = shuntKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分流比例
|
||||
*/
|
||||
public Integer getShuntProportion() {
|
||||
return shuntProportion;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分流比例
|
||||
*/
|
||||
public void setShuntProportion(Integer shuntProportion) {
|
||||
this.shuntProportion = shuntProportion;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
public LocalDateTime getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
public void setUpdateTime(LocalDateTime updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
public String getEmployeeName() {
|
||||
return employeeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
public void setEmployeeName(String employeeName) {
|
||||
this.employeeName = employeeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
public String getEmployeeWorkCode() {
|
||||
return employeeWorkCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
public void setEmployeeWorkCode(String employeeWorkCode) {
|
||||
this.employeeWorkCode = employeeWorkCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 已删除 1 未删除 0
|
||||
*/
|
||||
public Integer getDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* 已删除 1 未删除 0
|
||||
*/
|
||||
public void setDeleted(Integer deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* etl更新时间
|
||||
*/
|
||||
public LocalDateTime getBeidouEtlTime() {
|
||||
return beidouEtlTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* etl更新时间
|
||||
*/
|
||||
public void setBeidouEtlTime(LocalDateTime beidouEtlTime) {
|
||||
this.beidouEtlTime = beidouEtlTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
AbtestExperimentAlgorithm other = (AbtestExperimentAlgorithm) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getParametersList() == null ? other.getParametersList() == null : this.getParametersList().equals(other.getParametersList()))
|
||||
&& (this.getShuntType() == null ? other.getShuntType() == null : this.getShuntType().equals(other.getShuntType()))
|
||||
&& (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()))
|
||||
&& (this.getAbtestExperimentGroupId() == null ? other.getAbtestExperimentGroupId() == null : this.getAbtestExperimentGroupId().equals(other.getAbtestExperimentGroupId()))
|
||||
&& (this.getDetailsDescription() == null ? other.getDetailsDescription() == null : this.getDetailsDescription().equals(other.getDetailsDescription()))
|
||||
&& (this.getShuntKey() == null ? other.getShuntKey() == null : this.getShuntKey().equals(other.getShuntKey()))
|
||||
&& (this.getShuntProportion() == null ? other.getShuntProportion() == null : this.getShuntProportion().equals(other.getShuntProportion()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||
&& (this.getEmployeeName() == null ? other.getEmployeeName() == null : this.getEmployeeName().equals(other.getEmployeeName()))
|
||||
&& (this.getEmployeeWorkCode() == null ? other.getEmployeeWorkCode() == null : this.getEmployeeWorkCode().equals(other.getEmployeeWorkCode()))
|
||||
&& (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()))
|
||||
&& (this.getBeidouEtlTime() == null ? other.getBeidouEtlTime() == null : this.getBeidouEtlTime().equals(other.getBeidouEtlTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getParametersList() == null) ? 0 : getParametersList().hashCode());
|
||||
result = prime * result + ((getShuntType() == null) ? 0 : getShuntType().hashCode());
|
||||
result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode());
|
||||
result = prime * result + ((getAbtestExperimentGroupId() == null) ? 0 : getAbtestExperimentGroupId().hashCode());
|
||||
result = prime * result + ((getDetailsDescription() == null) ? 0 : getDetailsDescription().hashCode());
|
||||
result = prime * result + ((getShuntKey() == null) ? 0 : getShuntKey().hashCode());
|
||||
result = prime * result + ((getShuntProportion() == null) ? 0 : getShuntProportion().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
result = prime * result + ((getEmployeeName() == null) ? 0 : getEmployeeName().hashCode());
|
||||
result = prime * result + ((getEmployeeWorkCode() == null) ? 0 : getEmployeeWorkCode().hashCode());
|
||||
result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
|
||||
result = prime * result + ((getBeidouEtlTime() == null) ? 0 : getBeidouEtlTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", parametersList=").append(parametersList);
|
||||
sb.append(", shuntType=").append(shuntType);
|
||||
sb.append(", version=").append(version);
|
||||
sb.append(", abtestExperimentGroupId=").append(abtestExperimentGroupId);
|
||||
sb.append(", detailsDescription=").append(detailsDescription);
|
||||
sb.append(", shuntKey=").append(shuntKey);
|
||||
sb.append(", shuntProportion=").append(shuntProportion);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", employeeName=").append(employeeName);
|
||||
sb.append(", employeeWorkCode=").append(employeeWorkCode);
|
||||
sb.append(", deleted=").append(deleted);
|
||||
sb.append(", beidouEtlTime=").append(beidouEtlTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package generator.mapper;
|
||||
|
||||
import generator.domain.AbtestExperimentAlgorithm;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author wyl
|
||||
* @description 针对表【abtest_experiment_algorithm(算法实验记录表)】的数据库操作Mapper
|
||||
* @createDate 2023-05-26 10:46:15
|
||||
* @Entity generator.domain.AbtestExperimentAlgorithm
|
||||
*/
|
||||
public interface AbtestExperimentAlgorithmMapper extends BaseMapper<AbtestExperimentAlgorithm> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package generator.service;
|
||||
|
||||
import generator.domain.AbtestExperimentAlgorithm;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author wyl
|
||||
* @description 针对表【abtest_experiment_algorithm(算法实验记录表)】的数据库操作Service
|
||||
* @createDate 2023-05-26 10:46:15
|
||||
*/
|
||||
public interface AbtestExperimentAlgorithmService extends IService<AbtestExperimentAlgorithm> {
|
||||
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package generator.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import generator.domain.AbtestExperimentAlgorithm;
|
||||
import generator.service.AbtestExperimentAlgorithmService;
|
||||
import generator.mapper.AbtestExperimentAlgorithmMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author wyl
|
||||
* @description 针对表【abtest_experiment_algorithm(算法实验记录表)】的数据库操作Service实现
|
||||
* @createDate 2023-05-26 10:46:15
|
||||
*/
|
||||
@Service
|
||||
public class AbtestExperimentAlgorithmServiceImpl extends ServiceImpl<AbtestExperimentAlgorithmMapper, AbtestExperimentAlgorithm>
|
||||
implements AbtestExperimentAlgorithmService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+23
-24
@@ -17,18 +17,17 @@
|
||||
<system.linuxx64>linux-x86_64</system.linuxx64>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.opencv</groupId>-->
|
||||
<!-- <artifactId>opencv-480</artifactId>-->
|
||||
<!-- <version>1.0.0-java1.8</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!--JAVA使用javacv实现图片合成短视频,相关JAR包-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.bytedeco</groupId>-->
|
||||
<!-- <artifactId>javacv-platform</artifactId>-->
|
||||
<!-- <version>1.5.9</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>javacv-platform</artifactId>
|
||||
<version>1.5.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>opencv-platform</artifactId>
|
||||
<version>4.7.0-${javacv.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>javacv</artifactId>
|
||||
@@ -39,19 +38,19 @@
|
||||
<artifactId>javacpp-platform</artifactId>
|
||||
<version>${javacv.version}</version>
|
||||
</dependency>
|
||||
<!-- ffmpeg最小依赖包,必须包含上面的javacv+javacpp核心库 -->
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>ffmpeg</artifactId>
|
||||
<version>6.0-${javacv.version}</version>
|
||||
<classifier>${system.windowsx64}</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>ffmpeg</artifactId>
|
||||
<version>6.0-${javacv.version}</version>
|
||||
<classifier>${system.linuxx64}</classifier>
|
||||
</dependency>
|
||||
<!-- <!– ffmpeg最小依赖包,必须包含上面的javacv+javacpp核心库 –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.bytedeco</groupId>-->
|
||||
<!-- <artifactId>ffmpeg</artifactId>-->
|
||||
<!-- <version>6.0-${javacv.version}</version>-->
|
||||
<!-- <classifier>${system.windowsx64}</classifier>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.bytedeco</groupId>-->
|
||||
<!-- <artifactId>ffmpeg</artifactId>-->
|
||||
<!-- <version>6.0-${javacv.version}</version>-->
|
||||
<!-- <classifier>${system.linuxx64}</classifier>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.wyl.javacv;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.AffineTransformOp;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
public class AssemblyImageTest {
|
||||
public static void main(String[] args) {
|
||||
BufferedImage result = new BufferedImage(1548, 1032, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D graphics = result.createGraphics();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
try {
|
||||
BufferedImage read = ImageIO.read(new File(""));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +1,46 @@
|
||||
//package com.wyl.javacv;
|
||||
//
|
||||
//
|
||||
//import org.opencv.core.CvType;
|
||||
//import org.opencv.core.Mat;
|
||||
//import org.opencv.core.MatOfByte;
|
||||
//import org.opencv.highgui.HighGui;
|
||||
//import org.opencv.imgcodecs.Imgcodecs;
|
||||
//import org.opencv.imgproc.Imgproc;
|
||||
//import org.opencv.videoio.VideoWriter;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.FileInputStream;
|
||||
//import java.io.InputStream;
|
||||
//import java.net.URL;
|
||||
//
|
||||
//
|
||||
//public class DemoApplicationTests {
|
||||
// /**
|
||||
// * @return
|
||||
// * @Description
|
||||
// * @Param
|
||||
// * @Author zhangsan
|
||||
// * @Date 2020.09.05 9:43
|
||||
// **/
|
||||
// public static void main(String[] args) throws Exception {
|
||||
// // 解决awt报错问题
|
||||
// // 加载动态库
|
||||
// URL url = ClassLoader.getSystemResource("opencv_java480.dll");
|
||||
// System.load(url.getPath());
|
||||
// // 读取图像
|
||||
//// Mat image = Imgcodecs.imread("D:\\1.jpg");
|
||||
// File file = new File("C:\\Users\\95981\\Desktop\\Mattingfailure.jpg");
|
||||
// InputStream fos = new FileInputStream(file);
|
||||
// Mat image = Imgcodecs.imdecode(new MatOfByte(fos.readAllBytes()), Imgcodecs.IMREAD_COLOR);
|
||||
// if (image.empty()) {
|
||||
// throw new Exception("image is empty");
|
||||
// }
|
||||
// HighGui.imshow("Original Image", image);
|
||||
//
|
||||
// // 创建输出单通道图像
|
||||
// Mat grayImage = new Mat(image.rows(), image.cols(), CvType.CV_8SC1);
|
||||
// // 进行图像色彩空间转换
|
||||
// Imgproc.cvtColor(image, grayImage, Imgproc.COLOR_RGB2GRAY);
|
||||
//
|
||||
// HighGui.imshow("Processed Image", grayImage);
|
||||
// Imgcodecs.imwrite("D:/hello.jpg", grayImage);
|
||||
// HighGui.waitKey();
|
||||
// }
|
||||
//}
|
||||
package com.wyl.javacv;
|
||||
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfByte;
|
||||
import org.opencv.highgui.HighGui;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
|
||||
public class DemoApplicationTests {
|
||||
/**
|
||||
* @return
|
||||
* @Description
|
||||
* @Param
|
||||
* @Author zhangsan
|
||||
* @Date 2020.09.05 9:43
|
||||
**/
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
// 读取图像
|
||||
File file = new File("C:\\Users\\95981\\Desktop\\Mattingfailure.jpg");
|
||||
InputStream fos = new FileInputStream(file);
|
||||
Mat image = Imgcodecs.imdecode(new MatOfByte(IOUtils.toByteArray(fos)), Imgcodecs.IMREAD_COLOR);
|
||||
if (image.empty()) {
|
||||
throw new Exception("image is empty");
|
||||
}
|
||||
HighGui.imshow("Original Image", image);
|
||||
|
||||
// 创建输出单通道图像
|
||||
Mat grayImage = new Mat(image.rows(), image.cols(), CvType.CV_8SC1);
|
||||
// 进行图像色彩空间转换
|
||||
Imgproc.cvtColor(image, grayImage, Imgproc.COLOR_RGB2GRAY);
|
||||
|
||||
HighGui.imshow("Processed Image", grayImage);
|
||||
Imgcodecs.imwrite("D:/hello.jpg", grayImage);
|
||||
HighGui.waitKey();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.wyl.javacv;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ImageProcessing {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
File inputFile1 = new File("D:\\AIVFO\\doc\\vidoe\\10_211_2488\\10_2024-03-14-11-07-11_1号图层\\10_211\\2488_1"); // 原始图片路径
|
||||
File inputFile2 = new File("D:\\AIVFO\\doc\\vidoe\\10_211_2488\\10_2024-03-14-11-07-11_2号图层\\10_211\\2488_1"); // 原始图片路径
|
||||
File inputFile3 = new File("D:\\AIVFO\\doc\\vidoe\\10_211_2488\\10_2024-03-14-11-07-11_3号图层\\10_211\\2488_1"); // 原始图片路径
|
||||
File inputFile4 = new File("D:\\AIVFO\\doc\\vidoe\\10_211_2488\\10_2024-03-14-11-07-11_4号图层\\10_211\\2488_1"); // 原始图片路径
|
||||
File inputFile5 = new File("D:\\AIVFO\\doc\\vidoe\\10_211_2488\\10_2024-03-14-11-07-11_5号图层\\10_211\\2488_1"); // 原始图片路径
|
||||
File inputFile6 = new File("D:\\AIVFO\\doc\\vidoe\\10_211_2488\\10_2024-03-14-11-07-11_-1号图层\\10_211\\2488_1"); // 原始图片路径
|
||||
File inputFile7 = new File("D:\\AIVFO\\doc\\vidoe\\10_211_2488\\10_2024-03-14-11-07-11_-2号图层\\10_211\\2488_1"); // 原始图片路径
|
||||
File inputFile8 = new File("D:\\AIVFO\\doc\\vidoe\\10_211_2488\\10_2024-03-14-11-07-11_-3号图层\\10_211\\2488_1"); // 原始图片路径
|
||||
File inputFile9 = new File("D:\\AIVFO\\doc\\vidoe\\10_211_2488\\10_2024-03-14-11-07-11_-4号图层\\10_211\\2488_1"); // 原始图片路径
|
||||
File inputFile10 = new File("D:\\AIVFO\\doc\\vidoe\\10_211_2488\\10_2024-03-14-11-07-11_-5号图层\\10_211\\2488_1"); // 原始图片路径
|
||||
File inputFile11 = new File("D:\\AIVFO\\doc\\vidoe\\10_211_2488\\10_2024-03-14-11-07-11_0号图层\\10_211\\2488_1"); // 原始图片路径
|
||||
List<File> pictureList1 = Arrays.asList(inputFile1.listFiles()).stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
|
||||
List<File> pictureList2 = Arrays.asList(inputFile2.listFiles()).stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
|
||||
List<File> pictureList3 = Arrays.asList(inputFile3.listFiles()).stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
|
||||
List<File> pictureList4 = Arrays.asList(inputFile4.listFiles()).stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
|
||||
List<File> pictureList5 = Arrays.asList(inputFile5.listFiles()).stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
|
||||
List<File> pictureList6 = Arrays.asList(inputFile6.listFiles()).stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
|
||||
List<File> pictureList7 = Arrays.asList(inputFile7.listFiles()).stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
|
||||
List<File> pictureList8 = Arrays.asList(inputFile8.listFiles()).stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
|
||||
List<File> pictureList9 = Arrays.asList(inputFile9.listFiles()).stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
|
||||
List<File> pictureList10 = Arrays.asList(inputFile10.listFiles()).stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
|
||||
List<File> pictureList11 = Arrays.asList(inputFile11.listFiles()).stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
|
||||
|
||||
List<List<File>> res = new ArrayList<>();
|
||||
res.add(pictureList1);
|
||||
res.add(pictureList2);
|
||||
res.add(pictureList3);
|
||||
res.add(pictureList4);
|
||||
res.add(pictureList5);
|
||||
res.add(pictureList6);
|
||||
res.add(pictureList7);
|
||||
res.add(pictureList8);
|
||||
res.add(pictureList9);
|
||||
res.add(pictureList10);
|
||||
res.add(pictureList11);
|
||||
|
||||
for (int i = 0; i < pictureList1.size(); i++) {
|
||||
// 创建9宫格图片
|
||||
int scaledWidth = 430;
|
||||
int scaledHeight = 430;
|
||||
int gridWidth = scaledWidth * 3;
|
||||
int gridHeight = scaledHeight * 3;
|
||||
BufferedImage gridImage = new BufferedImage(gridWidth, gridHeight, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D g2dGrid = gridImage.createGraphics();
|
||||
// 绘制9宫格
|
||||
int wyl = 0;
|
||||
for (int x = 0; x < 3; x++) {
|
||||
for (int y = 0; y < 3; y++) {
|
||||
g2dGrid.drawImage(zoom(res.get(wyl).get(i)), x * scaledWidth, y * scaledHeight, null);
|
||||
wyl++;
|
||||
}
|
||||
}
|
||||
g2dGrid.dispose();
|
||||
// 保存9宫格图片
|
||||
File outputFile = new File("C:\\Users\\95981\\Desktop\\test\\outputImage_" + String.format("%04d", i) + ".jpg");
|
||||
ImageIO.write(gridImage, "jpg", outputFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建缩放图片
|
||||
*
|
||||
* @param file
|
||||
* @return java.awt.image.BufferedImage
|
||||
* @Date 2024/3/14
|
||||
* @Author wangyl
|
||||
*/
|
||||
public static BufferedImage zoom(File file) throws IOException {
|
||||
BufferedImage originalImage = ImageIO.read(file);
|
||||
/**
|
||||
* 缩放图片 缩放到一半宽度
|
||||
*/
|
||||
int scaledWidth = originalImage.getWidth() / 2;
|
||||
int scaledHeight = originalImage.getHeight() / 2;
|
||||
BufferedImage scaledImage = new BufferedImage(scaledWidth, scaledHeight, originalImage.getType());
|
||||
Graphics2D g2d = scaledImage.createGraphics();
|
||||
g2d.drawImage(originalImage, 0, 0, scaledWidth, scaledHeight, null);
|
||||
g2d.dispose();
|
||||
return scaledImage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.wyl.javacv;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.bytedeco.javacpp.BytePointer;
|
||||
import org.bytedeco.leptonica.PIX;
|
||||
import org.bytedeco.leptonica.global.leptonica;
|
||||
import org.bytedeco.opencv.global.opencv_imgcodecs;
|
||||
import org.bytedeco.opencv.opencv_core.Mat;
|
||||
import org.bytedeco.opencv.opencv_core.Rect;
|
||||
import org.bytedeco.tesseract.TessBaseAPI;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class JavaCvRead {
|
||||
public static void main(String[] args) throws IOException {
|
||||
// Load the input image
|
||||
// Mat inputImage = opencv_imgcodecs.imread("D:\\AIVFO\\doc\\embryo_picture\\picture\\img_0018-79920-942-942.jpg");
|
||||
File file = new File("D:\\AIVFO\\doc\\embryo_picture\\picture\\img_0018-79920-942-942.jpg");
|
||||
InputStream fos = new FileInputStream(file);
|
||||
byte[] bytes = IOUtils.toByteArray(fos);
|
||||
BytePointer bytePointer = new BytePointer(bytes);
|
||||
Mat inputImage = opencv_imgcodecs.imdecode(new Mat(bytePointer), opencv_imgcodecs.IMREAD_COLOR);
|
||||
System.out.println(inputImage.cols());
|
||||
int cropWidth = 780;
|
||||
int cropHeight = 830;
|
||||
Rect roi = new Rect(cropWidth, cropHeight, inputImage.cols() - cropWidth - 10, inputImage.rows() - cropHeight - 50);
|
||||
/**
|
||||
* 裁剪为新的图片
|
||||
*/
|
||||
Mat croppedImage = new Mat(inputImage, roi);
|
||||
int cols = croppedImage.cols();
|
||||
int rows = croppedImage.rows();
|
||||
PIX pixS = leptonica.pixCreate(cols, rows, 8);
|
||||
|
||||
|
||||
for (int i = 0; i < rows; i++) {
|
||||
for (int j = 0; j < cols; j++) {
|
||||
int anInt = croppedImage.ptr(i, j).getInt();
|
||||
leptonica.pixSetPixel(pixS, j, i, anInt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TessBaseAPI api = new TessBaseAPI();
|
||||
if (api.Init("C:\\Users\\95981\\Desktop", "eng") != 0) {
|
||||
System.out.println("error");
|
||||
System.out.println(api.GetInitLanguagesAsString());
|
||||
}
|
||||
api.SetImage(pixS);
|
||||
BytePointer outText = api.GetUTF8Text();
|
||||
String result = outText.getString();
|
||||
System.out.println(result);
|
||||
api.End();
|
||||
outText.deallocate();
|
||||
leptonica.pixDestroy(pixS);
|
||||
|
||||
// Release resources
|
||||
inputImage.release();
|
||||
croppedImage.release();
|
||||
}
|
||||
|
||||
|
||||
public static void main2(String[] args) {
|
||||
// Mat inputImage = opencv_imgcodecs.imread("D:\\AIVFO\\doc\\embryo_picture\\picture\\img_0001-79920-944-944.jpg");
|
||||
// int cropWidth = 780;
|
||||
// int cropHeight = 830;
|
||||
// Rect roi = new Rect(cropWidth, cropHeight, inputImage.cols() - cropWidth - 10, inputImage.rows() - cropHeight - 50);
|
||||
// // Crop the bottom right corner of the image using the ROI
|
||||
// Mat croppedImage = new Mat(inputImage, roi);
|
||||
//
|
||||
// // Display the cropped image
|
||||
// opencv_imgcodecs.imwrite("D:\\AIVFO\\doc\\embryo_picture\\picture\\cropped.jpg", croppedImage);
|
||||
//
|
||||
// // Release resources
|
||||
// inputImage.release();
|
||||
// croppedImage.release();
|
||||
}
|
||||
|
||||
|
||||
public static void main1(String[] args) {
|
||||
// Load the input image
|
||||
PIX pixS = leptonica.pixRead("D:\\AIVFO\\doc\\embryo_picture\\picture\\cropped.jpg");
|
||||
|
||||
TessBaseAPI api = new TessBaseAPI();
|
||||
if (api.Init("C:\\Users\\95981\\Desktop", "eng") != 0) {
|
||||
System.out.println("error");
|
||||
System.out.println(api.GetInitLanguagesAsString());
|
||||
}
|
||||
api.SetImage(pixS);
|
||||
BytePointer outText = api.GetUTF8Text();
|
||||
String result = outText.getString();
|
||||
System.out.println(result);
|
||||
api.End();
|
||||
outText.deallocate();
|
||||
leptonica.pixDestroy(pixS);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.wyl.javacv;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.bytedeco.ffmpeg.global.avcodec;
|
||||
import org.bytedeco.ffmpeg.global.avutil;
|
||||
import org.bytedeco.javacv.FFmpegFrameRecorder;
|
||||
@@ -18,11 +17,9 @@ public class JavaCvTest {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
//合成的MP4 存放的地址路径 这里的路径并不会自动创建,需要手动提前创建好,否则会报错:Could not open 'null'
|
||||
String mp4SavePath = "E:\\桌面\\vidoe\\img2.mp4";
|
||||
// String img = "/home/wyl/project/aos/opencv/picture";
|
||||
// String mp4SavePath = "/home/wyl/project/aos/opencv/video/video14.mp4"; // 输出视频文件路径
|
||||
String mp4SavePath = "C:\\Users\\95981\\Desktop\\vidoe\\img2.mp4";
|
||||
//图片存放的地址路径
|
||||
String img = "E:\\桌面\\picture";
|
||||
String img = "D:\\AIVFO\\doc\\视频\\0\\";
|
||||
int width = 910;
|
||||
int height = 910;
|
||||
//读取所有图片
|
||||
@@ -34,7 +31,12 @@ public class JavaCvTest {
|
||||
imgMap.put(num, imgFile);
|
||||
num++;
|
||||
}
|
||||
// while (true) {
|
||||
long s = System.currentTimeMillis();
|
||||
createMp4(mp4SavePath, imgMap, width, height);
|
||||
System.out.println(System.currentTimeMillis() - s);
|
||||
// Thread.sleep(10000);
|
||||
// }
|
||||
}
|
||||
|
||||
private static void createMp4(String mp4SavePath, Map<Integer, File> imgMap, int width, int height) throws FrameRecorder.Exception {
|
||||
|
||||
+4
-2
@@ -16,16 +16,18 @@
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
|
||||
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>5.2.0</version>
|
||||
<version>5.13.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna-platform</artifactId>
|
||||
<version>5.2.0</version>
|
||||
<version>5.13.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.wyl.jna;
|
||||
|
||||
import com.sun.jna.Structure;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description: 图片剪裁结果
|
||||
* @author: wangyl
|
||||
* @date: 2023/6/2
|
||||
*/
|
||||
@Data
|
||||
public class CropPictureInfo extends Structure implements Structure.ByValue {
|
||||
|
||||
/**
|
||||
* 剪裁成功 1 成功 0 失败
|
||||
*/
|
||||
public int success;
|
||||
/**
|
||||
* 图片分数
|
||||
*/
|
||||
public double score;
|
||||
/**
|
||||
* 图片名称
|
||||
*/
|
||||
public String fileName;
|
||||
/**
|
||||
* 半径
|
||||
*/
|
||||
public int radius;
|
||||
|
||||
|
||||
/**
|
||||
* 类型转换
|
||||
*
|
||||
* @param
|
||||
* @return com.aivfo.jna.picture.entity.CropPictureInfo
|
||||
* @Date 2023/9/6
|
||||
* @Author wangyl
|
||||
*/
|
||||
public CropPictureInfo toCropPictureInfo() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[]{"success", "score", "fileName", "radius"});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.wyl.jna;
|
||||
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Location2 extends Structure {
|
||||
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
public static class ByValue extends Point implements Structure.ByValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[]{"x", "y"});
|
||||
}
|
||||
}
|
||||
@@ -1,112 +1,109 @@
|
||||
package com.wyl.jna;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
public class Main {
|
||||
public interface CLibrary extends Library {
|
||||
CLibrary INSTANCE = (CLibrary)
|
||||
Native.load("JavaImageDLL", CLibrary.class);
|
||||
|
||||
int getValue1();
|
||||
|
||||
BmpData getStruct1(String imagePath);
|
||||
}
|
||||
|
||||
public static void main1(String[] args) {
|
||||
System.setProperty("jna.debug_load", "true");
|
||||
System.setProperty("jna.debug_load.jna", "true");
|
||||
System.setProperty("jna.platform.library.path", "C:\\Users\\95981\\Desktop\\dll");
|
||||
// int value1 = CLibrary.INSTANCE.getValue1();
|
||||
// System.out.println(value1);
|
||||
BmpData struct1 = CLibrary.INSTANCE.getStruct1("C:\\Users\\95981\\Desktop\\wangyongliang.jpg");
|
||||
int datasize = struct1.size;
|
||||
Pointer data = struct1.data;
|
||||
byte[] byteArray = data.getByteArray(0, datasize);
|
||||
String filePath = "C:\\Users\\95981\\Desktop\\wyl001.jpg"; // 替换为您要写入的文件路径
|
||||
try (FileOutputStream fos = new FileOutputStream(filePath)) {
|
||||
fos.write(byteArray);
|
||||
System.out.println("字节数组成功写入文件。");
|
||||
} catch (IOException e) {
|
||||
System.out.println("写入文件时发生错误:" + e.getMessage());
|
||||
}
|
||||
// 将内存块转换为byte[]数组
|
||||
}
|
||||
|
||||
public static void main123(String[] args) {
|
||||
LocalDateTime fromDateTime = LocalDateTime.now();
|
||||
LocalDateTime toDateTime = fromDateTime.plusDays(1).plusHours(6).plusMinutes(12);
|
||||
LocalDateTime tempDateTime = LocalDateTime.from(fromDateTime);
|
||||
ChronoUnit a = ChronoUnit.MINUTES;
|
||||
long days = 0;
|
||||
long hours = 0;
|
||||
long minutes = 0;
|
||||
long seconds = 0;
|
||||
switch (a) {
|
||||
case DAYS:
|
||||
days = tempDateTime.until(toDateTime, ChronoUnit.DAYS);
|
||||
tempDateTime = tempDateTime.plusDays(days);
|
||||
case HOURS:
|
||||
hours = tempDateTime.until(toDateTime, ChronoUnit.HOURS);
|
||||
tempDateTime = tempDateTime.plusHours(hours);
|
||||
case MINUTES:
|
||||
minutes = tempDateTime.until(toDateTime, ChronoUnit.MINUTES);
|
||||
tempDateTime = tempDateTime.plusMinutes(minutes);
|
||||
case SECONDS:
|
||||
seconds = tempDateTime.until(toDateTime, ChronoUnit.SECONDS);
|
||||
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
days + " 天 " +
|
||||
hours + " 小时 " +
|
||||
minutes + " 分 " +
|
||||
seconds + " 秒.");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
long minutes = 62;
|
||||
String result = convertMinutesToUnits(minutes, ChronoUnit.DAYS);
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
|
||||
public static String convertMinutesToUnits(long minutes1, ChronoUnit maxUnit) {
|
||||
long min = minutes1;
|
||||
long days = 0;
|
||||
long hours = 0;
|
||||
long minutes = 0;
|
||||
long secound = 0;
|
||||
long millis = 0;
|
||||
switch (maxUnit) {
|
||||
case DAYS:
|
||||
days = min / 1440;
|
||||
min = min % 1440;
|
||||
case HOURS:
|
||||
hours = min / 60;
|
||||
min = min % 60;
|
||||
case MINUTES:
|
||||
minutes = min / 1;
|
||||
break;
|
||||
case SECONDS:
|
||||
secound = min * 60;
|
||||
break;
|
||||
case MILLIS:
|
||||
millis = min * 6000;
|
||||
}
|
||||
String reult = days + " 天 " +
|
||||
hours + " 小时 " +
|
||||
minutes + " 分 " +
|
||||
secound + " 秒 " +
|
||||
millis + " 毫秒 ";
|
||||
return reult;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package com.wyl.jna;
|
||||
//
|
||||
//import com.sun.jna.Library;
|
||||
//import com.sun.jna.Native;
|
||||
//import com.sun.jna.Pointer;
|
||||
//
|
||||
//import java.io.FileOutputStream;
|
||||
//import java.io.IOException;
|
||||
//import java.time.LocalDateTime;
|
||||
//import java.time.temporal.ChronoUnit;
|
||||
//
|
||||
//public class Main {
|
||||
// public interface CLibrary extends Library {
|
||||
// CLibrary INSTANCE = (CLibrary)
|
||||
// Native.load("JavaImageDLL", CLibrary.class);
|
||||
//
|
||||
// int getValue1();
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public static void main1(String[] args) {
|
||||
// System.setProperty("jna.debug_load", "true");
|
||||
// System.setProperty("jna.debug_load.jna", "true");
|
||||
// System.setProperty("jna.platform.library.path", "C:\\Users\\95981\\Desktop\\dll");
|
||||
//// int value1 = CLibrary.INSTANCE.getValue1();
|
||||
//// System.out.println(value1);
|
||||
// BmpData struct1 = CLibrary.INSTANCE.findcircles("C:\\Users\\95981\\Desktop\\wangyongliang.jpg");
|
||||
// String filePath = "C:\\Users\\95981\\Desktop\\wyl001.jpg"; // 替换为您要写入的文件路径
|
||||
// try (FileOutputStream fos = new FileOutputStream(filePath)) {
|
||||
// fos.write(byteArray);
|
||||
// System.out.println("字节数组成功写入文件。");
|
||||
// } catch (IOException e) {
|
||||
// System.out.println("写入文件时发生错误:" + e.getMessage());
|
||||
// }
|
||||
// // 将内存块转换为byte[]数组
|
||||
// }
|
||||
//
|
||||
// public static void main123(String[] args) {
|
||||
// LocalDateTime fromDateTime = LocalDateTime.now();
|
||||
// LocalDateTime toDateTime = fromDateTime.plusDays(1).plusHours(6).plusMinutes(12);
|
||||
// LocalDateTime tempDateTime = LocalDateTime.from(fromDateTime);
|
||||
// ChronoUnit a = ChronoUnit.MINUTES;
|
||||
// long days = 0;
|
||||
// long hours = 0;
|
||||
// long minutes = 0;
|
||||
// long seconds = 0;
|
||||
// switch (a) {
|
||||
// case DAYS:
|
||||
// days = tempDateTime.until(toDateTime, ChronoUnit.DAYS);
|
||||
// tempDateTime = tempDateTime.plusDays(days);
|
||||
// case HOURS:
|
||||
// hours = tempDateTime.until(toDateTime, ChronoUnit.HOURS);
|
||||
// tempDateTime = tempDateTime.plusHours(hours);
|
||||
// case MINUTES:
|
||||
// minutes = tempDateTime.until(toDateTime, ChronoUnit.MINUTES);
|
||||
// tempDateTime = tempDateTime.plusMinutes(minutes);
|
||||
// case SECONDS:
|
||||
// seconds = tempDateTime.until(toDateTime, ChronoUnit.SECONDS);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// System.out.println(
|
||||
// days + " 天 " +
|
||||
// hours + " 小时 " +
|
||||
// minutes + " 分 " +
|
||||
// seconds + " 秒.");
|
||||
// }
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// long minutes = 62;
|
||||
// String result = convertMinutesToUnits(minutes, ChronoUnit.DAYS);
|
||||
// System.out.println(result);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static String convertMinutesToUnits(long minutes1, ChronoUnit maxUnit) {
|
||||
// long min = minutes1;
|
||||
// long days = 0;
|
||||
// long hours = 0;
|
||||
// long minutes = 0;
|
||||
// long secound = 0;
|
||||
// long millis = 0;
|
||||
// switch (maxUnit) {
|
||||
// case DAYS:
|
||||
// days = min / 1440;
|
||||
// min = min % 1440;
|
||||
// case HOURS:
|
||||
// hours = min / 60;
|
||||
// min = min % 60;
|
||||
// case MINUTES:
|
||||
// minutes = min / 1;
|
||||
// break;
|
||||
// case SECONDS:
|
||||
// secound = min * 60;
|
||||
// break;
|
||||
// case MILLIS:
|
||||
// millis = min * 6000;
|
||||
// }
|
||||
// String reult = days + " 天 " +
|
||||
// hours + " 小时 " +
|
||||
// minutes + " 分 " +
|
||||
// secound + " 秒 " +
|
||||
// millis + " 毫秒 ";
|
||||
// return reult;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.wyl.jna;
|
||||
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
// 映射C的Point结构体
|
||||
public class Point extends Structure {
|
||||
public int x;
|
||||
|
||||
// 定义结构体中字段的顺序
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("x");
|
||||
}
|
||||
|
||||
public static class ByValue extends Point implements Structure.ByValue {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.wyl.jna;
|
||||
|
||||
import com.sun.jna.FunctionMapper;
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLibrary;
|
||||
import com.sun.jna.win32.StdCallFunctionMapper;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
|
||||
public class Structure2Test {
|
||||
public interface StructureLib1 extends Library {
|
||||
StructureLib1 INSTANCE = Native.load("wyltest123", StructureLib1.class);
|
||||
|
||||
Point.ByValue getStructTest11();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
System.setProperty("jna.debug_load", "true");
|
||||
System.setProperty("jna.debug_load.jna", "true");
|
||||
System.setProperty("jna.library.path", "D:\\wyl\\JavaBasiceDemo\\jna\\src\\main\\resources");
|
||||
System.setProperty("jna.encoding", "UTF-8");
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
Point.ByValue asd = StructureLib1.INSTANCE.getStructTest11();
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
class MyFunctionMapper extends StdCallFunctionMapper { // 这里可能需要根据平台选择不同的 FunctionMapper 类
|
||||
@Override
|
||||
public String getFunctionName(NativeLibrary library, Method method) {
|
||||
// 使用默认的映射
|
||||
return super.getFunctionName(library, method);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.wyl.jna;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
|
||||
public class StructureTest {
|
||||
public interface StructureLib extends Library {
|
||||
/**
|
||||
* 图片裁剪
|
||||
*
|
||||
* @param sourcepath 原图路径
|
||||
* @param w 原图宽度
|
||||
* @param h 原图高度
|
||||
* @param soucepath 目标路径
|
||||
* @param issave 是否存储原图 1 存 0 不存
|
||||
* @param wellName well编号
|
||||
* @param timeString 培养时间
|
||||
* @param leftOffset 左边裁剪距离 默认0
|
||||
* @param bottomOffset 下边裁剪距离默认0
|
||||
* @return java.lang.String null为失败
|
||||
* @Date 2023/8/31
|
||||
* @Author wangyl
|
||||
*/
|
||||
CropPictureInfo findcircles(String sourcepath, int w, int h, String path, String soucepath, int issave, String wellName, String timeString, int leftOffset, int bottomOffset, int imageSize);
|
||||
|
||||
/**
|
||||
* 图片打分
|
||||
*
|
||||
* @param sourcepath 原图路径
|
||||
* @param w 原图宽度
|
||||
* @param h 原图高度
|
||||
* @param path 评分图片存储的路径
|
||||
* @param id 图片ID(垂直电机脉冲)
|
||||
* @param leftOffset 左边裁剪距离(可不传,默认为0)
|
||||
* @param bottomOffset 下边裁剪距离(可不传,默认为0)
|
||||
* @return com.wyl.jna.CropPictureInfo.ByValue
|
||||
* @Date 2023/9/5
|
||||
* @Author wangyl
|
||||
*/
|
||||
CropPictureInfo getscore(String sourcepath, int w, int h, String path, int id, int leftOffset, int bottomOffset);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
StructureLib instance = Native.load("JavaImageDLL", StructureLib.class);
|
||||
// System.setProperty("jna.debug_load", "true");
|
||||
// System.setProperty("jna.debug_load.jna", "true");
|
||||
System.setProperty("jna.library.path", "D:\\wyl\\JavaBasiceDemo\\jna\\src\\main\\resources");
|
||||
long l = System.currentTimeMillis();
|
||||
for (int i = 1; i < 4; i++) {
|
||||
System.out.println("-----");
|
||||
String picturePant = "C:\\Users\\95981\\Desktop\\1\\" + i + ".jpg";
|
||||
String tagPath = "C:\\Users\\95981\\Desktop\\1\\test\\" + i + ".jpg";
|
||||
findcircles(picturePant, tagPath, instance);
|
||||
// getscore(picturePant, tagPath,instance);
|
||||
System.out.println("-----");
|
||||
}
|
||||
System.out.println(System.currentTimeMillis() - l);
|
||||
}
|
||||
|
||||
public static void getscore(String picturePant, String tagPath, StructureLib instance) {
|
||||
CropPictureInfo well1 = instance.getscore(picturePant, 2392, 1744, tagPath, 123, 0, 0);
|
||||
double score = well1.score;
|
||||
String fileName = well1.fileName;
|
||||
int radius = well1.radius;
|
||||
int success = well1.success;
|
||||
System.out.println("名字" + fileName);
|
||||
System.out.println("分数" + score);
|
||||
System.out.println("半径" + radius);
|
||||
System.out.println("成功" + success);
|
||||
}
|
||||
|
||||
public static void findcircles(String picturePant, String tagPath, StructureLib instance) {
|
||||
CropPictureInfo well1 = instance.findcircles(picturePant, 2392, 1744, tagPath, "", 0, "well1", "2H22M", 0, 0, 455);
|
||||
double score = well1.score;
|
||||
String fileName = well1.fileName;
|
||||
int radius = well1.radius;
|
||||
int success = well1.success;
|
||||
System.out.println("名字" + fileName);
|
||||
System.out.println("分数" + score);
|
||||
System.out.println("半径" + radius);
|
||||
System.out.println("成功" + success);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// System.setProperty("file.encoding", "UTF-16");
|
||||
// String encoding = Charset.defaultCharset().name();
|
||||
// System.out.println("当前字符编码是:" + encoding);
|
||||
// String fileEncoding = System.getProperty("file.encoding");
|
||||
// System.out.println("默认文件编码是:" + fileEncoding);
|
||||
// System.setProperty("jna.debug_load", "true");
|
||||
// System.setProperty("jna.debug_load.jna", "true");
|
||||
// System.out.println("长度:" + length);
|
||||
@@ -20,7 +20,10 @@ public class UsageSystem {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
CLibrary.INSTANCE.printf("Hello, World\n");
|
||||
CLibrary.INSTANCE.printf("你好\n");
|
||||
args = new String[2];
|
||||
args[0] = "不好";
|
||||
args[1] = "好不好";
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
CLibrary.INSTANCE.printf("Argument %d: %s\n", i, args[i]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.wyl.jna;
|
||||
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class bmp_data extends Structure {
|
||||
public int diam;
|
||||
public int width;
|
||||
public String message;
|
||||
public static class ByValue extends bmp_data implements Structure.ByValue {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[]{"diam", "width", "message"});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.wyl.jna;
|
||||
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class intData extends Structure {
|
||||
public Integer x;
|
||||
public Integer y;
|
||||
|
||||
public static class ByValue extends intData implements Structure.ByValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[]{"x", "y"});
|
||||
}
|
||||
}
|
||||
Binary file not shown.
+19
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>JavaBasiceDemo</artifactId>
|
||||
<groupId>com.wyl.example</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>jni</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.wyl.jni;
|
||||
|
||||
import com.wyl.jni.entity.CropPictureInfoC;
|
||||
|
||||
public class JniTest {
|
||||
static {
|
||||
System.loadLibrary("hello"); // Load native library at runtime
|
||||
// hello.dll (Windows) or libhello.so (Unixes)
|
||||
}
|
||||
|
||||
public static native CropPictureInfoC findcircles(String sourcepath, int w, int h, String path, String soucepath, int issave, String wellName, String timeString, int leftOffset, int bottomOffset, int imageSize, String logpath);
|
||||
|
||||
public static native CropPictureInfoC getscore(String sourcepath, int w, int h, String path, int id, int leftOffset, int bottomOffset);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.wyl.jni.entity;
|
||||
|
||||
/**
|
||||
* @description: 图片剪裁结果 C对应
|
||||
* @author: wangyl
|
||||
* @date: 2023/6/2
|
||||
*/
|
||||
public class CropPictureInfoC {
|
||||
|
||||
/**
|
||||
* 剪裁成功 1 成功 0 失败
|
||||
*/
|
||||
public int success;
|
||||
/**
|
||||
* 图片分数 -1为null
|
||||
*/
|
||||
public double score;
|
||||
/**
|
||||
* 图片名称
|
||||
*/
|
||||
public String fileName;
|
||||
/**
|
||||
* 半径 -1 为null
|
||||
*/
|
||||
public int radius;
|
||||
|
||||
public int getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(int success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public double getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(double score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public int getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
public void setRadius(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>JavaBasiceDemo</artifactId>
|
||||
<groupId>com.wyl.example</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>jnr</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.jnr</groupId>
|
||||
<artifactId>jnr-ffi</artifactId>
|
||||
<version>2.2.15</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.wyl.jnr;
|
||||
|
||||
import jnr.ffi.Runtime;
|
||||
import jnr.ffi.Struct;
|
||||
|
||||
/**
|
||||
* @description: 图片剪裁结果
|
||||
* @author: wangyl
|
||||
* @date: 2023/6/2
|
||||
*/
|
||||
public class CropPictureInfo extends Struct {
|
||||
|
||||
/**
|
||||
* 剪裁成功 1 成功 0 失败
|
||||
*/
|
||||
public Struct.Signed32 success;
|
||||
/**
|
||||
* 图片分数
|
||||
*/
|
||||
public Struct.Double score;
|
||||
/**
|
||||
* 图片名称
|
||||
*/
|
||||
public Struct.Pointer fileName;
|
||||
|
||||
/**
|
||||
* 半径
|
||||
*/
|
||||
public Struct.Signed32 radius;
|
||||
|
||||
/**
|
||||
* Creates a new {@code Struct}.
|
||||
*
|
||||
* @param runtime The current runtime.
|
||||
*/
|
||||
public CropPictureInfo(Runtime runtime) {
|
||||
super(runtime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.wyl.jnr;
|
||||
|
||||
import jnr.ffi.LibraryLoader;
|
||||
|
||||
/**
|
||||
* @description: 调用系统库
|
||||
* @author: wangyl
|
||||
* @date: 2023/6/27
|
||||
*/
|
||||
public class UsageSystem {
|
||||
|
||||
public interface StructureLib {
|
||||
/**
|
||||
* 图片裁剪
|
||||
*
|
||||
* @param sourcepath 原图路径
|
||||
* @param w 原图宽度
|
||||
* @param h 原图高度
|
||||
* @param soucepath 目标路径
|
||||
* @param issave 是否存储原图 1 存 0 不存
|
||||
* @param wellName well编号
|
||||
* @param timeString 培养时间
|
||||
* @param leftOffset 左边裁剪距离 默认0
|
||||
* @param bottomOffset 下边裁剪距离默认0
|
||||
* @return java.lang.String null为失败
|
||||
* @Date 2023/8/31
|
||||
* @Author wangyl
|
||||
*/
|
||||
CropPictureInfo findcircles(String sourcepath, int w, int h, String path, String soucepath, int issave, String wellName, String timeString, int leftOffset, int bottomOffset, int imageSize);
|
||||
|
||||
/**
|
||||
* 图片打分
|
||||
*
|
||||
* @param sourcepath 原图路径
|
||||
* @param w 原图宽度
|
||||
* @param h 原图高度
|
||||
* @param path 评分图片存储的路径
|
||||
* @param id 图片ID(垂直电机脉冲)
|
||||
* @param leftOffset 左边裁剪距离(可不传,默认为0)
|
||||
* @param bottomOffset 下边裁剪距离(可不传,默认为0)
|
||||
* @return com.wyl.jna.CropPictureInfo.ByValue
|
||||
* @Date 2023/9/5
|
||||
* @Author wangyl
|
||||
*/
|
||||
CropPictureInfo getscore(String sourcepath, int w, int h, String path, int id, int leftOffset, int bottomOffset);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.setProperty("jnr.ffi.library.path", "D:\\wyl\\JavaBasiceDemo\\jnr\\src\\main\\resources");
|
||||
StructureLib libc = LibraryLoader.create(StructureLib.class).load("JavaImageDLL");
|
||||
CropPictureInfo well1 = libc.findcircles("C:\\Users\\95981\\Desktop\\1\\1.jpg", 2592, 1944, "C:\\Users\\95981\\Desktop\\1\\test\\1.jpg", "C:\\Users\\95981\\Desktop\\1\\1.jpg", 0, "well1", "2H22M", 0, 0, 455);
|
||||
System.out.println(well1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,79 +1,81 @@
|
||||
package com.wyl.kafka.producers;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
|
||||
/**
|
||||
* kafka发送消息测试
|
||||
* @ClassName: KafkaProducerSend
|
||||
* @Date: 2022/4/12 15:18
|
||||
* @author wangyl
|
||||
* @version V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class KafkaProducerSend {
|
||||
/**
|
||||
* 生产者发送回调消息
|
||||
* @param kafkaProducerNormal
|
||||
* @param topic
|
||||
* @param message
|
||||
* @return void
|
||||
* @Date 2022/4/12 17:43
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
*/
|
||||
public static void sendMessageAndCallback(Producer<String, String> kafkaProducerNormal, String topic, String message) {
|
||||
ProducerRecord<String, String> messageObj = new ProducerRecord<>(topic, message);
|
||||
kafkaProducerNormal.send(messageObj, (metadata, exception) -> {
|
||||
if (null != exception) {
|
||||
log.error("kafka 信息推送失败[" + messageObj + "]", exception);
|
||||
}
|
||||
log.info("消息发送成功[{}]", messageObj);
|
||||
});
|
||||
kafkaProducerNormal.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送事务消息
|
||||
* @param kafkaProducerTransactional
|
||||
* @param topic
|
||||
* @param message
|
||||
* @return void
|
||||
* @Date 2022/4/12 17:42
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
*/
|
||||
public static void sendMessageTransactional(Producer<String, String> kafkaProducerTransactional, String topic, String message) {
|
||||
/**
|
||||
* 初始化事务
|
||||
*/
|
||||
kafkaProducerTransactional.initTransactions();
|
||||
/**
|
||||
* 开启事务
|
||||
*/
|
||||
kafkaProducerTransactional.beginTransaction();
|
||||
log.info("开始发送事务消息");
|
||||
try {
|
||||
for (int i = 0; i < 10; i++){
|
||||
ProducerRecord<String, String> messageObj = new ProducerRecord<>(topic, message + i);
|
||||
kafkaProducerTransactional.send(messageObj, (metadata, exception) -> {
|
||||
if (null != exception) {
|
||||
log.error("kafka 信息推送失败[" + messageObj + "]", exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
log.info("消息发送成功");
|
||||
kafkaProducerTransactional.commitTransaction();
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("kafka 事务消息推送失败", e);
|
||||
kafkaProducerTransactional.abortTransaction();
|
||||
}
|
||||
finally {
|
||||
kafkaProducerTransactional.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package com.wyl.kafka.producers;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* kafka发送消息测试
|
||||
* @ClassName: KafkaProducerSend
|
||||
* @Date: 2022/4/12 15:18
|
||||
* @author wangyl
|
||||
* @version V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class KafkaProducerSend {
|
||||
/**
|
||||
* 生产者发送回调消息
|
||||
* @param kafkaProducerNormal
|
||||
* @param topic
|
||||
* @param message
|
||||
* @return void
|
||||
* @Date 2022/4/12 17:43
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
*/
|
||||
public static void sendMessageAndCallback(Producer<String, String> kafkaProducerNormal, String topic, String message) {
|
||||
ProducerRecord<String, String> messageObj = new ProducerRecord<>(topic, message);
|
||||
kafkaProducerNormal.send(messageObj, (metadata, exception) -> {
|
||||
if (null != exception) {
|
||||
log.error("kafka 信息推送失败[" + messageObj + "]", exception);
|
||||
}
|
||||
log.info("消息发送成功[{}]", messageObj);
|
||||
});
|
||||
kafkaProducerNormal.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送事务消息
|
||||
* @param kafkaProducerTransactional
|
||||
* @param topic
|
||||
* @param message
|
||||
* @return void
|
||||
* @Date 2022/4/12 17:42
|
||||
* @Author wangyl
|
||||
* @Version V1.0
|
||||
*/
|
||||
public static void sendMessageTransactional(Producer<String, String> kafkaProducerTransactional, String topic, String message) {
|
||||
/**
|
||||
* 初始化事务
|
||||
*/
|
||||
kafkaProducerTransactional.initTransactions();
|
||||
/**
|
||||
* 开启事务
|
||||
*/
|
||||
kafkaProducerTransactional.beginTransaction();
|
||||
log.info("开始发送事务消息");
|
||||
try {
|
||||
for (int i = 0; i < 10; i++){
|
||||
ProducerRecord<String, String> messageObj = new ProducerRecord<>(topic, message + i);
|
||||
kafkaProducerTransactional.send(messageObj, (metadata, exception) -> {
|
||||
if (null != exception) {
|
||||
log.error("kafka 信息推送失败[" + messageObj + "]", exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
log.info("消息发送成功");
|
||||
kafkaProducerTransactional.commitTransaction();
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("kafka 事务消息推送失败", e);
|
||||
kafkaProducerTransactional.abortTransaction();
|
||||
}
|
||||
finally {
|
||||
kafkaProducerTransactional.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,7 +25,7 @@ public class TlPictureProducerTest {
|
||||
* 构建kafka 生产者
|
||||
*/
|
||||
KafkaProducer<String, byte[]> kafkaProducer = buildProducer();
|
||||
String topic = "CCD-PICTURE-NEO-1-wyltest";
|
||||
String topic = "CCD-PICTURE-NEO-1-20230101";
|
||||
AtomicReference<Integer> partition = new AtomicReference<>(0);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String format = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
@@ -38,7 +38,8 @@ public class TlPictureProducerTest {
|
||||
if (i == 80) {
|
||||
end = 1;
|
||||
}
|
||||
ImageDataDTO.ImageDTO image = makeSendData(null, embryo.getHouseSn(), id.getKey(), 1, format, embryo.getFertilizationTime(), i, shootingPosition * (125 + i), end, id.getValue(), embryo.getId());
|
||||
ImageDataDTO.ImageDTO image = makeSendData(null, embryo.getHouseSn(), id.getKey(), 1, format, embryo.getFertilizationTime(), i, shootingPosition * (125 + i), end, embryo.getId(), id.getValue());
|
||||
System.out.println(image.getImageData().size());
|
||||
partition.set(image.getHouseSn() % 3);
|
||||
ProducerRecord<String, byte[]> record = new ProducerRecord<>(topic, partition.get(), null, image.toByteArray());
|
||||
/**
|
||||
@@ -87,7 +88,7 @@ public class TlPictureProducerTest {
|
||||
}
|
||||
ImageDataDTO.ImageDTO image = makeSendData(c, embryo.getHouseSn(), id.getKey(), 0, format,
|
||||
embryo.getFertilizationTime(), i, shootingPosition * (125 + i),
|
||||
end, id.getValue(), embryo.getId());
|
||||
end, embryo.getId(), id.getValue());
|
||||
partition.set(image.getHouseSn() % 3);
|
||||
ProducerRecord<String, byte[]> record = new ProducerRecord<>(topic, partition.get(), null, image.toByteArray());
|
||||
/**
|
||||
@@ -134,8 +135,8 @@ public class TlPictureProducerTest {
|
||||
* @Date 2023/7/18
|
||||
* @Author wangyl
|
||||
*/
|
||||
public static byte[] getImageData() throws IOException {
|
||||
File file = new File("C:\\Users\\95981\\Desktop\\wangyongliang.jpg");
|
||||
private static byte[] getImageData() throws IOException {
|
||||
File file = new File("C:\\Users\\95981\\Desktop\\picControlBreak1\\1_1_1_1_2023-09-25-17-37-08_66400_80200.jpg");
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
byte[] bytes = inputStream.readAllBytes();
|
||||
return bytes;
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
<artifactId>org.eclipse.paho.mqttv5.client</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aivfo</groupId>
|
||||
<artifactId>aivfo-element-common</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.wyl.mqtt;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @description: tl上报的mqtt采集数据
|
||||
* @author: wangyl
|
||||
* @date: 2023/7/11
|
||||
*/
|
||||
@Data
|
||||
public class MqttCollectDTO {
|
||||
/**
|
||||
* tlSn
|
||||
*/
|
||||
String tlSn;
|
||||
/**
|
||||
* 仓室的Sn
|
||||
*/
|
||||
Integer houseSn;
|
||||
/**
|
||||
* 气压
|
||||
*/
|
||||
BigDecimal pressure;
|
||||
/**
|
||||
* 温度
|
||||
*/
|
||||
BigDecimal temperature;
|
||||
/**
|
||||
* 仓门状态
|
||||
*/
|
||||
Integer houseDoorState;
|
||||
/**
|
||||
* 气压状态
|
||||
*/
|
||||
String pressureDesc;
|
||||
|
||||
/**
|
||||
* 仓室状态
|
||||
*/
|
||||
String houseDesc;
|
||||
/**
|
||||
* 采集时间
|
||||
*/
|
||||
String collectTime;
|
||||
|
||||
}
|
||||
@@ -1,21 +1,31 @@
|
||||
package com.wyl.mqtt;
|
||||
|
||||
import com.aivfo.el.start.core.util.RandomUtils;
|
||||
import com.aivfo.el.starter.base.utils.JsonUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class SimpleMqttClient {
|
||||
|
||||
static List<String> operationDesc = Arrays.asList("握手中", "CCP拍照", "自动对焦", "平衡中", "温压检测", "补气中", "换气中");
|
||||
|
||||
//全局唯一 单例
|
||||
private static IMqttAsyncClient client;
|
||||
|
||||
private static IMqttAsyncClient getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
private static void setClient(IMqttAsyncClient client) {
|
||||
SimpleMqttClient.client = client;
|
||||
}
|
||||
@@ -58,7 +68,7 @@ public class SimpleMqttClient {
|
||||
log.info("接收消息主题 : " + topic);
|
||||
log.info("接收消息Qos : " + mqttMessage.getQos());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||
@@ -82,14 +92,14 @@ public class SimpleMqttClient {
|
||||
/**
|
||||
* 发布
|
||||
*
|
||||
* @param qos 连接方式
|
||||
* @param retained 是否保留
|
||||
* @param topic 主题
|
||||
* @param qos 连接方式
|
||||
* @param retained 是否保留
|
||||
* @param topic 主题
|
||||
* @param pushMessage 消息体
|
||||
*/
|
||||
public void publish(String topic, byte[] message, int qos, boolean retained) {
|
||||
|
||||
if(client != null && client.isConnected()) {
|
||||
|
||||
if (client != null && client.isConnected()) {
|
||||
try {
|
||||
IMqttDeliveryToken token = client.publish(topic, message, qos, retained);
|
||||
token.waitForCompletion();
|
||||
@@ -104,10 +114,10 @@ public class SimpleMqttClient {
|
||||
* 订阅某个主题
|
||||
*
|
||||
* @param topic 主题
|
||||
* @param qos 连接方式
|
||||
* @param qos 连接方式
|
||||
*/
|
||||
public void subscribe(String topic, int qos) {
|
||||
log.info("开始订阅主题: {}" , topic);
|
||||
log.info("开始订阅主题: {}", topic);
|
||||
if (client != null && client.isConnected()) {
|
||||
try {
|
||||
IMqttToken token = client.subscribe(topic, qos);
|
||||
@@ -118,11 +128,12 @@ public class SimpleMqttClient {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅多主题
|
||||
*
|
||||
* @param topic 主题
|
||||
* @param qos 连接方式
|
||||
* @param qos 连接方式
|
||||
*/
|
||||
public void subscribe(String[] topics, int[] qos) {
|
||||
log.info("开始订阅主题集合:{}", Arrays.asList(topics));
|
||||
@@ -137,10 +148,35 @@ public class SimpleMqttClient {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SimpleMqttClient simpleMqttClient = new SimpleMqttClient();
|
||||
simpleMqttClient.connect("tcp://127.0.0.1:1883", "123", "wyl","wyl");
|
||||
simpleMqttClient.publish("wyl001", "123".getBytes(StandardCharsets.UTF_8), 0, false);
|
||||
public static List<MqttCollectDTO> buildData() {
|
||||
List<MqttCollectDTO> res = new ArrayList<>();
|
||||
for (int i = 1; i < 11; i++) {
|
||||
MqttCollectDTO mqttCollectDTO = new MqttCollectDTO();
|
||||
mqttCollectDTO.setTlSn("NEO-1-wyltest");
|
||||
mqttCollectDTO.setHouseSn(i);
|
||||
mqttCollectDTO.setPressure(new BigDecimal(RandomUtils.nextDouble(40, 50)));
|
||||
mqttCollectDTO.setTemperature(new BigDecimal(RandomUtils.nextDouble(36, 38)));
|
||||
mqttCollectDTO.setHouseDoorState(RandomUtils.nextInt(0, 1));
|
||||
mqttCollectDTO.setPressureDesc(operationDesc.get(RandomUtils.nextInt(0, 7)));
|
||||
mqttCollectDTO.setHouseDesc(operationDesc.get(RandomUtils.nextInt(0, 7)));
|
||||
mqttCollectDTO.setCollectTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
res.add(mqttCollectDTO);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
SimpleMqttClient simpleMqttClient = new SimpleMqttClient();
|
||||
List<MqttCollectDTO> mqttCollectDTOS = buildData();
|
||||
simpleMqttClient.connect("tcp://192.168.31.89:1883", "test", "aivfo", "aivfo");
|
||||
while (true) {
|
||||
Thread.sleep(1000);
|
||||
simpleMqttClient.publish("TL/House/collecting-data", JsonUtils.toJson(mqttCollectDTOS).getBytes(StandardCharsets.UTF_8), 2, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
<module>Socket</module>
|
||||
<module>jna</module>
|
||||
<module>mapsturct</module>
|
||||
<module>cache</module>
|
||||
<module>jnr</module>
|
||||
<module>jni</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
<properties>
|
||||
|
||||
+7
@@ -5,12 +5,19 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
@EnableAspectJAutoProxy(exposeProxy = true)
|
||||
@EnableAsync
|
||||
public class SpringBootCommonApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// SpringApplication springApplication = new SpringApplication(SpringBootCommonApplication.class);
|
||||
// springApplication.setBannerMode(Banner.Mode.OFF);
|
||||
// ConfigurableApplicationContext run = springApplication.run(args);
|
||||
SpringApplication.run(SpringBootCommonApplication.class, args);
|
||||
}
|
||||
|
||||
|
||||
+20
-9
@@ -3,23 +3,24 @@ package com.wyl.spring.boot.common.service.impl;
|
||||
import com.wyl.spring.boot.common.service.LogTestService;
|
||||
import com.wyl.spring.boot.common.spel.annotation.SpelTest;
|
||||
import com.wyl.spring.boot.common.spel.bean.Order;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class LogTestServiceImpl implements LogTestService {
|
||||
|
||||
// @Override
|
||||
//// @LogTest
|
||||
// @Transactional
|
||||
// public void test() {
|
||||
// System.out.println("testLog");
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
// @LogTest
|
||||
@Transactional
|
||||
public void test() {
|
||||
System.out.println("testLog");
|
||||
}
|
||||
|
||||
|
||||
@SpelTest(spel = "123{#order?'真':'假'}")
|
||||
public void testSPEL(Boolean order) {
|
||||
System.out.println(123);
|
||||
@@ -37,4 +38,14 @@ public class LogTestServiceImpl implements LogTestService {
|
||||
String abc = "123";
|
||||
return abc;
|
||||
}
|
||||
|
||||
@Scheduled(cron = "*/5 * * * * ?")
|
||||
@Override
|
||||
@Async
|
||||
public void test() {
|
||||
System.out.println(1);
|
||||
while (true) {
|
||||
int a = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -8,6 +8,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("rule/person")
|
||||
@@ -17,8 +19,9 @@ public class PersonRuleController {
|
||||
private RuleExecutor ruleExecutor;
|
||||
|
||||
@PostMapping("one")
|
||||
public void fireAllRules4One(@RequestBody Person person) {
|
||||
ruleExecutor.execute(person);
|
||||
public void fireAllRules4One(@RequestBody List<Person> person) {
|
||||
System.out.println(person);
|
||||
// ruleExecutor.execute(person);
|
||||
}
|
||||
|
||||
}
|
||||
+2
@@ -2,8 +2,10 @@ package com.wyl.springbootmybatis;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class SpringBootMybatisApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+8
-6
@@ -2,19 +2,21 @@ package com.wyl.springbootmybatis.mybatis.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.wyl.springbootmybatis.mybatis.domain.KeyTest;
|
||||
import com.wyl.springbootmybatis.mybatis.service.KeyTestService;
|
||||
import com.wyl.springbootmybatis.mybatis.mapper.KeyTestMapper;
|
||||
import com.wyl.springbootmybatis.mybatis.service.KeyTestService;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author wyl
|
||||
* @description 针对表【key_test(联合唯一索引更新测试)】的数据库操作Service实现
|
||||
* @createDate 2022-05-18 22:54:18
|
||||
*/
|
||||
* @author wyl
|
||||
* @description 针对表【key_test(联合唯一索引更新测试)】的数据库操作Service实现
|
||||
* @createDate 2022-05-18 22:54:18
|
||||
*/
|
||||
@Service
|
||||
public class KeyTestServiceImpl extends ServiceImpl<KeyTestMapper, KeyTest>
|
||||
implements KeyTestService{
|
||||
implements KeyTestService {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,18 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-boot-wxrobot</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>9</source>
|
||||
<target>9</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
@@ -30,6 +42,11 @@
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aivfo</groupId>
|
||||
<artifactId>aivfo-dfs-client-spring-boot-starter</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.wyl.spring.wxrobot.controller;
|
||||
|
||||
import com.aivfo.dfs.client.core.DFSClient;
|
||||
import com.aivfo.el.start.core.util.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@Component
|
||||
public class Download {
|
||||
@Autowired
|
||||
DFSClient dfsClient;
|
||||
|
||||
public void test(HttpServletResponse response, List<String> path) throws Exception {
|
||||
ZipOutputStream zipOutputStream = build(response);
|
||||
AtomicReference<Boolean> skip = new AtomicReference<>(false);
|
||||
try (zipOutputStream) {
|
||||
for (int i = 0; i < path.size(); i++) {
|
||||
if (skip.get()) {
|
||||
return;
|
||||
}
|
||||
zipOutputStream.putNextEntry(new ZipEntry(path.get(i)));
|
||||
dfsClient.downloadFile(path.get(i), (data, dataSize) -> {
|
||||
try {
|
||||
if (ObjectUtils.isNotNull(zipOutputStream)) {
|
||||
zipOutputStream.write(data, 0, dataSize);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
skip.set(true);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
zipOutputStream.flush();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ZipOutputStream build(HttpServletResponse response) throws IOException {
|
||||
return new ZipOutputStream(response.getOutputStream());
|
||||
}
|
||||
}
|
||||
+2477
File diff suppressed because it is too large
Load Diff
-33
@@ -1,33 +0,0 @@
|
||||
package com.wyl.spring.wxrobot.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.wyl.spring.wxrobot.entity.param.WxRobotMessageParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author: wangyl
|
||||
* @date: 2023/2/6
|
||||
* @description:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/")
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class RobotMessage {
|
||||
|
||||
@PostMapping("/getMessageData")
|
||||
public String getMessageData(@RequestBody WxRobotMessageParam skuListPageReq) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("code", 200);
|
||||
jsonObject.put("message", "成功");
|
||||
jsonObject.put("data", "123");
|
||||
System.out.println(jsonObject.toJSONString());
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.wyl.spring.wxrobot.entity.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 选中图片导出
|
||||
*
|
||||
* @author Lbq
|
||||
* @date 2023/7/12 15:57
|
||||
*/
|
||||
@Data
|
||||
public class PictureExportDTO {
|
||||
|
||||
private String tlSn;
|
||||
private Integer houseSn;
|
||||
private List<Long> ids;
|
||||
private Integer pictureLayer;
|
||||
|
||||
}
|
||||
@@ -1 +1,9 @@
|
||||
server.port=65006
|
||||
server.port=65006
|
||||
aivfo.dfs.fastdfs.enable=true
|
||||
aivfo.dfs.fastdfs.trackerServers=192.168.31.89:22122,192.168.31.89:22123
|
||||
aivfo.dfs.fastdfs.storagePath.group1[0]=/mnt/data01/image/group1/storaged01
|
||||
aivfo.dfs.fastdfs.storagePath.group1[1]=/mnt/data01/image/group1/storaged02
|
||||
aivfo.dfs.fastdfs.storagePath.group1[2]=/mnt/data01/image/group1/storaged03
|
||||
aivfo.dfs.fastdfs.storagePath.group2[0]=/mnt/data01/image/group1/storaged01
|
||||
aivfo.dfs.fastdfs.storagePath.group2[1]=/mnt/data01/image/group1/storaged02
|
||||
aivfo.dfs.fastdfs.storagePath.group2[2]=/mnt/data01/image/group1/storaged03
|
||||
Reference in New Issue
Block a user