From eafeda3c30ab282a351e3bf5ab2ce74c08506f6d Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Mon, 15 Jul 2024 11:29:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E6=8A=A5=E8=AD=A6=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/config/SecurityConfig.java | 2 + .../CodeScanningAlarmController.java | 2 +- .../service/impl/DcWarningServiceImpl.java | 37 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index ead83dcd..ea1a8073 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/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() // license .antMatchers("/license/identityCode", "/license/authentication").anonymous() + // 扫码报警 + .antMatchers( "/codeScanningAlarm/event").anonymous() // 第三方、小程序、APP //.antMatchers("/api/**").anonymous() diff --git a/zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java b/zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java index 62c9fc98..14b9cfee 100644 --- a/zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java +++ b/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()); 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.setWarningSource(UniversalEnum.FIVE.getNumber()); dcWarning.setWarningState(UniversalEnum.ONE.getNumber()); diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java index 0f823ab8..187d3c09 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java @@ -1,11 +1,14 @@ 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.redis.RedisCache; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.uuid.IdUtils; +import com.ruoyi.system.service.ISysConfigService; import com.zc.business.domain.*; import com.zc.business.enums.UniversalEnum; 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.IDcWarningService; 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.constant.WebSocketEvent; +import okhttp3.Response; import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; import org.json.JSONObject; @@ -27,6 +34,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.io.IOException; import java.util.*; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; @@ -53,6 +61,8 @@ public class DcWarningServiceImpl implements IDcWarningService private IDcTrafficPoliceService dcTrafficPoliceService; @Autowired private DcProcessConfigMapper dcProcessConfigMapper; + @Autowired + private ISysConfigService configService; @Resource private RedisCache redisCache; private final String HAPPEN = UniversalEnum.TAKE_PLACE.getValue(); @@ -516,10 +526,37 @@ public class DcWarningServiceImpl implements IDcWarningService } //推送待处理数量 dcEventService.getCountNum(); + + //扫码报警小程序 + if(dcWarning.getWarningSource() == 5){ + HashMap 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()); } + 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 public int deleteDcWarningByStringId(DcWarning dcWarning) { return dcWarningMapper.deleteDcWarningByStringId(dcWarning);