jinpengyong
2021-08-19 c98bb582d6a313940310a5e05bc80bafe386e3a2
走航车轨迹
1 files deleted
13 files added
4 files modified
822 ■■■■ changed files
screen-api/src/main/java/com/moral/api/controller/DeviceController.java 98 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java 32 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/OrganizationController.java 52 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/SpecialDeviceController.java 55 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/WebController.java 174 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/entity/HistorySecondSpecial.java 55 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/entity/SpecialDevice.java 83 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/HistorySecondSpecialMapper.java 21 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/SpecialDeviceMapper.java 16 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/HistorySecondSpecialService.java 16 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/SpecialDeviceService.java 22 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/HistorySecondSpecialServiceImpl.java 20 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java 97 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/HistorySecondSpecialMapper.xml 24 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/SpecialDeviceMapper.xml 19 ●●●●● patch | view | raw | blame | history
screen-common/src/main/java/com/moral/constant/Constants.java 10 ●●●●● patch | view | raw | blame | history
screen-common/src/main/java/com/moral/util/GeodesyUtils.java 25 ●●●●● patch | view | raw | blame | history
screen-manage/src/main/resources/mapper/SpecialDeviceMapper.xml 3 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/DeviceController.java
@@ -2,18 +2,31 @@
import com.moral.api.entity.Sensor;
import com.moral.api.pojo.vo.alarm.AlarmLevelVO;
import com.moral.api.service.DeviceService;
import com.moral.api.service.HistoryDailyService;
import com.moral.api.service.HistoryHourlyService;
import com.moral.api.service.OrganizationUnitAlarmService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
/**
 * @ClassName AlarmController
@@ -32,6 +45,15 @@
    @Autowired
    OrganizationUnitAlarmService organizationUnitAlarmService;
    @Autowired
    private HistoryHourlyService historyHourlyService;
    @Autowired
    private HistoryDailyService historyDailyService;
    @Autowired
    private DeviceService deviceService;
    @GetMapping("queryAlarmByMac")
    public ResultMessage queryAlarmByMac(String mac){
        List<Sensor> sensors = organizationUnitAlarmService.queryAlarmLevel(mac);
@@ -39,5 +61,81 @@
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo);
    }
    /**
     * @param request 请求信息
     * @return 返回请求成功后的对象信息
     */
    @GetMapping("getHourlyAqi")
    @ApiOperation(value = "获取一小时AQI", notes = "获取一小时AQI")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String")
    })
    public ResultMessage getHourlyAqi(HttpServletRequest request) {
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("mac")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Map<String, Object> response = historyHourlyService.getHourlyAqiByMac(params.get("mac").toString());
        return ResultMessage.ok(response);
    }
    /**
     * @param request 请求信息
     * @return 返回请求成功后的对象信息
     */
    @GetMapping("getMonthAvg")
    @ApiOperation(value = "获取某设备某因子本月均值", notes = "获取某设备某因子本月均值")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "sensorCode", value = "传感器code", required = true, paramType = "query", dataType = "String")
    })
    public ResultMessage getMonthAvg(HttpServletRequest request) {
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("mac") || !params.containsKey("sensorCode")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Map<String, Object> response = historyDailyService.getMonthAvg(params);
        return ResultMessage.ok(response);
    }
    /**
     * @param params 请求信息
     * @return 返回请求成功后的对象信息
     */
    @PostMapping("getMacSensors")
    @ApiOperation(value = "获取多个mac公有传感器", notes = "获取多个mac公有传感器")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "macs", value = "设备mac,多个逗号隔开", required = true, paramType = "query", dataType = "List")
    })
    public ResultMessage getMacSensors(@RequestBody Map<String, Object> params) {
        if (!params.containsKey("macs")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Map<String, Object> response = deviceService.getSensorsByMac(params);
        return ResultMessage.ok(response);
    }
    /**
     * @param params 请求信息
     * @return 返回请求成功后的对象信息
     */
    @PostMapping("getTrendChartData")
    @ApiOperation(value = "多设备单监测因子趋势图", notes = "多设备单监测因子趋势图.")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "macs", value = "设备mac,多个逗号隔开", required = true, paramType = "body", dataType = "list"),
            @ApiImplicitParam(name = "sensorCode", value = "因子code", required = true, paramType = "body", dataType = "String"),
            @ApiImplicitParam(name = "type", value = "数据类型,日(day),月(month),年(year)", required = true, paramType = "body", dataType = "String"),
            @ApiImplicitParam(name = "times", value = "数据时间,日(2021-07-29),月(2021-07),年(2021),多个逗号隔开", required = true, paramType = "body", dataType = "List")
    })
    public ResultMessage getTrendChartData(@RequestBody Map<String, Object> params) {
        if (!params.containsKey("macs") || !params.containsKey("sensorCode") || !params.containsKey("type") || !params.containsKey("times")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        List<Map<String, Object>> response = deviceService.getTrendChartData(params);
        return ResultMessage.ok(response);
    }
}
screen-api/src/main/java/com/moral/api/controller/MonitorPointController.java
@@ -4,11 +4,17 @@
import com.moral.api.pojo.form.device.MonitorPointQueryForm;
import com.moral.api.pojo.vo.monitorPoint.MonitorPointsVO;
import com.moral.api.pojo.vo.monitorPoint.StateControllerStationVO;
import com.moral.api.service.HistoryFiveMinutelyService;
import com.moral.api.service.MonitorPointService;
import com.moral.api.service.OrganizationService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
@@ -17,6 +23,9 @@
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
/**
 * @ClassName DeviceController
@@ -34,6 +43,9 @@
    @Autowired
    MonitorPointService monitorPointService;
    @Autowired
    private HistoryFiveMinutelyService historyFiveMinutelyService;
    @GetMapping("queryMonitorPoints")
    public ResultMessage queryMonitorPointsAndDevices(MonitorPointQueryForm form){
@@ -61,5 +73,25 @@
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),vo);
    }
    /**
     * @param request 请求信息
     * @return 返回请求成功后的对象信息
     */
    @GetMapping("getWindData")
    @ApiOperation(value = "获取风场数据", notes = "获取风场数据")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "monitorPointIds", value = "站点id", required = true, paramType = "query", dataType = "String")
    })
    public ResultMessage getWindData(HttpServletRequest request) {
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("monitorPointIds")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        String[] monitorPointIds = params.remove("monitorPointIds").toString().split(",");
        params.put("monitorPointIds", monitorPointIds);
        List<Object> response = historyFiveMinutelyService.getAreaWindData(params);
        return ResultMessage.ok(response);
    }
}
screen-api/src/main/java/com/moral/api/controller/OrganizationController.java
New file
@@ -0,0 +1,52 @@
package com.moral.api.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.moral.api.service.SysAreaService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
@Slf4j
@Api(tags = {"组织"})
@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/organization")
public class OrganizationController {
    @Autowired
    private SysAreaService sysAreaService;
    /**
     * @param request 请求信息
     * @return 返回请求成功后的对象信息
     */
    @GetMapping("getMapPath")
    @ApiOperation(value = "获取当前用户地图权限", notes = "获取当前用户地图权限")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "organizationId", value = "组织id", required = true, paramType = "query", dataType = "String")
    })
    public ResultMessage getMapPath(HttpServletRequest request) {
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("organizationId")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        List<Map<String, Object>> response = sysAreaService.getMapPath(Integer.parseInt(params.get("organizationId").toString()));
        return ResultMessage.ok(response);
    }
}
screen-api/src/main/java/com/moral/api/controller/SpecialDeviceController.java
New file
@@ -0,0 +1,55 @@
package com.moral.api.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.moral.api.service.SpecialDeviceService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
@Slf4j
@Api(tags = {"特殊设备"})
@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/specialDevice")
public class SpecialDeviceController {
    @Autowired
    private SpecialDeviceService specialDeviceService;
    /**
     * @param request 请求信息
     * @return 返回请求成功后的对象信息
     */
    @GetMapping("carTrajectory")
    @ApiOperation(value = "走航车轨迹", notes = "走航车轨迹")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "sensorCode", value = "传感器code", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String")
    })
    public ResultMessage carTrajectory(HttpServletRequest request) {
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("mac") || !params.containsKey("sensorCode") || !params.containsKey("time")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        List<Map<String, Object>> response = specialDeviceService.carTrajectory(params);
        return ResultMessage.ok(response);
    }
}
screen-api/src/main/java/com/moral/api/controller/WebController.java
File was deleted
screen-api/src/main/java/com/moral/api/entity/HistorySecondSpecial.java
New file
@@ -0,0 +1,55 @@
package com.moral.api.entity;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * <p>
 * 特殊设备秒数据表
 * </p>
 *
 * @author moral
 * @since 2021-08-18
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class HistorySecondSpecial extends Model<HistorySecondSpecial> {
    private static final long serialVersionUID = 1L;
    /**
     * 设备mac
     */
    private String mac;
    /**
     * 数据时间
     */
    private Date time;
    /**
     * 数据
     */
    private String value;
    /**
     * 此数据所属组织id
     */
    private Integer organizationId;
    /**
     * 数据批次
     */
    private Date batch;
    @Override
    protected Serializable pkVal() {
        return null;
    }
}
screen-api/src/main/java/com/moral/api/entity/SpecialDevice.java
New file
@@ -0,0 +1,83 @@
package com.moral.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * <p>
 *
 * </p>
 *
 * @author moral
 * @since 2021-08-18
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class SpecialDevice extends Model<SpecialDevice> {
    private static final long serialVersionUID = 1L;
    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 设备名称
     */
    private String name;
    /**
     * mac号
     */
    private String mac;
    /**
     * 维护人id,多个逗号隔开,来源于manage_account
     */
    private String operateIds;
    /**
     * 当前所属组织id
     */
    private Integer organizationId;
    /**
     * 当前所属型号id
     */
    private Integer deviceVersionId;
    /**
     * 特殊设备类型,与字典表关联
     */
    private String specialType;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新时间
     */
    private Date updateTime;
    /**
     * 逻辑删除,0:不删除;1:删除
     */
    private String isDelete;
    @Override
    protected Serializable pkVal() {
        return this.id;
    }
}
screen-api/src/main/java/com/moral/api/mapper/HistorySecondSpecialMapper.java
New file
@@ -0,0 +1,21 @@
package com.moral.api.mapper;
import java.util.List;
import java.util.Map;
import com.moral.api.entity.HistorySecondSpecial;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
 * <p>
 * 特殊设备秒数据表 Mapper 接口
 * </p>
 *
 * @author moral
 * @since 2021-08-18
 */
