提交 00d2ca60 作者: 涂茂林

feat:报警扫描定时任务

上级 87df2a26
...@@ -8,6 +8,7 @@ import com.yiring.common.core.Result; ...@@ -8,6 +8,7 @@ import com.yiring.common.core.Result;
* @version 1.0 * @version 1.0
* @date 2022/4/29 9:21 * @date 2022/4/29 9:21
*/ */
@FunctionalInterface
public interface IParamInitStrategy<T> { public interface IParamInitStrategy<T> {
/** /**
* 校验参数 * 校验参数
......
...@@ -10,6 +10,7 @@ import com.yiring.app.vo.location.fence.LocationFenceJobVo; ...@@ -10,6 +10,7 @@ import com.yiring.app.vo.location.fence.LocationFenceJobVo;
* @version 1.0 * @version 1.0
* @date 2022/5/14 11:05 * @date 2022/5/14 11:05
*/ */
@FunctionalInterface
public interface IScanAlarmStrategy { public interface IScanAlarmStrategy {
/** /**
* 判断是否触发报警 * 判断是否触发报警
......
...@@ -16,7 +16,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -16,7 +16,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class ScanAlarmContext { public class ScanAlarmContext {
public static final ConcurrentHashMap<Integer, IScanAlarmStrategy> MAP = new ConcurrentHashMap<>(10); private static final ConcurrentHashMap<Integer, IScanAlarmStrategy> MAP = new ConcurrentHashMap<>(10);
public static void register(Integer relevanceParam, IScanAlarmStrategy strategy) { public static void register(Integer relevanceParam, IScanAlarmStrategy strategy) {
MAP.put(relevanceParam, strategy); MAP.put(relevanceParam, strategy);
......
...@@ -3,20 +3,33 @@ package com.yiring.app.design.strategy.rule; ...@@ -3,20 +3,33 @@ package com.yiring.app.design.strategy.rule;
import com.yiring.app.constant.alarm.RelevanceParamEnum; import com.yiring.app.constant.alarm.RelevanceParamEnum;
import com.yiring.app.design.strategy.IParamInitStrategy; import com.yiring.app.design.strategy.IParamInitStrategy;
import com.yiring.app.design.strategy.IScanAlarmStrategy;
import com.yiring.app.domain.alarm.AlarmType;
import com.yiring.app.domain.location.LocationFence;
import com.yiring.app.domain.location.LocationFenceAlarm;
import com.yiring.app.domain.location.LocationTag;
import com.yiring.app.param.location.fence.LocationFenceJobParam;
import com.yiring.app.param.location.rule.LocationFenceRuleAddParam; import com.yiring.app.param.location.rule.LocationFenceRuleAddParam;
import com.yiring.app.param.location.rule.RuleParam; import com.yiring.app.param.location.rule.RuleParam;
import com.yiring.app.vo.location.fence.LocationFenceJobVo;
import com.yiring.common.core.Result; import com.yiring.common.core.Result;
import com.yiring.common.core.Status; import com.yiring.common.core.Status;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
/** /**
* 静止时长相关策略
* @author tml * @author tml
* @version 1.0 * @version 1.0
* @date 2022/4/29 9:32 * @date 2022/4/29 9:32
*/ */
@Component @Component
public class StaticDurationStrategy implements IParamInitStrategy<LocationFenceRuleAddParam> { public class StaticDurationStrategy implements IParamInitStrategy<LocationFenceRuleAddParam>, IScanAlarmStrategy {
public StaticDurationStrategy() { public StaticDurationStrategy() {
Integer relevanceParam = RelevanceParamEnum.STATIC_DURATION.getCode(); Integer relevanceParam = RelevanceParamEnum.STATIC_DURATION.getCode();
...@@ -34,4 +47,50 @@ public class StaticDurationStrategy implements IParamInitStrategy<LocationFenceR ...@@ -34,4 +47,50 @@ public class StaticDurationStrategy implements IParamInitStrategy<LocationFenceR
ruleParam.setTimeAndNumber(new ArrayList<>()); ruleParam.setTimeAndNumber(new ArrayList<>());
return Result.ok(); return Result.ok();
} }
@Override
public LocationFenceJobVo scanAlarm(LocationFenceJobParam param) {
RuleParam rule = param.getRule();
Set<LocationTag> tagSet = param.getTagSet();
Long mapId = param.getMapId();
List<LocationFenceAlarm> oldAlarms = param.getOldAlarms();
Long fenceId = param.getFenceId();
Long alarmTypeId = param.getAlarmTypeId();
LocationFenceJobVo jobVo = new LocationFenceJobVo();
//筛选出围栏中静止的,并且静止时长超过配置规则时长的标签
LocalDateTime time = LocalDateTime.now().minusMinutes(rule.getDuration());
List<LocationFenceAlarm> newAlarms = tagSet
.stream()
.filter(LocationTag::getSilent)
.filter(e -> e.getTime().isBefore(time))
.map(e -> {
LocationFence fence = LocationFence.builder().id(fenceId).build();
AlarmType alarmType = AlarmType.builder().id(alarmTypeId).build();
return LocationFenceAlarm
.builder()
.fence(fence)
.point(e.getPoint())
.areaId(mapId)
.user(e.getUser())
.tag(e)
.startTime(LocalDateTime.now())
.type(alarmType)
.status(LocationFenceAlarm.Status.ING)
.build();
})
.collect(Collectors.toList());
//取两个集合没有相交的部分,newAlarms不重合的部分代表需要添加的报警,oldAlarms不重合的部分代表需要结束的报警
if (!CollectionUtils.isEmpty(oldAlarms)) {
Set<Long> newSet = newAlarms.stream().map(e -> e.getTag().getId()).collect(Collectors.toSet());
Set<Long> oldSet = oldAlarms.stream().map(e -> e.getTag().getId()).collect(Collectors.toSet());
newAlarms =
newAlarms.stream().filter(e -> !oldSet.contains(e.getTag().getId())).collect(Collectors.toList());
oldAlarms =
oldAlarms.stream().filter(e -> !newSet.contains(e.getTag().getId())).collect(Collectors.toList());
}
jobVo.setAddAlarm(newAlarms);
jobVo.setModifyAlarm(oldAlarms);
return jobVo;
}
} }
...@@ -3,20 +3,39 @@ package com.yiring.app.design.strategy.rule; ...@@ -3,20 +3,39 @@ package com.yiring.app.design.strategy.rule;
import com.yiring.app.constant.alarm.RelevanceParamEnum; import com.yiring.app.constant.alarm.RelevanceParamEnum;
import com.yiring.app.design.strategy.IParamInitStrategy; import com.yiring.app.design.strategy.IParamInitStrategy;
import com.yiring.app.design.strategy.IScanAlarmStrategy;
import com.yiring.app.domain.alarm.AlarmType;
import com.yiring.app.domain.location.LocationFence;
import com.yiring.app.domain.location.LocationFenceAlarm;
import com.yiring.app.domain.location.LocationTag;
import com.yiring.app.domain.location.LocationTagRepository;
import com.yiring.app.param.location.fence.LocationFenceJobParam;
import com.yiring.app.param.location.rule.LocationFenceRuleAddParam; import com.yiring.app.param.location.rule.LocationFenceRuleAddParam;
import com.yiring.app.param.location.rule.RuleParam; import com.yiring.app.param.location.rule.RuleParam;
import com.yiring.app.vo.location.fence.LocationFenceJobVo;
import com.yiring.common.core.Result; import com.yiring.common.core.Result;
import com.yiring.common.core.Status; import com.yiring.common.core.Status;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.locationtech.jts.geom.Geometry;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
/** /**
* 触发报警距离相关策略
* @author tml * @author tml
* @version 1.0 * @version 1.0
* @date 2022/4/29 9:33 * @date 2022/4/29 9:33
*/ */
@Component @Component
public class TriggerAlarmDistanceStrategy implements IParamInitStrategy<LocationFenceRuleAddParam> { public class TriggerAlarmDistanceStrategy implements IParamInitStrategy<LocationFenceRuleAddParam>, IScanAlarmStrategy {
@Resource
private LocationTagRepository locationTagRepository;
public TriggerAlarmDistanceStrategy() { public TriggerAlarmDistanceStrategy() {
Integer relevanceParam = RelevanceParamEnum.TRIGGER_ALARM_DISTANCE.getCode(); Integer relevanceParam = RelevanceParamEnum.TRIGGER_ALARM_DISTANCE.getCode();
...@@ -34,4 +53,49 @@ public class TriggerAlarmDistanceStrategy implements IParamInitStrategy<Location ...@@ -34,4 +53,49 @@ public class TriggerAlarmDistanceStrategy implements IParamInitStrategy<Location
ruleParam.setTimeAndNumber(new ArrayList<>()); ruleParam.setTimeAndNumber(new ArrayList<>());
return Result.ok(); return Result.ok();
} }
@Override
public LocationFenceJobVo scanAlarm(LocationFenceJobParam param) {
RuleParam rule = param.getRule();
Set<LocationTag> tagSet = param.getTagSet();
Long mapId = param.getMapId();
List<LocationFenceAlarm> oldAlarms = param.getOldAlarms();
Long fenceId = param.getFenceId();
Long alarmTypeId = param.getAlarmTypeId();
Geometry geometry = param.getGeometry();
LocationFenceJobVo jobVo = new LocationFenceJobVo();
//查询出距离围栏规则之类距离的所有标签,封装成报警信息
List<LocationTag> locationTags = locationTagRepository.findByDistance(geometry, rule.getDistance());
List<LocationFenceAlarm> newAlarms = locationTags
.stream()
.map(e -> {
LocationFence fence = LocationFence.builder().id(fenceId).build();
AlarmType alarmType = AlarmType.builder().id(alarmTypeId).build();
return LocationFenceAlarm
.builder()
.fence(fence)
.point(e.getPoint())
.areaId(mapId)
.user(e.getUser())
.tag(e)
.startTime(LocalDateTime.now())
.type(alarmType)
.status(LocationFenceAlarm.Status.ING)
.build();
})
.collect(Collectors.toList());
//取两个集合没有相交的部分,newAlarms不重合的部分代表需要添加的报警,oldAlarms不重合的部分代表需要结束的报警
if (!CollectionUtils.isEmpty(oldAlarms)) {
Set<Long> newSet = newAlarms.stream().map(e -> e.getTag().getId()).collect(Collectors.toSet());
Set<Long> oldSet = oldAlarms.stream().map(e -> e.getTag().getId()).collect(Collectors.toSet());
newAlarms =
newAlarms.stream().filter(e -> !oldSet.contains(e.getTag().getId())).collect(Collectors.toList());
oldAlarms =
oldAlarms.stream().filter(e -> !newSet.contains(e.getTag().getId())).collect(Collectors.toList());
}
jobVo.setAddAlarm(newAlarms);
jobVo.setModifyAlarm(oldAlarms);
return jobVo;
}
} }
...@@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/** /**
...@@ -25,7 +26,15 @@ public interface LocationFenceAlarmRepository ...@@ -25,7 +26,15 @@ public interface LocationFenceAlarmRepository
* @param now 当前时间 * @param now 当前时间
* @return 修改量 * @return 修改量
*/ */
@Query("UPDATE LocationFenceAlarm SET status = 'OVER', updateTime = ?2 WHERE id IN(?1)") @Query("UPDATE LocationFenceAlarm SET status = 'OVER', updateTime = :now WHERE id IN(:ids)")
@Modifying @Modifying
int batchOver(List<Long> ids, LocalDateTime now); int batchOver(@Param("ids") List<Long> ids, @Param("now") LocalDateTime now);
/**
* 根据状态查询
* @param status 状态
* @return 报警信息
*/
@Query("SELECT l FROM LocationFenceAlarm l WHERE l.status = ?1")
List<LocationFenceAlarm> findAllByStatus(LocationFenceAlarm.Status status);
} }
...@@ -6,6 +6,8 @@ import com.yiring.common.annotation.FieldMapping; ...@@ -6,6 +6,8 @@ import com.yiring.common.annotation.FieldMapping;
import com.yiring.common.domain.BasicEntity; import com.yiring.common.domain.BasicEntity;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;
import javax.persistence.*; import javax.persistence.*;
import lombok.*; import lombok.*;
import lombok.experimental.FieldDefaults; import lombok.experimental.FieldDefaults;
...@@ -107,6 +109,9 @@ public class LocationTag extends BasicEntity implements Serializable { ...@@ -107,6 +109,9 @@ public class LocationTag extends BasicEntity implements Serializable {
@Comment("是否在厂外") @Comment("是否在厂外")
Boolean out; Boolean out;
@Comment("静止/运动变更时间")
LocalDateTime time;
@SuppressWarnings({ "unused" }) @SuppressWarnings({ "unused" })
public enum Type { public enum Type {
BTT01("蓝牙人员定位卡"), BTT01("蓝牙人员定位卡"),
...@@ -122,4 +127,31 @@ public class LocationTag extends BasicEntity implements Serializable { ...@@ -122,4 +127,31 @@ public class LocationTag extends BasicEntity implements Serializable {
return this.text; return this.text;
} }
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LocationTag that = (LocationTag) o;
return (
Objects.equals(linkId, that.linkId) &&
Objects.equals(imei, that.imei) &&
Objects.equals(code, that.code) &&
type == that.type &&
Objects.equals(silent, that.silent) &&
Objects.equals(user, that.user) &&
Objects.equals(used, that.used) &&
Objects.equals(volt, that.volt) &&
Objects.equals(voltUnit, that.voltUnit) &&
Objects.equals(category, that.category) &&
Objects.equals(point, that.point) &&
Objects.equals(out, that.out) &&
Objects.equals(time, that.time)
);
}
@Override
public int hashCode() {
return Objects.hash(linkId, imei, code, type, silent, user, used, volt, voltUnit, category, point, out, time);
}
} }
...@@ -7,6 +7,7 @@ import org.locationtech.jts.geom.Geometry; ...@@ -7,6 +7,7 @@ import org.locationtech.jts.geom.Geometry;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/** /**
...@@ -41,4 +42,13 @@ public interface LocationTagRepository ...@@ -41,4 +42,13 @@ public interface LocationTagRepository
*/ */
@Query(value = "SELECT * FROM BS_LOCATION_TAG WHERE user_id IN (?1)", nativeQuery = true) @Query(value = "SELECT * FROM BS_LOCATION_TAG WHERE user_id IN (?1)", nativeQuery = true)
List<LocationTag> findByUserIds(List<Long> userIds); List<LocationTag> findByUserIds(List<Long> userIds);
/**
* 查询距离指定区域多少米的标签
* @param geometry 指定区域
* @param distance 距离(米)
* @return 定位标签
*/
@Query(value = "SELECT * FROM BS_LOCATION_TAG WHERE st_distance(point, :geometry) < :distance", nativeQuery = true)
List<LocationTag> findByDistance(@Param("geometry") Geometry geometry, @Param("distance") Integer distance);
} }
...@@ -4,17 +4,20 @@ package com.yiring.app.job; ...@@ -4,17 +4,20 @@ package com.yiring.app.job;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
import com.yiring.app.design.strategy.rule.ScanAlarmContext; import com.yiring.app.design.strategy.rule.ScanAlarmContext;
import com.yiring.app.domain.location.LocationFence; import com.yiring.app.domain.location.*;
import com.yiring.app.domain.location.LocationFenceRepository;
import com.yiring.app.domain.location.LocationFenceRule;
import com.yiring.app.param.location.fence.LocationFenceJobParam; import com.yiring.app.param.location.fence.LocationFenceJobParam;
import com.yiring.app.param.location.rule.RuleParam; import com.yiring.app.param.location.rule.RuleParam;
import com.yiring.app.vo.location.fence.LocationFenceJobVo; import com.yiring.app.vo.location.fence.LocationFenceJobVo;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
/** /**
* @author tml * @author tml
...@@ -28,15 +31,31 @@ public class FenceAlarmJob { ...@@ -28,15 +31,31 @@ public class FenceAlarmJob {
@Resource @Resource
private LocationFenceRepository locationFenceRepository; private LocationFenceRepository locationFenceRepository;
@Resource
private LocationFenceAlarmRepository locationFenceAlarmRepository;
@XxlJob("ScanAlarmHandler") @XxlJob("ScanAlarmHandler")
@Transactional(rollbackFor = Exception.class)
public void scanAlarmHandler() { public void scanAlarmHandler() {
//查询出所有已启用的电子围栏信息 //查询出所有已启用的电子围栏信息和正在报警的报警信息
List<LocationFence> fenceList = locationFenceRepository.findAllByEnable(true); List<LocationFence> fenceList = locationFenceRepository.findAllByEnable(true);
List<LocationFenceAlarm> alarmList = locationFenceAlarmRepository.findAllByStatus(
LocationFenceAlarm.Status.ING
);
Map<Long, List<LocationFenceAlarm>> alarmMap = alarmList
.stream()
.collect(Collectors.groupingBy(e -> e.getFence().getId()));
LocationFenceJobVo jobVo = LocationFenceJobVo
.builder()
.addAlarm(new ArrayList<>())
.modifyAlarm(new ArrayList<>())
.build();
for (LocationFence fence : fenceList) { for (LocationFence fence : fenceList) {
//获取该围栏下的所有报警规则 //获取该围栏下的所有报警规则
Set<LocationFenceRule> fenceRuleSet = fence.getRules(); Set<LocationFenceRule> fenceRuleSet = fence.getRules();
for (LocationFenceRule fenceRule : fenceRuleSet) { for (LocationFenceRule fenceRule : fenceRuleSet) {
RuleParam ruleParam = JSON.parseObject(fenceRule.getRule(), RuleParam.class); RuleParam ruleParam = JSON.parseObject(fenceRule.getRule(), RuleParam.class);
List<LocationFenceAlarm> oldAlarms = alarmMap.get(fence.getId());
LocationFenceJobParam fenceJobParam = LocationFenceJobParam LocationFenceJobParam fenceJobParam = LocationFenceJobParam
.builder() .builder()
.rule(ruleParam) .rule(ruleParam)
...@@ -44,15 +63,24 @@ public class FenceAlarmJob { ...@@ -44,15 +63,24 @@ public class FenceAlarmJob {
.alarmTypeId(fenceRule.getAlarmType().getId()) .alarmTypeId(fenceRule.getAlarmType().getId())
.tagSet(fence.getTags()) .tagSet(fence.getTags())
.mapId(fence.getMapId()) .mapId(fence.getMapId())
//todo 查询出正在报警的规则 .geometry(fence.getGeometry())
//.oldAlarms() .oldAlarms(oldAlarms)
.build(); .build();
LocationFenceJobVo locationFenceJobVo = ScanAlarmContext.scanAlarm( LocationFenceJobVo locationFenceJobVo = ScanAlarmContext.scanAlarm(
fenceRule.getRelevanceParamType(), fenceRule.getRelevanceParamType(),
fenceJobParam fenceJobParam
); );
//todo 将结果入库 jobVo.merge(locationFenceJobVo);
} }
} }
//添加报警和关闭报警
locationFenceAlarmRepository.saveAllAndFlush(jobVo.getAddAlarm());
List<Long> ids = jobVo.getModifyAlarm().stream().map(LocationFenceAlarm::getId).collect(Collectors.toList());
locationFenceAlarmRepository.batchOver(ids, LocalDateTime.now());
log.info(
"FenceAlarmJob.scanAlarmHandler: 添加的报警:[{}], 关闭的报警:[{}]",
JSON.toJSONString(jobVo.getAddAlarm()),
JSON.toJSONString(jobVo.getModifyAlarm())
);
} }
} }
...@@ -12,6 +12,7 @@ import lombok.AllArgsConstructor; ...@@ -12,6 +12,7 @@ import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.locationtech.jts.geom.Geometry;
/** /**
* 扫描围栏报警的param * 扫描围栏报警的param
...@@ -54,6 +55,11 @@ public class LocationFenceJobParam implements Serializable { ...@@ -54,6 +55,11 @@ public class LocationFenceJobParam implements Serializable {
private Long mapId; private Long mapId;
/** /**
* 围栏的空间信息
*/
private Geometry geometry;
/**
* 属于该围栏当前正在报警的信息 * 属于该围栏当前正在报警的信息
*/ */
private List<LocationFenceAlarm> oldAlarms; private List<LocationFenceAlarm> oldAlarms;
......
...@@ -13,6 +13,7 @@ import lombok.Data; ...@@ -13,6 +13,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
*
* @author tml * @author tml
* @version 1.0 * @version 1.0
* @date 2022/5/12 11:56 * @date 2022/5/12 11:56
...@@ -21,7 +22,7 @@ import lombok.NoArgsConstructor; ...@@ -21,7 +22,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Builder @Builder
@ApiModel("演练计划查看回放param") @ApiModel("RehearsalPlanPlaybackParam")
public class RehearsalPlanPlaybackParam implements Serializable { public class RehearsalPlanPlaybackParam implements Serializable {
@Serial @Serial
...@@ -31,6 +32,6 @@ public class RehearsalPlanPlaybackParam implements Serializable { ...@@ -31,6 +32,6 @@ public class RehearsalPlanPlaybackParam implements Serializable {
@NotNull(message = "演练计划id不能为空") @NotNull(message = "演练计划id不能为空")
private Long id; private Long id;
@ApiModelProperty(value = "看回放的开始时间(不传则默认演练开始的时间)") @ApiModelProperty(value = "看回放的开始时间")
private LocalDateTime beginTime; private LocalDateTime beginTime;
} }
...@@ -35,7 +35,7 @@ public class HistoryRouteVo implements Serializable { ...@@ -35,7 +35,7 @@ public class HistoryRouteVo implements Serializable {
@ApiModelProperty(value = "工号", example = "ks2022") @ApiModelProperty(value = "工号", example = "ks2022")
private String uuid; private String uuid;
@ApiModelProperty(value = "经纬度") @ApiModelProperty(value = "经纬度", dataType = "java.lang.String")
private Point point; private Point point;
@ApiModelProperty(value = "地图名称", example = "总图") @ApiModelProperty(value = "地图名称", example = "总图")
......
...@@ -34,4 +34,13 @@ public class LocationFenceJobVo implements Serializable { ...@@ -34,4 +34,13 @@ public class LocationFenceJobVo implements Serializable {
* 需要修改成取消报警的报警信息集合 * 需要修改成取消报警的报警信息集合
*/ */
private List<LocationFenceAlarm> modifyAlarm; private List<LocationFenceAlarm> modifyAlarm;
/**
* 合并一个LocationFenceJobVo
* @param vo 目标LocationFenceJobVo
*/
public void merge(LocationFenceJobVo vo) {
addAlarm.addAll(vo.getAddAlarm());
modifyAlarm.addAll(vo.getModifyAlarm());
}
} }
...@@ -43,7 +43,7 @@ public class AccidentSpotVo implements Serializable { ...@@ -43,7 +43,7 @@ public class AccidentSpotVo implements Serializable {
@ApiModelProperty(value = "地图名称", example = "总图") @ApiModelProperty(value = "地图名称", example = "总图")
private String mapName; private String mapName;
@ApiModelProperty(value = "空间信息") @ApiModelProperty(value = "空间信息", dataType = "java.lang.String")
private Geometry geometry; private Geometry geometry;
@ApiModelProperty(value = "摄像头id", example = "1") @ApiModelProperty(value = "摄像头id", example = "1")
......
...@@ -42,7 +42,7 @@ public class EvacuationZoneVo implements Serializable { ...@@ -42,7 +42,7 @@ public class EvacuationZoneVo implements Serializable {
@ApiModelProperty(value = "地图名称", example = "总图") @ApiModelProperty(value = "地图名称", example = "总图")
private String mapName; private String mapName;
@ApiModelProperty(value = "空间信息") @ApiModelProperty(value = "空间信息", dataType = "java.lang.String")
private Geometry geometry; private Geometry geometry;
@ApiModelProperty(value = "摄像头id", example = "1") @ApiModelProperty(value = "摄像头id", example = "1")
......
...@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor; ...@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor;
* @version 1.0 * @version 1.0
* @date 2022/5/12 11:40 * @date 2022/5/12 11:40
*/ */
@ApiModel("演练计划实时数据VO") @ApiModel("RehearsalPlanRealTimeVo")
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
......
...@@ -18,7 +18,7 @@ import org.locationtech.jts.geom.Point; ...@@ -18,7 +18,7 @@ import org.locationtech.jts.geom.Point;
* @version 1.0 * @version 1.0
* @date 2022/5/12 11:48 * @date 2022/5/12 11:48
*/ */
@ApiModel("员工位置信息VO") @ApiModel("员工位置信息")
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
...@@ -35,6 +35,6 @@ public class UserLocationVo implements Serializable { ...@@ -35,6 +35,6 @@ public class UserLocationVo implements Serializable {
@ApiModelProperty(value = "员工姓名", example = "1") @ApiModelProperty(value = "员工姓名", example = "1")
private String realmName; private String realmName;
@ApiModelProperty(value = "员工坐标") @ApiModelProperty(value = "员工坐标", dataType = "java.lang.String")
private Point point; private Point point;
} }
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.web.alarm;
/**
* @author tml
* @version 1.0
* @date 2022/5/17 14:41
*/
public class FenceAlarmController {}
...@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.*;
@Validated @Validated
@SuppressWarnings({ "deprecation" }) @SuppressWarnings({ "deprecation" })
@Api(tags = "电子围栏报警规则,配置报警给谁", description = "AlarmRule") @Api(tags = "报警规则", description = "AlarmRule")
@RestController @RestController
@RequestMapping("/alarm/rule") @RequestMapping("/alarm/rule")
public class LocationAlarmRuleController { public class LocationAlarmRuleController {
......
...@@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
@Validated @Validated
@SuppressWarnings({ "deprecation" }) @SuppressWarnings({ "deprecation" })
@Api(tags = "电子围栏报警规则,什么情况下会报警", description = "FenceRule") @Api(tags = "电子围栏报警规则", description = "FenceRule")
@RestController @RestController
@RequestMapping("/location/rule") @RequestMapping("/location/rule")
public class LocationFenceRuleController { public class LocationFenceRuleController {
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
package com.yiring.app.web.rehearsal; package com.yiring.app.web.rehearsal;
import com.yiring.app.domain.alarm.AlarmType; import com.yiring.app.domain.alarm.AlarmType;
import com.yiring.app.domain.location.LocationTag;
import com.yiring.app.domain.location.LocationTagRepository;
import com.yiring.app.domain.rehearsal.AccidentSpot;
import com.yiring.app.domain.rehearsal.AccidentSpotRepository;
import com.yiring.app.param.rehearsal.RehearsalPlanAddParam; import com.yiring.app.param.rehearsal.RehearsalPlanAddParam;
import com.yiring.app.param.rehearsal.RehearsalPlanConditionParam; import com.yiring.app.param.rehearsal.RehearsalPlanConditionParam;
import com.yiring.app.param.rehearsal.RehearsalPlanModifyParam; import com.yiring.app.param.rehearsal.RehearsalPlanModifyParam;
...@@ -19,14 +15,10 @@ import com.yiring.common.param.PageParam; ...@@ -19,14 +15,10 @@ import com.yiring.common.param.PageParam;
import com.yiring.common.vo.PageVo; import com.yiring.common.vo.PageVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import org.locationtech.jts.geom.Geometry;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -47,12 +39,6 @@ public class RehearsalPlanController { ...@@ -47,12 +39,6 @@ public class RehearsalPlanController {
@Resource @Resource
private RehearsalPlanService rehearsalPlanService; private RehearsalPlanService rehearsalPlanService;
@Resource
LocationTagRepository locationTagRepository;
@Resource
AccidentSpotRepository accidentSpotRepository;
@ApiOperation("添加一条演练计划") @ApiOperation("添加一条演练计划")
@PostMapping("/addOne") @PostMapping("/addOne")
public Result<String> addOne(@Valid RehearsalPlanAddParam param) { public Result<String> addOne(@Valid RehearsalPlanAddParam param) {
...@@ -108,30 +94,15 @@ public class RehearsalPlanController { ...@@ -108,30 +94,15 @@ public class RehearsalPlanController {
return rehearsalPlanService.stop(idParam); return rehearsalPlanService.stop(idParam);
} }
@ApiOperation("查看演练(实时)") @ApiOperation("实时查看演练")
@GetMapping("/findRealTime") @GetMapping("/findRealTime")
public Result<RehearsalPlanRealTimeVo> findRealTime(@Valid IdParam idParam) { public Result<RehearsalPlanRealTimeVo> findRealTime(@Valid IdParam idParam) {
return rehearsalPlanService.findRealTime(idParam); return rehearsalPlanService.findRealTime(idParam);
} }
@ApiOperation("查看回放(每次查询一分钟的回放信息)") @ApiOperation("查看回放")
@GetMapping("/findPlayback") @GetMapping("/findPlayback")
public Result<PageVo<RehearsalPlanRealTimeVo>> findPlayback(@Valid RehearsalPlanPlaybackParam param) { public Result<PageVo<RehearsalPlanRealTimeVo>> findPlayback(@Valid RehearsalPlanPlaybackParam param) {
return rehearsalPlanService.findPlayback(param); return rehearsalPlanService.findPlayback(param);
} }
@PostMapping("/test")
public Geometry test(@RequestBody Geometry geometry) {
double degree = 100 / (2 * Math.PI * 6371004) * 360;
return geometry.buffer(degree);
}
@GetMapping("/get")
public Result<ArrayList<LocationTag>> get() {
Optional<AccidentSpot> optional = accidentSpotRepository.findById(1524292027951353856L);
Geometry geometry = optional.get().getGeometry();
List<LocationTag> inArea = locationTagRepository.findInArea(geometry);
System.out.println(inArea);
return Result.ok(new ArrayList<>(inArea));
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论