修改气象预警
parent
a8685d7cb1
commit
a49185944b
|
|
@ -0,0 +1,48 @@
|
|||
package com.gunshi.project.xyt.entity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author xusan
|
||||
* @Date 2023/7/4 10:28
|
||||
* @Notes
|
||||
**/
|
||||
@Data
|
||||
public class ApiVo {
|
||||
|
||||
@Schema(description = "开始时间, 格式应为:yyyy-MM-dd HH:mm:ss", example = "2023-06-15 08:00:00")
|
||||
private String startTime;
|
||||
|
||||
@Schema(description = "结束时间, 格式应为:yyyy-MM-dd HH:mm:ss", example = "2023-06-15 08:00:00")
|
||||
private String endTime;
|
||||
|
||||
@Schema(description = "页数", example = "1")
|
||||
private Integer pageNumber = 1;
|
||||
|
||||
@Schema(description = "条数", example = "10")
|
||||
private Integer pageSize = 10;
|
||||
|
||||
@Schema(description = "过滤条件", example = "[]")
|
||||
private List<Filter> filter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class Filter {
|
||||
|
||||
@Schema(description = "查询列名 publishUnit:发布单位,warnSignalType:类型,warnSignalLevel:级别", example = "publishUnit")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "查询类型", example = "like")
|
||||
private String condition;
|
||||
|
||||
@Schema(description = "值", example = "%1%")
|
||||
private String description;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package com.gunshi.project.xyt.entity.vo;
|
||||
|
||||
import com.gunshi.project.xyt.model.StQxWarnR;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -20,7 +19,7 @@ public class HomeWarnVo {
|
|||
private String rzWarn;
|
||||
|
||||
@Schema(description="气象告警")
|
||||
private List<StQxWarnR> qxWarn;
|
||||
private List<QXWarningVo> qxWarn;
|
||||
|
||||
@Schema(description="位移告警")
|
||||
private List<OsmoticWarnVo> shiftWarn;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
package com.gunshi.project.xyt.entity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class QXWarningVo {
|
||||
|
||||
@Schema(description = "是否播放报警声音")
|
||||
private Boolean play;
|
||||
|
||||
@Schema(description = "生成时间")
|
||||
private String createTime;
|
||||
|
||||
@Schema(description = "发布时间")
|
||||
private String publishTime;
|
||||
|
||||
@Schema(description = "起始时间")
|
||||
private String startTime;
|
||||
|
||||
@Schema(description = "终止时间")
|
||||
private String endTime;
|
||||
|
||||
@Schema(description = "发布单位")
|
||||
private String publishUnit;
|
||||
|
||||
@Schema(description = "预警类型")
|
||||
private String warnSignalType;
|
||||
|
||||
@Schema(description = "预警级别")
|
||||
private String warnSignalLevel;
|
||||
|
||||
@Schema(description = "区县名称")
|
||||
private String cnnm;
|
||||
|
||||
@Schema(description = "市名称")
|
||||
private String ctnm;
|
||||
|
||||
@Schema(description = "预警内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "状态")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "预警信息id")
|
||||
private Integer warnid;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.gunshi.project.xyt.entity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author xusan
|
||||
* @Date 2023/7/4 10:28
|
||||
* @Notes
|
||||
**/
|
||||
@Data
|
||||
public class WarningData {
|
||||
|
||||
@Schema(description = "服务名")
|
||||
private String effectArea;
|
||||
|
||||
@Schema(description = "预警信息列表")
|
||||
private List<TypeList> typeList;
|
||||
|
||||
|
||||
@Data
|
||||
public static class TypeList {
|
||||
|
||||
@Schema(description = "预警信息详情")
|
||||
private List<Warning> warnList;
|
||||
|
||||
@Schema(description = "预警信号")
|
||||
private String type;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Warning {
|
||||
|
||||
@Schema(description = "ID")
|
||||
private int id;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@Schema(description = "发布时间")
|
||||
private String publishTime;
|
||||
|
||||
@Schema(description = "预警开始时间")
|
||||
private String startTime;
|
||||
|
||||
@Schema(description = "预警结束时间")
|
||||
private String endTime;
|
||||
|
||||
@Schema(description = "预警类型")
|
||||
private String warnSignalType;
|
||||
|
||||
@Schema(description = "预警级别")
|
||||
private String warnSignalLevel;
|
||||
|
||||
@Schema(description = "预警地区")
|
||||
private String effectArea;
|
||||
|
||||
@Schema(description = "发布单位")
|
||||
private String publishUnit;
|
||||
|
||||
@Schema(description = "预警内容")
|
||||
private String content;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,34 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.gunshi.db.dto.DateTimeRangeSo;
|
||||
import com.gunshi.project.xyt.entity.vo.AttResBaseVo;
|
||||
import com.gunshi.project.xyt.entity.vo.HomeWarnVo;
|
||||
import com.gunshi.project.xyt.entity.vo.OsmoticWarnVo;
|
||||
import com.gunshi.project.xyt.entity.vo.*;
|
||||
import com.gunshi.project.xyt.mapper.AttResBaseMapper;
|
||||
import com.gunshi.project.xyt.mapper.StQxWarnRMapper;
|
||||
import com.gunshi.project.xyt.model.StImgWarnR;
|
||||
import com.gunshi.project.xyt.model.StQxWarnR;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -27,8 +41,10 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class StQxWarnRService extends ServiceImpl<StQxWarnRMapper, StQxWarnR>
|
||||
{
|
||||
public class StQxWarnRService extends ServiceImpl<StQxWarnRMapper, StQxWarnR> {
|
||||
|
||||
@Value("${shqxjsWarnPath}")
|
||||
private String shqxjsWarnPath;
|
||||
|
||||
@Resource
|
||||
private StImgWarnRService imgWarnRService;
|
||||
|
|
@ -43,44 +59,102 @@ public class StQxWarnRService extends ServiceImpl<StQxWarnRMapper, StQxWarnR>
|
|||
AttResBaseVo attResBaseVo = attResBaseVos.get(0);
|
||||
Date tm = attResBaseVo.getTm();
|
||||
//水位的最新采集时间不在24小时内
|
||||
if(tm.before(dateTimeRangeSo.getStart())){
|
||||
if (tm.before(dateTimeRangeSo.getStart())) {
|
||||
vo.setRzWarn("-");
|
||||
}else{
|
||||
} else {
|
||||
BigDecimal rz = attResBaseVo.getRz();
|
||||
if(attResBaseVo.getCalState() == 1){
|
||||
if (attResBaseVo.getCalState() == 1) {
|
||||
BigDecimal aboveCal = rz.subtract(attResBaseVo.getCalFloodLev());
|
||||
vo.setRzWarn("超校核("+aboveCal+")");
|
||||
vo.setRzWarn("超校核(" + aboveCal + ")");
|
||||
attResBaseVo.setDesState(0);
|
||||
attResBaseVo.setFlState(0);
|
||||
}else if(attResBaseVo.getDesState() == 1){
|
||||
} else if (attResBaseVo.getDesState() == 1) {
|
||||
BigDecimal aboveDes = rz.subtract(attResBaseVo.getDesFloodLev());
|
||||
vo.setRzWarn("超设计("+aboveDes+")");
|
||||
vo.setRzWarn("超设计(" + aboveDes + ")");
|
||||
attResBaseVo.setFlState(0);
|
||||
}else if(attResBaseVo.getFlState() == 1){
|
||||
vo.setRzWarn("超汛限("+attResBaseVo.getAFsltdz()+")");
|
||||
}else if(rz.compareTo(attResBaseVo.getDeadLev()) < 0){
|
||||
} else if (attResBaseVo.getFlState() == 1) {
|
||||
vo.setRzWarn("超汛限(" + attResBaseVo.getAFsltdz() + ")");
|
||||
} else if (rz.compareTo(attResBaseVo.getDeadLev()) < 0) {
|
||||
BigDecimal aboveDead = rz.subtract(attResBaseVo.getDeadLev());
|
||||
vo.setRzWarn("低水位("+aboveDead+")");
|
||||
}else {
|
||||
vo.setRzWarn("正常("+attResBaseVo.getAFsltdz()+")");
|
||||
vo.setRzWarn("低水位(" + aboveDead + ")");
|
||||
} else {
|
||||
vo.setRzWarn("正常(" + attResBaseVo.getAFsltdz() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
List<StQxWarnR> qxWarn = this.lambdaQuery()
|
||||
.ge(StQxWarnR::getTm, dateTimeRangeSo.getStart()).lt(StQxWarnR::getTm, dateTimeRangeSo.getEnd()).list();
|
||||
vo.setQxWarn(qxWarn);
|
||||
vo.setQxWarn(queryQxWarn());
|
||||
|
||||
List<OsmoticWarnVo> warnVos = baseMapper.queryOsmoticWarn(dateTimeRangeSo);
|
||||
|
||||
vo.setPressWarn(warnVos.stream().filter(o->o.getType() == 1).collect(Collectors.toList()));
|
||||
vo.setFlowWarn(warnVos.stream().filter(o->o.getType() == 2).collect(Collectors.toList()));
|
||||
vo.setShiftWarn(warnVos.stream().filter(o->o.getType() == 3).collect(Collectors.toList()));
|
||||
vo.setPressWarn(warnVos.stream().filter(o -> o.getType() == 1).collect(Collectors.toList()));
|
||||
vo.setFlowWarn(warnVos.stream().filter(o -> o.getType() == 2).collect(Collectors.toList()));
|
||||
vo.setShiftWarn(warnVos.stream().filter(o -> o.getType() == 3).collect(Collectors.toList()));
|
||||
|
||||
Long aiWarnCount = imgWarnRService.lambdaQuery()
|
||||
.ge(StImgWarnR::getTm, dateTimeRangeSo.getStart()).lt(StImgWarnR::getTm, dateTimeRangeSo.getEnd()).count();
|
||||
vo.setAiWarnCount(aiWarnCount);
|
||||
return vo;
|
||||
}
|
||||
|
||||
private List<QXWarningVo> queryQxWarn() {
|
||||
List<QXWarningVo> list = new ArrayList<>();
|
||||
ApiVo apiVo = new ApiVo();
|
||||
apiVo.setFilter(Lists.newArrayList());
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
HttpClient httpClient = HttpClientBuilder.create().build();
|
||||
HttpPost httpPost = new HttpPost(shqxjsWarnPath);
|
||||
StringEntity stringEntity;
|
||||
try {
|
||||
stringEntity = new StringEntity(om.writeValueAsString(apiVo), ContentType.APPLICATION_JSON);
|
||||
httpPost.setEntity(stringEntity);
|
||||
HttpResponse response = httpClient.execute(httpPost);
|
||||
HttpEntity entity = response.getEntity();
|
||||
JSONObject dataObject = JSONUtil.parseObj(EntityUtils.toString(entity));
|
||||
JSONArray data = dataObject.getJSONArray("data");
|
||||
if (data == null) return list;
|
||||
List<WarningData> dataList = data.toList(WarningData.class);
|
||||
list = getList(dataList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<QXWarningVo> getList(List<WarningData> data) {
|
||||
List<QXWarningVo> respList = Lists.newArrayList();
|
||||
for (WarningData datum : data) {//最外层的列表
|
||||
String ctnm = datum.getEffectArea();//市级范围
|
||||
for (WarningData.TypeList typeList : datum.getTypeList()) {//里面的
|
||||
// 预警类型
|
||||
String type = typeList.getType();
|
||||
List<WarningData.Warning> warnList = typeList.getWarnList();
|
||||
|
||||
for (WarningData.Warning warning : warnList) {
|
||||
String cnnm = warning.getEffectArea();
|
||||
if("麻城".equals(cnnm)){
|
||||
QXWarningVo vo = new QXWarningVo();
|
||||
String publishUnit = warning.getPublishUnit();
|
||||
vo.setCtnm(ctnm);//市级名称
|
||||
vo.setCnnm(cnnm);//县级名称
|
||||
vo.setPublishUnit(publishUnit);//发布单位
|
||||
vo.setPublishTime(warning.getPublishTime());//预警发布时间
|
||||
vo.setWarnSignalType(warning.getWarnSignalType());//预警类型
|
||||
vo.setWarnSignalLevel(warning.getWarnSignalLevel());//预警级别
|
||||
vo.setContent(warning.getContent());//预警内容
|
||||
vo.setWarnid(warning.getId());
|
||||
vo.setCreateTime(warning.getCreateTime());
|
||||
vo.setStartTime(warning.getStartTime());
|
||||
vo.setEndTime(warning.getEndTime());
|
||||
respList.add(vo);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
respList = respList.stream().filter(o -> "暴雨".equals(o.getWarnSignalType()) || "雷雨大风".equals(o.getWarnSignalType())).collect(Collectors.toList());
|
||||
respList = respList.stream().filter(o -> "红色".equals(o.getWarnSignalLevel()) || "橙色".equals(o.getWarnSignalLevel())).collect(Collectors.toList());
|
||||
return respList.stream().sorted(Comparator.comparing(QXWarningVo::getPublishTime).reversed())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,3 +27,4 @@ gunshi:
|
|||
privateBucket: test.by-lyf.tmp
|
||||
|
||||
shqxjsCloudowrCnPath: http://shqxjs.cloudowr.cn/service/
|
||||
shqxjsWarnPath: http://223.75.53.141:8000/shzh/met/zyqxfw/api/warning/getGroupWarning
|
||||
|
|
|
|||
Loading…
Reference in New Issue