public interface HistorySecondSpecialMapper extends BaseMapper<HistorySecondSpecial> {
    List<Map<String, Object>> getSpecialDeviceData(Map<String, Object> params);
}
screen-api/src/main/java/com/moral/api/mapper/SpecialDeviceMapper.java
New file
@@ -0,0 +1,16 @@
package com.moral.api.mapper;
import com.moral.api.entity.SpecialDevice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author moral
 * @since 2021-08-18
 */
public interface SpecialDeviceMapper extends BaseMapper<SpecialDevice> {
}
screen-api/src/main/java/com/moral/api/service/HistorySecondSpecialService.java
New file
@@ -0,0 +1,16 @@
package com.moral.api.service;
import com.moral.api.entity.HistorySecondSpecial;
import com.baomidou.mybatisplus.extension.service.IService;
/**
 * <p>
 * 特殊设备秒数据表 服务类
 * </p>
 *
 * @author moral
 * @since 2021-08-18
 */
public interface HistorySecondSpecialService extends IService<HistorySecondSpecial> {
}
screen-api/src/main/java/com/moral/api/service/SpecialDeviceService.java
New file
@@ -0,0 +1,22 @@
package com.moral.api.service;
import java.util.List;
import java.util.Map;
import com.moral.api.entity.SpecialDevice;
import com.baomidou.mybatisplus.extension.service.IService;
/**
 * <p>
 * 服务类
 * </p>
 *
 * @author moral
 * @since 2021-08-18
 */
