| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | |
| | | import com.moral.api.entity.HistorySecondCruiser; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.entity.SpecialDevice; |
| | | import com.moral.api.entity.SpecialDeviceHistory; |
| | | import com.moral.api.mapper.HistorySecondCruiserMapper; |
| | | import com.moral.api.mapper.HistorySecondSpecialMapper; |
| | | import com.moral.api.mapper.SpecialDeviceMapper; |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.moral.api.service.SpecialDeviceHistoryService; |
| | | import com.moral.api.service.SpecialDeviceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | 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 java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class SpecialDeviceServiceImpl extends ServiceImpl<SpecialDeviceMapper, SpecialDevice> implements SpecialDeviceService { |
| | | |
| | | @Autowired |
| | | private HistorySecondSpecialMapper historySecondSpecialMapper; |
| | | private HistorySecondCruiserMapper HistorySecondCruiserMapper; |
| | | |
| | | @Autowired |
| | | private SpecialDeviceHistoryService specialDeviceHistoryService; |
| | |
| | | private final static Double dis = 50d; |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getCarsInfo() { |
| | | public List<Map<String, Object>> selectCruisers() { |
| | | //获取当前用户信息 |
| | | 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"); |
| | | //获取所有子组织 |
| | | List<Organization> organizations = organizationService.getChildrenOrganizationsById(orgId); |
| | | List<Integer> orgIds = organizations.stream().map(Organization::getId).collect(Collectors.toList()); |
| | | orgIds.add(orgId); |
| | | QueryWrapper<SpecialDeviceHistory> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("mac", "name") |
| | | .eq("organization_id", orgId) |
| | | .eq("special_type", Constants.SPECIAL_DEVICE_CAR) |
| | | .eq("is_delete", Constants.NOT_DELETE); |
| | | .eq("special_type", Constants.SPECIAL_DEVICE_CRUISER) |
| | | .eq("is_delete", Constants.NOT_DELETE) |
| | | .in("organization_id", orgIds); |
| | | return specialDeviceHistoryService.listMaps(queryWrapper); |
| | | } |
| | | |
| | |
| | | Integer orgId = (Integer) orgInfo.get("id"); |
| | | params.put("orgId", orgId); |
| | | //从秒数据表获取走航车数据 |
| | | List<Map<String, Object>> data = historySecondSpecialMapper.getSpecialDeviceData(params); |
| | | List<Map<String, Object>> data = HistorySecondCruiserMapper.getCruiserData(params); |
| | | if (ObjectUtils.isEmpty(data)) { |
| | | return data; |
| | | } |
| | | data.removeIf(o -> { |
| | | Map<String, Object> value = JSONObject.parseObject(o.remove("value").toString(), Map.class); |
| | | Object flylon = value.get("flylon"); |
| | | Object flylat = value.get("flylat"); |
| | | Object flylon = value.get(Constants.SENSOR_CODE_LON); |
| | | Object flylat = value.get(Constants.SENSOR_CODE_LAT); |
| | | if (ObjectUtils.isEmpty(flylon) || ObjectUtils.isEmpty(flylat)) { |
| | | return true; |
| | | } |
| | |
| | | return filterData(data); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public SpecialDevice getSpecialDeviceMapByMac(String mac) { |
| | | QueryWrapper<SpecialDevice> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("mac", mac); |
| | | wrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | return specialDeviceMapper.selectOne(wrapper); |
| | | QueryWrapper<SpecialDevice> queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("mac", mac); |
| | | queryWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | SpecialDevice specialDevice = specialDeviceMapper.selectOne(queryWrapper); |
| | | return specialDevice; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<String> getDatesByMac(String mac) { |