Browse Source

修改 交通管制 收费站设施 等 多选 插入 。事件处置 收费站多选插入

develop
王兴琳 8 months ago
parent
commit
cebdf8ede8
  1. 9
      zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java
  2. 5
      zc-business/src/main/java/com/zc/business/service/IDcEventService.java
  3. 132
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  4. 42
      zc-business/src/main/resources/mapper/business/DcEventMapper.xml

9
zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java

@ -51,6 +51,15 @@ public interface DcEventMapper extends BaseMapper<DcEvent>
*/ */
int updateDcEvent(DcEvent dcEvent); int updateDcEvent(DcEvent dcEvent);
/**
* 修改事件性质 关联管制事件id
*
* @param dcEvent 事件信息
* @return 结果
*/
int updateDcEventLinkId(DcEvent dcEvent);
/** /**
* 删除事件信息 * 删除事件信息
* *

5
zc-business/src/main/java/com/zc/business/service/IDcEventService.java

@ -57,6 +57,11 @@ public interface IDcEventService
*/ */
public int updateDcEvent(DcEvent dcEvent); public int updateDcEvent(DcEvent dcEvent);
/**
* @param dcEvent
* @return int
*/
/** /**
* 批量删除事件信息 * 批量删除事件信息
* *

132
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.mapper.*;
import com.zc.business.service.IDcEventService; import com.zc.business.service.IDcEventService;
import com.zc.business.service.IMiddleDatabaseService; import com.zc.business.service.IMiddleDatabaseService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -137,9 +138,11 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
dcEvent.setId(uuid); dcEvent.setId(uuid);
dcEvent.setEventState(0L); 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()); dcEvent.setCreateTime(DateUtils.getNowDate());
@ -180,9 +183,9 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
if (i7 > 0) { if (i7 > 0) {
//中间库 /* //中间库
MdEvent mdEvent = new MdEvent(dcEvent); MdEvent mdEvent = new MdEvent(dcEvent);
middleDatabaseService.insertMiddleDatabaseEvent(mdEvent); middleDatabaseService.insertMiddleDatabaseEvent(mdEvent);*/
switch (eventType) { switch (eventType) {
//交通事故 //交通事故
case 1: case 1:
@ -207,57 +210,134 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
//TODO 插入多个收费站 //TODO 插入多个收费站
if (dcEvent.getDcEventTrafficControl().getFacilityIds().length==1){//facilityIds==1 说明只选择了一个收费站 if (dcEvent.getDcEventTrafficControl().getFacilityIds().length==1){//facilityIds==1 说明只选择了一个收费站
if (dcEventId !=null){ if (dcEventId !=null){//不等于空 事件处置页面 修改
dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类 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); }else if (dcEvent.getDcEventTrafficControl().getFacilityIds().length>1){//facilityIds1=1 说明只选择了多个收费站
dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]);//取出数组字段赋值 设施id
int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl()); if (dcEventId !=null){//不等于空 事件处置页面 修改
}else { dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类
DcEvent dcEvent1 = new DcEvent();
dcEvent1.setId(dcEventId);//事件id
dcEvent1.setEventNature(1l);//首发事件
Map<String,String> 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<String, String> 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<String, String> 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);//删除添加的事件主类 dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) { //设置事件Id UUID无下划线格式32 for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) { //设置事件Id UUID无下划线格式32
String facilityUUID = IdUtils.fastSimpleUUID(); String facilityUUID = IdUtils.fastSimpleUUID();
map.put("facilityId"+i,facilityUUID);//每循环一次生成一个uuid 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++) { 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.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]);//取出数组字段赋值 设施id
//新增第一条数据 //新增第一条数据
dcEvent.setId(map.get("facilityId"+i)); dcEvent.setId(map.get("facilityId" + i));
dcEvent.setEventState(0L); dcEvent.setEventState(0L);
dcEvent.setDeptId(SecurityUtils.getDeptId()); dcEvent.setDeptId(1l);
dcEvent.setUserId(SecurityUtils.getUserId()); dcEvent.setUserId(1l);
dcEvent.setCreateTime(DateUtils.getNowDate()); dcEvent.setCreateTime(DateUtils.getNowDate());
dcEvent.setEventNature(2L);//关联管制 dcEvent.setEventNature(2L);//关联管制
// 使用StringBuilder来构建逗号分隔的字符串 // 使用StringBuilder来构建逗号分隔的字符串
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
boolean isFirst = true;
// 迭代Map并过滤出不为1的键对应的值 // 遍历map,排除与当前索引i对应的键
for (Map.Entry<String, String> entry : map.entrySet()) { for (Map.Entry<String, String> entry : map.entrySet()) {
if (entry.getKey() !="facilityId"+i) { if (!entry.getKey().equals("facilityId" + i)) {
if (!isFirst) { if (sb.length() > 0) {
sb.append(","); sb.append(",");
} }
sb.append(entry.getValue()); sb.append(entry.getValue());
isFirst = false;
} }
} }
String linkId= sb.toString();
String linkId = sb.toString();
dcEvent.setLinkId(linkId); 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]); String facilityId = String.valueOf(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]);
dcEvent.setStakeMark( extracted(facilityId)); dcEvent.setStakeMark(extracted(facilityId));
} }
dcEventMapper.insertDcEvent(dcEvent); dcEventMapper.insertDcEvent(dcEvent);
int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl()); int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl());
}
} }
} }
@ -574,6 +654,8 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
} }
/** /**
* 批量删除事件信息 * 批量删除事件信息
* *

42
zc-business/src/main/resources/mapper/business/DcEventMapper.xml

@ -35,6 +35,7 @@
<result property="isPerceived" column="is_perceived"/> <result property="isPerceived" column="is_perceived"/>
<result property="dimension" column="dimension"/> <result property="dimension" column="dimension"/>
<result property="longitude" column="longitude"/> <result property="longitude" column="longitude"/>
<result property="linkId" column="link_id"/>
</resultMap> </resultMap>
<resultMap type="map" id="countMap"> <resultMap type="map" id="countMap">
@ -81,6 +82,7 @@
<result property="subclass" column="subclass"/> <result property="subclass" column="subclass"/>
<result property="dimension" column="dimension"/> <result property="dimension" column="dimension"/>
<result property="longitude" column="longitude"/> <result property="longitude" column="longitude"/>
<result property="linkId" column="link_id"/>
</resultMap> </resultMap>
@ -164,6 +166,7 @@
longitude, longitude,
dimension, dimension,
event_title, event_title,
link_id,
is_perceived, is_perceived,
CASE event_type CASE event_type
WHEN '1' THEN '交通事故' WHEN '1' THEN '交通事故'
@ -268,6 +271,7 @@
<sql id="selectDcEventVoListAll"> select dc_event.id AS id, <sql id="selectDcEventVoListAll"> select dc_event.id AS id,
dc_event.stake_mark, dc_event.stake_mark,
dc_event.link_id,
dc_event.dimension, dc_event.dimension,
dc_event.longitude, dc_event.longitude,
dc_event.direction, dc_event.direction,
@ -373,6 +377,7 @@
/*详情可以调用事件处理流程*/ /*详情可以调用事件处理流程*/
SELECT dc_event.id AS id, SELECT dc_event.id AS id,
dc_event.stake_mark, dc_event.stake_mark,
dc_event.link_id,
CASE dc_event.direction CASE dc_event.direction
WHEN '1' THEN '菏泽方向' WHEN '1' THEN '菏泽方向'
WHEN '3' THEN '济南方向' WHEN '3' THEN '济南方向'
@ -528,6 +533,7 @@
<if test="isPerceived != null">is_perceived,</if> <if test="isPerceived != null">is_perceived,</if>
<if test="dimension != null">dimension,</if> <if test="dimension != null">dimension,</if>
<if test="longitude != null">longitude,</if> <if test="longitude != null">longitude,</if>
<if test="linkId != null">link_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
@ -558,6 +564,7 @@
<if test="isPerceived != null">#{isPerceived},</if> <if test="isPerceived != null">#{isPerceived},</if>
<if test="dimension != null">#{dimension},</if> <if test="dimension != null">#{dimension},</if>
<if test="longitude != null">#{longitude},</if> <if test="longitude != null">#{longitude},</if>
<if test="linkId != null">#{linkId},</if>
</trim> </trim>
</insert> </insert>
<insert id="batchInsertDcEvent" useGeneratedKeys="true" keyProperty="id"> <insert id="batchInsertDcEvent" useGeneratedKeys="true" keyProperty="id">
@ -656,6 +663,41 @@
<if test="isPerceived != null">is_perceived = #{isPerceived},</if> <if test="isPerceived != null">is_perceived = #{isPerceived},</if>
<if test="dimension != null">dimension = #{dimension},</if> <if test="dimension != null">dimension = #{dimension},</if>
<if test="longitude != null">longitude = #{longitude},</if> <if test="longitude != null">longitude = #{longitude},</if>
<if test="linkId != null">link_id = #{linkId},</if>
</trim>
where id = #{id}
</update>
<update id="updateDcEventLinkId" parameterType="DcEvent">
update dc_event
<trim prefix="SET" suffixOverrides=",">
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="stakeMark != null and stakeMark != ''">stake_mark = #{stakeMark},</if>
<if test="direction != null and direction != ''">direction = #{direction},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="estimatedEndTime != null">estimated_end_time = #{estimatedEndTime},</if>
<if test="eventLevel != null">event_level = #{eventLevel},</if>
<if test="eventType != null">event_type = #{eventType},</if>
<if test="eventSubclass != null">event_subclass = #{eventSubclass},</if>
<if test="eventCause != null">event_cause = #{eventCause},</if>
<if test="description != null">description = #{description},</if>
<if test="eventState != null">event_state = #{eventState},</if>
<if test="eventSource != null">event_source = #{eventSource},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="eventSourceTips != null">event_source_tips = #{eventSourceTips},</if>
<if test="inTunnel != null">in_tunnel = #{inTunnel},</if>
<if test="roadId != null">road_id = #{roadId},</if>
<if test="lang != null">road_id = #{lang},</if>
<if test="eventTitle != null">event_title = #{eventTitle},</if>
<if test="occurrenceTime != null">occurrence_time = #{occurrenceTime},</if>
<if test="isPerceived != null">is_perceived = #{isPerceived},</if>
<if test="dimension != null">dimension = #{dimension},</if>
<if test="eventNature != null">event_nature = #{eventNature},</if>
<if test="linkId != null">link_id = #{linkId},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

Loading…
Cancel
Save