public interface SpecialDeviceService extends IService<SpecialDevice> {
    //走航车轨迹
    List<Map<String, Object>> carTrajectory(Map<String, Object> params);
}
screen-api/src/main/java/com/moral/api/service/impl/HistorySecondSpecialServiceImpl.java
New file
@@ -0,0 +1,20 @@
package com.moral.api.service.impl;
import com.moral.api.entity.HistorySecondSpecial;
import com.moral.api.mapper.HistorySecondSpecialMapper;
import com.moral.api.service.HistorySecondSpecialService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
 * <p>
 * 特殊设备秒数据表 服务实现类
 * </p>
 *
 * @author moral
 * @since 2021-08-18
 */
@Service
public class HistorySecondSpecialServiceImpl extends ServiceImpl<HistorySecondSpecialMapper, HistorySecondSpecial> implements HistorySecondSpecialService {
}
screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java
New file
@@ -0,0 +1,97 @@
package com.moral.api.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.moral.api.entity.HistorySecondSpecial;
import com.moral.api.entity.Sensor;
import com.moral.api.entity.SpecialDevice;
import com.moral.api.entity.SysDictData;
import com.moral.api.mapper.HistorySecondSpecialMapper;
import com.moral.api.mapper.SpecialDeviceMapper;
import com.moral.api.service.HistorySecondSpecialService;
import com.moral.api.service.SensorService;
import com.moral.api.service.SpecialDeviceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.service.SysDictDataService;
import com.moral.constant.Constants;
import com.moral.util.DateUtils;
import com.moral.util.GeodesyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author moral
 * @since 2021-08-18
 */
