Commit 8d4ec981 by YANGYANG

历史预警信息

parent d65cc84b
package com.founder.commonutils.ZdryApiEntity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author yangyang
* @since 2021-07-29
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="warn对象", description="warn对象")
@TableName("gk_warn")
public class Warn implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = " 信息主键编号")
@TableId(type = IdType.AUTO)
private String id ;
@ApiModelProperty(value = "设备imei")
private String imei;
@ApiModelProperty(value = "发生时间")
private String timeBegin;
@ApiModelProperty(value = "时间段")
private String time;
@ApiModelProperty(value = "任务类型")
private String rwlx;
@ApiModelProperty(value = "最新位置")
private String location;
@ApiModelProperty(value = "任务名称")
private String rwmc;
@ApiModelProperty(value = "经度")
private String x;
@ApiModelProperty(value = "纬度")
private String y;
@ApiModelProperty(value = "登记时间")
@TableField(fill = FieldFill.INSERT)
private Date djsj;
@ApiModelProperty(value = "改写时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date gxsj;
}
...@@ -131,5 +131,17 @@ public class ZdryApiController { ...@@ -131,5 +131,17 @@ public class ZdryApiController {
public MapRestResult newLocationdataList(@RequestBody String[] imeis) { public MapRestResult newLocationdataList(@RequestBody String[] imeis) {
return zdryApiService.newLocationdataList(imeis); return zdryApiService.newLocationdataList(imeis);
} }
@ApiOperation(value = "根据imei获取预警历史消息")
@PostMapping("/getWarnByImei/{page}/{limit}")
public MapRestResult getWarnByImei( @ApiParam(name = "page", value = "当前页码", required = true)
@PathVariable Long page,
@ApiParam(name = "limit", value = "每页记录数", required = true)
@PathVariable Long limit,
@RequestParam String imei) {
return zdryApiService.getWarnByImei(imei,page,limit);
}
} }
package com.founder.zdryapi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.founder.commonutils.ZdryApiEntity.Warn;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author yangyang
* @since 2021-07-29
*/
@Mapper
@Component
public interface WarnMapper extends BaseMapper<Warn> {
}
<?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.founder.zdryapi.mapper.WarnMapper">
</mapper>
...@@ -32,4 +32,6 @@ public interface ZdryApiService { ...@@ -32,4 +32,6 @@ public interface ZdryApiService {
MapRestResult wearFlag(); MapRestResult wearFlag();
MapRestResult newLocationdataList(String[] imeis); MapRestResult newLocationdataList(String[] imeis);
MapRestResult getWarnByImei(String imei,Long page,Long limit);
} }
...@@ -3,6 +3,7 @@ package com.founder.zdryapi.service.impl; ...@@ -3,6 +3,7 @@ package com.founder.zdryapi.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.founder.commonutils.ZdryApiEntity.*; import com.founder.commonutils.ZdryApiEntity.*;
import com.founder.commonutils.constant.CommonCodeConstant; import com.founder.commonutils.constant.CommonCodeConstant;
...@@ -85,6 +86,9 @@ public class ZdryApiServiceImpl implements ZdryApiService { ...@@ -85,6 +86,9 @@ public class ZdryApiServiceImpl implements ZdryApiService {
@Autowired @Autowired
private ZdryHeartrateMessageMapper zdryHeartrateMessageMapper; private ZdryHeartrateMessageMapper zdryHeartrateMessageMapper;
@Autowired
private WarnMapper warnMapper;
public Device getDevice(String deviceId){ public Device getDevice(String deviceId){
Device device = new Device(); Device device = new Device();
try { try {
...@@ -536,6 +540,18 @@ public class ZdryApiServiceImpl implements ZdryApiService { ...@@ -536,6 +540,18 @@ public class ZdryApiServiceImpl implements ZdryApiService {
map.put("经度",locationMessage.getX()); map.put("经度",locationMessage.getX());
map.put("纬度",locationMessage.getY()); map.put("纬度",locationMessage.getY());
map.put("开始时间",locationMessage.getTimeBegin()); map.put("开始时间",locationMessage.getTimeBegin());
// 将预警的imei信息插入到gk_warn
Warn warn = new Warn();
warn.setImei(data.getSbImei());
warn.setRwmc(fenceTask.getName());
warn.setRwlx(fenceTask.getTaskType());
warn.setTime(fenceTask.getTimeBegin()+"-"+fenceTask.getTimeEnd());
warn.setTimeBegin(locationMessage.getTimeBegin());
warn.setLocation(locationMessage.getAddress());
warn.setX(locationMessage.getX());
warn.setY(locationMessage.getY());
warnMapper.insert(warn);
listResult.add(map); listResult.add(map);
}else{ }else{
// 查询对应任务 // 查询对应任务
...@@ -696,6 +712,20 @@ public class ZdryApiServiceImpl implements ZdryApiService { ...@@ -696,6 +712,20 @@ public class ZdryApiServiceImpl implements ZdryApiService {
return MapRestResult.build(200,"批量获取设备最新位置",resultList.size(),resultList); return MapRestResult.build(200,"批量获取设备最新位置",resultList.size(),resultList);
} }
@Override
public MapRestResult getWarnByImei(String imei,Long page,Long limit) {
Page<Warn> pageParam = new Page<Warn>(page - 1, limit);
QueryWrapper<Warn> wrapper = new QueryWrapper<>();
if(StringUtils.isNotBlank(imei)){
wrapper.eq("imei", imei);
}
wrapper.orderByAsc("djsj");
warnMapper.selectPage(pageParam, wrapper);
List<Warn> records = pageParam.getRecords();
long total = pageParam.getTotal();
return MapRestResult.build(ResultCode.SUCCESS,"成功获取任务列表信息",total,records);
}
public String getToken() { public String getToken() {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json"); MediaType type = MediaType.parseMediaType("application/json");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment