From cebdf8ede82a9b3e4f320ba515fde25bf1b71252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Wed, 10 Apr 2024 19:34:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E4=BA=A4=E9=80=9A?= =?UTF-8?q?=E7=AE=A1=E5=88=B6=20=E6=94=B6=E8=B4=B9=E7=AB=99=E8=AE=BE?= =?UTF-8?q?=E6=96=BD=20=E7=AD=89=20=E5=A4=9A=E9=80=89=20=E6=8F=92=E5=85=A5?= =?UTF-8?q?=20=E3=80=82=E4=BA=8B=E4=BB=B6=E5=A4=84=E7=BD=AE=20=E6=94=B6?= =?UTF-8?q?=E8=B4=B9=E7=AB=99=E5=A4=9A=E9=80=89=E6=8F=92=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zc/business/mapper/DcEventMapper.java | 9 ++ .../zc/business/service/IDcEventService.java | 5 + .../service/impl/DcEventServiceImpl.java | 132 ++++++++++++++---- .../mapper/business/DcEventMapper.xml | 42 ++++++ 4 files changed, 163 insertions(+), 25 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java index b4be7c31..32391683 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java @@ -51,6 +51,15 @@ public interface DcEventMapper extends BaseMapper */ int updateDcEvent(DcEvent dcEvent); + + /** + * 修改事件性质 关联管制事件id + * + * @param dcEvent 事件信息 + * @return 结果 + */ + int updateDcEventLinkId(DcEvent dcEvent); + /** * 删除事件信息 * diff --git a/zc-business/src/main/java/com/zc/business/service/IDcEventService.java b/zc-business/src/main/java/com/zc/business/service/IDcEventService.java index e97685fe..51eed49d 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcEventService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcEventService.java @@ -57,6 +57,11 @@ public interface IDcEventService */ public int updateDcEvent(DcEvent dcEvent); + /** + * @param dcEvent + * @return int + */ + /** * 批量删除事件信息 * 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 ed6bc7b9..9a789863 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 @@ -11,6 +11,7 @@ import com.zc.business.domain.*; import com.zc.business.mapper.*; import com.zc.business.service.IDcEventService; import com.zc.business.service.IMiddleDatabaseService; +import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -137,9 +138,11 @@ public class DcEventServiceImpl extends ServiceImpl impl dcEvent.setId(uuid); dcEvent.setEventState(0L); //获取部门信息 - dcEvent.setDeptId(SecurityUtils.getDeptId()); + //dcEvent.setDeptId(SecurityUtils.getDeptId()); + dcEvent.setDeptId(1l); //用户 - dcEvent.setUserId(SecurityUtils.getUserId()); + // dcEvent.setUserId(SecurityUtils.getUserId()); + dcEvent.setUserId(1l); dcEvent.setCreateTime(DateUtils.getNowDate()); @@ -180,9 +183,9 @@ public class DcEventServiceImpl extends ServiceImpl impl if (i7 > 0) { - //中间库 + /* //中间库 MdEvent mdEvent = new MdEvent(dcEvent); - middleDatabaseService.insertMiddleDatabaseEvent(mdEvent); + middleDatabaseService.insertMiddleDatabaseEvent(mdEvent);*/ switch (eventType) { //交通事故 case 1: @@ -207,57 +210,134 @@ public class DcEventServiceImpl extends ServiceImpl impl //TODO 插入多个收费站 if (dcEvent.getDcEventTrafficControl().getFacilityIds().length==1){//facilityIds==1 说明只选择了一个收费站 - if (dcEventId !=null){ + if (dcEventId !=null){//不等于空 事件处置页面 修改 dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类 - + DcEvent dcEvent1 = new DcEvent(); + dcEvent1.setId(dcEventId);//事件id + dcEvent1.setEventNature(1l);//首发事件 + dcEvent1.setLinkId(uuid);//关联管制事件id + dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + dcEvent.getDcEventTrafficControl().setId(uuid); + dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]);//取出数组字段赋值 设施id + int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl());// + }else { + + dcEvent.getDcEventTrafficControl().setId(uuid); + dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]);//取出数组字段赋值 设施id + int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl()); } - dcEvent.getDcEventTrafficControl().setId(uuid); - dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]);//取出数组字段赋值 设施id - int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl()); - }else { + }else if (dcEvent.getDcEventTrafficControl().getFacilityIds().length>1){//facilityIds1=1 说明只选择了多个收费站 + + if (dcEventId !=null){//不等于空 事件处置页面 修改 + dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类 + DcEvent dcEvent1 = new DcEvent(); + dcEvent1.setId(dcEventId);//事件id + dcEvent1.setEventNature(1l);//首发事件 + Map map = new HashMap<>(); + for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) { //设置事件Id UUID无下划线格式32 + String facilityUUID = IdUtils.fastSimpleUUID(); + map.put("facilityId"+i,facilityUUID);//每循环一次生成一个uuid + } + StringBuilder sb2 = new StringBuilder(); + // 遍历map, + int a = 0; + for (Map.Entry entry : map.entrySet()) { + sb2.append(entry.getValue()); + if (dcEvent.getDcEventTrafficControl().getFacilityIds().length-a !=1){ + sb2.append(","); + } + a++; + } + String linkId2 = sb2.toString(); + dcEvent1.setLinkId(linkId2);//关联管制事件id + + dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + + for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) { + + dcEvent.getDcEventTrafficControl().setId(map.get("facilityId"+i));//交通管制事件id + dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]);//取出数组字段赋值 设施id + // 使用StringBuilder来构建逗号分隔的字符串 + + //新增第一条数据 + dcEvent.setId(map.get("facilityId" + i)); + dcEvent.setEventState(0L); + dcEvent.setDeptId(1l); + dcEvent.setUserId(1l); + dcEvent.setCreateTime(DateUtils.getNowDate()); + dcEvent.setEventNature(2L);//关联管制 + + StringBuilder sb = new StringBuilder(); + // 遍历map,排除与当前索引i对应的键 + for (Map.Entry entry : map.entrySet()) { + if (!entry.getKey().equals("facilityId" + i)) { + if (sb.length() > 0) { + sb.append(","); + } + sb.append(entry.getValue()); + } + } + String linkId = sb.toString(); + dcEvent.setLinkId(linkId); + + //交通管制 + if (eventType == 3 && dcEvent.getDcEventTrafficControl().getFacilityIds()[i] != null) { + String facilityId = String.valueOf(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]); + dcEvent.setStakeMark(extracted(facilityId)); + } + dcEventMapper.insertDcEvent(dcEvent); + int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl()); + + } + }else { + + dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类 Map map = new HashMap<>(); for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) { //设置事件Id UUID无下划线格式32 String facilityUUID = IdUtils.fastSimpleUUID(); map.put("facilityId"+i,facilityUUID);//每循环一次生成一个uuid - Long facilityId = dcEvent.getDcEventTrafficControl().getFacilityIds()[i]; - map.put(facilityUUID, String.valueOf(facilityId));//将uuid作为主键 设施id作为 值 存放map } for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) { - dcEvent.getDcEventTrafficControl().setId(map.get("facilityId"+i));//交通管制事件id + + + dcEvent.getDcEventTrafficControl().setId(map.get("facilityId" + i));//交通管制事件id dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]);//取出数组字段赋值 设施id //新增第一条数据 - dcEvent.setId(map.get("facilityId"+i)); + dcEvent.setId(map.get("facilityId" + i)); dcEvent.setEventState(0L); - dcEvent.setDeptId(SecurityUtils.getDeptId()); - dcEvent.setUserId(SecurityUtils.getUserId()); + dcEvent.setDeptId(1l); + dcEvent.setUserId(1l); dcEvent.setCreateTime(DateUtils.getNowDate()); dcEvent.setEventNature(2L);//关联管制 + // 使用StringBuilder来构建逗号分隔的字符串 StringBuilder sb = new StringBuilder(); - boolean isFirst = true; - // 迭代Map并过滤出不为1的键对应的值 + + // 遍历map,排除与当前索引i对应的键 for (Map.Entry entry : map.entrySet()) { - if (entry.getKey() !="facilityId"+i) { - if (!isFirst) { + if (!entry.getKey().equals("facilityId" + i)) { + if (sb.length() > 0) { sb.append(","); } sb.append(entry.getValue()); - isFirst = false; } } - String linkId= sb.toString(); + + String linkId = sb.toString(); dcEvent.setLinkId(linkId); + System.out.println(linkId); + //交通管制 - if (eventType ==3 && dcEvent.getDcEventTrafficControl().getFacilityIds()[i] != null) { + if (eventType == 3 && dcEvent.getDcEventTrafficControl().getFacilityIds()[i] != null) { String facilityId = String.valueOf(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]); - dcEvent.setStakeMark( extracted(facilityId)); + dcEvent.setStakeMark(extracted(facilityId)); } dcEventMapper.insertDcEvent(dcEvent); int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl()); - + } } } @@ -574,6 +654,8 @@ public class DcEventServiceImpl extends ServiceImpl impl } + + /** * 批量删除事件信息 * diff --git a/zc-business/src/main/resources/mapper/business/DcEventMapper.xml b/zc-business/src/main/resources/mapper/business/DcEventMapper.xml index dd3fbddd..1b9d8aa3 100644 --- a/zc-business/src/main/resources/mapper/business/DcEventMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcEventMapper.xml @@ -35,6 +35,7 @@ + @@ -81,6 +82,7 @@ + @@ -164,6 +166,7 @@ longitude, dimension, event_title, + link_id, is_perceived, CASE event_type WHEN '1' THEN '交通事故' @@ -268,6 +271,7 @@ select dc_event.id AS id, dc_event.stake_mark, + dc_event.link_id, dc_event.dimension, dc_event.longitude, dc_event.direction, @@ -373,6 +377,7 @@ /*详情可以调用事件处理流程*/ SELECT dc_event.id AS id, dc_event.stake_mark, + dc_event.link_id, CASE dc_event.direction WHEN '1' THEN '菏泽方向' WHEN '3' THEN '济南方向' @@ -528,6 +533,7 @@ is_perceived, dimension, longitude, + link_id, #{id}, @@ -558,6 +564,7 @@ #{isPerceived}, #{dimension}, #{longitude}, + #{linkId}, @@ -656,6 +663,41 @@ is_perceived = #{isPerceived}, dimension = #{dimension}, longitude = #{longitude}, + link_id = #{linkId}, + + where id = #{id} + + + update dc_event + + dept_id = #{deptId}, + stake_mark = #{stakeMark}, + direction = #{direction}, + user_id = #{userId}, + start_time = #{startTime}, + end_time = #{endTime}, + estimated_end_time = #{estimatedEndTime}, + event_level = #{eventLevel}, + event_type = #{eventType}, + event_subclass = #{eventSubclass}, + event_cause = #{eventCause}, + description = #{description}, + event_state = #{eventState}, + event_source = #{eventSource}, + remark = #{remark}, + create_time = #{createTime}, + update_time = #{updateTime}, + event_source_tips = #{eventSourceTips}, + in_tunnel = #{inTunnel}, + road_id = #{roadId}, + road_id = #{lang}, + event_title = #{eventTitle}, + occurrence_time = #{occurrenceTime}, + is_perceived = #{isPerceived}, + dimension = #{dimension}, + + event_nature = #{eventNature}, + link_id = #{linkId}, where id = #{id}