From ee7eb850b82506106b1f9e05372f64db749c9581 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Tue, 19 Mar 2024 11:52:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=AB=E7=A0=81=E6=8A=A5?= =?UTF-8?q?=E8=AD=A6=E4=B8=8A=E4=BC=A0=E6=95=B0=E6=8D=AE=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CodeScanningAlarmController.java | 90 ++++++++++--------- .../zc/business/mapper/DcWarningMapper.java | 18 ++-- .../business/service/IDcWarningService.java | 18 ++-- .../service/impl/DcWarningServiceImpl.java | 11 ++- .../mapper/business/DcWarningMapper.xml | 10 +-- 5 files changed, 77 insertions(+), 70 deletions(-) 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 138b31b7..a8cbac0b 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 @@ -1,8 +1,8 @@ package com.zc.business.controller; +import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.utils.uuid.IdUtils; import com.zc.business.domain.DcWarning; import com.zc.business.service.IDcWarningService; import io.swagger.annotations.Api; @@ -36,49 +36,53 @@ public class CodeScanningAlarmController extends BaseController { */ @PostMapping(value = "/event") public AjaxResult codeScanningAlarmControllerEvent(@RequestBody Map returnParameters) { + String id = String.valueOf(returnParameters.get("id")); DcWarning dcWarning = new DcWarning(); - //设置事件Id UUID无下划线格式32 - String uuid = IdUtils.fastSimpleUUID(); - dcWarning.setId(uuid); - dcWarning.setStakeMark(String.valueOf(returnParameters.get("stakeNum"))); - String roadCode = String.valueOf(returnParameters.get("roadCode")); - dcWarning.setDirection(Objects.equals(roadCode, "1") ? "3" : "1"); - String createTime = String.valueOf(returnParameters.get("createTime")); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmXXX"); - try { - dcWarning.setWarningTime(format.parse(createTime)); - } catch (ParseException e) { - dcWarning.setWarningTime(new Date()); + dcWarning.setId(id); + dcWarning.setOtherConfig(String.valueOf(JSONObject.parseObject(JSONObject.toJSONString(returnParameters)))); + if (dcWarningService.selectDcWarningById(id) == null) { + dcWarning.setStakeMark(String.valueOf(returnParameters.get("stakeNum"))); + String roadCode = String.valueOf(returnParameters.get("roadCode")); + dcWarning.setDirection(Objects.equals(roadCode, "1") ? "3" : "1"); + String createTime = String.valueOf(returnParameters.get("createTime")); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmXXX"); + try { + dcWarning.setWarningTime(format.parse(createTime)); + } catch (ParseException e) { + dcWarning.setWarningTime(new Date()); + } + dcWarning.setCreateTime(new Date()); + String accidentType = String.valueOf(returnParameters.get("accidentType")); + switch (accidentType) { + case "1"://车辆炸胎(无备胎) + dcWarning.setWarningType(11); + dcWarning.setWarningSubclass("11-3"); + break; + case "2"://车辆炸胎(有备胎) + dcWarning.setWarningType(11); + dcWarning.setWarningSubclass("11-2"); + break; + case "3"://车辆抛锚 + dcWarning.setWarningType(11); + dcWarning.setWarningSubclass("11-1"); + break; + case "4"://单车事故 + dcWarning.setWarningType(10); + dcWarning.setWarningSubclass("10-2"); + break; + case "5"://多车事故 + dcWarning.setWarningType(10); + dcWarning.setWarningSubclass("10-3"); + break; + } + String warningTitle = "济荷高速:" + (Objects.equals(roadCode, "1") ? "济南方向" : "菏泽方向") + "发生" + (Integer.parseInt(accidentType) >= 4 ? "交通事故事件" : "车辆故障事件"); + dcWarning.setWarningTitle(warningTitle); + dcWarning.setWarningSource(5); + dcWarning.setWarningState(1); + return AjaxResult.success(dcWarningService.insertDcWarning(dcWarning)); + } else { + return AjaxResult.success(dcWarningService.updateDcWarning(dcWarning)); } - dcWarning.setCreateTime(new Date()); - String accidentType = String.valueOf(returnParameters.get("accidentType")); - switch (accidentType) { - case "1"://车辆炸胎(无备胎) - dcWarning.setWarningType(11); - dcWarning.setWarningSubclass("11-3"); - break; - case "2"://车辆炸胎(有备胎) - dcWarning.setWarningType(11); - dcWarning.setWarningSubclass("11-2"); - break; - case "3"://车辆抛锚 - dcWarning.setWarningType(11); - dcWarning.setWarningSubclass("11-1"); - break; - case "4"://单车事故 - dcWarning.setWarningType(10); - dcWarning.setWarningSubclass("10-2"); - break; - case "5"://多车事故 - dcWarning.setWarningType(10); - dcWarning.setWarningSubclass("10-3"); - break; - } - String warningTitle = "济荷高速:" + (Objects.equals(roadCode, "1") ? "济南方向" : "菏泽方向") + "发生" + (Integer.parseInt(accidentType) >= 4 ? "交通事故事件" : "车辆故障事件"); - dcWarning.setWarningTitle(warningTitle); - dcWarning.setOtherConfig(returnParameters.toString()); - dcWarning.setWarningSource(5); - dcWarning.setWarningState(1); - return AjaxResult.success(dcWarningService.insertDcWarning(dcWarning)); } + } diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java index 35aaf365..70c353a1 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java @@ -7,23 +7,23 @@ import org.apache.ibatis.annotations.Param; /** * 预警信息Mapper接口 - * + * * @author ruoyi * @date 2024-01-26 */ -public interface DcWarningMapper +public interface DcWarningMapper { /** * 查询预警信息 - * + * * @param id 预警信息主键 * @return 预警信息 */ - public HashMap selectDcWarningById(Integer id); + public DcWarning selectDcWarningById(String id); /** * 查询预警信息列表 - * + * * @param dcWarning 预警信息 * @return 预警信息集合 */ @@ -32,7 +32,7 @@ public interface DcWarningMapper List export(DcWarning dcWarning); /** * 新增预警信息 - * + * * @param dcWarning 预警信息 * @return 结果 */ @@ -40,7 +40,7 @@ public interface DcWarningMapper /** * 修改预警信息 - * + * * @param dcWarning 预警信息 * @return 结果 */ @@ -48,7 +48,7 @@ public interface DcWarningMapper /** * 删除预警信息 - * + * * @param id 预警信息主键 * @return 结果 */ @@ -56,7 +56,7 @@ public interface DcWarningMapper /** * 批量删除预警信息 - * + * * @param id 需要删除的数据主键集合 * @return 结果 */ diff --git a/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java b/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java index 7d2650ad..8ad61ccc 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java @@ -10,23 +10,23 @@ import org.springframework.web.bind.annotation.RequestBody; /** * 预警信息Service接口 - * + * * @author ruoyi * @date 2024-01-26 */ -public interface IDcWarningService +public interface IDcWarningService { /** * 查询预警信息 - * + * * @param id 预警信息主键 * @return 预警信息 */ - public HashMap selectDcWarningById(Integer id); + public DcWarning selectDcWarningById(String id); /** * 查询预警信息列表 - * + * * @param dcWarning 预警信息 * @return 预警信息集合 */ @@ -35,7 +35,7 @@ public interface IDcWarningService List export(DcWarning dcWarning); /** * 新增预警信息 - * + * * @param dcWarning 预警信息 * @return 结果 */ @@ -43,7 +43,7 @@ public interface IDcWarningService /** * 修改预警信息 - * + * * @param dcWarning 预警信息 * @return 结果 */ @@ -51,7 +51,7 @@ public interface IDcWarningService /** * 批量删除预警信息 - * + * * @param id 需要删除的预警信息主键集合 * @return 结果 */ @@ -59,7 +59,7 @@ public interface IDcWarningService /** * 删除预警信息信息 - * + * * @param id 预警信息主键 * @return 结果 */ 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 e2e1e7c9..e439ee16 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 @@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.uuid.IdUtils; +import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcEvent; import com.zc.business.domain.DcWarning; import com.zc.business.domain.DcWarningBatchConvert; @@ -44,7 +45,7 @@ public class DcWarningServiceImpl implements IDcWarningService * @return 预警信息 */ @Override - public HashMap selectDcWarningById(Integer id) + public DcWarning selectDcWarningById(String id) { return dcWarningMapper.selectDcWarningById(id); } @@ -76,9 +77,11 @@ public class DcWarningServiceImpl implements IDcWarningService public int insertDcWarning(DcWarning dcWarning) { dcWarning.setCreateTime(DateUtils.getNowDate()); - //设置事件Id UUID无下划线格式32 - String uuid = IdUtils.fastSimpleUUID(); - dcWarning.setId(uuid); + if (dcWarning.getId()==null) { + //设置事件Id UUID无下划线格式32 + String uuid = IdUtils.fastSimpleUUID(); + dcWarning.setId(uuid); + } return dcWarningMapper.insertDcWarning(dcWarning); } diff --git a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml index 255812b2..070a93bd 100644 --- a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - where id = #{id} @@ -198,4 +198,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - \ No newline at end of file +