package com.huimv.video.dhicc.test.controller;


import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.dahuatech.icc.exception.ClientException;
import com.huimv.video.dhicc.result.R;
import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo03;
import com.huimv.video.dhicc.test.request.ClientAllVideoPlayBackRequestCn;
import com.huimv.video.dhicc.test.request.ClientAllVideoPlayBackRequestHn;
import com.huimv.video.dhicc.test.request.ClientAllVideoPlayBackRequestSg;
import com.huimv.video.video.entity.Camera;
import com.huimv.video.video.service.ICameraService;
import net.sf.json.JSONObject;
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;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/clientAllVideoPlayBackTest")
public class ClientAllVideoPlayBackGTest {

    @Autowired
    private ICameraService iCameraService;
    @Autowired
    private OauthConfigBaseInfo oauthConfigBaseInfo;
    @Autowired
    private OauthConfigBaseInfo02 oauthConfigBaseInfo02;
    @Autowired
    private OauthConfigBaseInfo03 oauthConfigBaseInfo03;


    @PostMapping("/startPlaybackByTime")
    public R videoPlayBack(@RequestBody Map<String,String> map) throws ClientException {
        String id = map.get("id");
        String farmId = map.get("farmId");

        if (StringUtils.isBlank(id)){
            return R.error("摄像头选择有误");
        }
        Camera byId = iCameraService.getById(id);
        if (ObjectUtil.isEmpty(byId) || ObjectUtil.isEmpty(byId.getIccChannel())){
            return R.error("该摄像头未进行回放配置");

        }
        String startTime = map.get("startTime");
        String endTime = map.get("endTime");
        String iccChannel = byId.getIccChannel();


        Map<String, Object> value = new HashMap<>();
        value.put("nvrId", "");
        value.put("optional", "/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime");
        value.put("recordType", "1");
        value.put("streamType", "1");
        value.put("recordSource", "2");
        value.put("channelId",iccChannel);
        //开始结束时间代为处理
        value.put("endTime", endTime);
        value.put("startTime",startTime);
//        params.put("clientMac", "30:9c:23:79:40:08");

        Object action = null;
        if ("1".equals(farmId)) {
            ClientAllVideoPlayBackRequestSg requestSg = new ClientAllVideoPlayBackRequestSg(oauthConfigBaseInfo);
            requestSg.setClientPushId("");
            requestSg.setProject("PSDK");
            requestSg.setMethod("SS.Playback.StartPlaybackByTime");
            requestSg.setData(value);
            System.out.println(requestSg);
            Object action1 = requestSg.doAction();
            action = action1;
        } else if ("2".equals(farmId)) {
            ClientAllVideoPlayBackRequestHn requestHn = new ClientAllVideoPlayBackRequestHn(oauthConfigBaseInfo02);
            requestHn.setClientPushId("");
            requestHn.setProject("PSDK");
            requestHn.setMethod("SS.Playback.StartPlaybackByTime");
            requestHn.setData(value);
            System.out.println(requestHn);
            Object action1 = requestHn.doAction();
            action = action1;
        } else {
            ClientAllVideoPlayBackRequestCn requestCn = new ClientAllVideoPlayBackRequestCn(oauthConfigBaseInfo03);
            requestCn.setClientPushId("");
            requestCn.setProject("PSDK");
            requestCn.setMethod("SS.Playback.StartPlaybackByTime");
            requestCn.setData(value);
            System.out.println(requestCn);
            Object action1 = requestCn.doAction();
            action = action1;
        }

        JSONObject jsonObject = JSONObject.fromObject(action);
        System.out.println(jsonObject.toString());
        String url = (String) jsonObject.get("url");
        String token = (String) jsonObject.get("token");
        // "|"  特殊字符需要加转义字符
        String[] sourceStrArray = url.split("\\|");
        String recordUrl = sourceStrArray[1] + "?token=" + token + "&trackID=701";
        return R.ok("请求成功").put("URL", recordUrl);

    }
//    @PostMapping("/test")
//    public R test() throws ClientException {
//
//
//        String iccChannel = "1003238$1$0$2";
//
//        String URL = "/evo-apigw/admin/API/SS/Record/QueryRecords";  //
//        IClient iClient = new DefaultClient();
//        GeneralRequest generalRequest = new GeneralRequest(URL, Method.POST);
//        Map<String, Object> params = new HashMap<>();
//        Map<String, Object> value = new HashMap<>();
//        value.put("recordType", "0");
//        value.put("streamType", "0");
//        value.put("recordSource", "2");
//        value.put("channelId",iccChannel);
//        //开始结束时间代为处理
//        value.put("endTime", "1654023445");
//        value.put("startTime","1654019845");
////        params.put("clientMac", "30:9c:23:79:40:08");
//        params.put("data", value);
//        generalRequest.body(JSON.toJSONString(params));
//        System.out.println(JSON.toJSONString(params));
//        //这种已经在配置文件里面安排了账号ip以及密码
//        generalRequest.header("Content-Type", " application/json");
//        //发起请求处理应答
//        GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
//
//        JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
////        System.out.println(jsonObject.toString());
////        Object data = jsonObject.get("data");
////        String url = (String) JSONObject.fromObject(data).get("url");
////        String token = (String) JSONObject.fromObject(data).get("token");
////        // "|"  特殊字符需要加转义字符
////        String[] sourceStrArray = url.split("\\|");
////        String recordUrl = sourceStrArray[1] + "?token=" + token + "&trackID=701";
//        return R.ok("请求成功").put("URL", jsonObject);
//
//    }
//    @Autowired
//    private IIccChannelService channelService;
//    @GetMapping("/test")
//    public void test(){
//        String  data ="{\"success\":true,\"data\":{\"pageData\":[{\"channelName\":\"环保区发酵罐南通道\",\"channelCode\":\"1003486$1$0$31\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":33,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"饲料塔道路\",\"channelCode\":\"1003486$1$0$30\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":32,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"产蛋舍一过道一\",\"channelCode\":\"1003486$1$0$3\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":5,\"updateTime\":1656915963000,\"createTime\":1656915949000},{\"channelName\":\"有机肥东通道\",\"channelCode\":\"1003486$1$0$29\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":70,\"updateTime\":1656982369000,\"createTime\":1656915949000},{\"channelName\":\"雏鸡舍后道路1\",\"channelCode\":\"1003486$1$0$28\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":30,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"有机肥西通道\",\"channelCode\":\"1003486$1$0$27\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":68,\"updateTime\":1656982129000,\"createTime\":1656915949000},{\"channelName\":\"环保区发酵罐北通道\",\"channelCode\":\"1003486$1$0$26\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":28,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"饲料仓库南道路1\",\"channelCode\":\"1003486$1$0$25\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":27,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"饲料仓库1\",\"channelCode\":\"1003486$1$0$24\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":26,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"饲料仓库2\",\"channelCode\":\"1003486$1$0$23\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":25,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"饲料仓库南道路2\",\"channelCode\":\"1003486$1$0$22\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":24,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"鸡蛋打包台\",\"channelCode\":\"1003486$1$0$21\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":23,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"蛋库南\",\"channelCode\":\"1003486$1$0$20\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":22,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"产蛋舍一过道三\",\"channelCode\":\"1003486$1$0$2\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":4,\"updateTime\":1656915962000,\"createTime\":1656915949000},{\"channelName\":\"蛋库西南门\",\"channelCode\":\"1003486$1$0$19\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":21,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"蛋库出库口\",\"channelCode\":\"1003486$1$0$18\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":20,\"updateTime\":1656915964000,\"createTime\":1656915949000},{\"channelName\":\"送蛋机\",\"channelCode\":\"1003486$1$0$17\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":19,\"updateTime\":1656915963000,\"createTime\":1656915949000},{\"channelName\":\"蛋库北\",\"channelCode\":\"1003486$1$0$16\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":18,\"updateTime\":1656915963000,\"createTime\":1656915949000},{\"channelName\":\"产蛋舍一西通道\",\"channelCode\":\"1003486$1$0$15\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":17,\"updateTime\":1656915963000,\"createTime\":1656915949000},{\"channelName\":\"雏鸡舍后道路2\",\"channelCode\":\"1003486$1$0$14\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":16,\"updateTime\":1656915963000,\"createTime\":1656915949000},{\"channelName\":\"蛋库东通道\",\"channelCode\":\"1003486$1$0$13\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":15,\"updateTime\":1656915963000,\"createTime\":1656915949000},{\"channelName\":\"雏鸡舍后道路3\",\"channelCode\":\"1003486$1$0$12\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":14,\"updateTime\":1656915963000,\"createTime\":1656915949000},{\"channelName\":\"蛋库北东门\",\"channelCode\":\"1003486$1$0$11\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":13,\"updateTime\":1656915963000,\"createTime\":1656915949000},{\"channelName\":\"小鸡舍北通道\",\"channelCode\":\"1003486$1$0$10\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":12,\"updateTime\":1656915963000,\"createTime\":1656915949000},{\"channelName\":\"污水处理池\",\"channelCode\":\"1003486$1$0$1\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":3,\"updateTime\":1656915962000,\"createTime\":1656915949000},{\"channelName\":\"产蛋舍一南通道\",\"channelCode\":\"1003486$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003486\",\"deviceName\":\"192.168.1.4\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":2,\"updateTime\":1656915962000,\"createTime\":1656915949000},{\"channelName\":\"有机肥后东南围墙\",\"channelCode\":\"1003470$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003470\",\"deviceName\":\"192.168.1.123\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":75,\"updateTime\":1656899781000,\"createTime\":1643079695000},{\"channelName\":\"有机肥后西南围墙\",\"channelCode\":\"1003469$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003469\",\"deviceName\":\"192.168.1.121\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":75,\"updateTime\":1656899780000,\"createTime\":1643079666000},{\"channelName\":\"厂区后北围墙2\",\"channelCode\":\"1003468$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003468\",\"deviceName\":\"192.168.1.138\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":23,\"updateTime\":1653003018000,\"createTime\":1643079628000},{\"channelName\":\"厂区后北围墙1\",\"channelCode\":\"1003467$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003467\",\"deviceName\":\"192.168.1.137\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":23,\"updateTime\":1653003022000,\"createTime\":1643079595000},{\"channelName\":\"厂区后南围墙2\",\"channelCode\":\"1003466$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003466\",\"deviceName\":\"192.168.1.136\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":25,\"updateTime\":1653003015000,\"createTime\":1643079555000},{\"channelName\":\"厂区后南围墙1\",\"channelCode\":\"1003465$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003465\",\"deviceName\":\"192.168.1.135\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":25,\"updateTime\":1653003023000,\"createTime\":1643079525000},{\"channelName\":\"环保区后西围墙1\",\"channelCode\":\"1003464$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003464\",\"deviceName\":\"192.168.1.130\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":25,\"updateTime\":1653003021000,\"createTime\":1643079434000},{\"channelName\":\"环保区后西围墙2\",\"channelCode\":\"1003463$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003463\",\"deviceName\":\"192.168.1.131\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":27,\"updateTime\":1653003020000,\"createTime\":1643079385000},{\"channelName\":\"环保区加药房围墙\",\"channelCode\":\"1003461$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003461\",\"deviceName\":\"192.168.1.129\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":23,\"updateTime\":1653003020000,\"createTime\":1643079289000},{\"channelName\":\"有机肥南围墙1\",\"channelCode\":\"1003460$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003460\",\"deviceName\":\"192.168.1.128\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":79,\"updateTime\":1656899811000,\"createTime\":1643079040000},{\"channelName\":\"有机肥南围墙2\",\"channelCode\":\"1003297$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003297\",\"deviceName\":\"192.168.1.127\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":79,\"updateTime\":1656899780000,\"createTime\":1643024628000},{\"channelName\":\"大门西南围墙1\",\"channelCode\":\"1003296$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003296\",\"deviceName\":\"192.168.1.126\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":81,\"updateTime\":1656899779000,\"createTime\":1643024596000},{\"channelName\":\"大门西南围墙2\",\"channelCode\":\"1003295$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003295\",\"deviceName\":\"192.168.1.125\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":79,\"updateTime\":1656899779000,\"createTime\":1643024519000},{\"channelName\":\"大门北洗消院墙\",\"channelCode\":\"1003284$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003284\",\"deviceName\":\"192.168.1.27\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":37,\"updateTime\":1656574556000,\"createTime\":1643021699000},{\"channelName\":\"门卫室外向北\",\"channelCode\":\"1003281$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003281\",\"deviceName\":\"192.168.1.29\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":39,\"updateTime\":1656574553000,\"createTime\":1643021017000},{\"channelName\":\"门卫室外向南\",\"channelCode\":\"1003278$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003278\",\"deviceName\":\"192.168.1.31\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":38,\"updateTime\":1656574552000,\"createTime\":1643020463000},{\"channelName\":\"门卫室\",\"channelCode\":\"1003276$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003276\",\"deviceName\":\"192.168.1.26\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":36,\"updateTime\":1656574555000,\"createTime\":1643020009000},{\"channelName\":\"饲料仓库围墙2\",\"channelCode\":\"1003238$1$0$9\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":730,\"updateTime\":1656925095000,\"createTime\":1643008893000},{\"channelName\":\"饲料仓库围墙1\",\"channelCode\":\"1003238$1$0$8\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":728,\"updateTime\":1656924915000,\"createTime\":1643008893000},{\"channelName\":\"饲料塔围墙1\",\"channelCode\":\"1003238$1$0$7\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":726,\"updateTime\":1656924615000,\"createTime\":1643008893000},{\"channelName\":\"饲料塔围墙2\",\"channelCode\":\"1003238$1$0$6\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":736,\"updateTime\":1656926745000,\"createTime\":1643008893000},{\"channelName\":\"综合楼北围墙2\",\"channelCode\":\"1003238$1$0$5\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":734,\"updateTime\":1656926535000,\"createTime\":1643008893000},{\"channelName\":\"综合楼北围墙1\",\"channelCode\":\"1003238$1$0$4\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":732,\"updateTime\":1656926355000,\"createTime\":1643008893000},{\"channelName\":\"大门北洗消院墙\",\"channelCode\":\"1003238$1$0$3\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":716,\"updateTime\":1656919925000,\"createTime\":1643008893000},{\"channelName\":\"门卫室\",\"channelCode\":\"1003238$1$0$2\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":715,\"updateTime\":1656919925000,\"createTime\":1643008893000},{\"channelName\":\"配电房北院墙\",\"channelCode\":\"1003238$1$0$11\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":740,\"updateTime\":1656927255000,\"createTime\":1643008893000},{\"channelName\":\"配电房东院墙\",\"channelCode\":\"1003238$1$0$10\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":738,\"updateTime\":1656927075000,\"createTime\":1643008893000},{\"channelName\":\"门卫室外向北\",\"channelCode\":\"1003238$1$0$1\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":714,\"updateTime\":1656919925000,\"createTime\":1643008893000},{\"channelName\":\"门卫室外向南\",\"channelCode\":\"1003238$1$0$0\",\"unitType\":1,\"deviceCode\":\"1003238\",\"deviceName\":\"192.168.1.6\",\"ownerCode\":\"001\",\"orgName\":\"根节点\",\"isOnline\":1,\"onlineUpdateVersion\":713,\"updateTime\":1656919925000,\"createTime\":1643008893000}],\"currentPage\":2,\"totalPage\":2,\"pageSize\":100,\"totalRows\":155},\"code\":\"0\",\"errMsg\":\"\"}";
//        JSONObject jsonObject = JSONObject.fromObject(data);
//        System.out.println(jsonObject);
//        Object data1 = jsonObject.get("data");
//        List<Map> list =(List<Map>) JSONObject.fromObject(data1).get("pageData");
//        for (Map map : list) {
//            String channelName = (String)map.get("channelName");
//            String channelId = (String)map.get("channelCode");
////            String replace = channelName.replace("楼", "层");
//            IccChannel iccChannel = new IccChannel();
//
//            iccChannel.setChannelId(channelId);
//            iccChannel.setChannelName(channelName);
//            channelService.save(iccChannel);
//            List<Camera> farmIds = iCameraService.list(new QueryWrapper<Camera>().eq("camera_name", channelName));
//
//
//            if (ObjectUtil.isNotEmpty(farmIds)){
//                Camera farmId = farmIds.get(0);
//                farmId.setIccChannel(channelId);
//                iCameraService.updateById(farmId);
//            }
//        }
//    }


}
