/getGroupWarning:把预警信息存起来
parent
4146d1fc2a
commit
143b765fd3
|
|
@ -8,12 +8,10 @@ import com.whdc.model.dto.GroupWarningDto;
|
||||||
import com.whdc.model.dto.WarnDppleDto;
|
import com.whdc.model.dto.WarnDppleDto;
|
||||||
import com.whdc.model.entity.AddressBook;
|
import com.whdc.model.entity.AddressBook;
|
||||||
import com.whdc.model.entity.AddressBookOld;
|
import com.whdc.model.entity.AddressBookOld;
|
||||||
|
import com.whdc.model.entity.QXWarning;
|
||||||
import com.whdc.model.entity.WarnMsgFB;
|
import com.whdc.model.entity.WarnMsgFB;
|
||||||
import com.whdc.model.vo.*;
|
import com.whdc.model.vo.*;
|
||||||
import com.whdc.service.IAddressBookOldService;
|
import com.whdc.service.*;
|
||||||
import com.whdc.service.IAddressBookService;
|
|
||||||
import com.whdc.service.IAdinfoService;
|
|
||||||
import com.whdc.service.IWarnMsgFBService;
|
|
||||||
import com.whdc.utils.HttpUtil;
|
import com.whdc.utils.HttpUtil;
|
||||||
import com.whdc.utils.ResultJson;
|
import com.whdc.utils.ResultJson;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
|
@ -25,12 +23,15 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -49,9 +50,27 @@ public class QXWarnController {
|
||||||
private IAddressBookOldService addressBookOldService;
|
private IAddressBookOldService addressBookOldService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAdinfoService adinfoService;
|
private IAdinfoService adinfoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IWarnMsgFBService warnMsgFBService;
|
private IWarnMsgFBService warnMsgFBService;
|
||||||
|
@Autowired
|
||||||
|
private IQXWarningService service;
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public ResultJson<String> insert(@RequestBody @Validated QXWarning dto) {
|
||||||
|
|
||||||
|
//根据warnid是否重复
|
||||||
|
if (CollectionUtils.isNotEmpty(
|
||||||
|
service.lambdaQuery()
|
||||||
|
.eq(QXWarning::getWarnid,dto.getWarnid()).list()
|
||||||
|
)
|
||||||
|
){
|
||||||
|
return ResultJson.error("该名称或编码重复");
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean save = service.save(dto);
|
||||||
|
return ResultJson.ok(save);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 气象预警-正在生效的预警信息
|
* 气象预警-正在生效的预警信息
|
||||||
|
|
@ -81,7 +100,26 @@ public class QXWarnController {
|
||||||
JSONObject json = JSON.parseObject(str);
|
JSONObject json = JSON.parseObject(str);
|
||||||
if (json != null && json.getInteger("code") == HttpStatus.SC_OK) {
|
if (json != null && json.getInteger("code") == HttpStatus.SC_OK) {
|
||||||
List<WarningData> data = json.getJSONArray("data").toJavaList(WarningData.class);
|
List<WarningData> data = json.getJSONArray("data").toJavaList(WarningData.class);
|
||||||
return ResultJson.ok(getList(data, publishUnit, warnSignalLevel, warnSignalType));
|
List<QXWarningVO> warningList = getList(data, publishUnit, warnSignalLevel, warnSignalType);
|
||||||
|
//将warningList存起来
|
||||||
|
for(int i=0;i<warningList.size();i++){
|
||||||
|
DateTimeFormatter SECOND_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
QXWarningVO warningVO = warningList.get(i);
|
||||||
|
QXWarning qxwarning = new QXWarning();
|
||||||
|
qxwarning.setCreateTime(Date.from(LocalDateTime.parse(warningVO.getCreateTime(), SECOND_FORMATTER).atZone(ZoneId.systemDefault()).toInstant()));
|
||||||
|
qxwarning.setPublishTime(Date.from(LocalDateTime.parse(warningVO.getPublishTime(), SECOND_FORMATTER).atZone(ZoneId.systemDefault()).toInstant()));
|
||||||
|
qxwarning.setStartTime(Date.from(LocalDateTime.parse(warningVO.getStartTime(), SECOND_FORMATTER).atZone(ZoneId.systemDefault()).toInstant()));
|
||||||
|
qxwarning.setEndTime(Date.from(LocalDateTime.parse(warningVO.getEndTime(), SECOND_FORMATTER).atZone(ZoneId.systemDefault()).toInstant()));
|
||||||
|
qxwarning.setWarnSignalType(warningVO.getWarnSignalType());
|
||||||
|
qxwarning.setWarnSignalLevel(warningVO.getWarnSignalLevel());
|
||||||
|
qxwarning.setPublishUnit(warningVO.getPublishUnit());
|
||||||
|
qxwarning.setContent(warningVO.getContent());
|
||||||
|
qxwarning.setWarnid(warningVO.getWarnid());
|
||||||
|
qxwarning.setCtnm(warningVO.getCtnm());
|
||||||
|
qxwarning.setCnnm(warningVO.getCnnm());
|
||||||
|
insert(qxwarning);
|
||||||
|
}
|
||||||
|
return ResultJson.ok(warningList);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResultJson.ok(json);
|
return ResultJson.ok(json);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.whdc.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.whdc.model.entity.QXWarning;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface QXWarningMapper extends BaseMapper<QXWarning> {
|
||||||
|
List<QXWarning> find(@Param("dto")QXWarning dto);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.whdc.model.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true) // chain = true 实现链式调用
|
||||||
|
@ApiModel(value = "QXWARNING 对象", description = "气象预警表")
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性
|
||||||
|
@TableName("FXKH_TXL.QXWARNING")
|
||||||
|
public class QXWarning {
|
||||||
|
@TableId(value = "ID",type = IdType.AUTO)
|
||||||
|
@ApiModelProperty(value = "id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@TableField("CREATE_TIME")
|
||||||
|
@ApiModelProperty(value = "预警信息生成时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@TableField("PUBLISH_TIME")
|
||||||
|
@ApiModelProperty(value = "预警信息发布时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date publishTime;
|
||||||
|
|
||||||
|
@TableField("START_TIME")
|
||||||
|
@ApiModelProperty(value = "预警信息开始时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
@TableField("END_TIME")
|
||||||
|
@ApiModelProperty(value = "预警信息结束时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
@ApiParam(value = "预警类型")
|
||||||
|
@ApiModelProperty(value = "预警类型", dataType = "java.lang.String")
|
||||||
|
private String warnSignalType;
|
||||||
|
|
||||||
|
@ApiParam(value = "预警级别")
|
||||||
|
@ApiModelProperty(value = "预警级别", dataType = "java.lang.String")
|
||||||
|
private String warnSignalLevel;
|
||||||
|
|
||||||
|
@ApiParam(value = "发布单位")
|
||||||
|
@ApiModelProperty(value = "发布单位", dataType = "java.lang.String")
|
||||||
|
private String publishUnit;
|
||||||
|
|
||||||
|
@ApiParam(value = "预警内容")
|
||||||
|
@ApiModelProperty(value = "预警内容", dataType = "java.lang.String")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@TableField("WARNID")
|
||||||
|
@ApiModelProperty(value = "预警信息ID")
|
||||||
|
private Integer warnid;
|
||||||
|
|
||||||
|
@TableField("CTNM")
|
||||||
|
@ApiModelProperty(value = "预警市名称", dataType = "java.lang.String")
|
||||||
|
private String ctnm;
|
||||||
|
|
||||||
|
@TableField("CNNM")
|
||||||
|
@ApiModelProperty(value = "预警县名称", dataType = "java.lang.String")
|
||||||
|
private String cnnm;
|
||||||
|
}
|
||||||
|
|
@ -10,9 +10,18 @@ import lombok.NoArgsConstructor;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class QXWarningVO {
|
public class QXWarningVO {
|
||||||
|
@ApiModelProperty(value = "生成时间")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "发布时间")
|
@ApiModelProperty(value = "发布时间")
|
||||||
private String publishTime;
|
private String publishTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "起始时间")
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "终止时间")
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "发布单位")
|
@ApiModelProperty(value = "发布单位")
|
||||||
private String publishUnit;
|
private String publishUnit;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.whdc.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.whdc.model.entity.QXWarning;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IQXWarningService extends IService<QXWarning> {
|
||||||
|
List<QXWarning> find(QXWarning dto);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.whdc.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.whdc.mapper.QXWarningMapper;
|
||||||
|
import com.whdc.model.entity.QXWarning;
|
||||||
|
import com.whdc.service.IQXWarningService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class QXWarningServiceImpl extends ServiceImpl<QXWarningMapper, QXWarning> implements IQXWarningService {
|
||||||
|
@Override
|
||||||
|
public List<QXWarning> find(QXWarning dto) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.whdc.mapper.QXWarningMapper">
|
||||||
|
<select id="find" resultType="com.whdc.model.entity.QXWarning">
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue