jinpengyong
2021-08-23 3bc57d8582d3d13e7e653b0f04dd09742c3b2c15
screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java
@@ -14,16 +14,21 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.service.SysDictDataService;
import com.moral.constant.Constants;
import com.moral.constant.RedisConstants;
import com.moral.util.DateUtils;
import com.moral.util.GeodesyUtils;
import com.moral.util.TokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * <p>
@@ -45,6 +50,9 @@
    @Autowired
    private SysDictDataService sysDictDataService;
    @Autowired
    private RedisTemplate redisTemplate;
    private final static Double dis = 50d;
    @Override
@@ -60,14 +68,29 @@
        String sensorUnit = sysDictDataService.getOne(sysDictDataQueryWrapper).getDataValue();
        params.put("sensorUnit", sensorUnit);*/
        Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo();
        Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization");
        Integer orgId = (Integer) orgInfo.get("id");
        params.put("orgId", orgId);
        //从秒数据表获取走航车数据
        List<Map<String, Object>> data = historySecondSpecialMapper.getSpecialDeviceData(params);
        if (ObjectUtils.isEmpty(data)) {
            return data;
        }
        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;
            Map<String, Object> value = JSONObject.parseObject(o.remove("value").toString(), Map.class);
            Object flylon = value.get("flylon");
            Object flylat = value.get("flylat");
            if (ObjectUtils.isEmpty(flylon) || ObjectUtils.isEmpty(flylat)) {
                return true;
            }
            double lon = Double.parseDouble(flylon.toString());
            double lat = Double.parseDouble(flylat.toString());
            if (lon < 70 || lon > 150 || lat < 20 || lat > 60) {
                return true;
            }
            o.putAll(value);
            return false;
        });
        return filterData(data);
    }