From 1f96127261451109423f7a7a8aba1029e738b902 Mon Sep 17 00:00:00 2001 From: liuguijing <123456> Date: Tue, 14 May 2024 15:38:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=A1=A8=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xypower/mpmaster/sms/SimUtil.java | 98 +++++++++++++++---- .../mpmaster/sms/UpdateSysConfigUtil.java | 39 +++++++- 2 files changed, 118 insertions(+), 19 deletions(-) diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java b/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java index 42ad2f5f..c99fc665 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java @@ -247,14 +247,14 @@ public class SimUtil { int encrypto = -1; if (integer != null) { ifmessageCorrect = true; + if (split2.length == 4) { + String s1 = split2[2]; + utcp = StringUtils.convert2Int(s1); + String s2 = split2[3]; + encrypto = StringUtils.convert2Int(s2); + } + UpdateSysConfigUtil.setIP(context, server, integer, utcp, encrypto); } - if (split2.length == 4) { - String s1 = split2[2]; - utcp = StringUtils.convert2Int(s1); - String s2 = split2[3]; - encrypto = StringUtils.convert2Int(s2); - } - UpdateSysConfigUtil.setIP(context, server, integer, utcp, encrypto); } } String menssageBack = ""; @@ -272,12 +272,6 @@ public class SimUtil { } else if (content.contains(SmsTypeEnum.SET_OSD.value())) { sendtype = SmsTypeEnum.SET_OSD.value(); String[] split1 = StringUtils.splitString1(content); - if (split1 != null && split1.length > 1) { - String s = split1[1]; - String[] split2 = StringUtils.splitString2(s); - if (split2 != null && split2.length == 2) { - } - } String menssageBack = ""; if (ifmessageCorrect) { menssageBack = " OK"; @@ -285,11 +279,81 @@ public class SimUtil { menssageBack = " ERROR"; } sendmessage = content + menssageBack; + if (split1 != null && split1.length == 2) { + ifmessageCorrect = true; + HashMap osdmap = new HashMap<>(); + String s = split1[1]; + String[] split2 = StringUtils.splitString2(s); + int spilt2len = split2.length; + if (split2 != null && spilt2len > 1 && spilt2len % 2 == 1) { + String num = split2[0]; + Integer integer = StringUtils.convert2Int(num); + if (integer != null) { + if (integer == 0) {//所有通道 + ifmessageCorrect = true; + } else { + for (int i = 0; i < spilt2len; i++) { + if (i == 0) { + continue; + } + if (i % 2 == 1) { + if ((i + 1) <= spilt2len) { + String s1 = split2[i]; + Integer position = StringUtils.convert2Int(s1); + if (position != null) { + if (position == 1) { + osdmap.put("leftTop", split2[i + 1]); + } else if (position == 2) { + osdmap.put("rightTop", split2[i + 1]); + } else if (position == 3) { + osdmap.put("leftBottom", split2[i + 1]); + } else if (position == 4) { + osdmap.put("rightBottom", split2[i + 1]); + } else { + ifmessageCorrect = false; + } + } else { + ifmessageCorrect = false; + } + } else { + ifmessageCorrect = false; + } + } + } + } + if (ifmessageCorrect) { + UpdateSysConfigUtil.setChannelOSD(integer, osdmap); + } + } + } + } } else if (content.contains(SmsTypeEnum.GET_OSD.value())) { sendtype = SmsTypeEnum.GET_OSD.value(); - ifmessageCorrect = true; + String[] split = StringUtils.splitString1(content); + if (split != null && split.length == 2) { + sendmessage = SmsTypeEnum.GET_OSD.value() + "="; + ifmessageCorrect = true; + Integer channel = StringUtils.convert2Int(split[0]); + HashMap channelOSD = UpdateSysConfigUtil.getChannelOSD(channel); + String leftTop = channelOSD.get("leftTop"); + String rightTop = channelOSD.get("rightTop"); + String leftBottom = channelOSD.get("leftBottom"); + String rightBottom = channelOSD.get("rightBottom"); + if (leftTop != null && StringUtils.isNotEmpty(leftTop)) { + sendmessage += "1," + leftTop; + } + if (rightTop != null && StringUtils.isNotEmpty(rightTop)) { + sendmessage += "2," + rightTop; + } + if (leftBottom != null && StringUtils.isNotEmpty(leftBottom)) { + sendmessage += "3" + leftBottom; + } + if (rightBottom != null && StringUtils.isNotEmpty(rightBottom)) { + sendmessage += "4," + leftTop; + } + } } else if (content.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) { - sendtype = SmsTypeEnum.SET_OSD.value(); + sendtype = SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value(); String[] split1 = StringUtils.splitString1(content); if (split1 != null && split1.length > 1) { String s = split1[1]; @@ -321,7 +385,7 @@ public class SimUtil { Integer videoCY = StringUtils.convert2Int(split2[4]); if (channel != null && resolutionCX != null && resolutionCY != null && videoCX != null && videoCY != null) { ifmessageCorrect = true; - UpdateSysConfigUtil.setChannelResolution(packageName, channel, resolutionCX, resolutionCY, videoCX, videoCY); + UpdateSysConfigUtil.setChannelResolution(channel, resolutionCX, resolutionCY, videoCX, videoCY); } } } @@ -337,7 +401,7 @@ public class SimUtil { ifmessageCorrect = true; String[] split = StringUtils.splitString1(content); Integer channel = StringUtils.convert2Int(split[0]); - HashMap hashMap = UpdateSysConfigUtil.getChannelResolution(packageName, channel); + HashMap hashMap = UpdateSysConfigUtil.getChannelResolution(channel); Integer resolutionCX = hashMap.get("resolutionCX"); Integer resolutionCY = hashMap.get("resolutionCY"); Integer videoCX = hashMap.get("videoCX"); diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/sms/UpdateSysConfigUtil.java b/mpmaster/src/main/java/com/xypower/mpmaster/sms/UpdateSysConfigUtil.java index b224fa7f..b80cc06f 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/sms/UpdateSysConfigUtil.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/sms/UpdateSysConfigUtil.java @@ -191,7 +191,7 @@ public class UpdateSysConfigUtil { } //设置通道分辨率 - public static boolean setChannelResolution(String packageurl, int channel, int resolutionCX, int resolutionCY, int videoCX, int videoCY) { + public static boolean setChannelResolution(int channel, int resolutionCX, int resolutionCY, int videoCX, int videoCY) { String path = getChannelDir(channel); JSONObject jsonObject = JSONUtils.loadJson(path); try { @@ -206,7 +206,7 @@ public class UpdateSysConfigUtil { } //查询通道分辨率 - public static HashMap getChannelResolution(String packageurl, int channel) { + public static HashMap getChannelResolution(int channel) { HashMap hashMap = new HashMap<>(); String path = getChannelDir(channel); JSONObject jsonObject = JSONUtils.loadJson(path); @@ -226,6 +226,41 @@ public class UpdateSysConfigUtil { return hashMap; } + //设置通道水印 + public static boolean setChannelOSD(int channel, HashMap hashMap) { + String path = getChannelDir(channel); + JSONObject jsonObject = JSONUtils.loadJson(path); + try { + jsonObject.put("leftTop", hashMap.get("leftTop")); + jsonObject.put("rightTop", hashMap.get("rightTop")); + jsonObject.put("leftBottom", hashMap.get("leftBottom")); + jsonObject.put("rightBottom", hashMap.get("rightBottom")); + } catch (Exception ex) { + ex.printStackTrace(); + } + return JSONUtils.saveJson(path, jsonObject); + } + + //查询通道分辨率 + public static HashMap getChannelOSD(int channel) { + HashMap hashMap = new HashMap<>(); + String path = getChannelDir(channel); + JSONObject jsonObject = JSONUtils.loadJson(path); + try { + String leftTop = jsonObject.getString("leftTop"); + String rightTop = jsonObject.getString("rightTop"); + String leftBottom = jsonObject.getString("leftBottom"); + String rightBottom = jsonObject.getString("rightBottom"); + hashMap.put("leftTop", leftTop); + hashMap.put("rightTop", rightTop); + hashMap.put("rightBottom", rightBottom); + hashMap.put("leftBottom", leftBottom); + } catch (Exception ex) { + ex.printStackTrace(); + } + return hashMap; + } + //清除历史图片和视频 public static void clearHistoryPic(Context context) {