Commit 0adc6970 authored by hanbing's avatar hanbing

静态信息接口-路口数据,请求海康接口

parent 719f2224
...@@ -43,6 +43,12 @@ ...@@ -43,6 +43,12 @@
<druid.version>1.1.5</druid.version> <druid.version>1.1.5</druid.version>
<swagger.version>2.9.2</swagger.version> <swagger.version>2.9.2</swagger.version>
<lombok.version>1.16.18</lombok.version> <lombok.version>1.16.18</lombok.version>
<hutool.version>5.7.17</hutool.version>
<lang3.version>3.12.0</lang3.version>
<io.version>2.7</io.version>
<collections.version>3.2.2</collections.version>
<beanutils.version>1.9.4</beanutils.version>
<httpclient.version>4.5.13</httpclient.version>
</properties> </properties>
<!-- 依赖声明 --> <!-- 依赖声明 -->
...@@ -102,6 +108,39 @@ ...@@ -102,6 +108,39 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>${lombok.version}</version> <version>${lombok.version}</version>
</dependency> </dependency>
<!-- Hutool -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
<!-- apache commons-->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${io.version}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${collections.version}</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>${beanutils.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${lang3.version}</version>
</dependency>
<!-- httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
......
...@@ -29,21 +29,19 @@ ...@@ -29,21 +29,19 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId> <artifactId>spring-boot-starter</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-aop</artifactId>
<exclusions> </dependency>
<exclusion> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId> <artifactId>spring-boot-starter-cache</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -91,6 +89,11 @@ ...@@ -91,6 +89,11 @@
<version>RELEASE</version> <version>RELEASE</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- Swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>springfox-swagger2</artifactId>
...@@ -99,6 +102,33 @@ ...@@ -99,6 +102,33 @@
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</dependency> </dependency>
<!-- Hutool -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<!-- apache commons-->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -14,6 +14,6 @@ public class BaseCrossInfo { ...@@ -14,6 +14,6 @@ public class BaseCrossInfo {
@ApiModelProperty(value = "信号机ID") @ApiModelProperty(value = "信号机ID")
private String telesemeId; private String telesemeId;
@ApiModelProperty(value = "厂商ID") @ApiModelProperty(value = "厂商缩写")
private String manufacturerId; private String manufacturerAbbr;
} }
package net.wanji.utc.common.commonentity;
import lombok.Data;
import net.wanji.utc.common.constant.Constants;
import net.wanji.utc.common.exception.NoSuchApiException;
import net.wanji.utc.po.ApiInfoPO;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import java.util.HashMap;
import java.util.Map;
@Data
public class HttpRequest {
private String url;
// 请求方式
private HttpMethod httpMethod;
private Map<String, String> headers;
public HttpRequest() {
}
public HttpRequest(String manufacturerAbbr, String apiCode) {
// 获取请求地址
ApiInfoPO apiInfoPO = Constants.getManufacturerUrlMap(manufacturerAbbr +
Constants.SEPARATOR_UNDER_LINE + apiCode);
if (apiInfoPO == null) {
throw new NoSuchApiException("没有此接口信息,请在t_manufacturer_api_info表中添加");
}
url = apiInfoPO.getAddress();
httpMethod = HttpMethod.valueOf(apiInfoPO.getMethod());
headers = buildHeader();
}
/**
* Discription:[封装请求头]
* @author: hfx
* @date 2019/4/24 15:23
*/
private Map<String, String> buildHeader() {
Map<String, String> header = new HashMap<>();
header.put("Content-Type","application/json; charset=UTF-8");
header.put("Accept", MediaType.APPLICATION_JSON.toString());
return header;
}
}
\ No newline at end of file
package net.wanji.utc.common.constant; package net.wanji.utc.common.constant;
import net.wanji.utc.po.ApiInfoPO;
import java.util.concurrent.ConcurrentHashMap;
public class Constants { public class Constants {
/**
* 厂商接口地址
*/
private static ConcurrentHashMap<String, ApiInfoPO> manufacturerUrlMap = new ConcurrentHashMap<>();
/** /**
* 系统缩写 * 系统缩写
*/ */
public static final String SYSTEM_ABBR = "UTC"; public static final String SYSTEM_ABBR = "UTC";
/**
* 分隔符:下划线
**/
public static final String SEPARATOR_UNDER_LINE = "_";
/**
* 海康返回成功码
*/
public static final Integer HK_SUCCESS_CODE = 0;
/**
* 海康返回码的 key
*/
public static final String HK_CODE_KEY = "code";
public static ApiInfoPO getManufacturerUrlMap(String key) {
return manufacturerUrlMap.get(key);
}
public static void putManufacturerUrlMap(String key, ApiInfoPO value) {
manufacturerUrlMap.put(key, value);
}
} }
\ No newline at end of file
package net.wanji.utc.common.exception;
/**
* @author Kent HAN
* @date 2022/11/15 13:57
*/
public class NoSuchApiException extends RuntimeException{
public NoSuchApiException(String message) {
super(message);
}
public NoSuchApiException(String message, Exception e) {
super(message,e);
}
}
...@@ -19,9 +19,9 @@ public class OutVO<T> { ...@@ -19,9 +19,9 @@ public class OutVO<T> {
private String systemAbbr; private String systemAbbr;
/** /**
* 厂商ID * 厂商缩写
*/ */
private String manufacturerId; private String manufacturerAbbr;
/** /**
* 更新时间 * 更新时间
......
package net.wanji.utc.common.task;
import lombok.extern.slf4j.Slf4j;
import net.wanji.utc.common.constant.Constants;
import net.wanji.utc.mapper.ApiInfoMapper;
import net.wanji.utc.mapper.ManufacturerInfoMapper;
import net.wanji.utc.po.ApiInfoPO;
import net.wanji.utc.po.ManufacturerInfoPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Slf4j
@EnableAsync
public class ApiInfoTask {
@Autowired
ApiInfoMapper apiInfoMapper;
@Autowired
ManufacturerInfoMapper manufacturerInfoMapper;
@Scheduled(fixedRate = 2 * 60 * 1000)
public void apiInfoRefresh() {
try {
ApiInfoPO apiInfoPO = new ApiInfoPO();
List<ApiInfoPO> apiInfoPOList = apiInfoMapper.selectAll();
if (apiInfoPOList== null || apiInfoPOList.isEmpty()) {
return;
}
// 刷新JVM
for (ApiInfoPO infoPO : apiInfoPOList) {
Integer manufacturerId = infoPO.getManufacturerId();
ManufacturerInfoPO manufacturerInfoPO = manufacturerInfoMapper.selectById(manufacturerId);
String abbr = manufacturerInfoPO.getNickName();
String s = abbr + Constants.SEPARATOR_UNDER_LINE + infoPO.getCode();
Constants.putManufacturerUrlMap(s, infoPO);
}
log.info("刷新" + apiInfoPOList.size() + "条厂商URL至JVM");
} catch (Exception e) {
log.error("刷新厂商URL到JVM异常", e);
}
}
}
\ No newline at end of file
...@@ -7,38 +7,10 @@ public class BasicEnum { ...@@ -7,38 +7,10 @@ public class BasicEnum {
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum ManufacturerEnum { public enum ManufacturerEnum {
QS(1, "青松", "QS"), HK(1, "海康", "HK");
SCATS(2, "SCATS", "SCATS"),
HS(3, "海信", "Hisense"),
HK(4, "海康", "HK"),
JA(5, "京安", "JA"),
TA(6, "同安", "TA"),
TSC(7, "励安","TSC"),
DT(8, "东土","DT"),
LES(9, "莱斯","LES");
private Integer code; private Integer code;
private String name; private String name;
private String abbr;
private String id;
public static ManufacturerEnum getNameByCode(int code) {
for (ManufacturerEnum manufacturerEnum : ManufacturerEnum.values()) {
if (manufacturerEnum.getCode() == code) {
return manufacturerEnum;
}
}
return null;
}
public static ManufacturerEnum getNameById(String id) {
for (ManufacturerEnum manufacturerEnum : ManufacturerEnum.values()) {
if (manufacturerEnum.getId().equals(id)) {
return manufacturerEnum;
}
}
return null;
}
} }
} }
package net.wanji.utc.config;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MyArtemisConfig {
@Value("${signal.manufacturer.hk.artemisHost}")
private String artemisHost;
@Value("${signal.manufacturer.hk.artemisAppKey}")
private String artemisAppKey;
@Value("${signal.manufacturer.hk.artemisAppSecret}")
private String artemisAppSecret;
@Bean
public ArtemisConfig artemisConfig() {
ArtemisConfig artemisConfig = new ArtemisConfig();
artemisConfig.setHost(artemisHost); //平台(nginx)IP 和端口
artemisConfig.setAppKey(artemisAppKey); //合作方 key
artemisConfig.setAppSecret(artemisAppSecret);//合作方 Secret
return artemisConfig;
}
}
\ No newline at end of file
package net.wanji.utc.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class Swagger2 {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//为当前包路径
.apis(RequestHandlerSelectors.basePackage("net.wanji.utc.controller"))
.paths(PathSelectors.any())
.build();
}
//构建 api文档的详细信息函数,注意这里的注解引用的是哪个
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
//页面标题
.title("万集科技-城市交通信号OpenAPI")
//创建人
.contact(new Contact("test", "#", "test@wanji.net.cn"))
//版本号
.version("1.1.0")
//描述
.description("城市交通信号厂商调用服务API")
.build();
}
}
\ No newline at end of file
package net.wanji.utc.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfigurer implements WebMvcConfigurer {
/**
* 跨域支持
* @param registry
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("GET", "POST", "DELETE", "PUT")
.allowedHeaders("*")
.maxAge(3600 * 24);
}
}
\ No newline at end of file
...@@ -30,8 +30,8 @@ public class StaticInfoController { ...@@ -30,8 +30,8 @@ public class StaticInfoController {
@ApiOperation(value = "信号路口基础信息", notes = "信号路口基础信息") @ApiOperation(value = "信号路口基础信息", notes = "信号路口基础信息")
public ResponseEntity crossInfo(HttpServletRequest request, @RequestBody CrossInfoInVO crossInfoInVO) { public ResponseEntity crossInfo(HttpServletRequest request, @RequestBody CrossInfoInVO crossInfoInVO) {
OutVO<BaseCrossInfo> outVO = new OutVO<>(); OutVO<BaseCrossInfo> outVO = new OutVO<>();
String manufacturerId = crossInfoInVO.getManufacturerId(); String manufacturerAbbr = crossInfoInVO.getManufacturerAbbr();
outVO.setManufacturerId(manufacturerId); outVO.setManufacturerAbbr(manufacturerAbbr);
outVO.setUpdatetime(new Date()); outVO.setUpdatetime(new Date());
outVO.setSystemAbbr(Constants.SYSTEM_ABBR); outVO.setSystemAbbr(Constants.SYSTEM_ABBR);
......
package net.wanji.utc.mapper;
import net.wanji.utc.po.ApiInfoPO;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/11/15 15:31
*/
public interface ApiInfoMapper {
List<ApiInfoPO> selectAll();
}
package net.wanji.utc.mapper;
import net.wanji.utc.po.CrossInfoPO;
import org.apache.ibatis.annotations.Param;
/**
* @author Kent HAN
* @date 2022/11/15 14:57
*/
public interface CrossInfoMapper {
CrossInfoPO selectByPrimaryKey(@Param("key") String key);
}
package net.wanji.utc.mapper;
import net.wanji.utc.po.ManufacturerInfoPO;
import org.apache.ibatis.annotations.Param;
/**
* @author Kent HAN
* @date 2022/11/15 16:48
*/
public interface ManufacturerInfoMapper {
ManufacturerInfoPO selectByAbbr(@Param("abbr") String abbr);
ManufacturerInfoPO selectById(@Param("manufacturerId") Integer manufacturerId);
}
package net.wanji.utc.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/15 13:41
*/
@Data
public class ApiInfoPO {
/** 接口ID */
@ApiModelProperty(name = "接口ID",notes = "")
private Integer id ;
/** 接口代码 */
@ApiModelProperty(name = "接口代码",notes = "")
private String code ;
/** 接口名称 */
@ApiModelProperty(name = "接口名称",notes = "")
private String name ;
/** 接口类型:1、静态;2、动态;3、控制 */
@ApiModelProperty(name = "接口类型:1、静态;2、动态;3、控制",notes = "")
private Integer type ;
/** 请求方式:get、post */
@ApiModelProperty(name = "请求方式:get、post",notes = "")
private String method ;
/** 接口地址 */
@ApiModelProperty(name = "接口地址",notes = "")
private String address ;
/** 厂商ID */
@ApiModelProperty(name = "厂商ID",notes = "")
private Integer manufacturerId ;
/** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(name = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.utc.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/15 16:47
*/
@Data
public class ManufacturerInfoPO {
/** 厂商ID */
@ApiModelProperty(name = "厂商ID",notes = "")
private Integer id ;
/** 厂商代码 */
@ApiModelProperty(name = "厂商代码",notes = "")
private String code ;
/** 厂商名称 */
@ApiModelProperty(name = "厂商名称",notes = "")
private String name ;
/** 厂商简称 */
@ApiModelProperty(name = "厂商简称",notes = "")
private String nickName ;
/** 平台地址 */
@ApiModelProperty(name = "平台地址",notes = "")
private String address ;
/** 维护单位 */
@ApiModelProperty(name = "维护单位",notes = "")
private String maintenanceUnit ;
/** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(name = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.utc.service;
import net.wanji.utc.po.CrossInfoPO;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/11/15 13:18
*/
public interface HkService {
List<CrossInfoPO> crossBasicInfo();
}
package net.wanji.utc.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import lombok.extern.slf4j.Slf4j;
import net.wanji.utc.common.commonentity.HttpRequest;
import net.wanji.utc.common.constant.Constants;
import net.wanji.utc.common.typeenum.BasicEnum;
import net.wanji.utc.mapper.CrossInfoMapper;
import net.wanji.utc.mapper.ManufacturerInfoMapper;
import net.wanji.utc.po.CrossInfoPO;
import net.wanji.utc.po.ManufacturerInfoPO;
import net.wanji.utc.service.HkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @date 2022/11/15 13:18
*/
@Slf4j
@Service
public class HkServiceImpl implements HkService {
@Value("${signal.manufacturer.hk.artemisPath}")
private String artemisPath;
@Autowired
private ArtemisConfig artemisConfig;
@Autowired
private CrossInfoMapper crossInfoMapper;
@Autowired
private ManufacturerInfoMapper manufacturerInfoMapper;
@Override
public List<CrossInfoPO> crossBasicInfo() {
List<CrossInfoPO> res = new ArrayList<>();
try{
// key如"http://",value如"/artemis/api/itscms-scms/v1/crossinfo/crossBasicInfo"
Map<String, String> path = getPathMapByApiCode("crossBasicInfo");
JSONObject requestContent = new JSONObject();
// 海康固定入参字段名
requestContent.put("pageNo", 1);
requestContent.put("pageSize", 9999);
requestContent.put("searchObj", new JSONObject());
String body = requestContent.toJSONString();
// 请求参数
String responseStr = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, path, body, null,
null, "application/json", null);
JSONObject responseObj = JSON.parseObject(responseStr);
if(Constants.HK_SUCCESS_CODE.equals(responseObj.getInteger(Constants.HK_CODE_KEY))) {
JSONObject data = responseObj.getJSONObject("data");
JSONArray list = data.getJSONArray("list");
for(int i = 0; i < list.size(); i++){
JSONObject signalObj = list.getJSONObject(i);
String crossCode = signalObj.getString("crossCode");
String crossName = signalObj.getString("crossName");
String crossId = signalObj.getString("crossId");
// t_cross_info表的主键ID 例如"18c8db5a7772428eb91be749fb3004c8"
CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(crossCode);
if (null != crossInfoPO) {
continue;
}
crossInfoPO = new CrossInfoPO();
crossInfoPO.setId(crossCode);
crossInfoPO.setName(crossName);
crossInfoPO.setCode(crossId);
ManufacturerInfoPO manufacturerInfoPO = manufacturerInfoMapper.selectByAbbr(
BasicEnum.ManufacturerEnum.HK.getAbbr());
if (manufacturerInfoPO != null) {
crossInfoPO.setManufacturerId(manufacturerInfoPO.getId());
}
crossInfoPO.setIp(signalObj.getString("ip"));
crossInfoPO.setPort(signalObj.getInteger("port"));
// 经纬度
String longitude = signalObj.getString("longitude");
String latitude = signalObj.getString("latitude");
crossInfoPO.setLocation(longitude + "," + latitude);
crossInfoPO.setVersion(signalObj.getString("sigVersion"));
crossInfoPO.setInstallTime(signalObj.getDate("installTime"));
res.add(crossInfoPO);
}
}
} catch(Exception e) {
log.error("服务器端内部错误!", e);
}
return res;
}
private Map<String, String> getPathMapByApiCode(String apiCode) {
Map<String, String> res = new HashMap<>();
HttpRequest httpRequest = new HttpRequest(BasicEnum.ManufacturerEnum.HK.getAbbr(), apiCode);
res.put("http://", artemisPath + httpRequest.getUrl());
return res;
}
}
...@@ -3,14 +3,17 @@ package net.wanji.utc.service.impl; ...@@ -3,14 +3,17 @@ package net.wanji.utc.service.impl;
import net.wanji.utc.common.genericentity.ManufacturerRes; import net.wanji.utc.common.genericentity.ManufacturerRes;
import net.wanji.utc.common.typeenum.BasicEnum; import net.wanji.utc.common.typeenum.BasicEnum;
import net.wanji.utc.po.CrossInfoPO; import net.wanji.utc.po.CrossInfoPO;
import net.wanji.utc.service.HkService;
import net.wanji.utc.service.StaticInfoService; import net.wanji.utc.service.StaticInfoService;
import net.wanji.utc.common.baseentity.BaseCrossInfo; import net.wanji.utc.common.baseentity.BaseCrossInfo;
import net.wanji.utc.common.genericentity.OutVO; import net.wanji.utc.common.genericentity.OutVO;
import net.wanji.utc.vo.DetailCrossInfoVO; import net.wanji.utc.vo.DetailCrossInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author Kent HAN * @author Kent HAN
...@@ -18,13 +21,15 @@ import java.util.List; ...@@ -18,13 +21,15 @@ import java.util.List;
*/ */
@Service @Service
public class StaticInfoServiceImpl implements StaticInfoService { public class StaticInfoServiceImpl implements StaticInfoService {
@Autowired
HkService hkService;
@Override @Override
public void crossBasicInfo(OutVO<BaseCrossInfo> outVO) { public void crossBasicInfo(OutVO<BaseCrossInfo> outVO) {
List<CrossInfoPO> crossInfoPOList = new ArrayList<>(); List<CrossInfoPO> crossInfoPOList = new ArrayList<>();
ManufacturerRes<DetailCrossInfoVO> res = new ManufacturerRes<>(); ManufacturerRes<DetailCrossInfoVO> res = new ManufacturerRes<>();
if (BasicEnum.ManufacturerEnum.HK.getId().equalsIgnoreCase(outVO.getManufacturerId())) { if (Objects.equals(BasicEnum.ManufacturerEnum.HK.getAbbr(), outVO.getManufacturerAbbr())) {
// todo 海康 crossInfoPOList = hkService.crossBasicInfo();
} else { } else {
// todo 其他厂商 // todo 其他厂商
} }
......
...@@ -11,6 +11,6 @@ import lombok.Data; ...@@ -11,6 +11,6 @@ import lombok.Data;
@Data @Data
@ApiModel(value = "CrossInfoInVO", description = "查询信号路口基础信息输入参数") @ApiModel(value = "CrossInfoInVO", description = "查询信号路口基础信息输入参数")
public class CrossInfoInVO { public class CrossInfoInVO {
@ApiModelProperty(value = "厂商ID QS/SCATS/HS/HK") @ApiModelProperty(value = "厂商缩写 HK-海康")
String manufacturerId; String manufacturerAbbr;
} }
...@@ -31,3 +31,17 @@ spring: ...@@ -31,3 +31,17 @@ spring:
min-idle: 10 min-idle: 10
timeout: 5000 timeout: 5000
database: 3 database: 3
# 信号平台
signal:
# 厂商接口
manufacturer:
hk:
# 服务地址
artemisHost: 10.100.1.101
# 接口服务验证用户名
artemisAppKey: 21560443
# 接口服务验证密钥
artemisAppSecret: 5z0O0DRKALWyIxdQU4kp
# 海康能力开放平台的网站路径
artemisPath: /artemis
spring: spring:
profiles: profiles:
active: dev active: dev
mvc:
pathmatch:
matching-strategy: ant_path_matcher
server: server:
undertow: undertow:
url-charset: UTF-8 url-charset: UTF-8
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.utc.mapper.ApiInfoMapper">
<resultMap type="net.wanji.utc.po.ApiInfoPO" id="BaseResultMap">
<result property="id" column="id"/>
<result property="code" column="code"/>
<result property="name" column="name"/>
<result property="type" column="type"/>
<result property="method" column="method"/>
<result property="address" column="address"/>
<result property="manufacturerId" column="manufacturer_id"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<select id="selectAll" resultMap="BaseResultMap">
select
id,code,name,type,method,address,manufacturer_id,gmt_create,gmt_modified
from t_manufacturer_api_info
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.utc.mapper.CrossInfoMapper">
<resultMap type="net.wanji.utc.po.CrossInfoPO" id="BaseResultMap">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="code" column="code"/>
<result property="manufacturerId" column="manufacturer_id"/>
<result property="ip" column="ip"/>
<result property="port" column="port"/>
<result property="location" column="location"/>
<result property="version" column="version"/>
<result property="model" column="model"/>
<result property="installTime" column="install_time"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<select id="selectByPrimaryKey" resultMap="BaseResultMap">
select
id,name,code,manufacturer_id,ip,port,location,version,model,install_time,gmt_create,gmt_modified
from t_cross_info
where id = #{key}
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.utc.mapper.ManufacturerInfoMapper">
<resultMap type="net.wanji.utc.po.ManufacturerInfoPO" id="BaseResultMap">
<result property="id" column="id"/>
<result property="code" column="code"/>
<result property="name" column="name"/>
<result property="nickName" column="nick_name"/>
<result property="address" column="address"/>
<result property="maintenanceUnit" column="maintenance_unit"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<select id="selectByAbbr" resultMap="BaseResultMap">
select
id,code,name,nick_name,address,maintenance_unit,gmt_create,gmt_modified
from t_manufacturer_info
where nick_name = #{abbr}
</select>
<select id="selectById" resultMap="BaseResultMap">
select
id,code,name,nick_name,address,maintenance_unit,gmt_create,gmt_modified
from t_manufacturer_info
where id = #{manufacturerId}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment