Commit f96f6a97 authored by 赵啸非's avatar 赵啸非

修改平台编码

parent 229f8acb
...@@ -271,29 +271,27 @@ public class DeviceApiController { ...@@ -271,29 +271,27 @@ public class DeviceApiController {
//log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp))); //log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp)));
} else { } else {
if (ObjectUtils.isEmpty(req.getPlatformId())) { if (ObjectUtils.isEmpty(req.getPlatformCode())) {
throw new AppException("当前平台Id为空!"); throw new AppException("当前平台编码为空!");
} }
PlatformEntity platformEntity = platformService.get(req.getPlatformId()); PlatformEntity platformEntity = platformService.selectOne(new PlatformQuery().platformSn(req.getPlatformCode()));
if (ObjectUtils.isEmpty(platformEntity)) { if (ObjectUtils.isEmpty(platformEntity)) {
throw new AppException("当前设备未配置所属系统平!"); throw new AppException("所属系统平台不存在!");
} }
if (ObjectUtils.isEmpty(req.getProductId())) { if (ObjectUtils.isEmpty(req.getPlatformCode())) {
throw new AppException("当前产品Id为空!"); throw new AppException("当前产品Code为空!");
} }
ProductEntity productEntity = productService.get(req.getProductId()); ProductEntity productEntity = productService.selectOne(new ProductQuery().productCode(req.getProductCode()));
if (ObjectUtils.isEmpty(productEntity)) { if (ObjectUtils.isEmpty(productEntity)) {
throw new AppException("当前设备未配置所属产品,"); throw new AppException("所属产品编码不存在");
} }
deviceEntity = new DeviceEntity(); deviceEntity = new DeviceEntity();
deviceEntity.initAttrValue(); deviceEntity.initAttrValue();
deviceEntity.setDeviceName(req.getDeviceName()); deviceEntity.setDeviceName(req.getDeviceName());
deviceEntity.setDeviceCode(req.getDeviceCode()); deviceEntity.setDeviceCode(req.getDeviceCode());
deviceEntity.setDeviceMac(req.getDeviceMac()); deviceEntity.setDeviceMac(req.getDeviceCode());
deviceEntity.setSiteCode(req.getSiteCode()); deviceEntity.setSiteCode(req.getSiteCode());
deviceEntity.setSiteName(req.getSiteName()); deviceEntity.setSiteName(req.getSiteName());
deviceEntity.setIp(req.getIp());
deviceEntity.setPort(req.getPort());
deviceEntity.setPlatformId(platformEntity.getId()); deviceEntity.setPlatformId(platformEntity.getId());
deviceEntity.setPlatformName(platformEntity.getPlatformName()); deviceEntity.setPlatformName(platformEntity.getPlatformName());
deviceEntity.setProductId(productEntity.getId()); deviceEntity.setProductId(productEntity.getId());
...@@ -347,8 +345,39 @@ public class DeviceApiController { ...@@ -347,8 +345,39 @@ public class DeviceApiController {
rsp.setMsg(e.getMessage()); rsp.setMsg(e.getMessage());
return JSON.toJSONString(rsp); return JSON.toJSONString(rsp);
} }
log.info("响应【激活设备】【响应体】--> " + JSONObject.toJSONString(rsp));
return JSON.toJSONString(rsp);
}
/**
* 删除设备
*
* @param req
* @return
*/
@PostMapping("deviceDel")
@ApiUserAuth
public String deviceDel(@RequestBody DeviceReq req) {
log.info("【删除设备】【请求体】--> " + JSONObject.toJSONString(req));
ApiResp<String> rsp = new ApiResp<>();
rsp.setMsg(ApiRespCodeEnum.SUCCESS.getLabel());
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
try {
//根据设备编码查询设备
DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceCode());
if (ObjectUtils.isEmpty(deviceEntity)) {
throw new AppException("当前设备不存在!");
}
deviceService.remove(deviceEntity.getId(),null);
} catch (Exception e) {
log.error("接收数据失败", e);
rsp.setCode(ApiRespCodeEnum.FAILED.getValue());
rsp.setMsg(e.getMessage());
return JSON.toJSONString(rsp);
}
log.info("响应【激活设备设备】【响应体】--> " + JSONObject.toJSONString(rsp)); log.info("响应【删除设备】【响应体】--> " + JSONObject.toJSONString(rsp));
return JSON.toJSONString(rsp); return JSON.toJSONString(rsp);
} }
......
...@@ -112,7 +112,6 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic ...@@ -112,7 +112,6 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
} }
/** /**
* 下发信息 * 下发信息
*/ */
...@@ -142,7 +141,7 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic ...@@ -142,7 +141,7 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
obj.put("content", content); obj.put("content", content);
ApiResp<String> sendDeviceMessageResp =this.service.sendDeviceMessage(deviceEntity, info, header, JSON.toJSONString(obj), null); ApiResp<String> sendDeviceMessageResp = this.service.sendDeviceMessage(deviceEntity, info, header, JSON.toJSONString(obj), null);
log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp))); log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp)));
if (ApiRespCodeEnum.SUCCESS.getValue() != sendDeviceMessageResp.getCode()) { if (ApiRespCodeEnum.SUCCESS.getValue() != sendDeviceMessageResp.getCode()) {
throw new AppException("下发消息失败!"); throw new AppException("下发消息失败!");
...@@ -150,7 +149,7 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic ...@@ -150,7 +149,7 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
// Thread.sleep(50); // Thread.sleep(50);
//log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp))); //log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp)));
}else { } else {
throw new AppException("设备不存在!deviceId:" + deviceId); throw new AppException("设备不存在!deviceId:" + deviceId);
} }
...@@ -166,4 +165,27 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic ...@@ -166,4 +165,27 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
return jsonObject.toJSONString(); return jsonObject.toJSONString();
} }
/**
* 设备激活
*/
@PostMapping(value = "active")
public String deviceActive(@RequestParam(value = "deviceCode") String deviceCode) {
JSONObject jsonObject = new JSONObject();
Map<String, Object> model = new HashMap<>();
String busiDesc = this.getModuleDesc() + "下发设备消息";
try {
this.service.active(deviceCode, getContext());
this.init(request, response, null, model, getContext());
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_DATA, model);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
} catch (Exception e) {
log.error("设备激活消息", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment