OpenApiICEServiceImpl.java 8.71 KB
package com.glsx.service.impl;

import com.glsx.base.aop.SysLog;
import com.glsx.base.controller.BaseService;
import com.glsx.base.enums.MapTypeEnum;
import com.glsx.ice.iceClient.*;
import com.glsx.model.BO.*;
import com.glsx.model.BaseMapModel;
import com.glsx.model.DTO.*;
import com.glsx.service.IOpenApiICEService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author fengzhi
 * @version V1.0
 * @Description: 开放平台接口实现类
 */
@Service
public class OpenApiICEServiceImpl extends BaseService implements IOpenApiICEService {
    //todo  接口还没给
    @SysLog
    @Override
    public void postCommands(CommandsBo commandsBo) {

    }

    //todo  接口还没给
    @SysLog
    @Override
    public Map<String, Integer> getDeviceStatus(DeviceStatusBo deviceStatusBo) {
        Map<String, Integer> map = new HashMap<>();
        map.put("status", 1);
        return map;
    }

    @SysLog
    @Override
    public LatestGpsRecordDto getLatestGPSRecord(DeviceStatusBo deviceStatusBo) {
        long sn = getSn(deviceStatusBo);
        Integer dType = getDeviceType(deviceStatusBo);
        LatestGpsRecordDto gpsRecord = IceHDaoGpsClient.getLatestGpsRecord(sn, dType, MapTypeEnum.GAODE_TYPE.getId());
        return gpsRecord;
    }

    @SysLog
    @Override
    public LatestBsRecordDto getLatestBsRecord(DeviceStatusBo deviceStatusBo) {
        long sn = getSn(deviceStatusBo);
        Integer dType = getDeviceType(deviceStatusBo);
        LatestBsRecordDto bsRecord = IceHDaoGpsClient.getLatestBsRecord(sn, dType);
        return bsRecord;
    }

    @SysLog
    @Override
    public LatestGpsBsRecordDto getLatestGpsBsRecord(DeviceStatusBo deviceStatusBo) {
        //todo ice接口有问题,暂用组合代替
        long sn = getSn(deviceStatusBo);
        Integer dType = getDeviceType(deviceStatusBo);
        LatestGpsRecordDto gpsRecord = IceHDaoGpsClient.getLatestGpsRecord(sn, dType, MapTypeEnum.DOUBLE_TYPE.getId());
        LatestBsRecordDto bsRecord = IceHDaoGpsClient.getLatestBsRecord(sn, dType);
        LatestGpsBsRecordDto gpsBsRecordDto = new LatestGpsBsRecordDto();
        BeanUtils.copyProperties(gpsRecord, gpsBsRecordDto);
        BeanUtils.copyProperties(bsRecord, gpsBsRecordDto);
        //LatestGpsBsRecordDto latestGpsBsRecordDto = IceHDaoGpsClient.getDevicesGpsInfo(dId, 0, 0);
        return gpsBsRecordDto;
    }

    @SysLog
    @Override
    public GpsRecordsDto getGpsRecords(GpsBsRecordsBo gpsRecordsBo) {
        long sn = getSn(gpsRecordsBo);
        Integer dType = getDeviceType(gpsRecordsBo);
        GpsRecordsDto gpsRecordsDto = IceHDaoGpsClient.getGpsRecords(dType, gpsRecordsBo.getStartTime(), gpsRecordsBo.getEndTime(), sn, MapTypeEnum.DOUBLE_TYPE.getId());
        return gpsRecordsDto;
    }

    @SysLog
    @Override
    public BsRecordsDto getBsRecords(GpsBsRecordsBo bsRecordsBo) {
        long sn = getSn(bsRecordsBo);
        Integer dType = getDeviceType(bsRecordsBo);
        BsRecordsDto bsRecordsDto = IceHDaoGpsClient.getBsRecords(dType, bsRecordsBo.getStartTime(), bsRecordsBo.getEndTime(), sn);
        return bsRecordsDto;
    }

    @SysLog
    @Override
    public FirstGpsRecordDto getFirstGpsRecord(DeviceStatusBo deviceStatusBo) {
        long sn = getSn(deviceStatusBo);
        Integer dType = getDeviceType(deviceStatusBo);
        FirstGpsRecordDto firstGpsRecordDto = IceHDaoGpsClient.getFirstGpsRecord(dType, sn, MapTypeEnum.GAODE_TYPE.getId());
        return firstGpsRecordDto;
    }

    @SysLog
    @Override
    public GpsRecordsDto getRecentGpsRecords(DeviceStatusCountBo deviceStatusCountBo) {
        long sn = getSn(deviceStatusCountBo);
        Integer dType = getDeviceType(deviceStatusCountBo);
        Integer count = deviceStatusCountBo.getCount();
        GpsRecordsDto bsRecordsDto = IceHDaoGpsClient.getRecentGpsRecords(sn, dType, count, MapTypeEnum.GAODE_TYPE.getId());
        return bsRecordsDto;
    }

