diff --git a/zc-business/pom.xml b/zc-business/pom.xml index 275f2980..c0017e0b 100644 --- a/zc-business/pom.xml +++ b/zc-business/pom.xml @@ -21,7 +21,11 @@ org.eclipse.paho.client.mqttv3 1.2.2 - + + org.json + json + 20210307 + com.hikvision.ga artemis-http-client diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java index d98c053a..d0b0f0c3 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java @@ -1,5 +1,6 @@ package com.zc.business.controller; +import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -207,6 +208,47 @@ public class DcDeviceController extends BaseController { return JSON.parseObject(response.body().string(), AjaxResult.class); } + /** + * 查询当天设备指定属性列表 + * @param deviceId 设备id + * @param propertyId 属性id + * @return 属性列表 + */ + @ApiOperation("查询当天设备指定属性列表") + @GetMapping("/properties/history/day/{deviceId}/{propertyId}") + public AjaxResult queryDevicePropertiesOneDay(@PathVariable @Parameter(description = "设备ID") String deviceId, + @PathVariable @Parameter(description = "属性ID") String propertyId) throws HttpException, IOException { + + HashMap props = new HashMap<>(); + // 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内 + props.put("terms[0].column", "timestamp$BTW"); + ArrayList dateList = new ArrayList<>(); + // 添加当前日期的开始和结束时间到列表,用于设定时间范围 + dateList.add(DateUtil.beginOfDay(new Date()).toString()); + dateList.add(DateUtil.endOfDay(new Date()).toString()); + // 将日期列表以逗号分隔并设置为查询条件的值 + props.put("terms[0].value", String.join(",", dateList)); + props.put("paging", false); + AjaxResult ajaxResult = queryDeviceProperties(deviceId, propertyId, props); + if (!ajaxResult.get("code").equals(200)) { + return ajaxResult; + } + + Object data = JSON.parseObject(queryDeviceProperties(deviceId, propertyId, props).get("data").toString()).get("data"); + JSONArray dataArray = JSON.parseArray(data.toString()); + List list = new ArrayList<>(); + dataArray.forEach(o -> { + Map map = new HashMap<>(); + JSONObject jsonObject = JSON.parseObject(o.toString()); + JSONObject formatValue = JSON.parseObject(jsonObject.get("formatValue").toString()); + map.put("1",formatValue.get("1")); + map.put("3",formatValue.get("3")); + map.put("timestamp",jsonObject.get("timestamp")); + list.add(map); + }); + return AjaxResult.success(list); + } + /** * 查询设备指定属性列表 * diff --git a/zc-business/src/main/java/com/zc/business/controller/DcRoadSectionController.java b/zc-business/src/main/java/com/zc/business/controller/DcRoadSectionController.java index 4acd42b5..9487c289 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcRoadSectionController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcRoadSectionController.java @@ -50,6 +50,12 @@ public class DcRoadSectionController extends BaseController List list = dcRoadSectionService.selectDcRoadSectionList(dcRoadSection); return getDataTable(list); } + //查询全路段名称与id + @GetMapping("/listName") + public AjaxResult listRoadName() + { + return AjaxResult.success(dcRoadSectionService.selectName()); + } /** * 查询辖区路段列表(不分页) */ diff --git a/zc-business/src/main/java/com/zc/business/domain/DcWaringStrategy.java b/zc-business/src/main/java/com/zc/business/domain/DcWaringStrategy.java new file mode 100644 index 00000000..213957ca --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/DcWaringStrategy.java @@ -0,0 +1,123 @@ +package com.zc.business.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 预警事件配置对象 dc_waring_strategy + * + * @author ruoyi + * @date 2024-03-19 + */ +public class DcWaringStrategy extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 事件源 */ + @Excel(name = "事件源") + private Integer warningSource; + + /** 事件主类 */ + @Excel(name = "事件主类") + private Integer warningType; + + /** 事件子类 */ + @Excel(name = "事件子类") + private String warningSubclass; + + /** 过期策略 */ + @Excel(name = "过期策略") + private Integer strategy; + + /** 策略时间 */ + @Excel(name = "策略时间", width = 30, dateFormat = "yyyy-MM-dd") + private Integer strategyTime; + + //优先级 + private String priority; + + public String getPriority() { + return priority; + } + + public void setPriority(String priority) { + this.priority = priority; + } + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setWarningSource(Integer warningSource) + { + this.warningSource = warningSource; + } + + public Integer getWarningSource() + { + return warningSource; + } + public void setWarningType(Integer warningType) + { + this.warningType = warningType; + } + + public Integer getWarningType() + { + return warningType; + } + public void setWarningSubclass(String warningSubclass) + { + this.warningSubclass = warningSubclass; + } + + public String getWarningSubclass() + { + return warningSubclass; + } + public void setStrategy(Integer strategy) + { + this.strategy = strategy; + } + + public Integer getStrategy() + { + return strategy; + } + + public Integer getStrategyTime() { + return strategyTime; + } + + public void setStrategyTime(Integer strategyTime) { + this.strategyTime = strategyTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("warningSource", getWarningSource()) + .append("warningType", getWarningType()) + .append("warningSubclass", getWarningSubclass()) + .append("strategy", getStrategy()) + .append("strategyTime", getStrategyTime()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcRoadSectionMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcRoadSectionMapper.java index 3bac0457..ee5def34 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcRoadSectionMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcRoadSectionMapper.java @@ -28,7 +28,7 @@ public interface DcRoadSectionMapper * @return 辖区路段集合 */ List selectDcRoadSectionList(DcRoadSection dcRoadSection); - + List selectName(); /** * 新增辖区路段 * diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java index 771d7a38..2726acff 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java @@ -70,9 +70,11 @@ public interface DcShiftsMapper HashMap contactNumber(String contactNumber); //路管驻点名称查询路管驻点id HashMap selectStationId(@Param("stationName") String stationName); + //查询人员与驻点的信息 + List> selectEmp(@Param("organizationId")Long organizationId,@Param("name") String name); //根据创建时间获取信息 public DcShifts selectDcShiftsByCreateTime(Long id); - + // /** * 查询值班 * 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 70c353a1..81af54ab 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 @@ -2,6 +2,9 @@ package com.zc.business.mapper; import java.util.HashMap; import java.util.List; + +import cn.hutool.core.lang.hash.Hash; +import com.zc.business.domain.DcWaringStrategy; import com.zc.business.domain.DcWarning; import org.apache.ibatis.annotations.Param; @@ -19,7 +22,7 @@ public interface DcWarningMapper * @param id 预警信息主键 * @return 预警信息 */ - public DcWarning selectDcWarningById(String id); + public HashMap selectDcWarningById(String id); /** * 查询预警信息列表 @@ -73,4 +76,11 @@ public interface DcWarningMapper boolean batchUpdateState(@Param("userId") Long userId,@Param("dcWarningList") List dcWarningList); boolean batchDelete(@Param("dcWarningList") List dcWarningList); + + //查询预警配置信息 + public List selectDcWaringStrategyList(DcWaringStrategy dcWaringStrategy); + public List selectDcWaringStrategyList(); + + //修改配置 + public Integer updateOtherConfig(@Param("id")String id,@Param("otherConfig")String otherConfig); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcRoadSectionService.java b/zc-business/src/main/java/com/zc/business/service/IDcRoadSectionService.java index 958019ff..90711465 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcRoadSectionService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcRoadSectionService.java @@ -28,6 +28,7 @@ public interface IDcRoadSectionService */ List selectDcRoadSectionList(DcRoadSection dcRoadSection); List selectDcRoadSectionListAll(DcRoadSection dcRoadSection); + List selectName(); /** * 新增辖区路段 * 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 8ad61ccc..d046a7ef 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 @@ -22,7 +22,7 @@ public interface IDcWarningService * @param id 预警信息主键 * @return 预警信息 */ - public DcWarning selectDcWarningById(String id); + public HashMap selectDcWarningById(String id); /** * 查询预警信息列表 diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcRoadSectionServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcRoadSectionServiceImpl.java index 87403f26..0db3e373 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcRoadSectionServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcRoadSectionServiceImpl.java @@ -93,6 +93,11 @@ public class DcRoadSectionServiceImpl implements IDcRoadSectionService return dcRoadSectionMapper.selectDcRoadSectionList(dcRoadSection); } + @Override + public List selectName() { + return dcRoadSectionMapper.selectName(); + } + /** * 新增辖区路段 * diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java index 117e969d..d82d34c8 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java @@ -326,6 +326,11 @@ public class DcShiftsServiceImpl implements IDcShiftsService throw new ServiceException(msg); } Long stationId =(Long) stationIdMap.get("id"); + List> mapList = dcShiftsMapper.selectEmp(stationId, name);//查询人员配置中是否有此人员配置的对应机构信息 + if (mapList==null||mapList.size()==0){ + msg = "没有查询到" + name + "对应的"+organizationName+"驻点信息,请查看输入是否正确以及人员信息中是否配置正确"; + throw new ServiceException(msg); + } dcShifts.setStation(stationId);//驻点id Long id = (Long) map.get("id"); dcShifts.setEmployeesId(id); 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 c6b28825..266a685e 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 @@ -1,11 +1,16 @@ package com.zc.business.service.impl; -import com.alibaba.fastjson.JSONObject; + + import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.uuid.IdUtils; -import com.zc.business.domain.*; +import com.zc.business.domain.DcEvent; +import com.zc.business.domain.DcWaringStrategy; +import com.zc.business.domain.DcWarning; +import com.zc.business.domain.DcWarningBatchConvert; import com.zc.business.enums.ValueConverter; import com.zc.business.mapper.DcEventMapper; import com.zc.business.mapper.DcWarningMapper; @@ -16,11 +21,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.ArrayList; -import java.util.Calendar; import java.util.HashMap; import java.util.List; - +import java.util.Map; +import java.util.concurrent.TimeUnit; +import org.json.JSONObject; +import org.json.JSONArray; /** * 预警信息Service业务层处理 * @@ -37,6 +45,12 @@ public class DcWarningServiceImpl implements IDcWarningService private DcEventMapper dcEventMapper; @Autowired private IDcEventService dcEventService; + @Resource + private RedisCache redisCache; + + private static final String WARNINGSTRATEGY = "warningStrategy";//redis策略缓存的key + private static final String WARNINGDATA = "warningData:";//redis事件缓存的key + private static String JUDGE = "1"; //自定义判断参数,1为满足0为不满足 /** * 查询预警信息 * @@ -44,7 +58,7 @@ public class DcWarningServiceImpl implements IDcWarningService * @return 预警信息 */ @Override - public DcWarning selectDcWarningById(String id) + public HashMap selectDcWarningById(String id) { return dcWarningMapper.selectDcWarningById(id); } @@ -75,15 +89,149 @@ public class DcWarningServiceImpl implements IDcWarningService @Override public int insertDcWarning(DcWarning dcWarning) { + dcWarning.setCreateTime(DateUtils.getNowDate()); - if (dcWarning.getId()==null) { - //设置事件Id UUID无下划线格式32 - String uuid = IdUtils.fastSimpleUUID(); - dcWarning.setId(uuid); + //设置事件Id UUID无下划线格式32 + String uuid = IdUtils.fastSimpleUUID(); + dcWarning.setId(uuid); + int priority = new DcWarningServiceImpl().priority(dcWarning); + if (priority==0){ + return 0; } return dcWarningMapper.insertDcWarning(dcWarning); } + //优先级策略 + public int priority(DcWarning dcWarning){ + if (StringUtils.isBlank(dcWarning.getStakeMark())||dcWarning.getWarningSource()==null||dcWarning.getWarningType()==null|| + StringUtils.isBlank(dcWarning.getWarningSubclass())||StringUtils.isBlank(dcWarning.getDirection())){ + return 0; + } + String redisKye=dcWarning.getWarningSource().toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//配置数据的key 事件源+事件类型+策略 + Map redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//获取缓存全部的配置数据 + if (redisWarningStrategy==null){//如果缓存为空,查询数据重新加入缓存 + Map redisMap = new HashMap<>(); + List dcWaringStrategies = dcWarningMapper.selectDcWaringStrategyList();//数据库全部配置数据 + for (DcWaringStrategy waringStrategy : dcWaringStrategies) { + String key = waringStrategy.getWarningSource().toString() + waringStrategy.getWarningType().toString() + + waringStrategy.getWarningSubclass()+waringStrategy.getStrategy().toString();//redis配置数据key + JSONObject jsonObject = new JSONObject(); + jsonObject.put("strategy", waringStrategy.getStrategy());//策略模式 + jsonObject.put("strategyTime", waringStrategy.getStrategyTime());//模式时长,单位为分钟 + jsonObject.put("priority", waringStrategy.getPriority());//策略模式 + redisMap.put(key, jsonObject); + } + redisCache.setCacheMap(WARNINGSTRATEGY, redisMap);//数据库配置数据加入缓存中 + redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//缓存数据为空重新加入到缓存在取出缓存的配置 + } + String key=dcWarning.getStakeMark()+dcWarning.getDirection()+dcWarning.getWarningSource(). + toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//key,redis存储事件的key(桩号+方向+事件源+类型) + String dataId = redisCache.getCacheObject(WARNINGDATA + key);//查看redis是否存在数据(id的值) + JSONObject redisValueOne = redisWarningStrategy.get(redisKye+"1");//查看传入的事件类型是否配置策略1(优先级策略) + if(redisValueOne!=null){//执行策略1(暂时未定义,定义后开发) + + } + JSONObject redisValueTwo = redisWarningStrategy.get(redisKye+"2");//查看传入的事件类型是否配置策略2(延迟策略) + if (redisValueOne==null&&redisValueTwo!=null){ //执行策略2,执行到这里说明1不存在或者1未满足过滤条件 + String strategyTime = redisValueTwo.getString("strategyTime").toString();//策略时长 + if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间 + int insertDcWarning = new DcWarningServiceImpl().insertDcWarning(dcWarning);//加入数据库 + if (insertDcWarning==0){ + return 0; + } + String id = dcWarning.getId();//取出加入后的id作为value + redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟) + } + //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置,重新定义延迟时间 + HashMap map = dcWarningMapper.selectDcWarningById(dataId); + String otherConfig = map.get("otherConfig").toString();//取出原id的配置信息 + String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息 + JSONObject jsonObjectOne = new JSONObject(otherConfig); + JSONObject jsonObjectTwo = new JSONObject(otherConfigString); + JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json + Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置 + redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间 + if (integer==0){ + return 0; + } + return 1; + } + JSONObject redisValueThree = redisWarningStrategy.get(redisKye+"3");//查看传入的事件类型是否配置策略3(时间窗口策略) + if (redisValueOne==null&&redisValueTwo==null&&redisValueThree!=null){ //执行策略3,执行到这里说明1不存在或者2不存在或者1未满足过滤条件 + if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间(30分钟) + int insertDcWarning = new DcWarningServiceImpl().insertDcWarning(dcWarning);//加入数据库 + if (insertDcWarning==0){ + return 0; + } + String id = dcWarning.getId();//取出加入后的id作为value + redisCache.setCacheObject(WARNINGDATA+key,id,30,TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟) + } + //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置 + HashMap map = dcWarningMapper.selectDcWarningById(dataId); + String otherConfig = map.get("otherConfig").toString();//取出原id的配置信息 + String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息 + JSONObject jsonObjectOne = new JSONObject(otherConfig); + JSONObject jsonObjectTwo = new JSONObject(otherConfigString); + JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json + Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置 + if (integer==0){ + return 0; + } + return 1; + } + JSONObject redisValueFour = redisWarningStrategy.get(redisKye+"4");//查看传入的事件类型是否配置策略3(自动结束策略) + if (redisValueOne==null&&redisValueTwo==null&&redisValueThree==null&&redisValueFour!=null){ //执行策略4,执行到这里说明1不存在或者2、3不存在或者1未满足过滤条件 + if (dataId==null){//如果不存在直接加入数据库,加入缓存 + int insertDcWarning = new DcWarningServiceImpl().insertDcWarning(dcWarning);//加入数据库 + if (insertDcWarning==0){ + return 0; + } + String id = dcWarning.getId();//取出加入后的id作为value + redisCache.setCacheObject(WARNINGDATA+key,id);//加入缓存????存在问题会数据累计 + } + //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置 + HashMap map = dcWarningMapper.selectDcWarningById(dataId); + String otherConfig = map.get("otherConfig").toString();//取出原id的配置信息 + String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息 + JSONObject jsonObjectOne = new JSONObject(otherConfig); + JSONObject jsonObjectTwo = new JSONObject(otherConfigString); + JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json + Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置 + redisCache.deleteObject(WARNINGDATA + key);//删除对应的合成事件 + if (integer==0){ + return 0; + } + return 1; + } + return 1; + } + private JSONObject mergeJsonObjects(JSONObject jsonObjectOne, JSONObject jsonObjectTwo){ + // 合并videoList + if (jsonObjectTwo.has("videoList")) { + JSONArray videoListTwo = jsonObjectTwo.getJSONArray("videoList"); + JSONArray videoListOne = jsonObjectOne.optJSONArray("videoList"); + if (videoListOne == null) { + videoListOne = new JSONArray(); + } + for (int i = 0; i < videoListTwo.length(); i++) { + videoListOne.put(videoListTwo.get(i)); + } + jsonObjectOne.put("videoList", videoListOne); + } + // 合并pictures + if (jsonObjectTwo.has("pictures")) { + JSONArray picturesTwo = jsonObjectTwo.getJSONArray("pictures"); + JSONArray picturesOne = jsonObjectOne.optJSONArray("pictures"); + if (picturesOne == null) { + picturesOne = new JSONArray(); + } + for (int i = 0; i < picturesTwo.length(); i++) { + picturesOne.put(picturesTwo.get(i)); + } + jsonObjectOne.put("pictures", picturesOne); + } + return jsonObjectOne; + } /** * 修改预警信息 * @@ -203,7 +351,7 @@ public class DcWarningServiceImpl implements IDcWarningService if ("0".equals(dcWarningBatchConvert.getType())){ dcWarningMapper.batchDelete(dcWarningList); } else { - //确认,批量转换为事件 + //确认,批量转换为事件 List dcEventList = new ArrayList<>(); for (DcWarning dcWarning : dcWarningList) { if (dcWarning == null || dcWarning.getId() == null || StringUtils.isBlank(dcWarning.getStakeMark()) || @@ -238,156 +386,6 @@ public class DcWarningServiceImpl implements IDcWarningService dcEvent.setCreateTime(DateUtils.getNowDate());//创建时间 dcEvent.setUserId(SecurityUtils.getUserId());//处置人员 - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.HOUR,3); - dcEvent.setEstimatedEndTime(cal.getTime()); //预计解除时间 - dcEvent.setRoadId(1L); //道路id - dcEvent.setRoadName("济菏高速"); //道路id - dcEvent.setInTunnel(0); //是否处在隧道 - - - Integer warningType = dcWarning.getWarningType(); - if (warningType == 1){ - - //交通拥堵 - DcEventTrafficCongestion dcEventTrafficCongestion = new DcEventTrafficCongestion(); - dcEventTrafficCongestion.setId(dcWarning.getId()); - dcEventTrafficCongestion.setCongestionCause(5L); - dcEventTrafficCongestion.setCongestionMileage(0F); - dcEventTrafficCongestion.setMaxCongestionMileage(0F); - dcEvent.setDcEventTrafficCongestion(dcEventTrafficCongestion); - } else if (warningType == 4) { - //停车 - DcEventVehicleAccident dcEventVehicleAccident = new DcEventVehicleAccident(); - dcEventVehicleAccident.setId(dcWarning.getId()); - - if (dcWarning.getWarningSource() == 1) { - dcEventVehicleAccident.setReporterName("视频AI"); - } else if (dcWarning.getWarningSource() == 2) { - dcEventVehicleAccident.setReporterName("雷达识别"); - } else if (dcWarning.getWarningSource() == 3) { - dcEventVehicleAccident.setReporterName("智慧锥桶"); - } else if (dcWarning.getWarningSource() == 4) { - dcEventVehicleAccident.setReporterName("护栏碰撞"); - } else if (dcWarning.getWarningSource() == 6) { - dcEventVehicleAccident.setReporterName("非机预警"); - } - dcEventVehicleAccident.setReporterPhoneNumber("96659"); - dcEventVehicleAccident.setLocationType(1L); - dcEventVehicleAccident.setTrafficJam(0L); - dcEventVehicleAccident.setWeatherCondition(1L); - dcEventVehicleAccident.setCongestionAhead(1); - dcEventVehicleAccident.setAtIntersection(1); - dcEventVehicleAccident.setOnCurve(1); - dcEventVehicleAccident.setSmallCar(0L); - dcEventVehicleAccident.setTrucks(0L); - dcEventVehicleAccident.setBuses(0L); - dcEventVehicleAccident.setTankers(0L); - dcEventVehicleAccident.setMinorInjuries(0L); - dcEventVehicleAccident.setSeriousInjuries(0L); - dcEventVehicleAccident.setFatalities(0L); - dcEvent.setDcEventVehicleAccident(dcEventVehicleAccident); - } else if (warningType == 7){ - //道路施工 - - } else if (warningType == 8) { - //异常天气 - DcEventAbnormalWeather dcEventAbnormalWeather = new DcEventAbnormalWeather(); - dcEventAbnormalWeather.setId(dcWarning.getId()); - dcEventAbnormalWeather.setEmergencyLevel(1L); - dcEvent.setDcEventAbnormalWeather(dcEventAbnormalWeather); - } else if (warningType == 9) { - //护栏碰撞 - DcEventAccident dcEventAccident = new DcEventAccident(); - dcEventAccident.setId(dcWarning.getId()); - if (dcWarning.getWarningSource() == 1) { - dcEventAccident.setReporterName("视频AI"); - dcEventAccident.setReporterPhoneNumber("96659"); - } else if (dcWarning.getWarningSource() == 2) { - dcEventAccident.setReporterName("雷达识别"); - dcEventAccident.setReporterPhoneNumber("96659"); - } else if (dcWarning.getWarningSource() == 3) { - dcEventAccident.setReporterName("智慧锥桶"); - dcEventAccident.setReporterPhoneNumber("96659"); - } else if (dcWarning.getWarningSource() == 4) { - dcEventAccident.setReporterName("护栏碰撞"); - dcEventAccident.setReporterPhoneNumber("96659"); - } else if (dcWarning.getWarningSource() == 5) { - dcEventAccident.setReporterName("扫码报警"); - JSONObject otherConfig = JSONObject.parseObject(dcWarning.getOtherConfig()); - if (otherConfig != null && otherConfig.containsKey("phone")) { - dcEventAccident.setReporterPhoneNumber(otherConfig.getString("phone")); - dcEventAccident.setVehicleOwnerPhone(otherConfig.getString("phone")); - } - } else if (dcWarning.getWarningSource() == 6) { - dcEventAccident.setReporterName("非机预警"); - dcEventAccident.setReporterPhoneNumber("96659"); - } - dcEventAccident.setLocationType(1L); - dcEventAccident.setTrafficJam(0f); - dcEventAccident.setWeatherCondition(1L); - dcEventAccident.setImpactLevel(1L); - dcEventAccident.setIsReverseCargo(0); - dcEventAccident.setIsMaintenance(0); - dcEventAccident.setCongestionAhead(0); - dcEventAccident.setOnCurve(0); - dcEventAccident.setSmallCar(0L); - dcEventAccident.setTrucks(0L); - dcEventAccident.setBuses(0L); - dcEventAccident.setTankers(0L); - dcEventAccident.setMinorInjuries(0L); - dcEventAccident.setSeriousInjuries(0L); - dcEventAccident.setFatalities(0L); - dcEvent.setDcEventAccident(dcEventAccident); - } else if (warningType == 10) { - //交通事故 - DcEventAccident dcEventAccident = new DcEventAccident(); - - - } else if (warningType == 11) { - //车辆故障 - DcEventVehicleAccident dcEventVehicleAccident = new DcEventVehicleAccident(); - dcEventVehicleAccident.setId(dcWarning.getId()); - - if (dcWarning.getWarningSource() == 1) { - dcEventVehicleAccident.setReporterName("视频AI"); - dcEventVehicleAccident.setReporterPhoneNumber("96659"); - } else if (dcWarning.getWarningSource() == 2) { - dcEventVehicleAccident.setReporterName("雷达识别"); - dcEventVehicleAccident.setReporterPhoneNumber("96659"); - } else if (dcWarning.getWarningSource() == 3) { - dcEventVehicleAccident.setReporterName("智慧锥桶"); - dcEventVehicleAccident.setReporterPhoneNumber("96659"); - } else if (dcWarning.getWarningSource() == 4) { - dcEventVehicleAccident.setReporterName("护栏碰撞"); - dcEventVehicleAccident.setReporterPhoneNumber("96659"); - } else if (dcWarning.getWarningSource() == 5) { - dcEventVehicleAccident.setReporterName("扫码报警"); - JSONObject otherConfig = JSONObject.parseObject(dcWarning.getOtherConfig()); - if (otherConfig != null && otherConfig.containsKey("phone")) { - dcEventVehicleAccident.setReporterPhoneNumber(otherConfig.getString("phone")); - } - } else if (dcWarning.getWarningSource() == 6) { - dcEventVehicleAccident.setReporterName("非机预警"); - dcEventVehicleAccident.setReporterPhoneNumber("96659"); - } - dcEventVehicleAccident.setLocationType(1L); - dcEventVehicleAccident.setTrafficJam(0L); - dcEventVehicleAccident.setWeatherCondition(1L); - dcEventVehicleAccident.setCongestionAhead(1); - dcEventVehicleAccident.setAtIntersection(1); - dcEventVehicleAccident.setOnCurve(1); - dcEventVehicleAccident.setSmallCar(0L); - dcEventVehicleAccident.setTrucks(0L); - dcEventVehicleAccident.setBuses(0L); - dcEventVehicleAccident.setTankers(0L); - dcEventVehicleAccident.setMinorInjuries(0L); - dcEventVehicleAccident.setSeriousInjuries(0L); - dcEventVehicleAccident.setFatalities(0L); - dcEvent.setDcEventVehicleAccident(dcEventVehicleAccident); - } - - dcEventList.add(dcEvent); } @@ -395,7 +393,6 @@ public class DcWarningServiceImpl implements IDcWarningService dcWarningMapper.batchUpdateState(SecurityUtils.getUserId(),dcWarningList); //批量插入事件表 dcEventService.batchInsertDcEventWarning(dcEventList); - } diff --git a/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml b/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml index 033288e8..8144dbf5 100644 --- a/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml @@ -100,7 +100,8 @@ FROM dc_road_section AS s LEFT JOIN ( SELECT mark.section_id, COUNT(1) AS number FROM dc_warning AS w JOIN dc_stake_mark AS mark ON mark.stake_mark = w.stake_mark AND mark.direction = w.direction - WHERE mark.stake_mark IS NOT NULL AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{warningTime}, '%Y-%m-%d') + WHERE mark.stake_mark IS NOT NULL AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{warningTime}, '%Y-%m-%d') + and w.warning_source!=6 GROUP BY mark.section_id ) AS w_count ON s.id = w_count.section_id @@ -127,18 +128,18 @@ SELECT HOUR(warning_time) AS time, COUNT(*) AS number FROM dc_warning WHERE MONTH(warning_time) = MONTH(CURDATE()) - AND YEAR(warning_time) = YEAR(CURDATE()) + AND YEAR(warning_time) = YEAR(CURDATE()) and warning_source!=6 GROUP BY HOUR(warning_time) ORDER BY HOUR(warning_time); @@ -169,7 +171,7 @@ ) t1 left join (select HOUR(warning_time) hours,count(*) num from dc_warning t1 - left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark + left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.warning_source!=6 and t1.direction = t2.direction where date_format(warning_time,'%Y-%m-%d') = date_format(#{warningTime},'%Y-%m-%d') and t2.section_id = #{sectionId} and t1.direction=#{direction} and t2.direction=#{direction} @@ -182,7 +184,7 @@ LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark WHERE DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m') AND warning.direction=#{direction} and mark.direction=#{direction} - and mark.`section_id`=#{sectionId} + and mark.`section_id`=#{sectionId} and warning.warning_source!=6 GROUP BY day ORDER BY day @@ -194,7 +196,7 @@ LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark WHERE QUARTER(warning.warning_time)=#{quarter} AND warning.direction=#{direction} and mark.direction=#{direction} - and mark.`section_id`=#{sectionId} + and mark.`section_id`=#{sectionId} and warning.warning_source!=6 GROUP BY MONTH ORDER BY MONTH; @@ -209,7 +211,7 @@ (select month(warning_time) hours,count(*) num from dc_warning t1 left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction where DATE_FORMAT(t1.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y') and t2.section_id =#{sectionId} - and t1.direction=#{direction} and t2.direction=#{direction} GROUP BY hours) t2 + and t1.direction=#{direction} and t1.warning_source!=6 and t2.direction=#{direction} GROUP BY hours) t2 on t1.n = t2.hours @@ -235,7 +237,7 @@ LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark where DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m') AND warning.direction=#{direction} and mark.direction=#{direction} - and mark.`section_id`=#{sectionId} + and mark.`section_id`=#{sectionId} and warning.warning_source!=6 @@ -254,7 +256,7 @@ LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark WHERE QUARTER(warning.warning_time)=#{quarter} AND warning.direction=#{direction} and mark.direction=#{direction} - and mark.`section_id`=#{sectionId} + and mark.`section_id`=#{sectionId} and warning.warning_source!=6 @@ -273,7 +275,7 @@ LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark where mark.`section_id`=#{sectionId} AND warning.direction=#{direction} and mark.direction=#{direction} and DATE_FORMAT(warning.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y') - + and warning.warning_source!=6 @@ -356,7 +359,7 @@ diff --git a/zc-business/src/main/resources/mapper/business/DcRoadSectionMapper.xml b/zc-business/src/main/resources/mapper/business/DcRoadSectionMapper.xml index aa4eab64..c47cc671 100644 --- a/zc-business/src/main/resources/mapper/business/DcRoadSectionMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcRoadSectionMapper.xml @@ -31,7 +31,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + update dc_stake_mark set section_id=#{sectionId} where stake_mark=#{stakeMark} diff --git a/zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml b/zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml index fb141fa1..a18da1eb 100644 --- a/zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml @@ -109,6 +109,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + diff --git a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml index 070a93bd..b0d6e2c7 100644 --- a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml @@ -64,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - where id = #{id} @@ -159,6 +159,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + update dc_warning set other_config=#{otherConfig} where id=#{id} + delete from dc_warning where id = #{id} @@ -197,5 +200,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and warning_subclass = #{warningSubclass} +