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 6d5d060b..f075ffe3 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 @@ -161,5 +161,13 @@ public class DcEventController extends BaseController return map; } + @ApiOperation("根据事件id修改事件状态") + // @PreAuthorize("@ss.hasPermi('system:event:edit')") + @Log(title = "事件信息", businessType = BusinessType.UPDATE) + @PutMapping("/dcEventState/{id}/{state}") + public AjaxResult dcEventState(@PathVariable("id") String id,@PathVariable("state") int state) + { + return toAjax(dcEventService.updateDcEventState(id,state)); + } } 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 172107f8..3d2c7750 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 @@ -298,6 +298,6 @@ public class DcEvent { private String remark; private String subclass; - - +@ApiModelProperty("关联管制事件id") +private String linkId; } diff --git a/zc-business/src/main/java/com/zc/business/domain/DcEventTrafficControl.java b/zc-business/src/main/java/com/zc/business/domain/DcEventTrafficControl.java index 2b0cffc5..32c2b6fa 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcEventTrafficControl.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcEventTrafficControl.java @@ -97,4 +97,6 @@ public class DcEventTrafficControl extends BaseEntity @TableField(exist = false) private DcFacility dcFacility; + @TableField(exist = false) + private Long[] facilityIds; // 数组存储多个设备ID } 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 c82f85ef..b4be7c31 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 @@ -4,6 +4,7 @@ package com.zc.business.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.zc.business.domain.DcEvent; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -83,6 +84,7 @@ public interface DcEventMapper extends BaseMapper */ boolean batchInsertDcEvent(List eventList); + int updateDcEventState(@Param("id") String id,@Param("state") int state); } 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 ed7ce542..e97685fe 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 @@ -89,4 +89,6 @@ public interface IDcEventService Map selectCount(); List eventPileNumberQueryEvent(Map parameter); + + int updateDcEventState(String id, int state); } 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 53846d7b..fb759fcc 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 @@ -6,6 +6,7 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.service.ISysDeptService; +import com.sun.xml.bind.v2.TODO; import com.zc.business.domain.*; import com.zc.business.mapper.*; import com.zc.business.service.IDcEventService; @@ -121,6 +122,10 @@ public class DcEventServiceImpl extends ServiceImpl impl */ @Override public int insertDcEvent(DcEvent dcEvent) { + + String dcEventId =dcEvent.getId(); + + //获取事件类型 int eventType = Math.toIntExact(dcEvent.getEventType()); @@ -196,8 +201,57 @@ public class DcEventServiceImpl extends ServiceImpl impl //交通管制 case 3: if (dcEvent.getDcEventTrafficControl() != null) { - dcEvent.getDcEventTrafficControl().setId(uuid); - int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl()); + //TODO 插入多个收费站 + if (dcEvent.getDcEventTrafficControl().getFacilityIds().length==1){//facilityIds==1 说明只选择了一个收费站 + dcEvent.getDcEventTrafficControl().setId(uuid); + dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]);//取出数组字段赋值 设施id + 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().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]);//取出数组字段赋值 设施id + + //新增第一条数据 + dcEvent.setId(map.get("facilityId"+i)); + dcEvent.setEventState(0L); + dcEvent.setDeptId(SecurityUtils.getDeptId()); + dcEvent.setUserId(SecurityUtils.getUserId()); + dcEvent.setCreateTime(DateUtils.getNowDate()); + dcEvent.setEventNature(2L);//关联管制 + // 使用StringBuilder来构建逗号分隔的字符串 + StringBuilder sb = new StringBuilder(); + boolean isFirst = true; + // 迭代Map并过滤出不为1的键对应的值 + for (Map.Entry entry : map.entrySet()) { + if (entry.getKey() !="facilityId"+i) { + if (!isFirst) { + sb.append(","); + } + sb.append(entry.getValue()); + isFirst = false; + } + } + 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()); + + } + } + } break; //交通拥堵 @@ -723,6 +777,11 @@ public class DcEventServiceImpl extends ServiceImpl impl return dcEvents; } + @Override + public int updateDcEventState(String id, int state) { + return dcEventMapper.updateDcEventState(id,state); + } + public static List castList(Object obj, Class clazz) { List result = new ArrayList(); if (obj instanceof List) { diff --git a/zc-business/src/main/resources/mapper/business/DcEventMapper.xml b/zc-business/src/main/resources/mapper/business/DcEventMapper.xml index 590b58bf..67dea91f 100644 --- a/zc-business/src/main/resources/mapper/business/DcEventMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcEventMapper.xml @@ -639,6 +639,7 @@ where id = #{id} + delete from dc_event where id = #{id} @@ -679,4 +680,13 @@ GROUP BY event_state ) t ON s.event_state = t.event_state; + + + + update dc_event + + event_state = #{state}, + + where id = #{id} + \ No newline at end of file