From 46095c229d3db96c3fec8b98341e33ff11717f67 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Mon, 24 Jun 2024 10:52:41 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=85=B3=E8=81=94=E7=AE=A1=E5=88=B6=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95=202.=E4=BE=A7?= =?UTF-8?q?=E9=87=8D=E8=A6=81=E7=B4=A0=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zc/business/enums/ValueConverter.java | 21 +++++ .../impl/DcEventImportantServiceImpl.java | 63 ++++++++++++++- .../service/impl/DcEventServiceImpl.java | 77 ++++++++++++++++++- 3 files changed, 157 insertions(+), 4 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/enums/ValueConverter.java b/zc-business/src/main/java/com/zc/business/enums/ValueConverter.java index d539ef4a..e146a163 100644 --- a/zc-business/src/main/java/com/zc/business/enums/ValueConverter.java +++ b/zc-business/src/main/java/com/zc/business/enums/ValueConverter.java @@ -30,6 +30,8 @@ public class ValueConverter { private static final Map eventSubclassName = new HashMap<>(); // 事件字段 private static final Map eventLabel = new HashMap<>(); + // 事件侧重要素字段 + private static final Map eventImportantLabel = new HashMap<>(); static { valueMappingSource.put(1,5); @@ -287,6 +289,18 @@ public class ValueConverter { eventLabel.put("dcEventTrafficControl.classify","分类"); eventLabel.put("dcEventTrafficControl.limitedType","限制类型"); // eventLabel.put("dcEventTrafficControl.vehicleType","车辆类型"); + + + eventImportantLabel.put("plateNumber","车型及车牌号"); + eventImportantLabel.put("diversionPoint","分流点名称及桩号"); + eventImportantLabel.put("currentProgress","目前处置进度"); + eventImportantLabel.put("takeSteps","已采取的措施"); + eventImportantLabel.put("planStatus","是否启动应急预案"); + eventImportantLabel.put("trafficPoliceStatus","交警是否到达"); + eventImportantLabel.put("medicalStatus","医疗是否到达"); + eventImportantLabel.put("boardStatus","是否做好情报板提示"); + eventImportantLabel.put("chemicalsStatus","是否有危化品泄露"); + eventImportantLabel.put("fireStatus","消防是否到达"); } } @@ -312,6 +326,9 @@ public class ValueConverter { public static Map getEventLabel() { return ValueMappingHolder.eventLabel; } + public static Map getEventImportantLabel() { + return ValueMappingHolder.eventImportantLabel; + } public static Map getEventSubclassName() { return ValueMappingHolder.eventSubclassName; @@ -354,6 +371,10 @@ public class ValueConverter { Map mapping = getEventSubclassName(); return mapping.getOrDefault(inputValue, inputValue); } + public static String eventImportantLabel(String inputValue) { + Map mapping = getEventImportantLabel(); + return mapping.getOrDefault(inputValue, ""); + } //测试 // @Test diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantServiceImpl.java index b0bc219e..86711668 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantServiceImpl.java @@ -1,13 +1,19 @@ package com.zc.business.service.impl; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; +import com.alibaba.fastjson.JSON; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.StringUtils; +import com.zc.business.domain.*; +import com.zc.business.enums.ValueConverter; +import com.zc.business.utils.diff.Diff; +import com.zc.business.utils.diff.model.Result; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.zc.business.mapper.DcEventImportantMapper; -import com.zc.business.domain.DcEventImportant; import com.zc.business.service.IDcEventImportantService; /** @@ -21,6 +27,8 @@ public class DcEventImportantServiceImpl implements IDcEventImportantService { @Autowired private DcEventImportantMapper dcEventImportantMapper; + @Autowired + private DcEventProcessServiceImpl dcEventProcessService; /** * 查询事件侧重要素 @@ -70,10 +78,23 @@ public class DcEventImportantServiceImpl implements IDcEventImportantService if (StringUtils.isEmpty(dcEventImportant.getEventId())){ return AjaxResult.error("事件id不能为空"); } - int i = dcEventImportantMapper.updateDcEventImportant(dcEventImportant); - if (i < 1){ + DcEventImportant oldData = dcEventImportantMapper.selectDcEventImportantByEventId(dcEventImportant.getEventId()); + if (oldData != null){ + dcEventImportantMapper.updateDcEventImportant(dcEventImportant); + } else { dcEventImportantMapper.insertDcEventImportant(dcEventImportant); } + + String context = comparisonInfo(oldData,dcEventImportant); + if (context.length() > 0) { + //事件处置流程记录 + DcEventProcess dcEventProcess = new DcEventProcess(); + dcEventProcess.setEventId(dcEventImportant.getEventId()); + dcEventProcess.setSource(1); + dcEventProcess.setContext(context); + dcEventProcessService.insertDcEventProcess(dcEventProcess); + } + return AjaxResult.success("侧重要素添加成功"); } @@ -100,4 +121,40 @@ public class DcEventImportantServiceImpl implements IDcEventImportantService { return dcEventImportantMapper.deleteDcEventImportantByEventId(id); } + + public String comparisonInfo(DcEventImportant oldData, DcEventImportant newData) { + String context = "上报侧重要素,"; + if (oldData == null ) { + oldData = new DcEventImportant(); + } + Diff diff = new Diff(); + List diffList = diff.diff(JSON.toJSON(oldData).toString(), JSON.toJSON(newData).toString()); + for (Result result : diffList) { + if ("ADD".equals(result.getDiffType()) || "MODIFY".equals(result.getDiffType())) { + if ("planStatus".equals(result.getRightPath()) + || "trafficPoliceStatus".equals(result.getRightPath()) + || "medicalStatus".equals(result.getRightPath()) + || "boardStatus".equals(result.getRightPath()) + || "chemicalsStatus".equals(result.getRightPath()) + || "fireStatus".equals(result.getRightPath())) { + if ("0".equals(result.getRight())) { + result.setRight("否"); + } else if ("1".equals(result.getRight())) { + result.setRight("是"); + } + } + String label = ValueConverter.eventImportantLabel(result.getRightPath()); + if (StringUtils.isNotEmpty(label)) { + context = context + label + "修改为:" + result.getRight() + ","; + } + } + } + + if (context.length() > 0) { + context = context.substring(0, context.length() - 1); + } + + + return context; + } } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java index 9d9db46a..2c61d4ff 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java @@ -294,7 +294,39 @@ public class DcEventServiceImpl extends ServiceImpl impl dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 } } - + DcEventProcess dcEventProcess = new DcEventProcess(); + dcEventProcess.setEventId(dcEventId); + dcEventProcess.setSource(1); + String context = "新增管制事件:"; + if ("3-1".equals(dcEvent.getSubclass())){ + context += dcEvent.getStakeMark(); + if ("1".equals(dcEvent.getDirection())){ + context += "菏泽方向"; + } else if ("3".equals(dcEvent.getDirection())){ + context += "菏泽方向"; + } + if (dcEvent.getDcEventTrafficControl().getControlType() == 1){ + context += "主线封闭"; + } else { + context += "主线限行"; + } + } else if ("3-3".equals(dcEvent.getSubclass()) || "3-4".equals(dcEvent.getSubclass())){ + String facilityId = String.valueOf(dcEvent.getDcEventTrafficControl().getFacilityId()); + DcFacility facility = dcFacilityService.getFacility(facilityId); + context += facility.getFacilityName(); + if ("1".equals(dcEvent.getDirection())){ + context += "菏泽方向"; + } else if ("3".equals(dcEvent.getDirection())){ + context += "菏泽方向"; + } + if (dcEvent.getDcEventTrafficControl().getControlType() == 1){ + context += "封闭"; + } else { + context += "限行"; + } + } + dcEventProcess.setContext(context); + dcEventProcessService.insertDcEventProcess(dcEventProcess); break; } @@ -322,6 +354,27 @@ public class DcEventServiceImpl extends ServiceImpl impl int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl());// //首页事件 交通管制事件 添加 状态默认为 1 处置中 updateDcEventState(dcEvent.getId(), 1); + + DcEventProcess dcEventProcess = new DcEventProcess(); + dcEventProcess.setEventId(dcEventId); + dcEventProcess.setSource(1); + String context = "新增管制事件:"; + String facilityId = String.valueOf(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]); + DcFacility facility = dcFacilityService.getFacility(facilityId); + context += facility.getFacilityName(); + if ("1".equals(dcEvent.getDirection())){ + context += "菏泽方向"; + } else if ("3".equals(dcEvent.getDirection())){ + context += "菏泽方向"; + } + if (dcEvent.getDcEventTrafficControl().getControlType() == 1){ + context += "封闭"; + } else { + context += "限行"; + } + dcEventProcess.setContext(context); + dcEventProcessService.insertDcEventProcess(dcEventProcess); + } else { // extracted(dcEvent);//事件推送到 首页 @@ -408,6 +461,28 @@ public class DcEventServiceImpl extends ServiceImpl impl updateDcEventState(map.get("facilityId" + i),1);//直接确认 } + DcEventProcess dcEventProcess = new DcEventProcess(); + dcEventProcess.setEventId(dcEventId); + dcEventProcess.setSource(1); + String context = "新增管制事件:"; + Long[] facilityIds = dcEvent.getDcEventTrafficControl().getFacilityIds(); + for (Long facilityId : facilityIds) { + DcFacility facility = dcFacilityService.getFacility(facilityId.toString()); + context += facility.getFacilityName() + "、"; + } + context = context.substring(0,context.length() -1); + if ("1".equals(dcEvent.getDirection())){ + context += "菏泽方向"; + } else if ("3".equals(dcEvent.getDirection())){ + context += "菏泽方向"; + } + if (dcEvent.getDcEventTrafficControl().getControlType() == 1){ + context += "封闭"; + } else { + context += "限行"; + } + dcEventProcess.setContext(context); + dcEventProcessService.insertDcEventProcess(dcEventProcess); } else { dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类