Commit 00db2a25 by 王欣伟

api首次提交

1 parent 7970d096
......@@ -16,6 +16,7 @@
<properties>
<rest.admin.feign.version>1.1.0-SNAPSHOT</rest.admin.feign.version>
<neshield.common.version>1.0-SNAPSHOT</neshield.common.version>
</properties>
<dependencies>
......@@ -26,6 +27,15 @@
<version>${rest.admin.feign.version}</version>
<scope>compile</scope>
</dependency>
<!-- swagger -->
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-swagger2</artifactId>
<version>${neshield.common.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package cn.com.glsx.devicemonitor.api.dto.request;
import cn.com.glsx.devicemonitor.api.enums.DeviceTypeRelationEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @author wangxw
* @version 1.0.0
* @ClassName GpsBsLastBatchRequest.java
* @description: ${description}
* @createTime 2021年05月20日 15:18:00
*/
@ApiModel(value = "批量查询设备最新位置和基站数据请求")
@Data
public class GpsBsLastBatchRequest implements Serializable {
/**
* 设备列表
*/
@NotEmpty(message = "设备信息不能为空")
@ApiModelProperty(value = "设备列表")
private List<String> snList;
/**
* 设备类型
*/
@NotNull(message = "设备类型不能为空")
@ApiModelProperty(value = "设备类型")
private DeviceTypeRelationEnum deviceTypeRelationEnum;
}
package cn.com.glsx.devicemonitor.api.dto.response;
import lombok.Data;
import java.io.Serializable;
/**
* @author wangxw
* @version 1.0.0
* @ClassName GpsBsData.java
* @description: ${description}
* @createTime 2021年05月20日 16:05:00
*/
@Data
public class GpsBsData implements Serializable {
/**
* 设备号
*/
private String sn;
/**
* gps数据
*/
private GpsLocation gpsLocation;
/**
* 基站数据
*/
private GpsLocation bsLocation;
}
package cn.com.glsx.devicemonitor.api.dto.response;
import lombok.Data;
import java.io.Serializable;
/**
* @author wangxw
* @version 1.0.0
* @ClassName GpsLocation.java
* @description: ${description}
* @createTime 2021年05月20日 16:06:00
*/
@Data
public class GpsLocation implements Serializable {
/**
* 原始 经度
*/
private String lng;
/**
* 原始 纬度
*/
private String lat;
/**
* Google 经度
*/
private String elng;
/**
* Google 纬度
*/
private String elat;
/**
* Baidu 经度
*/
private String blng;
/**
* Baidu 纬度
*/
private String blat;
/**
* 经纬度时间
*/
private String dateTime;
/**
* 地址信息
*/
private String address;
}
package cn.com.glsx.devicemonitor.api.enums;
import org.springframework.util.StringUtils;
/**
* @author wangxw
* @version 1.0.0
* @ClassName DeviceTypeRelationEnum.java
* @description: 设备类型信息(包含大叔据类型关系维护)
* @createTime 2021年05月20日 15:21:00
*/
public enum DeviceTypeRelationEnum {
OBD("obd", 1, 2, "OBD设备"),
GPS("gps", 8, 5, "GPS设备");
/**
* 设备编码:唯一值
*/
private String deviceCode;
/**
* 业务平台 设备类型
*/
private Integer bizDeviceType;
/**
* 数据部门 设备类型
*/
private Integer dataDeviceType;
/**
* 设备名称
*/
private String deviceName;
DeviceTypeRelationEnum() {
}
DeviceTypeRelationEnum(String deviceCode, Integer bizDeviceType, Integer dataDeviceType, String deviceName) {
this.deviceCode = deviceCode;
this.bizDeviceType = bizDeviceType;
this.dataDeviceType = dataDeviceType;
this.deviceName = deviceName;
}
public String getDeviceCode() {
return deviceCode;
}
public Integer getBizDeviceType() {
return bizDeviceType;
}
public Integer getDataDeviceType() {
return dataDeviceType;
}
public String getDeviceName() {
return deviceName;
}
/**
* 通过业务设备类型查询 枚举
* @param deviceCode
* @return
*/
public static DeviceTypeRelationEnum findByDeviceCode(String deviceCode) {
if (StringUtils.isEmpty(deviceCode)) {
return null;
}
DeviceTypeRelationEnum[] dataArray = DeviceTypeRelationEnum.values();
for (int i = 0; i < dataArray.length; i++) {
DeviceTypeRelationEnum deviceTypeRelationEnum = dataArray[i];
if (deviceTypeRelationEnum.deviceCode.equals(deviceCode)) {
return deviceTypeRelationEnum;
}
}
return null;
}
}
package cn.com.glsx.devicemonitor.api.enums;
/**
* @author wangxw
* @version 1.0.0
* @ClassName GeoCoordinateEnum.java
* @description: 座标系 类型
* @createTime 2021年05月20日 15:33:00
*/
public enum GeoCoordinateEnum {
// 0: none;1: google&baidu;2: google;3: baidu
NONE(0, "不指定座标系"),
GOOGLE_BAIDU(1, "谷歌和百度座标系"),
GOOGLE(2, "谷歌座标系"),
BAIDU(3, "百度座标系");
/**
* 座标系 类型
*/
private Integer coordType;
/**
* 座标系 类型描述
*/
private String coordDesc;
GeoCoordinateEnum() {
}
GeoCoordinateEnum(Integer coordType, String coordDesc) {
this.coordType = coordType;
this.coordDesc = coordDesc;
}
public Integer getCoordType() {
return coordType;
}
public String getCoordDesc() {
return coordDesc;
}
/**
* 通过类型获取 枚举
* @param coordType
* @return
*/
public static GeoCoordinateEnum findByCoordType(Integer coordType) {
if (coordType==null) {
return null;
}
GeoCoordinateEnum[] dataArray = GeoCoordinateEnum.values();
for (int i = 0; i < dataArray.length; i++) {
GeoCoordinateEnum geoCoordinateEnum = dataArray[i];
if (geoCoordinateEnum.coordType.equals(coordType)) {
return geoCoordinateEnum;
}
}
return null;
}
}
package cn.com.glsx.devicemonitor.api.enums;
/**
* @author wangxw
* @version 1.0.0
* @ClassName GeoCoordinateEnum.java
* @description: 位置信息 类型
* @createTime 2021年05月20日 15:33:00
*/
public enum GeoLocationEnum {
GPS(0, "GPS信息"),
BS(1, "基站信息");
/**
* 位置数据 类型
*/
private Integer locationType;
/**
* 位置数据 类型描述
*/
private String locationDesc;
GeoLocationEnum() {
}
GeoLocationEnum(Integer locationType, String locationDesc) {
this.locationType = locationType;
this.locationDesc = locationDesc;
}
public Integer getLocationType() {
return locationType;
}
public String getLocationDesc() {
return locationDesc;
}
/**
* 通过数据类型 获取枚举
* @param locationType
* @return
*/
public static GeoLocationEnum findByLocationType(Integer locationType) {
if (locationType==null) {
return null;
}
GeoLocationEnum[] dataArray = GeoLocationEnum.values();
for (int i = 0; i < dataArray.length; i++) {
GeoLocationEnum geoLocationEnum = dataArray[i];
if (geoLocationEnum.locationType.equals(locationType)) {
return geoLocationEnum;
}
}
return null;
}
}
package cn.com.glsx.devicemonitor.api.feign;
import cn.com.glsx.devicemonitor.api.dto.request.GpsBsLastBatchRequest;
import cn.com.glsx.devicemonitor.api.feign.factory.GpsBsServiceFallbackFactory;
import com.glsx.plat.core.web.R;
import org.springframework.cloud.openfeign.FeignClient;
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.RequestParam;
/**
* @author wangxw
* @version 1.0.0
* @ClassName GpsBsService.java
* @description: devicemonitor
* GpsBs 服务feignclient
* 服务名:ne-shield-devicemonitor
* 路径:location/lastgpsbs/batch
* eg:http://localhost:8080/ne-shield-devicemonitor/location/lastgpsbs/batch
*
* @createTime 2021年05月21日 15:19:00
*/
@FeignClient(name = "${feign.server.name}", url = "${feign.server.url}", fallbackFactory = GpsBsServiceFallbackFactory.class, decode404 = true)
public interface GpsBsService {
/**
* 通过设备号批量查询 设备位置信息
* @param gpsBsLastBatchRequest
* @return
*/
@PostMapping(value = "/lastgpsbs/batch")
public R getLastGpsBsBatch(@RequestBody GpsBsLastBatchRequest gpsBsLastBatchRequest);
/**
* 获取单个设备的最新位置和基站数据
* @param sn
* @param deviceCode
* @return
*/
@GetMapping(value = "/single")
public R getLastGpsBsBySn(@RequestParam(value = "sn") String sn, @RequestParam(value = "deviceCode") String deviceCode);
}
/*
*
* * Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com).
* * <p>
* * Licensed under the GNU Lesser General Public License 3.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* * <p>
* * https://www.gnu.org/licenses/lgpl.html
* * <p>
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package cn.com.glsx.devicemonitor.api.feign.factory;
import cn.com.glsx.devicemonitor.api.feign.GpsBsService;
import cn.com.glsx.devicemonitor.api.feign.fallback.GpsBsServiceFallbackImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* @author wangxw
* @version 1.0.0
* @ClassName GpsBsService.java
* @description: GpsBsService fallback factory
*
* @createTime 2021年05月21日 15:19:00
*/
@Component
public class GpsBsServiceFallbackFactory implements FallbackFactory<GpsBsService> {
@Override
public GpsBsService create(Throwable throwable) {
GpsBsServiceFallbackImpl gpsBsServiceFallback = new GpsBsServiceFallbackImpl();
gpsBsServiceFallback.setCause(throwable);
return gpsBsServiceFallback;
}
}
/*
*
* * Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com).
* * <p>
* * Licensed under the GNU Lesser General Public License 3.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* * <p>
* * https://www.gnu.org/licenses/lgpl.html
* * <p>
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package cn.com.glsx.devicemonitor.api.feign.fallback;
import cn.com.glsx.devicemonitor.api.dto.request.GpsBsLastBatchRequest;
import cn.com.glsx.devicemonitor.api.feign.GpsBsService;
import com.glsx.plat.core.web.R;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author wangxw
* @version 1.0.0
* @ClassName GpsBsService.java
* @description: GpsBsService fallback impl
*
* @createTime 2021年05月21日 15:19:00
*/
@Slf4j
@Component
public class GpsBsServiceFallbackImpl implements GpsBsService {
@Setter
private Throwable cause;
@Override
public R getLastGpsBsBatch(GpsBsLastBatchRequest gpsBsLastBatchRequest) {
return R.ok("无数据");
}
@Override
public R getLastGpsBsBySn(String sn, String deviceCode) {
return R.ok("无数据");
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!