Commit d05e3c87 by fz

1.service添加公共获取客户信息的方法

2.添加ICE接口(dist)
1 parent b405fce7
......@@ -19,54 +19,55 @@
</properties>
<dependencies>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<!--ICE-->
<dependency>
<groupId>Ice</groupId>
<artifactId>Ice</artifactId>
<version>${Ice.version}</version>
</dependency>
<!--jwt-->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>${jwt.version}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jjwt.version}</version>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
</dependency>
<!--dubbo api 服务-->
<dependency>
<groupId>cn.com.glsx.openplatform</groupId>
<artifactId>rpc-openplatform-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!--swagger2-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.glsx.base.controller;
import com.glsx.config.SystemProperty;
import com.glsx.model.Basemodel;
import com.glsx.utils.JwtUtil;
import io.jsonwebtoken.Claims;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -15,19 +18,34 @@ public class BaseService {
@Autowired
private SystemProperty systemProperty;
public String getProperty(String propertyName){
@Autowired
private JwtUtil jwtUtil;
protected String getProperty(String propertyName){
return systemProperty.getProperty(propertyName);
}
public void logd(String message){
protected void logd(String message){
log.debug(message);
}
public void logi(String message){
protected void logi(String message){
log.info(message);
}
public void loge(String message,Throwable e){
protected void loge(String message,Throwable e){
log.error(message,e);
}
private Claims getCustomerFromToken(Basemodel basemodel){
return jwtUtil.getClaimsFromToken(basemodel.getToken());
}
public String getCustomerProperty(Basemodel basemodel,String propertyName){
return (String) getCustomerFromToken(basemodel).get(propertyName);
}
public Integer getCustomerID(Basemodel basemodel){
return Integer.parseInt(getCustomerProperty(basemodel,"appid"));
}
}
......@@ -6,9 +6,9 @@ package com.glsx.constant;
* @version V1.0
*/
public class OpenAPIConstant {
public static final String TEST_PRIVATE_KEY = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJLYAe7vz8bZX0/Ro1c7SxwoAmzbH85MfPTWIPl4QQ6QRoZTThlzsRqDggGsRXPc1PVXv02o6v+oC7xV8ewG4GKJJ6RScuVVcGPbgDMIrc6J3LLKl5ullUDA3+KiWrAOQ8mHD9KcO9tN8y8uii3aDQapKl4DtyThaKyx37oYJ1BJAgMBAAECgYBhpzLJ8kML6zzeOPzWIwFVLSpHuAVTzTwAGnJ9VMJ26+1qoPW8KVrq1e/cKvNZFM+uhPccryvwbpG3YrRqkTwgZoodnBe06WlQH2iqdXfeW5bXcVfcbFNMlztDO2JgXuhPHajvgb28+4bd2wHr0aQk6cDSxWo3jOUpY9eezGoY7QJBAOCLz7/wtVEH5CfbD7K6707l8NNgZbxGqs41WtVWCLoUAx3WOPj0GR6p8ns7Ng5zykn8nnO72qqfVP/s5Q6alGcCQQCnac1Jmbfa7P38Or7qZYfTIvVNUxPXiMpK5GieYFEF0FAnKtmVGvLUk70ghDKi4Bm+/RYTs+e7fX3qjgb7gYfPAkA1FFezw67YzMi+MyZu1YmkWO6oyOzDqODPhgVG0OOXOQvTjcRB9VHK0dmkD8cje3OiMbkzGoECPE/Xf6RV42yZAkBCl8ZuEXRd5El/jIqmyG5H4S78bCCHasU1Fzg6T4vLKTrI6bWVJxwSzRW9Gnjd6xCytQ+UFMsH/Hoa1BYY80RnAkEArY7J7I37JsL1L+tNaSsD7vdb/+9eSv81n5dzh2yhyMCKgMhvPbqFn3V5p6gaL5YnCjN4ulxqvay79cohnyn9+A==";
public static final String TEST_PRIVATE_KEY = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAr4QOskcQI5/s3fbY7tYsqoz+FQFGtGH6LIpp7QcyoZ/v/8h28nZ8Jy5xA/++TRG24aG9bOSP5/soITx+7JMTlQIDAQABAkBRubfuI1DMhccRg8N3Uprxvz0AItv9WjHXU4wHJnbY8o6x8KPOMnob7gvLjZaF+R9P4s0qhOHySJgp14DErIvxAiEA1R+qzOeoo7KDIYp5JjU1w21ahGSTAv5kchokz4FlSLsCIQDS04EcLS4VASJNjHCY74+qw1o07XTY/cSpl2ue8Ow37wIhAKhOIMk+bLwRnmLfgvr8bF/PvPrunfZwRYyiPs2sJvs/AiBvVxnheo7SsvWdxOSWMDZMdb0HJLzH+EVLV1eT6iKmawIgTGwHe+QSl0N2GHQY1bNBi4ynWWLKK6GBIwwBiv5gtEQ=";
public static final String TEST_TOKEN = "yRaUk3pOtRxYLH2nNoNBXSEC4zvPicu2d6gAOh+NLXl7TIiR8kDL/aMJQcjN4LDqLAnBosahygnRro6ZCoR7KXoE0bmJ+5Ozhv3Hz+vvzUyGEjGmorIVXIlS/KkZWAwIguFYhXXSDLHwxfZZHMQxTtARAv3hpf7nM++YeGCnNUQ=";
public static final String TEST_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCS2AHu78/G2V9P0aNXO0scKAJs2x/OTHz01iD5eEEOkEaGU04Zc7Eag4IBrEVz3NT1V79NqOr/qAu8VfHsBuBiiSekUnLlVXBj24AzCK3OidyyypebpZVAwN/iolqwDkPJhw/SnDvbTfMvLoot2g0GqSpeA7ck4Wissd+6GCdQSQIDAQAB";
public static final String TEST_PUBLIC_KEY = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAK+EDrJHECOf7N322O7WLKqM/hUBRrRh+iyKae0HMqGf7//IdvJ2fCcucQP/vk0RtuGhvWzkj+f7KCE8fuyTE5UCAwEAAQ==";
public static final String TIME_FROMAT_NORMAL = "yyyy-MM-dd HH:mm:ss";
public static final String PARAM_SIGN = "sign";
......
package com.glsx.controller;
import com.glsx.model.BO.*;
import com.glsx.model.BaseMapModel;
import com.glsx.model.DTO.*;
import com.glsx.model.Result;
import com.glsx.service.OpenApiService;
......@@ -39,8 +40,8 @@ public class OpenApiController {
*/
@PostMapping("deviceList")
public Result getDeviceList(@RequestBody DeviceListBo deviceListBo){
DeviceListDTO deviceListVo = openApiService.getDeviceList(deviceListBo);
return Result.ok().data(deviceListVo);
Map<String,Object> data = openApiService.getDeviceList(deviceListBo);
return Result.ok().data(data);
}
/*
......@@ -153,4 +154,23 @@ public class OpenApiController {
BsRecordsDto recentBsRecords = openApiService.getRecentBsRecords(deviceStatusBo);
return Result.ok().data(recentBsRecords);
}
/*
* 通过经纬度查询所属行政区域
*/
@PostMapping("distInfoByPos")
public Result getDistInfoByPos(@RequestBody DistBO mapModel){
DistInfoDto distInfo = openApiService.getDistInfoByPos(mapModel);
return Result.ok().data(distInfo);
}
/*
* 通过经纬度查询所属省份城市区域()
*/
@PostMapping("distDetailByPos")
public Result getDistDetailByPos(@RequestBody DistBO mapModel){
DistDetilDto distDetail = openApiService.getDistDetailByPos(mapModel);
return Result.ok().data(distDetail);
}
}
package com.glsx.ice.iceClient;
import Ice.StringHolder;
import com.glsx.config.SystemProperty;
import com.glsx.ice.DISTRICT.IDistrictFinderPrx;
import com.glsx.ice.DISTRICT.IDistrictFinderPrxHelper;
import com.glsx.model.BO.DistBO;
import com.glsx.model.DTO.BsRecordDto;
import com.glsx.model.DTO.DistDetilDto;
import com.glsx.model.DTO.DistInfoDto;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
@Slf4j
......@@ -16,9 +21,10 @@ public class IceDistrictClient {
/**
* 通过经纬度查询所属行政区域
*
* @return
*/
public static List<BsRecordDto> getDistInfoByPos(float lng, float lat) {
public static DistInfoDto getDistInfoByPos(float lng, float lat) {
try {
if (prx == null) {
throw new Exception("Invalid proxy");
......@@ -27,10 +33,16 @@ public class IceDistrictClient {
Ice.IntHolder distCode = new Ice.IntHolder();
Ice.StringHolder strDistName = new Ice.StringHolder();
boolean res = prx.get_distinfo_by_pos(lng,lat,distCode,strDistName);
boolean res = prx.get_distinfo_by_pos(lng, lat, distCode, strDistName);
DistInfoDto infoDto = null;
if (res) {
log.info("success===getDistInfoByPos:" + distCode+"=="+strDistName);
int dist_code = distCode.value;
String dist_name = strDistName.value;
infoDto = new DistInfoDto();
infoDto.setDist_code(dist_code);
infoDto.setDist_name(dist_name);
log.info("success===getDistInfoByPos:" + distCode + "==" + strDistName);
return infoDto;
}
} catch (Ice.LocalException e) {
log.error("===getDistInfoByPos_ICE_EXCEP:" + e.getMessage(), e);
......@@ -40,5 +52,42 @@ public class IceDistrictClient {
return null;
}
/**
* 通过经纬度查询所属省份城市区域
*
* @return
*/
public static DistDetilDto getDistDetailByPos(float lng, float lat) {
try {
if (prx == null) {
throw new Exception("Invalid proxy");
}
Ice.StringHolder strProvName = new Ice.StringHolder();
Ice.StringHolder strCityName = new Ice.StringHolder();
Ice.StringHolder strCountyName = new Ice.StringHolder();
boolean res = prx.get_distdetail_by_pos(lng, lat, strProvName, strCityName, strCountyName);
DistDetilDto detilDto = null;
if (res) {
String provName = strProvName.value;
String cityName = strCityName.value;
String countyName = strCountyName.value;
detilDto = new DistDetilDto();
detilDto.setProv_name(provName);
detilDto.setCity_name(cityName);
detilDto.setCounty_name(countyName);
log.info("success===getDistDetailByPos:" + provName + "==" + cityName + "==" + countyName);
return detilDto;
}
} catch (Ice.LocalException e) {
log.error("===getDistDetailByPos_ICE_EXCEP:" + e.getMessage(), e);
} catch (Exception e) {
log.error("===getDistDetailByPos_EXCEP:" + e.getMessage(), e);
}
return null;
}
}
......@@ -18,7 +18,7 @@ public class IceHDaoGpsClient {
static Ice.ObjectPrx base = ic.stringToProxy(url).ice_timeout(Integer.parseInt(SystemProperty.getProperty("ice.connectTimeout")));
static DaoGpsServicePrx prx = DaoGpsServicePrxHelper.checkedCast(base);
public static LatestGpsRecordDto getLatestGpsRecord(Long userId, Integer deviceType, Integer mapType) {
public static LatestGpsRecordDto getLatestGpsRecord(Long sn, Integer deviceType, Integer mapType) {
LatestGpsRecordDto gpsRecord = null;
try {
if (prx == null) {
......@@ -26,13 +26,14 @@ public class IceHDaoGpsClient {
}
// 第2个参数:2: OBD; 4: DDbox(DVD) 5: Tracker 6: rearMirror 7: car recorder
LatestRgpsGetRequest req = new LatestRgpsGetRequest(userId, deviceType, mapType);
LatestRgpsGetRequest req = new LatestRgpsGetRequest(sn, deviceType, mapType);
LatestRgpsGetResponseHolder res = new LatestRgpsGetResponseHolder();
boolean ret = false;
ret = prx.getLatestRgpsRecord(req, res);
if (ret) {
log.info("===getLatestRGPSRecord:" + res.value.record);
gpsRecord = new LatestGpsRecordDto();
gpsRecord.setSn(sn+"");
gpsRecord.setGlng(res.value.record.gLng/ 1000000D);
gpsRecord.setGlat(res.value.record.gLat/ 1000000D);
gpsRecord.setLng(res.value.record.lng/ 1000000D);
......@@ -48,7 +49,7 @@ public class IceHDaoGpsClient {
return gpsRecord;
}
public static LatestBsRecordDto getLatestBsRecord(long userId, Integer deviceType) {
public static LatestBsRecordDto getLatestBsRecord(long sn, Integer deviceType) {
LatestBsRecordDto bsRecord = null;
try {
if (prx == null) {
......@@ -58,11 +59,12 @@ public class IceHDaoGpsClient {
// 第2个参数:2: OBD; 4: DDbox(DVD) 5: Tracker 6: rearMirror 7: car recorder
LatestBsGetResponseHolder res = new LatestBsGetResponseHolder();
boolean ret = false;
LatestBsGetRequest req = new LatestBsGetRequest(userId, deviceType);
LatestBsGetRequest req = new LatestBsGetRequest(sn, deviceType);
ret = prx.getLatestBsRecord(req, res);
if (ret) {
log.info("===LatestBsRecord:" + res.value.record);
bsRecord = new LatestBsRecordDto();
bsRecord.setSn(sn+"");
bsRecord.setGpstime(res.value.record.gpsTime);
bsRecord.setMcc(res.value.record.mcc);
bsRecord.setMnc(res.value.record.mnc);
......@@ -131,7 +133,7 @@ public class IceHDaoGpsClient {
* @param endTime 结束时间
* @return
*/
public static GpsRecordsDto getGpsRecords(int apType, Date startTime, Date endTime, long userId) {
public static GpsRecordsDto getGpsRecords(int apType, Date startTime, Date endTime, long sn) {
try {
if (prx == null) {
throw new Exception("Invalid proxy");
......@@ -146,8 +148,7 @@ public class IceHDaoGpsClient {
req.startTime = new Long(startTime.getTime() / 1000).intValue();
req.endTime = new Long(endTime.getTime() / 1000).intValue();
req.extraMapReq = 1;
req.reqCount = 0;
req.userID = userId;
req.userID = sn;
prx.getGpsRecords(req, res);
if (res != null && res.value != null && res.value.oprResult == 0) {
......@@ -184,7 +185,6 @@ public class IceHDaoGpsClient {
req.apType = apType;
req.startTime = new Long(startTime.getTime() / 1000).intValue();
req.endTime = new Long(endTime.getTime() / 1000).intValue();
req.reqCount = 0;
req.userID = userId;
prx.getBsRecords(req, res);
......@@ -203,7 +203,7 @@ public class IceHDaoGpsClient {
//查询首次GPS点
public static FirstGpsRecordDto getFirstGpsRecord(int apType, long userId) {
public static FirstGpsRecordDto getFirstGpsRecord(int apType, long sn) {
try {
if (prx == null) {
throw new Exception("Invalid proxy");
......@@ -213,7 +213,7 @@ public class IceHDaoGpsClient {
GpsGetRequest req = new GpsGetRequest();
req.apType = apType;
req.reqCount = 0;
req.userID = userId;
req.userID = sn;
prx.getFirstGpsRecord(req, res);
if (res != null && res.value != null && res.value.oprResult == 0) {
......@@ -239,14 +239,17 @@ public class IceHDaoGpsClient {
return null;
}
public static GpsRecordsDto getRecentGpsRecords(long userID, int apType, int apSubType, int extraMapReq, int reqCount) {
public static GpsRecordsDto getRecentGpsRecords(long sn, int apType,int reqCount) {
try {
if (prx == null) {
throw new Exception("Invalid proxy");
}
GpsRecordsDto gpsRecordsDto = new GpsRecordsDto();
RecentGpsGetResponseHolder res = new RecentGpsGetResponseHolder(new RecentGpsGetResponse());
RecentGpsGetRequest req = new RecentGpsGetRequest(userID,apType,apSubType,extraMapReq,reqCount);
RecentGpsGetRequest req = new RecentGpsGetRequest();
req.userID = sn;
req.apType = apType;
req.reqCount = reqCount;
prx.getRecentGpsRecords(req, res);
if (res != null && res.value != null && res.value.oprResult == 0) {
......@@ -262,7 +265,7 @@ public class IceHDaoGpsClient {
return null;
}
public static BsRecordsDto getRecentBsRecords(int apType, long userId) {
public static BsRecordsDto getRecentBsRecords(long sn, int apType,int reqCount) {
try {
if (prx == null) {
throw new Exception("Invalid proxy");
......@@ -271,8 +274,8 @@ public class IceHDaoGpsClient {
RecentBsGetResponseHolder res = new RecentBsGetResponseHolder(new RecentBsGetResponse());
RecentBsGetRequest req = new RecentBsGetRequest();
req.apType = apType;
req.reqCount = 0;
req.userID = userId;
req.reqCount = reqCount;
req.userID = sn;
prx.getRecentBsRecords(req, res);
if (res != null && res.value != null && res.value.oprResult == 0) {
......
......@@ -54,7 +54,7 @@ public class AuthIntercepter implements HandlerInterceptor {
//解析验证token
tokenExpired = jwtUtil.isTokenExpired(jwtToken);
}catch (Exception e){
throw ApiErrorMessage.TOKEN_ERROR.exception();
throw ApiErrorMessage.TOKEN_ERROR.exception(jwtToken);
}
if(tokenExpired){
......
package com.glsx.model.BO;
import com.glsx.model.BaseMapModel;
import lombok.Data;
import lombok.ToString;
@Data
@ToString(callSuper = true)
public class DistBO extends BaseMapModel {
}
package com.glsx.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
@ToString(callSuper = true)
public class BaseTimeRangeModel extends Basemodel{
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
}
package com.glsx.model.DTO;
import lombok.Data;
@Data
public class DistDetilDto {
//所属省份
private String prov_name;
//所属城市
private String city_name;
//所属县城
private String county_name;
}
package com.glsx.model.DTO;
import lombok.Data;
@Data
public class DistInfoDto {
//行政编码
private Integer dist_code;
//行政区域名称
private String dist_name;
}
package com.glsx.service;
import com.glsx.model.BO.*;
import com.glsx.model.BaseMapModel;
import com.glsx.model.DTO.*;
import java.util.Map;
......@@ -9,7 +10,7 @@ import java.util.Map;
public interface OpenApiService {
String getToken(TokenBo grantType);
DeviceListDTO getDeviceList(DeviceListBo deviceListBo);
Map<String,Object> getDeviceList(DeviceListBo deviceListBo);
void postCommands(CommandsBo commandsBo);
......@@ -31,7 +32,11 @@ public interface OpenApiService {
FirstGpsRecordDto getFirstGpsRecord(DeviceStatusBo deviceStatusBo);
GpsRecordsDto getRecentGpsRecords(DeviceStatusBo deviceStatusBo);
GpsRecordsDto getRecentGpsRecords(DeviceStatusCountBo deviceStatusBo);
BsRecordsDto getRecentBsRecords(DeviceStatusBo deviceStatusBo);
BsRecordsDto getRecentBsRecords(DeviceStatusCountBo deviceStatusBo);
DistInfoDto getDistInfoByPos(DistBO distBO);
DistDetilDto getDistDetailByPos(DistBO distBO);
}
......@@ -25,7 +25,7 @@ public class RSAUtils {
//生成公钥和私钥
genKeyPair();
//加密字符串
String message = "appId123456grantType1time1427093913";
String message = "appId4grantType1time123456";
System.out.println("随机生成的公钥为:" + keyMap.get(0));
System.out.println("随机生成的私钥为:" + keyMap.get(1));
//String messageEn = encrypt(message, OpenAPIConstant.TEST_PUBLIC_KEY);
......@@ -43,7 +43,7 @@ public class RSAUtils {
// KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
// 初始化密钥对生成器,密钥大小为96-1024位
keyPairGen.initialize(1024,new SecureRandom());
keyPairGen.initialize(512,new SecureRandom());
// 生成一个密钥对,保存在keyPair中
KeyPair keyPair = keyPairGen.generateKeyPair();
RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); // 得到私钥
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!