Browse Source

扫码报警事件对接

develop
lau572 4 months ago
parent
commit
eafeda3c30
  1. 2
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
  2. 2
      zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java
  3. 37
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

2
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@ -140,6 +140,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/captcha/get", "/captcha/check", "/captchaConfig").anonymous() .antMatchers("/captcha/get", "/captcha/check", "/captchaConfig").anonymous()
// license // license
.antMatchers("/license/identityCode", "/license/authentication").anonymous() .antMatchers("/license/identityCode", "/license/authentication").anonymous()
// 扫码报警
.antMatchers( "/codeScanningAlarm/event").anonymous()
// 第三方、小程序、APP // 第三方、小程序、APP
//.antMatchers("/api/**").anonymous() //.antMatchers("/api/**").anonymous()

2
zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java

@ -79,7 +79,7 @@ public class CodeScanningAlarmController extends BaseController {
dcWarning.setWarningSubclass(UniversalEnum.TEN_THREE.getValue()); dcWarning.setWarningSubclass(UniversalEnum.TEN_THREE.getValue());
break; break;
} }
String warningTitle = "济荷高速:" + (Objects.equals(roadCode, UniversalEnum.ONE.getValue()) ? UniversalEnum.DIRECTION_OF_JINAN.getValue() : UniversalEnum.DIRECTION_OF_HEZE.getValue()) + "发生" + (Integer.parseInt(accidentType) >= 4 ? UniversalEnum.TRAFFIC_ACCIDENT_EVENT.getValue() : UniversalEnum.VEHICLE_BREAKDOWN_EVENT.getValue()); String warningTitle = "G35济菏高速" + dcWarning.getStakeMark() + (Objects.equals(roadCode, UniversalEnum.ONE.getValue()) ? UniversalEnum.DIRECTION_OF_JINAN.getValue() : UniversalEnum.DIRECTION_OF_HEZE.getValue()) + "发生" + (Integer.parseInt(accidentType) >= 4 ? UniversalEnum.TRAFFIC_ACCIDENT_EVENT.getValue() : UniversalEnum.VEHICLE_BREAKDOWN_EVENT.getValue());
dcWarning.setWarningTitle(warningTitle); dcWarning.setWarningTitle(warningTitle);
dcWarning.setWarningSource(UniversalEnum.FIVE.getNumber()); dcWarning.setWarningSource(UniversalEnum.FIVE.getNumber());
dcWarning.setWarningState(UniversalEnum.ONE.getNumber()); dcWarning.setWarningState(UniversalEnum.ONE.getNumber());

37
zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

@ -1,11 +1,14 @@
package com.zc.business.service.impl; package com.zc.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.google.gson.JsonObject;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.service.ISysConfigService;
import com.zc.business.domain.*; import com.zc.business.domain.*;
import com.zc.business.enums.UniversalEnum; import com.zc.business.enums.UniversalEnum;
import com.zc.business.enums.ValueConverter; import com.zc.business.enums.ValueConverter;
@ -17,8 +20,12 @@ import com.zc.business.service.IDcEventService;
import com.zc.business.service.IDcTrafficPoliceService; import com.zc.business.service.IDcTrafficPoliceService;
import com.zc.business.service.IDcWarningService; import com.zc.business.service.IDcWarningService;
import com.zc.business.utils.StakeMarkUtils; import com.zc.business.utils.StakeMarkUtils;
import com.zc.common.core.httpclient.OkHttp;
import com.zc.common.core.httpclient.exception.HttpException;
import com.zc.common.core.httpclient.request.RequestParams;
import com.zc.common.core.websocket.WebSocketService; import com.zc.common.core.websocket.WebSocketService;
import com.zc.common.core.websocket.constant.WebSocketEvent; import com.zc.common.core.websocket.constant.WebSocketEvent;
import okhttp3.Response;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -27,6 +34,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -53,6 +61,8 @@ public class DcWarningServiceImpl implements IDcWarningService
private IDcTrafficPoliceService dcTrafficPoliceService; private IDcTrafficPoliceService dcTrafficPoliceService;
@Autowired @Autowired
private DcProcessConfigMapper dcProcessConfigMapper; private DcProcessConfigMapper dcProcessConfigMapper;
@Autowired
private ISysConfigService configService;
@Resource @Resource
private RedisCache redisCache; private RedisCache redisCache;
private final String HAPPEN = UniversalEnum.TAKE_PLACE.getValue(); private final String HAPPEN = UniversalEnum.TAKE_PLACE.getValue();
@ -516,10 +526,37 @@ public class DcWarningServiceImpl implements IDcWarningService
} }
//推送待处理数量 //推送待处理数量
dcEventService.getCountNum(); dcEventService.getCountNum();
//扫码报警小程序
if(dcWarning.getWarningSource() == 5){
HashMap<String, Object> warningInfo = dcWarningMapper.selectDcWarningById(dcWarning.getId());
com.alibaba.fastjson.JSONObject otherConfig = com.alibaba.fastjson.JSONObject.parseObject(warningInfo.get("otherConfig").toString());
String alarmId = otherConfig.getString("id");
if (StringUtils.isNotBlank(alarmId)) {
try {
AjaxResult alarmResult = dealWarning(alarmId);
System.out.println(alarmResult);
} catch (IOException | HttpException e) {
e.printStackTrace();
}
}
}
return AjaxResult.success(UniversalEnum.SUCCESSFUL_OPERATION.getValue()); return AjaxResult.success(UniversalEnum.SUCCESSFUL_OPERATION.getValue());
} }
public AjaxResult dealWarning(String alarmId) throws IOException, HttpException {
String url = configService.selectConfigByKey("alarmCode");
url = url + "/warning/dealWarning/" + alarmId;
OkHttp okHttp = new OkHttp();
Response response // 请求响应
= okHttp
.headers(new HashMap<>())
.url(url) // 请求地址
.put(); // 请求方法
return JSON.parseObject(response.body().string(), AjaxResult.class);
}
@Override @Override
public int deleteDcWarningByStringId(DcWarning dcWarning) { public int deleteDcWarningByStringId(DcWarning dcWarning) {
return dcWarningMapper.deleteDcWarningByStringId(dcWarning); return dcWarningMapper.deleteDcWarningByStringId(dcWarning);

Loading…
Cancel
Save