1、cad拆单支持造型数据压缩存入mysql;2、未排单数据、计算用板量、优化生产接口支持mysql造型数据替换es造型数据;

This commit is contained in:
gaoqr
2026-05-12 09:50:18 +08:00
parent ba914beb16
commit 9f9941e71e
19 changed files with 291 additions and 98 deletions
@@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
@@ -75,7 +76,7 @@ public class JsonUtils {
try {
return objectMapper.readValue(text, clazz);
} catch (IOException e) {
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
// log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -89,7 +90,7 @@ public class JsonUtils {
JsonNode pathNode = treeNode.path(path);
return objectMapper.readValue(pathNode.toString(), clazz);
} catch (IOException e) {
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
// log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -101,7 +102,7 @@ public class JsonUtils {
try {
return objectMapper.readValue(text, objectMapper.getTypeFactory().constructType(type));
} catch (IOException e) {
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
// log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -129,7 +130,7 @@ public class JsonUtils {
try {
return objectMapper.readValue(bytes, clazz);
} catch (IOException e) {
log.error(JSON_PARSE_ERROR_NOTIFICATION, bytes, e);
// log.error(JSON_PARSE_ERROR_NOTIFICATION, bytes, e);
throw new RuntimeException(e);
}
}
@@ -138,7 +139,7 @@ public class JsonUtils {
try {
return objectMapper.readValue(text, typeReference);
} catch (IOException e) {
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
// log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -150,7 +151,7 @@ public class JsonUtils {
try {
return objectMapper.readValue(text, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
} catch (IOException e) {
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
// log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -164,7 +165,7 @@ public class JsonUtils {
JsonNode pathNode = treeNode.path(path);
return objectMapper.readValue(pathNode.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
} catch (IOException e) {
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
// log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -173,7 +174,7 @@ public class JsonUtils {
try {
return objectMapper.readTree(text);
} catch (IOException e) {
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
// log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -182,7 +183,7 @@ public class JsonUtils {
try {
return objectMapper.readTree(text);
} catch (IOException e) {
log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
// log.error(JSON_PARSE_ERROR_NOTIFICATION, text, e);
throw new RuntimeException(e);
}
}
@@ -269,5 +270,80 @@ public class JsonUtils {
}
}
/**
* 压缩
*
* @param str
* @return
*/
public static byte[] zip(String str) {
Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION);
deflater.setInput(str.getBytes(StandardCharsets.UTF_8));
deflater.finish();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
while (!deflater.finished()) {
int len = deflater.deflate(buffer);
outputStream.write(buffer, 0, len);
}
deflater.end();
return outputStream.toByteArray();
}
/**
* 解压缩
*
* @param data
* @return
*/
public static String unzip(byte[] data) {
Inflater inflater = new Inflater();
inflater.setInput(data);
byte[] buffer = new byte[1024];
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
while (!inflater.finished()) {
int len = inflater.inflate(buffer);
// 防止异常数据导致死循环
if (len == 0) {
if (inflater.needsInput()) {
break;
}
if (inflater.needsDictionary()) {
throw new RuntimeException("Inflater needs dictionary");
}
}
outputStream.write(buffer, 0, len);
}
return outputStream.toString(StandardCharsets.UTF_8);
} catch (DataFormatException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
inflater.end();
}
}
}