forked from wuweidong/hzims-back-huoshan
15 changed files with 226 additions and 4 deletions
@ -0,0 +1,31 @@ |
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
<parent> |
||||||
|
<groupId>com.hnac.hzims</groupId> |
||||||
|
<artifactId>hzims-service</artifactId> |
||||||
|
<version>4.0.0-SNAPSHOT</version> |
||||||
|
</parent> |
||||||
|
|
||||||
|
<artifactId>hikvision</artifactId> |
||||||
|
<packaging>jar</packaging> |
||||||
|
|
||||||
|
<name>hikvision</name> |
||||||
|
<url>http://maven.apache.org</url> |
||||||
|
|
||||||
|
<properties> |
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||||
|
</properties> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>com.hzinfo.framework</groupId> |
||||||
|
<artifactId>hnac-framework-mqtt-starters</artifactId> |
||||||
|
<version>${bladex.project.version}</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>com.hikvision.ga</groupId> |
||||||
|
<artifactId>artemis-http-client</artifactId> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
</project> |
@ -0,0 +1,28 @@ |
|||||||
|
package com.hnac.hzims.hikvision; |
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan; |
||||||
|
import org.springblade.core.cloud.feign.EnableBladeFeign; |
||||||
|
import org.springblade.core.launch.BladeApplication; |
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||||
|
import org.springframework.cloud.client.SpringCloudApplication; |
||||||
|
|
||||||
|
/** |
||||||
|
* 海康威视微服务 |
||||||
|
* |
||||||
|
* @author ypj |
||||||
|
* @date 2025-06-12 |
||||||
|
*/ |
||||||
|
@EnableBladeFeign |
||||||
|
@SpringCloudApplication |
||||||
|
@MapperScan(basePackages = {"com.hnac.hzinfo.**.mapper"}) |
||||||
|
public class HikvisionApplication { |
||||||
|
static String APPLICATION_NAME = "hzims-hikvision"; |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
BladeApplication.run(APPLICATION_NAME, HikvisionApplication.class, args); |
||||||
|
} |
||||||
|
|
||||||
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { |
||||||
|
return BladeApplication.createSpringApplicationBuilder(builder, APPLICATION_NAME, HikvisionApplication.class); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
package com.hnac.hzims.hikvision.config; |
||||||
|
|
||||||
|
import com.hikvision.artemis.sdk.config.ArtemisConfig; |
||||||
|
import lombok.Data; |
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||||
|
import org.springframework.cloud.context.config.annotation.RefreshScope; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
/** |
||||||
|
* 海康威视配置 |
||||||
|
* |
||||||
|
* @author ypj |
||||||
|
* @date 2025-06-13 |
||||||
|
*/ |
||||||
|
@Configuration |
||||||
|
@ConfigurationProperties(prefix = "hikvision.server") |
||||||
|
@Data |
||||||
|
@RefreshScope |
||||||
|
public class HikvisionConfig { |
||||||
|
private String host; |
||||||
|
|
||||||
|
private String appKey; |
||||||
|
|
||||||
|
private String appSecret; |
||||||
|
|
||||||
|
public ArtemisConfig toArtemisConfig() { |
||||||
|
ArtemisConfig artemisConfig = new ArtemisConfig(); |
||||||
|
artemisConfig.setHost(host); |
||||||
|
artemisConfig.setAppKey(appKey); |
||||||
|
artemisConfig.setAppSecret(appSecret); |
||||||
|
return artemisConfig; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
package com.hnac.hzims.hikvision.controller; |
||||||
|
|
||||||
|
import com.hnac.hzims.hikvision.service.IHikvisionService; |
||||||
|
import lombok.RequiredArgsConstructor; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
/** |
||||||
|
* 海康威视智能告警 |
||||||
|
* |
||||||
|
* @author ypj |
||||||
|
* @date 2025-06-13 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/hikvision") |
||||||
|
@RequiredArgsConstructor |
||||||
|
public class HikvisionController { |
||||||
|
private final IHikvisionService hikvisionService; |
||||||
|
|
||||||
|
@GetMapping("/getSubscriptionResult") |
||||||
|
public R<String> getSubscriptionResult() { |
||||||
|
return R.data(hikvisionService.getSubscriptionResult()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
package com.hnac.hzims.hikvision.service; |
||||||
|
|
||||||
|
/** |
||||||
|
* 海康威视视频服务 |
||||||
|
* |
||||||
|
* @author ypj |
||||||
|
* @date 2025-06-12 |
||||||
|
*/ |
||||||
|
public interface IHikvisionService { |
||||||
|
|
||||||
|
String getSubscriptionResult(); |
||||||
|
|
||||||
|
Boolean subscribe(); |
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
package com.hnac.hzims.hikvision.service.impl; |
||||||
|
|
||||||
|
import com.hikvision.artemis.sdk.ArtemisHttpUtil; |
||||||
|
import com.hikvision.artemis.sdk.config.ArtemisConfig; |
||||||
|
import com.hnac.hzims.hikvision.config.HikvisionConfig; |
||||||
|
import com.hnac.hzims.hikvision.service.IHikvisionService; |
||||||
|
import lombok.RequiredArgsConstructor; |
||||||
|
import lombok.extern.java.Log; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springblade.mqtt.config.MqttConfig; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 海康威视服务 |
||||||
|
* |
||||||
|
* @author ypj |
||||||
|
* @date 2025-06-12 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
@Slf4j |
||||||
|
@RequiredArgsConstructor |
||||||
|
public class HikvisionServiceImpl implements IHikvisionService { |
||||||
|
|
||||||
|
private final MqttConfig mqttConfig; |
||||||
|
|
||||||
|
private final HikvisionConfig hikvisionConfig; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getSubscriptionResult() { |
||||||
|
ArtemisConfig.host = this.hikvisionConfig.getHost(); |
||||||
|
ArtemisConfig.appKey = this.hikvisionConfig.getAppKey(); |
||||||
|
ArtemisConfig.appSecret = this.hikvisionConfig.getAppSecret(); |
||||||
|
final Map<String, String> subscriptionPath = new HashMap<String, String>(2) { |
||||||
|
{ |
||||||
|
this.put("https://", "/artemis/api/eventService/v1/eventSubscriptionView"); |
||||||
|
} |
||||||
|
}; |
||||||
|
return ArtemisHttpUtil.doPostStringArtemis(subscriptionPath, |
||||||
|
"{\"subWay\":2}", |
||||||
|
(Map<String, String>) null, |
||||||
|
(String) null, |
||||||
|
"application/json", |
||||||
|
(Map<String, String>) null); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Boolean subscribe() { |
||||||
|
String result = this.getSubscriptionResult(); |
||||||
|
log.info("海康威视订阅结果:{}", result); |
||||||
|
return Boolean.TRUE; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
#服务器端口 |
||||||
|
server: |
||||||
|
port: 8271 |
||||||
|
|
||||||
|
#数据源配置 |
||||||
|
spring: |
||||||
|
datasource: |
||||||
|
url: ${blade.datasource.dev.url} |
||||||
|
username: ${blade.datasource.dev.username} |
||||||
|
password: ${blade.datasource.dev.password} |
@ -0,0 +1,6 @@ |
|||||||
|
#数据源配置 |
||||||
|
spring: |
||||||
|
datasource: |
||||||
|
url: ${blade.datasource.prod.url} |
||||||
|
username: ${blade.datasource.prod.username} |
||||||
|
password: ${blade.datasource.prod.password} |
@ -0,0 +1,6 @@ |
|||||||
|
#数据源配置 |
||||||
|
spring: |
||||||
|
datasource: |
||||||
|
url: ${blade.datasource.test.url} |
||||||
|
username: ${blade.datasource.test.username} |
||||||
|
password: ${blade.datasource.test.password} |
@ -0,0 +1,15 @@ |
|||||||
|
spring: |
||||||
|
application: |
||||||
|
name: hzims-hikvision |
||||||
|
|
||||||
|
#mybatis-plus配置 |
||||||
|
mybatis-plus: |
||||||
|
mapper-locations: classpath:org/springbalde/**/mapper/*Mapper.xml,classpath:com/hnac/hzinfo/**/mapper/*Mapper.xml |
||||||
|
#实体扫描,多个package用逗号或者分号分隔 |
||||||
|
typeAliasesPackage: org.springbalde.**.entity,com.hnac.hzinfo.**.entity |
||||||
|
|
||||||
|
#swagger扫描路径配置 |
||||||
|
swagger: |
||||||
|
base-packages: |
||||||
|
- org.springbalde |
||||||
|
- com.hnac.hzinfo |
Loading…
Reference in new issue