Commit 56dd3eaa by YANGYANG

历史预警修改

parent 8d4ec981
......@@ -35,6 +35,9 @@ public class Warn implements Serializable {
@ApiModelProperty(value = "设备imei")
private String imei;
@ApiModelProperty(value = "用户姓名")
private String xm;
@ApiModelProperty(value = "发生时间")
private String timeBegin;
......@@ -56,6 +59,12 @@ public class Warn implements Serializable {
@ApiModelProperty(value = "纬度")
private String y;
@ApiModelProperty(value = "信息登记单位公安机关机构代码")
private String xxdjdwGajgjgdm;
@ApiModelProperty(value = "信息登记单位公安机关机构名称")
private String xxdjdwGajgjgmc;
@ApiModelProperty(value = "登记时间")
@TableField(fill = FieldFill.INSERT)
private Date djsj;
......
......@@ -12,6 +12,7 @@ import com.founder.commonutils.zdryEntity.Users;
import com.founder.commonutils.zdryEntity.UsersAndDevice;
import com.founder.zdry.fegin.ServerZdryApi;
import com.founder.zdry.service.UsersService;
import com.founder.zdry.service.ZdryApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -41,6 +42,8 @@ public class UsersController {
private UsersService usersService;
@Autowired
private ServerZdryApi serverZdryApi;
@Autowired
private ZdryApiService zdryApiService;
@ApiOperation(value = "分页用户列表")
@GetMapping("userPageList/{page}/{limit}")
......@@ -336,5 +339,20 @@ public class UsersController {
Integer total = usersService.userStepListCount(map);
return MapRestResult.build(ResultCode.SUCCESS,"成功获取用户步数列表信息",total,list);
}
@ApiOperation(value = "根据imei获取预警历史消息")
@PostMapping(value = {"/getWarnByImei/{page}/{limit}","/getWarnByImei"})
public MapRestResult getWarnByImei( @ApiParam(name = "page", value = "当前页码")
@PathVariable(required = false) Long page,
@ApiParam(name = "limit", value = "每页记录数")
@PathVariable(required = false) Long limit,
@RequestParam(required = false) String imei,
HttpServletRequest httpServletRequest) {
DlUsers user=(DlUsers)httpServletRequest.getSession().getAttribute(CommonCodeConstant.LOGIN_USER_KEY);
return zdryApiService.getWarnByImei(imei,page,limit,user);
}
}
package com.founder.zdry.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.founder.commonutils.ZdryApiEntity.Warn;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
/**
* <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.zdry.mapper.WarnMapper">
</mapper>
package com.founder.zdry.service;
import com.founder.commonutils.ZdryApiEntity.Device;
import com.founder.commonutils.publicEntity.MapRestResult;
import com.founder.commonutils.zdryEntity.DlUsers;
/**
* <p>
* 接口 服务类
* </p>
*
* @author yangyang
* @since 2021-05-31
*/
public interface ZdryApiService {
MapRestResult getWarnByImei(String imei, Long page, Long limit, DlUsers user);
}
package com.founder.zdry.service.impl;
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.publicEntity.MapRestResult;
import com.founder.commonutils.publicEntity.ResultCode;
import com.founder.commonutils.zdryEntity.DlUsers;
import com.founder.zdry.mapper.WarnMapper;
import com.founder.zdry.service.ZdryApiService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/*
*
* <p>
* 爱牵挂接口 服务实现类
* </p>
*
* @author yangyang
* @since 2021-05-31
*/
@Service
public class ZdryApiServiceImpl implements ZdryApiService {
@Autowired
private WarnMapper warnMapper;
@Override
public MapRestResult getWarnByImei(String imei, Long page, Long limit, DlUsers user) {
String code = "";
if(null != user){// 市局 分局 派出所
if(user.getUnitCode().endsWith("00000000")){
code = user.getUnitCode().substring(0,4);
}else if(user.getUnitCode().endsWith("000000")){
code = user.getUnitCode().substring(0,6);
}else if(user.getUnitCode().endsWith("0000")){
code = user.getUnitCode().substring(0,8);
}
}
// page和limit
if(null != imei){
Page<Warn> pageParam = new Page<Warn>(page - 1, limit);
QueryWrapper<Warn> wrapper = new QueryWrapper<>();
if(StringUtils.isNotBlank(imei)){
wrapper.eq("imei", imei);
}
wrapper.like("xxdjdw_gajgjgdm", code);
wrapper.orderByDesc("time_begin");
warnMapper.selectPage(pageParam, wrapper);
List<Warn> records = pageParam.getRecords();
long total = pageParam.getTotal();
return MapRestResult.build(ResultCode.SUCCESS,"成功获取历史预警列表信息",total,records);
}else{
QueryWrapper<Warn> wrapper = new QueryWrapper<>();
wrapper.orderByDesc("time_begin");
wrapper.like("xxdjdw_gajgjgdm", code);
warnMapper.selectList(wrapper);
return MapRestResult.build(ResultCode.SUCCESS,"成功获取历史预警列表信息",warnMapper.selectList(wrapper).size(),warnMapper.selectList(wrapper));
}
}
}
......@@ -131,17 +131,5 @@ public class ZdryApiController {
public MapRestResult newLocationdataList(@RequestBody String[] 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);
}
}
......@@ -32,6 +32,4 @@ public interface ZdryApiService {
MapRestResult wearFlag();
MapRestResult newLocationdataList(String[] imeis);
MapRestResult getWarnByImei(String imei,Long page,Long limit);
}
......@@ -541,17 +541,40 @@ public class ZdryApiServiceImpl implements ZdryApiService {
map.put("纬度",locationMessage.getY());
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);
// 查询imei对应用户姓名
QueryWrapper<Users> wrapper3 = new QueryWrapper<>();
wrapper3.eq("sb_imei",data.getSbImei());
Users user = usersMapper.selectOne(wrapper3);
// 将预警的imei信息插入到gk_warn 先根据imei和timebegin查询预警是否存在 存在则不插入
QueryWrapper<Warn> wrapper4 = new QueryWrapper<>();
wrapper4.eq("imei",data.getSbImei());
wrapper4.eq("time_begin",locationMessage.getTimeBegin());
if(warnMapper.selectList(wrapper4).size()==0){
Warn warn = new Warn();
warn.setXm(user.getXm());
warn.setImei(data.getSbImei());
warn.setRwmc(fenceTask.getName());
String rwlx = "";
if(1==fenceTask.getGklx()){
rwlx = "进入区域";
}else if(2==fenceTask.getGklx()){
rwlx = "离开区域";
}else if(3==fenceTask.getGklx()){
rwlx = "异常预警";
}
warn.setRwlx(rwlx);
warn.setTime(fenceTask.getTimeBegin()+"-"+fenceTask.getTimeEnd());
warn.setTimeBegin(locationMessage.getTimeBegin());
warn.setLocation(locationMessage.getAddress());
warn.setX(locationMessage.getX());
warn.setY(locationMessage.getY());
warn.setXxdjdwGajgjgdm(fenceTask.getXxdjdwGajgjgdm());
warn.setXxdjdwGajgjgmc(fenceTask.getXxdjdwGajgjgmc());
warnMapper.insert(warn);
}
listResult.add(map);
}else{
// 查询对应任务
......@@ -712,20 +735,6 @@ public class ZdryApiServiceImpl implements ZdryApiService {
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() {
HttpHeaders headers = new HttpHeaders();
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