|
@@ -71,6 +71,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
+import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -97,7 +98,8 @@ import java.util.stream.Collectors;
|
|
|
* @author Administrator
|
|
|
*/
|
|
|
@RestController
|
|
|
-//@Slf4j
|
|
|
+@Slf4j
|
|
|
+@CrossOrigin(origins = "*")
|
|
|
public class GeoHazardMonitorTokenController {
|
|
|
public static final String PATTERN = "^([0-9]+),([0-9]+),([0-9]+),([0-9]+),([0-9]+),([0-9]+)$";
|
|
|
public static final String PATTERNS = "^[0-9]*$";
|
|
@@ -158,14 +160,18 @@ public class GeoHazardMonitorTokenController {
|
|
|
public String getWebToken(@RequestBody SvcAddress svcAddress) {
|
|
|
// 生成令牌
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
+ if (ObjectUtils.isEmpty(svcAddress)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "svcAddress参数不能为空");
|
|
|
+ return JSONObject.toJSONString(jsonObject);
|
|
|
+ }
|
|
|
LambdaQueryWrapper<SvcAddress> lw = new LambdaQueryWrapper<SvcAddress>();
|
|
|
if (!ObjectUtils.isEmpty(svcAddress.getClientId())) {
|
|
|
lw.eq(SvcAddress::getClientId, svcAddress.getClientId());
|
|
|
lw.eq(SvcAddress::getEnv, env);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "客户端编号不能为空");
|
|
|
+ jsonObject.put("message", "客户端编号不能为空");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
SvcAddress serviceOne = svcAddressService.getOne(lw);
|
|
@@ -176,14 +182,12 @@ public class GeoHazardMonitorTokenController {
|
|
|
if (!ObjectUtils.isEmpty(svcAddress.getGrantType())) {
|
|
|
if (!svcAddress.getGrantType().toString().matches(PATTERNS)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "授权类型填写错误");
|
|
|
+ jsonObject.put("message", "授权类型填写错误");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "授权类型不能为空");
|
|
|
+ jsonObject.put("message", "授权类型不能为空");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
ArrayList<String> objects = apiTokenUtils.createGeoHazardMonitorToken(svcAddress.getGrantType().toString(), svcAddress.getClientId(), sm4);
|
|
@@ -199,20 +203,17 @@ public class GeoHazardMonitorTokenController {
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), sm4);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "生成token失败");
|
|
|
+ jsonObject.put("message", "生成token失败");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
} else {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "客户端密钥错误");
|
|
|
+ jsonObject.put("resultCode", 2);
|
|
|
+ jsonObject.put("message", "客户端密钥错误");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "参数验证失败");
|
|
|
+ jsonObject.put("message", "参数验证失败");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
}
|
|
@@ -224,9 +225,14 @@ public class GeoHazardMonitorTokenController {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String alarm(@RequestBody ParameterVo parameterVo, HttpServletRequest request) throws Exception {
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
- //log.info("token:{}", token);
|
|
|
- //log.info("parameter:{}", parameterVo);
|
|
|
+ log.info("token:{}", token);
|
|
|
+ log.info("parameter:{}", parameterVo);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "parameterVo参数不能为空");
|
|
|
+ return JSONObject.toJSONString(jsonObject);
|
|
|
+ }
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
@@ -234,20 +240,20 @@ public class GeoHazardMonitorTokenController {
|
|
|
ReqMsgAlarmVo reqMsgAlarmVo = JSON.parseObject(s, ReqMsgAlarmVo.class);
|
|
|
if (ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmAttr())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "你填写的报警病害属性不符合规则!!!");
|
|
|
+ jsonObject.put("message", "你填写的报警病害属性不符合规则!!!");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (!reqMsgAlarmVo.getAlarmMile().toString().matches(PATTERNS)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "报警里程位置填写错误");
|
|
|
+ jsonObject.put("message", "报警里程位置填写错误");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (reqMsgAlarmVo.getLineDir() != 1 && reqMsgAlarmVo.getLineDir() != 2) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "行别填写错误");
|
|
|
+ jsonObject.put("message", "行别填写错误");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
LambdaQueryWrapper<BaseRailwayManagement> queryWrapper = new LambdaQueryWrapper<BaseRailwayManagement>();
|
|
@@ -257,38 +263,38 @@ public class GeoHazardMonitorTokenController {
|
|
|
BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
|
|
|
if (ObjectUtils.isEmpty(baseRailwayManagement)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "填写的报警线路编码不存在");
|
|
|
+ jsonObject.put("message", "填写的报警线路编码不存在");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmId())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "报警的唯一标识不能为空");
|
|
|
+ jsonObject.put("message", "报警的唯一标识不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmTime())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "报警时间不能为空");
|
|
|
+ jsonObject.put("message", "报警时间不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
- if (reqMsgAlarmVo.getAlarmType() < 1 || reqMsgAlarmVo.getAlarmType() > 3) {
|
|
|
+ if (reqMsgAlarmVo.getAlarmType() < 1 || reqMsgAlarmVo.getAlarmType() > 4) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "报警病害类型填写错误");
|
|
|
+ jsonObject.put("message", "报警病害类型填写错误");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (!reqMsgAlarmVo.getAlarmLevel().toString().matches(PATTERNS)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "报警级别填写错误");
|
|
|
+ jsonObject.put("message", "报警级别填写错误");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (reqMsgAlarmVo.getAlarmTime().toString().length() == 10) {
|
|
|
reqMsgAlarmVo.setAlarmTime(reqMsgAlarmVo.getAlarmTime() * 1000);
|
|
|
}
|
|
|
- //log.info("reqMsgAlarmVo:{}", reqMsgAlarmVo);
|
|
|
+ log.info("reqMsgAlarmVo:{}", reqMsgAlarmVo);
|
|
|
|
|
|
LambdaQueryWrapper<BaseCameraManagement> wrapper = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
|
if (!ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmMile())) {
|
|
@@ -331,14 +337,14 @@ public class GeoHazardMonitorTokenController {
|
|
|
for (int i = 0; i < files1.length; i++) {
|
|
|
if (ObjectUtils.isEmpty(files1[i].fileUrl)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "上传文件地址不能为空");
|
|
|
+ jsonObject.put("message", "上传文件地址不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (files1[i].fileType < 1 || files1[i].fileType > 3) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "文件类型填写错误");
|
|
|
+ jsonObject.put("message", "文件类型填写错误");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
MsgAlarmExt msgAlarmExt = new MsgAlarmExt();
|
|
@@ -373,12 +379,10 @@ public class GeoHazardMonitorTokenController {
|
|
|
}
|
|
|
jsonObject.put("resultCode", 1);
|
|
|
jsonObject.put("message", "ok");
|
|
|
- jsonObject.put("data", null);
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "token验证失败");
|
|
|
+ jsonObject.put("message", "token验证失败");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
}
|
|
@@ -393,9 +397,14 @@ public class GeoHazardMonitorTokenController {
|
|
|
@PostMapping("/api/releaseAlarm")
|
|
|
public String releaseAlarm(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
- //log.info("token:{}", token);
|
|
|
- //log.info("parameter:{}", parameterVo);
|
|
|
+ log.info("token:{}", token);
|
|
|
+ log.info("parameter:{}", parameterVo);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "parameterVo参数不能为空");
|
|
|
+ return JSONObject.toJSONString(jsonObject);
|
|
|
+ }
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
@@ -403,26 +412,26 @@ public class GeoHazardMonitorTokenController {
|
|
|
ReleaseAlarmVo releaseAlarmVo = JSON.parseObject(s, ReleaseAlarmVo.class);
|
|
|
if (ObjectUtils.isEmpty(releaseAlarmVo.getAlarmId())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "报警的唯一标识不能为空");
|
|
|
+ jsonObject.put("message", "报警的唯一标识不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(releaseAlarmVo.getReleaseTime())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "解除报警时间不能为空");
|
|
|
+ jsonObject.put("message", "解除报警时间不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(releaseAlarmVo.getReleaseContent())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "解除原因不能为空");
|
|
|
+ jsonObject.put("message", "解除原因不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(releaseAlarmVo.getReleaseTime())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "解除人不能为空");
|
|
|
+ jsonObject.put("message", "解除人不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
LambdaQueryWrapper<MsgAlarm> wrapper = new LambdaQueryWrapper<>();
|
|
@@ -430,8 +439,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
MsgAlarm msgAlarm = msgAlarmService.getOne(wrapper);
|
|
|
if (ObjectUtils.isEmpty(msgAlarm)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "不存在该报警的唯一标识的数据");
|
|
|
+ jsonObject.put("message", "不存在该报警的唯一标识的数据");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (releaseAlarmVo.getReleaseTime().toString().length() == 10) {
|
|
@@ -459,8 +468,7 @@ public class GeoHazardMonitorTokenController {
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "token验证失败");
|
|
|
+ jsonObject.put("message", "token验证失败");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
}
|
|
@@ -487,32 +495,38 @@ public class GeoHazardMonitorTokenController {
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "parameterVo参数不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ }
|
|
|
// 1. 解密参数
|
|
|
String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
|
|
|
// 2、 心跳参数
|
|
|
HeartbeatVo heartbeatVo = JSON.parseObject(s, HeartbeatVo.class);
|
|
|
if (ObjectUtils.isEmpty(heartbeatVo.getTerminalCode())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("message", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (!heartbeatVo.getCurrentMile().toString().matches(PATTERNS)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "当前里程位置填写错误");
|
|
|
+ jsonObject.put("message", "当前里程位置填写错误");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(heartbeatVo.getLatitude())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "当前所在纬度不能为空");
|
|
|
+ jsonObject.put("message", "当前所在纬度不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(heartbeatVo.getLongitude())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "当前所在经度不能为空");
|
|
|
+ jsonObject.put("message", "当前所在经度不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
LambdaQueryWrapper<BaseRailwayManagement> railway = new LambdaQueryWrapper<BaseRailwayManagement>();
|
|
@@ -522,26 +536,26 @@ public class GeoHazardMonitorTokenController {
|
|
|
BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(railway);
|
|
|
if (ObjectUtils.isEmpty(baseRailwayManagement)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "填写的线路编码不存在");
|
|
|
+ jsonObject.put("message", "填写的线路编码不存在");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (heartbeatVo.getLineDir() != 1 && heartbeatVo.getLineDir() != 2) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "行别填写错误");
|
|
|
+ jsonObject.put("message", "行别填写错误");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (!heartbeatVo.getVisualDistance().toString().matches(PATTERNS)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "司机目视距离填写错误");
|
|
|
+ jsonObject.put("message", "司机目视距离填写错误");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (heartbeatVo.getSignalStrength() != 1 && heartbeatVo.getSignalStrength() != 2) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "信号强度填写错误");
|
|
|
+ jsonObject.put("message", "信号强度填写错误");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
VehiclePosition vehiclePosition = new VehiclePosition();
|
|
@@ -551,8 +565,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
BaseVehicleTerminal baseTerminal = baseVehicleTerminalService.getOne(wrapper);
|
|
|
if (ObjectUtils.isEmpty(baseTerminal)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "关联表中没有改终端编码的信息");
|
|
|
+ jsonObject.put("message", "关联表中没有改终端编码的信息");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (heartbeatVo.getSignalStrength() == 1) {
|
|
@@ -826,14 +840,12 @@ public class GeoHazardMonitorTokenController {
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "心跳机制交互失败");
|
|
|
+ jsonObject.put("message", "心跳机制交互失败");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "token验证失败");
|
|
|
+ jsonObject.put("message", "token验证失败");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
|
|
@@ -850,24 +862,30 @@ public class GeoHazardMonitorTokenController {
|
|
|
public String terminalIgnore(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- //log.info("token:{}", token);
|
|
|
- //log.info("parameter:{}", parameterVo);
|
|
|
+ log.info("token:{}", token);
|
|
|
+ log.info("parameter:{}", parameterVo);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "parameterVo参数不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ }
|
|
|
String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
|
|
|
TerminalIgnoreVo terminalIgnoreVo = JSON.parseObject(s, TerminalIgnoreVo.class);
|
|
|
if (ObjectUtils.isEmpty(terminalIgnoreVo.getTerminalCode())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("message", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(terminalIgnoreVo.getAlarmId())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "报警唯一UUID不能为空");
|
|
|
+ jsonObject.put("message", "报警唯一UUID不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
map.put("terminalCode", terminalIgnoreVo.getTerminalCode());
|
|
@@ -904,8 +922,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "token验证失败");
|
|
|
+ jsonObject.put("message", "token验证失败");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
}
|
|
@@ -920,31 +938,39 @@ public class GeoHazardMonitorTokenController {
|
|
|
@PostMapping("/api/query/camera")
|
|
|
public String camera(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
- //log.info("token:{}", token);
|
|
|
- //log.info("parameter:{}", parameterVo);
|
|
|
+ log.info("token:{}", token);
|
|
|
+ log.info("parameter:{}", parameterVo);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "parameterVo参数不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ }
|
|
|
String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
|
|
|
CameraVo cameraVo = JSON.parseObject(s, CameraVo.class);
|
|
|
if (ObjectUtils.isEmpty(cameraVo.getTerminalCode())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("message", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
LambdaQueryWrapper<BaseCameraManagement> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(BaseCameraManagement::getRailwayCode, cameraVo.getRailwayCode())
|
|
|
- .and(w1 -> w1.eq(BaseCameraManagement::getMonitoringDirection, cameraVo.getLineDir())
|
|
|
- .or(w2 -> w2.eq(BaseCameraManagement::getMonitoringDirection, 3)));
|
|
|
+ if (!ObjectUtils.isEmpty(cameraVo.getLineDir())) {
|
|
|
+ wrapper.eq(BaseCameraManagement::getRailwayCode, cameraVo.getRailwayCode())
|
|
|
+ .and(w1 -> w1.eq(BaseCameraManagement::getMonitoringDirection, cameraVo.getLineDir())
|
|
|
+ .or(w2 -> w2.eq(BaseCameraManagement::getMonitoringDirection, 3)));
|
|
|
+ }
|
|
|
wrapper.eq(BaseCameraManagement::getEnableOrNot, 1);
|
|
|
wrapper.orderByAsc(BaseCameraManagement::getInstallMile);
|
|
|
List<BaseCameraManagement> list = baseCameraManagementService.list(wrapper);
|
|
|
if (list.size() <= 0) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "没有该线路编码或行别的相机信息");
|
|
|
+ jsonObject.put("message", "没有该线路编码或行别的相机信息");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
for (BaseCameraManagement baseCameraManagement : list) {
|
|
@@ -955,8 +981,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
|
|
|
if (ObjectUtils.isEmpty(baseRailwayManagement)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "没有该线路编码的线路信息");
|
|
|
+ jsonObject.put("message", "没有该线路编码的线路信息");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
baseCameraManagement.setRailwayName(baseRailwayManagement.getRailwayName());
|
|
@@ -989,8 +1015,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "token验证失败");
|
|
|
+ jsonObject.put("message", "token验证失败");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
}
|
|
@@ -1006,24 +1032,30 @@ public class GeoHazardMonitorTokenController {
|
|
|
public String cameraPlay(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
- //log.info("token:{}", token);
|
|
|
- //log.info("parameter:{}", parameterVo);
|
|
|
+ log.info("token:{}", token);
|
|
|
+ log.info("parameter:{}", parameterVo);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "parameterVo参数不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ }
|
|
|
String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
|
|
|
CameraPlayVo cameraPlayVo = JSON.parseObject(s, CameraPlayVo.class);
|
|
|
if (ObjectUtils.isEmpty(cameraPlayVo.getTerminalCode())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("message", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(cameraPlayVo.getCameraCode())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "相机编码不能为空");
|
|
|
+ jsonObject.put("message", "相机编码不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
@@ -1032,8 +1064,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
BaseCameraManagement one = baseCameraManagementService.getOne(lw);
|
|
|
if (ObjectUtils.isEmpty(one)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "没有该相机编码的相机或已离线");
|
|
|
+ jsonObject.put("message", "没有该相机编码的相机或已离线");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
//获取视频点播地址
|
|
@@ -1054,8 +1086,60 @@ public class GeoHazardMonitorTokenController {
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "token验证失败");
|
|
|
+ jsonObject.put("message", "token验证失败");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return JSONObject.toJSONString(jsonObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关闭点播功能接口
|
|
|
+ *
|
|
|
+ * @param parameterVo
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/api/close/camera/play")
|
|
|
+ public String closeCameraPlay(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
|
|
|
+ String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
+ log.info("token:{}", token);
|
|
|
+ log.info("parameter:{}", parameterVo);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ if (StringUtils.isNotEmpty(token)) {
|
|
|
+ String[] split = token.split("-");
|
|
|
+ String key = split[split.length - 1];
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "parameterVo参数不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ }
|
|
|
+ String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
|
|
|
+ CameraPlayVo cameraPlayVo = JSON.parseObject(s, CameraPlayVo.class);
|
|
|
+ if (ObjectUtils.isEmpty(cameraPlayVo.getCameraCode())) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "相机编码不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
|
+ lw.eq(BaseCameraManagement::getCameraCode, cameraPlayVo.getCameraCode());
|
|
|
+ lw.eq(BaseCameraManagement::getOnline, 2);
|
|
|
+ lw.eq(BaseCameraManagement::getEnableOrNot, 1);
|
|
|
+ BaseCameraManagement one = baseCameraManagementService.getOne(lw);
|
|
|
+ if (ObjectUtils.isEmpty(one)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "没有该相机编码的相机或已离线");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ }
|
|
|
+ jsonObject.put("resultCode", 1);
|
|
|
+ jsonObject.put("message", "ok");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ } else {
|
|
|
+ jsonObject.put("resultCode", 2);
|
|
|
+ jsonObject.put("message", "token验证失败");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
}
|
|
@@ -1071,18 +1155,24 @@ public class GeoHazardMonitorTokenController {
|
|
|
@PostMapping("/api/query/alarm")
|
|
|
public String queryAlarm(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
- //log.info("token:{}", token);
|
|
|
- //log.info("parameter:{}", parameterVo);
|
|
|
+ log.info("token:{}", token);
|
|
|
+ log.info("parameter:{}", parameterVo);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "parameterVo参数不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ }
|
|
|
String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
|
|
|
CameraVo cameraVo = JSON.parseObject(s, CameraVo.class);
|
|
|
if (ObjectUtils.isEmpty(cameraVo.getTerminalCode())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("message", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
LambdaQueryWrapper<MsgAlarm> wrapper = new LambdaQueryWrapper<>();
|
|
@@ -1092,11 +1182,12 @@ public class GeoHazardMonitorTokenController {
|
|
|
if (!ObjectUtils.isEmpty(cameraVo.getLineDir())) {
|
|
|
wrapper.eq(MsgAlarm::getLineDir, cameraVo.getLineDir());
|
|
|
}
|
|
|
+ wrapper.orderByDesc(MsgAlarm::getAlarmTime);
|
|
|
List<MsgAlarm> list = msgAlarmService.list(wrapper);
|
|
|
if (list.size() <= 0) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "没有该报警线路或行别的报警信息");
|
|
|
+ jsonObject.put("message", "没有该报警线路或行别的报警信息");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
QueryAlarmVo queryAlarmVo = new QueryAlarmVo();
|
|
@@ -1133,8 +1224,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "token验证失败");
|
|
|
+ jsonObject.put("message", "token验证失败");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
}
|
|
@@ -1151,24 +1242,30 @@ public class GeoHazardMonitorTokenController {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
String urls = null;
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
- //log.info("token:{}", token);
|
|
|
- //log.info("parameter:{}", parameterVo);
|
|
|
+ log.info("token:{}", token);
|
|
|
+ log.info("parameter:{}", parameterVo);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "parameterVo参数不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ }
|
|
|
String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
|
|
|
TerminalIgnoreVo terminalIgnoreVo = JSON.parseObject(s, TerminalIgnoreVo.class);
|
|
|
if (ObjectUtils.isEmpty(terminalIgnoreVo.getTerminalCode())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("message", "车载终端编码不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(terminalIgnoreVo.getAlarmId())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "报警唯一UUID不能为空");
|
|
|
+ jsonObject.put("message", "报警唯一UUID不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
LambdaQueryWrapper<MsgAlarm> wrapper = new LambdaQueryWrapper<>();
|
|
@@ -1176,8 +1273,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
MsgAlarm one = msgAlarmService.getOne(wrapper);
|
|
|
if (ObjectUtils.isEmpty(one)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "没有该报警唯一UUID的报警数据");
|
|
|
+ jsonObject.put("message", "没有该报警唯一UUID的报警数据");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
} else {
|
|
|
if (ObjectUtils.isEmpty(one.getReleasedUrl())) {
|
|
@@ -1209,8 +1306,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "token验证失败");
|
|
|
+ jsonObject.put("message", "token验证失败");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
}
|
|
@@ -1222,48 +1319,54 @@ public class GeoHazardMonitorTokenController {
|
|
|
@PostMapping("/api/skynet/heartbeat")
|
|
|
public String skynetHeartbeat(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
- //log.info("token:{}", token);
|
|
|
- //log.info("parameter:{}", parameterVo);
|
|
|
+ log.info("token:{}", token);
|
|
|
+ log.info("parameter:{}", parameterVo);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "parameterVo参数不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ }
|
|
|
String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
|
|
|
SkynetHeartbeatVo skynetHeartbeatVo = JSON.parseObject(s, SkynetHeartbeatVo.class);
|
|
|
if (ObjectUtils.isEmpty(skynetHeartbeatVo.getRailwayCode())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "线路编码不能为空");
|
|
|
+ jsonObject.put("message", "线路编码不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(skynetHeartbeatVo.getLineDir())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "行别不能为空");
|
|
|
+ jsonObject.put("message", "行别不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (skynetHeartbeatVo.getLineDir() != 1 && skynetHeartbeatVo.getLineDir() != 2) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "行别填写错误");
|
|
|
+ jsonObject.put("message", "行别填写错误");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(skynetHeartbeatVo.getInstallMile())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "安装里程位置不能为空");
|
|
|
+ jsonObject.put("message", "安装里程位置不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (!skynetHeartbeatVo.getInstallMile().toString().matches(PATTERNS)) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "里程位置填写错误,只能填写数字");
|
|
|
+ jsonObject.put("message", "里程位置填写错误,只能填写数字");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(skynetHeartbeatVo.getCameraCode())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "相机编码不能为空");
|
|
|
+ jsonObject.put("message", "相机编码不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
SkynetHeartbeatLog skynetHeartbeatLog = new SkynetHeartbeatLog();
|
|
@@ -1280,14 +1383,14 @@ public class GeoHazardMonitorTokenController {
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "新增失败");
|
|
|
+ jsonObject.put("message", "新增失败");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "token验证失败");
|
|
|
+ jsonObject.put("message", "token验证失败");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
}
|
|
@@ -1298,24 +1401,30 @@ public class GeoHazardMonitorTokenController {
|
|
|
@PostMapping("/api/alarm/heartbeat")
|
|
|
public String alarmHeartbeat(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
- //log.info("token:{}", token);
|
|
|
- //log.info("parameter:{}", parameterVo);
|
|
|
+ log.info("token:{}", token);
|
|
|
+ log.info("parameter:{}", parameterVo);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ jsonObject.put("resultCode", 0);
|
|
|
+ jsonObject.put("message", "parameterVo参数不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ }
|
|
|
String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
|
|
|
SvcAddress svcAddress = JSON.parseObject(s, SvcAddress.class);
|
|
|
if (ObjectUtils.isEmpty(svcAddress.getGrantType())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "授权类型不能为空");
|
|
|
+ jsonObject.put("message", "授权类型不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(svcAddress.getClientId())) {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "客户端编号不能为空");
|
|
|
+ jsonObject.put("message", "客户端编号不能为空");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
AlarmHeartbeatLog alarmHeartbeatLog = new AlarmHeartbeatLog();
|
|
@@ -1323,21 +1432,21 @@ public class GeoHazardMonitorTokenController {
|
|
|
alarmHeartbeatLog.setGrantType(svcAddress.getGrantType());
|
|
|
if (alarmHeartbeatLogMapper.insert(alarmHeartbeatLog) > 0) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("cameraCode", svcAddress.getClientId());
|
|
|
+ map.put("clientId", svcAddress.getClientId());
|
|
|
jsonObject.put("resultCode", 1);
|
|
|
jsonObject.put("message", "ok");
|
|
|
jsonObject.put("data", map);
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "新增失败");
|
|
|
+ jsonObject.put("message", "新增失败");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
}
|
|
|
} else {
|
|
|
jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "token验证失败");
|
|
|
+ jsonObject.put("message", "token验证失败");
|
|
|
+ jsonObject.put("data", "");
|
|
|
return JSONObject.toJSONString(jsonObject);
|
|
|
}
|
|
|
}
|