@Service
public class SpecialDeviceServiceImpl extends ServiceImpl<SpecialDeviceMapper, SpecialDevice> implements SpecialDeviceService {
    @Autowired
    private HistorySecondSpecialMapper historySecondSpecialMapper;
    @Autowired
    private SensorService sensorService;
    @Autowired
    private SysDictDataService sysDictDataService;
    private final static Double dis = 50d;
    @Override
    public List<Map<String, Object>> carTrajectory(Map<String, Object> params) {
        params.put("dateFormat", "%Y-%m-%d %H:%i:%s");
        //查询传感器单位
        /*QueryWrapper<Sensor> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("default_unit_key").eq("code", sensorCode);
        String defaultUnitKey = sensorService.getOne(queryWrapper).getDefaultUnitKey();
        QueryWrapper<SysDictData> sysDictDataQueryWrapper = new QueryWrapper<>();
        sysDictDataQueryWrapper.select("dataValue").eq("dict_type_id", 14).eq("dataKey", defaultUnitKey);
        String sensorUnit = sysDictDataService.getOne(sysDictDataQueryWrapper).getDataValue();
        params.put("sensorUnit", sensorUnit);*/
        //从秒数据表获取走航车数据
        List<Map<String, Object>> data = historySecondSpecialMapper.getSpecialDeviceData(params);
        data.removeIf(o -> {
            //经度
            double lng = Double.parseDouble(o.get(Constants.SENSOR_CODE_LON).toString());
            //纬度
            double lat = Double.parseDouble(o.get(Constants.SENSOR_CODE_LAT).toString());
            return lng < 70 || lng > 150 || lat > 60 || lat < 20;
        });
        return filterData(data);
    }
    //根据距离筛选数据
    private List<Map<String, Object>> filterData(List<Map<String, Object>> data) {
        List<Map<String, Object>> result = new ArrayList<>();
        result.add(data.remove(0));
        for (Map<String, Object> map : data) {
            boolean flag = true;
            for (Map<String, Object> resultMap : result) {
                double lng1 = Double.parseDouble(map.get(Constants.SENSOR_CODE_LON).toString());
                double lat1 = Double.parseDouble(map.get(Constants.SENSOR_CODE_LAT).toString());
                double lng2 = Double.parseDouble(resultMap.get(Constants.SENSOR_CODE_LON).toString());
                double lat2 = Double.parseDouble(resultMap.get(Constants.SENSOR_CODE_LAT).toString());
                double distance = GeodesyUtils.getDistance(lat1, lng1, lat2, lng2);
                if (distance < dis) {
                    flag = false;
                }
            }
            if (flag) {
                result.add(map);
            }
        }
        return result;
    }
}
screen-api/src/main/resources/mapper/HistorySecondSpecialMapper.xml
New file
@@ -0,0 +1,24 @@
<?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.moral.api.mapper.HistorySecondSpecialMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.moral.api.entity.HistorySecondSpecial">
        <result column="mac" property="mac"/>
        <result column="time" property="time"/>
        <result column="value" property="value"/>
        <result column="organization_id" property="organizationId"/>
        <result column="batch" property="batch"/>
    </resultMap>
    <select id="getSpecialDeviceData" resultType="java.util.Map">
        SELECT JSON_UNQUOTE(`value`->'$.${sensorCode}') AS '${sensorCode}',
        JSON_UNQUOTE(`value`->'$.flylon') AS 'flylon',
        JSON_UNQUOTE(`value`->'$.flylat') AS 'flylat',
        DATE_FORMAT(`time`, #{dateFormat}) AS 'time'
        FROM `history_second_special`
        WHERE mac = #{mac}
        AND `time` LIKE #{time}"%"
    </select>
</mapper>
screen-api/src/main/resources/mapper/SpecialDeviceMapper.xml
New file
@@ -0,0 +1,19 @@
<?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.moral.api.mapper.SpecialDeviceMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.moral.api.entity.SpecialDevice">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="mac" property="mac"/>
        <result column="operate_ids" property="operateIds"/>
        <result column="organization_id" property="organizationId"/>
        <result column="device_version_id" property="deviceVersionId"/>
        <result column="special_type" property="specialType"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="is_delete" property="isDelete"/>
    </resultMap>
</mapper>
screen-common/src/main/java/com/moral/constant/Constants.java
@@ -174,6 +174,16 @@
     * */
    public static final String SENSOR_CODE_NO2 = "a21004";
    /*
     * 经度 code
     * */
    public static final String SENSOR_CODE_LON = "flylon";
    /*
     * 纬度 code
     * */
    public static final String SENSOR_CODE_LAT = "flylat";
    /**
     * The Constant NULL_VALUE.
     */
screen-common/src/main/java/com/moral/util/GeodesyUtils.java
New file
@@ -0,0 +1,25 @@
package com.moral.util;
import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GeodeticCurve;
import org.gavaghan.geodesy.GlobalCoordinates;
import org.springframework.stereotype.Component;
@Component
public class GeodesyUtils {
    /**
     * @param lat1 第一点纬度
     * @param lng1 第一点经度
     * @param lat2 第二点纬度
     * @param lng2 第二点经度
     * @return 功能:根据经纬度计算两点间距离,采用WGS84坐标系
     */
    public static double getDistance(double lat1, double lng1, double lat2, double lng2) {
        GlobalCoordinates source = new GlobalCoordinates(lat1, lng1);
        GlobalCoordinates target = new GlobalCoordinates(lat2, lng2);
        GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.WGS84, source, target);
        return geoCurve.getEllipsoidalDistance();
    }
}
screen-manage/src/main/resources/mapper/SpecialDeviceMapper.xml
@@ -67,8 +67,7 @@
    <select id="selectOrgByMac" resultType="com.moral.api.entity.Organization">
        SELECT area_code, city_code
        FROM organization
        WHERE organization_id =
              (SELECT organization_id FROM special_device WHERE mac = #{mac})
        WHERE id = (SELECT organization_id FROM special_device WHERE mac = #{mac})
    </select>
</mapper>