package com.inspect.metadata.patrolpointmnt.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.inspect.metadata.patrolpointmnt.domain.vo.DevicePointModel;
import com.inspect.base.core.web.controller.BaseController;
import com.inspect.base.core.web.domain.AjaxResult;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/patrolpointmnt/devicepointmodel"})
public class BasedataDevicePointModelController extends BaseController {

    @GetMapping({"/dataParser"})
    public AjaxResult dataParser() {
        String data = "{\n\t\"Items\": [{\n\t\t\"station_name\": \"哈南变电站\",\n\t\t\"station_id\": \"changzhan0001\",\n\t\t\"area_id\": \"102\",\n\t\t\"area_name\": \"站外1\",\n\t\t\"bay_id\": \"108\",\n\t\t\"bay_name\": \"变电站全景\",\n\t\t\"main_device_id\": \"30260\",\n\t\t\"main_device_name\": \"套管3\",\n\t\t\"component_id\": \"137\",\n\t\t\"component_name\": \"套管3_部件二级02_部件三级\",\n\t\t\"device_id\": \"czjgdw\",\n\t\t\"device_name\": \"机器人上传点位-1\",\n\t\t\"device_type\": \"2\",\n\t\t\"meter_type\": \"1\",\n\t\t\"appearance_type\": \"1\",\n\t\t\"save_type_list\": \"采集/保存文件类型列表\",\n\t\t\"recognition_type_list\": \"表计表盘模糊,表计表盘破损\",\n\t\t\"phase\": \"A\",\n\t\t\"device_info\": \"\",\n\t\t\"data_type\": \"\",\n\t\t\"lower_value\": \"20\",\n\t\t\"upper_value\": \"30\",\n\t\t\"video_pos\": [{\n\t\t\t\t\"device_code\": \"视频编码\",\n\t\t\t\t\"device_pos\": \"视频预置位号\",\n\t\t\t\t\"robot_code\": \"机器人编码\",\n\t\t\t\t\"robot_pos\": \"机器人预置位号\",\n\t\t\t\t\"uav_code\": \"无人机编码\",\n\t\t\t\t\"uav_pos\": \"无人机预置位号\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"device_code\": \"视频编码\",\n\t\t\t\t\"device_pos\": \"视频预置位号\",\n\t\t\t\t\"robot_code\": \"机器人编码\",\n\t\t\t\t\"robot_pos\": \"机器人预置位号\",\n\t\t\t\t\"uav_code\": \"无人机编码\",\n\t\t\t\t\"uav_pos\": \"无人机预置位号\"\n\t\t\t}\n\t\t]\n\t}]\n}";
        JSONObject jsonObject = JSONObject.parseObject(data);
        JSONArray jsonObjectItems = jsonObject.getJSONArray("Items");
        List<DevicePointModel> list = jsonObjectItems.toJavaList(DevicePointModel.class);
        return AjaxResult.success("成功！！！", jsonObjectItems);
    }
}
