Browse Source

根据事件id修改事件id

develop
王兴琳 8 months ago
parent
commit
bb2011d937
  1. 8
      zc-business/src/main/java/com/zc/business/controller/DcEventController.java
  2. 4
      zc-business/src/main/java/com/zc/business/domain/DcEvent.java
  3. 2
      zc-business/src/main/java/com/zc/business/domain/DcEventTrafficControl.java
  4. 2
      zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java
  5. 2
      zc-business/src/main/java/com/zc/business/service/IDcEventService.java
  6. 59
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  7. 10
      zc-business/src/main/resources/mapper/business/DcEventMapper.xml

8
zc-business/src/main/java/com/zc/business/controller/DcEventController.java

@ -161,5 +161,13 @@ public class DcEventController extends BaseController
return map; 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));
}
} }

4
zc-business/src/main/java/com/zc/business/domain/DcEvent.java

@ -298,6 +298,6 @@ public class DcEvent {
private String remark; private String remark;
private String subclass; private String subclass;
@ApiModelProperty("关联管制事件id")
private String linkId;
} }

2
zc-business/src/main/java/com/zc/business/domain/DcEventTrafficControl.java

@ -97,4 +97,6 @@ public class DcEventTrafficControl extends BaseEntity
@TableField(exist = false) @TableField(exist = false)
private DcFacility dcFacility; private DcFacility dcFacility;
@TableField(exist = false)
private Long[] facilityIds; // 数组存储多个设备ID
} }

2
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.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcEvent; import com.zc.business.domain.DcEvent;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -83,6 +84,7 @@ public interface DcEventMapper extends BaseMapper<DcEvent>
*/ */
boolean batchInsertDcEvent(List<DcEvent> eventList); boolean batchInsertDcEvent(List<DcEvent> eventList);
int updateDcEventState(@Param("id") String id,@Param("state") int state);
} }

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

@ -89,4 +89,6 @@ public interface IDcEventService
Map<String,Object> selectCount(); Map<String,Object> selectCount();
List<DcEvent> eventPileNumberQueryEvent(Map<String, Object> parameter); List<DcEvent> eventPileNumberQueryEvent(Map<String, Object> parameter);
int updateDcEventState(String id, int state);
} }

59
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.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysDeptService;
import com.sun.xml.bind.v2.TODO;
import com.zc.business.domain.*; 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;
@ -121,6 +122,10 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
*/ */
@Override @Override
public int insertDcEvent(DcEvent dcEvent) { public int insertDcEvent(DcEvent dcEvent) {
String dcEventId =dcEvent.getId();
//获取事件类型 //获取事件类型
int eventType = Math.toIntExact(dcEvent.getEventType()); int eventType = Math.toIntExact(dcEvent.getEventType());
@ -196,8 +201,57 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
//交通管制 //交通管制
case 3: case 3:
if (dcEvent.getDcEventTrafficControl() != null) { if (dcEvent.getDcEventTrafficControl() != null) {
//TODO 插入多个收费站
if (dcEvent.getDcEventTrafficControl().getFacilityIds().length==1){//facilityIds==1 说明只选择了一个收费站
dcEvent.getDcEventTrafficControl().setId(uuid); dcEvent.getDcEventTrafficControl().setId(uuid);
dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]);//取出数组字段赋值 设施id
int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl()); int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl());
}else {
dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类
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
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<String, String> 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; break;
//交通拥堵 //交通拥堵
@ -723,6 +777,11 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
return dcEvents; return dcEvents;
} }
@Override
public int updateDcEventState(String id, int state) {
return dcEventMapper.updateDcEventState(id,state);
}
public static <T> List<T> castList(Object obj, Class<T> clazz) { public static <T> List<T> castList(Object obj, Class<T> clazz) {
List<T> result = new ArrayList<T>(); List<T> result = new ArrayList<T>();
if (obj instanceof List<?>) { if (obj instanceof List<?>) {

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

@ -639,6 +639,7 @@
where id = #{id} where id = #{id}
</update> </update>
<delete id="deleteDcEventById" parameterType="String"> <delete id="deleteDcEventById" parameterType="String">
delete from dc_event where id = #{id} delete from dc_event where id = #{id}
</delete> </delete>
@ -679,4 +680,13 @@
GROUP BY event_state GROUP BY event_state
) t ON s.event_state = t.event_state; ) t ON s.event_state = t.event_state;
</select> </select>
<update id="updateDcEventState" parameterType="string">
update dc_event
<trim prefix="SET" suffixOverrides=",">
<if test="state != null">event_state = #{state},</if>
</trim>
where id = #{id}
</update>
</mapper> </mapper>
Loading…
Cancel
Save