Explorar el Código

终端管理重构

konghl %!s(int64=4) %!d(string=hace) años
padre
commit
58511cb6d2

+ 118 - 69
location-rescue-service/src/main/java/com/ai/bss/location/rescue/controller/DeviceManageController.java

@ -44,7 +44,9 @@ public class DeviceManageController {
44 44
		// 每页条数
45 45
		int pageSize = request.getPageSize() < 1 ? EbcConstant.DEFAULT_PAGE_SIZE : request.getPageSize();
46 46
47
		Map<String, Object> result = deviceManageService.queryPageDeviceInfo(request.getData(), pageNumber, pageSize);
47
		Map<String, String> params = request.getData() == null ? new HashMap<String, String>() : request.getData();
48
49
		Map<String, Object> result = deviceManageService.queryPageDeviceInfo(params, pageNumber, pageSize);
48 50
49 51
		return result;
50 52
	}
@ -73,10 +75,10 @@ public class DeviceManageController {
73 75
	 */
74 76
	@ResponseBody
75 77
	@RequestMapping("/queryOneDeviceInfo")
76
	public Map<String, Object> queryOneDeviceInfo(Map<String, String> params) throws Exception {
78
	public Map<String, Object> queryOneDeviceInfo(@RequestBody Map<String, String> params) throws Exception {
77 79
		Map<String, Object> result = new HashMap<String, Object>();
78 80
79
		if (params == null || params.get("deviceId") == null) {
81
		if (params == null || params.get("deviceId") == null||"".equals(params.get("deviceId"))) {
80 82
			result.put("result", false);
81 83
			result.put("errMsg", "操作失败");
82 84
			return result;
@ -84,6 +86,7 @@ public class DeviceManageController {
84 86
85 87
		Map<String, Object> resultMap = deviceManageService.queryOneDeviceInfo(params);
86 88
		result.put("resultData", resultMap);
89
		result.put("result", true);
87 90
		return result;
88 91
	}
89 92
@ -96,18 +99,18 @@ public class DeviceManageController {
96 99
	 */
97 100
	@ResponseBody
98 101
	@RequestMapping("/addDeviceInfo")
99
	public Map<String, Object> addDeviceInfo(Map<String, String> params) throws Exception {
102
	public Map<String, Object> addDeviceInfo(@RequestBody Map<String, String> params) throws Exception {
100 103
		Map<String, Object> result = new HashMap<String, Object>();
101 104
102
		if (params == null || params.get("deviceNo") == null) {
105
		if (params == null || params.get("deviceNo") == null||"".equals(params.get("deviceId"))) {
103 106
			result.put("result", false);
104 107
			result.put("errMsg", "添加失败");
105 108
			return result;
106 109
		}
107 110
108
		Map<String, String> resultMap = deviceManageService.addDeviceInfo(params);
111
		Map<String, Object> resultMap = deviceManageService.addDeviceInfo(params);
109 112
110
		if (NorthboundInterfaceConstant.resultCode_succeed.equals(resultMap.get("resultCode"))) {
113
		if (NorthboundInterfaceConstant.resultCode_succeed.equals(String.valueOf(resultMap.get("resultCode")))) {
111 114
			result.put("result", true);
112 115
		} else {
113 116
			result.put("result", false);
@ -126,18 +129,18 @@ public class DeviceManageController {
126 129
	 */
127 130
	@ResponseBody
128 131
	@RequestMapping("/modifyDeviceInfo")
129
	public Map<String, Object> modifyDeviceInfo(Map<String, String> params) throws Exception {
132
	public Map<String, Object> modifyDeviceInfo(@RequestBody Map<String, String> params) throws Exception {
130 133
		Map<String, Object> result = new HashMap<String, Object>();
131 134
132
		if (params == null || params.get("deviceId") == null) {
135
		if (params == null || params.get("deviceId") == null||"".equals(params.get("deviceId"))) {
133 136
			result.put("result", false);
134 137
			result.put("errMsg", "修改失败");
135 138
			return result;
136 139
		}
137 140
138
		Map<String, String> resultMap = deviceManageService.modifyDeviceInfo(params);
141
		Map<String, Object> resultMap = deviceManageService.modifyDeviceInfo(params);
139 142
140
		if (NorthboundInterfaceConstant.resultCode_succeed.equals(resultMap.get("resultCode"))) {
143
		if (NorthboundInterfaceConstant.resultCode_succeed.equals(String.valueOf(resultMap.get("resultCode")))) {
141 144
			result.put("result", true);
142 145
		} else {
143 146
			result.put("result", false);
@ -156,18 +159,19 @@ public class DeviceManageController {
156 159
	 */
157 160
	@ResponseBody
158 161
	@RequestMapping("/deleteDeviceInfo")
159
	public Map<String, Object> deleteDeviceInfo(Map<String, String> params) throws Exception {
162
	public Map<String, Object> deleteDeviceInfo(@RequestBody Map<String, String> params) throws Exception {
160 163
		Map<String, Object> result = new HashMap<String, Object>();
161 164
162
		if (params == null || params.get("deviceId") == null) {
165
		if (params == null || params.get("deviceId") == null||"".equals(params.get("deviceId"))) {
163 166
			result.put("result", false);
164 167
			result.put("errMsg", "删除失败");
165 168
			return result;
166 169
		}
167 170
168
		Map<String, String> resultMap = deviceManageService.deleteDeviceInfo(params);
171
		Map<String, Object> resultMap = deviceManageService.deleteDeviceInfo(params);
169 172
170
		if (NorthboundInterfaceConstant.resultCode_succeed.equals(resultMap.get("resultCode"))) {
173
		if (resultMap != null
174
				&& NorthboundInterfaceConstant.resultCode_succeed.equals(String.valueOf(resultMap.get("resultCode")))) {
171 175
			result.put("result", true);
172 176
		} else {
173 177
			result.put("result", false);
@ -178,79 +182,124 @@ public class DeviceManageController {
178 182
	}
179 183
180 184
	/**
181
	 * 获取下拉列表的终端信息
182
	 * 
185
	 * 查询已绑定关系信息
183 186
	 * @param params
184 187
	 * @return
185 188
	 * @throws Exception
186 189
	 */
187
	/*
188 190
	@ResponseBody
189
	@RequestMapping("/queryListDeviceInfo")
190
	public Map<String, Object> queryListDeviceInfo(Map<String, Object> params) throws Exception {
191
	Map<String, Object> result = new HashMap<String, Object>();
192
	
193
	// 当前页数
194
	int pageNum = 1;
195
	// 每页条数
196
	int pageSize = EbcConstant.COMBOBOX_MAXNUM;
191
	@RequestMapping("/queryBindDeviceInfo")
192
	public Map<String, Object> queryBindDeviceInfo(@RequestBody Map<String, String> params) throws Exception {
193
		Map<String, Object> result = new HashMap<String, Object>();
194
195
		if (params == null || params.get("deviceId") == null||"".equals(params.get("deviceId"))) {
196
			result.put("result", false);
197
			result.put("errMsg", "获取绑定关系失败");
198
			return result;
199
		}
200
201
		Map<String, Object> resultMap  = deviceManageService.queryBindDeviceInfo(params);
202
203
		result.put("resultData", resultMap);
204
		result.put("result", true);
205
		return result;
206
	}
197 207
	
198
	List<Map<String, String>> resultList = deviceManageService.queryListDeviceInfo(params, pageNum, pageSize);
199
	result.put("dataList", resultList);
200
	return result;
208
	/**
209
	 *  关联列表信息查询
210
	 * @param params
211
	 * @return
212
	 * @throws Exception
213
	 */
214
	@ResponseBody
215
	@RequestMapping("/queryAssociatInfo")
216
	public Map<String, Object> queryAssociatInfo(@RequestBody Map<String, String> params) throws Exception {
217
		List<Map<String, Object>> userList = deviceManageService.queryAssociatInfo(params);
218
		Map<String, Object> result = new HashMap<String, Object>();
219
		result.put("result", userList);
220
		return result;
201 221
	}
202 222
	
203
	*//**
204
		* 关联终端(关联用户或者船舶的保存功能)
205
		*
206
		*/
207
	/*
223
	/**
224
	 * 关联终端(关联用户或者船舶的保存功能)
225
	 * @param params
226
	 * @return
227
	 * @throws Exception
228
	 */
208 229
	@ResponseBody
209 230
	@RequestMapping("/bindDevice")
210
	public Map<String, Object> bindDevice(Map<String, Object> params) throws Exception {
211
	Map<String, Object> result = new HashMap<String, Object>(); // 返回值
212
	if (params.get("DEVICE_ID") != null && !"".equals(params.get("DEVICE_ID"))) {
213
		boolean flag = false;
214
		flag = deviceManageService.bindDevice(params);
215
		result.put("result", flag);
216
	} else {
217
		logger.error("关联终端失败:设备id为空");
218
		result.put("result", false);
219
		result.put("errMsg", "关联终端失败");
220
	}
221
	return result;
231
	public Map<String, Object> bindDevice(@RequestBody Map<String, String> params) throws Exception {
232
		Map<String, Object> result = new HashMap<String, Object>();
233
234
		if (params == null || params.get("deviceId") == null||"".equals(params.get("deviceId"))) {
235
			result.put("result", false);
236
			result.put("errMsg", "关联终端失败");
237
			return result;
238
		}
239
240
		boolean resultFlag = deviceManageService.bindDevice(params);
241
242
		if (resultFlag) {
243
			result.put("result", true);
244
		} else {
245
			result.put("result", false);
246
			result.put("errMsg", "关联终端失败");
247
		}
248
249
		return result;
222 250
	}
223 251
	
224
	*//**
225
		* 解绑终端
226
		*/
227
	/*
252
	/**
253
	 * 解绑终端
254
	 * @param params
255
	 * @return
256
	 * @throws Exception
257
	 */
228 258
	@ResponseBody
229 259
	@RequestMapping("/unbindDevice")
230
	public Map<String, Object> unbindDevice(Map<String, Object> params) throws Exception {
231
	Map<String, Object> result = new HashMap<String, Object>(); // 返回值
232
	boolean flag = false;
233
	if (params.get("DEVICE_ID") != null && !"".equals(params.get("DEVICE_ID"))) {
234
		flag = deviceManageService.unbindDevice(params);
235
	} else {
236
		logger.error("解绑终端失败:设备id为空");
237
		result.put("result", false);
238
		result.put("errMsg", "解绑终端失败");
239
	}
240
	result.put("result", flag);
241
	return result;
260
	public Map<String, Object> unbindDevice(@RequestBody Map<String, String> params) throws Exception {
261
		Map<String, Object> result = new HashMap<String, Object>();
262
263
		if (params == null || params.get("deviceId") == null||"".equals(params.get("deviceId"))) {
264
			result.put("result", false);
265
			result.put("errMsg", "关联终端失败");
266
			return result;
267
		}
268
269
		boolean resultFlag = deviceManageService.unbindDevice(params);
270
271
		if (resultFlag) {
272
			result.put("result", true);
273
		} else {
274
			result.put("result", false);
275
			result.put("errMsg", "关联终端失败");
276
		}
277
278
		return result;
242 279
	}
280
243 281
	
244
	*//**
245
		* 关联列表信息查询
246
		*/
282
283
	/**
284
	 * 获取下拉列表的终端信息
285
	 * 
286
	 * @param params
287
	 * @return
288
	 * @throws Exception
289
	 */
247 290
	/*
248 291
	@ResponseBody
249
	@RequestMapping("/queryAssociatInfo")
250
	public Map<String, Object> queryAssociatInfo(Map<String, Object> params) throws Exception {
251
	List<Map<String, Object>> userList = deviceManageService.queryAssociatInfo(params);
292
	@RequestMapping("/queryListDeviceInfo")
293
	public Map<String, Object> queryListDeviceInfo(Map<String, Object> params) throws Exception {
252 294
	Map<String, Object> result = new HashMap<String, Object>();
253
	result.put("result", userList);
295
	
296
	// 当前页数
297
	int pageNum = 1;
298
	// 每页条数
299
	int pageSize = EbcConstant.COMBOBOX_MAXNUM;
300
	
301
	List<Map<String, String>> resultList = deviceManageService.queryListDeviceInfo(params, pageNum, pageSize);
302
	result.put("dataList", resultList);
254 303
	return result;
255 304
	}
256 305
	

+ 166 - 51
location-rescue-service/src/main/java/com/ai/bss/location/rescue/service/impl/DeviceManageServiceImpl.java

@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
10 10
import org.springframework.beans.factory.annotation.Autowired;
11 11
import org.springframework.stereotype.Service;
12 12
13
import com.ai.abc.api.model.CommonRequest;
13 14
import com.ai.abc.api.model.CommonResponse;
14 15
import com.ai.bss.characteristic.spec.model.CharacteristicSpec;
15 16
import com.ai.bss.characteristic.spec.model.CharacteristicSpecValue;
@ -19,13 +20,18 @@ import com.ai.bss.location.rescue.service.interfaces.DeviceManageService;
19 20
import com.ai.bss.location.rescue.util.EbcConstant;
20 21
import com.ai.bss.location.rescue.util.NorthboundInterfaceConstant;
21 22
import com.ai.bss.location.rescue.util.NorthboundInterfaceUtil;
23
import com.ai.bss.work.tool.model.ResourceToolTerminalRel;
24
import com.ai.bss.work.tool.service.api.ResourceToolCommand;
22 25
import com.ai.bss.work.tool.service.api.ResourceToolQuery;
26
import com.ai.bss.worker.model.EmployeeTerminalRela;
23 27
import com.ai.bss.worker.model.EmployeeTerminalRelaDto;
24 28
import com.ai.bss.worker.service.api.EmployeeTerminalRelaCommand;
25 29
import com.ai.bss.worker.service.api.EmployeeTerminalRelaQuery;
26 30
import com.alibaba.fastjson.JSON;
27 31
import com.alibaba.fastjson.JSONObject;
28 32
33
import antlr.debug.NewLineEvent;
34
29 35
@Service
30 36
public class DeviceManageServiceImpl implements DeviceManageService {
31 37
	Logger logger = LoggerFactory.getLogger(DeviceManageServiceImpl.class);
@ -45,6 +51,9 @@ public class DeviceManageServiceImpl implements DeviceManageService {
45 51
	@Autowired
46 52
	NorthboundInterfaceUtil northboundInterfaceUtil;
47 53
54
	@Autowired
55
	ResourceToolCommand resourceToolCommand;
56
48 57
	@Override
49 58
	public Map<String, Object> queryPageDeviceInfo(Map<String, String> params, int pageNumber, int pageSize)
50 59
			throws Exception {
@ -59,19 +68,19 @@ public class DeviceManageServiceImpl implements DeviceManageService {
59 68
		Map<String, Object> paramsMap = new HashMap<String, Object>();
60 69
61 70
		// 终端编号
62
		if (null != params.get("deviceNo") &&!"".equals(params.get("deviceNo"))) {
71
		if (null != params.get("deviceNo") && !"".equals(params.get("deviceNo"))) {
63 72
			paramsMap.put("terminalSN", params.get("deviceNo"));
64 73
		}
65 74
66 75
		// 终端类型
76
		List<CharacteristicSpecValue> characteristicSpecValueList = queryDeviceTypeList();
67 77
		if (null == params.get("deviceTypeId") || "".equals(params.get("deviceTypeId"))) {
68
			List<CharacteristicSpecValue> characteristicSpecValueList = queryDeviceTypeList();
69 78
			List<String> specIds = new ArrayList<String>();
70 79
			for (CharacteristicSpecValue characteristicSpecValue : characteristicSpecValueList) {
71 80
				specIds.add(characteristicSpecValue.getCode());
72 81
			}
73 82
			paramsMap.put("specId", specIds);
74
		}else {
83
		} else {
75 84
			paramsMap.put("specId", params.get("deviceTypeId"));
76 85
		}
77 86
@ -114,38 +123,50 @@ public class DeviceManageServiceImpl implements DeviceManageService {
114 123
115 124
		// 调用北向接口
116 125
		String url = NorthboundInterfaceConstant.queryPageDevice;
117
		Map<String, String> deviceInfoListMap = northboundInterfaceUtil.iotPostCallUtil(url, dataMap);
126
		Map<String, Object> deviceInfoListMap = northboundInterfaceUtil.iotPostCallUtil(url, dataMap);
118 127
		List<Map> deviceInfoList = JSON.parseArray(JSON.toJSONString(deviceInfoListMap.get("result")), Map.class);
119 128
120 129
		// 整理返回数据信息
121 130
		List<Map> resultList = new ArrayList<Map>();
122 131
		if (deviceInfoList != null && deviceInfoList.size() > 0) {
123
			for (Map map : deviceInfoList) {
132
			for (Map deviceInfoMap : deviceInfoList) {
124 133
				Map resultMap = new HashMap();
125 134
126 135
				// 终端编号
127
				String deviceId = String.valueOf(map.get("resourceId"));
136
				String deviceId = String.valueOf(deviceInfoMap.get("resourceId"));
128 137
				resultMap.put("deviceId", deviceId);
129 138
				resultMap.put("deviceNo", deviceId);
130 139
131 140
				// 备注
132
				String remarks = String.valueOf(map.get("remarks"));
141
				String remarks = String.valueOf(deviceInfoMap.get("remarks"));
133 142
				remarks = (remarks == null || "".equals(remarks) || "null".equals(remarks)) ? "无" : remarks;
134 143
				resultMap.put("remarks", remarks);
135 144
145
				// 终端类型
146
				String deviceType = String.valueOf(deviceInfoMap.get("specId"));
147
				for (CharacteristicSpecValue characteristicSpecValue : characteristicSpecValueList) {
148
					if (deviceType.equals(characteristicSpecValue.getCode())) {
149
						resultMap.put("deviceTypeId", deviceType);
150
						resultMap.put("deviceTypeName", characteristicSpecValue.getValue());
151
						break;
152
					}
153
				}
154
136 155
				// 绑定信息
137 156
				resultMap.put("bindName", "--");
157
				boolean bindFlag = true;
138 158
				if (!unBindDeviceBoolean) {
139 159
					if (bindToolInfoList != null) {
140
						for (Map<String, Object> bindToolInfoMap : bindToolInfoList) {
160
						for (int i = 0; i < bindToolInfoList.size() && bindFlag; i++) {
161
							Map<String, Object> bindToolInfoMap = bindToolInfoList.get(i);
141 162
							if (deviceId.equals(String.valueOf(bindToolInfoMap.get("terminalId")))) {
142 163
								resultMap.put("bindCode", bindToolInfoMap.get("resourceToolCode"));
143 164
								resultMap.put("bindName", bindToolInfoMap.get("resourceToolName"));
144
								break;
165
								bindFlag = false;
145 166
							}
146 167
						}
147 168
					}
148
					if (bindEmployeeInfoList != null) {
169
					if (bindEmployeeInfoList != null && bindFlag) {
149 170
						for (EmployeeTerminalRelaDto employeeTerminalRelaDto : bindEmployeeInfoList) {
150 171
							if (deviceId.equals(employeeTerminalRelaDto.getTerminalId())) {
151 172
								resultMap.put("bindCode", employeeTerminalRelaDto.getCode());
@ -168,86 +189,180 @@ public class DeviceManageServiceImpl implements DeviceManageService {
168 189
	}
169 190
170 191
	public List<CharacteristicSpecValue> queryDeviceTypeList() {
171
		CharacteristicSpec characteristicSpec = this.characteristicSpecService
192
		CharacteristicSpec characteristicSpec = characteristicSpecService
172 193
				.findBusinessSpecByCharSpecCode(EbcConstant.BUSINESS_SPEC_PRODUCT_TYPE);
194
		if (characteristicSpec == null) {
195
			return new ArrayList<CharacteristicSpecValue>();
196
		}
197
173 198
		List<CharacteristicSpecValue> resultList = characteristicSpec.getCharacteristicSpecValues();
174 199
		return resultList;
175 200
	}
176 201
177
	
178 202
	@Override
179 203
	public Map<String, Object> queryOneDeviceInfo(Map<String, String> params) throws Exception {
180
		//调用北向接口
181
		String url = NorthboundInterfaceConstant.queryOneDevice+ params.get("deviceId");
182
		Map<String, String> deviceInfoMap = northboundInterfaceUtil.iotGetCallUtil(url);
183
		Map resultMap = JSONObject.parseObject(deviceInfoMap.get("result"), Map.class);
184
		String remarks = deviceInfoMap.get("remarks") == null ? "" : deviceInfoMap.get("remarks");
185
		resultMap.put("remarks", remarks);
204
		// 调用北向接口
205
		String url = NorthboundInterfaceConstant.queryOneDevice + params.get("deviceId");
206
		Map<String, Object> deviceInfoMap = northboundInterfaceUtil.iotGetCallUtil(url);
207
208
		JSONObject deviceInfoJson = (JSONObject) deviceInfoMap.get("result");
209
210
		if (deviceInfoJson == null) {
211
			return new HashMap<String, Object>();
212
		}
213
214
		Map<String, Object> resultMap = new HashMap<String, Object>();
215
		resultMap.put("deviceId", deviceInfoJson.get("deviceId"));
216
		resultMap.put("deviceNo", deviceInfoJson.get("deviceId"));
217
		resultMap.put("remarks", deviceInfoJson.get("remarks"));
218
219
		// 终端类型
220
		List<CharacteristicSpecValue> characteristicSpecValueList = queryDeviceTypeList();
221
		for (CharacteristicSpecValue characteristicSpecValue : characteristicSpecValueList) {
222
			if (deviceInfoJson.get("productId").equals(characteristicSpecValue.getCode())) {
223
				resultMap.put("deviceTypeId", deviceInfoJson.get("productId"));
224
				resultMap.put("deviceTypeName", characteristicSpecValue.getValue());
225
				break;
226
			}
227
		}
228
186 229
		return resultMap;
187 230
	}
188
	
189 231
190 232
	@Override
191
	public Map<String, String> addDeviceInfo(Map<String, String> params) throws Exception {
233
	public Map<String, Object> addDeviceInfo(Map<String, String> params) throws Exception {
192 234
		Map<String, Object> paramsMap = new HashMap<String, Object>();
193 235
		String deviceId = params.get("deviceNo");
194 236
195 237
		paramsMap.put("deviceId", deviceId);// 终端id
196 238
		paramsMap.put("terminalSN", deviceId); // 终端编号
197 239
		paramsMap.put("productId", params.get("deviceTypeId")); // 终端类型
198
		paramsMap.put("deviceName", EbcConstant.BEIDOUDEVICE_NAME+params.get("deviceTypeName") + deviceId); // 名称
240
		paramsMap.put("deviceName", EbcConstant.BEIDOUDEVICE_NAME + params.get("deviceTypeName") + deviceId); // 名称
199 241
		paramsMap.put("remarks", params.get("remarks")); // 备注
200 242
201 243
		// 调用北向接口
202 244
		String url = NorthboundInterfaceConstant.addDevice;
203
		Map<String, String> map = northboundInterfaceUtil.iotPostCallUtil(url, paramsMap);
204
		return map;
245
		Map<String, Object> resultMap = northboundInterfaceUtil.iotPostCallUtil(url, paramsMap);
246
		return resultMap;
205 247
	}
206
	
207 248
208 249
	@Override
209
	public Map<String, String> modifyDeviceInfo(Map<String, String> params) throws Exception {
250
	public Map<String, Object> modifyDeviceInfo(Map<String, String> params) throws Exception {
210 251
		Map<String, Object> paramsMap = new HashMap<String, Object>();
211 252
		String deviceId = params.get("deviceId");
212 253
213 254
		paramsMap.put("deviceId", deviceId);// 终端id
214 255
		paramsMap.put("terminalSN", deviceId); // 终端编号
215 256
		paramsMap.put("productId", params.get("deviceTypeId")); // 终端类型
216
		paramsMap.put("deviceName", EbcConstant.BEIDOUDEVICE_NAME+params.get("deviceTypeName") + deviceId); // 名称
257
		paramsMap.put("deviceName", EbcConstant.BEIDOUDEVICE_NAME + params.get("deviceTypeName") + deviceId); // 名称
217 258
		paramsMap.put("remarks", params.get("remarks")); // 备注
218 259
219 260
		// 调用北向接口
220 261
		String url = NorthboundInterfaceConstant.updateDevice;
221
		Map<String, String> map = northboundInterfaceUtil.iotPostCallUtil(url, paramsMap);
222
		return map;
262
		Map<String, Object> resultMap = northboundInterfaceUtil.iotPostCallUtil(url, paramsMap);
263
		return resultMap;
223 264
	}
224
	
225 265
226 266
	@Override
227
	public Map<String, String> deleteDeviceInfo(Map<String, String> params) throws Exception {
228
		// 调用北向接口
229
				String url = NorthboundInterfaceConstant.deleteDevice + params.get("deviceId");
230
				Map<String, String> map = northboundInterfaceUtil.iotGetCallUtil(url);
267
	public Map<String, Object> deleteDeviceInfo(Map<String, String> params) throws Exception {
268
		Map<String, Object> resultMap = null;
269
		if (unbindDevice(params)) {
270
			// 调用北向接口
271
			String url = NorthboundInterfaceConstant.deleteDevice + params.get("deviceId");
272
			resultMap = northboundInterfaceUtil.iotGetCallUtil(url);
273
		}
274
275
		return resultMap;
276
	}
277
278
	@Override
279
	public boolean bindDevice(Map<String, String> params) throws Exception {
280
		boolean result=false;
281
		if (unbindDevice(params)) {
282
			if (EbcConstant.BIND_DEVICE_TYPE_USER.equals(params.get("bindType"))) {
283
				//与人员绑定
284
				EmployeeTerminalRela employeeTerminalRela = new EmployeeTerminalRela();
285
				employeeTerminalRela.setRelaType("1");//TODO 关系类型
286
				  employeeTerminalRela.setWorkEmployeeId(params.get("workEmployeeId"));//用户ID
287
				  employeeTerminalRela.setTerminalId(params.get("deviceId"));//终端ID
288
				  CommonRequest<EmployeeTerminalRela> resourceEmployeeTerminalRelalCommonRequest = new CommonRequest<EmployeeTerminalRela>(employeeTerminalRela);
289
				  
290
				  CommonResponse<EmployeeTerminalRela> createRelaResult = employeeTerminalRelaCommand.createIndividualDevRela(resourceEmployeeTerminalRelalCommonRequest);
291
				  result=createRelaResult.isSuccess();
292
				  
293
			}else if (EbcConstant.BIND_DEVICE_TYPE_SHIP.equals(params.get("bindType"))) {
294
				//与工具绑定
295
				ResourceToolTerminalRel resourceToolTerminalRel=new ResourceToolTerminalRel();
296
				resourceToolTerminalRel.setRelaType("LOC");//TODO 关系类型,默认可填'LOC'
297
				resourceToolTerminalRel.setTerminalId(params.get("deviceId"));//终端ID
298
				resourceToolTerminalRel.setResourceToolId(params.get("toolId"));//设备ID
299
				CommonRequest<ResourceToolTerminalRel> resourceToolTerminalRelCommonRequest =new CommonRequest<ResourceToolTerminalRel>(resourceToolTerminalRel);
231 300
				
301
				CommonResponse<ResourceToolTerminalRel> createRelaResult = resourceToolCommand.createWorkToolsDevRela(resourceToolTerminalRelCommonRequest);
302
				result=createRelaResult.isSuccess();
232 303
				
233
				// 根据终端id删除终端关联信息
234
				/*if (NorthboundInterfaceConstant.resultCode_succeed.equals(map.get("resultCode"))) {
235
					HashMap<String, Object> paramsHashMap = new HashMap<>();
236
					paramsHashMap.put("DEVICE_ID", params.get("deviceId"));
237
					int i = unbindDevice(paramsHashMap);
238
				}*/
239
				return map;
304
			}
305
		}
306
		return result;
307
	}
308
309
	@Override
310
	public Map<String, Object> queryBindDeviceInfo(Map<String, String> params) throws Exception {
311
		List<String> deviceIdList=new ArrayList<String>();
312
		deviceIdList.add(params.get("deviceId"));
313
		HashMap<String, Object> deviceIdListMap=new HashMap<String, Object>();
314
		deviceIdListMap.put("deviceIdList", deviceIdList);
315
		
316
		
317
		
318
		// 终端与人员绑定
319
		CommonResponse<List<EmployeeTerminalRelaDto>> bindEmployeeInfoCommon = employeeTerminalRelaQuery
320
				.queryIndividualDevRela(new CommonRequest<List<String>>(deviceIdList));
321
		List<EmployeeTerminalRelaDto> bindEmployeeInfoList = bindEmployeeInfoCommon.getData();
322
		
323
		
324
		
325
		// 终端与工具绑定
326
		CommonResponse<PageInfo<Map<String, Object>>> bindToolInfoCommon = resourceToolQuery
327
				.queryWorkToolsDevRela(new CommonRequest<HashMap<String, Object>>(deviceIdListMap));
328
		List<Map<String, Object>> bindToolInfoList = bindToolInfoCommon.getData().getData();
329
			
330
			
331
			
332
		
333
		return null;
334
	}
335
336
	@Override
337
	public boolean unbindDevice(Map<String, String> params) throws Exception {
338
		String[] deviceIds = params.get("deviceId").split(",");
339
		List<String> deviceIdList = new ArrayList<String>();
340
		for (String deviceId : deviceIds) {
341
			deviceIdList.add(deviceId);
342
		}
343
344
		// 根据终端id删除终端关联信息
345
		CommonResponse deleteRelaResult = resourceToolCommand
346
				.deleteWorkToolsDevRelaByTerminalId(new CommonRequest(deviceIdList));
347
		CommonResponse<Void> resopnse = employeeTerminalRelaCommand
348
				.deleteIndividualDevRela(new CommonRequest(deviceIdList));
349
350
		return deleteRelaResult.isSuccess() && resopnse.isSuccess();
351
	}
352
353
	@Override
354
	public List<Map<String, Object>> queryAssociatInfo(Map<String, String> params) throws Exception {
355
		if (EbcConstant.BIND_DEVICE_TYPE_USER.equals(params.get("type"))) {
356
			// 类型是用户,查询用户列表
357
			
358
			
359
		} else if (EbcConstant.BIND_DEVICE_TYPE_SHIP.equals(params.get("type"))) {
360
			// 类型是船舶,查询船舶列表
361
			
362
		}
363
		return null;
240 364
	}
241 365
242
	
243
	
244
	
245
	
246
	
247
	
248
	
249
	
250
	
251 366
	/*@Override
252 367
	public Map<String, Object> queryPageDeviceInfo(Map<String, Object> params, int pageNum, int pageSize)
253 368
			throws Exception {
@ -291,11 +406,11 @@ public class DeviceManageServiceImpl implements DeviceManageService {
291 406
	
292 407
	@Override
293 408
	public List<Map<String, Object>> queryAssociatInfo(Map<String, Object> params) throws Exception {
294
		if (EbcConstant.bind_device_type_user.equals(params.get("type"))) {
409
		if (EbcConstant.BIND_DEVICE_TYPE_USER.equals(params.get("type"))) {
295 410
			// 类型是用户,查询用户列表
296 411
			// TODO 调用uspa接口获取人员信息 暂时用枚举
297 412
			return UserEnums.getAllUserList();
298
		} else if (EbcConstant.bind_device_type_ship.equals(params.get("type"))) {
413
		} else if (EbcConstant.BIND_DEVICE_TYPE_SHIP.equals(params.get("type"))) {
299 414
			// 类型是船舶,查询船舶列表
300 415
			return deviceManageDao.queryAssociatBoatInfo(params);
301 416
		}

+ 48 - 60
location-rescue-service/src/main/java/com/ai/bss/location/rescue/service/interfaces/DeviceManageService.java

@ -3,6 +3,8 @@ package com.ai.bss.location.rescue.service.interfaces;
3 3
import java.util.List;
4 4
import java.util.Map;
5 5
6
import org.springframework.web.bind.annotation.RequestBody;
7
6 8
import com.ai.bss.characteristic.spec.model.CharacteristicSpecValue;
7 9
8 10
public interface DeviceManageService {
@ -22,7 +24,7 @@ public interface DeviceManageService {
22 24
	 * @return
23 25
	 */
24 26
	List<CharacteristicSpecValue> queryDeviceTypeList();
25
	
27
26 28
	/**
27 29
	* 获取单个终端信息
28 30
	* @param params
@ -30,55 +32,67 @@ public interface DeviceManageService {
30 32
	* @throws Exception
31 33
	*/
32 34
33
Map<String, Object> queryOneDeviceInfo(Map<String, String> params) throws Exception;
35
	Map<String, Object> queryOneDeviceInfo(Map<String, String> params) throws Exception;
36
37
	/**
38
		* 新增终端信息
39
		* @param params
40
		* @return
41
		* @throws Exception
42
		*/
43
44
	Map<String, Object> addDeviceInfo(Map<String, String> params) throws Exception;
34 45
35
/**
36
	* 新增终端信息
46
	/**
47
		* 修改终端信息
48
		* @param params
49
		* @return
50
		* @throws Exception
51
		*/
52
53
	Map<String, Object> modifyDeviceInfo(Map<String, String> params) throws Exception;
54
55
	/**
56
		* 删除终端信息
57
		* @param params
58
		* @return
59
		* @throws Exception
60
		*/
61
	Map<String, Object> deleteDeviceInfo(Map<String, String> params) throws Exception;
62
63
	/**
64
	* 绑定终端
37 65
	* @param params
66
	* @param type
38 67
	* @return
39 68
	* @throws Exception
40 69
	*/
70
	boolean bindDevice(Map<String, String> params) throws Exception;
41 71
42
Map<String, String> addDeviceInfo(Map<String, String> params) throws Exception;
72
	/**
73
	 * 查询绑定关系信息
74
	 * @param params
75
	 * @return
76
	 * @throws Exception
77
	 */
78
	Map<String, Object> queryBindDeviceInfo(Map<String, String> params) throws Exception;
43 79
44
/**
45
	* 修改终端信息
80
	/**
81
	* 解绑终端
46 82
	* @param params
47 83
	* @return
48 84
	* @throws Exception
49 85
	*/
86
	boolean unbindDevice(Map<String, String> params) throws Exception;
50 87
51
Map<String, String> modifyDeviceInfo(Map<String, String> params) throws Exception;
52
53
/**
54
	* 删除终端信息
88
	/**
89
	* 获取人员或船舶的下拉列表数据
55 90
	* @param params
56 91
	* @return
57 92
	* @throws Exception
58 93
	*/
59
Map<String, String> deleteDeviceInfo(Map<String, String> params) throws Exception;
60
94
	List<Map<String, Object>> queryAssociatInfo(Map<String, String> params) throws Exception;
61 95
62
	
63
	
64
	
65
	
66
	
67
	
68
	
69
	
70
	
71
	
72
	
73
	
74
	
75
	
76
	
77
	
78
	
79
	
80
	
81
	
82 96
	/**
83 97
	 * 获取下拉列表的终端信息
84 98
	 * @param params
@ -90,34 +104,8 @@ Map<String, String> deleteDeviceInfo(Map<String, String> params) throws Exceptio
90 104
	/*List<Map<String, String>> queryListDeviceInfo(Map<String, Object> params, int pageNum, int pageSize)
91 105
			throws Exception;
92 106
	
93
	*//**
94
		* 绑定终端
95
		* @param params
96
		* @param type
97
		* @return
98
		* @throws Exception
99
		*/
100
	/*
101
	boolean bindDevice(Map<String, Object> params) throws Exception;
102
	
103
	*//**
104
		* 解绑终端
105
		* @param params
106
		* @return
107
		* @throws Exception
108
		*/
109
	/*
110
	boolean unbindDevice(Map<String, Object> params) throws Exception;
111
	
112
	*//**
113
		* 获取人员或船舶的下拉列表数据
114
		* @param params
115
		* @return
116
		* @throws Exception
117
		*/
107
	*/
118 108
	/*
119
	List<Map<String, Object>> queryAssociatInfo(Map<String, Object> params) throws Exception;
120
	
121 109
	Map<String, Object> verifyUserOrBoatAssociatInfo(Map<String, Object> params) throws Exception;
122 110
	
123 111
	*//**

+ 14 - 14
location-rescue-service/src/main/java/com/ai/bss/location/rescue/util/NorthboundInterfaceUtil.java

@ -68,7 +68,7 @@ public class NorthboundInterfaceUtil {
68 68
	 * @return
69 69
	 * @throws Exception
70 70
	 */
71
	public Map<String, String> iotGetCallUtil(String url) throws Exception {
71
	public Map<String, Object> iotGetCallUtil(String url) throws Exception {
72 72
		// 调用北向服务的接口
73 73
		logger.debug("GET调用北向接口");
74 74
@ -83,7 +83,7 @@ public class NorthboundInterfaceUtil {
83 83
84 84
		if (!loginFlag) {
85 85
			logger.debug("调用北向接口登录失败");
86
			return new HashMap<String, String>();
86
			return new HashMap<String, Object>();
87 87
		}
88 88
89 89
		// 3.调用北向服务接口
@ -92,7 +92,7 @@ public class NorthboundInterfaceUtil {
92 92
		// (2)调用接口
93 93
		String resultJson = HttpServiceUtil.sendGet(iotServiceUrl + url, charset);
94 94
		// (3)将参数转为Map<String,String>【将返回值统一为String】
95
		Map<String, String> resultMap = JSON.parseObject(resultJson, Map.class);
95
		Map<String, Object> resultMap = JSON.parseObject(resultJson, Map.class);
96 96
97 97
		// 4.登录超时,需重新登录
98 98
		if ("登录超时".equals(resultMap.get("resultMsg"))) {
@ -105,7 +105,7 @@ public class NorthboundInterfaceUtil {
105 105
106 106
			if (!loginFlag) {
107 107
				logger.debug("再次调用北向接口登录失败");
108
				return new HashMap<String, String>();
108
				return new HashMap<String, Object>();
109 109
			}
110 110
111 111
			try {
@ -115,12 +115,12 @@ public class NorthboundInterfaceUtil {
115 115
				resultMap = JSON.parseObject(fianlresultJson, Map.class);
116 116
			} catch (Exception e) {
117 117
				logger.error("再次调用北向接口失败: " + e.getMessage());
118
				return new HashMap<String, String>();
118
				return new HashMap<String, Object>();
119 119
			}
120 120
121 121
			if (resultMap == null) {
122 122
				logger.error("再次调用北向接口返回值为空");
123
				return new HashMap<String, String>();
123
				return new HashMap<String, Object>();
124 124
			}
125 125
		}
126 126
@ -142,7 +142,7 @@ public class NorthboundInterfaceUtil {
142 142
	 * @return
143 143
	 * @throws Exception
144 144
	 */
145
	public Map<String, String> iotPostCallUtil(String url, Map<String, Object> paramsMap) throws Exception {
145
	public Map<String, Object> iotPostCallUtil(String url, Map<String, Object> paramsMap) throws Exception {
146 146
		// 调用北向服务的接口
147 147
		logger.debug("POSt调用北向接口");
148 148
@ -157,14 +157,14 @@ public class NorthboundInterfaceUtil {
157 157
158 158
		if (!loginFlag) {
159 159
			logger.debug("调用北向接口登录失败");
160
			return new HashMap<String, String>();
160
			return new HashMap<String, Object>();
161 161
		}
162 162
163 163
		// 3.调用北向服务接口
164 164
		// (1)设置字符集
165 165
		Charset charset = Charset.forName("utf-8");
166 166
		// 返回值
167
		Map<String, String> resultMap = null;
167
		Map<String, Object> resultMap = null;
168 168
		try {
169 169
			// (2)调用接口
170 170
			String resultJson = HttpServiceUtil.sendPost(iotServiceUrl + url, paramsMap, charset, getMapCache());
@ -172,12 +172,12 @@ public class NorthboundInterfaceUtil {
172 172
			resultMap = JSON.parseObject(resultJson, Map.class);
173 173
		} catch (Exception e) {
174 174
			logger.error("调用北向接口失败: " + e.getMessage());
175
			return new HashMap<String, String>();
175
			return new HashMap<String, Object>();
176 176
		}
177 177
178 178
		if (resultMap == null) {
179 179
			logger.error("调用北向接口返回值为空");
180
			return new HashMap<String, String>();
180
			return new HashMap<String, Object>();
181 181
		}
182 182
183 183
		// 4.登录超时,需重新登录
@ -191,7 +191,7 @@ public class NorthboundInterfaceUtil {
191 191
192 192
			if (!loginFlag) {
193 193
				logger.debug("再次调用北向接口登录失败");
194
				return new HashMap<String, String>();
194
				return new HashMap<String, Object>();
195 195
			}
196 196
197 197
			try {
@ -202,12 +202,12 @@ public class NorthboundInterfaceUtil {
202 202
				resultMap = JSON.parseObject(fianlresultJson, Map.class);
203 203
			} catch (Exception e) {
204 204
				logger.error("再次调用北向接口失败: " + e.getMessage());
205
				return new HashMap<String, String>();
205
				return new HashMap<String, Object>();
206 206
			}
207 207
208 208
			if (resultMap == null) {
209 209
				logger.error("再次调用北向接口返回值为空");
210
				return new HashMap<String, String>();
210
				return new HashMap<String, Object>();
211 211
			}
212 212
		}
213 213

+ 3 - 3
location-rescue-service/src/main/resources/application.properties

@ -3,10 +3,10 @@ server.port=8086
3 3
4 4
# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
5 5
#spring.datasource.url=jdbc:mysql://localhost:3306/cmp
6
spring.datasource.url=jdbc:mysql://10.11.20.120:3306/common_frm?serverTimezone=Asia/Shanghai&characterEncoding=utf-8&verifyServerCertificate=false&useSSL=false&requireSSL=false
6
spring.datasource.url=jdbc:mysql://10.19.90.34:3307/energy
7 7
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
8
spring.datasource.username=comon_frm
9
spring.datasource.password=1qaz@WSX
8
spring.datasource.username=ebc
9
spring.datasource.password=ebc@123
10 10
11 11
# JPA (JpaBaseConfiguration, HibernateJpaAutoConfiguration)
12 12
#spring.jpa.database=default