提交 72d1f1ff 作者: 涂茂林

feat:风险预警管理导入

上级 427753dc
...@@ -19,6 +19,7 @@ public class TemplateList { ...@@ -19,6 +19,7 @@ public class TemplateList {
RiskWarnExcel RiskWarnExcel
.builder() .builder()
.workAreaName("BTC产品库房") .workAreaName("BTC产品库房")
.point("112.863173604639,30.4786075211555,0")
.install("产品库房北侧中间立柱东1") .install("产品库房北侧中间立柱东1")
.monitoring("有毒气体报警器") .monitoring("有毒气体报警器")
.locationNum("AT-4736") .locationNum("AT-4736")
...@@ -36,6 +37,7 @@ public class TemplateList { ...@@ -36,6 +37,7 @@ public class TemplateList {
RiskWarnExcel RiskWarnExcel
.builder() .builder()
.workAreaName("计量槽") .workAreaName("计量槽")
.point("112.863173604639,30.4786075211555,0")
.install("1号槽液位") .install("1号槽液位")
.monitoring("液位") .monitoring("液位")
.locationNum("PI-2107A") .locationNum("PI-2107A")
...@@ -53,6 +55,7 @@ public class TemplateList { ...@@ -53,6 +55,7 @@ public class TemplateList {
RiskWarnExcel RiskWarnExcel
.builder() .builder()
.workAreaName("合成盐酸") .workAreaName("合成盐酸")
.point("112.863173604639,30.4786075211555,0")
.install("1号炉一楼") .install("1号炉一楼")
.monitoring("火焰检测") .monitoring("火焰检测")
.locationNum("BSA-1401A") .locationNum("BSA-1401A")
...@@ -63,7 +66,7 @@ public class TemplateList { ...@@ -63,7 +66,7 @@ public class TemplateList {
.high("") .high("")
.highHigh("") .highHigh("")
.flame("1") .flame("1")
.remark("注意:火焰检测在报警值(熄灭)这里添加预警值") .remark("注意:火焰检测在报警值(熄灭)这里添加预警值,等于这个数值时显示熄灭")
.build() .build()
); );
} }
......
...@@ -12,13 +12,16 @@ import com.yiring.app.param.location.fence.LocationFenceJobParam; ...@@ -12,13 +12,16 @@ import com.yiring.app.param.location.fence.LocationFenceJobParam;
import com.yiring.app.param.location.rule.*; import com.yiring.app.param.location.rule.*;
import com.yiring.app.util.TimeUtil; import com.yiring.app.util.TimeUtil;
import com.yiring.app.vo.location.fence.LocationFenceJobVo; import com.yiring.app.vo.location.fence.LocationFenceJobVo;
import com.yiring.auth.domain.user.User;
import com.yiring.auth.domain.user.UserRepository;
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.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.persistence.criteria.CriteriaBuilder;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -31,6 +34,9 @@ import org.springframework.util.CollectionUtils; ...@@ -31,6 +34,9 @@ import org.springframework.util.CollectionUtils;
@Component @Component
public class AllowEntranceStrategy implements IParamInitStrategy<LocationFenceRuleAddParam>, IScanAlarmStrategy { public class AllowEntranceStrategy implements IParamInitStrategy<LocationFenceRuleAddParam>, IScanAlarmStrategy {
@Resource
private UserRepository userRepository;
public AllowEntranceStrategy() { public AllowEntranceStrategy() {
Integer relevanceParam = RelevanceParamEnum.ALLOW_ENTRANCE.getCode(); Integer relevanceParam = RelevanceParamEnum.ALLOW_ENTRANCE.getCode();
LocationFenceRuleContext.register(relevanceParam, this); LocationFenceRuleContext.register(relevanceParam, this);
...@@ -62,6 +68,33 @@ public class AllowEntranceStrategy implements IParamInitStrategy<LocationFenceRu ...@@ -62,6 +68,33 @@ public class AllowEntranceStrategy implements IParamInitStrategy<LocationFenceRu
} }
} }
} }
//检查配置的员工是否存在
Specification<User> specification = (root, query, criteriaBuilder) -> {
CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get(User.Fields.uuid));
HashSet<String> ids = new HashSet<>();
for (TimeAndUserParam item : timeAndUser) {
for (RelevanceUserParam userParam : item.getUser()) {
ids.add(userParam.getUuid());
}
}
for (String uuid : ids) {
in.value(uuid);
}
return criteriaBuilder.and(in);
};
Map<String, List<User>> map = userRepository
.findAll(specification)
.stream()
.collect(Collectors.groupingBy(User::getUuid));
for (TimeAndUserParam item : timeAndUser) {
for (RelevanceUserParam userParam : item.getUser()) {
List<User> list = map.get(userParam.getUuid());
if (CollectionUtils.isEmpty(list)) {
return Result.no(Status.EXPECTATION_FAILED, "工号为:" + userParam.getUuid() + "员工不存在");
}
userParam.setRealName(list.get(0).getRealName());
}
}
ruleParam.setDuration(null); ruleParam.setDuration(null);
ruleParam.setDistance(null); ruleParam.setDistance(null);
ruleParam.setTimeAndNumber(new ArrayList<>()); ruleParam.setTimeAndNumber(new ArrayList<>());
......
...@@ -10,15 +10,16 @@ import com.yiring.app.param.location.fence.LocationFenceJobParam; ...@@ -10,15 +10,16 @@ import com.yiring.app.param.location.fence.LocationFenceJobParam;
import com.yiring.app.param.location.rule.*; import com.yiring.app.param.location.rule.*;
import com.yiring.app.util.TimeUtil; import com.yiring.app.util.TimeUtil;
import com.yiring.app.vo.location.fence.LocationFenceJobVo; import com.yiring.app.vo.location.fence.LocationFenceJobVo;
import com.yiring.auth.domain.user.User;
import com.yiring.auth.domain.user.UserRepository;
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.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.persistence.criteria.CriteriaBuilder;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -34,6 +35,9 @@ public class NotAllowLeaveStrategy implements IParamInitStrategy<LocationFenceRu ...@@ -34,6 +35,9 @@ public class NotAllowLeaveStrategy implements IParamInitStrategy<LocationFenceRu
@Resource @Resource
private LocationTurnoverRepository locationTurnoverRepository; private LocationTurnoverRepository locationTurnoverRepository;
@Resource
private UserRepository userRepository;
public NotAllowLeaveStrategy() { public NotAllowLeaveStrategy() {
Integer relevanceParam = RelevanceParamEnum.NOT_ALLOW_LEAVE.getCode(); Integer relevanceParam = RelevanceParamEnum.NOT_ALLOW_LEAVE.getCode();
LocationFenceRuleContext.register(relevanceParam, this); LocationFenceRuleContext.register(relevanceParam, this);
...@@ -65,6 +69,33 @@ public class NotAllowLeaveStrategy implements IParamInitStrategy<LocationFenceRu ...@@ -65,6 +69,33 @@ public class NotAllowLeaveStrategy implements IParamInitStrategy<LocationFenceRu
} }
} }
} }
//检查配置的员工是否存在
Specification<User> specification = (root, query, criteriaBuilder) -> {
CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get(User.Fields.uuid));
HashSet<String> ids = new HashSet<>();
for (TimeAndUserParam item : timeAndUser) {
for (RelevanceUserParam userParam : item.getUser()) {
ids.add(userParam.getUuid());
}
}
for (String uuid : ids) {
in.value(uuid);
}
return criteriaBuilder.and(in);
};
Map<String, List<User>> map = userRepository
.findAll(specification)
.stream()
.collect(Collectors.groupingBy(User::getUuid));
for (TimeAndUserParam item : timeAndUser) {
for (RelevanceUserParam userParam : item.getUser()) {
List<User> list = map.get(userParam.getUuid());
if (CollectionUtils.isEmpty(list)) {
return Result.no(Status.EXPECTATION_FAILED, "工号为:" + userParam.getUuid() + "员工不存在");
}
userParam.setRealName(list.get(0).getRealName());
}
}
ruleParam.setDuration(null); ruleParam.setDuration(null);
ruleParam.setDistance(null); ruleParam.setDistance(null);
ruleParam.setTimeAndNumber(new ArrayList<>()); ruleParam.setTimeAndNumber(new ArrayList<>());
......
...@@ -44,7 +44,7 @@ public class RiskWarn extends BasicEntity implements Serializable { ...@@ -44,7 +44,7 @@ public class RiskWarn extends BasicEntity implements Serializable {
private String install; private String install;
@Comment("经纬度") @Comment("经纬度")
@Column(columnDefinition = "geometry(Point,4326)") @Column(columnDefinition = "geometry(PointZ,4326)")
private Point point; private Point point;
@Comment("监控参数") @Comment("监控参数")
...@@ -68,6 +68,7 @@ public class RiskWarn extends BasicEntity implements Serializable { ...@@ -68,6 +68,7 @@ public class RiskWarn extends BasicEntity implements Serializable {
@ToString.Exclude @ToString.Exclude
@Comment("阈值区间信息") @Comment("阈值区间信息")
@Builder.Default @Builder.Default
@OneToMany(mappedBy = "riskWarn") @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.REFRESH })
@JoinColumn(name = "risk_warn_id")
private List<Threshold> thresholds = new ArrayList<>(); private List<Threshold> thresholds = new ArrayList<>();
} }
...@@ -30,10 +30,10 @@ public class Threshold extends BasicEntity implements Serializable { ...@@ -30,10 +30,10 @@ public class Threshold extends BasicEntity implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 3115736944401082777L; private static final long serialVersionUID = 3115736944401082777L;
@ManyToOne /*@ManyToOne
@JoinColumn(name = "risk_warn_id") @JoinColumn(name = "risk_warn_id")
@Comment("对应的风险预警信息") @Comment("对应的风险预警信息")
private RiskWarn riskWarn; private RiskWarn riskWarn;*/
@Comment("阈值区间起始值") @Comment("阈值区间起始值")
private String min; private String min;
......
...@@ -15,6 +15,7 @@ import lombok.AllArgsConstructor; ...@@ -15,6 +15,7 @@ import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;
/** /**
* @author tml * @author tml
...@@ -37,6 +38,9 @@ public class RiskWarnExcel implements Serializable { ...@@ -37,6 +38,9 @@ public class RiskWarnExcel implements Serializable {
@ExcelColumn(title = "安装位置", width = 15) @ExcelColumn(title = "安装位置", width = 15)
private String install; private String install;
@ExcelColumn(title = "经纬度", width = 30)
private String point;
@ExcelColumn(title = "监控参数", width = 15) @ExcelColumn(title = "监控参数", width = 15)
private String monitoring; private String monitoring;
...@@ -68,19 +72,34 @@ public class RiskWarnExcel implements Serializable { ...@@ -68,19 +72,34 @@ public class RiskWarnExcel implements Serializable {
private String remark; private String remark;
public static RiskWarnExcel transform(RiskWarn riskWarn) { public static RiskWarnExcel transform(RiskWarn riskWarn) {
String range = riskWarn.getMin() + " - " + riskWarn.getMax(); String range = "";
if (riskWarn.getMin() != null && riskWarn.getMax() != null) {
range = riskWarn.getMin() + "-" + riskWarn.getMax();
}
String point =
riskWarn.getPoint().getCoordinate().getX() +
"," +
riskWarn.getPoint().getCoordinate().getY() +
"," +
riskWarn.getPoint().getCoordinate().getZ();
Map<Integer, List<Threshold>> map = riskWarn Map<Integer, List<Threshold>> map = riskWarn
.getThresholds() .getThresholds()
.stream() .stream()
.collect(Collectors.groupingBy(Threshold::getStatus)); .collect(Collectors.groupingBy(Threshold::getStatus));
String lowLow = map.get(ThresholdStatusEnum.LOW_LOW.getCode()).get(0).getMin(); List<Threshold> lowLowList = map.get(ThresholdStatusEnum.LOW_LOW.getCode());
String low = map.get(ThresholdStatusEnum.LOW.getCode()).get(0).getMin(); List<Threshold> lowList = map.get(ThresholdStatusEnum.LOW.getCode());
String high = map.get(ThresholdStatusEnum.HIGH.getCode()).get(0).getMin(); List<Threshold> highList = map.get(ThresholdStatusEnum.HIGH.getCode());
String highHigh = map.get(ThresholdStatusEnum.HIGH_HIGH.getCode()).get(0).getMin(); List<Threshold> highHighList = map.get(ThresholdStatusEnum.HIGH_HIGH.getCode());
String flame = map.get(ThresholdStatusEnum.FLAME_EXTINGUISH.getCode()).get(0).getMin(); List<Threshold> flameList = map.get(ThresholdStatusEnum.FLAME_EXTINGUISH.getCode());
String lowLow = CollectionUtils.isEmpty(lowLowList) ? "" : lowLowList.get(0).getMin();
String low = CollectionUtils.isEmpty(lowList) ? "" : lowList.get(0).getMin();
String high = CollectionUtils.isEmpty(highList) ? "" : highList.get(0).getMin();
String highHigh = CollectionUtils.isEmpty(highHighList) ? "" : highHighList.get(0).getMin();
String flame = CollectionUtils.isEmpty(flameList) ? "" : flameList.get(0).getMin();
return RiskWarnExcel return RiskWarnExcel
.builder() .builder()
.workAreaName(riskWarn.getWorkArea().getWorkAreaName()) .workAreaName(riskWarn.getWorkArea().getWorkAreaName())
.point(point)
.install(riskWarn.getInstall()) .install(riskWarn.getInstall())
.monitoring(riskWarn.getMonitoring()) .monitoring(riskWarn.getMonitoring())
.locationNum(riskWarn.getLocationNum()) .locationNum(riskWarn.getLocationNum())
......
...@@ -7,6 +7,7 @@ import com.yiring.app.param.location.fence.LocationFenceConditionParam; ...@@ -7,6 +7,7 @@ import com.yiring.app.param.location.fence.LocationFenceConditionParam;
import com.yiring.app.param.location.fence.LocationFenceModifyParam; import com.yiring.app.param.location.fence.LocationFenceModifyParam;
import com.yiring.app.vo.CodeNameVo; import com.yiring.app.vo.CodeNameVo;
import com.yiring.app.vo.location.fence.FenceRealtimeVo; import com.yiring.app.vo.location.fence.FenceRealtimeVo;
import com.yiring.app.vo.location.fence.LocationFenceGeoVo;
import com.yiring.app.vo.location.fence.LocationFenceSearchVo; import com.yiring.app.vo.location.fence.LocationFenceSearchVo;
import com.yiring.app.vo.location.fence.LocationFenceVo; import com.yiring.app.vo.location.fence.LocationFenceVo;
import com.yiring.auth.param.IdsParam; import com.yiring.auth.param.IdsParam;
...@@ -52,6 +53,13 @@ public interface LocationFenceService { ...@@ -52,6 +53,13 @@ public interface LocationFenceService {
Result<PageVo<LocationFenceVo>> findList(LocationFenceConditionParam conditionParam, PageParam pageParam); Result<PageVo<LocationFenceVo>> findList(LocationFenceConditionParam conditionParam, PageParam pageParam);
/** /**
* 查询围栏的位置信息列表
* @param conditionParam 条件
* @return 是否成功
*/
Result<PageVo<LocationFenceGeoVo>> findGeoList(LocationFenceConditionParam conditionParam);
/**
* 根据id查询围栏信息 * 根据id查询围栏信息
* @param param id * @param param id
* @return 详细信息 * @return 详细信息
......
...@@ -13,6 +13,7 @@ import com.yiring.app.service.location.fence.LocationFenceService; ...@@ -13,6 +13,7 @@ import com.yiring.app.service.location.fence.LocationFenceService;
import com.yiring.app.util.JpaUtil; import com.yiring.app.util.JpaUtil;
import com.yiring.app.vo.CodeNameVo; import com.yiring.app.vo.CodeNameVo;
import com.yiring.app.vo.location.fence.FenceRealtimeVo; import com.yiring.app.vo.location.fence.FenceRealtimeVo;
import com.yiring.app.vo.location.fence.LocationFenceGeoVo;
import com.yiring.app.vo.location.fence.LocationFenceSearchVo; import com.yiring.app.vo.location.fence.LocationFenceSearchVo;
import com.yiring.app.vo.location.fence.LocationFenceVo; import com.yiring.app.vo.location.fence.LocationFenceVo;
import com.yiring.app.vo.map.MapVo; import com.yiring.app.vo.map.MapVo;
...@@ -36,6 +37,7 @@ import org.springframework.data.domain.Pageable; ...@@ -36,6 +37,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
/** /**
* 围栏信息service * 围栏信息service
...@@ -96,13 +98,34 @@ public class LocationFenceServiceImpl implements LocationFenceService { ...@@ -96,13 +98,34 @@ public class LocationFenceServiceImpl implements LocationFenceService {
if (optional.isEmpty()) { if (optional.isEmpty()) {
return Result.no(Status.EXPECTATION_FAILED, "要删除的围栏信息不存在"); return Result.no(Status.EXPECTATION_FAILED, "要删除的围栏信息不存在");
} }
if (!CollectionUtils.isEmpty(optional.get().getRules())) {
return Result.no(Status.EXPECTATION_FAILED, "要删除的围栏已经配置了规则,不能删除");
}
optional.get().setDeleted(true); optional.get().setDeleted(true);
return Result.ok(); return Result.ok();
} }
@Override @Override
public Result<PageVo<LocationFenceVo>> findList(LocationFenceConditionParam conditionParam, PageParam pageParam) { public Result<PageVo<LocationFenceVo>> findList(LocationFenceConditionParam conditionParam, PageParam pageParam) {
Specification<LocationFence> specification = (root, query, criteriaBuilder) -> { Specification<LocationFence> specification = getSpecification(conditionParam);
Pageable pageable = PageParam.toPageable(pageParam);
Page<LocationFence> fencePage = locationFenceRepository.findAll(specification, pageable);
List<LocationFenceVo> voList = fencePage.get().map(LocationFenceVo::transform).collect(Collectors.toList());
PageVo<LocationFenceVo> pageVo = PageVo.build(voList, fencePage.getTotalElements());
return Result.ok(pageVo);
}
@Override
public Result<PageVo<LocationFenceGeoVo>> findGeoList(LocationFenceConditionParam conditionParam) {
Specification<LocationFence> specification = getSpecification(conditionParam);
List<LocationFence> list = locationFenceRepository.findAll(specification);
List<LocationFenceGeoVo> voList = list.stream().map(LocationFenceGeoVo::transform).collect(Collectors.toList());
PageVo<LocationFenceGeoVo> pageVo = PageVo.build(voList, voList.size());
return Result.ok(pageVo);
}
private Specification<LocationFence> getSpecification(LocationFenceConditionParam conditionParam) {
return (root, query, criteriaBuilder) -> {
ArrayList<Predicate> list = new ArrayList<>(); ArrayList<Predicate> list = new ArrayList<>();
if (conditionParam.getMapId() != null) { if (conditionParam.getMapId() != null) {
list.add(criteriaBuilder.equal(root.get("mapId"), conditionParam.getMapId())); list.add(criteriaBuilder.equal(root.get("mapId"), conditionParam.getMapId()));
...@@ -113,11 +136,6 @@ public class LocationFenceServiceImpl implements LocationFenceService { ...@@ -113,11 +136,6 @@ public class LocationFenceServiceImpl implements LocationFenceService {
Predicate[] array = list.toArray(new Predicate[0]); Predicate[] array = list.toArray(new Predicate[0]);
return criteriaBuilder.and(array); return criteriaBuilder.and(array);
}; };
Pageable pageable = PageParam.toPageable(pageParam);
Page<LocationFence> fencePage = locationFenceRepository.findAll(specification, pageable);
List<LocationFenceVo> voList = fencePage.get().map(LocationFenceVo::transform).collect(Collectors.toList());
PageVo<LocationFenceVo> pageVo = PageVo.build(voList, fencePage.getTotalElements());
return Result.ok(pageVo);
} }
@Override @Override
......
...@@ -13,6 +13,7 @@ import com.yiring.common.core.Result; ...@@ -13,6 +13,7 @@ import com.yiring.common.core.Result;
import com.yiring.common.core.Status; import com.yiring.common.core.Status;
import com.yiring.common.param.IdParam; import com.yiring.common.param.IdParam;
import com.yiring.common.vo.PageVo; import com.yiring.common.vo.PageVo;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -79,6 +80,11 @@ public class LocationFenceRuleServiceImpl implements LocationFenceRuleService { ...@@ -79,6 +80,11 @@ public class LocationFenceRuleServiceImpl implements LocationFenceRuleService {
List<LocationFenceRuleVo> voList = ruleList List<LocationFenceRuleVo> voList = ruleList
.stream() .stream()
.map(LocationFenceRuleVo::transform) .map(LocationFenceRuleVo::transform)
.sorted(
Comparator
.comparing(LocationFenceRuleVo::getRelevanceParamType)
.thenComparing(LocationFenceRuleVo::getId)
)
.collect(Collectors.toList()); .collect(Collectors.toList());
PageVo<LocationFenceRuleVo> pageVo = PageVo.build(voList, voList.size()); PageVo<LocationFenceRuleVo> pageVo = PageVo.build(voList, voList.size());
return Result.ok(pageVo); return Result.ok(pageVo);
......
...@@ -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;
/** /**
* 区域信息VO * 区域信息VO
...@@ -39,12 +40,16 @@ public class DistrictVo implements Serializable { ...@@ -39,12 +40,16 @@ public class DistrictVo implements Serializable {
@ApiModelProperty(value = "风险等级(区域颜色)", example = "f##0000") @ApiModelProperty(value = "风险等级(区域颜色)", example = "f##0000")
private String riskGrade; private String riskGrade;
@ApiModelProperty(value = "区域位置信息", dataType = "java.lang.String")
private Geometry geometry;
public static DistrictVo transform(District district) { public static DistrictVo transform(District district) {
return DistrictVo return DistrictVo
.builder() .builder()
.id(district.getId()) .id(district.getId())
.name(district.getName()) .name(district.getName())
.riskGrade(district.getRiskGrade()) .riskGrade(district.getRiskGrade())
.geometry(district.getGeometry())
.build(); .build();
} }
} }
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.vo.location.fence;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yiring.app.domain.location.LocationFence;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serial;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.locationtech.jts.geom.Geometry;
/**
* @author tml
* @version 1.0
* @date 2022/5/26 9:08
*/
@ApiModel("电子围栏地图信息")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class LocationFenceGeoVo implements Serializable {
@Serial
private static final long serialVersionUID = 7736396772271720214L;
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "id")
private Long id;
@ApiModelProperty(value = "type")
private String type;
@ApiModelProperty("properties")
private Properties properties;
@ApiModelProperty(value = "位置信息")
private Geometry geometry;
public static LocationFenceGeoVo transform(LocationFence locationFence) {
return LocationFenceGeoVo
.builder()
.id(locationFence.getId())
.type("Feature")
.properties(new Properties(locationFence.getName(), locationFence.getGeometry().getGeometryType()))
.geometry(locationFence.getGeometry())
.build();
}
@Data
@AllArgsConstructor
@NoArgsConstructor
static class Properties {
@ApiModelProperty(value = "围栏名称")
private String name;
@ApiModelProperty(value = "位置类型")
private String type;
}
}
...@@ -14,6 +14,7 @@ import lombok.AllArgsConstructor; ...@@ -14,6 +14,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.Point;
/** /**
* @author tml * @author tml
...@@ -37,6 +38,9 @@ public class RiskWarnDetailVo implements Serializable { ...@@ -37,6 +38,9 @@ public class RiskWarnDetailVo implements Serializable {
@ApiModelProperty(value = "工区名称", example = "组装工区") @ApiModelProperty(value = "工区名称", example = "组装工区")
private String workAreaName; private String workAreaName;
@ApiModelProperty(value = "经纬度", dataType = "java.lang.String")
private Point point;
@ApiModelProperty(value = "安装位置", example = "组装厂区二楼") @ApiModelProperty(value = "安装位置", example = "组装厂区二楼")
private String install; private String install;
...@@ -68,6 +72,7 @@ public class RiskWarnDetailVo implements Serializable { ...@@ -68,6 +72,7 @@ public class RiskWarnDetailVo implements Serializable {
.builder() .builder()
.id(riskWarn.getId()) .id(riskWarn.getId())
.workAreaName(riskWarn.getWorkArea().getWorkAreaName()) .workAreaName(riskWarn.getWorkArea().getWorkAreaName())
.point(riskWarn.getPoint())
.install(riskWarn.getInstall()) .install(riskWarn.getInstall())
.monitoring(riskWarn.getMonitoring()) .monitoring(riskWarn.getMonitoring())
.locationNum(riskWarn.getLocationNum()) .locationNum(riskWarn.getLocationNum())
......
...@@ -10,6 +10,7 @@ import com.yiring.app.param.location.fence.LocationFenceModifyParam; ...@@ -10,6 +10,7 @@ import com.yiring.app.param.location.fence.LocationFenceModifyParam;
import com.yiring.app.service.location.fence.LocationFenceService; import com.yiring.app.service.location.fence.LocationFenceService;
import com.yiring.app.vo.CodeNameVo; import com.yiring.app.vo.CodeNameVo;
import com.yiring.app.vo.location.fence.FenceRealtimeVo; import com.yiring.app.vo.location.fence.FenceRealtimeVo;
import com.yiring.app.vo.location.fence.LocationFenceGeoVo;
import com.yiring.app.vo.location.fence.LocationFenceSearchVo; import com.yiring.app.vo.location.fence.LocationFenceSearchVo;
import com.yiring.app.vo.location.fence.LocationFenceVo; import com.yiring.app.vo.location.fence.LocationFenceVo;
import com.yiring.auth.param.IdsParam; import com.yiring.auth.param.IdsParam;
...@@ -63,7 +64,7 @@ public class LocationFenceController { ...@@ -63,7 +64,7 @@ public class LocationFenceController {
} }
@ApiOperation("根据条件分页查询围栏信息") @ApiOperation("根据条件分页查询围栏信息")
@PostMapping("/LocationFenceVo") @PostMapping("/findList")
public Result<PageVo<LocationFenceVo>> findList( public Result<PageVo<LocationFenceVo>> findList(
@Valid LocationFenceConditionParam conditionParam, @Valid LocationFenceConditionParam conditionParam,
@Valid PageParam pageParam @Valid PageParam pageParam
...@@ -75,6 +76,12 @@ public class LocationFenceController { ...@@ -75,6 +76,12 @@ public class LocationFenceController {
return locationFenceService.findList(conditionParam, pageParam); return locationFenceService.findList(conditionParam, pageParam);
} }
@ApiOperation("根据条件查询围栏地图位置信息")
@GetMapping("/findGeoList")
public Result<PageVo<LocationFenceGeoVo>> findGeoList(@Valid LocationFenceConditionParam conditionParam) {
return locationFenceService.findGeoList(conditionParam);
}
@ApiOperation("根据id查询围栏信息") @ApiOperation("根据id查询围栏信息")
@PostMapping("/findById") @PostMapping("/findById")
public Result<LocationFenceVo> findById(@Valid IdParam param) { public Result<LocationFenceVo> findById(@Valid IdParam param) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论