fix(bug): 修复摄像头传输流关闭和日志大小上限问题

- 修改 logback.xml 中的日志大小上限为 200MB
- 修正 Operational 类中的摄像头传输流操作
- 在 R 类中添加 noMean 方法用于处理无对应方法的情况
- 更新 SocketServer 和 SocketUtils 类中的消息处理逻辑
- 优化 TwainContainer 类中的 intValue 方法
This commit is contained in:
JianGuo 2025-06-06 14:37:59 +08:00
parent c620d07075
commit 84eac91bac
6 changed files with 21 additions and 8 deletions

View File

@ -79,7 +79,7 @@ public class Operational {
WebCamUtils.setViewSizes(param.getInteger("width"), param.getInteger("height"));
r = R.ok();
}else if("002007".equals(function)){
//打开摄像头传输流
//关闭摄像头传输流
WebCamUtils.closeWebcamTransfer();
}

View File

@ -32,6 +32,10 @@ public class R<T> {
public static R fail(String msg) {
return new R<>("500", msg, null, false);
}
public static R noMean(){
return new R<>("201", "没有找到对应的方法", null, true);
}
public String toJsonStr() {
return JSONUtil.toJsonStr(this);

View File

@ -54,6 +54,10 @@ public abstract class TwainContainer {
}
private int intValue(Object obj) throws TwainException {
if(obj == null){
return 0;
}
if (obj instanceof Number) {
return ((Number) obj).intValue();
} else if (obj instanceof Boolean) {

View File

@ -43,7 +43,7 @@ public class SocketServer extends WebSocketServer {
public void onMessage(WebSocket conn, String message) {
JSONObject json = SocketUtils.isNoPingMessage(message);
if (json == null){
conn.send(R.ok().toJsonStr());
conn.send(R.noMean().toJsonStr());
}else{
conn.send(selectOperational(json));
}

View File

@ -77,11 +77,16 @@ public class SocketUtils {
* @return
*/
public static JSONObject isNoPingMessage(String message){
JSONObject json = JSONObject.parse(message);
String type = json.getString("type");
if("ping".equals(type)){
return json;
try{
JSONObject json = JSONObject.parse(message);
String type = json.getString("type");
if("ping".equals(type)){
return json;
}
return null;
}catch (Exception e){
return null;
}
return null;
}
}

View File

@ -20,7 +20,7 @@
<fileNamePattern>${log.path}/ScanService.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
<totalSizeCap>200M</totalSizeCap>
<totalSizeCap>200MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>