From 549a736a4ba2aed302127b41a6ae1c7e914ea265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Thu, 30 May 2024 11:07:10 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=B0=83=E5=BA=A6=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=EF=BC=8C=E6=94=B6=E8=B4=B9=E7=AB=99=EF=BC=88=20=E5=89=94?= =?UTF-8?q?=E9=99=A4=E9=97=A8=E6=9E=B6=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcEventController.java | 9 +++ .../java/com/zc/business/domain/DcEvent.java | 69 +++++++++++-------- .../com/zc/business/mapper/DcEventMapper.java | 2 + .../business/mapper/DcEventProcessMapper.java | 2 + .../service/IDcEventProcessService.java | 2 + .../zc/business/service/IDcEventService.java | 2 + .../impl/DcEventProcessServiceImpl.java | 5 ++ .../service/impl/DcEventServiceImpl.java | 42 +++++++++-- .../service/impl/DcFacilityServiceImpl.java | 2 +- .../mapper/business/DcEventMapper.xml | 38 ++++++++++ .../mapper/business/DcEventProcessMapper.xml | 5 ++ 11 files changed, 142 insertions(+), 36 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcEventController.java b/zc-business/src/main/java/com/zc/business/controller/DcEventController.java index 629bf40c..6c024945 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcEventController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcEventController.java @@ -204,4 +204,13 @@ public class DcEventController extends BaseController public AjaxResult skipClear(@ApiParam(value="事件id", name="eventId", required=true) @RequestParam ("eventId") String eventId){ return dcEventService.skipClear(eventId); } + + @ApiOperation("调度记录-事件列表 按时间展示交通事件,默认当天时间 。可查询条件 交通事件状态 ,时间范围") + @GetMapping("/dispatchRecordEventList") + public TableDataInfo dispatchRecordEventList(DcEvent dcEvent){ + + List list = dcEventService.dispatchRecordEventList(dcEvent); + return getDataTable(list); + } + } diff --git a/zc-business/src/main/java/com/zc/business/domain/DcEvent.java b/zc-business/src/main/java/com/zc/business/domain/DcEvent.java index fd84070d..14f05f49 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcEvent.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcEvent.java @@ -1,16 +1,16 @@ package com.zc.business.domain; -import java.util.Date; -import java.util.List; - import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import com.ruoyi.common.annotation.Excel; + +import java.util.Date; +import java.util.List; /** * 事件信息对象 dc_event @@ -58,8 +58,8 @@ public class DcEvent { * 2-中 * 3-下 */ - @Excel(name = "方向", readConverterExp = "1=菏泽方向,3=济南方向") - //@Excel(name = "方向") + @Excel(name = "方向", readConverterExp = "1=菏泽方向,3=济南方向") + //@Excel(name = "方向") @ApiModelProperty("方向") private String direction; @@ -69,7 +69,7 @@ public class DcEvent { @ApiModelProperty("处理人员") private Long userId; - @ApiModelProperty("事件子类") + @ApiModelProperty("事件子类") private String eventSubclassName; /** @@ -156,12 +156,12 @@ public class DcEvent { private String description; /** * 事件状态: - 事件状态: - 0-待确认 - 1-已确认 - 2-处理中 - 3-已完成 - 4-已撤销 + * 事件状态: + * 0-待确认 + * 1-已确认 + * 2-处理中 + * 3-已完成 + * 4-已撤销 */ @ApiModelProperty("事件状态 事件状态:* 0-未解决1-已解决2-已关闭") private Long eventState; @@ -200,7 +200,7 @@ public class DcEvent { /** * 是否处在隧道 */ - @Excel(name = "是否处在隧道" , readConverterExp = "0=否,1=是") + @Excel(name = "是否处在隧道", readConverterExp = "0=否,1=是") @ApiModelProperty("是否处在隧道 0 表示 false,1 表示 true") private Integer inTunnel; //@Excel(name = "高速") @@ -214,27 +214,27 @@ public class DcEvent { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty("发生时间") private Date occurrenceTime; - @Excel(name = "是否是感知事件" , readConverterExp = "0=否,1=是") + @Excel(name = "是否是感知事件", readConverterExp = "0=否,1=是") @ApiModelProperty("是否是感知事件 0 表示 false,1 表示 true") private Integer isPerceived; @Excel(name = "影响车道") - @ApiModelProperty("影响车道 车道占用:0-应急1-行1,2-行2,3-行3,4-行4") + @ApiModelProperty("影响车道 车道占用:0-应急1-行1,2-行2,3-行3,4-行4") private String lang; @ApiModelProperty("高速名") @TableField(exist = false) - private String roadName; + private String roadName; @ApiModelProperty("机构") @TableField(exist = false) - private String organizationName; + private String organizationName; @ApiModelProperty("事件流程") @TableField(exist = false) - private List processConfigList; -@ApiModelProperty("事件标题") + private List processConfigList; + @ApiModelProperty("事件标题") private String eventTitle; -@ApiModelProperty("维度") + @ApiModelProperty("维度") private String dimension; -@ApiModelProperty("经度") + @ApiModelProperty("经度") private String longitude; /** * 2014/2/21新增 @@ -291,20 +291,29 @@ public class DcEvent { private String processNode; - - /** 更新时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date updateTime; - /** 创建时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; - /** 备注 */ + /** + * 备注 + */ private String remark; private String subclass; -@ApiModelProperty("关联管制事件id") -private String linkId; + @ApiModelProperty("关联管制事件id") + private String linkId; + + @TableField(exist = false) + private List dcEventProcessList; + } 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 89f211a9..63ed43a8 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 @@ -119,6 +119,8 @@ public interface DcEventMapper extends BaseMapper boolean completeEvent(@Param("eventId") String eventId); int selectClearInfo(String eventId); + + List dispatchRecordEventList(DcEvent dcEvent); } diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcEventProcessMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcEventProcessMapper.java index 4a00c447..7e4798d9 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcEventProcessMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcEventProcessMapper.java @@ -87,4 +87,6 @@ public interface DcEventProcessMapper * @return 状态 0未完成 1已完成 */ int selectPreviousNodeStatus(@Param("eventId") String eventId, @Param("processId") Long processId); + + List selectDcEventProcessByEventId(String eventId); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcEventProcessService.java b/zc-business/src/main/java/com/zc/business/service/IDcEventProcessService.java index 3d261edd..91948483 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcEventProcessService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcEventProcessService.java @@ -83,4 +83,6 @@ public interface IDcEventProcessService * @return status 0未完成 1已完成 */ int selectPreviousNodeStatus(String eventId, Long processId); + + List selectDcEventProcessByEventId(String eventId); } 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 058a6469..9a740f91 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 @@ -127,4 +127,6 @@ public interface IDcEventService * @return com.ruoyi.common.core.domain.AjaxResult */ AjaxResult skipClear(String eventId); + + List dispatchRecordEventList(DcEvent dcEvent); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java index 6dd2a68c..bddefec7 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java @@ -163,4 +163,9 @@ public class DcEventProcessServiceImpl implements IDcEventProcessService return dcEventProcessMapper.selectPreviousNodeStatus(eventId,processId); } + @Override + public List selectDcEventProcessByEventId(String eventId) { + return dcEventProcessMapper.selectDcEventProcessByEventId(eventId); + } + } 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 0fafc02c..453f9260 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 @@ -245,11 +245,25 @@ public class DcEventServiceImpl extends ServiceImpl impl updateDcEventState(dcEvent.getId(), 1); dcEvent.getDcEventTrafficControl().setId(uuid); int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl()); - DcEvent dcEvent1 = new DcEvent(); - dcEvent1.setId(dcEventId);//事件id - dcEvent1.setEventNature(1l);//首发事件 - dcEvent1.setLinkId(uuid);//关联管制事件id - dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + //查询事件 + DcEvent dcEvent2 = dcEventMapper.selectDcEventById(dcEventId); + //判断事件 关联事件id是否为空 + if (dcEvent2.getLinkId()==null){ + DcEvent dcEvent1 = new DcEvent(); + dcEvent1.setId(dcEventId);//事件id + dcEvent1.setEventNature(1l);//首发事件 + dcEvent1.setLinkId(uuid);//关联管制事件id + dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + }else { + + DcEvent dcEvent1 = new DcEvent(); + dcEvent1.setId(dcEventId);//事件id + dcEvent1.setEventNature(1l);//首发事件 + dcEvent1.setLinkId(dcEvent2.getLinkId()+","+uuid);//关联管制事件id + dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + } + + break; } // 插入多个收费站 @@ -261,6 +275,7 @@ public class DcEventServiceImpl extends ServiceImpl impl 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());// @@ -1762,6 +1777,23 @@ public class DcEventServiceImpl extends ServiceImpl impl return AjaxResult.success("无需清障成功"); } + /** + * 调度记录 + * @param dcEvent + * @return + */ + @Override + public List dispatchRecordEventList(DcEvent dcEvent) { + dcEvent.setEventState(2l); + List dcEvents = dcEventMapper.dispatchRecordEventList(dcEvent); + for (DcEvent event : dcEvents) { + List dcEventProcess= dcEventProcessService.selectDcEventProcessByEventId(event.getId()); + event.setDcEventProcessList(dcEventProcess); + } + + return dcEvents; + } + //时间比对 public static String getDatePoor(Date endDate, Date nowDate) { diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcFacilityServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcFacilityServiceImpl.java index 4737cc8d..4f1338ee 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcFacilityServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcFacilityServiceImpl.java @@ -50,7 +50,7 @@ public class DcFacilityServiceImpl extends ServiceImpl + \ No newline at end of file diff --git a/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml b/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml index 6a7ea7fb..68376d4f 100644 --- a/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml @@ -150,4 +150,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where event_id = #{eventId} and process_type = '1' and process_id = #{processId} - 1 + + \ No newline at end of file From cb77b40acd1a4c5b3606d39ec8f2bb040a1768d3 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Thu, 30 May 2024 14:51:46 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=85=B3=E8=81=94?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcEventController.java | 14 +++++++++ .../zc/business/service/IDcEventService.java | 10 ++++++ .../service/impl/DcEventServiceImpl.java | 31 +++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcEventController.java b/zc-business/src/main/java/com/zc/business/controller/DcEventController.java index 6c024945..8fe87c39 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcEventController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcEventController.java @@ -213,4 +213,18 @@ public class DcEventController extends BaseController return getDataTable(list); } + + /** + * @Description 查询关联事件 + * + * @author liuwenge + * @date 2024/5/30 14:27 + * @param eventId + * @return com.ruoyi.common.core.domain.AjaxResult + */ + @ApiOperation("查询关联事件") + @GetMapping( "/getLinkEvent/{eventId}") + public AjaxResult getLinkEvent(@ApiParam(name = "eventId", value = "事件id", required = true) @PathVariable("eventId") String eventId){ + return dcEventService.getLinkEvent(eventId); + } } 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 9a740f91..8d5d5933 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 @@ -128,5 +128,15 @@ public interface IDcEventService */ AjaxResult skipClear(String eventId); + /** + * @Description 查询关联事件 + * + * @author liuwenge + * @date 2024/5/30 14:28 + * @param eventId + * @return com.ruoyi.common.core.domain.AjaxResult + */ + AjaxResult getLinkEvent(String eventId); + List dispatchRecordEventList(DcEvent dcEvent); } 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 453f9260..7e59ea01 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 @@ -1818,4 +1818,35 @@ public class DcEventServiceImpl extends ServiceImpl impl } + /** + * @Description 查询关联事件 + * + * @author liuwenge + * @date 2024/5/30 14:29 + * @param eventId + * @return com.ruoyi.common.core.domain.AjaxResult + */ + @Override + public AjaxResult getLinkEvent(String eventId){ + + List> result = new ArrayList<>(); + DcEvent dcEvent = dcEventMapper.selectDcEventById(eventId); + if (StringUtils.isNotEmpty(dcEvent.getLinkId())){ + Map item = new HashMap<>(); + item.put("eventId",eventId); + item.put("eventNature",dcEvent.getEventNature()); + result.add(item); + + String[] linkIds = dcEvent.getLinkId().split(","); + for (String linkId : linkIds) { + item = new HashMap<>(); + item.put("eventId",linkId); + item.put("eventNature",2); + result.add(item); + } + } + return AjaxResult.success(result); + } + + } From 953e14f9405961afe187767c4d2cde6604c58e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Thu, 30 May 2024 16:02:38 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E7=AE=A1=E5=88=B6=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=EF=BC=88=20=E5=85=B3=E8=81=94=E7=AE=A1=E5=88=B6=EF=BC=89=20?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DcEventServiceImpl.java | 120 +++++++++++------- .../mapper/business/DcEventMapper.xml | 4 +- 2 files changed, 73 insertions(+), 51 deletions(-) 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 7e59ea01..53c23e79 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 @@ -197,7 +197,7 @@ public class DcEventServiceImpl extends ServiceImpl impl dcEvent.setStakeMark(extracted(facilityId)); } //桩号校验 - if (!com.ruoyi.common.utils.StakeMarkUtils.checkStakeMark(dcEvent.getStakeMark())){ + if (!com.ruoyi.common.utils.StakeMarkUtils.checkStakeMark(dcEvent.getStakeMark())) { return -1; } @@ -232,9 +232,11 @@ public class DcEventServiceImpl extends ServiceImpl impl break; //交通管制 case 3: + //交通管制事件 不做 首因关联 + if (dcEvent.getDcEventTrafficControl() != null) { if (dcEventId == null) {//非首页进入 - if (dcEvent.getDcEventTrafficControl().getFacilityIds() ==null ) { + if (dcEvent.getDcEventTrafficControl().getFacilityIds() == null) { dcEvent.getDcEventTrafficControl().setId(uuid); int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl()); break; @@ -248,19 +250,23 @@ public class DcEventServiceImpl extends ServiceImpl impl //查询事件 DcEvent dcEvent2 = dcEventMapper.selectDcEventById(dcEventId); //判断事件 关联事件id是否为空 - if (dcEvent2.getLinkId()==null){ + if (dcEvent2.getLinkId() == null) { DcEvent dcEvent1 = new DcEvent(); dcEvent1.setId(dcEventId);//事件id - dcEvent1.setEventNature(1l);//首发事件 - dcEvent1.setLinkId(uuid);//关联管制事件id - dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 - }else { + if (dcEvent2.getEventType() != 3) { + dcEvent1.setEventNature(1l);//首发事件 + dcEvent1.setLinkId(uuid);//关联管制事件id + dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + } + } else { DcEvent dcEvent1 = new DcEvent(); dcEvent1.setId(dcEventId);//事件id - dcEvent1.setEventNature(1l);//首发事件 - dcEvent1.setLinkId(dcEvent2.getLinkId()+","+uuid);//关联管制事件id - dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + if (dcEvent2.getEventType() != 3) { + dcEvent1.setEventNature(1l);//首发事件 + dcEvent1.setLinkId(dcEvent2.getLinkId() + "," + uuid);//关联管制事件id + dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + } } @@ -270,11 +276,16 @@ public class DcEventServiceImpl extends ServiceImpl impl if (dcEvent.getDcEventTrafficControl().getFacilityIds().length == 1) {//facilityIds==1 说明只选择了一个收费站 if (dcEventId != null && !dcEventId.equals("")) {//不等于空 事件处置页面 修改 + DcEvent dcEvent2 = dcEventMapper.selectDcEventById(dcEventId); + DcEvent dcEvent1 = new DcEvent(); dcEvent1.setId(dcEventId);//事件id - dcEvent1.setEventNature(1l);//首发事件 - dcEvent1.setLinkId(uuid);//关联管制事件id - dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + if (dcEvent2.getEventType() != 3) { + dcEvent1.setEventNature(1l);//首发事件 + dcEvent1.setLinkId(dcEvent2.getLinkId()+","+uuid);//关联管制事件id + dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + + } dcEvent.getDcEventTrafficControl().setId(uuid); dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]);//取出数组字段赋值 设施id @@ -292,10 +303,14 @@ public class DcEventServiceImpl extends ServiceImpl impl } else if (dcEvent.getDcEventTrafficControl().getFacilityIds().length > 1) {//facilityIds1=1 说明只选择了多个收费站 if (dcEventId != null) {//不等于空 事件处置页面 修改 + DcEvent dcEvent2 = dcEventMapper.selectDcEventById(dcEventId); + dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类 DcEvent dcEvent1 = new DcEvent(); dcEvent1.setId(dcEventId);//事件id - dcEvent1.setEventNature(1l);//首发事件 + + dcEvent1.setEventNature(1l);//首发事件 + Map map = new HashMap<>(); for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) { //设置事件Id UUID无下划线格式32 String facilityUUID = IdUtils.fastSimpleUUID(); @@ -312,8 +327,13 @@ public class DcEventServiceImpl extends ServiceImpl impl a++; } String linkId2 = sb2.toString(); - dcEvent1.setLinkId(linkId2);//关联管制事件id - dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + dcEvent1.setLinkId(dcEvent2.getLinkId()+","+linkId2);//关联管制事件id + + if (dcEvent2.getEventType() != 3) { + 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 @@ -409,6 +429,7 @@ public class DcEventServiceImpl extends ServiceImpl impl } + break; //交通拥堵 case 4: @@ -524,7 +545,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventAccident() != null) { }*/ - DcEventAccident dcEventAccident =new DcEventAccident(); + DcEventAccident dcEventAccident = new DcEventAccident(); dcEvent.setDcEventAccident(dcEventAccident); dcEvent.getDcEventAccident().setId(uuid); dcEvent.getDcEventAccident().setReporterName("视频AI"); @@ -537,7 +558,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventVehicleAccident() != null) { }*/ - DcEventVehicleAccident dcEventVehicleAccident =new DcEventVehicleAccident(); + DcEventVehicleAccident dcEventVehicleAccident = new DcEventVehicleAccident(); dcEvent.setDcEventVehicleAccident(dcEventVehicleAccident); dcEvent.getDcEventVehicleAccident().setReporterName("视频AI"); dcEvent.getDcEventVehicleAccident().setReporterPhoneNumber("96659"); @@ -550,7 +571,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventTrafficControl() != null) { } */ - DcEventTrafficControl dcEventTrafficControl =new DcEventTrafficControl(); + DcEventTrafficControl dcEventTrafficControl = new DcEventTrafficControl(); dcEvent.setDcEventTrafficControl(dcEventTrafficControl); dcEvent.getDcEventTrafficControl().setControlType(1L);//限行 dcEvent.getDcEventTrafficControl().setControlCause(2L);//交通事故 @@ -562,7 +583,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventTrafficCongestion() != null) { }*/ - DcEventTrafficCongestion dcEventTrafficCongestion =new DcEventTrafficCongestion(); + DcEventTrafficCongestion dcEventTrafficCongestion = new DcEventTrafficCongestion(); dcEvent.setDcEventTrafficCongestion(dcEventTrafficCongestion); dcEvent.getDcEventTrafficCongestion().setId(uuid); dcEvent.getDcEventTrafficCongestion().setCongestionMileage(0F);//拥堵里程(公里) @@ -581,7 +602,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventConstruction() != null) { }*/ - DcEventConstruction dcEventConstruction =new DcEventConstruction(); + DcEventConstruction dcEventConstruction = new DcEventConstruction(); dcEvent.setDcEventConstruction(dcEventConstruction); dcEvent.getDcEventConstruction().setId(uuid); dcEvent.getDcEventConstruction().setControlMode(1l);//封闭 @@ -592,7 +613,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventServiceArea() != null) { }*/ - DcEventServiceArea dcEventServiceArea =new DcEventServiceArea(); + DcEventServiceArea dcEventServiceArea = new DcEventServiceArea(); dcEvent.setDcEventServiceArea(dcEventServiceArea); dcEvent.getDcEventServiceArea().setId(uuid); int i3 = dcEventServiceAreaMapper.insertDcEventServiceArea(dcEvent.getDcEventServiceArea()); @@ -604,7 +625,7 @@ public class DcEventServiceImpl extends ServiceImpl impl case 10: /* if (dcEvent.getDcEventAbnormalWeather() != null) { }*/ - DcEventAbnormalWeather dcEventAbnormalWeather =new DcEventAbnormalWeather(); + DcEventAbnormalWeather dcEventAbnormalWeather = new DcEventAbnormalWeather(); dcEvent.setDcEventAbnormalWeather(dcEventAbnormalWeather); dcEvent.getDcEventAbnormalWeather().setId(uuid); dcEvent.getDcEventAbnormalWeather().setWeatherSituation("1-1");//雨雾 @@ -798,7 +819,7 @@ public class DcEventServiceImpl extends ServiceImpl impl int i7 = dcEventMapper.updateDcEvent(dcEvent); if (i7 > 0) { String context = comparisonInfo(oldEvent, dcEvent); - if (context.length() > 0){ + if (context.length() > 0) { //事件处置流程记录 DcEventProcess dcEventProcess = new DcEventProcess(); dcEventProcess.setEventId(dcEvent.getId()); @@ -1146,11 +1167,11 @@ public class DcEventServiceImpl extends ServiceImpl impl dcEventProcessService.insertDcEventProcess(dcEventProcess); //插入调度默认数据 - ArrayList> hashMaps = new ArrayList<>(); + ArrayList> hashMaps = new ArrayList<>(); String stakeMark = dcEvent.getStakeMark();//传入桩号 List> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称 - for (HashMap map:mapList){ - if (org.apache.commons.lang3.StringUtils.isBlank(map.get("stakeMark").toString())){ + for (HashMap map : mapList) { + if (org.apache.commons.lang3.StringUtils.isBlank(map.get("stakeMark").toString())) { continue; } Long sectionId = (Long) map.get("id");//机构的id @@ -1158,15 +1179,16 @@ public class DcEventServiceImpl extends ServiceImpl impl com.zc.business.utils.StakeMarkUtils stakeMarkUtils = new StakeMarkUtils(); Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMarkNew);//机构本身的米数 Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMark);//传入的桩号米数 - Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值 - map.put("difference",difference/1000.0);//米转公里加入到map - map.put("id",sectionId); + Integer difference = Math.abs(afferentStakeMark - itselfStakeMark); //计算距离绝对值 + map.put("difference", difference / 1000.0);//米转公里加入到map + map.put("id", sectionId); hashMaps.add(map); } List> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> { - return (Double) map.get("difference"); })).collect(Collectors.toList()); + return (Double) map.get("difference"); + })).collect(Collectors.toList()); HashMap hashMap = dcWarningMapper.selectDcDispatch(id);//查询事件是否已经有转的调度记录 - if (!sortedHashMaps.isEmpty()&&hashMap==null) { + if (!sortedHashMaps.isEmpty() && hashMap == null) { HashMap map = sortedHashMaps.get(0); Long sortId = (Long) map.get("id");//取出最近的机构id if (sortId != null) { @@ -1180,7 +1202,7 @@ public class DcEventServiceImpl extends ServiceImpl impl dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录 Long dispatchId = dcDispatch.getId();//信息记录id List> employeesMap = dcWarningMapper.selectOrganizationEmployees(sortId);//人员map - if (employeesMap != null&&employeesMap.size()>0) { + if (employeesMap != null && employeesMap.size() > 0) { // 生成一个随机索引,范围在0到列表长度减1之间 int randomIndex = ThreadLocalRandom.current().nextInt(employeesMap.size()); HashMap randomEmployee = employeesMap.get(randomIndex); @@ -1191,7 +1213,7 @@ public class DcEventServiceImpl extends ServiceImpl impl dcWarningMapper.insertDispatchResource(dcDispatchResource); } List> vehiclesMap = dcWarningMapper.selectVehicles(sortId);//车辆map - if (vehiclesMap != null&&vehiclesMap.size()>0) { + if (vehiclesMap != null && vehiclesMap.size() > 0) { // 生成一个随机索引,范围在0到列表长度减1之间 int randomIndex = ThreadLocalRandom.current().nextInt(vehiclesMap.size()); HashMap randomEmployee = employeesMap.get(randomIndex); @@ -1250,10 +1272,10 @@ public class DcEventServiceImpl extends ServiceImpl impl } else if ("direction".equals(result.getRightPath())) { if (("1".equals(result.getRight()) || "上行".equals(result.getRight()) || "菏泽方向".equals(result.getRight())) - && ("1".equals(result.getLeft()) || "上行".equals(result.getLeft()) || "菏泽方向".equals(result.getLeft()))){ + && ("1".equals(result.getLeft()) || "上行".equals(result.getLeft()) || "菏泽方向".equals(result.getLeft()))) { continue; - } else if(("3".equals(result.getRight()) || "下行".equals(result.getRight()) || "济南方向".equals(result.getRight())) - && ("3".equals(result.getLeft()) || "下行".equals(result.getLeft()) || "济南方向".equals(result.getLeft()))){ + } else if (("3".equals(result.getRight()) || "下行".equals(result.getRight()) || "济南方向".equals(result.getRight())) + && ("3".equals(result.getLeft()) || "下行".equals(result.getLeft()) || "济南方向".equals(result.getLeft()))) { continue; } @@ -1779,6 +1801,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /** * 调度记录 + * * @param dcEvent * @return */ @@ -1787,7 +1810,7 @@ public class DcEventServiceImpl extends ServiceImpl impl dcEvent.setEventState(2l); List dcEvents = dcEventMapper.dispatchRecordEventList(dcEvent); for (DcEvent event : dcEvents) { - List dcEventProcess= dcEventProcessService.selectDcEventProcessByEventId(event.getId()); + List dcEventProcess = dcEventProcessService.selectDcEventProcessByEventId(event.getId()); event.setDcEventProcessList(dcEventProcess); } @@ -1819,29 +1842,28 @@ public class DcEventServiceImpl extends ServiceImpl impl } /** + * @param eventId + * @return com.ruoyi.common.core.domain.AjaxResult * @Description 查询关联事件 - * * @author liuwenge * @date 2024/5/30 14:29 - * @param eventId - * @return com.ruoyi.common.core.domain.AjaxResult */ @Override - public AjaxResult getLinkEvent(String eventId){ + public AjaxResult getLinkEvent(String eventId) { - List> result = new ArrayList<>(); + List> result = new ArrayList<>(); DcEvent dcEvent = dcEventMapper.selectDcEventById(eventId); - if (StringUtils.isNotEmpty(dcEvent.getLinkId())){ - Map item = new HashMap<>(); - item.put("eventId",eventId); - item.put("eventNature",dcEvent.getEventNature()); + if (StringUtils.isNotEmpty(dcEvent.getLinkId())) { + Map item = new HashMap<>(); + item.put("eventId", eventId); + item.put("eventNature", dcEvent.getEventNature()); result.add(item); String[] linkIds = dcEvent.getLinkId().split(","); for (String linkId : linkIds) { item = new HashMap<>(); - item.put("eventId",linkId); - item.put("eventNature",2); + item.put("eventId", linkId); + item.put("eventNature", 2); result.add(item); } } diff --git a/zc-business/src/main/resources/mapper/business/DcEventMapper.xml b/zc-business/src/main/resources/mapper/business/DcEventMapper.xml index 86a50871..38faaef3 100644 --- a/zc-business/src/main/resources/mapper/business/DcEventMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcEventMapper.xml @@ -816,12 +816,12 @@ and dept_id = #{deptId} + and id = #{id} and stake_mark BETWEEN #{stakeMark} and #{endStakeMark} and direction = #{direction} and user_id = #{userId} - and start_time BETWEEN #{startTime} and #{endTime} - and estimated_end_time = #{estimatedEndTime} + and end_time BETWEEN #{startTime} and #{endTime} and event_level = #{eventLevel} and event_type = #{eventType} and event_subclass = #{eventSubclass} From 7f9c15642735c50cc9f3a907f65d019cd973bb31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Thu, 30 May 2024 16:35:55 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=B0=83=E5=BA=A6=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/business/DcEventProcessMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml b/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml index 68376d4f..e852e609 100644 --- a/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml @@ -152,7 +152,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" \ No newline at end of file From 109320d0a1f0f0240dd85a13f2ddf37f2a3ff324 Mon Sep 17 00:00:00 2001 From: wangsixiang <2970484253@qq.com> Date: Thu, 30 May 2024 17:45:38 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=A4=84=E7=BD=AE=E8=B0=83=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcWarningController.java | 23 +- .../zc/business/mapper/DcWarningMapper.java | 11 + .../business/service/IDcWarningService.java | 6 +- .../service/impl/DcWarningServiceImpl.java | 215 ++++++++++++------ .../mapper/business/DcWarningMapper.xml | 37 +-- 5 files changed, 202 insertions(+), 90 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java b/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java index 3c9f6cc5..029931fa 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java @@ -160,7 +160,7 @@ public class DcWarningController extends BaseController return dcWarningService.batchConvert(dcWarningBatchConvert); } - //指挥调度 + //1,指挥调度,查看是否存在记录和资源信息,存在即返回 @PostMapping("/commandAndDispatch") public AjaxResult commandAndDispatch(@RequestBody DcWarning dcWarning){ if (StringUtils.isBlank(dcWarning.getStakeMark())||StringUtils.isBlank(dcWarning.getId())){ @@ -168,6 +168,22 @@ public class DcWarningController extends BaseController } return (dcWarningService.commandAndDispatch(dcWarning)); } + //2,指挥调度,当调度信息为空的时候调用智能分配资源 + @PostMapping("/intelligentSource") + public AjaxResult intelligentSource(@RequestBody DcWarning dcWarning){ + if (StringUtils.isBlank(dcWarning.getStakeMark())){ + return AjaxResult.error("参数错误"); + } + return (dcWarningService.intelligentSource(dcWarning)); + } + //3.指挥调度,新增调度记录信息 + @PostMapping("/insertDispatch") + public AjaxResult insertDispatch(@RequestBody HashMap map){ + if (map == null || !map.containsKey("eventId")||StringUtils.isBlank(map.get("eventId").toString())){ + return AjaxResult.error("参数错误"); + } + return (dcWarningService.insertDispatch(map)); + } //指挥调度记录修改 @PostMapping("/updateDispatch") public AjaxResult insertDispatch(@RequestBody DcDispatch dcDispatch){ @@ -176,12 +192,9 @@ public class DcWarningController extends BaseController } return toAjax(dcWarningService.insertDispatch(dcDispatch)); } - //指挥调度资源新增 + //4.指挥调度资源新增(用户修改弹窗的提交) @PostMapping("/updateSource") public AjaxResult insertDispatchSource(@RequestBody HashMap map){ - if (map==null||!map.containsKey("dispatchId")){ - return AjaxResult.error("参数错误"); - } return toAjax(dcWarningService.insertDispatchSource(map)); } //感知事件误报 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 aa7a8af8..95df0a5b 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 @@ -99,6 +99,7 @@ public interface DcWarningMapper public Integer updateEndSection(@Param("dcWarningList") List dcWarningList); //查询当天全部可以结束的事件 public List selectEndSection(); + //依据桩号返回驻点id public Long selectSectionId(@Param("stakeMark")String stakeMark,@Param("direction")String direction); //依据桩号获取最近距离的驻点 @@ -130,6 +131,8 @@ public interface DcWarningMapper public HashMap selectOrganization(); //选中的人员信息 public List> selectEmployeesChoice(@Param("dispatchId")Long dispatchId); + //查询最近的交警人员和电话 + public List> selectTrafficPolice(@Param("organizationId")Long organizationId); //选中的车辆信息 public List> selectVehiclesChoice(@Param("dispatchId")Long dispatchId); public Integer deleteDispatchResource(@Param("dispatchId")Long dispatchId); @@ -137,4 +140,12 @@ public interface DcWarningMapper DcDispatch selectDcDispatchById(@Param("id") Long id); //误报解除 public Integer falseAlarmResolution(DcWarning dcWarning); + //依据人员id查询人员名称 + public String employeesName(Long id); + //依据车辆id查询车辆信息,前提车辆可用 + public String vehiclesName(Long id); + //依据车辆id查询车辆信息,前提车辆可用 + public String vehiclesType(Long id); + //依据机构id查询机构名称 + public String organizationName(Long id); } 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 c33cacb8..095c3f74 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 @@ -91,8 +91,12 @@ public interface IDcWarningService //定时结束部分事件 Integer updateEndSection(); - //指挥调度 + //1.指挥调度 AjaxResult commandAndDispatch(DcWarning dcWarning); + //2.指挥调度,当调度信息为空的时候调用智能分配资源 + AjaxResult intelligentSource(DcWarning dcWarning); + //3.指挥调度新增资源 + AjaxResult insertDispatch(HashMap map); //修改指挥调度资源记录 public Integer insertDispatch(DcDispatch dcDispatch); //新增指挥调度资源记录 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 fb839689..7216ea41 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 @@ -27,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional; import java.lang.reflect.Array; import java.rmi.MarshalledObject; +import java.util.Objects; import java.util.concurrent.ThreadLocalRandom; import javax.annotation.Resource; import java.util.ArrayList; @@ -508,68 +509,10 @@ public class DcWarningServiceImpl implements IDcWarningService dcEvent.setCreateTime(DateUtils.getNowDate());//创建时间 dcEvent.setUserId(SecurityUtils.getUserId());//处置人员 dcEvent.setRoadId(1L);//高速公路(济菏高速) - int insertDcEvent = dcEventService.insertDcEventWarning(dcEvent); - if (insertDcEvent==0){ return AjaxResult.error("操作失败"); } - List> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称 - for (HashMap map:mapList){ - if (StringUtils.isBlank(map.get("stakeMark").toString())){ - continue; - } - Long id = (Long) map.get("id");//机构的id - String stakeMarkNew = map.get("stakeMark").toString();//机构桩号 - StakeMarkUtils stakeMarkUtils = new StakeMarkUtils(); - Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMarkNew);//机构本身的米数 - Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMark);//传入的桩号米数 - Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值 - map.put("difference",difference/1000.0);//米转公里加入到map - map.put("id",id); - hashMaps.add(map); - } - List> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> { - return (Double) map.get("difference"); })).collect(Collectors.toList()); - HashMap hashMap = dcWarningMapper.selectDcDispatch(dcWarning.getId());//查询事件是否已经有转的调度记录 - if (!sortedHashMaps.isEmpty()&&hashMap==null) { - HashMap map = sortedHashMaps.get(0); - Long id = (Long) map.get("id");//取出最近的机构id - if (id != null) { - DcDispatch dcDispatch = new DcDispatch(); - DcDispatchResource dcDispatchResource = new DcDispatchResource(); - dcDispatch.setDeptId(SecurityUtils.getLoginUser().getDeptId()); - dcDispatch.setEventId(dcWarning.getId()); - dcDispatch.setStartTime(DateUtils.getNowDate()); - dcDispatch.setDispatchStatus(2L);//进行中状态 - dcDispatch.setRemark(dcWarning.getRemark()); - dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录 - Long dispatchId = dcDispatch.getId();//信息记录id - List> employeesMap = dcWarningMapper.selectOrganizationEmployees(id);//人员map - if (employeesMap != null&&employeesMap.size()>0) { - // 生成一个随机索引,范围在0到列表长度减1之间 - int randomIndex = ThreadLocalRandom.current().nextInt(employeesMap.size()); - HashMap randomEmployee = employeesMap.get(randomIndex); - Long employeesId = (Long) randomEmployee.get("id");//随机人员id - dcDispatchResource.setResourceId(employeesId);//资源id - dcDispatchResource.setDispatchType(1);//资源类型 - dcDispatchResource.setDispatchId(dispatchId);//信息记录id - dcWarningMapper.insertDispatchResource(dcDispatchResource); - } - List> vehiclesMap = dcWarningMapper.selectVehicles(id);//车辆map - if (vehiclesMap != null&&vehiclesMap.size()>0) { - // 生成一个随机索引,范围在0到列表长度减1之间 - int randomIndex = ThreadLocalRandom.current().nextInt(vehiclesMap.size()); - HashMap randomEmployee = employeesMap.get(randomIndex); - Long vehiclesId = (Long) randomEmployee.get("id");//随机车辆id - dcDispatchResource.setResourceId(vehiclesId);//资源id - dcDispatchResource.setDispatchType(2);//资源类型 - dcDispatchResource.setDispatchId(dispatchId);//信息记录id - dcWarningMapper.insertDispatchResource(dcDispatchResource);//绑定车辆信息 - } - } - } - return AjaxResult.success("操作成功"); } @@ -670,10 +613,12 @@ public class DcWarningServiceImpl implements IDcWarningService @Override public AjaxResult commandAndDispatch(DcWarning dcWarning) { + Map mapAll = new HashMap<>(); + HashMap dcDispatch = dcWarningMapper.selectDcDispatch(dcWarning.getId());//查询是否存在调度记录 //逻辑,调用全部的机构信息,计算传入的桩号与机构桩号的距离作为排序使用,使用机构的id调出车辆,人员,值班等信息 List> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称 ArrayList> hashMaps = new ArrayList<>(); - Map mapAll = new HashMap<>(); + for (HashMap map:mapList){ if (StringUtils.isBlank(map.get("stakeMark").toString())){ continue; @@ -684,7 +629,7 @@ public class DcWarningServiceImpl implements IDcWarningService Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(dcWarning.getStakeMark());//传入的桩号米数 Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值 map.put("difference",difference/1000.0);//米转公里加入到map - Long id = (Long) map.get("id");//机构的id,用户获取人员、值班、车辆等信息 + Long id =Long.parseLong(map.get("id").toString());//机构的id,用户获取人员、值班、车辆等信息 List> employeesMap = dcWarningMapper.selectEmployeesDispatch(id,dcWarning.getId());//人员map List> vehiclesMap = dcWarningMapper.selectVehiclesDispatch(id,dcWarning.getId());//车辆map map.put("employeesMap",employeesMap); @@ -692,20 +637,31 @@ public class DcWarningServiceImpl implements IDcWarningService hashMaps.add(map); } List> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> { - return (Double) map.get("difference"); })).collect(Collectors.toList()); + return (Double) map.get("difference"); })).collect(Collectors.toList()); mapAll.put("listData",sortedHashMaps); + if (!sortedHashMaps.isEmpty()) { + HashMap map = sortedHashMaps.get(0); + Long id = Long.parseLong(map.get("id").toString());//取出最近的机构id + List> trafficPolice = dcWarningMapper.selectTrafficPolice(id);//交警人员信息 + mapAll.put("trafficPolice",trafficPolice); + } + if (dcDispatch==null){ + mapAll.put("existence",0); + return AjaxResult.success(mapAll); + } + mapAll.put("existence",1); HashMap map = dcWarningMapper.selectDcDispatch(dcWarning.getId());//获取机构id与资源id if (map!=null){ HashMap hashMap = new HashMap<>(); - Long id = (Long) map.get("id");//调度记录id + Long id =Long.parseLong(map.get("id").toString());//调度记录id Object deptName =map.get("deptName");//部门名称 - List> shifts = dcWarningMapper.selectShiftsEmployees();//值班为空把全部的人员信息作为值班人员信息 + //List> shifts = dcWarningMapper.selectShiftsEmployees();//值班为空把全部的人员信息作为值班人员信息 List> resource = dcWarningMapper.selectDispatchResource(id);//全部资源信息 List> employeesChoice = dcWarningMapper.selectEmployeesChoice(id);//选中人员信息 List> vehiclesChoice = dcWarningMapper.selectVehiclesChoice(id);//选中车辆信息 hashMap.put("id",id);//调度记录id hashMap.put("deptName",deptName); - hashMap.put("shifts",shifts); + //hashMap.put("shifts",shifts); hashMap.put("resource",resource); mapAll.put("resource",hashMap); mapAll.put("employeesChoice",employeesChoice); @@ -713,6 +669,120 @@ public class DcWarningServiceImpl implements IDcWarningService } return AjaxResult.success(mapAll); } + //指挥调度,当调度信息为空的时候调用智能分配资源 + @Override + public AjaxResult intelligentSource(DcWarning dcWarning) { + String stakeMark = dcWarning.getStakeMark(); + ArrayList> hashMaps = new ArrayList<>(); + Map mapAll = new HashMap<>(); + List> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称 + for (HashMap map:mapList){ + HashMap mapValue = new HashMap<>(); + if (StringUtils.isBlank(map.get("stakeMark").toString())){ + continue; + } + StakeMarkUtils stakeMarkUtils = new StakeMarkUtils(); + String stakeMarkValue = map.get("stakeMark").toString(); + Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMarkValue);//桩号本身的米数 + Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(dcWarning.getStakeMark());//传入的桩号米数 + Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值 + + mapValue.put("difference",difference/1000.0);//米转公里加入到map + Long id =Long.parseLong(map.get("id").toString());//机构的id,用户获取人员、车辆等信息 + List> employeesMap = dcWarningMapper.selectEmployeesDispatch(id,dcWarning.getId());//人员map + List> vehiclesMap = dcWarningMapper.selectVehiclesDispatch(id,dcWarning.getId());//车辆map + String organizationName = dcWarningMapper.organizationName(id); + mapValue.put("employeesMap",employeesMap); + mapValue.put("vehiclesMap",vehiclesMap); + mapValue.put("organizationId",id); + mapValue.put("organizationName",organizationName); + hashMaps.add(mapValue); + } + mapAll.put("selectData",hashMaps); + List> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> { + return (Double) map.get("difference"); })).collect(Collectors.toList()); + if (!sortedHashMaps.isEmpty()) { + HashMap map = sortedHashMaps.get(0); + Long id = Long.parseLong(map.get("organizationId").toString());//取出最近的机构id + if (id != null) { + List> employeesMap = dcWarningMapper.selectOrganizationEmployees(id);//人员map + if (employeesMap != null&&employeesMap.size()>0) { + HashMap employeesHashMap = new HashMap<>(); + // 生成一个随机索引,范围在0到列表长度减1之间 + int randomIndex = ThreadLocalRandom.current().nextInt(employeesMap.size()); + HashMap randomEmployee = employeesMap.get(randomIndex); + Long employeesId = Long.parseLong(randomEmployee.get("id").toString());//随机人员id + String employeesName = dcWarningMapper.employeesName(employeesId);//随机人员姓名 + employeesHashMap.put("employeesId",employeesId); + employeesHashMap.put("employeesName",employeesName); + mapAll.put("employees",employeesHashMap); + } + List> vehiclesMap = dcWarningMapper.selectVehicles(id);//车辆map + if (vehiclesMap != null&&vehiclesMap.size()>0) { + HashMap vehiclesHashMap = new HashMap<>(); + // 生成一个随机索引,范围在0到列表长度减1之间 + int randomIndex = ThreadLocalRandom.current().nextInt(vehiclesMap.size()); + HashMap randomEmployee = vehiclesMap.get(randomIndex); + Long vehiclesId =Long.parseLong(randomEmployee.get("id").toString());//随机车辆id + String vehiclesName = dcWarningMapper.vehiclesName(vehiclesId);//随机车辆 + String vehiclesType = dcWarningMapper.vehiclesType(vehiclesId);//随机车辆 + vehiclesHashMap.put("vehiclesId",vehiclesId); + vehiclesHashMap.put("vehiclesName",vehiclesName); + vehiclesHashMap.put("vehiclesType",vehiclesType); + mapAll.put("vehicles",vehiclesHashMap); + } + } + } + return AjaxResult.success(mapAll); + } + //3.指挥调度新增资源 + @Override + @Transactional(rollbackFor = Exception.class) + public AjaxResult insertDispatch(HashMap map) { + //事件id、事件备注、机构id、资源id + String eventId = map.get("eventId").toString();//事件id + String remark = Objects.toString(map.get("remark"), ""); + Long employees=null; + if (map.get("employeesId")!=null){ + employees = Long.parseLong(map.get("employeesId").toString());//人员 + } + Long vehicles=null; + if (map.get("vehiclesId").toString()!=null){ + vehicles = Long.parseLong(map.get("vehiclesId").toString());//车辆 + } + DcDispatch dcDispatch = new DcDispatch(); + DcDispatchResource dcDispatchResource = new DcDispatchResource(); + dcDispatch.setDeptId(SecurityUtils.getLoginUser().getDeptId()); + dcDispatch.setEventId(eventId); + dcDispatch.setStartTime(DateUtils.getNowDate()); + dcDispatch.setDispatchStatus(2L);//进行中状态 + dcDispatch.setRemark(remark); + Integer integer = dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录 + if (integer==0){ + return AjaxResult.error(); + } + Long dispatchId = dcDispatch.getId();//信息记录id + if (employees!=null) { + dcDispatchResource.setResourceId(employees);//资源id + dcDispatchResource.setDispatchType(1);//资源类型 + dcDispatchResource.setDispatchId(dispatchId);//信息记录id + Integer employeesSource = dcWarningMapper.insertDispatchResource(dcDispatchResource); + if (employeesSource==0){ + return AjaxResult.error("人员调度异常"); + } + } + if (vehicles!=null) { + // 生成一个随机索引,范围在0到列表长度减1之间 + dcDispatchResource.setResourceId(vehicles);//资源id + dcDispatchResource.setDispatchType(2);//资源类型 + dcDispatchResource.setDispatchId(dispatchId);//信息记录id + Integer dispatchResource = dcWarningMapper.insertDispatchResource(dcDispatchResource);//绑定车辆信息 + if (dispatchResource==0){ + return AjaxResult.error("车辆调度异常"); + } + } + return AjaxResult.success(); + } @Override public Integer insertDispatch(DcDispatch dcDispatch) { @@ -725,12 +795,19 @@ public class DcWarningServiceImpl implements IDcWarningService @Override @Transactional(rollbackFor = Exception.class) public Integer insertDispatchSource(HashMap map) { + String eventId = map.get("eventId").toString();//事件id + String remark = Objects.toString(map.get("remark"), ""); + DcDispatch dcDispatch = new DcDispatch(); DcDispatchResource dcDispatchResource = new DcDispatchResource(); - Integer pat = (Integer) map.get("dispatchId"); - long dispatchId = pat.longValue(); + dcDispatch.setDeptId(SecurityUtils.getLoginUser().getDeptId()); + dcDispatch.setEventId(eventId); + dcDispatch.setStartTime(DateUtils.getNowDate()); + dcDispatch.setDispatchStatus(2L);//进行中状态 + dcDispatch.setRemark(remark); + dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录 + Long dispatchId = dcDispatch.getId(); dcWarningMapper.deleteDispatchResource(dispatchId);//删除全部属于该调度记录下的全部资源 ArrayList> employeesArray = (ArrayList>) map.get("employees");//取出人员 - String context = ""; if (employeesArray!=null&&employeesArray.size()>0) { context += "路管人员"; @@ -768,9 +845,9 @@ public class DcWarningServiceImpl implements IDcWarningService context += "参与事件救援"; } - DcDispatch dcDispatch = dcWarningMapper.selectDcDispatchById(dispatchId); + DcDispatch dcDispatchEventId = dcWarningMapper.selectDcDispatchById(dispatchId); DcEventProcess dcEventProcess = new DcEventProcess(); - dcEventProcess.setEventId(dcDispatch.getEventId()); + dcEventProcess.setEventId(dcDispatchEventId.getEventId()); dcEventProcess.setSource(1); dcEventProcess.setContext(context); dcEventProcessService.insertDcEventProcess(dcEventProcess); diff --git a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml index 3486169b..c3986369 100644 --- a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml @@ -255,6 +255,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + delete from dc_warning where id = #{id} @@ -278,6 +279,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from dc_dispatch_resource where dispatch_id=#{dispatchId} + @@ -317,7 +319,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where parent_id!=0 SELECT DISTINCT dc_employees.id, dc_employees.name, - dc_employees.contact_number AS contactNumber, - CASE - WHEN t.id IS NOT NULL THEN 1 -- 连接成立 - ELSE 0 -- 连接不成立 - END AS state + dc_employees.contact_number AS contactNumber from dc_employees LEFT JOIN( select employees.id id, employees.name, employees.contact_number contactNumber @@ -380,19 +378,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left JOIN dc_dispatch_resource as respurce on respurce.resource_id = employees.id LEFT JOIN dc_dispatch as path on path.id = respurce.dispatch_id where employees.organization_id = #{organizationId} - and employees.employees_type = 2 and respurce.dispatch_type = 1 and path.event_id = #{eventId}) as t on t.id = dc_employees.id - where organization_id = #{organizationId} + where organization_id = #{organizationId} and dc_employees.employees_type=1 select * from dc_dispatch where id = #{id} + + + + +