提交 d9d4b466 作者: 涂茂林

feat:围栏报警数据管理

上级 634cf4de
...@@ -88,5 +88,9 @@ public class LocationFenceAlarm extends BasicEntity implements Serializable { ...@@ -88,5 +88,9 @@ public class LocationFenceAlarm extends BasicEntity implements Serializable {
public String text() { public String text() {
return this.text; return this.text;
} }
public static Status get(boolean flag) {
return flag ? ING : OVER;
}
} }
} }
...@@ -26,7 +26,7 @@ public interface LocationFenceAlarmRepository ...@@ -26,7 +26,7 @@ public interface LocationFenceAlarmRepository
* @param now 当前时间 * @param now 当前时间
* @return 修改量 * @return 修改量
*/ */
@Query("UPDATE LocationFenceAlarm SET status = 'OVER', updateTime = :now WHERE id IN(:ids)") @Query("UPDATE LocationFenceAlarm SET status = 'OVER', updateTime = :now, endTime = :now WHERE id IN(:ids)")
@Modifying @Modifying
int batchOver(@Param("ids") List<Long> ids, @Param("now") LocalDateTime now); int batchOver(@Param("ids") List<Long> ids, @Param("now") LocalDateTime now);
......
...@@ -49,7 +49,7 @@ public interface EvacuationZoneRepository ...@@ -49,7 +49,7 @@ public interface EvacuationZoneRepository
* @param name 名称 * @param name 名称
* @return 撤离区列表 * @return 撤离区列表
*/ */
@Query("SELECT e FROM EvacuationZone e WHERE e.deleted = false AND e.name like %?1%") @Query("SELECT e FROM EvacuationZone e WHERE e.deleted = false AND e.enable = true AND e.name like %?1%")
List<EvacuationZone> findLikeName(String name); List<EvacuationZone> findLikeName(String name);
/** /**
......
...@@ -63,9 +63,6 @@ public class RehearsalPlan extends BasicEntity implements Serializable { ...@@ -63,9 +63,6 @@ public class RehearsalPlan extends BasicEntity implements Serializable {
@Comment("演练时间") @Comment("演练时间")
private LocalDateTime rehearsalTime; private LocalDateTime rehearsalTime;
@Comment("推送信息")
private String pushMsg;
@Comment("演练计划的状态(1:未启动, 2:进行中, 3:已结束)") @Comment("演练计划的状态(1:未启动, 2:进行中, 3:已结束)")
private Integer status; private Integer status;
......
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.excel.location.fence;
import com.github.liaochong.myexcel.core.annotation.ExcelColumn;
import com.github.liaochong.myexcel.core.annotation.ExcelModel;
import com.yiring.app.constant.alarm.FenceTypeEnum;
import com.yiring.app.domain.location.LocationFenceAlarm;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author tml
* @version 1.0
* @date 2022/5/17 17:23
*/
@ExcelModel
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class FenceAlarmExcel implements Serializable {
@Serial
private static final long serialVersionUID = 4526095986813965381L;
@ExcelColumn(title = "地图名称")
private String mapName;
@ExcelColumn(title = "围栏名称")
private String fenceName;
@ExcelColumn(title = "围栏类别")
private String fenceTypeName;
@ExcelColumn(title = "报警人员")
private String realName;
@ExcelColumn(title = "标签号")
private String tagId;
@ExcelColumn(title = "报警开始时间")
private LocalDateTime startTime;
@ExcelColumn(title = "报警结束时间")
private LocalDateTime endTime;
@ExcelColumn(title = "报警类型")
private String alarmTypeName;
@ExcelColumn(title = "接收人")
private String recipient;
@ExcelColumn(title = "报警状态")
private String statusName;
public static FenceAlarmExcel transform(LocationFenceAlarm fenceAlarm) {
return FenceAlarmExcel
.builder()
.fenceName(fenceAlarm.getFence().getName())
.fenceTypeName(FenceTypeEnum.getByCode(fenceAlarm.getFence().getFenceType()))
.realName(fenceAlarm.getUser().getRealName())
.tagId(fenceAlarm.getTag().getCode())
.startTime(fenceAlarm.getStartTime())
.endTime(fenceAlarm.getEndTime())
.alarmTypeName(fenceAlarm.getType().getName())
//todo
//.recipient()
.statusName(fenceAlarm.getStatus().text())
.build();
}
}
...@@ -29,31 +29,28 @@ public class RehearsalPlanExcel implements Serializable { ...@@ -29,31 +29,28 @@ public class RehearsalPlanExcel implements Serializable {
@Serial @Serial
private static final long serialVersionUID = -2976618459214077036L; private static final long serialVersionUID = -2976618459214077036L;
@ExcelColumn(title = "演练主题") @ExcelColumn(title = "演练主题", width = 10)
private String topical; private String topical;
@ExcelColumn(title = "事故点") @ExcelColumn(title = "事故点", width = 10)
private String accidentSpotName; private String accidentSpotName;
@ExcelColumn(title = "周边范围(m)") @ExcelColumn(title = "周边范围(m)", width = 10)
private Integer scope; private Integer scope;
@ExcelColumn(title = "撤离点") @ExcelColumn(title = "撤离点", width = 10)
private String evacuationZoneName; private String evacuationZoneName;
@ExcelColumn(title = "风险程度") @ExcelColumn(title = "风险程度", width = 10)
private String riskLevelName; private String riskLevelName;
@ExcelColumn(title = "事故信息") @ExcelColumn(title = "事故信息", width = 10)
private String accidentMsg; private String accidentMsg;
@ExcelColumn(title = "演练时间") @ExcelColumn(title = "演练时间", width = 20)
private LocalDateTime rehearsalTime; private LocalDateTime rehearsalTime;
@ExcelColumn(title = "推送信息") @ExcelColumn(title = "状态", width = 10)
private String pushMsg;
@ExcelColumn(title = "状态")
private String statusName; private String statusName;
public static RehearsalPlanExcel transform(RehearsalPlan rehearsalPlan) { public static RehearsalPlanExcel transform(RehearsalPlan rehearsalPlan) {
...@@ -66,7 +63,6 @@ public class RehearsalPlanExcel implements Serializable { ...@@ -66,7 +63,6 @@ public class RehearsalPlanExcel implements Serializable {
.riskLevelName(RiskLevelEnum.getByCode(rehearsalPlan.getRiskLevel())) .riskLevelName(RiskLevelEnum.getByCode(rehearsalPlan.getRiskLevel()))
.accidentMsg(rehearsalPlan.getAccidentMsg()) .accidentMsg(rehearsalPlan.getAccidentMsg())
.rehearsalTime(rehearsalPlan.getRehearsalTime()) .rehearsalTime(rehearsalPlan.getRehearsalTime())
.pushMsg(rehearsalPlan.getPushMsg())
.statusName(RehearsalPlanStatusEnum.getByCode(rehearsalPlan.getStatus())) .statusName(RehearsalPlanStatusEnum.getByCode(rehearsalPlan.getStatus()))
.build(); .build();
} }
......
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.param.location.fence;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author tml
* @version 1.0
* @date 2022/5/17 14:49
*/
@ApiModel("围栏报警数据管理查询")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class FenceAlarmConditionParam implements Serializable {
@Serial
private static final long serialVersionUID = -2397459299914947087L;
@ApiModelProperty(value = "地图id", example = "1")
private Long mapId;
@ApiModelProperty(value = "围栏id", example = "1")
private Long fenceId;
@ApiModelProperty(value = "报警人员真名", example = "张三")
private String realName;
@ApiModelProperty(value = "报警状态", example = "true|false")
private Boolean status;
@ApiModelProperty(value = "报警开始时间", example = "2022-05-06 14:00:00")
private LocalDateTime beginTime;
@ApiModelProperty(value = "报警结束时间", example = "2022-05-7 14:00:00")
private LocalDateTime endTime;
}
...@@ -55,10 +55,6 @@ public class RehearsalPlanAddParam implements Serializable { ...@@ -55,10 +55,6 @@ public class RehearsalPlanAddParam implements Serializable {
@NotEmpty(message = "事故信息不能为空") @NotEmpty(message = "事故信息不能为空")
private String accidentMsg; private String accidentMsg;
@ApiModelProperty(value = "推送信息", example = "气体泄露,请尽快逃离", required = true)
@NotEmpty(message = "推送信息不能为空")
private String pushMsg;
public RehearsalPlan transform() { public RehearsalPlan transform() {
AccidentSpot accidentSpot = AccidentSpot.builder().id(accidentSpotId).build(); AccidentSpot accidentSpot = AccidentSpot.builder().id(accidentSpotId).build();
EvacuationZone evacuationZone = EvacuationZone.builder().id(evacuationZoneId).build(); EvacuationZone evacuationZone = EvacuationZone.builder().id(evacuationZoneId).build();
...@@ -70,7 +66,6 @@ public class RehearsalPlanAddParam implements Serializable { ...@@ -70,7 +66,6 @@ public class RehearsalPlanAddParam implements Serializable {
.evacuationZone(evacuationZone) .evacuationZone(evacuationZone)
.riskLevel(riskLevel) .riskLevel(riskLevel)
.accidentMsg(accidentMsg) .accidentMsg(accidentMsg)
.pushMsg(pushMsg)
.status(RehearsalPlanStatusEnum.UN_START.getCode()) .status(RehearsalPlanStatusEnum.UN_START.getCode())
.deleted(false) .deleted(false)
.build(); .build();
......
...@@ -51,9 +51,6 @@ public class RehearsalPlanModifyParam implements Serializable { ...@@ -51,9 +51,6 @@ public class RehearsalPlanModifyParam implements Serializable {
@ApiModelProperty(value = "事故信息", example = "气体泄露") @ApiModelProperty(value = "事故信息", example = "气体泄露")
private String accidentMsg; private String accidentMsg;
@ApiModelProperty(value = "推送信息", example = "气体泄露,请尽快逃离")
private String pushMsg;
public RehearsalPlan transform() { public RehearsalPlan transform() {
AccidentSpot accidentSpot = AccidentSpot.builder().id(accidentSpotId).build(); AccidentSpot accidentSpot = AccidentSpot.builder().id(accidentSpotId).build();
EvacuationZone evacuationZone = EvacuationZone.builder().id(evacuationZoneId).build(); EvacuationZone evacuationZone = EvacuationZone.builder().id(evacuationZoneId).build();
...@@ -66,7 +63,6 @@ public class RehearsalPlanModifyParam implements Serializable { ...@@ -66,7 +63,6 @@ public class RehearsalPlanModifyParam implements Serializable {
.evacuationZone(evacuationZone) .evacuationZone(evacuationZone)
.riskLevel(riskLevel) .riskLevel(riskLevel)
.accidentMsg(accidentMsg) .accidentMsg(accidentMsg)
.pushMsg(pushMsg)
.build(); .build();
} }
} }
/* (C) 2022 YiRing, Inc. */ /* (C) 2022 YiRing, Inc. */
package com.yiring.app.service.analysis.history.impl; package com.yiring.app.service.analysis.history.impl;
import com.alibaba.fastjson.JSONArray;
import com.github.liaochong.myexcel.core.DefaultStreamExcelBuilder; import com.github.liaochong.myexcel.core.DefaultStreamExcelBuilder;
import com.yiring.app.constant.RedisKey;
import com.yiring.app.domain.location.LocationLog; import com.yiring.app.domain.location.LocationLog;
import com.yiring.app.domain.location.LocationLogRepository; import com.yiring.app.domain.location.LocationLogRepository;
import com.yiring.app.excel.analysis.history.HistoryRouteExcel; import com.yiring.app.excel.analysis.history.HistoryRouteExcel;
import com.yiring.app.param.analysis.history.HistoryRouteConditionParam; import com.yiring.app.param.analysis.history.HistoryRouteConditionParam;
import com.yiring.app.service.analysis.history.HistoryRouteService; import com.yiring.app.service.analysis.history.HistoryRouteService;
import com.yiring.app.util.MapUtil;
import com.yiring.app.vo.analysis.history.HistoryRouteVo; import com.yiring.app.vo.analysis.history.HistoryRouteVo;
import com.yiring.app.vo.map.MapVo; import com.yiring.app.vo.map.MapVo;
import com.yiring.common.core.Redis;
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 com.yiring.common.vo.PageVo; import com.yiring.common.vo.PageVo;
...@@ -45,26 +43,18 @@ public class HistoryRouteServiceImpl implements HistoryRouteService { ...@@ -45,26 +43,18 @@ public class HistoryRouteServiceImpl implements HistoryRouteService {
private LocationLogRepository locationLogRepository; private LocationLogRepository locationLogRepository;
@Resource @Resource
private Redis redis; private MapUtil mapUtil;
@Override @Override
public Result<PageVo<HistoryRouteVo>> findByCondition(HistoryRouteConditionParam param) { public Result<PageVo<HistoryRouteVo>> findByCondition(HistoryRouteConditionParam param) {
Specification<LocationLog> specification = getSpecification(param); Specification<LocationLog> specification = getSpecification(param);
ArrayList<MapVo.MapVoReuslt> list1 = new ArrayList<>(); ArrayList<MapVo.MapVoReuslt> list1 = new ArrayList<>();
Object map = redis.get(RedisKey.ZY_MAP_AREAS);
String mapString = JSONArray.toJSONString(map);
List<MapVo.MapVoReuslt> mapVo = JSONArray.parseArray(mapString, MapVo.MapVoReuslt.class);
List<LocationLog> list = locationLogRepository.findAll(specification); List<LocationLog> list = locationLogRepository.findAll(specification);
List<HistoryRouteVo> voList = list List<HistoryRouteVo> voList = list
.stream() .stream()
.map(e -> { .map(e -> {
HistoryRouteVo routeVo = HistoryRouteVo.transform(e); HistoryRouteVo routeVo = HistoryRouteVo.transform(e);
for (MapVo.MapVoReuslt item : mapVo) { routeVo.setMapName(mapUtil.getMapName(e.getAreaId().intValue()));
if (item.getId().equals(e.getAreaId().intValue())) {
routeVo.setMapName(item.getName());
break;
}
}
return routeVo; return routeVo;
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
......
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.service.location.fence;
import com.yiring.app.param.location.fence.FenceAlarmConditionParam;
import com.yiring.app.vo.IdNameVo;
import com.yiring.app.vo.location.fence.FenceAlarmVo;
import com.yiring.common.core.Result;
import com.yiring.common.param.PageParam;
import com.yiring.common.vo.PageVo;
import javax.servlet.http.HttpServletResponse;
/**
* @author tml
* @version 1.0
* @date 2022/5/17 16:24
*/
public interface FenceAlarmService {
/**
* 查询围栏报警数据列表
* @param param 查询条件
* @param pageParam 分页参数
* @return 报警数据
*/
Result<PageVo<FenceAlarmVo>> findList(FenceAlarmConditionParam param, PageParam pageParam);
/**
* 查询围栏下拉框
* @return 围栏id和名称
*/
Result<PageVo<IdNameVo>> findFenceList();
/**
* 导出围栏报警数据
* @param param 查询条件
*/
void export(FenceAlarmConditionParam param, HttpServletResponse response);
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.service.location.fence.impl;
import com.github.liaochong.myexcel.core.DefaultStreamExcelBuilder;
import com.yiring.app.domain.location.LocationFence;
import com.yiring.app.domain.location.LocationFenceAlarm;
import com.yiring.app.domain.location.LocationFenceAlarmRepository;
import com.yiring.app.domain.location.LocationFenceRepository;
import com.yiring.app.excel.location.fence.FenceAlarmExcel;
import com.yiring.app.param.location.fence.FenceAlarmConditionParam;
import com.yiring.app.service.location.fence.FenceAlarmService;
import com.yiring.app.util.MapUtil;
import com.yiring.app.vo.IdNameVo;
import com.yiring.app.vo.location.fence.FenceAlarmVo;
import com.yiring.auth.domain.user.User;
import com.yiring.common.core.Result;
import com.yiring.common.param.PageParam;
import com.yiring.common.vo.PageVo;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Predicate;
import javax.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @author tml
* @version 1.0
* @date 2022/5/17 16:27
*/
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class FenceAlarmServiceImpl implements FenceAlarmService {
@Resource
private LocationFenceAlarmRepository locationFenceAlarmRepository;
@Resource
private LocationFenceRepository locationFenceRepository;
@Resource
private MapUtil mapUtil;
@Override
public Result<PageVo<FenceAlarmVo>> findList(FenceAlarmConditionParam param, PageParam pageParam) {
Pageable pageable = PageParam.toPageable(pageParam);
Specification<LocationFenceAlarm> specification = getSpecification(param);
Page<LocationFenceAlarm> page = locationFenceAlarmRepository.findAll(specification, pageable);
List<FenceAlarmVo> voList = page
.get()
.map(e -> {
FenceAlarmVo vo = FenceAlarmVo.transform(e);
vo.setMapName(mapUtil.getMapName(e.getAreaId().intValue()));
return vo;
})
.collect(Collectors.toList());
PageVo<FenceAlarmVo> pageVo = PageVo.build(voList, voList.size());
return Result.ok(pageVo);
}
@Override
public Result<PageVo<IdNameVo>> findFenceList() {
List<LocationFence> list = locationFenceRepository.findAll();
List<IdNameVo> voList = list
.stream()
.map(e -> new IdNameVo(e.getId(), e.getName()))
.collect(Collectors.toList());
PageVo<IdNameVo> pageVo = PageVo.build(voList, voList.size());
return Result.ok(pageVo);
}
@Override
public void export(FenceAlarmConditionParam param, HttpServletResponse response) {
Specification<LocationFenceAlarm> specification = getSpecification(param);
List<LocationFenceAlarm> list = locationFenceAlarmRepository.findAll(specification);
List<FenceAlarmExcel> excelList = list
.stream()
.map(e -> {
FenceAlarmExcel excel = FenceAlarmExcel.transform(e);
excel.setMapName(mapUtil.getMapName(e.getAreaId().intValue()));
return excel;
})
.collect(Collectors.toList());
try (
DefaultStreamExcelBuilder<FenceAlarmExcel> streamExcelBuilder = DefaultStreamExcelBuilder
.of(FenceAlarmExcel.class)
.threadPool(Executors.newFixedThreadPool(2))
.rowHeight(14)
.titleRowHeight(14)
.style(
"cell->vertical-align:center;text-align:center",
"title->vertical-align:center;text-align:center;font-weight:bold;font-family:等线"
)
.start()
) {
streamExcelBuilder.append(excelList);
String fileName = URLEncoder.encode("围栏报警数据列表.xlsx", StandardCharsets.UTF_8);
response.setContentType("application/octet-stream");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
OutputStream out = response.getOutputStream();
Workbook workbook = streamExcelBuilder.fixedTitles().build();
workbook.write(out);
workbook.close();
out.flush();
out.close();
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RuntimeException("报警类型列表导出失败: " + e.getMessage());
}
}
private Specification<LocationFenceAlarm> getSpecification(FenceAlarmConditionParam param) {
return (root, query, criteriaBuilder) -> {
ArrayList<Predicate> list = new ArrayList<>();
if (param.getMapId() != null) {
list.add(criteriaBuilder.equal(root.get(LocationFenceAlarm.Fields.areaId), param.getMapId()));
}
if (param.getFenceId() != null) {
LocationFence fence = LocationFence.builder().id(param.getFenceId()).build();
list.add(criteriaBuilder.equal(root.get(LocationFenceAlarm.Fields.fence), fence));
}
if (param.getRealName() != null) {
Join<Object, Object> join = root.join(LocationFenceAlarm.Fields.user, JoinType.LEFT);
list.add(criteriaBuilder.equal(join.get(User.Fields.realName), param.getRealName()));
}
if (param.getStatus() != null) {
list.add(
criteriaBuilder.equal(
root.get(LocationFenceAlarm.Fields.status),
LocationFenceAlarm.Status.get(param.getStatus())
)
);
}
if (param.getBeginTime() != null) {
list.add(
criteriaBuilder.greaterThanOrEqualTo(
root.get(LocationFenceAlarm.Fields.startTime),
param.getBeginTime()
)
);
}
if (param.getEndTime() != null) {
list.add(
criteriaBuilder.lessThanOrEqualTo(root.get(LocationFenceAlarm.Fields.endTime), param.getEndTime())
);
}
Predicate[] array = list.toArray(new Predicate[0]);
return criteriaBuilder.and(array);
};
}
}
...@@ -237,6 +237,7 @@ public class RehearsalPlanServiceImpl implements RehearsalPlanService { ...@@ -237,6 +237,7 @@ public class RehearsalPlanServiceImpl implements RehearsalPlanService {
return Result.no(Status.EXPECTATION_FAILED, "演练计划已经启动过了"); return Result.no(Status.EXPECTATION_FAILED, "演练计划已经启动过了");
} }
rehearsalPlan.setStatus(RehearsalPlanStatusEnum.RUNNING.getCode()); rehearsalPlan.setStatus(RehearsalPlanStatusEnum.RUNNING.getCode());
rehearsalPlan.setRehearsalTime(LocalDateTime.now());
//事故点信息 //事故点信息
AccidentSpot accidentSpot = rehearsalPlan.getAccidentSpot(); AccidentSpot accidentSpot = rehearsalPlan.getAccidentSpot();
Integer scope = rehearsalPlan.getScope(); Integer scope = rehearsalPlan.getScope();
......
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.util;
import com.alibaba.fastjson.JSONArray;
import com.yiring.app.constant.RedisKey;
import com.yiring.app.vo.map.MapVo;
import com.yiring.common.core.Redis;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
/**
* @author tml
* @version 1.0
* @date 2022/5/17 16:58
*/
@Component
public class MapUtil {
@Resource
private Redis redis;
public String getMapName(Integer mapId) {
Object map = redis.get(RedisKey.ZY_MAP_AREAS);
String mapString = JSONArray.toJSONString(map);
List<MapVo.MapVoReuslt> mapVo = JSONArray.parseArray(mapString, MapVo.MapVoReuslt.class);
for (MapVo.MapVoReuslt item : mapVo) {
if (item.getId().equals(mapId)) {
return item.getName();
}
}
return "未知地图";
}
}
/* (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.constant.alarm.FenceTypeEnum;
import com.yiring.app.domain.location.LocationFenceAlarm;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author tml
* @version 1.0
* @date 2022/5/17 15:15
*/
@ApiModel("围栏报警数据管理")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class FenceAlarmVo implements Serializable {
@Serial
private static final long serialVersionUID = 8259241388552022873L;
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "id", example = "1")
private Long id;
@ApiModelProperty(value = "地图id", example = "1")
private Long mapId;
@ApiModelProperty(value = "地图名称", example = "总图")
private String mapName;
@ApiModelProperty(value = "围栏名称", example = "一号围栏")
private String fenceName;
@ApiModelProperty(value = "围栏类别code", example = "1")
private Integer fenceType;
@ApiModelProperty(value = "围栏类别名称", example = "普通围栏")
private String fenceTypeName;
@ApiModelProperty(value = "报警人员名称", example = "张三")
private String realName;
@ApiModelProperty(value = "标签号", example = "BTT1")
private String tagId;
@ApiModelProperty(value = "报警开始时间", example = "2022-05-04 13:00:00")
private LocalDateTime startTime;
@ApiModelProperty(value = "报警结束时间", example = "2022-05-04 13:00:00")
private LocalDateTime endTime;
@ApiModelProperty(value = "报警类型", example = "超员报警")
private String alarmTypeName;
@ApiModelProperty(value = "接收人", example = "李四")
private String recipient;
@ApiModelProperty(value = "报警状态", example = "报警中")
private String statusName;
public static FenceAlarmVo transform(LocationFenceAlarm fenceAlarm) {
return FenceAlarmVo
.builder()
.id(fenceAlarm.getId())
.mapId(fenceAlarm.getAreaId())
.fenceName(fenceAlarm.getFence().getName())
.fenceType(fenceAlarm.getFence().getFenceType())
.fenceTypeName(FenceTypeEnum.getByCode(fenceAlarm.getFence().getFenceType()))
.realName(fenceAlarm.getUser().getRealName())
.tagId(fenceAlarm.getTag().getCode())
.startTime(fenceAlarm.getStartTime())
.endTime(fenceAlarm.getEndTime())
.alarmTypeName(fenceAlarm.getType().getName())
//todo
//.recipient()
.statusName(fenceAlarm.getStatus().text())
.build();
}
}
...@@ -38,6 +38,7 @@ public class RehearsalPlanVo implements Serializable { ...@@ -38,6 +38,7 @@ public class RehearsalPlanVo implements Serializable {
@ApiModelProperty(value = "演练主题", example = "红色演练") @ApiModelProperty(value = "演练主题", example = "红色演练")
private String topical; private String topical;
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "事故点id", example = "1522844636060585984") @ApiModelProperty(value = "事故点id", example = "1522844636060585984")
private Long accidentSpotId; private Long accidentSpotId;
...@@ -47,6 +48,7 @@ public class RehearsalPlanVo implements Serializable { ...@@ -47,6 +48,7 @@ public class RehearsalPlanVo implements Serializable {
@ApiModelProperty(value = "周边范围(事故点周围多少米)", example = "50") @ApiModelProperty(value = "周边范围(事故点周围多少米)", example = "50")
private Integer scope; private Integer scope;
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "撤离区id", example = "1523562795864428544") @ApiModelProperty(value = "撤离区id", example = "1523562795864428544")
private Long evacuationZoneId; private Long evacuationZoneId;
...@@ -65,9 +67,6 @@ public class RehearsalPlanVo implements Serializable { ...@@ -65,9 +67,6 @@ public class RehearsalPlanVo implements Serializable {
@ApiModelProperty(value = "演练时间", example = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "演练时间", example = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime rehearsalTime; private LocalDateTime rehearsalTime;
@ApiModelProperty(value = "推送信息", example = "气体泄露,请尽快逃离")
private String pushMsg;
@ApiModelProperty(value = "演练计划的状态code", example = "1") @ApiModelProperty(value = "演练计划的状态code", example = "1")
private Integer status; private Integer status;
...@@ -88,7 +87,6 @@ public class RehearsalPlanVo implements Serializable { ...@@ -88,7 +87,6 @@ public class RehearsalPlanVo implements Serializable {
.riskLevelName(RiskLevelEnum.getByCode(rehearsalPlan.getRiskLevel())) .riskLevelName(RiskLevelEnum.getByCode(rehearsalPlan.getRiskLevel()))
.accidentMsg(rehearsalPlan.getAccidentMsg()) .accidentMsg(rehearsalPlan.getAccidentMsg())
.rehearsalTime(rehearsalPlan.getRehearsalTime()) .rehearsalTime(rehearsalPlan.getRehearsalTime())
.pushMsg(rehearsalPlan.getPushMsg())
.status(rehearsalPlan.getStatus()) .status(rehearsalPlan.getStatus())
.statusName(RehearsalPlanStatusEnum.getByCode(rehearsalPlan.getStatus())) .statusName(RehearsalPlanStatusEnum.getByCode(rehearsalPlan.getStatus()))
.build(); .build();
......
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.web.alarm;
/**
* @author tml
* @version 1.0
* @date 2022/5/17 14:41
*/
public class FenceAlarmController {}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.web.location.fence;
import com.yiring.app.param.location.fence.FenceAlarmConditionParam;
import com.yiring.app.service.location.fence.FenceAlarmService;
import com.yiring.app.vo.IdNameVo;
import com.yiring.app.vo.location.fence.FenceAlarmVo;
import com.yiring.common.core.Result;
import com.yiring.common.domain.BasicEntity;
import com.yiring.common.param.PageParam;
import com.yiring.common.vo.PageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Objects;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.springframework.data.domain.Sort;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author tml
* @version 1.0
* @date 2022/5/17 14:41
*/
@Api(tags = "围栏报警数据管理")
@Validated
@RestController
@RequestMapping("/fence/alarm")
public class FenceAlarmController {
@Resource
private FenceAlarmService fenceAlarmService;
@ApiOperation("查询围栏报警数据列表")
@GetMapping("/findList")
public Result<PageVo<FenceAlarmVo>> findList(@Valid FenceAlarmConditionParam param, @Valid PageParam pageParam) {
if (Objects.isNull(pageParam.getSortField())) {
pageParam.setSortField(BasicEntity.Fields.createTime);
pageParam.setSortOrder(Sort.Direction.DESC);
}
return fenceAlarmService.findList(param, pageParam);
}
@ApiOperation("查询围栏下拉框")
@GetMapping("/findFenceList")
public Result<PageVo<IdNameVo>> findFenceList() {
return fenceAlarmService.findFenceList();
}
@ApiOperation(value = "导出围栏报警数据", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@GetMapping("/export")
public void export(@Valid FenceAlarmConditionParam param, HttpServletResponse response) {
fenceAlarmService.export(param, response);
}
}
...@@ -84,7 +84,7 @@ public class AccidentSpotController { ...@@ -84,7 +84,7 @@ public class AccidentSpotController {
} }
@ApiOperation("事故点名下拉框") @ApiOperation("事故点名下拉框")
@ApiImplicitParam(value = "事故点名(全模糊)", name = "name", example = "事故", required = true) @ApiImplicitParam(value = "事故点名(全模糊)", name = "name", example = "事故")
@GetMapping("/findAccidentList") @GetMapping("/findAccidentList")
public Result<PageVo<IdNameVo>> findAccidentList(String name) { public Result<PageVo<IdNameVo>> findAccidentList(String name) {
if (name == null) { if (name == null) {
......
/* (C) 2022 YiRing, Inc. */ /* (C) 2022 YiRing, Inc. */
package com.yiring.app.web.rehearsal; package com.yiring.app.web.rehearsal;
import com.yiring.app.constant.rehearsal.RiskLevelEnum;
import com.yiring.app.domain.alarm.AlarmType; import com.yiring.app.domain.alarm.AlarmType;
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;
import com.yiring.app.param.rehearsal.RehearsalPlanPlaybackParam; import com.yiring.app.param.rehearsal.RehearsalPlanPlaybackParam;
import com.yiring.app.service.rehearsal.RehearsalPlanService; import com.yiring.app.service.rehearsal.RehearsalPlanService;
import com.yiring.app.vo.CodeNameVo;
import com.yiring.app.vo.rehearsal.RehearsalPlanRealTimeVo; import com.yiring.app.vo.rehearsal.RehearsalPlanRealTimeVo;
import com.yiring.app.vo.rehearsal.RehearsalPlanVo; import com.yiring.app.vo.rehearsal.RehearsalPlanVo;
import com.yiring.common.core.Result; import com.yiring.common.core.Result;
...@@ -15,6 +17,7 @@ import com.yiring.common.param.PageParam; ...@@ -15,6 +17,7 @@ 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.List;
import java.util.Objects; import java.util.Objects;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -76,6 +79,14 @@ public class RehearsalPlanController { ...@@ -76,6 +79,14 @@ public class RehearsalPlanController {
return rehearsalPlanService.findList(conditionParam, pageParam); return rehearsalPlanService.findList(conditionParam, pageParam);
} }
@ApiOperation(value = "查询风险等级")
@GetMapping("/findRiskLevel")
public Result<PageVo<CodeNameVo>> findRiskLevel() {
List<CodeNameVo> list = RiskLevelEnum.getAll();
PageVo<CodeNameVo> pageVo = PageVo.build(list, list.size());
return Result.ok(pageVo);
}
@ApiOperation(value = "导出演练计划", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) @ApiOperation(value = "导出演练计划", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@GetMapping("/export") @GetMapping("/export")
public void export(@Valid RehearsalPlanConditionParam conditionParam, HttpServletResponse response) { public void export(@Valid RehearsalPlanConditionParam conditionParam, HttpServletResponse response) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论