    @SysLog
    @Override
    public BsRecordsDto getRecentBsRecords(DeviceStatusCountBo deviceStatusCountBo) {
        long sn = getSn(deviceStatusCountBo);
        Integer dType = getDeviceType(deviceStatusCountBo);
        Integer count = deviceStatusCountBo.getCount();
        BsRecordsDto bsRecordsDto = IceHDaoGpsClient.getRecentBsRecords(sn, dType, count);
        return bsRecordsDto;
    }

    @SysLog
    @Override
    public Map<String, Object> getDistInfoByPos(BaseMapModel mapModel) {
        float lat = getLat(mapModel);
        float lng = getLat(mapModel);
        Map<String, Object> res  = IceDistrictClient.getDistInfoByPos(lng, lat);
        return res;
    }

    @SysLog
    @Override
    public Map<String, Object> getDistDetailByPos(BaseMapModel mapModel) {
        float lat = getLat(mapModel);
        float lng = getLat(mapModel);
        Map<String, Object> res  = IceDistrictClient.getDistDetailByPos(lng, lat);
        return res;
    }

    @SysLog
    @Override
    public Map<String, Object> getGeocoding(GeocodeBO geocodeBO) {
        String address = geocodeBO.getAddress();
        Map<String, Object> res = IcePoiSearchFTRClient.Geocoding(address);
        return res;
    }

    @SysLog
    @Override
    public Map<String, Object> getReverseGeocoding(BaseMapModel mapModel) {
        float lat = getLat(mapModel);
        float lng = getLat(mapModel);
        String address = IcePoiSearchNearClient.getReverseGeocoding(lng, lat);
        Map<String, Object> map = new HashMap<>();
        map.put("address", address);
        return map;
    }

    @SysLog
    @Override
    public Map<String, Object> getCoordTransForMap(CoordTransForMapBo coordTransForMapBo) {
        int lat = getLat(coordTransForMapBo).intValue();
        int lng = getLng(coordTransForMapBo).intValue();
        int map_type = coordTransForMapBo.getMaptype();
        Map<String, Object> map = IceHDaoGpsClient.convGeoGps(lng, lat, map_type);
        return map;
    }

    @SysLog
    @Override
    public Map<String, Object> getJourneyByGpsRecords(GpsBsRecordsBo gpsBsRecordsBo) {
        long sn = getSn(gpsBsRecordsBo);
        Integer dType = getDeviceType(gpsBsRecordsBo);
        int start_time = Integer.parseInt(gpsBsRecordsBo.getStartTime().getTime() + "");
        int end_time = Integer.parseInt(gpsBsRecordsBo.getEndTime().getTime() + "");
        Map<String, Object> map = IceRtMileStatClient.getJourneyByGpsRecords(sn, dType, start_time, end_time);
        return map;
    }

    @SysLog
    @Override
    public Map<String, Object> getJourneyRecords(GpsBsRecordsBo gpsBsRecordsBo) {
        long sn = getSn(gpsBsRecordsBo);
        Integer dType = getDeviceType(gpsBsRecordsBo);
        Date start_time = gpsBsRecordsBo.getStartTime();
        Date end_time = gpsBsRecordsBo.getEndTime();
        Map<String, Object> map = IceRtMileStatClient.getJourneyRecords(sn, dType, start_time, end_time);
        return map;
    }

    @SysLog
    @Override
    public Map<String, Object> getDailyMileageRecords(GpsBsRecordsBo gpsBsRecordsBo) {
        long sn = getSn(gpsBsRecordsBo);
        Integer dType = getDeviceType(gpsBsRecordsBo);
        Date start_time = gpsBsRecordsBo.getStartTime();
        Date end_time = gpsBsRecordsBo.getEndTime();
        Map<String, Object> map = IceRtMileStatClient.getDailyMileageRecords(sn, dType, start_time, end_time);
        return map;
    }

    @SysLog
    @Override
    public Map<String, Object> getTotalMileageRecords(DeviceStatusBo deviceStatusBo) {
        Long sn = getSn(deviceStatusBo);
        Integer dType = getDeviceType(deviceStatusBo);
        Map<String, Object> map = IceRtMileStatClient.getTotalMileageRecords(sn, dType);
        return map;
    }

    @SysLog
    @Override
    public Map<String, Object> getMonthResideRecords(DeviceMonthBo deviceMonthBo) {
        long sn = getSn(deviceMonthBo);
        Integer dType = getDeviceType(deviceMonthBo);
        String bgn_month = deviceMonthBo.getBegin_month();
        String end_month = deviceMonthBo.getEnd_month();
        Map<String, Object> map = IceRtMileStatClient.getMonthResideRecords(sn, dType, bgn_month, end_month);
        return map;
    }

    @SysLog
    @Override
    public Map<String, Object> getDeviceStayRecords(DeviceStayBo deviceStayBo) {
        long sn = getSn(deviceStayBo);
        Integer dType = getDeviceType(deviceStayBo);
        String start_date = deviceStayBo.getStart_date();
        String end_date = deviceStayBo.getEnd_date();
        Integer period_type = deviceStayBo.getPeriod_type();
        Integer max_duration = deviceStayBo.getMax_duration();
        Integer min_duration = deviceStayBo.getMin_duration();
        Map<String, Object> map = IceRtMileStatClient.getDeviceStayRecords(sn, dType, start_date, end_date, period_type, max_duration, min_duration);
        return map;
    }
}