liuxiaolong
2019-05-06 0bc4f4c791437b39b8c30624f5c21f8c855dc61d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package com.cloud.retrieve.controller;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cloud.common.utils.JsonUtil;
import com.cloud.common.utils.RestTemplateUtil;
import com.cloud.model.common.Page;
import com.cloud.model.common.Result;
import com.cloud.retrieve.service.DeviceService;
import com.cloud.retrieve.utils.EnumStr;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
@Slf4j
@Api(value = "DeviceController",description = "设备管理")
@RequestMapping(value = "/data/api-d/device")
@RestController
public class DeviceController {
 
    @Autowired
    private DeviceService deviceService;
 
    @RequestMapping("/getDeviceType")
    @ApiOperation(value = "获取设备类型", notes = "获取设备类型", httpMethod = "POST",produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    public Result getDeviceType(){
        return deviceService.getDeviceType();
    }
 
    @GetMapping("/getDeviceBrand")
    @ApiOperation(value = "获取设备品牌", notes = "获取设备品牌", httpMethod = "GET", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    public Result getDeviceBrand(){
        return deviceService.getDeviceBrand();
    }
 
    @GetMapping("/getStatus")
    @ApiOperation(value = "获取设备状态字典列表", notes = "获取设备状态字典列表", httpMethod = "GET", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    public Result getStatusList(){
        return deviceService.getStatusList();
    }
 
    @ApiOperation(value="获取设备组织机构树", notes = "获取设备组织机构",httpMethod = "GET",produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", value = "无用参数", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "名称,模糊查询", required = false, dataType = "String", paramType = "query")
    })
    @RequestMapping("/getOrgDeviceTree")
    public List getOrgDeviceTree(@RequestParam Map<String,Object> param){
 
        return deviceService.getOrgDeviceTree(param);
    }
 
    @ApiOperation(value = "获取所有设备", notes = "获取所有设备", httpMethod = "GET", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @GetMapping("/findAllDevices")
    public Result findAllDevices(){
        return deviceService.findAllDevices();
    }
 
    @ApiOperation(value = "获取所有设备树(不分集群和非集群)", notes = "获取所有设备树(不分集群和非集群)", httpMethod = "GET", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", value = "无用参数", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "condition", value = "设备名称/设备地址", required = false, dataType = "String", paramType = "query")
    })
    @GetMapping("/findByArea")
    public Result findByArea(@RequestParam Map<String, Object> param){
        return deviceService.findByArea(param);
    }
 
    @ApiOperation(value = "通过区域查找设备", notes = "通过区域查找设备", httpMethod = "GET", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", value = "无用参数", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "condition", value = "设备名称/设备位置", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "orgId", value = "组织机构id", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "类型(MENU或其它)", required = true, dataType = "String", paramType = "query")
    })
    @GetMapping("/findAllDeviceByArea")
    public Result findAllDeviceByArea(@RequestParam Map<String, Object> param){
        return deviceService.findAllDeviceByArea(param);
    }
 
    @GetMapping("/findPlatDeviceList")
    @ApiOperation(value = "获取平台设备列表",notes = "获取平台设备列表",httpMethod = "GET", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name ="param", value = "无用参数", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "orgId", value = "组织机构id", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name ="condition", value = "设备名称/设备id/设备位置", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "类型(MENU或其它)", required = true, dataType = "String", paramType = "query")
    })
    public Result findPlatDeviceList(@RequestParam Map<String,Object> param){
        return deviceService.findAllPlatDeviceList(param);
    }
 
 
    @RequestMapping("/getDeviceById")
    @ApiOperation(value = "通过id查找设备", notes = "通过id查找设备", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "设备id", required = true, dataType = "String",paramType = "query")
    })
    public Result getDeviceById(@RequestParam String id){
        return deviceService.getDeviceById(id);
    }
 
}