From fc46a1c1863ecbbd49069252e15029f4541e2265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AF=85?= <97163845@qq.com> Date: Wed, 4 Jun 2025 17:11:17 +0800 Subject: [PATCH] =?UTF-8?q?ivs1800=E7=BA=A2=E5=A4=96=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ivs/controller/IvsDeviceController.java | 76 +++++++++++++++++-- .../controller/PatrolPresetPosController.java | 1 + 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsDeviceController.java b/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsDeviceController.java index 851e1bb..2dd4f56 100644 --- a/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsDeviceController.java +++ b/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsDeviceController.java @@ -1,6 +1,7 @@ package com.inspect.ivs.controller; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.inspect.base.core.constant.Color; import com.inspect.base.core.domain.Response; @@ -17,10 +18,7 @@ import com.inspect.ivs.vo.IvsDevChanListVo; import com.inspect.ivs.vo.IvsDevChanSnapVo; import java.io.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; @@ -57,6 +55,14 @@ public class IvsDeviceController { */ @PostMapping("/setHwConfig") public Response setHwConfig(@RequestBody TempConfiguration tempConfiguration) throws Exception { + Temp temp = new Temp(); + temp.setCameraCode(tempConfiguration.getCameraCode()); + JSONObject config = getConfig(temp); + + JSONArray radiometryRuleExListOrginl = config.getJSONArray("radiometryRuleExList"); + JSONArray radiometryRuleListOrginl = config.getJSONArray("radiometryRuleList"); + + log.info("[infra_1800] =======tempConfiguration: {}", tempConfiguration); JSONObject json = new JSONObject(); JSONObject configItem = new JSONObject(); @@ -65,6 +71,7 @@ public class IvsDeviceController { alarmSettings.put("preDuration", 0); alarmSettings.put("preThreshold", 22); alarmSettingListEx.add(alarmSettings); + //设置blockBodyTemp List> radiometryRuleExList = new ArrayList<>(); Map ruleItem = new HashMap<>(); @@ -73,6 +80,24 @@ public class IvsDeviceController { ruleItem.put("usefReflectedTemp", false);//写死 ruleItem.put("alarmSettingList", alarmSettingListEx);//写死 radiometryRuleExList.add(ruleItem); + // 遍历 FastJSON 的 JSONArray + for (Object obj : radiometryRuleExListOrginl) { + if (obj instanceof JSONObject) { + JSONObject jsonObject = (JSONObject) obj; + Map map = new HashMap<>(); + // FastJSON 的 JSONObject 可以直接转换为 Map + map = jsonObject.getInnerMap(); // 直接获取内部 Map + // 或者逐个处理 key-value(更安全) + for (Map.Entry entry : jsonObject.entrySet()) { + map.put(entry.getKey(), entry.getValue()); + } + radiometryRuleExList.add(map); + } else if (obj instanceof String) { + // 处理基本类型(如果 JSONArray 中包含字符串等) + Map map = Collections.singletonMap("value", obj); + radiometryRuleExList.add(map); + } + } // 设置 configItem configItem.put("radiometryRuleExList", radiometryRuleExList); List> radiometryRuleList = new ArrayList<>(); @@ -105,6 +130,25 @@ public class IvsDeviceController { radiometryRule.put("localParam", localParam); radiometryRule.put("polygonList", tempConfiguration.getPolygonList()); radiometryRuleList.add(radiometryRule); + + // 遍历 FastJSON 的 JSONArray + for (Object obj : radiometryRuleListOrginl) { + if (obj instanceof JSONObject) { + JSONObject jsonObject = (JSONObject) obj; + Map map = new HashMap<>(); + // FastJSON 的 JSONObject 可以直接转换为 Map + map = jsonObject.getInnerMap(); // 直接获取内部 Map + // 或者逐个处理 key-value(更安全) + for (Map.Entry entry : jsonObject.entrySet()) { + map.put(entry.getKey(), entry.getValue()); + } + radiometryRuleList.add(map); + } else if (obj instanceof String) { + // 处理基本类型(如果 JSONArray 中包含字符串等) + Map map = Collections.singletonMap("value", obj); + radiometryRuleList.add(map); + } + } configItem.put("radiometryRuleList", radiometryRuleList); json.put("deviceCode", tempConfiguration.getCameraCode().split("#")[0]);//传 json.put("configType", 500);//写死500 @@ -150,7 +194,29 @@ public class IvsDeviceController { return "0"; } - + /** + * 获取原始规则 + * + * @param + * @return + * @throws Exception + */ + @PostMapping("/getConfig") + public JSONObject getConfig(@RequestBody Temp temp) { + log.info( "[infrared_1800] 获取红外温度 temper param: {}", temp); + String cameraCode = temp.getCameraCode().split("#")[0]; + String nvrcode = temp.getCameraCode().split("#")[1]; + String requestMsg = ""; + //发送请求 + String resp = ivsCommonService.sendsslGetCookie(address + "/device/deviceconfig/500/"+cameraCode+"/"+nvrcode, requestMsg,"UTF-8"); + JSONObject jsonObject = JSON.parseObject(resp); + JSONObject configItem = jsonObject.getJSONObject("configItem"); + log.info( "configItem: {}", configItem); + return configItem; +// JSONArray radiometryRuleExList = configItem.getJSONArray("radiometryRuleExList"); +// JSONArray radiometryRuleList = configItem.getJSONArray("radiometryRuleList"); +// return "0"; + } @GetMapping({"channelsnap"}) public ResponseEntity channelSnap(IvsDevChanSnapVo ivsDevChanSnapVo) throws Exception { diff --git a/inspect-main/inspect-main-video/src/main/java/com/inspect/patrol/controller/PatrolPresetPosController.java b/inspect-main/inspect-main-video/src/main/java/com/inspect/patrol/controller/PatrolPresetPosController.java index 9a4b5bd..f41905e 100644 --- a/inspect-main/inspect-main-video/src/main/java/com/inspect/patrol/controller/PatrolPresetPosController.java +++ b/inspect-main/inspect-main-video/src/main/java/com/inspect/patrol/controller/PatrolPresetPosController.java @@ -506,6 +506,7 @@ public class PatrolPresetPosController extends BaseController { PatrolPresetParam patrolPresetParam = patrolPresetPos.getPresetParamList().get(0); final String temperUrl = liveSIPBUrl + "/api/v1/device/setHwConfig"; logger.info("=========temperUrl====={}", temperUrl); + logger.info("=========patrolPresetParam====={}", patrolPresetParam); JSONObject temperParam = new JSONObject(); temperParam.put("ruleId", Integer.parseInt(patrolPresetParam.getPresetParamCode())); //设置ruleId temperParam.put("presetId", patrolPresetPos.getPresetPosCode());