|
@@ -220,34 +220,27 @@ public class GeoHazardMonitorTokenController {
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
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);
|
|
|
- }
|
|
|
+ AjaxResult ajaxResult1=null;
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ ajaxResult1 = new AjaxResult(0, "parameterVo参数不能为空");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
+ }
|
|
|
String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
|
|
|
ReqMsgAlarmVo reqMsgAlarmVo = JSON.parseObject(s, ReqMsgAlarmVo.class);
|
|
|
if (ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmAttr())) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "你填写的报警病害属性不符合规则!!!");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "你填写的报警病害属性不符合规则");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (!reqMsgAlarmVo.getAlarmMile().toString().matches(PATTERNS)) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "报警里程位置填写错误");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "报警里程位置填写错误");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (reqMsgAlarmVo.getLineDir() != 1 && reqMsgAlarmVo.getLineDir() != 2) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "行别填写错误");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "行别填写错误");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
LambdaQueryWrapper<BaseRailwayManagement> queryWrapper = new LambdaQueryWrapper<BaseRailwayManagement>();
|
|
|
if (!ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmRailway())) {
|
|
@@ -255,34 +248,24 @@ public class GeoHazardMonitorTokenController {
|
|
|
}
|
|
|
BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(queryWrapper);
|
|
|
if (ObjectUtils.isEmpty(baseRailwayManagement)) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "填写的报警线路编码不存在");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "填写的报警线路编码不存在");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmId())) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "报警的唯一标识不能为空");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "报警的唯一标识不能为空");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmTime())) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "报警时间不能为空");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "报警时间不能为空");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (reqMsgAlarmVo.getAlarmType() < 1 || reqMsgAlarmVo.getAlarmType() > 4) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "报警病害类型填写错误");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "报警病害类型填写错误");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (!reqMsgAlarmVo.getAlarmLevel().toString().matches(PATTERNS)) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "报警级别填写错误");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "报警级别填写错误");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (reqMsgAlarmVo.getAlarmTime().toString().length() == 10) {
|
|
|
reqMsgAlarmVo.setAlarmTime(reqMsgAlarmVo.getAlarmTime() * 1000);
|
|
@@ -299,10 +282,8 @@ public class GeoHazardMonitorTokenController {
|
|
|
List<BaseCameraManagement> baseCameraManagementList = baseCameraManagementService.list(wrapper);
|
|
|
//log.info("baseCameraManagement:{}", baseCameraManagementList);
|
|
|
if (baseCameraManagementList.size() <= 0) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "报警里程位置没有可用的相机!!!");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "报警里程位置没有可用的相机!!!");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
LambdaQueryWrapper<MsgAlarm> lw = new LambdaQueryWrapper<MsgAlarm>();
|
|
|
if (!ObjectUtils.isEmpty(reqMsgAlarmVo.getAlarmId())) {
|
|
@@ -329,16 +310,12 @@ public class GeoHazardMonitorTokenController {
|
|
|
if (files1.length > 0) {
|
|
|
for (int i = 0; i < files1.length; i++) {
|
|
|
if (ObjectUtils.isEmpty(files1[i].fileUrl)) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "上传文件地址不能为空");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "上传文件地址不能为空!!!");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (files1[i].fileType < 1 || files1[i].fileType > 3) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "文件类型填写错误");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "文件类型填写错误!!!");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
MsgAlarmExt msgAlarmExt = new MsgAlarmExt();
|
|
|
msgAlarmExt.setAlarmId(msgAlarm.getAlarmId());
|
|
@@ -370,13 +347,11 @@ public class GeoHazardMonitorTokenController {
|
|
|
msgAlarmVice.setRailwayCode(reqMsgAlarmVo.getAlarmRailway());
|
|
|
msgAlarmFrequencyService.save(msgAlarmVice);
|
|
|
}
|
|
|
- jsonObject.put("resultCode", 1);
|
|
|
- jsonObject.put("message", "ok");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(1, "ok");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
} else {
|
|
|
- jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "token验证失败");
|
|
|
- return JSONObject.toJSONString(jsonObject);
|
|
|
+ ajaxResult1 = new AjaxResult(2, "token验证失败");
|
|
|
+ return JSONObject.toJSONString(ajaxResult1);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -389,52 +364,41 @@ public class GeoHazardMonitorTokenController {
|
|
|
*/
|
|
|
@PostMapping("/api/releaseAlarm")
|
|
|
public String releaseAlarm(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
|
|
|
+ AjaxResult ajaxResult1=null;
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
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];
|
|
|
+ if (ObjectUtils.isEmpty(parameterVo)) {
|
|
|
+ ajaxResult1 = new AjaxResult(0, "parameterVo参数不能为空");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
+ }
|
|
|
String s = SM4Utils.decryptData_ECB(parameterVo.getParameter(), key);
|
|
|
ReleaseAlarmVo releaseAlarmVo = JSON.parseObject(s, ReleaseAlarmVo.class);
|
|
|
if (ObjectUtils.isEmpty(releaseAlarmVo.getAlarmId())) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "报警的唯一标识不能为空");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "报警的唯一标识不能为空");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(releaseAlarmVo.getReleaseTime())) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "解除报警时间不能为空");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "解除报警时间不能为空");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(releaseAlarmVo.getReleaseContent())) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "解除原因不能为空");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "解除原因不能为空");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(releaseAlarmVo.getReleaseTime())) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "解除人不能为空");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "解除人不能为空");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
LambdaQueryWrapper<MsgAlarm> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(MsgAlarm::getAlarmId, releaseAlarmVo.getAlarmId());
|
|
|
MsgAlarm msgAlarm = msgAlarmService.getOne(wrapper);
|
|
|
if (ObjectUtils.isEmpty(msgAlarm)) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "不存在该报警的唯一标识的数据");
|
|
|
- jsonObject.put("data", "");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "不存在该报警的唯一标识的数据");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
}
|
|
|
if (releaseAlarmVo.getReleaseTime().toString().length() == 10) {
|
|
|
releaseAlarmVo.setReleaseTime(releaseAlarmVo.getReleaseTime() * 1000);
|
|
@@ -449,20 +413,15 @@ public class GeoHazardMonitorTokenController {
|
|
|
map.put("alarmId", msgAlarm.getAlarmId());
|
|
|
if (count) {
|
|
|
map.put("releaseState", 1);
|
|
|
- jsonObject.put("resultCode", 1);
|
|
|
- jsonObject.put("message", "ok");
|
|
|
- jsonObject.put("data", map);
|
|
|
+ ajaxResult1 = new AjaxResult(1, "ok",map);
|
|
|
} else {
|
|
|
map.put("releaseState", 2);
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", map);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "失败",map);
|
|
|
}
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), key);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), key);
|
|
|
} else {
|
|
|
- jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "token验证失败");
|
|
|
- return JSONObject.toJSONString(jsonObject);
|
|
|
+ ajaxResult1 = new AjaxResult(2, "token验证失败");
|
|
|
+ return JSONObject.toJSONString(ajaxResult1);
|
|
|
}
|
|
|
}
|
|
|
|