Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
traffic-signal-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
signal
traffic-signal-platform
Commits
0adc6970
Commit
0adc6970
authored
Nov 16, 2022
by
hanbing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
静态信息接口-路口数据,请求海康接口
parent
719f2224
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
653 additions
and
50 deletions
+653
-50
artemis-http-client-1.1.7.jar
lib/artemis-http-client-1.1.7.jar
+0
-0
pom.xml
pom.xml
+39
-0
pom.xml
signal-utc-service/pom.xml
+39
-9
BaseCrossInfo.java
...n/java/net/wanji/utc/common/baseentity/BaseCrossInfo.java
+2
-2
HttpRequest.java
...n/java/net/wanji/utc/common/commonentity/HttpRequest.java
+47
-0
Constants.java
...rc/main/java/net/wanji/utc/common/constant/Constants.java
+31
-0
NoSuchApiException.java
...va/net/wanji/utc/common/exception/NoSuchApiException.java
+15
-0
OutVO.java
...c/main/java/net/wanji/utc/common/genericentity/OutVO.java
+2
-2
ApiInfoTask.java
.../src/main/java/net/wanji/utc/common/task/ApiInfoTask.java
+46
-0
BasicEnum.java
...rc/main/java/net/wanji/utc/common/typeenum/BasicEnum.java
+2
-30
MyArtemisConfig.java
...e/src/main/java/net/wanji/utc/config/MyArtemisConfig.java
+27
-0
Swagger2.java
...-service/src/main/java/net/wanji/utc/config/Swagger2.java
+42
-0
WebConfigurer.java
...ice/src/main/java/net/wanji/utc/config/WebConfigurer.java
+21
-0
StaticInfoController.java
...n/java/net/wanji/utc/controller/StaticInfoController.java
+2
-2
ApiInfoMapper.java
...ice/src/main/java/net/wanji/utc/mapper/ApiInfoMapper.java
+13
-0
CrossInfoMapper.java
...e/src/main/java/net/wanji/utc/mapper/CrossInfoMapper.java
+12
-0
ManufacturerInfoMapper.java
...ain/java/net/wanji/utc/mapper/ManufacturerInfoMapper.java
+15
-0
ApiInfoPO.java
...utc-service/src/main/java/net/wanji/utc/po/ApiInfoPO.java
+41
-0
ManufacturerInfoPO.java
...ce/src/main/java/net/wanji/utc/po/ManufacturerInfoPO.java
+38
-0
HkService.java
...ervice/src/main/java/net/wanji/utc/service/HkService.java
+13
-0
HkServiceImpl.java
...c/main/java/net/wanji/utc/service/impl/HkServiceImpl.java
+105
-0
StaticInfoServiceImpl.java
...ava/net/wanji/utc/service/impl/StaticInfoServiceImpl.java
+8
-3
CrossInfoInVO.java
...service/src/main/java/net/wanji/utc/vo/CrossInfoInVO.java
+2
-2
application-dev.yml
signal-utc-service/src/main/resources/application-dev.yml
+14
-0
application.yml
signal-utc-service/src/main/resources/application.yml
+3
-0
ApiInfoMapper.xml
...l-utc-service/src/main/resources/mapper/ApiInfoMapper.xml
+21
-0
CrossInfoMapper.xml
...utc-service/src/main/resources/mapper/CrossInfoMapper.xml
+25
-0
ManufacturerInfoMapper.xml
...vice/src/main/resources/mapper/ManufacturerInfoMapper.xml
+28
-0
No files found.
lib/artemis-http-client-1.1.7.jar
0 → 100644
View file @
0adc6970
File added
pom.xml
View file @
0adc6970
...
...
@@ -43,6 +43,12 @@
<druid.version>
1.1.5
</druid.version>
<swagger.version>
2.9.2
</swagger.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>
<!-- 依赖声明 -->
...
...
@@ -102,6 +108,39 @@
<artifactId>
lombok
</artifactId>
<version>
${lombok.version}
</version>
</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>
</dependencyManagement>
...
...
signal-utc-service/pom.xml
View file @
0adc6970
...
...
@@ -29,21 +29,19 @@
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
-cache
</artifactId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<exclusions>
<exclusion>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-tomcat
</artifactId>
</exclusion>
</exclusions>
<artifactId>
spring-boot-starter-aop
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-undertow
</artifactId>
<artifactId>
spring-boot-starter-cache
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
@@ -91,6 +89,11 @@
<version>
RELEASE
</version>
<scope>
compile
</scope>
</dependency>
<!-- Swagger -->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
...
...
@@ -99,6 +102,33 @@
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</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>
<build>
...
...
signal-utc-service/src/main/java/net/wanji/utc/common/baseentity/BaseCrossInfo.java
View file @
0adc6970
...
...
@@ -14,6 +14,6 @@ public class BaseCrossInfo {
@ApiModelProperty
(
value
=
"信号机ID"
)
private
String
telesemeId
;
@ApiModelProperty
(
value
=
"厂商
ID
"
)
private
String
manufacturer
Id
;
@ApiModelProperty
(
value
=
"厂商
缩写
"
)
private
String
manufacturer
Abbr
;
}
signal-utc-service/src/main/java/net/wanji/utc/common/commonentity/HttpRequest.java
0 → 100644
View file @
0adc6970
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
signal-utc-service/src/main/java/net/wanji/utc/common/constant/Constants.java
View file @
0adc6970
package
net
.
wanji
.
utc
.
common
.
constant
;
import
net.wanji.utc.po.ApiInfoPO
;
import
java.util.concurrent.ConcurrentHashMap
;
public
class
Constants
{
/**
* 厂商接口地址
*/
private
static
ConcurrentHashMap
<
String
,
ApiInfoPO
>
manufacturerUrlMap
=
new
ConcurrentHashMap
<>();
/**
* 系统缩写
*/
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
signal-utc-service/src/main/java/net/wanji/utc/common/exception/NoSuchApiException.java
0 → 100644
View file @
0adc6970
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
);
}
}
signal-utc-service/src/main/java/net/wanji/utc/common/genericentity/OutVO.java
View file @
0adc6970
...
...
@@ -19,9 +19,9 @@ public class OutVO<T> {
private
String
systemAbbr
;
/**
* 厂商
ID
* 厂商
缩写
*/
private
String
manufacturer
Id
;
private
String
manufacturer
Abbr
;
/**
* 更新时间
...
...
signal-utc-service/src/main/java/net/wanji/utc/common/task/ApiInfoTask.java
0 → 100644
View file @
0adc6970
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
signal-utc-service/src/main/java/net/wanji/utc/common/typeenum/BasicEnum.java
View file @
0adc6970
...
...
@@ -7,38 +7,10 @@ public class BasicEnum {
@Getter
@AllArgsConstructor
public
enum
ManufacturerEnum
{
QS
(
1
,
"青松"
,
"QS"
),
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"
);
HK
(
1
,
"海康"
,
"HK"
);
private
Integer
code
;
private
String
name
;
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
;
}
private
String
abbr
;
}
}
signal-utc-service/src/main/java/net/wanji/utc/config/MyArtemisConfig.java
0 → 100644
View file @
0adc6970
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
signal-utc-service/src/main/java/net/wanji/utc/config/Swagger2.java
0 → 100644
View file @
0adc6970
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
signal-utc-service/src/main/java/net/wanji/utc/config/WebConfigurer.java
0 → 100644
View file @
0adc6970
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
signal-utc-service/src/main/java/net/wanji/utc/controller/StaticInfoController.java
View file @
0adc6970
...
...
@@ -30,8 +30,8 @@ public class StaticInfoController {
@ApiOperation
(
value
=
"信号路口基础信息"
,
notes
=
"信号路口基础信息"
)
public
ResponseEntity
crossInfo
(
HttpServletRequest
request
,
@RequestBody
CrossInfoInVO
crossInfoInVO
)
{
OutVO
<
BaseCrossInfo
>
outVO
=
new
OutVO
<>();
String
manufacturer
Id
=
crossInfoInVO
.
getManufacturerId
();
outVO
.
setManufacturer
Id
(
manufacturerId
);
String
manufacturer
Abbr
=
crossInfoInVO
.
getManufacturerAbbr
();
outVO
.
setManufacturer
Abbr
(
manufacturerAbbr
);
outVO
.
setUpdatetime
(
new
Date
());
outVO
.
setSystemAbbr
(
Constants
.
SYSTEM_ABBR
);
...
...
signal-utc-service/src/main/java/net/wanji/utc/mapper/ApiInfoMapper.java
0 → 100644
View file @
0adc6970
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
();
}
signal-utc-service/src/main/java/net/wanji/utc/mapper/CrossInfoMapper.java
0 → 100644
View file @
0adc6970
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
);
}
signal-utc-service/src/main/java/net/wanji/utc/mapper/ManufacturerInfoMapper.java
0 → 100644
View file @
0adc6970
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
);
}
signal-utc-service/src/main/java/net/wanji/utc/po/ApiInfoPO.java
0 → 100644
View file @
0adc6970
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
;
}
signal-utc-service/src/main/java/net/wanji/utc/po/ManufacturerInfoPO.java
0 → 100644
View file @
0adc6970
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
;
}
signal-utc-service/src/main/java/net/wanji/utc/service/HkService.java
0 → 100644
View file @
0adc6970
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
();
}
signal-utc-service/src/main/java/net/wanji/utc/service/impl/HkServiceImpl.java
0 → 100644
View file @
0adc6970
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
;
}
}
signal-utc-service/src/main/java/net/wanji/utc/service/impl/StaticInfoServiceImpl.java
View file @
0adc6970
...
...
@@ -3,14 +3,17 @@ package net.wanji.utc.service.impl;
import
net.wanji.utc.common.genericentity.ManufacturerRes
;
import
net.wanji.utc.common.typeenum.BasicEnum
;
import
net.wanji.utc.po.CrossInfoPO
;
import
net.wanji.utc.service.HkService
;
import
net.wanji.utc.service.StaticInfoService
;
import
net.wanji.utc.common.baseentity.BaseCrossInfo
;
import
net.wanji.utc.common.genericentity.OutVO
;
import
net.wanji.utc.vo.DetailCrossInfoVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
/**
* @author Kent HAN
...
...
@@ -18,13 +21,15 @@ import java.util.List;
*/
@Service
public
class
StaticInfoServiceImpl
implements
StaticInfoService
{
@Autowired
HkService
hkService
;
@Override
public
void
crossBasicInfo
(
OutVO
<
BaseCrossInfo
>
outVO
)
{
List
<
CrossInfoPO
>
crossInfoPOList
=
new
ArrayList
<>();
ManufacturerRes
<
DetailCrossInfoVO
>
res
=
new
ManufacturerRes
<>();
if
(
BasicEnum
.
ManufacturerEnum
.
HK
.
getId
().
equalsIgnoreCase
(
outVO
.
getManufacturerId
()))
{
// todo 海康
if
(
Objects
.
equals
(
BasicEnum
.
ManufacturerEnum
.
HK
.
getAbbr
(),
outVO
.
getManufacturerAbbr
()))
{
crossInfoPOList
=
hkService
.
crossBasicInfo
();
}
else
{
// todo 其他厂商
}
...
...
signal-utc-service/src/main/java/net/wanji/utc/vo/CrossInfoInVO.java
View file @
0adc6970
...
...
@@ -11,6 +11,6 @@ import lombok.Data;
@Data
@ApiModel
(
value
=
"CrossInfoInVO"
,
description
=
"查询信号路口基础信息输入参数"
)
public
class
CrossInfoInVO
{
@ApiModelProperty
(
value
=
"厂商
ID QS/SCATS/HS/HK
"
)
String
manufacturer
Id
;
@ApiModelProperty
(
value
=
"厂商
缩写 HK-海康
"
)
String
manufacturer
Abbr
;
}
signal-utc-service/src/main/resources/application-dev.yml
View file @
0adc6970
...
...
@@ -31,3 +31,17 @@ spring:
min-idle
:
10
timeout
:
5000
database
:
3
# 信号平台
signal
:
# 厂商接口
manufacturer
:
hk
:
# 服务地址
artemisHost
:
10.100.1.101
# 接口服务验证用户名
artemisAppKey
:
21560443
# 接口服务验证密钥
artemisAppSecret
:
5z0O0DRKALWyIxdQU4kp
# 海康能力开放平台的网站路径
artemisPath
:
/artemis
signal-utc-service/src/main/resources/application.yml
View file @
0adc6970
spring
:
profiles
:
active
:
dev
mvc
:
pathmatch
:
matching-strategy
:
ant_path_matcher
server
:
undertow
:
url-charset
:
UTF-8
...
...
signal-utc-service/src/main/resources/mapper/ApiInfoMapper.xml
0 → 100644
View file @
0adc6970
<?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>
signal-utc-service/src/main/resources/mapper/CrossInfoMapper.xml
0 → 100644
View file @
0adc6970
<?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>
signal-utc-service/src/main/resources/mapper/ManufacturerInfoMapper.xml
0 → 100644
View file @
0adc6970
<?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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment