|
@ -1,9 +1,7 @@
|
1
|
1
|
package com.ai.ipu.server.controller;
|
2
|
2
|
|
3
|
|
import com.ai.ipu.data.JMap;
|
4
|
|
import com.ai.ipu.data.impl.JsonMap;
|
5
|
|
import com.ai.ipu.server.service.interfaces.DeviceManageService;
|
6
|
|
import com.github.pagehelper.PageInfo;
|
|
3
|
import java.util.Map;
|
|
4
|
|
7
|
5
|
import org.slf4j.Logger;
|
8
|
6
|
import org.slf4j.LoggerFactory;
|
9
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -11,115 +9,168 @@ import org.springframework.stereotype.Controller;
|
11
|
9
|
import org.springframework.web.bind.annotation.RequestMapping;
|
12
|
10
|
import org.springframework.web.bind.annotation.ResponseBody;
|
13
|
11
|
|
|
12
|
import com.ai.ipu.data.JMap;
|
|
13
|
import com.ai.ipu.data.impl.JsonMap;
|
|
14
|
import com.ai.ipu.server.service.interfaces.DeviceManageService;
|
|
15
|
import com.github.pagehelper.PageInfo;
|
|
16
|
|
14
|
17
|
/**
|
15
|
18
|
* 终端管理
|
16
|
19
|
*/
|
17
|
20
|
@Controller
|
18
|
21
|
@RequestMapping("/device")
|
19
|
22
|
public class DeviceManageController {
|
|
23
|
Logger logger = LoggerFactory.getLogger(DeviceManageController.class);
|
|
24
|
|
|
25
|
@Autowired
|
|
26
|
DeviceManageService deviceManageService;
|
|
27
|
|
|
28
|
/**
|
|
29
|
* 分页查询终端信息
|
|
30
|
*/
|
|
31
|
@ResponseBody
|
|
32
|
@RequestMapping("/queryDeviceInfo")
|
|
33
|
public JMap queryDeviceInfo(JMap params) throws Exception {
|
|
34
|
Map<String,String> params1 = (Map<String, String>) params.get("params"); // 参数
|
|
35
|
|
|
36
|
PageInfo deviceList = deviceManageService.queryDeviceInfo(params);
|
|
37
|
JMap result = new JsonMap();
|
|
38
|
result.put("result", deviceList);
|
|
39
|
return result;
|
|
40
|
}
|
|
41
|
|
|
42
|
/**
|
|
43
|
* 添加终端信息
|
|
44
|
*/
|
|
45
|
@ResponseBody
|
|
46
|
@RequestMapping("/addDeviceInfo")
|
|
47
|
public JMap addDeviceInfo(JMap params) throws Exception {
|
|
48
|
JMap params1 = params.getJMap("params"); // 参数
|
|
49
|
JMap result = new JsonMap(); // 返回值
|
|
50
|
try {
|
|
51
|
Map<String, String> resultMap = deviceManageService.addDeviceInfo(params1);
|
|
52
|
if ("0".equals(resultMap.get("resultCode"))) {
|
|
53
|
result.put("result", true);
|
|
54
|
} else {
|
|
55
|
result.put("result", false);
|
|
56
|
result.put("errMsg", "添加失败:" + resultMap.get("resultMsg"));
|
|
57
|
}
|
|
58
|
} catch (Exception e) {
|
|
59
|
logger.error("添加失败,原因为:" + e.getMessage());
|
|
60
|
result.put("result", false);
|
|
61
|
result.put("errMsg", "添加失败");
|
|
62
|
}
|
|
63
|
|
|
64
|
return result;
|
|
65
|
}
|
|
66
|
|
|
67
|
/**
|
|
68
|
* 修改终端信息
|
|
69
|
*/
|
|
70
|
@ResponseBody
|
|
71
|
@RequestMapping("/modifyDeviceInfo")
|
|
72
|
public JMap modifyDeviceInfo(JMap params) throws Exception {
|
|
73
|
JMap params1 = params.getJMap("params"); // 参数
|
|
74
|
JMap result = new JsonMap(); // 返回值
|
|
75
|
try {
|
|
76
|
Map<String, String> resultMap = deviceManageService.modifyDeviceInfo(params1);
|
|
77
|
if ("0".equals(resultMap.get("resultCode"))) {
|
|
78
|
result.put("result", true);
|
|
79
|
} else {
|
|
80
|
result.put("result", false);
|
|
81
|
result.put("errMsg", "修改失败:" + resultMap.get("resultMsg"));
|
|
82
|
}
|
|
83
|
} catch (Exception e) {
|
|
84
|
logger.error("异常,原因为:" + e.getMessage());
|
|
85
|
result.put("result", false);
|
|
86
|
result.put("errMsg", "修改失败");
|
|
87
|
}
|
|
88
|
|
|
89
|
return result;
|
|
90
|
}
|
|
91
|
|
|
92
|
/**
|
|
93
|
* 删除终端信息
|
|
94
|
*/
|
|
95
|
@ResponseBody
|
|
96
|
@RequestMapping("/deleteDeviceInfo")
|
|
97
|
public JMap deleteDeviceInfo(JMap params) throws Exception {
|
|
98
|
JMap params1 = params.getJMap("params"); // 参数
|
|
99
|
JMap result = new JsonMap(); // 返回值
|
|
100
|
try {
|
|
101
|
if (params1.get("deviceId") != null && !"".equals(params1.get("deviceId"))) {
|
|
102
|
Map<String, String> resultMap = deviceManageService.deleteDeviceInfo(params1);
|
|
103
|
|
|
104
|
if ("0".equals(resultMap.get("resultCode"))) {
|
|
105
|
result.put("result", true);
|
|
106
|
} else {
|
|
107
|
result.put("result", false);
|
|
108
|
result.put("errMsg", resultMap.get("resultMsg"));
|
|
109
|
}
|
|
110
|
} else {
|
|
111
|
result.put("result", false);
|
|
112
|
result.put("errMsg", "删除失败:终端为空");
|
|
113
|
}
|
|
114
|
|
|
115
|
} catch (Exception e) {
|
|
116
|
logger.error("异常,原因为:" + e.getMessage());
|
|
117
|
result.put("result", false);
|
|
118
|
result.put("errMsg", "删除失败");
|
|
119
|
}
|
|
120
|
|
|
121
|
return result;
|
|
122
|
}
|
|
123
|
|
|
124
|
/**
|
|
125
|
* 关联终端
|
|
126
|
*/
|
|
127
|
@ResponseBody
|
|
128
|
@RequestMapping("/bindDevice")
|
|
129
|
public JMap bindDevice(JMap params) throws Exception {
|
|
130
|
JMap result = new JsonMap(); // 返回值
|
|
131
|
if (params.get("deviceId") != null && "".equals(params.get("deviceId"))) {
|
|
132
|
boolean flag = false;
|
|
133
|
flag = deviceManageService.bindDevice(params);
|
|
134
|
result.put("result", flag);
|
|
135
|
} else {
|
|
136
|
logger.error("关联终端失败:设备id为空");
|
|
137
|
result.put("result", false);
|
|
138
|
result.put("errMsg", "关联终端失败");
|
|
139
|
}
|
|
140
|
return result;
|
|
141
|
}
|
|
142
|
|
|
143
|
/**
|
|
144
|
* 解绑终端
|
|
145
|
*/
|
|
146
|
@ResponseBody
|
|
147
|
@RequestMapping("/unbindDevice")
|
|
148
|
public JMap unbindDevice(JMap params) throws Exception {
|
|
149
|
JMap result = new JsonMap(); // 返回值
|
|
150
|
boolean flag = false;
|
|
151
|
if (params.get("deviceId") != null && "".equals(params.get("deviceId"))) {
|
|
152
|
flag = deviceManageService.unbindDevice(params);
|
|
153
|
} else {
|
|
154
|
logger.error("解绑终端失败:设备id为空");
|
|
155
|
result.put("result", false);
|
|
156
|
result.put("errMsg", "解绑终端失败");
|
|
157
|
}
|
|
158
|
result.put("result", flag);
|
|
159
|
return result;
|
|
160
|
}
|
20
|
161
|
|
21
|
|
@Autowired
|
22
|
|
DeviceManageService deviceManageService;
|
23
|
|
|
24
|
|
Logger logger = LoggerFactory.getLogger(DeviceManageController.class);
|
25
|
|
/**
|
26
|
|
* 查询终端信息
|
27
|
|
*/
|
28
|
|
@ResponseBody
|
29
|
|
@RequestMapping("/queryDeviceInfo")
|
30
|
|
public JMap queryDeviceInfo(JMap params) throws Exception {
|
31
|
|
|
32
|
|
PageInfo deviceList= deviceManageService.queryDeviceInfo(params);
|
33
|
|
JMap result = new JsonMap();
|
34
|
|
result.put("result", deviceList);
|
35
|
|
return result;
|
36
|
|
}
|
37
|
|
|
38
|
|
|
39
|
|
/**
|
40
|
|
* 编辑终端信息、增加终端信息
|
41
|
|
*/
|
42
|
|
@ResponseBody
|
43
|
|
@RequestMapping("/modifyDeviceInfo")
|
44
|
|
public JMap modifyDeviceInfo(JMap params) throws Exception {
|
45
|
|
int num=0;
|
46
|
|
//取值判断如果有当前id则为修改,否则为新增
|
47
|
|
JMap params1 = params.getJMap("params");
|
48
|
|
try{
|
49
|
|
if(params1.getInt("MAP_TAG_ID")!=0){
|
50
|
|
num= deviceManageService.modifyDeviceInfo(params1);
|
51
|
|
}else{
|
52
|
|
num= deviceManageService.addDeviceInfo(params1);
|
53
|
|
}
|
54
|
|
}catch(Exception e){
|
55
|
|
logger.error("异常,原因为:" + e.getMessage());
|
56
|
|
}
|
57
|
|
JMap result = new JsonMap();
|
58
|
|
if(num>0){
|
59
|
|
result.put("result", true);
|
60
|
|
}else{
|
61
|
|
result.put("result", false);
|
62
|
|
}
|
63
|
|
return result;
|
64
|
|
}
|
65
|
|
|
66
|
|
/**
|
67
|
|
* 刪除终端管理
|
68
|
|
*
|
69
|
|
*/
|
70
|
|
@ResponseBody
|
71
|
|
@RequestMapping("/deleteDeviceInfo")
|
72
|
|
public JMap deleteDeviceInfo(JMap params) throws Exception {
|
73
|
|
boolean flag=false;
|
74
|
|
if(params.getInt("MAP_TAG_ID")!=0){
|
75
|
|
flag= deviceManageService.deleteDeviceXyInfo(params);
|
76
|
|
}
|
77
|
|
JMap result = new JsonMap();
|
78
|
|
result.put("result", flag);
|
79
|
|
return result;
|
80
|
|
}
|
81
|
|
/**
|
82
|
|
* 导入终端信息
|
83
|
|
*/
|
84
|
|
@ResponseBody
|
85
|
|
@RequestMapping("/importDeviceInfo")
|
86
|
|
public JMap importDeviceInfo(JMap params) throws Exception {
|
87
|
|
boolean flag=false;
|
88
|
|
if(params.getInt("MAP_TAG_ID")!=0){
|
89
|
|
//flag= userManageService.importUserInfo(params);
|
90
|
|
}
|
91
|
|
JMap result = new JsonMap();
|
92
|
|
result.put("result", flag);
|
93
|
|
return result;
|
94
|
|
}
|
95
|
|
|
96
|
|
/**
|
97
|
|
* 关联用户
|
98
|
|
*/
|
99
|
|
@ResponseBody
|
100
|
|
@RequestMapping("/associatUser")
|
101
|
|
public JMap associatUser(JMap params) throws Exception {
|
102
|
|
boolean flag=false;
|
103
|
|
if(params.getInt("MAP_TAG_ID")!=0){
|
104
|
|
//flag= userManageService.associatTerminal(params);
|
105
|
|
}
|
106
|
|
JMap result = new JsonMap();
|
107
|
|
result.put("result", flag);
|
108
|
|
return result;
|
109
|
|
}
|
110
|
|
|
111
|
|
/**
|
112
|
|
* 解绑用户
|
113
|
|
*/
|
114
|
|
@ResponseBody
|
115
|
|
@RequestMapping("/unbundUser")
|
116
|
|
public JMap unbundUser(JMap params) throws Exception {
|
117
|
|
boolean flag=false;
|
118
|
|
if(params.getInt("MAP_TAG_ID")!=0){
|
119
|
|
//flag= userManageService.unbundTerminal(params);
|
120
|
|
}
|
121
|
|
JMap result = new JsonMap();
|
122
|
|
result.put("result", flag);
|
123
|
|
return result;
|
124
|
|
}
|
|
162
|
/**
|
|
163
|
* 导入终端信息
|
|
164
|
*/
|
|
165
|
@ResponseBody
|
|
166
|
@RequestMapping("/importDeviceInfo")
|
|
167
|
public JMap importDeviceInfo(JMap params) throws Exception {
|
|
168
|
boolean flag = false;
|
|
169
|
if (params.getInt("MAP_TAG_ID") != 0) {
|
|
170
|
// flag= userManageService.importUserInfo(params);
|
|
171
|
}
|
|
172
|
JMap result = new JsonMap();
|
|
173
|
result.put("result", flag);
|
|
174
|
return result;
|
|
175
|
}
|
125
|
176
|
}
|