commit 79d013398aa2a79fa8e6c76286c1c6916ef6f486 Author: fangyang2021 <3020949587@qq.com> Date: Tue Jun 10 14:22:49 2025 +0800 0.0.1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76ea69b --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea +**/target/ +**/logs/ +*.log diff --git a/box-common/pom.xml b/box-common/pom.xml new file mode 100644 index 0000000..aee262b --- /dev/null +++ b/box-common/pom.xml @@ -0,0 +1,62 @@ + + + + box + com.mathvision + 1.0-SNAPSHOT + + 4.0.0 + + box-common + 通用工具 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-validation + + + + org.apache.poi + poi-ooxml + + + org.apache.poi + poi-scratchpad + + + + com.auth0 + java-jwt + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + + + + com.opencsv + opencsv + + + com.squareup.okhttp3 + okhttp + + + + com.github.xiaoymin + knife4j-spring-boot-starter + + + + + \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/annotation/Auth.java b/box-common/src/main/java/com/mathvision/box/common/annotation/Auth.java new file mode 100644 index 0000000..e2e99b4 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/annotation/Auth.java @@ -0,0 +1,15 @@ +package com.mathvision.box.common.annotation; + +import java.lang.annotation.*; + +/** + * 自定义鉴权注解 + * + * @author fy + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Auth { + String permission() default ""; +} diff --git a/box-common/src/main/java/com/mathvision/box/common/annotation/CsvColumn.java b/box-common/src/main/java/com/mathvision/box/common/annotation/CsvColumn.java new file mode 100644 index 0000000..f190c12 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/annotation/CsvColumn.java @@ -0,0 +1,13 @@ +package com.mathvision.box.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface CsvColumn { + String header() default ""; + int order() default 0; +} diff --git a/box-common/src/main/java/com/mathvision/box/common/annotation/Log.java b/box-common/src/main/java/com/mathvision/box/common/annotation/Log.java new file mode 100644 index 0000000..2d13489 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/annotation/Log.java @@ -0,0 +1,18 @@ +package com.mathvision.box.common.annotation; + +import java.lang.annotation.*; + +/** + * 自定义操作日志注解 + * + * @author fy + */ +@Target(ElementType.METHOD) //注解放置的目标位置,METHOD是可注解在方法级别上 +@Retention(RetentionPolicy.RUNTIME) //注解在哪个阶段执行 +@Documented +public @interface Log { + + String logType() default ""; // 日志类型 + + String logContent() default ""; // 日志内容 +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/annotation/aes/AesDecrypt.java b/box-common/src/main/java/com/mathvision/box/common/annotation/aes/AesDecrypt.java new file mode 100644 index 0000000..8db1d18 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/annotation/aes/AesDecrypt.java @@ -0,0 +1,12 @@ +package com.mathvision.box.common.annotation.aes; + +import java.lang.annotation.*; + +/** + * AES解密 参数校验 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface AesDecrypt { + String message() default "字段需AES加密传输"; +} diff --git a/box-common/src/main/java/com/mathvision/box/common/annotation/aes/AesEncrypt.java b/box-common/src/main/java/com/mathvision/box/common/annotation/aes/AesEncrypt.java new file mode 100644 index 0000000..ce0aa29 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/annotation/aes/AesEncrypt.java @@ -0,0 +1,7 @@ +package com.mathvision.box.common.annotation.aes; + +/** + * AES加密 + */ +public @interface AesEncrypt { +} diff --git a/box-common/src/main/java/com/mathvision/box/common/annotation/excel/Excel.java b/box-common/src/main/java/com/mathvision/box/common/annotation/excel/Excel.java new file mode 100644 index 0000000..6d7610b --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/annotation/excel/Excel.java @@ -0,0 +1,186 @@ +package com.mathvision.box.common.annotation.excel; + +import com.mathvision.box.common.utils.poi.ExcelHandlerAdapter; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.IndexedColors; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.math.BigDecimal; + +/** + * 自定义导出Excel数据注解 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface Excel +{ + /** + * 导出时在excel中排序 + */ + public int sort() default Integer.MAX_VALUE; + + /** + * 导出到Excel中的名字. + */ + public String name() default ""; + + /** + * 日期格式, 如: yyyy-MM-dd + */ + public String dateFormat() default ""; + + /** + * 如果是字典类型,请设置字典的type值 (如: sys_user_sex) + */ + public String dictType() default ""; + + /** + * 读取内容转表达式 (如: 0=男,1=女,2=未知) + */ + public String readConverterExp() default ""; + + /** + * 分隔符,读取字符串组内容 + */ + public String separator() default ","; + + /** + * BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化) + */ + public int scale() default -1; + + /** + * BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN + */ + public int roundingMode() default BigDecimal.ROUND_HALF_EVEN; + + /** + * 导出时在excel中每个列的高度 + */ + public double height() default 14; + + /** + * 导出时在excel中每个列的宽度 + */ + public double width() default 16; + + /** + * 文字后缀,如% 90 变成90% + */ + public String suffix() default ""; + + /** + * 当值为空时,字段的默认值 + */ + public String defaultValue() default ""; + + /** + * 提示信息 + */ + public String prompt() default ""; + + /** + * 设置只能选择不能输入的列内容. + */ + public String[] combo() default {}; + + /** + * 是否需要纵向合并单元格,应对需求:含有list集合单元格) + */ + public boolean needMerge() default false; + + /** + * 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写. + */ + public boolean isExport() default true; + + /** + * 另一个类中的属性名称,支持多级获取,以小数点隔开 + */ + public String targetAttr() default ""; + + /** + * 是否自动统计数据,在最后追加一行统计数据总和 + */ + public boolean isStatistics() default false; + + /** + * 导出类型(0数字 1字符串 2图片) + */ + public ColumnType cellType() default ColumnType.STRING; + + /** + * 导出列头背景颜色 + */ + public IndexedColors headerBackgroundColor() default IndexedColors.SKY_BLUE; + + /** + * 导出列头字体颜色 + */ + public IndexedColors headerColor() default IndexedColors.WHITE; + + /** + * 导出单元格背景颜色 + */ + public IndexedColors backgroundColor() default IndexedColors.WHITE; + + /** + * 导出单元格字体颜色 + */ + public IndexedColors color() default IndexedColors.BLACK; + + /** + * 导出字段对齐方式 + */ + public HorizontalAlignment align() default HorizontalAlignment.CENTER; + + /** + * 自定义数据处理器 + */ + public Class handler() default ExcelHandlerAdapter.class; + + /** + * 自定义数据处理器参数 + */ + public String[] args() default {}; + + /** + * 字段类型(0:导出导入;1:仅导出;2:仅导入) + */ + Type type() default Type.ALL; + + public enum Type + { + ALL(0), EXPORT(1), IMPORT(2); + private final int value; + + Type(int value) + { + this.value = value; + } + + public int value() + { + return this.value; + } + } + + public enum ColumnType + { + NUMERIC(0), STRING(1), IMAGE(2); + private final int value; + + ColumnType(int value) + { + this.value = value; + } + + public int value() + { + return this.value; + } + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/annotation/excel/Excels.java b/box-common/src/main/java/com/mathvision/box/common/annotation/excel/Excels.java new file mode 100644 index 0000000..fff482a --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/annotation/excel/Excels.java @@ -0,0 +1,17 @@ +package com.mathvision.box.common.annotation.excel; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Excel注解集 + * + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Excels +{ + Excel[] value(); +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/annotation/tree/TreeNodeId.java b/box-common/src/main/java/com/mathvision/box/common/annotation/tree/TreeNodeId.java new file mode 100644 index 0000000..8e37c4f --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/annotation/tree/TreeNodeId.java @@ -0,0 +1,16 @@ +package com.mathvision.box.common.annotation.tree; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @Description:树节点ID注解 + * @Version: 1.0 + * @Author: yyy + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface TreeNodeId { +} diff --git a/box-common/src/main/java/com/mathvision/box/common/annotation/tree/TreeNodeName.java b/box-common/src/main/java/com/mathvision/box/common/annotation/tree/TreeNodeName.java new file mode 100644 index 0000000..e964479 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/annotation/tree/TreeNodeName.java @@ -0,0 +1,16 @@ +package com.mathvision.box.common.annotation.tree; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @Description:树节点名称注解 + * @Version: 1.0 + * @Author: yyy + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface TreeNodeName { +} diff --git a/box-common/src/main/java/com/mathvision/box/common/annotation/tree/TreeNodeParentId.java b/box-common/src/main/java/com/mathvision/box/common/annotation/tree/TreeNodeParentId.java new file mode 100644 index 0000000..5e296b9 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/annotation/tree/TreeNodeParentId.java @@ -0,0 +1,16 @@ +package com.mathvision.box.common.annotation.tree; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @Description:树节点父ID注解 + * @Version: 1.0 + * @Author: yyy + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface TreeNodeParentId { +} diff --git a/box-common/src/main/java/com/mathvision/box/common/config/AppConfig.java b/box-common/src/main/java/com/mathvision/box/common/config/AppConfig.java new file mode 100644 index 0000000..3124d69 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/config/AppConfig.java @@ -0,0 +1,252 @@ +package com.mathvision.box.common.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:全局配置类 + */ +@Component +@ConfigurationProperties(prefix = "app") +public class AppConfig { + /** 项目名称 */ + private static String name = ""; + + /** 版本 */ + private static String version = ""; + + /** 版权 */ + private static String copyright = ""; + + /** 版权年份 */ + private static String copyrightYear = ""; + + /** 上传路径 */ + private static String profile = ""; + + /** 定时清除-数据的保留天数 */ + private static Integer dataCleanupRetentionDays = 30; + + /** 定时清除-清除数据的保存csv的批量处理数 */ + private static Integer dataBatchSize = 100; + + // 实例变量用于注入 + @Value("${app.name}") + private String tempName; + + @Value("${app.version}") + private String tempVersion; + + @Value("${app.copyright}") + private String tempCopyright; + + @Value("${app.copyrightYear}") + private String tempCopyrightYear; + + @Value("${app.profile}") + private String tempProfile; + + @Value("${app.data.cleanup.retention-days}") + private Integer tempDataCleanupRetentionDays; + + @Value("${app.data.batch-size}") + private Integer tempDataBatchSize; + + @PostConstruct + public void init() { + if (tempName != null) { + name = tempName; + } + + if (tempVersion != null) { + version = tempVersion; + } + + if (tempCopyright != null) { + copyright = tempCopyright; + } + + if (tempCopyrightYear != null) { + copyrightYear = tempCopyrightYear; + } + + if (tempProfile != null) { + profile = tempProfile; + } + + if (tempDataCleanupRetentionDays != null) { + dataCleanupRetentionDays = tempDataCleanupRetentionDays; + } + + if (tempDataBatchSize != null) { + dataBatchSize = tempDataBatchSize; + } + } + + public static String getName() { + return name; + } + + public static void setName(String name) { + AppConfig.name = name; + } + + public static String getVersion() { + return version; + } + + public static void setVersion(String version) { + AppConfig.version = version; + } + + public static String getCopyright() { + return copyright; + } + + public static void setCopyright(String copyright) { + AppConfig.copyright = copyright; + } + + public static String getCopyrightYear() { + return copyrightYear; + } + + public static void setCopyrightYear(String copyrightYear) { + AppConfig.copyrightYear = copyrightYear; + } + + public static String getProfile() { + return profile; + } + + public static void setProfile(String profile) { + AppConfig.profile = profile; + } + + public static Integer getDataCleanupRetentionDays() { + return dataCleanupRetentionDays; + } + + public static void setDataCleanupRetentionDays(Integer dataCleanupRetentionDays) { + AppConfig.dataCleanupRetentionDays = dataCleanupRetentionDays; + } + + public static Integer getDataBatchSize() { + return dataBatchSize; + } + + public static void setDataBatchSize(Integer dataBatchSize) { + AppConfig.dataBatchSize = dataBatchSize; + } + + /** + * 获取导入上传路径 + */ + public static String getImportPath() + { + return getProfile() + "/import"; + } + + /** + * 获取头像上传路径 + */ + public static String getAvatarPath() + { + return getProfile() + "/avatar"; + } + + /** + * 获取下载路径 + */ + public static String getDownloadPath() + { + return getProfile() + "/download/"; + } + + /** + * 获取上传路径 + */ + public static String getUploadPath() + { + return getProfile() + "/upload"; + } + + /** + * 获取长期存储CSV数据文件路径 + */ + public static String getCsvPath() + { + return getProfile() + "/csv/"; + } + + /** + * 告警数据文件路径 + */ + public static String getAlarmPath() + { + return getProfile() + "/alarm/"; + } + + + // getter 和 setter for temp variables + public String getTempName() { + return tempName; + } + + public void setTempName(String tempName) { + this.tempName = tempName; + } + + public String getTempVersion() { + return tempVersion; + } + + public void setTempVersion(String tempVersion) { + this.tempVersion = tempVersion; + } + + public String getTempCopyright() { + return tempCopyright; + } + + public void setTempCopyright(String tempCopyright) { + this.tempCopyright = tempCopyright; + } + + public String getTempCopyrightYear() { + return tempCopyrightYear; + } + + public void setTempCopyrightYear(String tempCopyrightYear) { + this.tempCopyrightYear = tempCopyrightYear; + } + + public String getTempProfile() { + return tempProfile; + } + + public void setTempProfile(String tempProfile) { + this.tempProfile = tempProfile; + } + + public Integer getTempDataCleanupRetentionDays() { + return tempDataCleanupRetentionDays; + } + + public void setTempDataCleanupRetentionDays(Integer tempDataCleanupRetentionDays) { + this.tempDataCleanupRetentionDays = tempDataCleanupRetentionDays; + } + + public Integer getTempDataBatchSize() { + return tempDataBatchSize; + } + + public void setTempDataBatchSize(Integer tempDataBatchSize) { + this.tempDataBatchSize = tempDataBatchSize; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/config/ServerConfig.java b/box-common/src/main/java/com/mathvision/box/common/config/ServerConfig.java new file mode 100644 index 0000000..dd37a41 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/config/ServerConfig.java @@ -0,0 +1,33 @@ +package com.mathvision.box.common.config; + +import com.mathvision.box.common.utils.common.ServletUtils; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:服务相关配置 + */ +@Component +public class ServerConfig +{ + /** + * 获取完整的请求路径,包括:域名,端口,上下文访问路径 + * + * @return 服务地址 + */ + public String getUrl() + { + HttpServletRequest request = ServletUtils.getRequest(); + return getDomain(request); + } + + public static String getDomain(HttpServletRequest request) + { + StringBuffer url = request.getRequestURL(); + String contextPath = request.getServletContext().getContextPath(); + return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString(); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/constant/Constants.java b/box-common/src/main/java/com/mathvision/box/common/constant/Constants.java new file mode 100644 index 0000000..a3cfe4e --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/constant/Constants.java @@ -0,0 +1,136 @@ +package com.mathvision.box.common.constant; + +import com.google.common.collect.Lists; +import org.springframework.http.MediaType; + +import java.util.List; +import java.util.Locale; + +/** + * @Author: fy + * @Date: 2024/03/21 + * @Description:通用常量信息 + */ +public class Constants { + public static final String SESSION_USER_KEY = "user"; + + public static final List SUPPORTED_MEDIA_TYPES = Lists.newArrayList( + MediaType.APPLICATION_JSON, + MediaType.APPLICATION_ATOM_XML, + MediaType.APPLICATION_FORM_URLENCODED, + MediaType.APPLICATION_OCTET_STREAM, + MediaType.APPLICATION_PDF, + MediaType.APPLICATION_RSS_XML, + MediaType.APPLICATION_XHTML_XML, + MediaType.APPLICATION_XML, + MediaType.IMAGE_GIF, + MediaType.IMAGE_JPEG, + MediaType.IMAGE_PNG, + MediaType.TEXT_EVENT_STREAM, + MediaType.TEXT_HTML, + MediaType.TEXT_MARKDOWN, + MediaType.TEXT_PLAIN, + MediaType.TEXT_XML + ); + + /** + * UTF-8 字符集 + */ + public static final String UTF8 = "UTF-8"; + + /** + * GBK 字符集 + */ + public static final String GBK = "GBK"; + + /** + * 系统语言 + */ + public static final Locale DEFAULT_LOCALE = Locale.SIMPLIFIED_CHINESE; + + /** + * http请求 + */ + public static final String HTTP = "http://"; + + /** + * https请求 + */ + public static final String HTTPS = "https://"; + + /** + * 通用成功标识 + */ + public static final String SUCCESS = "0"; + + /** + * 通用失败标识 + */ + public static final String FAIL = "1"; + + /** + * 登录成功 + */ + public static final String LOGIN_SUCCESS = "Success"; + + /** + * 注销 + */ + public static final String LOGOUT = "Logout"; + + /** + * 注册 + */ + public static final String REGISTER = "Register"; + + /** + * 登录失败 + */ + public static final String LOGIN_FAIL = "Error"; + + /** + * 系统用户授权缓存 + */ + public static final String SYS_AUTH_CACHE = "sys-authCache"; + + /** + * 参数管理 cache name + */ + public static final String SYS_CONFIG_CACHE = "sys-config"; + + /** + * 参数管理 cache key + */ + public static final String SYS_CONFIG_KEY = "sys_config:"; + + /** + * 字典管理 cache name + */ + public static final String SYS_DICT_CACHE = "sys-dict"; + + /** + * 字典管理 cache key + */ + public static final String SYS_DICT_KEY = "sys_dict:"; + + /** + * 资源映射路径 前缀 + */ + public static final String RESOURCE_PREFIX = "/file"; + + /** + * RMI 远程方法调用 + */ + public static final String LOOKUP_RMI = "rmi:"; + + /** + * LDAP 远程方法调用 + */ + public static final String LOOKUP_LDAP = "ldap:"; + + /** + * LDAPS 远程方法调用 + */ + public static final String LOOKUP_LDAPS = "ldaps:"; + +} diff --git a/box-common/src/main/java/com/mathvision/box/common/core/controller/BaseController.java b/box-common/src/main/java/com/mathvision/box/common/core/controller/BaseController.java new file mode 100644 index 0000000..4289a66 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/core/controller/BaseController.java @@ -0,0 +1,217 @@ +package com.mathvision.box.common.core.controller; + + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.domain.ResultCode; +import com.mathvision.box.common.core.domain.entity.UserCache; +import com.mathvision.box.common.core.page.PageDomain; +import com.mathvision.box.common.core.page.TableDataInfo; +import com.mathvision.box.common.core.page.TableSupport; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.common.PageUtils; +import com.mathvision.box.common.utils.common.ServletUtils; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.security.SessionHolder; +import com.mathvision.box.common.utils.sql.SqlUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.InitBinder; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.beans.PropertyEditorSupport; +import java.util.Date; +import java.util.List; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:web层通用数据处理 + */ +@Component +public class BaseController { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + + /** + * 将前台传递过来的日期格式的字符串,自动转化为Date类型 + */ + @InitBinder + public void initBinder(WebDataBinder binder) { + // Date 类型转换 + binder.registerCustomEditor(Date.class, new PropertyEditorSupport() { + @Override + public void setAsText(String text) { + setValue(DateUtils.parseDate(text)); + } + }); + } + + /** + * 设置请求分页数据 + */ + protected void startPage() { + PageUtils.startPage(); + } + + /** + * 设置请求排序数据 + */ + protected void startOrderBy() { + PageDomain pageDomain = TableSupport.buildPageRequest(); + if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) { + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + PageHelper.orderBy(orderBy); + } + } + + /** + * 清理分页的线程变量 + */ + protected void clearPage() { + PageUtils.clearPage(); + } + + /** + * 获取request + */ + public HttpServletRequest getRequest() { + return ServletUtils.getRequest(); + } + + /** + * 获取response + */ + public HttpServletResponse getResponse() { + return ServletUtils.getResponse(); + } + + /** + * 获取session + */ + public HttpSession getSession() { + return getRequest().getSession(); + } + + /** + * 响应请求分页数据 + */ + @SuppressWarnings({"rawtypes", "unchecked"}) + protected TableDataInfo getDataTable(List list) { + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(0); + rspData.setRows(list); + rspData.setTotal(new PageInfo(list).getTotal()); + return rspData; + } + + protected TableDataInfo getDataTable(List list, int total) { + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(0); + rspData.setRows(list); + rspData.setTotal(total); + return rspData; + } + + /** + * 响应返回结果 + * + * @param rows 影响行数 + * @return 操作结果 + */ + protected Result toResult(int rows) { + return rows > 0 ? success() : error(); + } + + /** + * 响应返回结果 + * + * @param result 结果 + * @return 操作结果 + */ + protected Result toResult(boolean result) { + return result ? success() : error(); + } + + /** + * 返回成功 + */ + public Result success() { + return Result.SUCCESS; + } + + /** + * 返回失败消息 + */ + public Result error() { + return Result.FAILURE; + } + + /** + * 返回成功消息 + */ + public Result success(String message) { + return new Result(ResultCode.success, message); + } + + /** + * 返回成功数据 + */ + public static Result success(Object data) { + return new Result(ResultCode.success, data); + } + + /** + * 返回失败消息 + */ + public Result error(String message) { + return new Result(ResultCode.operate_failure.getCode(), message); + } + + /** + * 返回错误码消息 + */ + public Result error(ResultCode code, String message) { + return new Result(code, message); + } + + /** + * 页面跳转 + */ + public String redirect(String url) { + return StringUtils.format("redirect:{}", url); + } + + /** + * 获取用户缓存信息 + */ + public UserCache getUser() { + return SessionHolder.get(); + } + + /** + * 设置用户缓存信息 + */ + public void setUser(UserCache user) { + SessionHolder.set(user); + } + + /** + * 获取登录用户id + */ + public Long getUserId() { + return getUser().getUserId(); + } + + /** + * 获取登录用户名 + */ + public String getLoginName() { + return getUser().getLoginName(); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/core/domain/Result.java b/box-common/src/main/java/com/mathvision/box/common/core/domain/Result.java new file mode 100644 index 0000000..d7baaf5 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/core/domain/Result.java @@ -0,0 +1,63 @@ +package com.mathvision.box.common.core.domain; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.io.Serializable; + +/** + * @Author: fy + * @Date: 2024/03/21 + * @Description:统一返回结果 + */ +@ToString +public class Result implements Serializable { + + private static final long serialVersionUID = 1L; + public static final Result NOT_SUPPORT = new Result(ResultCode.not_support_operate); + public static final Result NOT_PRIVILEGED = new Result(ResultCode.not_privileged); + public static final Result INVALID_USER_PASS = new Result(ResultCode.invalidUserOrPassword); + public static final Result ILLEGAL_ARGUMENT = new Result(ResultCode.illegal_argument); + public static final Result FAILURE = new Result(ResultCode.operate_failure); + public static final Result ERROR = new Result(ResultCode.system_error); + public static final Result NOT_LOGIN = new Result(ResultCode.need_login); + public static final Result SUCCESS = new Result(ResultCode.success); + public static final Result INVALID_LICENSE = new Result(ResultCode.invalid_license); + + @Getter + @Setter + private int code; + @Getter + @Setter + private String desc; + @Getter + @Setter + private T body; + + public Result(ResultCode resultCode) { + setCode(resultCode.getCode()); + setDesc(resultCode.getDesc()); + } + + public Result(int code, String msg) { + setCode(code); + setDesc(msg); + } + + /** + * 使用通用结果码生成对象 + */ + public Result(ResultCode resultCode, T body) { + setCode(resultCode.getCode()); + setDesc(resultCode.getDesc()); + setBody(body); + } + + /** + * 判断执行结果是否成功 + */ + public boolean isSuccess() { + return ResultCode.success.getCode() == code; + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/core/domain/ResultCode.java b/box-common/src/main/java/com/mathvision/box/common/core/domain/ResultCode.java new file mode 100644 index 0000000..b7e6ea4 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/core/domain/ResultCode.java @@ -0,0 +1,32 @@ +package com.mathvision.box.common.core.domain; + +import lombok.Getter; + +/** + * @Author: fy + * @Date: 2024/03/21 + * @Description:统一结果码定义 + */ +public enum ResultCode { + success(200, "成功"), + + invalidUserOrPassword(300, "用户名或者密码错误!"), + illegal_argument(400, "参数错误!"), + need_login(401, "未登录!"), + not_support_operate(404, "不支持的请求!"), + not_privileged(405, "无权限执行该操作!"), + invalid_license(406, "您的证书无效,请核查服务器是否取得授权或重新申请证书!"), + system_error(500, "系统异常!"), + operate_failure(503, "操作失败!"); + + @Getter + private final int code; + @Getter + private final String desc; + + ResultCode(int code, String desc) { + this.code = code; + this.desc = desc; + } + +} diff --git a/box-common/src/main/java/com/mathvision/box/common/core/domain/entity/UserCache.java b/box-common/src/main/java/com/mathvision/box/common/core/domain/entity/UserCache.java new file mode 100644 index 0000000..0246271 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/core/domain/entity/UserCache.java @@ -0,0 +1,24 @@ +package com.mathvision.box.common.core.domain.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UserCache { + private Long userId; + + private String loginName; + + private String userName; + + private Set permissions; + + private Long timeStamp; +} diff --git a/box-common/src/main/java/com/mathvision/box/common/core/page/PageDomain.java b/box-common/src/main/java/com/mathvision/box/common/core/page/PageDomain.java new file mode 100644 index 0000000..156e47a --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/core/page/PageDomain.java @@ -0,0 +1,90 @@ +package com.mathvision.box.common.core.page; + + +import com.mathvision.box.common.utils.common.StringUtils; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:分页数据 + */ +public class PageDomain +{ + /** 当前记录起始索引 */ + private Integer pageNum; + + /** 每页显示记录数 */ + private Integer pageSize; + + /** 排序列 */ + private String orderByColumn; + + /** 排序的方向desc或者asc */ + private String isAsc = "asc"; + + /** 分页参数合理化 */ + private Boolean reasonable = true; + + public String getOrderBy() + { + if (StringUtils.isEmpty(orderByColumn)) + { + return ""; + } + return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc; + } + + public Integer getPageNum() + { + return pageNum; + } + + public void setPageNum(Integer pageNum) + { + this.pageNum = pageNum; + } + + public Integer getPageSize() + { + return pageSize; + } + + public void setPageSize(Integer pageSize) + { + this.pageSize = pageSize; + } + + public String getOrderByColumn() + { + return orderByColumn; + } + + public void setOrderByColumn(String orderByColumn) + { + this.orderByColumn = orderByColumn; + } + + public String getIsAsc() + { + return isAsc; + } + + public void setIsAsc(String isAsc) + { + this.isAsc = isAsc; + } + + public Boolean getReasonable() + { + if (StringUtils.isNull(reasonable)) + { + return Boolean.TRUE; + } + return reasonable; + } + + public void setReasonable(Boolean reasonable) + { + this.reasonable = reasonable; + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/core/page/TableDataInfo.java b/box-common/src/main/java/com/mathvision/box/common/core/page/TableDataInfo.java new file mode 100644 index 0000000..50b785f --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/core/page/TableDataInfo.java @@ -0,0 +1,84 @@ +package com.mathvision.box.common.core.page; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.util.List; + +@ApiModel("表格分页数据对象") +public class TableDataInfo implements Serializable +{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty("总记录数") + private long total; + + @ApiModelProperty("列表数据") + private List rows; + + @ApiModelProperty("消息状态码") + private int code; + + @ApiModelProperty("消息内容") + private String msg; + + /** + * 表格数据对象 + */ + public TableDataInfo() + { + } + + /** + * 分页 + * + * @param list 列表数据 + * @param total 总记录数 + */ + public TableDataInfo(List list, int total) + { + this.rows = list; + this.total = total; + } + + public long getTotal() + { + return total; + } + + public void setTotal(long total) + { + this.total = total; + } + + public List getRows() + { + return rows; + } + + public void setRows(List rows) + { + this.rows = rows; + } + + public int getCode() + { + return code; + } + + public void setCode(int code) + { + this.code = code; + } + + public String getMsg() + { + return msg; + } + + public void setMsg(String msg) + { + this.msg = msg; + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/core/page/TableSupport.java b/box-common/src/main/java/com/mathvision/box/common/core/page/TableSupport.java new file mode 100644 index 0000000..05eb388 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/core/page/TableSupport.java @@ -0,0 +1,57 @@ +package com.mathvision.box.common.core.page; + + +import com.mathvision.box.common.core.text.Convert; +import com.mathvision.box.common.utils.common.ServletUtils; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:表格数据处理 + */ +public class TableSupport +{ + /** + * 当前记录起始索引 + */ + public static final String PAGE_NUM = "pageNum"; + + /** + * 每页显示记录数 + */ + public static final String PAGE_SIZE = "pageSize"; + + /** + * 排序列 + */ + public static final String ORDER_BY_COLUMN = "orderByColumn"; + + /** + * 排序的方向 "desc" 或者 "asc". + */ + public static final String IS_ASC = "isAsc"; + + /** + * 分页参数合理化 + */ + public static final String REASONABLE = "reasonable"; + + /** + * 封装分页对象 + */ + public static PageDomain getPageDomain() + { + PageDomain pageDomain = new PageDomain(); + pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1)); + pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10)); + pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN)); + pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC)); + pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE)); + return pageDomain; + } + + public static PageDomain buildPageRequest() + { + return getPageDomain(); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/core/text/CharsetKit.java b/box-common/src/main/java/com/mathvision/box/common/core/text/CharsetKit.java new file mode 100644 index 0000000..f9a86c1 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/core/text/CharsetKit.java @@ -0,0 +1,88 @@ +package com.mathvision.box.common.core.text; + + +import com.mathvision.box.common.utils.common.StringUtils; + +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +/** + * 字符集工具类 + * + * @author ruoyi + */ +public class CharsetKit +{ + /** ISO-8859-1 */ + public static final String ISO_8859_1 = "ISO-8859-1"; + /** UTF-8 */ + public static final String UTF_8 = "UTF-8"; + /** GBK */ + public static final String GBK = "GBK"; + + /** ISO-8859-1 */ + public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1); + /** UTF-8 */ + public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8); + /** GBK */ + public static final Charset CHARSET_GBK = Charset.forName(GBK); + + /** + * 转换为Charset对象 + * + * @param charset 字符集,为空则返回默认字符集 + * @return Charset + */ + public static Charset charset(String charset) + { + return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset); + } + + /** + * 转换字符串的字符集编码 + * + * @param source 字符串 + * @param srcCharset 源字符集,默认ISO-8859-1 + * @param destCharset 目标字符集,默认UTF-8 + * @return 转换后的字符集 + */ + public static String convert(String source, String srcCharset, String destCharset) + { + return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset)); + } + + /** + * 转换字符串的字符集编码 + * + * @param source 字符串 + * @param srcCharset 源字符集,默认ISO-8859-1 + * @param destCharset 目标字符集,默认UTF-8 + * @return 转换后的字符集 + */ + public static String convert(String source, Charset srcCharset, Charset destCharset) + { + if (null == srcCharset) + { + srcCharset = StandardCharsets.ISO_8859_1; + } + + if (null == destCharset) + { + destCharset = StandardCharsets.UTF_8; + } + + if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) + { + return source; + } + return new String(source.getBytes(srcCharset), destCharset); + } + + /** + * @return 系统字符集编码 + */ + public static String systemCharset() + { + return Charset.defaultCharset().name(); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/core/text/Convert.java b/box-common/src/main/java/com/mathvision/box/common/core/text/Convert.java new file mode 100644 index 0000000..4700d34 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/core/text/Convert.java @@ -0,0 +1,1007 @@ +package com.mathvision.box.common.core.text; + +import com.mathvision.box.common.utils.common.StringUtils; +import org.apache.commons.lang3.ArrayUtils; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.math.RoundingMode; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.text.NumberFormat; +import java.util.Set; + +/** + * 类型转换器 + * + * @author ruoyi + */ +public class Convert +{ + /** + * 转换为字符串
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static String toStr(Object value, String defaultValue) + { + if (null == value) + { + return defaultValue; + } + if (value instanceof String) + { + return (String) value; + } + return value.toString(); + } + + /** + * 转换为字符串
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static String toStr(Object value) + { + return toStr(value, null); + } + + /** + * 转换为字符
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Character toChar(Object value, Character defaultValue) + { + if (null == value) + { + return defaultValue; + } + if (value instanceof Character) + { + return (Character) value; + } + + final String valueStr = toStr(value, null); + return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0); + } + + /** + * 转换为字符
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Character toChar(Object value) + { + return toChar(value, null); + } + + /** + * 转换为byte
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Byte toByte(Object value, Byte defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Byte) + { + return (Byte) value; + } + if (value instanceof Number) + { + return ((Number) value).byteValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Byte.parseByte(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为byte
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Byte toByte(Object value) + { + return toByte(value, null); + } + + /** + * 转换为Short
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Short toShort(Object value, Short defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Short) + { + return (Short) value; + } + if (value instanceof Number) + { + return ((Number) value).shortValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Short.parseShort(valueStr.trim()); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Short
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Short toShort(Object value) + { + return toShort(value, null); + } + + /** + * 转换为Number
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Number toNumber(Object value, Number defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Number) + { + return (Number) value; + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return NumberFormat.getInstance().parse(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Number
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Number toNumber(Object value) + { + return toNumber(value, null); + } + + /** + * 转换为int
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Integer toInt(Object value, Integer defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Integer) + { + return (Integer) value; + } + if (value instanceof Number) + { + return ((Number) value).intValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Integer.parseInt(valueStr.trim()); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为int
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Integer toInt(Object value) + { + return toInt(value, null); + } + + /** + * 转换为Integer数组
+ * + * @param str 被转换的值 + * @return 结果 + */ + public static Integer[] toIntArray(String str) + { + return toIntArray(",", str); + } + + /** + * 转换为Long数组
+ * + * @param str 被转换的值 + * @return 结果 + */ + public static Long[] toLongArray(String str) + { + return toLongArray(",", str); + } + + /** + * 转换为Integer数组
+ * + * @param split 分隔符 + * @param split 被转换的值 + * @return 结果 + */ + public static Integer[] toIntArray(String split, String str) + { + if (StringUtils.isEmpty(str)) + { + return new Integer[] {}; + } + String[] arr = str.split(split); + final Integer[] ints = new Integer[arr.length]; + for (int i = 0; i < arr.length; i++) + { + final Integer v = toInt(arr[i], 0); + ints[i] = v; + } + return ints; + } + + /** + * 转换为Long数组
+ * + * @param split 分隔符 + * @param str 被转换的值 + * @return 结果 + */ + public static Long[] toLongArray(String split, String str) + { + if (StringUtils.isEmpty(str)) + { + return new Long[] {}; + } + String[] arr = str.split(split); + final Long[] longs = new Long[arr.length]; + for (int i = 0; i < arr.length; i++) + { + final Long v = toLong(arr[i], null); + longs[i] = v; + } + return longs; + } + + /** + * 转换为String数组
+ * + * @param str 被转换的值 + * @return 结果 + */ + public static String[] toStrArray(String str) + { + return toStrArray(",", str); + } + + /** + * 转换为String数组
+ * + * @param split 分隔符 + * @param split 被转换的值 + * @return 结果 + */ + public static String[] toStrArray(String split, String str) + { + return str.split(split); + } + + /** + * 转换为long
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Long toLong(Object value, Long defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Long) + { + return (Long) value; + } + if (value instanceof Number) + { + return ((Number) value).longValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + // 支持科学计数法 + return new BigDecimal(valueStr.trim()).longValue(); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为long
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Long toLong(Object value) + { + return toLong(value, null); + } + + /** + * 转换为double
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Double toDouble(Object value, Double defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Double) + { + return (Double) value; + } + if (value instanceof Number) + { + return ((Number) value).doubleValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + // 支持科学计数法 + return new BigDecimal(valueStr.trim()).doubleValue(); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为double
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Double toDouble(Object value) + { + return toDouble(value, null); + } + + /** + * 转换为Float
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Float toFloat(Object value, Float defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Float) + { + return (Float) value; + } + if (value instanceof Number) + { + return ((Number) value).floatValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Float.parseFloat(valueStr.trim()); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Float
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Float toFloat(Object value) + { + return toFloat(value, null); + } + + /** + * 转换为boolean
+ * String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Boolean toBool(Object value, Boolean defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Boolean) + { + return (Boolean) value; + } + String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + valueStr = valueStr.trim().toLowerCase(); + switch (valueStr) + { + case "true": + case "yes": + case "ok": + case "1": + return true; + case "false": + case "no": + case "0": + return false; + default: + return defaultValue; + } + } + + /** + * 转换为boolean
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Boolean toBool(Object value) + { + return toBool(value, null); + } + + /** + * 转换为Enum对象
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * + * @param clazz Enum的Class + * @param value 值 + * @param defaultValue 默认值 + * @return Enum + */ + public static > E toEnum(Class clazz, Object value, E defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (clazz.isAssignableFrom(value.getClass())) + { + @SuppressWarnings("unchecked") + E myE = (E) value; + return myE; + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Enum.valueOf(clazz, valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Enum对象
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * + * @param clazz Enum的Class + * @param value 值 + * @return Enum + */ + public static > E toEnum(Class clazz, Object value) + { + return toEnum(clazz, value, null); + } + + /** + * 转换为BigInteger
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static BigInteger toBigInteger(Object value, BigInteger defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof BigInteger) + { + return (BigInteger) value; + } + if (value instanceof Long) + { + return BigInteger.valueOf((Long) value); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return new BigInteger(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为BigInteger
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static BigInteger toBigInteger(Object value) + { + return toBigInteger(value, null); + } + + /** + * 转换为BigDecimal
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof BigDecimal) + { + return (BigDecimal) value; + } + if (value instanceof Long) + { + return new BigDecimal((Long) value); + } + if (value instanceof Double) + { + return BigDecimal.valueOf((Double) value); + } + if (value instanceof Integer) + { + return new BigDecimal((Integer) value); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return new BigDecimal(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为BigDecimal
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static BigDecimal toBigDecimal(Object value) + { + return toBigDecimal(value, null); + } + + /** + * 将对象转为字符串
+ * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 + * + * @param obj 对象 + * @return 字符串 + */ + public static String utf8Str(Object obj) + { + return str(obj, CharsetKit.CHARSET_UTF_8); + } + + /** + * 将对象转为字符串
+ * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 + * + * @param obj 对象 + * @param charsetName 字符集 + * @return 字符串 + */ + public static String str(Object obj, String charsetName) + { + return str(obj, Charset.forName(charsetName)); + } + + /** + * 将对象转为字符串
+ * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 + * + * @param obj 对象 + * @param charset 字符集 + * @return 字符串 + */ + public static String str(Object obj, Charset charset) + { + if (null == obj) + { + return null; + } + + if (obj instanceof String) + { + return (String) obj; + } + else if (obj instanceof byte[]) + { + return str((byte[]) obj, charset); + } + else if (obj instanceof Byte[]) + { + byte[] bytes = ArrayUtils.toPrimitive((Byte[]) obj); + return str(bytes, charset); + } + else if (obj instanceof ByteBuffer) + { + return str((ByteBuffer) obj, charset); + } + return obj.toString(); + } + + /** + * 将byte数组转为字符串 + * + * @param bytes byte数组 + * @param charset 字符集 + * @return 字符串 + */ + public static String str(byte[] bytes, String charset) + { + return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset)); + } + + /** + * 解码字节码 + * + * @param data 字符串 + * @param charset 字符集,如果此字段为空,则解码的结果取决于平台 + * @return 解码后的字符串 + */ + public static String str(byte[] data, Charset charset) + { + if (data == null) + { + return null; + } + + if (null == charset) + { + return new String(data); + } + return new String(data, charset); + } + + /** + * 将编码的byteBuffer数据转换为字符串 + * + * @param data 数据 + * @param charset 字符集,如果为空使用当前系统字符集 + * @return 字符串 + */ + public static String str(ByteBuffer data, String charset) + { + if (data == null) + { + return null; + } + + return str(data, Charset.forName(charset)); + } + + /** + * 将编码的byteBuffer数据转换为字符串 + * + * @param data 数据 + * @param charset 字符集,如果为空使用当前系统字符集 + * @return 字符串 + */ + public static String str(ByteBuffer data, Charset charset) + { + if (null == charset) + { + charset = Charset.defaultCharset(); + } + return charset.decode(data).toString(); + } + + // ----------------------------------------------------------------------- 全角半角转换 + /** + * 半角转全角 + * + * @param input String. + * @return 全角字符串. + */ + public static String toSBC(String input) + { + return toSBC(input, null); + } + + /** + * 半角转全角 + * + * @param input String + * @param notConvertSet 不替换的字符集合 + * @return 全角字符串. + */ + public static String toSBC(String input, Set notConvertSet) + { + char[] c = input.toCharArray(); + for (int i = 0; i < c.length; i++) + { + if (null != notConvertSet && notConvertSet.contains(c[i])) + { + // 跳过不替换的字符 + continue; + } + + if (c[i] == ' ') + { + c[i] = '\u3000'; + } + else if (c[i] < '\177') + { + c[i] = (char) (c[i] + 65248); + + } + } + return new String(c); + } + + /** + * 全角转半角 + * + * @param input String. + * @return 半角字符串 + */ + public static String toDBC(String input) + { + return toDBC(input, null); + } + + /** + * 替换全角为半角 + * + * @param text 文本 + * @param notConvertSet 不替换的字符集合 + * @return 替换后的字符 + */ + public static String toDBC(String text, Set notConvertSet) + { + char[] c = text.toCharArray(); + for (int i = 0; i < c.length; i++) + { + if (null != notConvertSet && notConvertSet.contains(c[i])) + { + // 跳过不替换的字符 + continue; + } + + if (c[i] == '\u3000') + { + c[i] = ' '; + } + else if (c[i] > '\uFF00' && c[i] < '\uFF5F') + { + c[i] = (char) (c[i] - 65248); + } + } + String returnString = new String(c); + + return returnString; + } + + /** + * 数字金额大写转换 先写个完整的然后将如零拾替换成零 + * + * @param n 数字 + * @return 中文大写数字 + */ + public static String digitUppercase(double n) + { + String[] fraction = { "角", "分" }; + String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; + String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } }; + + String head = n < 0 ? "负" : ""; + n = Math.abs(n); + + String s = ""; + for (int i = 0; i < fraction.length; i++) + { + // 优化double计算精度丢失问题 + BigDecimal nNum = new BigDecimal(n); + BigDecimal decimal = new BigDecimal(10); + BigDecimal scale = nNum.multiply(decimal).setScale(2, RoundingMode.HALF_EVEN); + double d = scale.doubleValue(); + s += (digit[(int) (Math.floor(d * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", ""); + } + if (s.length() < 1) + { + s = "整"; + } + int integerPart = (int) Math.floor(n); + + for (int i = 0; i < unit[0].length && integerPart > 0; i++) + { + String p = ""; + for (int j = 0; j < unit[1].length && n > 0; j++) + { + p = digit[integerPart % 10] + unit[1][j] + p; + integerPart = integerPart / 10; + } + s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s; + } + return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整"); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/core/text/StrFormatter.java b/box-common/src/main/java/com/mathvision/box/common/core/text/StrFormatter.java new file mode 100644 index 0000000..96b11c3 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/core/text/StrFormatter.java @@ -0,0 +1,93 @@ +package com.mathvision.box.common.core.text; + + +import com.mathvision.box.common.utils.common.StringUtils; + +/** + * 字符串格式化 + * + * @author ruoyi + */ +public class StrFormatter +{ + public static final String EMPTY_JSON = "{}"; + public static final char C_BACKSLASH = '\\'; + public static final char C_DELIM_START = '{'; + public static final char C_DELIM_END = '}'; + + /** + * 格式化字符串
+ * 此方法只是简单将占位符 {} 按照顺序替换为参数
+ * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
+ * 例:
+ * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
+ * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
+ * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
+ * + * @param strPattern 字符串模板 + * @param argArray 参数列表 + * @return 结果 + */ + public static String format(final String strPattern, final Object... argArray) + { + if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) + { + return strPattern; + } + final int strPatternLength = strPattern.length(); + + // 初始化定义好的长度以获得更好的性能 + StringBuilder sbuf = new StringBuilder(strPatternLength + 50); + + int handledPosition = 0; + int delimIndex;// 占位符所在位置 + for (int argIndex = 0; argIndex < argArray.length; argIndex++) + { + delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition); + if (delimIndex == -1) + { + if (handledPosition == 0) + { + return strPattern; + } + else + { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果 + sbuf.append(strPattern, handledPosition, strPatternLength); + return sbuf.toString(); + } + } + else + { + if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) + { + if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) + { + // 转义符之前还有一个转义符,占位符依旧有效 + sbuf.append(strPattern, handledPosition, delimIndex - 1); + sbuf.append(Convert.utf8Str(argArray[argIndex])); + handledPosition = delimIndex + 2; + } + else + { + // 占位符被转义 + argIndex--; + sbuf.append(strPattern, handledPosition, delimIndex - 1); + sbuf.append(C_DELIM_START); + handledPosition = delimIndex + 1; + } + } + else + { + // 正常占位符 + sbuf.append(strPattern, handledPosition, delimIndex); + sbuf.append(Convert.utf8Str(argArray[argIndex])); + handledPosition = delimIndex + 2; + } + } + } + // 加入最后一个占位符后所有的字符 + sbuf.append(strPattern, handledPosition, strPattern.length()); + + return sbuf.toString(); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/enums/ConfigEnum.java b/box-common/src/main/java/com/mathvision/box/common/enums/ConfigEnum.java new file mode 100644 index 0000000..fb13406 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/enums/ConfigEnum.java @@ -0,0 +1,29 @@ +package com.mathvision.box.common.enums; + +public enum ConfigEnum { + ADMIN_USER_ID("1", "管理员用户ID"), + DEFAULT_ROLE_ID("3", "默认角色ID"), + DEFAULT_ORGANIZATION_ID("1", "总公司"), + DEFAULT_ROLE_IDS("1,2,3", "默认角色ID"), + ; + + + private final String data; + private final String desc; + + ConfigEnum(String data, String desc) + { + this.data = data; + this.desc = desc; + } + + public String getData() + { + return data; + } + + public String getDesc() + { + return desc; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/enums/DefectStatusEnum.java b/box-common/src/main/java/com/mathvision/box/common/enums/DefectStatusEnum.java new file mode 100644 index 0000000..ec43150 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/enums/DefectStatusEnum.java @@ -0,0 +1,23 @@ +package com.mathvision.box.common.enums; + +public enum DefectStatusEnum { + unprocessed("0", "已完成/未处理"), + processed("1", "已处理"), + unfinished("2", "未完成"); + + private final String code; + private final String info; + + DefectStatusEnum(String code, String info) { + this.code = code; + this.info = info; + } + + public String getCode() { + return code; + } + + public String getInfo() { + return info; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/enums/DetectStatusEnum.java b/box-common/src/main/java/com/mathvision/box/common/enums/DetectStatusEnum.java new file mode 100644 index 0000000..48b577c --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/enums/DetectStatusEnum.java @@ -0,0 +1,26 @@ +package com.mathvision.box.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum DetectStatusEnum { + info("0", "正常"), + alert("1", "异常"), + fix("2", "修正"), + NULL("", "") + ; + + private final String code; + private final String description; + + public static DetectStatusEnum getStatus(String code){ + for (DetectStatusEnum status: DetectStatusEnum.values() ) { + if (status.code.equals(code) || status.name().equals(code)){ + return status; + } + } + return NULL; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/enums/DeviceStatus.java b/box-common/src/main/java/com/mathvision/box/common/enums/DeviceStatus.java new file mode 100644 index 0000000..ff11ad1 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/enums/DeviceStatus.java @@ -0,0 +1,5 @@ +package com.mathvision.box.common.enums; + +public enum DeviceStatus { + ready, online, offline, error;//, working +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/enums/RecordType.java b/box-common/src/main/java/com/mathvision/box/common/enums/RecordType.java new file mode 100644 index 0000000..60c540c --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/enums/RecordType.java @@ -0,0 +1,24 @@ +package com.mathvision.box.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +@Getter +@AllArgsConstructor +public enum RecordType { + alarm("告警", true), device("设备", true), message("消息", true), capture("图片",false), page("页面", false), config("配置", false); + + private final String desc; + private final boolean isQueryable; + + public static RecordType getByName(String type) { + return Arrays.stream(RecordType.values()).filter(x -> x.name().equals(type)).findFirst().orElse(null); + } + + @Override + public String toString() { + return desc; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/enums/SexEnum.java b/box-common/src/main/java/com/mathvision/box/common/enums/SexEnum.java new file mode 100644 index 0000000..967641a --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/enums/SexEnum.java @@ -0,0 +1,29 @@ +package com.mathvision.box.common.enums; + +/** + * @Author: fy + * @Date: 2024/04/02 + * @Description: + */ +public enum SexEnum { + MAN("0", "男"), WOMAN("1", "女"), UNKNOWN("2", "未知"); + + private final String code; + private final String info; + + SexEnum(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/CustomException.java b/box-common/src/main/java/com/mathvision/box/common/exception/CustomException.java new file mode 100644 index 0000000..5970e34 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/CustomException.java @@ -0,0 +1,41 @@ +package com.mathvision.box.common.exception; + +/** + * 自定义异常 + */ +public class CustomException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + private Integer code; + + private String message; + + public CustomException(String message) + { + this.message = message; + } + + public CustomException(String message, Integer code) + { + this.message = message; + this.code = code; + } + + public CustomException(String message, Throwable e) + { + super(message, e); + this.message = message; + } + + @Override + public String getMessage() + { + return message; + } + + public Integer getCode() + { + return code; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/DemoModeException.java b/box-common/src/main/java/com/mathvision/box/common/exception/DemoModeException.java new file mode 100644 index 0000000..3d79659 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/DemoModeException.java @@ -0,0 +1,13 @@ +package com.mathvision.box.common.exception; + +/** + * 演示模式异常 + */ +public class DemoModeException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + public DemoModeException() + { + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/GlobalException.java b/box-common/src/main/java/com/mathvision/box/common/exception/GlobalException.java new file mode 100644 index 0000000..6cde8cd --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/GlobalException.java @@ -0,0 +1,56 @@ +package com.mathvision.box.common.exception; + +/** + * 全局异常 + */ +public class GlobalException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + /** + * 错误提示 + */ + private String message; + + /** + * 错误明细,内部调试错误 + * + * 和 {@link CommonResult#getDetailMessage()} 一致的设计 + */ + private String detailMessage; + + /** + * 空构造方法,避免反序列化问题 + */ + public GlobalException() + { + } + + public GlobalException(String message) + { + this.message = message; + } + + public String getDetailMessage() + { + return detailMessage; + } + + public GlobalException setDetailMessage(String detailMessage) + { + this.detailMessage = detailMessage; + return this; + } + + @Override + public String getMessage() + { + return message; + } + + public GlobalException setMessage(String message) + { + this.message = message; + return this; + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/ServiceException.java b/box-common/src/main/java/com/mathvision/box/common/exception/ServiceException.java new file mode 100644 index 0000000..edcda58 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/ServiceException.java @@ -0,0 +1,56 @@ +package com.mathvision.box.common.exception; + +/** + * 业务异常 + */ +public final class ServiceException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + /** + * 错误提示 + */ + private String message; + + /** + * 错误明细,内部调试错误 + * + * 和 {@link CommonResult#getDetailMessage()} 一致的设计 + */ + private String detailMessage; + + /** + * 空构造方法,避免反序列化问题 + */ + public ServiceException() + { + } + + public ServiceException(String message) + { + this.message = message; + } + + public String getDetailMessage() + { + return detailMessage; + } + + public ServiceException setDetailMessage(String detailMessage) + { + this.detailMessage = detailMessage; + return this; + } + + @Override + public String getMessage() + { + return message; + } + + public ServiceException setMessage(String message) + { + this.message = message; + return this; + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/UtilException.java b/box-common/src/main/java/com/mathvision/box/common/exception/UtilException.java new file mode 100644 index 0000000..7b0cb65 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/UtilException.java @@ -0,0 +1,24 @@ +package com.mathvision.box.common.exception; + +/** + * 工具类异常 + */ +public class UtilException extends RuntimeException +{ + private static final long serialVersionUID = 8247610319171014183L; + + public UtilException(Throwable e) + { + super(e.getMessage(), e); + } + + public UtilException(String message) + { + super(message); + } + + public UtilException(String message, Throwable throwable) + { + super(message, throwable); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/base/BaseException.java b/box-common/src/main/java/com/mathvision/box/common/exception/base/BaseException.java new file mode 100644 index 0000000..e169b8c --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/base/BaseException.java @@ -0,0 +1,21 @@ +package com.mathvision.box.common.exception.base; + +import com.mathvision.box.common.core.domain.Result; +import lombok.Getter; + +/** + * @Author: fy + * @Date: 2024/03/21 + * @Description:通用异常 + */ +@Getter +public class BaseException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + private final Result result; + + public BaseException(Result result) { + this.result = result; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/box/BoxException.java b/box-common/src/main/java/com/mathvision/box/common/exception/box/BoxException.java new file mode 100644 index 0000000..9fd61ad --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/box/BoxException.java @@ -0,0 +1,19 @@ +package com.mathvision.box.common.exception.box; + + +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.domain.ResultCode; +import com.mathvision.box.common.exception.base.BaseException; + +public class BoxException extends BaseException { + private static final long serialVersionUID = 1L; + + public BoxException(String code, Object[] args) { + super(new Result(Integer.parseInt(code), "[BoxException]:" + args.toString())); + } + + public BoxException(String msg) { + super(new Result( ResultCode.operate_failure.getCode() , "[BoxException]:" + msg)); + } + +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/file/FileException.java b/box-common/src/main/java/com/mathvision/box/common/exception/file/FileException.java new file mode 100644 index 0000000..7f06bdc --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/file/FileException.java @@ -0,0 +1,17 @@ +package com.mathvision.box.common.exception.file; + + +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.exception.base.BaseException; + +/** + * 文件信息异常类 + */ +public class FileException extends BaseException { + private static final long serialVersionUID = 1L; + + public FileException(String code, Object[] args) { + super(new Result(Integer.parseInt(code), "[FileException]:" + args.toString())); + } + +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/file/FileNameLengthLimitExceededException.java b/box-common/src/main/java/com/mathvision/box/common/exception/file/FileNameLengthLimitExceededException.java new file mode 100644 index 0000000..26b8959 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/file/FileNameLengthLimitExceededException.java @@ -0,0 +1,13 @@ +package com.mathvision.box.common.exception.file; + +/** + * 文件名称超长限制异常类 + * + */ +public class FileNameLengthLimitExceededException extends FileException { + private static final long serialVersionUID = 1L; + + public FileNameLengthLimitExceededException(int defaultFileNameLength) { + super("upload.filename.exceed.length", new Object[]{defaultFileNameLength}); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/file/FileSizeLimitExceededException.java b/box-common/src/main/java/com/mathvision/box/common/exception/file/FileSizeLimitExceededException.java new file mode 100644 index 0000000..fb7b4e9 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/file/FileSizeLimitExceededException.java @@ -0,0 +1,14 @@ +package com.mathvision.box.common.exception.file; + +/** + * 文件名大小限制异常类 + */ +public class FileSizeLimitExceededException extends FileException +{ + private static final long serialVersionUID = 1L; + + public FileSizeLimitExceededException(long defaultMaxSize) + { + super("upload.exceed.maxSize", new Object[] { defaultMaxSize }); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/file/FileUploadException.java b/box-common/src/main/java/com/mathvision/box/common/exception/file/FileUploadException.java new file mode 100644 index 0000000..15ecdbf --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/file/FileUploadException.java @@ -0,0 +1,59 @@ +package com.mathvision.box.common.exception.file; + +import java.io.PrintStream; +import java.io.PrintWriter; + +/** + * 文件上传异常类 + */ +public class FileUploadException extends Exception +{ + + private static final long serialVersionUID = 1L; + + private final Throwable cause; + + public FileUploadException() + { + this(null, null); + } + + public FileUploadException(final String msg) + { + this(msg, null); + } + + public FileUploadException(String msg, Throwable cause) + { + super(msg); + this.cause = cause; + } + + @Override + public void printStackTrace(PrintStream stream) + { + super.printStackTrace(stream); + if (cause != null) + { + stream.println("Caused by:"); + cause.printStackTrace(stream); + } + } + + @Override + public void printStackTrace(PrintWriter writer) + { + super.printStackTrace(writer); + if (cause != null) + { + writer.println("Caused by:"); + cause.printStackTrace(writer); + } + } + + @Override + public Throwable getCause() + { + return cause; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/file/InvalidExtensionException.java b/box-common/src/main/java/com/mathvision/box/common/exception/file/InvalidExtensionException.java new file mode 100644 index 0000000..4f69917 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/file/InvalidExtensionException.java @@ -0,0 +1,78 @@ +package com.mathvision.box.common.exception.file; + +import java.util.Arrays; + +/** + * 文件上传 误异常类 + */ +public class InvalidExtensionException extends FileUploadException +{ + private static final long serialVersionUID = 1L; + + private String[] allowedExtension; + private String extension; + private String filename; + + public InvalidExtensionException(String[] allowedExtension, String extension, String filename) + { + super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传" + Arrays.toString(allowedExtension) + "格式"); + this.allowedExtension = allowedExtension; + this.extension = extension; + this.filename = filename; + } + + public String[] getAllowedExtension() + { + return allowedExtension; + } + + public String getExtension() + { + return extension; + } + + public String getFilename() + { + return filename; + } + + public static class InvalidImageExtensionException extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) + { + super(allowedExtension, extension, filename); + } + } + + public static class InvalidFlashExtensionException extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) + { + super(allowedExtension, extension, filename); + } + } + + public static class InvalidMediaExtensionException extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) + { + super(allowedExtension, extension, filename); + } + } + + public static class InvalidVideoExtensionException extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) + { + super(allowedExtension, extension, filename); + } + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/user/BlackListException.java b/box-common/src/main/java/com/mathvision/box/common/exception/user/BlackListException.java new file mode 100644 index 0000000..f45084c --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/user/BlackListException.java @@ -0,0 +1,14 @@ +package com.mathvision.box.common.exception.user; + +/** + * 黑名单IP异常类 + */ +public class BlackListException extends UserException +{ + private static final long serialVersionUID = 1L; + + public BlackListException() + { + super("login.blocked", null); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/user/CaptchaException.java b/box-common/src/main/java/com/mathvision/box/common/exception/user/CaptchaException.java new file mode 100644 index 0000000..6e27dfb --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/user/CaptchaException.java @@ -0,0 +1,16 @@ +package com.mathvision.box.common.exception.user; + +/** + * 验证码错误异常类 + * + * @author ruoyi + */ +public class CaptchaException extends UserException +{ + private static final long serialVersionUID = 1L; + + public CaptchaException() + { + super("user.jcaptcha.error", null); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/user/RoleBlockedException.java b/box-common/src/main/java/com/mathvision/box/common/exception/user/RoleBlockedException.java new file mode 100644 index 0000000..3d63681 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/user/RoleBlockedException.java @@ -0,0 +1,14 @@ +package com.mathvision.box.common.exception.user; + +/** + * 角色锁定异常类 + */ +public class RoleBlockedException extends UserException +{ + private static final long serialVersionUID = 1L; + + public RoleBlockedException() + { + super("role.blocked", null); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/user/UserBlockedException.java b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserBlockedException.java new file mode 100644 index 0000000..66eb3f7 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserBlockedException.java @@ -0,0 +1,14 @@ +package com.mathvision.box.common.exception.user; + +/** + * 用户锁定异常类 + */ +public class UserBlockedException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserBlockedException() + { + super("user.blocked", null); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/user/UserDeleteException.java b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserDeleteException.java new file mode 100644 index 0000000..eba8d9a --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserDeleteException.java @@ -0,0 +1,14 @@ +package com.mathvision.box.common.exception.user; + +/** + * 用户账号已被删除 + */ +public class UserDeleteException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserDeleteException() + { + super("user.password.delete", null); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/user/UserException.java b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserException.java new file mode 100644 index 0000000..eb48cb6 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserException.java @@ -0,0 +1,16 @@ +package com.mathvision.box.common.exception.user; + + +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.exception.base.BaseException; + +/** + * 用户信息异常类 + */ +public class UserException extends BaseException { + private static final long serialVersionUID = 1L; + + public UserException(String code, Object[] args) { + super(new Result(Integer.parseInt(code), "[UserException]:" + args.toString())); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/user/UserNotExistsException.java b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserNotExistsException.java new file mode 100644 index 0000000..53e0292 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserNotExistsException.java @@ -0,0 +1,14 @@ +package com.mathvision.box.common.exception.user; + +/** + * 用户不存在异常类 + */ +public class UserNotExistsException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserNotExistsException() + { + super("user.not.exists", null); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/user/UserPasswordNotMatchException.java b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserPasswordNotMatchException.java new file mode 100644 index 0000000..26ab6bc --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserPasswordNotMatchException.java @@ -0,0 +1,14 @@ +package com.mathvision.box.common.exception.user; + +/** + * 用户密码不正确或不符合规范异常类 + */ +public class UserPasswordNotMatchException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserPasswordNotMatchException() + { + super("user.password.not.match", null); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/user/UserPasswordRetryLimitCountException.java b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserPasswordRetryLimitCountException.java new file mode 100644 index 0000000..ec34c54 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserPasswordRetryLimitCountException.java @@ -0,0 +1,14 @@ +package com.mathvision.box.common.exception.user; + +/** + * 用户错误记数异常类 + */ +public class UserPasswordRetryLimitCountException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserPasswordRetryLimitCountException(int retryLimitCount) + { + super("user.password.retry.limit.count", new Object[] { retryLimitCount }); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/exception/user/UserPasswordRetryLimitExceedException.java b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserPasswordRetryLimitExceedException.java new file mode 100644 index 0000000..f168cc8 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/exception/user/UserPasswordRetryLimitExceedException.java @@ -0,0 +1,14 @@ +package com.mathvision.box.common.exception.user; + +/** + * 用户错误最大次数异常类 + */ +public class UserPasswordRetryLimitExceedException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserPasswordRetryLimitExceedException(int retryLimitCount) + { + super("user.password.retry.limit.exceed", new Object[] { retryLimitCount }); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/aes/AesEncryptUtil.java b/box-common/src/main/java/com/mathvision/box/common/utils/aes/AesEncryptUtil.java new file mode 100644 index 0000000..782bb2a --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/aes/AesEncryptUtil.java @@ -0,0 +1,250 @@ +package com.mathvision.box.common.utils.aes; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.codec.binary.Hex; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +/** + * @Author: fy + * @Description:AES 加/解密工具类 + * 使用密钥时请使用 initKey() 方法来生成随机密钥 + * initKey 方法内部使用 java.crypto.KeyGenerator 密钥生成器来生成特定于 AES 算法参数集的随机密钥 + */ + +@Slf4j +public class AesEncryptUtil { + + private AesEncryptUtil() { + } + + /** + * 密钥算法类型 + */ + public static final String KEY_ALGORITHM = "AES"; + + /** + * 密钥的默认位长度 + */ + public static final int DEFAULT_KEY_SIZE = 128; + + /** + * 密钥类型 Utf8 Base64 Hex + */ + public static final String keyType = "Utf8"; + + /** + * 加解密算法/工作模式/填充方式 + */ + private static final String ECB_PKCS_5_PADDING = "AES/ECB/PKCS5Padding"; + public static final String ECB_NO_PADDING = "AES/ECB/NoPadding"; + + public static String base64Encode(byte[] bytes) { + return Base64.encodeBase64String(bytes); + } + + public static byte[] base64Decode(String base64Code) { + return Base64.decodeBase64(base64Code); + } + + public static byte[] aesEncryptToBytes(String content, String hexAesKey) throws Exception { + return encrypt(content.getBytes(StandardCharsets.UTF_8), Hex.decodeHex(hexAesKey.toCharArray())); + } + + /** + * 加密 + * + * @param content 待加密内容 + * @param hexAesKey 密钥 + * @return String 加密后的密文 + */ + public static String aesEncrypt(String content, String hexAesKey) throws Exception { + return base64Encode(aesEncryptToBytes(content, hexAesKey)); + } + + public static String aesDecryptByBytes(byte[] encryptBytes, String hexAesKey) throws Exception { + byte[] decrypt = decrypt(encryptBytes, Hex.decodeHex(hexAesKey.toCharArray())); + return new String(decrypt, StandardCharsets.UTF_8); + } + + /** + * 解密 + * + * @param encryptStr 密文 + * @param hexAesKey 密钥 + * @return String 明文 + */ + public static String aesDecrypt(String encryptStr, String hexAesKey) throws Exception { + return aesDecryptByBytes(base64Decode(encryptStr), hexAesKey); + } + + + /** + * 生成 Hex 格式默认长度的随机密钥 + * 字符串长度为 32,解二进制后为 16 个字节 + * + * @return String Hex 格式的随机密钥 + */ + public static String initHexKey() { + return Hex.encodeHexString(initKey()); + } + + /** + * 生成默认长度的随机密钥 + * 默认长度为 128 + * + * @return byte[] 二进制密钥 + */ + public static byte[] initKey() { + return initKey(DEFAULT_KEY_SIZE); + } + + /** + * 生成密钥 + * 128、192、256 可选 + * + * @param keySize 密钥长度 + * @return byte[] 二进制密钥 + */ + public static byte[] initKey(int keySize) { + // AES 要求密钥长度为 128 位、192 位或 256 位 + if (keySize != 128 && keySize != 192 && keySize != 256) { + throw new RuntimeException("error keySize: " + keySize); + } + // 实例化 + KeyGenerator keyGenerator; + try { + keyGenerator = KeyGenerator.getInstance(KEY_ALGORITHM); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("no such algorithm exception: " + KEY_ALGORITHM, e); + } + keyGenerator.init(keySize); + // 生成秘密密钥 + SecretKey secretKey = keyGenerator.generateKey(); + // 获得密钥的二进制编码形式 + return secretKey.getEncoded(); + } + + /** + * 转换密钥 + * + * @param key 二进制密钥 + * @return Key 密钥 + */ + private static Key toKey(byte[] key) { + // 实例化 DES 密钥材料 + return new SecretKeySpec(key, KEY_ALGORITHM); + } + + /** + * 加密 + * + * @param data 待加密数据 + * @param key 密钥 + * @return byte[] 加密的数据 + */ + public static byte[] encrypt(byte[] data, byte[] key) { + return encrypt(data, key, ECB_PKCS_5_PADDING); + } + + /** + * 加密 + * + * @param data 待加密数据 + * @param key 密钥 + * @param cipherAlgorithm 算法/工作模式/填充模式 + * @return byte[] 加密的数据 + */ + public static byte[] encrypt(byte[] data, byte[] key, final String cipherAlgorithm) { + // 还原密钥 + Key k = toKey(key); + try { + Cipher cipher = Cipher.getInstance(cipherAlgorithm); + // 初始化,设置为加密模式 + cipher.init(Cipher.ENCRYPT_MODE, k); + + // 发现使用 NoPadding 时,使用 ZeroPadding 填充 + if (ECB_NO_PADDING.equals(cipherAlgorithm)) { + return cipher.doFinal(formatWithZeroPadding(data, cipher.getBlockSize())); + } + + // 执行操作 + return cipher.doFinal(data); + } catch (Exception e) { + throw new RuntimeException("AES encrypt error", e); + } + } + + /** + * 解密 + * + * @param data 待解密数据 + * @param key 密钥 + * @return byte[] 解密的数据 + */ + public static byte[] decrypt(byte[] data, byte[] key) { + return decrypt(data, key, ECB_PKCS_5_PADDING); + } + + /** + * 解密 + * + * @param data 待解密数据 + * @param key 密钥 + * @param cipherAlgorithm 算法/工作模式/填充模式 + * @return byte[] 解密的数据 + */ + public static byte[] decrypt(byte[] data, byte[] key, final String cipherAlgorithm) { + // 还原密钥 + Key k = toKey(key); + try { + Cipher cipher = Cipher.getInstance(cipherAlgorithm); + // 初始化,设置为解密模式 + cipher.init(Cipher.DECRYPT_MODE, k); + + // 发现使用 NoPadding 时,使用 ZeroPadding 填充 + if (ECB_NO_PADDING.equals(cipherAlgorithm)) { + return removeZeroPadding(cipher.doFinal(data), cipher.getBlockSize()); + } + + // 执行操作 + return cipher.doFinal(data); + } catch (Exception e) { + throw new RuntimeException("AES解码失败", e); + } + } + + private static byte[] formatWithZeroPadding(byte[] data, final int blockSize) { + final int length = data.length; + final int remainLength = length % blockSize; + + if (remainLength > 0) { + byte[] inputData = new byte[length + blockSize - remainLength]; + System.arraycopy(data, 0, inputData, 0, length); + return inputData; + } + return data; + } + + private static byte[] removeZeroPadding(byte[] data, final int blockSize) { + final int length = data.length; + final int remainLength = length % blockSize; + if (remainLength == 0) { + // 解码后的数据正好是块大小的整数倍,说明可能存在补 0 的情况,去掉末尾所有的 0 + int i = length - 1; + while (i >= 0 && 0 == data[i]) { + i--; + } + byte[] outputData = new byte[i + 1]; + System.arraycopy(data, 0, outputData, 0, outputData.length); + return outputData; + } + return data; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/bean/BeanUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/bean/BeanUtils.java new file mode 100644 index 0000000..333338e --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/bean/BeanUtils.java @@ -0,0 +1,104 @@ +package com.mathvision.box.common.utils.bean; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @Author: fy + * @Date: 2024/03/25 + * @Description: Bean 工具类 + */ +public class BeanUtils extends org.springframework.beans.BeanUtils { + /** + * Bean方法名中属性名开始的下标 + */ + private static final int BEAN_METHOD_PROP_INDEX = 3; + + /** + * 匹配getter方法的正则表达式 + */ + private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)"); + + /** + * 匹配setter方法的正则表达式 + */ + private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)"); + + /** + * Bean属性复制工具方法。 + * + * @param dest 目标对象 + * @param src 源对象 + */ + public static void copyBeanProp(Object dest, Object src) { + try { + copyProperties(src, dest); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 获取对象的setter方法。 + * + * @param obj 对象 + * @return 对象的setter方法列表 + */ + public static List getSetterMethods(Object obj) { + // setter方法列表 + List setterMethods = new ArrayList(); + + // 获取所有方法 + Method[] methods = obj.getClass().getMethods(); + + // 查找setter方法 + + for (Method method : methods) { + Matcher m = SET_PATTERN.matcher(method.getName()); + if (m.matches() && (method.getParameterTypes().length == 1)) { + setterMethods.add(method); + } + } + // 返回setter方法列表 + return setterMethods; + } + + /** + * 获取对象的getter方法。 + * + * @param obj 对象 + * @return 对象的getter方法列表 + */ + + public static List getGetterMethods(Object obj) { + // getter方法列表 + List getterMethods = new ArrayList(); + // 获取所有方法 + Method[] methods = obj.getClass().getMethods(); + // 查找getter方法 + for (Method method : methods) { + Matcher m = GET_PATTERN.matcher(method.getName()); + if (m.matches() && (method.getParameterTypes().length == 0)) { + getterMethods.add(method); + } + } + // 返回getter方法列表 + return getterMethods; + } + + /** + * 检查Bean方法名中的属性名是否相等。
+ * 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。 + * + * @param m1 方法名1 + * @param m2 方法名2 + * @return 属性名一样返回true,否则返回false + */ + + public static boolean isMethodPropEquals(String m1, String m2) { + return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX)); + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/common/BigDecimalUtil.java b/box-common/src/main/java/com/mathvision/box/common/utils/common/BigDecimalUtil.java new file mode 100644 index 0000000..1bd2971 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/common/BigDecimalUtil.java @@ -0,0 +1,142 @@ +package com.mathvision.box.common.utils.common; + +import java.math.BigDecimal; + +/** + * @description 提供精确的浮点数运算(包括加 、 减 、 乘 、 除 、 四舍五入)工具类 + */ +public class BigDecimalUtil { + + // 除法运算默认精度 + private static final int DEF_DIV_SCALE = 10; + + private BigDecimalUtil() { + + } + + /** + * 精确加法 + */ + public static double add(double value1, double value2) { + BigDecimal b1 = BigDecimal.valueOf(value1); + BigDecimal b2 = BigDecimal.valueOf(value2); + return b1.add(b2).doubleValue(); + } + + /** + * 精确加法 + */ + public static double add(String value1, String value2) { + BigDecimal b1 = new BigDecimal(value1); + BigDecimal b2 = new BigDecimal(value2); + return b1.add(b2).doubleValue(); + } + + /** + * 精确减法 + */ + public static double sub(double value1, double value2) { + BigDecimal b1 = BigDecimal.valueOf(value1); + BigDecimal b2 = BigDecimal.valueOf(value2); + return b1.subtract(b2).doubleValue(); + } + + /** + * 精确减法 + */ + public static double sub(String value1, String value2) { + BigDecimal b1 = new BigDecimal(value1); + BigDecimal b2 = new BigDecimal(value2); + return b1.subtract(b2).doubleValue(); + } + + /** + * 精确乘法 + */ + public static double mul(double value1, double value2) { + BigDecimal b1 = BigDecimal.valueOf(value1); + BigDecimal b2 = BigDecimal.valueOf(value2); + return b1.multiply(b2).doubleValue(); + } + + /** + * 精确乘法 + */ + public static double mul(String value1, String value2) { + BigDecimal b1 = new BigDecimal(value1); + BigDecimal b2 = new BigDecimal(value2); + return b1.multiply(b2).doubleValue(); + } + + /** + * 精确除法 使用默认精度 + */ + public static double div(double value1, double value2) throws IllegalAccessException { + return div(value1, value2, DEF_DIV_SCALE); + } + + /** + * 精确除法 使用默认精度 + */ + public static double div(String value1, String value2) throws IllegalAccessException { + return div(value1, value2, DEF_DIV_SCALE); + } + + /** + * 精确除法 + * + * @param scale 精度 + */ + public static double div(double value1, double value2, int scale) throws IllegalAccessException { + if (scale < 0) { + throw new IllegalAccessException("精确度不能小于0"); + } + BigDecimal b1 = BigDecimal.valueOf(value1); + BigDecimal b2 = BigDecimal.valueOf(value2); + // return b1.divide(b2, scale).doubleValue(); + return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + /** + * 精确除法 + * + * @param scale 精度 + */ + public static double div(String value1, String value2, int scale) throws IllegalAccessException { + if (scale < 0) { + throw new IllegalAccessException("精确度不能小于0"); + } + BigDecimal b1 = new BigDecimal(value1); + BigDecimal b2 = new BigDecimal(value2); + // return b1.divide(b2, scale).doubleValue(); + return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + /** + * 四舍五入 + * + * @param scale 小数点后保留几位 + */ + public static double round(double v, int scale) throws IllegalAccessException { + return div(v, 1, scale); + } + + /** + * 四舍五入 + * + * @param scale 小数点后保留几位 + */ + public static double round(String v, int scale) throws IllegalAccessException { + return div(v, "1", scale); + } + + /** + * 比较大小 + */ + public static boolean equalTo(BigDecimal b1, BigDecimal b2) { + if (b1 == null || b2 == null) { + return false; + } + return 0 == b1.compareTo(b2); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/common/CMDUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/common/CMDUtils.java new file mode 100644 index 0000000..4a66cf1 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/common/CMDUtils.java @@ -0,0 +1,28 @@ +package com.mathvision.box.common.utils.common; + +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; + +@Slf4j +public class CMDUtils { + /** + * 执行命令行 + * + * @param cmd 命令行 + * @return + */ + public static boolean executeLinuxCmd(String cmd) { + try { + Process process = Runtime.getRuntime().exec(cmd); + process.waitFor(); + } catch (InterruptedException e) { + log.error("executeLinuxCmd 执行Linux命令异常:", e); + Thread.currentThread().interrupt(); + return false; + } catch (IOException e) { + log.error("获取系统命令执行环境异常", e); + } + return true; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/common/CacheUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/common/CacheUtils.java new file mode 100644 index 0000000..4b33b3d --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/common/CacheUtils.java @@ -0,0 +1,365 @@ +package com.mathvision.box.common.utils.common; + + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Cache缓存工具类 + */ +public class CacheUtils { + private static Logger logger = LoggerFactory.getLogger(CacheUtils.class); + + private static final String SYS_CACHE = "sys-cache"; + + + /** + * 全局缓存(本地),可切换成redis + */ + private static final Map> caches = new ConcurrentHashMap<>(); + + /** + * 获取SYS_CACHE缓存 + * + * @param key + * @return + */ + public static Object get(String key) { + return get(SYS_CACHE, key); + } + + /** + * 获取SYS_CACHE缓存 + * + * @param key + * @param defaultValue + * @return + */ + public static Object get(String key, Object defaultValue) { + Object value = get(SYS_CACHE, key); + return value != null ? value : defaultValue; + } + + /** + * 写入SYS_CACHE缓存 + * + * @param key + * @param value + */ + public static void put(String key, Object value) { + put(SYS_CACHE, key, value); + } + + /** + * 从SYS_CACHE缓存中移除 + * + * @param key + */ + public static void remove(String key) { + remove(SYS_CACHE, key); + } + + /** + * 获取缓存 + * + * @param cacheName + * @param key + * @return + */ + public static Object get(String cacheName, String key) { + return getCache(cacheName).get(getKey(key)); + } + + /** + * 获取缓存 + * + * @param cacheName + * @param key + * @param defaultValue + * @return + */ + public static Object get(String cacheName, String key, Object defaultValue) { + Object value = get(cacheName, key); + return value != null ? value : defaultValue; + } + + /** + * 写入缓存 + * + * @param cacheName + * @param key + * @param value + */ + public static void put(String cacheName, String key, Object value) { + if (StringUtils.isNotBlank(key) && value != null) { + getCache(cacheName).put(getKey(key), value); + } + } + + /** + * 从缓存中移除 + * + * @param cacheName + * @param key + */ + public static void remove(String cacheName, String key) { + getCache(cacheName).remove(getKey(key)); + } + + /** + * 从缓存中移除所有 + * + * @param cacheName + */ + public static void removeAll(String cacheName) { + Map cache = getCache(cacheName); + Set keys = cache.keySet(); + for (Iterator it = keys.iterator(); it.hasNext(); ) { + cache.remove(it.next()); + } + logger.info("清理缓存: {} => {}", cacheName, keys); + } + + /** + * 从缓存中移除指定key + * + * @param keys + */ + public static void removeByKeys(Set keys) { + removeByKeys(SYS_CACHE, keys); + } + + /** + * 从缓存中移除指定key + * + * @param cacheName + * @param keys + */ + public static void removeByKeys(String cacheName, Set keys) { + for (Iterator it = keys.iterator(); it.hasNext(); ) { + remove(cacheName, it.next()); + } + logger.info("清理缓存: {} => {}", cacheName, keys); + } + + /** + * 获取缓存键名 + * + * @param key + * @return + */ + private static String getKey(String key) { + return key; + } + + /** + * 获得一个Cache,没有则创建一个新的Cache。 + * + * @param cacheName + * @return + */ + public static Map getCache(String cacheName) { + return caches.computeIfAbsent(cacheName, k -> new ConcurrentHashMap<>()); + } + + public static String getNameById(String cacheName, Long id) { + if (id != null && caches.containsKey(cacheName) && caches.get(cacheName).containsKey(id.toString())) { + return CacheUtils.get(cacheName, id.toString(), "").toString(); + } + return ""; + } + + + /** + * 获取所有缓存名称 + * + * @return 缓存组 + */ + public static Set getCacheNames() { + return caches.keySet(); + } + +// private static Logger logger = LoggerFactory.getLogger(CacheUtils.class); +// +// private static CacheManager cacheManager = SpringUtils.getBean(CacheManager.class); +// +// private static final String SYS_CACHE = "sys-cache"; +// +// /** +// * 获取SYS_CACHE缓存 +// * +// * @param key +// * @return +// */ +// public static Object get(String key) +// { +// return get(SYS_CACHE, key); +// } +// +// /** +// * 获取SYS_CACHE缓存 +// * +// * @param key +// * @param defaultValue +// * @return +// */ +// public static Object get(String key, Object defaultValue) +// { +// Object value = get(key); +// return value != null ? value : defaultValue; +// } +// +// /** +// * 写入SYS_CACHE缓存 +// * +// * @param key +// * @return +// */ +// public static void put(String key, Object value) +// { +// put(SYS_CACHE, key, value); +// } +// +// /** +// * 从SYS_CACHE缓存中移除 +// * +// * @param key +// * @return +// */ +// public static void remove(String key) +// { +// remove(SYS_CACHE, key); +// } +// +// /** +// * 获取缓存 +// * +// * @param cacheName +// * @param key +// * @return +// */ +// public static Object get(String cacheName, String key) +// { +// return getCache(cacheName).get(getKey(key)); +// } +// +// /** +// * 获取缓存 +// * +// * @param cacheName +// * @param key +// * @param defaultValue +// * @return +// */ +// public static Object get(String cacheName, String key, Object defaultValue) +// { +// Object value = get(cacheName, getKey(key)); +// return value != null ? value : defaultValue; +// } +// +// /** +// * 写入缓存 +// * +// * @param cacheName +// * @param key +// * @param value +// */ +// public static void put(String cacheName, String key, Object value) +// { +// getCache(cacheName).put(getKey(key), value); +// } +// +// /** +// * 从缓存中移除 +// * +// * @param cacheName +// * @param key +// */ +// public static void remove(String cacheName, String key) +// { +// getCache(cacheName).remove(getKey(key)); +// } +// +// /** +// * 从缓存中移除所有 +// * +// * @param cacheName +// */ +// public static void removeAll(String cacheName) +// { +// Cache cache = getCache(cacheName); +// Set keys = cache.keys(); +// for (Iterator it = keys.iterator(); it.hasNext();) +// { +// cache.remove(it.next()); +// } +// logger.info("清理缓存: {} => {}", cacheName, keys); +// } +// +// /** +// * 从缓存中移除指定key +// * +// * @param keys +// */ +// public static void removeByKeys(Set keys) +// { +// removeByKeys(SYS_CACHE, keys); +// } +// +// /** +// * 从缓存中移除指定key +// * +// * @param cacheName +// * @param keys +// */ +// public static void removeByKeys(String cacheName, Set keys) +// { +// for (Iterator it = keys.iterator(); it.hasNext();) +// { +// remove(it.next()); +// } +// logger.info("清理缓存: {} => {}", cacheName, keys); +// } +// +// /** +// * 获取缓存键名 +// * +// * @param key +// * @return +// */ +// private static String getKey(String key) +// { +// return key; +// } +// +// /** +// * 获得一个Cache,没有则显示日志。 +// * +// * @param cacheName +// * @return +// */ +// public static Cache getCache(String cacheName) +// { +// Cache cache = cacheManager.getCache(cacheName); +// if (cache == null) +// { +// throw new RuntimeException("当前系统中没有定义“" + cacheName + "”这个缓存。"); +// } +// return cache; +// } +// +// /** +// * 获取所有缓存 +// * +// * @return 缓存组 +// */ +// public static String[] getCacheNames() +// { +// return ((EhCacheManager) cacheManager).getCacheManager().getCacheNames(); +// } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/common/DateUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/common/DateUtils.java new file mode 100644 index 0000000..1c94cc0 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/common/DateUtils.java @@ -0,0 +1,264 @@ +package com.mathvision.box.common.utils.common; + +import org.apache.commons.lang3.time.DateFormatUtils; + +import java.lang.management.ManagementFactory; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.*; +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:时间工具类 + */ +public class DateUtils extends org.apache.commons.lang3.time.DateUtils +{ + public static String YYYY = "yyyy"; + + public static String YYYY_MM = "yyyy-MM"; + + public static String YYYY_MM_DD = "yyyy-MM-dd"; + + public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; + + public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; + + private static String[] parsePatterns = { + "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", + "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", + "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM", + "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" + }; + + /** + * 获取当前Date型日期 + * + * @return Date() 当前日期 + */ + public static Date getNowDate() + { + return new Date(); + } + + /** + * 获取当前日期, 默认格式为yyyy-MM-dd + * + * @return String + */ + public static String getDate() + { + return dateTimeNow(YYYY_MM_DD); + } + + public static final String getTime() + { + return dateTimeNow(YYYY_MM_DD_HH_MM_SS); + } + + public static final String dateTimeNow() + { + return dateTimeNow(YYYYMMDDHHMMSS); + } + + public static final String dateTimeNow(final String format) + { + return parseDateToStr(format, new Date()); + } + + public static final String dateTime(final Date date) + { + return parseDateToStr(YYYY_MM_DD, date); + } + + public static final String parseDateToStr(final String format, final Date date) + { + return new SimpleDateFormat(format).format(date); + } + + public static final Date dateTime(final String format, final String ts) + { + try + { + return new SimpleDateFormat(format).parse(ts); + } + catch (ParseException e) + { + throw new RuntimeException(e); + } + } + + /** + * 日期路径 即年/月/日 如2018/08/08 + */ + public static final String datePath() + { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyy/MM/dd"); + } + + /** + * 日期路径 即年/月/日 如20180808 + */ + public static final String dateTime() + { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyyMMdd"); + } + + /** + * 日期型字符串转化为日期 格式 + */ + public static Date parseDate(Object str) + { + if (str == null) + { + return null; + } + try + { + return parseDate(str.toString(), parsePatterns); + } + catch (ParseException e) + { + return null; + } + } + + public static Date parseDate(String dateString, String format) + { + SimpleDateFormat dateFormat = new SimpleDateFormat(format); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + + try { + return dateFormat.parse(dateString); + } catch (ParseException e) { + return null; + } + } + + /** + * 获取服务器启动时间 + */ + public static Date getServerStartDate() + { + long time = ManagementFactory.getRuntimeMXBean().getStartTime(); + return new Date(time); + } + + /** + * 计算相差月数 + */ + public static int getMonthDiff(Date date1, Date date2) + { + Calendar c1 = Calendar.getInstance(); + Calendar c2 = Calendar.getInstance(); + c1.setTime(date1); + c2.setTime(date2); + int year1 = c1.get(Calendar.YEAR); + int year2 = c2.get(Calendar.YEAR); + int month1 = c1.get(Calendar.MONTH); + int month2 = c2.get(Calendar.MONTH); + // 获取年的差值 + int yearInterval = year1 - year2; + // 获取月数差值 + int monthInterval = month1 - month2; + int monthsDiff = yearInterval * 12 + monthInterval; + return monthsDiff; + } + + /** + * 计算相差天数 + */ + public static int differentDaysByMillisecond(Date date1, Date date2) + { + return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24))); + } + + /** + * 计算相差小时 + */ + public static long getHourDiff(Date endDate, Date startDate) + { + if (endDate == null || startDate == null) + { + return 0; + } + long diffInMillis = endDate.getTime() - startDate.getTime(); + double diffInHours = (double) diffInMillis / (1000 * 60 * 60); + //四舍五入 + return Math.round(diffInHours); + } + + /** + * 计算时间差 + * + * @param endDate 最后时间 + * @param startTime 开始时间 + * @return 时间差(天/小时/分钟) + */ + public static String timeDistance(Date endDate, Date startTime) + { + long nd = 1000 * 24 * 60 * 60; + long nh = 1000 * 60 * 60; + long nm = 1000 * 60; + // long ns = 1000; + // 获得两个时间的毫秒时间差异 + long diff = endDate.getTime() - startTime.getTime(); + // 计算差多少天 + long day = diff / nd; + // 计算差多少小时 + long hour = diff % nd / nh; + // 计算差多少分钟 + long min = diff % nd % nh / nm; + // 计算差多少秒//输出结果 + // long sec = diff % nd % nh % nm / ns; + return day + "天" + hour + "小时" + min + "分钟"; + } + + /** + * 增加 LocalDateTime ==> Date + */ + public static Date toDate(LocalDateTime temporalAccessor) + { + ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault()); + return Date.from(zdt.toInstant()); + } + + /** + * 增加 LocalDate ==> Date + */ + public static Date toDate(LocalDate temporalAccessor) + { + LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0)); + ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault()); + return Date.from(zdt.toInstant()); + } + + public static Date getDayStartTime(Date date, boolean isStart) + { + if (date == null){ + date = new Date(); + } + if (isStart){ + LocalDateTime startDateTime = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + LocalDateTime modifiedStartDateTime = startDateTime.toLocalDate().atStartOfDay(); + return Date.from(modifiedStartDateTime.atZone(ZoneId.systemDefault()).toInstant()); + }else { + LocalDateTime endDateTime = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + LocalDateTime modifiedEndDateTime = endDateTime.toLocalDate().atTime(23, 59, 59); + return Date.from(modifiedEndDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } + } + + public static boolean isWeekend(Date date) + { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); + return dayOfWeek == Calendar.SUNDAY || dayOfWeek == Calendar.SATURDAY; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/common/ExceptionUtil.java b/box-common/src/main/java/com/mathvision/box/common/utils/common/ExceptionUtil.java new file mode 100644 index 0000000..e4f8841 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/common/ExceptionUtil.java @@ -0,0 +1,40 @@ +package com.mathvision.box.common.utils.common; + + +import org.apache.commons.lang3.exception.ExceptionUtils; + +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * 错误信息处理类。 + * + */ +public class ExceptionUtil +{ + /** + * 获取exception的详细错误信息。 + */ + public static String getExceptionMessage(Throwable e) + { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw, true)); + return sw.toString(); + } + + public static String getRootErrorMessage(Exception e) + { + Throwable root = ExceptionUtils.getRootCause(e); + root = (root == null ? e : root); + if (root == null) + { + return ""; + } + String msg = root.getMessage(); + if (msg == null) + { + return "null"; + } + return StringUtils.defaultString(msg); + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/common/MD5Utils.java b/box-common/src/main/java/com/mathvision/box/common/utils/common/MD5Utils.java new file mode 100644 index 0000000..d7015cb --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/common/MD5Utils.java @@ -0,0 +1,47 @@ +package com.mathvision.box.common.utils.common; + +import org.springframework.util.DigestUtils; + +import java.security.SecureRandom; +import java.util.Base64; + +/** + * Created with IntelliJ IDEA. + * + * @Author: fy + * @Date: 2023/04/19/10:09 + * @Description:MD5密码加密 + */ +public class MD5Utils { + public static String md5(String src) { + return DigestUtils.md5DigestAsHex(src.getBytes()); + } + + //第一次加密 + public static String inputPassToFormPass(String inputPass, String salt) { + //md5加密密码前,先对密码进行处理,按以下salt的规则处理密码 + String str = "" + salt.charAt(0) + salt.charAt(2) + inputPass + salt.charAt(5) + salt.charAt(4); + return md5(str); + } + + //第二次加密 + public static String formPassToDBPass(String formPass, String salt) { + String str = "" + salt.charAt(0) + salt.charAt(2) + formPass + salt.charAt(5) + salt.charAt(4); + return md5(str); + } + + //实际调用的方法,将第一次加密和第二次加密合并,结果应该一致 + public static String inputPassToDBPass(String inputPass, String salt) { + String formPass = inputPassToFormPass(inputPass, salt); + String dbPass = formPassToDBPass(formPass, salt); + return dbPass; + } + + public static String randomSalt() { + int length = 16; + SecureRandom random = new SecureRandom(); + byte[] salt = new byte[length]; + random.nextBytes(salt); + return Base64.getEncoder().encodeToString(salt); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/common/OSUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/common/OSUtils.java new file mode 100644 index 0000000..cf8735c --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/common/OSUtils.java @@ -0,0 +1,11 @@ +package com.mathvision.box.common.utils.common; + +public class OSUtils { + public static String getOsName() { + return System.getProperty("os.name").toLowerCase(); + } + + public static boolean isWindows() { + return getOsName().contains("win"); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/common/PageUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/common/PageUtils.java new file mode 100644 index 0000000..7af22ac --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/common/PageUtils.java @@ -0,0 +1,29 @@ +package com.mathvision.box.common.utils.common; + +import com.github.pagehelper.PageHelper; +import com.mathvision.box.common.core.page.PageDomain; +import com.mathvision.box.common.core.page.TableSupport; +import com.mathvision.box.common.utils.sql.SqlUtil; + +public class PageUtils extends PageHelper { + /** + * 设置请求分页数据 + */ + public static void startPage() + { + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + Boolean reasonable = pageDomain.getReasonable(); + PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable); + } + + /** + * 清理分页的线程变量 + */ + public static void clearPage() + { + PageHelper.clearPage(); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/common/ServletUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/common/ServletUtils.java new file mode 100644 index 0000000..3d377f3 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/common/ServletUtils.java @@ -0,0 +1,230 @@ +package com.mathvision.box.common.utils.common; + +import cn.hutool.core.convert.Convert; +import com.mathvision.box.common.constant.Constants; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:客户端工具类 + */ +public class ServletUtils +{ + /** + * 定义移动端请求的所有可能类型 + */ + private final static String[] agent = { "Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser" }; + + /** + * 获取String参数 + */ + public static String getParameter(String name) + { + return getRequest().getParameter(name); + } + + /** + * 获取String参数 + */ + public static String getParameter(String name, String defaultValue) + { + return Convert.toStr(getRequest().getParameter(name), defaultValue); + } + + /** + * 获取Integer参数 + */ + public static Integer getParameterToInt(String name) + { + return Convert.toInt(getRequest().getParameter(name)); + } + + /** + * 获取Integer参数 + */ + public static Integer getParameterToInt(String name, Integer defaultValue) + { + return Convert.toInt(getRequest().getParameter(name), defaultValue); + } + + /** + * 获取Boolean参数 + */ + public static Boolean getParameterToBool(String name) + { + return Convert.toBool(getRequest().getParameter(name)); + } + + /** + * 获取Boolean参数 + */ + public static Boolean getParameterToBool(String name, Boolean defaultValue) + { + return Convert.toBool(getRequest().getParameter(name), defaultValue); + } + + /** + * 获取request + */ + public static HttpServletRequest getRequest() + { + return getRequestAttributes().getRequest(); + } + + /** + * 获取response + */ + public static HttpServletResponse getResponse() + { + return getRequestAttributes().getResponse(); + } + + /** + * 获取session + */ + public static HttpSession getSession() + { + return getRequest().getSession(); + } + + public static ServletRequestAttributes getRequestAttributes() + { + RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); + return (ServletRequestAttributes) attributes; + } + + /** + * 将字符串渲染到客户端 + * + * @param response 渲染对象 + * @param string 待渲染的字符串 + * @return null + */ + public static String renderString(HttpServletResponse response, String string) + { + try + { + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + response.getWriter().print(string); + } + catch (IOException e) + { + e.printStackTrace(); + } + return null; + } + + /** + * 是否是Ajax异步请求 + * + * @param request + */ + public static boolean isAjaxRequest(HttpServletRequest request) + { + String accept = request.getHeader("accept"); + if (accept != null && accept.contains("application/json")) + { + return true; + } + + String xRequestedWith = request.getHeader("X-Requested-With"); + if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest")) + { + return true; + } + + String uri = request.getRequestURI(); + if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) + { + return true; + } + + String ajax = request.getParameter("__ajax"); + return StringUtils.inStringIgnoreCase(ajax, "json", "xml"); + } + + /** + * 判断User-Agent 是不是来自于手机 + */ + public static boolean checkAgentIsMobile(String ua) + { + boolean flag = false; + if (!ua.contains("Windows NT") || (ua.contains("Windows NT") && ua.contains("compatible; MSIE 9.0;"))) + { + // 排除 苹果桌面系统 + if (!ua.contains("Windows NT") && !ua.contains("Macintosh")) + { + for (String item : agent) + { + if (ua.contains(item)) + { + flag = true; + break; + } + } + } + } + return flag; + } + + /** + * 内容编码 + * + * @param str 内容 + * @return 编码后的内容 + */ + public static String urlEncode(String str) + { + try + { + return URLEncoder.encode(str, Constants.UTF8); + } + catch (UnsupportedEncodingException e) + { + return StringUtils.EMPTY; + } + } + + /** + * 内容解码 + * + * @param str 内容 + * @return 解码后的内容 + */ + public static String urlDecode(String str) + { + try + { + return URLDecoder.decode(str, Constants.UTF8); + } + catch (UnsupportedEncodingException e) + { + return StringUtils.EMPTY; + } + } + + /** + * 判断当前是否通过 HTTP 请求调用 + * + * @return 如果是 HTTP 请求则返回 true,否则返回 false + */ + public static boolean isHttpRequest() { + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + if (requestAttributes == null || ! (requestAttributes instanceof ServletRequestAttributes)){ + return false; + } + return true; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/common/StringUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/common/StringUtils.java new file mode 100644 index 0000000..bfb7ac2 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/common/StringUtils.java @@ -0,0 +1,631 @@ +package com.mathvision.box.common.utils.common; + +import com.mathvision.box.common.constant.Constants; +import com.mathvision.box.common.core.text.StrFormatter; +import org.springframework.util.AntPathMatcher; + +import java.util.*; +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description: + */ + +/** + * 字符串工具类 + * + * @author ruoyi + */ +public class StringUtils extends org.apache.commons.lang3.StringUtils +{ + /** 空字符串 */ + private static final String NULLSTR = ""; + + /** 下划线 */ + private static final char SEPARATOR = '_'; + + /** + * 获取参数不为空值 + * + * @param value defaultValue 要判断的value + * @return value 返回值 + */ + public static T nvl(T value, T defaultValue) + { + return value != null ? value : defaultValue; + } + + /** + * * 判断一个Collection是否为空, 包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Collection coll) + { + return isNull(coll) || coll.isEmpty(); + } + + /** + * * 判断一个Collection是否非空,包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Collection coll) + { + return !isEmpty(coll); + } + + /** + * * 判断一个对象数组是否为空 + * + * @param objects 要判断的对象数组 + ** @return true:为空 false:非空 + */ + public static boolean isEmpty(Object[] objects) + { + return isNull(objects) || (objects.length == 0); + } + + /** + * * 判断一个对象数组是否非空 + * + * @param objects 要判断的对象数组 + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Object[] objects) + { + return !isEmpty(objects); + } + + /** + * * 判断一个Map是否为空 + * + * @param map 要判断的Map + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Map map) + { + return isNull(map) || map.isEmpty(); + } + + /** + * * 判断一个Map是否为空 + * + * @param map 要判断的Map + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Map map) + { + return !isEmpty(map); + } + + /** + * * 判断一个字符串是否为空串 + * + * @param str String + * @return true:为空 false:非空 + */ + public static boolean isEmpty(String str) + { + return isNull(str) || NULLSTR.equals(str.trim()); + } + + /** + * * 判断一个字符串是否为非空串 + * + * @param str String + * @return true:非空串 false:空串 + */ + public static boolean isNotEmpty(String str) + { + return !isEmpty(str); + } + + /** + * * 判断一个对象是否为空 + * + * @param object Object + * @return true:为空 false:非空 + */ + public static boolean isNull(Object object) + { + return object == null; + } + + /** + * * 判断一个对象是否非空 + * + * @param object Object + * @return true:非空 false:空 + */ + public static boolean isNotNull(Object object) + { + return !isNull(object); + } + + /** + * * 判断一个对象是否是数组类型(Java基本型别的数组) + * + * @param object 对象 + * @return true:是数组 false:不是数组 + */ + public static boolean isArray(Object object) + { + return isNotNull(object) && object.getClass().isArray(); + } + + /** + * 去空格 + */ + public static String trim(String str) + { + return (str == null ? "" : str.trim()); + } + + /** + * 截取字符串 + * + * @param str 字符串 + * @param start 开始 + * @return 结果 + */ + public static String substring(final String str, int start) + { + if (str == null) + { + return NULLSTR; + } + + if (start < 0) + { + start = str.length() + start; + } + + if (start < 0) + { + start = 0; + } + if (start > str.length()) + { + return NULLSTR; + } + + return str.substring(start); + } + + /** + * 截取字符串 + * + * @param str 字符串 + * @param start 开始 + * @param end 结束 + * @return 结果 + */ + public static String substring(final String str, int start, int end) + { + if (str == null) + { + return NULLSTR; + } + + if (end < 0) + { + end = str.length() + end; + } + if (start < 0) + { + start = str.length() + start; + } + + if (end > str.length()) + { + end = str.length(); + } + + if (start > end) + { + return NULLSTR; + } + + if (start < 0) + { + start = 0; + } + if (end < 0) + { + end = 0; + } + + return str.substring(start, end); + } + + /** + * 格式化文本, {} 表示占位符
+ * 此方法只是简单将占位符 {} 按照顺序替换为参数
+ * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
+ * 例:
+ * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
+ * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
+ * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
+ * + * @param template 文本模板,被替换的部分用 {} 表示 + * @param params 参数值 + * @return 格式化后的文本 + */ + public static String format(String template, Object... params) + { + if (isEmpty(params) || isEmpty(template)) + { + return template; + } + return StrFormatter.format(template, params); + } + + /** + * 是否为http(s)://开头 + * + * @param link 链接 + * @return 结果 + */ + public static boolean ishttp(String link) + { + return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS); + } + + /** + * 字符串转set + * + * @param str 字符串 + * @param sep 分隔符 + * @return set集合 + */ + public static final Set str2Set(String str, String sep) + { + return new HashSet(str2List(str, sep, true, false)); + } + + /** + * 字符串转list + * + * @param str 字符串 + * @param sep 分隔符 + * @param filterBlank 过滤纯空白 + * @param trim 去掉首尾空白 + * @return list集合 + */ + public static final List str2List(String str, String sep, boolean filterBlank, boolean trim) + { + List list = new ArrayList(); + if (StringUtils.isEmpty(str)) + { + return list; + } + + // 过滤空白字符串 + if (filterBlank && StringUtils.isBlank(str)) + { + return list; + } + String[] split = str.split(sep); + for (String string : split) + { + if (filterBlank && StringUtils.isBlank(string)) + { + continue; + } + if (trim) + { + string = string.trim(); + } + list.add(string); + } + + return list; + } + + /** + * 判断给定的collection列表中是否包含数组array 判断给定的数组array中是否包含给定的元素value + * + * @param collection 给定的集合 + * @param array 给定的数组 + * @return boolean 结果 + */ + public static boolean containsAny(Collection collection, String... array) + { + if (isEmpty(collection) || isEmpty(array)) + { + return false; + } + else + { + for (String str : array) + { + if (collection.contains(str)) + { + return true; + } + } + return false; + } + } + + /** + * 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写 + * + * @param cs 指定字符串 + * @param searchCharSequences 需要检查的字符串数组 + * @return 是否包含任意一个字符串 + */ + public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) + { + if (isEmpty(cs) || isEmpty(searchCharSequences)) + { + return false; + } + for (CharSequence testStr : searchCharSequences) + { + if (containsIgnoreCase(cs, testStr)) + { + return true; + } + } + return false; + } + + /** + * 驼峰转下划线命名 + */ + public static String toUnderScoreCase(String str) + { + if (str == null) + { + return null; + } + StringBuilder sb = new StringBuilder(); + // 前置字符是否大写 + boolean preCharIsUpperCase = true; + // 当前字符是否大写 + boolean curreCharIsUpperCase = true; + // 下一字符是否大写 + boolean nexteCharIsUpperCase = true; + for (int i = 0; i < str.length(); i++) + { + char c = str.charAt(i); + if (i > 0) + { + preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); + } + else + { + preCharIsUpperCase = false; + } + + curreCharIsUpperCase = Character.isUpperCase(c); + + if (i < (str.length() - 1)) + { + nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); + } + + if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) + { + sb.append(SEPARATOR); + } + else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) + { + sb.append(SEPARATOR); + } + sb.append(Character.toLowerCase(c)); + } + + return sb.toString(); + } + + /** + * 是否包含字符串 + * + * @param str 验证字符串 + * @param strs 字符串组 + * @return 包含返回true + */ + public static boolean inStringIgnoreCase(String str, String... strs) + { + if (str != null && strs != null) + { + for (String s : strs) + { + if (str.equalsIgnoreCase(trim(s))) + { + return true; + } + } + } + return false; + } + + /** + * 删除最后一个字符串 + * + * @param str 输入字符串 + * @param spit 以什么类型结尾的 + * @return 截取后的字符串 + */ + public static String lastStringDel(String str, String spit) + { + if (!StringUtils.isEmpty(str) && str.endsWith(spit)) + { + return str.subSequence(0, str.length() - 1).toString(); + } + return str; + } + + /** + * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld + * + * @param name 转换前的下划线大写方式命名的字符串 + * @return 转换后的驼峰式命名的字符串 + */ + public static String convertToCamelCase(String name) + { + StringBuilder result = new StringBuilder(); + // 快速检查 + if (name == null || name.isEmpty()) + { + // 没必要转换 + return ""; + } + else if (!name.contains("_")) + { + // 不含下划线,仅将首字母大写 + return name.substring(0, 1).toUpperCase() + name.substring(1); + } + // 用下划线将原始字符串分割 + String[] camels = name.split("_"); + for (String camel : camels) + { + // 跳过原始字符串中开头、结尾的下换线或双重下划线 + if (camel.isEmpty()) + { + continue; + } + // 首字母大写 + result.append(camel.substring(0, 1).toUpperCase()); + result.append(camel.substring(1).toLowerCase()); + } + return result.toString(); + } + + /** + * 驼峰式命名法 + * 例如:user_name->userName + */ + public static String toCamelCase(String s) + { + if (s == null) + { + return null; + } + if (s.indexOf(SEPARATOR) == -1) + { + return s; + } + s = s.toLowerCase(); + StringBuilder sb = new StringBuilder(s.length()); + boolean upperCase = false; + for (int i = 0; i < s.length(); i++) + { + char c = s.charAt(i); + + if (c == SEPARATOR) + { + upperCase = true; + } + else if (upperCase) + { + sb.append(Character.toUpperCase(c)); + upperCase = false; + } + else + { + sb.append(c); + } + } + return sb.toString(); + } + + /** + * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串 + * + * @param str 指定字符串 + * @param strs 需要检查的字符串数组 + * @return 是否匹配 + */ + public static boolean matches(String str, List strs) + { + if (isEmpty(str) || isEmpty(strs)) + { + return false; + } + for (String pattern : strs) + { + if (isMatch(pattern, str)) + { + return true; + } + } + return false; + } + + /** + * 判断url是否与规则配置: + * ? 表示单个字符; + * * 表示一层路径内的任意字符串,不可跨层级; + * ** 表示任意层路径; + * + * @param pattern 匹配规则 + * @param url 需要匹配的url + * @return + */ + public static boolean isMatch(String pattern, String url) + { + AntPathMatcher matcher = new AntPathMatcher(); + return matcher.match(pattern, url); + } + + @SuppressWarnings("unchecked") + public static T cast(Object obj) + { + return (T) obj; + } + + /** + * 数字左边补齐0,使之达到指定长度。注意,如果数字转换为字符串后,长度大于size,则只保留 最后size个字符。 + * + * @param num 数字对象 + * @param size 字符串指定长度 + * @return 返回数字的字符串格式,该字符串为指定长度。 + */ + public static final String padl(final Number num, final int size) + { + return padl(num.toString(), size, '0'); + } + + /** + * 字符串左补齐。如果原始字符串s长度大于size,则只保留最后size个字符。 + * + * @param s 原始字符串 + * @param size 字符串指定长度 + * @param c 用于补齐的字符 + * @return 返回指定长度的字符串,由原字符串左补齐或截取得到。 + */ + public static final String padl(final String s, final int size, final char c) + { + final StringBuilder sb = new StringBuilder(size); + if (s != null) + { + final int len = s.length(); + if (s.length() <= size) + { + for (int i = size - len; i > 0; i--) + { + sb.append(c); + } + sb.append(s); + } + else + { + return s.substring(len - size, len); + } + } + else + { + for (int i = size; i > 0; i--) + { + sb.append(c); + } + } + return sb.toString(); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/common/Threads.java b/box-common/src/main/java/com/mathvision/box/common/utils/common/Threads.java new file mode 100644 index 0000000..7333975 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/common/Threads.java @@ -0,0 +1,94 @@ +package com.mathvision.box.common.utils.common; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.*; + +/** + * 线程相关工具类. + */ +public class Threads +{ + private static final Logger logger = LoggerFactory.getLogger(Threads.class); + + /** + * sleep等待,单位为毫秒 + */ + public static void sleep(long milliseconds) + { + try + { + Thread.sleep(milliseconds); + } + catch (InterruptedException e) + { + return; + } + } + + /** + * 停止线程池 + * 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务. + * 如果超时, 则调用shutdownNow, 取消在workQueue中Pending的任务,并中断所有阻塞函数. + * 如果仍人超時,則強制退出. + * 另对在shutdown时线程本身被调用中断做了处理. + */ + public static void shutdownAndAwaitTermination(ExecutorService pool) + { + if (pool != null && !pool.isShutdown()) + { + pool.shutdown(); + try + { + if (!pool.awaitTermination(120, TimeUnit.SECONDS)) + { + pool.shutdownNow(); + if (!pool.awaitTermination(120, TimeUnit.SECONDS)) + { + logger.info("Pool did not terminate"); + } + } + } + catch (InterruptedException ie) + { + pool.shutdownNow(); + Thread.currentThread().interrupt(); + } + } + } + + /** + * 打印线程异常信息 + */ + public static void printException(Runnable r, Throwable t) + { + if (t == null && r instanceof Future) + { + try + { + Future future = (Future) r; + if (future.isDone()) + { + future.get(); + } + } + catch (CancellationException ce) + { + t = ce; + } + catch (ExecutionException ee) + { + t = ee.getCause(); + } + catch (InterruptedException ie) + { + Thread.currentThread().interrupt(); + } + } + if (t != null) + { + logger.error(t.getMessage(), t); + } + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/csv/CsvUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/csv/CsvUtils.java new file mode 100644 index 0000000..2952993 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/csv/CsvUtils.java @@ -0,0 +1,131 @@ +package com.mathvision.box.common.utils.csv; + +import com.mathvision.box.common.annotation.CsvColumn; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.file.FileUtils; +import com.opencsv.CSVWriter; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.util.ReflectionUtils; + +import java.io.FileWriter; +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Date; +import java.util.List; + +@Slf4j +public class CsvUtils { + /** + * 导出数据到 CSV 文件 + * @param data 数据列表 + * @param headers CSV 表头 + * @param fieldNames 对应的字段名 + * @param filePath 文件保存路径 + * @param 数据类型 + */ + private static void exportToCsv(List data, String[] headers, String[] fieldNames, String filePath) { + try { + FileUtils.createFile(filePath); + try (CSVWriter writer = new CSVWriter(new FileWriter(filePath))) { + // 写入表头 + writer.writeNext(headers); + + // 写入数据 + for (T item : data) { + String[] row = new String[fieldNames.length]; + for (int i = 0; i < fieldNames.length; i++) { + row[i] = getFieldValue(item, fieldNames[i]); + } + writer.writeNext(row); + } + + // 确保数据写入 + writer.flush(); + + log.info("[CsvUtils]:CSV file created successfully: {}", filePath); + } + } catch (IOException e) { + log.error("Error exporting CSV file: ", e); + throw new RuntimeException("Failed to export CSV file", e); + } + } + + /** + * 使用反射获取对象字段值 + */ + private static String getFieldValue(T item, String fieldName) { + try { + Field field = ReflectionUtils.findField(item.getClass(), fieldName); + if (field != null) { + field.setAccessible(true); + Object value = field.get(item); + if (value != null && value instanceof Date){ + return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, (Date) value); + } + return value != null ? value.toString() : ""; + } + return ""; + } catch (Exception e) { + log.error("[CsvUtils]:Error getting field value: ", e); + return ""; + } + } + + /** + * 根据注解自动导出 CSV + * @param data 数据列表 + * @param filePath 文件保存路径 + * @param 数据类型 + */ + public static void exportToCsvWithAnnotation(List data, String filePath) { + if (data.isEmpty()) { + return; + } + + Class clazz = data.get(0).getClass(); + List csvFields = getCsvFields(clazz); + + String[] headers = csvFields.stream() + .map(CsvField::getHeader) + .toArray(String[]::new); + + String[] fieldNames = csvFields.stream() + .map(CsvField::getField) + .toArray(String[]::new); + + exportToCsv(data, headers, fieldNames, filePath); + } + + /** + * 获取类中标注了 @CsvColumn 的字段信息 + */ + private static List getCsvFields(Class clazz) { + List fields = new ArrayList<>(); + ReflectionUtils.doWithFields(clazz, field -> { + CsvColumn annotation = field.getAnnotation(CsvColumn.class); + if (annotation != null) { + fields.add(new CsvField( + annotation.header(), + field.getName(), + annotation.order() + )); + } + }); + + // 按 order 排序 + fields.sort(Comparator.comparingInt(CsvField::getOrder)); + return fields; + } + + @Data + @AllArgsConstructor + private static class CsvField { + private String header; + private String field; + private int order; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/file/DiskUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/file/DiskUtils.java new file mode 100644 index 0000000..9c17a84 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/file/DiskUtils.java @@ -0,0 +1,83 @@ +package com.mathvision.box.common.utils.file; + +import com.mathvision.box.common.utils.common.OSUtils; +import lombok.extern.slf4j.Slf4j; + +import java.io.File; +import java.io.IOException; +import java.nio.file.FileStore; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +@Slf4j +public class DiskUtils { + /** + * 检查磁盘使用率 + * Windows传入盘符(如"C") + * Linux传入挂载路径(如"/data") + * + * @param path 磁盘路径 + * @throws IOException + */ + public static boolean checkDiskUsage(String path, Integer threshold) { + try { + double usage; + + if (OSUtils.isWindows()) { + usage = getWindowsDiskUsage(path); + } else { + usage = getLinuxDiskUsage(path); + } + + if (usage > threshold) { + log.error("[警告] 磁盘" + path + "使用率已达" + usage); + return true; + } else { + //log.info("[正常] 磁盘" + path + "使用率正常" + usage); + return false; + } + } catch (IOException e) { + log.error("[警告] 获取磁盘使用率失败", e); + return true; + } + } + + public static double getDiskUsage(String path) { + try { + double usage; + if (OSUtils.isWindows()) { + usage = getWindowsDiskUsage(path); + } else { + usage = getLinuxDiskUsage(path); + } + return usage; + } catch (IOException e) { + log.error("[警告] 获取磁盘使用率失败", e); + return 0d; + } + } + + + // Linux磁盘容量 + private static double getLinuxDiskUsage(String path) throws IOException { + Path targetPath = Paths.get(path); + FileStore store = Files.getFileStore(targetPath); + long total = store.getTotalSpace(); + long usable = store.getUsableSpace(); + return (total - usable) * 100.0 / total; + } + + // Windows磁盘容量 + private static double getWindowsDiskUsage(String path) throws IOException { + File file = new File(path); + for (File root : File.listRoots()) { + if (file.getAbsolutePath().startsWith(root.getAbsolutePath())) { + long total = root.getTotalSpace(); + long free = root.getFreeSpace(); + return (total - free) * 100.0 / total; + } + } + throw new IOException("路径未映射到有效磁盘: " + path); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/file/FileTypeUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/file/FileTypeUtils.java new file mode 100644 index 0000000..1a2bf85 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/file/FileTypeUtils.java @@ -0,0 +1,82 @@ +package com.mathvision.box.common.utils.file; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:文件类型工具类 + */ +@Slf4j +public class FileTypeUtils +{ + /** + * 获取文件类型 + *

+ * 例如: ruoyi.txt, 返回: txt + * + * @param file 文件名 + * @return 后缀(不含".") + */ + public static String getFileType(File file) + { + if (null == file) + { + return StringUtils.EMPTY; + } + return getFileType(file.getName()); + } + + /** + * 获取文件类型 + *

+ * 例如: ruoyi.txt, 返回: txt + * + * @param fileName 文件名 + * @return 后缀(不含".") + */ + public static String getFileType(String fileName) + { + int separatorIndex = fileName.lastIndexOf("."); + if (separatorIndex < 0) + { + return ""; + } + return fileName.substring(separatorIndex + 1).toLowerCase(); + } + + /** + * 获取文件类型 + * + * @param photoByte 文件字节码 + * @return 后缀(不含".") + */ + public static String getFileExtendName(byte[] photoByte) + { + String strFileExtendName = "JPG"; + if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56) + && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) + { + strFileExtendName = "GIF"; + } + else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70)) + { + strFileExtendName = "JPG"; + } + else if ((photoByte[0] == 66) && (photoByte[1] == 77)) + { + strFileExtendName = "BMP"; + } + else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71)) + { + strFileExtendName = "PNG"; + } + return strFileExtendName; + } + +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/file/FileUploadUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/file/FileUploadUtils.java new file mode 100644 index 0000000..315dd82 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/file/FileUploadUtils.java @@ -0,0 +1,258 @@ +package com.mathvision.box.common.utils.file; + +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.constant.Constants; +import com.mathvision.box.common.exception.file.*; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.uuid.Seq; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FilenameUtils; +import org.springframework.web.multipart.MultipartFile; + +import java.io.*; +import java.nio.ByteBuffer; +import java.nio.file.Paths; +import java.util.Objects; + +/** + * 文件上传工具类 + */ +@Slf4j +public class FileUploadUtils { + /** + * 默认大小 50M + */ + public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024; + + /** + * 默认的文件名最大长度 100 + */ + public static final int DEFAULT_FILE_NAME_LENGTH = 100; + + /** + * 默认上传的地址 + */ + private static String defaultBaseDir = AppConfig.getProfile(); + + public static void setDefaultBaseDir(String defaultBaseDir) { + FileUploadUtils.defaultBaseDir = defaultBaseDir; + } + + public static String getDefaultBaseDir() { + return defaultBaseDir; + } + + public static final String upload(ByteBuffer buffer, int dataLen, String fileName, String profile) { + if (dataLen <= 0) { + log.error("buffer数据长度无效({}),保存失败", dataLen); + return ""; + } + if (buffer.capacity() < dataLen) { + log.error("缓冲区容量不足(需要{},实际{}),保存失败", dataLen, buffer.capacity()); + return ""; + } + byte[] bytes = new byte[dataLen]; + buffer.rewind(); + buffer.get(bytes); + return upload(bytes, dataLen, fileName, profile); + } + + public static final String upload(byte[] bytes, int dataLen, String fileName, String profile) { + String newFileName = StringUtils.isNotBlank(profile) ? AppConfig.getProfile() + "/" + profile + "/" + DateUtils.datePath() + "/" + fileName : AppConfig.getUploadPath() + DateUtils.datePath() + "/" + fileName; + File file = new File(newFileName); + + // 创建文件 + if (!file.exists()) { + if (!file.getParentFile().exists()) { + if (!file.getParentFile().mkdirs()) { + log.error("无法创建目录: {}", newFileName); + } + } + try { + file.createNewFile(); + } catch (IOException e) { + log.error("创建文件失败:{}", e); + } + } + + try (FileOutputStream fout = new FileOutputStream(newFileName)) { + fout.write(bytes, 0, dataLen); + fout.close(); + return newFileName; + } catch (Exception e) { + log.error("保存失败:{}", e); + return ""; + } + } + + /** + * 以默认配置进行文件上传 + * + * @param file 上传的文件 + * @return 文件名称 + * @throws Exception + */ + public static final String upload(MultipartFile file) throws IOException { + try { + return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + } catch (Exception e) { + throw new IOException(e.getMessage(), e); + } + } + + /** + * 根据文件路径上传 + * + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 + * @return 文件名称 + * @throws IOException + */ + public static final String upload(String baseDir, MultipartFile file) throws IOException { + try { + return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + } catch (Exception e) { + throw new IOException(e.getMessage(), e); + } + } + + /** + * 文件上传 + * + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 + * @param allowedExtension 上传文件类型 + * @return 返回上传成功的文件名 + * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws FileNameLengthLimitExceededException 文件名太长 + * @throws IOException 比如读写文件出错时 + * @throws InvalidExtensionException 文件校验异常 + */ + public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) + throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, + InvalidExtensionException { + int fileNameLength = Objects.requireNonNull(file.getOriginalFilename()).length(); + if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { + throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); + } + + assertAllowed(file, allowedExtension); + + String fileName = extractFilename(file); + + String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath(); + file.transferTo(Paths.get(absPath)); + return getPathFileName(baseDir, fileName); + } + + /** + * 编码文件名 + */ + public static final String extractFilename(MultipartFile file) { + return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file)); + } + + public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException { + File desc = new File(uploadDir + File.separator + fileName); + + if (!desc.exists()) { + if (!desc.getParentFile().exists()) { + desc.getParentFile().mkdirs(); + } + } + return desc; + } + + public static final String getPathFileName(String uploadDir, String fileName) throws IOException { + int dirLastIndex = AppConfig.getProfile().length() + 1; + String currentDir = StringUtils.substring(uploadDir, dirLastIndex); + return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName; + } + + /** + * 文件大小校验 + * + * @param file 上传的文件 + * @return + * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws InvalidExtensionException + */ + public static final void assertAllowed(MultipartFile file, String[] allowedExtension) + throws FileSizeLimitExceededException, InvalidExtensionException { + long size = file.getSize(); + if (size > DEFAULT_MAX_SIZE) { + throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); + } + + String fileName = file.getOriginalFilename(); + String extension = getExtension(file); + if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) { + if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) { + throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, + fileName); + } else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) { + throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, + fileName); + } else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) { + throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, + fileName); + } else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) { + throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension, + fileName); + } else { + throw new InvalidExtensionException(allowedExtension, extension, fileName); + } + } + } + + /** + * 判断MIME类型是否是允许的MIME类型 + * + * @param extension + * @param allowedExtension + * @return + */ + public static final boolean isAllowedExtension(String extension, String[] allowedExtension) { + for (String str : allowedExtension) { + if (str.equalsIgnoreCase(extension)) { + return true; + } + } + return false; + } + + /** + * 获取文件名的后缀 + * + * @param file 表单文件 + * @return 后缀名 + */ + public static final String getExtension(MultipartFile file) { + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + if (StringUtils.isEmpty(extension)) { + extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType())); + } + return extension; + } + + /** + * 将 MultipartFile 转换为 File 并保存 + * + * @param multipartFile 上传的文件 + * @param destPath 保存的目标路径 + * @return 保存后的 File 对象 + * @throws IOException 如果在保存过程中发生错误 + */ + public static File convertMultipartFileToFile(MultipartFile multipartFile, String destPath) throws IOException { + File destFile = new File(destPath); + // 如果目标路径不存在,创建目录 + if (!destFile.getParentFile().exists()) { + destFile.getParentFile().mkdirs(); + } + multipartFile.transferTo(destFile); + return destFile; + } + + +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/file/FileUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/file/FileUtils.java new file mode 100644 index 0000000..e386d79 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/file/FileUtils.java @@ -0,0 +1,447 @@ +package com.mathvision.box.common.utils.file; + +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.uuid.IdUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.ArrayUtils; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.concurrent.TimeUnit; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:文件处理工具类 + */ +@Slf4j +public class FileUtils { + public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; + + /** + * 检查级别枚举 + */ + public enum CheckLevel { + BASIC, // 基础检查(存在性、类型) + NORMAL, // 普通检查(基础 + 大小、权限) + STRICT // 严格检查(普通 + 内容、时效性) + } + + public static boolean checkParentDir(String filePath) throws IOException { + File file = new File(filePath); + // 确保父目录存在 + File parentDir = file.getParentFile(); + if (parentDir.exists()){ + return true; + }else { + if (parentDir.mkdirs()) { + return true; + }else { + throw new IOException("无法创建目录: " + parentDir.getAbsolutePath()); + } + } + } + + + public static boolean isExist(String filePath){ + File file = new File(filePath); + return file.exists(); + } + + /** + * 使用 File 类创建文件 + */ + public static File createFile(String filePath) throws IOException { + File file = new File(filePath); + // 确保父目录存在 + File parentDir = file.getParentFile(); + if (!parentDir.exists()) { + if (!parentDir.mkdirs()) { + throw new IOException("无法创建目录: " + parentDir.getAbsolutePath()); + } + } + // 创建文件 + if (!file.exists()) { + if (!file.createNewFile()) { + throw new IOException("无法创建文件: " + filePath); + } + } + return file; + } + + + /** + * 输出指定文件的byte数组 + * + * @param filePath 文件路径 + * @param os 输出流 + * @return + */ + public static void writeBytes(String filePath, OutputStream os) throws IOException { + FileInputStream fis = null; + try { + File file = new File(filePath); + if (!file.exists()) { + throw new FileNotFoundException(filePath); + } + fis = new FileInputStream(file); + byte[] b = new byte[1024]; + int length; + while ((length = fis.read(b)) > 0) { + os.write(b, 0, length); + } + } catch (IOException e) { + throw e; + } finally { + IOUtils.close(os); + IOUtils.close(fis); + } + } + + /** + * 写数据到文件中 + * + * @param data 数据 + * @return 目标文件 + * @throws IOException IO异常 + */ + public static String writeImportBytes(byte[] data) throws IOException { + return writeBytes(data, AppConfig.getImportPath()); + } + + /** + * 写数据到文件中 + * + * @param data 数据 + * @param uploadDir 目标文件 + * @return 目标文件 + * @throws IOException IO异常 + */ + public static String writeBytes(byte[] data, String uploadDir) throws IOException { + FileOutputStream fos = null; + String pathName = ""; + try { + String extension = getFileExtendName(data); + pathName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension; + File file = FileUploadUtils.getAbsoluteFile(uploadDir, pathName); + fos = new FileOutputStream(file); + fos.write(data); + } finally { + IOUtils.close(fos); + } + return FileUploadUtils.getPathFileName(uploadDir, pathName); + } + + /** + * 删除文件 + * + * @param filePath 文件 + * @return + */ + public static boolean deleteFile(String filePath) { + boolean flag = false; + File file = new File(filePath); + // 路径为文件且不为空则进行删除 + if (file.isFile() && file.exists()) { + flag = file.delete(); + } + return flag; + } + + /** + * 文件名称验证 + * + * @param filename 文件名称 + * @return true 正常 false 非法 + */ + public static boolean isValidFilename(String filename) { + return filename.matches(FILENAME_PATTERN); + } + + /** + * 检查文件是否可下载 + * + * @param resource 需要下载的文件 + * @return true 正常 false 非法 + */ + public static boolean checkAllowDownload(String resource) { + // 禁止目录上跳级别 + if (StringUtils.contains(resource, "..")) { + return false; + } + + // 检查允许下载的文件规则 + if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource))) { + return true; + } + + // 不在允许下载的文件规则 + return false; + } + + /** + * 下载文件名重新编码 + * + * @param request 请求对象 + * @param fileName 文件名 + * @return 编码后的文件名 + */ + public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException { + final String agent = request.getHeader("USER-AGENT"); + String filename = fileName; + if (agent.contains("MSIE")) { + // IE浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + filename = filename.replace("+", " "); + } else if (agent.contains("Firefox")) { + // 火狐浏览器 + filename = new String(fileName.getBytes(), "ISO8859-1"); + } else if (agent.contains("Chrome")) { + // google浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + } else { + // 其它浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + } + return filename; + } + + /** + * 下载文件名重新编码 + * + * @param response 响应对象 + * @param realFileName 真实文件名 + * @return + */ + public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException { + String percentEncodedFileName = percentEncode(realFileName); + + StringBuilder contentDispositionValue = new StringBuilder(); + contentDispositionValue.append("attachment; filename=") + .append(percentEncodedFileName) + .append(";") + .append("filename*=") + .append("utf-8''") + .append(percentEncodedFileName); + + response.setHeader("Content-disposition", contentDispositionValue.toString()); + } + + public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName, String type) throws UnsupportedEncodingException { + response.setCharacterEncoding("utf-8"); + if ("pdf".equals(type)) { + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=\"" + URLEncoder.encode(realFileName + "_" + DateUtils.dateTimeNow() + "." + type, "UTF-8") + "\""); + } else if ("doc".equals(type) || "docx".equals(type)) { + response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(realFileName + "_" + DateUtils.dateTimeNow() + "." + type, "UTF-8") + "\""); + } else if ("xls".equals(type) || "xlsx".equals(type)) { + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(realFileName + "_" + DateUtils.dateTimeNow() + "." + type, "UTF-8") + "\""); + } else if ("zip".equals(type)) { + response.setContentType("application/zip"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(realFileName + "_" + DateUtils.dateTimeNow() + "." + type, "UTF-8") + "\""); + } + + } + + /** + * 百分号编码工具方法 + * + * @param s 需要百分号编码的字符串 + * @return 百分号编码后的字符串 + */ + public static String percentEncode(String s) throws UnsupportedEncodingException { + String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString()); + return encode.replaceAll("\\+", "%20"); + } + + /** + * 获取图像后缀 + * + * @param photoByte 图像数据 + * @return 后缀名 + */ + public static String getFileExtendName(byte[] photoByte) { + String strFileExtendName = "jpg"; + if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56) + && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) { + strFileExtendName = "gif"; + } else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70)) { + strFileExtendName = "jpg"; + } else if ((photoByte[0] == 66) && (photoByte[1] == 77)) { + strFileExtendName = "bmp"; + } else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71)) { + strFileExtendName = "png"; + } + return strFileExtendName; + } + + /** + * 获取文件名称 /profile/upload/2022/04/16/ruoyi.png -- ruoyi.png + * + * @param fileName 路径名称 + * @return 没有文件路径的名称 + */ + public static String getName(String fileName) { + if (fileName == null) { + return null; + } + int lastUnixPos = fileName.lastIndexOf('/'); + int lastWindowsPos = fileName.lastIndexOf('\\'); + int index = Math.max(lastUnixPos, lastWindowsPos); + return fileName.substring(index + 1); + } + + /** + * 获取文件父路径 + * + * @param fileName 文件路径 + * @return 获取文件父路径 + */ + public static String getParent(String fileName) { + File file = new File(fileName); + File parentDir = file.getParentFile(); + if (parentDir != null) { + return parentDir.getAbsolutePath(); + } else { + return ""; + } + } + + /** + * 获取不带后缀文件名称 /profile/upload/2022/04/16/ruoyi.png -- ruoyi + * + * @param fileName 路径名称 + * @return 没有文件路径和后缀的名称 + */ + public static String getNameNotSuffix(String fileName) { + if (fileName == null) { + return null; + } + String baseName = FilenameUtils.getBaseName(fileName); + return baseName; + } + + /** + * 检查文件是否有效 + * + * @param filePath 文件路径 + * @param level 检查级别 + * @return 文件是否有效 + */ + public static boolean isFileValid(String filePath, CheckLevel level) { + if (StringUtils.isEmpty(filePath)) { + log.warn("文件路径为空"); + return false; + } + + File file = new File(filePath); + + // 基础检查 + if (!basicCheck(file)) { + return false; + } + + // 根据检查级别执行不同的检查 + if (level.ordinal() >= CheckLevel.NORMAL.ordinal()) { + if (!normalCheck(file)) { + return false; + } + } + + if (level.ordinal() >= CheckLevel.STRICT.ordinal()) { + if (!strictCheck(file)) { + return false; + } + } + + return true; + } + + /** + * 基础检查:文件存在性和类型 + */ + private static boolean basicCheck(File file) { + if (!file.exists()) { + log.warn("文件不存在: {}", file.getPath()); + return false; + } + + if (!file.isFile()) { + log.warn("不是普通文件: {}", file.getPath()); + return false; + } + + return true; + } + + /** + * 普通检查:文件大小和权限 + */ + private static boolean normalCheck(File file) { + if (file.length() == 0) { + log.warn("文件为空: {}", file.getPath()); + return false; + } + + if (!file.canRead()) { + log.warn("文件不可读: {}", file.getPath()); + return false; + } + + try { + if (!Files.isReadable(file.toPath())) { + log.warn("文件不可访问: {}", file.getPath()); + return false; + } + } catch (SecurityException e) { + log.error("检查文件权限时出错: {}", file.getPath(), e); + return false; + } + + return true; + } + + /** + * 严格检查:文件内容和时效性 + */ + private static boolean strictCheck(File file) { + // 检查文件内容 + try (FileInputStream fis = new FileInputStream(file)) { + byte[] buffer = new byte[1024]; + if (fis.read(buffer) == -1) { + //logger.warn("文件可能已损坏: {}", file.getPath()); + return false; + } + } catch (IOException e) { + //logger.error("读取文件时出错: {}", file.getPath(), e); + return false; + } + + // 检查文件时效性(示例:30天) + long lastModified = file.lastModified(); + if (lastModified == 0L || + System.currentTimeMillis() - lastModified > TimeUnit.DAYS.toMillis(30)) { + //logger.warn("文件可能已过期: {}", file.getPath()); + return false; + } + + return true; + } + + /** + * 使用默认检查级别(NORMAL)检查文件 + */ + public static boolean isFileValid(String filePath) { + return isFileValid(filePath, CheckLevel.NORMAL); + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/file/ImageUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/file/ImageUtils.java new file mode 100644 index 0000000..5582738 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/file/ImageUtils.java @@ -0,0 +1,265 @@ +package com.mathvision.box.common.utils.file; + + +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.constant.Constants; +import com.mathvision.box.common.utils.common.StringUtils; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import sun.misc.BASE64Decoder; +import sun.misc.BASE64Encoder; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.*; +import java.net.URL; +import java.net.URLConnection; +import java.util.Arrays; +import java.util.Base64; + +/** + * 图片处理工具类 + */ +public class ImageUtils +{ + private static final Logger log = LoggerFactory.getLogger(ImageUtils.class); + + public static byte[] getImage(String imagePath) + { + InputStream is = getFile(imagePath); + try + { + return IOUtils.toByteArray(is); + } + catch (Exception e) + { + log.error("图片加载异常 {}", e); + return null; + } + finally + { + IOUtils.closeQuietly(is); + } + } + + public static InputStream getFile(String imagePath) + { + try + { + byte[] result = readFile(imagePath); + result = Arrays.copyOf(result, result.length); + return new ByteArrayInputStream(result); + } + catch (Exception e) + { + log.error("获取图片异常 {}", e); + } + return null; + } + + /** + * 读取文件为字节数据 + * + * @param url 地址 + * @return 字节数据 + */ + public static byte[] readFile(String url) + { + InputStream in = null; + try + { + if (url.startsWith("http")) + { + // 网络地址 + URL urlObj = new URL(url); + URLConnection urlConnection = urlObj.openConnection(); + urlConnection.setConnectTimeout(30 * 1000); + urlConnection.setReadTimeout(60 * 1000); + urlConnection.setDoInput(true); + in = urlConnection.getInputStream(); + } + else + { + // 本机地址 + String localPath = AppConfig.getProfile(); + String downloadPath = localPath + StringUtils.substringAfter(url, Constants.RESOURCE_PREFIX); + in = new FileInputStream(downloadPath); + } + return IOUtils.toByteArray(in); + } + catch (Exception e) + { + log.error("获取文件路径异常 {}", e); + return null; + } + finally + { + IOUtils.closeQuietly(in); + } + } + + /** + * 通过BufferedImage图片流调整图片大小 + */ + public static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) throws IOException { + Image resultingImage = originalImage.getScaledInstance(targetWidth, targetHeight, Image.SCALE_AREA_AVERAGING); + BufferedImage outputImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB); + outputImage.getGraphics().drawImage(resultingImage, 0, 0, null); + return outputImage; + } + + /** + * 返回base64图片 + * @param data + * @return + */ + public static String imageToBase64(byte[] data) { + BASE64Encoder encoder = new BASE64Encoder(); + // 返回Base64编码过的字节数组字符串 + return encoder.encode(data); + } + + /** + * base64转换成byte数组 + * @param base64 + * @return + * @throws IOException + */ + public static byte[] base64ToByte(String base64) throws IOException { + BASE64Decoder decoder = new BASE64Decoder(); + // 返回Base64编码过的字节数组字符串 + return decoder.decodeBuffer(base64); + } + + /** + * BufferedImage图片流转byte[]数组 + */ + public static byte[] imageToBytes(BufferedImage bImage) { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + try { + ImageIO.write(bImage, "png", out); + } catch (IOException e) { + e.printStackTrace(); + } + return out.toByteArray(); + } + + /** + * byte[]数组转BufferedImage图片流 + */ + public static BufferedImage bytesToBufferedImage(byte[] ImageByte) { + ByteArrayInputStream in = new ByteArrayInputStream(ImageByte); + BufferedImage image = null; + try { + image = ImageIO.read(in); + } catch (IOException e) { + e.printStackTrace(); + } + return image; + } + + /** + * 在线图片资源转base + * @param imageUrl + * @return + * @throws IOException + */ + public static String convertToBase64(String imageUrl) throws IOException { + URL url = new URL(imageUrl); + String fileType = imageUrl.substring(imageUrl.length()-3); + String base64Str = "data:" + fileType + ";base64,"; + InputStream inputStream = url.openStream(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + byte[] imageBytes = outputStream.toByteArray(); + String base64String = base64Str + Base64.getEncoder().encodeToString(imageBytes); + return base64String; + } + + //图片转化成base64字符串 + public static String getImageStr(String imgPath) throws IOException { + File file = new File(imgPath); + String fileContentBase64 = null; + if(file.exists()){ + String fileType = imgPath.substring(imgPath.length()-3); + String base64Str = "data:" + fileType + ";base64,"; + String content = null; + //将图片文件转化为字节数组字符串,并对其进行Base64编码处理 + InputStream in = null; + byte[] data = null; + //读取图片字节数组 + try { + in = new FileInputStream(file); + data = new byte[in.available()]; + in.read(data); + in.close(); + //对字节数组Base64编码 + if (data == null || data.length == 0) { + return null; + } + //content = Base64.encodeBytes(data); + content = new BASE64Encoder().encode(data); + if (content == null || "".equals(content)) { + return null; + } + // 缩小图片 + if (StringUtils.isNotBlank(content)) { + BufferedImage bufferedImage = ImageUtils.bytesToBufferedImage(ImageUtils.base64ToByte(content)); + if (bufferedImage != null){ + int height = bufferedImage.getHeight(); + int width = bufferedImage.getWidth(); + // 如果图片宽度大于650,图片缩放 + if (width > 500) { + //高度等比缩放 + height = (int)(height*500.0/width); + BufferedImage imgZoom = ImageUtils.resizeImage(bufferedImage, 500, height); + content = ImageUtils.imageToBase64(ImageUtils.imageToBytes(imgZoom)); + } + } + } + fileContentBase64 = base64Str + content; + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (in != null) { + in.close(); + } + } + } + + return fileContentBase64; + } + + + /** + * 验证给定的字符串是否为有效的 Base64 编码。 + * + * @param base64Str 要验证的字符串 + * @return 如果是有效的 Base64 编码,则返回 true;否则,返回 false + */ + public static boolean isValidBase64(String base64Str) { + if (base64Str == null || base64Str.isEmpty()) { + return false; + } + try { + // 移除 Base64 数据的前缀(如果存在) + String actualBase64Str = base64Str; + if (base64Str.contains(",")) { + actualBase64Str = base64Str.split(",")[1]; + } + + // 尝试解码 + Base64.getDecoder().decode(actualBase64Str); + return true; + } catch (IllegalArgumentException e) { + // 捕获解码异常,说明不是有效的 Base64 字符串 + return false; + } + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/file/MimeTypeUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/file/MimeTypeUtils.java new file mode 100644 index 0000000..1afb3e8 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/file/MimeTypeUtils.java @@ -0,0 +1,61 @@ +package com.mathvision.box.common.utils.file; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:媒体类型工具类 + */ +public class MimeTypeUtils +{ + public static final String IMAGE_PNG = "image/png"; + + public static final String IMAGE_JPG = "image/jpg"; + + public static final String IMAGE_JPEG = "image/jpeg"; + + public static final String IMAGE_BMP = "image/bmp"; + + public static final String IMAGE_GIF = "image/gif"; + + public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" }; + + public static final String[] FLASH_EXTENSION = { "swf", "flv" }; + + public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", + "asf", "rm", "rmvb" }; + + public static final String[] VIDEO_EXTENSION = { "mp4", "avi", "rmvb" }; + + public static final String[] DEFAULT_ALLOWED_EXTENSION = { + // 图片 + "bmp", "gif", "jpg", "jpeg", "png", + // word excel powerpoint + "doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt", + // 压缩文件 + "rar", "zip", "gz", "bz2", + // 视频格式 + "mp4", "avi", "rmvb", + // 音频格式 + "mp3", "wav", "aac", + // pdf + "pdf" }; + + public static String getExtension(String prefix) + { + switch (prefix) + { + case IMAGE_PNG: + return "png"; + case IMAGE_JPG: + return "jpg"; + case IMAGE_JPEG: + return "jpeg"; + case IMAGE_BMP: + return "bmp"; + case IMAGE_GIF: + return "gif"; + default: + return ""; + } + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/html/EscapeUtil.java b/box-common/src/main/java/com/mathvision/box/common/utils/html/EscapeUtil.java new file mode 100644 index 0000000..11b2d23 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/html/EscapeUtil.java @@ -0,0 +1,166 @@ +package com.mathvision.box.common.utils.html; + + +import com.mathvision.box.common.utils.common.StringUtils; + +/** + * 转义和反转义工具类 + */ +public class EscapeUtil +{ + public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)"; + + private static final char[][] TEXT = new char[64][]; + + static + { + for (int i = 0; i < 64; i++) + { + TEXT[i] = new char[] { (char) i }; + } + + // special HTML characters + TEXT['\''] = "'".toCharArray(); // 单引号 + TEXT['"'] = """.toCharArray(); // 双引号 + TEXT['&'] = "&".toCharArray(); // &符 + TEXT['<'] = "<".toCharArray(); // 小于号 + TEXT['>'] = ">".toCharArray(); // 大于号 + } + + /** + * 转义文本中的HTML字符为安全的字符 + * + * @param text 被转义的文本 + * @return 转义后的文本 + */ + public static String escape(String text) + { + return encode(text); + } + + /** + * 还原被转义的HTML特殊字符 + * + * @param content 包含转义符的HTML内容 + * @return 转换后的字符串 + */ + public static String unescape(String content) + { + return decode(content); + } + + /** + * 清除所有HTML标签,但是不删除标签内的内容 + * + * @param content 文本 + * @return 清除标签后的文本 + */ + public static String clean(String content) + { + return new HTMLFilter().filter(content); + } + + /** + * Escape编码 + * + * @param text 被编码的文本 + * @return 编码后的字符 + */ + private static String encode(String text) + { + if (StringUtils.isEmpty(text)) + { + return StringUtils.EMPTY; + } + + final StringBuilder tmp = new StringBuilder(text.length() * 6); + char c; + for (int i = 0; i < text.length(); i++) + { + c = text.charAt(i); + if (c < 256) + { + tmp.append("%"); + if (c < 16) + { + tmp.append("0"); + } + tmp.append(Integer.toString(c, 16)); + } + else + { + tmp.append("%u"); + if (c <= 0xfff) + { + // issue#I49JU8@Gitee + tmp.append("0"); + } + tmp.append(Integer.toString(c, 16)); + } + } + return tmp.toString(); + } + + /** + * Escape解码 + * + * @param content 被转义的内容 + * @return 解码后的字符串 + */ + public static String decode(String content) + { + if (StringUtils.isEmpty(content)) + { + return content; + } + + StringBuilder tmp = new StringBuilder(content.length()); + int lastPos = 0, pos = 0; + char ch; + while (lastPos < content.length()) + { + pos = content.indexOf("%", lastPos); + if (pos == lastPos) + { + if (content.charAt(pos + 1) == 'u') + { + ch = (char) Integer.parseInt(content.substring(pos + 2, pos + 6), 16); + tmp.append(ch); + lastPos = pos + 6; + } + else + { + ch = (char) Integer.parseInt(content.substring(pos + 1, pos + 3), 16); + tmp.append(ch); + lastPos = pos + 3; + } + } + else + { + if (pos == -1) + { + tmp.append(content.substring(lastPos)); + lastPos = content.length(); + } + else + { + tmp.append(content.substring(lastPos, pos)); + lastPos = pos; + } + } + } + return tmp.toString(); + } + + public static void main(String[] args) + { + String html = ""; + String escape = EscapeUtil.escape(html); + // String html = "ipt>alert(\"XSS\")ipt>"; + // String html = "<123"; + // String html = "123>"; + System.out.println("clean: " + EscapeUtil.clean(html)); + System.out.println("escape: " + escape); + System.out.println("unescape: " + EscapeUtil.unescape(escape)); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/html/HTMLFilter.java b/box-common/src/main/java/com/mathvision/box/common/utils/html/HTMLFilter.java new file mode 100644 index 0000000..f37ce82 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/html/HTMLFilter.java @@ -0,0 +1,564 @@ +package com.mathvision.box.common.utils.html; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * HTML过滤器,用于去除XSS漏洞隐患。 + */ +public final class HTMLFilter +{ + /** + * regex flag union representing /si modifiers in php + **/ + private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; + private static final Pattern P_COMMENTS = Pattern.compile("", Pattern.DOTALL); + private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI); + private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL); + private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI); + private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI); + private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI); + private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI); + private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI); + private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); + private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); + private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); + private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); + private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL); + private static final Pattern P_END_ARROW = Pattern.compile("^>"); + private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_AMP = Pattern.compile("&"); + private static final Pattern P_QUOTE = Pattern.compile("\""); + private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); + private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); + private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); + + // @xxx could grow large... maybe use sesat's ReferenceMap + private static final ConcurrentMap P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>(); + private static final ConcurrentMap P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>(); + + /** + * set of allowed html elements, along with allowed attributes for each element + **/ + private final Map> vAllowed; + /** + * counts of open tags for each (allowable) html element + **/ + private final Map vTagCounts = new HashMap<>(); + + /** + * html elements which must always be self-closing (e.g. "") + **/ + private final String[] vSelfClosingTags; + /** + * html elements which must always have separate opening and closing tags (e.g. "") + **/ + private final String[] vNeedClosingTags; + /** + * set of disallowed html elements + **/ + private final String[] vDisallowed; + /** + * attributes which should be checked for valid protocols + **/ + private final String[] vProtocolAtts; + /** + * allowed protocols + **/ + private final String[] vAllowedProtocols; + /** + * tags which should be removed if they contain no content (e.g. "" or "") + **/ + private final String[] vRemoveBlanks; + /** + * entities allowed within html markup + **/ + private final String[] vAllowedEntities; + /** + * flag determining whether comments are allowed in input String. + */ + private final boolean stripComment; + private final boolean encodeQuotes; + /** + * flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. "" + * becomes " text "). If set to false, unbalanced angle brackets will be html escaped. + */ + private final boolean alwaysMakeTags; + + /** + * Default constructor. + */ + public HTMLFilter() + { + vAllowed = new HashMap<>(); + + final ArrayList a_atts = new ArrayList<>(); + a_atts.add("href"); + a_atts.add("target"); + vAllowed.put("a", a_atts); + + final ArrayList img_atts = new ArrayList<>(); + img_atts.add("src"); + img_atts.add("width"); + img_atts.add("height"); + img_atts.add("alt"); + vAllowed.put("img", img_atts); + + final ArrayList no_atts = new ArrayList<>(); + vAllowed.put("b", no_atts); + vAllowed.put("strong", no_atts); + vAllowed.put("i", no_atts); + vAllowed.put("em", no_atts); + + vSelfClosingTags = new String[] { "img" }; + vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" }; + vDisallowed = new String[] {}; + vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp. + vProtocolAtts = new String[] { "src", "href" }; + vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" }; + vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" }; + stripComment = true; + encodeQuotes = true; + alwaysMakeTags = false; + } + + /** + * Map-parameter configurable constructor. + * + * @param conf map containing configuration. keys match field names. + */ + @SuppressWarnings("unchecked") + public HTMLFilter(final Map conf) + { + + assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; + assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; + assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; + assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; + assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; + assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; + assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; + assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; + + vAllowed = Collections.unmodifiableMap((HashMap>) conf.get("vAllowed")); + vSelfClosingTags = (String[]) conf.get("vSelfClosingTags"); + vNeedClosingTags = (String[]) conf.get("vNeedClosingTags"); + vDisallowed = (String[]) conf.get("vDisallowed"); + vAllowedProtocols = (String[]) conf.get("vAllowedProtocols"); + vProtocolAtts = (String[]) conf.get("vProtocolAtts"); + vRemoveBlanks = (String[]) conf.get("vRemoveBlanks"); + vAllowedEntities = (String[]) conf.get("vAllowedEntities"); + stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true; + encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true; + alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; + } + + private void reset() + { + vTagCounts.clear(); + } + + // --------------------------------------------------------------- + // my versions of some PHP library functions + public static String chr(final int decimal) + { + return String.valueOf((char) decimal); + } + + public static String htmlSpecialChars(final String s) + { + String result = s; + result = regexReplace(P_AMP, "&", result); + result = regexReplace(P_QUOTE, """, result); + result = regexReplace(P_LEFT_ARROW, "<", result); + result = regexReplace(P_RIGHT_ARROW, ">", result); + return result; + } + + // --------------------------------------------------------------- + + /** + * given a user submitted input String, filter out any invalid or restricted html. + * + * @param input text (i.e. submitted by a user) than may contain html + * @return "clean" version of input, with only valid, whitelisted html elements allowed + */ + public String filter(final String input) + { + reset(); + String s = input; + + s = escapeComments(s); + + s = balanceHTML(s); + + s = checkTags(s); + + s = processRemoveBlanks(s); + + // s = validateEntities(s); + + return s; + } + + public boolean isAlwaysMakeTags() + { + return alwaysMakeTags; + } + + public boolean isStripComments() + { + return stripComment; + } + + private String escapeComments(final String s) + { + final Matcher m = P_COMMENTS.matcher(s); + final StringBuffer buf = new StringBuffer(); + if (m.find()) + { + final String match = m.group(1); // (.*?) + m.appendReplacement(buf, Matcher.quoteReplacement("")); + } + m.appendTail(buf); + + return buf.toString(); + } + + private String balanceHTML(String s) + { + if (alwaysMakeTags) + { + // + // try and form html + // + s = regexReplace(P_END_ARROW, "", s); + // 不追加结束标签 + s = regexReplace(P_BODY_TO_END, "<$1>", s); + s = regexReplace(P_XML_CONTENT, "$1<$2", s); + + } + else + { + // + // escape stray brackets + // + s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); + s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); + + // + // the last regexp causes '<>' entities to appear + // (we need to do a lookahead assertion so that the last bracket can + // be used in the next pass of the regexp) + // + s = regexReplace(P_BOTH_ARROWS, "", s); + } + + return s; + } + + private String checkTags(String s) + { + Matcher m = P_TAGS.matcher(s); + + final StringBuffer buf = new StringBuffer(); + while (m.find()) + { + String replaceStr = m.group(1); + replaceStr = processTag(replaceStr); + m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); + } + m.appendTail(buf); + + // these get tallied in processTag + // (remember to reset before subsequent calls to filter method) + final StringBuilder sBuilder = new StringBuilder(buf.toString()); + for (String key : vTagCounts.keySet()) + { + for (int ii = 0; ii < vTagCounts.get(key); ii++) + { + sBuilder.append(""); + } + } + s = sBuilder.toString(); + + return s; + } + + private String processRemoveBlanks(final String s) + { + String result = s; + for (String tag : vRemoveBlanks) + { + if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) + { + P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); + } + result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); + if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) + { + P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); + } + result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); + } + + return result; + } + + private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) + { + Matcher m = regex_pattern.matcher(s); + return m.replaceAll(replacement); + } + + private String processTag(final String s) + { + // ending tags + Matcher m = P_END_TAG.matcher(s); + if (m.find()) + { + final String name = m.group(1).toLowerCase(); + if (allowed(name)) + { + if (false == inArray(name, vSelfClosingTags)) + { + if (vTagCounts.containsKey(name)) + { + vTagCounts.put(name, vTagCounts.get(name) - 1); + return ""; + } + } + } + } + + // starting tags + m = P_START_TAG.matcher(s); + if (m.find()) + { + final String name = m.group(1).toLowerCase(); + final String body = m.group(2); + String ending = m.group(3); + + // debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); + if (allowed(name)) + { + final StringBuilder params = new StringBuilder(); + + final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); + final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); + final List paramNames = new ArrayList<>(); + final List paramValues = new ArrayList<>(); + while (m2.find()) + { + paramNames.add(m2.group(1)); // ([a-z0-9]+) + paramValues.add(m2.group(3)); // (.*?) + } + while (m3.find()) + { + paramNames.add(m3.group(1)); // ([a-z0-9]+) + paramValues.add(m3.group(3)); // ([^\"\\s']+) + } + + String paramName, paramValue; + for (int ii = 0; ii < paramNames.size(); ii++) + { + paramName = paramNames.get(ii).toLowerCase(); + paramValue = paramValues.get(ii); + + // debug( "paramName='" + paramName + "'" ); + // debug( "paramValue='" + paramValue + "'" ); + // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); + + if (allowedAttribute(name, paramName)) + { + if (inArray(paramName, vProtocolAtts)) + { + paramValue = processParamProtocol(paramValue); + } + params.append(' ').append(paramName).append("=\"").append(paramValue).append("\""); + } + } + + if (inArray(name, vSelfClosingTags)) + { + ending = " /"; + } + + if (inArray(name, vNeedClosingTags)) + { + ending = ""; + } + + if (ending == null || ending.length() < 1) + { + if (vTagCounts.containsKey(name)) + { + vTagCounts.put(name, vTagCounts.get(name) + 1); + } + else + { + vTagCounts.put(name, 1); + } + } + else + { + ending = " /"; + } + return "<" + name + params + ending + ">"; + } + else + { + return ""; + } + } + + // comments + m = P_COMMENT.matcher(s); + if (!stripComment && m.find()) + { + return "<" + m.group() + ">"; + } + + return ""; + } + + private String processParamProtocol(String s) + { + s = decodeEntities(s); + final Matcher m = P_PROTOCOL.matcher(s); + if (m.find()) + { + final String protocol = m.group(1); + if (!inArray(protocol, vAllowedProtocols)) + { + // bad protocol, turn into local anchor link instead + s = "#" + s.substring(protocol.length() + 1); + if (s.startsWith("#//")) + { + s = "#" + s.substring(3); + } + } + } + + return s; + } + + private String decodeEntities(String s) + { + StringBuffer buf = new StringBuffer(); + + Matcher m = P_ENTITY.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.decode(match).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENTITY_UNICODE.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENCODE.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + s = validateEntities(s); + return s; + } + + private String validateEntities(final String s) + { + StringBuffer buf = new StringBuffer(); + + // validate entities throughout the string + Matcher m = P_VALID_ENTITIES.matcher(s); + while (m.find()) + { + final String one = m.group(1); // ([^&;]*) + final String two = m.group(2); // (?=(;|&|$)) + m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); + } + m.appendTail(buf); + + return encodeQuotes(buf.toString()); + } + + private String encodeQuotes(final String s) + { + if (encodeQuotes) + { + StringBuffer buf = new StringBuffer(); + Matcher m = P_VALID_QUOTES.matcher(s); + while (m.find()) + { + final String one = m.group(1); // (>|^) + final String two = m.group(2); // ([^<]+?) + final String three = m.group(3); // (<|$) + // 不替换双引号为",防止json格式无效 regexReplace(P_QUOTE, """, two) + m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three)); + } + m.appendTail(buf); + return buf.toString(); + } + else + { + return s; + } + } + + private String checkEntity(final String preamble, final String term) + { + + return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&" + preamble; + } + + private boolean isValidEntity(final String entity) + { + return inArray(entity, vAllowedEntities); + } + + private static boolean inArray(final String s, final String[] array) + { + for (String item : array) + { + if (item != null && item.equals(s)) + { + return true; + } + } + return false; + } + + private boolean allowed(final String name) + { + return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); + } + + private boolean allowedAttribute(final String name, final String paramName) + { + return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/http/HttpReqTemp.java b/box-common/src/main/java/com/mathvision/box/common/utils/http/HttpReqTemp.java new file mode 100644 index 0000000..f1a8e5a --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/http/HttpReqTemp.java @@ -0,0 +1,340 @@ +package com.mathvision.box.common.utils.http; + +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.lang.Nullable; +import org.springframework.util.Assert; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; + +import java.util.Objects; +import java.util.regex.Pattern; + +/** + * HTTP请求模板封装(线程不安全) + *

提供类型安全的HTTP请求配置,支持参数校验、防御性拷贝和流畅API

+ * + *

使用示例:

+ *
{@code
+ * HttpReqTemp reqTemp = new HttpReqTemp()
+ *                 .withMethod(HttpMethod.POST)
+ *                 .withUrl("http://192.168.1.3/api/version")
+ *                 .withQueryParam()
+ *                 .withHeader("Content-Type", "application/json")
+ *                 .withMediaType(MediaType.APPLICATION_JSON)
+ *                 .withBody("{\"name\":\"John\",\"age\":30}")
+ *                 .withTimeout(120)
+ *                 .withRetryCount(3)
+ *                 .withExceptionStrategy(HttpReqTemp.ExceptionHandlingStrategy.FALLBACK)
+ *                 .withExample("{\"name\":\"John\",\"age\":30}");
+ * }
+ */ +public class HttpReqTemp { + private static final Pattern URL_PATTERN = Pattern.compile("^(https?|ftp)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"); + private static final int MAX_TIMEOUT = 10000; + private static final int MAX_RETRY = 10; + + // 核心参数 + private HttpMethod method; + private String url; + private MediaType mediaType; + private String body; + + // 集合参数(防御性拷贝) + private MultiValueMap queryParams = new LinkedMultiValueMap<>(); + private MultiValueMap headers = new LinkedMultiValueMap<>(); + + // 执行策略 + private int timeout = 120; + private int retryCount = 1; + private ExceptionHandlingStrategy exceptionStrategy = ExceptionHandlingStrategy.DEFAULT; + + // MOCK数据 + private String example; + + /** + * 参数有效性校验 + * + * @throws IllegalStateException 当配置存在矛盾时抛出 + */ + public void validateConfig() { + if (method == HttpMethod.GET && body != null) { + throw new IllegalStateException("GET请求不能包含请求体"); + } + if (mediaType == null && body != null) { + throw new IllegalStateException("包含请求体时必须指定MediaType"); + } + } + + /*----------------------- 核心参数配置 -----------------------*/ + + /** + * 设置HTTP方法 + * + * @param method HTTP方法枚举,不可为空 + */ + public void setMethod(HttpMethod method) { + this.method = Objects.requireNonNull(method, "HTTP方法不能为空"); + } + + /** + * 设置请求URL + * + * @param url 符合格式的完整URL(支持http/https/ftp) + * @throws IllegalArgumentException 当URL格式无效时抛出 + */ + public void setUrl(String url) { + Assert.hasText(url, "URL不能为空"); + if (!URL_PATTERN.matcher(url).matches()) { + throw new IllegalArgumentException("无效的URL格式: " + url); + } + this.url = url; + } + + /** + * 设置媒体类型 + * + * @param mediaType 标准MediaType枚举值,不可为空 + */ + public void setMediaType(MediaType mediaType) { + this.mediaType = Objects.requireNonNull(mediaType, "MediaType不能为空"); + } + + public void setBody(String body) { + this.body = body; + } + + public void setExample(String example) { + this.example = example; + } + + /*----------------------- 集合参数操作 -----------------------*/ + + /** + * 完全替换查询参数 + * + * @param params 新的参数集合(自动防御性拷贝) + */ + public void setQueryParams(@Nullable MultiValueMap params) { + this.queryParams = params != null ? + new LinkedMultiValueMap<>(params) : + new LinkedMultiValueMap<>(); + } + + /** + * 添加单个查询参数 + * + * @param key 参数键(自动trim,不允许空值或包含非法字符) + * @param value 参数值(允许null) + */ + public void addQueryParam(String key, @Nullable String value) { + validateParameterKey(key); + this.queryParams.add(key.trim(), value); + } + + /** + * 完全替换请求头 + * + * @param headers 新的头信息集合(自动防御性拷贝) + */ + public void setHeaders(@Nullable MultiValueMap headers) { + this.headers = headers != null ? + new LinkedMultiValueMap<>(headers) : + new LinkedMultiValueMap<>(); + } + + /** + * 添加请求头 + * + * @param key 头字段名(自动trim,需符合规范) + * @param value 头字段值(允许null) + */ + public void addHeader(String key, @Nullable String value) { + validateHeaderKey(key); + this.headers.add(key.trim(), value); + } + + /*----------------------- 策略配置 -----------------------*/ + + /** + * 设置超时时间 + * + * @param seconds 超时时间(0-120秒) + */ + public void setTimeout(int seconds) { + if (seconds < 0 || seconds > MAX_TIMEOUT) { + throw new IllegalArgumentException("超时时间需在0-" + MAX_TIMEOUT + "秒之间"); + } + this.timeout = seconds; + } + + /** + * 设置重试次数 + * + * @param count 重试次数(0-10次) + */ + public void setRetryCount(int count) { + if (count < 0 || count > MAX_RETRY) { + throw new IllegalArgumentException("重试次数需在0-" + MAX_RETRY + "次之间"); + } + this.retryCount = count; + } + + /** + * 设置异常处理策略 + * + * @param strategy 异常处理策略枚举 + */ + public void setExceptionStrategy(ExceptionHandlingStrategy strategy) { + this.exceptionStrategy = Objects.requireNonNull(strategy); + } + + /*----------------------- 校验方法 -----------------------*/ + + private void validateParameterKey(String key) { + Assert.hasText(key, "查询参数键不能为空"); + if (key.contains(" ")) { + throw new IllegalArgumentException("参数键包含非法空格: " + key); + } + } + + private void validateHeaderKey(String key) { + Assert.hasText(key, "请求头键不能为空"); + String normalized = key.trim().toLowerCase(); + if (normalized.equals("content-length")) { + throw new IllegalArgumentException("禁止手动设置Content-Length头"); + } + } + + /*----------------------- 流畅接口方法 -----------------------*/ + + public HttpReqTemp withMethod(HttpMethod method) { + setMethod(method); + return this; + } + + public HttpReqTemp withUrl(String url) { + setUrl(url); + return this; + } + + public HttpReqTemp withQueryParam(String key, String value) { + addQueryParam(key, value); + return this; + } + + public HttpReqTemp withHeader(String key, String value) { + addHeader(key, value); + return this; + } + + public HttpReqTemp withOauth(String token) { + addHeader("Authorization", "Bearer " + token); + return this; + } + + public HttpReqTemp withMediaType(MediaType mediaType) { + setMediaType(mediaType); + return this; + } + + public HttpReqTemp withTimeout(int seconds) { + setTimeout(seconds); + return this; + } + + public HttpReqTemp withRetryCount(int count) { + setRetryCount(count); + return this; + } + + public HttpReqTemp withExample(String example) { + setExample(example); + return this; + } + + public HttpReqTemp withBody(String body) { + setBody(body); + return this; + } + + /*----------------------- 枚举定义 -----------------------*/ + + /** + * 异常处理策略 + */ + public enum ExceptionHandlingStrategy { + /** + * 抛出原始异常 + */ + DEFAULT, + /** + * 返回预定义的示例数据 + */ + FALLBACK + } + + /*----------------------- Getter方法 -----------------------*/ + + public HttpMethod getMethod() { + return method; + } + + public String getUrl() { + return url; + } + + public MediaType getMediaType() { + if (mediaType == null) { + return MediaType.APPLICATION_JSON; + } else { + return mediaType; + } + } + + public MultiValueMap getQueryParams() { + return new LinkedMultiValueMap<>(queryParams); + } + + public MultiValueMap getHeaders() { + return new LinkedMultiValueMap<>(headers); + } + + public int getTimeout() { + return timeout; + } + + public int getRetryCount() { + return retryCount; + } + + public ExceptionHandlingStrategy getExceptionStrategy() { + return exceptionStrategy; + } + + public String getBody() { + return body; + } + + public String getExample() { + return example; + } + + @Override + public String toString() { + return "HttpReqTemp{" + + "method=" + method + + ", url='" + url + '\'' + + ", mediaType=" + mediaType + + ", body='" + body + '\'' + + ", queryParams=" + queryParams + + ", headers=" + headers + + ", timeout=" + timeout + + ", retryCount=" + retryCount + + ", exceptionStrategy=" + exceptionStrategy + + ", example='" + example + '\'' + + '}'; + } +} + + diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/http/HttpUtil.java b/box-common/src/main/java/com/mathvision/box/common/utils/http/HttpUtil.java new file mode 100644 index 0000000..37470be --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/http/HttpUtil.java @@ -0,0 +1,246 @@ +package com.mathvision.box.common.utils.http; + +import com.mathvision.box.common.utils.common.Threads; +import com.mathvision.box.common.utils.file.FileUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.*; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; + +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; + +/** + * http请求工具类 + *

+ * 中文乱码问题:json = new String(json.getBytes("ISO-8859-1"), "UTF-8"); + */ +@Slf4j +public class HttpUtil { + /** + * get请求 + * + * @param url + * @param params 请求参数 + * @return + */ + public static String get(String url, MultiValueMap params) { + return get(url, params, null); + } + + /** + * get请求 + * + * @param url + * @param params 请求参数 + * @param headers 请求头 + * @return + */ + public static String get(String url, MultiValueMap params, MultiValueMap headers) { + return request(url, params, headers, HttpMethod.GET); + } + + /** + * post请求 + * + * @param url + * @param params 请求参数 + * @return + */ + public static String post(String url, MultiValueMap params) { + return post(url, params, null); + } + + /** + * post请求 + * + * @param url + * @param params 请求参数 + * @param headers 请求头 + * @return + */ + public static String post(String url, MultiValueMap params, MultiValueMap headers) { + return request(url, params, headers, HttpMethod.POST); + } + + /** + * put请求 + * + * @param url + * @param params 请求参数 + * @return + */ + public static String put(String url, MultiValueMap params) { + return put(url, params, null); + } + + /** + * put请求 + * + * @param url + * @param params 请求参数 + * @param headers 请求头 + * @return + */ + public static String put(String url, MultiValueMap params, MultiValueMap headers) { + return request(url, params, headers, HttpMethod.PUT); + } + + /** + * delete请求 + * + * @param url + * @param params 请求参数 + * @return + */ + public static String delete(String url, MultiValueMap params) { + return delete(url, params, null); + } + + /** + * delete请求 + * + * @param url + * @param params 请求参数 + * @param headers 请求头 + * @return + */ + public static String delete(String url, MultiValueMap params, MultiValueMap headers) { + return request(url, params, headers, HttpMethod.DELETE); + } + + /** + * 表单请求 + * + * @param url + * @param params 请求参数 + * @param headers 请求头 + * @param method 请求方式 + * @return + */ + public static String request(String url, MultiValueMap params, MultiValueMap headers, HttpMethod method) { + if (params == null) { + params = new LinkedMultiValueMap<>(); + } + return request(url, params, headers, method, MediaType.APPLICATION_FORM_URLENCODED); + } + + /** + * http请求 + * + * @param url + * @param params 请求参数 + * @param headers 请求头 + * @param method 请求方式 + * @param mediaType 参数类型 + * @return + */ + public static String request(String url, Object params, MultiValueMap headers, HttpMethod method, MediaType mediaType) { + if (url == null || url.trim().isEmpty()) { + return null; + } + RestTemplate client = new RestTemplate(); + // header + HttpHeaders httpHeaders = new HttpHeaders(); + if (headers != null) { + httpHeaders.addAll(headers); + } + // 提交方式:表单、json + httpHeaders.setContentType(mediaType); + HttpEntity httpEntity = new HttpEntity(params, httpHeaders); + ResponseEntity response = client.exchange(url, method, httpEntity, String.class); + return response.getBody(); + } + + public static String request(HttpReqTemp reqTemp) { + // 参数校验强化 + if (reqTemp == null) { + throw new IllegalArgumentException("HttpReqTemp cannot be null"); + } + reqTemp.validateConfig(); + + String url = reqTemp.getUrl(); + HttpMethod method = reqTemp.getMethod(); + + // 构建带有查询参数的URL + url = UriComponentsBuilder.fromHttpUrl(url).queryParams(new LinkedMultiValueMap<>(reqTemp.getQueryParams())).build().toUriString(); + + // 配置请求头 + HttpHeaders headers = new HttpHeaders(); + reqTemp.getHeaders().forEach((key, values) -> headers.addAll(key, values)); + + // 设置Content-Type,如果未设置则使用默认值 + headers.setContentType(reqTemp.getMediaType()); + + // 构建请求实体 + HttpEntity httpEntity = (reqTemp.getBody() != null) ? new HttpEntity<>(reqTemp.getBody(), headers) : new HttpEntity<>(headers); + + SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); + factory.setConnectTimeout(reqTemp.getTimeout()); + factory.setReadTimeout(reqTemp.getTimeout()); + RestTemplate restTemplate = new RestTemplate(factory); + + int retryCount = 0; + while (retryCount < reqTemp.getRetryCount()){ + try { + return restTemplate.exchange(url, method, httpEntity, String.class).getBody(); + }catch (Exception e){ + log.warn("请求失败(尝试{}次): {}", retryCount+1, e.getMessage()); + if (retryCount == reqTemp.getRetryCount()-1) { + if (reqTemp.getExceptionStrategy() == HttpReqTemp.ExceptionHandlingStrategy.DEFAULT) { + throw e; + } else if (reqTemp.getExceptionStrategy() == HttpReqTemp.ExceptionHandlingStrategy.FALLBACK) { + return reqTemp.getExample(); + } + } + Threads.sleep(reqTemp.getTimeout()); + retryCount++; + } + } +// // 发送请求并处理响应 +// ResponseEntity response = null; +// try { +// response = restTemplate.exchange(url, method, httpEntity, String.class); +// } catch (Exception e) { +// if (reqTemp.getExceptionStrategy() == HttpReqTemp.ExceptionHandlingStrategy.DEFAULT) { +// log.error("请求失败:{}", e.getMessage()); +// throw e; +// } else if (reqTemp.getExceptionStrategy() == HttpReqTemp.ExceptionHandlingStrategy.FALLBACK) { +// response = new ResponseEntity<>(reqTemp.getExample(), HttpStatus.OK); +// } +// } +// return response.getBody(); + return null; + } + + public static boolean downloadImage(String imageUrl, String savePath){ + if (imageUrl == null || imageUrl.trim().isEmpty()) { + return false; + } + try { + FileUtils.checkParentDir(savePath); + + RestTemplate restTemplate = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Arrays.asList(MediaType.IMAGE_JPEG, MediaType.IMAGE_PNG)); + ResponseEntity response = restTemplate.exchange( + imageUrl, + HttpMethod.GET, + new HttpEntity<>(headers), + byte[].class + ); + if (response.getStatusCode() == HttpStatus.OK) { + Files.write(Paths.get(savePath), response.getBody()); + return true; + } + } catch (Exception e) { + log.error("下载图片失败:{}", e.getMessage()); + } + return false; + } +} + diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/http/OkHttpUtil.java b/box-common/src/main/java/com/mathvision/box/common/utils/http/OkHttpUtil.java new file mode 100644 index 0000000..09eec85 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/http/OkHttpUtil.java @@ -0,0 +1,135 @@ +package com.mathvision.box.common.utils.http; + +import lombok.extern.slf4j.Slf4j; +import okhttp3.*; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Slf4j +public class OkHttpUtil { + private OkHttpUtil() { + } + + /** + * 发送get请求 + * + * @param url 地址 + * @param params 参数 + * @return 请求结果 + */ + public static String get(String url, Map params) { + return get(url, params, null); + } + + public static String get(String url, Map params, Map headers) { + return request("get", url, params, headers); + } + + /** + * 发送post请求 + * + * @param url 地址 + * @param params 参数 + * @return 请求结果 + */ + public static String post(String url, Map params) { + return post(url, params, null); + } + + public static String post(String url, Map params, Map headers) { + return request("post", url, params, headers); + } + + /** + * 发送http请求 + * + * @param method 请求方法 + * @param url 地址 + * @param params 参数 + * @param headers 请求头 + * @return 请求结果 + */ + public static String request(String method, String url, Map params, Map headers) { + if (method == null) { + throw new RuntimeException("请求方法不能为空"); + } + + if (url == null) { + throw new RuntimeException("url不能为空"); + } + + HttpUrl.Builder httpBuilder = HttpUrl.parse(url).newBuilder(); + RequestBody requestBody = null; + + if ("get".equals(method) || "head".equals(method) || "delete".equals(method)) { + // 添加 QueryParam + if (params != null) { + for (Map.Entry param : params.entrySet()) { + httpBuilder.addQueryParameter(param.getKey(), param.getValue()); + } + } + } else { + FormBody.Builder formBodyBuilder = new FormBody.Builder(); + if (params != null) { + for (Map.Entry param : params.entrySet()) { + formBodyBuilder.add(param.getKey(), param.getValue()); + } + } + requestBody = formBodyBuilder.build(); + } + Request.Builder requestBuilder = new Request.Builder().url(httpBuilder.build()); + + // 添加请求头 + if (headers != null) { + for (Map.Entry header : headers.entrySet()) { + requestBuilder.addHeader(header.getKey(), header.getValue()); + } + } + + // 设置请求方法和请求体 + if (requestBody != null) { + requestBuilder.method(method, requestBody); + } else { + requestBuilder.method(method, new FormBody.Builder().build()); + } + + Request request = requestBuilder.build(); + + try { + OkHttpClient client = new OkHttpClient.Builder() + .readTimeout(20, TimeUnit.SECONDS) + .build(); + Response response = client.newCall(request).execute(); + if (!response.isSuccessful()) { + throw new IOException("请求失败,状态码: " + response.code()); + } + return response.body().string(); + } catch (IOException e) { + log.error("[OKHttpUtil]: 请求失败{}", e.getMessage()); + return null; + } + } + + /** + * 发送post请求(json格式) + * + * @param url url + * @param json json字符串 + * @return 请求结果 + */ + public static String postJson(String url, String json) { + Request request = new Request.Builder() + .url(url) + .post(RequestBody.Companion.create(json, MediaType.Companion.parse("application/json"))) + .build(); + try { + OkHttpClient client = new OkHttpClient(); + Response response = client.newCall(request).execute(); + return response.body().string(); + } catch (IOException e) { + return null; + } + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/poi/ExcelHandlerAdapter.java b/box-common/src/main/java/com/mathvision/box/common/utils/poi/ExcelHandlerAdapter.java new file mode 100644 index 0000000..f14f723 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/poi/ExcelHandlerAdapter.java @@ -0,0 +1,25 @@ +package com.mathvision.box.common.utils.poi; + + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Workbook; + +/** + * @Author: fy + * @Date: 2024/04/08 + * @Description:Excel数据格式处理适配器 + */ +public interface ExcelHandlerAdapter +{ + /** + * 格式化 + * + * @param value 单元格数据值 + * @param args excel注解args参数组 + * @param cell 单元格对象 + * @param wb 工作簿对象 + * + * @return 处理后的值 + */ + Object format(Object value, String[] args, Cell cell, Workbook wb); +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/poi/ExcelUtil.java b/box-common/src/main/java/com/mathvision/box/common/utils/poi/ExcelUtil.java new file mode 100644 index 0000000..5fcd885 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/poi/ExcelUtil.java @@ -0,0 +1,1440 @@ +package com.mathvision.box.common.utils.poi; + +import com.mathvision.box.common.annotation.excel.Excel; +import com.mathvision.box.common.annotation.excel.Excels; +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.domain.ResultCode; +import com.mathvision.box.common.core.text.Convert; +import com.mathvision.box.common.exception.UtilException; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.file.FileTypeUtils; +import com.mathvision.box.common.utils.file.FileUtils; +import com.mathvision.box.common.utils.file.ImageUtils; +import com.mathvision.box.common.utils.reflect.ReflectUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.RegExUtils; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ooxml.POIXMLDocumentPart; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellRangeAddressList; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; +import org.apache.poi.xssf.usermodel.*; +import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.text.DecimalFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * Excel相关处理 + */ +public class ExcelUtil { + private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); + + public static final String FORMULA_REGEX_STR = "=|-|\\+|@"; + + public static final String[] FORMULA_STR = {"=", "-", "+", "@"}; + + /** + * 用于dictType属性数据存储,避免重复查缓存 + */ + public Map sysDictMap = new HashMap(); + + /** + * Excel sheet最大行数,默认65536 + */ + public static final int sheetSize = 65536; + + /** + * 工作表名称 + */ + private String sheetName; + + /** + * 导出类型(EXPORT:导出数据;IMPORT:导入模板) + */ + private Excel.Type type; + + /** + * 工作薄对象 + */ + private Workbook wb; + + /** + * 工作表对象 + */ + private Sheet sheet; + + /** + * 样式列表 + */ + private Map styles; + + /** + * 导入导出数据列表 + */ + private List list; + + /** + * 注解列表 + */ + private List fields; + + /** + * 当前行号 + */ + private int rownum; + + /** + * 标题 + */ + private String title; + + /** + * 最大高度 + */ + private short maxHeight; + + /** + * 合并后最后行数 + */ + private int subMergedLastRowNum = 0; + + /** + * 合并后开始行数 + */ + private int subMergedFirstRowNum = 1; + + /** + * 对象的子列表方法 + */ + private Method subMethod; + + /** + * 对象的子列表属性 + */ + private List subFields; + + /** + * 统计列表 + */ + private Map statistics = new HashMap(); + + /** + * 数字格式 + */ + private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("######0.00"); + + /** + * 实体对象 + */ + public Class clazz; + + /** + * 需要排除列属性 + */ + public String[] excludeFields; + + public ExcelUtil(Class clazz) { + this.clazz = clazz; + } + + /** + * 隐藏Excel中列属性 + * + * @param fields 列属性名 示例[单个"name"/多个"id","name"] + * @throws Exception + */ + public void hideColumn(String... fields) { + this.excludeFields = fields; + } + + public void init(List list, String sheetName, String title, Excel.Type type) { + if (list == null) { + list = new ArrayList(); + } + this.list = list; + this.sheetName = sheetName; + this.type = type; + this.title = title; + createExcelField(); + createWorkbook(); + createTitle(); + createSubHead(); + } + + /** + * 创建excel第一行标题 + */ + public void createTitle() { + if (StringUtils.isNotEmpty(title)) { + subMergedFirstRowNum++; + subMergedLastRowNum++; + int titleLastCol = this.fields.size() - 1; + if (isSubList()) { + titleLastCol = titleLastCol + subFields.size() - 1; + } + Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0); + titleRow.setHeightInPoints(30); + Cell titleCell = titleRow.createCell(0); + titleCell.setCellStyle(styles.get("title")); + titleCell.setCellValue(title); + sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(), titleLastCol)); + } + } + + /** + * 创建对象的子列表名称 + */ + public void createSubHead() { + if (isSubList()) { + subMergedFirstRowNum++; + subMergedLastRowNum++; + Row subRow = sheet.createRow(rownum); + int excelNum = 0; + for (Object[] objects : fields) { + Excel attr = (Excel) objects[1]; + Cell headCell1 = subRow.createCell(excelNum); + headCell1.setCellValue(attr.name()); + headCell1.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor()))); + excelNum++; + } + int headFirstRow = excelNum - 1; + int headLastRow = headFirstRow + subFields.size() - 1; + if (headLastRow > headFirstRow) { + sheet.addMergedRegion(new CellRangeAddress(rownum, rownum, headFirstRow, headLastRow)); + } + rownum++; + } + } + + /** + * 对excel表单默认第一个索引名转换成list + * + * @param is 输入流 + * @return 转换后集合 + */ + public List importExcel(InputStream is) { + List list = null; + try { + list = importExcel(is, 0); + } catch (Exception e) { + log.error("导入Excel异常{}", e.getMessage()); + throw new UtilException(e.getMessage()); + } finally { + IOUtils.closeQuietly(is); + } + return list; + } + + /** + * 对excel表单默认第一个索引名转换成list + * + * @param is 输入流 + * @param titleNum 标题占用行数 + * @return 转换后集合 + */ + public List importExcel(InputStream is, int titleNum) throws Exception { + return importExcel(StringUtils.EMPTY, is, titleNum); + } + + /** + * 对excel表单指定表格索引名转换成list + * + * @param sheetName 表格索引名 + * @param titleNum 标题占用行数 + * @param is 输入流 + * @return 转换后集合 + */ + public List importExcel(String sheetName, InputStream is, int titleNum) throws Exception { + this.type = Excel.Type.IMPORT; + this.wb = WorkbookFactory.create(is); + List list = new ArrayList(); + // 如果指定sheet名,则取指定sheet中的内容 否则默认指向第1个sheet + Sheet sheet = StringUtils.isNotEmpty(sheetName) ? wb.getSheet(sheetName) : wb.getSheetAt(0); + if (sheet == null) { + throw new IOException("文件sheet不存在"); + } + boolean isXSSFWorkbook = !(wb instanceof HSSFWorkbook); + Map pictures; + if (isXSSFWorkbook) { + pictures = getSheetPictures07((XSSFSheet) sheet, (XSSFWorkbook) wb); + } else { + pictures = getSheetPictures03((HSSFSheet) sheet, (HSSFWorkbook) wb); + } + // 获取最后一个非空行的行下标,比如总行数为n,则返回的为n-1 + int rows = sheet.getLastRowNum(); + if (rows > 0) { + // 定义一个map用于存放excel列的序号和field. + Map cellMap = new HashMap(); + // 获取表头 + Row heard = sheet.getRow(titleNum); + for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) { + Cell cell = heard.getCell(i); + if (StringUtils.isNotNull(cell)) { + String value = this.getCellValue(heard, i).toString(); + cellMap.put(value, i); + } else { + cellMap.put(null, i); + } + } + // 有数据时才处理 得到类的所有field. + List fields = this.getFields(); + Map fieldsMap = new HashMap(); + for (Object[] objects : fields) { + Excel attr = (Excel) objects[1]; + Integer column = cellMap.get(attr.name()); + if (column != null) { + fieldsMap.put(column, objects); + } + } + for (int i = titleNum + 1; i <= rows; i++) { + // 从第2行开始取数据,默认第一行是表头. + Row row = sheet.getRow(i); + // 判断当前行是否是空行 + if (isRowEmpty(row)) { + continue; + } + T entity = null; + for (Map.Entry entry : fieldsMap.entrySet()) { + Object val = this.getCellValue(row, entry.getKey()); + + // 如果不存在实例则新建. + entity = (entity == null ? clazz.newInstance() : entity); + // 从map中得到对应列的field. + Field field = (Field) entry.getValue()[0]; + Excel attr = (Excel) entry.getValue()[1]; + // 取得类型,并根据对象类型设置值. + Class fieldType = field.getType(); + if (String.class == fieldType) { + String s = Convert.toStr(val); + if (StringUtils.endsWith(s, ".0")) { + val = StringUtils.substringBefore(s, ".0"); + } else { + String dateFormat = field.getAnnotation(Excel.class).dateFormat(); + if (StringUtils.isNotEmpty(dateFormat)) { + val = parseDateToStr(dateFormat, val); + } else { + val = Convert.toStr(val); + } + } + } else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) { + val = Convert.toInt(val); + } else if ((Long.TYPE == fieldType || Long.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) { + val = Convert.toLong(val); + } else if (Double.TYPE == fieldType || Double.class == fieldType) { + val = Convert.toDouble(val); + } else if (Float.TYPE == fieldType || Float.class == fieldType) { + val = Convert.toFloat(val); + } else if (BigDecimal.class == fieldType) { + val = Convert.toBigDecimal(val); + } else if (Date.class == fieldType) { + if (val instanceof String) { + val = DateUtils.parseDate(val); + } else if (val instanceof Double) { + val = DateUtil.getJavaDate((Double) val); + } + } else if (Boolean.TYPE == fieldType || Boolean.class == fieldType) { + val = Convert.toBool(val, false); + } + if (StringUtils.isNotNull(fieldType)) { + String propertyName = field.getName(); + if (StringUtils.isNotEmpty(attr.targetAttr())) { + propertyName = field.getName() + "." + attr.targetAttr(); + } + if (StringUtils.isNotEmpty(attr.readConverterExp())) { + val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator()); + } else if (StringUtils.isNotEmpty(attr.dictType())) { + val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator()); + } else if (!attr.handler().equals(ExcelHandlerAdapter.class)) { + val = dataFormatHandlerAdapter(val, attr, null); + } else if (Excel.ColumnType.IMAGE == attr.cellType() && StringUtils.isNotEmpty(pictures)) { + PictureData image = pictures.get(row.getRowNum() + "_" + entry.getKey()); + if (image == null) { + val = ""; + } else { + byte[] data = image.getData(); + val = FileUtils.writeImportBytes(data); + } + } + ReflectUtils.invokeSetter(entity, propertyName, val); + } + } + list.add(entity); + } + } + return list; + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @return 结果 + */ + public Result exportExcel(List list, String sheetName) { + return exportExcel(list, sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public Result exportExcel(List list, String sheetName, String title) { + this.init(list, sheetName, title, Excel.Type.EXPORT); + return exportExcel(); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param response 返回数据 + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @return 结果 + */ + public void exportExcel(HttpServletResponse response, List list, String sheetName) throws Exception { + exportExcel(response, list, sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param response 返回数据 + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public void exportExcel(HttpServletResponse response, List list, String sheetName, String title) { + try { + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(sheetName + "_" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8") + "\""); + this.init(list, sheetName, title, Excel.Type.EXPORT); + exportExcel(response); + } catch (Exception e) { + log.error("导出excel失败", e.getMessage(), e); + } + + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @return 结果 + */ + public Result importTemplateExcel(String sheetName) { + return importTemplateExcel(sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public Result importTemplateExcel(String sheetName, String title) { + this.init(null, sheetName, title, Excel.Type.IMPORT); + return exportExcel(); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @return 结果 + */ + public void importTemplateExcel(HttpServletResponse response, String sheetName) { + importTemplateExcel(response, sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) { + try { + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(sheetName + "_" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8") + "\""); + this.init(null, sheetName, title, Excel.Type.IMPORT); + exportExcel(response); + } catch (Exception e) { + log.error("导出模板Excel异常{}", e.getMessage(), e); + } + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @return 结果 + */ + public void exportExcel(HttpServletResponse response) { + try { + writeSheet(); + wb.write(response.getOutputStream()); + } catch (Exception e) { + log.error("导出Excel异常{}", e.getMessage()); + } finally { + IOUtils.closeQuietly(wb); + } + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @return 结果 + */ + public Result exportExcel() { + OutputStream out = null; + try { + writeSheet(); + String filename = encodingFilename(sheetName); + out = new FileOutputStream(getAbsoluteFile(filename)); + wb.write(out); + return new Result(ResultCode.success, filename); + } catch (Exception e) { + log.error("导出Excel异常{}", e.getMessage()); + throw new UtilException("导出Excel失败,请联系网站管理员!"); + } finally { + IOUtils.closeQuietly(wb); + IOUtils.closeQuietly(out); + } + } + + /** + * 创建写入数据到Sheet + */ + public void writeSheet() { + // 取出一共有多少个sheet. + int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / sheetSize)); + for (int index = 0; index < sheetNo; index++) { + createSheet(sheetNo, index); + + // 产生一行 + Row row = sheet.createRow(rownum); + int column = 0; + // 写入各个字段的列头名称 + for (Object[] os : fields) { + Field field = (Field) os[0]; + Excel excel = (Excel) os[1]; + if (Collection.class.isAssignableFrom(field.getType())) { + for (Field subField : subFields) { + Excel subExcel = subField.getAnnotation(Excel.class); + this.createHeadCell(subExcel, row, column++); + } + } else { + this.createHeadCell(excel, row, column++); + } + } + if (Excel.Type.EXPORT.equals(type)) { + fillExcelData(index, row); + addStatisticsRow(); + } + } + } + + /** + * 填充excel数据 + * + * @param index 序号 + * @param row 单元格行 + */ + @SuppressWarnings("unchecked") + public void fillExcelData(int index, Row row) { + int startNo = index * sheetSize; + int endNo = Math.min(startNo + sheetSize, list.size()); + int rowNo = (1 + rownum) - startNo; + for (int i = startNo; i < endNo; i++) { + rowNo = isSubList() ? (i > 1 ? rowNo + 1 : rowNo + i) : i + 1 + rownum - startNo; + row = sheet.createRow(rowNo); + // 得到导出对象. + T vo = (T) list.get(i); + Collection subList = null; + if (isSubList()) { + if (isSubListValue(vo)) { + subList = getListCellValue(vo); + subMergedLastRowNum = subMergedLastRowNum + subList.size(); + } else { + subMergedFirstRowNum++; + subMergedLastRowNum++; + } + } + int column = 0; + for (Object[] os : fields) { + Field field = (Field) os[0]; + Excel excel = (Excel) os[1]; + if (Collection.class.isAssignableFrom(field.getType()) && StringUtils.isNotNull(subList)) { + boolean subFirst = false; + for (Object obj : subList) { + if (subFirst) { + rowNo++; + row = sheet.createRow(rowNo); + } + List subFields = FieldUtils.getFieldsListWithAnnotation(obj.getClass(), Excel.class); + int subIndex = 0; + for (Field subField : subFields) { + if (subField.isAnnotationPresent(Excel.class)) { + subField.setAccessible(true); + Excel attr = subField.getAnnotation(Excel.class); + this.addCell(attr, row, (T) obj, subField, column + subIndex); + } + subIndex++; + } + subFirst = true; + } + this.subMergedFirstRowNum = this.subMergedFirstRowNum + subList.size(); + } else { + this.addCell(excel, row, vo, field, column++); + } + } + } + } + + /** + * 创建表格样式 + * + * @param wb 工作薄对象 + * @return 样式列表 + */ + private Map createStyles(Workbook wb) { + // 写入各条记录,每条记录对应excel表中的一行 + Map styles = new HashMap(); + CellStyle style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + Font titleFont = wb.createFont(); + titleFont.setFontName("Arial"); + titleFont.setFontHeightInPoints((short) 16); + titleFont.setBold(true); + style.setFont(titleFont); + styles.put("title", style); + + style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setBorderRight(BorderStyle.THIN); + style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderLeft(BorderStyle.THIN); + style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderTop(BorderStyle.THIN); + style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderBottom(BorderStyle.THIN); + style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + Font dataFont = wb.createFont(); + dataFont.setFontName("Arial"); + dataFont.setFontHeightInPoints((short) 10); + style.setFont(dataFont); + styles.put("data", style); + + style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + Font totalFont = wb.createFont(); + totalFont.setFontName("Arial"); + totalFont.setFontHeightInPoints((short) 10); + style.setFont(totalFont); + styles.put("total", style); + + styles.putAll(annotationHeaderStyles(wb, styles)); + + styles.putAll(annotationDataStyles(wb)); + + return styles; + } + + /** + * 根据Excel注解创建表格头样式 + * + * @param wb 工作薄对象 + * @return 自定义样式列表 + */ + private Map annotationHeaderStyles(Workbook wb, Map styles) { + Map headerStyles = new HashMap(); + for (Object[] os : fields) { + Excel excel = (Excel) os[1]; + String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor()); + if (!headerStyles.containsKey(key)) { + CellStyle style = wb.createCellStyle(); + style.cloneStyleFrom(styles.get("data")); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setFillForegroundColor(excel.headerBackgroundColor().index); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + Font headerFont = wb.createFont(); + headerFont.setFontName("Arial"); + headerFont.setFontHeightInPoints((short) 10); + headerFont.setBold(true); + headerFont.setColor(excel.headerColor().index); + style.setFont(headerFont); + headerStyles.put(key, style); + } + } + return headerStyles; + } + + /** + * 根据Excel注解创建表格列样式 + * + * @param wb 工作薄对象 + * @return 自定义样式列表 + */ + private Map annotationDataStyles(Workbook wb) { + Map styles = new HashMap(); + for (Object[] os : fields) { + Excel excel = (Excel) os[1]; + String key = StringUtils.format("data_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor()); + if (!styles.containsKey(key)) { + CellStyle style = wb.createCellStyle(); + style.setAlignment(excel.align()); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setBorderRight(BorderStyle.THIN); + style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderLeft(BorderStyle.THIN); + style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderTop(BorderStyle.THIN); + style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderBottom(BorderStyle.THIN); + style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + style.setFillForegroundColor(excel.backgroundColor().getIndex()); + Font dataFont = wb.createFont(); + dataFont.setFontName("Arial"); + dataFont.setFontHeightInPoints((short) 10); + dataFont.setColor(excel.color().index); + style.setFont(dataFont); + styles.put(key, style); + } + } + return styles; + } + + /** + * 创建单元格 + */ + public Cell createHeadCell(Excel attr, Row row, int column) { + // 创建列 + Cell cell = row.createCell(column); + // 写入列信息 + cell.setCellValue(attr.name()); + setDataValidation(attr, row, column); + cell.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor()))); + if (isSubList()) { + // 填充默认样式,防止合并单元格样式失效 + sheet.setDefaultColumnStyle(column, styles.get(StringUtils.format("data_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor()))); + if (attr.needMerge()) { + sheet.addMergedRegion(new CellRangeAddress(rownum - 1, rownum, column, column)); + } + } + return cell; + } + + /** + * 设置单元格信息 + * + * @param value 单元格值 + * @param attr 注解相关 + * @param cell 单元格信息 + */ + public void setCellVo(Object value, Excel attr, Cell cell) { + if (Excel.ColumnType.STRING == attr.cellType()) { + String cellValue = Convert.toStr(value); + // 对于任何以表达式触发字符 =-+@开头的单元格,直接使用tab字符作为前缀,防止CSV注入。 + if (StringUtils.startsWithAny(cellValue, FORMULA_STR)) { + cellValue = RegExUtils.replaceFirst(cellValue, FORMULA_REGEX_STR, "\t$0"); + } + if (value instanceof Collection && StringUtils.equals("[]", cellValue)) { + cellValue = StringUtils.EMPTY; + } + cell.setCellValue(StringUtils.isNull(cellValue) ? attr.defaultValue() : cellValue + attr.suffix()); + } else if (Excel.ColumnType.NUMERIC == attr.cellType()) { + if (StringUtils.isNotNull(value)) { + cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value)); + } + } else if (Excel.ColumnType.IMAGE == attr.cellType()) { + ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 1), cell.getRow().getRowNum() + 1); + String imagePath = Convert.toStr(value); + if (StringUtils.isNotEmpty(imagePath)) { + byte[] data = ImageUtils.getImage(imagePath); + getDrawingPatriarch(cell.getSheet()).createPicture(anchor, + cell.getSheet().getWorkbook().addPicture(data, getImageType(data))); + } + } + } + + /** + * 获取画布 + */ + public static Drawing getDrawingPatriarch(Sheet sheet) { + if (sheet.getDrawingPatriarch() == null) { + sheet.createDrawingPatriarch(); + } + return sheet.getDrawingPatriarch(); + } + + /** + * 获取图片类型,设置图片插入类型 + */ + public int getImageType(byte[] value) { + String type = FileTypeUtils.getFileExtendName(value); + if ("JPG".equalsIgnoreCase(type)) { + return Workbook.PICTURE_TYPE_JPEG; + } else if ("PNG".equalsIgnoreCase(type)) { + return Workbook.PICTURE_TYPE_PNG; + } + return Workbook.PICTURE_TYPE_JPEG; + } + + /** + * 创建表格样式 + */ + public void setDataValidation(Excel attr, Row row, int column) { + if (attr.name().indexOf("注:") >= 0) { + sheet.setColumnWidth(column, 6000); + } else { + // 设置列宽 + sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256)); + } + if (StringUtils.isNotEmpty(attr.prompt()) || attr.combo().length > 0) { + if (attr.combo().length > 15 || StringUtils.join(attr.combo()).length() > 255) { + // 如果下拉数大于15或字符串长度大于255,则使用一个新sheet存储,避免生成的模板下拉值获取不到 + setXSSFValidationWithHidden(sheet, attr.combo(), attr.prompt(), 1, 100, column, column); + } else { + // 提示信息或只能选择不能输入的列内容. + setPromptOrValidation(sheet, attr.combo(), attr.prompt(), 1, 100, column, column); + } + } + } + + /** + * 添加单元格 + */ + public Cell addCell(Excel attr, Row row, T vo, Field field, int column) { + Cell cell = null; + try { + // 设置行高 + row.setHeight(maxHeight); + // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. + if (attr.isExport()) { + // 创建cell + cell = row.createCell(column); + if (isSubListValue(vo) && getListCellValue(vo).size() > 1 && attr.needMerge()) { + CellRangeAddress cellAddress = new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column); + sheet.addMergedRegion(cellAddress); + } + cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor()))); + + // 用于读取对象中的属性 + Object value = getTargetValue(vo, field, attr); + String dateFormat = attr.dateFormat(); + String readConverterExp = attr.readConverterExp(); + String separator = attr.separator(); + String dictType = attr.dictType(); + if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) { + cell.setCellValue(parseDateToStr(dateFormat, value)); + } else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) { + cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator)); + } else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value)) { + if (!sysDictMap.containsKey(dictType + value)) { + String lable = convertDictByExp(Convert.toStr(value), dictType, separator); + sysDictMap.put(dictType + value, lable); + } + cell.setCellValue(sysDictMap.get(dictType + value)); + } else if (value instanceof BigDecimal && -1 != attr.scale()) { + cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).doubleValue()); + } else if (!attr.handler().equals(ExcelHandlerAdapter.class)) { + cell.setCellValue(dataFormatHandlerAdapter(value, attr, cell)); + } else { + // 设置列类型 + setCellVo(value, attr, cell); + } + addStatisticsData(column, Convert.toStr(value), attr); + } + } catch (Exception e) { + log.error("导出Excel失败{}", e); + } + return cell; + } + + /** + * 设置 POI XSSFSheet 单元格提示或选择框 + * + * @param sheet 表单 + * @param textlist 下拉框显示的内容 + * @param promptContent 提示内容 + * @param firstRow 开始行 + * @param endRow 结束行 + * @param firstCol 开始列 + * @param endCol 结束列 + */ + public void setPromptOrValidation(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow, + int firstCol, int endCol) { + DataValidationHelper helper = sheet.getDataValidationHelper(); + DataValidationConstraint constraint = textlist.length > 0 ? helper.createExplicitListConstraint(textlist) : helper.createCustomConstraint("DD1"); + CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); + DataValidation dataValidation = helper.createValidation(constraint, regions); + if (StringUtils.isNotEmpty(promptContent)) { + // 如果设置了提示信息则鼠标放上去提示 + dataValidation.createPromptBox("", promptContent); + dataValidation.setShowPromptBox(true); + } + // 处理Excel兼容性问题 + if (dataValidation instanceof XSSFDataValidation) { + dataValidation.setSuppressDropDownArrow(true); + dataValidation.setShowErrorBox(true); + } else { + dataValidation.setSuppressDropDownArrow(false); + } + sheet.addValidationData(dataValidation); + } + + /** + * 设置某些列的值只能输入预制的数据,显示下拉框(兼容超出一定数量的下拉框). + * + * @param sheet 要设置的sheet. + * @param textlist 下拉框显示的内容 + * @param promptContent 提示内容 + * @param firstRow 开始行 + * @param endRow 结束行 + * @param firstCol 开始列 + * @param endCol 结束列 + */ + public void setXSSFValidationWithHidden(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow, int firstCol, int endCol) { + String hideSheetName = "combo_" + firstCol + "_" + endCol; + Sheet hideSheet = wb.createSheet(hideSheetName); // 用于存储 下拉菜单数据 + for (int i = 0; i < textlist.length; i++) { + hideSheet.createRow(i).createCell(0).setCellValue(textlist[i]); + } + // 创建名称,可被其他单元格引用 + Name name = wb.createName(); + name.setNameName(hideSheetName + "_data"); + name.setRefersToFormula(hideSheetName + "!$A$1:$A$" + textlist.length); + DataValidationHelper helper = sheet.getDataValidationHelper(); + // 加载下拉列表内容 + DataValidationConstraint constraint = helper.createFormulaListConstraint(hideSheetName + "_data"); + // 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列 + CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); + // 数据有效性对象 + DataValidation dataValidation = helper.createValidation(constraint, regions); + if (StringUtils.isNotEmpty(promptContent)) { + // 如果设置了提示信息则鼠标放上去提示 + dataValidation.createPromptBox("", promptContent); + dataValidation.setShowPromptBox(true); + } + // 处理Excel兼容性问题 + if (dataValidation instanceof XSSFDataValidation) { + dataValidation.setSuppressDropDownArrow(true); + dataValidation.setShowErrorBox(true); + } else { + dataValidation.setSuppressDropDownArrow(false); + } + + sheet.addValidationData(dataValidation); + // 设置hiddenSheet隐藏 + wb.setSheetHidden(wb.getSheetIndex(hideSheet), true); + } + + /** + * 解析导出值 0=男,1=女,2=未知 + * + * @param propertyValue 参数值 + * @param converterExp 翻译注解 + * @param separator 分隔符 + * @return 解析后值 + */ + public static String convertByExp(String propertyValue, String converterExp, String separator) { + StringBuilder propertyString = new StringBuilder(); + String[] convertSource = converterExp.split(","); + for (String item : convertSource) { + String[] itemArray = item.split("="); + if (StringUtils.containsAny(propertyValue, separator)) { + for (String value : propertyValue.split(separator)) { + if (itemArray[0].equals(value)) { + propertyString.append(itemArray[1] + separator); + break; + } + } + } else { + if (itemArray[0].equals(propertyValue)) { + return itemArray[1]; + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + /** + * 反向解析值 男=0,女=1,未知=2 + * + * @param propertyValue 参数值 + * @param converterExp 翻译注解 + * @param separator 分隔符 + * @return 解析后值 + */ + public static String reverseByExp(String propertyValue, String converterExp, String separator) { + StringBuilder propertyString = new StringBuilder(); + String[] convertSource = converterExp.split(","); + for (String item : convertSource) { + String[] itemArray = item.split("="); + if (StringUtils.containsAny(propertyValue, separator)) { + for (String value : propertyValue.split(separator)) { + if (itemArray[1].equals(value)) { + propertyString.append(itemArray[0] + separator); + break; + } + } + } else { + if (itemArray[1].equals(propertyValue)) { + return itemArray[0]; + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + /** + * 解析字典值 + * + * @param dictValue 字典值 + * @param dictType 字典类型 + * @param separator 分隔符 + * @return 字典标签 + */ + public static String convertDictByExp(String dictValue, String dictType, String separator) { +// return DictUtils.getDictLabel(dictType, dictValue, separator); + return null; + } + + /** + * 反向解析值字典值 + * + * @param dictLabel 字典标签 + * @param dictType 字典类型 + * @param separator 分隔符 + * @return 字典值 + */ + public static String reverseDictByExp(String dictLabel, String dictType, String separator) { +// return DictUtils.getDictValue(dictType, dictLabel, separator); + return null; + } + + /** + * 数据处理器 + * + * @param value 数据值 + * @param excel 数据注解 + * @return + */ + public String dataFormatHandlerAdapter(Object value, Excel excel, Cell cell) { + try { + Object instance = excel.handler().newInstance(); + Method formatMethod = excel.handler().getMethod("format", new Class[]{Object.class, String[].class, Cell.class, Workbook.class}); + value = formatMethod.invoke(instance, value, excel.args(), cell, this.wb); + } catch (Exception e) { + log.error("不能格式化数据 " + excel.handler(), e.getMessage()); + } + return Convert.toStr(value); + } + + /** + * 合计统计信息 + */ + private void addStatisticsData(Integer index, String text, Excel entity) { + if (entity != null && entity.isStatistics()) { + Double temp = 0D; + if (!statistics.containsKey(index)) { + statistics.put(index, temp); + } + try { + temp = Double.valueOf(text); + } catch (NumberFormatException e) { + } + statistics.put(index, statistics.get(index) + temp); + } + } + + /** + * 创建统计行 + */ + public void addStatisticsRow() { + if (statistics.size() > 0) { + Row row = sheet.createRow(sheet.getLastRowNum() + 1); + Set keys = statistics.keySet(); + Cell cell = row.createCell(0); + cell.setCellStyle(styles.get("total")); + cell.setCellValue("合计"); + + for (Integer key : keys) { + cell = row.createCell(key); + cell.setCellStyle(styles.get("total")); + cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key))); + } + statistics.clear(); + } + } + + /** + * 编码文件名 + */ + public String encodingFilename(String filename) { + filename = UUID.randomUUID() + "_" + filename + ".xlsx"; + return filename; + } + + /** + * 获取下载路径 + * + * @param filename 文件名称 + */ + public String getAbsoluteFile(String filename) { + String downloadPath = AppConfig.getDownloadPath() + filename; + File desc = new File(downloadPath); + if (!desc.getParentFile().exists()) { + desc.getParentFile().mkdirs(); + } + return downloadPath; + } + + /** + * 获取bean中的属性值 + * + * @param vo 实体对象 + * @param field 字段 + * @param excel 注解 + * @return 最终的属性值 + * @throws Exception + */ + private Object getTargetValue(T vo, Field field, Excel excel) throws Exception { + Object o = field.get(vo); + if (StringUtils.isNotEmpty(excel.targetAttr())) { + String target = excel.targetAttr(); + if (target.contains(".")) { + String[] targets = target.split("[.]"); + for (String name : targets) { + o = getValue(o, name); + } + } else { + o = getValue(o, target); + } + } + return o; + } + + /** + * 以类的属性的get方法方法形式获取值 + * + * @param o + * @param name + * @return value + * @throws Exception + */ + private Object getValue(Object o, String name) throws Exception { + if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name)) { + Class clazz = o.getClass(); + Field field = clazz.getDeclaredField(name); + field.setAccessible(true); + o = field.get(o); + } + return o; + } + + /** + * 得到所有定义字段 + */ + private void createExcelField() { + this.fields = getFields(); + this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList()); + this.maxHeight = getRowHeight(); + } + + /** + * 获取字段注解信息 + */ + public List getFields() { + List fields = new ArrayList(); + List tempFields = new ArrayList<>(); + tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); + tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); + for (Field field : tempFields) { + if (!ArrayUtils.contains(this.excludeFields, field.getName())) { + // 单注解 + if (field.isAnnotationPresent(Excel.class)) { + Excel attr = field.getAnnotation(Excel.class); + if (attr != null && (attr.type() == Excel.Type.ALL || attr.type() == type)) { + field.setAccessible(true); + fields.add(new Object[]{field, attr}); + } + if (Collection.class.isAssignableFrom(field.getType())) { + subMethod = getSubMethod(field.getName(), clazz); + ParameterizedType pt = (ParameterizedType) field.getGenericType(); + Class subClass = (Class) pt.getActualTypeArguments()[0]; + this.subFields = FieldUtils.getFieldsListWithAnnotation(subClass, Excel.class); + } + } + + // 多注解 + if (field.isAnnotationPresent(Excels.class)) { + Excels attrs = field.getAnnotation(Excels.class); + Excel[] excels = attrs.value(); + for (Excel attr : excels) { + if (!ArrayUtils.contains(this.excludeFields, field.getName() + "." + attr.targetAttr()) + && (attr != null && (attr.type() == Excel.Type.ALL || attr.type() == type))) { + field.setAccessible(true); + fields.add(new Object[]{field, attr}); + } + } + } + } + } + return fields; + } + + /** + * 根据注解获取最大行高 + */ + public short getRowHeight() { + double maxHeight = 0; + for (Object[] os : this.fields) { + Excel excel = (Excel) os[1]; + maxHeight = Math.max(maxHeight, excel.height()); + } + return (short) (maxHeight * 20); + } + + /** + * 创建一个工作簿 + */ + public void createWorkbook() { + this.wb = new SXSSFWorkbook(500); + this.sheet = wb.createSheet(); + wb.setSheetName(0, sheetName); + this.styles = createStyles(wb); + } + + /** + * 创建工作表 + * + * @param sheetNo sheet数量 + * @param index 序号 + */ + public void createSheet(int sheetNo, int index) { + // 设置工作表的名称. + if (sheetNo > 1 && index > 0) { + this.sheet = wb.createSheet(); + this.createTitle(); + wb.setSheetName(index, sheetName + index); + } + } + + /** + * 获取单元格值 + * + * @param row 获取的行 + * @param column 获取单元格列号 + * @return 单元格值 + */ + public Object getCellValue(Row row, int column) { + if (row == null) { + return row; + } + Object val = ""; + try { + Cell cell = row.getCell(column); + if (StringUtils.isNotNull(cell)) { + if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA) { + val = cell.getNumericCellValue(); + if (DateUtil.isCellDateFormatted(cell)) { + val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换 + } else { + if ((Double) val % 1 != 0) { + val = new BigDecimal(val.toString()); + } else { + val = new DecimalFormat("0").format(val); + } + } + } else if (cell.getCellType() == CellType.STRING) { + val = cell.getStringCellValue(); + } else if (cell.getCellType() == CellType.BOOLEAN) { + val = cell.getBooleanCellValue(); + } else if (cell.getCellType() == CellType.ERROR) { + val = cell.getErrorCellValue(); + } + + } + } catch (Exception e) { + return val; + } + return val; + } + + /** + * 判断是否是空行 + * + * @param row 判断的行 + * @return + */ + private boolean isRowEmpty(Row row) { + if (row == null) { + return true; + } + for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) { + Cell cell = row.getCell(i); + if (cell != null && cell.getCellType() != CellType.BLANK) { + return false; + } + } + return true; + } + + /** + * 获取Excel2003图片 + * + * @param sheet 当前sheet对象 + * @param workbook 工作簿对象 + * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData + */ + public static Map getSheetPictures03(HSSFSheet sheet, HSSFWorkbook workbook) { + Map sheetIndexPicMap = new HashMap(); + List pictures = workbook.getAllPictures(); + if (!pictures.isEmpty()) { + for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) { + HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor(); + if (shape instanceof HSSFPicture) { + HSSFPicture pic = (HSSFPicture) shape; + int pictureIndex = pic.getPictureIndex() - 1; + HSSFPictureData picData = pictures.get(pictureIndex); + String picIndex = anchor.getRow1() + "_" + anchor.getCol1(); + sheetIndexPicMap.put(picIndex, picData); + } + } + return sheetIndexPicMap; + } else { + return sheetIndexPicMap; + } + } + + /** + * 获取Excel2007图片 + * + * @param sheet 当前sheet对象 + * @param workbook 工作簿对象 + * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData + */ + public static Map getSheetPictures07(XSSFSheet sheet, XSSFWorkbook workbook) { + Map sheetIndexPicMap = new HashMap(); + for (POIXMLDocumentPart dr : sheet.getRelations()) { + if (dr instanceof XSSFDrawing) { + XSSFDrawing drawing = (XSSFDrawing) dr; + List shapes = drawing.getShapes(); + for (XSSFShape shape : shapes) { + if (shape instanceof XSSFPicture) { + XSSFPicture pic = (XSSFPicture) shape; + XSSFClientAnchor anchor = pic.getPreferredSize(); + CTMarker ctMarker = anchor.getFrom(); + String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol(); + sheetIndexPicMap.put(picIndex, pic.getPictureData()); + } + } + } + } + return sheetIndexPicMap; + } + + /** + * 格式化不同类型的日期对象 + * + * @param dateFormat 日期格式 + * @param val 被格式化的日期对象 + * @return 格式化后的日期字符 + */ + public String parseDateToStr(String dateFormat, Object val) { + if (val == null) { + return ""; + } + String str; + if (val instanceof Date) { + str = DateUtils.parseDateToStr(dateFormat, (Date) val); + } else if (val instanceof LocalDateTime) { + str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDateTime) val)); + } else if (val instanceof LocalDate) { + str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDate) val)); + } else { + str = val.toString(); + } + return str; + } + + /** + * 是否有对象的子列表 + */ + public boolean isSubList() { + return StringUtils.isNotNull(subFields) && subFields.size() > 0; + } + + /** + * 是否有对象的子列表,集合不为空 + */ + public boolean isSubListValue(T vo) { + return StringUtils.isNotNull(subFields) && subFields.size() > 0 && StringUtils.isNotNull(getListCellValue(vo)) && getListCellValue(vo).size() > 0; + } + + /** + * 获取集合的值 + */ + public Collection getListCellValue(Object obj) { + Object value; + try { + value = subMethod.invoke(obj, new Object[]{}); + } catch (Exception e) { + return new ArrayList(); + } + return (Collection) value; + } + + /** + * 获取对象的子列表方法 + * + * @param name 名称 + * @param pojoClass 类对象 + * @return 子列表方法 + */ + public Method getSubMethod(String name, Class pojoClass) { + StringBuffer getMethodName = new StringBuffer("get"); + getMethodName.append(name.substring(0, 1).toUpperCase()); + getMethodName.append(name.substring(1)); + Method method = null; + try { + method = pojoClass.getMethod(getMethodName.toString(), new Class[]{}); + } catch (Exception e) { + log.error("获取对象异常{}", e.getMessage()); + } + return method; + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/reflect/ReflectUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/reflect/ReflectUtils.java new file mode 100644 index 0000000..2d84fa4 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/reflect/ReflectUtils.java @@ -0,0 +1,405 @@ +package com.mathvision.box.common.utils.reflect; + +import com.mathvision.box.common.core.text.Convert; +import com.mathvision.box.common.utils.common.DateUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.poi.ss.usermodel.DateUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.*; +import java.util.Date; + +/** + * 反射工具类. 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数. + * + */ +@SuppressWarnings("rawtypes") +public class ReflectUtils +{ + private static final String SETTER_PREFIX = "set"; + + private static final String GETTER_PREFIX = "get"; + + private static final String CGLIB_CLASS_SEPARATOR = "$$"; + + private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class); + + /** + * 调用Getter方法. + * 支持多级,如:对象名.对象名.方法 + */ + @SuppressWarnings("unchecked") + public static E invokeGetter(Object obj, String propertyName) + { + Object object = obj; + for (String name : StringUtils.split(propertyName, ".")) + { + String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); + object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); + } + return (E) object; + } + + /** + * 调用Setter方法, 仅匹配方法名。 + * 支持多级,如:对象名.对象名.方法 + */ + public static void invokeSetter(Object obj, String propertyName, E value) + { + Object object = obj; + String[] names = StringUtils.split(propertyName, "."); + for (int i = 0; i < names.length; i++) + { + if (i < names.length - 1) + { + String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); + object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); + } + else + { + String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); + invokeMethodByName(object, setterMethodName, new Object[] { value }); + } + } + } + + /** + * 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数. + */ + @SuppressWarnings("unchecked") + public static E getFieldValue(final Object obj, final String fieldName) + { + Field field = getAccessibleField(obj, fieldName); + if (field == null) + { + logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); + return null; + } + E result = null; + try + { + result = (E) field.get(obj); + } + catch (IllegalAccessException e) + { + logger.error("不可能抛出的异常{}", e.getMessage()); + } + return result; + } + + /** + * 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数. + */ + public static void setFieldValue(final Object obj, final String fieldName, final E value) + { + Field field = getAccessibleField(obj, fieldName); + if (field == null) + { + // throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); + logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); + return; + } + try + { + field.set(obj, value); + } + catch (IllegalAccessException e) + { + logger.error("不可能抛出的异常: {}", e.getMessage()); + } + } + + /** + * 直接调用对象方法, 无视private/protected修饰符. + * 用于一次性调用的情况,否则应使用getAccessibleMethod()函数获得Method后反复调用. + * 同时匹配方法名+参数类型, + */ + @SuppressWarnings("unchecked") + public static E invokeMethod(final Object obj, final String methodName, final Class[] parameterTypes, + final Object[] args) + { + if (obj == null || methodName == null) + { + return null; + } + Method method = getAccessibleMethod(obj, methodName, parameterTypes); + if (method == null) + { + logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 "); + return null; + } + try + { + return (E) method.invoke(obj, args); + } + catch (Exception e) + { + String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; + throw convertReflectionExceptionToUnchecked(msg, e); + } + } + + /** + * 直接调用对象方法, 无视private/protected修饰符, + * 用于一次性调用的情况,否则应使用getAccessibleMethodByName()函数获得Method后反复调用. + * 只匹配函数名,如果有多个同名函数调用第一个。 + */ + @SuppressWarnings("unchecked") + public static E invokeMethodByName(final Object obj, final String methodName, final Object[] args) + { + Method method = getAccessibleMethodByName(obj, methodName, args.length); + if (method == null) + { + // 如果为空不报错,直接返回空。 + logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 "); + return null; + } + try + { + // 类型转换(将参数数据类型转换为目标方法参数类型) + Class[] cs = method.getParameterTypes(); + for (int i = 0; i < cs.length; i++) + { + if (args[i] != null && !args[i].getClass().equals(cs[i])) + { + if (cs[i] == String.class) + { + args[i] = Convert.toStr(args[i]); + if (StringUtils.endsWith((String) args[i], ".0")) + { + args[i] = StringUtils.substringBefore((String) args[i], ".0"); + } + } + else if (cs[i] == Integer.class) + { + args[i] = Convert.toInt(args[i]); + } + else if (cs[i] == Long.class) + { + args[i] = Convert.toLong(args[i]); + } + else if (cs[i] == Double.class) + { + args[i] = Convert.toDouble(args[i]); + } + else if (cs[i] == Float.class) + { + args[i] = Convert.toFloat(args[i]); + } + else if (cs[i] == Date.class) + { + if (args[i] instanceof String) + { + args[i] = DateUtils.parseDate(args[i]); + } + else + { + args[i] = DateUtil.getJavaDate((Double) args[i]); + } + } + else if (cs[i] == boolean.class || cs[i] == Boolean.class) + { + args[i] = Convert.toBool(args[i]); + } + } + } + return (E) method.invoke(obj, args); + } + catch (Exception e) + { + String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; + throw convertReflectionExceptionToUnchecked(msg, e); + } + } + + /** + * 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问. + * 如向上转型到Object仍无法找到, 返回null. + */ + public static Field getAccessibleField(final Object obj, final String fieldName) + { + // 为空不报错。直接返回 null + if (obj == null) + { + return null; + } + Validate.notBlank(fieldName, "fieldName can't be blank"); + for (Class superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) + { + try + { + Field field = superClass.getDeclaredField(fieldName); + makeAccessible(field); + return field; + } + catch (NoSuchFieldException e) + { + continue; + } + } + return null; + } + + /** + * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问. + * 如向上转型到Object仍无法找到, 返回null. + * 匹配函数名+参数类型。 + * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) + */ + public static Method getAccessibleMethod(final Object obj, final String methodName, + final Class... parameterTypes) + { + // 为空不报错。直接返回 null + if (obj == null) + { + return null; + } + Validate.notBlank(methodName, "methodName can't be blank"); + for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) + { + try + { + Method method = searchType.getDeclaredMethod(methodName, parameterTypes); + makeAccessible(method); + return method; + } + catch (NoSuchMethodException e) + { + continue; + } + } + return null; + } + + /** + * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问. + * 如向上转型到Object仍无法找到, 返回null. + * 只匹配函数名。 + * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) + */ + public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) + { + // 为空不报错。直接返回 null + if (obj == null) + { + return null; + } + Validate.notBlank(methodName, "methodName can't be blank"); + for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) + { + Method[] methods = searchType.getDeclaredMethods(); + for (Method method : methods) + { + if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum) + { + makeAccessible(method); + return method; + } + } + } + return null; + } + + /** + * 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 + */ + public static void makeAccessible(Method method) + { + if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) + && !method.isAccessible()) + { + method.setAccessible(true); + } + } + + /** + * 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 + */ + public static void makeAccessible(Field field) + { + if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) + || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) + { + field.setAccessible(true); + } + } + + /** + * 通过反射, 获得Class定义中声明的泛型参数的类型, 注意泛型必须定义在父类处 + * 如无法找到, 返回Object.class. + */ + @SuppressWarnings("unchecked") + public static Class getClassGenricType(final Class clazz) + { + return getClassGenricType(clazz, 0); + } + + /** + * 通过反射, 获得Class定义中声明的父类的泛型参数的类型. + * 如无法找到, 返回Object.class. + */ + public static Class getClassGenricType(final Class clazz, final int index) + { + Type genType = clazz.getGenericSuperclass(); + + if (!(genType instanceof ParameterizedType)) + { + logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType"); + return Object.class; + } + + Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); + + if (index >= params.length || index < 0) + { + logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " + + params.length); + return Object.class; + } + if (!(params[index] instanceof Class)) + { + logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter"); + return Object.class; + } + + return (Class) params[index]; + } + + public static Class getUserClass(Object instance) + { + if (instance == null) + { + throw new RuntimeException("Instance must not be null"); + } + Class clazz = instance.getClass(); + if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) + { + Class superClass = clazz.getSuperclass(); + if (superClass != null && !Object.class.equals(superClass)) + { + return superClass; + } + } + return clazz; + + } + + /** + * 将反射时的checked exception转换为unchecked exception. + */ + public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) + { + if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException + || e instanceof NoSuchMethodException) + { + return new IllegalArgumentException(msg, e); + } + else if (e instanceof InvocationTargetException) + { + return new RuntimeException(msg, ((InvocationTargetException) e).getTargetException()); + } + return new RuntimeException(msg, e); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/security/JwtUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/security/JwtUtils.java new file mode 100644 index 0000000..c8659b1 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/security/JwtUtils.java @@ -0,0 +1,43 @@ +package com.mathvision.box.common.utils.security; + +import com.alibaba.fastjson.JSON; +import com.auth0.jwt.JWT; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.Claim; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.mathvision.box.common.core.domain.entity.UserCache; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:生成token + */ +@Component +public class JwtUtils { + + @Value("${jwt.config.secretKey}") + private String secretKey; + + /** + * 加密token. + */ + public String getToken(UserCache user) { + String token = JWT + .create() + .withClaim("user", JSON.toJSONString(user)) +// .withClaim("timeStamp", System.currentTimeMillis()) + .sign(Algorithm.HMAC256(secretKey)); + return token; + } + + /** + * 解析token. + */ + public UserCache parseToken(String token) { + DecodedJWT decodedjwt = JWT.require(Algorithm.HMAC256(secretKey)).build().verify(token); + Claim user = decodedjwt.getClaim("user"); + return JSON.parseObject(user.asString(), UserCache.class); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/security/SessionHolder.java b/box-common/src/main/java/com/mathvision/box/common/utils/security/SessionHolder.java new file mode 100644 index 0000000..8844d82 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/security/SessionHolder.java @@ -0,0 +1,22 @@ +package com.mathvision.box.common.utils.security; + +import com.mathvision.box.common.core.domain.entity.UserCache; + +/** + * 线程安全用户会话 + */ +public class SessionHolder { + private static final ThreadLocal USER_SESSION = new ThreadLocal<>(); + + public static void set(UserCache user) { + USER_SESSION.set(user); + } + + public static UserCache get() { + return USER_SESSION.get(); + } + + public static void clear() { + USER_SESSION.remove(); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/spring/SpringUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/spring/SpringUtils.java new file mode 100644 index 0000000..7448aac --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/spring/SpringUtils.java @@ -0,0 +1,157 @@ +package com.mathvision.box.common.utils.spring; + +import com.mathvision.box.common.utils.common.StringUtils; +import org.springframework.aop.framework.AopContext; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +/** + * spring工具类 方便在非spring管理环境中获取bean + */ +@Component +public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware +{ + /** Spring应用上下文环境 */ + private static ConfigurableListableBeanFactory beanFactory; + + private static ApplicationContext applicationContext; + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException + { + SpringUtils.beanFactory = beanFactory; + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + { + SpringUtils.applicationContext = applicationContext; + } + + /** + * 获取对象 + * + * @param name + * @return Object 一个以所给名字注册的bean的实例 + * @throws BeansException + * + */ + @SuppressWarnings("unchecked") + public static T getBean(String name) throws BeansException + { + return (T) beanFactory.getBean(name); + } + + /** + * 获取类型为requiredType的对象 + * + * @param clz + * @return + * @throws BeansException + * + */ + public static T getBean(Class clz) throws BeansException + { + T result = (T) beanFactory.getBean(clz); + return result; + } + + /** + * 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true + * + * @param name + * @return boolean + */ + public static boolean containsBean(String name) + { + return beanFactory.containsBean(name); + } + + /** + * 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException) + * + * @param name + * @return boolean + * @throws NoSuchBeanDefinitionException + * + */ + public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException + { + return beanFactory.isSingleton(name); + } + + /** + * @param name + * @return Class 注册对象的类型 + * @throws NoSuchBeanDefinitionException + * + */ + public static Class getType(String name) throws NoSuchBeanDefinitionException + { + return beanFactory.getType(name); + } + + /** + * 如果给定的bean名字在bean定义中有别名,则返回这些别名 + * + * @param name + * @return + * @throws NoSuchBeanDefinitionException + * + */ + public static String[] getAliases(String name) throws NoSuchBeanDefinitionException + { + return beanFactory.getAliases(name); + } + + /** + * 获取aop代理对象 + * + * @param invoker + * @return + */ + @SuppressWarnings("unchecked") + public static T getAopProxy(T invoker) + { + return (T) AopContext.currentProxy(); + } + + /** + * 获取当前的环境配置,无配置返回null + * + * @return 当前的环境配置 + */ + public static String[] getActiveProfiles() + { + return applicationContext.getEnvironment().getActiveProfiles(); + } + + /** + * 获取当前的环境配置,当有多个环境配置时,只获取第一个 + * + * @return 当前的环境配置 + */ + public static String getActiveProfile() + { + final String[] activeProfiles = getActiveProfiles(); + return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null; + } + + /** + * 获取配置文件中的值 + * + * @param key 配置文件的key + * @return 当前的配置文件的值 + * + */ + public static String getRequiredProperty(String key) + { + return applicationContext.getEnvironment().getRequiredProperty(key); + } + +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/sql/SqlUtil.java b/box-common/src/main/java/com/mathvision/box/common/utils/sql/SqlUtil.java new file mode 100644 index 0000000..f17f0cd --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/sql/SqlUtil.java @@ -0,0 +1,77 @@ +package com.mathvision.box.common.utils.sql; + + +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.exception.base.BaseException; +import com.mathvision.box.common.utils.common.StringUtils; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:sql操作工具类 + */ +public class SqlUtil +{ + /** + * 定义常用的 sql关键字 + */ + public static String SQL_REGEX = "and |extractvalue|updatexml|exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |or |+|user()"; + + /** + * 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序) + */ + public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+"; + + /** + * 限制orderBy最大长度 + */ + private static final int ORDER_BY_MAX_LENGTH = 500; + + /** + * 检查字符,防止注入绕过 + */ + public static String escapeOrderBySql(String value) + { + if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) + { + + throw new BaseException(Result.ILLEGAL_ARGUMENT); + } + if (StringUtils.length(value) > ORDER_BY_MAX_LENGTH) + { + Result result = Result.FAILURE; + result.setDesc("参数已超过最大限制,不能进行查询"); + throw new BaseException(result); + } + return value; + } + + /** + * 验证 order by 语法是否符合规范 + */ + public static boolean isValidOrderBySql(String value) + { + return value.matches(SQL_PATTERN); + } + + /** + * SQL关键字检查 + */ + public static void filterKeyword(String value) + { + if (StringUtils.isEmpty(value)) + { + return; + } + String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|"); + for (String sqlKeyword : sqlKeywords) + { + if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) + { + Result result = Result.FAILURE; + result.setDesc("参数存在SQL注入风险"); + throw new BaseException(result); + } + } + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/tree/TreeBuilderUtil.java b/box-common/src/main/java/com/mathvision/box/common/utils/tree/TreeBuilderUtil.java new file mode 100644 index 0000000..e8b414e --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/tree/TreeBuilderUtil.java @@ -0,0 +1,149 @@ +package com.mathvision.box.common.utils.tree; + +import com.mathvision.box.common.annotation.tree.TreeNodeId; +import com.mathvision.box.common.annotation.tree.TreeNodeParentId; +import lombok.extern.slf4j.Slf4j; +import org.springframework.util.CollectionUtils; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description:树型结构数据构建工具 + * @Version: 1.0 + * @Author: yyy + */ +@Slf4j +public class TreeBuilderUtil { + + public static List> buildTree(List nodes) { + if (CollectionUtils.isEmpty(nodes)) { + return new ArrayList<>(); + } + Map> nodeMap = new HashMap<>(); + List> rootNodes = new ArrayList<>(); + + Field idField = null; + Field parentIdField = null; + + // 找到标注了注解的字段 + for (Field field : nodes.get(0).getClass().getDeclaredFields()) { + if (field.isAnnotationPresent(TreeNodeId.class)) { + idField = field; + idField.setAccessible(true); + } + if (field.isAnnotationPresent(TreeNodeParentId.class)) { + parentIdField = field; + parentIdField.setAccessible(true); + } + } + if (idField == null || parentIdField == null) { + throw new IllegalArgumentException("Missing TreeNodeId or TreeNodeParentId annotation"); + } + try { + // 将节点存储到Map中 + for (T node : nodes) { + Object id = idField.get(node); + TreeNode treeNode = new TreeNode<>(node); + nodeMap.put(id, treeNode); + } + + // 构建树形结构 + for (T node : nodes) { + Object parentId = parentIdField.get(node); + TreeNode treeNode = nodeMap.get(idField.get(node)); + if (parentId == null) { + rootNodes.add(treeNode); + treeNode.setPath("/" + treeNode.getId() + "-" + treeNode.getName()); + } else { + TreeNode parentNode = nodeMap.get(parentId); + if (parentNode != null) { + parentNode.getChildren().add(treeNode); + treeNode.setParent(parentNode); + treeNode.setPath(parentNode.getPath() + "/" + treeNode.getId() + "-" + treeNode.getName()); + } else { + rootNodes.add(treeNode); + treeNode.setPath("/" + treeNode.getId() + "-" + treeNode.getName()); + } + } + } + } catch (Exception e) { + log.error("Error in buildTree:{}", e); + } + return rootNodes; + } + + /** + * 根据ID在树结构中查找节点 + * + * @param treeNodes 树节点列表 + * @param id 要查找的ID + * @return 找到的节点, 未找到返回null + */ + public static TreeNode getById(List> treeNodes, Long id) { + // 参数校验 + if (CollectionUtils.isEmpty(treeNodes)) { + log.debug("Tree nodes list is empty"); + return null; + } + + if (id == null) { + log.warn("Search id is null"); + return null; + } + + try { + // 遍历顶层节点 + for (TreeNode node : treeNodes) { + TreeNode result = findNodeById(node, id); + if (result != null) { + return result; + } + } + log.debug("No node found with id: {}", id); + return null; + } catch (Exception e) { + log.error("Error while searching node with id: {}", id, e); + return null; + } + } + + /** + * 递归查找节点 + * + * @param node 当前节点 + * @param id 要查找的ID + * @return 找到的节点, 未找到返回null + */ + private static TreeNode findNodeById(TreeNode node, Long id) { + // 参数校验 + if (node == null || id == null) { + return null; + } + + try { + // 检查当前节点 + if (id.equals(node.getId())) { + return node; + } + + // 递归检查子节点 + List> children = node.getChildren(); + if (!CollectionUtils.isEmpty(children)) { + for (TreeNode child : children) { + TreeNode result = findNodeById(child, id); + if (result != null) { + return result; + } + } + } + return null; + } catch (Exception e) { + log.error("Error in findNodeById for id: {}, node: {}", id, node, e); + return null; + } + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/tree/TreeNode.java b/box-common/src/main/java/com/mathvision/box/common/utils/tree/TreeNode.java new file mode 100644 index 0000000..9a89c32 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/tree/TreeNode.java @@ -0,0 +1,173 @@ +package com.mathvision.box.common.utils.tree; + + +import com.mathvision.box.common.annotation.tree.TreeNodeId; +import com.mathvision.box.common.annotation.tree.TreeNodeName; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; +import java.util.stream.Collectors; + +/** + * @Description:树节点 + * @Version: 1.0 + * @Author: yyy + */ +public class TreeNode { + private T data; + private List> children = new ArrayList<>(); + private TreeNode parent; + private String path; + + public TreeNode(T data) { + this.data = data; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + public List> getChildren() { + return children; + } + + public void setChildren(List> children) { + this.children = children; + } + + public TreeNode getParent() { + return parent; + } + + public void setParent(TreeNode parent) { + this.parent = parent; + } + + public String getPath() { + return path; + } + + //path = /1-资产/2-办公用品/3-办公用品/4-办公用品/5-办公用品 + public String getRootId() { + return path.split("/")[1].split("-")[0]; + } + + public String getRootName() { + return path.split("/")[1].split("-")[1]; + } + + public String getIdPath() { + String[] segments = path.split("/"); + StringBuilder idPath = new StringBuilder(); + for (int i = 1; i < segments.length; i++) { + String[] parts = segments[i].split("-"); + if (parts.length > 1) { + idPath.append(parts[0]); + if (i < segments.length - 1) { + idPath.append("/"); + } + } + } + return idPath.toString(); + } + + public String getNamePath() { + String[] segments = path.split("/"); + StringBuilder namePath = new StringBuilder(); + for (int i = 1; i < segments.length; i++) { + String[] parts = segments[i].split("-"); + if (parts.length > 1) { + namePath.append(parts[1]); + if (i < segments.length - 1) { + namePath.append("/"); + } + } + } + return namePath.toString(); + } + + public void setPath(String path) { + this.path = path; + } + + public List getChildIds() { + List idList = new ArrayList<>(); + // 检查 children 是否为 null 或空 + if (children == null || children.isEmpty()) { + return idList; + } + // 使用栈实现迭代遍历 + Stack> stack = new Stack<>(); + for (TreeNode node : children) { + stack.push(node); + } + while (!stack.isEmpty()) { + TreeNode currentNode = stack.pop(); + idList.add(currentNode.getId()); + // 将当前节点的子节点压入栈中 + if (currentNode.getChildren() != null && !currentNode.getChildren().isEmpty()) { + for (TreeNode child : currentNode.getChildren()) { + stack.push(child); + } + } + } + return idList; + } + + + public List getChildNames() { + return children.stream() + .map(TreeNode::getName) + .collect(Collectors.toList()); + } + + public Object getParentId() { + return parent != null ? getId(parent.getData()) : null; + } + + public String getParentName() { + return parent != null ? getName(parent.getData()) : null; + } + + public Object getId() { + return getId(this.data); + } + + public String getName() { + return getName(this.data); + } + + private Object getId(T node) { + try { + for (Field field : node.getClass().getDeclaredFields()) { + if (field.isAnnotationPresent(TreeNodeId.class)) { + field.setAccessible(true); + return field.get(node); + } + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return null; + } + + private String getName(T node) { + try { + for (Field field : node.getClass().getDeclaredFields()) { + if (field.isAnnotationPresent(TreeNodeName.class)) { + field.setAccessible(true); + return (String) field.get(node); + } + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return null; + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/uuid/IdUtils.java b/box-common/src/main/java/com/mathvision/box/common/utils/uuid/IdUtils.java new file mode 100644 index 0000000..31b107b --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/uuid/IdUtils.java @@ -0,0 +1,53 @@ +package com.mathvision.box.common.utils.uuid; + +/** + * ID生成器工具类 + */ +public class IdUtils +{ + /** + * 获取随机UUID + * + * @return 随机UUID + */ + public static String randomUUID() + { + return UUID.randomUUID().toString(); + } + + /** + * 简化的UUID,去掉了横线 + * + * @return 简化的UUID,去掉了横线 + */ + public static String simpleUUID() + { + return UUID.randomUUID().toString(true); + } + + /** + * 获取随机UUID,使用性能更好的ThreadLocalRandom生成UUID + * + * @return 随机UUID + */ + public static String fastUUID() + { + return UUID.fastUUID().toString(); + } + + /** + * 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID + * + * @return 简化的UUID,去掉了横线 + */ + public static String fastSimpleUUID() + { + return UUID.fastUUID().toString(true); + } + + + public static String shortUUID() + { + return UUID.randomUUID().toString().substring(0, 8); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/uuid/Seq.java b/box-common/src/main/java/com/mathvision/box/common/utils/uuid/Seq.java new file mode 100644 index 0000000..a238cad --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/uuid/Seq.java @@ -0,0 +1,88 @@ +package com.mathvision.box.common.utils.uuid; + + +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.common.StringUtils; + +import java.util.concurrent.atomic.AtomicInteger; + +/** + * 序列生成类 + */ +public class Seq +{ + // 通用序列类型 + public static final String commSeqType = "COMMON"; + + // 上传序列类型 + public static final String uploadSeqType = "UPLOAD"; + + // 通用接口序列数 + private static AtomicInteger commSeq = new AtomicInteger(1); + + // 上传接口序列数 + private static AtomicInteger uploadSeq = new AtomicInteger(1); + + // 机器标识 + private static final String machineCode = "A"; + + /** + * 获取通用序列号 + * + * @return 序列值 + */ + public static String getId() + { + return getId(commSeqType); + } + + /** + * 默认16位序列号 yyMMddHHmmss + 一位机器标识 + 3长度循环递增字符串 + * + * @return 序列值 + */ + public static String getId(String type) + { + AtomicInteger atomicInt = commSeq; + if (uploadSeqType.equals(type)) + { + atomicInt = uploadSeq; + } + return getId(atomicInt, 3); + } + + /** + * 通用接口序列号 yyMMddHHmmss + 一位机器标识 + length长度循环递增字符串 + * + * @param atomicInt 序列数 + * @param length 数值长度 + * @return 序列值 + */ + public static String getId(AtomicInteger atomicInt, int length) + { + String result = DateUtils.dateTimeNow(); + result += machineCode; + result += getSeq(atomicInt, length); + return result; + } + + /** + * 序列循环递增字符串[1, 10 的 (length)幂次方), 用0左补齐length位数 + * + * @return 序列值 + */ + private synchronized static String getSeq(AtomicInteger atomicInt, int length) + { + // 先取值再+1 + int value = atomicInt.getAndIncrement(); + + // 如果更新后值>=10 的 (length)幂次方则重置为1 + int maxSeq = (int) Math.pow(10, length); + if (atomicInt.get() >= maxSeq) + { + atomicInt.set(1); + } + // 转字符串,用0左补齐 + return StringUtils.padl(value, length); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/uuid/SnowFlakeUtil.java b/box-common/src/main/java/com/mathvision/box/common/utils/uuid/SnowFlakeUtil.java new file mode 100644 index 0000000..0e623e3 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/uuid/SnowFlakeUtil.java @@ -0,0 +1,75 @@ +package com.mathvision.box.common.utils.uuid; +import cn.hutool.core.lang.Singleton; + +/** + * Created with IntelliJ IDEA. + * + * @Author: fy + * @Date: 2023/05/09/15:41 + * @Description:雪花算法工具类 + */ +public class SnowFlakeUtil { + private static final long START_STMP = 1420041600000L; + private static final long SEQUENCE_BIT = 9L; + private static final long MACHINE_BIT = 2L; + private static final long DATACENTER_BIT = 2L; + private static final long MAX_SEQUENCE = 511L; + private static final long MAX_MACHINE_NUM = 3L; + private static final long MAX_DATACENTER_NUM = 3L; + private static final long MACHINE_LEFT = 9L; + private static final long DATACENTER_LEFT = 11L; + private static final long TIMESTMP_LEFT = 13L; + private long datacenterId; + private long machineId; + private long sequence = 0L; + private long lastStmp = -1L; + + public SnowFlakeUtil(long datacenterId, long machineId) { + if (datacenterId <= 3L && datacenterId >= 0L) { + if (machineId <= 3L && machineId >= 0L) { + this.datacenterId = datacenterId; + this.machineId = machineId; + } else { + throw new IllegalArgumentException("machineId can't be greater than MAX_MACHINE_NUM or less than 0"); + } + } else { + throw new IllegalArgumentException("datacenterId can't be greater than MAX_DATACENTER_NUM or less than 0"); + } + } + + public synchronized long nextId() { + long currStmp = this.getNewstmp(); + if (currStmp < this.lastStmp) { + throw new RuntimeException("Clock moved backwards. Refusing to generate id"); + } else { + if (currStmp == this.lastStmp) { + this.sequence = this.sequence + 1L & 511L; + if (this.sequence == 0L) { + currStmp = this.getNextMill(); + } + } else { + this.sequence = 0L; + } + + this.lastStmp = currStmp; + return currStmp - 1420041600000L << 13 | this.datacenterId << 11 | this.machineId << 9 | this.sequence; + } + } + + private long getNextMill() { + long mill; + for(mill = this.getNewstmp(); mill <= this.lastStmp; mill = this.getNewstmp()) { + } + + return mill; + } + + private long getNewstmp() { + return System.currentTimeMillis(); + } + + public static Long getDefaultSnowFlakeId() { + return ((SnowFlakeUtil)Singleton.get(SnowFlakeUtil.class, new Object[]{1L, 1L})).nextId(); + } + +} diff --git a/box-common/src/main/java/com/mathvision/box/common/utils/uuid/UUID.java b/box-common/src/main/java/com/mathvision/box/common/utils/uuid/UUID.java new file mode 100644 index 0000000..eaafdc7 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/utils/uuid/UUID.java @@ -0,0 +1,485 @@ +package com.mathvision.box.common.utils.uuid; + + +import com.mathvision.box.common.exception.UtilException; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; + +/** + * 提供通用唯一识别码(universally unique identifier)(UUID)实现 + */ +public final class UUID implements java.io.Serializable, Comparable +{ + private static final long serialVersionUID = -1185015143654744140L; + + /** + * SecureRandom 的单例 + * + */ + private static class Holder + { + static final SecureRandom numberGenerator = getSecureRandom(); + } + + /** 此UUID的最高64有效位 */ + private final long mostSigBits; + + /** 此UUID的最低64有效位 */ + private final long leastSigBits; + + /** + * 私有构造 + * + * @param data 数据 + */ + private UUID(byte[] data) + { + long msb = 0; + long lsb = 0; + assert data.length == 16 : "data must be 16 bytes in length"; + for (int i = 0; i < 8; i++) + { + msb = (msb << 8) | (data[i] & 0xff); + } + for (int i = 8; i < 16; i++) + { + lsb = (lsb << 8) | (data[i] & 0xff); + } + this.mostSigBits = msb; + this.leastSigBits = lsb; + } + + /** + * 使用指定的数据构造新的 UUID。 + * + * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位 + * @param leastSigBits 用于 {@code UUID} 的最低有效 64 位 + */ + public UUID(long mostSigBits, long leastSigBits) + { + this.mostSigBits = mostSigBits; + this.leastSigBits = leastSigBits; + } + + /** + * 获取类型 4(伪随机生成的)UUID 的静态工厂。 + * + * @return 随机生成的 {@code UUID} + */ + public static UUID fastUUID() + { + return randomUUID(false); + } + + /** + * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。 + * + * @return 随机生成的 {@code UUID} + */ + public static UUID randomUUID() + { + return randomUUID(true); + } + + /** + * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。 + * + * @param isSecure 是否使用{@link SecureRandom}如果是可以获得更安全的随机码,否则可以得到更好的性能 + * @return 随机生成的 {@code UUID} + */ + public static UUID randomUUID(boolean isSecure) + { + final Random ng = isSecure ? Holder.numberGenerator : getRandom(); + + byte[] randomBytes = new byte[16]; + ng.nextBytes(randomBytes); + randomBytes[6] &= 0x0f; /* clear version */ + randomBytes[6] |= 0x40; /* set to version 4 */ + randomBytes[8] &= 0x3f; /* clear variant */ + randomBytes[8] |= 0x80; /* set to IETF variant */ + return new UUID(randomBytes); + } + + /** + * 根据指定的字节数组获取类型 3(基于名称的)UUID 的静态工厂。 + * + * @param name 用于构造 UUID 的字节数组。 + * + * @return 根据指定数组生成的 {@code UUID} + */ + public static UUID nameUUIDFromBytes(byte[] name) + { + MessageDigest md; + try + { + md = MessageDigest.getInstance("MD5"); + } + catch (NoSuchAlgorithmException nsae) + { + throw new InternalError("MD5 not supported"); + } + byte[] md5Bytes = md.digest(name); + md5Bytes[6] &= 0x0f; /* clear version */ + md5Bytes[6] |= 0x30; /* set to version 3 */ + md5Bytes[8] &= 0x3f; /* clear variant */ + md5Bytes[8] |= 0x80; /* set to IETF variant */ + return new UUID(md5Bytes); + } + + /** + * 根据 {@link #toString()} 方法中描述的字符串标准表示形式创建{@code UUID}。 + * + * @param name 指定 {@code UUID} 字符串 + * @return 具有指定值的 {@code UUID} + * @throws IllegalArgumentException 如果 name 与 {@link #toString} 中描述的字符串表示形式不符抛出此异常 + * + */ + public static UUID fromString(String name) + { + String[] components = name.split("-"); + if (components.length != 5) + { + throw new IllegalArgumentException("Invalid UUID string: " + name); + } + for (int i = 0; i < 5; i++) + { + components[i] = "0x" + components[i]; + } + + long mostSigBits = Long.decode(components[0]).longValue(); + mostSigBits <<= 16; + mostSigBits |= Long.decode(components[1]).longValue(); + mostSigBits <<= 16; + mostSigBits |= Long.decode(components[2]).longValue(); + + long leastSigBits = Long.decode(components[3]).longValue(); + leastSigBits <<= 48; + leastSigBits |= Long.decode(components[4]).longValue(); + + return new UUID(mostSigBits, leastSigBits); + } + + /** + * 返回此 UUID 的 128 位值中的最低有效 64 位。 + * + * @return 此 UUID 的 128 位值中的最低有效 64 位。 + */ + public long getLeastSignificantBits() + { + return leastSigBits; + } + + /** + * 返回此 UUID 的 128 位值中的最高有效 64 位。 + * + * @return 此 UUID 的 128 位值中最高有效 64 位。 + */ + public long getMostSignificantBits() + { + return mostSigBits; + } + + /** + * 与此 {@code UUID} 相关联的版本号. 版本号描述此 {@code UUID} 是如何生成的。 + *

+ * 版本号具有以下含意: + *

    + *
  • 1 基于时间的 UUID + *
  • 2 DCE 安全 UUID + *
  • 3 基于名称的 UUID + *
  • 4 随机生成的 UUID + *
+ * + * @return 此 {@code UUID} 的版本号 + */ + public int version() + { + // Version is bits masked by 0x000000000000F000 in MS long + return (int) ((mostSigBits >> 12) & 0x0f); + } + + /** + * 与此 {@code UUID} 相关联的变体号。变体号描述 {@code UUID} 的布局。 + *

+ * 变体号具有以下含意: + *

    + *
  • 0 为 NCS 向后兼容保留 + *
  • 2 IETF RFC 4122(Leach-Salz), 用于此类 + *
  • 6 保留,微软向后兼容 + *
  • 7 保留供以后定义使用 + *
+ * + * @return 此 {@code UUID} 相关联的变体号 + */ + public int variant() + { + // This field is composed of a varying number of bits. + // 0 - - Reserved for NCS backward compatibility + // 1 0 - The IETF aka Leach-Salz variant (used by this class) + // 1 1 0 Reserved, Microsoft backward compatibility + // 1 1 1 Reserved for future definition. + return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63)); + } + + /** + * 与此 UUID 相关联的时间戳值。 + * + *

+ * 60 位的时间戳值根据此 {@code UUID} 的 time_low、time_mid 和 time_hi 字段构造。
+ * 所得到的时间戳以 100 毫微秒为单位,从 UTC(通用协调时间) 1582 年 10 月 15 日零时开始。 + * + *

+ * 时间戳值仅在在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 {@code UUID} 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。 + * + * @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。 + */ + public long timestamp() throws UnsupportedOperationException + { + checkTimeBase(); + return (mostSigBits & 0x0FFFL) << 48// + | ((mostSigBits >> 16) & 0x0FFFFL) << 32// + | mostSigBits >>> 32; + } + + /** + * 与此 UUID 相关联的时钟序列值。 + * + *

+ * 14 位的时钟序列值根据此 UUID 的 clock_seq 字段构造。clock_seq 字段用于保证在基于时间的 UUID 中的时间唯一性。 + *

+ * {@code clockSequence} 值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。 如果此 UUID 不是基于时间的 UUID,则此方法抛出 + * UnsupportedOperationException。 + * + * @return 此 {@code UUID} 的时钟序列 + * + * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1 + */ + public int clockSequence() throws UnsupportedOperationException + { + checkTimeBase(); + return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48); + } + + /** + * 与此 UUID 相关的节点值。 + * + *

+ * 48 位的节点值根据此 UUID 的 node 字段构造。此字段旨在用于保存机器的 IEEE 802 地址,该地址用于生成此 UUID 以保证空间唯一性。 + *

+ * 节点值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。 + * + * @return 此 {@code UUID} 的节点值 + * + * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1 + */ + public long node() throws UnsupportedOperationException + { + checkTimeBase(); + return leastSigBits & 0x0000FFFFFFFFFFFFL; + } + + /** + * 返回此{@code UUID} 的字符串表现形式。 + * + *

+ * UUID 的字符串表示形式由此 BNF 描述: + * + *

+     * {@code
+     * UUID                   = ----
+     * time_low               = 4*
+     * time_mid               = 2*
+     * time_high_and_version  = 2*
+     * variant_and_sequence   = 2*
+     * node                   = 6*
+     * hexOctet               = 
+     * hexDigit               = [0-9a-fA-F]
+     * }
+     * 
+ * + * + * + * @return 此{@code UUID} 的字符串表现形式 + * @see #toString(boolean) + */ + @Override + public String toString() + { + return toString(false); + } + + /** + * 返回此{@code UUID} 的字符串表现形式。 + * + *

+ * UUID 的字符串表示形式由此 BNF 描述: + * + *

+     * {@code
+     * UUID                   = ----
+     * time_low               = 4*
+     * time_mid               = 2*
+     * time_high_and_version  = 2*
+     * variant_and_sequence   = 2*
+     * node                   = 6*
+     * hexOctet               = 
+     * hexDigit               = [0-9a-fA-F]
+     * }
+     * 
+ * + * + * + * @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串 + * @return 此{@code UUID} 的字符串表现形式 + */ + public String toString(boolean isSimple) + { + final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36); + // time_low + builder.append(digits(mostSigBits >> 32, 8)); + if (false == isSimple) + { + builder.append('-'); + } + // time_mid + builder.append(digits(mostSigBits >> 16, 4)); + if (false == isSimple) + { + builder.append('-'); + } + // time_high_and_version + builder.append(digits(mostSigBits, 4)); + if (false == isSimple) + { + builder.append('-'); + } + // variant_and_sequence + builder.append(digits(leastSigBits >> 48, 4)); + if (false == isSimple) + { + builder.append('-'); + } + // node + builder.append(digits(leastSigBits, 12)); + + return builder.toString(); + } + + /** + * 返回此 UUID 的哈希码。 + * + * @return UUID 的哈希码值。 + */ + @Override + public int hashCode() + { + long hilo = mostSigBits ^ leastSigBits; + return ((int) (hilo >> 32)) ^ (int) hilo; + } + + /** + * 将此对象与指定对象比较。 + *

+ * 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。 + * + * @param obj 要与之比较的对象 + * + * @return 如果对象相同,则返回 {@code true};否则返回 {@code false} + */ + @Override + public boolean equals(Object obj) + { + if ((null == obj) || (obj.getClass() != UUID.class)) + { + return false; + } + UUID id = (UUID) obj; + return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits); + } + + // Comparison Operations + + /** + * 将此 UUID 与指定的 UUID 比较。 + * + *

+ * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。 + * + * @param val 与此 UUID 比较的 UUID + * + * @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。 + * + */ + @Override + public int compareTo(UUID val) + { + // The ordering is intentionally set up so that the UUIDs + // can simply be numerically compared as two numbers + return (this.mostSigBits < val.mostSigBits ? -1 : // + (this.mostSigBits > val.mostSigBits ? 1 : // + (this.leastSigBits < val.leastSigBits ? -1 : // + (this.leastSigBits > val.leastSigBits ? 1 : // + 0)))); + } + + // ------------------------------------------------------------------------------------------------------------------- + // Private method start + /** + * 返回指定数字对应的hex值 + * + * @param val 值 + * @param digits 位 + * @return 值 + */ + private static String digits(long val, int digits) + { + long hi = 1L << (digits * 4); + return Long.toHexString(hi | (val & (hi - 1))).substring(1); + } + + /** + * 检查是否为time-based版本UUID + */ + private void checkTimeBase() + { + if (version() != 1) + { + throw new UnsupportedOperationException("Not a time-based UUID"); + } + } + + /** + * 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG) + * + * @return {@link SecureRandom} + */ + public static SecureRandom getSecureRandom() + { + try + { + return SecureRandom.getInstance("SHA1PRNG"); + } + catch (NoSuchAlgorithmException e) + { + + throw new UtilException(e); + } + } + + /** + * 获取随机数生成器对象
+ * ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。 + * + * @return {@link ThreadLocalRandom} + */ + public static ThreadLocalRandom getRandom() + { + return ThreadLocalRandom.current(); + } +} diff --git a/box-common/src/main/java/com/mathvision/box/common/xss/Xss.java b/box-common/src/main/java/com/mathvision/box/common/xss/Xss.java new file mode 100644 index 0000000..476d3eb --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/xss/Xss.java @@ -0,0 +1,25 @@ +package com.mathvision.box.common.xss; + +import javax.validation.Constraint; +import javax.validation.Payload; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 自定义xss校验注解 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(value = { ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER }) +@Constraint(validatedBy = { XssValidator.class }) +public @interface Xss +{ + String message() + + default "不允许任何脚本运行"; + + Class[] groups() default {}; + + Class[] payload() default {}; +} diff --git a/box-common/src/main/java/com/mathvision/box/common/xss/XssFilter.java b/box-common/src/main/java/com/mathvision/box/common/xss/XssFilter.java new file mode 100644 index 0000000..d3db34e --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/xss/XssFilter.java @@ -0,0 +1,71 @@ +package com.mathvision.box.common.xss; + + +import com.mathvision.box.common.utils.common.StringUtils; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * 防止XSS攻击的过滤器 + * + * @author ruoyi + */ +public class XssFilter implements Filter +{ + /** + * 排除链接 + */ + public List excludes = new ArrayList<>(); + + @Override + public void init(FilterConfig filterConfig) throws ServletException + { + String tempExcludes = filterConfig.getInitParameter("excludes"); + if (StringUtils.isNotEmpty(tempExcludes)) + { + String[] urls = tempExcludes.split(","); + for (String url : urls) + { + excludes.add(url); + } + } + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + HttpServletRequest req = (HttpServletRequest) request; + HttpServletResponse resp = (HttpServletResponse) response; + if (handleExcludeURL(req, resp)) + { + chain.doFilter(request, response); + return; + } + XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request); + chain.doFilter(xssRequest, response); + } + + private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) + { + String url = request.getServletPath(); + String method = request.getMethod(); + // GET DELETE 不过滤 + if (method == null || method.matches("GET") || method.matches("DELETE")) + { + return true; + } + return StringUtils.matches(url, excludes); + } + + @Override + public void destroy() + { + + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/xss/XssHttpServletRequestWrapper.java b/box-common/src/main/java/com/mathvision/box/common/xss/XssHttpServletRequestWrapper.java new file mode 100644 index 0000000..1e66958 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/xss/XssHttpServletRequestWrapper.java @@ -0,0 +1,41 @@ +package com.mathvision.box.common.xss; + + +import com.mathvision.box.common.utils.html.EscapeUtil; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; + +/** + * XSS过滤处理 + * + * @author ruoyi + */ +public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper +{ + /** + * @param request + */ + public XssHttpServletRequestWrapper(HttpServletRequest request) + { + super(request); + } + + @Override + public String[] getParameterValues(String name) + { + String[] values = super.getParameterValues(name); + if (values != null) + { + int length = values.length; + String[] escapseValues = new String[length]; + for (int i = 0; i < length; i++) + { + // 防xss攻击和过滤前后空格 + escapseValues[i] = EscapeUtil.clean(values[i]).trim(); + } + return escapseValues; + } + return super.getParameterValues(name); + } +} \ No newline at end of file diff --git a/box-common/src/main/java/com/mathvision/box/common/xss/XssValidator.java b/box-common/src/main/java/com/mathvision/box/common/xss/XssValidator.java new file mode 100644 index 0000000..0487db7 --- /dev/null +++ b/box-common/src/main/java/com/mathvision/box/common/xss/XssValidator.java @@ -0,0 +1,39 @@ +package com.mathvision.box.common.xss; + + +import com.mathvision.box.common.utils.common.StringUtils; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 自定义xss校验注解实现 + */ +public class XssValidator implements ConstraintValidator +{ + private static final String HTML_PATTERN = "<(\\S*?)[^>]*>.*?|<.*? />"; + + @Override + public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) + { + if (StringUtils.isBlank(value)) + { + return true; + } + return !containsHtml(value); + } + + public static boolean containsHtml(String value) + { + StringBuilder sHtml = new StringBuilder(); + Pattern pattern = Pattern.compile(HTML_PATTERN); + Matcher matcher = pattern.matcher(value); + while (matcher.find()) + { + sHtml.append(matcher.group()); + } + return pattern.matcher(sHtml).matches(); + } +} \ No newline at end of file diff --git a/box-dao/pom.xml b/box-dao/pom.xml new file mode 100644 index 0000000..d4c450e --- /dev/null +++ b/box-dao/pom.xml @@ -0,0 +1,35 @@ + + + + box + com.mathvision + 1.0-SNAPSHOT + + 4.0.0 + + box-dao + 数据库操作 + + + + com.mathvision + box-common + 1.0-SNAPSHOT + + + + org.xerial + sqlite-jdbc + + + com.alibaba + druid-spring-boot-starter + + + com.baomidou + mybatis-plus-boot-starter + + + \ No newline at end of file diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DataStorageConfigDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DataStorageConfigDto.java new file mode 100644 index 0000000..a92b318 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DataStorageConfigDto.java @@ -0,0 +1,45 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +@ApiModel("数据存储管理修改参数") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DataStorageConfigDto implements Serializable { + private static final long serialVersionUID = 534034771306361219L; + + @ApiModelProperty(value = "告警阈值", example = "告警阈值(整数0-100)") + @NotNull(message = "告警阈值不能为空") + @Min(value = 0, message = "阈值不能小于0") + @Max(value = 100, message = "阈值不能超过100") + private Integer threshold; + + @ApiModelProperty(value = "扩展字段1", example = "扩展字段1") + private String ext1; + + @ApiModelProperty(value = "扩展字段2", example = "扩展字段2") + private String ext2; + + @ApiModelProperty(value = "扩展字段3", example = "扩展字段3") + private String ext3; + + @ApiModelProperty(value = "扩展字段4", example = "扩展字段4") + private String ext4; + + @ApiModelProperty(value = "扩展字段5", example = "扩展字段5") + private String ext5; + +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DefectQueryDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DefectQueryDto.java new file mode 100644 index 0000000..32ea165 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DefectQueryDto.java @@ -0,0 +1,43 @@ +package com.mathvision.box.dao.domain.dto; + +import java.util.Date; +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.Builder; + +@ApiModel("检测结果查询") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DefectQueryDto implements Serializable { + private static final long serialVersionUID = 459409543849580076L; + @ApiModelProperty(notes = "开始时间") + private Date startTime; + + @ApiModelProperty(notes = "结束时间") + private Date endTime; + + @ApiModelProperty(notes = "过程id") + private String processId; + + @ApiModelProperty(notes = "告警类型") + private String type; + + @ApiModelProperty(notes = "设备ip") + private String ip; + + @ApiModelProperty(notes = "设备名称") + private String deviceName; + + @ApiModelProperty(notes = "通道名称") + private String channelName; + + @ApiModelProperty("状态(0-未处理/1-已处理)") + private String status; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DefectUpdateDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DefectUpdateDto.java new file mode 100644 index 0000000..e395f06 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DefectUpdateDto.java @@ -0,0 +1,23 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@ApiModel("检测结果修改") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DefectUpdateDto implements Serializable { + private static final long serialVersionUID = 459409543849580076L; + private Long id; + + @ApiModelProperty(notes = "处置信息") + private String ext; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DetectDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DetectDto.java new file mode 100644 index 0000000..c5632fa --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DetectDto.java @@ -0,0 +1,44 @@ +package com.mathvision.box.dao.domain.dto; + +import java.util.Date; +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.Builder; + +@ApiModel("检测过程表(DetectDto)传输数据类") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DetectDto implements Serializable { + private static final long serialVersionUID = 346776873048750268L; + + private Long id; + + @ApiModelProperty(notes = "告警时间") + private Date time; + + @ApiModelProperty(notes = "告警类型") + private String type; + + @ApiModelProperty(notes = "设备IP") + private String ip; + + @ApiModelProperty(notes = "通道") + private Integer channel; + + @ApiModelProperty(notes = "图片") + private String img; + + @ApiModelProperty(notes = "热成像图片") + private String thermalImg; + + @ApiModelProperty(notes = "扩展数据") + private String data; + +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DeviceAddDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DeviceAddDto.java new file mode 100644 index 0000000..6d5c1cf --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DeviceAddDto.java @@ -0,0 +1,62 @@ +package com.mathvision.box.dao.domain.dto; + +import java.io.Serializable; +import java.util.List; + +import com.mathvision.box.common.annotation.aes.AesDecrypt; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.Builder; + +import javax.validation.constraints.NotBlank; + +@ApiModel("设备信息表(DeviceDto)传输数据类") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DeviceAddDto implements Serializable { + private static final long serialVersionUID = -82361770389504903L; + + private Long id; + + @ApiModelProperty(notes = "设备类型:{box:边缘计算盒子, surveillance_camera:监控摄像头, network_sound_column:网络音响}", example = "设备类型(可选项:box、network_sound_column、surveillance_camera)", required = true) + @NotBlank(message = "设备类型不能为空") + private String type; + + @ApiModelProperty(notes = "设备厂商:{hikvision:海康威视, corerain:鲲云, sophgo:算能, mock:MOCK}", example = "设备厂商(可选项:hikvision, corerain, sophgo, mock", required = true) + @NotBlank(message = "设备厂商不能为空") + private String vendor; + + @ApiModelProperty(notes = "设备编号", example = "设备编号") + private String deviceId; + + @ApiModelProperty(notes = "上级设备id", example = "上级设备id, 默认为0, 当设备类型type=box时,可添加surveillance_camera或network_sound_column类型的设备") + private Long parentId = 0L; + + @ApiModelProperty(notes = "设备名称", example = "设备名称", required = true) + @NotBlank(message = "设备名称不能为空") + private String name; + + @ApiModelProperty(notes = "备注", example = "备注") + private String remark; + + @ApiModelProperty(notes = "关联检测点位[归属场景](对应point表的id字段(int),不是pointId(string))") + private List points; + + @ApiModelProperty(notes = "ip地址", example = "ip地址") + private String ip; + + @ApiModelProperty(notes = "端口", example = "端口") + private Short port; + + @ApiModelProperty(notes = "账号", example = "账号") + private String username; + + @ApiModelProperty(notes = "密码", example = "密码") +// @AesDecrypt + private String password; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DeviceQueryDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DeviceQueryDto.java new file mode 100644 index 0000000..eef2a8b --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/DeviceQueryDto.java @@ -0,0 +1,36 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.io.Serializable; + +@ApiModel("设备信息分页查询") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DeviceQueryDto implements Serializable { + private static final long serialVersionUID = -82361770389504903L; + + @ApiModelProperty(notes = "设备编号", example = "设备编号") + private String deviceId; + + @ApiModelProperty(notes = "设备类型:{box:边缘计算盒子, surveillance_camera:监控摄像头, network_sound_column:网络音响}", example = "设备类型(可选项:box、network_sound_column、surveillance_camera)") + private String type; + + @ApiModelProperty(notes = "设备厂商:{hikvision:海康威视, corerain:鲲云, sophgo:算能, mock:MOCK}", example = "设备厂商(可选项:hikvision, corerain, sophgo, mock") + private String vendor; + + @ApiModelProperty(notes = "设备名称", example = "设备名称") + private String name; + + @ApiModelProperty(notes = "检测点(场景id)", example = "检测点(场景id)") + private Integer point; + + @ApiModelProperty(notes = "上级设备id", example = "上级设备id, 默认为0") + private Long parentId = 0L; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/LoginDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/LoginDto.java new file mode 100644 index 0000000..fe112f9 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/LoginDto.java @@ -0,0 +1,36 @@ +package com.mathvision.box.dao.domain.dto; + +import com.mathvision.box.common.annotation.aes.AesDecrypt; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: fy + * @Date: 2024/04/03 + * @Description: + */ +@ApiModel("登录") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LoginDto implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(notes = "账号", required = true) + @NotBlank(message = "账号不能为空") + private String loginName; + + @ApiModelProperty(notes = "密码", required = true) + @NotBlank(message = "密码不能为空") +// @AesDecrypt + private String password; + + @ApiModelProperty(notes = "验证码") + private String code; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/PointAddDeviceDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/PointAddDeviceDto.java new file mode 100644 index 0000000..3f6ffc0 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/PointAddDeviceDto.java @@ -0,0 +1,28 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@ApiModel("检测点关联设备参数") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PointAddDeviceDto implements Serializable { + private static final long serialVersionUID = 674711670966002821L; + + @ApiModelProperty(notes = "检测点id", required = true) + @NotNull(message = "关联场景不能为空") + private Long pointId; + + @ApiModelProperty(notes = "设备id", required = true) + @NotNull(message = "关联设备不能为空") + private Long deviceId; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/PointAddDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/PointAddDto.java new file mode 100644 index 0000000..8dc5ae0 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/PointAddDto.java @@ -0,0 +1,42 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@ApiModel("检测点表(PointDto)传输数据类") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PointAddDto implements Serializable { + private static final long serialVersionUID = 674711670966002821L; + + private Long id; + + @ApiModelProperty(notes = "检测点编号") + private String pointId; + + @ApiModelProperty(notes = "检测点名称") + private String pointName; + + @ApiModelProperty(notes = "关联站id") + private Long stationId; + + @ApiModelProperty(notes = "配置参数") + private String config; + + @ApiModelProperty(notes = "备注") + private String remark; + + @ApiModelProperty("展示图片url") + private String cover; + + @ApiModelProperty("状态(0-停止/1-启动)") + private String status; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/PointQueryDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/PointQueryDto.java new file mode 100644 index 0000000..ef8ee5f --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/PointQueryDto.java @@ -0,0 +1,33 @@ +package com.mathvision.box.dao.domain.dto; + +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.Builder; + +@ApiModel("检测点查询参数") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PointQueryDto implements Serializable { + private static final long serialVersionUID = 674711670966002821L; + + private Long id; + + @ApiModelProperty(notes = "检测点编号") + private String pointId; + + @ApiModelProperty(notes = "检测点名称") + private String pointName; + + @ApiModelProperty(notes = "关联站id") + private Long stationId; + + @ApiModelProperty("状态(0-禁用/1-启动)") + private String status; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/StationAddDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/StationAddDto.java new file mode 100644 index 0000000..5976ebe --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/StationAddDto.java @@ -0,0 +1,42 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +@ApiModel("站新增/修改参数") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StationAddDto implements Serializable { + private static final long serialVersionUID = 654669892807817746L; + + private Long id; + + @ApiModelProperty(notes = "站编号") + @NotBlank(message = "编号不能为空") + private String stationId; + + @ApiModelProperty(notes = "站名称") + @NotBlank(message = "名称不能为空") + private String stationName; + + @ApiModelProperty(notes = "站地址") + private String address; + + @ApiModelProperty(notes = "联系人") + private String contact; + + @ApiModelProperty(notes = "联系人电话") + private String phone; + + @ApiModelProperty(notes = "站简介") + private String introduction; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/StationQueryDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/StationQueryDto.java new file mode 100644 index 0000000..6f79742 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/StationQueryDto.java @@ -0,0 +1,34 @@ +package com.mathvision.box.dao.domain.dto; + +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.Builder; + +@ApiModel("站查询参数") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StationQueryDto implements Serializable { + private static final long serialVersionUID = 654669892807817746L; + + @ApiModelProperty(notes = "站编号") + private String stationId; + + @ApiModelProperty(notes = "站名称") + private String stationName; + + @ApiModelProperty(notes = "站地址") + private String address; + + @ApiModelProperty(notes = "联系人") + private String contact; + + @ApiModelProperty(notes = "联系人电话") + private String phone; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysConfigDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysConfigDto.java new file mode 100644 index 0000000..68f03ff --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysConfigDto.java @@ -0,0 +1,48 @@ +package com.mathvision.box.dao.domain.dto; + +import java.util.Date; +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.Builder; + +@ApiModel("参数配置表(SysConfigDto)传输数据类") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysConfigDto implements Serializable { + private static final long serialVersionUID = 534034771306361219L; + + @ApiModelProperty(notes = "参数主键") + private Integer configId; + + @ApiModelProperty(notes = "参数名称") + private String configName; + + @ApiModelProperty(notes = "参数键名") + private String configKey; + + @ApiModelProperty(notes = "参数键值") + private String configValue; + + @ApiModelProperty(notes = "创建者") + private Long createUser; + + @ApiModelProperty(notes = "创建时间") + private Date createTime; + + @ApiModelProperty(notes = "更新者") + private Long updateUser; + + @ApiModelProperty(notes = "更新时间") + private Date updateTime; + + @ApiModelProperty(notes = "备注") + private String remark; + +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysFileAddDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysFileAddDto.java new file mode 100644 index 0000000..18d3afa --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysFileAddDto.java @@ -0,0 +1,35 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +@ApiModel("文件添加") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysFileAddDto implements Serializable { + private static final long serialVersionUID = 213481926880050290L; + + @ApiModelProperty(notes = "文件ID", example = "文件ID") + private Long fileId; + + @ApiModelProperty(notes = "文件类型", example = "音频文件固定填 Audio", required = true) + @NotBlank(message = "文件类型不能为空") + private String fileType; + + @ApiModelProperty(notes = "文件名称", example = "文件名称", required = true) + @NotBlank(message = "文件名称不能为空") + private String fileName; + + @ApiModelProperty(notes = "文件url 音频文件仅支持AAC(推荐)、MP3格式的音频文件, 每个文件大小不超过1MB。", example = "文件url", required = true) + @NotBlank(message = "文件url不能为空") + private String url; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysFileQueryDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysFileQueryDto.java new file mode 100644 index 0000000..96f5ac3 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysFileQueryDto.java @@ -0,0 +1,33 @@ +package com.mathvision.box.dao.domain.dto; + +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.Builder; + +import javax.validation.constraints.NotBlank; + +@ApiModel("文件查询") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysFileQueryDto implements Serializable { + private static final long serialVersionUID = 213481926880050290L; + + @ApiModelProperty(notes = "文件ID", example = "文件ID") + private Long fileId; + + @ApiModelProperty(notes = "文件类型", example = "音频文件固定填 Audio") + private String fileType; + + @ApiModelProperty(notes = "文件名称", example = "文件名称") + private String fileName; + + @ApiModelProperty(notes = "文件url 音频文件仅支持AAC(推荐)、MP3格式的音频文件, 每个文件大小不超过1MB。", example = "文件url") + private String url; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysLogDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysLogDto.java new file mode 100644 index 0000000..828a6ac --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/SysLogDto.java @@ -0,0 +1,36 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Date; + +@ApiModel("系统日志信息表(SysLogDto)传输数据类") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysLogDto implements Serializable { + private static final long serialVersionUID = 366128147942255654L; + + @ApiModelProperty(notes = "日志ID") + private Long logId; + + @ApiModelProperty(notes = "日志类型") + private String logType; + + @ApiModelProperty(notes = "日志内容") + private String logContent; + + @ApiModelProperty(notes = "创建人") + private Long createUser; + + @ApiModelProperty(notes = "创建时间") + private Date createTime; + +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UISettingConfigDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UISettingConfigDto.java new file mode 100644 index 0000000..b693305 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UISettingConfigDto.java @@ -0,0 +1,49 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +@ApiModel("界面设置修改参数") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UISettingConfigDto implements Serializable { + private static final long serialVersionUID = 534034771306361219L; + + @ApiModelProperty(value = "产品名称", example = "产品名称",required = true) + @NotBlank(message = "产品名称不能为空") + private String name; + + @ApiModelProperty(value = "产品Logo 图片url", example = "产品Logo 图片url") + private String logo; + + @ApiModelProperty(value = "产品favicon 图片url", example = "产品favicon 图片url") + private String favicon; + + @ApiModelProperty(value = "登录背景 图片url", example = "登录背景 图片url") + private String loginBackground; + + @ApiModelProperty(value = "扩展字段1", example = "扩展字段1") + private String ext1; + + @ApiModelProperty(value = "扩展字段2", example = "扩展字段2") + private String ext2; + + @ApiModelProperty(value = "扩展字段3", example = "扩展字段3") + private String ext3; + + @ApiModelProperty(value = "扩展字段4", example = "扩展字段4") + private String ext4; + + @ApiModelProperty(value = "扩展字段5", example = "扩展字段5") + private String ext5; + +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsMenuDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsMenuDto.java new file mode 100644 index 0000000..d42e9fd --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsMenuDto.java @@ -0,0 +1,52 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +@ApiModel("菜单表(UmsMenuDto)传输数据类") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UmsMenuDto implements Serializable { + private static final long serialVersionUID = -26115459430198770L; + + @ApiModelProperty(notes = "菜单ID") + private Long menuId; + + @ApiModelProperty(notes = "菜单名称", required = true) + @NotBlank(message = "菜单名称不能为空") + private String menuName; + + @ApiModelProperty(notes = "父主键ID") + private Long parentId; + + @ApiModelProperty(notes = "排序") + private Integer sort; + + @ApiModelProperty(notes = "请求路径") + private String url; + + @ApiModelProperty(notes = "菜单类型(M目录 C菜单 F按钮)") + private String menuType; + + @ApiModelProperty(notes = "菜单状态(1隐藏 0显示)") + private String visible; + + @ApiModelProperty(notes = "权限标识") + private String permission; + + @ApiModelProperty(notes = "菜单图标") + private String icon; + + @ApiModelProperty(notes = "备注") + private String remark; + +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsOrganizationDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsOrganizationDto.java new file mode 100644 index 0000000..063e3f4 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsOrganizationDto.java @@ -0,0 +1,46 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +@ApiModel("组织信息表(UmsOrganizationDto)传输数据类") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UmsOrganizationDto implements Serializable { + private static final long serialVersionUID = -22653557155840114L; + + @ApiModelProperty(notes = "组织ID") + private Long organizationId; + + @ApiModelProperty(notes = "组织名称", required = true) + @NotBlank(message = "组织名称不能为空") + private String organizationName; + + @ApiModelProperty(notes = "组织类型(0:公司/1:部门/2:岗位)") + private String organizationType; + + @ApiModelProperty(notes = "显示顺序") + private Integer orderNum; + + @ApiModelProperty(notes = "父组织id") + private Long parentId; + + @ApiModelProperty(notes = "深度") + private String depth; + + @ApiModelProperty(notes = "状态(0:正常/1:停用)") + private String status; + + private Long createUser; + + private Long updateUser; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsRoleDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsRoleDto.java new file mode 100644 index 0000000..759965b --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsRoleDto.java @@ -0,0 +1,43 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +@ApiModel("角色表(UmsRoleDto)传输数据类") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UmsRoleDto implements Serializable { + private static final long serialVersionUID = 154065236903833980L; + + @ApiModelProperty("角色ID") + private Long roleId; + + @ApiModelProperty(notes = "角色名称", required = true) + @NotBlank(message = "角色名称不能为空") + private String roleName; + + @ApiModelProperty(notes = "角色权限字符串") + private String roleKey; + + @ApiModelProperty(notes = "角色状态(0:正常/1:停用)") + private String status; + + @ApiModelProperty("显示顺序") + private Integer roleSort; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("菜单权限idList") + private List menuIdList; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserAddDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserAddDto.java new file mode 100644 index 0000000..3e3f87d --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserAddDto.java @@ -0,0 +1,65 @@ +package com.mathvision.box.dao.domain.dto; + +import com.mathvision.box.common.annotation.aes.AesDecrypt; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; +import java.io.Serializable; + + +@ApiModel("用户表(UmsUserDto)传输数据类") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UmsUserAddDto implements Serializable { + private static final long serialVersionUID = -65838283669796140L; + + @ApiModelProperty(notes = "主键") + private Long userId; + + @ApiModelProperty(notes = "账号名", required = true) + @NotBlank(message = "账号名不能为空") + private String loginName; + + @ApiModelProperty(notes = "姓名", required = true) + @NotBlank(message = "姓名不能为空") + private String userName; + + @ApiModelProperty(notes = "用户邮箱") + private String email; + + @ApiModelProperty(notes = "联系电话", required = true) + @NotBlank(message = "手机号码不能为空") + @Length(min = 11, max = 11, message = "手机号只能为11位") + @Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误") + private String phone; + + @ApiModelProperty(notes = "状态(0-在职 1-离职)") + private String status; + + @ApiModelProperty(notes = "密码") +// @AesDecrypt + private String password; + + @ApiModelProperty(notes = "用户性别(0-男 1-女 2-未知)") + private String sex; + + @ApiModelProperty(notes = "头像路径") + private String avatar; + + @ApiModelProperty(notes = "岗位id") + private Long organizationId; + + @ApiModelProperty(notes = "角色id") + private Long roleId; + + private Long createUser; + + private Long updateUser; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserPasswordDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserPasswordDto.java new file mode 100644 index 0000000..9f75398 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserPasswordDto.java @@ -0,0 +1,35 @@ +package com.mathvision.box.dao.domain.dto; + +import com.mathvision.box.common.annotation.aes.AesDecrypt; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +@ApiModel("个人密码修改") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UmsUserPasswordDto implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(notes = "旧密码", required = true) + @NotBlank(message = "旧密码不能为空") +// @AesDecrypt + private String oldPassword; + + @ApiModelProperty(notes = "新密码", required = true) + @NotBlank(message = "新密码不能为空") +// @AesDecrypt + private String newPassword; + + @ApiModelProperty(notes = "确认密码", required = true) + @NotBlank(message = "确认密码不能为空") +// @AesDecrypt + private String checkPassword; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserQueryDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserQueryDto.java new file mode 100644 index 0000000..fea1eb5 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserQueryDto.java @@ -0,0 +1,51 @@ +package com.mathvision.box.dao.domain.dto; + +import com.mathvision.box.common.core.page.PageDomain; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author: fy + * @Date: 2024/04/02 + * @Description: + */ +@ApiModel("用户查询") +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UmsUserQueryDto extends PageDomain implements Serializable { + private static final long serialVersionUID = -65838283669796140L; + @ApiModelProperty(notes = "userId") + private Long userId; + + @ApiModelProperty(notes = "账号名") + private String loginName; + + @ApiModelProperty(notes = "姓名") + private String userName; + + @ApiModelProperty(notes = "联系电话") + private String phone; + + @ApiModelProperty(notes = "状态(0-在职 1-离职)") + private String status; + + @ApiModelProperty(notes = "用户性别(0-男 1-女 2-未知)") + private String sex; + + @ApiModelProperty(notes = "公司/部门/岗位id") + private Long organizationId; + + @ApiModelProperty(notes = "角色id") + private Long roleId; + + private List organizationIds_; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserSelfDto.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserSelfDto.java new file mode 100644 index 0000000..5d5b7b6 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/dto/UmsUserSelfDto.java @@ -0,0 +1,39 @@ +package com.mathvision.box.dao.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; +import java.io.Serializable; + + +@ApiModel("个人基本信息修改") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UmsUserSelfDto implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(notes = "姓名", required = true) + @NotBlank(message = "姓名不能为空") + private String userName; + + @ApiModelProperty(notes = "用户邮箱") + private String email; + + @ApiModelProperty(notes = "联系电话") + @Length(min = 11, max = 11, message = "手机号只能为11位") + @Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误") + private String phone; + + @ApiModelProperty(notes = "用户性别(0-男 1-女 2-未知)") + private String sex; + + @ApiModelProperty(notes = "头像路径") + private String avatar; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/BoxRecord.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/BoxRecord.java new file mode 100644 index 0000000..29a8eba --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/BoxRecord.java @@ -0,0 +1,76 @@ +package com.mathvision.box.dao.domain.entity; + +import java.util.Date; + +import com.mathvision.box.common.annotation.CsvColumn; +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "box_record") +public class BoxRecord { + private static final long serialVersionUID = 402312892612839559L; + + /** + * 记录id(主键) + */ + @JsonIgnore + @TableId(value = "record_id", type = IdType.AUTO) + @CsvColumn(header = "记录id") + private Long recordId; + + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + @CsvColumn(header = "创建时间") + private Date createTime; + + /** + * 记录类型 + */ + @TableField("record_type") + @CsvColumn(header = "记录类型") + private String recordType; + + /** + * 设备id + */ + @TableField("device_id") + @CsvColumn(header = "设备id") + private Long deviceId; + + /** + * 数据key + */ + @TableField("data_key") + @CsvColumn(header = "数据key") + private String dataKey; + + /** + * 数据类型 + */ + @TableField("data_type") + @CsvColumn(header = "数据类型") + private String dataType; + + /** + * 内容 + */ + @TableField("content") + @CsvColumn(header = "内容") + private String content; + + /** + * 扩展字段 + */ + @TableField("extended") + @CsvColumn(header = "扩展字段") + private String extended; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/BoxTrace.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/BoxTrace.java new file mode 100644 index 0000000..0c38262 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/BoxTrace.java @@ -0,0 +1,77 @@ +package com.mathvision.box.dao.domain.entity; + +import java.util.Date; + +import com.mathvision.box.common.annotation.CsvColumn; +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * 边缘计算盒子报警追踪表(BoxTrace)表实体类 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "box_trace") +public class BoxTrace { + private static final long serialVersionUID = -61610949484105814L; + + @JsonIgnore + @TableId(value = "id", type = IdType.AUTO) + @CsvColumn(header = "id") + private Long id; + + /** + * 关联设备id + */ + @TableField("device_id") + @CsvColumn(header = "关联设备id") + private String deviceId; + + /** + * 报警代码 + */ + @TableField("alarm_code") + @CsvColumn(header = "报警代码") + private String alarmCode; + + /** + * 报警级别 + */ + @TableField("alarm_level") + @CsvColumn(header = "报警级别") + private String alarmLevel; + + /** + * 报警详情内容 + */ + @TableField("alarm_content") + @CsvColumn(header = "报警详情内容") + private String alarmContent; + + /** + * 追踪信息 + */ + @TableField("trace_info") + @CsvColumn(header = "追踪信息") + private String traceInfo; + + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + @CsvColumn(header = "创建时间") + private Date createTime; + + /** + * 修改时间 + */ + @JsonIgnore + @TableField(fill = FieldFill.INSERT_UPDATE) + @CsvColumn(header = "修改时间") + private Date updateTime; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Defect.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Defect.java new file mode 100644 index 0000000..1f9cb17 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Defect.java @@ -0,0 +1,107 @@ +package com.mathvision.box.dao.domain.entity; + +import java.util.Date; +import java.util.List; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.mathvision.box.common.annotation.CsvColumn; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonIgnore; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "defect") +@ApiModel("告警数据") +public class Defect { + private static final long serialVersionUID = 141252724050606238L; + + @JsonIgnore + @TableId(value = "id", type = IdType.AUTO) + @CsvColumn(header = "id") + private Long id; + + @TableField("process_id") + @ApiModelProperty("过程id") + @CsvColumn(header = "过程id") + private String processId; + + @TableField("time") + @ApiModelProperty("告警时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JSONField(format="yyyy-MM-dd HH:mm:ss") + @CsvColumn(header = "告警时间") + private Date time; + + @TableField("end_time") + @ApiModelProperty("结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JSONField(format="yyyy-MM-dd HH:mm:ss") + @CsvColumn(header = "结束时间") + private Date endTime; + + @TableField("type") + @ApiModelProperty("告警类型") + @CsvColumn(header = "告警类型") + private String type; + + @TableField("ip") + @ApiModelProperty("设备IP") + @CsvColumn(header = "设备IP") + private String ip; + + @ApiModelProperty("设备id") + @TableField("device_id") + @CsvColumn(header = "设备id") + private Long deviceId; + + @ApiModelProperty("设备名称") + @TableField("device_name") + @CsvColumn(header = "设备名称") + private String deviceName; + + @ApiModelProperty("通道") + @TableField("channel") + @CsvColumn(header = "通道") + private Integer channel; + + @ApiModelProperty("通道名称") + @TableField("channel_name") + @CsvColumn(header = "通道名称") + private String channelName; + + @ApiModelProperty("图片信息json") + @TableField("img") + @CsvColumn(header = "图片信息json") + private String img; + + @ApiModelProperty("视频url") + @TableField("video") + @CsvColumn(header = "视频url") + private String video; + + @ApiModelProperty("告警详情") + @TableField("data") + @CsvColumn(header = "告警详情") + private String data; + + @ApiModelProperty("处置信息") + @TableField("ext") + @CsvColumn(header = "处置信息") + private String ext; + + @ApiModelProperty("状态(0-未处理(已完成)/1-已处理/2-未完成)") + @TableField("status") + @CsvColumn(header = "状态") + private String status; + + @ApiModelProperty("点位ids") + @TableField(exist = false) + @CsvColumn(header = "点位ids") + private List pointIds; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Detect.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Detect.java new file mode 100644 index 0000000..a254c57 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Detect.java @@ -0,0 +1,82 @@ +package com.mathvision.box.dao.domain.entity; + +import java.util.Date; + +import com.mathvision.box.common.annotation.CsvColumn; +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonIgnore; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "detect") +public class Detect { + private static final long serialVersionUID = -98448484824682528L; + + @JsonIgnore + @TableId(value = "id", type = IdType.AUTO) + @CsvColumn(header = "id") + private Long id; + + /** + * 步骤id + */ + @TableField("detect_id") + @CsvColumn(header = "步骤id") + private String detectId; + + /** + * 过程id + */ + @TableField("process_id") + @CsvColumn(header = "过程id") + private String processId; + + @TableField("time") + @CsvColumn(header = "告警时间") + private Date time; + + /** + * 告警类型 + */ + @TableField("type") + @CsvColumn(header = "告警类型") + private String type; + + /** + * 设备IP + */ + @TableField("ip") + @CsvColumn(header = "设备IP") + private String ip; + + /** + * 通道 + */ + @TableField("channel") + @CsvColumn(header = "通道") + private Integer channel; + + /** + * 图片json + */ + @TableField("img") + @CsvColumn(header = "图片json") + private String img; + + /** + * 扩展数据 + */ + @TableField("data") + @CsvColumn(header = "扩展数据") + private String data; + + /** + * 状态(0-正常,1-异常,2-修正) + */ + @TableField("status") + @CsvColumn(header = "状态") + private String status; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Device.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Device.java new file mode 100644 index 0000000..5714fba --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Device.java @@ -0,0 +1,80 @@ +package com.mathvision.box.dao.domain.entity; + +import java.util.Date; +import java.util.List; + +import com.mathvision.box.common.annotation.tree.TreeNodeId; +import com.mathvision.box.common.annotation.tree.TreeNodeName; +import com.mathvision.box.common.annotation.tree.TreeNodeParentId; +import com.mathvision.box.common.enums.DeviceStatus; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "device") +@ApiModel("设备数据") +public class Device { + private static final long serialVersionUID = 120190760617787120L; + + @TableId(value = "id", type = IdType.AUTO) + @TreeNodeId + private Long id; + + @TableField("device_id") + @ApiModelProperty("设备编号") + private String deviceId; + + @ApiModelProperty("上级设备id") + @TableField("parent_id") + @TreeNodeParentId + private Long parentId; + + @ApiModelProperty(notes = "设备类型:{box:边缘计算盒子, surveillance_camera:监控摄像头, network_sound_column:网络音响}", example = "设备类型(可选项:box、network_sound_column、surveillance_camera)") + @TableField("type") + private String type; + + @ApiModelProperty("设备名称") + @TableField("name") + @TreeNodeName + private String name; + + //todo 设备密码加密 + @ApiModelProperty("设备配置属性") + @TableField("config") + private String config; + + @ApiModelProperty(notes = "设备厂商:{hikvision:海康威视, corerain:鲲云, sophgo:算能, mock:MOCK}", example = "设备厂商(可选项:hikvision, corerain, sophgo, mock") + @TableField("vendor") + private String vendor; + + @ApiModelProperty("备注") + @TableField("remark") + private String remark; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @JsonIgnore + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + @ApiModelProperty("关联检测点位[归属场景]id") + @TableField(exist = false) + private List pointIds; + + @ApiModelProperty(notes = "设备状态", example = "设备状态(ready, online, offline, working, error)") + @TableField(exist = false) + private DeviceStatus status; + + @ApiModelProperty(notes = "设备温度") + @TableField(exist = false) + private Float temperature; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Point.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Point.java new file mode 100644 index 0000000..53bbf92 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Point.java @@ -0,0 +1,61 @@ +package com.mathvision.box.dao.domain.entity; + +import java.util.Date; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "point") +@ApiModel("检测点数据") +public class Point { + private static final long serialVersionUID = -59190068196003152L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty("检测点编号") + @TableField("point_id") + private String pointId; + + @ApiModelProperty("检测点名称") + @TableField("point_name") + private String pointName; + + @ApiModelProperty("关联站id") + @TableField("station_id") + private Long stationId; + + @ApiModelProperty("展示图片url") + @TableField("cover") + private String cover; + + @ApiModelProperty("配置参数") + @TableField("config") + private String config; + + @ApiModelProperty("备注") + @TableField("remark") + private String remark; + + @ApiModelProperty("状态(0-停止/1-启动)") + @TableField("status") + private String status; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @JsonIgnore + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + //TODO 关联设备数量 +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/PointDevice.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/PointDevice.java new file mode 100644 index 0000000..7122196 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/PointDevice.java @@ -0,0 +1,18 @@ +package com.mathvision.box.dao.domain.entity; + +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "point_device") +public class PointDevice { + private static final long serialVersionUID = -65577103179935444L; + + @TableId(type = IdType.INPUT) + private Long pointId; + + private Long deviceId; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Station.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Station.java new file mode 100644 index 0000000..227ecf5 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/Station.java @@ -0,0 +1,55 @@ +package com.mathvision.box.dao.domain.entity; + +import java.util.Date; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "station") +@ApiModel("站数据") +public class Station { + private static final long serialVersionUID = -65996004779023028L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty("站编号") + @TableField("station_id") + private String stationId; + + @ApiModelProperty("站名称") + @TableField("station_name") + private String stationName; + + @ApiModelProperty("站地址") + @TableField("address") + private String address; + + @ApiModelProperty("联系人") + @TableField("contact") + private String contact; + + @ApiModelProperty("联系人电话") + @TableField("phone") + private String phone; + + @ApiModelProperty("站简介") + @TableField("introduction") + private String introduction; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @JsonIgnore + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/SysConfig.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/SysConfig.java new file mode 100644 index 0000000..79ba729 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/SysConfig.java @@ -0,0 +1,82 @@ +package com.mathvision.box.dao.domain.entity; + +import java.util.Date; + +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * 参数配置表(SysConfig)表实体类 + * + * @author Fangy + * @since 2025-04-30 10:28:58 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "sys_config") +public class SysConfig { + private static final long serialVersionUID = 572097922499322799L; + + + /** + * 参数主键(主键) + */ + @TableId(value = "config_id", type = IdType.AUTO) + private Integer configId; + + /** + * 参数名称 + */ + @TableField("config_name") + private String configName; + + /** + * 参数键名 + */ + @TableField("config_key") + private String configKey; + + /** + * 参数键值 + */ + @TableField("config_value") + private String configValue; + + /** + * 创建者 + */ + @TableField("create_user") + private Long createUser; + + /** + * 创建时间 + */ + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 更新者 + */ + @TableField("update_user") + private Long updateUser; + + /** + * 更新时间 + */ + + @JsonIgnore + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** + * 备注 + */ + @TableField("remark") + private String remark; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/SysFile.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/SysFile.java new file mode 100644 index 0000000..7c1de3b --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/SysFile.java @@ -0,0 +1,43 @@ +package com.mathvision.box.dao.domain.entity; + +import java.util.Date; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "sys_file") +@ApiModel("文件数据") +public class SysFile { + private static final long serialVersionUID = 762280504929240825L; + + @ApiModelProperty(notes = "文件ID") + @TableId(value = "file_id", type = IdType.AUTO) + private Long fileId; + + @ApiModelProperty(notes = "文件类型") + @TableField("file_type") + private String fileType; + + @ApiModelProperty(notes = "文件名称") + @TableField("file_name") + private String fileName; + + @ApiModelProperty(notes = "文件url") + @TableField("url") + private String url; + + @TableField("create_user") + private Long createUser; + + @ApiModelProperty(notes = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + private Date createTime; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/SysLog.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/SysLog.java new file mode 100644 index 0000000..e6cad49 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/SysLog.java @@ -0,0 +1,65 @@ +package com.mathvision.box.dao.domain.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.mathvision.box.common.annotation.CsvColumn; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 系统日志信息表(SysLog)表实体类 + * + * @author Fangy + * @since 2024-09-24 15:57:56 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "sys_log") +public class SysLog { + private static final long serialVersionUID = -71371159198944404L; + + + /** + * 日志ID(主键) + */ + @JsonIgnore + @TableId(value = "log_id", type = IdType.AUTO) + @CsvColumn(header = "日志ID(主键)") + private Long logId; + + /** + * 日志类型 + */ + @TableField("log_type") + @CsvColumn(header = "日志类型") + private String logType; + + /** + * 日志内容 + */ + @TableField("log_content") + @CsvColumn(header = "日志内容") + private String logContent; + + /** + * 创建人 + */ + @TableField("create_user") + @CsvColumn(header = "创建人id") + private Long createUser; + + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + @CsvColumn(header = "创建时间") + private Date createTime; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsMenu.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsMenu.java new file mode 100644 index 0000000..5003da9 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsMenu.java @@ -0,0 +1,133 @@ +package com.mathvision.box.dao.domain.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 菜单表(UmsMenu)表实体类 + * + * @author Fangy + * @since 2024-03-25 15:50:12 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "ums_menu") +@ApiModel("菜单表") +public class UmsMenu { + private static final long serialVersionUID = -97647718306147532L; + + /** + * 菜单ID(主键) + */ + @JsonIgnore + @TableId(value = "menu_id", type = IdType.AUTO) + @ApiModelProperty("菜单ID") + private Long menuId; + + /** + * 菜单名称 + */ + @TableField("menu_name") + @ApiModelProperty("菜单名称") + private String menuName; + + /** + * 父主键ID + */ + @TableField("parent_id") + @ApiModelProperty("父主键ID") + private Long parentId; + + /** + * 排序 + */ + @TableField("sort") + @ApiModelProperty("排序") + private Integer sort; + + /** + * 请求路径 + */ + @TableField("url") + @ApiModelProperty("请求路径") + private String url; + + /** + * 菜单类型(M目录 C菜单 F按钮) + */ + @TableField("menu_type") + @ApiModelProperty("菜单类型(M目录 C菜单 F按钮)") + private String menuType; + + /** + * 菜单状态(1隐藏 0显示) + */ + @TableField("visible") + @ApiModelProperty("菜单状态(1隐藏 0显示)") + private String visible; + + /** + * 权限标识 + */ + @TableField("permission") + @ApiModelProperty("权限标识") + private String permission; + + /** + * 菜单图标 + */ + @TableField("icon") + @ApiModelProperty("菜单图标") + private String icon; + + /** + * 创建人 + */ + @TableField("create_user") + private Long createUser; + + /** + * 创建时间 + */ + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 修改人 + */ + @TableField("update_user") + private Long updateUser; + + /** + * 修改时间 + */ + + @JsonIgnore + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** + * 是否删除(0:正常/1:删除) + */ + @TableField("is_deleted") + private Object isDeleted; + + /** + * 备注 + */ + @TableField("remark") + private String remark; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsOrganization.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsOrganization.java new file mode 100644 index 0000000..b6bffd5 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsOrganization.java @@ -0,0 +1,113 @@ +package com.mathvision.box.dao.domain.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.mathvision.box.common.annotation.tree.TreeNodeId; +import com.mathvision.box.common.annotation.tree.TreeNodeName; +import com.mathvision.box.common.annotation.tree.TreeNodeParentId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "ums_organization") +@ApiModel("组织信息表") +public class UmsOrganization { + private static final long serialVersionUID = -27479820178077875L; + + /** + * 组织ID(主键) + */ + @JsonIgnore + @TableId(value = "organization_id", type = IdType.AUTO) + @TreeNodeId + @ApiModelProperty("组织ID") + private Long organizationId; + + /** + * 组织名称 + */ + @TableField("organization_name") + @TreeNodeName + @ApiModelProperty("组织名称") + private String organizationName; + + /** + * 组织类型(0:公司/1:部门/2:岗位) + */ + @TableField("organization_type") + @ApiModelProperty("组织类型(0:公司/1:部门/2:岗位)") + private String organizationType; + + /** + * 显示顺序 + */ + @TableField("order_num") + @ApiModelProperty("显示顺序") + private Integer orderNum; + + /** + * 父组织id + */ + @TableField("parent_id") + @TreeNodeParentId + @ApiModelProperty("父组织id") + private Long parentId; + + /** + * 深度 + */ + @TableField("depth") + @ApiModelProperty("深度") + private String depth; + + /** + * 状态(0:正常/1:停用) + */ + @TableField("status") + @ApiModelProperty("状态(0:正常/1:停用)") + private String status; + + /** + * 是否删除有效(0:正常/1:删除有效) + */ + @TableField("is_deleted") + private String isDeleted; + + /** + * 创建人 + */ + @TableField("create_user") + private Long createUser; + + /** + * 创建时间 + */ + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 修改人 + */ + @TableField("update_user") + private Long updateUser; + + /** + * 修改时间 + */ + + @JsonIgnore + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsRole.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsRole.java new file mode 100644 index 0000000..5ca4395 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsRole.java @@ -0,0 +1,104 @@ +package com.mathvision.box.dao.domain.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * 角色表(UmsRole)表实体类 + * + * @author Fangy + * @since 2024-04-03 16:14:03 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "ums_role") +public class UmsRole { + private static final long serialVersionUID = -51781180838006152L; + + /** + * 角色ID(主键) + */ + @JsonIgnore + @TableId(value = "role_id", type = IdType.AUTO) + private Long roleId; + + /** + * 角色名称 + */ + @TableField("role_name") + private String roleName; + + /** + * 角色权限字符串 + */ + @TableField("role_key") + private String roleKey; + + /** + * 显示顺序 + */ + @TableField("role_sort") + private Integer roleSort; + + /** + * 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) + */ + @TableField("data_scope") + private String dataScope; + + /** + * 角色状态(0:正常/1:停用) + */ + @TableField("status") + private String status; + + /** + * 是否删除(0:正常/1:删除) + */ + @TableField("is_deleted") + private String isDeleted; + + /** + * 创建人 + */ + @TableField("create_user") + private Long createUser; + + /** + * 创建时间 + */ + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 修改人 + */ + @TableField("update_user") + private Long updateUser; + + /** + * 修改时间 + */ + + @JsonIgnore + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** + * 备注 + */ + @TableField("remark") + private String remark; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsRoleMenu.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsRoleMenu.java new file mode 100644 index 0000000..5e4d22b --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsRoleMenu.java @@ -0,0 +1,23 @@ +package com.mathvision.box.dao.domain.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "ums_role_menu") +public class UmsRoleMenu { + private static final long serialVersionUID = 686031140857580486L; + + @TableId(type = IdType.INPUT) + private Long roleId; + + private Long menuId; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsUser.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsUser.java new file mode 100644 index 0000000..548a33a --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsUser.java @@ -0,0 +1,195 @@ +package com.mathvision.box.dao.domain.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.mathvision.box.common.annotation.aes.AesEncrypt; +import com.mathvision.box.common.annotation.excel.Excel; +import com.mathvision.box.common.xss.Xss; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 用户表(UmsUser)表实体类 + * + * @author Fangy + * @since 2024-03-22 17:47:19 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "ums_user") +@ApiModel("用户信息") +public class UmsUser { + private static final long serialVersionUID = -73936105573664937L; + + /** + * 用户ID(主键) + */ + @TableId(value = "user_id", type = IdType.AUTO) + @ApiModelProperty("用户ID(主键)") + private Long userId; + + /** + * 登录账号 + */ + @TableField("login_name") + @Excel(name = "账号名") + @ApiModelProperty("账号名") + @Xss(message = "登录账号不能包含脚本字符") + private String loginName; + + /** + * 用户昵称 + */ + @TableField("user_name") + @Excel(name = "姓名") + @ApiModelProperty("用户昵称") + private String userName; + + /** + * 用户邮箱 + */ + @Excel(name = "邮箱") + @TableField("email") + @ApiModelProperty("用户邮箱") + private String email; + + /** + * 联系电话 + */ + @TableField("phone") + @Excel(name = "联系电话") + @ApiModelProperty("联系电话") + private String phone; + + /** + * 密码 + */ + @TableField("password") +// @AesEncrypt + @JSONField(serialize = false) + private String password; + + /** + * 盐加密 + */ + @TableField("salt") + @JSONField(serialize = false) + private String salt; + + /** + * 状态(0:正常/1:停用) + */ + @TableField("status") + @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用", combo = {"正常", "停用"}) + @ApiModelProperty("状态(0=正常,1=停用)") + private String status; + + /** + * 是否删除(0:正常/1:删除) + */ + @TableField("is_deleted") + @JSONField(serialize = false) + private Integer isDeleted; + + /** + * 最后登录IP + */ + @TableField("login_ip") + private String loginIp; + + /** + * 最后登录时间 + */ + @TableField("login_date") + private Date loginDate; + + /** + * 密码最后更新时间 + */ + @TableField("pwd_update_date") + private Date pwdUpdateDate; + + /** + * 创建人 + */ + @TableField("create_user") + @JSONField(serialize = false) + private Long createUser; + + /** + * 创建时间 + */ + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** + * 修改人 + */ + @TableField("update_user") + @JSONField(serialize = false) + private Long updateUser; + + /** + * 修改时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @JSONField(serialize = false) + private Date updateTime; + + /** + * 备注 + */ + @Excel(name = "备注") + @TableField("remark") + private String remark; + + /** + * 用户性别(0-男 1-女 2-未知) + */ + @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知", combo = {"男", "女", "未知"}) + @TableField("sex") + @ApiModelProperty("用户性别(0-男 1-女 2-未知)") + private String sex; + + /** + * 头像路径 + */ + @TableField("avatar") + @ApiModelProperty("头像路径") + private String avatar; + + @TableField(exist = false) + @ApiModelProperty("所属组织ID") + private Long organizationId; + + @TableField(exist = false) + @ApiModelProperty("所属组织名称") + private String organizationName; + + @TableField(exist = false) + @ApiModelProperty("角色ID") + private Long roleId; + + @TableField(exist = false) + @ApiModelProperty("角色名称") + private String roleName; + + public boolean isAdmin() { + return isAdmin(this.userId); + } + + public static boolean isAdmin(Long userId) { + return userId != null && 1L == userId; + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsUserOrganization.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsUserOrganization.java new file mode 100644 index 0000000..7ca544f --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsUserOrganization.java @@ -0,0 +1,23 @@ +package com.mathvision.box.dao.domain.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "ums_user_organization") +public class UmsUserOrganization { + private static final long serialVersionUID = 453006522982935793L; + + @TableId(type = IdType.INPUT) + private Long organizationId; + + private Long userId; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsUserRole.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsUserRole.java new file mode 100644 index 0000000..80058c0 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/entity/UmsUserRole.java @@ -0,0 +1,23 @@ +package com.mathvision.box.dao.domain.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "ums_user_role") +public class UmsUserRole { + private static final long serialVersionUID = 767125177028822730L; + + @TableId(type = IdType.INPUT) + private Long userId; + + private Long roleId; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/AlarmStatistics.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/AlarmStatistics.java new file mode 100644 index 0000000..8c0db50 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/AlarmStatistics.java @@ -0,0 +1,18 @@ +package com.mathvision.box.dao.domain.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@ApiModel("报警统计数据") +@Data +public class AlarmStatistics { + @ApiModelProperty(value = "报警类型") + public String type; + + @ApiModelProperty(value = "总数") + public Long totalCount; + + @ApiModelProperty(value = "当日新增") + public Long todayCount; +} \ No newline at end of file diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/BigScreenVo.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/BigScreenVo.java new file mode 100644 index 0000000..98c1a60 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/BigScreenVo.java @@ -0,0 +1,40 @@ +package com.mathvision.box.dao.domain.vo; + +import com.mathvision.box.dao.domain.entity.Defect; +import com.mathvision.box.dao.domain.entity.Device; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + + +@ApiModel("大屏数据") +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class BigScreenVo { + + @ApiModelProperty(value = "大屏展示名称") + public String bigScreenName = "加油站安全管理驾驶舱"; + + @ApiModelProperty(value = "大屏展示标语") + public String bigScreenSlogan = "欢迎领导莅临指导!"; + + @ApiModelProperty(value = "报警统计") + public List alarmStatisticsList; + + @ApiModelProperty(value = "报警数据") + public List defectList; + + @ApiModelProperty(value = "设备数据") + public List deviceList; +// +// @ApiModelProperty(value = "设备分析") +// public Map deviceAnalysisMap; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/DataStorageConfigVo.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/DataStorageConfigVo.java new file mode 100644 index 0000000..f2fb6ef --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/DataStorageConfigVo.java @@ -0,0 +1,41 @@ +package com.mathvision.box.dao.domain.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@ApiModel("数据存储管理数据") +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class DataStorageConfigVo { + + @ApiModelProperty(value = "数据存储路径", example = "数据存储路径(只展示)") + private String path; + + @ApiModelProperty(value = "告警阈值", example = "告警阈值(整数0-100)") + private Integer threshold; + + @ApiModelProperty(value = "内存用量", example = "内存用量") + private Double usage; + + @ApiModelProperty(value = "扩展字段1", example = "扩展字段1") + private String ext1; + + @ApiModelProperty(value = "扩展字段2", example = "扩展字段2") + private String ext2; + + @ApiModelProperty(value = "扩展字段3", example = "扩展字段3") + private String ext3; + + @ApiModelProperty(value = "扩展字段4", example = "扩展字段4") + private String ext4; + + @ApiModelProperty(value = "扩展字段5", example = "扩展字段5") + private String ext5; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/LoginVo.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/LoginVo.java new file mode 100644 index 0000000..cbc5ca5 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/LoginVo.java @@ -0,0 +1,49 @@ +package com.mathvision.box.dao.domain.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +/** + * @Author: fy + * @Date: 2024/04/03 + * @Description: + */ +@ApiModel("登陆成功返回信息") +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class LoginVo { + @ApiModelProperty("用户id") + private Long userId; + + @ApiModelProperty("登录账号") + private String loginName; + + @ApiModelProperty("用户名称") + private String userName; + + @ApiModelProperty("用户头像地址") + private String avatar; + + @ApiModelProperty("手机号") + private String phone; + + @ApiModelProperty("邮箱") + private String email; + + @ApiModelProperty("Token信息") + private String Authorization; + + @ApiModelProperty("角色keySet") + private Set roles; + + @ApiModelProperty("权限标识Set") + private Set permissions; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/UISettingConfigVo.java b/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/UISettingConfigVo.java new file mode 100644 index 0000000..c9da535 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/domain/vo/UISettingConfigVo.java @@ -0,0 +1,43 @@ +package com.mathvision.box.dao.domain.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@ApiModel("界面设置数据") +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class UISettingConfigVo { + + @ApiModelProperty(value = "产品名称", example = "产品名称") + private String name; + + @ApiModelProperty(value = "产品Logo 图片url", example = "产品Logo 图片url") + private String logo; + + @ApiModelProperty(value = "产品favicon 图片url", example = "产品favicon 图片url") + private String favicon; + + @ApiModelProperty(value = "登录背景 图片url", example = "登录背景 图片url") + private String loginBackground; + + @ApiModelProperty(value = "扩展字段1", example = "扩展字段1") + private String ext1; + + @ApiModelProperty(value = "扩展字段2", example = "扩展字段2") + private String ext2; + + @ApiModelProperty(value = "扩展字段3", example = "扩展字段3") + private String ext3; + + @ApiModelProperty(value = "扩展字段4", example = "扩展字段4") + private String ext4; + + @ApiModelProperty(value = "扩展字段5", example = "扩展字段5") + private String ext5; +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/BoxRecordMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/BoxRecordMapper.java new file mode 100644 index 0000000..196cc27 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/BoxRecordMapper.java @@ -0,0 +1,10 @@ +package com.mathvision.box.dao.mapper; +import org.springframework.stereotype.Repository; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.BoxRecord; +import java.util.List; + +@Repository +public interface BoxRecordMapper extends BaseMapper { + List query(BoxRecord boxRecord); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/BoxTraceMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/BoxTraceMapper.java new file mode 100644 index 0000000..4718d73 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/BoxTraceMapper.java @@ -0,0 +1,18 @@ +package com.mathvision.box.dao.mapper; + +import org.springframework.stereotype.Repository; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.BoxTrace; + +import java.util.List; + +/** + * 边缘计算盒子报警追踪表(BoxTrace)表数据库访问层 + * + * @author Fangy + * @date 2025-05-22 15:47:59 + */ +@Repository +public interface BoxTraceMapper extends BaseMapper { + List query(BoxTrace boxTrace); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/DefectMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/DefectMapper.java new file mode 100644 index 0000000..f5e26b2 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/DefectMapper.java @@ -0,0 +1,19 @@ +package com.mathvision.box.dao.mapper; +import com.mathvision.box.dao.domain.dto.DefectQueryDto; +import com.mathvision.box.dao.domain.vo.AlarmStatistics; +import org.springframework.stereotype.Repository; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.Defect; +import java.util.List; + +@Repository +public interface DefectMapper extends BaseMapper { + List query(DefectQueryDto defectDto); + + List queryByPoint(Long pointId); + + /** + * 查询报警统计 + */ + ListqueryAlarmStatisticsByPoint(Long pointId); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/DetectMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/DetectMapper.java new file mode 100644 index 0000000..dbb05f3 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/DetectMapper.java @@ -0,0 +1,15 @@ +package com.mathvision.box.dao.mapper; +import org.springframework.stereotype.Repository; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.Detect; +import java.util.List; + +/** + * 检测过程表(Detect)表数据库访问层 + * @author Fangy + * @date 2025-04-29 15:50:32 + */ +@Repository +public interface DetectMapper extends BaseMapper { + List query(Detect detect); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/DeviceMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/DeviceMapper.java new file mode 100644 index 0000000..2e05b81 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/DeviceMapper.java @@ -0,0 +1,16 @@ +package com.mathvision.box.dao.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.dto.DeviceQueryDto; +import com.mathvision.box.dao.domain.entity.Device; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface DeviceMapper extends BaseMapper { + List query(Device device); + + List selectPages(DeviceQueryDto device); + + List quarryTree(Long pointId); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/PointDeviceMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/PointDeviceMapper.java new file mode 100644 index 0000000..ca1008f --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/PointDeviceMapper.java @@ -0,0 +1,14 @@ +package com.mathvision.box.dao.mapper; +import org.springframework.stereotype.Repository; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.PointDevice; + +/** + * 检测点设备关联表(PointDevice)表数据库访问层 + * @author Fangy + * @date 2025-05-07 15:23:42 + */ +@Repository +public interface PointDeviceMapper extends BaseMapper { + +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/PointMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/PointMapper.java new file mode 100644 index 0000000..614c24a --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/PointMapper.java @@ -0,0 +1,15 @@ +package com.mathvision.box.dao.mapper; +import org.springframework.stereotype.Repository; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.Point; +import java.util.List; + +/** + * 检测点表(Point)表数据库访问层 + * @author Fangy + * @date 2025-04-28 15:20:12 + */ +@Repository +public interface PointMapper extends BaseMapper { + List query(Point point); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/StationMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/StationMapper.java new file mode 100644 index 0000000..3e84eca --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/StationMapper.java @@ -0,0 +1,15 @@ +package com.mathvision.box.dao.mapper; +import org.springframework.stereotype.Repository; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.Station; +import java.util.List; + +/** + * 电站表(Station)表数据库访问层 + * @author Fangy + * @date 2025-04-28 15:20:12 + */ +@Repository +public interface StationMapper extends BaseMapper { + List query(Station station); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/SysConfigMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/SysConfigMapper.java new file mode 100644 index 0000000..dca63a5 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/SysConfigMapper.java @@ -0,0 +1,15 @@ +package com.mathvision.box.dao.mapper; +import org.springframework.stereotype.Repository; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.SysConfig; +import java.util.List; + +/** + * 参数配置表(SysConfig)表数据库访问层 + * @author Fangy + * @date 2025-04-30 10:28:58 + */ +@Repository +public interface SysConfigMapper extends BaseMapper { + List query(SysConfig sysConfig); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/SysFileMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/SysFileMapper.java new file mode 100644 index 0000000..86833f5 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/SysFileMapper.java @@ -0,0 +1,15 @@ +package com.mathvision.box.dao.mapper; +import org.springframework.stereotype.Repository; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.SysFile; +import java.util.List; + +/** + * 系统日志信息表(SysFile)表数据库访问层 + * @author Fangy + * @date 2025-05-07 12:39:51 + */ +@Repository +public interface SysFileMapper extends BaseMapper { + List query(SysFile sysFile); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/SysLogMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/SysLogMapper.java new file mode 100644 index 0000000..a16c65f --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/SysLogMapper.java @@ -0,0 +1,17 @@ +package com.mathvision.box.dao.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.SysLog; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 系统日志信息表(SysLog)表数据库访问层 + * @author Fangy + * @date 2024-09-24 15:57:56 + */ +@Repository +public interface SysLogMapper extends BaseMapper { + List query(SysLog sysLog); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsMenuMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsMenuMapper.java new file mode 100644 index 0000000..253d05f --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsMenuMapper.java @@ -0,0 +1,25 @@ +package com.mathvision.box.dao.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.UmsMenu; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 菜单表(UmsMenu)表数据库访问层 + * @author Fangy + * @date 2024-04-02 14:08:06 + */ +@Repository +public interface UmsMenuMapper extends BaseMapper { + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + public List selectPermsByUserId(Long userId); + + public List selectPermsByRoleId(Long roleId); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsOrganizationMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsOrganizationMapper.java new file mode 100644 index 0000000..4623e47 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsOrganizationMapper.java @@ -0,0 +1,15 @@ +package com.mathvision.box.dao.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.UmsOrganization; +import org.springframework.stereotype.Repository; + +/** + * 组织信息表(UmsOrganization)表数据库访问层 + * @author Fangy + * @date 2024-04-03 09:47:07 + */ +@Repository +public interface UmsOrganizationMapper extends BaseMapper { + UmsOrganization getByUid(Long userId); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsRoleMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsRoleMapper.java new file mode 100644 index 0000000..b0e0c52 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsRoleMapper.java @@ -0,0 +1,23 @@ +package com.mathvision.box.dao.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.UmsRole; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 角色表(UmsRole)表数据库访问层 + * @author Fangy + * @date 2024-04-02 14:08:04 + */ +@Repository +public interface UmsRoleMapper extends BaseMapper { + /** + * 根据用户ID查询角色 + * + * @param userId 用户ID + * @return 角色列表 + */ + public List selectRolesByUserId(Long userId); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsRoleMenuMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsRoleMenuMapper.java new file mode 100644 index 0000000..d4c0acb --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsRoleMenuMapper.java @@ -0,0 +1,17 @@ +package com.mathvision.box.dao.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.UmsRoleMenu; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 角色权限关联表(UmsRoleMenu)表数据库访问层 + * @author Fangy + * @date 2024-04-12 20:42:25 + */ +@Repository +public interface UmsRoleMenuMapper extends BaseMapper { + List query(UmsRoleMenu umsRoleMenu); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsUserMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsUserMapper.java new file mode 100644 index 0000000..a73bc74 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsUserMapper.java @@ -0,0 +1,20 @@ +package com.mathvision.box.dao.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.dto.UmsUserQueryDto; +import com.mathvision.box.dao.domain.entity.UmsUser; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 用户表(UmsUser)表数据库访问层 + * @author Fangy + * @date 2024-04-02 14:08:03 + */ +@Repository +public interface UmsUserMapper extends BaseMapper { + List query(UmsUserQueryDto umsUserQueryDto); + + List listByIds(List idList); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsUserOrganizationMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsUserOrganizationMapper.java new file mode 100644 index 0000000..e1cf166 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsUserOrganizationMapper.java @@ -0,0 +1,15 @@ +package com.mathvision.box.dao.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.UmsUserOrganization; +import org.springframework.stereotype.Repository; + +/** + * 组织信息关联表(UmsUserOrganization)表数据库访问层 + * @author Fangy + * @date 2024-04-03 14:51:06 + */ +@Repository +public interface UmsUserOrganizationMapper extends BaseMapper { + +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsUserRoleMapper.java b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsUserRoleMapper.java new file mode 100644 index 0000000..3973720 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/mapper/UmsUserRoleMapper.java @@ -0,0 +1,15 @@ +package com.mathvision.box.dao.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mathvision.box.dao.domain.entity.UmsUserRole; +import org.springframework.stereotype.Repository; + +/** + * 用户角色关联表(UmsUserRole)表数据库访问层 + * @author Fangy + * @date 2024-04-03 15:08:07 + */ +@Repository +public interface UmsUserRoleMapper extends BaseMapper { + +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/BoxRecordService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/BoxRecordService.java new file mode 100644 index 0000000..d859f8c --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/BoxRecordService.java @@ -0,0 +1,8 @@ +package com.mathvision.box.dao.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.entity.BoxRecord; +import java.util.List; + +public interface BoxRecordService extends IService { + List query(BoxRecord boxRecord); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/BoxTraceService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/BoxTraceService.java new file mode 100644 index 0000000..ff09af8 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/BoxTraceService.java @@ -0,0 +1,13 @@ +package com.mathvision.box.dao.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.entity.BoxTrace; +import java.util.List; + +/** + * 边缘计算盒子报警追踪表(BoxTrace)表服务接口 + * @author Fangy + * @date 2025-05-22 15:48:00 + */ +public interface BoxTraceService extends IService { + List query(BoxTrace boxTrace); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/DefectService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/DefectService.java new file mode 100644 index 0000000..067a473 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/DefectService.java @@ -0,0 +1,26 @@ +package com.mathvision.box.dao.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.entity.Defect; +import com.mathvision.box.dao.domain.dto.DefectQueryDto; +import com.mathvision.box.dao.domain.vo.AlarmStatistics; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +public interface DefectService extends IService { + List query(DefectQueryDto defectDto); + + List queryByPoint(Long pointId); + /** + * 查询报警统计 + */ + ListqueryAlarmStatisticsByPoint(Long pointId); + + @Transactional + boolean saveOrUpdateBatchByProcess(List defectList); + + /** + * 油管卸油完成 + */ + void checkOilUnloadingComplete(String processId); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/DetectService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/DetectService.java new file mode 100644 index 0000000..31a7963 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/DetectService.java @@ -0,0 +1,16 @@ +package com.mathvision.box.dao.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.entity.Detect; +import com.mathvision.box.dao.domain.dto.DetectDto; + +import java.util.List; +import java.util.Map; + +public interface DetectService extends IService { + List query(DetectDto detectDto); + + /** + * 修正过程数据 + */ + Map> fixDetect(List detectList, boolean isProcess); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/DeviceService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/DeviceService.java new file mode 100644 index 0000000..415a338 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/DeviceService.java @@ -0,0 +1,13 @@ +package com.mathvision.box.dao.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.dto.DeviceQueryDto; +import com.mathvision.box.dao.domain.entity.Device; + +import java.util.List; + +public interface DeviceService extends IService { + List selectPages(DeviceQueryDto deviceDto); + + List quarryTree(Long pointId); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/PointService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/PointService.java new file mode 100644 index 0000000..301a478 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/PointService.java @@ -0,0 +1,21 @@ +package com.mathvision.box.dao.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.dto.PointAddDeviceDto; +import com.mathvision.box.dao.domain.dto.PointAddDto; +import com.mathvision.box.dao.domain.entity.Point; +import com.mathvision.box.dao.domain.dto.PointQueryDto; +import java.util.List; + +public interface PointService extends IService { + List query(PointQueryDto pointDto); + + boolean add(PointAddDto pointDto); + + boolean update(PointAddDto pointDto); + + boolean delete(List idList); + + boolean addDevice(PointAddDeviceDto dto); + + boolean deleteDevice(PointAddDeviceDto dto); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/StationService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/StationService.java new file mode 100644 index 0000000..39e347d --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/StationService.java @@ -0,0 +1,19 @@ +package com.mathvision.box.dao.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.entity.Station; +import com.mathvision.box.dao.domain.dto.StationQueryDto; +import java.util.List; + +public interface StationService extends IService { + List query(StationQueryDto stationDto); + + /** + * 校验站名称是否唯一 + */ + boolean checkStationNameUnique(Long id, String stationName); + + /** + * 校验点位编号是否唯一 + */ + boolean checkStationIdUnique(Long id, String stationId); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/SysConfigService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/SysConfigService.java new file mode 100644 index 0000000..7ebca7c --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/SysConfigService.java @@ -0,0 +1,13 @@ +package com.mathvision.box.dao.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.entity.SysConfig; +import com.mathvision.box.dao.domain.dto.SysConfigDto; +import java.util.List; + +public interface SysConfigService extends IService { + List query(SysConfigDto sysConfigDto); + + SysConfig queryUISettingConfig(); + + SysConfig queryDataStorageConfig(); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/SysFileService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/SysFileService.java new file mode 100644 index 0000000..2a4841b --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/SysFileService.java @@ -0,0 +1,14 @@ +package com.mathvision.box.dao.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.entity.SysFile; +import com.mathvision.box.dao.domain.dto.SysFileQueryDto; +import java.util.List; + +public interface SysFileService extends IService { + List query(SysFileQueryDto sysFileDto); + + /** + * 校验名称是否唯一 + */ + boolean checkNameUnique(Long id, String name); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/SysLogService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/SysLogService.java new file mode 100644 index 0000000..33a3a4a --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/SysLogService.java @@ -0,0 +1,14 @@ +package com.mathvision.box.dao.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.dto.SysLogDto; +import com.mathvision.box.dao.domain.entity.SysLog; + +import java.util.List; + +public interface SysLogService extends IService { + /** + * 日志查询 + */ + List query(SysLogDto sysLogDto); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/UmsMenuService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/UmsMenuService.java new file mode 100644 index 0000000..bbcc569 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/UmsMenuService.java @@ -0,0 +1,27 @@ +package com.mathvision.box.dao.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.dto.UmsMenuDto; +import com.mathvision.box.dao.domain.entity.UmsMenu; + +import java.util.List; +import java.util.Set; + +/** + * 菜单表(UmsMenu)表服务接口 + * @author Fangy + * @date 2024-03-25 15:50:12 + */ + +public interface UmsMenuService extends IService { + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + Set selectPermsByUserId(Long userId); + + List query(UmsMenuDto umsMenuDto); + + List selectPermsByRoleId(Long roleId); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/UmsOrganizationService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/UmsOrganizationService.java new file mode 100644 index 0000000..a641696 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/UmsOrganizationService.java @@ -0,0 +1,37 @@ +package com.mathvision.box.dao.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.common.utils.tree.TreeNode; +import com.mathvision.box.dao.domain.dto.UmsOrganizationDto; +import com.mathvision.box.dao.domain.entity.UmsOrganization; + +import java.util.List; + +/** + * 组织信息表(UmsOrganization)表服务接口 + * @author Fangy + * @date 2024-04-03 09:47:08 + */ + +public interface UmsOrganizationService extends IService { + + List> quarryTree(); + + UmsOrganization getByUid(Long userId); + + boolean add(UmsOrganizationDto umsOrganizationDto); + + boolean update(UmsOrganizationDto umsOrganizationDto); + + boolean delete(List idList); + + boolean save(Long userId, Long organizationId); + + boolean deleteByUserId(Long userId); + + boolean deleteByUserId(List userIds); + + /** + * 校验名称是否唯一 + */ + boolean checkNameUnique(Long id, String name); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/UmsRoleMenuService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/UmsRoleMenuService.java new file mode 100644 index 0000000..45298ea --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/UmsRoleMenuService.java @@ -0,0 +1,12 @@ +package com.mathvision.box.dao.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.entity.UmsRoleMenu; + +/** + * 角色权限关联表(UmsRoleMenu)表服务接口 + * @author Fangy + * @date 2024-04-12 20:46:30 + */ + +public interface UmsRoleMenuService extends IService { +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/UmsRoleService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/UmsRoleService.java new file mode 100644 index 0000000..2eb2644 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/UmsRoleService.java @@ -0,0 +1,45 @@ +package com.mathvision.box.dao.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.dao.domain.dto.UmsRoleDto; +import com.mathvision.box.dao.domain.entity.UmsRole; + +import java.util.List; +import java.util.Set; + +/** + * 角色表(UmsRole)表服务接口 + * + * @author Fangy + * @date 2024-03-25 15:50:12 + */ + +public interface UmsRoleService extends IService { + /** + * 根据用户ID查询角色列表 + * + * @param userId 用户ID + * @return 权限列表 + */ + Set selectRoleKeys(Long userId); + + List query(UmsRoleDto umsRoleDto); + + boolean bindMenu(Long roleId, List menuIds); + + boolean save(Long userId, Long roleId); + + boolean deleteByUserId(Long userId); + + boolean deleteByUserId(List userIds); + + /** + * 校验名称是否唯一 + */ + boolean checkNameUnique(Long id, String name); + + /** + * 校验编号是否唯一 + */ + boolean checkCodeUnique(Long id, String code); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/UmsUserService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/UmsUserService.java new file mode 100644 index 0000000..62c1a17 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/UmsUserService.java @@ -0,0 +1,63 @@ +package com.mathvision.box.dao.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.mathvision.box.common.core.page.PageDomain; +import com.mathvision.box.dao.domain.dto.UmsUserAddDto; +import com.mathvision.box.dao.domain.dto.UmsUserQueryDto; +import com.mathvision.box.dao.domain.entity.UmsUser; + +import java.util.List; + +/** + * 用户表(UmsUser)表服务接口 + * @author Fangy + * @date 2024-03-22 17:31:34 + */ + +public interface UmsUserService extends IService { + + /** + * 新增用户 + */ + boolean add(UmsUserAddDto umsUserDto); + + /** + * 修改用户 + */ + boolean update(UmsUserAddDto umsUserDto); + + /** + * 删除用户 + */ + boolean delete(List idList); + + /** + * 查询数据 + */ + List list(UmsUserQueryDto umsUserDto); + + /** + * 根据id查询 + */ + UmsUser getById(Long id); + + /** + * 根据id集合查询 + */ + List listByIds(List idList); + + /** + * 校验用户登录账号是否唯一 + */ + boolean checkLoginNameUnique(Long userId, String loginName); + + /** + * 校验手机号码是否唯一 + */ + boolean checkPhoneUnique(Long userId, String phone); + + /** + * 校验email是否唯一 + */ + boolean checkEmailUnique(Long userId, String email); +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/BoxClearFileService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/BoxClearFileService.java new file mode 100644 index 0000000..a3b7fac --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/BoxClearFileService.java @@ -0,0 +1,62 @@ +package com.mathvision.box.dao.service.impl; + +import com.mathvision.box.common.config.AppConfig; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.nio.file.*; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.stream.Stream; + +@Service +@Slf4j +public class BoxClearFileService { + @Scheduled(cron = "0 0 2,3 * * ?") + void clean() throws Exception { + + Files.walkFileTree(Paths.get(AppConfig.getProfile(), "alarm"), new FileVisitor() { + + @Override + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { + log.info("[BoxClearFileService] preVisitDirectory dir:" + dir.toString()); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + if (attrs.lastModifiedTime().toMillis() + AppConfig.getDataCleanupRetentionDays() * 24 * 60 * 60 * 1000 < System.currentTimeMillis()) { + if (Files.deleteIfExists(file)) { + log.info("[BoxClearFileService] delete file:" + file); + } else { + log.error("[BoxClearFileService] delete failed, file:" + file); + } + } + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFileFailed(Path file, IOException exc) { + log.error("[BoxClearFileService] visitFileFailed failed:" + file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) { + try (Stream pathStream = Files.list(dir)) { + if (!pathStream.findAny().isPresent()) { + if (Files.deleteIfExists(dir)) { + log.info("[BoxClearFileService] postVisitDirectory dir:" + dir); + } else { + log.error("[BoxClearFileService] postVisitDirectory failed, dir:" + dir); + } + } + } catch (IOException e) { + log.error("[BoxClearFileService] postVisitDirectory exception:" + e.getMessage(), e); + } + return FileVisitResult.CONTINUE; + } + }); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/BoxRecordServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/BoxRecordServiceImpl.java new file mode 100644 index 0000000..97029c5 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/BoxRecordServiceImpl.java @@ -0,0 +1,45 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.csv.CsvUtils; +import com.mathvision.box.dao.mapper.BoxRecordMapper; +import com.mathvision.box.dao.domain.entity.BoxRecord; +import com.mathvision.box.dao.service.BoxRecordService; + +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; + +@Service +public class BoxRecordServiceImpl extends ServiceImpl implements BoxRecordService { + + private static final Logger logger = LoggerFactory.getLogger(BoxRecordServiceImpl.class); + + @Autowired + private BoxRecordMapper boxRecordMapper; + + @Override + public List query(BoxRecord boxRecord) { + return boxRecordMapper.query(boxRecord); + } + + @Scheduled(cron = "0 0 1 * * ?") + void clean() { + Date before = DateUtils.addDays(DateUtils.getNowDate(), -AppConfig.getDataCleanupRetentionDays()); + List oldData = boxRecordMapper.selectList(new QueryWrapper().lt("create_time", before)); + if (oldData == null || oldData.isEmpty()) { + return; + } + boxRecordMapper.deleteBatchIds(oldData.stream().map(BoxRecord::getRecordId).collect(Collectors.toList())); + CsvUtils.exportToCsvWithAnnotation(oldData, AppConfig.getCsvPath() + "/" + DateUtils.datePath() + "/BoxRecord.csv"); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/BoxTraceServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/BoxTraceServiceImpl.java new file mode 100644 index 0000000..3a8894b --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/BoxTraceServiceImpl.java @@ -0,0 +1,51 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.csv.CsvUtils; +import com.mathvision.box.dao.domain.entity.BoxRecord; +import com.mathvision.box.dao.mapper.BoxTraceMapper; +import com.mathvision.box.dao.domain.entity.BoxTrace; +import com.mathvision.box.dao.service.BoxTraceService; + +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * 边缘计算盒子报警追踪表(BoxTrace)表服务实现类 + */ +@Service +public class BoxTraceServiceImpl extends ServiceImpl implements BoxTraceService { + /** + * logger:日志文件 + */ + private static final Logger logger = LoggerFactory.getLogger(BoxTraceServiceImpl.class); + + @Autowired + private BoxTraceMapper boxTraceMapper; + + @Override + public List query(BoxTrace boxTrace) { + return boxTraceMapper.query(boxTrace); + } + + @Scheduled(cron = "0 0 1 * * ?") + void clean() { + Date before = DateUtils.addDays(DateUtils.getNowDate(), -AppConfig.getDataCleanupRetentionDays()); + List oldData = boxTraceMapper.selectList(new QueryWrapper().lt("create_time", before)); + if (oldData == null || oldData.isEmpty()) { + return; + } + boxTraceMapper.deleteBatchIds(oldData.stream().map(BoxTrace::getId).collect(Collectors.toList())); + CsvUtils.exportToCsvWithAnnotation(oldData, AppConfig.getCsvPath() + "/" + DateUtils.datePath() + "/BoxTrace.csv"); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/CacheService.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/CacheService.java new file mode 100644 index 0000000..360bf1a --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/CacheService.java @@ -0,0 +1,78 @@ +package com.mathvision.box.dao.service.impl; + +import com.mathvision.box.common.utils.common.CacheUtils; +import com.mathvision.box.dao.domain.entity.Point; +import com.mathvision.box.dao.domain.entity.UmsOrganization; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class CacheService { + //用户名 + public static final String USER_NAME_CACHE = "user_name"; + //组织名 + public static final String ORGANIZATION_CACHE = "organization"; + //检测点 + public static final String POINT_CACHE = "point"; + + public static Map> getAll() { + Map> map = new HashMap<>(); + map.put(USER_NAME_CACHE, CacheUtils.getCache(USER_NAME_CACHE)); + map.put(ORGANIZATION_CACHE, CacheUtils.getCache(ORGANIZATION_CACHE)); + map.put(POINT_CACHE, CacheUtils.getCache(POINT_CACHE)); + return map; + } + + public static void putUserName(Long userId, String userName) { + CacheUtils.put(USER_NAME_CACHE, userId.toString(), userName); + } + + public static void removeUserName(List idList) { + CacheUtils.removeByKeys(USER_NAME_CACHE, idList.stream().map(e -> e.toString()).collect(Collectors.toSet())); + } + + public static String getUserName(Long userId) { + return CacheUtils.get(USER_NAME_CACHE, userId.toString(), "").toString(); + } + + public static List getUserName(List idList) { + return idList.stream().map(id -> getUserName(id)).collect(Collectors.toList()); + } + + public static void putOrganization(Long id, UmsOrganization e) { + CacheUtils.put(ORGANIZATION_CACHE, id.toString(), e); + } + + public static void removeOrganization(List idList) { + CacheUtils.removeByKeys(ORGANIZATION_CACHE, idList.stream().map(e -> e.toString()).collect(Collectors.toSet())); + } + + public static List getOrganization(Long... ids) { + if (ids == null || ids.length == 0){ + return CacheUtils.getCache(ORGANIZATION_CACHE).values().stream().map(e -> (UmsOrganization) e).collect(Collectors.toList()); + }else { + List idList = Arrays.stream(ids).collect(Collectors.toList()); + return idList.stream().map(id -> (UmsOrganization) CacheUtils.get(ORGANIZATION_CACHE, id.toString(), new UmsOrganization())).collect(Collectors.toList()); + } + } + + public static void putPoint(Long id, Point e) { + CacheUtils.put(POINT_CACHE, id.toString(), e); + } + + public static void removePoint(List idList) { + CacheUtils.removeByKeys(POINT_CACHE, idList.stream().map(e -> e.toString()).collect(Collectors.toSet())); + } + + public static List getPoint(Long... ids) { + List idList = Arrays.stream(ids).collect(Collectors.toList()); + if (idList == null || idList.size() == 0) { + return CacheUtils.getCache(POINT_CACHE).values().stream().map(e -> (Point) e).collect(Collectors.toList()); + } else { + return idList.stream().map(id -> (Point) CacheUtils.get(POINT_CACHE, id.toString(), new UmsOrganization())).collect(Collectors.toList()); + } + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/DefectServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/DefectServiceImpl.java new file mode 100644 index 0000000..f54f9bd --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/DefectServiceImpl.java @@ -0,0 +1,125 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.enums.DefectStatusEnum; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.csv.CsvUtils; +import com.mathvision.box.dao.domain.entity.Detect; +import com.mathvision.box.dao.domain.vo.AlarmStatistics; +import com.mathvision.box.dao.mapper.DefectMapper; +import com.mathvision.box.dao.domain.entity.Defect; +import com.mathvision.box.dao.mapper.DetectMapper; +import com.mathvision.box.dao.service.DefectService; +import com.mathvision.box.dao.domain.dto.DefectQueryDto; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; + +@Service +public class DefectServiceImpl extends ServiceImpl implements DefectService { + + private static final Logger logger = LoggerFactory.getLogger(DefectServiceImpl.class); + + @Autowired + private DefectMapper defectMapper; + + @Autowired + private DetectMapper detectMapper; + + @Override + public List query(DefectQueryDto defectDto) { + return defectMapper.query(defectDto); + } + + @Override + public List queryByPoint(Long pointId) { + return defectMapper.queryByPoint(pointId); + } + + @Override + public List queryAlarmStatisticsByPoint(Long pointId) { + return defectMapper.queryAlarmStatisticsByPoint(pointId); + } + + @Override + @Transactional + public boolean saveOrUpdateBatchByProcess(List defectList) { + if (CollectionUtils.isEmpty(defectList)) { + return true; + } + Set processIds = defectList.stream().map(Defect::getProcessId).filter(StringUtils::isNotBlank).collect(Collectors.toSet()); + Map existingDefects = processIds.isEmpty() ? Collections.emptyMap() : defectMapper.selectList(new QueryWrapper().in("process_id", processIds)).stream().collect(Collectors.toMap(Defect::getProcessId, Function.identity())); + List toInsert = new ArrayList<>(); + List toUpdate = new ArrayList<>(); + + defectList.forEach(item -> { + if (StringUtils.isBlank(item.getProcessId())) { + toInsert.add(item); + } else { + Defect existing = existingDefects.get(item.getProcessId()); + if (existing == null) { + toInsert.add(item); + } else { + if (StringUtils.isNotBlank(item.getImg())) { + existing.setImg(item.getImg()); + } + if (StringUtils.isNotBlank(item.getData())) { + existing.setData(item.getData()); + } + toUpdate.add(existing); + } + } + }); + + if (!toInsert.isEmpty()) { + saveBatch(toInsert); + } + if (!toUpdate.isEmpty()) { + updateBatchById(toUpdate); + } + + return true; + } + + + @Override + public void checkOilUnloadingComplete(String processId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("process_id", processId); + Defect defect = defectMapper.selectOne(queryWrapper); + if (defect != null && defect.getEndTime() == null) { + Detect carLocation = detectMapper.selectOne(new QueryWrapper().eq("detect_id", processId + "_car_location_info")); + Detect carLeave = detectMapper.selectOne(new QueryWrapper().eq("detect_id", processId + "_car_leave_info")); + Assert.notNull(carLocation, "未找到卸油作业步骤: " + processId + "_car_location_info"); + Assert.notNull(carLeave, "未找到卸油作业步骤: " + processId + "_car_leave_info"); + defect.setTime(carLocation.getTime()); + defect.setEndTime(carLeave.getTime()); + defect.setStatus(DefectStatusEnum.unprocessed.getCode()); + defectMapper.updateById(defect); + } + } + + @Scheduled(cron = "0 0 1 * * ?") + void clean() { + Date before = DateUtils.addDays(DateUtils.getNowDate(), -AppConfig.getDataCleanupRetentionDays()); + List oldData = defectMapper.selectList(new QueryWrapper().lt("time", before)); + if (oldData == null || oldData.isEmpty()) { + return; + } + defectMapper.deleteBatchIds(oldData.stream().map(Defect::getId).collect(Collectors.toList())); + CsvUtils.exportToCsvWithAnnotation(oldData, AppConfig.getCsvPath() + "/" + DateUtils.datePath() + "/Defect.csv"); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/DetectServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/DetectServiceImpl.java new file mode 100644 index 0000000..5951dac --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/DetectServiceImpl.java @@ -0,0 +1,156 @@ +package com.mathvision.box.dao.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.enums.DetectStatusEnum; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.csv.CsvUtils; +import com.mathvision.box.dao.domain.entity.BoxTrace; +import com.mathvision.box.dao.mapper.BoxTraceMapper; +import com.mathvision.box.dao.mapper.DetectMapper; +import com.mathvision.box.dao.domain.entity.Detect; +import com.mathvision.box.dao.service.BoxTraceService; +import com.mathvision.box.dao.service.DetectService; +import com.mathvision.box.dao.domain.dto.DetectDto; + +import java.util.*; +import java.util.stream.Collectors; + +import org.apache.commons.compress.utils.Lists; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +@Service +public class DetectServiceImpl extends ServiceImpl implements DetectService { + /** + * logger:日志文件 + */ + private static final Logger logger = LoggerFactory.getLogger(DetectServiceImpl.class); + + @Autowired + private DetectMapper detectMapper; + + @Autowired + private BoxTraceService boxTraceService; + + @Override + public List query(DetectDto detectDto) { + Detect detect = new Detect(); + BeanUtils.copyProperties(detectDto, detect); + return detectMapper.query(detect); + } + + @Override + @Transactional + public Map> fixDetect(List detectList, boolean isProcess) { + + if (CollectionUtils.isEmpty(detectList)) { + return new HashMap<>(); + } + Map> groupedDetects = detectList.stream().filter(Objects::nonNull).peek(this::processImageUrls).collect(Collectors.groupingBy(item -> StringUtils.isBlank(item.getProcessId()) ? "BLANK" : item.getProcessId())); + // 处理常规报警的记录(直接插入) + this.saveBatch(groupedDetects.getOrDefault("BLANK", Collections.emptyList())); + // 处理过程报警 + List processIds = groupedDetects.keySet().stream().filter(key -> !"BLANK".equals(key)).collect(Collectors.toList()); + if (!processIds.isEmpty()) { + batchProcessWithProcessId(groupedDetects, processIds, isProcess); + } + return groupedDetects; + } + + + private void processImageUrls(Detect detect) { + Optional.ofNullable(detect.getImg()) + .filter(StringUtils::isNotBlank) + .map(JSONArray::parseArray) + .ifPresent(imgJson -> { + imgJson.forEach(imgObj -> { + JSONObject imgItem = (JSONObject) imgObj; + Optional.ofNullable(imgItem.getString("url")) + .ifPresent(url -> imgItem.put("url", + StringUtils.replace(url, AppConfig.getProfile(), "/file"))); + }); + detect.setImg(imgJson.toJSONString()); + }); + } + + private void batchProcessWithProcessId(Map> groupedDetects, List processIds, boolean isProcess) { + List dbDetects = detectMapper.selectList(new QueryWrapper().in("process_id", processIds)); + Map> dbDetectsMap = dbDetects.stream().filter(d -> d.getType() != null && d.getStatus() != null).collect(Collectors.groupingBy(Detect::getType, Collectors.toMap(Detect::getStatus, d -> d, (oldOne, newOne) -> oldOne))); + + List toInsert = Lists.newArrayList(); + List toUpdate = Lists.newArrayList(); + List traces = Lists.newArrayList(); + + groupedDetects.forEach((processId, boxDetects) -> { + if ("BLANK".equals(processId) || CollectionUtils.isEmpty(boxDetects)) return; + boxDetects.removeIf(detect -> detect == null || detect.getType() == null); + boxDetects.forEach(detect -> { + Map statusMap = dbDetectsMap.getOrDefault(detect.getType(), Collections.emptyMap()); + if (isProcess && detect.getStatus().equals(DetectStatusEnum.alert.getCode())) { + Detect fixDetect = statusMap.get(DetectStatusEnum.fix.getCode()); + Detect infoDetect = statusMap.get(DetectStatusEnum.info.getCode()); + if (fixDetect != null) { + boxDetects.set(boxDetects.indexOf(detect), fixDetect); + } else if (infoDetect != null) { + boxDetects.set(boxDetects.indexOf(detect), infoDetect); + } else { + toInsert.add(detect); + traces.add(BoxTrace.builder() + .deviceId(detect.getIp()) + .alarmCode(detect.getDetectId()) + .alarmLevel(detect.getStatus()) + .alarmContent(JSONObject.toJSONString(detect)) + .traceInfo(detect.getType()) + .build()); + } + } else { + Detect existing = statusMap.get(detect.getStatus()); + if (existing == null) { + toInsert.add(detect); + traces.add(BoxTrace.builder() + .deviceId(detect.getIp()) + .alarmCode(detect.getDetectId()) + .alarmLevel(detect.getStatus()) + .alarmContent(JSONObject.toJSONString(detect)) + .traceInfo(detect.getType()) + .build()); + } else { + toUpdate.add(detect); + } + } + }); + }); + if (!toInsert.isEmpty()) { + this.saveBatch(toInsert); + } + if (!toUpdate.isEmpty()) { + this.updateBatchById(toUpdate); + } + if (!traces.isEmpty()) { + boxTraceService.saveBatch(traces); + } + } + + @Scheduled(cron = "0 0 1 * * ?") + void clean() { + Date before = DateUtils.addDays(DateUtils.getNowDate(), -AppConfig.getDataCleanupRetentionDays()); + List oldData = detectMapper.selectList(new QueryWrapper().lt("time", before)); + if (oldData == null || oldData.isEmpty()) { + return; + } + detectMapper.deleteBatchIds(oldData.stream().map(Detect::getId).collect(Collectors.toList())); + CsvUtils.exportToCsvWithAnnotation(oldData, AppConfig.getCsvPath() + "/" + DateUtils.datePath() + "/Detect.csv"); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/DeviceServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/DeviceServiceImpl.java new file mode 100644 index 0000000..af5169c --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/DeviceServiceImpl.java @@ -0,0 +1,37 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.core.page.PageDomain; +import com.mathvision.box.common.core.page.TableSupport; +import com.mathvision.box.common.utils.sql.SqlUtil; +import com.mathvision.box.dao.domain.dto.DeviceQueryDto; +import com.mathvision.box.dao.domain.entity.Device; +import com.mathvision.box.dao.mapper.DeviceMapper; +import com.mathvision.box.dao.service.DeviceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +@Service +public class DeviceServiceImpl extends ServiceImpl implements DeviceService { + /** + * logger:日志文件 + */ + private static final Logger logger = LoggerFactory.getLogger(DeviceServiceImpl.class); + + @Autowired + private DeviceMapper deviceMapper; + + @Override + public List selectPages(DeviceQueryDto deviceDto) { + return deviceMapper.selectPages(deviceDto); + } + + @Override + public List quarryTree(Long pointId) { + return deviceMapper.quarryTree(pointId); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/PointServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/PointServiceImpl.java new file mode 100644 index 0000000..39cdbc1 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/PointServiceImpl.java @@ -0,0 +1,116 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.dao.domain.dto.PointAddDeviceDto; +import com.mathvision.box.dao.domain.dto.PointAddDto; +import com.mathvision.box.dao.domain.entity.PointDevice; +import com.mathvision.box.dao.mapper.PointDeviceMapper; +import com.mathvision.box.dao.mapper.PointMapper; +import com.mathvision.box.dao.domain.entity.Point; +import com.mathvision.box.dao.service.PointService; +import com.mathvision.box.dao.domain.dto.PointQueryDto; +import com.mathvision.box.common.utils.bean.BeanUtils; + +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.Assert; + +import javax.annotation.PostConstruct; + +@Service +public class PointServiceImpl extends ServiceImpl implements PointService { + /** + * logger:日志文件 + */ + private static final Logger logger = LoggerFactory.getLogger(PointServiceImpl.class); + + @Autowired + private PointMapper pointMapper; + + @Autowired + private PointDeviceMapper pointDeviceMapper; + + @PostConstruct + @Scheduled(cron = "0 0 0/1 * * *") + public void init() { + pointMapper.selectList(new QueryWrapper<>()).forEach(e -> { + CacheService.putPoint(e.getId(), e); + }); + } + + @Override + public List query(PointQueryDto pointDto) { + Point point = new Point(); + BeanUtils.copyProperties(pointDto, point); + return pointMapper.query(point); + } + + @Override + public boolean add(PointAddDto pointDto) { + Assert.isTrue(checkPointNameUnique(null, pointDto.getStationId(), pointDto.getPointName()), "名称已存在"); + Assert.isTrue(checkPointIdUnique(null, pointDto.getStationId(), pointDto.getPointId()), "编号已存在"); + Point point = new Point(); + BeanUtils.copyProperties(pointDto, point); + if (pointMapper.insert(point) > 0) { + CacheService.putPoint(point.getId(), point); + return true; + } + return false; + } + + @Override + public boolean update(PointAddDto pointDto) { + Assert.isTrue(checkPointNameUnique(pointDto.getId(), pointDto.getStationId(), pointDto.getPointName()), "名称已存在"); + Assert.isTrue(checkPointIdUnique(pointDto.getId(), pointDto.getStationId(), pointDto.getPointId()), "编号已存在"); + Point point = pointMapper.selectById(pointDto.getId()); + Assert.notNull(point, "数据不存在"); + BeanUtils.copyProperties(pointDto, point); + if (pointMapper.updateById(point) > 0) { + CacheService.putPoint(point.getId(), point); + return true; + } + return false; + } + + @Override + public boolean delete(List idList) { + if (pointMapper.deleteBatchIds(idList) > 0) { + CacheService.removePoint(idList); + return true; + } + return false; + } + + @Override + public boolean addDevice(PointAddDeviceDto dto) { + PointDevice pd = PointDevice.builder().pointId(dto.getPointId()).deviceId(dto.getDeviceId()).build(); + return pointDeviceMapper.insert(pd) > 0; + } + + @Override + public boolean deleteDevice(PointAddDeviceDto dto) { + return pointDeviceMapper.delete(new QueryWrapper().eq("point_id", dto.getPointId()).eq("device_id", dto.getDeviceId())) > 0; + } + + /** + * 校验点位名称是否唯一 + */ + public boolean checkPointNameUnique(Long id, Long stationId, String pointName) { + List list = pointMapper.selectList(new QueryWrapper().eq("station_id", stationId).eq("point_name", pointName)); + return list.isEmpty() || (id != null && list.size() == 1 && list.get(0).getStationId().equals(stationId) && list.get(0).getPointName().equals(pointName)); + } + + /** + * 校验点位编号是否唯一 + */ + public boolean checkPointIdUnique(Long id, Long stationId, String pointId) { + List list = pointMapper.selectList(new QueryWrapper().eq("station_id", stationId).eq("point_id", pointId)); + return list.isEmpty() || (id != null && list.size() == 1 && list.get(0).getStationId().equals(stationId) && list.get(0).getPointId().equals(pointId)); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/StationServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/StationServiceImpl.java new file mode 100644 index 0000000..a05b7f8 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/StationServiceImpl.java @@ -0,0 +1,44 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.dao.mapper.StationMapper; +import com.mathvision.box.dao.domain.entity.Station; +import com.mathvision.box.dao.service.StationService; +import com.mathvision.box.dao.domain.dto.StationQueryDto; +import com.mathvision.box.common.utils.bean.BeanUtils; + +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; + +@Service +public class StationServiceImpl extends ServiceImpl implements StationService { + /** + * logger:日志文件 + */ + private static final Logger logger = LoggerFactory.getLogger(StationServiceImpl.class); + + @Autowired + private StationMapper stationMapper; + + @Override + public List query(StationQueryDto stationDto) { + Station station = new Station(); + BeanUtils.copyProperties(stationDto, station); + return stationMapper.query(station); + } + + public boolean checkStationNameUnique(Long id, String stationName) { + List list = stationMapper.selectList(new QueryWrapper().eq("station_name", stationName)); + return list.isEmpty() || (id != null && list.size() == 1 && list.get(0).getId().equals(id) && list.get(0).getStationName().equals(stationName)); + } + + public boolean checkStationIdUnique(Long id, String stationId) { + List list = stationMapper.selectList(new QueryWrapper().eq("station_id", stationId)); + return list.isEmpty() || (id != null && list.size() == 1 && list.get(0).getId().equals(id) && list.get(0).getStationId().equals(stationId)); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/SysConfigServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/SysConfigServiceImpl.java new file mode 100644 index 0000000..05db045 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/SysConfigServiceImpl.java @@ -0,0 +1,78 @@ +package com.mathvision.box.dao.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.dao.domain.vo.DataStorageConfigVo; +import com.mathvision.box.dao.domain.vo.UISettingConfigVo; +import com.mathvision.box.dao.mapper.SysConfigMapper; +import com.mathvision.box.dao.domain.entity.SysConfig; +import com.mathvision.box.dao.service.SysConfigService; +import com.mathvision.box.dao.domain.dto.SysConfigDto; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.annotation.PostConstruct; + +/** + * 参数配置表(SysConfig)表服务实现类 + * @author Fangy + * @date 2025-04-30 10:28:58 + */ +@Service +public class SysConfigServiceImpl extends ServiceImpl implements SysConfigService { + /** logger:日志文件 */ + private static final Logger logger = LoggerFactory.getLogger(SysConfigServiceImpl.class); + private static final String DataStorageConfigKey = "DataStorageConfig"; + private static final String UISettingConfigKey = "UISettingConfig"; + @Autowired + private SysConfigMapper sysConfigMapper; + + @PostConstruct + public void init() { + SysConfig dataStorageConfig = this.queryDataStorageConfig(); + if (dataStorageConfig == null) { + dataStorageConfig = SysConfig.builder() + .configName("数据存储管理") + .configKey(DataStorageConfigKey) + .configValue(JSONObject.toJSONString(DataStorageConfigVo.builder().threshold(80).build())) + .createUser(1L) + .updateUser(1L) + .remark("数据存储管理") + .build(); + this.save(dataStorageConfig); + } + SysConfig UISettingConfig = this.queryUISettingConfig(); + if (UISettingConfig == null) { + UISettingConfig = SysConfig.builder() + .configName("界面设置") + .configKey(UISettingConfigKey) + .configValue(JSONObject.toJSONString(UISettingConfigVo.builder().name("服务区智慧管理平台").logo("").favicon("").loginBackground("").ext1("欢迎领导莅临指导!").ext2("加油站安全管理驾驶舱").build())) + .createUser(1L) + .updateUser(1L) + .remark("界面设置") + .build(); + this.save(UISettingConfig); + } + } + + @Override + public List query(SysConfigDto sysConfigDto) { + SysConfig sysConfig = new SysConfig(); + BeanUtils.copyProperties(sysConfigDto, sysConfig); + return sysConfigMapper.query(sysConfig); + } + + @Override + public SysConfig queryUISettingConfig() { + return sysConfigMapper.query(SysConfig.builder().configKey(UISettingConfigKey).build()).stream().findFirst().orElse(null); + } + + @Override + public SysConfig queryDataStorageConfig() { + return sysConfigMapper.query(SysConfig.builder().configKey(DataStorageConfigKey).build()).stream().findFirst().orElse(null); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/SysFileServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/SysFileServiceImpl.java new file mode 100644 index 0000000..cb420d5 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/SysFileServiceImpl.java @@ -0,0 +1,37 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.dao.domain.entity.Station; +import com.mathvision.box.dao.mapper.SysFileMapper; +import com.mathvision.box.dao.domain.entity.SysFile; +import com.mathvision.box.dao.service.SysFileService; +import com.mathvision.box.dao.domain.dto.SysFileQueryDto; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; + +@Service +public class SysFileServiceImpl extends ServiceImpl implements SysFileService { + /** logger:日志文件 */ + private static final Logger logger = LoggerFactory.getLogger(SysFileServiceImpl.class); + + @Autowired + private SysFileMapper sysFileMapper; + + @Override + public List query(SysFileQueryDto sysFileDto) { + SysFile sysFile = new SysFile(); + BeanUtils.copyProperties(sysFileDto, sysFile); + return sysFileMapper.query(sysFile); + } + + @Override + public boolean checkNameUnique(Long id, String name) { + List list = sysFileMapper.selectList(new QueryWrapper().eq("file_name", name)); + return list.isEmpty() || (id != null && list.size() == 1 && list.get(0).getFileId().equals(id) && list.get(0).getFileName().equals(name)); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/SysLogServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/SysLogServiceImpl.java new file mode 100644 index 0000000..bf61658 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/SysLogServiceImpl.java @@ -0,0 +1,55 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.csv.CsvUtils; +import com.mathvision.box.dao.domain.dto.SysLogDto; +import com.mathvision.box.dao.domain.entity.Detect; +import com.mathvision.box.dao.domain.entity.SysLog; +import com.mathvision.box.dao.mapper.SysLogMapper; +import com.mathvision.box.dao.service.SysLogService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 系统日志信息表(SysLog)表服务实现类 + * @author Fangy + * @date 2024-09-24 15:57:56 + */ +@Service +public class SysLogServiceImpl extends ServiceImpl implements SysLogService { + /** logger:日志文件 */ + private static final Logger logger = LoggerFactory.getLogger(SysLogServiceImpl.class); + + @Autowired + private SysLogMapper sysLogMapper; + + @Override + public List query(SysLogDto sysLogDto) { + SysLog sysLog = new SysLog(); + BeanUtils.copyProperties(sysLogDto, sysLog); + return sysLogMapper.query(sysLog); + } + + @Scheduled(cron = "0 0 1 * * ?") + void clean() { + Date before = DateUtils.addDays(DateUtils.getNowDate(), -AppConfig.getDataCleanupRetentionDays()); + List oldData = sysLogMapper.selectList(new QueryWrapper().lt("create_time", before)); + if (oldData == null || oldData.isEmpty()) { + return; + } + sysLogMapper.deleteBatchIds(oldData.stream().map(SysLog::getLogId).collect(Collectors.toList())); + CsvUtils.exportToCsvWithAnnotation(oldData, AppConfig.getCsvPath() + "/" + DateUtils.datePath() + "/SysLog.csv"); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsMenuServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsMenuServiceImpl.java new file mode 100644 index 0000000..8ca003b --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsMenuServiceImpl.java @@ -0,0 +1,62 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.dao.domain.dto.UmsMenuDto; +import com.mathvision.box.dao.domain.entity.UmsMenu; +import com.mathvision.box.dao.mapper.UmsMenuMapper; +import com.mathvision.box.dao.service.UmsMenuService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * 菜单表(UmsMenu)表服务实现类 + * + * @author Fangy + * @date 2024-03-25 15:50:12 + */ +@Service +public class UmsMenuServiceImpl extends ServiceImpl implements UmsMenuService { + /** + * logger:日志文件 + */ + private static final Logger logger = LoggerFactory.getLogger(UmsMenuServiceImpl.class); + + @Autowired + private UmsMenuMapper umsMenuMapper; + + @Override + public Set selectPermsByUserId(Long userId) { + List perms = umsMenuMapper.selectPermsByUserId(userId); + Set permsSet = new HashSet<>(); + for (String perm : perms) { + if (StringUtils.isNotEmpty(perm)) { + permsSet.addAll(Arrays.asList(perm.trim().split(","))); + } + } + return permsSet; + } + + @Override + public List query(UmsMenuDto umsMenuDto) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(StringUtils.isNotBlank(umsMenuDto.getMenuName()), "menu_name", umsMenuDto.getMenuName()) + .eq(umsMenuDto.getParentId() != null && umsMenuDto.getParentId() != 0, "parent_id", umsMenuDto.getParentId()) + .eq(StringUtils.isNotBlank(umsMenuDto.getMenuType()), "menu_type", umsMenuDto.getMenuType()) + .eq(StringUtils.isNotBlank(umsMenuDto.getPermission()), "permission", umsMenuDto.getPermission()); + return umsMenuMapper.selectList(queryWrapper); + } + + @Override + public List selectPermsByRoleId(Long roleId) { + return umsMenuMapper.selectPermsByRoleId(roleId); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsOrganizationServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsOrganizationServiceImpl.java new file mode 100644 index 0000000..469f3cb --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsOrganizationServiceImpl.java @@ -0,0 +1,117 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.enums.ConfigEnum; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.common.utils.tree.TreeBuilderUtil; +import com.mathvision.box.common.utils.tree.TreeNode; +import com.mathvision.box.dao.domain.dto.UmsOrganizationDto; +import com.mathvision.box.dao.domain.entity.UmsOrganization; +import com.mathvision.box.dao.domain.entity.UmsUserOrganization; +import com.mathvision.box.dao.mapper.UmsOrganizationMapper; +import com.mathvision.box.dao.mapper.UmsUserOrganizationMapper; +import com.mathvision.box.dao.service.UmsOrganizationService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import javax.annotation.PostConstruct; +import java.util.List; + +/** + * 组织信息表(UmsOrganization)表服务实现类 + * + * @author Fangy + * @date 2024-04-03 09:47:08 + */ +@Service +public class UmsOrganizationServiceImpl extends ServiceImpl implements UmsOrganizationService { + /** + * logger:日志文件 + */ + private static final Logger logger = LoggerFactory.getLogger(UmsOrganizationServiceImpl.class); + + @Autowired + private UmsOrganizationMapper umsOrganizationMapper; + + @Autowired + private UmsUserOrganizationMapper umsUserOrganizationMapper; + + @PostConstruct + @Scheduled(cron = "0 0 0/1 * * *") + public void init() { + umsOrganizationMapper.selectList(new QueryWrapper<>()).forEach(e -> { + CacheService.putOrganization(e.getOrganizationId(), e); + }); + } + + @Override + public List> quarryTree() { + return TreeBuilderUtil.buildTree(CacheService.getOrganization(null)); + } + + @Override + public boolean add(UmsOrganizationDto umsOrganizationDto) { + Assert.isTrue(checkNameUnique(null, umsOrganizationDto.getOrganizationName()), "名称重复"); + UmsOrganization umsOrganization = new UmsOrganization(); + BeanUtils.copyProperties(umsOrganizationDto, umsOrganization); + if (umsOrganizationMapper.insert(umsOrganization) > 0) { + CacheService.putOrganization(umsOrganization.getOrganizationId(), umsOrganization); + return true; + } + return false; + } + + @Override + public boolean update(UmsOrganizationDto umsOrganizationDto) { + Assert.isTrue(checkNameUnique(umsOrganizationDto.getOrganizationId(), umsOrganizationDto.getOrganizationName()), "名称重复"); + UmsOrganization umsOrganization = umsOrganizationMapper.selectById(umsOrganizationDto.getOrganizationId()); + Assert.isTrue(umsOrganization != null, "组织不存在"); + BeanUtils.copyProperties(umsOrganizationDto, umsOrganization); + if (umsOrganizationMapper.updateById(umsOrganization) > 0) { + CacheService.putOrganization(umsOrganization.getOrganizationId(), umsOrganization); + return true; + } + return false; + } + + @Override + public boolean delete(List idList) { + Assert.isTrue(!idList.contains(Long.parseLong(ConfigEnum.DEFAULT_ORGANIZATION_ID.getData())), "删除失败,总公司不允许删除!"); + if (umsOrganizationMapper.deleteBatchIds(idList) > 0) { + CacheService.removeOrganization(idList); + return true; + } + return false; + } + + @Override + public UmsOrganization getByUid(Long id) { + return umsOrganizationMapper.getByUid(id); + } + + @Override + public boolean save(Long userId, Long organizationId) { + return umsUserOrganizationMapper.insert(UmsUserOrganization.builder().userId(userId).organizationId(organizationId).build()) > 0; + } + + @Override + public boolean deleteByUserId(Long userId) { + return umsUserOrganizationMapper.delete(new QueryWrapper().eq("user_id", userId)) > 0; + } + + @Override + public boolean deleteByUserId(List userIds) { + return umsUserOrganizationMapper.delete(new QueryWrapper().in("user_id", userIds)) > 0; + } + + @Override + public boolean checkNameUnique(Long id, String name) { + List list = umsOrganizationMapper.selectList(new QueryWrapper().eq("organization_name", name)); + return list.isEmpty() || (id != null && list.size() == 1 && list.get(0).getOrganizationId().equals(id) && list.get(0).getOrganizationName().equals(name)); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsRoleMenuServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsRoleMenuServiceImpl.java new file mode 100644 index 0000000..8f60d0b --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsRoleMenuServiceImpl.java @@ -0,0 +1,25 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.dao.domain.entity.UmsRoleMenu; +import com.mathvision.box.dao.mapper.UmsRoleMenuMapper; +import com.mathvision.box.dao.service.UmsRoleMenuService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 角色权限关联表(UmsRoleMenu)表服务实现类 + * @author Fangy + * @date 2024-04-12 20:46:30 + */ +@Service +public class UmsRoleMenuServiceImpl extends ServiceImpl implements UmsRoleMenuService { + /** logger:日志文件 */ + private static final Logger logger = LoggerFactory.getLogger(UmsRoleMenuServiceImpl.class); + + @Autowired + private UmsRoleMenuMapper umsRoleMenuMapper; + +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsRoleServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsRoleServiceImpl.java new file mode 100644 index 0000000..4581422 --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsRoleServiceImpl.java @@ -0,0 +1,99 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.dao.domain.dto.UmsRoleDto; +import com.mathvision.box.dao.domain.entity.UmsRole; +import com.mathvision.box.dao.domain.entity.UmsRoleMenu; +import com.mathvision.box.dao.domain.entity.UmsUserRole; +import com.mathvision.box.dao.mapper.UmsRoleMapper; +import com.mathvision.box.dao.mapper.UmsUserRoleMapper; +import com.mathvision.box.dao.service.UmsRoleMenuService; +import com.mathvision.box.dao.service.UmsRoleService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * 角色表(UmsRole)表服务实现类 + * @author Fangy + * @date 2024-03-25 15:50:12 + */ +@Service +public class UmsRoleServiceImpl extends ServiceImpl implements UmsRoleService { + /** logger:日志文件 */ + private static final Logger logger = LoggerFactory.getLogger(UmsRoleServiceImpl.class); + + @Autowired + private UmsRoleMapper umsRoleMapper; + + @Autowired + private UmsRoleMenuService umsRoleMenuService; + + @Autowired + private UmsUserRoleMapper umsUserRoleMapper; + + @Override + public Set selectRoleKeys(Long userId) { + List perms = umsRoleMapper.selectRolesByUserId(userId); + Set permsSet = new HashSet<>(); + for (UmsRole perm : perms) + { + if (StringUtils.isNotNull(perm)) + { + permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); + } + } + return permsSet; + } + + @Override + public List query(UmsRoleDto umsRoleDto) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(StringUtils.isNotBlank(umsRoleDto.getRoleKey()),"role_key",umsRoleDto.getRoleKey()) + .eq(StringUtils.isNotBlank(umsRoleDto.getRoleName()),"role_name",umsRoleDto.getRoleName()) + .eq(StringUtils.isNotBlank(umsRoleDto.getStatus()),"status",umsRoleDto.getStatus()); + return umsRoleMapper.selectList(queryWrapper); + } + + @Override + public boolean bindMenu(Long roleId, List menuIds) { + Map map= new HashMap<>(); + map.put("role_id",roleId); + umsRoleMenuService.removeByMap(map); + List list = new ArrayList<>(); + menuIds.forEach(e->{list.add(UmsRoleMenu.builder().roleId(roleId).menuId(e).build());}); + return umsRoleMenuService.saveBatch(list); + } + + @Override + public boolean save(Long userId, Long roleId) { + return umsUserRoleMapper.insert(UmsUserRole.builder().userId(userId).roleId(roleId).build()) > 0; + } + + @Override + public boolean deleteByUserId(Long userId) { + return umsUserRoleMapper.delete(new QueryWrapper().eq("user_id", userId)) > 0; + } + + @Override + public boolean deleteByUserId(List userIds) { + return umsUserRoleMapper.delete(new QueryWrapper().in("user_id", userIds)) > 0; + } + + @Override + public boolean checkNameUnique(Long id, String name) { + List list = umsRoleMapper.selectList(new QueryWrapper().eq("role_name", name)); + return list.isEmpty() || (id != null && list.size() == 1 && list.get(0).getRoleId().equals(id) && list.get(0).getRoleName().equals(name)); + } + + @Override + public boolean checkCodeUnique(Long id, String code) { + List list = umsRoleMapper.selectList(new QueryWrapper().eq("role_key", code)); + return list.isEmpty() || (id != null && list.size() == 1 && list.get(0).getRoleId().equals(id) && list.get(0).getRoleKey().equals(code)); + } +} diff --git a/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsUserServiceImpl.java b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsUserServiceImpl.java new file mode 100644 index 0000000..08cd75a --- /dev/null +++ b/box-dao/src/main/java/com/mathvision/box/dao/service/impl/UmsUserServiceImpl.java @@ -0,0 +1,160 @@ +package com.mathvision.box.dao.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mathvision.box.common.enums.ConfigEnum; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.common.utils.common.MD5Utils; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.tree.TreeBuilderUtil; +import com.mathvision.box.common.utils.tree.TreeNode; +import com.mathvision.box.dao.domain.dto.UmsUserAddDto; +import com.mathvision.box.dao.domain.dto.UmsUserQueryDto; +import com.mathvision.box.dao.domain.entity.*; +import com.mathvision.box.dao.mapper.*; +import com.mathvision.box.dao.service.UmsOrganizationService; +import com.mathvision.box.dao.service.UmsRoleService; +import com.mathvision.box.dao.service.UmsUserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class UmsUserServiceImpl extends ServiceImpl implements UmsUserService { + + private static final Logger logger = LoggerFactory.getLogger(UmsUserServiceImpl.class); + + @Autowired + private UmsUserMapper userMapper; + + @Resource + private UmsOrganizationService organizationService; + + @Resource + private UmsRoleService roleService; + + @PostConstruct + @Scheduled(cron = "0 0 0/1 * * *") + public void init() { + userMapper.selectList(new QueryWrapper<>()).forEach(user -> { + CacheService.putUserName(user.getUserId(), user.getUserName()); + }); + } + + @Override + public boolean add(UmsUserAddDto umsUserDto) { + Assert.isTrue(checkLoginNameUnique(null, umsUserDto.getLoginName()), "新增用户'" + umsUserDto.getLoginName() + "'失败,登录账号已存在"); + Assert.isTrue(checkPhoneUnique(null, umsUserDto.getPhone()), "新增用户'" + umsUserDto.getLoginName() + "'失败,手机号码已存在"); + Assert.isTrue(StringUtils.isEmpty(umsUserDto.getEmail()) || checkEmailUnique(null, umsUserDto.getEmail()), "新增用户'" + umsUserDto.getLoginName() + "'失败,邮箱账号已存在"); + String salt = MD5Utils.randomSalt(); + UmsUser user = new UmsUser(); + BeanUtils.copyProperties(umsUserDto, user); + user.setPassword(MD5Utils.inputPassToDBPass(umsUserDto.getPassword(), salt)); + user.setSalt(salt); + Assert.isTrue(userMapper.insert(user) > 0, "新增用户失败"); + Long userId = user.getUserId(); + //外键绑定 + organizationService.save(userId, umsUserDto.getOrganizationId() != null ? umsUserDto.getOrganizationId() : 1L); + roleService.save(userId, umsUserDto.getRoleId() != null ? umsUserDto.getRoleId() : Long.parseLong(ConfigEnum.DEFAULT_ROLE_ID.getData())); + //更新缓存 + CacheService.putUserName(userId, user.getUserName()); + return true; + } + + @Override + public boolean update(UmsUserAddDto umsUserDto) { + Assert.isTrue(checkLoginNameUnique(umsUserDto.getUserId(), umsUserDto.getLoginName()), "修改用户'" + umsUserDto.getLoginName() + "'失败,登录账号已存在"); + Assert.isTrue(checkPhoneUnique(umsUserDto.getUserId(), umsUserDto.getPhone()), "修改用户'" + umsUserDto.getLoginName() + "'失败,手机号码已存在"); + Assert.isTrue(StringUtils.isEmpty(umsUserDto.getEmail()) || checkEmailUnique(umsUserDto.getUserId(), umsUserDto.getEmail()), "修改用户'" + umsUserDto.getLoginName() + "'失败,邮箱账号已存在"); + + UpdateWrapper umsUserUpdateWrapper = new UpdateWrapper<>(); + String salt = MD5Utils.randomSalt(); + umsUserUpdateWrapper.eq("user_id", umsUserDto.getUserId()) + .set(StringUtils.isNotBlank(umsUserDto.getLoginName()), "login_name", umsUserDto.getLoginName()) + .set(StringUtils.isNotBlank(umsUserDto.getUserName()), "user_name", umsUserDto.getUserName()) + .set(StringUtils.isNotBlank(umsUserDto.getEmail()), "email", umsUserDto.getEmail()) + .set(StringUtils.isNotBlank(umsUserDto.getPhone()), "phone", umsUserDto.getPhone()) + .set(StringUtils.isNotBlank(umsUserDto.getStatus()), "status", umsUserDto.getStatus()) + .set(StringUtils.isNotBlank(umsUserDto.getPassword()), "password", MD5Utils.inputPassToDBPass(umsUserDto.getPassword(), salt)) + .set(StringUtils.isNotBlank(umsUserDto.getPassword()), "salt", salt) + .set(StringUtils.isNotBlank(umsUserDto.getSex()), "sex", umsUserDto.getSex()) + .set(StringUtils.isNotBlank(umsUserDto.getAvatar()), "avatar", umsUserDto.getAvatar()) + .set("update_user", umsUserDto.getUpdateUser()); + Assert.isTrue(userMapper.update(null, umsUserUpdateWrapper) > 0, "修改用户失败"); + Long userId = umsUserDto.getUserId(); + //外键绑定 + if (umsUserDto.getOrganizationId() != null) { + organizationService.deleteByUserId(userId); + organizationService.save(userId, umsUserDto.getOrganizationId()); + } + if (umsUserDto.getRoleId() != null) { + roleService.deleteByUserId(userId); + roleService.save(userId, umsUserDto.getRoleId()); + } + //更新缓存 + CacheService.putUserName(userId, umsUserDto.getUserName()); + return true; + } + + @Override + public List list(UmsUserQueryDto umsUserDto) { + if (umsUserDto.getOrganizationId() != null) { + List> treeNodes = organizationService.quarryTree(); + TreeNode treeNode = TreeBuilderUtil.getById(treeNodes, umsUserDto.getOrganizationId()); + Assert.notNull(treeNode, "组织不存在"); + List organizationIds = treeNode.getChildIds().stream().map(obj -> Long.valueOf(obj.toString())).collect(Collectors.toList()); + organizationIds.add(umsUserDto.getOrganizationId()); + umsUserDto.setOrganizationIds_(organizationIds); + } + return userMapper.query(umsUserDto); + } + + @Override + public UmsUser getById(Long id) { + return list(UmsUserQueryDto.builder().userId(id).build()).stream().findFirst().orElse(null); + } + + @Override + public List listByIds(List idList) { + return userMapper.listByIds(idList); + } + + @Override + public boolean delete(List idList) { + Assert.isTrue(!idList.contains(Long.parseLong(ConfigEnum.ADMIN_USER_ID.getData())), "删除失败,该用户为超级管理员,不允许删除!"); + roleService.deleteByUserId(idList); + organizationService.deleteByUserId(idList); + if (userMapper.deleteBatchIds(idList) > 0) { + CacheService.removeUserName(idList); + return true; + } + return false; + } + + @Override + public boolean checkLoginNameUnique(Long userId, String loginName) { + List userList = userMapper.selectList(new QueryWrapper().eq("login_name", loginName).eq("is_deleted", 0)); + return userList.isEmpty() || (userId != null && userList.size() == 1 && userList.get(0).getUserId().equals(userId)) ? true : false; + } + + @Override + public boolean checkPhoneUnique(Long userId, String phone) { + List userList = userMapper.selectList(new QueryWrapper().eq("phone", phone).eq("is_deleted", 0)); + return userList.isEmpty() || (userId != null && userList.size() == 1 && userList.get(0).getUserId().equals(userId)) ? true : false; + } + + @Override + public boolean checkEmailUnique(Long userId, String email) { + List userList = userMapper.selectList(new QueryWrapper().eq("email", email).eq("is_deleted", 0)); + return userList.isEmpty() || (userId != null && userList.size() == 1 && userList.get(0).getUserId().equals(userId)) ? true : false; + } +} diff --git a/box-dao/src/main/resources/mapper/BoxRecordMapper.xml b/box-dao/src/main/resources/mapper/BoxRecordMapper.xml new file mode 100644 index 0000000..48a0ca0 --- /dev/null +++ b/box-dao/src/main/resources/mapper/BoxRecordMapper.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + record_id , create_time, record_type, device_id, data_key, data_type, content, extended + + + + + + diff --git a/box-dao/src/main/resources/mapper/BoxTraceMapper.xml b/box-dao/src/main/resources/mapper/BoxTraceMapper.xml new file mode 100644 index 0000000..d6a1509 --- /dev/null +++ b/box-dao/src/main/resources/mapper/BoxTraceMapper.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + id + , device_id, alarm_code, alarm_level, alarm_content, trace_info, create_time, update_time + + + + + + diff --git a/box-dao/src/main/resources/mapper/DefectMapper.xml b/box-dao/src/main/resources/mapper/DefectMapper.xml new file mode 100644 index 0000000..ca3a747 --- /dev/null +++ b/box-dao/src/main/resources/mapper/DefectMapper.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + id , process_id, time, end_time, type, ip,device_name, device_id, channel, channel_name, img, video, data, ext, status + + + + + + + + + diff --git a/box-dao/src/main/resources/mapper/DetectMapper.xml b/box-dao/src/main/resources/mapper/DetectMapper.xml new file mode 100644 index 0000000..968e428 --- /dev/null +++ b/box-dao/src/main/resources/mapper/DetectMapper.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + id, detect_id, process_id, time, type, ip, channel, img, data, status + + + + + + diff --git a/box-dao/src/main/resources/mapper/DeviceMapper.xml b/box-dao/src/main/resources/mapper/DeviceMapper.xml new file mode 100644 index 0000000..705bbfd --- /dev/null +++ b/box-dao/src/main/resources/mapper/DeviceMapper.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + id + , device_id, type, name, config, vendor, remark, create_time, update_time + + + + + + + + + + diff --git a/box-dao/src/main/resources/mapper/PointDeviceMapper.xml b/box-dao/src/main/resources/mapper/PointDeviceMapper.xml new file mode 100644 index 0000000..4a0daba --- /dev/null +++ b/box-dao/src/main/resources/mapper/PointDeviceMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + point_id , device_id + + + + + + diff --git a/box-dao/src/main/resources/mapper/PointMapper.xml b/box-dao/src/main/resources/mapper/PointMapper.xml new file mode 100644 index 0000000..6197c32 --- /dev/null +++ b/box-dao/src/main/resources/mapper/PointMapper.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + id + , point_id, point_name, station_id, cover, config, remark, status, create_time, update_time + + + + + + diff --git a/box-dao/src/main/resources/mapper/StationMapper.xml b/box-dao/src/main/resources/mapper/StationMapper.xml new file mode 100644 index 0000000..2f2ad41 --- /dev/null +++ b/box-dao/src/main/resources/mapper/StationMapper.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + id + , station_id, station_name, address, contact, phone, introduction, create_time, update_time + + + + + + diff --git a/box-dao/src/main/resources/mapper/SysConfigMapper.xml b/box-dao/src/main/resources/mapper/SysConfigMapper.xml new file mode 100644 index 0000000..356c3c6 --- /dev/null +++ b/box-dao/src/main/resources/mapper/SysConfigMapper.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + config_id + , config_name, config_key, config_value, create_user, create_time, update_user, update_time, remark + + + + + + diff --git a/box-dao/src/main/resources/mapper/SysFileMapper.xml b/box-dao/src/main/resources/mapper/SysFileMapper.xml new file mode 100644 index 0000000..545807a --- /dev/null +++ b/box-dao/src/main/resources/mapper/SysFileMapper.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + file_id + , file_type, file_name, url, create_user, create_time + + + + + + diff --git a/box-dao/src/main/resources/mapper/SysLogMapper.xml b/box-dao/src/main/resources/mapper/SysLogMapper.xml new file mode 100644 index 0000000..e72549b --- /dev/null +++ b/box-dao/src/main/resources/mapper/SysLogMapper.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + log_id + , log_type, log_content, create_user, create_time + + + + + + diff --git a/box-dao/src/main/resources/mapper/UmsMenuMapper.xml b/box-dao/src/main/resources/mapper/UmsMenuMapper.xml new file mode 100644 index 0000000..0fabd74 --- /dev/null +++ b/box-dao/src/main/resources/mapper/UmsMenuMapper.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + m.menu_id, m.menu_name, m.parent_id, m.sort, m.url, m.menu_type, m.visible, m.permission, m.icon, m.create_user, m.create_time, m.update_user, m.update_time, m.is_deleted, m.remark + + + + + + + diff --git a/box-dao/src/main/resources/mapper/UmsOrganizationMapper.xml b/box-dao/src/main/resources/mapper/UmsOrganizationMapper.xml new file mode 100644 index 0000000..3edf34a --- /dev/null +++ b/box-dao/src/main/resources/mapper/UmsOrganizationMapper.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + o.organization_id, o.organization_name, o.organization_type, o.order_num, o.parent_id, o.depth, o.status, o.is_deleted, o.create_user, o.create_time, o.update_user, o.update_time + + + + + + + diff --git a/box-dao/src/main/resources/mapper/UmsRoleMapper.xml b/box-dao/src/main/resources/mapper/UmsRoleMapper.xml new file mode 100644 index 0000000..505774e --- /dev/null +++ b/box-dao/src/main/resources/mapper/UmsRoleMapper.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status, r.is_deleted, r.create_user, r.create_time, r.update_user, r.update_time, r.remark + + + + + + + diff --git a/box-dao/src/main/resources/mapper/UmsRoleMenuMapper.xml b/box-dao/src/main/resources/mapper/UmsRoleMenuMapper.xml new file mode 100644 index 0000000..fe85346 --- /dev/null +++ b/box-dao/src/main/resources/mapper/UmsRoleMenuMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + role_id, menu_id + + + diff --git a/box-dao/src/main/resources/mapper/UmsUserMapper.xml b/box-dao/src/main/resources/mapper/UmsUserMapper.xml new file mode 100644 index 0000000..5565cf5 --- /dev/null +++ b/box-dao/src/main/resources/mapper/UmsUserMapper.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + u.user_id, u.login_name, u.user_name, u.email, u.phone, u.password, u.salt, u.status, u.is_deleted, u.login_ip, u.login_date, u.pwd_update_date, u.create_user, u.create_time, u.update_user, u.update_time, u.remark, u.sex, u.avatar + ,r.role_id,r.role_name + ,o.organization_id,o.organization_name + + + + + + diff --git a/box-dao/src/main/resources/mapper/UmsUserOrganizationMapper.xml b/box-dao/src/main/resources/mapper/UmsUserOrganizationMapper.xml new file mode 100644 index 0000000..d19948f --- /dev/null +++ b/box-dao/src/main/resources/mapper/UmsUserOrganizationMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + organization_id + , user_id + + + + + + diff --git a/box-dao/src/main/resources/mapper/UmsUserRoleMapper.xml b/box-dao/src/main/resources/mapper/UmsUserRoleMapper.xml new file mode 100644 index 0000000..cb4695b --- /dev/null +++ b/box-dao/src/main/resources/mapper/UmsUserRoleMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + user_id + , role_id + + + + + + diff --git a/box-device/pom.xml b/box-device/pom.xml new file mode 100644 index 0000000..63ddd17 --- /dev/null +++ b/box-device/pom.xml @@ -0,0 +1,38 @@ + + + + box + com.mathvision + 1.0-SNAPSHOT + + 4.0.0 + + box-device + + + + com.mathvision + box-message + 1.0-SNAPSHOT + + + + + com.sun.jna + jna + 1.0-SNAPSHOT + + + + + com.sun.jna.examples + examples + 1.0-SNAPSHOT + + + + + + \ No newline at end of file diff --git a/box-device/src/main/java/com/mathvision/box/device/common/domin/HKPoint.java b/box-device/src/main/java/com/mathvision/box/device/common/domin/HKPoint.java new file mode 100644 index 0000000..52c3807 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/domin/HKPoint.java @@ -0,0 +1,24 @@ +package com.mathvision.box.device.common.domin; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class HKPoint { + public int x; + public int y; + + public HKPoint point2point(int sourceWidth, int sourceHeight, int targetWidth, int targetHeight) { + this.x = this.x * sourceWidth / targetWidth; + this.y = this.y * sourceHeight / targetHeight; + + this.x = this.x >= targetWidth ? targetWidth : this.x; + this.x = this.x < 0 ? 0 : this.x; + + this.y = this.y >= targetHeight ? targetHeight : this.y; + this.y = this.y < 0 ? 0 : this.y; + + return this; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/domin/HikvisonBoxAlgorithmModel.java b/box-device/src/main/java/com/mathvision/box/device/common/domin/HikvisonBoxAlgorithmModel.java new file mode 100644 index 0000000..e20f684 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/domin/HikvisonBoxAlgorithmModel.java @@ -0,0 +1,63 @@ +package com.mathvision.box.device.common.domin; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.mathvision.box.common.utils.common.StringUtils; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class HikvisonBoxAlgorithmModel { + private static HikvisonBoxAlgorithmModel instance; + + private JSONObject model; + + private HikvisonBoxAlgorithmModel() { + } + + public static synchronized HikvisonBoxAlgorithmModel getInstance() { + if (instance == null) { + instance = new HikvisonBoxAlgorithmModel(); + } + return instance; + } + + private JSONArray getAlgorithmModels() { + if (model != null && model.containsKey("AlgorithmModels")) { + return model.getJSONArray("AlgorithmModels"); + } else return null; + } + + private JSONArray getCoordinationModels() { + if (model != null && model.containsKey("coordinationModels")) { + return model.getJSONArray("coordinationModels"); + } else return null; + } + + public String getMPNameByMPID(String MPID){ + if(StringUtils.isNotBlank(MPID)){ + JSONArray algorithmModels = getAlgorithmModels(); + if (algorithmModels != null){ + for (int i = 0; i < algorithmModels.size(); i++) { + JSONObject model = algorithmModels.getJSONObject(i); + if (model.containsKey("MPID") && model.getString("MPID").equals(MPID)){ + return model.getString("MPName"); + } + } + } + JSONArray coordinationModels = getCoordinationModels(); + if (coordinationModels != null){ + for (int i = 0; i < coordinationModels.size(); i++) { + JSONObject model = coordinationModels.getJSONObject(i); + if (model.containsKey("MPID") && model.getString("MPID").equals(MPID)){ + return model.getString("MPName"); + } + } + } + } + return "未知"; + } + + public static void init(String jsonStr) { + getInstance().model = JSONObject.parseObject(jsonStr); + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/domin/NvrTime.java b/box-device/src/main/java/com/mathvision/box/device/common/domin/NvrTime.java new file mode 100644 index 0000000..7413e2a --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/domin/NvrTime.java @@ -0,0 +1,25 @@ +package com.mathvision.box.device.common.domin; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class NvrTime { + @ApiModelProperty(value = "年", example = "年") + private Integer dwYear; + + @ApiModelProperty(value = "月", example = "月") + private Integer dwMonth; + + @ApiModelProperty(value = "日", example = "日") + private Integer dwDay; + + @ApiModelProperty(value = "时", example = "时") + private Integer dwHour; + + @ApiModelProperty(value = "分", example = "分") + private Integer dwMinute; + + @ApiModelProperty(value = "秒", example = "秒") + private Integer dwSecond; +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/domin/PlayBack.java b/box-device/src/main/java/com/mathvision/box/device/common/domin/PlayBack.java new file mode 100644 index 0000000..5fbe0f8 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/domin/PlayBack.java @@ -0,0 +1,29 @@ +package com.mathvision.box.device.common.domin; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +@ApiModel(value = "条件搜索", description = "条件搜索") +public class PlayBack { + @ApiModelProperty(value = "NVR盒子id参数", example = "NVR盒子id参数") + private Long id; + + @ApiModelProperty(value = "摄像头 设备IP", example = "摄像头 设备IP") + private String deviceIp; + + @ApiModelProperty(value = "摄像机通道", example = "摄像机通道") + private Integer channelNumber; + + @ApiModelProperty(value = "开始时间", example = "开始时间") + private Date startTime; + + @ApiModelProperty(value = "结束时间", example = "结束时间") + private Date endTime; + + @ApiModelProperty(value = "获取流类型 0-实时视频流,1-回放视频流", example = "获取流类型 0-实时视频流,1-回放视频流") + private Integer urlType; +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/domin/SignIn.java b/box-device/src/main/java/com/mathvision/box/device/common/domin/SignIn.java new file mode 100644 index 0000000..8e5fd5a --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/domin/SignIn.java @@ -0,0 +1,48 @@ +package com.mathvision.box.device.common.domin; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value = "设备注册信息", description = "设备注册信息") +public class SignIn { + @ApiModelProperty(value = "NVR盒子id", example = "NVR盒子id") + private Long id; + + @ApiModelProperty(value = "设备ID", example = "设备ID") + private String deviceId; + + @ApiModelProperty(value = "名称", example = "名称") + private String name; + + @ApiModelProperty(value = "IP地址", example = "IP地址") + private String ip; + + @ApiModelProperty(value = "设备端口", example = "设备端口") + private int port; + + @ApiModelProperty(value = "用户名", example = "用户名") + private String userName; + + @ApiModelProperty(value = "密码", example = "密码") + private String password; + + @ApiModelProperty(value = "通道号", example = "通道号") + private int channel; + + @ApiModelProperty(value = "是否在线", example = "是否在线") + private String status; + + @ApiModelProperty(value = "设备类型", example = "设备类型") + private String type; + + @ApiModelProperty(value = "设备厂商", example = "设备厂商") + private String vendor; +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/dto/CoreainDefect.java b/box-device/src/main/java/com/mathvision/box/device/common/dto/CoreainDefect.java new file mode 100644 index 0000000..6182ded --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/dto/CoreainDefect.java @@ -0,0 +1,52 @@ +package com.mathvision.box.device.common.dto; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * 鲲云盒子-卸油作业-检测结果日志数据 + */ +@Data +public class CoreainDefect { + private String processId; + + // + private Boolean isFinished; + + // + private Date startTime; + + private Date endTime; + + private Boolean isCheck; + + private String tag; + + private List steps; + + @Data + public class CoreainStep { + + private String alarmLevel; + + // + private String id; + + private String picUrl; + + private Date alarmTime; + + // + private String stepId; + + private String imgPath; + + private String check; + + private String checkNote; + } +} + + diff --git a/box-device/src/main/java/com/mathvision/box/device/common/dto/CoreainDetect.java b/box-device/src/main/java/com/mathvision/box/device/common/dto/CoreainDetect.java new file mode 100644 index 0000000..5390477 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/dto/CoreainDetect.java @@ -0,0 +1,42 @@ +package com.mathvision.box.device.common.dto; + +import com.alibaba.fastjson.JSONArray; +import lombok.Data; + +import java.util.Date; + +/** + * 鲲云盒子-卸油作业-检测过程日志数据 + */ +@Data +public class CoreainDetect { + private String alarmLevel; + + private Long id; + + private Date alarmTime; + + private Integer algorithmId; + + private String algorithmName; + + private Integer cameraId; + + private String cameraName; + + private String imgPath; + + private String jobId; + + private String processId; + + private String processName; + + private JSONArray resultData; + + private String srcImgPath; + + private String stepId; + + private String type; +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/dto/CoreainDevice.java b/box-device/src/main/java/com/mathvision/box/device/common/dto/CoreainDevice.java new file mode 100644 index 0000000..fd295a7 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/dto/CoreainDevice.java @@ -0,0 +1,28 @@ +package com.mathvision.box.device.common.dto; + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +import java.util.List; + +/** + * @Description:鲲云设备信息 + */ +@Data +public class CoreainDevice { + private Long id; + private String name; + private String gps; + private Integer exists; + private Integer onlineStatus; + private Integer sourceId; + private String cameraId; + private List cameraTypes; + private JSONObject sdkInfo; + private String streamUrl; + private String initPicture; + private Long width; + private Long height; + private JSONObject extra; + private Long third_platform_index_id; +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/dto/DeviceAddDto.java b/box-device/src/main/java/com/mathvision/box/device/common/dto/DeviceAddDto.java new file mode 100644 index 0000000..2ccdb6b --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/dto/DeviceAddDto.java @@ -0,0 +1,33 @@ +package com.mathvision.box.device.common.dto; + +import com.mathvision.box.device.common.enums.DeviceVendor; +import lombok.Data; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +@Data +public class DeviceAddDto { + @NotBlank(message = "设备名称不能为空") + private String deviceName; + + @Pattern(regexp = "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", + message = "IP地址格式错误") + private String deviceIp; + + @Range(min = 1, max = 65535, message = "端口号无效") + private String devicePort; + + @NotBlank(message = "用户名不能为空") + private String deviceUsername; + + @NotBlank(message = "密码不能为空") + private String devicePassword; + + @NotNull(message = "厂商类型不能为空") + private DeviceVendor deviceVendor; +} + + diff --git a/box-device/src/main/java/com/mathvision/box/device/common/enums/DefectType.java b/box-device/src/main/java/com/mathvision/box/device/common/enums/DefectType.java new file mode 100644 index 0000000..4aadd05 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/enums/DefectType.java @@ -0,0 +1,32 @@ +package com.mathvision.box.device.common.enums; + +import lombok.Getter; + +@Getter +public enum DefectType { + COMM_THERMOMETRY_ALARM_0("COMM_THERMOMETRY_ALARM_0", "测温预警"), + + COMM_THERMOMETRY_ALARM_1("COMM_THERMOMETRY_ALARM_1", "测温告警"), + + COMM_THERMOMETRY_ALARM_3("COMM_THERMOMETRY_ALARM_3", "温变预警"), + + SMOKING("SMOKING", "抽烟检测"), + + PHONE_CALL("PHONE_CALL", "打电话检测"), + + OIL_UNLOADING("OIL_UNLOADING", "卸油作业"), + + NULL("NULL", "未定义报警类型"), + ; + + @Getter + String type; + + @Getter + String desc; + + DefectType(String type, String desc) { + this.desc = desc; + this.type = type; + } +} \ No newline at end of file diff --git a/box-device/src/main/java/com/mathvision/box/device/common/enums/DetectType.java b/box-device/src/main/java/com/mathvision/box/device/common/enums/DetectType.java new file mode 100644 index 0000000..c5a7c45 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/enums/DetectType.java @@ -0,0 +1,50 @@ +package com.mathvision.box.device.common.enums; + +import com.mathvision.box.device.common.domin.HikvisonBoxAlgorithmModel; +import lombok.Getter; + +import java.util.Arrays; + +@Getter +public enum DetectType { + COMM_THERMOMETRY_ALARM("COMM_THERMOMETRY_ALARM", "温度报警信息"), + H930_MODEL_SPD("H930_MODEL_SPD", "抽烟打电话"), + + static_ground("static_ground", "静电接地"), + oil_pipe_remove("oil_pipe_remove", "油管拆除顺序"), + car_location("car_location", "车辆位置"), + car_leave("car_leave", "车辆离场"), + personnel_break_in("personnel_break_in", "人员闯入"), + fire_equipment_recover("fire_equipment_recover", "设备回收"), + protective_tools("protective_tools", "防护工具"), + plug_connection_status("plug_connection_status", "油管连接"), + static_wire_disconnect("static_wire_disconnect", "静电连接断开"), + protective_suit("protective_suit", "防护穿戴"), + anti_rolling_device("anti_rolling_device", "防溜车器"), + stable_oil_time("stable_oil_time", "稳油时间"), + personnel_present("personnel_present", "人员在场"); + + @Getter + String type; + + @Getter + String desc; + + DetectType(String type, String desc) { + this.desc = desc; + this.type = type; + } + + public static DetectType toDetectType(String type) { + return Arrays.stream(DetectType.values()).filter(_t -> _t.getType().equalsIgnoreCase(type) || _t.getDesc().equalsIgnoreCase(type)).findFirst().orElse(null); + } + + public static String toDesc(String type) { + DetectType detectType = toDetectType(type); + if (detectType != null) { + return detectType.getDesc(); + }else { + return HikvisonBoxAlgorithmModel.getInstance().getMPNameByMPID(type); + } + } +} \ No newline at end of file diff --git a/box-device/src/main/java/com/mathvision/box/device/common/enums/DeviceType.java b/box-device/src/main/java/com/mathvision/box/device/common/enums/DeviceType.java new file mode 100644 index 0000000..e89d33f --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/enums/DeviceType.java @@ -0,0 +1,5 @@ +package com.mathvision.box.device.common.enums; + +public enum DeviceType { + surveillance_camera, network_sound_column, box +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/enums/DeviceVendor.java b/box-device/src/main/java/com/mathvision/box/device/common/enums/DeviceVendor.java new file mode 100644 index 0000000..fd2f837 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/enums/DeviceVendor.java @@ -0,0 +1,33 @@ +package com.mathvision.box.device.common.enums; + +import com.mathvision.box.device.core.factory.*; +import lombok.Getter; + +@Getter +public enum DeviceVendor { + HIKVISION_BOX(DeviceType.box,"hikvision", HikvisionBox.class), + CORERAIN_BOX(DeviceType.box,"corerain", CorerainBox.class), + SOPHGO_BOX(DeviceType.box,"sophgo", SophgoBox.class), + HIKVISION_CAMERA(DeviceType.surveillance_camera,"hikvision", HikvisionCamera.class), + MOCK_BOX(DeviceType.box,"mock", MockBox.class), + MOCK_CAMERA(DeviceType.surveillance_camera,"mock", MockCamera.class); + + String vendor; + DeviceType type; + Class clazz; + + DeviceVendor(DeviceType type, String vendor, Class clazz) { + this.type = type; + this.vendor = vendor; + this.clazz = clazz; + } + + public static DeviceVendor getVendor(String vendor, String type) { + for (DeviceVendor deviceVendor : values()) { + if (deviceVendor.getVendor().equals(vendor) && deviceVendor.getType().name().equals(type)) { + return deviceVendor; + } + } + return null; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetEventEnum.java b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetEventEnum.java new file mode 100644 index 0000000..3527cde --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetEventEnum.java @@ -0,0 +1,71 @@ +package com.mathvision.box.device.common.enums; + +public enum HCNetEventEnum { + COMM_ALARM(0x1100, "8000报警信息主动上传"), + COMM_TRADEINFO(0x1500, "ATMDVR主动上传交易信息"), + COMM_ALARM_V30(0x4000, "9000报警信息主动上传"), + COMM_ALARM_V40(0x4007, ""), + COMM_ALARM_RULE(0x1102, "异常行为检测信息上传"), + COMM_ALARM_PDC(0x1103, "客流量统计报警上传"), + COMM_UPLOAD_PLATE_RESULT(0x2800, "交通抓拍结果上传"), + COMM_ITS_PLATE_RESULT(0x3050, "交通抓拍的终端图片上传"), + COMM_IPCCFG(0x4001, "9000设备IPC接入配置改变报警信息主动上传"), + COMM_ITS_PARK_VEHICLE(0x3056, "停车场数据上传"), + COMM_VEHICLE_CONTROL_ALARM(0x3059, "车辆报警上传"), + COMM_ALARM_TFS(0x1113, "交通取证报警信息"), + COMM_ALARM_TPS_V41(0x1114, "道路违章取证报警"), + COMM_ALARM_AID_V41(0x1115, "道路事件检测"), + COMM_UPLOAD_FACESNAP_RESULT(0x1112, "特征识别结果上传"), + COMM_SNAP_MATCH_ALARM(0x2902, "人脸比对结果上传"), + COMM_ALARM_ACS(0x5002, "门禁主机报警信息"), + COMM_ID_INFO_ALARM(0x5200, "门禁身份证刷卡信息"), + COMM_VCA_ALARM(0x4993, "智能检测通用报警"), + COMM_ISAPI_ALARM(0x6009, "ISAPI协议报警信息"), + COMM_ALARMHOST_CID_ALARM(0x1127, "报告报警上传"), + COMM_SENSOR_VALUE_UPLOAD(0x1120, "模拟量数据实时上传"), + COMM_SENSOR_ALARM(0x1121, "模拟量报警上传"), + COMM_SWITCH_ALARM(0x1122, "开关量报警"), + COMM_ALARMHOST_EXCEPTION(0x1123, "报警主机故障报警"), + COMM_ALARMHOST_OPERATEEVENT_ALARM(0x1124, "操作事件报警上传"), + COMM_ALARMHOST_SAFETYCABINSTATE(0x1125, "防护舱状态"), + COMM_ALARMHOST_ALARMOUTSTATUS(0x1126, "报警输出口/警号状态"), + COMM_ALARMHOST_DATA_UPLOAD(0x1129, "报警数据上传"), + COMM_UPLOAD_VIDEO_INTERCOM_EVENT(0x1132, "可视对讲事件记录上传"), + COMM_ALARM_VIDEO_INTERCOM(0x1133, "可视对讲报警上传"), + COMM_THERMOMETRY_ALARM(0x5212, "温度报警上传"), + COMM_FIREDETECTION_ALARM(0x4991, "火点报警上传"), + COMM_THERMOMETRY_DIFF_ALARM(0x5111, "温差报警"), + COMM_ALARM_SHIPSDETECTION(0x4521, "船只检测报警"), + COMM_UPLOAD_AIOP_VIDEO(0x4021, "设备支持AI开放平台接入,上传视频检测数据"), + COMM_UPLOAD_AIOP_PICTURE(0x4022, "设备支持AI开放平台接入,上传图片检测数据"), + COMM_UPLOAD_AIOP_POLLING_SNAP(0x4023, "设备支持AI开放平台接入,上传轮巡视频检测数据"), + COMM_UPLOAD_AIOP_POLLING_VIDEO(0x4024, "设备支持AI开放平台接入,上传轮巡视频检测数据"), + COMM_IPC_AUXALARM_RESULT(0x2820, "PIR报警、无线报警、呼救报警信息"), + + UNKNOWN(-1, "未知"); + + private final int code; + private final String message; + + HCNetEventEnum(int code, String message) { + this.code = code; + this.message = message; + } + + public int getCode() { + return code; + } + + public String getMessage() { + return message; + } + + public static HCNetEventEnum getByCode(int code) { + for (HCNetEventEnum eventEnum : values()) { + if (eventEnum.getCode() == code) { + return eventEnum; + } + } + return UNKNOWN; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetSDKCallbackStatus.java b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetSDKCallbackStatus.java new file mode 100644 index 0000000..c16ab1c --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetSDKCallbackStatus.java @@ -0,0 +1,19 @@ +package com.mathvision.box.device.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum HCNetSDKCallbackStatus { + SUCCESS(1000), + PROCESSING(1001), + FAILED(1002), + EXCEPTION(1003), + LANGUAGE_MISMATCH(1004), + DEV_TYPE_MISMATCH(1005), + SEND_WAIT(1006); + + private int code; + +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetSDKCallbackType.java b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetSDKCallbackType.java new file mode 100644 index 0000000..b85674f --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetSDKCallbackType.java @@ -0,0 +1,15 @@ +package com.mathvision.box.device.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum HCNetSDKCallbackType { + STATUS(0), + PROGRESS(1), + DATA(2); + + private int code; + +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetSDKErrorEnum.java b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetSDKErrorEnum.java new file mode 100644 index 0000000..626e5d3 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetSDKErrorEnum.java @@ -0,0 +1,154 @@ +package com.mathvision.box.device.common.enums; + +/** + * 海康sdk错误码枚举 + */ +public enum HCNetSDKErrorEnum { + NET_DVR_NOERROR(0, "没有错误。"), + NET_DVR_PASSWORD_ERROR(1, "用户名密码错误。"), + NET_DVR_NOENOUGHPRI(2, "权限不足。"), + NET_DVR_NOINIT(3, "没有初始化。"), + NET_DVR_CHANNEL_ERROR(4, "通道号错误。"), + NET_DVR_OVER_MAXLINK(5, "连接到DVR的客户端个数超过最大。"), + NET_DVR_VERSIONNOMATCH(6, "版本不匹配。"), + NET_DVR_NETWORK_FAIL_CONNECT(7, "连接服务器失败。"), + NET_DVR_NETWORK_SEND_ERROR(8, "向服务器发送失败。"), + NET_DVR_NETWORK_RECV_ERROR(9, "从服务器接收数据失败。"), + NET_DVR_NETWORK_RECV_TIMEOUT(10, "从服务器接收数据超时。"), + NET_DVR_NETWORK_ERRORDATA(11, "传送的数据有误。"), + NET_DVR_ORDER_ERROR(12, "调用次序错误。"), + NET_DVR_OPERNOPERMIT(13, "无此权限。"), + NET_DVR_COMMANDTIMEOUT(14, "DVR命令执行超时。"), + NET_DVR_ERRORSERIALPORT(15, "串口号错误。"), + NET_DVR_ERRORALARMPORT(16, "报警端口错误。"), + NET_DVR_PARAMETER_ERROR(17, "参数错误。"), + NET_DVR_CHAN_EXCEPTION(18, "服务器通道处于错误状态。"), + NET_DVR_NODISK(19, "没有硬盘。"), + NET_DVR_ERRORDISKNUM(20, "硬盘号错误。"), + NET_DVR_DISK_FULL(21, "服务器硬盘满。"), + NET_DVR_DISK_ERROR(22, "服务器硬盘出错。"), + NET_DVR_NOSUPPORT(23, "服务器不支持。"), + NET_DVR_BUSY(24, "服务器忙。"), + NET_DVR_MODIFY_FAIL(25, "服务器修改不成功。"), + NET_DVR_PASSWORD_FORMAT_ERROR(26, "密码输入格式不正确。"), + NET_DVR_DISK_FORMATING(27, "硬盘正在格式化,不能启动操作。"), + NET_DVR_DVRNORESOURCE(28, "DVR资源不足。"), + NET_DVR_DVROPRATEFAILED(29, "DVR操作失败。"), + NET_DVR_OPENHOSTSOUND_FAIL(30, "打开PC声音失败。"), + NET_DVR_DVRVOICEOPENED(31, "服务器语音对讲被占用。"), + NET_DVR_TIMEINPUTERROR(32, "时间输入不正确。"), + NET_DVR_NOSPECFILE(33, "回放时服务器没有指定的文件。"), + NET_DVR_CREATEFILE_ERROR(34, "创建文件出错。"), + NET_DVR_FILEOPENFAIL(35, "打开文件出错。"), + NET_DVR_OPERNOTFINISH(36, "上次的操作还没有完成。"), + NET_DVR_GETPLAYTIMEFAIL(37, "获取当前播放的时间出错。"), + NET_DVR_PLAYFAIL(38, "播放出错。"), + NET_DVR_FILEFORMAT_ERROR(39, "文件格式不正确。"), + NET_DVR_DIR_ERROR(40, "路径错误。"), + NET_DVR_ALLOC_RESOURCE_ERROR(41, "资源分配错误。"), + NET_DVR_AUDIO_MODE_ERROR(42, "声卡模式错误。"), + NET_DVR_NOENOUGH_BUF(43, "缓冲区太小。"), + NET_DVR_CREATESOCKET_ERROR(44, "创建SOCKET出错。"), + NET_DVR_SETSOCKET_ERROR(45, "设置SOCKET出错。"), + NET_DVR_MAX_NUM(46, "个数达到最大。"), + NET_DVR_USERNOTEXIST(47, "用户不存在。"), + NET_DVR_WRITEFLASHERROR(48, "写FLASH出错。"), + NET_DVR_UPGRADEFAIL(49, "DVR升级失败。"), + NET_DVR_CARDHAVEINIT(50, "解码卡已经初始化过。"), + NET_DVR_PLAYERFAILED(51, "调用播放库中某个函数失败。"), + NET_DVR_MAX_USERNUM(52, "设备端用户数达到最大。"), + NET_DVR_GETLOCALIPANDMACFAIL(53, "获得客户端的IP地址或物理地址失败。"), + NET_DVR_NOENCODEING(54, "该通道没有编码。"), + NET_DVR_IPMISMATCH(55, "IP地址不匹配。"), + NET_DVR_MACMISMATCH(56, "MAC地址不匹配。"), + NET_DVR_UPGRADELANGMISMATCH(57, "升级文件语言不匹配。"), + NET_DVR_MAX_PLAYERPORT(58, "播放器路数达到最大。"), + NET_DVR_NOSPACEBACKUP(59, "备份设备中没有足够空间进行备份。"), + NET_DVR_NODEVICEBACKUP(60, "没有找到指定的备份设备。"), + NET_DVR_PICTURE_BITS_ERROR(61, "图像素位数不符,限24色。"), + NET_DVR_PICTURE_DIMENSION_ERROR(62, "图片高*宽超限, 限128*256。"), + NET_DVR_PICTURE_SIZ_ERROR(63, "图片大小超限,限100K。"), + NET_DVR_LOADPLAYERSDKFAILED(64, "载入当前目录下Player Sdk出错。"), + NET_DVR_LOADPLAYERSDKPROC_ERROR(65, "找不到Player Sdk中某个函数入口。"), + NET_DVR_LOADDSSDKFAILED(66, "载入当前目录下DSsdk出错。"), + NET_DVR_LOADDSSDKPROC_ERROR(67, "找不到DsSdk中某个函数入口。"), + NET_DVR_DSSDK_ERROR(68, "调用硬解码库DsSdk中某个函数失败。"), + NET_DVR_VOICEMONOPOLIZE(69, "声卡被独占。"), + NET_DVR_JOINMULTICASTFAILED(70, "加入多播组失败。"), + NET_DVR_CREATEDIR_ERROR(71, "建立日志文件目录失败。"), + NET_DVR_BINDSOCKET_ERROR(72, "绑定套接字失败。"), + NET_DVR_SOCKETCLOSE_ERROR(73, "socket连接中断,此错误通常是由于连接中断或目的地不可达。"), + NET_DVR_USERID_ISUSING(74, "注销时用户ID正在进行某操作。"), + NET_DVR_SOCKETLISTEN_ERROR(75, "监听失败。"), + NET_DVR_PROGRAM_EXCEPTION(76, "程序异常。"), + NET_DVR_WRITEFILE_FAILED(77, "写文件失败。"), + NET_DVR_FORMAT_READONLY(78, "禁止格式化只读硬盘。"), + NET_DVR_WITHSAMEUSERNAME(79, "用户配置结构中存在相同的用户名。"), + NET_DVR_DEVICETYPE_ERROR(80, "导入参数时设备型号不匹配。"), + NET_DVR_LANGUAGE_ERROR(81, "导入参数时语言不匹配。"), + NET_DVR_PARAVERSION_ERROR(82, "导入参数时软件版本不匹配。"), + NET_DVR_IPCHAN_NOTALIVE(83, "预览时外接IP通道不在线。"), + NET_DVR_RTSP_SDK_ERROR(84, "加载高清IPC通讯库StreamTransClient.dll失败。"), + NET_DVR_CONVERT_SDK_ERROR(85, "加载转码库失败。"), + NET_DVR_IPC_COUNT_OVERFLOW(86, "超出最大的ip接入通道数。"), + NET_PLAYM4_NOERROR(500, "no error。"), + NET_PLAYM4_PARA_OVER(501, "input parameter is invalid。"), + NET_PLAYM4_ORDER_ERROR(502, "The order of the function to be called is error."), + NET_PLAYM4_TIMER_ERROR(503, "Create multimedia clock failed;"), + NET_PLAYM4_DEC_VIDEO_ERROR(504, "Decode video data failed."), + NET_PLAYM4_DEC_AUDIO_ERROR(505, "Decode audio data failed."), + NET_PLAYM4_ALLOC_MEMORY_ERROR(506, "Allocate memory failed."), + NET_PLAYM4_OPEN_FILE_ERROR(507, "Open the file failed."), + NET_PLAYM4_CREATE_OBJ_ERROR(508, "Create thread or event failed"), + NET_PLAYM4_CREATE_DDRAW_ERROR(509, "Create DirectDraw object failed."), + NET_PLAYM4_CREATE_OFFSCREEN_ERROR(510, "failed when creating off-screen surface."), + NET_PLAYM4_BUF_OVER(511, "buffer is overflow"), + NET_PLAYM4_CREATE_SOUND_ERROR(512, "failed when creating audio device."), + NET_PLAYM4_SET_VOLUME_ERROR(513, "Set volume failed"), + NET_PLAYM4_SUPPORT_FILE_ONLY(514, "The function only support play file."), + NET_PLAYM4_SUPPORT_STREAM_ONLY(515, "The function only support play stream."), + NET_PLAYM4_SYS_NOT_SUPPORT(516, "System not support."), + NET_PLAYM4_FILEHEADER_UNKNOWN(517, "No file header."), + NET_PLAYM4_VERSION_INCORRECT(518, "The version of decoder and encoder is not adapted."), + NET_PALYM4_INIT_DECODER_ERROR(519, "Initialize decoder failed."), + NET_PLAYM4_CHECK_FILE_ERROR(520, "The file data is unknown."), + NET_PLAYM4_INIT_TIMER_ERROR(521, "Initialize multimedia clock failed."), + NET_PLAYM4_BLT_ERROR(522, "Blt failed."), + NET_PLAYM4_UPDATE_ERROR(523, "Update failed."), + NET_PLAYM4_OPEN_FILE_ERROR_MULTI(524, "openfile error, streamtypeis multi"), + NET_PLAYM4_OPEN_FILE_ERROR_VIDEO(525, "openfile error, streamtypeis video"), + NET_PLAYM4_JPEG_COMPRESS_ERROR(526, "JPEG compress error"), + NET_PLAYM4_EXTRACT_NOT_SUPPORT(527, "Don't support the version of this file."), + NET_PLAYM4_EXTRACT_DATA_ERROR(528, "extract video data failed."), + + UNKNOWN(-1, "未知错误"); // 用于处理未列出的错误码 + + private final int code; + private final String message; + + // 构造函数 + HCNetSDKErrorEnum(int code, String message) { + this.code = code; + this.message = message; + } + + // 获取错误码 + public int getCode() { + return code; + } + + // 获取错误描述 + public String getMessage() { + return message; + } + + // 根据错误码获取对应的枚举实例 + public static HCNetSDKErrorEnum getByCode(int code) { + for (HCNetSDKErrorEnum errorEnum : HCNetSDKErrorEnum.values()) { + if (errorEnum.getCode() == code) { + return errorEnum; + } + } + return UNKNOWN; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetThermometryAlarmType.java b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetThermometryAlarmType.java new file mode 100644 index 0000000..a1d7f5e --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetThermometryAlarmType.java @@ -0,0 +1,48 @@ +package com.mathvision.box.device.common.enums; + +import lombok.Getter; + +import java.util.Arrays; + +@Getter +public enum HCNetThermometryAlarmType { + HIGH(0, "最高温度"), + + LOW(1, "最低温度"), + + AVERAGE(2, "平均温度"), + + DIFFERENCE(3, "温差"), + + TEMPERATURE_RISE(4, "温度突升"), + + TEMPERATURE_DROP(5, "温度突降"); + + Integer code; + + String desc; + + DefectType type; + + HCNetThermometryAlarmType(Integer code, String desc) { + this.desc = desc; + this.code = code; + } + + public static HCNetThermometryAlarmType get(Integer code) { + return Arrays.stream(HCNetThermometryAlarmType.values()).filter(_t -> _t.getCode().equals(code)).findFirst().orElse(null); + } + + public DefectType getDefectType(Integer alarmLevel) { + if (alarmLevel == 1) { + return DefectType.COMM_THERMOMETRY_ALARM_1; + } else if (alarmLevel == 0) { + if (this == HCNetThermometryAlarmType.TEMPERATURE_DROP || this == HCNetThermometryAlarmType.TEMPERATURE_RISE) { + return DefectType.COMM_THERMOMETRY_ALARM_3; + } else { + return DefectType.COMM_THERMOMETRY_ALARM_0; + } + } + return DefectType.NULL; + } +} \ No newline at end of file diff --git a/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetThermometryUnit.java b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetThermometryUnit.java new file mode 100644 index 0000000..fb89628 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/common/enums/HCNetThermometryUnit.java @@ -0,0 +1,28 @@ +package com.mathvision.box.device.common.enums; + +import lombok.Getter; + +import java.util.Arrays; + +@Getter +public enum HCNetThermometryUnit { + //测温单位: 0-摄氏度(℃),1-华氏度(℉),2-开尔文(K) + Degree(0, "℃"), + + Fahrenheit(1, "℉"), + + Kelvin(2, "K"); + + Integer code; + + String desc; + + HCNetThermometryUnit(Integer code, String desc) { + this.desc = desc; + this.code = code; + } + + public static HCNetThermometryUnit get(Integer code) { + return Arrays.stream(HCNetThermometryUnit.values()).filter(_t -> _t.getCode().equals(code)).findFirst().orElse(null); + } +} \ No newline at end of file diff --git a/box-device/src/main/java/com/mathvision/box/device/config/BoxAlarmConfig.java b/box-device/src/main/java/com/mathvision/box/device/config/BoxAlarmConfig.java new file mode 100644 index 0000000..4a1f1ff --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/config/BoxAlarmConfig.java @@ -0,0 +1,33 @@ +package com.mathvision.box.device.config; + +import com.mathvision.box.device.common.enums.DetectType; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.Map; + +@Data +@Component +@ConfigurationProperties(prefix = "box.alarm") +public class BoxAlarmConfig { + private boolean fixProcess; + private boolean fixResult; + + private boolean filterEnabled; + private String filterType; + private Integer filterCountThreshold; + private Integer filterTimeThreshold; + + private boolean mockEnabled; + private Integer mockFixedRate; + + private Map types; + + + + public boolean isTypeEnabled(String type) { + DetectType detectType = DetectType.toDetectType(type); + return types != null && detectType != null && types.getOrDefault(detectType.getType(), false); + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/config/HCNetSDKConfig.java b/box-device/src/main/java/com/mathvision/box/device/config/HCNetSDKConfig.java new file mode 100644 index 0000000..ab626a7 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/config/HCNetSDKConfig.java @@ -0,0 +1,145 @@ +package com.mathvision.box.device.config; + +import com.mathvision.box.common.utils.common.OSUtils; +import com.mathvision.box.common.utils.file.FileUtils; +import com.mathvision.box.device.common.enums.HCNetSDKErrorEnum; +import com.mathvision.box.device.core.callback.FMSGCallBack_V31; +import com.mathvision.box.device.exception.HCNetSDKException; +import com.mathvision.box.device.sdk.HCNetSDK; +import com.mathvision.box.device.utils.SDKUtil; +import com.sun.jna.Native; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.io.File; + +@Configuration +@Slf4j +public class HCNetSDKConfig { + @Value("${box.hc.sdk.path}") + private String path; + @Value("${box.hc.sdk.connect-timeout:2000}") + private int connectTimeout; + @Value("${box.hc.sdk.retry-count:1}") + private int retryCount; + @Value("${box.hc.sdk.reconnect-interval:6000}") + private int reconnectInterval; + + /** + * 海康SDK核心Bean + */ + @Bean + @ConditionalOnProperty(name = "box.hc.sdk.enable", havingValue = "true") + public HCNetSDK hcNetSDK(FMSGCallBack_V31 fmsCallBack) throws HCNetSDKException { + // 1. SDK路径校验 + SDKUtil.validatePath(path); + + // 2. 动态库加载 + HCNetSDK sdk = loadNativeLibrary(path); + + // 3. SDK初始化 + initializeSdk(sdk); + + // 4. 配置网络参数 + configureNetwork(sdk, connectTimeout, retryCount); + + // 5. 配置重连策略 + setupReconnection(sdk, reconnectInterval); + + + /**加载日志*/ + sdk.NET_DVR_SetLogToFile(3, "../sdklog", false); + + // 6. 回调配置 + setupAlarmCallback(sdk, fmsCallBack); + configureAlarmDataSeparate(sdk); + + return sdk; + } + + + /** + * 加载本地库 + */ + private HCNetSDK loadNativeLibrary(String sdkPath) { + log.info("Loading HCNetSDK from: {}", sdkPath); + HCNetSDK sdk = (HCNetSDK) Native.loadLibrary(sdkPath, HCNetSDK.class); + if (!OSUtils.isWindows()) { + log.info("Linux环境加载海康sdk依赖"); + //设置HCNetSDKCom组件库所在路径 + String strPathCom = FileUtils.getParent(sdkPath); + HCNetSDK.NET_DVR_LOCAL_SDK_PATH struComPath = new HCNetSDK.NET_DVR_LOCAL_SDK_PATH(); + System.arraycopy(strPathCom.getBytes(), 0, struComPath.sPath, 0, strPathCom.length()); + struComPath.write(); + sdk.NET_DVR_SetSDKInitCfg(2, struComPath.getPointer()); + + //设置libcrypto.so所在路径 + HCNetSDK.BYTE_ARRAY ptrByteArrayCrypto = new HCNetSDK.BYTE_ARRAY(256); + String strPathCrypto = strPathCom + File.separator + "libcrypto.so.1.1"; + System.arraycopy(strPathCrypto.getBytes(), 0, ptrByteArrayCrypto.byValue, 0, strPathCrypto.length()); + ptrByteArrayCrypto.write(); + sdk.NET_DVR_SetSDKInitCfg(3, ptrByteArrayCrypto.getPointer()); + + //设置libssl.so所在路径 + HCNetSDK.BYTE_ARRAY ptrByteArraySsl = new HCNetSDK.BYTE_ARRAY(256); + String strPathSsl = strPathCom + File.separator + "libssl.so.1.1"; + System.arraycopy(strPathSsl.getBytes(), 0, ptrByteArraySsl.byValue, 0, strPathSsl.length()); + ptrByteArraySsl.write(); + sdk.NET_DVR_SetSDKInitCfg(4, ptrByteArraySsl.getPointer()); + } + return sdk; + } + + /** + * SDK初始化核心逻辑 + */ + private void initializeSdk(HCNetSDK sdk) throws HCNetSDKException { + if (!sdk.NET_DVR_Init()) { + int errorCode = sdk.NET_DVR_GetLastError(); + throw new HCNetSDKException("SDK初始化失败", errorCode); + } + log.info("HCNetSDK initialized successfully"); + } + + /** + * 网络参数配置 + */ + private void configureNetwork(HCNetSDK sdk, int timeout, int retries) { + sdk.NET_DVR_SetConnectTime(timeout, retries); + log.debug("Set connection timeout: {}ms, retries: {}", timeout, retries); + } + + /** + * 重连策略配置 + */ + private void setupReconnection(HCNetSDK sdk, int interval) { + sdk.NET_DVR_SetReconnect(interval, true); + log.debug("Enabled auto-reconnect with interval: {}ms", interval); + } + + /** + * 报警回调配置 + */ + private void setupAlarmCallback(HCNetSDK sdk, FMSGCallBack_V31 callback) { + if (!sdk.NET_DVR_SetDVRMessageCallBack_V31(callback, null)) { + int errorCode = sdk.NET_DVR_GetLastError(); + log.warn("Failed to setup alarm callback. Code: {}, Msg: {}", errorCode, HCNetSDKErrorEnum.getByCode(errorCode).getMessage()); + } else { + log.info("Alarm callback configured successfully"); + } + } + + /** + * 报警数据分离配置 + */ + private void configureAlarmDataSeparate(HCNetSDK sdk) { + HCNetSDK.NET_DVR_LOCAL_GENERAL_CFG config = new HCNetSDK.NET_DVR_LOCAL_GENERAL_CFG(); + config.byAlarmJsonPictureSeparate = 1; + config.write(); + sdk.NET_DVR_SetSDKLocalCfg(17, config.getPointer()); + log.debug("Enabled alarm data separation"); + } +} \ No newline at end of file diff --git a/box-device/src/main/java/com/mathvision/box/device/core/callback/FMSGCallBack_V31.java b/box-device/src/main/java/com/mathvision/box/device/core/callback/FMSGCallBack_V31.java new file mode 100644 index 0000000..36c7fcc --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/callback/FMSGCallBack_V31.java @@ -0,0 +1,29 @@ +package com.mathvision.box.device.core.callback; + +import com.mathvision.box.dao.domain.entity.Detect; +import com.mathvision.box.device.sdk.HCNetSDK; +import com.mathvision.box.device.service.BoxAlarmService; +import com.sun.jna.Pointer; +import org.apache.commons.compress.utils.Lists; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; + + +@Component +@ConditionalOnProperty(name = "box.hc.sdk.enable", havingValue = "true") +public class FMSGCallBack_V31 implements HCNetSDK.FMSGCallBack_V31 { + @Resource + private BoxAlarmService boxAlarmService; + + //报警信息回调函数 + public boolean invoke(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) { + Detect detect = HCNetSDKAlarmDataParse.alarmDataHandle(lCommand, pAlarmer, pAlarmInfo, dwBufLen, pUser); + List detectList = Lists.newArrayList(); + detectList.add(detect); + boxAlarmService.handle(detectList); + return true; + } +} \ No newline at end of file diff --git a/box-device/src/main/java/com/mathvision/box/device/core/callback/GetThermInfoCallback.java b/box-device/src/main/java/com/mathvision/box/device/core/callback/GetThermInfoCallback.java new file mode 100644 index 0000000..de23926 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/callback/GetThermInfoCallback.java @@ -0,0 +1,70 @@ +package com.mathvision.box.device.core.callback; + +import com.mathvision.box.device.sdk.HCNetSDK; +import com.sun.jna.Pointer; + +public class GetThermInfoCallback implements HCNetSDK.FRemoteConfigCallBack { + @Override + public void invoke(int dwType, Pointer pBuffer, int dwBufLen, Pointer pUserData) { + + System.out.println("return callback invoke"); + System.out.println("-----dwType:" + dwType + "---------dwBufLen:" + dwBufLen); + + + switch (dwType) { + case 0: //NET_SDK_CALLBACK_TYPE_STATUS + HCNetSDK.REMOTECONFIGSTATUS struCfgStatus = new HCNetSDK.REMOTECONFIGSTATUS(); + struCfgStatus.write(); + Pointer pCfgStatus = struCfgStatus.getPointer(); + pCfgStatus.write(0, pBuffer.getByteArray(0, struCfgStatus.size()), 0, struCfgStatus.size()); + struCfgStatus.read(); + + int iStatus = 0; + for (int i = 0; i < 4; i++) { + int ioffset = i * 8; + int iByte = struCfgStatus.byStatus[i] & 0xff; + iStatus = iStatus + (iByte << ioffset); + } + + switch (iStatus) { + case 1000:// NET_SDK_CALLBACK_STATUS_SUCCESS + System.out.println("实时测温回调成功,dwStatus:" + iStatus); + break; + case 1001: + System.out.println("正在获取实时测温回调数据中,dwStatus:" + iStatus); + break; + case 1002: + int iErrorCode = 0; + for (int i = 0; i < 4; i++) { + int ioffset = i * 8; + int iByte = struCfgStatus.byErrorCode[i] & 0xff; + iErrorCode = iErrorCode + (iByte << ioffset); + } + System.out.println("获取实时测温回调数据失败, dwStatus:" + iStatus + "错误号:" + iErrorCode); + break; + } + break; + case 2: //NET_SDK_CALLBACK_TYPE_DATA + HCNetSDK.NET_DVR_THERMOMETRY_UPLOAD m_struThermometryInfo = new HCNetSDK.NET_DVR_THERMOMETRY_UPLOAD(); + m_struThermometryInfo.write(); + Pointer pInfoV30 = m_struThermometryInfo.getPointer(); + pInfoV30.write(0, pBuffer.getByteArray(0, m_struThermometryInfo.size()), 0, m_struThermometryInfo.size()); + m_struThermometryInfo.read(); + + if (m_struThermometryInfo.byRuleCalibType == 0) { + System.out.println("点测温信息:" + m_struThermometryInfo.struPointThermCfg.fTemperature); + } + if (m_struThermometryInfo.byRuleCalibType == 1 || m_struThermometryInfo.byRuleCalibType == 2) { + System.out.println("框/线测温信息:fMaxTemperature__" + m_struThermometryInfo.struLinePolygonThermCfg.fMaxTemperature); + System.out.println(" fMinTemperature__" + m_struThermometryInfo.struLinePolygonThermCfg.fMinTemperature); + System.out.println(" fAverageTemperature__" + m_struThermometryInfo.struLinePolygonThermCfg.fAverageTemperature); + System.out.println(" fTemperatureDiff__" + m_struThermometryInfo.struLinePolygonThermCfg.fTemperatureDiff); + System.out.println(" fCenterPointTemperature__" + m_struThermometryInfo.fCenterPointTemperature); + } + break; + default: + break; + } + + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/callback/HCNetSDKAlarmDataParse.java b/box-device/src/main/java/com/mathvision/box/device/core/callback/HCNetSDKAlarmDataParse.java new file mode 100644 index 0000000..1330bfb --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/callback/HCNetSDKAlarmDataParse.java @@ -0,0 +1,1062 @@ +package com.mathvision.box.device.core.callback; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.mathvision.box.common.enums.DetectStatusEnum; +import com.mathvision.box.common.utils.common.BigDecimalUtil; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.file.FileUploadUtils; +import com.mathvision.box.common.utils.uuid.IdUtils; +import com.mathvision.box.dao.domain.entity.Detect; +import com.mathvision.box.device.common.enums.DetectType; +import com.mathvision.box.device.common.enums.HCNetEventEnum; +import com.mathvision.box.device.common.enums.HCNetThermometryAlarmType; +import com.mathvision.box.device.common.enums.HCNetThermometryUnit; +import com.mathvision.box.device.sdk.HCNetSDK; +import com.mathvision.box.device.utils.SDKUtil; +import com.sun.jna.Pointer; +import org.apache.commons.io.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.nio.ByteBuffer; + +public class HCNetSDKAlarmDataParse { + private static final Logger logger = LoggerFactory.getLogger(HCNetSDKAlarmDataParse.class); + private static final String profile = "alarm"; + private static final String jpg = ".jpg"; + private static final String json = ".json"; + private static final String xml = ".xml"; + + public static Detect alarmDataHandle(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) { + String eventMsg = HCNetEventEnum.getByCode(lCommand).getMessage(); + String sDeviceIp = new String(pAlarmer.sDeviceIP).trim(); + String sSerialNumber = new String(pAlarmer.sSerialNumber).trim(); + logger.error("事件信息:{},deviceIp:{};", eventMsg, sDeviceIp); + String sTime; + String MonitoringSiteID; + Detect detect = Detect.builder().detectId(IdUtils.fastSimpleUUID()).status(DetectStatusEnum.alert.getCode()).time(DateUtils.getNowDate()).ip(sDeviceIp).type(HCNetEventEnum.getByCode(lCommand).getMessage()).build(); + JSONArray imgJsonArray = new JSONArray(); + + //lCommand是传的报警类型 + switch (lCommand) { + case HCNetSDK.COMM_ITS_PLATE_RESULT://交通抓拍结果(新报警信息) + HCNetSDK.NET_ITS_PLATE_RESULT strItsPlateResult = new HCNetSDK.NET_ITS_PLATE_RESULT(); + strItsPlateResult.write(); + Pointer pItsPlateInfo = strItsPlateResult.getPointer(); + pItsPlateInfo.write(0, pAlarmInfo.getByteArray(0, strItsPlateResult.size()), 0, strItsPlateResult.size()); + strItsPlateResult.read(); + try { + String sLicense = new String(strItsPlateResult.struPlateInfo.sLicense, "GBK"); + byte VehicleType = strItsPlateResult.byVehicleType; //0-其他车辆,1-小型车,2-大型车,3- 行人触发,4- 二轮车触发,5- 三轮车触发,6- 机动车触发 + MonitoringSiteID = new String(strItsPlateResult.byMonitoringSiteID); + logger.error("车牌号:" + sLicense + ":车辆类型:" + VehicleType + ":布防点编号:" + MonitoringSiteID); + } catch (Exception e) { + logger.error("报警事件类型:" + Integer.toHexString(lCommand) + "错误信息:", e); + } + /** + * 报警图片保存,车牌,车辆图片 + */ + for (int i = 0; i < strItsPlateResult.dwPicNum; i++) { + if (strItsPlateResult.struPicInfo[i].dwDataLen > 0) { + saveFile(strItsPlateResult.struPicInfo[i].pBuffer.getByteBuffer(0, strItsPlateResult.struPicInfo[i].dwDataLen), + strItsPlateResult.struPicInfo[i].dwDataLen, + sDeviceIp, + strItsPlateResult.struPicInfo[i].byType + "_ItsPlate", + DateUtils.dateTimeNow(), + jpg); + } + } + break; + case HCNetSDK.COMM_ALARM_TFS: //道路违章取证报警 + HCNetSDK.NET_DVR_TFS_ALARM strTfsAlarm = new HCNetSDK.NET_DVR_TFS_ALARM(); + strTfsAlarm.write(); + Pointer pTfsAlarm = strTfsAlarm.getPointer(); + pTfsAlarm.write(0, pAlarmInfo.getByteArray(0, strTfsAlarm.size()), 0, strTfsAlarm.size()); + strTfsAlarm.read(); + sTime = SDKUtil.parseTime(strTfsAlarm.dwAbsTime); //报警绝对时间 + int IllegalType = strTfsAlarm.dwIllegalType; // 违章类型 + MonitoringSiteID = strTfsAlarm.byMonitoringSiteID.toString(); //布防点编号 + // 车牌信息 + try { + String PlateInfo = "车牌号:" + new String(strTfsAlarm.struPlateInfo.sLicense, "GBK"); + logger.error("【道路违章取证报警】时间:" + sTime + "违章类型:" + IllegalType + "车牌信息:" + PlateInfo); + } catch (Exception e) { + logger.error("报警事件类型:" + Integer.toHexString(lCommand) + "错误信息:", e); + } + //报警图片信息 + for (int i = 0; i < strTfsAlarm.dwPicNum; i++) { + if (strTfsAlarm.struPicInfo[i].dwDataLen > 0) { + saveFile(strTfsAlarm.struPicInfo[i].pBuffer.getByteBuffer(0, strTfsAlarm.struPicInfo[i].dwDataLen), + strTfsAlarm.struPicInfo[i].dwDataLen, + sDeviceIp, + strTfsAlarm.struPicInfo[i].byType + "_TfsPlate", + DateUtils.dateTimeNow(), + jpg); + } + } + break; + case HCNetSDK.COMM_ALARM_AID_V41: //道路事件检测 + HCNetSDK.NET_DVR_AID_ALARM_V41 strAIDAlarmV41 = new HCNetSDK.NET_DVR_AID_ALARM_V41(); + strAIDAlarmV41.write(); + Pointer pstrAIDAlarmV41 = strAIDAlarmV41.getPointer(); + pstrAIDAlarmV41.write(0, pAlarmInfo.getByteArray(0, strAIDAlarmV41.size()), 0, strAIDAlarmV41.size()); + strAIDAlarmV41.read(); + sTime = SDKUtil.parseTime(strAIDAlarmV41.dwAbsTime); //报警触发绝对时间 + MonitoringSiteID = strAIDAlarmV41.byMonitoringSiteID.toString(); //布防点编号 + int AIDType = strAIDAlarmV41.struAIDInfo.dwAIDType; // 交通事件类型 + int AIDTypeEx = strAIDAlarmV41.struAIDInfo.dwAIDTypeEx; //交通事件类型扩展 + logger.error("【道路事件检测】" + "时间:" + sTime + "布防点:" + MonitoringSiteID + "交通事件类型:" + AIDType + "交通事件类型扩展:" + AIDTypeEx); + //报警图片信息 + if (strAIDAlarmV41.dwPicDataLen > 0 && strAIDAlarmV41.pImage != null) { + saveFile(strAIDAlarmV41.pImage.getByteBuffer(0, strAIDAlarmV41.dwPicDataLen), + strAIDAlarmV41.dwPicDataLen, + sDeviceIp, + "AIDalarm", + DateUtils.dateTimeNow(), + jpg); + } + break; + case HCNetSDK.COMM_ALARM_TPS_V41://交通数据统计的报警 + HCNetSDK.NET_DVR_TPS_ALARM_V41 strTPSalarmV41 = new HCNetSDK.NET_DVR_TPS_ALARM_V41(); + strTPSalarmV41.write(); + Pointer pstrTPSalarmV41 = strTPSalarmV41.getPointer(); + pstrTPSalarmV41.write(0, pAlarmInfo.getByteArray(0, strTPSalarmV41.size()), 0, strTPSalarmV41.size()); + strTPSalarmV41.read(); + sTime = SDKUtil.parseTime(strTPSalarmV41.dwAbsTime); + MonitoringSiteID = strTPSalarmV41.byMonitoringSiteID.toString(); //布防点编号 + String StartTime = SDKUtil.parseTime(strTPSalarmV41.dwStartTime); //开始统计时间; + String StopTime = SDKUtil.parseTime(strTPSalarmV41.dwStopTime); //结束统计时间; + logger.error("【交通数据统计】" + "时间:" + sTime + "布防点编号:" + MonitoringSiteID + "开始统计时间:" + StartTime + "结束统计时间:" + StopTime); + //车道统计参数信息 + for (int i = 0; i <= HCNetSDK.MAX_TPS_RULE; i++) { + byte LaneNo = strTPSalarmV41.struTPSInfo.struLaneParam[i].byLaneNo; //车道号 + byte TrafficState = strTPSalarmV41.struTPSInfo.struLaneParam[i].byTrafficState; //车道状态 0-无效,1-畅通,2-拥挤,3-堵塞 + int TpsType = strTPSalarmV41.struTPSInfo.struLaneParam[i].dwTpsType; //数据变化类型标志,表示当前上传的统计参数中,哪些数据有效,按位区分 + int LaneVolume = strTPSalarmV41.struTPSInfo.struLaneParam[i].dwLaneVolume; //车道流量 + int LaneVelocity = strTPSalarmV41.struTPSInfo.struLaneParam[i].dwLaneVelocity; //车道平均速度 + float SpaceOccupyRation = strTPSalarmV41.struTPSInfo.struLaneParam[i].fSpaceOccupyRation; //车道占有率,百分比计算(空间上,车辆长度与布防路段总长度的比值) + logger.error("车道号:" + LaneNo + "车道状态:" + TrafficState + "车道流量:" + LaneVolume + "车道占有率:" + SpaceOccupyRation + "\n"); + } + break; + case HCNetSDK.COMM_ALARM_TPS_REAL_TIME: //实时过车数据数据 + HCNetSDK.NET_DVR_TPS_REAL_TIME_INFO netDvrTpsParam = new HCNetSDK.NET_DVR_TPS_REAL_TIME_INFO(); + netDvrTpsParam.write(); + Pointer pItsParkVehicle = netDvrTpsParam.getPointer(); + pItsParkVehicle.write(0, pAlarmInfo.getByteArray(0, netDvrTpsParam.size()), 0, netDvrTpsParam.size()); + netDvrTpsParam.read(); + String struTime = "" + String.format("%04d", netDvrTpsParam.struTime.wYear) + + String.format("%02d", netDvrTpsParam.struTime.byMonth) + + String.format("%02d", netDvrTpsParam.struTime.byDay) + + String.format("%02d", netDvrTpsParam.struTime.byDay) + + String.format("%02d", netDvrTpsParam.struTime.byHour) + + String.format("%02d", netDvrTpsParam.struTime.byMinute) + + String.format("%02d", netDvrTpsParam.struTime.bySecond); + Short wDeviceID = new Short(netDvrTpsParam.struTPSRealTimeInfo.wDeviceID);//设备ID + int channel = netDvrTpsParam.dwChan; //触发报警通道号 + String byLane = new String(String.valueOf(netDvrTpsParam.struTPSRealTimeInfo.byLane)).trim();// 对应车道号 + String bySpeed = new String(String.valueOf(netDvrTpsParam.struTPSRealTimeInfo.bySpeed)).trim();// 对应车速(KM/H) + int dwDownwardFlow = netDvrTpsParam.struTPSRealTimeInfo.dwDownwardFlow;//当前车道 从上到下车流量 + int dwUpwardFlow = netDvrTpsParam.struTPSRealTimeInfo.dwUpwardFlow; //当前车道 从下到上车流量 + logger.error("通道号:" + channel + "; 时间:" + struTime + ";对应车道号:" + byLane + ";当前车道 从上到下车流量:" + dwDownwardFlow + ";dwUpwardFlow:" + dwUpwardFlow); + break; + + case HCNetSDK.COMM_ALARM_TPS_STATISTICS: //统计过车数据 + HCNetSDK.NET_DVR_TPS_STATISTICS_INFO netDvrTpsStatisticsInfo = new HCNetSDK.NET_DVR_TPS_STATISTICS_INFO(); + netDvrTpsStatisticsInfo.write(); + Pointer pTpsVehicle = netDvrTpsStatisticsInfo.getPointer(); + pTpsVehicle.write(0, pAlarmInfo.getByteArray(0, netDvrTpsStatisticsInfo.size()), 0, netDvrTpsStatisticsInfo.size()); + netDvrTpsStatisticsInfo.read(); + int Tpschannel = netDvrTpsStatisticsInfo.dwChan; //触发报警通道号 + //统计开始时间 + String struStartTime = "" + String.format("%04d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.wYear) + + String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byMonth) + + String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byDay) + + String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byDay) + + String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byHour) + + String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.byMinute) + + String.format("%02d", netDvrTpsStatisticsInfo.struTPSStatisticsInfo.struStartTime.bySecond); + byte TotalLaneNum = netDvrTpsStatisticsInfo.struTPSStatisticsInfo.byTotalLaneNum; //有效车道总数 + logger.error("通道号:" + Tpschannel + "; 开始统计时间:" + struStartTime + "有效车道总数:" + TotalLaneNum); + break; + case HCNetSDK.COMM_ITS_PARK_VEHICLE: //停车场数据上传 + HCNetSDK.NET_ITS_PARK_VEHICLE strParkVehicle = new HCNetSDK.NET_ITS_PARK_VEHICLE(); + strParkVehicle.write(); + Pointer pstrParkVehicle = strParkVehicle.getPointer(); + pstrParkVehicle.write(0, pAlarmInfo.getByteArray(0, strParkVehicle.size()), 0, strParkVehicle.size()); + strParkVehicle.read(); + try { + byte ParkError = strParkVehicle.byParkError; //停车异常:0- 正常,1- 异常 + String ParkingNo = new String(strParkVehicle.byParkingNo, "UTF-8"); //车位编号 + byte LocationStatus = strParkVehicle.byLocationStatus; //车位车辆状态 0- 无车,1- 有车 + MonitoringSiteID = strParkVehicle.byMonitoringSiteID.toString(); + String plateNo = new String(strParkVehicle.struPlateInfo.sLicense, "GBK"); //车牌号 + } catch (Exception e) { + logger.error("报警事件类型:" + Integer.toHexString(lCommand) + "错误信息:", e); + } + //报警图片信息 + for (int i = 0; i < strParkVehicle.dwPicNum; i++) { + if (strParkVehicle.struPicInfo[i].dwDataLen > 0) { + saveFile(strParkVehicle.struPicInfo[i].pBuffer.getByteBuffer(0, strParkVehicle.struPicInfo[i].dwDataLen), + strParkVehicle.struPicInfo[i].dwDataLen, + sDeviceIp, + "ParkVehicle", + DateUtils.dateTimeNow(), + jpg); + } + } + break; + case HCNetSDK.COMM_ALARMHOST_CID_ALARM://报警主机CID报告报警上传 + HCNetSDK.NET_DVR_CID_ALARM strCIDalarm = new HCNetSDK.NET_DVR_CID_ALARM(); + strCIDalarm.write(); + Pointer pstrCIDalarm = strCIDalarm.getPointer(); + pstrCIDalarm.write(0, pAlarmInfo.getByteArray(0, strCIDalarm.size()), 0, strCIDalarm.size()); + strCIDalarm.read(); + try { + String TriggerTime = "" + String.format("%04d", strCIDalarm.struTriggerTime.wYear) + + String.format("%02d", strCIDalarm.struTriggerTime.byMonth) + + String.format("%02d", strCIDalarm.struTriggerTime.byDay) + + String.format("%02d", strCIDalarm.struTriggerTime.byDay) + + String.format("%02d", strCIDalarm.struTriggerTime.byHour) + + String.format("%02d", strCIDalarm.struTriggerTime.byMinute) + + String.format("%02d", strCIDalarm.struTriggerTime.bySecond); //触发报警时间 + String sCIDCode = new String(strCIDalarm.sCIDCode, "GBK"); //CID事件号 + String sCIDDescribe = new String(strCIDalarm.sCIDDescribe, "GBK"); //CID事件名 + byte bySubSysNo = strCIDalarm.bySubSysNo; //子系统号 + if (strCIDalarm.wDefenceNo != 0xff) { + logger.error("防区号:" + Integer.sum(strCIDalarm.wDefenceNo, 1)); + } + logger.error("【CID事件】" + "触发时间:" + TriggerTime + "CID事件号:" + sCIDCode + "CID事件名:" + sCIDDescribe + "子系统号:" + + bySubSysNo); + } catch (Exception e) { + logger.error("报警事件类型:" + Integer.toHexString(lCommand) + "错误信息:", e); + } + break; + case HCNetSDK.COMM_IPC_AUXALARM_RESULT: //PIR报警、无线报警、呼救报警信息 + logger.error("PIR报警、无线报警、呼救报警触发"); + break; + case HCNetSDK.COMM_ISAPI_ALARM: //ISAPI协议报警信息 + HCNetSDK.NET_DVR_ALARM_ISAPI_INFO struEventISAPI = new HCNetSDK.NET_DVR_ALARM_ISAPI_INFO(); + struEventISAPI.write(); + Pointer pEventISAPI = struEventISAPI.getPointer(); + pEventISAPI.write(0, pAlarmInfo.getByteArray(0, struEventISAPI.size()), 0, struEventISAPI.size()); + struEventISAPI.read(); + String sAlarmInfo = new String(pAlarmer.sDeviceIP).trim(); + //报警数据类型:0- invalid,1- xml,2- json + sAlarmInfo = "报警设备IP:" + sAlarmInfo + ":ISAPI协议报警信息, 数据格式:" + struEventISAPI.byDataType + + ", 图片个数:" + struEventISAPI.byPicturesNumber; + logger.error(sAlarmInfo); + + //报警数据打印 + HCNetSDK.BYTE_ARRAY m_strISAPIData = new HCNetSDK.BYTE_ARRAY(struEventISAPI.dwAlarmDataLen); + m_strISAPIData.write(); + Pointer pPlateInfo = m_strISAPIData.getPointer(); + pPlateInfo.write(0, struEventISAPI.pAlarmData.getByteArray(0, m_strISAPIData.size()), 0, m_strISAPIData.size()); + m_strISAPIData.read(); + logger.error(new String(m_strISAPIData.byValue).trim() + "\n"); +/* + FileOutputStream foutdata; + try { + String jsonfilename = AppConfig.getAlarmPath() + DateUtils.datePath()+"/" + new String(pAlarmer.sDeviceIP).trim() + curTime1 + "_ISAPI_Alarm_" + ".json"; + foutdata = new FileOutputStream(jsonfilename); + //将字节写入文件 + ByteBuffer jsonbuffers = struEventISAPI.pAlarmData.getByteBuffer(0, struEventISAPI.dwAlarmDataLen); + byte[] jsonbytes = new byte[struEventISAPI.dwAlarmDataLen]; + jsonbuffers.rewind(); + jsonbuffers.get(jsonbytes); + foutdata.write(jsonbytes); + foutdata.close(); + } catch (Exception e) { + logger.error("报警事件类型:" + Integer.toHexString(lCommand) + "错误信息:", e); + }*/ + //图片数据保存 + for (int i = 0; i < struEventISAPI.byPicturesNumber; i++) { + HCNetSDK.NET_DVR_ALARM_ISAPI_PICDATA struPicData = new HCNetSDK.NET_DVR_ALARM_ISAPI_PICDATA(); + struPicData.write(); + Pointer pPicData = struPicData.getPointer(); + pPicData.write(0, struEventISAPI.pPicPackData.getByteArray(i * struPicData.size(), struPicData.size()), 0, struPicData.size()); + struPicData.read(); + saveFile(struPicData.pPicData.getByteBuffer(0, struPicData.dwPicLen), + struPicData.dwPicLen, + sDeviceIp, + "ISAPIPic_" + i + "_" + new String(struPicData.szFilename).trim(), + DateUtils.dateTimeNow(), + jpg); + } + break; + case HCNetSDK.COMM_VCA_ALARM: // 智能检测通用报警(Json或者XML数据结构) + sAlarmInfo = new String(pAlarmer.sDeviceIP); + //报警数据类型:0- invalid,1- xml,2- json + sAlarmInfo = "报警设备IP:" + sAlarmInfo; + logger.error(sAlarmInfo); + saveFile(pAlarmInfo.getByteBuffer(0, dwBufLen), + dwBufLen, + sDeviceIp, + "VCA_ALARM", + DateUtils.dateTimeNow(), + json); + break; + + //异常行为检测信息 + case HCNetSDK.COMM_ALARM_RULE: + HCNetSDK.NET_VCA_RULE_ALARM strVcaAlarm = new HCNetSDK.NET_VCA_RULE_ALARM(); + strVcaAlarm.write(); + Pointer pVCAInfo = strVcaAlarm.getPointer(); + pVCAInfo.write(0, pAlarmInfo.getByteArray(0, strVcaAlarm.size()), 0, strVcaAlarm.size()); + strVcaAlarm.read(); + + switch (strVcaAlarm.struRuleInfo.wEventTypeEx) { + case 1: //穿越警戒面 (越界侦测) + logger.error("越界侦测报警发生"); + strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_TRAVERSE_PLANE.class); + logger.error("检测目标:" + strVcaAlarm.struRuleInfo.uEventParam.struTraversePlane.byDetectionTarget); //检测目标,0表示所有目标(表示不锁定检测目标,所有目标都将进行检测),其他取值按位表示不同的检测目标:0x01-人,0x02-车 + //图片保存 + if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { + saveFile(strVcaAlarm.pImage.getByteBuffer(0, strVcaAlarm.dwPicDataLen), + strVcaAlarm.dwPicDataLen, + sDeviceIp, + "VCA_TRAVERSE_PLANE", + DateUtils.dateTimeNow(), + jpg); + } + break; + case 2: //目标进入区域 + logger.error("目标进入区域报警发生"); + strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class); + logger.error("检测目标:" + strVcaAlarm.struRuleInfo.uEventParam.struArea.byDetectionTarget); + //图片保存 + if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { + saveFile(strVcaAlarm.pImage.getByteBuffer(0, strVcaAlarm.dwPicDataLen), + strVcaAlarm.dwPicDataLen, + sDeviceIp, + "TargetEnter", + DateUtils.dateTimeNow(), + jpg); + } + break; + case 3: //目标离开区域 + logger.error("目标离开区域报警触发"); + strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_AREA.class); + logger.error("检测目标:" + strVcaAlarm.struRuleInfo.uEventParam.struArea.byDetectionTarget); + //图片保存 + if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { + saveFile(strVcaAlarm.pImage.getByteBuffer(0, strVcaAlarm.dwPicDataLen), + strVcaAlarm.dwPicDataLen, + sDeviceIp, + "TargetLeave", + DateUtils.dateTimeNow(), + jpg); + } + break; + case 4: //周界入侵 + logger.error("周界入侵报警发生"); + strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_INTRUSION.class); + logger.error("检测目标:" + strVcaAlarm.struRuleInfo.uEventParam.struIntrusion.byDetectionTarget); + //图片保存 + if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { + saveFile(strVcaAlarm.pImage.getByteBuffer(0, strVcaAlarm.dwPicDataLen), + strVcaAlarm.dwPicDataLen, + sDeviceIp, + "VCA_INTRUSION", + DateUtils.dateTimeNow(), + jpg); + } + break; + case 5: //徘徊 + logger.error("徘徊事件触发"); + + break; + case 8: //快速移动(奔跑), + logger.error("快速移动(奔跑)事件触发"); + break; + case 15: + logger.error("事件触发"); + strVcaAlarm.struRuleInfo.uEventParam.setType(HCNetSDK.NET_VCA_LEAVE_POSITION.class); + logger.error(String.valueOf(strVcaAlarm.struRuleInfo.uEventParam.struLeavePos.byOnPosition)); + //图片保存 + if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { + saveFile(strVcaAlarm.pImage.getByteBuffer(0, strVcaAlarm.dwPicDataLen), + strVcaAlarm.dwPicDataLen, + sDeviceIp, + "VCA_LEAVE_POSITION_", + DateUtils.dateTimeNow(), + jpg); + } + case 20: //倒地检测 + logger.error("倒地事件触发"); + break; + case 44: //玩手机 + logger.error("玩手机报警发生"); + //图片保存 + if ((strVcaAlarm.dwPicDataLen > 0) && (strVcaAlarm.byPicTransType == 0)) { + saveFile(strVcaAlarm.pImage.getByteBuffer(0, strVcaAlarm.dwPicDataLen), + strVcaAlarm.dwPicDataLen, + sDeviceIp, + "PLAY_CELLPHONE", + DateUtils.dateTimeNow(), + jpg); + } + break; + case 45: //持续检测 + logger.error("持续检测事件触发"); + default: + logger.error("行为事件类型:" + strVcaAlarm.struRuleInfo.wEventTypeEx); + break; + } + break; + case HCNetSDK.COMM_ALARM_ACS: //门禁主机报警信息 + HCNetSDK.NET_DVR_ACS_ALARM_INFO strACSInfo = new HCNetSDK.NET_DVR_ACS_ALARM_INFO(); + strACSInfo.write(); + Pointer pACSInfo = strACSInfo.getPointer(); + pACSInfo.write(0, pAlarmInfo.getByteArray(0, strACSInfo.size()), 0, strACSInfo.size()); + strACSInfo.read(); + /**门禁事件的详细信息解析,通过主次类型的可以判断当前的具体门禁类型,例如(主类型:0X5 次类型:0x4b 表示人脸认证通过, + 主类型:0X5 次类型:0x4c 表示人脸认证失败)*/ + logger.error("【门禁主机报警信息】卡号:" + new String(strACSInfo.struAcsEventInfo.byCardNo).trim() + ",卡类型:" + + strACSInfo.struAcsEventInfo.byCardType + ",报警主类型:" + Integer.toHexString(strACSInfo.dwMajor) + ",报警次类型:" + Integer.toHexString(strACSInfo.dwMinor)); + logger.error("工号1:" + strACSInfo.struAcsEventInfo.dwEmployeeNo); + //温度信息(如果设备支持测温功能,人脸温度信息从NET_DVR_ACS_EVENT_INFO_EXTEND_V20结构体获取) + if (strACSInfo.byAcsEventInfoExtendV20 == 1) { + HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND_V20 strAcsInfoExV20 = new HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND_V20(); + strAcsInfoExV20.write(); + Pointer pAcsInfoExV20 = strAcsInfoExV20.getPointer(); + pAcsInfoExV20.write(0, strACSInfo.pAcsEventInfoExtendV20.getByteArray(0, strAcsInfoExV20.size()), 0, strAcsInfoExV20.size()); + strAcsInfoExV20.read(); + logger.error("实时温度值:" + strAcsInfoExV20.fCurrTemperature); + } + //考勤状态 + if (strACSInfo.byAcsEventInfoExtend == 1) { + HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND strAcsInfoEx = new HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND(); + strAcsInfoEx.write(); + Pointer pAcsInfoEx = strAcsInfoEx.getPointer(); + pAcsInfoEx.write(0, strACSInfo.pAcsEventInfoExtend.getByteArray(0, strAcsInfoEx.size()), 0, strAcsInfoEx.size()); + strAcsInfoEx.read(); + logger.error("考勤状态:" + strAcsInfoEx.byAttendanceStatus); + logger.error("工号2:" + new String(strAcsInfoEx.byEmployeeNo).trim()); + } + + /** + * 报警时间 + */ + String year = Integer.toString(strACSInfo.struTime.dwYear); + String SwipeTime = year + strACSInfo.struTime.dwMonth + strACSInfo.struTime.dwDay + strACSInfo.struTime.dwHour + strACSInfo.struTime.dwMinute + + strACSInfo.struTime.dwSecond; + if (strACSInfo.dwPicDataLen > 0) { + saveFile(strACSInfo.pPicData.getByteBuffer(0, strACSInfo.dwPicDataLen), + strACSInfo.dwPicDataLen, + sDeviceIp, + "ACS_Event_" + new String(strACSInfo.struAcsEventInfo.byCardNo).trim(), + DateUtils.dateTimeNow(), + jpg); + } + break; + + case HCNetSDK.COMM_ID_INFO_ALARM: //身份证信息 + HCNetSDK.NET_DVR_ID_CARD_INFO_ALARM strIDCardInfo = new HCNetSDK.NET_DVR_ID_CARD_INFO_ALARM(); + strIDCardInfo.write(); + Pointer pIDCardInfo = strIDCardInfo.getPointer(); + pIDCardInfo.write(0, pAlarmInfo.getByteArray(0, strIDCardInfo.size()), 0, strIDCardInfo.size()); + strIDCardInfo.read(); + logger.error("报警主类型:" + Integer.toHexString(strIDCardInfo.dwMajor) + ",报警次类型:" + Integer.toHexString(strIDCardInfo.dwMinor)); + /** + * 身份证信息 + */ + String IDnum = new String(strIDCardInfo.struIDCardCfg.byIDNum).trim(); + logger.error("【身份证信息】:身份证号码:" + IDnum + ",姓名:" + + new String(strIDCardInfo.struIDCardCfg.byName).trim() + ",住址:" + new String(strIDCardInfo.struIDCardCfg.byAddr)); + + /** + * 报警时间 + */ + String year1 = Integer.toString(strIDCardInfo.struSwipeTime.wYear); + String SwipeTime1 = year1 + strIDCardInfo.struSwipeTime.byMonth + strIDCardInfo.struSwipeTime.byDay + strIDCardInfo.struSwipeTime.byHour + strIDCardInfo.struSwipeTime.byMinute + + strIDCardInfo.struSwipeTime.bySecond; + /** + * 保存图片 + */ + //身份证图片 + if (strIDCardInfo.dwPicDataLen > 0 || strIDCardInfo.pPicData != null) { + saveFile(strIDCardInfo.pPicData.getByteBuffer(0, strIDCardInfo.dwPicDataLen), + strIDCardInfo.dwPicDataLen, + sDeviceIp, + IDnum, + SwipeTime1, + jpg); + } + + if (strIDCardInfo.dwCapturePicDataLen > 0 || strIDCardInfo.pCapturePicData != null) { + saveFile(strIDCardInfo.pPicData.getByteBuffer(0, strIDCardInfo.dwPicDataLen), + strIDCardInfo.dwPicDataLen, + sDeviceIp, + "CapturePic", + SwipeTime1, + jpg); + } + break; + + case HCNetSDK.COMM_ALARM_VIDEO_INTERCOM: //可视对讲报警信息 + logger.error("可视对讲报警触发"); + HCNetSDK.NET_DVR_VIDEO_INTERCOM_ALARM strVideoIntercomAlarm = new HCNetSDK.NET_DVR_VIDEO_INTERCOM_ALARM(); + strVideoIntercomAlarm.write(); + Pointer pVideoIntercomAlarm = strVideoIntercomAlarm.getPointer(); + pVideoIntercomAlarm.write(0, pAlarmInfo.getByteArray(0, strVideoIntercomAlarm.size()), 0, strVideoIntercomAlarm.size()); + strVideoIntercomAlarm.read(); + logger.error("byAlarmType:" + strVideoIntercomAlarm.byAlarmType); + + if (strVideoIntercomAlarm.byAlarmType == 1) { + strVideoIntercomAlarm.uAlarmInfo.setType(HCNetSDK.NET_DVR_VIDEO_INTERCOM_ALARM_INFO_UNION.class); + strVideoIntercomAlarm.uAlarmInfo.read(); + logger.error("byZoneType :" + strVideoIntercomAlarm.uAlarmInfo.struZoneAlarm.byZoneType); + } + + break; + case HCNetSDK.COMM_UPLOAD_VIDEO_INTERCOM_EVENT: //可视对讲事件记录信息 + logger.error("可视对讲事件记录报警触发"); + HCNetSDK.NET_DVR_VIDEO_INTERCOM_EVENT strVideoIntercomEvent = new HCNetSDK.NET_DVR_VIDEO_INTERCOM_EVENT(); + strVideoIntercomEvent.write(); + Pointer pVideoIntercomEvent = strVideoIntercomEvent.getPointer(); + pVideoIntercomEvent.write(0, pAlarmInfo.getByteArray(0, strVideoIntercomEvent.size()), 0, strVideoIntercomEvent.size()); + strVideoIntercomEvent.read(); + logger.error("byEventType:" + strVideoIntercomEvent.byEventType); + + if (strVideoIntercomEvent.byEventType == 1) { + strVideoIntercomEvent.uEventInfo.setType(HCNetSDK.NET_DVR_UNLOCK_RECORD_INFO.class); + strVideoIntercomEvent.uEventInfo.read(); + logger.error("byUnlockType:" + strVideoIntercomEvent.uEventInfo.struUnlockRecord.byUnlockType + + ",byControlSrc:" + new String(strVideoIntercomEvent.uEventInfo.struUnlockRecord.byControlSrc).trim()); + } + break; + case HCNetSDK.COMM_UPLOAD_FACESNAP_RESULT: //实时特征抓拍上传 + logger.error("UPLOAD_FACESNAP_Alarm"); + HCNetSDK.NET_VCA_FACESNAP_RESULT strFaceSnapInfo = new HCNetSDK.NET_VCA_FACESNAP_RESULT(); + strFaceSnapInfo.write(); + Pointer pFaceSnapInfo = strFaceSnapInfo.getPointer(); + pFaceSnapInfo.write(0, pAlarmInfo.getByteArray(0, strFaceSnapInfo.size()), 0, strFaceSnapInfo.size()); + strFaceSnapInfo.read(); + + //事件时间 + int dwYear = (strFaceSnapInfo.dwAbsTime >> 26) + 2000; + int dwMonth = (strFaceSnapInfo.dwAbsTime >> 22) & 15; + int dwDay = (strFaceSnapInfo.dwAbsTime >> 17) & 31; + int dwHour = (strFaceSnapInfo.dwAbsTime >> 12) & 31; + int dwMinute = (strFaceSnapInfo.dwAbsTime >> 6) & 63; + int dwSecond = (strFaceSnapInfo.dwAbsTime >> 0) & 63; + + String strAbsTime = "" + String.format("%04d", dwYear) + + String.format("%02d", dwMonth) + + String.format("%02d", dwDay) + + String.format("%02d", dwHour) + + String.format("%02d", dwMinute) + + String.format("%02d", dwSecond); + + //人脸属性信息 + String sFaceAlarmInfo = "Abs时间:" + strAbsTime + ",是否戴口罩:" + + strFaceSnapInfo.struFeature.byMask + ",是否微笑:" + strFaceSnapInfo.struFeature.bySmile; + logger.error("人脸信息:" + sFaceAlarmInfo); + + //人脸测温信息 + if (strFaceSnapInfo.byAddInfo == 1) { + HCNetSDK.NET_VCA_FACESNAP_ADDINFO strAddInfo = new HCNetSDK.NET_VCA_FACESNAP_ADDINFO(); + strAddInfo.write(); + Pointer pAddInfo = strAddInfo.getPointer(); + pAddInfo.write(0, strFaceSnapInfo.pAddInfoBuffer.getByteArray(0, strAddInfo.size()), 0, strAddInfo.size()); + strAddInfo.read(); + + String sTemperatureInfo = "测温是否开启:" + strAddInfo.byFaceSnapThermometryEnabled + "人脸温度:" + strAddInfo.fFaceTemperature + "温度是否异常" + + strAddInfo.byIsAbnomalTemperature + "报警温度阈值:" + strAddInfo.fAlarmTemperature; + logger.error("人脸温度信息:" + sTemperatureInfo); + + } + saveFile(strFaceSnapInfo.pBuffer1.getByteArray(0, strFaceSnapInfo.dwFacePicLen), + strFaceSnapInfo.dwFacePicLen, + sDeviceIp, + "small", + DateUtils.dateTimeNow(), + jpg); + saveFile(strFaceSnapInfo.pBuffer2.getByteArray(0, strFaceSnapInfo.dwBackgroundPicLen), + strFaceSnapInfo.dwBackgroundPicLen, + sDeviceIp, + "big", + DateUtils.dateTimeNow(), + jpg); + break; + + case HCNetSDK.COMM_SNAP_MATCH_ALARM: //人脸比对报警 + HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM strFaceSnapMatch = new HCNetSDK.NET_VCA_FACESNAP_MATCH_ALARM(); + strFaceSnapMatch.write(); + Pointer pFaceSnapMatch = strFaceSnapMatch.getPointer(); + pFaceSnapMatch.write(0, pAlarmInfo.getByteArray(0, strFaceSnapMatch.size()), 0, strFaceSnapMatch.size()); + strFaceSnapMatch.read(); + //比对结果,0-保留,1-比对成功,2-比对失败 + String sFaceSnapMatchInfo = "比对结果:" + strFaceSnapMatch.byContrastStatus + ",相似度:" + strFaceSnapMatch.fSimilarity; + logger.error(sFaceSnapMatchInfo); + if (strFaceSnapMatch.struBlockListInfo.dwFDIDLen > 0) { + long offset1 = 0; + ByteBuffer buffers1 = strFaceSnapMatch.struBlockListInfo.pFDID.getByteBuffer(offset1, strFaceSnapMatch.struBlockListInfo.dwFDIDLen); + byte[] bytes1 = new byte[strFaceSnapMatch.struBlockListInfo.dwFDIDLen]; + buffers1.get(bytes1); + logger.error("人脸库ID:" + new String(bytes1)); + } + if (strFaceSnapMatch.struBlockListInfo.dwPIDLen > 0) { + long offset2 = 0; + ByteBuffer buffers2 = strFaceSnapMatch.struBlockListInfo.pPID.getByteBuffer(offset2, strFaceSnapMatch.struBlockListInfo.dwPIDLen); + byte[] bytes2 = new byte[strFaceSnapMatch.struBlockListInfo.dwPIDLen]; + buffers2.get(bytes2); + logger.error("图片ID:" + new String(bytes2)); + } + if (strFaceSnapMatch.struBlockListInfo.struBlockListInfo.dwFCAdditionInfoLen > 0) { + //抓拍库附加信息解析(解析人脸测温温度,人脸温度存放在附件信息的XML报文中,节点: ) + saveFile(strFaceSnapMatch.struBlockListInfo.struBlockListInfo.pFCAdditionInfoBuffer.getByteBuffer(0, strFaceSnapMatch.struBlockListInfo.struBlockListInfo.dwFCAdditionInfoLen), + strFaceSnapMatch.struBlockListInfo.struBlockListInfo.dwFCAdditionInfoLen, + sDeviceIp, + "FCAdditionInfo", + DateUtils.dateTimeNow(), + xml); + } + //人脸比对报警图片保存,图片格式二进制 + if ((strFaceSnapMatch.dwSnapPicLen > 0) && (strFaceSnapMatch.byPicTransType == 0)) { + saveFile(strFaceSnapMatch.pSnapPicBuffer.getByteBuffer(0, strFaceSnapMatch.dwSnapPicLen), + strFaceSnapMatch.dwSnapPicLen, + sDeviceIp, + "pSnapPicBuffer", + DateUtils.dateTimeNow(), + jpg); + } + if ((strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen > 0) && (strFaceSnapMatch.byPicTransType == 0)) { + saveFile(strFaceSnapMatch.struSnapInfo.pBuffer1.getByteBuffer(0, strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen), + strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen, + sDeviceIp, + "struSnapInfo_pBuffer1", + DateUtils.dateTimeNow(), + jpg); + } + if ((strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen > 0) && (strFaceSnapMatch.byPicTransType == 0)) { + saveFile(strFaceSnapMatch.struBlockListInfo.pBuffer1.getByteBuffer(0, strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen), + strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen, + sDeviceIp, + "fSimilarity_" + strFaceSnapMatch.fSimilarity + "_struBlackListInfo_pBuffer1", + DateUtils.dateTimeNow(), + jpg); + } + //人脸比对报警图片保存,图片格式URL格式 + if ((strFaceSnapMatch.dwSnapPicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) { + long offset = 0; + ByteBuffer buffers = strFaceSnapMatch.pSnapPicBuffer.getByteBuffer(offset, strFaceSnapMatch.dwSnapPicLen); + byte[] bytes = new byte[strFaceSnapMatch.dwSnapPicLen]; + buffers.rewind(); + buffers.get(bytes); + String SnapPicUrl = new String(bytes); + logger.error("抓拍图URL:" + SnapPicUrl); + } + if ((strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) { + + long offset = 0; + ByteBuffer buffers = strFaceSnapMatch.struSnapInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen); + byte[] bytes = new byte[strFaceSnapMatch.struSnapInfo.dwSnapFacePicLen]; + buffers.rewind(); + buffers.get(bytes); + String SnapPicUrl = new String(bytes); + logger.error("抓拍人脸子图URL:" + SnapPicUrl); + } + if ((strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen > 0) && (strFaceSnapMatch.byPicTransType == 1)) { + + long offset = 0; + ByteBuffer buffers = strFaceSnapMatch.struBlockListInfo.pBuffer1.getByteBuffer(offset, strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen); + byte[] bytes = new byte[strFaceSnapMatch.struBlockListInfo.dwBlockListPicLen]; + buffers.rewind(); + buffers.get(bytes); + String SnapPicUrl = new String(bytes); + logger.error("人脸库人脸图的URL:" + SnapPicUrl); + } + + + break; + // 客流量报警信息 + case HCNetSDK.COMM_ALARM_PDC: + HCNetSDK.NET_DVR_PDC_ALRAM_INFO strPDCResult = new HCNetSDK.NET_DVR_PDC_ALRAM_INFO(); + strPDCResult.write(); + Pointer pPDCInfo = strPDCResult.getPointer(); + pPDCInfo.write(0, pAlarmInfo.getByteArray(0, strPDCResult.size()), 0, strPDCResult.size()); + strPDCResult.read(); + // byMode=0-实时统计结果(联合体中struStatFrame有效), + if (strPDCResult.byMode == 0) { + strPDCResult.uStatModeParam.setType(HCNetSDK.NET_DVR_STATFRAME.class); + String sAlarmPDC0Info = "实时客流量统计,进入人数:" + strPDCResult.dwEnterNum + ",离开人数:" + strPDCResult.dwLeaveNum + + ", byMode:" + strPDCResult.byMode + ", dwRelativeTime:" + strPDCResult.uStatModeParam.struStatFrame.dwRelativeTime + + ", dwAbsTime:" + strPDCResult.uStatModeParam.struStatFrame.dwAbsTime; + } + // byMode=1-周期统计结果(联合体中struStatTime有效), + if (strPDCResult.byMode == 1) { + strPDCResult.uStatModeParam.setType(HCNetSDK.NET_DVR_STATTIME.class); + String strtmStart = "" + String.format("%04d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwYear) + + String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwMonth) + + String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwDay) + + String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwHour) + + String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwMinute) + + String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmStart.dwSecond); + String strtmEnd = "" + String.format("%04d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwYear) + + String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwMonth) + + String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwDay) + + String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwHour) + + String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwMinute) + + String.format("%02d", strPDCResult.uStatModeParam.struStatTime.tmEnd.dwSecond); + String sAlarmPDC1Info = "周期性客流量统计,进入人数:" + strPDCResult.dwEnterNum + ",离开人数:" + strPDCResult.dwLeaveNum + + ", byMode:" + strPDCResult.byMode + ", tmStart:" + strtmStart + ",tmEnd :" + strtmEnd; + } + break; + case HCNetSDK.COMM_ALARM_V30: //移动侦测、视频丢失、遮挡、IO信号量等报警信息(V3.0以上版本支持的设备) + HCNetSDK.NET_DVR_ALARMINFO_V30 struAlarmInfo = new HCNetSDK.NET_DVR_ALARMINFO_V30(); + struAlarmInfo.write(); + Pointer pAlarmInfo_V30 = struAlarmInfo.getPointer(); + pAlarmInfo_V30.write(0, pAlarmInfo.getByteArray(0, struAlarmInfo.size()), 0, struAlarmInfo.size()); + struAlarmInfo.read(); + logger.error("报警类型:" + struAlarmInfo.dwAlarmType); // 3-移动侦测 + break; + case HCNetSDK.COMM_ALARM_V40: //移动侦测、视频丢失、遮挡、IO信号量等报警信息,报警数据为可变长 + + HCNetSDK.NET_DVR_ALARMINFO_V40 struAlarmInfoV40 = new HCNetSDK.NET_DVR_ALARMINFO_V40(); + struAlarmInfoV40.write(); + Pointer pAlarmInfoV40 = struAlarmInfoV40.getPointer(); + pAlarmInfoV40.write(0, pAlarmInfo.getByteArray(0, struAlarmInfoV40.size()), 0, struAlarmInfoV40.size()); + struAlarmInfoV40.read(); + switch (struAlarmInfoV40.struAlarmFixedHeader.dwAlarmType) { + case 0: + struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.setType(HCNetSDK.struIOAlarm.class); + struAlarmInfoV40.read(); + logger.error("信号量报警,报警输入口:" + struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.struioAlarm.dwAlarmInputNo); + break; + case 1: + logger.error("硬盘满"); + break; + case 2: + logger.error("信号丢失"); + break; + case 3: + String sAlarmType = ""; + struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.setType(HCNetSDK.struAlarmChannel.class); + struAlarmInfoV40.read(); + int iChanNum = struAlarmInfoV40.struAlarmFixedHeader.ustruAlarm.strualarmChannel.dwAlarmChanNum; + sAlarmType = sAlarmType + new String(":移动侦测") + "," + "报警通道个数:" + iChanNum + "," + "报警通道号:"; + + for (int i = 0; i < iChanNum; i++) { + byte[] byChannel = struAlarmInfoV40.pAlarmData.getByteArray(i * 4, 4); + + int iChanneNo = 0; + for (int j = 0; j < 4; j++) { + int ioffset = j * 8; + int iByte = byChannel[j] & 0xff; + iChanneNo = iChanneNo + (iByte << ioffset); + } + + sAlarmType = sAlarmType + "+ch[" + iChanneNo + "]"; + } + logger.error(sAlarmType); + break; + case 4: + logger.error("硬盘未格式化"); + break; + case 5: + logger.error("读写硬盘出错"); + break; + case 6: + logger.error("遮挡报警"); + break; + case 7: + logger.error("制式不匹配"); + break; + case 8: + logger.error("非法访问"); + break; + } + + break; + case HCNetSDK.COMM_THERMOMETRY_ALARM: //温度报警信息 + HCNetSDK.NET_DVR_THERMOMETRY_ALARM struTemInfo = new HCNetSDK.NET_DVR_THERMOMETRY_ALARM(); + struTemInfo.write(); + Pointer pTemInfo = struTemInfo.getPointer(); + pTemInfo.write(0, pAlarmInfo.getByteArray(0, struTemInfo.size()), 0, struTemInfo.size()); + struTemInfo.read(); + detect.setType(DetectType.COMM_THERMOMETRY_ALARM.getDesc()); + detect.setChannel(struTemInfo.dwChannel); + + JSONObject data = new JSONObject(); + data.put("byAlarmLevel", Integer.valueOf(struTemInfo.byAlarmLevel)); + data.put("byAlarmType", Integer.valueOf(struTemInfo.byAlarmType)); + data.put("byThermometryUnit", Integer.valueOf(struTemInfo.byThermometryUnit)); + data.put("fCurrTemperature", struTemInfo.fCurrTemperature); + data.put("fRuleTemperature", struTemInfo.fRuleTemperature); + detect.setData(data.toJSONString()); + + //可见光图片保存 + if ((struTemInfo.dwPicLen > 0) && (struTemInfo.byPicTransType == 0)) { + JSONObject imgJson = new JSONObject(); + imgJson.put("img", SDKUtil.ToFrontFileUrl(saveFile(struTemInfo.pPicBuff.getByteBuffer(0, struTemInfo.dwPicLen), + struTemInfo.dwPicLen, + sDeviceIp, + "" + struTemInfo.fCurrTemperature, + DateUtils.dateTimeNow(), + jpg))); + imgJsonArray.add(imgJson); + } + + if ((struTemInfo.dwThermalPicLen > 0) && (struTemInfo.byPicTransType == 0)) { + JSONObject imgJson = new JSONObject(); + imgJson.put("thermal_img", SDKUtil.ToFrontFileUrl(saveFile(struTemInfo.pThermalPicBuff.getByteBuffer(0, struTemInfo.dwThermalPicLen), + struTemInfo.dwThermalPicLen, + sDeviceIp, + "ThermalPiC", + DateUtils.dateTimeNow(), + jpg))); + imgJsonArray.add(imgJson); + } + break; + case HCNetSDK.COMM_THERMOMETRY_DIFF_ALARM: //温差检测报警 + HCNetSDK.NET_DVR_THERMOMETRY_DIFF_ALARM strThermDiffAlarm = new HCNetSDK.NET_DVR_THERMOMETRY_DIFF_ALARM(); + strThermDiffAlarm.write(); + Pointer pTemDiffInfo = strThermDiffAlarm.getPointer(); + pTemDiffInfo.write(0, pAlarmInfo.getByteArray(0, strThermDiffAlarm.size()), 0, strThermDiffAlarm.size()); + strThermDiffAlarm.read(); + String sThremDiffInfo = "通道号:" + strThermDiffAlarm.dwChannel + ",报警规则:" + strThermDiffAlarm.byAlarmRule + ",当前温差:" + strThermDiffAlarm.fCurTemperatureDiff; + logger.error(sThremDiffInfo); + //可见光图片保存 + if ((strThermDiffAlarm.dwPicLen > 0) && (strThermDiffAlarm.byPicTransType == 0)) { + saveFile(strThermDiffAlarm.pPicBuff.getByteBuffer(0, strThermDiffAlarm.dwPicLen), + strThermDiffAlarm.dwPicLen, + sDeviceIp, + "" + strThermDiffAlarm.fCurTemperatureDiff, + DateUtils.dateTimeNow(), + jpg); + } + //热成像图片保存 + if ((strThermDiffAlarm.dwThermalPicLen > 0) && (strThermDiffAlarm.byPicTransType == 0)) { + saveFile(strThermDiffAlarm.pThermalPicBuff.getByteBuffer(0, strThermDiffAlarm.dwThermalPicLen), + strThermDiffAlarm.dwThermalPicLen, + sDeviceIp, + "hermalDiffPiC", + DateUtils.dateTimeNow(), + jpg); + } + break; + case HCNetSDK.COMM_ALARM_SHIPSDETECTION: //船只检测报警 + HCNetSDK.NET_DVR_SHIPSDETECTION_ALARM struShipAlarm = new HCNetSDK.NET_DVR_SHIPSDETECTION_ALARM(); + struShipAlarm.write(); + Pointer pShipAlarm = struShipAlarm.getPointer(); + pShipAlarm.write(0, pAlarmInfo.getByteArray(0, struShipAlarm.size()), 0, struShipAlarm.size()); + struShipAlarm.read(); + String sShipAlarm = "绝对时间:" + struShipAlarm.dwAbsTime + ",正跨越检测线的船只数:" + struShipAlarm.byShipsNum + ",船头检测的船只数 :" + struShipAlarm.byShipsNumHead + + ", 船尾检测的船只数 :" + struShipAlarm.byShipsNumEnd; + logger.error(sShipAlarm); + //可见光图片保存 + if ((struShipAlarm.dwPicLen > 0) && (struShipAlarm.byPicTransType == 0)) { + saveFile(struShipAlarm.pPicBuffer.getByteBuffer(0, struShipAlarm.dwPicLen), + struShipAlarm.dwPicLen, + sDeviceIp, + "ShipAlarm", + DateUtils.dateTimeNow(), + jpg); + } + //热成像图片保存 + if ((struShipAlarm.dwThermalPicLen > 0) && (struShipAlarm.byPicTransType == 0)) { + saveFile(struShipAlarm.pThermalPicBuffer.getByteBuffer(0, struShipAlarm.dwThermalPicLen), + struShipAlarm.dwThermalPicLen, + sDeviceIp, + "ThermalShipAlarm", + DateUtils.dateTimeNow(), + jpg); + } + break; + + case HCNetSDK.COMM_FIREDETECTION_ALARM://烟火检测 + HCNetSDK.NET_DVR_FIREDETECTION_ALARM struFireDecAlarm = new HCNetSDK.NET_DVR_FIREDETECTION_ALARM(); + struFireDecAlarm.write(); + Pointer pFireDecAlarm = struFireDecAlarm.getPointer(); + pFireDecAlarm.write(0, pAlarmInfo.getByteArray(0, struFireDecAlarm.size()), 0, struFireDecAlarm.size()); + struFireDecAlarm.read(); + String sFireDecAlarmInfo = "绝对时间:" + struFireDecAlarm.dwAbsTime + ",报警子类型:" + struFireDecAlarm.byAlarmSubType + ",火点最高温度 :" + + struFireDecAlarm.wFireMaxTemperature + ",火点目标距离:" + struFireDecAlarm.wTargetDistance; + logger.error(sFireDecAlarmInfo); + //可见光图片保存 + if ((struFireDecAlarm.dwVisiblePicLen > 0) && (struFireDecAlarm.byPicTransType == 0)) { + saveFile(struFireDecAlarm.pVisiblePicBuf.getByteBuffer(0, struFireDecAlarm.dwVisiblePicLen), + struFireDecAlarm.dwVisiblePicLen, + sDeviceIp, + "FireDecAlarm", + DateUtils.dateTimeNow(), + jpg); + } + //热成像图片保存 + if ((struFireDecAlarm.dwPicDataLen > 0) && (struFireDecAlarm.byPicTransType == 0)) { + saveFile(struFireDecAlarm.pBuffer.getByteBuffer(0, struFireDecAlarm.dwPicDataLen), + struFireDecAlarm.dwPicDataLen, + sDeviceIp, + "ThermalFireAlarm", + DateUtils.dateTimeNow(), + jpg); + } + break; + case HCNetSDK.COMM_UPLOAD_AIOP_VIDEO: //AI开放平台接入视频检测报警信息 + HCNetSDK.NET_AIOP_VIDEO_HEAD struAIOPVideo = new HCNetSDK.NET_AIOP_VIDEO_HEAD(); + struAIOPVideo.write(); + Pointer pAIOPVideo = struAIOPVideo.getPointer(); + pAIOPVideo.write(0, pAlarmInfo.getByteArray(0, struAIOPVideo.size()), 0, struAIOPVideo.size()); + struAIOPVideo.read(); + detect.setChannel(struAIOPVideo.dwChannel); + detect.setTime(DateUtils.parseDate(SDKUtil.parseTime(struAIOPVideo.struTime))); + //AIOPData数据 + if (struAIOPVideo.dwAIOPDataSize > 0) { + detect.setType(DetectType.toDesc(new String(struAIOPVideo.szMPID).trim())); + try { + File jsonFile = new File(saveFile(struAIOPVideo.pBufferAIOPData.getByteBuffer(0, struAIOPVideo.dwAIOPDataSize), + struAIOPVideo.dwAIOPDataSize, + sDeviceIp, + "VideoData", + DateUtils.dateTimeNow(), + json)); + if (jsonFile.exists()){ + String jsonStr = FileUtils.readFileToString(jsonFile, "UTF-8"); + JSONObject jsonData = JSONObject.parseObject(jsonStr); + if (jsonData.containsKey("events")){ + detect.setData(new JSONObject().fluentPut("events", jsonData.getJSONObject("events")).toJSONString()); + }else { + detect.setData(jsonData.toJSONString()); + } + }else { + detect.setData("{}"); + } + } catch (IOException e) { + detect.setData("{}"); + logger.error("AI开放平台接入视频检测报警数据解析失败:{}", e.getMessage()); + } + } + //图片数据保存 + if (struAIOPVideo.dwPictureSize > 0) { + JSONObject imgJson = new JSONObject(); + imgJson.put("img",SDKUtil.ToFrontFileUrl(saveFile(struAIOPVideo.pBufferPicture.getByteBuffer(0, struAIOPVideo.dwPictureSize), + struAIOPVideo.dwPictureSize, + sDeviceIp, + "VideoPic", + DateUtils.dateTimeNow(), + jpg))); + imgJsonArray.add(imgJson); + } + break; + case HCNetSDK.COMM_UPLOAD_AIOP_PICTURE: //AI开放平台接入图片检测报警信息 + logger.error("AI开放平台接入图片检测报警上传"); + HCNetSDK.NET_AIOP_PICTURE_HEAD struAIOPPic = new HCNetSDK.NET_AIOP_PICTURE_HEAD(); + struAIOPPic.write(); + Pointer pAIOPPic = struAIOPPic.getPointer(); + pAIOPPic.write(0, pAlarmInfo.getByteArray(0, struAIOPPic.size()), 0, struAIOPPic.size()); + struAIOPPic.read(); + logger.error("图片ID:" + new String(struAIOPPic.szPID)); + logger.error("检测模型包ID:" + new String(struAIOPPic.szMPID)); + String strPicTime = "" + String.format("%04d", struAIOPPic.struTime.wYear) + + String.format("%02d", struAIOPPic.struTime.wMonth) + + String.format("%02d", struAIOPPic.struTime.wDay) + + String.format("%02d", struAIOPPic.struTime.wHour) + + String.format("%02d", struAIOPPic.struTime.wMinute) + + String.format("%02d", struAIOPPic.struTime.wSecond) + + String.format("%03d", struAIOPPic.struTime.wMilliSec); + //AIOPData数据 + if (struAIOPPic.dwAIOPDataSize > 0) { + saveFile(struAIOPPic.pBufferAIOPData.getByteBuffer(0, struAIOPPic.dwAIOPDataSize), + struAIOPPic.dwAIOPDataSize, + sDeviceIp, + "AIO_PicData", + strPicTime, + json); + } + break; + + //AI开放平台接入轮询抓图检测报警信息 + case HCNetSDK.COMM_UPLOAD_AIOP_POLLING_SNAP: + logger.error("AI开放平台接入轮询抓图检测报警事件上传"); + HCNetSDK.NET_AIOP_POLLING_SNAP_HEAD strAiopPollingPic = new HCNetSDK.NET_AIOP_POLLING_SNAP_HEAD(); + strAiopPollingPic.write(); + Pointer pAiopPollingPic = strAiopPollingPic.getPointer(); + pAiopPollingPic.write(0, pAlarmInfo.getByteArray(0, strAiopPollingPic.size()), 0, strAiopPollingPic.size()); + strAiopPollingPic.read(); + logger.error("通道号:" + strAiopPollingPic.dwChannel); + logger.error("轮询抓图任务ID:" + new String(strAiopPollingPic.szTaskID)); + String strPollingPicTime = "" + String.format("%04d", strAiopPollingPic.struTime.wYear) + + String.format("%02d", strAiopPollingPic.struTime.wMonth) + + String.format("%02d", strAiopPollingPic.struTime.wDay) + + String.format("%02d", strAiopPollingPic.struTime.wHour) + + String.format("%02d", strAiopPollingPic.struTime.wMinute) + + String.format("%02d", strAiopPollingPic.struTime.wSecond) + + String.format("%03d", strAiopPollingPic.struTime.wMilliSec); + //AIOPData数据保存 + if (strAiopPollingPic.dwAIOPDataSize > 0) { + saveFile(strAiopPollingPic.pBufferAIOPData.getByteBuffer(0, strAiopPollingPic.dwAIOPDataSize), + strAiopPollingPic.dwAIOPDataSize, + sDeviceIp, + "PollingPicData", + strPollingPicTime, + json); + } + //轮询抓图图片保存 + if (strAiopPollingPic.dwPictureSize > 0) { + saveFile(strAiopPollingPic.pBufferPicture.getByteBuffer(0, strAiopPollingPic.dwPictureSize), + strAiopPollingPic.dwPictureSize, + sDeviceIp, + "PollingPic", + strPollingPicTime, + jpg); + } + + break; + //AI开放平台接入轮询视频检测报警信息 + case HCNetSDK.COMM_UPLOAD_AIOP_POLLING_VIDEO: + HCNetSDK.NET_AIOP_POLLING_VIDEO_HEAD strAiopPollingVideo = new HCNetSDK.NET_AIOP_POLLING_VIDEO_HEAD(); + strAiopPollingVideo.write(); + Pointer pAiopPollingVideo = strAiopPollingVideo.getPointer(); + pAiopPollingVideo.write(0, pAlarmInfo.getByteArray(0, strAiopPollingVideo.size()), 0, strAiopPollingVideo.size()); + strAiopPollingVideo.read(); + logger.error("通道号:" + strAiopPollingVideo.dwChannel); + logger.error("轮询视频任务ID:" + new String(strAiopPollingVideo.szTaskID)); + String AiopPollingVideoTime = "" + String.format("%04d", strAiopPollingVideo.struTime.wYear) + + String.format("%02d", strAiopPollingVideo.struTime.wMonth) + + String.format("%02d", strAiopPollingVideo.struTime.wDay) + + String.format("%02d", strAiopPollingVideo.struTime.wHour) + + String.format("%02d", strAiopPollingVideo.struTime.wMinute) + + String.format("%02d", strAiopPollingVideo.struTime.wSecond) + + String.format("%03d", strAiopPollingVideo.struTime.wMilliSec); + //AIOPData数据保存 + if (strAiopPollingVideo.dwAIOPDataSize > 0) { + saveFile(strAiopPollingVideo.pBufferAIOPData.getByteBuffer(0, strAiopPollingVideo.dwAIOPDataSize), + strAiopPollingVideo.dwAIOPDataSize, + sDeviceIp, + "PollingVideoData", + AiopPollingVideoTime, + json); + } + //对应分析图片数据 + if (strAiopPollingVideo.dwPictureSize > 0) { + saveFile(strAiopPollingVideo.pBufferPicture.getByteBuffer(0, strAiopPollingVideo.dwPictureSize), + strAiopPollingVideo.dwPictureSize, + sDeviceIp, + "PollingVideo", + AiopPollingVideoTime, + jpg); + } + break; + default: + logger.error("报警类型{}", eventMsg); + break; + } + detect.setImg(imgJsonArray.toJSONString()); + return detect; + } + + private static String saveFile(ByteBuffer buffer, int dataLen, String deviceIp, String fileNamePrefix, String dateTime, String fileType) { + String fileName = deviceIp + "_" + fileNamePrefix + "_" + dateTime + fileType; + return FileUploadUtils.upload(buffer, dataLen, fileName, profile); + } + + private static String saveFile(byte[] bytes, int dataLen, String deviceIp, String fileNamePrefix, String dateTime, String fileType) { + String fileName = deviceIp + "_" + fileNamePrefix + "_" + dateTime + fileType; + return FileUploadUtils.upload(bytes, dataLen, fileName, profile); + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/factory/CorerainBox.java b/box-device/src/main/java/com/mathvision/box/device/core/factory/CorerainBox.java new file mode 100644 index 0000000..3d38e13 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/factory/CorerainBox.java @@ -0,0 +1,171 @@ +package com.mathvision.box.device.core.factory; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.mathvision.box.common.enums.DetectStatusEnum; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.dao.domain.entity.Detect; +import com.mathvision.box.device.common.domin.PlayBack; +import com.mathvision.box.common.enums.DeviceStatus; +import com.mathvision.box.device.common.domin.SignIn; +import com.mathvision.box.device.common.dto.CoreainDefect; +import com.mathvision.box.device.common.dto.CoreainDetect; +import com.mathvision.box.device.common.dto.CoreainDevice; +import com.mathvision.box.device.common.enums.DetectType; +import com.mathvision.box.device.common.enums.DeviceType; +import com.mathvision.box.device.common.enums.DeviceVendor; +import com.mathvision.box.device.sdk.CorerainAPI; +import com.mathvision.box.device.utils.SDKUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.Assert; + +import java.net.URISyntaxException; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 鲲云盒子 + */ +public class CorerainBox extends DeviceAbstractFactory implements IBox { + + private static final Logger logger = LoggerFactory.getLogger(CorerainBox.class); + + private CorerainAPI corerainAPI; + + public CorerainBox(String identity) { + super(DeviceType.box, identity); + deviceStatus = DeviceStatus.ready; + } + + @Override + public boolean config(Map input) { + deviceStatus = DeviceStatus.online; + params.putAll(input); + return true; + } + + @Override + public boolean open(Map input) { + if (params == null || !params.containsKey("ip") || !params.containsKey("port") || !params.containsKey("username") || !params.containsKey("password")) { + logger.error("缺少必要参数:{}", params); + deviceStatus = DeviceStatus.error; + return false; + } + String ip = (String) params.get("ip"); + Integer port = (Integer) params.get("port"); + String appId = (String) params.get("username"); + String appSecret = (String) params.get("password"); + corerainAPI = new CorerainAPI(ip, port.toString(), appId, appSecret); + try { + corerainAPI.checkOauth(); + logger.info("设备注册成功:{}", params.get("name")); +// deviceStatus = DeviceStatus.working; + deviceStatus = DeviceStatus.online; + return true; + } catch (Exception e) { + logger.error("设备注册失败:{}", e.getMessage()); + deviceStatus = DeviceStatus.error; + return false; + } + } + + @Override + public boolean close(Map input) { + deviceStatus = DeviceStatus.offline; + return true; + } + + @Override + public void heartbeat() { + deviceStatus = checkServiceStatus() ? DeviceStatus.online : DeviceStatus.offline; + } + + @Override + public List getChild() { + return JSONObject.parseArray(JSONObject.parseObject(corerainAPI.openapi_usm_v1_camera_list(1, 999, null, null, null, null)).getString("data"), CoreainDevice.class) + .stream().map(e -> { + SignIn signIn = new SignIn(); + try { + signIn = SDKUtil.parseRTSPUrl(e.getStreamUrl()); + } catch (URISyntaxException ex) { + logger.error("设备URL转换失败:[{}]", e.getName(), ex); + } + signIn.setId((Long) params.get("id")); + signIn.setDeviceId(SDKUtil.getChanelId(identity, e.getId().toString())); + signIn.setName(params.get("name") + "_" + e.getName()); + signIn.setStatus(e.getOnlineStatus() == 1 ? DeviceStatus.online.name() : DeviceStatus.offline.name()); + signIn.setType(DeviceVendor.HIKVISION_CAMERA.getType().name()); + signIn.setVendor(DeviceVendor.HIKVISION_CAMERA.getVendor()); + return signIn; + } + ).collect(Collectors.toList()); + } + + @Override + public String getVideoUrl(PlayBack playBack) { + return null; + } + + public CoreainDefect getStepsByJobId(String jobId) { + Assert.isTrue(StringUtils.isNotBlank(jobId), "getStepsByJobId: jobId参数错误"); + String steps = corerainAPI.openapi_cb_v1_callback_gas_station_steps(jobId); + Assert.isTrue(StringUtils.isNotBlank(steps), "steps获取失败"); + CoreainDefect coreainDefect = JSONObject.parseObject(steps, CoreainDefect.class); + coreainDefect.getSteps().forEach(step -> + step.setPicUrl(SDKUtil.checkImg(params.get("ip").toString(), params.get("port").toString(), step.getPicUrl())) + ); + return coreainDefect; + } + + public String getJobId() { + String jobs = corerainAPI.openapi_vam_v1_gas_station_jobs(); + Assert.isTrue(StringUtils.isNotBlank(jobs), "job获取失败"); + JSONObject jsonObject = JSONObject.parseObject(jobs); + if (jsonObject.containsKey("jobId")) { + return jsonObject.getString("jobId"); + } + return ""; + } + + private boolean checkServiceStatus() { + String requestStr = corerainAPI.openapi_vam_v1_service_list_executing(); + JSONObject requestBody = JSONObject.parseObject(requestStr); + if (requestBody.containsKey("data")){ + JSONArray serviceList = requestBody.getJSONArray("data"); + if (serviceList != null && serviceList.size() > 0) { + return serviceList.getJSONObject(0).getString("status").equals("run") ? true : false; + } + } + return false; + } + + public List getDetect(String processId, String stepId, String alarmLevel) { + String detectStr = corerainAPI.openapi_cb_v1_gas_station_logs(processId, null, null, null, null, alarmLevel, 1, 99, null, stepId); + JSONObject detectJson = JSONObject.parseObject(detectStr); + + if (detectJson.containsKey("total") && detectJson.getInteger("total") > 0) { + if (detectJson.getInteger("total") > 99) { + detectStr = corerainAPI.openapi_cb_v1_gas_station_logs(processId, null, null, null, null, alarmLevel, 1, detectJson.getInteger("total"), null, stepId); + detectJson = JSONObject.parseObject(detectStr); + } + List detects = JSONObject.parseArray(detectJson.getJSONArray("data").toJSONString(), CoreainDetect.class); + List detectList = detects.stream().map(coreainDetect -> { + String imgUrl = SDKUtil.checkImg(params.get("ip").toString(), params.get("port").toString(), coreainDetect.getImgPath()); + return Detect.builder() + .processId(coreainDetect.getProcessId()) + .detectId(coreainDetect.getProcessId() + "_" + coreainDetect.getStepId() + "_" + coreainDetect.getAlarmLevel()) + .time(coreainDetect.getAlarmTime()) + .type(DetectType.toDesc(coreainDetect.getStepId())) + .ip(params.get("ip").toString()) + .channel(coreainDetect.getCameraId()) + .img("[{\"name\":\"" + DetectType.toDesc(coreainDetect.getStepId()) + "\",\"url\":\"" + imgUrl + "\"}]") + .data(JSONObject.toJSONString(coreainDetect)) + .status(DetectStatusEnum.getStatus(coreainDetect.getAlarmLevel()).getCode()) + .build(); + }).collect(Collectors.toList()); + } + return null; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/factory/DeviceAbstractFactory.java b/box-device/src/main/java/com/mathvision/box/device/core/factory/DeviceAbstractFactory.java new file mode 100644 index 0000000..cee553a --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/factory/DeviceAbstractFactory.java @@ -0,0 +1,58 @@ +package com.mathvision.box.device.core.factory; + +import com.mathvision.box.common.enums.DeviceStatus; +import com.mathvision.box.device.common.enums.DeviceType; +import com.mathvision.box.device.common.enums.DeviceVendor; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; + +/** + * 设备抽象工厂 + */ +public abstract class DeviceAbstractFactory implements IDevice{ + private static ConcurrentHashMap DEVICES = new ConcurrentHashMap<>(); + + protected String identity; + protected DeviceType deviceType; + protected DeviceStatus deviceStatus; + protected Map params = new HashMap<>(); + + public DeviceAbstractFactory(DeviceType deviceType, String identity) { + this.deviceType = deviceType; + this.identity = identity; + DEVICES.putIfAbsent(identity, this); + } + + public String identity() { + return identity; + } + + public DeviceType type() { + return this.deviceType; + } + + public DeviceStatus status() { + return deviceStatus; + } + + public Map params() { + return params; + } + + public static IDevice getByIdentity(String identity) { + return DEVICES.get(identity); + } + + public static List getByParam(String param, Object value) { + return DEVICES.values().stream().filter(d -> d.params().containsKey(param) && d.params().get(param).equals(value)).collect(Collectors.toList()); + } + + public static List getByVendor(DeviceVendor vendor) { + if (vendor == null){ + return DEVICES.values().stream().collect(Collectors.toList()); + } + return DEVICES.values().stream().filter(Objects::nonNull).filter(d -> vendor.getClazz().isInstance(d)).collect(Collectors.toList()); + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/factory/HikvisionBox.java b/box-device/src/main/java/com/mathvision/box/device/core/factory/HikvisionBox.java new file mode 100644 index 0000000..fe4ccfc --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/factory/HikvisionBox.java @@ -0,0 +1,264 @@ +package com.mathvision.box.device.core.factory; + +import com.mathvision.box.device.common.domin.HikvisonBoxAlgorithmModel; +import com.mathvision.box.device.common.domin.PlayBack; +import com.mathvision.box.device.common.domin.SignIn; +import com.mathvision.box.common.enums.DeviceStatus; +import com.mathvision.box.device.common.enums.DeviceType; +import com.mathvision.box.device.common.enums.DeviceVendor; +import com.mathvision.box.device.common.enums.HCNetSDKErrorEnum; +import com.mathvision.box.device.sdk.HCNetSDK; +import com.mathvision.box.device.utils.DataUtil; +import com.mathvision.box.device.utils.ISAPIUtils; +import com.mathvision.box.device.utils.SDKUtil; +import com.sun.jna.NativeLong; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.IntByReference; +import org.apache.commons.compress.utils.Lists; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.Assert; + +import java.io.UnsupportedEncodingException; +import java.util.*; + +/** + * 海康超脑nvr + */ +public class HikvisionBox extends DeviceAbstractFactory implements IBox { + + private static final Logger logger = LoggerFactory.getLogger(HikvisionBox.class); + + //sdk + private HCNetSDK hcNetSDK; + + //登录后返回的id,用于注销设备,登出 + protected int lUserID = -1; + + //监听句柄 + private int lAlarmHandle = -1; + + /*设备信息*/ + HCNetSDK.NET_DVR_DEVICEINFO_V30 m_strDeviceInfo; + + /*获取IP接入配置信息*/ + public static final int NET_DVR_GET_IPPARACFG = 1048; + + /*允许加入的最多IP通道数*/ + public static final int MAX_IP_CHANNEL = 32; + + + public HikvisionBox(String identity) { + super(DeviceType.box, identity); + deviceStatus = DeviceStatus.ready; + } + + public void init(HCNetSDK hcNetSDK) { + this.hcNetSDK = hcNetSDK; + } + + @Override + public boolean config(Map input) { + deviceStatus = DeviceStatus.online; + params.putAll(input); + return true; + } + + @Override + public boolean open(Map input) { +// deviceStatus = DeviceStatus.working; + deviceStatus = DeviceStatus.online; + registerV30(); + setAlarm(); + return true; + } + + /** + * 撤防,登出,注销; + */ + @Override + public boolean close(Map input) { + deviceStatus = DeviceStatus.offline; + if (registered()) { + //撤防 + closeAlarm(); + logger.info("登出设备:{}", identity); + if (hcNetSDK.NET_DVR_Logout(lUserID)) { + lUserID = -1; + } else { + logger.error("登出失败:{},错误信息:{}", identity, HCNetSDKErrorEnum.getByCode(hcNetSDK.NET_DVR_GetLastError()).getMessage()); + } + } + return true; + } + + @Override + public void heartbeat() { + deviceStatus = hcNetSDK.NET_DVR_RemoteControl(lUserID, HCNetSDK.NET_DVR_CHECK_USER_STATUS, null, 0) ? DeviceStatus.online : DeviceStatus.offline; + } + + @Override + public List getChild() { + List signIns = Lists.newArrayList(); + String nvrName = (String) params.get("name"); + + IntByReference ibrBytesReturned = new IntByReference(0);//获取IP接入配置参数 + HCNetSDK.NET_DVR_IPPARACFG_V40 m_strIpparaCfg = new HCNetSDK.NET_DVR_IPPARACFG_V40(); + m_strIpparaCfg.write(); + //lpIpParaConfig 接收数据的缓冲指针 + Pointer lpIpParaConfig = m_strIpparaCfg.getPointer(); + boolean bRet = hcNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_IPPARACFG_V40, 0, lpIpParaConfig, m_strIpparaCfg.size(), ibrBytesReturned); + m_strIpparaCfg.read(); + + for (int iChannum = 0; iChannum < m_strIpparaCfg.dwDChanNum; iChannum++) { + int channum = iChannum + m_strIpparaCfg.dwStartDChan; + HCNetSDK.NET_DVR_PICCFG_V40 strPicCfg = new HCNetSDK.NET_DVR_PICCFG_V40(); + strPicCfg.dwSize = strPicCfg.size(); + strPicCfg.write(); + Pointer pStrPicCfg = strPicCfg.getPointer(); + NativeLong lChannel = new NativeLong(channum); + IntByReference pInt = new IntByReference(0); + boolean b_GetPicCfg = hcNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_PICCFG_V40, lChannel.intValue(), + pStrPicCfg, strPicCfg.size(), pInt); +// if (b_GetPicCfg == false) { +// logger.error("获取图像参数失败,错误码:" + hcNetSDK.NET_DVR_GetLastError()); +// } + strPicCfg.read(); + m_strIpparaCfg.struStreamMode[iChannum].read(); + if (m_strIpparaCfg.struStreamMode[iChannum].byGetStreamType == 0) { + m_strIpparaCfg.struStreamMode[iChannum].uGetStream.setType(HCNetSDK.NET_DVR_IPCHANINFO.class); + m_strIpparaCfg.struStreamMode[iChannum].uGetStream.struChanInfo.read(); + int channel = m_strIpparaCfg.struStreamMode[iChannum].uGetStream.struChanInfo.byIPID + m_strIpparaCfg.struStreamMode[iChannum].uGetStream.struChanInfo.byIPIDHigh * 256; + String ip = ""; + if (channel > 0) { + ip = new String(m_strIpparaCfg.struIPDevInfo[channel - 1].struIP.sIpV4).trim(); + } + String deviceId = "IPCamera" + (iChannum + 1); + String name; + try { + name = new String(strPicCfg.sChanName, "GBK").trim(); + } catch (UnsupportedEncodingException e) { + logger.error("{}-{}通道名称编码错误", nvrName, channum, e); + name = deviceId; + } + if (m_strIpparaCfg.struStreamMode[iChannum].uGetStream.struChanInfo.byEnable == 1) { + SignIn s = new SignIn(); + s.setId((Long) params.get("id")); + s.setDeviceId(SDKUtil.getChanelId(identity, String.valueOf(channum))); + s.setName(nvrName + "_" + name); + s.setIp(ip); + s.setPort((Integer) params.get("port")); + s.setUserName((String) params.get("username")); + s.setPassword((String) params.get("password")); + s.setStatus(DeviceStatus.online.name()); + s.setChannel(channum); + s.setType(DeviceVendor.HIKVISION_CAMERA.getType().name()); + s.setVendor(DeviceVendor.HIKVISION_CAMERA.getVendor()); + signIns.add(s); + } else { + deviceStatus = DeviceStatus.offline; + } + } + } + return signIns; + } + + @Override + public String getVideoUrl(PlayBack playBack) { + Assert.isTrue(lUserID != -1, "设备未注册"); + + /*获取设备通道号*/ + List signIns = getChild(); + int channelNum = 0; + for (SignIn signIn : signIns) { + if (signIn.getIp().equals(playBack.getDeviceIp()) && playBack.getChannelNumber() == signIn.getChannel()) { + channelNum = signIn.getChannel(); + } + } + Assert.isTrue(channelNum != 0, "设备ip或通道错误"); + String backUrl = ""; + if (playBack.getUrlType() == 1) { + /*组装回放流地址*/ + backUrl = "rtsp://" + params.get("username") + ":" + params.get("password") + "@" + params.get("ip") + ":554/Streaming/tracks/" + (channelNum - 32) + "01/?" + "starttime=" + DataUtil.backTimeAssemble(playBack.getStartTime()) + "&endtime=" + DataUtil.backTimeAssemble(playBack.getEndTime()); + } else { + /*组装实时流地址*/ + backUrl = "rtsp://" + params.get("username") + ":" + params.get("password") + "@" + params.get("ip") + ":554/Streaming/Channels/" + (channelNum - 32) + "01/?" + "transportmode=unicast"; + } + return backUrl; + } + + /** + * 注册,登录; + */ + private void registerV30() { + if (!registered()) { + HCNetSDK.NET_DVR_DEVICEINFO_V30 v30 = new HCNetSDK.NET_DVR_DEVICEINFO_V30(); + if (params == null || !params.containsKey("ip") || !params.containsKey("port") || !params.containsKey("username") || !params.containsKey("password")) { + logger.error("缺少必要参数:{}", params); + return; + } + String ip = (String) params.get("ip"); + Integer port = (Integer) params.get("port"); + String username = (String) params.get("username"); + String password = (String) params.get("password"); + lUserID = hcNetSDK.NET_DVR_Login_V30(ip, port.shortValue(), username, password, v30); + + String AIOPModelStr = ISAPIUtils.ISAPI_Intelligent_AIOpenPlatform_algorithmModel_management(ip, "80", username, password); + HikvisonBoxAlgorithmModel.init(AIOPModelStr); + } else { + return; + } + if (!registered()) { + logger.error("设备注册失败:{},错误信息:{}", identity, HCNetSDKErrorEnum.getByCode(hcNetSDK.NET_DVR_GetLastError()).getMessage()); + } else { + logger.info("设备注册成功:{}", identity); + } + } + + private boolean registered() { + return lUserID != -1 && lUserID != 0xFFFFFFFF; + } + + private boolean hasSetAlarm() { + return lAlarmHandle != -1; + } + + /** + * 布防操作 + */ + private void setAlarm() { + if (hasSetAlarm()) return; + //布防需要注册登录,监听则不需要 + if (registered()) { + //报警布防参数设置 + HCNetSDK.NET_DVR_SETUPALARM_PARAM m_strAlarmInfo = new HCNetSDK.NET_DVR_SETUPALARM_PARAM(); + m_strAlarmInfo.dwSize = m_strAlarmInfo.size(); + m_strAlarmInfo.byLevel = 0; //布防等级 + m_strAlarmInfo.byAlarmInfoType = 1; // 智能交通报警信息上传类型:0- 老报警信息(NET_DVR_PLATE_RESULT),1- 新报警信息(NET_ITS_PLATE_RESULT) + m_strAlarmInfo.byDeployType = 0; //布防类型:0-客户端布防,1-实时布防 + m_strAlarmInfo.write(); + lAlarmHandle = hcNetSDK.NET_DVR_SetupAlarmChan_V41(lUserID, m_strAlarmInfo); + if (hasSetAlarm()) { + logger.info("布防成功:{}", identity); + } else { + logger.error("布防失败:{},错误信息:{}", identity, HCNetSDKErrorEnum.getByCode(hcNetSDK.NET_DVR_GetLastError()).getMessage()); + } + } else { + logger.error("未注册,无法布防:{}", identity); + } + } + + /** + * 撤防操作 + */ + private void closeAlarm() { + if (hasSetAlarm()) { + if (hcNetSDK.NET_DVR_CloseAlarmChan(lAlarmHandle)) { + lAlarmHandle = -1; + logger.info("撤防成功:{}", identity); + } else { + logger.error("停止监听失败:{},错误信息:{}", identity, HCNetSDKErrorEnum.getByCode(hcNetSDK.NET_DVR_GetLastError()).getMessage()); + } + } + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/factory/HikvisionCamera.java b/box-device/src/main/java/com/mathvision/box/device/core/factory/HikvisionCamera.java new file mode 100644 index 0000000..30702f3 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/factory/HikvisionCamera.java @@ -0,0 +1,109 @@ +package com.mathvision.box.device.core.factory; + +import com.mathvision.box.common.enums.DeviceStatus; +import com.mathvision.box.device.common.enums.DeviceType; +import com.mathvision.box.device.common.enums.HCNetSDKErrorEnum; +import com.mathvision.box.device.sdk.HCNetAPI; +import com.mathvision.box.device.sdk.HCNetSDK; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.Map; + +/** + * 海康威视摄像头 + */ +public class HikvisionCamera extends DeviceAbstractFactory implements ICamera{ + + private static final Logger logger = LoggerFactory.getLogger(HikvisionCamera.class); + + private HCNetSDK hcNetSDK; + + protected int lUserID = -1; + + private Float temperature = 0f; + + + public HikvisionCamera(String identity) { + super(DeviceType.surveillance_camera, identity); + deviceStatus = DeviceStatus.ready; + } + + public void init(HCNetSDK hcNetSDK) { + this.hcNetSDK = hcNetSDK; + } + + @Override + public boolean config(Map input) { + deviceStatus = DeviceStatus.online; + params.putAll(input); + return true; + } + + @Override + public boolean open(Map input) { +// deviceStatus = DeviceStatus.working; + deviceStatus = DeviceStatus.online; + registerV30(); + return true; + } + + @Override + public boolean close(Map input) { + deviceStatus = DeviceStatus.offline; + if (registered()) { + logger.info("登出设备:{}", identity); + if (hcNetSDK.NET_DVR_Logout(lUserID)) { + lUserID = -1; + } else { + logger.error("登出失败:{},错误信息:{}", identity, HCNetSDKErrorEnum.getByCode(hcNetSDK.NET_DVR_GetLastError()).getMessage()); + } + } + return true; + } + + @Override + public void heartbeat() { + deviceStatus = DeviceStatus.online; + } + + + @Override + public void setTemperature(Float temperature) { + if (temperature!=null && temperature!=0f){ + this.temperature = temperature; + }else { + this.temperature = HCNetAPI.getAverageTemperature(hcNetSDK, lUserID, 2); + } + } + + @Override + public Float getTemperature() { + return temperature; + } + + private void registerV30() { + if (!registered()) { + HCNetSDK.NET_DVR_DEVICEINFO_V30 v30 = new HCNetSDK.NET_DVR_DEVICEINFO_V30(); + if (params == null || !params.containsKey("ip") || !params.containsKey("port") || !params.containsKey("username") || !params.containsKey("password")) { + logger.error("缺少必要参数:{}", params); + return; + } + String ip = (String) params.get("ip"); + Integer port = (Integer) params.get("port"); + String username = (String) params.get("username"); + String password = (String) params.get("password"); + lUserID = hcNetSDK.NET_DVR_Login_V30(ip, port.shortValue(), username, password, v30); + } else { + return; + } + if (!registered()) { + logger.error("设备注册失败:{},错误信息:{}", identity, HCNetSDKErrorEnum.getByCode(hcNetSDK.NET_DVR_GetLastError()).getMessage()); + } else { + logger.info("设备注册成功:{}", identity); + } + } + + private boolean registered() { + return lUserID != -1 && lUserID != 0xFFFFFFFF; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/factory/IBox.java b/box-device/src/main/java/com/mathvision/box/device/core/factory/IBox.java new file mode 100644 index 0000000..e9de146 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/factory/IBox.java @@ -0,0 +1,18 @@ +package com.mathvision.box.device.core.factory; + +import com.mathvision.box.device.common.domin.PlayBack; +import com.mathvision.box.device.common.domin.SignIn; + +import java.util.List; + +public interface IBox extends IDevice{ + /** + * 获取子设备 + */ + List getChild(); + + /** + * 回放拉流 + */ + String getVideoUrl(PlayBack playBack); +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/factory/ICamera.java b/box-device/src/main/java/com/mathvision/box/device/core/factory/ICamera.java new file mode 100644 index 0000000..c2d01a7 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/factory/ICamera.java @@ -0,0 +1,12 @@ +package com.mathvision.box.device.core.factory; + +public interface ICamera extends IDevice { + /** + * 设置设备温度 + */ + void setTemperature(Float temperature); + /** + * 获取设备温度 + */ + Float getTemperature(); +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/factory/IDevice.java b/box-device/src/main/java/com/mathvision/box/device/core/factory/IDevice.java new file mode 100644 index 0000000..a9b2e82 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/factory/IDevice.java @@ -0,0 +1,48 @@ +package com.mathvision.box.device.core.factory; + +import com.mathvision.box.common.enums.DeviceStatus; +import com.mathvision.box.device.common.enums.DeviceType; +import java.util.Map; + +public interface IDevice { + + /** + * 设备参数配置 + */ + boolean config(Map input); + + /** + * 打开设备 + */ + boolean open(Map input); + + /** + * 关闭设备 + */ + boolean close(Map input); + + /** + * 心跳 + */ + void heartbeat(); + + /** + * 查询状态 + */ + DeviceStatus status(); + + /** + * 查询设备类型 + */ + DeviceType type(); + + /** + * 设备标识 + */ + String identity(); + + /** + * 设备配置参数 + */ + Map params(); +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/factory/MockBox.java b/box-device/src/main/java/com/mathvision/box/device/core/factory/MockBox.java new file mode 100644 index 0000000..3873109 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/factory/MockBox.java @@ -0,0 +1,68 @@ +package com.mathvision.box.device.core.factory; + +import com.mathvision.box.common.enums.DeviceStatus; +import com.mathvision.box.device.common.domin.PlayBack; +import com.mathvision.box.device.common.domin.SignIn; +import com.mathvision.box.device.common.enums.DeviceType; +import com.mathvision.box.device.utils.SDKUtil; +import org.apache.commons.compress.utils.Lists; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.List; +import java.util.Map; + +/** + * 模拟盒子 + */ +public class MockBox extends DeviceAbstractFactory implements IBox{ + + private static final Logger logger = LoggerFactory.getLogger(MockBox.class); + + public MockBox(String identity) { + super(DeviceType.box, identity); + deviceStatus = DeviceStatus.ready; + } + + @Override + public boolean config(Map input) { + deviceStatus = DeviceStatus.online; + params.putAll(input); + return true; + } + + @Override + public boolean open(Map input) { +// deviceStatus = DeviceStatus.working; + deviceStatus = DeviceStatus.online; + logger.info("设备注册成功:{}", identity); + return true; + } + + @Override + public boolean close(Map input) { + deviceStatus = DeviceStatus.offline; + return true; + } + + @Override + public void heartbeat() { + deviceStatus = DeviceStatus.online; + } + + @Override + public List getChild() { + List signIns = Lists.newArrayList(); + SignIn s1 = SignIn.builder().id((Long) params.get("id")).deviceId(SDKUtil.getChanelId(identity , "33")).name("海康超脑NVR_Camera 02").ip("192.168.1.64").port(8000).userName("admin").password("123456").status("1").channel(33).type("surveillance_camera").vendor("mock").build(); + SignIn s2 = SignIn.builder().id((Long) params.get("id")).deviceId(SDKUtil.getChanelId(identity , "34")).name("海康超脑NVR_Camera 01").ip("192.168.1.64").port(8000).userName("admin").password("123456").status("1").channel(34).type("surveillance_camera").vendor("mock").build(); + SignIn s3 = SignIn.builder().id((Long) params.get("id")).deviceId(SDKUtil.getChanelId(identity , "35")).name("海康超脑NVR_G000001 广通北高速").ip("192.168.1.100").port(8000).userName("admin").password("123456").status("1").channel(35).type("surveillance_camera").vendor("mock").build(); + signIns.add(s1); + signIns.add(s2); + signIns.add(s3); + return signIns; + } + + @Override + public String getVideoUrl(PlayBack playBack) { + return ""; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/factory/MockCamera.java b/box-device/src/main/java/com/mathvision/box/device/core/factory/MockCamera.java new file mode 100644 index 0000000..9036f69 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/factory/MockCamera.java @@ -0,0 +1,434 @@ +package com.mathvision.box.device.core.factory; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.mathvision.box.common.enums.DetectStatusEnum; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.uuid.IdUtils; +import com.mathvision.box.dao.domain.entity.Detect; +import com.mathvision.box.device.common.enums.DetectType; +import com.mathvision.box.common.enums.DeviceStatus; +import com.mathvision.box.device.common.enums.DeviceType; +import org.apache.commons.compress.utils.Lists; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.Map; +import java.util.Random; + +public class MockCamera extends DeviceAbstractFactory implements ICamera{ + + private static final Logger logger = LoggerFactory.getLogger(MockCamera.class); + private Float temperature = 0f; + + public MockCamera(String identity) { + super(DeviceType.surveillance_camera, identity); + deviceStatus = DeviceStatus.ready; + } + + @Override + public boolean config(Map input) { + /** + * 模拟配置: 1注册sdk 2登录设备 3参数设置 + */ + deviceStatus = DeviceStatus.online; + params.putAll(input); + return true; + } + + @Override + public boolean open(Map input) { +// deviceStatus = DeviceStatus.working; + deviceStatus = DeviceStatus.online; + logger.info("设备注册成功:{}", identity); + return true; + } + + @Override + public boolean close(Map input) { + deviceStatus = DeviceStatus.offline; + return true; + } + + @Override + public void heartbeat() { + deviceStatus = DeviceStatus.online; + } + + + @Override + public void setTemperature(Float temperature) { + if (temperature!=null && temperature!=0f){ + this.temperature = temperature; + }else { + this.temperature = (float) (Math.random() * 10 + 25); + } + + } + + @Override + public Float getTemperature() { + return temperature; + } +// +// @Override +// public String getVideoUrl(PlayBack playBack) { +// return "rtsp://用户名:密码@IP:554/Streaming/Channels/101/transportmode=unicast"; +// } + + //生成模拟数据 + public List getDetect() { + List detectList = Lists.newArrayList(); + detectList.add(type1()); + detectList.add(type2()); + detectList.add(type3()); + detectList.add(type4()); + detectList.add(type5()); + detectList.addAll(getOilDetect()); + return detectList; +// Random random = new Random(); +// if(random.nextBoolean()) { +// +// +// } else { +// return ; +// } + } + + public List getOilDetect() { + List detectList = Lists.newArrayList(); + detectList.add(Detect.builder() + .processId(DateUtils.parseDateToStr("yyyyMMddHH", DateUtils.getNowDate())) + .detectId("personnel_break_in") + .time(DateUtils.getNowDate()) + .type("personnel_break_in") + .ip("192.168.1.3") + .img("[{\"name\":\"人员闯入\",\"url\":\"/file/mock/1922929838563086336_unload_oil.jpg\"}]") + .data("{\n" + + " \"id\": 88764,\n" + + " \"process_id\": \"1747793444452\",\n" + + " \"type\": \"algorithm\",\n" + + " \"algorithm_id\": 239,\n" + + " \"algorithm_name\": \"非工作人员闯入检测\",\n" + + " \"alarm_time\": \"2025-05-21 10:45:34\",\n" + + " \"process_name\": \"\",\n" + + " \"alarm_level\": \"\",\n" + + " \"img_path\": \"/dw/31070c9bd186422b85c513bab9a154d4/alarm_result/2025-05-21/10_45/image_files/resultPicture/1925020111222431744_unload_oil.jpg\",\n" + + " \"src_img_path\": \"/dw/31070c9bd186422b85c513bab9a154d4/alarm_result/2025-05-21/10_45/video_files/picture/1925020108771794944_Picture.jpg\",\n" + + " \"job_id\": \"9cf5da313fa44a479c464791339f3002\",\n" + + " \"step_id\": \"personnel_break_in\",\n" + + " \"camera_name\": \"XY推流\",\n" + + " \"camera_id\": 4\n" + + "}") + .status(DetectStatusEnum.alert.getCode()) + .build()); + detectList.add(Detect.builder() + .detectId("fire_equipment_recover") + .processId(DateUtils.parseDateToStr("yyyyMMddHH", DateUtils.getNowDate())) + .time(DateUtils.getNowDate()) + .type("fire_equipment_recover") + .ip("192.168.1.3") + .img("[{\"name\":\"设备回收\",\"url\":\"/file/mock/1922931328589545472_unload_oil.jpg\"}]") + .data("{}") + .status(DetectStatusEnum.info.getCode()) + .build()); + detectList.add(Detect.builder() + .processId(DateUtils.parseDateToStr("yyyyMMddHH",DateUtils.getNowDate())) + .detectId("static_ground") + .time(DateUtils.getNowDate()) + .type("static_ground") + .ip("192.168.1.3") + .img("[{\"name\":\"静电接地\",\"url\":\"/file/mock/snap_stream_1747297511120292792.jpeg\"}]") + .data("{\n" + + " \"id\": 88691,\n" + + " \"process_id\": \"1747793444452\",\n" + + " \"type\": \"business\",\n" + + " \"algorithm_id\": 236,\n" + + " \"algorithm_name\": \"静电接地夹与油罐车车体连接检测\",\n" + + " \"alarm_time\": \"2025-05-21 10:42:44\",\n" + + " \"process_name\": \"静电接地连接检测\",\n" + + " \"alarm_level\": \"alert\",\n" + + " \"img_path\": \"/usm/download?filename=snap/snap_stream_1747795366030177691.jpeg\",\n" + + " \"src_img_path\": \"/usm/download?filename=snap/snap_stream_1747795366030177691.jpeg\",\n" + + " \"job_id\": \"9cf5da313fa44a479c464791339f3002\",\n" + + " \"step_id\": \"static_ground\",\n" + + " \"camera_name\": \"XY推流\",\n" + + " \"camera_id\": 4,\n" + + " \"result_data\": []\n" + + "}") + .status(DetectStatusEnum.alert.getCode()) + .build()); + detectList.add(Detect.builder() + .processId(DateUtils.parseDateToStr("yyyyMMddHH",DateUtils.getNowDate())) + .detectId("anti_rolling_device") + .time(DateUtils.getNowDate()) + .type("anti_rolling_device") + .ip("192.168.1.3") + .img("[{\"name\":\"防溜车器\",\"url\":\"/file/mock/snap_stream_1747297509558889554.jpeg\"}]") + .data("{\n" + + " \"id\": 88690,\n" + + " \"process_id\": \"1747793444452\",\n" + + " \"type\": \"business\",\n" + + " \"algorithm_id\": 238,\n" + + " \"algorithm_name\": \"防溜车器检测\",\n" + + " \"alarm_time\": \"2025-05-21 10:42:44\",\n" + + " \"process_name\": \"防溜车器检测\",\n" + + " \"alarm_level\": \"alert\",\n" + + " \"img_path\": \"/usm/download?filename=snap/snap_stream_1747795364464512131.jpeg\",\n" + + " \"src_img_path\": \"/usm/download?filename=snap/snap_stream_1747795364464512131.jpeg\",\n" + + " \"job_id\": \"9cf5da313fa44a479c464791339f3002\",\n" + + " \"step_id\": \"anti_rolling_device\",\n" + + " \"camera_name\": \"XY推流\",\n" + + " \"camera_id\": 4,\n" + + " \"result_data\": []\n" + + "}") + .status(DetectStatusEnum.alert.getCode()) + .build()); + detectList.add(Detect.builder() + .detectId("static_wire_disconnect") + .processId(DateUtils.parseDateToStr("yyyyMMddHH",DateUtils.getNowDate())) + .time(DateUtils.getNowDate()) + .type("static_wire_disconnect") + .ip("192.168.1.3") + .img("[{\"name\":\"静电连接断开\",\"url\":\"/file/mock/snap_stream_1747297217688505045.jpeg\"}]") + .data("{}") + .status(DetectStatusEnum.info.getCode()) + .build()); + detectList.add(Detect.builder() + .detectId("protective_suit") + .processId(DateUtils.parseDateToStr("yyyyMMddHH",DateUtils.getNowDate())) + .time(DateUtils.getNowDate()) + .type("protective_suit") + .ip("192.168.1.3") + .img("[{\"name\":\"防护穿戴\",\"url\":\"/file/mock/1922929834947256320_unload_oil.jpg\"}]") + .data("{\n" + + " \"id\": 88763,\n" + + " \"process_id\": \"1747793444452\",\n" + + " \"type\": \"algorithm\",\n" + + " \"algorithm_id\": 239,\n" + + " \"algorithm_name\": \"非工作人员闯入检测\",\n" + + " \"alarm_time\": \"2025-05-21 10:45:34\",\n" + + " \"process_name\": \"\",\n" + + " \"alarm_level\": \"\",\n" + + " \"img_path\": \"/dw/31070c9bd186422b85c513bab9a154d4/alarm_result/2025-05-21/10_45/image_files/resultPicture/1925020111222431744_unload_oil.jpg\",\n" + + " \"src_img_path\": \"/dw/31070c9bd186422b85c513bab9a154d4/alarm_result/2025-05-21/10_45/video_files/picture/1925020108771794944_Picture.jpg\",\n" + + " \"job_id\": \"9cf5da313fa44a479c464791339f3002\",\n" + + " \"step_id\": \"protective_suit\",\n" + + " \"camera_name\": \"XY推流\",\n" + + " \"camera_id\": 4\n" + + "}") + .status(DetectStatusEnum.info.getCode()) + .build()); + detectList.add(Detect.builder() + .detectId("protective_tools") + .processId(DateUtils.parseDateToStr("yyyyMMddHH",DateUtils.getNowDate())) + .time(DateUtils.getNowDate()) + .type("protective_tools") + .ip("192.168.1.3") + .img("[{\"name\":\"防护工具\",\"url\":\"/file/mock/snap_stream_1747295809559520574.jpg\"}]") + .data("{\n" + + " \"id\": 88781,\n" + + " \"process_id\": \"1747793444452\",\n" + + " \"type\": \"algorithm\",\n" + + " \"algorithm_id\": 162,\n" + + " \"algorithm_name\": \"未摆放灭火器识别\",\n" + + " \"alarm_time\": \"2025-05-21 10:46:24\",\n" + + " \"process_name\": \"\",\n" + + " \"alarm_level\": \"\",\n" + + " \"img_path\": \"/dw/31070c9bd186422b85c513bab9a154d4/alarm_result/2025-05-21/10_46/image_files/resultPicture/1925020320763883520_unload_oil.jpg\",\n" + + " \"src_img_path\": \"/dw/31070c9bd186422b85c513bab9a154d4/alarm_result/2025-05-21/10_46/video_files/picture/1925020318297133056_Picture.jpg\",\n" + + " \"job_id\": \"9cf5da313fa44a479c464791339f3002\",\n" + + " \"step_id\": \"protective_tools\",\n" + + " \"camera_name\": \"XY推流\",\n" + + " \"camera_id\": 4\n" + + "}") + .status(DetectStatusEnum.info.getCode()) + .build()); + detectList.add(Detect.builder() + .processId(DateUtils.parseDateToStr("yyyyMMddHH",DateUtils.getNowDate())) + .detectId("personnel_present") + .time(DateUtils.getNowDate()) + .type("personnel_present") + .ip("192.168.1.3") + .img("[{\"name\":\"人员存在\",\"url\":\"/file/mock/1922929930871062528_unload_oil.jpg\"}]") + .data("{}") + .status(DetectStatusEnum.alert.getCode()) + .build()); + detectList.add(Detect.builder() + .processId(DateUtils.parseDateToStr("yyyyMMddHH",DateUtils.getNowDate())) + .detectId("stable_oil_time") + .time(DateUtils.getNowDate()) + .type("stable_oil_time") + .ip("192.168.1.3") + .img("[{\"name\":\"稳油时间\",\"url\":\"/file/mock/1922923895776079872_unload_oil.jpg\"}]") + .data("{}") + .status(DetectStatusEnum.alert.getCode()) + .build()); + detectList.add(Detect.builder() + .processId(DateUtils.parseDateToStr("yyyyMMddHH",DateUtils.getNowDate())) + .detectId("oil_pipe_remove") + .time(DateUtils.getNowDate()) + .type("oil_pipe_remove") + .ip("192.168.1.3") + .img("[{\"name\":\"油管拆除顺序\",\"url\":\"/file/mock/1922929875453345792_unload_oil.jpg\"}]") + .data("{}") + .status(DetectStatusEnum.info.getCode()) + .build()); + detectList.add(Detect.builder() + .detectId("plug_connection_status") + .processId(DateUtils.parseDateToStr("yyyyMMddHH",DateUtils.getNowDate())) + .time(DateUtils.getNowDate()) + .type("plug_connection_status") + .ip("192.168.1.3") + .img("[{\"name\":\"油管连接\",\"url\":\"/file/mock/1922923892065460224_unload_oil.jpg\"}]") + .data("{}") + .status(DetectStatusEnum.info.getCode()) + .build()); + detectList.add(Detect.builder() + .processId(DateUtils.parseDateToStr("yyyyMMddHH",DateUtils.getNowDate())) + .detectId("car_location") + .time(DateUtils.getNowDate()) + .type("car_location") + .ip("192.168.1.3") + .img("[{\"name\":\"车辆位置\",\"url\":\"/file/mock/1922923254767132672_unload_oil.jpg\"}]") + .data("{\n" + + " \"id\": 88696,\n" + + " \"process_id\": \"1747793444452\",\n" + + " \"type\": \"algorithm\",\n" + + " \"algorithm_id\": 47,\n" + + " \"algorithm_name\": \"油罐车检测\",\n" + + " \"alarm_time\": \"2025-05-21 10:42:47\",\n" + + " \"process_name\": \"\",\n" + + " \"alarm_level\": \"\",\n" + + " \"img_path\": \"/dw/31070c9bd186422b85c513bab9a154d4/alarm_result/2025-05-21/10_42/image_files/resultPicture/1925019412336910336_unload_oil.jpg\",\n" + + " \"src_img_path\": \"/dw/31070c9bd186422b85c513bab9a154d4/alarm_result/2025-05-21/10_42/video_files/picture/1925019409706446848_Picture.jpg\",\n" + + " \"job_id\": \"9cf5da313fa44a479c464791339f3002\",\n" + + " \"step_id\": \"car_location\",\n" + + " \"camera_name\": \"XY推流\",\n" + + " \"camera_id\": 4\n" + + "}") + .status(DetectStatusEnum.info.getCode()) + .build()); + detectList.add(Detect.builder() + .processId(DateUtils.parseDateToStr("yyyyMMddHH",DateUtils.getNowDate())) + .detectId("car_leave") + .time(DateUtils.getNowDate()) + .type("car_leave") + .ip("192.168.1.3") + .img("[{\"name\":\"车辆离场\",\"url\":\"/file/mock/snap_stream_1747297679559204912.jpeg\"}]") + .data("{}") + .status(DetectStatusEnum.info.getCode()) + .build()); + return detectList; + } + + private Detect type1() { + String dataStr = "{\"autoWrite\":true,\"fRuleTemperature\":50,\"autoRead\":true,\"dwThermalInfoLen\":0,\"dwPicLen\":254826,\"dwSize\":248,\"dwTemperatureSuddenChangeCycle\":60,\"fCurrTemperature\":54.5,\"byThermometryUnit\":0,\"dwThermalPicLen\":20926,\"byAlarmType\":0,\"byPicTransType\":0,\"byAlarmRule\":0,\"byRuleID\":0,\"dwChannel\":33,\"dwAlertFilteringTime\":0,\"byAlarmLevel\":0}"; + JSONArray imgJson = new JSONArray(); + JSONObject img1 = new JSONObject(); + img1.put("name", "可见光"); + img1.put("url", "/file/mock/1_1.jpg"); + JSONObject img2 = new JSONObject(); + img2.put("name", "热成像"); + img2.put("url", "/file/mock/1_2.jpg"); + imgJson.add(img1); + imgJson.add(img2); + return Detect.builder() + .detectId(IdUtils.fastSimpleUUID()) + .status(DetectStatusEnum.alert.getCode()) + .time(DateUtils.getNowDate()) + .type(DetectType.COMM_THERMOMETRY_ALARM.getDesc()) + .ip("192.168.1.60") + .channel(33) + .img(imgJson.toJSONString()) + .data(dataStr) + .build(); + } + + private Detect type2() { + String dataStr = "{\"autoWrite\":true,\"fRuleTemperature\":50,\"autoRead\":true,\"dwThermalInfoLen\":0,\"dwPicLen\":254826,\"dwSize\":248,\"dwTemperatureSuddenChangeCycle\":60,\"fCurrTemperature\":62,\"byThermometryUnit\":0,\"dwThermalPicLen\":20926,\"byAlarmType\":0,\"byPicTransType\":0,\"byAlarmRule\":0,\"byRuleID\":0,\"dwChannel\":33,\"dwAlertFilteringTime\":0,\"byAlarmLevel\":1}"; + JSONArray imgJson = new JSONArray(); + JSONObject img1 = new JSONObject(); + img1.put("name", "可见光"); + img1.put("url", "/file/mock/2_1.jpg"); + JSONObject img2 = new JSONObject(); + img2.put("name", "热成像"); + img2.put("url", "/file/mock/2_2.jpg"); + imgJson.add(img1); + imgJson.add(img2); + return Detect.builder() + .detectId(IdUtils.fastSimpleUUID()) + .status(DetectStatusEnum.alert.getCode()) + .time(DateUtils.getNowDate()) + .type(DetectType.COMM_THERMOMETRY_ALARM.getDesc()) + .ip("192.168.1.60") + .channel(33) + .img(imgJson.toJSONString()) + .data(dataStr) + .build(); + } + + private Detect type3() { + //String dataStr = "{\"timeStamp\":19445987,\"aitype\":0,\"width\":\"1920\",\"frameNum\":19572712,\"version\":\"2.1.0\",\"targets\":[{\"obj\":{\"valid\":1,\"rect\":{\"w\":\"0.021088\",\"x\":\"0.441813\",\"h\":\"0.079419\",\"y\":\"0.520892\"},\"visible\":1,\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":1000,\"id\":11018,\"type\":5},\"nodeID\":3},{\"obj\":{\"valid\":1,\"rect\":{\"w\":\"0.042717\",\"x\":\"0.452338\",\"h\":\"0.077729\",\"y\":\"0.483798\"},\"visible\":1,\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":1000,\"id\":11019,\"type\":4},\"nodeID\":3},{\"obj\":{\"valid\":1,\"rect\":{\"w\":\"0.043799\",\"x\":\"0.438569\",\"h\":\"0.112313\",\"y\":\"0.489800\"},\"visible\":1,\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":833,\"id\":11020,\"type\":3},\"nodeID\":3},{\"obj\":{\"valid\":1,\"rect\":{\"w\":\"0.088281\",\"x\":\"0.426563\",\"h\":\"0.141304\",\"y\":\"0.466033\"},\"visible\":1,\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":1000,\"id\":398,\"type\":1},\"nodeID\":3}],\"errorcode\":0,\"events\":{\"alertInfo\":[{\"ruleInfo\":{\"ruleName\":\"打电话检测\",\"movDir\":0,\"triggerType\":1073758209,\"ruleID\":2,\"region\":{\"polygon\":[{\"x\":\"0.010000\",\"y\":\"0.010000\"},{\"x\":\"0.990000\",\"y\":\"0.010000\"},{\"x\":\"0.990000\",\"y\":\"0.990000\"},{\"x\":\"0.010000\",\"y\":\"0.990000\"}]}},\"nodeID\":3,\"target\":{\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":833,\"id\":11020,\"type\":3,\"region\":{\"rect\":{\"w\":\"0.043799\",\"x\":\"0.438569\",\"h\":\"0.112313\",\"y\":\"0.489800\"}}}}]},\"height\":\"1080\"}"; + String dataStr = "{\"events\":{\"alertInfo\":[{\"ruleInfo\":{\"ruleName\":\"抽烟检测\",\"movDir\":0,\"triggerType\":1073758209,\"ruleID\":1,\"region\":{\"polygon\":[{\"x\":\"0.010000\",\"y\":\"0.010000\"},{\"x\":\"0.990000\",\"y\":\"0.010000\"},{\"x\":\"0.990000\",\"y\":\"0.990000\"},{\"x\":\"0.010000\",\"y\":\"0.990000\"}]}},\"nodeID\":3,\"target\":{\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":634,\"id\":11027,\"type\":2,\"region\":{\"rect\":{\"w\":\"0.022987\",\"x\":\"0.502834\",\"h\":\"0.020477\",\"y\":\"0.518633\"}},\"relatedTargetList\":[{\"modelID\":\"00012023050501005hms3classDet00\",\"id\":11024},{\"modelID\":\"00012023050501005hms3classDet00\",\"id\":11025}]}}]}}"; + JSONArray imgJson = new JSONArray(); + JSONObject img1 = new JSONObject(); + img1.put("name", "报警图片"); + img1.put("url", "/file/mock/3.jpg"); + imgJson.add(img1); + return Detect.builder() + .detectId(IdUtils.fastSimpleUUID()) + .status(DetectStatusEnum.alert.getCode()) + .time(DateUtils.getNowDate()) + .type(DetectType.H930_MODEL_SPD.getDesc()) + .ip("192.168.1.60") + .channel(35) + .img(imgJson.toJSONString()) + .data(dataStr) + .build(); + } + + private Detect type4() { + //String dataStr = "{\"timeStamp\":19786507,\"aitype\":0,\"width\":\"1920\",\"frameNum\":19581225,\"version\":\"2.1.0\",\"targets\":[{\"obj\":{\"valid\":1,\"rect\":{\"w\":\"0.029065\",\"x\":\"0.501966\",\"h\":\"0.076185\",\"y\":\"0.519246\"},\"visible\":1,\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":1000,\"id\":11024,\"type\":5},\"nodeID\":3},{\"obj\":{\"valid\":1,\"rect\":{\"w\":\"0.040426\",\"x\":\"0.514687\",\"h\":\"0.081359\",\"y\":\"0.487838\"},\"visible\":1,\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":1000,\"id\":11025,\"type\":4},\"nodeID\":3},{\"obj\":{\"valid\":1,\"rect\":{\"w\":\"0.022987\",\"x\":\"0.502834\",\"h\":\"0.020477\",\"y\":\"0.518633\"},\"visible\":1,\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":634,\"id\":11027,\"type\":2},\"nodeID\":3},{\"obj\":{\"valid\":1,\"rect\":{\"w\":\"0.074219\",\"x\":\"0.517188\",\"h\":\"0.172554\",\"y\":\"0.451087\"},\"visible\":1,\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":999,\"id\":400,\"type\":1},\"nodeID\":3}],\"errorcode\":0,\"events\":{\"alertInfo\":[{\"ruleInfo\":{\"ruleName\":\"抽烟检测\",\"movDir\":0,\"triggerType\":1073758209,\"ruleID\":1,\"region\":{\"polygon\":[{\"x\":\"0.010000\",\"y\":\"0.010000\"},{\"x\":\"0.990000\",\"y\":\"0.010000\"},{\"x\":\"0.990000\",\"y\":\"0.990000\"},{\"x\":\"0.010000\",\"y\":\"0.990000\"}]}},\"nodeID\":3,\"target\":{\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":634,\"id\":11027,\"type\":2,\"region\":{\"rect\":{\"w\":\"0.022987\",\"x\":\"0.502834\",\"h\":\"0.020477\",\"y\":\"0.518633\"}},\"relatedTargetList\":[{\"modelID\":\"00012023050501005hms3classDet00\",\"id\":11024},{\"modelID\":\"00012023050501005hms3classDet00\",\"id\":11025}]}}]},\"height\":\"1080\"}"; + String dataStr = "{\"events\":{\"alertInfo\":[{\"ruleInfo\":{\"ruleName\":\"抽烟检测\",\"movDir\":0,\"triggerType\":1073758209,\"ruleID\":1,\"region\":{\"polygon\":[{\"x\":\"0.010000\",\"y\":\"0.010000\"},{\"x\":\"0.990000\",\"y\":\"0.010000\"},{\"x\":\"0.990000\",\"y\":\"0.990000\"},{\"x\":\"0.010000\",\"y\":\"0.990000\"}]}},\"nodeID\":3,\"target\":{\"modelID\":\"00012023050501005hms3classDet00\",\"confidence\":634,\"id\":11027,\"type\":2,\"region\":{\"rect\":{\"w\":\"0.022987\",\"x\":\"0.502834\",\"h\":\"0.020477\",\"y\":\"0.518633\"}},\"relatedTargetList\":[{\"modelID\":\"00012023050501005hms3classDet00\",\"id\":11024},{\"modelID\":\"00012023050501005hms3classDet00\",\"id\":11025}]}}]}}"; + JSONArray imgJson = new JSONArray(); + JSONObject img1 = new JSONObject(); + img1.put("name", "报警图片"); + img1.put("url", "/file/mock/4.jpg"); + imgJson.add(img1); + return Detect.builder() + .detectId(IdUtils.fastSimpleUUID()) + .status(DetectStatusEnum.alert.getCode()) + .time(DateUtils.getNowDate()) + .type(DetectType.H930_MODEL_SPD.getDesc()) + .ip("192.168.1.60") + .channel(35) + .img(imgJson.toJSONString()) + .data(dataStr) + .build(); + } + + private Detect type5() { + String dataStr = "{\"byThermometryUnit\":0,\"fRuleTemperature\":10.0,\"byAlarmType\":4,\"byAlarmLevel\":0,\"fCurrTemperature\":28.800003}"; + JSONArray imgJson = new JSONArray(); + JSONObject img1 = new JSONObject(); + img1.put("name", "可见光"); + img1.put("url", "/file/mock/2_1.jpg"); + JSONObject img2 = new JSONObject(); + img2.put("name", "热成像"); + img2.put("url", "/file/mock/2_2.jpg"); + imgJson.add(img1); + imgJson.add(img2); + return Detect.builder() + .detectId(IdUtils.fastSimpleUUID()) + .status(DetectStatusEnum.alert.getCode()) + .time(DateUtils.getNowDate()) + .type(DetectType.COMM_THERMOMETRY_ALARM.getDesc()) + .ip("192.168.1.60") + .channel(33) + .img(imgJson.toJSONString()) + .data(dataStr) + .build(); + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/factory/SophgoBox.java b/box-device/src/main/java/com/mathvision/box/device/core/factory/SophgoBox.java new file mode 100644 index 0000000..936db78 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/factory/SophgoBox.java @@ -0,0 +1,59 @@ +package com.mathvision.box.device.core.factory; + +import com.mathvision.box.device.common.domin.PlayBack; +import com.mathvision.box.common.enums.DeviceStatus; +import com.mathvision.box.device.common.domin.SignIn; +import com.mathvision.box.device.common.enums.DeviceType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.Map; + +/** + * 算能盒子 + */ +public class SophgoBox extends DeviceAbstractFactory implements IBox{ + + private static final Logger logger = LoggerFactory.getLogger(SophgoBox.class); + + public SophgoBox(String identity) { + super(DeviceType.box, identity); + deviceStatus = DeviceStatus.ready; + } + + @Override + public boolean config(Map input) { + deviceStatus = DeviceStatus.online; + this.params.putAll(input); + return true; + } + + @Override + public boolean open(Map input) { +// deviceStatus = DeviceStatus.working; + deviceStatus = DeviceStatus.online; + return true; + } + + @Override + public boolean close(Map input) { + deviceStatus = DeviceStatus.offline; + return true; + } + + @Override + public void heartbeat() { + deviceStatus = DeviceStatus.online; + } + + @Override + public List getChild() { + return null; + } + + @Override + public String getVideoUrl(PlayBack playBack) { + return null; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/core/strategy/AlarmStrategy.java b/box-device/src/main/java/com/mathvision/box/device/core/strategy/AlarmStrategy.java new file mode 100644 index 0000000..700e2d6 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/core/strategy/AlarmStrategy.java @@ -0,0 +1,109 @@ +package com.mathvision.box.device.core.strategy; + +import lombok.Getter; + +import java.util.*; +import java.util.concurrent.*; + +public class AlarmStrategy { + // 线程安全的计数器存储 + private static final ConcurrentMap consecutiveCountMap = new ConcurrentHashMap<>(); + private static final ConcurrentMap lastTriggerTimeMap = new ConcurrentHashMap<>(); + private static final ConcurrentMap> timeWindowMap = new ConcurrentHashMap<>(); + + /** + * 连续次数策略(带自动重置) + * + * @param alarmType 报警类型标识 + * @param countThreshold 次数阈值 + * @return 是否触发报警 + */ + private static boolean filterByConsecutiveTimes(String alarmType, int countThreshold) { + int count = consecutiveCountMap.merge(alarmType, 1, Integer::sum); + if (count >= countThreshold) { + consecutiveCountMap.put(alarmType, 0); + return true; + } + return false; + } + + /** + * 智能间隔时间策略(防抖动) + * + * @param alarmType 报警类型标识 + * @param timeThreshold 最小间隔(秒) + * @return 是否触发报警 + */ + private static boolean filterByIntervalTime(String alarmType, int timeThreshold) { + long currentTime = System.currentTimeMillis(); + return lastTriggerTimeMap.compute(alarmType, (k, v) -> (v == null || (currentTime - v) >= timeThreshold * 1000L) ? currentTime : v) == currentTime; + } + + /** + * 滑动窗口计数策略(防风暴) + * + * @param alarmType 报警类型标识 + * @param timeThreshold 最小间隔(秒) + * @param countThreshold 次数阈值 + * @return 是否触发报警 + */ + private static boolean filterByWindowCount(String alarmType, int timeThreshold, int countThreshold) { + long currentTime = System.currentTimeMillis(); + Queue timeQueue = timeWindowMap.computeIfAbsent(alarmType, k -> new ConcurrentLinkedQueue<>()); + // 移除过期记录 + timeQueue.forEach(time -> { + if (currentTime - time > timeThreshold * 1000L) { + timeQueue.remove(time); + } + }); + + timeQueue.offer(currentTime); + return timeQueue.size() >= countThreshold; + } + + /** + * 报警策略 + * + * @param alarmStrategyType 策略类型 (consecutive_times:连续次数;interval_time:间隔时间;window_count:滑动窗口计数) + * @param alarmType 报警类型标识 + * @param timeThreshold 时间窗口(秒) + * @param countThreshold 次数阈值 + * @return 是否触发报警 + */ + public static boolean IsAlarm(AlarmStrategyType alarmStrategyType, String alarmType, int countThreshold, int timeThreshold) { + switch (alarmStrategyType) { + case CONSECUTIVE_TIMES: + return filterByConsecutiveTimes(alarmType, countThreshold); + case INTERVAL_TIME: + return filterByIntervalTime(alarmType, timeThreshold); + case WINDOW_COUNT: + return filterByWindowCount(alarmType, timeThreshold, countThreshold); + default: + return false; + } + } + + @Getter + public enum AlarmStrategyType { + CONSECUTIVE_TIMES("consecutive_times", "连续次数"), + INTERVAL_TIME("interval_time", "间隔时间"), + WINDOW_COUNT("window_count", "滑动窗口计数"); + + private final String code; + private final String description; + + AlarmStrategyType(String code, String description) { + this.code = code; + this.description = description; + } + + public static AlarmStrategyType getType(String type) { + for (AlarmStrategyType value : values()) { + if (value.getCode().equals(type) || value.name().equals(type)) { + return value; + } + } + return null; + } + } +} \ No newline at end of file diff --git a/box-device/src/main/java/com/mathvision/box/device/exception/HCNetSDKException.java b/box-device/src/main/java/com/mathvision/box/device/exception/HCNetSDKException.java new file mode 100644 index 0000000..2f89444 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/exception/HCNetSDKException.java @@ -0,0 +1,31 @@ +package com.mathvision.box.device.exception; + +import com.mathvision.box.device.common.enums.HCNetSDKErrorEnum; + +/** + * 海康SDK异常 + * + * @author fy + */ +public class HCNetSDKException extends Exception { + private final int errorCode; + + public HCNetSDKException(String message, int errorCode, String detail) { + super(String.format("%s [Code:%d, Detail:%s]", message, errorCode, detail)); + this.errorCode = errorCode; + } + + public HCNetSDKException(String message, String detail) { + super(String.format("%s [Code:%d, Detail:%s]", message, 5001, detail)); + this.errorCode = 5001; + } + + public HCNetSDKException(String message, int errorCode) { + super(String.format("%s [Code:%d, Detail:%s]", message, errorCode, HCNetSDKErrorEnum.getByCode(errorCode).getMessage())); + this.errorCode = 5001; + } + + public int getErrorCode() { + return errorCode; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/sdk/CorerainAPI.java b/box-device/src/main/java/com/mathvision/box/device/sdk/CorerainAPI.java new file mode 100644 index 0000000..e33ed2e --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/sdk/CorerainAPI.java @@ -0,0 +1,236 @@ +package com.mathvision.box.device.sdk; + +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Maps; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.http.HttpReqTemp; +import com.mathvision.box.common.utils.http.HttpUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.util.Assert; + +import java.util.Map; + +/** + * 鲲云盒子接口 + */ +@Slf4j +public class CorerainAPI { + private static String ip = null; + + private static String port = null; + + private static String accessToken = null; + + private static final int timeout = 5000; + + private static final int retryCount = 2; + + private static final String http = "http://"; + + public CorerainAPI(String ip, String port, String appId, String appSecret) { + this.ip = ip; + this.port = port; + this.accessToken = openapi_mc_v1_authenticate(appId, appSecret); + } + + /** + * @Name 第三方登录认证. + * @URL POST /mc/v1/authenticate + * @Description 使用获取的秘钥信息(APP ID和访问秘钥)调用此接口,获取accessToken的值(token有效时间7天) + */ + public String openapi_mc_v1_authenticate(String appId, String appSecret) { + Map body = Maps.newHashMap(); + body.put("app_id", appId); + body.put("app_secret", appSecret); + HttpReqTemp reqTemp = new HttpReqTemp() + .withMethod(HttpMethod.POST) + .withUrl(http + ip + ":" + port + "/openapi/mc/v1/authenticate") + .withBody(JSONObject.toJSONString(body)) + .withMediaType(MediaType.APPLICATION_JSON) + .withTimeout(timeout) + .withRetryCount(retryCount); + String responseStr = HttpUtil.request(reqTemp); + JSONObject response = JSONObject.parseObject(responseStr); + if (response.containsKey("accessToken")) { + return response.getString("accessToken"); + } else { + log.error("【CorerainAPI】: openapi_mc_v1_authenticate:登录失败; info:{}", responseStr); + return null; + } + } + + /** + * @Name 获取各卸油步骤当前报警结果. + * @URL GET /cb/v1/callback/gas_station/steps + * @Description + */ + public String openapi_cb_v1_callback_gas_station_steps(String jobId) { + checkOauth(); + HttpReqTemp reqTemp = new HttpReqTemp().withOauth(accessToken) + .withMethod(HttpMethod.GET) + .withUrl(http + ip + ":" + port + "/openapi/cb/v1/callback/gas_station/steps") + .withQueryParam("job_id", jobId) + .withMediaType(MediaType.APPLICATION_JSON) + .withTimeout(timeout) + .withRetryCount(retryCount); + return HttpUtil.request(reqTemp); + } + + /** + * @Name 获取任务详情. + * @URL GET /vam/v1/gas_station/jobs + * @Description + */ + public String openapi_vam_v1_gas_station_jobs() { + checkOauth(); + HttpReqTemp reqTemp = new HttpReqTemp().withOauth(accessToken) + .withMethod(HttpMethod.GET) + .withUrl(http + ip + ":" + port + "/openapi/vam/v1/gas_station/jobs") + .withMediaType(MediaType.APPLICATION_JSON) + .withTimeout(timeout) + .withRetryCount(retryCount); + return HttpUtil.request(reqTemp); + } + + /** + * @Name 启用任务. + * @URL POST /vam/v1/gas_station/jobs/start + * @Description + */ + public String openapi_vam_v1_gas_station_jobs_start() { + checkOauth(); + HttpReqTemp reqTemp = new HttpReqTemp().withOauth(accessToken) + .withMethod(HttpMethod.POST) + .withUrl(http + ip + ":" + port + "/openapi/vam/v1/gas_station/jobs/start") + .withMediaType(MediaType.APPLICATION_JSON) + .withTimeout(timeout) + .withRetryCount(retryCount); + return HttpUtil.request(reqTemp); + } + + /** + * @Name 停用任务. + * @URL POST /vam/v1/gas_station/jobs/stop + * @Description + */ + public String openapi_vam_v1_gas_station_jobs_stop() { + checkOauth(); + HttpReqTemp reqTemp = new HttpReqTemp().withOauth(accessToken) + .withMethod(HttpMethod.POST) + .withUrl(http + ip + ":" + port + "/openapi/vam/v1/gas_station/jobs/stop") + .withMediaType(MediaType.APPLICATION_JSON) + .withTimeout(timeout) + .withRetryCount(retryCount); + return HttpUtil.request(reqTemp); + } + + + /** + * @Name 获取过程日志列表. + * @URL GET /cb/v1/gas_station/logs + * @Description + */ + public String openapi_cb_v1_gas_station_logs(String processId, String type, Integer algorithmId, String startTime, String endTime, String alarmLevel, Integer current, Integer pageSize, String ids, String stepId) { + checkOauth(); + HttpReqTemp reqTemp = new HttpReqTemp().withOauth(accessToken) + .withMethod(HttpMethod.GET) + .withUrl(http + ip + ":" + port + "/openapi/cb/v1/gas_station/logs") + .withMediaType(MediaType.APPLICATION_JSON) + .withTimeout(timeout) + .withRetryCount(retryCount); + if (StringUtils.isNotBlank(processId)) { + reqTemp.withQueryParam("process_id", processId); + } + if (StringUtils.isNotBlank(type)) { + reqTemp.withQueryParam("type", type); + } + if (algorithmId != null && algorithmId > 0) { + reqTemp.withQueryParam("algorithm_id", algorithmId.toString()); + } + if (StringUtils.isNotBlank(startTime)) { + reqTemp.withQueryParam("start_time", startTime); + } + if (StringUtils.isNotBlank(endTime)) { + reqTemp.withQueryParam("end_time", endTime); + } + if (StringUtils.isNotBlank(alarmLevel)) { + reqTemp.withQueryParam("alarm_level", alarmLevel); + } + if (current != null) { + reqTemp.withQueryParam("current", current.toString()); + } + if (pageSize != null && pageSize > 0) { + reqTemp.withQueryParam("page_size", pageSize.toString()); + } + if (StringUtils.isNotBlank(ids)) { + reqTemp.withQueryParam("ids", ids); + } + if (StringUtils.isNotBlank(stepId)) { + reqTemp.withQueryParam("step_id", stepId); + } + return HttpUtil.request(reqTemp); + } + + /** + * @Name 获取摄像头列表. + * @URL GET /usm/v1/camera/list + * @Param current 当前页码(默认: 1) + * @Param pageSize 每页数量(默认: 10) + * @Param ids 点位ID列表: ids=0 + * @Param name 点位名称: name=0 + * @Param groupId 点位分组ID + * @Param sourceId 视频源ID + * @Description + */ + public String openapi_usm_v1_camera_list(Integer current, Integer pageSize, String ids, String name, Long groupId, Long sourceId) { + checkOauth(); + HttpReqTemp reqTemp = new HttpReqTemp().withOauth(accessToken) + .withMethod(HttpMethod.GET) + .withUrl(http + ip + ":" + port + "/openapi/usm/v1/camera/list") + .withMediaType(MediaType.APPLICATION_JSON) + .withTimeout(timeout) + .withRetryCount(retryCount); + if (current != null) { + reqTemp.withQueryParam("current", current.toString()); + } + if (pageSize != null && pageSize > 0) { + reqTemp.withQueryParam("page_size", pageSize.toString()); + } + if (StringUtils.isNotBlank(ids)) { + reqTemp.withQueryParam("ids", ids); + } + if (StringUtils.isNotBlank(name)) { + reqTemp.withQueryParam("name", name); + } + if (groupId != null && groupId > 0) { + reqTemp.withQueryParam("group_id", groupId.toString()); + } + if (sourceId != null && sourceId > 0) { + reqTemp.withQueryParam("source_id", sourceId.toString()); + } + return HttpUtil.request(reqTemp); + } + + /** + * @Name 获取分析服务状态列表. + * @URL GET /openapi/vam/v1/service/list_executing + * @Description + */ + public String openapi_vam_v1_service_list_executing() { + checkOauth(); + HttpReqTemp reqTemp = new HttpReqTemp().withOauth(accessToken) + .withMethod(HttpMethod.GET) + .withUrl(http + ip + ":" + port + "/openapi/vam/v1/service/list_executing") + .withMediaType(MediaType.APPLICATION_JSON) + .withTimeout(timeout) + .withRetryCount(retryCount); + return HttpUtil.request(reqTemp); + } + + public void checkOauth() { + Assert.isTrue(StringUtils.isNotNull(accessToken), "鲲云盒子未登录授权"); + return; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/sdk/HCNetAPI.java b/box-device/src/main/java/com/mathvision/box/device/sdk/HCNetAPI.java new file mode 100644 index 0000000..5727ba7 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/sdk/HCNetAPI.java @@ -0,0 +1,134 @@ +package com.mathvision.box.device.sdk; + +import lombok.extern.slf4j.Slf4j; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.*; + +@Slf4j +public class HCNetAPI { + private static List getAllTemperature(HCNetSDK hCNetSDK, int lUserID, int channelNum) { + boolean bRet = false; + int nErr; + HCNetSDK.NET_DVR_THERMOMETRY_PRESETINFO m_struThermometryInfo = new HCNetSDK.NET_DVR_THERMOMETRY_PRESETINFO(); + m_struThermometryInfo.dwSize = m_struThermometryInfo.size(); + + HCNetSDK.NET_DVR_THERMOMETRY_COND m_struThermometryCond = new HCNetSDK.NET_DVR_THERMOMETRY_COND(); + m_struThermometryCond.dwSize = m_struThermometryCond.size(); + m_struThermometryCond.dwChannel = 1; + m_struThermometryCond.wPresetNo = 1; + m_struThermometryCond.write(); + + HCNetSDK.NET_DVR_STD_CONFIG struCfg = new HCNetSDK.NET_DVR_STD_CONFIG(); + struCfg.lpCondBuffer = m_struThermometryCond.getPointer(); + struCfg.dwCondSize = m_struThermometryCond.size(); + struCfg.lpOutBuffer = m_struThermometryInfo.getPointer(); + struCfg.dwOutSize = m_struThermometryInfo.size(); + + HCNetSDK.BYTE_ARRAY m_szStatusBuf = new HCNetSDK.BYTE_ARRAY(4096 * 4); + struCfg.lpStatusBuffer = m_szStatusBuf.getPointer(); + struCfg.dwStatusSize = 4096 * 4; + struCfg.byDataType = 0; + + bRet = hCNetSDK.NET_DVR_GetSTDConfig(lUserID, HCNetSDK.NET_DVR_GET_THERMOMETRY_PRESETINFO, struCfg); + if (!bRet) { + nErr = hCNetSDK.NET_DVR_GetLastError(); +// log.error("NET_DVR_GetSTDConfig失败,errCode:{}", nErr); + return null; + } + + m_struThermometryInfo.dwSize = m_struThermometryInfo.size(); + m_struThermometryInfo.wPresetNo = 1; + m_struThermometryInfo.struPresetInfo[0] = new HCNetSDK.NET_DVR_THERMOMETRY_PRESETINFO_PARAM(); + m_struThermometryInfo.struPresetInfo[0].byEnabled = 1; + m_struThermometryInfo.struPresetInfo[0].byRuleID = 1; + m_struThermometryInfo.struPresetInfo[0].wDistance = 10; + m_struThermometryInfo.struPresetInfo[0].fEmissivity = (float) 0.9599; + m_struThermometryInfo.struPresetInfo[0].byReflectiveEnabled = 0; + m_struThermometryInfo.struPresetInfo[0].fReflectiveTemperature = 20; + m_struThermometryInfo.struPresetInfo[0].byRuleCalibType = 2; + //m_struThermometryInfo.struPresetInfo[0].szRuleName ="1"; + m_struThermometryInfo.struPresetInfo[0].byDistanceUnit = 0; + //m_struThermometryInfo.struPresetInfo[0].byemissivityMode = 0; + m_struThermometryInfo.struPresetInfo[0].struPoint = new HCNetSDK.NET_VCA_POINT(); + m_struThermometryInfo.struPresetInfo[0].struPoint.fX = 0; + m_struThermometryInfo.struPresetInfo[0].struPoint.fY = 0; + m_struThermometryInfo.struPresetInfo[0].struPoint.write(); + m_struThermometryInfo.struPresetInfo[0].struRegion = new HCNetSDK.NET_VCA_POLYGON(); + m_struThermometryInfo.struPresetInfo[0].struRegion.dwPointNum = 2; + m_struThermometryInfo.struPresetInfo[0].struRegion.struPos[0] = new HCNetSDK.NET_VCA_POINT(); + m_struThermometryInfo.struPresetInfo[0].struRegion.struPos[0].fX = (float) 0.187; + m_struThermometryInfo.struPresetInfo[0].struRegion.struPos[0].fY = (float) 0.6119; + m_struThermometryInfo.struPresetInfo[0].struRegion.struPos[0].write(); + m_struThermometryInfo.struPresetInfo[0].struRegion.struPos[1] = new HCNetSDK.NET_VCA_POINT(); + m_struThermometryInfo.struPresetInfo[0].struRegion.struPos[1].fX = (float) 0.876; + m_struThermometryInfo.struPresetInfo[0].struRegion.struPos[1].fY = (float) 0.569; + m_struThermometryInfo.struPresetInfo[0].struRegion.struPos[1].write(); + m_struThermometryInfo.struPresetInfo[0].struRegion.write(); + m_struThermometryInfo.write(); + struCfg.lpInBuffer = m_struThermometryInfo.getPointer(); + struCfg.dwInSize = m_struThermometryInfo.size(); + + bRet = hCNetSDK.NET_DVR_SetSTDConfig(lUserID, HCNetSDK.NET_DVR_SET_THERMOMETRY_PRESETINFO, struCfg); + + HCNetSDK.NET_DVR_JPEGPICTURE_WITH_APPENDDATA m_strJpegWithAppenData = new HCNetSDK.NET_DVR_JPEGPICTURE_WITH_APPENDDATA(); + m_strJpegWithAppenData.dwSize = m_strJpegWithAppenData.size(); + m_strJpegWithAppenData.dwChannel = 1; + HCNetSDK.BYTE_ARRAY ptrJpegByte = new HCNetSDK.BYTE_ARRAY(2 * 1024 * 1024); + HCNetSDK.BYTE_ARRAY ptrP2PDataByte = new HCNetSDK.BYTE_ARRAY(2 * 1024 * 1024); + m_strJpegWithAppenData.pJpegPicBuff = ptrJpegByte.getPointer(); + m_strJpegWithAppenData.pP2PDataBuff = ptrP2PDataByte.getPointer(); + + + bRet = hCNetSDK.NET_DVR_CaptureJPEGPicture_WithAppendData(lUserID, channelNum, m_strJpegWithAppenData); + if (bRet) { + //测温数据 + if (m_strJpegWithAppenData.dwP2PDataLen > 0) { + return convertToFloatList(m_strJpegWithAppenData.pP2PDataBuff.getByteBuffer(0, m_strJpegWithAppenData.dwP2PDataLen), true); + } + } + return null; + } + + /** + * 将字节数组转换为Float列表 + * + * @param byteBuffer 字节数组 + * @param isLittleEndian 是否小端字节序 + * @return + */ + private static List convertToFloatList(ByteBuffer byteBuffer, boolean isLittleEndian) { + List result = new ArrayList<>(); + byteBuffer.order(isLittleEndian ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); + + while (byteBuffer.remaining() >= 4) { + float value = byteBuffer.getFloat(); + result.add(value); + } + + return result; + } + + /** + * 获取最高温度 + */ + public static Float getHighestTemperature(HCNetSDK hCNetSDK, int lUserID, int channelNum) { + return Optional.ofNullable(getAllTemperature(hCNetSDK, lUserID, channelNum)).orElse(Collections.emptyList()).stream().max(Comparator.comparingDouble(Float::floatValue)).orElse(null); + } + + /** + * 获取最低温度 + */ + public static Float getLowestTemperature(HCNetSDK hCNetSDK, int lUserID, int channelNum) { + + return Optional.ofNullable(getAllTemperature(hCNetSDK, lUserID, channelNum)).orElse(Collections.emptyList()).stream().min(Comparator.comparingDouble(Float::floatValue)).orElse(null); + } + + /** + * 获取平均温度 + */ + public static Float getAverageTemperature(HCNetSDK hCNetSDK, int lUserID, int channelNum) { + return new Double(Optional.ofNullable(getAllTemperature(hCNetSDK, lUserID, channelNum)).orElse(Collections.emptyList()).stream().mapToDouble(Float::floatValue).average().orElse(0d)).floatValue(); + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/sdk/HCNetSDK.java b/box-device/src/main/java/com/mathvision/box/device/sdk/HCNetSDK.java new file mode 100644 index 0000000..13901ed --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/sdk/HCNetSDK.java @@ -0,0 +1,10756 @@ +package com.mathvision.box.device.sdk; + +import com.sun.jna.*; +import com.sun.jna.examples.win32.W32API; +import com.sun.jna.examples.win32.W32API.HWND; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.ShortByReference; + +import java.util.Arrays; +import java.util.List; + +//SDK接口说明,HCNetSDK.dll +public interface HCNetSDK extends Library { + + /*** 宏定义 ***/ + //常量 + + public static final int MAX_NAMELEN = 16; //DVR本地登陆名 + public static final int MAX_RIGHT = 32; //设备支持的权限(1-12表示本地权限,13-32表示远程权限) + public static final int NAME_LEN = 32; //用户名长度 + public static final int PASSWD_LEN = 16; //密码长度 + public static final int SERIALNO_LEN = 48; //序列号长度 + public static final int MACADDR_LEN = 6; //mac地址长度 + public static final int MAX_ETHERNET = 2; //设备可配以太网络 + public static final int PATHNAME_LEN = 128; //路径长度 + public static final int MAX_TIMESEGMENT_V30 = 8; //9000设备最大时间段数 + public static final int MAX_TIMESEGMENT = 4; //8000设备最大时间段数 + public static final int MAX_SHELTERNUM = 4; //8000设备最大遮挡区域数 + public static final int MAX_DAYS = 7; //每周天数 + public static final int PHONENUMBER_LEN = 32; //pppoe拨号号码最大长度 + public static final int MAX_DISKNUM_V30 = 33; //9000设备最大硬盘数/* 最多33个硬盘(包括16个内置SATA硬盘、1个eSATA硬盘和16个NFS盘) */ + public static final int MAX_DISKNUM = 16; //8000设备最大硬盘数 + public static final int MAX_DISKNUM_V10 = 8; //1.2版本之前版本 + public static final int MAX_WINDOW_V30 = 32; //9000设备本地显示最大播放窗口数 + public static final int MAX_WINDOW = 16; //8000设备最大硬盘数 + public static final int MAX_VGA_V30 = 4; //9000设备最大可接VGA数 + public static final int MAX_VGA = 1; //8000设备最大可接VGA数 + public static final int MAX_USERNUM_V30 = 32; //9000设备最大用户数 + public static final int MAX_USERNUM = 16; //8000设备最大用户数 + public static final int MAX_EXCEPTIONNUM_V30 = 32; //9000设备最大异常处理数 + public static final int MAX_EXCEPTIONNUM = 16; //8000设备最大异常处理数 + public static final int MAX_LINK = 6; //8000设备单通道最大视频流连接数 + public static final int MAX_DECPOOLNUM = 4; //单路解码器每个解码通道最大可循环解码数 + public static final int MAX_DECNUM = 4; //单路解码器的最大解码通道数(实际只有一个,其他三个保留) + public static final int MAX_TRANSPARENTNUM = 2; //单路解码器可配置最大透明通道数 + public static final int MAX_CYCLE_CHAN = 16; //单路解码器最大轮循通道数 + public static final int MAX_DIRNAME_LENGTH = 80; //最大目录长度 + public static final int MAX_STRINGNUM_V30 = 8; //9000设备最大OSD字符行数数 + public static final int MAX_STRINGNUM = 4; //8000设备最大OSD字符行数数 + public static final int MAX_STRINGNUM_EX = 8; //8000定制扩展 + public static final int MAX_AUXOUT_V30 = 16; //9000设备最大辅助输出数 + public static final int MAX_AUXOUT = 4; //8000设备最大辅助输出数 + public static final int MAX_HD_GROUP = 16; //9000设备最大硬盘组数 + public static final int MAX_NFS_DISK = 8; //8000设备最大NFS硬盘数 + public static final int IW_ESSID_MAX_SIZE = 32; //WIFI的SSID号长度 + public static final int IW_ENCODING_TOKEN_MAX = 32; //WIFI密锁最大字节数 + public static final int MAX_SERIAL_NUM = 64; //最多支持的透明通道路数 + public static final int MAX_DDNS_NUMS = 10; //9000设备最大可配ddns数 + public static final int MAX_DOMAIN_NAME = 64; /* 最大域名长度 */ + + public static final int MAX_EMAIL_ADDR_LEN = 48; //最大email地址长度 + public static final int MAX_EMAIL_PWD_LEN = 32; //最大email密码长度 + public static final int MAXPROGRESS = 100; //回放时的最大百分率 + public static final int MAX_SERIALNUM = 2; //8000设备支持的串口数 1-232, 2-485 + public static final int CARDNUM_LEN = 20; //卡号长度 + public static final int MAX_VIDEOOUT_V30 = 4; //9000设备的视频输出数 + public static final int MAX_VIDEOOUT = 2; //8000设备的视频输出数 + public static final int MAX_PRESET_V30 = 256; /* 9000设备支持的云台预置点数 */ + public static final int MAX_TRACK_V30 = 256; /* 9000设备支持的云台数 */ + public static final int MAX_CRUISE_V30 = 256; /* 9000设备支持的云台巡航数 */ + public static final int MAX_PRESET = 128; /* 8000设备支持的云台预置点数 */ + public static final int MAX_TRACK = 128; /* 8000设备支持的云台数 */ + public static final int MAX_CRUISE = 128; /* 8000设备支持的云台巡航数 */ + public static final int CRUISE_MAX_PRESET_NUMS = 32; /* 一条巡航最多的巡航点 */ + public static final int MAX_SERIAL_PORT = 8; //9000设备支持232串口数 + public static final int MAX_PREVIEW_MODE = 8; /* 设备支持最大预览模式数目 1画面,4画面,9画面,16画面.... */ + public static final int MAX_MATRIXOUT = 16; /* 最大模拟矩阵输出个数 */ + public static final int LOG_INFO_LEN = 11840; /* 日志附加信息 */ + public static final int DESC_LEN = 16; /* 云台描述字符串长度 */ + public static final int PTZ_PROTOCOL_NUM = 200; /* 9000最大支持的云台协议数 */ + public static final int MAX_AUDIO = 1; //8000语音对讲通道数 + public static final int MAX_AUDIO_V30 = 2; //9000语音对讲通道数 + public static final int MAX_CHANNUM = 16; //8000设备最大通道数 + public static final int MAX_ALARMIN = 16; //8000设备最大报警输入数 + public static final int MAX_ALARMOUT = 4; //8000设备最大报警输出数 + //9000 IPC接入 + public static final int MAX_ANALOG_CHANNUM = 32; //最大32个模拟通道 + public static final int MAX_ANALOG_ALARMOUT = 32; //最大32路模拟报警输出 + public static final int MAX_ANALOG_ALARMIN = 32; //最大32路模拟报警输入 + public static final int MAX_IP_ALARMIN_V40 = 4096; //允许加入的最多报警输入数 + public static final int MAX_IP_ALARMOUT_V40 = 4096; //允许加入的最多报警输出数 + public static final int MAX_ALARMOUT_V40 = (MAX_IP_ALARMOUT_V40 + MAX_ANALOG_ALARMOUT); //4128 + public static final int MAX_ALARMIN_V40 = (MAX_IP_ALARMIN_V40 + MAX_ANALOG_ALARMOUT); //4128 + public static final int MAX_CHANNUM_V40 = 512; + public static final int MAX_IP_DEVICE = 32; //允许接入的最大IP设备数 + public static final int MAX_IP_CHANNEL = 32; //允许加入的最多IP通道数 + public static final int MAX_IP_ALARMIN = 128; //允许加入的最多报警输入数 + public static final int MAX_IP_ALARMOUT = 64; //允许加入的最多报警输出数 + + /* 最大支持的通道数 最大模拟加上最大IP支持 */ + public static final int MAX_CHANNUM_V30 = (MAX_ANALOG_CHANNUM + MAX_IP_CHANNEL);//64 + public static final int MAX_ALARMOUT_V30 = (MAX_ANALOG_ALARMOUT + MAX_IP_ALARMOUT);//96 + public static final int MAX_ALARMIN_V30 = (MAX_ANALOG_ALARMIN + MAX_IP_ALARMIN);//160 + public static final int MAX_IP_DEVICE_V40 = 64; + public static final int STREAM_ID_LEN = 32; + + public static final int MAX_LICENSE_LEN = 16; + public static final int MAX_LICENSE_LEN_EX = 32; //车牌号最大长度 + public static final int MAX_CARDNO_LEN = 48; //卡号最大长度 + public static final int VCA_MAX_POLYGON_POINT_NUM = 10; + + public static final int MAX_ID_NUM_LEN = 32; //最大身份证号长度 + public static final int MAX_ID_NAME_LEN = 128; //最大姓名长度 + public static final int MAX_ID_ADDR_LEN = 280; //最大住址长度 + public static final int MAX_ID_ISSUING_AUTHORITY_LEN = 128; //最大签发机关长度 + public static final int MAX_CARD_READER_NUM_512 = 512; //最大读卡器数 + public static final int ERROR_MSG_LEN = 32; //下发错误信息 + public static final int MAX_FACE_NUM = 2; //最大人脸数 + public static final int MAX_FINGER_PRINT_LEN = 768; //最大指纹长度 + + public static final int DEV_TYPE_NAME_LEN = 24; //设备类型名称长度 + public static final int MAX_FACE_PIC_NUM = 30; /*人脸子图个数*/ + public static final int CARDNUM_LEN_V30 = 40; + + public static final int MAX_NOTICE_NUMBER_LEN = 32; //公告编号最大长度 + public static final int MAX_NOTICE_THEME_LEN = 64; //公告主题最大长度 + public static final int MAX_NOTICE_DETAIL_LEN = 1024; //公告详情最大长度 + public static final int MAX_NOTICE_PIC_NUM = 6; //公告信息最大图片数量 + public static final int MAX_DEV_NUMBER_LEN = 32; //设备编号最大长度 + public static final int LOCK_NAME_LEN = 32; //锁名称 + + public static final int NET_SDK_EMPLOYEE_NO_LEN = 32; //工号长度 + public static final int NET_SDK_UUID_LEN = 36; //UUID长度 + + public static final int MAX_INQUEST_CDRW_NUM = 4; //最大刻录机数目 + public static final int INQUEST_MESSAGE_LEN = 44; //审讯重点标记信息长度 + public static final int INQUEST_MAX_ROOM_NUM = 2; //最大审讯室个数 + public static final int MAX_RESUME_SEGMENT = 2; //支持同时恢复的片段数目 + + public static final int SUPPORT_PD_NUM = 16; + public static final int SUPPORT_ARRAY_NUM = 8; + public static final int SUPPORT_VD_NUM = 128; + public static final int SUPPORT_PD_NUM_ = 16; + public static final int SUPPORT_PD_NUM_PARTTWO = 8; + + public static final int CARDNUM_LEN_OUT = 32; //外部结构体卡号长度 + public static final int GUID_LEN = 16; //GUID长度 + + public static final int MAX_ROIDETECT_NUM = 8; //支持的ROI区域数 + public static final int MAX_LANERECT_NUM = 5; //最大车牌识别区域数 + public static final int MAX_FORTIFY_NUM = 10; //最大布防个数 + public static final int MAX_INTERVAL_NUM = 4; //最大时间间隔个数 + public static final int MAX_CHJC_NUM = 3; //最大车辆省份简称字符个数 + public static final int MAX_VL_NUM = 5; //最大虚拟线圈个数 + public static final int MAX_DRIVECHAN_NUM = 16; //最大车道数 + public static final int MAX_COIL_NUM = 3; //最大线圈个数 + public static final int MAX_SIGNALLIGHT_NUM = 6; //最大信号灯个数 + public static final int MAX_IOSPEED_GROUP_NUM = 4; //IO测速组个数 + public static final int MAX_IOOUT_NUM = 4; //最大IO输出口个数 + public static final int MAX_IOIN_NUM = 8; //最大IO输入口个数 + public static final int MAX_RELAY_NUM = 12; //继电器控制设备最大数 2013-11-04 + public static final int MAX_VEHICLE_TYPE_NUM = 8; //车辆信息管控最大数2013-11-04 + public static final int MAX_IOIN_NUMEX = 10; //最大IO输入口个数(扩展) + public static final int MAX_ITC_LANE_NUM = 6; //最大车道个数 + public static final int MAX_LANEAREA_NUM = 2; //单车道最大区域个数 + public static final int ITC_MAX_POLYGON_POINT_NUM = 20; //检测区域最多支持20个点的多边形 + public static final int MAX_ITC_SERIALCHECK_NUM = 8; //串口校验类型个数 + public static final int MAX_LIGHT_NUM = 6; //最大交通灯数 + public static final int MAX_VIDEO_INTERVAL_NUM = 2; //最大抓拍间隔数 + public static final int MAX_VIDEO_DETECT_LIGHT_NUM = 12; //视频检测的最大检测区域 + public static final int MAX_CALIB_RECOG_NUM = 2; //标定区域个数 + public static final int MAX_RS485_NUM = 12; //485口最大支持数 + public static final int MAX_MOBILE_POLYGON_NUM = 3; //移动布防支持最大牌识区域个数 + public static final int MAX_MOBILE_DETECTLINE_NUM = 3; //移动布防支持最大违规检测线个数 + public static final int MAX_IOOUT_K_NUM = 8; //K系列最大IO输出口个数 + + public static final int NET_SDK_MAX_FDID_LEN = 256; //人脸库ID最大长度 + public static final int NET_SDK_MAX_PICID_LEN = 256; //人脸ID最大长度 + public static final int NET_SDK_MAX_INDENTITY_KEY_LEN = 64; //交互操作口令长度 + + public static final int SEARCH_EVENT_INFO_LEN = 300; //事件信息长度 + public static final int SEARCH_EVENT_INFO_LEN_V40 = 800; + public static final int MAX_POS_KEYWORDS_NUM = 3; //支持关键字查找条数 + public static final int MAX_POS_KEYWORD_LEN = 128; //每条关键字长度 + public static final int INQUEST_CASE_LEN = 64; //审讯信息长度 + + public static final int SEARCH_CASE_NO_LEN = 56; + public static final int SEARCH_CASE_NAME_LEN = 100; + public static final int SEARCH_LITIGANT_LEN = 32; + public static final int SEARCH_CHIEF_JUDGE_LEN = 32; + public static final int CASE_NO_RET_LEN = 52; + public static final int CASE_NAME_RET_LEN = 64; + public static final int LITIGANT_RET_LEN = 24; + public static final int CHIEF_JUDGE_RET_LEN = 24; + public static final int NET_SDK_CASETYPE_LEN = 32; + public static final int NET_SDK_MAX_TAPE_INDEX_LEN = 32; //磁带编号最大长度 + public static final int NET_SDK_MAX_FILE_LEN = 256; //文件名最大长度 + /******************************************************************/ + + /** + *NET_SDK_INIT_CFG_TYPE 枚举 + */ + public static final int NET_SDK_INIT_CFG_TYPE_CHECK_MODULE_COM = 0; //增加对必须库的检查 + public static final int NET_SDK_INIT_CFG_ABILITY = 1;//sdk支持的业务的能力集 + public static final int NET_SDK_INIT_CFG_SDK_PATH = 2; //设置HCNetSDK库所在目录 + public static final int NET_SDK_INIT_CFG_LIBEAY_PATH = 3; //设置OpenSSL的libeay32.dll/libcrypto.so/libcrypto.dylib所在路径 + public static final int NET_SDK_INIT_CFG_SSLEAY_PATH = 4; //设置OpenSSL的ssleay32.dll/libssl.so/libssl.dylib所在路径 + + /******************* + * 全局错误码 begin + **********************/ + public static final int NET_DVR_NOERROR = 0; //没有错误 + public static final int NET_DVR_PASSWORD_ERROR = 1; //用户名密码错误 + public static final int NET_DVR_NOENOUGHPRI = 2;//权限不足 + public static final int NET_DVR_NOINIT = 3;//没有初始化 + public static final int NET_DVR_CHANNEL_ERROR = 4; //通道号错误 + public static final int NET_DVR_OVER_MAXLINK = 5; //连接到DVR的客户端个数超过最大 + public static final int NET_DVR_VERSIONNOMATCH = 6; //版本不匹配 + public static final int NET_DVR_NETWORK_FAIL_CONNECT = 7;//连接服务器失败 + public static final int NET_DVR_NETWORK_SEND_ERROR = 8; //向服务器发送失败 + public static final int NET_DVR_NETWORK_RECV_ERROR = 9; //从服务器接收数据失败 + public static final int NET_DVR_NETWORK_RECV_TIMEOUT = 10; //从服务器接收数据超时 + public static final int NET_DVR_NETWORK_ERRORDATA = 11; //传送的数据有误 + public static final int NET_DVR_ORDER_ERROR = 12; //调用次序错误 + public static final int NET_DVR_OPERNOPERMIT = 13; //无此权限 + public static final int NET_DVR_COMMANDTIMEOUT = 14; //DVR命令执行超时 + public static final int NET_DVR_ERRORSERIALPORT = 15; //串口号错误 + public static final int NET_DVR_ERRORALARMPORT = 16; //报警端口错误 + public static final int NET_DVR_PARAMETER_ERROR = 17;//参数错误 + public static final int NET_DVR_CHAN_EXCEPTION = 18; //服务器通道处于错误状态 + public static final int NET_DVR_NODISK = 19; //没有硬盘 + public static final int NET_DVR_ERRORDISKNUM = 20; //硬盘号错误 + public static final int NET_DVR_DISK_FULL = 21; //服务器硬盘满 + public static final int NET_DVR_DISK_ERROR = 22;//服务器硬盘出错 + public static final int NET_DVR_NOSUPPORT = 23;//服务器不支持 + public static final int NET_DVR_BUSY = 24;//服务器忙 + public static final int NET_DVR_MODIFY_FAIL = 25;//服务器修改不成功 + public static final int NET_DVR_PASSWORD_FORMAT_ERROR = 26;//密码输入格式不正确 + public static final int NET_DVR_DISK_FORMATING = 27; //硬盘正在格式化,不能启动操作 + public static final int NET_DVR_DVRNORESOURCE = 28; //DVR资源不足 + public static final int NET_DVR_DVROPRATEFAILED = 29; //DVR操作失败 + public static final int NET_DVR_OPENHOSTSOUND_FAIL = 30; //打开PC声音失败 + public static final int NET_DVR_DVRVOICEOPENED = 31; //服务器语音对讲被占用 + public static final int NET_DVR_TIMEINPUTERROR = 32; //时间输入不正确 + public static final int NET_DVR_NOSPECFILE = 33; //回放时服务器没有指定的文件 + public static final int NET_DVR_CREATEFILE_ERROR = 34; //创建文件出错 + public static final int NET_DVR_FILEOPENFAIL = 35; //打开文件出错 + public static final int NET_DVR_OPERNOTFINISH = 36; //上次的操作还没有完成 + public static final int NET_DVR_GETPLAYTIMEFAIL = 37; //获取当前播放的时间出错 + public static final int NET_DVR_PLAYFAIL = 38; //播放出错 + public static final int NET_DVR_FILEFORMAT_ERROR = 39;//文件格式不正确 + public static final int NET_DVR_DIR_ERROR = 40; //路径错误 + public static final int NET_DVR_ALLOC_RESOURCE_ERROR = 41;//资源分配错误 + public static final int NET_DVR_AUDIO_MODE_ERROR = 42; //声卡模式错误 + public static final int NET_DVR_NOENOUGH_BUF = 43; //缓冲区太小 + public static final int NET_DVR_CREATESOCKET_ERROR = 44; //创建SOCKET出错 + public static final int NET_DVR_SETSOCKET_ERROR = 45; //设置SOCKET出错 + public static final int NET_DVR_MAX_NUM = 46; //个数达到最大 + public static final int NET_DVR_USERNOTEXIST = 47; //用户不存在 + public static final int NET_DVR_WRITEFLASHERROR = 48;//写FLASH出错 + public static final int NET_DVR_UPGRADEFAIL = 49;//DVR升级失败 + public static final int NET_DVR_CARDHAVEINIT = 50; //解码卡已经初始化过 + public static final int NET_DVR_PLAYERFAILED = 51; //调用播放库中某个函数失败 + public static final int NET_DVR_MAX_USERNUM = 52; //设备端用户数达到最大 + public static final int NET_DVR_GETLOCALIPANDMACFAIL = 53;//获得客户端的IP地址或物理地址失败 + public static final int NET_DVR_NOENCODEING = 54; //该通道没有编码 + public static final int NET_DVR_IPMISMATCH = 55; //IP地址不匹配 + public static final int NET_DVR_MACMISMATCH = 56;//MAC地址不匹配 + public static final int NET_DVR_UPGRADELANGMISMATCH = 57;//升级文件语言不匹配 + public static final int NET_DVR_MAX_PLAYERPORT = 58;//播放器路数达到最大 + public static final int NET_DVR_NOSPACEBACKUP = 59;//备份设备中没有足够空间进行备份 + public static final int NET_DVR_NODEVICEBACKUP = 60; //没有找到指定的备份设备 + public static final int NET_DVR_PICTURE_BITS_ERROR = 61; //图像素位数不符,限24色 + public static final int NET_DVR_PICTURE_DIMENSION_ERROR = 62;//图片高*宽超限, 限128*256 + public static final int NET_DVR_PICTURE_SIZ_ERROR = 63; //图片大小超限,限100K + public static final int NET_DVR_LOADPLAYERSDKFAILED = 64; //载入当前目录下Player Sdk出错 + public static final int NET_DVR_LOADPLAYERSDKPROC_ERROR = 65; //找不到Player Sdk中某个函数入口 + public static final int NET_DVR_LOADDSSDKFAILED = 66; //载入当前目录下DSsdk出错 + public static final int NET_DVR_LOADDSSDKPROC_ERROR = 67; //找不到DsSdk中某个函数入口 + public static final int NET_DVR_DSSDK_ERROR = 68; //调用硬解码库DsSdk中某个函数失败 + public static final int NET_DVR_VOICEMONOPOLIZE = 69; //声卡被独占 + public static final int NET_DVR_JOINMULTICASTFAILED = 70; //加入多播组失败 + public static final int NET_DVR_CREATEDIR_ERROR = 71; //建立日志文件目录失败 + public static final int NET_DVR_BINDSOCKET_ERROR = 72; //绑定套接字失败 + public static final int NET_DVR_SOCKETCLOSE_ERROR = 73; //socket连接中断,此错误通常是由于连接中断或目的地不可达 + public static final int NET_DVR_USERID_ISUSING = 74; //注销时用户ID正在进行某操作 + public static final int NET_DVR_SOCKETLISTEN_ERROR = 75; //监听失败 + public static final int NET_DVR_PROGRAM_EXCEPTION = 76; //程序异常 + public static final int NET_DVR_WRITEFILE_FAILED = 77; //写文件失败 + public static final int NET_DVR_FORMAT_READONLY = 78;//禁止格式化只读硬盘 + public static final int NET_DVR_WITHSAMEUSERNAME = 79;//用户配置结构中存在相同的用户名 + public static final int NET_DVR_DEVICETYPE_ERROR = 80; /*导入参数时设备型号不匹配*/ + public static final int NET_DVR_LANGUAGE_ERROR = 81; /*导入参数时语言不匹配*/ + public static final int NET_DVR_PARAVERSION_ERROR = 82; /*导入参数时软件版本不匹配*/ + public static final int NET_DVR_IPCHAN_NOTALIVE = 83; /*预览时外接IP通道不在线*/ + public static final int NET_DVR_RTSP_SDK_ERROR = 84; /*加载高清IPC通讯库StreamTransClient.dll失败*/ + public static final int NET_DVR_CONVERT_SDK_ERROR = 85; /*加载转码库失败*/ + public static final int NET_DVR_IPC_COUNT_OVERFLOW = 86; /*超出最大的ip接入通道数*/ + public static final int NET_PLAYM4_NOERROR = 500; //no error + public static final int NET_PLAYM4_PARA_OVER = 501;//input parameter is invalid; + public static final int NET_PLAYM4_ORDER_ERROR = 502;//The order of the function to be called is error. + public static final int NET_PLAYM4_TIMER_ERROR = 503;//Create multimedia clock failed; + public static final int NET_PLAYM4_DEC_VIDEO_ERROR = 504;//Decode video data failed. + public static final int NET_PLAYM4_DEC_AUDIO_ERROR = 505;//Decode audio data failed. + public static final int NET_PLAYM4_ALLOC_MEMORY_ERROR = 506; //Allocate memory failed. + public static final int NET_PLAYM4_OPEN_FILE_ERROR = 507; //Open the file failed. + public static final int NET_PLAYM4_CREATE_OBJ_ERROR = 508;//Create thread or event failed + public static final int NET_PLAYM4_CREATE_DDRAW_ERROR = 509;//Create DirectDraw object failed. + public static final int NET_PLAYM4_CREATE_OFFSCREEN_ERROR = 510;//failed when creating off-screen surface. + public static final int NET_PLAYM4_BUF_OVER = 511; //buffer is overflow + public static final int NET_PLAYM4_CREATE_SOUND_ERROR = 512; //failed when creating audio device. + public static final int NET_PLAYM4_SET_VOLUME_ERROR = 513;//Set volume failed + public static final int NET_PLAYM4_SUPPORT_FILE_ONLY = 514;//The function only support play file. + public static final int NET_PLAYM4_SUPPORT_STREAM_ONLY = 515;//The function only support play stream. + public static final int NET_PLAYM4_SYS_NOT_SUPPORT = 516;//System not support. + public static final int NET_PLAYM4_FILEHEADER_UNKNOWN = 517; //No file header. + public static final int NET_PLAYM4_VERSION_INCORRECT = 518; //The version of decoder and encoder is not adapted. + public static final int NET_PALYM4_INIT_DECODER_ERROR = 519; //Initialize decoder failed. + public static final int NET_PLAYM4_CHECK_FILE_ERROR = 520; //The file data is unknown. + public static final int NET_PLAYM4_INIT_TIMER_ERROR = 521; //Initialize multimedia clock failed. + public static final int NET_PLAYM4_BLT_ERROR = 522;//Blt failed. + public static final int NET_PLAYM4_UPDATE_ERROR = 523;//Update failed. + public static final int NET_PLAYM4_OPEN_FILE_ERROR_MULTI = 524; //openfile error, streamtype is multi + public static final int NET_PLAYM4_OPEN_FILE_ERROR_VIDEO = 525; //openfile error, streamtype is video + public static final int NET_PLAYM4_JPEG_COMPRESS_ERROR = 526; //JPEG compress error + public static final int NET_PLAYM4_EXTRACT_NOT_SUPPORT = 527; //Don't support the version of this file. + public static final int NET_PLAYM4_EXTRACT_DATA_ERROR = 528; //extract video data failed. + /*******************全局错误码 end**********************/ + /************************************************* + * NET_DVR_IsSupport()返回值 + * 1-9位分别表示以下信息(位与是TRUE)表示支持; + **************************************************/ + public static final int NET_DVR_SUPPORT_DDRAW = 0x01;//支持DIRECTDRAW,如果不支持,则播放器不能工作; + public static final int NET_DVR_SUPPORT_BLT = 0x02;//显卡支持BLT操作,如果不支持,则播放器不能工作; + public static final int NET_DVR_SUPPORT_BLTFOURCC = 0x04;//显卡BLT支持颜色转换,如果不支持,播放器会用软件方法作RGB转换; + public static final int NET_DVR_SUPPORT_BLTSHRINKX = 0x08;//显卡BLT支持X轴缩小;如果不支持,系统会用软件方法转换; + public static final int NET_DVR_SUPPORT_BLTSHRINKY = 0x10;//显卡BLT支持Y轴缩小;如果不支持,系统会用软件方法转换; + public static final int NET_DVR_SUPPORT_BLTSTRETCHX = 0x20;//显卡BLT支持X轴放大;如果不支持,系统会用软件方法转换; + public static final int NET_DVR_SUPPORT_BLTSTRETCHY = 0x40;//显卡BLT支持Y轴放大;如果不支持,系统会用软件方法转换; + public static final int NET_DVR_SUPPORT_SSE = 0x80;//CPU支持SSE指令, Pentium3以上支持SSE指令; + public static final int NET_DVR_SUPPORT_MMX = 0x100;//CPU支持MMX指令集, Pentium3以上支持SSE指令; + /********************** + * 云台控制命令 begin + *************************/ + public static final int LIGHT_PWRON = 2; /* 接通灯光电源 */ + public static final int WIPER_PWRON = 3; /* 接通雨刷开关 */ + public static final int FAN_PWRON = 4; /* 接通风扇开关 */ + public static final int HEATER_PWRON = 5; /* 接通加热器开关 */ + public static final int AUX_PWRON1 = 6; /* 接通辅助设备开关 */ + public static final int AUX_PWRON2 = 7; /* 接通辅助设备开关 */ + public static final int SET_PRESET = 8; /* 设置预置点 */ + public static final int CLE_PRESET = 9; /* 清除预置点 */ + public static final int ZOOM_IN = 11; /* 焦距以速度SS变大(倍率变大) */ + public static final int ZOOM_OUT = 12; /* 焦距以速度SS变小(倍率变小) */ + public static final int FOCUS_NEAR = 13; /* 焦点以速度SS前调 */ + public static final int FOCUS_FAR = 14; /* 焦点以速度SS后调 */ + public static final int IRIS_OPEN = 15; /* 光圈以速度SS扩大 */ + public static final int IRIS_CLOSE = 16; /* 光圈以速度SS缩小 */ + public static final int TILT_UP = 21; /* 云台以SS的速度上仰 */ + public static final int TILT_DOWN = 22; /* 云台以SS的速度下俯 */ + public static final int PAN_LEFT = 23; /* 云台以SS的速度左转 */ + public static final int PAN_RIGHT = 24; /* 云台以SS的速度右转 */ + public static final int UP_LEFT = 25; /* 云台以SS的速度上仰和左转 */ + public static final int UP_RIGHT = 26; /* 云台以SS的速度上仰和右转 */ + public static final int DOWN_LEFT = 27; /* 云台以SS的速度下俯和左转 */ + public static final int DOWN_RIGHT = 28; /* 云台以SS的速度下俯和右转 */ + public static final int PAN_AUTO = 29; /* 云台以SS的速度左右自动扫描 */ + public static final int FILL_PRE_SEQ = 30; /* 将预置点加入巡航序列 */ + public static final int SET_SEQ_DWELL = 31; /* 设置巡航点停顿时间 */ + public static final int SET_SEQ_SPEED = 32; /* 设置巡航速度 */ + public static final int CLE_PRE_SEQ = 33;/* 将预置点从巡航序列中删除 */ + public static final int STA_MEM_CRUISE = 34;/* 开始记录 */ + public static final int STO_MEM_CRUISE = 35;/* 停止记录 */ + public static final int RUN_CRUISE = 36; /* 开始 */ + public static final int RUN_SEQ = 37; /* 开始巡航 */ + public static final int STOP_SEQ = 38; /* 停止巡航 */ + public static final int GOTO_PRESET = 39; /* 快球转到预置点 */ + + /**********************云台控制命令 end*************************/ + /************************************************* + * 回放时播放控制命令宏定义 + * NET_DVR_PlayBackControl + * NET_DVR_PlayControlLocDisplay + * NET_DVR_DecPlayBackCtrl的宏定义 + * 具体支持查看函数说明和代码 + **************************************************/ + public static final int NET_DVR_PLAYSTART = 1;//开始播放 + public static final int NET_DVR_PLAYSTOP = 2;//停止播放 + public static final int NET_DVR_PLAYPAUSE = 3;//暂停播放 + public static final int NET_DVR_PLAYRESTART = 4;//恢复播放 + public static final int NET_DVR_PLAYFAST = 5;//快放 + public static final int NET_DVR_PLAYSLOW = 6;//慢放 + public static final int NET_DVR_PLAYNORMAL = 7;//正常速度 + public static final int NET_DVR_PLAYFRAME = 8;//单帧放 + public static final int NET_DVR_PLAYSTARTAUDIO = 9;//打开声音 + public static final int NET_DVR_PLAYSTOPAUDIO = 10;//关闭声音 + public static final int NET_DVR_PLAYAUDIOVOLUME = 11;//调节音量 + public static final int NET_DVR_PLAYSETPOS = 12;//改变文件回放的进度 + public static final int NET_DVR_PLAYGETPOS = 13;//获取文件回放的进度 + public static final int NET_DVR_PLAYGETTIME = 14;//获取当前已经播放的时间(按文件回放的时候有效) + public static final int NET_DVR_PLAYGETFRAME = 15;//获取当前已经播放的帧数(按文件回放的时候有效) + public static final int NET_DVR_GETTOTALFRAMES = 16;//获取当前播放文件总的帧数(按文件回放的时候有效) + public static final int NET_DVR_GETTOTALTIME = 17;//获取当前播放文件总的时间(按文件回放的时候有效) + public static final int NET_DVR_THROWBFRAME = 20;//丢B帧 + public static final int NET_DVR_SETSPEED = 24;//设置码流速度 + public static final int NET_DVR_KEEPALIVE = 25;//保持与设备的心跳(如果回调阻塞,建议2秒发送一次) + public static final int NET_DVR_SET_TRANS_TYPE = 32; //设置转码格式 + + //远程按键定义如下: + /* key value send to CONFIG program */ + public static final int KEY_CODE_1 = 1; + public static final int KEY_CODE_2 = 2; + public static final int KEY_CODE_3 = 3; + public static final int KEY_CODE_4 = 4; + public static final int KEY_CODE_5 = 5; + public static final int KEY_CODE_6 = 6; + public static final int KEY_CODE_7 = 7; + public static final int KEY_CODE_8 = 8; + public static final int KEY_CODE_9 = 9; + public static final int KEY_CODE_0 = 10; + public static final int KEY_CODE_POWER = 11; + public static final int KEY_CODE_MENU = 12; + public static final int KEY_CODE_ENTER = 13; + public static final int KEY_CODE_CANCEL = 14; + public static final int KEY_CODE_UP = 15; + public static final int KEY_CODE_DOWN = 16; + public static final int KEY_CODE_LEFT = 17; + public static final int KEY_CODE_RIGHT = 18; + public static final int KEY_CODE_EDIT = 19; + public static final int KEY_CODE_ADD = 20; + public static final int KEY_CODE_MINUS = 21; + public static final int KEY_CODE_PLAY = 22; + public static final int KEY_CODE_REC = 23; + public static final int KEY_CODE_PAN = 24; + public static final int KEY_CODE_M = 25; + public static final int KEY_CODE_A = 26; + public static final int KEY_CODE_F1 = 27; + public static final int KEY_CODE_F2 = 28; + + /* for PTZ control */ + public static final int KEY_PTZ_UP_START = KEY_CODE_UP; + public static final int KEY_PTZ_UP_STO = 32; + public static final int KEY_PTZ_DOWN_START = KEY_CODE_DOWN; + public static final int KEY_PTZ_DOWN_STOP = 33; + public static final int KEY_PTZ_LEFT_START = KEY_CODE_LEFT; + public static final int KEY_PTZ_LEFT_STOP = 34; + public static final int KEY_PTZ_RIGHT_START = KEY_CODE_RIGHT; + public static final int KEY_PTZ_RIGHT_STOP = 35; + public static final int KEY_PTZ_AP1_START = KEY_CODE_EDIT;/* 光圈+ */ + public static final int KEY_PTZ_AP1_STOP = 36; + public static final int KEY_PTZ_AP2_START = KEY_CODE_PAN;/* 光圈- */ + public static final int KEY_PTZ_AP2_STOP = 37; + public static final int KEY_PTZ_FOCUS1_START = KEY_CODE_A;/* 聚焦+ */ + public static final int KEY_PTZ_FOCUS1_STOP = 38; + public static final int KEY_PTZ_FOCUS2_START = KEY_CODE_M;/* 聚焦- */ + public static final int KEY_PTZ_FOCUS2_STOP = 39; + public static final int KEY_PTZ_B1_START = 40;/* 变倍+ */ + public static final int KEY_PTZ_B1_STOP = 41; + public static final int KEY_PTZ_B2_START = 42;/* 变倍- */ + public static final int KEY_PTZ_B2_STOP = 43; + //9000新增 + public static final int KEY_CODE_11 = 44; + public static final int KEY_CODE_12 = 45; + public static final int KEY_CODE_13 = 46; + public static final int KEY_CODE_14 = 47; + public static final int KEY_CODE_15 = 48; + public static final int KEY_CODE_16 = 49; + /************************* + * 参数配置命令 begin + *******************************/ +//用于NET_DVR_SetDVRConfig和NET_DVR_GetDVRConfig,注意其对应的配置结构 + public static final int NET_DVR_GET_DEVICECFG = 100; //获取设备参数 + public static final int NET_DVR_SET_DEVICECFG = 101; //设置设备参数 + public static final int NET_DVR_GET_DEVICECFG_V40 = 1100; //获取扩展设备参数 + public static final int NET_DVR_SET_DEVICECFG_V40 = 1101; //设置扩展设备参数 + public static final int NET_DVR_GET_NETCFG = 102; //获取网络参数 + public static final int NET_DVR_SET_NETCFG = 103; //设置网络参数 + public static final int NET_DVR_GET_PICCFG = 104; //获取图象参数 + public static final int NET_DVR_SET_PICCFG = 105; //设置图象参数 + public static final int NET_DVR_GET_COMPRESSCFG = 106; //获取压缩参数 + public static final int NET_DVR_SET_COMPRESSCFG = 107; //设置压缩参数 + public static final int NET_DVR_GET_RECORDCFG = 108; //获取录像时间参数 + public static final int NET_DVR_SET_RECORDCFG = 109; //设置录像时间参数 + public static final int NET_DVR_GET_DECODERCFG = 110; //获取解码器参数 + public static final int NET_DVR_SET_DECODERCFG = 111; //设置解码器参数 + public static final int NET_DVR_GET_RS232CFG = 112; //获取232串口参数 + public static final int NET_DVR_SET_RS232CFG = 113; //设置232串口参数 + public static final int NET_DVR_GET_ALARMINCFG = 114; //获取报警输入参数 + public static final int NET_DVR_SET_ALARMINCFG = 115; //设置报警输入参数 + public static final int NET_DVR_GET_ALARMOUTCFG = 116; //获取报警输出参数 + public static final int NET_DVR_SET_ALARMOUTCFG = 117; //设置报警输出参数 + public static final int NET_DVR_GET_TIMECFG = 118; //获取DVR时间 + public static final int NET_DVR_SET_TIMECFG = 119; //设置DVR时间 + public static final int NET_DVR_GET_PREVIEWCFG = 120; //获取预览参数 + public static final int NET_DVR_SET_PREVIEWCFG = 121; //设置预览参数 + public static final int NET_DVR_GET_VIDEOOUTCFG = 122; //获取视频输出参数 + public static final int NET_DVR_SET_VIDEOOUTCFG = 123; //设置视频输出参数 + public static final int NET_DVR_GET_USERCFG = 124; //获取用户参数 + public static final int NET_DVR_SET_USERCFG = 125; //设置用户参数 + public static final int NET_DVR_GET_EXCEPTIONCFG = 126; //获取异常参数 + public static final int NET_DVR_SET_EXCEPTIONCFG = 127; //设置异常参数 + public static final int NET_DVR_GET_ZONEANDDST = 128; //获取时区和夏时制参数 + public static final int NET_DVR_SET_ZONEANDDST = 129; //设置时区和夏时制参数 + public static final int NET_DVR_GET_SHOWSTRING = 130; //获取叠加字符参数 + public static final int NET_DVR_SET_SHOWSTRING = 131; //设置叠加字符参数 + public static final int NET_DVR_GET_EVENTCOMPCFG = 132; //获取事件触发录像参数 + public static final int NET_DVR_SET_EVENTCOMPCFG = 133; //设置事件触发录像参数 + public static final int NET_DVR_GET_AUXOUTCFG = 140; //获取报警触发辅助输出设置(HS设备辅助输出2006-02-28) + public static final int NET_DVR_SET_AUXOUTCFG = 141; //设置报警触发辅助输出设置(HS设备辅助输出2006-02-28) + public static final int NET_DVR_GET_PREVIEWCFG_AUX = 142; //获取-s系列双输出预览参数(-s系列双输出2006-04-13) + public static final int NET_DVR_SET_PREVIEWCFG_AUX = 143; //设置-s系列双输出预览参数(-s系列双输出2006-04-13) + public static final int NET_DVR_GET_PICCFG_EX = 200; //获取图象参数(SDK_V14扩展命令) + public static final int NET_DVR_SET_PICCFG_EX = 201; //设置图象参数(SDK_V14扩展命令) + public static final int NET_DVR_GET_USERCFG_EX = 202; //获取用户参数(SDK_V15扩展命令) + public static final int NET_DVR_SET_USERCFG_EX = 203; //设置用户参数(SDK_V15扩展命令) + public static final int NET_DVR_GET_COMPRESSCFG_EX = 204; //获取压缩参数(SDK_V15扩展命令2006-05-15) + public static final int NET_DVR_SET_COMPRESSCFG_EX = 205; //设置压缩参数(SDK_V15扩展命令2006-05-15) + public static final int NET_DVR_GET_NETAPPCFG = 222; //获取网络应用参数 NTP/DDNS/EMAIL + public static final int NET_DVR_SET_NETAPPCFG = 223; //设置网络应用参数 NTP/DDNS/EMAIL + public static final int NET_DVR_GET_NTPCFG = 224; //获取网络应用参数 NTP + public static final int NET_DVR_SET_NTPCFG = 225; //设置网络应用参数 NTP + public static final int NET_DVR_GET_DDNSCFG = 226; //获取网络应用参数 DDNS + public static final int NET_DVR_SET_DDNSCFG = 227; //设置网络应用参数 DDNS + //对应NET_DVR_EMAILPARA + public static final int NET_DVR_GET_EMAILCFG = 228; //获取网络应用参数 EMAIL + public static final int NET_DVR_SET_EMAILCFG = 229; //设置网络应用参数 EMAIL + public static final int NET_DVR_GET_NFSCFG = 230; /* NFS disk config */ + public static final int NET_DVR_SET_NFSCFG = 231; /* NFS disk config */ + public static final int NET_DVR_GET_SHOWSTRING_EX = 238; //获取叠加字符参数扩展(支持8条字符) + public static final int NET_DVR_SET_SHOWSTRING_EX = 239; //设置叠加字符参数扩展(支持8条字符) + public static final int NET_DVR_GET_NETCFG_OTHER = 244; //获取网络参数 + public static final int NET_DVR_SET_NETCFG_OTHER = 245; //设置网络参数 + //对应NET_DVR_EMAILCFG结构 + public static final int NET_DVR_GET_EMAILPARACFG = 250; //Get EMAIL parameters + public static final int NET_DVR_SET_EMAILPARACFG = 251; //Setup EMAIL parameters + public static final int NET_DVR_GET_DDNSCFG_EX = 274;//获取扩展DDNS参数 + public static final int NET_DVR_SET_DDNSCFG_EX = 275;//设置扩展DDNS参数 + public static final int NET_DVR_SET_PTZPOS = 292; //云台设置PTZ位置 + public static final int NET_DVR_GET_PTZPOS = 293; //云台获取PTZ位置 + public static final int NET_DVR_GET_PTZSCOPE = 294;//云台获取PTZ范围 + public static final int NET_DVR_GET_PTZLOCKCFG=3287;//获取云台锁定信息 + public static final int NET_DVR_SET_PTZLOCKCFG=3288;//设置云台锁定信息 + + public static final int NET_DVR_COMPLETE_RESTORE_CTRL = 3420; //设置完全恢复出厂值 + /*************************** + * DS9000新增命令(_V30) begin + *****************************/ +//网络(NET_DVR_NETCFG_V30结构) + public static final int NET_DVR_GET_NETCFG_V30 = 1000; //获取网络参数 + public static final int NET_DVR_SET_NETCFG_V30 = 1001; //设置网络参数 + //图象(NET_DVR_PICCFG_V30结构) + public static final int NET_DVR_GET_PICCFG_V30 = 1002; //获取图象参数 + public static final int NET_DVR_SET_PICCFG_V30 = 1003; //设置图象参数 + public static final int NET_DVR_GET_PICCFG_V40 = 6179; //获取图象参数 + public static final int NET_DVR_SET_PICCFG_V40 = 6180; //设置图象参数 + public static final int NET_DVR_GET_AES_KEY = 6113; //获取设备AES加密密钥 + //录像时间(NET_DVR_RECORD_V30结构) + public static final int NET_DVR_GET_RECORDCFG_V30 = 1004; //获取录像参数 + public static final int NET_DVR_SET_RECORDCFG_V30 = 1005; //设置录像参数 + //用户(NET_DVR_USER_V30结构) + public static final int NET_DVR_GET_USERCFG_V30 = 1006; //获取用户参数 + public static final int NET_DVR_SET_USERCFG_V30 = 1007; //设置用户参数 + //9000DDNS参数配置(NET_DVR_DDNSPARA_V30结构) + public static final int NET_DVR_GET_DDNSCFG_V30 = 1010; //获取DDNS(9000扩展) + public static final int NET_DVR_SET_DDNSCFG_V30 = 1011; //设置DDNS(9000扩展) + //EMAIL功能(NET_DVR_EMAILCFG_V30结构) + public static final int NET_DVR_GET_EMAILCFG_V30 = 1012;//获取EMAIL参数 + public static final int NET_DVR_SET_EMAILCFG_V30 = 1013;//设置EMAIL参数 + //巡航参数 (NET_DVR_CRUISE_PARA结构) + public static final int NET_DVR_GET_CRUISE = 1020; + public static final int NET_DVR_SET_CRUISE = 1021; + //报警输入结构参数 (NET_DVR_ALARMINCFG_V30结构) + public static final int NET_DVR_GET_ALARMINCFG_V30 = 1024; + public static final int NET_DVR_SET_ALARMINCFG_V30 = 1025; + //报警输出结构参数 (NET_DVR_ALARMOUTCFG_V30结构) + public static final int NET_DVR_GET_ALARMOUTCFG_V30 = 1026; + public static final int NET_DVR_SET_ALARMOUTCFG_V30 = 1027; + //视频输出结构参数 (NET_DVR_VIDEOOUT_V30结构) + public static final int NET_DVR_GET_VIDEOOUTCFG_V30 = 1028; + public static final int NET_DVR_SET_VIDEOOUTCFG_V30 = 1029; + //叠加字符结构参数 (NET_DVR_SHOWSTRING_V30结构) + public static final int NET_DVR_GET_SHOWSTRING_V30 = 1030; + public static final int NET_DVR_SET_SHOWSTRING_V30 = 1031; + //异常结构参数 (NET_DVR_EXCEPTION_V30结构) + public static final int NET_DVR_GET_EXCEPTIONCFG_V30 = 1034; + public static final int NET_DVR_SET_EXCEPTIONCFG_V30 = 1035; + //串口232结构参数 (NET_DVR_RS232CFG_V30结构) + public static final int NET_DVR_GET_RS232CFG_V30 = 1036; + public static final int NET_DVR_SET_RS232CFG_V30 = 1037; + //压缩参数 (NET_DVR_COMPRESSIONCFG_V30结构) + public static final int NET_DVR_GET_COMPRESSCFG_V30 = 1040; + public static final int NET_DVR_SET_COMPRESSCFG_V30 = 1041; + //获取485解码器参数 (NET_DVR_DECODERCFG_V30结构) + public static final int NET_DVR_GET_DECODERCFG_V30 = 1042; //获取解码器参数 + public static final int NET_DVR_SET_DECODERCFG_V30 = 1043; //设置解码器参数 + //获取预览参数 (NET_DVR_PREVIEWCFG_V30结构) + public static final int NET_DVR_GET_PREVIEWCFG_V30 = 1044; //获取预览参数 + public static final int NET_DVR_SET_PREVIEWCFG_V30 = 1045; //设置预览参数 + //辅助预览参数 (NET_DVR_PREVIEWCFG_AUX_V30结构) + public static final int NET_DVR_GET_PREVIEWCFG_AUX_V30 = 1046; //获取辅助预览参数 + public static final int NET_DVR_SET_PREVIEWCFG_AUX_V30 = 1047; //设置辅助预览参数 + //IP接入配置参数 (NET_DVR_IPPARACFG结构) + public static final int NET_DVR_GET_IPPARACFG = 1048; //获取IP接入配置信息 + public static final int NET_DVR_SET_IPPARACFG = 1049; //设置IP接入配置信息 + //IP接入配置参数V40 (NET_DVR_IPPARACFG_V40结构) + public static final int NET_DVR_GET_IPPARACFG_V40 = 1062; //获取IP接入配置信息 + public static final int NET_DVR_SET_IPPARACFG_V40 = 1063; //设置IP接入配置信息 + //IP报警输入接入配置参数 (NET_DVR_IPALARMINCFG结构) + public static final int NET_DVR_GET_IPALARMINCFG = 1050; //获取IP报警输入接入配置信息 + public static final int NET_DVR_SET_IPALARMINCFG = 1051; //设置IP报警输入接入配置信息 + //IP报警输出接入配置参数 (NET_DVR_IPALARMOUTCFG结构) + public static final int NET_DVR_GET_IPALARMOUTCFG = 1052; //获取IP报警输出接入配置信息 + public static final int NET_DVR_SET_IPALARMOUTCFG = 1053; //设置IP报警输出接入配置信息 + //硬盘管理的参数获取 (NET_DVR_HDCFG结构) + public static final int NET_DVR_GET_HDCFG = 1054; //获取硬盘管理配置参数 + public static final int NET_DVR_SET_HDCFG = 1055; //设置硬盘管理配置参数 + //盘组管理的参数获取 (NET_DVR_HDGROUP_CFG结构) + public static final int NET_DVR_GET_HDGROUP_CFG = 1056; //获取盘组管理配置参数 + public static final int NET_DVR_SET_HDGROUP_CFG = 1057; //设置盘组管理配置参数 + //设备编码类型配置(NET_DVR_COMPRESSION_AUDIO结构) + public static final int NET_DVR_GET_COMPRESSCFG_AUD = 1058; //获取设备语音对讲编码参数 + public static final int NET_DVR_SET_COMPRESSCFG_AUD = 1059; //设置设备语音对讲编码参数 + + public static final int NET_SDK_FINDMEDICALFILE = 3954; //慧影科技智慧医疗查找录像文件 + public static final int NET_SDK_FINDMEDICALPICTURE = 3955; //慧影科技智慧医疗查找图片文件 + + public static final int NET_DVR_GET_RAPIDMOVE_DETECTION = 3539; //获取快速运动侦测配置 + public static final int NET_DVR_SET_RAPIDMOVE_DETECTION = 3540; //设置快速运动侦测配置 + + public static final int NET_DVR_GET_RAPIDMOVE_TRIGGER = 3543; //获取快速运动联动配置 + public static final int NET_DVR_SET_RAPIDMOVE_TRIGGER = 3544; //设置快速运动联动配置 + public static final int NET_DVR_GET_RAPIDMOVE_SCHEDULE = 3545; //获取快速运动的布防时间配置 + public static final int NET_DVR_SET_RAPIDMOVE_SCHEDULE = 3546; //设置快速运动的布防时间配置 + + public static final int NET_DVR_GET_PRESET_NAME = 3383; //获取预置点名称 + public static final int NET_DVR_SET_PRESET_NAME = 3382; //设置预置点名称 + public static final int NET_DVR_GET_RULECFG_V42 = 5049; //获取异常行为检测参数(支持16条规则扩展) + public static final int NET_DVR_SET_RULECFG_V42 = 5050; //设置异常行为检测参数(支持16条规则扩展) + + //车牌识别(NET_VCA_PLATE_CFG); + public static final int NET_DVR_SET_PLATECFG = 150;//设置车牌识别参数 + + public static final int NET_DVR_GET_PLATECFG = 151; //获取车牌识别参数 + //行为对应(NET_VCA_RULECFG) + public static final int NET_DVR_SET_RULECFG = 152; //设置异常行为检测规则 + public static final int NET_DVR_GET_RULECFG = 153;//获取异常行为检测规则 + //双摄像机标定参数(NET_DVR_LF_CFG) + public static final int NET_DVR_SET_LF_CFG = 160;//设置双摄像机的配置参数 + public static final int NET_DVR_GET_LF_CFG = 161;//获取双摄像机的配置参数 + //智能分析仪取流配置结构 + public static final int NET_DVR_SET_IVMS_STREAMCFG = 162; //设置智能分析仪取流参数 + public static final int NET_DVR_GET_IVMS_STREAMCFG = 163; //获取智能分析仪取流参数 + //智能控制参数结构 + public static final int NET_DVR_SET_VCA_CTRLCFG = 164; //设置智能控制参数 + public static final int NET_DVR_GET_VCA_CTRLCFG = 165; //获取智能控制参数 + //屏蔽区域NET_VCA_MASK_REGION_LIST + public static final int NET_DVR_SET_VCA_MASK_REGION = 166; //设置屏蔽区域参数 + public static final int NET_DVR_GET_VCA_MASK_REGION = 167; //获取屏蔽区域参数 + //ATM进入区域 NET_VCA_ENTER_REGION + public static final int NET_DVR_SET_VCA_ENTER_REGION = 168; //设置进入区域参数 + public static final int NET_DVR_GET_VCA_ENTER_REGION = 169; //获取进入区域参数 + //标定线配置NET_VCA_LINE_SEGMENT_LIST + public static final int NET_DVR_SET_VCA_LINE_SEGMENT = 170; //设置标定线 + public static final int NET_DVR_GET_VCA_LINE_SEGMENT = 171; //获取标定线 + // ivms屏蔽区域NET_IVMS_MASK_REGION_LIST + public static final int NET_DVR_SET_IVMS_MASK_REGION = 172; //设置IVMS屏蔽区域参数 + public static final int NET_DVR_GET_IVMS_MASK_REGION = 173; //获取IVMS屏蔽区域参数 + // ivms进入检测区域NET_IVMS_ENTER_REGION + public static final int NET_DVR_SET_IVMS_ENTER_REGION = 174; //设置IVMS进入区域参数 + public static final int NET_DVR_GET_IVMS_ENTER_REGION = 175; //获取IVMS进入区域参数 + public static final int NET_DVR_SET_IVMS_BEHAVIORCFG = 176;//设置智能分析仪行为规则参数 + public static final int NET_DVR_GET_IVMS_BEHAVIORCFG = 177; //获取智能分析仪行为规则参数 + public static final int NET_DVR_GET_TRAVERSE_PLANE_DETECTION = 3360; //获取越界侦测配置 + public static final int NET_DVR_SET_TRAVERSE_PLANE_DETECTION = 3361; + public static final int NET_DVR_GET_FIELD_DETECTION = 3362; //获取区域侦测配置 + public static final int NET_DVR_SET_FIELD_DETECTION = 3363; //设置区域侦测配置 + + public static final int NET_DVR_GET_STREAM_INFO = 6023; //获取已添加流ID信息 + public static final int NET_DVR_GET_STREAM_RECORD_STATUS = 6021; //获取流状态信息 + + public static final int NET_DVR_GET_ALL_VEHICLE_CONTROL_LIST = 3124; //获取所有车辆禁止和允许名单信息 + public static final int NET_DVR_VEHICLELIST_CTRL_START = 3133; //设置车辆禁止和允许名单信息(批量) + public static final int ENUM_SENDDATA = 0x0; //发送数据 + + public static final int NET_DVR_GET_LEDDISPLAY_CFG = 3673; + public static final int NET_DVR_SET_LEDDISPLAY_CFG = 3672; + public static final int NET_DVR_SET_VOICEBROADCAST_CFG = 3675; + public static final int NET_DVR_SET_CHARGE_ACCOUNTINFO = 3662; + + public static final int NET_DVR_GET_TRAFFIC_DATA = 3141; //长连接获取交通数据 + public static final int NET_DVR_GET_TRAFFIC_FLOW = 3142; //长连接获取交通流量 + + public static final int NET_DVR_GET_CCDPARAMCFG_EX = 3368;//获取前端参数(扩展) + public static final int NET_DVR_SET_CCDPARAMCFG_EX = 3369;//设置前端参数(扩展) + public static final int NET_DVR_GET_FOCUSMODECFG = 3305;//获取快球聚焦模式信息 + public static final int NET_DVR_SET_FOCUSMODECFG = 3306;//设置快球聚焦模式信息 + + public static final int NET_DVR_GET_SUPPLEMENTLIGHT = 3728; //获取内置补光灯配置协议 + public static final int NET_DVR_SET_SUPPLEMENTLIGHT = 3729; //设置内置补光灯配置协议 + + public static final int NET_DVR_GET_FACECONTRAST_TRIGGER = 3965;//获取人脸比对联动配置 + public static final int NET_DVR_SET_FACECONTRAST_TRIGGER = 3966;//设置人脸比对联动配置 + + public static final int NET_DVR_GET_FACECONTRAST_SCHEDULE = 3968;//获取人脸比对布防时间配置 + public static final int NET_DVR_SET_FACECONTRAST_SCHEDULE = 3969;//设置人脸比对布防时间配置 + + public static final int NET_DVR_INQUEST_GET_CDW_STATUS = 6350; //获取审讯机刻录状态-长连接 + + public static final int NET_DVR_GET_REALTIME_THERMOMETRY = 3629; //实时温度检测 + public static final int NET_DVR_GET_MANUALTHERM_INFO = 6706; //手动测温实时获取 + public static final int NET_DVR_GET_THERMOMETRY_MODE = 6765;//获取测温模式参数 + public static final int NET_DVR_SET_THERMOMETRY_MODE = 6766;//设置测温模式参数 + public static final int NET_DVR_GET_PTZABSOLUTEEX = 6696; + public static final int NET_DVR_GET_THERMOMETRY_PRESETINFO = 3624; //获取测温预置点关联配置参数 + public static final int NET_DVR_SET_THERMOMETRY_PRESETINFO = 3625; //设置测温预置点关联配置参数 + public static final int NET_DVR_GET_THERMOMETRYRULE_TEMPERATURE_INFO = 23001;//手动获取测温规则温度信息 + public static final int NET_DVR_SET_DEVSERVER_CFG = 3258;//设置模块服务配置 + + public static final int NET_DVR_GET_PHY_DISK_INFO = 6306; //获取物理磁盘信息 + public static final int NET_DVR_GET_WORK_STATUS = 6189; //获取设备工作状态 + public static final int NET_DVR_GET_MONTHLY_RECORD_DISTRIBUTION = 6164; //获取月历录像分布 + + public static final int NET_DVR_GET_CURTRIGGERMODE = 3130; //获取设备当前触发模式 + public static final int NET_ITC_GET_TRIGGERCFG = 3003; //获取触发参数 + public static final int NET_ITC_SET_TRIGGERCFG = 3004; //设置触发参数 + public static final int NET_ITC_GET_VIDEO_TRIGGERCFG = 3017; //获取视频电警触发参数 + public static final int NET_ITC_SET_VIDEO_TRIGGERCFG = 3018; //设置视频电警触发参数 + + public static final int NET_DVR_GET_MULTI_STREAM_COMPRESSIONCFG = 3216;//远程获取多码流压缩参数 + public static final int NET_DVR_SET_MULTI_STREAM_COMPRESSIONCFG = 3217;//远程设置多码流压缩参数 + + public static final int NET_DVR_GET_CMS_CFG = 2070; + public static final int NET_DVR_SET_CMS_CFG = 2071; + + public static final int NET_DVR_GET_ALARM_INFO = 4193; //获取报警事件数据 + /***************************DS9000新增命令(_V30) end *****************************/ + + /*************************参数配置命令 end*******************************/ + /*************************************特征识别门禁一体机1.0 begin**************************************/ + public static final int NET_DVR_GET_CARD_CFG = 2116; //获取卡参数 + public static final int NET_DVR_SET_CARD_CFG = 2117; //设置卡参数 + public static final int NET_DVR_GET_CARD_CFG_V50 = 2178; //获取新卡参数(V50) + public static final int NET_DVR_SET_CARD_CFG_V50 = 2179; //设置新卡参数(V50) + public static final int NET_DVR_GET_FACE_PARAM_CFG = 2507; //获取人脸参数 + public static final int NET_DVR_SET_FACE_PARAM_CFG = 2508; //设置人脸参数 + public static final int NET_DVR_DEL_FACE_PARAM_CFG = 2509; //删除人脸参数 + public static final int NET_DVR_CLEAR_ACS_PARAM = 2118; //清空门禁主机参数 + public static final int NET_DVR_DEL_FINGERPRINT_CFG = 2152; //删除指纹参数 + public static final int NET_DVR_GET_FINGERPRINT_CFG_V50 = 2183; //获取指纹参数V50 + public static final int NET_DVR_SET_FINGERPRINT_CFG_V50 = 2184; //设置指纹参数V50 + public static final int NET_DVR_DEL_FINGERPRINT_CFG_V50 = 2517; //删除指纹参数V50 + public static final int NET_DVR_GET_CARD_RIGHT_WEEK_PLAN_V50 = 2304; //获取卡权限周计划参数V50 + public static final int NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50 = 2305; //设置卡权限周计划参数V50 + public static final int NET_DVR_GET_CARD_RIGHT_PLAN_TEMPLATE_V50 = 2322; //获取卡权限计划模板参数V50 + public static final int NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50 = 2323;//设置卡权限计划模板参数V50 + public static final int NET_DVR_SET_DOOR_STATUS_PLAN_TEMPLATE = 2107; //设置门状态计划模板参数 + public static final int NET_DVR_GET_DOOR_CFG = 2108; //获取门参数 + public static final int NET_DVR_SET_DOOR_CFG = 2109; //设置门参数 + public static final int NET_DVR_GET_DOOR_STATUS_PLAN = 2110; //获取门状态计划参数 + public static final int NET_DVR_SET_DOOR_STATUS_PLAN = 2111; //设置门状态计划参数 + public static final int NET_DVR_GET_WEEK_PLAN_CFG = 2100; //获取门状态周计划参数 + public static final int NET_DVR_SET_WEEK_PLAN_CFG = 2101; //设置门状态周计划参数 + public static final int NET_DVR_GET_EVENT_CARD_LINKAGE_CFG_V50 = 2181; //获取事件卡号联动配置参数(V50) + public static final int NET_DVR_SET_EVENT_CARD_LINKAGE_CFG_V50 = 2182; //设置事件卡号联动配置参数(V50) + public static final int NET_DVR_CAPTURE_FACE_INFO = 2510; //采集人脸信息 + public static final int NET_DVR_CAPTURE_FINGERPRINT_INFO = 2504; //采集指纹信息 + public static final int NET_DVR_GET_ACS_EVENT = 2514;//设备事件获取 + public static final int NET_DVR_GET_CARD_READER_CFG_V50 = 2505; //获取读卡器参数(V50) + public static final int NET_DVR_SET_CARD_READER_CFG_V50 = 2506; //设置读卡器参数(V50) + public static final int NET_DVR_GET_REGISTER_INFO = 2511; //登记信息获取 + public static final int NET_DVR_GET_SMSRELATIVEPARA_V50 = 2512; //获取短信相关参数 + public static final int NET_DVR_SET_SMSRELATIVEPARA_V50 = 2513; //设置短信相关参数 + public static final int NET_DVR_GET_MULTI_CARD_CFG_V50 = 2515; //获取多重卡参数V50 + public static final int NET_DVR_SET_MULTI_CARD_CFG_V50 = 2516; //设置多重卡参数V5 + public static final int NET_DVR_GET_EVENT_CARD_LINKAGE_CFG_V51 = 2518; //获取事件卡号联动配置参数(V51) + public static final int NET_DVR_SET_EVENT_CARD_LINKAGE_CFG_V51 = 2519; //设置事件卡号联动配置参数(V51) + + public static final int NET_DVR_SET_EXAM_INFO = 2530; //考试信息下发 + public static final int NET_DVR_SET_EXAMINEE_INFO = 2531; //考生信息下发 + public static final int NET_DVR_SEARCH_EXAM_COMPARE_RESULT = 2532; //考试比对结果查询 + public static final int NET_DVR_BULK_CHECK_FACE_PICTURE = 2533; //批量校验人脸图片 + public static final int NET_DVR_JSON_CONFIG = 2550; //JSON透传数据 + public static final int NET_DVR_FACE_DATA_RECORD = 2551; //添加人脸数据到人脸库 + public static final int NET_DVR_FACE_DATA_SEARCH = 2552; //查询人脸库中的人脸数据 + public static final int NET_DVR_FACE_DATA_MODIFY = 2553; //修改人脸库中的人脸数据 + public static final int NET_DVR_CAPTURE_DATA_SEARCH = 2554; //查询离线采集数据集中数据 + public static final int NET_DVR_SET_FORM_DATA = 2555; //长连接设置表单数据 + public static final int NET_DVR_GET_FORM_DATA = 2556; //长连接获取表单数据 + public static final int NET_DVR_GET_CARD = 2560; + public static final int NET_DVR_SET_CARD = 2561; + public static final int NET_DVR_GET_FACE = 2566; + public static final int NET_DVR_SET_FACE = 2567; + public static final int NET_DVR_DEL_CARD = 2562; + public static final int NET_DVR_GET_FINGERPRINT = 2563; + public static final int NET_DVR_SET_FINGERPRINT = 2564; //下发指纹 + public static final int NET_DVR_DEL_FINGERPRINT = 2565; //删除指纹 + public static final int NET_DVR_GET_ACS_WORK_STATUS_V50 = 2180; //获取门禁主机工作状态 + public static final int NET_DVR_GET_ACS_CFG = 2159; //获取门禁主机参数 + public static final int NET_DVR_SET_ACS_CFG = 2160; //设置门禁主机参数 + public static final int NET_DVR_BULK_UPLOAD_ID_BLOCKLIST = 2521; //批量上传身份证禁止名单 + + /*************************************特征识别门禁一体机1.0 end**************************************/ + public static final int NET_DVR_SET_SENSOR_CFG = 1180;//设置模拟量参数 + public static final int NET_DVR_GET_SENSOR_CFG = 1181;//获取模拟量参数 + public static final int NET_DVR_SET_ALARMIN_PARAM = 1182;//设置报警输入参数 + public static final int NET_DVR_GET_ALARMIN_PARAM = 1183; + ;//获取报警输入参数 + public static final int NET_DVR_SET_ALARMOUT_PARAM = 1184;//设置报警输出参数 + public static final int NET_DVR_GET_ALARMOUT_PARAM = 1185;//获取报警输出参数 + public static final int NET_DVR_SET_SIREN_PARAM = 1186;//设置警号参数 + public static final int NET_DVR_GET_SIREN_PARAM = 1187;//获取警号参数 + public static final int NET_DVR_SET_ALARM_RS485CFG = 1188;//设置报警主机485参数 + public static final int NET_DVR_GET_ALARM_RS485CFG = 1189;//获取报警主机485参数 + public static final int NET_DVR_GET_ALARMHOST_MAIN_STATUS = 1190;//获取报警主机主要状态 + public static final int NET_DVR_GET_ALARMHOST_OTHER_STATUS = 1191;//获取报警主机其他状态 + public static final int NET_DVR_SET_ALARMHOST_ENABLECFG = 1192;//获取报警主机使能状态 + public static final int NET_DVR_GET_ALARMHOST_ENABLECFG = 1193;//设置报警主机使能状态 + public static final int NET_DVR_SET_ALARM_CAMCFG = 1194;//设置视频综合平台报警触发CAM操作配置 + public static final int NET_DVR_GET_ALARM_CAMCFG = 1195;//设置视频综合平台报警触发CAM操作配置 + public static final int NET_DVR_SET_ALARMHOST_RS485_SLOT_CFG = 2055;// 设置报警主机485槽位参数 + public static final int NET_DVR_GET_ALARMHOST_RS485_SLOT_CFG = 2056;// 获取报警主机485槽位参数 + public static final int NET_DVR_SET_VIDEOWALLDISPLAYMODE = 1730;//设置电视墙拼接模式 + public static final int NET_DVR_GET_VIDEOWALLDISPLAYMODE = 1731;//获取电视墙拼接模式 + public static final int NET_DVR_GET_VIDEOWALLDISPLAYNO = 1732;//获取设备显示输出号 + public static final int NET_DVR_SET_VIDEOWALLDISPLAYPOSITION = 1733;//设置显示输出位置参数 + public static final int NET_DVR_GET_VIDEOWALLDISPLAYPOSITION = 1734;//获取显示输出位置参数 + public static final int NET_DVR_GET_VIDEOWALLWINDOWPOSITION = 1735;//获取电视墙窗口参数 + public static final int NET_DVR_SET_VIDEOWALLWINDOWPOSITION = 1736;//设置电视墙窗口参数 + public static final int NET_DVR_VIDEOWALLWINDOW_CLOSEALL = 1737;//电视墙关闭所有窗口 + public static final int NET_DVR_SET_VIRTUALLED = 1738;//虚拟LED设置 + public static final int NET_DVR_GET_VIRTUALLED = 1739;//虚拟LED获取 + public static final int NET_DVR_GET_IMAGE_CUT_MODE = 1740;//获取图像切割模式 + public static final int NET_DVR_SET_IMAGE_CUT_MODE = 1741;//设置图像切割模式 + public static final int NET_DVR_GET_USING_SERIALPORT = 1742;//获取当前使用串口 + public static final int NET_DVR_SET_USING_SERIALPORT = 1743;//设置当前使用串口 + public static final int NET_DVR_SCENE_CONTROL = 1744;//场景控制 + public static final int NET_DVR_GET_CURRENT_SCENE = 1745;//获取当前场景号 + public static final int NET_DVR_GET_VW_SCENE_PARAM = 1746;//获取电视墙场景模式参数 + public static final int NET_DVR_SET_VW_SCENE_PARAM = 1747;//设置电视墙场景模式参数 + public static final int NET_DVR_DISPLAY_CHANNO_CONTROL = 1748;//电视墙显示编号控制 + public static final int NET_DVR_GET_WIN_DEC_INFO = 1749;//获取窗口解码信息(批量) + public static final int NET_DVR_RESET_VIDEOWALLDISPLAYPOSITION = 1750; //解除电视墙输出接口绑定 + public static final int NET_DVR_SET_VW_AUDIO_CFG = 1752; //设置音频切换参数 + public static final int NET_DVR_GET_VW_AUDIO_CFG = 1753; //获取音频切换参数 + public static final int NET_DVR_GET_GBT28181_DECCHANINFO_CFG = 1754; //获取GBT28181协议接入设备的解码通道信息 + public static final int NET_DVR_SET_GBT28181_DECCHANINFO_CFG = 1755; //设置GBT28181协议接入设备的解码通道信息 + public static final int NET_DVR_SET_MAINBOARD_SERIAL = 1756; //设置主控板串口参数 + public static final int NET_DVR_GET_MAINBOARD_SERIAL = 1757;//获取主控板串口参数 + public static final int NET_DVR_GET_SUBBOARD_INFO = 1758; //获取子板信息 + public static final int NET_DVR_GET_SUBBOARD_EXCEPTION = 1759; //获取异常子板异常信息 + /*****************************电视墙 start****************************/ + public static final int NET_DVR_MATRIX_WALL_SET = 9001; //设置电视墙中屏幕参数 + public static final int NET_DVR_MATRIX_WALL_GET = 9002; //获取电视墙中屏幕参数 + public static final int NET_DVR_WALLWIN_GET = 9003; //电视墙中获取窗口参数 + public static final int NET_DVR_WALLWIN_SET = 9004; //电视墙中设置窗口参数 + public static final int NET_DVR_WALLWINPARAM_SET = 9005; + ; //设置电视墙窗口相关参数 + public static final int NET_DVR_WALLWINPARAM_GET = 9006; //获取电视墙窗口相关参数 + public static final int NET_DVR_WALLSCENEPARAM_GET = 9007; //设置场景模式参数 + public static final int NET_DVR_WALLSCENEPARAM_SET = 9008; //获取场景模式参数 + public static final int NET_DVR_MATRIX_GETWINSTATUS = 9009; //获取窗口解码状态 + public static final int NET_DVR_GET_WINASSOCIATEDDEVINFO = 9010; //电视墙中获取对应资源信息 + public static final int NET_DVR_WALLOUTPUT_GET = 9011; //电视墙中获取显示输出参数 + public static final int NET_DVR_WALLOUTPUT_SET = 9012; //电视墙中设置显示输出参数 + public static final int NET_DVR_GET_UNITEDMATRIXSYSTEM = 9013; //电视墙中获取对应资源 + public static final int NET_DVR_GET_WALL_CFG = 9014; //获取电视墙全局参数 + public static final int NET_DVR_SET_WALL_CFG = 9015; //设置电视墙全局参数 + public static final int NET_DVR_CLOSE_ALL_WND = 9016; //关闭所有窗口 + public static final int NET_DVR_SWITCH_WIN_TOP = 9017; //窗口置顶 + public static final int NET_DVR_SWITCH_WIN_BOTTOM = 9018; //窗口置底 + + public static final int NET_DVR_CLOSE_ALL_WND_V41 = 9019; //电视墙关闭所有窗口v41(有多个电视墙) + public static final int NET_DVR_GET_WALL_WINDOW_V41 = 9020; //获取电视墙中的窗口v41 + public static final int NET_DVR_SET_WALL_WINDOW_V41 = 9021; //设置电视墙中的窗口v41 + public static final int NET_DVR_GET_CURRENT_SCENE_V41 = 9022; //获取当前电视墙中正在使用的场景v41 + public static final int NET_DVR_GET_WALL_SCENE_PARAM_V41 = 9023; //获取当前电视墙中正在使用的场景v41 + public static final int NET_DVR_SET_WALL_SCENE_PARAM_V41 = 9024; //设置当前电视墙中正在使用的场景v41 + public static final int NET_DVR_GET_MATRIX_LOGO_CFG = 9025; //获取logo参数 + public static final int NET_DVR_SET_MATRIX_LOGO_CFG = 9026; //设置logo参数 + public static final int NET_DVR_GET_WIN_LOGO_CFG = 9027; //获取窗口logo参数 + public static final int NET_DVR_SET_WIN_LOGO_CFG = 9028; //设置窗口logo参数 + public static final int NET_DVR_DELETE_LOGO = 9029; //删除logo + public static final int NET_DVR_SET_DISPLAY_EFFECT_CFG = 9030; //设置显示输出效果参数v41 + public static final int NET_DVR_GET_DISPLAY_EFFECT_CFG = 9031; //获取显示输出效果参数v41 + public static final int NET_DVR_DEC_PLAY_REMOTE_FILE = 9032; //解码播放远程文件 + public static final int NET_DVR_DEC_PLAY_REMOTE_FILE_V50 = 9314; //解码播放远程文件V50 + public static final int NET_DVR_GET_WIN_ZOOM_STATUS = 9033; //获取窗口电子放大状态 + public static final int NET_DVR_GET_ALL_MATRIX_LOGOCFG = 9034; //获取所有logo参数 + +/*****************************电视墙 end******************************/ + + /******************* + * 查找文件和日志函数返回值 + *************************/ + public static final int NET_DVR_FILE_SUCCESS = 1000; //获得文件信息 + public static final int NET_DVR_FILE_NOFIND = 1001; //没有文件 + public static final int NET_DVR_ISFINDING = 1002;//正在查找文件 + public static final int NET_DVR_NOMOREFILE = 1003;//查找文件时没有更多的文件 + public static final int NET_DVR_FILE_EXCEPTION = 1004;//查找文件时异常 + /********************* + * 回调函数类型 begin + ************************/ + public static final int COMM_ALARM = 0x1100; //8000报警信息主动上传 + public static final int COMM_TRADEINFO = 0x1500; //ATMDVR主动上传交易信息 + public static final int COMM_ALARM_V30 = 0x4000;//9000报警信息主动上传 + public static final int COMM_ALARM_V40 = 0x4007; + public static final int COMM_ALARM_RULE = 0x1102;//异常行为检测信息上传 + public static final int COMM_ALARM_PDC = 0x1103;//客流量统计报警上传 + public static final int COMM_UPLOAD_PLATE_RESULT = 0x2800;//交通抓拍结果上传 + public static final int COMM_ITS_PLATE_RESULT = 0x3050;//交通抓拍的终端图片上传 + public static final int COMM_IPCCFG = 0x4001;//9000设备IPC接入配置改变报警信息主动上传 + public static final int COMM_ITS_PARK_VEHICLE = 0x3056;//停车场数据上传 + public static final int COMM_VEHICLE_CONTROL_ALARM = 0x3059;//车辆报警上传 + public static final int COMM_ALARM_TFS = 0x1113; //交通取证报警信息 + public static final int COMM_ALARM_TPS_V41 = 0x1114; //交通事件报警信息扩展 + public static final int COMM_ALARM_AID_V41 = 0x1115; //交通事件报警信息扩展 + public static final int COMM_UPLOAD_FACESNAP_RESULT = 0x1112; //特征识别结果上传 + public static final int COMM_SNAP_MATCH_ALARM = 0x2902; //人脸比对结果上传 + public static final int COMM_ALARM_ACS = 0x5002; //门禁主机报警信息 + public static final int COMM_ID_INFO_ALARM = 0x5200; //门禁身份证刷卡信息 + public static final int COMM_VCA_ALARM = 0x4993; //智能检测通用报警 + public static final int COMM_ISAPI_ALARM = 0x6009;//ISAPI协议报警信息 + public static final int COMM_ALARM_TPS_STATISTICS = 0x3082; //TPS统计过车数据上传 + public static final int COMM_ALARM_TPS_REAL_TIME = 0x3081; //TPS实时过车数据上传 + public static final int COMM_ALARMHOST_CID_ALARM = 0x1127; //报告报警上传 + public static final int COMM_SENSOR_VALUE_UPLOAD = 0x1120; //模拟量数据实时上传 + public static final int COMM_SENSOR_ALARM = 0x1121; //模拟量报警上传 + public static final int COMM_SWITCH_ALARM = 0x1122; //开关量报警 + public static final int COMM_ALARMHOST_EXCEPTION = 0x1123; //报警主机故障报警 + public static final int COMM_ALARMHOST_OPERATEEVENT_ALARM = 0x1124; //操作事件报警上传 + public static final int COMM_ALARMHOST_SAFETYCABINSTATE = 0x1125; //防护舱状态 + public static final int COMM_ALARMHOST_ALARMOUTSTATUS = 0x1126; //报警输出口/警号状态 + public static final int COMM_ALARMHOST_DATA_UPLOAD = 0x1129; //报警数据上传 + + public static final int COMM_UPLOAD_VIDEO_INTERCOM_EVENT = 0x1132; //可视对讲事件记录上传 + public static final int COMM_ALARM_VIDEO_INTERCOM = 0x1133; //可视对讲报警上传 + public static final int COMM_THERMOMETRY_ALARM = 0x5212; //温度报警上传 + public static final int COMM_FIREDETECTION_ALARM = 0x4991; //火点报警上传 + public static final int COMM_THERMOMETRY_DIFF_ALARM = 0x5111; //温差报警 + public static final int COMM_ALARM_SHIPSDETECTION = 0x4521; //船只检测报警 + public static final int COMM_UPLOAD_AIOP_VIDEO = 0x4021; //设备支持AI开放平台接入,上传视频检测数据 + public static final int COMM_UPLOAD_AIOP_PICTURE = 0x4022; //设备支持AI开放平台接入,上传图片检测数据 + public static final int COMM_UPLOAD_AIOP_POLLING_SNAP = 0x4023; //设备支持AI开放平台接入,上传轮巡抓图图片检测数据 对应的结构体(NET_AIOP_POLLING_PICTURE_HEAD) + public static final int COMM_UPLOAD_AIOP_POLLING_VIDEO = 0x4024; //设备支持AI开放平台接入,上传轮巡视频检测数据 对应的结构体(NET_AIOP_POLLING_VIDEO_HEAD) + public static final int COMM_IPC_AUXALARM_RESULT = 0x2820; //PIR报警、无线报警、呼救报警信息 + /************* + * 操作异常类型(消息方式, 回调方式(保留)) + ****************/ + public static final int EXCEPTION_EXCHANGE = 0x8000;//用户交互时异常 + public static final int EXCEPTION_AUDIOEXCHANGE = 0x8001;//语音对讲异常 + public static final int EXCEPTION_ALARM = 0x8002;//报警异常 + public static final int EXCEPTION_PREVIEW = 0x8003;//网络预览异常 + public static final int EXCEPTION_SERIAL = 0x8004;//透明通道异常 + public static final int EXCEPTION_RECONNECT = 0x8005; //预览时重连 + public static final int EXCEPTION_ALARMRECONNECT = 0x8006;//报警时重连 + public static final int EXCEPTION_SERIALRECONNECT = 0x8007;//透明通道重连 + public static final int EXCEPTION_PLAYBACK = 0x8010;//回放异常 + public static final int EXCEPTION_DISKFMT = 0x8011;//硬盘格式化 + /******************** + * 预览回调函数 + *********************/ + public static final int NET_DVR_SYSHEAD = 1;//系统头数据 + public static final int NET_DVR_STREAMDATA = 2;//视频流数据(包括复合流和音视频分开的视频流数据) + public static final int NET_DVR_AUDIOSTREAMDATA = 3;//音频流数据 + public static final int NET_DVR_STD_VIDEODATA = 4;//标准视频流数据 + public static final int NET_DVR_STD_AUDIODATA = 5;//标准音频流数据 + //回调预览中的状态和消息 + public static final int NET_DVR_REALPLAYEXCEPTION = 111;//预览异常 + public static final int NET_DVR_REALPLAYNETCLOSE = 112;//预览时连接断开 + public static final int NET_DVR_REALPLAY5SNODATA = 113;//预览5s没有收到数据 + public static final int NET_DVR_REALPLAYRECONNECT = 114;//预览重连 + /******************** + * 回放回调函数 + *********************/ + public static final int NET_DVR_PLAYBACKOVER = 101;//回放数据播放完毕 + public static final int NET_DVR_PLAYBACKEXCEPTION = 102;//回放异常 + public static final int NET_DVR_PLAYBACKNETCLOSE = 103;//回放时候连接断开 + public static final int NET_DVR_PLAYBACK5SNODATA = 104; //回放5s没有收到数据 + /********************* + * 回调函数类型 end + ************************/ +//设备型号(DVR类型) + /* 设备类型 */ + public static final int DVR = 1; /*对尚未定义的dvr类型返回NETRET_DVR*/ + public static final int ATMDVR = 2; /*atm dvr*/ + public static final int DVS = 3; /*DVS*/ + public static final int DEC = 4; /* 6001D */ + public static final int ENC_DEC = 5; /* 6001F */ + public static final int DVR_HC = 6; /*8000HC*/ + public static final int DVR_HT = 7; /*8000HT*/ + public static final int DVR_HF = 8; /*8000HF*/ + public static final int DVR_HS = 9; /* 8000HS DVR(no audio) */ + public static final int DVR_HTS = 10; /* 8016HTS DVR(no audio) */ + public static final int DVR_HB = 11; /* HB DVR(SATA HD) */ + public static final int DVR_HCS = 12; /* 8000HCS DVR */ + public static final int DVS_A = 13; /* 带ATA硬盘的DVS */ + public static final int DVR_HC_S = 14; /* 8000HC-S */ + public static final int DVR_HT_S = 15; /* 8000HT-S */ + public static final int DVR_HF_S = 16; /* 8000HF-S */ + public static final int DVR_HS_S = 17; /* 8000HS-S */ + public static final int ATMDVR_S = 18; /* ATM-S */ + public static final int LOWCOST_DVR = 19; /*7000H系列*/ + public static final int DEC_MAT = 20; /*多路解码器*/ + public static final int DVR_MOBILE = 21; /* mobile DVR */ + public static final int DVR_HD_S = 22; /* 8000HD-S */ + public static final int DVR_HD_SL = 23; /* 8000HD-SL */ + public static final int DVR_HC_SL = 24; /* 8000HC-SL */ + public static final int DVR_HS_ST = 25; /* 8000HS_ST */ + public static final int DVS_HW = 26; /* 6000HW */ + public static final int IPCAM = 30; /*IP 摄像机*/ + public static final int MEGA_IPCAM = 31; /*X52MF系列,752MF,852MF*/ + public static final int IPCAM_X62MF = 32; /*X62MF系列可接入9000设备,762MF,862MF*/ + public static final int IPDOME = 40; /*IP标清快球*/ + public static final int MEGA_IPDOME = 41; /*IP高清快球*/ + public static final int IPMOD = 50; /*IP 模块*/ + public static final int DS71XX_H = 71; /* DS71XXH_S */ + public static final int DS72XX_H_S = 72; /* DS72XXH_S */ + public static final int DS73XX_H_S = 73; /* DS73XXH_S */ + public static final int DS81XX_HS_S = 81; /* DS81XX_HS_S */ + public static final int DS81XX_HL_S = 82; /* DS81XX_HL_S */ + public static final int DS81XX_HC_S = 83; /* DS81XX_HC_S */ + public static final int DS81XX_HD_S = 84; /* DS81XX_HD_S */ + public static final int DS81XX_HE_S = 85; /* DS81XX_HE_S */ + public static final int DS81XX_HF_S = 86; /* DS81XX_HF_S */ + public static final int DS81XX_AH_S = 87; /* DS81XX_AH_S */ + public static final int DS81XX_AHF_S = 88; /* DS81XX_AHF_S */ + public static final int DS90XX_HF_S = 90; /*DS90XX_HF_S*/ + public static final int DS91XX_HF_S = 91; /*DS91XX_HF_S*/ + public static final int DS91XX_HD_S = 92; /*91XXHD-S(MD)*/ + + /* 操作 */ +//主类型 + public static final int MAJOR_OPERATION = 0x3; + //次类型 + public static final int MINOR_START_DVR = 0x41; /* 开机 */ + public static final int MINOR_STOP_DVR = 0x42;/* 关机 */ + public static final int MINOR_STOP_ABNORMAL = 0x43;/* 异常关机 */ + public static final int MINOR_REBOOT_DVR = 0x44; /*本地重启设备*/ + public static final int MINOR_LOCAL_LOGIN = 0x50; /* 本地登陆 */ + public static final int MINOR_LOCAL_LOGOUT = 0x51; /* 本地注销登陆 */ + public static final int MINOR_LOCAL_CFG_PARM = 0x52; /* 本地配置参数 */ + public static final int MINOR_LOCAL_PLAYBYFILE = 0x53; /* 本地按文件回放或下载 */ + public static final int MINOR_LOCAL_PLAYBYTIME = 0x54; /* 本地按时间回放或下载*/ + public static final int MINOR_LOCAL_START_REC = 0x55; /* 本地开始录像 */ + public static final int MINOR_LOCAL_STOP_REC = 0x56; /* 本地停止录像 */ + public static final int MINOR_LOCAL_PTZCTRL = 0x57; /* 本地云台控制 */ + public static final int MINOR_LOCAL_PREVIEW = 0x58;/* 本地预览 (保留不使用)*/ + public static final int MINOR_LOCAL_MODIFY_TIME = 0x59;/* 本地修改时间(保留不使用) */ + public static final int MINOR_LOCAL_UPGRADE = 0x5a;/* 本地升级 */ + public static final int MINOR_LOCAL_RECFILE_OUTPUT = 0x5b; /* 本地备份录象文件 */ + public static final int MINOR_LOCAL_FORMAT_HDD = 0x5c; /* 本地初始化硬盘 */ + public static final int MINOR_LOCAL_CFGFILE_OUTPUT = 0x5d; /* 导出本地配置文件 */ + public static final int MINOR_LOCAL_CFGFILE_INPUT = 0x5e; /* 导入本地配置文件 */ + public static final int MINOR_LOCAL_COPYFILE = 0x5f; /* 本地备份文件 */ + public static final int MINOR_LOCAL_LOCKFILE = 0x60; /* 本地锁定录像文件 */ + public static final int MINOR_LOCAL_UNLOCKFILE = 0x61; /* 本地解锁录像文件 */ + public static final int MINOR_LOCAL_DVR_ALARM = 0x62; /* 本地手动清除和触发报警*/ + public static final int MINOR_IPC_ADD = 0x63; /* 本地添加IPC */ + public static final int MINOR_IPC_DEL = 0x64; /* 本地删除IPC */ + public static final int MINOR_IPC_SET = 0x65; /* 本地设置IPC */ + public static final int MINOR_LOCAL_START_BACKUP = 0x66; /* 本地开始备份 */ + public static final int MINOR_LOCAL_STOP_BACKUP = 0x67;/* 本地停止备份*/ + public static final int MINOR_LOCAL_COPYFILE_START_TIME = 0x68;/* 本地备份开始时间*/ + public static final int MINOR_LOCAL_COPYFILE_END_TIME = 0x69; /* 本地备份结束时间*/ + public static final int MINOR_REMOTE_LOGIN = 0x70;/* 远程登录 */ + public static final int MINOR_REMOTE_LOGOUT = 0x71;/* 远程注销登陆 */ + public static final int MINOR_REMOTE_START_REC = 0x72;/* 远程开始录像 */ + public static final int MINOR_REMOTE_STOP_REC = 0x73;/* 远程停止录像 */ + public static final int MINOR_START_TRANS_CHAN = 0x74;/* 开始透明传输 */ + public static final int MINOR_STOP_TRANS_CHAN = 0x75; /* 停止透明传输 */ + public static final int MINOR_REMOTE_GET_PARM = 0x76;/* 远程获取参数 */ + public static final int MINOR_REMOTE_CFG_PARM = 0x77;/* 远程配置参数 */ + public static final int MINOR_REMOTE_GET_STATUS = 0x78;/* 远程获取状态 */ + public static final int MINOR_REMOTE_ARM = 0x79; /* 远程布防 */ + public static final int MINOR_REMOTE_DISARM = 0x7a;/* 远程撤防 */ + public static final int MINOR_REMOTE_REBOOT = 0x7b; /* 远程重启 */ + public static final int MINOR_START_VT = 0x7c;/* 开始语音对讲 */ + public static final int MINOR_STOP_VT = 0x7d;/* 停止语音对讲 */ + public static final int MINOR_REMOTE_UPGRADE = 0x7e; /* 远程升级 */ + public static final int MINOR_REMOTE_PLAYBYFILE = 0x7f; /* 远程按文件回放 */ + public static final int MINOR_REMOTE_PLAYBYTIME = 0x80; /* 远程按时间回放 */ + public static final int MINOR_REMOTE_PTZCTRL = 0x81; /* 远程云台控制 */ + public static final int MINOR_REMOTE_FORMAT_HDD = 0x82; /* 远程格式化硬盘 */ + public static final int MINOR_REMOTE_STOP = 0x83; /* 远程关机 */ + public static final int MINOR_REMOTE_LOCKFILE = 0x84;/* 远程锁定文件 */ + public static final int MINOR_REMOTE_UNLOCKFILE = 0x85;/* 远程解锁文件 */ + public static final int MINOR_REMOTE_CFGFILE_OUTPUT = 0x86; /* 远程导出配置文件 */ + public static final int MINOR_REMOTE_CFGFILE_INTPUT = 0x87; /* 远程导入配置文件 */ + public static final int MINOR_REMOTE_RECFILE_OUTPUT = 0x88; /* 远程导出录象文件 */ + public static final int MINOR_REMOTE_DVR_ALARM = 0x89; /* 远程手动清除和触发报警*/ + public static final int MINOR_REMOTE_IPC_ADD = 0x8a; /* 远程添加IPC */ + public static final int MINOR_REMOTE_IPC_DEL = 0x8b;/* 远程删除IPC */ + public static final int MINOR_REMOTE_IPC_SET = 0x8c; /* 远程设置IPC */ + public static final int MINOR_REBOOT_VCA_LIB = 0x8d; /*重启智能库*/ + + /*日志附加信息*/ +//主类型 + public static final int MAJOR_INFORMATION = 0x4; /*附加信息*/ + //次类型 + public static final int MINOR_HDD_INFO = 0xa1;/*硬盘信息*/ + public static final int MINOR_SMART_INFO = 0xa2; /*SMART信息*/ + public static final int MINOR_REC_START = 0xa3; /*开始录像*/ + public static final int MINOR_REC_STOP = 0xa4;/*停止录像*/ + public static final int MINOR_REC_OVERDUE = 0xa5;/*过期录像删除*/ + public static final int MINOR_LINK_START = 0xa6; // ivms多路解码器等连接前端设备 + public static final int MINOR_LINK_STOP = 0xa7;// ivms多路解码器等断开前端设备  + //当日志的主类型为MAJOR_OPERATION=03,次类型为MINOR_LOCAL_CFG_PARM=0x52或者MINOR_REMOTE_GET_PARM=0x76或者MINOR_REMOTE_CFG_PARM=0x77时,dwParaType:参数类型有效,其含义如下: + public static final int PARA_VIDEOOUT = 0x1; + public static final int PARA_IMAGE = 0x2; + public static final int PARA_ENCODE = 0x4; + public static final int PARA_NETWORK = 0x8; + public static final int PARA_ALARM = 0x10; + public static final int PARA_EXCEPTION = 0x20; + public static final int PARA_DECODER = 0x40; /*解码器*/ + public static final int PARA_RS232 = 0x80; + public static final int PARA_PREVIEW = 0x100; + public static final int PARA_SECURITY = 0x200; + public static final int PARA_DATETIME = 0x400; + public static final int PARA_FRAMETYPE = 0x800; /*帧格式*/ + public static final int PARA_VCA_RULE = 0x1000; //行为规则 + //SDK_V222 +//智能设备类型 + public static final int DS6001_HF_B = 60;//异常行为检测:DS6001-HF/B + public static final int DS6001_HF_P = 61;//车牌识别:DS6001-HF/P + public static final int DS6002_HF_B = 62;//双机:DS6002-HF/B + public static final int DS6101_HF_B = 63;//异常行为检测:DS6101-HF/B + public static final int IVMS_2000 = 64;//智能分析仪 + public static final int DS9000_IVS = 65;//9000系列智能DVR + public static final int DS8004_AHL_A = 66;//智能ATM, DS8004AHL-S/A + public static final int DS6101_HF_P = 67;//车牌识别:DS6101-HF/P + //能力获取命令 + public static final int VCA_DEV_ABILITY = 0x100;//设备智能分析的总能力 + public static final int VCA_CHAN_ABILITY = 0x110;//异常行为检测能力 + public static final int DEVICE_ABILITY_INFO = 0x011; //设备通用能力类型,具体能力根据发送的能力节点来区分 + public static final int NET_DVR_CHECK_USER_STATUS = 20005; //检测设备是否在线 + /**********************设备类型 end***********************/ + + /************************************************* + * 参数配置结构、参数(其中_V30为9000新增) + **************************************************/ + + ///////////////////////////////////////////////////////////////////////// + //校时结构参数 + public static class NET_DVR_TIME extends Structure {//校时结构参数 + public int dwYear; //年 + public int dwMonth; //月 + public int dwDay; //日 + public int dwHour; //时 + public int dwMinute; //分 + public int dwSecond; //秒 + + public String toString() { + return "NET_DVR_TIME.dwYear: " + dwYear + "\n" + "NET_DVR_TIME.dwMonth: \n" + dwMonth + "\n" + "NET_DVR_TIME.dwDay: \n" + dwDay + "\n" + "NET_DVR_TIME.dwHour: \n" + dwHour + "\n" + "NET_DVR_TIME.dwMinute: \n" + dwMinute + "\n" + "NET_DVR_TIME.dwSecond: \n" + dwSecond; + } + + //用于列表中显示 + public String toStringTime() { + return String.format("%02d/%02d/%02d%02d:%02d:%02d", dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond); + } + + //存储文件名使用 + public String toStringTitle() { + return String.format("Time%02d%02d%02d%02d%02d%02d", dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond); + } + } + + public static class NET_DVR_SCHEDTIME extends Structure { + public byte byStartHour; //开始时间 + public byte byStartMin; + public byte byStopHour; //结束时间 + public byte byStopMin; + + + } + + public static class NET_DVR_HANDLEEXCEPTION_V30 extends Structure { + public int dwHandleType; /*处理方式,处理方式的"或"结果*//*0x00: 无响应*//*0x01: 布防器上警告*//*0x02: 声音警告*//*0x04: 上传中心*/ /*0x08: 触发报警输出*//*0x20: 触发抓图*/ //(JPEG定制) + public byte[] byRelAlarmOut = new byte[MAX_ALARMOUT_V30]; //报警触发的输出通道,报警触发的输出,为1表示触发该输出 + + } + + //报警和异常处理结构(子结构)(多处使用) + public static class NET_DVR_HANDLEEXCEPTION extends Structure { + public int dwHandleType; /*处理方式,处理方式的"或"结果*//*0x00: 无响应*//*0x01: 布防器上警告*//*0x02: 声音警告*//*0x04: 上传中心*/ /*0x08: 触发报警输出*//*0x20: 触发抓图*/ //(JPEG定制) + public byte[] byRelAlarmOut = new byte[MAX_ALARMOUT]; //报警触发的输出通道,报警触发的输出,为1表示触发该输出 + + } + + //DVR设备参数 + public static class NET_DVR_DEVICECFG extends Structure { + public int dwSize; + public byte[] sDVRName = new byte[NAME_LEN]; //DVR名称 + public int dwDVRID; //DVR ID,用于遥控器 //V1.4(0-99), V1.5(0-255) + public int dwRecycleRecord; //是否循环录像,0:不是; 1:是 + //以下不可更改 + public byte[] sSerialNumber = new byte[SERIALNO_LEN]; //序列号 + public int dwSoftwareVersion; //软件版本号,高16位是主版本,低16位是次版本 + public int dwSoftwareBuildDate; //软件生成日期,0xYYYYMMDD + public int dwDSPSoftwareVersion; //DSP软件版本,高16位是主版本,低16位是次版本 + public int dwDSPSoftwareBuildDate; // DSP软件生成日期,0xYYYYMMDD + public int dwPanelVersion; // 前面板版本,高16位是主版本,低16位是次版本 + public int dwHardwareVersion; // 硬件版本,高16位是主版本,低16位是次版本 + public byte byAlarmInPortNum; //DVR报警输入个数 + public byte byAlarmOutPortNum; //DVR报警输出个数 + public byte byRS232Num; //DVR 232串口个数 + public byte byRS485Num; //DVR 485串口个数 + public byte byNetworkPortNum; //网络口个数 + public byte byDiskCtrlNum; //DVR 硬盘控制器个数 + public byte byDiskNum; //DVR 硬盘个数 + public byte byDVRType; //DVR类型, 1:DVR 2:ATM DVR 3:DVS ...... + public byte byChanNum; //DVR 通道个数 + public byte byStartChan; //起始通道号,例如DVS-1,DVR - 1 + public byte byDecordChans; //DVR 解码路数 + public byte byVGANum; //VGA口的个数 + public byte byUSBNum; //USB口的个数 + public byte byAuxoutNum; //辅口的个数 + public byte byAudioNum; //语音口的个数 + public byte byIPChanNum; //最大数字通道数 + + + } + + //DVR设备参数 + public static class NET_DVR_DEVICECFG_V40 extends Structure { + public int dwSize; + public byte[] sDVRName = new byte[NAME_LEN]; //DVR名称 + public int dwDVRID; //DVR ID,用于遥控器 //V1.4(0-99), V1.5(0-255) + public int dwRecycleRecord; //是否循环录像,0:不是; 1:是 + //以下不可更改 + public byte[] sSerialNumber = new byte[SERIALNO_LEN]; //序列号 + public int dwSoftwareVersion; //软件版本号,高16位是主版本,低16位是次版本 + public int dwSoftwareBuildDate; //软件生成日期,0xYYYYMMDD + public int dwDSPSoftwareVersion; //DSP软件版本,高16位是主版本,低16位是次版本 + public int dwDSPSoftwareBuildDate; // DSP软件生成日期,0xYYYYMMDD + public int dwPanelVersion; // 前面板版本,高16位是主版本,低16位是次版本 + public int dwHardwareVersion; // 硬件版本,高16位是主版本,低16位是次版本 + public byte byAlarmInPortNum; //DVR报警输入个数 + public byte byAlarmOutPortNum; //DVR报警输出个数 + public byte byRS232Num; //DVR 232串口个数 + public byte byRS485Num; //DVR 485串口个数 + public byte byNetworkPortNum; //网络口个数 + public byte byDiskCtrlNum; //DVR 硬盘控制器个数 + public byte byDiskNum; //DVR 硬盘个数 + public byte byDVRType; //DVR类型, 1:DVR 2:ATM DVR 3:DVS ...... + public byte byChanNum; //DVR 通道个数 + public byte byStartChan; //起始通道号,例如DVS-1,DVR - 1 + public byte byDecordChans; //DVR 解码路数 + public byte byVGANum; //VGA口的个数 + public byte byUSBNum; //USB口的个数 + public byte byAuxoutNum; //辅口的个数 + public byte byAudioNum; //语音口的个数 + public byte byIPChanNum; //最大数字通道数 低8位,高8位见byHighIPChanNum + public byte byZeroChanNum; //零通道编码个数 + public byte bySupport; //能力,位与结果为0表示不支持,1表示支持, + public byte byEsataUseage; //Esata的默认用途,0-默认备份,1-默认录像 + public byte byIPCPlug; //0-关闭即插即用,1-打开即插即用 + public byte byStorageMode; //0-盘组模式,1-磁盘配额, 2抽帧模式, 3-自动 + public byte bySupport1; //能力,位与结果为0表示不支持,1表示支持 + public short wDevType;//设备型号 + public byte[] byDevTypeName = new byte[DEV_TYPE_NAME_LEN];//设备型号名称 + public byte bySupport2; //能力集扩展,位与结果为0表示不支持,1表示支持 + //bySupport2 & 0x1, 表示是否支持扩展的OSD字符叠加(终端和抓拍机扩展区分) + public byte byAnalogAlarmInPortNum; //模拟报警输入个数 + public byte byStartAlarmInNo; //模拟报警输入起始号 + public byte byStartAlarmOutNo; //模拟报警输出起始号 + public byte byStartIPAlarmInNo; //IP报警输入起始号 + public byte byStartIPAlarmOutNo; //IP报警输出起始号 + public byte byHighIPChanNum; //数字通道个数,高8位 + public byte byEnableRemotePowerOn;//是否启用在设备休眠的状态下远程开机功能,0-不启用,1-启用 + public short wDevClass; //设备大类备是属于哪个产品线,0 保留,1-50 DVR,51-100 DVS,101-150 NVR,151-200 IPC,65534 其他,具体分类方法见《设备类型对应序列号和类型值.docx》 + public byte[] byRes2 = new byte[6]; //保留 + + + } + + public static class NET_DVR_IPADDR extends Structure { + public byte[] sIpV4 = new byte[16]; + public byte[] byRes = new byte[128]; + + public String toString() { + return "NET_DVR_IPADDR.sIpV4: " + new String(sIpV4) + "\n" + "NET_DVR_IPADDR.byRes: " + new String(byRes) + "\n"; + } + + + } + + + //网络数据结构(子结构)(9000扩展) + public static class NET_DVR_ETHERNET_V30 extends Structure { + public NET_DVR_IPADDR struDVRIP; + public NET_DVR_IPADDR struDVRIPMask; + public int dwNetInterface; + public short wDVRPort; + public short wMTU; + public byte[] byMACAddr = new byte[6]; + + public String toString() { + return "NET_DVR_ETHERNET_V30.struDVRIP: \n" + struDVRIP + "\n" + "NET_DVR_ETHERNET_V30.struDVRIPMask: \n" + struDVRIPMask + "\n" + "NET_DVR_ETHERNET_V30.dwNetInterface: " + dwNetInterface + "\n" + "NET_DVR_ETHERNET_V30.wDVRPort: " + wDVRPort + "\n" + "NET_DVR_ETHERNET_V30.wMTU: " + wMTU + "\n" + "NET_DVR_ETHERNET_V30.byMACAddr: " + new String(byMACAddr) + "\n"; + } + + + } + + public static class NET_DVR_ETHERNET extends Structure {//网络数据结构(子结构) + public byte[] sDVRIP = new byte[16]; //DVR IP地址 + public byte[] sDVRIPMask = new byte[16]; //DVR IP地址掩码 + public int dwNetInterface; //网络接口 1-10MBase-T 2-10MBase-T全双工 3-100MBase-TX 4-100M全双工 5-10M/100M自适应 + public short wDVRPort; //端口号 + public byte[] byMACAddr = new byte[MACADDR_LEN]; //服务器的物理地址 + + + } + + public static class NET_DVR_PPPOECFG extends Structure {//PPPoe + public int dwPPPoE; + public byte[] sPPPoEUser = new byte[32]; + public byte[] sPPPoEPassword = new byte[16]; + public NET_DVR_IPADDR struPPPoEIP; + + + } + + public static class NET_DVR_NETCFG_V30 extends Structure { + public int dwSize; + public NET_DVR_ETHERNET_V30[] struEtherNet = new NET_DVR_ETHERNET_V30[2]; + public NET_DVR_IPADDR[] struRes1 = new NET_DVR_IPADDR[2]; + public NET_DVR_IPADDR struAlarmHostIpAddr; + public short[] wRes2 = new short[2]; + public short wAlarmHostIpPort; + public byte byUseDhcp; + public byte byRes3; + public NET_DVR_IPADDR struDnsServer1IpAddr; + public NET_DVR_IPADDR struDnsServer2IpAddr; + public byte[] byIpResolver = new byte[64]; + public short wIpResolverPort; + public short wHttpPortNo; + public NET_DVR_IPADDR struMulticastIpAddr; + public NET_DVR_IPADDR struGatewayIpAddr; + public NET_DVR_PPPOECFG struPPPoE; + public byte[] byRes = new byte[64]; + + public String toString() { + return "NET_DVR_NETCFG_V30.dwSize: " + dwSize + "\n" + "NET_DVR_NETCFG_V30.struEtherNet[0]: \n" + struEtherNet[0] + "\n" + "NET_DVR_NETCFG_V30.struAlarmHostIpAddr: \n" + struAlarmHostIpAddr + "\n" + "NET_DVR_NETCFG_V30.wAlarmHostIpPort: " + wAlarmHostIpPort + "\n" + "NET_DVR_NETCFG_V30.wHttpPortNo: " + wHttpPortNo + "\n" + "NET_DVR_NETCFG_V30.struGatewayIpAddr: \n" + struGatewayIpAddr + "\n"; + } + + + } + + + public static class NET_DVR_NETCFG extends Structure {//网络配置结构 + public int dwSize; + public NET_DVR_ETHERNET[] struEtherNet = new NET_DVR_ETHERNET[MAX_ETHERNET]; /* 以太网口 */ + public byte[] sManageHostIP = new byte[16]; //远程管理主机地址 + public short wManageHostPort; //远程管理主机端口号 + public byte[] sIPServerIP = new byte[16]; //IPServer服务器地址 + public byte[] sMultiCastIP = new byte[16]; //多播组地址 + public byte[] sGatewayIP = new byte[16]; //网关地址 + public byte[] sNFSIP = new byte[16]; //NFS主机IP地址 + public byte[] sNFSDirectory = new byte[PATHNAME_LEN];//NFS目录 + public int dwPPPOE; //0-不启用,1-启用 + public byte[] sPPPoEUser = new byte[NAME_LEN]; //PPPoE用户名 + public byte[] sPPPoEPassword = new byte[PASSWD_LEN];// PPPoE密码 + public byte[] sPPPoEIP = new byte[16]; //PPPoE IP地址(只读) + + + } + + //通道图象结构 + public static class NET_DVR_SCHEDTIMEWEEK extends Structure { + public NET_DVR_SCHEDTIME[] struAlarmTime = new NET_DVR_SCHEDTIME[8]; + + + } + + public static class byte96 extends Structure { + public byte[] byMotionScope = new byte[96]; + + + } + + public static class NET_DVR_MOTION_V30 extends Structure {//移动侦测(子结构)(9000扩展) + public byte96[] byMotionScope = new byte96[64]; /*侦测区域,0-96位,表示64行,共有96*64个小宏块,为1表示是移动侦测区域,0-表示不是*/ + public byte byMotionSensitive; /*移动侦测灵敏度, 0 - 5,越高越灵敏,oxff关闭*/ + public byte byEnableHandleMotion; /* 是否处理移动侦测 0-否 1-是*/ + public byte byPrecision; /* 移动侦测算法的进度: 0--16*16, 1--32*32, 2--64*64 ... */ + public byte reservedData; + public NET_DVR_HANDLEEXCEPTION_V30 struMotionHandleType; /* 处理方式 */ + public NET_DVR_SCHEDTIMEWEEK[] struAlarmTime = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS]; /*布防时间*/ + public byte[] byRelRecordChan = new byte[64]; /* 报警触发的录象通道*/ + + + } + + public static class NET_DVR_MOTION extends Structure {//移动侦测(子结构) + public byte[] byMotionScope = new byte[18 * 22]; /*侦测区域,共有22*18个小宏块,为1表示改宏块是移动侦测区域,0-表示不是*/ + public byte byMotionSensitive; /*移动侦测灵敏度, 0 - 5,越高越灵敏,0xff关闭*/ + public byte byEnableHandleMotion; /* 是否处理移动侦测 */ + public byte[] reservedData = new byte[2]; + public NET_DVR_HANDLEEXCEPTION strMotionHandleType; /* 处理方式 */ + public byte[] byRelRecordChan = new byte[MAX_CHANNUM]; //报警触发的录象通道,为1表示触发该通道 + + + } + + public static class NET_DVR_HIDEALARM_V30 extends Structure {//遮挡报警 + public int dwEnableHideAlarm; /* 是否启动遮挡报警 ,0-否,1-低灵敏度 2-中灵敏度 3-高灵敏度*/ + public short wHideAlarmAreaTopLeftX; /* 遮挡区域的x坐标 */ + public short wHideAlarmAreaTopLeftY; /* 遮挡区域的y坐标 */ + public short wHideAlarmAreaWidth; /* 遮挡区域的宽 */ + public short wHideAlarmAreaHeight; /*遮挡区域的高*/ + public NET_DVR_HANDLEEXCEPTION_V30 strHideAlarmHandleType; /* 处理方式 */ + public NET_DVR_SCHEDTIMEWEEK[] struAlarmTime = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS];//布防时间 + + + } + + public static class NET_DVR_HIDEALARM extends Structure {//遮挡报警(子结构) 区域大小704*576 + public int dwEnableHideAlarm; /* 是否启动遮挡报警 ,0-否,1-低灵敏度 2-中灵敏度 3-高灵敏度*/ + public short wHideAlarmAreaTopLeftX; /* 遮挡区域的x坐标 */ + public short wHideAlarmAreaTopLeftY; /* 遮挡区域的y坐标 */ + public short wHideAlarmAreaWidth; /* 遮挡区域的宽 */ + public short wHideAlarmAreaHeight; /*遮挡区域的高*/ + public NET_DVR_HANDLEEXCEPTION strHideAlarmHandleType; /* 处理方式 */ + + + } + + public static class NET_DVR_VILOST_V30 extends Structure { //信号丢失报警(子结构)(9000扩展) + public byte byEnableHandleVILost; /* 是否处理信号丢失报警 */ + public NET_DVR_HANDLEEXCEPTION_V30 strVILostHandleType; /* 处理方式 */ + public NET_DVR_SCHEDTIMEWEEK[] struAlarmTime = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS];//布防时间 + + } + + public static class NET_DVR_VILOST extends Structure { //信号丢失报警(子结构) + public byte byEnableHandleVILost; /* 是否处理信号丢失报警 */ + public NET_DVR_HANDLEEXCEPTION strVILostHandleType; /* 处理方式 */ + + } + + public static class NET_DVR_SHELTER extends Structure { //遮挡区域(子结构) + public short wHideAreaTopLeftX; /* 遮挡区域的x坐标 */ + public short wHideAreaTopLeftY; /* 遮挡区域的y坐标 */ + public short wHideAreaWidth; /* 遮挡区域的宽 */ + public short wHideAreaHeight; /* 遮挡区域的高*/ + + + } + + public static class NET_DVR_COLOR extends Structure { + public byte byBrightness; /*亮度,0-255*/ + public byte byContrast; /*对比度,0-255*/ + public byte bySaturation; /*饱和度,0-255*/ + public byte byHue; /*色调,0-255*/ + + + } + + public static class NET_DVR_VICOLOR extends Structure { + public NET_DVR_COLOR[] struColor = new NET_DVR_COLOR[MAX_TIMESEGMENT_V30];/*图象参数(第一个有效,其他三个保留)*/ + public NET_DVR_SCHEDTIME[] struHandleTime = new NET_DVR_SCHEDTIME[MAX_TIMESEGMENT_V30];/*处理时间段(保留)*/ + + + } + + //信号丢失 + public static class NET_DVR_VILOST_V40 extends Structure { + public int dwEnableVILostAlarm; /* 是否启动信号丢失报警 ,0-否,1-是*/ + /* 信号丢失触发报警输出 */ + public int dwHandleType; //异常处理,异常处理方式的"或"结果 + /*0x00: 无响应*/ + /*0x01: 布防器上警告*/ + /*0x02: 声音警告*/ + /*0x04: 上传中心*/ + /*0x08: 触发报警输出*/ + /*0x10: 触发JPRG抓图并上传Email*/ + /*0x20: 无线声光报警器联动*/ + /*0x40: 联动电子地图(目前只有PCNVR支持)*/ + /*0x200: 抓图并上传FTP*/ + /*0x1000:抓图上传到云*/ + public int dwMaxRelAlarmOutChanNum; //触发的报警输出通道数(只读)最大支持数量 + public int[] dwRelAlarmOut = new int[MAX_ALARMOUT_V40]; /*触发报警输出号,按值表示,采用紧凑型排列,从下标0 - dwRelAlarmOut -1有效,如果中间遇到0xffffffff,则后续无效*/ + public NET_DVR_SCHEDTIMEWEEK[] struAlarmTime = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS]; /*布防时间*/ + public byte byVILostAlarmThreshold; /*信号丢失报警阈值,当值低于阈值,认为信号丢失,取值0-99*/ + public byte[] byRes = new byte[63]; //保留 + + + } + + public static class NET_DVR_DNMODE extends Structure { + public byte byObjectSize;//占比参数(0~100) + public byte byMotionSensitive; /*移动侦测灵敏度, 0 - 5,越高越灵敏,0xff关闭*/ + public byte[] byRes = new byte[6]; + + + } + + public static class NET_DVR_MOTION_MULTI_AREAPARAM extends Structure { + public byte byAreaNo;//区域编号(IPC- 1~8) + public byte[] byRes = new byte[3]; + public NET_VCA_RECT struRect = new NET_VCA_RECT();//单个区域的坐标信息(矩形) size = 16; + public NET_DVR_DNMODE struDayNightDisable = new NET_DVR_DNMODE();//关闭模式 + public NET_DVR_DNMODE struDayModeParam = new NET_DVR_DNMODE();//白天模式 + public NET_DVR_DNMODE struNightModeParam = new NET_DVR_DNMODE();//夜晚模式 + public byte[] byRes1 = new byte[8]; + + + } + + public static final int MAX_MULTI_AREA_NUM = 24; + + public static class NET_DVR_MOTION_MULTI_AREA extends Structure { + public byte byDayNightCtrl;//日夜控制 0~关闭,1~自动切换,2~定时切换(默认关闭) + public byte byAllMotionSensitive; /*移动侦测灵敏度, 0 - 5,越高越灵敏,0xff关闭,全部区域的灵敏度范围*/ + public byte[] byRes = new byte[2];// + public NET_DVR_SCHEDULE_DAYTIME struScheduleTime = new NET_DVR_SCHEDULE_DAYTIME();//切换时间 16 + public NET_DVR_MOTION_MULTI_AREAPARAM[] struMotionMultiAreaParam = new NET_DVR_MOTION_MULTI_AREAPARAM[MAX_MULTI_AREA_NUM];//最大支持24个区域 + public byte[] byRes1 = new byte[60]; + + + } + + public static class NET_DVR_MOTION_SINGLE_AREA extends Structure { + public byte[] byMotionScope = new byte[64 * 96]; /*侦测区域,0-96位,表示64行,共有96*64个小宏块,目前有效的是22*18,为1表示是移动侦测区域,0-表示不是*/ + public byte byMotionSensitive; /*移动侦测灵敏度, 0 - 5,越高越灵敏,0xff关闭*/ + public byte[] byRes = new byte[3]; + + + } + + public static class NET_DVR_MOTION_MODE_PARAM extends Structure { + public NET_DVR_MOTION_SINGLE_AREA struMotionSingleArea = new NET_DVR_MOTION_SINGLE_AREA(); //普通模式下的单区域设 + public NET_DVR_MOTION_MULTI_AREA struMotionMultiArea = new NET_DVR_MOTION_MULTI_AREA(); //专家模式下的多区域设置 + + + } + + public static class NET_DVR_MOTION_V40 extends Structure { + public NET_DVR_MOTION_MODE_PARAM struMotionMode = new NET_DVR_MOTION_MODE_PARAM(); //(5.1.0新增) + public byte byEnableHandleMotion; /* 是否处理移动侦测 0-否 1-是*/ + public byte byEnableDisplay; /*启用移动侦测高亮显示,0-否,1-是*/ + public byte byConfigurationMode; //0~普通,1~专家(5.1.0新增) + public byte byKeyingEnable; //启用键控移动侦测 0-不启用,1-启用 + /* 异常处理方式 */ + public int dwHandleType; //异常处理,异常处理方式的"或"结果 + /*0x00: 无响应*/ + /*0x01: 布防器上警告*/ + /*0x02: 声音警告*/ + /*0x04: 上传中心*/ + /*0x08: 触发报警输出*/ + /*0x10: 触发JPRG抓图并上传Email*/ + /*0x20: 无线声光报警器联动*/ + /*0x40: 联动电子地图(目前只有PCNVR支持)*/ + /*0x200: 抓图并上传FTP*/ + /*0x1000: 抓图上传到云*/ + public int dwMaxRelAlarmOutChanNum; //触发的报警输出通道数(只读)最大支持数量 + public int[] dwRelAlarmOut = new int[MAX_ALARMOUT_V40]; //实际触发的报警输出号,按值表示,采用紧凑型排列,从下标0 - dwRelAlarmOut -1有效,如果中间遇到0xffffffff,则后续无效 + public NET_DVR_SCHEDTIMEWEEK[] struAlarmTime = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS]; /*布防时间*/ + /*触发的录像通道*/ + public int dwMaxRecordChanNum; //设备支持的最大关联录像通道数-只读 + public int[] dwRelRecordChan = new int[MAX_CHANNUM_V40]; /* 实际触发录像通道,按值表示,采用紧凑型排列,从下标0 - dwRelRecordChan -1有效,如果中间遇到0xffffffff,则后续无效*/ + public byte byDiscardFalseAlarm; //启用去误报 0-无效,1-不启用,2-启用 + public byte[] byRes = new byte[127]; //保留字节 + + + } + + public static class NET_DVR_RGB_COLOR extends Structure { + public byte byRed; //RGB颜色三分量中的红色 + public byte byGreen; //RGB颜色三分量中的绿色 + public byte byBlue; //RGB颜色三分量中的蓝色 + public byte byRes; //保留 + + + } + + public static class NET_DVR_HIDEALARM_V40 extends Structure { + public int dwEnableHideAlarm; /* 是否启动遮挡报警,0-否,1-低灵敏度,2-中灵敏度,3-高灵敏度*/ + public short wHideAlarmAreaTopLeftX; /* 遮挡区域的x坐标 */ + public short wHideAlarmAreaTopLeftY; /* 遮挡区域的y坐标 */ + public short wHideAlarmAreaWidth; /* 遮挡区域的宽 */ + public short wHideAlarmAreaHeight; /*遮挡区域的高*/ + /* 信号丢失触发报警输出 */ + public int dwHandleType; //异常处理,异常处理方式的"或"结果 + /*0x00: 无响应*/ + /*0x01: 布防器上警告*/ + /*0x02: 声音警告*/ + /*0x04: 上传中心*/ + /*0x08: 触发报警输出*/ + /*0x10: 触发JPRG抓图并上传Email*/ + /*0x20: 无线声光报警器联动*/ + /*0x40: 联动电子地图(目前只有PCNVR支持)*/ + /*0x200: 抓图并上传FTP*/ + /*0x1000:抓图上传到云*/ + public int dwMaxRelAlarmOutChanNum; //触发的报警输出通道数(只读)最大支持数量 + public int[] dwRelAlarmOut = new int[MAX_ALARMOUT_V40]; /*触发报警输出号,按值表示,采用紧凑型排列,从下标0 - dwRelAlarmOut -1有效,如果中间遇到0xffffffff,则后续无效*/ + public NET_DVR_SCHEDTIMEWEEK[] struAlarmTime = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS]; /*布防时间*/ + public byte[] byRes = new byte[64]; //保留 + + + }//遮挡报警 + + public static class NET_DVR_PICCFG_V40 extends Structure { + public int dwSize; + public byte[] sChanName = new byte[NAME_LEN]; + public int dwVideoFormat; /* 只读 视频制式 1-NTSC 2-PAL */ + public NET_DVR_VICOLOR struViColor = new NET_DVR_VICOLOR();// 图像参数按时间段设置 + //显示通道名 + public int dwShowChanName; // 预览的图象上是否显示通道名称,0-不显示,1-显示 + public short wShowNameTopLeftX; /* 通道名称显示位置的x坐标 */ + public short wShowNameTopLeftY; /* 通道名称显示位置的y坐标 */ + //隐私遮挡 + public int dwEnableHide; /* 是否启动遮挡 ,0-否,1-是*/ + public NET_DVR_SHELTER[] struShelter = new NET_DVR_SHELTER[MAX_SHELTERNUM]; + //OSD + public int dwShowOsd;// 预览的图象上是否显示OSD,0-不显示,1-显示 + public short wOSDTopLeftX; /* OSD的x坐标 */ + public short wOSDTopLeftY; /* OSD的y坐标 */ + public byte byOSDType; /* OSD类型(主要是年月日格式) */ + /* 0: XXXX-XX-XX 年月日 */ + /* 1: XX-XX-XXXX 月日年 */ + /* 2: XXXX年XX月XX日 */ + /* 3: XX月XX日XXXX年 */ + /* 4: XX-XX-XXXX 日月年*/ + /* 5: XX日XX月XXXX年 */ + /*6: xx/xx/xxxx(月/日/年) */ + /*7: xxxx/xx/xx(年/月/日) */ + /*8: xx/xx/xxxx(日/月/年)*/ + public byte byDispWeek; /* 是否显示星期 */ + public byte byOSDAttrib; /* OSD属性:透明,闪烁 */ + /* 0: 不显示OSD */ + /* 1: 透明,闪烁 */ + /* 2: 透明,不闪烁 */ + /* 3: 不透明,闪烁 */ + /* 4: 不透明,不闪烁 */ + public byte byHourOSDType; /* OSD小时制:0-24小时制,1-12小时制 */ + public byte byFontSize; //16*16(中)/8*16(英),1-32*32(中)/16*32(英),2-64*64(中)/32*64(英) 3-48*48(中)/24*48(英) 4-24*24(中)/12*24(英) 5-96*96(中)/48*96(英) 6-128*128(中)/64*128(英) 7-80*80(中)/40*80(英) 8-112*112(中)/56*112(英) 0xff-自适应(adaptive) + public byte byOSDColorType; //0-默认(黑白);1-自定义 + public byte byAlignment;//对齐方式 0-自适应,1-右对齐, 2-左对齐,3-国标模式,4-全部右对齐(包含叠加字符、时间以及标题等所有OSD字符),5-全部左对齐(包含叠加字符、时间以及标题等所有OSD字符) + public byte byOSDMilliSecondEnable;//视频叠加时间支持毫秒;0~不叠加, 1-叠加 + public NET_DVR_VILOST_V40 struVILost = new NET_DVR_VILOST_V40(); //视频信号丢失报警(支持组) + public NET_DVR_VILOST_V40 struAULost = new NET_DVR_VILOST_V40(); /*音频信号丢失报警(支持组)*/ + public NET_DVR_MOTION_V40 struMotion = new NET_DVR_MOTION_V40(); //移动侦测报警(支持组) + public NET_DVR_HIDEALARM_V40 struHideAlarm = new NET_DVR_HIDEALARM_V40(); //遮挡报警(支持组) + public NET_DVR_RGB_COLOR struOsdColor = new NET_DVR_RGB_COLOR();//OSD颜色 + public int dwBoundary; //边界值,左对齐,右对齐以及国标模式的边界值,0-表示默认值,单位:像素;在国标模式下,单位修改为字符个数(范围是,0,1,2) + public NET_DVR_RGB_COLOR struOsdBkColor = new NET_DVR_RGB_COLOR(); //自定义OSD背景色 + public byte byOSDBkColorMode; //OSD背景色模式,0-默认,1-自定义OSD背景色 + public byte byUpDownBoundary; //上下最小边界值选项,单位为字符个数(范围是,0,1,2),国标模式下无效。byAlignment=3该字段无效,通过dwBoundary进行边界配置,.byAlignment不等于3的情况下, byUpDownBoundary/byLeftRightBoundary配置成功后,dwBoundary值将不生效 + public byte byLeftRightBoundary; //左右最小边界值选项,单位为字符个数(范围是,0,1,2), 国标模式下无效。byAlignment=3该字段无效,通过dwBoundary进行边界配置,.byAlignment不等于3的情况下, byUpDownBoundary/byLeftRightBoundary配置成功后,dwBoundary值将不生效 + public byte[] byRes = new byte[113]; + + + } + + public static class NET_DVR_PICCFG_V30 extends Structure { + public int dwSize; + public byte[] sChanName = new byte[NAME_LEN]; + public int dwVideoFormat; /* 只读 视频制式 1-NTSC 2-PAL*/ + public NET_DVR_VICOLOR struViColor; // 图像参数按时间段设置 + public int dwShowChanName; // 预览的图象上是否显示通道名称,0-不显示,1-显示 区域大小704*576 + public short wShowNameTopLeftX; /* 通道名称显示位置的x坐标 */ + public short wShowNameTopLeftY; /* 通道名称显示位置的y坐标 */ + public NET_DVR_VILOST_V30 struVILost; //视频信号丢失报警 + public NET_DVR_VILOST_V30 struAULost; /*音频信号丢失报警(保留)*/ + public NET_DVR_MOTION_V30 struMotion; //移动侦测 + public NET_DVR_HIDEALARM_V30 struHideAlarm;//遮挡报警 + public int dwEnableHide; /* 是否启动遮盖(区域大小704*576) ,0-否,1-是*/ + public NET_DVR_SHELTER[] struShelter = new NET_DVR_SHELTER[4]; + public int dwShowOsd; //预览的图象上是否显示OSD,0-不显示,1-显示 区域大小704*576 + public short wOSDTopLeftX; /* OSD的x坐标 */ + public short wOSDTopLeftY; /* OSD的y坐标 */ + public byte byOSDType; /* OSD类型(主要是年月日格式) */ + public byte byDispWeek; /* 是否显示星期 */ + public byte byOSDAttrib; /* OSD属性:透明,闪烁 */ + public byte byHourOSDType; /* OSD小时制:0-24小时制,1-12小时制 */ + public byte[] byRes = new byte[64]; + + + } + + public static class NET_DVR_PICCFG_EX extends Structure {//通道图象结构SDK_V14扩展 + public int dwSize; + public byte[] sChanName = new byte[NAME_LEN]; + public int dwVideoFormat; /* 只读 视频制式 1-NTSC 2-PAL*/ + public byte byBrightness; /*亮度,0-255*/ + public byte byContrast; /*对比度,0-255*/ + public byte bySaturation; /*饱和度,0-255 */ + public byte byHue; /*色调,0-255*/ + //显示通道名 + public int dwShowChanName; // 预览的图象上是否显示通道名称,0-不显示,1-显示 区域大小704*576 + public short wShowNameTopLeftX; /* 通道名称显示位置的x坐标 */ + public short wShowNameTopLeftY; /* 通道名称显示位置的y坐标 */ + //信号丢失报警 + public NET_DVR_VILOST struVILost; + //移动侦测 + public NET_DVR_MOTION struMotion; + //遮挡报警 + public NET_DVR_HIDEALARM struHideAlarm; + //遮挡 区域大小704*576 + public int dwEnableHide; /* 是否启动遮挡 ,0-否,1-是*/ + public NET_DVR_SHELTER[] struShelter = new NET_DVR_SHELTER[MAX_SHELTERNUM]; + //OSD + public int dwShowOsd;// 预览的图象上是否显示OSD,0-不显示,1-显示 区域大小704*576 + public short wOSDTopLeftX; /* OSD的x坐标 */ + public short wOSDTopLeftY; /* OSD的y坐标 */ + public byte byOSDType; /* OSD类型(主要是年月日格式) */ + /* 0: XXXX-XX-XX 年月日 */ + /* 1: XX-XX-XXXX 月日年 */ + /* 2: XXXX年XX月XX日 */ + /* 3: XX月XX日XXXX年 */ + /* 4: XX-XX-XXXX 日月年*/ + /* 5: XX日XX月XXXX年 */ + public byte byDispWeek; /* 是否显示星期 */ + public byte byOSDAttrib; /* OSD属性:透明,闪烁 */ + /* 0: 不显示OSD */ + /* 1: 透明,闪烁 */ + /* 2: 透明,不闪烁 */ + /* 3: 闪烁,不透明 */ + /* 4: 不透明,不闪烁 */ + public byte byHourOsdType; //小时制:0表示24小时制,1-12小时制或am/pm + + + } + + + public static class NET_DVR_PICCFG extends Structure { //通道图象结构(SDK_V13及之前版本) + public int dwSize; + public byte[] sChanName = new byte[NAME_LEN]; + public int dwVideoFormat; /* 只读 视频制式 1-NTSC 2-PAL*/ + public byte byBrightness; /*亮度,0-255*/ + public byte byContrast; /*对比度,0-255*/ + public byte bySaturation; /*饱和度,0-255 */ + public byte byHue; /*色调,0-255*/ + //显示通道名 + public int dwShowChanName; // 预览的图象上是否显示通道名称,0-不显示,1-显示 区域大小704*576 + public short wShowNameTopLeftX; /* 通道名称显示位置的x坐标 */ + public short wShowNameTopLeftY; /* 通道名称显示位置的y坐标 */ + //信号丢失报警 + public NET_DVR_VILOST struVILost; + //移动侦测 + public NET_DVR_MOTION struMotion; + //遮挡报警 + public NET_DVR_HIDEALARM struHideAlarm; + //遮挡 区域大小704*576 + public int dwEnableHide; /* 是否启动遮挡 ,0-否,1-是*/ + public short wHideAreaTopLeftX; /* 遮挡区域的x坐标 */ + public short wHideAreaTopLeftY; /* 遮挡区域的y坐标 */ + public short wHideAreaWidth; /* 遮挡区域的宽 */ + public short wHideAreaHeight; /*遮挡区域的高*/ + //OSD + public int dwShowOsd;// 预览的图象上是否显示OSD,0-不显示,1-显示 区域大小704*576 + public short wOSDTopLeftX; /* OSD的x坐标 */ + public short wOSDTopLeftY; /* OSD的y坐标 */ + public byte byOSDType; /* OSD类型(主要是年月日格式) */ + /* 0: XXXX-XX-XX 年月日 */ + /* 1: XX-XX-XXXX 月日年 */ + /* 2: XXXX年XX月XX日 */ + /* 3: XX月XX日XXXX年 */ + /* 4: XX-XX-XXXX 日月年*/ + /* 5: XX日XX月XXXX年 */ + byte byDispWeek; /* 是否显示星期 */ + byte byOSDAttrib; /* OSD属性:透明,闪烁 */ + /* 0: 不显示OSD */ + /* 1: 透明,闪烁 */ + /* 2: 透明,不闪烁 */ + /* 3: 闪烁,不透明 */ + /* 4: 不透明,不闪烁 */ + public byte reservedData2; + + + } + + public static class NET_DVR_MULTI_STREAM_COMPRESSIONCFG_COND extends Structure { + public int dwSize; + public NET_DVR_STREAM_INFO struStreamInfo = new NET_DVR_STREAM_INFO(); + public int dwStreamType; + public byte[] byRes = new byte[32]; + } + + public static class NET_DVR_MULTI_STREAM_COMPRESSIONCFG extends Structure { + public int dwSize; + public int dwStreamType; + public NET_DVR_COMPRESSION_INFO_V30 struStreamPara = new NET_DVR_COMPRESSION_INFO_V30(); + public byte[] byRes = new byte[80]; + } + + //码流压缩参数(子结构)(9000扩展) + public static class NET_DVR_COMPRESSION_INFO_V30 extends Structure { + public byte byStreamType; //码流类型 0-视频流, 1-复合流 + public byte byResolution; //分辨率0-DCIF 1-CIF, 2-QCIF, 3-4CIF, 4-2CIF 5(保留)16-VGA(640*480) 17-UXGA(1600*1200) 18-SVGA (800*600)19-HD720p(1280*720)20-XVGA 21-HD900p + public byte byBitrateType; //码率类型 0:定码率,1:变码率 + public byte byPicQuality; //图象质量 0-最好 1-次好 2-较好 3-一般 4-较差 5-差 + public int dwVideoBitrate; //视频码率 0-保留 1-16K 2-32K 3-48k 4-64K 5-80K 6-96K 7-128K 8-160k 9-192K 10-224K 11-256K 12-320K 13-384K 14-448K 15-512K 16-640K 17-768K 18-896K 19-1024K 20-1280K 21-1536K 22-1792K 23-2048最高位(31位)置成1表示是自定义码流, 0-30位表示码流值。 + public int dwVideoFrameRate; //帧率 0-全部; 1-1/16; 2-1/8; 3-1/4; 4-1/2; 5-1; 6-2; 7-4; 8-6; 9-8; 10-10; 11-12; 12-16; 13-20; V2.0版本中新加14-15; 15-18; 16-22; + public short wIntervalFrameI; //I帧间隔 + public byte byIntervalBPFrame;//0-BBP帧; 1-BP帧; 2-单P帧 + public byte byENumber; //E帧数量(保留) + public byte byVideoEncType;//视频编码类型 0 hik264;1标准h264; 2标准mpeg4; + public byte byAudioEncType;//音频编码类型 0 G722 + public byte[] byres = new byte[10]; + + + } + + //通道压缩参数(9000扩展) + public static class NET_DVR_COMPRESSIONCFG_V30 extends Structure { + public int dwSize; + public NET_DVR_COMPRESSION_INFO_V30 struNormHighRecordPara; //录像 对应8000的普通 + public NET_DVR_COMPRESSION_INFO_V30 struRes; //保留 String[28]; + public NET_DVR_COMPRESSION_INFO_V30 struEventRecordPara; //事件触发压缩参数 + public NET_DVR_COMPRESSION_INFO_V30 struNetPara; //网传(子码流) + + + } + + + public static class NET_DVR_COMPRESSION_INFO extends Structure {//码流压缩参数(子结构) + public byte byStreamType; //码流类型0-视频流,1-复合流,表示压缩参数时最高位表示是否启用压缩参数 + public byte byResolution; //分辨率0-DCIF 1-CIF, 2-QCIF, 3-4CIF, 4-2CIF, 5-2QCIF(352X144)(车载专用) + public byte byBitrateType; //码率类型0:变码率,1:定码率 + public byte byPicQuality; //图象质量 0-最好 1-次好 2-较好 3-一般 4-较差 5-差 + public int dwVideoBitrate; //视频码率 0-保留 1-16K(保留) 2-32K 3-48k 4-64K 5-80K 6-96K 7-128K 8-160k 9-192K 10-224K 11-256K 12-320K + // 13-384K 14-448K 15-512K 16-640K 17-768K 18-896K 19-1024K 20-1280K 21-1536K 22-1792K 23-2048K + //最高位(31位)置成1表示是自定义码流, 0-30位表示码流值(MIN-32K MAX-8192K)。 + public int dwVideoFrameRate; //帧率 0-全部; 1-1/16; 2-1/8; 3-1/4; 4-1/2; 5-1; 6-2; 7-4; 8-6; 9-8; 10-10; 11-12; 12-16; 13-20; + + + } + + public static class NET_DVR_COMPRESSIONCFG extends Structure {//通道压缩参数 + public int dwSize; + public NET_DVR_COMPRESSION_INFO struRecordPara; //录像/事件触发录像 + public NET_DVR_COMPRESSION_INFO struNetPara; //网传/保留 + + + } + + + public static class NET_DVR_COMPRESSION_INFO_EX extends Structure {//码流压缩参数(子结构)(扩展) 增加I帧间隔 + public byte byStreamType; //码流类型0-视频流, 1-复合流 + public byte byResolution; //分辨率0-DCIF 1-CIF, 2-QCIF, 3-4CIF, 4-2CIF, 5-2QCIF(352X144)(车载专用) + public byte byBitrateType; //码率类型0:变码率,1:定码率 + public byte byPicQuality; //图象质量 0-最好 1-次好 2-较好 3-一般 4-较差 5-差 + public int dwVideoBitrate; //视频码率 0-保留 1-16K(保留) 2-32K 3-48k 4-64K 5-80K 6-96K 7-128K 8-160k 9-192K 10-224K 11-256K 12-320K + // 13-384K 14-448K 15-512K 16-640K 17-768K 18-896K 19-1024K 20-1280K 21-1536K 22-1792K 23-2048K + //最高位(31位)置成1表示是自定义码流, 0-30位表示码流值(MIN-32K MAX-8192K)。 + public int dwVideoFrameRate; //帧率 0-全部; 1-1/16; 2-1/8; 3-1/4; 4-1/2; 5-1; 6-2; 7-4; 8-6; 9-8; 10-10; 11-12; 12-16; 13-20, //V2.0增加14-15, 15-18, 16-22; + public short wIntervalFrameI; //I帧间隔 + //2006-08-11 增加单P帧的配置接口,可以改善实时流延时问题 + public byte byIntervalBPFrame;//0-BBP帧; 1-BP帧; 2-单P帧 + public byte byENumber;//E帧数量 + + + } + + public static class NET_DVR_RECORDSCHED extends Structure //时间段录像参数配置(子结构) + { + public NET_DVR_SCHEDTIME struRecordTime = new NET_DVR_SCHEDTIME(); + public byte byRecordType; //0:定时录像,1:移动侦测,2:报警录像,3:动测|报警,4:动测&报警, 5:命令触发, 6: 智能录像 + public byte[] reservedData = new byte[3]; + + + } + + public static class NET_DVR_RECORDDAY extends Structure //全天录像参数配置(子结构) + { + public short wAllDayRecord; /* 是否全天录像 0-否 1-是*/ + public byte byRecordType; /* 录象类型 0:定时录像,1:移动侦测,2:报警录像,3:动测|报警,4:动测&报警 5:命令触发, 6: 智能录像*/ + public byte reservedData; + + + } + + public static class NET_DVR_RECORDSCHEDWEEK extends Structure { + public NET_DVR_RECORDSCHED[] struRecordSched = new NET_DVR_RECORDSCHED[MAX_TIMESEGMENT_V30]; + + + } + + public static class NET_DVR_RECORD_V30 extends Structure { //通道录像参数配置(9000扩展) + public int dwSize; + public int dwRecord; /*是否录像 0-否 1-是*/ + public NET_DVR_RECORDDAY[] struRecAllDay = new NET_DVR_RECORDDAY[MAX_DAYS]; + public NET_DVR_RECORDSCHEDWEEK[] struRecordSched = new NET_DVR_RECORDSCHEDWEEK[MAX_DAYS]; + public int dwRecordTime; /* 录象延时长度 0-5秒, 1-20秒, 2-30秒, 3-1分钟, 4-2分钟, 5-5分钟, 6-10分钟*/ + public int dwPreRecordTime; /* 预录时间 0-不预录 1-5秒 2-10秒 3-15秒 4-20秒 5-25秒 6-30秒 7-0xffffffff(尽可能预录) */ + public int dwRecorderDuration; /* 录像保存的最长时间 */ + public byte byRedundancyRec; /*是否冗余录像,重要数据双备份:0/1*/ + public byte byAudioRec; /*录像时复合流编码时是否记录音频数据:国外有此法规*/ + public byte[] byReserve = new byte[10]; + + + } + + public static class NET_DVR_RECORD extends Structure { //通道录像参数配置 + public int dwSize; + public int dwRecord; /*是否录像 0-否 1-是*/ + public NET_DVR_RECORDDAY[] struRecAllDay = new NET_DVR_RECORDDAY[MAX_DAYS]; + public NET_DVR_RECORDSCHEDWEEK[] struRecordSched = new NET_DVR_RECORDSCHEDWEEK[MAX_DAYS]; + public int dwRecordTime; /* 录象时间长度 0-5秒, 1-20秒, 2-30秒, 3-1分钟, 4-2分钟, 5-5分钟, 6-10分钟*/ + public int dwPreRecordTime; /* 预录时间 0-不预录 1-5秒 2-10秒 3-15秒 4-20秒 5-25秒 6-30秒 7-0xffffffff(尽可能预录) */ + + + } + + public static class NET_DVR_STATFRAME extends Structure { //单帧统计参数 + public int dwRelativeTime; + public int dwAbsTime; /*统计绝对时标*/ + public byte[] byRes = new byte[92]; + + + } + + public static class NET_DVR_STATTIME extends Structure { //单帧统计参数 + public NET_DVR_TIME tmStart; //统计开始时间 + public NET_DVR_TIME tmEnd; //统计结束时间 + public byte[] byRes = new byte[92]; + + + } + + public static class UNION_PDC_STATPARAM extends Union { + // public byte[] byLen = new byte[140]; + public NET_DVR_STATFRAME struStatFrame; + public NET_DVR_STATTIME struStatTime; + + + } + + public static class NET_DVR_PDC_ALRAM_INFO extends Structure { //通道录像参数配置 + public int dwSize; + public byte byMode; /*0-单帧统计结果,1-最小时间段统计结果*/ + public byte byChannel; + public byte bySmart; //专业智能返回0,Smart 返回 1 + public byte byRes1; // 保留字节 + public NET_VCA_DEV_INFO struDevInfo = new NET_VCA_DEV_INFO(); //前端设备信息 + public UNION_PDC_STATPARAM uStatModeParam = new UNION_PDC_STATPARAM(); + public int dwLeaveNum; /* 离开人数 */ + public int dwEnterNum; /* 进入人数 */ + public byte byBrokenNetHttp; //断网续传标志位,0-不是重传数据,1-重传数据 + public byte byRes3; + public short wDevInfoIvmsChannelEx; //与NET_VCA_DEV_INFO里的byIvmsChannel含义相同,能表示更大的值。老客户端用byIvmsChannel能继续兼容,但是最大到255。新客户端版本请使用wDevInfoIvmsChannelEx + public int dwPassingNum; // 经过人数(进入区域后徘徊没有触发进入、离开的人数) + public int dwChildLeaveNum; // 小孩离开人数 + public int dwChildEnterNum; // 小孩进入人数 + public int dwDuplicatePeople; // 重复人数 + public int dwXmlLen;//XML透传数据长度, 即EventNotificationAlert XML Block的数据长度 + public Pointer pXmlBuf; // XML报警信息指针,其XML对应到EventNotificationAlert XML Block + public byte[] byRes2 = new byte[8]; + public void read() { + super.read(); + switch (byMode) { + case 0: + uStatModeParam.setType(NET_DVR_STATFRAME.class); + break; + case 1: + uStatModeParam.setType(NET_DVR_STATTIME.class); + break; + default: + break; + } + uStatModeParam.read(); + } + + public void write() { + super.write(); + uStatModeParam.write(); + } + + + } + + //云台协议表结构配置 + public static class NET_DVR_PTZ_PROTOCOL extends Structure { + public int dwType; /*解码器类型值,从1开始连续递增*/ + public byte[] byDescribe = new byte[DESC_LEN]; /*解码器的描述符,和8000中的一致*/ + + + } + + public static class NET_DVR_PTZCFG extends Structure { + public int dwSize; + public NET_DVR_PTZ_PROTOCOL[] struPtz = new NET_DVR_PTZ_PROTOCOL[PTZ_PROTOCOL_NUM];/*最大200中PTZ协议*/ + public int dwPtzNum; /*有效的ptz协议数目,从0开始(即计算时加1)*/ + public byte[] byRes = new byte[8]; + + + } + + /*************************** + * 云台类型(end) + ******************************/ + public static class NET_DVR_DECODERCFG_V30 extends Structure {//通道解码器(云台)参数配置(9000扩展) + public int dwSize; + public int dwBaudRate; //波特率(bps),0-50,1-75,2-110,3-150,4-300,5-600,6-1200,7-2400,8-4800,9-9600,10-19200, 11-38400,12-57600,13-76800,14-115.2k; + public byte byDataBit; // 数据有几位 0-5位,1-6位,2-7位,3-8位; + public byte byStopBit; // 停止位 0-1位,1-2位; + public byte byParity; // 校验 0-无校验,1-奇校验,2-偶校验; + public byte byFlowcontrol; // 0-无,1-软流控,2-硬流控 + public short wDecoderType; //解码器类型, 0-YouLi,1-LiLin-1016,2-LiLin-820,3-Pelco-p,4-DM DynaColor,5-HD600,6-JC-4116,7-Pelco-d WX,8-Pelco-d PICO + public short wDecoderAddress; /*解码器地址:0 - 255*/ + public byte[] bySetPreset = new byte[MAX_PRESET_V30]; /* 预置点是否设置,0-没有设置,1-设置*/ + public byte[] bySetCruise = new byte[MAX_CRUISE_V30]; /* 巡航是否设置: 0-没有设置,1-设置 */ + public byte[] bySetTrack = new byte[MAX_TRACK_V30]; /* 是否设置,0-没有设置,1-设置*/ + + + } + + public static class NET_DVR_DECODERCFG extends Structure {//通道解码器(云台)参数配置 + public int dwSize; + public int dwBaudRate; //波特率(bps),0-50,1-75,2-110,3-150,4-300,5-600,6-1200,7-2400,8-4800,9-9600,10-19200, 11-38400,12-57600,13-76800,14-115.2k; + public byte byDataBit; // 数据有几位 0-5位,1-6位,2-7位,3-8位; + public byte byStopBit; // 停止位 0-1位,1-2位; + public byte byParity; // 校验 0-无校验,1-奇校验,2-偶校验; + public byte byFlowcontrol; // 0-无,1-软流控,2-硬流控 + public short wDecoderType; //解码器类型, 0-YouLi,1-LiLin-1016,2-LiLin-820,3-Pelco-p,4-DM DynaColor,5-HD600,6-JC-4116,7-Pelco-d WX,8-Pelco-d PICO + public short wDecoderAddress; /*解码器地址:0 - 255*/ + public byte[] bySetPreset = new byte[MAX_PRESET]; /* 预置点是否设置,0-没有设置,1-设置*/ + public byte[] bySetCruise = new byte[MAX_CRUISE]; /* 巡航是否设置: 0-没有设置,1-设置 */ + public byte[] bySetTrack = new byte[MAX_TRACK]; /* 是否设置,0-没有设置,1-设置*/ + + + } + + public static class NET_DVR_PPPCFG_V30 extends Structure {//ppp参数配置(子结构) + public NET_DVR_IPADDR struRemoteIP; //远端IP地址 + public NET_DVR_IPADDR struLocalIP; //本地IP地址 + public byte[] sLocalIPMask = new byte[16]; //本地IP地址掩码 + public byte[] sUsername = new byte[NAME_LEN]; /* 用户名 */ + public byte[] sPassword = new byte[PASSWD_LEN]; /* 密码 */ + public byte byPPPMode; //PPP模式, 0-主动,1-被动 + public byte byRedial; //是否回拨 :0-否,1-是 + public byte byRedialMode; //回拨模式,0-由拨入者指定,1-预置回拨号码 + public byte byDataEncrypt; //数据加密,0-否,1-是 + public int dwMTU; //MTU + public byte[] sTelephoneNumber = new byte[PHONENUMBER_LEN]; //电话号码 + + + } + + public static class NET_DVR_PPPCFG extends Structure {//ppp参数配置(子结构) + public byte[] sRemoteIP = new byte[16]; //远端IP地址 + public byte[] sLocalIP = new byte[16]; //本地IP地址 + public byte[] sLocalIPMask = new byte[16]; //本地IP地址掩码 + public byte[] sUsername = new byte[NAME_LEN]; /* 用户名 */ + public byte[] sPassword = new byte[PASSWD_LEN]; /* 密码 */ + public byte byPPPMode; //PPP模式, 0-主动,1-被动 + public byte byRedial; //是否回拨 :0-否,1-是 + public byte byRedialMode; //回拨模式,0-由拨入者指定,1-预置回拨号码 + public byte byDataEncrypt; //数据加密,0-否,1-是 + public int dwMTU; //MTU + public byte[] sTelephoneNumber = new byte[PHONENUMBER_LEN]; //电话号码 + + + } + + + public static class NET_DVR_SINGLE_RS232 extends Structure {//RS232串口参数配置(9000扩展) + public int dwBaudRate; /*波特率(bps),0-50,1-75,2-110,3-150,4-300,5-600,6-1200,7-2400,8-4800,9-9600,10-19200, 11-38400,12-57600,13-76800,14-115.2k;*/ + public byte byDataBit; /* 数据有几位 0-5位,1-6位,2-7位,3-8位 */ + public byte byStopBit; /* 停止位 0-1位,1-2位 */ + public byte byParity; /* 校验 0-无校验,1-奇校验,2-偶校验 */ + public byte byFlowcontrol; /* 0-无,1-软流控,2-硬流控 */ + public int dwWorkMode; /* 工作模式,0-232串口用于PPP拨号,1-232串口用于参数控制,2-透明通道 */ + + + } + + public static class NET_DVR_RS232CFG_V30 extends Structure {//RS232串口参数配置(9000扩展) + public int dwSize; + public NET_DVR_SINGLE_RS232 struRs232;/*目前只有第一个串口设置有效,所有设备都只支持一个串口,其他七个保留*/ + public byte[] byRes = new byte[84]; + public NET_DVR_PPPCFG_V30 struPPPConfig;/*ppp参数*/ + + + } + + public static class NET_DVR_RS232CFG extends Structure {//RS232串口参数配置 + public int dwSize; + public int dwBaudRate;//波特率(bps),0-50,1-75,2-110,3-150,4-300,5-600,6-1200,7-2400,8-4800,9-9600,10-19200, 11-38400,12-57600,13-76800,14-115.2k; + public byte byDataBit;// 数据有几位 0-5位,1-6位,2-7位,3-8位; + public byte byStopBit;// 停止位 0-1位,1-2位; + public byte byParity;// 校验 0-无校验,1-奇校验,2-偶校验; + public byte byFlowcontrol;// 0-无,1-软流控,2-硬流控 + public int dwWorkMode;// 工作模式,0-窄带传输(232串口用于PPP拨号),1-控制台(232串口用于参数控制),2-透明通道 + public NET_DVR_PPPCFG struPPPConfig; + + + } + + public static class NET_DVR_ALARMINCFG_V30 extends Structure {//报警输入参数配置(9000扩展) + public int dwSize; + public byte[] sAlarmInName = new byte[NAME_LEN]; /* 名称 */ + public byte byAlarmType; //报警器类型,0:常开,1:常闭 + public byte byAlarmInHandle; /* 是否处理 0-不处理 1-处理*/ + public byte[] reservedData = new byte[2]; + public NET_DVR_HANDLEEXCEPTION_V30 struAlarmHandleType; /* 处理方式 */ + public NET_DVR_SCHEDTIMEWEEK[] struAlarmTime = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS];//布防时间 + public byte[] byRelRecordChan = new byte[MAX_CHANNUM_V30]; //报警触发的录象通道,为1表示触发该通道 + public byte[] byEnablePreset = new byte[MAX_CHANNUM_V30]; /* 是否调用预置点 0-否,1-是*/ + public byte[] byPresetNo = new byte[MAX_CHANNUM_V30]; /* 调用的云台预置点序号,一个报警输入可以调用多个通道的云台预置点, 0xff表示不调用预置点。*/ + public byte[] byEnablePresetRevert = new byte[MAX_CHANNUM_V30]; /* 是否恢复到调用预置点前的位置(保留) */ + public short[] wPresetRevertDelay = new short[MAX_CHANNUM_V30]; /* 恢复预置点延时(保留) */ + public byte[] byEnableCruise = new byte[MAX_CHANNUM_V30]; /* 是否调用巡航 0-否,1-是*/ + public byte[] byCruiseNo = new byte[MAX_CHANNUM_V30]; /* 巡航 */ + public byte[] byEnablePtzTrack = new byte[MAX_CHANNUM_V30]; /* 是否调用 0-否,1-是*/ + public byte[] byPTZTrack = new byte[MAX_CHANNUM_V30]; /* 调用的云台的序号 */ + public byte[] byRes = new byte[16]; + + + } + + public static class NET_DVR_ALARMINCFG extends Structure {//报警输入参数配置 + public int dwSize; + public byte[] sAlarmInName = new byte[NAME_LEN]; /* 名称 */ + public byte byAlarmType; //报警器类型,0:常开,1:常闭 + public byte byAlarmInHandle; /* 是否处理 0-不处理 1-处理*/ + public NET_DVR_HANDLEEXCEPTION struAlarmHandleType; /* 处理方式 */ + public NET_DVR_SCHEDTIMEWEEK[] struAlarmTime = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS];//布防时间 + public byte[] byRelRecordChan = new byte[MAX_CHANNUM]; //报警触发的录象通道,为1表示触发该通道 + public byte[] byEnablePreset = new byte[MAX_CHANNUM]; /* 是否调用预置点 0-否,1-是*/ + public byte[] byPresetNo = new byte[MAX_CHANNUM]; /* 调用的云台预置点序号,一个报警输入可以调用多个通道的云台预置点, 0xff表示不调用预置点。*/ + public byte[] byEnableCruise = new byte[MAX_CHANNUM]; /* 是否调用巡航 0-否,1-是*/ + public byte[] byCruiseNo = new byte[MAX_CHANNUM]; /* 巡航 */ + public byte[] byEnablePtzTrack = new byte[MAX_CHANNUM]; /* 是否调用 0-否,1-是*/ + public byte[] byPTZTrack = new byte[MAX_CHANNUM]; /* 调用的云台的序号 */ + + + } + + public static class NET_DVR_ADDIT_POSITION extends Structure {//车载GPS信息结构(2007-12-27) + public byte[] sDevName = new byte[32]; /* 设备名称 */ + public int dwSpeed; /*速度*/ + public int dwLongitude; /* 经度*/ + public int dwLatitude; /* 纬度*/ + public byte[] direction = new byte[2]; /* direction[0]:'E'or'W'(东经/西经), direction[1]:'N'or'S'(北纬/南纬) */ + public byte[] res = new byte[2]; /* 保留位 */ + + + } + + public static class struRecordingHost extends Structure { + public byte bySubAlarmType; + public byte[] byRes1 = new byte[3]; + public NET_DVR_TIME_EX struRecordEndTime = new NET_DVR_TIME_EX(); + } + + public static class struAlarmHardDisk extends Structure { + public int dwAlarmHardDiskNum; + + + } + + public static class struAlarmChannel extends Structure { + public int dwAlarmChanNum; + public int dwPicLen;//Jpeg图片长度 + public byte byPicURL; //图片数据采用URL方式 0-二进制图片数据,1-图片数据走URL方式 + public byte byTarget; /*0-不区分识别目标,1-识别目标为人,2-识别目标为车*/ + public byte[] byRes1 = new byte[2]; //保留 + public Pointer pDataBuff; //报警图片或者图片URL + } + + public static class struIOAlarm extends Structure { + public int dwAlarmInputNo; + public int dwTrigerAlarmOutNum; + public int dwTrigerRecordChanNum; + + + } + + public static class NET_DVR_TIME_EX extends Structure { + public short wYear; + public byte byMonth; + public byte byDay; + public byte byHour; + public byte byMinute; + public byte bySecond; + public byte byRes; + } + + public static class uStruAlarm extends Union { + public byte[] byUnionLen = new byte[116]; + public struIOAlarm struioAlarm = new struIOAlarm(); + public struAlarmHardDisk strualarmHardDisk = new struAlarmHardDisk(); + public struAlarmChannel strualarmChannel = new struAlarmChannel(); + public struRecordingHost strurecordingHost = new struRecordingHost(); + + + } + + public static class NET_DVR_ALRAM_FIXED_HEADER extends Structure { + public int dwAlarmType; + public NET_DVR_TIME_EX struAlarmTime = new NET_DVR_TIME_EX(); + public uStruAlarm ustruAlarm = new uStruAlarm(); + public Pointer pRes; + public byte byTimeDiffFlag; /*时差字段是否有效 0-时差无效, 1-时差有效 */ + public byte cTimeDifferenceH; /*与UTC的时差(小时),-12 ... +14, +表示东区,,byTimeDiffFlag为1时有效*/ + public byte cTimeDifferenceM; /*与UTC的时差(分钟),-30, 30, 45, +表示东区,byTimeDiffFlag为1时有效*/ + public byte byRes; //保留 + public short wDevInfoIvmsChannel; //增加后端透传前端时的通道号 + public byte[] byRes2 = new byte[2]; //保留 + } + + public static class NET_DVR_ALARMINFO_V40 extends Structure { + public NET_DVR_ALRAM_FIXED_HEADER struAlarmFixedHeader = new NET_DVR_ALRAM_FIXED_HEADER(); + public Pointer pAlarmData; + + + } + + public static class NET_DVR_ALARMINFO_V30 extends Structure {//上传报警信息(9000扩展) + public int dwAlarmType;/*0-信号量报警,1-硬盘满,2-信号丢失,3-移动侦测,4-硬盘未格式化,5-读写硬盘出错,6-遮挡报警,7-制式不匹配, 8-非法访问, 0xa-GPS定位信息(车载定制)*/ + public int dwAlarmInputNumber;/*报警输入端口*/ + public byte[] byAlarmOutputNumber = new byte[MAX_ALARMOUT_V30];/*触发的输出端口,为1表示对应输出*/ + public byte[] byAlarmRelateChannel = new byte[MAX_CHANNUM_V30];/*触发的录像通道,为1表示对应录像, dwAlarmRelateChannel[0]对应第1个通道*/ + public byte[] byChannel = new byte[MAX_CHANNUM_V30];/*dwAlarmType为2或3,6时,表示哪个通道,dwChannel[0]对应第1个通道*/ + public byte[] byDiskNumber = new byte[MAX_DISKNUM_V30];/*dwAlarmType为1,4,5时,表示哪个硬盘, dwDiskNumber[0]对应第1个硬盘*/ + + + } + + public static class NET_DVR_ALARMINFO extends Structure { + public int dwAlarmType;/*0-信号量报警,1-硬盘满,2-信号丢失,3-移动侦测,4-硬盘未格式化,5-读写硬盘出错,6-遮挡报警,7-制式不匹配, 8-非法访问, 9-串口状态, 0xa-GPS定位信息(车载定制)*/ + public int dwAlarmInputNumber;/*报警输入端口, 当报警类型为9时该变量表示串口状态0表示正常, -1表示错误*/ + public int[] dwAlarmOutputNumber = new int[MAX_ALARMOUT];/*触发的输出端口,为1表示对应哪一个输出*/ + public int[] dwAlarmRelateChannel = new int[MAX_CHANNUM];/*触发的录像通道,dwAlarmRelateChannel[0]为1表示第1个通道录像*/ + public int[] dwChannel = new int[MAX_CHANNUM];/*dwAlarmType为2或3,6时,表示哪个通道,dwChannel[0]位对应第1个通道*/ + public int[] dwDiskNumber = new int[MAX_DISKNUM];/*dwAlarmType为1,4,5时,表示哪个硬盘, dwDiskNumber[0]位对应第1个硬盘*/ + + + } + + public static class NET_DVR_ALARMINFO_EX extends Structure {//上传报警信息(杭州竞天定制 2006-07-28) + public int dwAlarmType;/*0-信号量报警,1-硬盘满,2-信号丢失,3-移动侦测,4-硬盘未格式化,5-读写硬盘出错,6-遮挡报警,7-制式不匹配, 8-非法访问*/ + public int dwAlarmInputNumber;/*报警输入端口*/ + public int[] dwAlarmOutputNumber = new int[MAX_ALARMOUT];/*报警输入端口对应的输出端口,哪一位为1表示对应哪一个输出*/ + public int[] dwAlarmRelateChannel = new int[MAX_CHANNUM];/*报警输入端口对应的录像通道,哪一位为1表示对应哪一路录像,dwAlarmRelateChannel[0]对应第1个通道*/ + public int[] dwChannel = new int[MAX_CHANNUM];/*dwAlarmType为2或3,6时,表示哪个通道,dwChannel[0]位对应第0个通道*/ + public int[] dwDiskNumber = new int[MAX_DISKNUM];/*dwAlarmType为1,4,5时,表示哪个硬盘*/ + public byte[] sSerialNumber = new byte[SERIALNO_LEN]; //序列号 + public byte[] sRemoteAlarmIP = new byte[16]; //远程报警IP地址; + + + } + + ////////////////////////////////////////////////////////////////////////////////////// +//IPC接入参数配置 + public static class NET_DVR_IPDEVINFO extends Structure {/* IP设备结构 */ + public int dwEnable; /* 该IP设备是否启用 */ + public byte[] sUserName = new byte[NAME_LEN]; /* 用户名 */ + public byte[] sPassword = new byte[PASSWD_LEN]; /* 密码 */ + public NET_DVR_IPADDR struIP = new NET_DVR_IPADDR(); /* IP地址 */ + public short wDVRPort; /* 端口号 */ + public byte[] byres = new byte[34]; /* 保留 */ + + + } + /* IP通道匹配参数 */ + public static class NET_DVR_IPCHANINFO extends Structure {/* IP通道匹配参数 */ + + public byte byEnable; /* 该通道是否在线 */ + public byte byIPID; //IP设备ID低8位,当设备ID为0时表示通道不可用 + public byte byChannel; /* 通道号 */ + public byte byIPIDHigh; // IP设备ID的高8位 + public byte byTransProtocol; //传输协议类型0-TCP/auto(具体有设备决定),1-UDP 2-多播 3-仅TCP 4-auto + public byte byGetStream; /* 是否对该通道取流,0-是,1-否*/ + public byte[] byres=new byte[30]; /* 保留 */ + + + } + + public static class NET_DVR_IPPARACFG extends Structure {/* IP接入配置结构 */ + public int dwSize; /* 结构大小 */ + public NET_DVR_IPDEVINFO[] struIPDevInfo = new NET_DVR_IPDEVINFO[MAX_IP_DEVICE]; /* IP设备 */ + public byte[] byAnalogChanEnable = new byte[MAX_ANALOG_CHANNUM]; /* 模拟通道是否启用,从低到高表示1-32通道,0表示无效 1有效 */ + public NET_DVR_IPCHANINFO[] struIPChanInfo = new NET_DVR_IPCHANINFO[MAX_IP_CHANNEL]; /* IP通道 */ + + + } + + public class NET_DVR_IPDEVINFO_V31 extends Structure { + public byte byEnable;/* 该通道是否启用 */ + public byte byProType;//协议类型(默认为私有协议),0- 私有协议,1- 松下协议,2- 索尼,更多协议通过NET_DVR_GetIPCProtoList获取。 + public byte byEnableQuickAdd;//0-不支持快速添加;1-使用快速添加 + public byte byRes1;//保留,置为0 + public byte[] sUserName = new byte[HCNetSDK.NAME_LEN];//用户名 + public byte[] sPassword = new byte[HCNetSDK.PASSWD_LEN];//密码 + public byte[] byDomain = new byte[HCNetSDK.MAX_DOMAIN_NAME];//设备域名 + public NET_DVR_IPADDR struIP = new NET_DVR_IPADDR();//IP地址 + public short wDVRPort;//端口号 + public byte[] szDeviceID = new byte[32]; + public byte[] byRes2 = new byte[2];//保留,置为0 + + + } + + public class NET_DVR_STREAM_MODE extends Structure { + + public byte byGetStreamType;//取流方式:0- 直接从设备取流;1- 从流媒体取流;2- 通过IPServer获得IP地址后取流; + //3- 通过IPServer找到设备,再通过流媒体取设备的流; 4- 通过流媒体由URL去取流;5- 通过hiDDNS域名连接设备然后从设备取流 + public byte[] byRes = new byte[3];//保留,置为0 + public NET_DVR_GET_STREAM_UNION uGetStream = new NET_DVR_GET_STREAM_UNION();//不同取流方式联合体 + + public void read() { + super.read(); + switch (byGetStreamType) { + case 0: + uGetStream.setType(NET_DVR_IPCHANINFO.class); + break; + case 6: + uGetStream.setType(NET_DVR_IPCHANINFO_V40.class); + break; + default: + break; + } + } + + + } + + public class NET_DVR_IPSERVER_STREAM extends Structure { + public byte byEnable; + public byte[] byRes = new byte[3]; + public NET_DVR_IPADDR struIPServer = new NET_DVR_IPADDR(); + public short wPort; + public short wDvrNameLen; + public byte[] byDVRName = new byte[HCNetSDK.NAME_LEN]; + public short wDVRSerialLen; + public short[] byRes1 = new short[2]; + public byte[] byDVRSerialNumber = new byte[HCNetSDK.SERIALNO_LEN]; + public byte[] byUserName = new byte[HCNetSDK.NAME_LEN]; + public byte[] byPassWord = new byte[HCNetSDK.PASSWD_LEN]; + public byte byChannel; + public byte[] byRes2 = new byte[11]; + + + } + + public class NET_DVR_STREAM_MEDIA_SERVER_CFG extends Structure { + + public byte byValid;//是否启用流媒体服务器取流:0-不启用,非0-启用 + public byte[] byRes1 = new byte[3];//保留,置为0 + public NET_DVR_IPADDR struDevIP = new NET_DVR_IPADDR();//流媒体服务器的IP地址 + public short wDevPort;//流媒体服务器端口 + public byte byTransmitType;//传输协议类型:0-TCP,1-UDP + public byte[] byRes2 = new byte[69]; + + + } + + public class NET_DVR_DEV_CHAN_INFO extends Structure { + public NET_DVR_IPADDR struIP = new NET_DVR_IPADDR();//设备IP地址 + public short wDVRPort;//设备端口号 + public byte byChannel;//通道号,目前设备的模拟通道号是从1开始的,对于9000等设备的IPC接入,数字通道号从33开始 + public byte byTransProtocol;//传输协议类型:0-TCP,1-UDP,2-多播方式,3-RTP + public byte byTransMode;//传输码流模式:0-主码流,1-子码流 + public byte byFactoryType;//前端设备厂家类型, 通过接口NET_DVR_GetIPCProtoList获取 + public byte byDeviceType;//设备类型(视频综合平台使用):1- IPC,2- ENCODER + public byte byDispChan;// 显示通道号(智能配置使用),根据能力集决定使用解码通道还是显示通道 + public byte bySubDispChan;//显示通道子通道号(智能配置时使用) + public byte byResolution;//分辨率:1- CIF,2- 4CIF,3- 720P,4- 1080P,5- 500W,用于多屏控制器,多屏控制器会根据该参数分配解码资源 + public byte[] byRes = new byte[2];//保留,置为0 + public byte[] byDomain = new byte[HCNetSDK.MAX_DOMAIN_NAME];//设备域名 + public byte[] sUserName = new byte[HCNetSDK.NAME_LEN];//设备登陆帐号 + public byte[] sPassword = new byte[HCNetSDK.PASSWD_LEN];//设备密码 + } + + public class NET_DVR_PU_STREAM_CFG extends Structure { + public int dwSize;//结构体大小 + public NET_DVR_STREAM_MEDIA_SERVER_CFG struStreamMediaSvrCfg = new NET_DVR_STREAM_MEDIA_SERVER_CFG(); + public NET_DVR_DEV_CHAN_INFO struDevChanInfo = new NET_DVR_DEV_CHAN_INFO(); + } + + public class NET_DVR_PU_STREAM_CFG_V41 extends Structure { + public int dwSize; + public byte byStreamMode;/*取流模式,0-无效,1-通过IP或域名取流,2-通过URL取流,3-通过动态域名解析向设备取流*/ + public byte byStreamEncrypt; //是否进行码流加密处理,0-不支持,1-支持 + public byte[] byRes1 = new byte[2]; + public NET_DVR_DEC_STREAM_MODE uDecStreamMode;//取流信息 + public int dwDecDelayTime;//解码延时时间,单位:毫秒 + public byte[] sStreamPassword = new byte[STREAM_PASSWD_LEN]; //码流加密密码,需敏感信息加密 + public byte[] byRes2 = new byte[48]; + } + + + public class NET_DVR_DDNS_STREAM_CFG extends Structure { + public byte byEnable; + public byte[] byRes1 = new byte[3]; + public NET_DVR_IPADDR struStreamServer = new NET_DVR_IPADDR(); + public short wStreamServerPort; + public byte byStreamServerTransmitType; + public byte byRes2; + public NET_DVR_IPADDR struIPServer = new NET_DVR_IPADDR(); + public short wIPServerPort; + public byte[] byRes3 = new byte[2]; + public byte[] sDVRName = new byte[HCNetSDK.NAME_LEN]; + public short wDVRNameLen; + public short wDVRSerialLen; + public byte[] sDVRSerialNumber = new byte[HCNetSDK.SERIALNO_LEN]; + public byte[] sUserName = new byte[HCNetSDK.NAME_LEN]; + public byte[] sPassWord = new byte[HCNetSDK.PASSWD_LEN]; + public short wDVRPort; + public byte[] byRes4 = new byte[2]; + public byte byChannel; + public byte byTransProtocol; + public byte byTransMode; + public byte byFactoryType; + + + } + + public class NET_DVR_PU_STREAM_URL extends Structure { + public byte byEnable;//是否启用:0- 禁用,1- 启用 + public byte[] strURL = new byte[240];//取流URL路径 + public byte byTransPortocol;//传输协议类型:0-TCP,1-UDP + public short wIPID;//设备ID号,wIPID = iDevInfoIndex + iGroupNO*64 +1 + public byte byChannel;//设备通道号 + public byte[] byRes = new byte[7];//保留,置为0 + + + } + + public class NET_DVR_HKDDNS_STREAM extends Structure { + public byte byEnable;//是否启用 + public byte[] byRes = new byte[3];//保留 + public byte[] byDDNSDomain = new byte[64];//hiDDNS服务器地址 + public short wPort;//hiDDNS端口,默认:80 + public short wAliasLen;//别名长度 + public byte[] byAlias = new byte[HCNetSDK.NAME_LEN];//别名 + public short wDVRSerialLen;//序列号长度 + public byte[] byRes1 = new byte[2];//保留 + public byte[] byDVRSerialNumber = new byte[HCNetSDK.SERIALNO_LEN];//设备序列号 + public byte[] byUserName = new byte[HCNetSDK.NAME_LEN];//设备登录用户名 + public byte[] byPassWord = new byte[HCNetSDK.PASSWD_LEN];//设备登录密码 + public byte byChannel;//设备通道号 + public byte[] byRes2 = new byte[11];//保留 + + + } + + public class NET_DVR_IPCHANINFO_V40 extends Structure { + + public byte byEnable;//IP通道在线状态,是一个只读的属性; + //0表示HDVR或者NVR设备的数字通道连接对应的IP设备失败,该通道不在线;1表示连接成功,该通道在线 + public byte byRes1;//保留,置为0 + public short wIPID;//IP设备ID + public int dwChannel;//IP设备的通道号,例如设备A(HDVR或者NVR设备)的IP通道01,对应的是设备B(DVS)里的通道04,则byChannel=4,如果前端接的是IPC则byChannel=1。 + public byte byTransProtocol;//传输协议类型:0- TCP,1- UDP,2- 多播,0xff- auto(自动) + public byte byTransMode;//传输码流模式:0- 主码流,1- 子码流 + public byte byFactoryType;//前端设备厂家类型 + public byte[] byRes = new byte[241];//保留,置为0 + + + } + + + public static class NET_DVR_GET_STREAM_UNION extends Union { + public NET_DVR_IPCHANINFO struChanInfo = new NET_DVR_IPCHANINFO(); /*IP通道信息*/ + public NET_DVR_IPCHANINFO_V40 struIPChan = new NET_DVR_IPCHANINFO_V40(); //直接从设备取流(扩展) + public byte[] byUnionLen = new byte[492]; //直接从设备取流(扩展) + + + } + + public static class NET_DVR_IPPARACFG_V40 extends Structure {/* IP接入配置结构V40 */ + public int dwSize; /* 结构大小 */ + public int dwGroupNum;//设备支持的总组数(只读)。 + public int dwAChanNum;//最大模拟通道个数(只读) + public int dwDChanNum;//数字通道个数(只读) + public int dwStartDChan;//起始数字通道(只读) + public byte[] byAnalogChanEnable = new byte[MAX_CHANNUM_V30]; //模拟通道资源是否启用,从低到高表示1-64通道:0-禁用,1-启用。 + public NET_DVR_IPDEVINFO_V31[] struIPDevInfo = new NET_DVR_IPDEVINFO_V31[MAX_IP_DEVICE_V40];//IP设备信息,下标0对应设备IP ID为1 + public NET_DVR_STREAM_MODE[] struStreamMode = new NET_DVR_STREAM_MODE[MAX_CHANNUM_V30];//取流模式 + public byte[] byRes2 = new byte[20];//保留,置为0 + + + } + + public static class NET_DVR_IPALARMOUTINFO extends Structure {/* 报警输出参数 */ + public byte byIPID; /* IP设备ID取值1- MAX_IP_DEVICE */ + public byte byAlarmOut; /* 报警输出号 */ + public byte[] byRes = new byte[18]; /* 保留 */ + + + } + + public static class NET_DVR_IPALARMOUTCFG extends Structure {/* IP报警输出配置结构 */ + public int dwSize; /* 结构大小 */ + public NET_DVR_IPALARMOUTINFO[] struIPAlarmOutInfo = new NET_DVR_IPALARMOUTINFO[MAX_IP_ALARMOUT];/* IP报警输出 */ + + + } + + public static class NET_DVR_IPALARMININFO extends Structure {/* 报警输入参数 */ + public byte byIPID; /* IP设备ID取值1- MAX_IP_DEVICE */ + public byte byAlarmIn; /* 报警输入号 */ + public byte[] byRes = new byte[18]; /* 保留 */ + + + } + + public static class NET_DVR_IPALARMINCFG extends Structure {/* IP报警输入配置结构 */ + public int dwSize; /* 结构大小 */ + public NET_DVR_IPALARMININFO[] struIPAlarmInInfo = new NET_DVR_IPALARMININFO[MAX_IP_ALARMIN];/* IP报警输入 */ + + + } + + public static class NET_DVR_IPALARMINFO extends Structure {//ipc alarm info + public NET_DVR_IPDEVINFO[] struIPDevInfo = new NET_DVR_IPDEVINFO[MAX_IP_DEVICE]; /* IP设备 */ + public byte[] byAnalogChanEnable = new byte[MAX_ANALOG_CHANNUM]; /* 模拟通道是否启用,0-未启用 1-启用 */ + public NET_DVR_IPCHANINFO[] struIPChanInfo = new NET_DVR_IPCHANINFO[MAX_IP_CHANNEL]; /* IP通道 */ + public NET_DVR_IPALARMININFO[] struIPAlarmInInfo = new NET_DVR_IPALARMININFO[MAX_IP_ALARMIN]; /* IP报警输入 */ + public NET_DVR_IPALARMOUTINFO[] struIPAlarmOutInfo = new NET_DVR_IPALARMOUTINFO[MAX_IP_ALARMOUT]; /* IP报警输出 */ + + + } + + public static class NET_DVR_SINGLE_HD extends Structure {//本地硬盘信息配置 + public int dwHDNo; /*硬盘号, 取值0~MAX_DISKNUM_V30-1*/ + public int dwCapacity; /*硬盘容量(不可设置)*/ + public int dwFreeSpace; /*硬盘剩余空间(不可设置)*/ + public int dwHdStatus; /*硬盘状态(不可设置) 0-正常, 1-未格式化, 2-错误, 3-SMART状态, 4-不匹配, 5-休眠*/ + public byte byHDAttr; /*0-默认, 1-冗余; 2-只读*/ + public byte[] byRes1 = new byte[3]; + public int dwHdGroup; /*属于哪个盘组 1-MAX_HD_GROUP*/ + public byte[] byRes2 = new byte[120]; + } + + public static class NET_DVR_HDCFG extends Structure { + public int dwSize; + public int dwHDCount; /*硬盘数(不可设置)*/ + public NET_DVR_SINGLE_HD[] struHDInfo = new NET_DVR_SINGLE_HD[MAX_DISKNUM_V30];//硬盘相关操作都需要重启才能生效; + } + + public static class NET_DVR_SINGLE_HDGROUP extends Structure {//本地盘组信息配置 + public int dwHDGroupNo; /*盘组号(不可设置) 1-MAX_HD_GROUP*/ + public byte[] byHDGroupChans = new byte[64]; /*盘组对应的录像通道, 0-表示该通道不录象到该盘组,1-表示录象到该盘组*/ + public byte[] byRes = new byte[8]; + } + + public static class NET_DVR_HDGROUP_CFG extends Structure { + public int dwSize; + public int dwHDGroupCount; /*盘组总数(不可设置)*/ + public NET_DVR_SINGLE_HDGROUP[] struHDGroupAttr = new NET_DVR_SINGLE_HDGROUP[MAX_HD_GROUP];//硬盘相关操作都需要重启才能生效; + } + + public static class NET_DVR_SCALECFG extends Structure {//配置缩放参数的结构 + public int dwSize; + public int dwMajorScale; /* 主显示 0-不缩放,1-缩放*/ + public int dwMinorScale; /* 辅显示 0-不缩放,1-缩放*/ + public int[] dwRes = new int[2]; + } + + public static class NET_DVR_ALARMOUTCFG_V30 extends Structure {//DVR报警输出(9000扩展) + public int dwSize; + public byte[] sAlarmOutName = new byte[NAME_LEN]; /* 名称 */ + public int dwAlarmOutDelay; /* 输出保持时间(-1为无限,手动关闭) */ + //0-5秒,1-10秒,2-30秒,3-1分钟,4-2分钟,5-5分钟,6-10分钟,7-手动 + public NET_DVR_SCHEDTIMEWEEK[] struAlarmOutTime = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS];/* 报警输出激活时间段 */ + public byte[] byRes = new byte[16]; + } + + public static class NET_DVR_ALARMOUTCFG extends Structure {//DVR报警输出 + public int dwSize; + public byte[] sAlarmOutName = new byte[NAME_LEN]; /* 名称 */ + public int dwAlarmOutDelay; /* 输出保持时间(-1为无限,手动关闭) */ + //0-5秒,1-10秒,2-30秒,3-1分钟,4-2分钟,5-5分钟,6-10分钟,7-手动 + public NET_DVR_SCHEDTIMEWEEK[] struAlarmOutTime = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS];/* 报警输出激活时间段 */ + } + + public static class NET_DVR_PREVIEWCFG_V30 extends Structure {//DVR本地预览参数(9000扩展) + public int dwSize; + public byte byPreviewNumber;//预览数目,0-1画面,1-4画面,2-9画面,3-16画面, 4-6画面, 5-8画面, 0xff:最大画面 + public byte byEnableAudio;//是否声音预览,0-不预览,1-预览 + public short wSwitchTime;//切换时间,0-不切换,1-5s,2-10s,3-20s,4-30s,5-60s,6-120s,7-300s + public byte[][] bySwitchSeq = new byte[MAX_PREVIEW_MODE][MAX_WINDOW_V30];//切换顺序,如果lSwitchSeq[i]为 0xff表示不用 + public byte[] byRes = new byte[24]; + } + + public static class NET_DVR_PREVIEWCFG extends Structure {//DVR本地预览参数 + public int dwSize; + public byte byPreviewNumber;//预览数目,0-1画面,1-4画面,2-9画面,3-16画面,0xff:最大画面 + public byte byEnableAudio;//是否声音预览,0-不预览,1-预览 + public short wSwitchTime;//切换时间,0-不切换,1-5s,2-10s,3-20s,4-30s,5-60s,6-120s,7-300s + public byte[] bySwitchSeq = new byte[MAX_WINDOW];//切换顺序,如果lSwitchSeq[i]为 0xff表示不用 + } + + public static class NET_DVR_VGAPARA extends Structure {//DVR视频输出 + public short wResolution; /* 分辨率 */ + public short wFreq; /* 刷新频率 */ + public int dwBrightness; /* 亮度 */ + } + + /* + * MATRIX输出参数结构 + */ + public static class NET_DVR_MATRIXPARA_V30 extends Structure { + public short[] wOrder = new short[MAX_ANALOG_CHANNUM]; /* 预览顺序, 0xff表示相应的窗口不预览 */ + public short wSwitchTime; /* 预览切换时间 */ + public byte[] res = new byte[14]; + } + + public static class NET_DVR_MATRIXPARA extends Structure { + public short wDisplayLogo; /* 显示视频通道号(保留) */ + public short wDisplayOsd; /* 显示时间(保留) */ + } + + public static class NET_DVR_VOOUT extends Structure { + public byte byVideoFormat; /* 输出制式,0-PAL,1-NTSC */ + public byte byMenuAlphaValue; /* 菜单与背景图象对比度 */ + public short wScreenSaveTime; /* 屏幕保护时间 0-从不,1-1分钟,2-2分钟,3-5分钟,4-10分钟,5-20分钟,6-30分钟 */ + public short wVOffset; /* 视频输出偏移 */ + public short wBrightness; /* 视频输出亮度 */ + public byte byStartMode; /* 启动后视频输出模式(0:菜单,1:预览)*/ + public byte byEnableScaler; /* 是否启动缩放 (0-不启动, 1-启动)*/ + } + + public static class NET_DVR_VIDEOOUT_V30 extends Structure {//DVR视频输出(9000扩展) + public int dwSize; + public NET_DVR_VOOUT[] struVOOut = new NET_DVR_VOOUT[MAX_VIDEOOUT_V30]; + public NET_DVR_VGAPARA[] struVGAPara = new NET_DVR_VGAPARA[MAX_VGA_V30]; /* VGA参数 */ + public NET_DVR_MATRIXPARA_V30[] struMatrixPara = new NET_DVR_MATRIXPARA_V30[MAX_MATRIXOUT]; /* MATRIX参数 */ + public byte[] byRes = new byte[16]; + } + + public static class NET_DVR_VIDEOOUT extends Structure {//DVR视频输出 + public int dwSize; + public NET_DVR_VOOUT[] struVOOut = new NET_DVR_VOOUT[MAX_VIDEOOUT]; + public NET_DVR_VGAPARA[] struVGAPara = new NET_DVR_VGAPARA[MAX_VGA]; /* VGA参数 */ + public NET_DVR_MATRIXPARA struMatrixPara; /* MATRIX参数 */ + } + + public static class NET_DVR_USER_INFO_V30 extends Structure {//单用户参数(子结构)(9000扩展) + public byte[] sUserName = new byte[NAME_LEN]; /* 用户名 */ + public byte[] sPassword = new byte[PASSWD_LEN]; /* 密码 */ + public byte[] byLocalRight = new byte[MAX_RIGHT]; /* 本地权限 */ + /*数组0: 本地控制云台*/ + /*数组1: 本地手动录象*/ + /*数组2: 本地回放*/ + /*数组3: 本地设置参数*/ + /*数组4: 本地查看状态、日志*/ + /*数组5: 本地高级操作(升级,格式化,重启,关机)*/ + /*数组6: 本地查看参数 */ + /*数组7: 本地管理模拟和IP camera */ + /*数组8: 本地备份 */ + /*数组9: 本地关机/重启 */ + public byte[] byRemoteRight = new byte[MAX_RIGHT];/* 远程权限 */ + /*数组0: 远程控制云台*/ + /*数组1: 远程手动录象*/ + /*数组2: 远程回放 */ + /*数组3: 远程设置参数*/ + /*数组4: 远程查看状态、日志*/ + /*数组5: 远程高级操作(升级,格式化,重启,关机)*/ + /*数组6: 远程发起语音对讲*/ + /*数组7: 远程预览*/ + /*数组8: 远程请求报警上传、报警输出*/ + /*数组9: 远程控制,本地输出*/ + /*数组10: 远程控制串口*/ + /*数组11: 远程查看参数 */ + /*数组12: 远程管理模拟和IP camera */ + /*数组13: 远程关机/重启 */ + public byte[] byNetPreviewRight = new byte[MAX_CHANNUM_V30]; /* 远程可以预览的通道 0-有权限,1-无权限*/ + public byte[] byLocalPlaybackRight = new byte[MAX_CHANNUM_V30]; /* 本地可以回放的通道 0-有权限,1-无权限*/ + public byte[] byNetPlaybackRight = new byte[MAX_CHANNUM_V30]; /* 远程可以回放的通道 0-有权限,1-无权限*/ + public byte[] byLocalRecordRight = new byte[MAX_CHANNUM_V30]; /* 本地可以录像的通道 0-有权限,1-无权限*/ + public byte[] byNetRecordRight = new byte[MAX_CHANNUM_V30]; /* 远程可以录像的通道 0-有权限,1-无权限*/ + public byte[] byLocalPTZRight = new byte[MAX_CHANNUM_V30]; /* 本地可以PTZ的通道 0-有权限,1-无权限*/ + public byte[] byNetPTZRight = new byte[MAX_CHANNUM_V30]; /* 远程可以PTZ的通道 0-有权限,1-无权限*/ + public byte[] byLocalBackupRight = new byte[MAX_CHANNUM_V30]; /* 本地备份权限通道 0-有权限,1-无权限*/ + public NET_DVR_IPADDR struUserIP; /* 用户IP地址(为0时表示允许任何地址) */ + public byte[] byMACAddr = new byte[MACADDR_LEN]; /* 物理地址 */ + public byte byPriority; /* 优先级,0xff-无,0--低,1--中,2--高 */ + /* + 无……表示不支持优先级的设置 + 低……默认权限:包括本地和远程回放,本地和远程查看日志和状态,本地和远程关机/重启 + 中……包括本地和远程控制云台,本地和远程手动录像,本地和远程回放,语音对讲和远程预览 + 本地备份,本地/远程关机/重启 + 高……管理员 + */ + public byte[] byRes = new byte[17]; + } + + public static class NET_DVR_USER_INFO_EX extends Structure {//单用户参数(SDK_V15扩展)(子结构) + public byte[] sUserName = new byte[NAME_LEN]; /* 用户名 */ + public byte[] sPassword = new byte[PASSWD_LEN]; /* 密码 */ + public int[] dwLocalRight = new int[MAX_RIGHT]; /* 权限 */ + /*数组0: 本地控制云台*/ + /*数组1: 本地手动录象*/ + /*数组2: 本地回放*/ + /*数组3: 本地设置参数*/ + /*数组4: 本地查看状态、日志*/ + /*数组5: 本地高级操作(升级,格式化,重启,关机)*/ + public int dwLocalPlaybackRight; /* 本地可以回放的通道 bit0 -- channel 1*/ + public int[] dwRemoteRight = new int[MAX_RIGHT]; /* 权限 */ + /*数组0: 远程控制云台*/ + /*数组1: 远程手动录象*/ + /*数组2: 远程回放 */ + /*数组3: 远程设置参数*/ + /*数组4: 远程查看状态、日志*/ + /*数组5: 远程高级操作(升级,格式化,重启,关机)*/ + /*数组6: 远程发起语音对讲*/ + /*数组7: 远程预览*/ + /*数组8: 远程请求报警上传、报警输出*/ + /*数组9: 远程控制,本地输出*/ + /*数组10: 远程控制串口*/ + public int dwNetPreviewRight; /* 远程可以预览的通道 bit0 -- channel 1*/ + public int dwNetPlaybackRight; /* 远程可以回放的通道 bit0 -- channel 1*/ + public byte[] sUserIP = new byte[16]; /* 用户IP地址(为0时表示允许任何地址) */ + public byte[] byMACAddr = new byte[MACADDR_LEN]; /* 物理地址 */ + } + + public static class NET_DVR_USER_INFO extends Structure {//单用户参数(子结构) + public byte[] sUserName = new byte[NAME_LEN]; /* 用户名 */ + public byte[] sPassword = new byte[PASSWD_LEN]; /* 密码 */ + public int[] dwLocalRight = new int[MAX_RIGHT]; /* 权限 */ + /*数组0: 本地控制云台*/ + /*数组1: 本地手动录象*/ + /*数组2: 本地回放*/ + /*数组3: 本地设置参数*/ + /*数组4: 本地查看状态、日志*/ + /*数组5: 本地高级操作(升级,格式化,重启,关机)*/ + public int[] dwRemoteRight = new int[MAX_RIGHT]; /* 权限 */ + /*数组0: 远程控制云台*/ + /*数组1: 远程手动录象*/ + /*数组2: 远程回放 */ + /*数组3: 远程设置参数*/ + /*数组4: 远程查看状态、日志*/ + /*数组5: 远程高级操作(升级,格式化,重启,关机)*/ + /*数组6: 远程发起语音对讲*/ + /*数组7: 远程预览*/ + /*数组8: 远程请求报警上传、报警输出*/ + /*数组9: 远程控制,本地输出*/ + /*数组10: 远程控制串口*/ + public byte[] sUserIP = new byte[16]; /* 用户IP地址(为0时表示允许任何地址) */ + public byte[] byMACAddr = new byte[MACADDR_LEN]; /* 物理地址 */ + } + + public static class NET_DVR_USER_V30 extends Structure {//DVR用户参数(9000扩展) + public int dwSize; + public NET_DVR_USER_INFO_V30[] struUser = new NET_DVR_USER_INFO_V30[MAX_USERNUM_V30]; + } + + public static class NET_DVR_USER_EX extends Structure {//DVR用户参数(SDK_V15扩展) + public int dwSize; + public NET_DVR_USER_INFO_EX[] struUser = new NET_DVR_USER_INFO_EX[MAX_USERNUM]; + } + + public static class NET_DVR_USER extends Structure {//DVR用户参数 + public int dwSize; + public NET_DVR_USER_INFO[] struUser = new NET_DVR_USER_INFO[MAX_USERNUM]; + } + + public static class NET_DVR_EXCEPTION_V30 extends Structure {//DVR异常参数(9000扩展) + public int dwSize; + public NET_DVR_HANDLEEXCEPTION_V30[] struExceptionHandleType = new NET_DVR_HANDLEEXCEPTION_V30[MAX_EXCEPTIONNUM_V30]; + /*数组0-盘满,1- 硬盘出错,2-网线断,3-局域网内IP 地址冲突,4-非法访问, 5-输入/输出视频制式不匹配, 6-行车超速(车载专用), 7-视频信号异常(9000)*/ + } + + public static class NET_DVR_EXCEPTION extends Structure {//DVR异常参数 + public int dwSize; + public NET_DVR_HANDLEEXCEPTION[] struExceptionHandleType = new NET_DVR_HANDLEEXCEPTION[MAX_EXCEPTIONNUM]; + /*数组0-盘满,1- 硬盘出错,2-网线断,3-局域网内IP 地址冲突,4-非法访问, 5-输入/输出视频制式不匹配, 6-行车超速(车载专用)*/ + } + + public static class NET_DVR_CHANNELSTATE_V30 extends Structure {//通道状态(9000扩展) + public byte byRecordStatic; //通道是否在录像,0-不录像,1-录像 + public byte bySignalStatic; //连接的信号状态,0-正常,1-信号丢失 + public byte byHardwareStatic;//通道硬件状态,0-正常,1-异常,例如DSP死掉 + public byte byRes1; //保留 + public int dwBitRate;//实际码率 + public int dwLinkNum;//客户端连接的个数 + public NET_DVR_IPADDR[] struClientIP = new NET_DVR_IPADDR[MAX_LINK];//客户端的IP地址 + public int dwIPLinkNum;//如果该通道为IP接入,那么表示IP接入当前的连接数 + public byte byExceedMaxLink; // 是否超出了单路6路连接数 0 - 未超出, 1-超出 + public byte[] byRes = new byte[3]; // 保留字节 + public int dwAllBitRate; //所有实际码率之和 + public int dwChannelNo; //当前的通道号,0xffffffff表示无效 + } + + public static class NET_DVR_CHANNELSTATE extends Structure {//通道状态 + public byte byRecordStatic; //通道是否在录像,0-不录像,1-录像 + public byte bySignalStatic; //连接的信号状态,0-正常,1-信号丢失 + public byte byHardwareStatic;//通道硬件状态,0-正常,1-异常,例如DSP死掉 + public byte reservedData; //保留 + public int dwBitRate;//实际码率 + public int dwLinkNum;//客户端连接的个数 + public int[] dwClientIP = new int[MAX_LINK];//客户端的IP地址 + } + + public static class NET_DVR_DISKSTATE extends Structure {//硬盘状态 + public int dwVolume;//硬盘的容量 + public int dwFreeSpace;//硬盘的剩余空间 + public int dwHardDiskStatic; //硬盘的状态,按位:1-休眠,2-不正常,3-休眠硬盘出错 + } + + public static class NET_DVR_WORKSTATE_V30 extends Structure {//DVR工作状态(9000扩展) + public int dwDeviceStatic; //设备的状态,0-正常,1-CPU占用率太高,超过85%,2-硬件错误,例如串口死掉 + public NET_DVR_DISKSTATE[] struHardDiskStatic = new NET_DVR_DISKSTATE[MAX_DISKNUM_V30]; + public NET_DVR_CHANNELSTATE_V30[] struChanStatic = new NET_DVR_CHANNELSTATE_V30[MAX_CHANNUM_V30];//通道的状态 + public byte[] byAlarmInStatic = new byte[MAX_ALARMIN_V30]; //报警端口的状态,0-没有报警,1-有报警 + public byte[] byAlarmOutStatic = new byte[MAX_ALARMOUT_V30]; //报警输出端口的状态,0-没有输出,1-有报警输出 + public int dwLocalDisplay;//本地显示状态,0-正常,1-不正常 + public byte[] byAudioChanStatus = new byte[MAX_AUDIO_V30];//表示语音通道的状态 0-未使用,1-使用中, 0xff无效 + public byte[] byRes = new byte[10]; + } + + public static class NET_DVR_WORKSTATE extends Structure {//DVR工作状态 + public int dwDeviceStatic; //设备的状态,0-正常,1-CPU占用率太高,超过85%,2-硬件错误,例如串口死掉 + public NET_DVR_DISKSTATE[] struHardDiskStatic = new NET_DVR_DISKSTATE[MAX_DISKNUM]; + public NET_DVR_CHANNELSTATE[] struChanStatic = new NET_DVR_CHANNELSTATE[MAX_CHANNUM];//通道的状态 + public byte[] byAlarmInStatic = new byte[MAX_ALARMIN]; //报警端口的状态,0-没有报警,1-有报警 + public byte[] byAlarmOutStatic = new byte[MAX_ALARMOUT]; //报警输出端口的状态,0-没有输出,1-有报警输出 + public int dwLocalDisplay;//本地显示状态,0-正常,1-不正常 + } + + public static class NET_DVR_LOG_V30 extends Structure {//日志信息(9000扩展) + public NET_DVR_TIME strLogTime; + public int dwMajorType; //主类型 1-报警; 2-异常; 3-操作; 0xff-全部 + public int dwMinorType;//次类型 0-全部; + public byte[] sPanelUser = new byte[MAX_NAMELEN]; //操作面板的用户名 + public byte[] sNetUser = new byte[MAX_NAMELEN];//网络操作的用户名 + public NET_DVR_IPADDR struRemoteHostAddr;//??程主机地址 + public int dwParaType;//参数类型 + public int dwChannel;//通道号 + public int dwDiskNumber;//硬盘号 + public int dwAlarmInPort;//报警输入端口 + public int dwAlarmOutPort;//报警输出端口 + public int dwInfoLen; + public byte[] sInfo = new byte[LOG_INFO_LEN]; + } + + //日志信息 + public static class NET_DVR_LOG extends Structure { + public NET_DVR_TIME strLogTime; + public int dwMajorType; //主类型 1-报警; 2-异常; 3-操作; 0xff-全部 + public int dwMinorType;//次类型 0-全部; + public byte[] sPanelUser = new byte[MAX_NAMELEN]; //操作面板的用户名 + public byte[] sNetUser = new byte[MAX_NAMELEN];//网络操作的用户名 + public byte[] sRemoteHostAddr = new byte[16];//远程主机地址 + public int dwParaType;//参数类型 + public int dwChannel;//通道号 + public int dwDiskNumber;//硬盘号 + public int dwAlarmInPort;//报警输入端口 + public int dwAlarmOutPort;//报警输出端口 + } + + /************************ + * DVR日志 end + ***************************/ + public static class NET_DVR_ALARMOUTSTATUS_V30 extends Structure {//报警输出状态(9000扩展) + public byte[] Output = new byte[MAX_ALARMOUT_V30]; + } + + public static class NET_DVR_ALARMOUTSTATUS extends Structure {//报警输出状态 + public byte[] Output = new byte[MAX_ALARMOUT]; + } + + public static class NET_DVR_TRADEINFO extends Structure {//交易信息 + public short m_Year; + public short m_Month; + public short m_Day; + public short m_Hour; + public short m_Minute; + public short m_Second; + public byte[] DeviceName = new byte[24]; //设备名称 + public int dwChannelNumer; //通道号 + public byte[] CardNumber = new byte[32]; //卡号 + public byte[] cTradeType = new byte[12]; //交易类型 + public int dwCash; //交易金额 + } + + public static class NET_DVR_FRAMETYPECODE extends Structure {/*帧格式*/ + public byte[] code = new byte[12]; /* 代码 */ + } + + public static class NET_DVR_FRAMEFORMAT_V30 extends Structure {//ATM参数(9000扩展) + public int dwSize; + public NET_DVR_IPADDR struATMIP; /* ATM IP地址 */ + public int dwATMType; /* ATM类型 */ + public int dwInputMode; /* 输入方式 0-网络侦听 1-网络接收 2-串口直接输入 3-串口ATM命令输入*/ + public int dwFrameSignBeginPos; /* 报文标志位的起始位置*/ + public int dwFrameSignLength; /* 报文标志位的长度 */ + public byte[] byFrameSignContent = new byte[12]; /* 报文标志位的内容 */ + public int dwCardLengthInfoBeginPos; /* 卡号长度信息的起始位置 */ + public int dwCardLengthInfoLength; /* 卡号长度信息的长度 */ + public int dwCardNumberInfoBeginPos; /* 卡号信息的起始位置 */ + public int dwCardNumberInfoLength; /* 卡号信息的长度 */ + public int dwBusinessTypeBeginPos; /* 交易类型的起始位置 */ + public int dwBusinessTypeLength; /* 交易类型的长度 */ + public NET_DVR_FRAMETYPECODE[] frameTypeCode = new NET_DVR_FRAMETYPECODE[10]; /* 类型 */ + public short wATMPort; /* 卡号捕捉端口号(网络协议方式) (保留)0xffff表示该值无效*/ + public short wProtocolType; /* 网络协议类型(保留) 0xffff表示该值无效*/ + public byte[] byRes = new byte[24]; + } + + public static class NET_DVR_FRAMEFORMAT extends Structure {//ATM参数 + public int dwSize; + public byte[] sATMIP = new byte[16]; /* ATM IP地址 */ + public int dwATMType; /* ATM类型 */ + public int dwInputMode; /* 输入方式 0-网络侦听 1-网络接收 2-串口直接输入 3-串口ATM命令输入*/ + public int dwFrameSignBeginPos; /* 报文标志位的起始位置*/ + public int dwFrameSignLength; /* 报文标志位的长度 */ + public byte[] byFrameSignContent = new byte[12]; /* 报文标志位的内容 */ + public int dwCardLengthInfoBeginPos; /* 卡号长度信息的起始位置 */ + public int dwCardLengthInfoLength; /* 卡号长度信息的长度 */ + public int dwCardNumberInfoBeginPos; /* 卡号信息的起始位置 */ + public int dwCardNumberInfoLength; /* 卡号信息的长度 */ + public int dwBusinessTypeBeginPos; /* 交易类型的起始位置 */ + public int dwBusinessTypeLength; /* 交易类型的长度 */ + public NET_DVR_FRAMETYPECODE[] frameTypeCode = new NET_DVR_FRAMETYPECODE[10];/* 类型 */ + } + + public static class NET_DVR_FTPTYPECODE extends Structure { + public byte[] sFtpType = new byte[32]; /*客户定义的操作类型*/ + public byte[] sFtpCode = new byte[8]; /*客户定义的操作类型的对应的码*/ + } + + public static class NET_DVR_FRAMEFORMAT_EX extends Structure {//ATM参数添加FTP上传参数, 银行定制, 2006-11-17 + public int dwSize; + public byte[] sATMIP = new byte[16]; /* ATM IP地址 */ + public int dwATMType; /* ATM类型 */ + public int dwInputMode; /* 输入方式 0-网络侦听 1-网络接收 2-串口直接输入 3-串口ATM命令输入*/ + public int dwFrameSignBeginPos; /* 报文标志位的起始位置*/ + public int dwFrameSignLength; /* 报文标志位的长度 */ + public byte[] byFrameSignContent = new byte[12]; /* 报文标志位的内容 */ + public int dwCardLengthInfoBeginPos; /* 卡号长度信息的起始位置 */ + public int dwCardLengthInfoLength; /* 卡号长度信息的长度 */ + public int dwCardNumberInfoBeginPos; /* 卡号信息的起始位置 */ + public int dwCardNumberInfoLength; /* 卡号信息的长度 */ + public int dwBusinessTypeBeginPos; /* 交易类型的起始位置 */ + public int dwBusinessTypeLength; /* 交易类型的长度 */ + public NET_DVR_FRAMETYPECODE[] frameTypeCode = new NET_DVR_FRAMETYPECODE[10];/* 类型 */ + public byte[] sFTPIP = new byte[16]; /* FTP IP */ + public byte[] byFtpUsername = new byte[NAME_LEN]; /* 用户名 */ + public byte[] byFtpPasswd = new byte[PASSWD_LEN]; /* 密码 */ + public byte[] sDirName = new byte[NAME_LEN]; /*服务器目录名*/ + public int dwATMSrvType; /*ATM服务器类型,0--wincor ,1--diebold*/ + public int dwTimeSpace; /*取值为1.2.3.4.5.10*/ + public NET_DVR_FTPTYPECODE[] sFtpTypeCodeOp = new NET_DVR_FTPTYPECODE[300]; /*新加的*/ + public int dwADPlay; /* 1 表示在播放广告,0 表示没有播放广告*/ + public int dwNewPort; //端口 + } +/****************************ATM(end)***************************/ + + /***************************** + * DS-6001D/F(begin) + ***************************/ +//DS-6001D Decoder + public static class NET_DVR_DECODERINFO extends Structure { + public byte[] byEncoderIP = new byte[16]; //解码设备连接的服务器IP + public byte[] byEncoderUser = new byte[16]; //解码设备连接的服务器的用户名 + public byte[] byEncoderPasswd = new byte[16]; //解码设备连接的服务器的密码 + public byte bySendMode; //解码设备连接服务器的连接模式 + public byte byEncoderChannel; //解码设备连接的服务器的通道号 + public short wEncoderPort; //解码设备连接的服务器的端口号 + public byte[] reservedData = new byte[4]; //保留 + } + + public static class NET_DVR_DECODERSTATE extends Structure { + public byte[] byEncoderIP = new byte[16]; //解码设备连接的服务器IP + public byte[] byEncoderUser = new byte[16]; //解码设备连接的服务器的用户名 + public byte[] byEncoderPasswd = new byte[16]; //解码设备连接的服务器的密码 + public byte byEncoderChannel; //解码设备连接的服务器的通道号 + public byte bySendMode; //解码设备连接的服务器的连接模式 + public short wEncoderPort; //解码设备连接的服务器的端口号 + public int dwConnectState; //解码设备连接服务器的状态 + public byte[] reservedData = new byte[4]; //保留 + } + + public static class NET_DVR_DECCHANINFO extends Structure { + public byte[] sDVRIP = new byte[16]; /* DVR IP地址 */ + public short wDVRPort; /* 端口号 */ + public byte[] sUserName = new byte[NAME_LEN]; /* 用户名 */ + public byte[] sPassword = new byte[PASSWD_LEN]; /* 密码 */ + public byte byChannel; /* 通道号 */ + public byte byLinkMode; /* 连接模式 */ + public byte byLinkType; /* 连接类型 0-主码流 1-子码流 */ + } + + public static class NET_DVR_DECINFO extends Structure {/*每个解码通道的配置*/ + public byte byPoolChans; /*每路解码通道上的循环通道数量, 最多4通道 0表示没有解码*/ + public NET_DVR_DECCHANINFO[] struchanConInfo = new NET_DVR_DECCHANINFO[MAX_DECPOOLNUM]; + public byte byEnablePoll; /*是否轮巡 0-否 1-是*/ + public byte byPoolTime; /*轮巡时间 0-保留 1-10秒 2-15秒 3-20秒 4-30秒 5-45秒 6-1分钟 7-2分钟 8-5分钟 */ + } + + public static class NET_DVR_DECCFG extends Structure {/*整个设备解码配置*/ + public int dwSize; + public int dwDecChanNum; /*解码通道的数量*/ + public NET_DVR_DECINFO[] struDecInfo = new NET_DVR_DECINFO[MAX_DECNUM]; + } + + //2005-08-01 + public static class NET_DVR_PORTINFO extends Structure {/* 解码设备透明通道设置 */ + public int dwEnableTransPort; /* 是否启动透明通道 0-不启用 1-启用*/ + public byte[] sDecoderIP = new byte[16]; /* DVR IP地址 */ + public short wDecoderPort; /* 端口号 */ + public short wDVRTransPort; /* 配置前端DVR是从485/232输出,1表示232串口,2表示485串口 */ + public byte[] cReserve = new byte[4]; + } + + public static class NET_DVR_PORTCFG extends Structure { + public int dwSize; + public NET_DVR_PORTINFO[] struTransPortInfo = new NET_DVR_PORTINFO[MAX_TRANSPARENTNUM]; /* 数组0表示232 数组1表示485 */ + } + + /*https://jna.dev.java.net/javadoc/com/sun/jna/Union.html#setType(java.lang.Class) see how to use the JNA Union*/ + public static class NET_DVR_PLAYREMOTEFILE extends Structure {/* 控制网络文件回放 */ + public int dwSize; + public byte[] sDecoderIP = new byte[16]; /* DVR IP地址 */ + public short wDecoderPort; /* 端口号 */ + public short wLoadMode; /* 回放下载模式 1-按名字 2-按时间 */ + public byte[] byFile = new byte[100]; + + public static class mode_size extends Union { + public byte[] byFile = new byte[100]; // 回放的文件名 + + public static class bytime extends Structure { + public int dwChannel; + public byte[] sUserName = new byte[NAME_LEN]; //请求视频用户名 + public byte[] sPassword = new byte[PASSWD_LEN]; // 密码 + public NET_DVR_TIME struStartTime; //按时间回放的开始时间 + public NET_DVR_TIME struStopTime; // 按时间回放的结束时间 + } + } + } + + public static class NET_DVR_DECCHANSTATUS extends Structure {/*当前设备解码连接状态*/ + public int dwWorkType; /*工作方式:1:轮巡、2:动态连接解码、3:文件回放下载 4:按时间回放下载*/ + public byte[] sDVRIP = new byte[16]; /*连接的设备ip*/ + public short wDVRPort; /*连接端口号*/ + public byte byChannel; /* 通道号 */ + public byte byLinkMode; /* 连接模式 */ + public int dwLinkType; /*连接类型 0-主码流 1-子码流*/ + public byte[] sUserName = new byte[NAME_LEN]; /*请求视频用户名*/ + public byte[] sPassword = new byte[PASSWD_LEN]; /* 密码 */ + public byte[] cReserve = new byte[52]; + + public static class objectInfo extends Union { + public static class userInfo extends Structure { + public byte[] sUserName = new byte[NAME_LEN]; //请求视频用户名 + public byte[] sPassword = new byte[PASSWD_LEN]; // 密码 + public byte[] cReserve = new byte[52]; + } + + public static class fileInfo extends Structure { + public byte[] fileName = new byte[100]; + } + + public static class timeInfo extends Structure { + public int dwChannel; + public byte[] sUserName = new byte[NAME_LEN]; //请求视频用户名 + public byte[] sPassword = new byte[PASSWD_LEN]; // 密码 + public NET_DVR_TIME struStartTime; // 按时间回放的开始时间 + public NET_DVR_TIME struStopTime; //按时间回放的结束时间 + } + } + } + + public static class NET_DVR_DECSTATUS extends Structure { + public int dwSize; + public NET_DVR_DECCHANSTATUS[] struDecState = new NET_DVR_DECCHANSTATUS[MAX_DECNUM]; + } + + /***************************** + * DS-6001D/F(end) + ***************************/ + + public static class NET_DVR_SHOWSTRINGINFO extends Structure {//单字符参数(子结构) + public short wShowString; // 预览的图象上是否显示字符,0-不显示,1-显示 区域大小704*576,单个字符的大小为32*32 + public short wStringSize; /* 该行字符的长度,不能大于44个字符 */ + public short wShowStringTopLeftX; /* 字符显示位置的x坐标 */ + public short wShowStringTopLeftY; /* 字符名称显示位置的y坐标 */ + public byte[] sString = new byte[44]; /* 要显示的字符内容 */ + } + + //叠加字符(9000扩展) + public static class NET_DVR_SHOWSTRING_V30 extends Structure { + public int dwSize; + public NET_DVR_SHOWSTRINGINFO[] struStringInfo = new NET_DVR_SHOWSTRINGINFO[MAX_STRINGNUM_V30]; /* 要显示的字符内容 */ + } + + //叠加字符扩展(8条字符) + public static class NET_DVR_SHOWSTRING_EX extends Structure { + public int dwSize; + public NET_DVR_SHOWSTRINGINFO[] struStringInfo = new NET_DVR_SHOWSTRINGINFO[MAX_STRINGNUM_EX]; /* 要显示的字符内容 */ + } + + //叠加字符 + public static class NET_DVR_SHOWSTRING extends Structure { + public int dwSize; + public NET_DVR_SHOWSTRINGINFO[] struStringInfo = new NET_DVR_SHOWSTRINGINFO[MAX_STRINGNUM]; /* 要显示的字符内容 */ + } + + /**************************** + * DS9000新增结构(begin) + ******************************/ + +/* +EMAIL参数结构 +*/ + public static class NET_DVR_SENDER extends Structure { + public byte[] sName = new byte[NAME_LEN]; /* 发件人姓名 */ + public byte[] sAddress = new byte[MAX_EMAIL_ADDR_LEN]; /* 发件人地址 */ + } + + public static class NET_DVRRECEIVER extends Structure { + public byte[] sName = new byte[NAME_LEN]; /* 收件人姓名 */ + public byte[] sAddress = new byte[MAX_EMAIL_ADDR_LEN]; /* 收件人地址 */ + } + + public static class NET_DVR_EMAILCFG_V30 extends Structure { + public int dwSize; + public byte[] sAccount = new byte[NAME_LEN]; /* 账号*/ + public byte[] sPassword = new byte[MAX_EMAIL_PWD_LEN]; /*密码 */ + public NET_DVR_SENDER struSender; + public byte[] sSmtpServer = new byte[MAX_EMAIL_ADDR_LEN]; /* smtp服务器 */ + public byte[] sPop3Server = new byte[MAX_EMAIL_ADDR_LEN]; /* pop3服务器 */ + public NET_DVRRECEIVER[] struReceiver = new NET_DVRRECEIVER[3]; /* 最多可以设置3个收件人 */ + public byte byAttachment; /* 是否带附件 */ + public byte bySmtpServerVerify; /* 发送服务器要求身份验证 */ + public byte byMailInterval; /* mail interval */ + public byte[] res = new byte[77]; + } + + /* +DVR实现巡航数据结构 +*/ + public static class NET_DVR_CRUISE_PARA extends Structure { + public int dwSize; + public byte[] byPresetNo = new byte[CRUISE_MAX_PRESET_NUMS]; /* 预置点号 */ + public byte[] byCruiseSpeed = new byte[CRUISE_MAX_PRESET_NUMS]; /* 巡航速度 */ + public short[] wDwellTime = new short[CRUISE_MAX_PRESET_NUMS]; /* 停留时间 */ + public byte[] byEnableThisCruise; /* 是否启用 */ + public byte[] res = new byte[15]; + } + + /**************************** + * DS9000新增结构(end) + ******************************/ + +//时间点 + public static class NET_DVR_TIMEPOINT extends Structure { + public int dwMonth; //月 0-11表示1-12个月 + public int dwWeekNo; //第几周 0-第1周 1-第2周 2-第3周 3-第4周 4-最后一周 + public int dwWeekDate; //星期几 0-星期日 1-星期一 2-星期二 3-星期三 4-星期四 5-星期五 6-星期六 + public int dwHour; //小时 开始时间0-23 结束时间1-23 + public int dwMin; //分 0-59 + } + + //夏令时参数 + public static class NET_DVR_ZONEANDDST extends Structure { + public int dwSize; + public byte[] byRes1 = new byte[16]; //保留 + public int dwEnableDST; //是否启用夏时制 0-不启用 1-启用 + public byte byDSTBias; //夏令时偏移值,30min, 60min, 90min, 120min, 以分钟计,传递原始数值 + public byte[] byRes2 = new byte[3]; + public NET_DVR_TIMEPOINT struBeginPoint; //夏时制开始时间 + public NET_DVR_TIMEPOINT struEndPoint; //夏时制停止时间 + } + + //图片质量 + public static class NET_DVR_JPEGPARA extends Structure { + /*注意:当图像压缩分辨率为VGA时,支持0=CIF, 1=QCIF, 2=D1抓图, + 当分辨率为3=UXGA(1600x1200), 4=SVGA(800x600), 5=HD720p(1280x720),6=VGA,7=XVGA, 8=HD900p + 仅支持当前分辨率的抓图*/ + public short wPicSize; /* 0=CIF, 1=QCIF, 2=D1 3=UXGA(1600x1200), 4=SVGA(800x600), 5=HD720p(1280x720),6=VGA*/ + public short wPicQuality; /* 图片质量系数 0-最好 1-较好 2-一般 */ + } + + /* aux video out parameter */ +//辅助输出参数配置 + public static class NET_DVR_AUXOUTCFG extends Structure { + public int dwSize; + public int dwAlarmOutChan; /* 选择报警弹出大报警通道切换时间:1画面的输出通道: 0:主输出/1:辅1/2:辅2/3:辅3/4:辅4 */ + public int dwAlarmChanSwitchTime; /* :1秒 - 10:10秒 */ + public int[] dwAuxSwitchTime = new int[MAX_AUXOUT]; /* 辅助输出切换时间: 0-不切换,1-5s,2-10s,3-20s,4-30s,5-60s,6-120s,7-300s */ + public byte[][] byAuxOrder = new byte[MAX_AUXOUT][MAX_WINDOW]; /* 辅助输出预览顺序, 0xff表示相应的窗口不预览 */ + } + + //ntp + public static class NET_DVR_NTPPARA extends Structure { + public byte[] sNTPServer = new byte[64]; /* Domain Name or IP addr of NTP server */ + public short wInterval; /* adjust time interval(hours) */ + public byte byEnableNTP; /* enable NPT client 0-no,1-yes*/ + public byte cTimeDifferenceH; /* 与国际标准时间的 小时偏移-12 ... +13 */ + public byte cTimeDifferenceM;/* 与国际标准时间的 分钟偏移0, 30, 45*/ + public byte res1; + public short wNtpPort; /* ntp server port 9000新增 设备默认为123*/ + public byte[] res2 = new byte[8]; + } + + //ddns + public static class NET_DVR_DDNSPARA extends Structure { + public byte[] sUsername = new byte[NAME_LEN]; /* DDNS账号用户名/密码 */ + public byte[] sPassword = new byte[PASSWD_LEN]; + public byte[] sDomainName = new byte[64]; /* 域名 */ + public byte byEnableDDNS; /*是否应用 0-否,1-是*/ + public byte[] res = new byte[15]; + } + + public static class NET_DVR_DDNSPARA_EX extends Structure { + public byte byHostIndex; /* 0-Hikvision DNS 1-Dyndns 2-PeanutHull(花生壳), 3-希网3322*/ + public byte byEnableDDNS; /*是否应用DDNS 0-否,1-是*/ + public short wDDNSPort; /* DDNS端口号 */ + public byte[] sUsername = new byte[NAME_LEN]; /* DDNS用户名*/ + public byte[] sPassword = new byte[PASSWD_LEN]; /* DDNS密码 */ + public byte[] sDomainName = new byte[MAX_DOMAIN_NAME]; /* 设备配备的域名地址 */ + public byte[] sServerName = new byte[MAX_DOMAIN_NAME]; /* DDNS 对应的服务器地址,可以是IP地址或域名 */ + public byte[] byRes = new byte[16]; + } + + public static class NET_DVR_DDNS extends Structure { + public byte[] sUsername = new byte[NAME_LEN]; /* DDNS账号用户名*/ + public byte[] sPassword = new byte[PASSWD_LEN]; /* 密码 */ + public byte[] sDomainName = new byte[MAX_DOMAIN_NAME]; /* 设备配备的域名地址 */ + public byte[] sServerName = new byte[MAX_DOMAIN_NAME]; /* DDNS协议对应的服务器地址,可以是IP地址或域名 */ + public short wDDNSPort; /* 端口号 */ + public byte[] byRes = new byte[10]; + } + + //9000扩展 + public static class NET_DVR_DDNSPARA_V30 extends Structure { + public byte byEnableDDNS; + public byte byHostIndex;/* 0-Hikvision DNS(保留) 1-Dyndns 2-PeanutHull(花生壳) 3-希网3322 */ + public byte[] byRes1 = new byte[2]; + public NET_DVR_DDNS[] struDDNS = new NET_DVR_DDNS[MAX_DDNS_NUMS];//9000目前只支持前3个配置,其他配置保留 + public byte[] byRes2 = new byte[16]; + } + + //email + public static class NET_DVR_EMAILPARA extends Structure { + public byte[] sUsername = new byte[64]; /* 邮件账号/密码 */ + public byte[] sPassword = new byte[64]; + public byte[] sSmtpServer = new byte[64]; + public byte[] sPop3Server = new byte[64]; + public byte[] sMailAddr = new byte[64]; /* email */ + public byte[] sEventMailAddr1 = new byte[64]; /* 上传报警/异常等的email */ + public byte[] sEventMailAddr2 = new byte[64]; + public byte[] res = new byte[16]; + } + + public static class NET_DVR_NETAPPCFG extends Structure {//网络参数配置 + public int dwSize; + public byte[] sDNSIp = new byte[16]; /* DNS服务器地址 */ + public NET_DVR_NTPPARA struNtpClientParam; /* NTP参数 */ + public NET_DVR_DDNSPARA struDDNSClientParam; /* DDNS参数 */ + //NET_DVR_EMAILPARA struEmailParam; /* EMAIL参数 */ + public byte[] res = new byte[464]; /* 保留 */ + } + + public static class NET_DVR_SINGLE_NFS extends Structure {//nfs结构配置 + public byte[] sNfsHostIPAddr = new byte[16]; + public byte[] sNfsDirectory = new byte[PATHNAME_LEN]; // PATHNAME_LEN = 128 + } + + public static class NET_DVR_NFSCFG extends Structure { + public int dwSize; + public NET_DVR_SINGLE_NFS[] struNfsDiskParam = new NET_DVR_SINGLE_NFS[MAX_NFS_DISK]; + } + + //巡航点配置(HIK IP快球专用) + public static class NET_DVR_CRUISE_POINT extends Structure { + public byte PresetNum; //预置点 + public byte Dwell; //停留时间 + public byte Speed; //速度 + public byte Reserve; //保留 + } + + public static class NET_DVR_CRUISE_RET extends Structure { + public NET_DVR_CRUISE_POINT[] struCruisePoint = new NET_DVR_CRUISE_POINT[32]; //最大支持32个巡航点 + } + + /************************************ + * 多路解码器(begin) + ***************************************/ +//多路解码器扩展 added by zxy 2007-05-23 + public static class NET_DVR_NETCFG_OTHER extends Structure { + public int dwSize; + public byte[] sFirstDNSIP = new byte[16]; + public byte[] sSecondDNSIP = new byte[16]; + public byte[] sRes = new byte[32]; + } + + public static class NET_DVR_MATRIX_DECINFO extends Structure { + public byte[] sDVRIP = new byte[16]; /* DVR IP地址 */ + public short wDVRPort; /* 端口号 */ + public byte byChannel; /* 通道号 */ + public byte byTransProtocol; /* 传输协议类型 0-TCP 1-UDP */ + public byte byTransMode; /* 传输码流模式 0-主码流 1-子码流*/ + public byte[] byRes = new byte[3]; + public byte[] sUserName = new byte[NAME_LEN]; /* 布防主机登陆帐号 */ + public byte[] sPassword = new byte[PASSWD_LEN]; /* 布防主机密码 */ + } + + public static class NET_DVR_MATRIX_DYNAMIC_DEC extends Structure {//启动/停止动态解码 + public int dwSize; + public NET_DVR_MATRIX_DECINFO struDecChanInfo; /* 动态解码通道信息 */ + } + + public static class NET_DVR_MATRIX_DEC_CHAN_STATUS extends Structure {//2007-12-13 modified by zxy 修改多路解码器的NET_DVR_MATRIX_DEC_CHAN_STATUS结构 + public int dwSize;//2008-1-16 modified by zxy dwIsLinked的状态由原来的0-未链接 1-连接修改成以下三种状态。 + public int dwIsLinked; /* 解码通道状态 0-休眠 1-正在连接 2-已连接 3-正在解码 */ + public int dwStreamCpRate; /* Stream copy rate, X kbits/second */ + public byte[] cRes = new byte[64]; /* 保留 */ + } +//end 2007-12-13 modified by zxy + + public static class NET_DVR_MATRIX_DEC_CHAN_INFO extends Structure { + public int dwSize; + public NET_DVR_MATRIX_DECINFO struDecChanInfo; /* 解码通道信息 */ + public int dwDecState; /* 0-动态解码 1-循环解码 2-按时间回放 3-按文件回放 */ + public NET_DVR_TIME StartTime; /* 按时间回放开始时间 */ + public NET_DVR_TIME StopTime; /* 按时间回放停止时间 */ + public byte[] sFileName = new byte[128]; /* 按文件回放文件名 */ + } + + //连接的通道配置 2007-11-05 + public static class NET_DVR_MATRIX_DECCHANINFO extends Structure { + public int dwEnable; /* 是否启用 0-否 1-启用*/ + public NET_DVR_MATRIX_DECINFO struDecChanInfo; /* 轮循解码通道信息 */ + } + + //2007-11-05 新增每个解码通道的配置 + public static class NET_DVR_MATRIX_LOOP_DECINFO extends Structure { + public int dwSize; + public int dwPoolTime; /*轮巡时间 */ + public NET_DVR_MATRIX_DECCHANINFO[] struchanConInfo = new NET_DVR_MATRIX_DECCHANINFO[MAX_CYCLE_CHAN]; + } + + //2007-05-25 多路解码器数字矩阵配置 +//矩阵行信息 2007-12-28 + public static class NET_DVR_MATRIX_ROW_ELEMENT extends Structure { + public byte[] sSurvChanName = new byte[128]; /* 布防通道名称,支持中文 */ + public int dwRowNum; /* 行号 */ + public NET_DVR_MATRIX_DECINFO struDecChanInfo; /* 矩阵行信息 */ + } + + public static class NET_DVR_MATRIX_ROW_INDEX extends Structure { + public byte[] sSurvChanName = new byte[128]; /* 布防通道名称,支持中文 */ + public int dwRowNum; /* 行号 */ + } + + //矩阵列信息 2007-12-28 + public static class NET_DVR_MATRIX_COLUMN_ELEMENT extends Structure { + public int dwLocalDispChanNum; /* 本地显示通道号 */ + public int dwGlobalDispChanNum; /* 全局显示通道号 */ + public int dwRes; /* 保留 */ + } + + public static class NET_DVR_MATRIX_GLOBAL_COLUMN_ELEMENT extends Structure { + public int dwConflictTag; /* 冲突标记,0:无冲突,1:冲突 */ + public int dwConflictGloDispChan; /* 与之冲突的全局通道号 */ + public NET_DVR_MATRIX_COLUMN_ELEMENT struColumnInfo;/* 矩阵列元素结构体 */ + } + + //手动查看 2007-12-28 + public static class NET_DVR_MATRIX_ROW_COLUMN_LINK extends Structure { + public int dwSize; + /* + * 以下三个参数只需要指定其中一个便可指定数字矩阵里的某一行 + * 所代表的远程布防通道。 + * 如果指定了多个域并有冲突,设备将按照域的先后顺序为准取最先定义者。 + */ + public int dwRowNum; /* -1代表无效域,大于0者方为有效的矩阵行号 */ + public byte[] sSurvChanName = new byte[128]; /* 布防通道名,是否无效按字符串的有效性判断 */ + public int dwSurvNum; /* 布防通道号,按矩阵行列表的顺序指定,一般情况下与行号一致 */ + /* + * 以下两项只需要指定其中一项便可,如果两项都有效默认选择第一项 + */ + public int dwGlobalDispChanNum; /* 电视墙上的电视机编号 */ + public int dwLocalDispChanNum; + /* + * 0代表播放即时码流, + * 1表示按时间回访远程布防设备的文件 + * 2表示按文件名回访 + */ + public int dwTimeSel; + public NET_DVR_TIME StartTime; + public NET_DVR_TIME StopTime; + public byte[] sFileName = new byte[128]; + } + + public static class NET_DVR_MATRIX_PREVIEW_DISP_CHAN extends Structure { + public int dwSize; + public int dwGlobalDispChanNum; /* 电视墙上的电视机编号 */ + public int dwLocalDispChanNum; /* 解码通道 */ + } + + public static class NET_DVR_MATRIX_LOOP_PLAY_SET extends Structure {//轮循功能 2007-12-28 + public int dwSize; + /* 任意指定一个,-1为无效,如果都指定则以LocalDispChanNum为准 */ + public int dwLocalDispChanNum; /* 解码通道 */ + public int dwGlobalDispChanNum; /* 电视墙上的电视机编号 */ + public int dwCycTimeInterval; /* 轮循时间间隔 */ + } + + public static class NET_DVR_MATRIX_LOCAL_HOST_INFO extends Structure {//矩阵中心配置 2007-12-28 + public int dwSize; + public int dwLocalHostProperty; /* 本地主机类型 0-服务器 1-客户端*/ + public int dwIsIsolated; /* 本地主机是否独立于系统,0:联网,1:独立 */ + public int dwLocalMatrixHostPort; /* 本地主机访问端口 */ + public byte[] byLocalMatrixHostUsrName = new byte[NAME_LEN]; /* 本地主机登录用户名 */ + public byte[] byLocalMatrixHostPasswd = new byte[PASSWD_LEN]; /* 本地主机登录密码 */ + public int dwLocalMatrixCtrlMedia; /* 控制方式 0x1串口键盘控制 0x2网络键盘控制 0x4矩阵中心控制 0x8PC客户端控制*/ + public byte[] sMatrixCenterIP = new byte[16]; /* 矩阵中心IP地址 */ + public int dwMatrixCenterPort; /* 矩阵中心端口号 */ + public byte[] byMatrixCenterUsrName = new byte[NAME_LEN]; /* 矩阵中心登录用户名 */ + public byte[] byMatrixCenterPasswd = new byte[PASSWD_LEN]; /* 矩阵中心登录密码 */ + } + + //2007-12-22 + public static class TTY_CONFIG extends Structure { + public byte baudrate; /* 波特率 */ + public byte databits; /* 数据位 */ + public byte stopbits; /* 停止位 */ + public byte parity; /* 奇偶校验位 */ + public byte flowcontrol; /* 流控 */ + public byte[] res = new byte[3]; + } + + public static class NET_DVR_MATRIX_TRAN_CHAN_INFO extends Structure { + public byte byTranChanEnable; /* 当前透明通道是否打开 0:关闭 1:打开 */ + /* + * 多路解码器本地有1个485串口,1个232串口都可以作为透明通道,设备号分配如下: + * 0 RS485 + * 1 RS232 Console + */ + public byte byLocalSerialDevice; /* Local serial device */ + /* + * 远程串口输出还是两个,一个RS232,一个RS485 + * 1表示232串口 + * 2表示485串口 + */ + public byte byRemoteSerialDevice; /* Remote output serial device */ + public byte res1; /* 保留 */ + public byte[] sRemoteDevIP = new byte[16]; /* Remote Device IP */ + public short wRemoteDevPort; /* Remote Net Communication Port */ + public byte[] res2 = new byte[2]; /* 保留 */ + public TTY_CONFIG RemoteSerialDevCfg; + } + + public static class NET_DVR_MATRIX_TRAN_CHAN_CONFIG extends Structure { + public int dwSize; + public byte by232IsDualChan; /* 设置哪路232透明通道是全双工的 取值1到MAX_SERIAL_NUM */ + public byte by485IsDualChan; /* 设置哪路485透明通道是全双工的 取值1到MAX_SERIAL_NUM */ + public byte[] res = new byte[2]; /* 保留 */ + public NET_DVR_MATRIX_TRAN_CHAN_INFO[] struTranInfo = new NET_DVR_MATRIX_TRAN_CHAN_INFO[MAX_SERIAL_NUM];/*同时支持建立MAX_SERIAL_NUM个透明通道*/ + } + + //2007-12-24 Merry Christmas Eve... + public static class NET_DVR_MATRIX_DEC_REMOTE_PLAY extends Structure { + public int dwSize; + public byte[] sDVRIP = new byte[16]; /* DVR IP地址 */ + public short wDVRPort; /* 端口号 */ + public byte byChannel; /* 通道号 */ + public byte byReserve; + public byte[] sUserName = new byte[NAME_LEN]; /* 用户名 */ + public byte[] sPassword = new byte[PASSWD_LEN]; /* 密码 */ + public int dwPlayMode; /* 0-按文件 1-按时间*/ + public NET_DVR_TIME StartTime; + public NET_DVR_TIME StopTime; + public byte[] sFileName = new byte[128]; + } + + + public static class NET_DVR_MATRIX_DEC_REMOTE_PLAY_CONTROL extends Structure { + public int dwSize; + public int dwPlayCmd; /* 播放命令 见文件播放命令*/ + public int dwCmdParam; /* 播放命令参数 */ + } + + public static class NET_DVR_MATRIX_DEC_REMOTE_PLAY_STATUS extends Structure { + public int dwSize; + public int dwCurMediaFileLen; /* 当前播放的媒体文件长度 */ + public int dwCurMediaFilePosition; /* 当前播放文件的播放位置 */ + public int dwCurMediaFileDuration; /* 当前播放文件的总时间 */ + public int dwCurPlayTime; /* ½“前已经播放的时间 */ + public int dwCurMediaFIleFrames; /* 当前播放文件的总帧数 */ + public int dwCurDataType; /* 当前传输的数据类型,19-文件头,20-流数据, 21-播放结束标志 */ + public byte[] res = new byte[72]; + } + + public static class NET_DVR_MATRIX_PASSIVEMODE extends Structure { + public short wTransProtol; //传输协议,0-TCP, 1-UDP, 2-MCAST + public short wPassivePort; //TCP,UDP时为TCP,UDP端口, MCAST时为MCAST端口 + public NET_DVR_IPADDR struMcastIP; //TCP,UDP时无效, MCAST时为多播地址 + public byte byStreamType; //数据播放模式:1- 实时流,2- 文件流 + public byte[] res = new byte[7]; + } +/************************************多路解码器(end)***************************************/ + + + /************************************ + * 拼控(Start) + ***************************************/ + + + public static final int NET_DVR_GET_SUBWND_DECODE_OSD = 9183; //获取子窗口解码OSD信息 + public static final int NET_DVR_GET_SUBWND_DECODE_OSD_ALL = 9184; //获取所有子窗口解码OSD信息 + public static final int NET_DVR_SET_SUBWND_DECODE_OSD = 9185; //设置子窗口解码OSD信息 + public static final int NET_DVR_GET_SUBWND_DECODE_OSD_CAP = 9186; //获取子窗口解码OSD信息能力集 + public static final int NET_DVR_GET_DECODE_CHANNEL_OSD = 9187; //获取解码通道OSD信息 + public static final int NET_DVR_SET_DECODE_CHANNEL_OSD = 9188; //设置解码通道OSD信息 + + public static final int MAX_PLAN_ACTION_NUM = 32; //预案动作个数 + public static final int DAYS_A_WEEK = 7; //一周7天 + public static final int MAX_PLAN_COUNT = 16; //预案个数 + public static final int MAX_LEN_OSD_CONTENT = 256; //OSD信息最大长度 + public static final int MAX_NUM_OSD_ONE_SUBWND = 8; //单个子窗口支持的最大OSD数量 + public static final int MAX_NUM_SPLIT_WND = 64; //单个窗口支持的最大分屏窗口数量(即子窗口数量) + public static final int MAX_NUM_OSD = 8; + public static final int MAX_CYCLE_CHAN_V30 = 64; //最大轮巡通道数(扩展) + public static final int STREAM_PASSWD_LEN = 12; //码流加密密钥最大长度 + + public static class NET_DVR_VIDEO_WALL_INFO extends Structure { + public int dwSize; + //窗口号:1字节墙号+1字节保留+2字节窗口号 + public int dwWindowNo; + public int dwSceneNo;//场景号 + public int dwDestWallNo; //目的墙号 + public int dwDestSceneNo;//目的场景号 + public byte[] byRes = new byte[12]; + } + + public static class NET_DVR_SCENE_CONTROL_INFO extends Structure { + public int dwSize; + public NET_DVR_VIDEO_WALL_INFO struVideoWallInfo; //电视墙信息 + public int dwCmd; //场景控制命令,1-场景模式切换(如果要切换的是当前场景,则不进行切换),2-初始化场景(将此场景的配置清空,如果是当前场景,则同时对当前场景进行清屏操作),3-强制切换(无论是否是当前场景,强制切换),4-保存当前模式到某场景 5-删除场景 ,6-场景复制 + public byte[] byRes = new byte[4]; + } + + public static class NET_DVR_BUF_INFO extends Structure { + public Pointer pBuf; + public int nLen; + } + + public static class NET_DVR_IN_PARAM extends Structure { + public NET_DVR_BUF_INFO struCondBuf; + public NET_DVR_BUF_INFO struInParamBuf; + public int dwRecvTimeout; //接收数据超时时间,单位:ms,置0采用接口默认超时 + public byte[] byRes = new byte[32]; + } + + public static class NET_DVR_OUT_PARAM extends Structure { + public NET_DVR_BUF_INFO struOutBuf; + public Pointer lpStatusList; + public byte[] byRes = new byte[32]; + } + + public static class NET_DVR_RECTCFG_EX extends Structure { + public int dwXCoordinate; /*矩形左上角起始点X坐标*/ + public int dwYCoordinate; /*矩形左上角Y坐标*/ + public int dwWidth; /*矩形宽度*/ + public int dwHeight; /*矩形高度*/ + public byte[] byRes = new byte[4]; + + } + + public static class NET_DVR_VIDEOWALLWINDOWPOSITION extends Structure { + public int dwSize; + public byte byEnable; //窗口使能,0-不使能,1-使能 + public byte byWndOperateMode; //窗口操作模式,0-统一坐标,1-分辨率坐标 + public byte[] byRes1 = new byte[6]; + public int dwWindowNo;//窗口号 + public int dwLayerIndex;//窗口相对应的图层号,图层号到最大即置顶,置顶操作 + public NET_DVR_RECTCFG_EX struRect; //目的窗口统一坐标(相对显示墙),获取或按统一坐标设置时有效 + public NET_DVR_RECTCFG_EX struResolution; //目的窗口分辨率坐标,获取或按分辨率坐标设置有效 + public int dwXCoordinate; //LED区域左上角X坐标(统一坐标),获取或按分辨率坐标设置有效 + public int dwYCoordinate; //LED区域左上角Y坐标(统一坐标),获取或按分辨率坐标设置有效 + public byte[] byRes2 = new byte[36]; + } + + public static class VIDEOWALLWINDOWPOSITION_ARRAY extends Structure { + public NET_DVR_VIDEOWALLWINDOWPOSITION[] strVideoWinPostion; + + public VIDEOWALLWINDOWPOSITION_ARRAY(int iLen) { + strVideoWinPostion = new NET_DVR_VIDEOWALLWINDOWPOSITION[iLen]; + } + + + } + + + public static class NET_DVR_WALLWINPARAM extends Structure { + public int dwSize; + public byte byTransparency; //使能透明度,0-关,非0-开 + public byte byWinMode;//窗口分屏模式,能力集获取 + public byte byEnableSpartan;//畅显使能,0-关,1-开 + public byte byDecResource; //为窗口分配的解码资源,1-D1,2-720P,3-1080P + public byte byWndShowMode; //窗口显示模式,0-此字段不用,1-子窗口模式,2-子窗口全屏模式 + public byte byEnabledFeature; //是否启用场景特写,0-不启用,!0-启用 + public byte byFeatureMode; //特写模式,启用场景特写时有效,0-无效,1-“1+5”模式 + public byte byRes1; + public int dwAmplifyingSubWndNo; //全屏子窗口号(1字节墙号+1字节子窗口号+2字节窗口号) + //当byWndShowMode为2时有效,表示当前全屏显示的子窗口 + public byte byWndTopKeep; //窗口置顶保持,0-不保持,1-保持 + public byte byWndOpenKeep; //窗口打开保持,0-不保持,1-保持 + public byte[] byRes = new byte[22]; + } + + public static class NET_DVR_PLAN_LIST extends Structure { + public int dwSize; + public int dwPlanNums; //设备输入信号源数量 + public Pointer pBuffer; //指向dwInputSignalNums个NET_DVR_PLAN_CFG结构大小的缓冲区 + public byte byWallNo; //墙号,从1开始 + public byte[] byRes1 = new byte[2]; + public int dwBufLen; //所分配缓冲区长度,输入参数(大于等于dwInputSignalNums个NET_DVR_PLAN_CFG结构大小) + public byte[] byRes2 = new byte[64]; + } + + /*预案项信息*/ + public static class NET_DVR_PLAN_INFO extends Structure { + public byte byValid; // 该项是否有效 + public byte byType; // 见定义NET_DVR_PLAN_OPERATE_TYPE + public short wLayoutNo; // 布局号 + public byte byScreenStyle; //屏幕型号,开关机所用,1是低亮,2是高亮 + public byte byBaseMapType; //底图类型,1-图片底图,2-超高清输入底图,底图切换时有效 + public byte[] byRes1 = new byte[2]; + public int dwDelayTime; // 一个项的运行时间, 单位秒 + public int dwSerialNo; //串口号,屏幕控制时使用 + public int dwBaseMapWndNo; //底图窗口号,底图切换时有效 + public int dwBaseMapNo; //底图号,底图切换时有效;底图类型为1时,此参数为图片序号,底图类型为2时此参数为超高清输入子系统输入号(1字节设备号+1字节子板号+2字节显示输入序号) + public byte[] byRes2 = new byte[20]; + } + + public static class NET_DVR_CYCLE_TIME extends Structure { + public byte byValid; + public byte[] byRes = new byte[3]; + public NET_DVR_TIME_EX struTime = new NET_DVR_TIME_EX(); + } + + /*预案管理*/ + public static class NET_DVR_PLAN_CFG extends Structure { + public int dwSize; + public byte byValid; // 该预案是否有效 + public byte byWorkMode; // 预案工作模式 1表示手动,2自动,3预案循环 + public byte byWallNo; //电视墙号,从1开始 + public byte byPlanNo; //预案号,获取预案列表时有效,0-无效或不支持 + public byte[] byPlanName = new byte[NAME_LEN/*32*/]; //预案名称 + public NET_DVR_TIME_EX struTime; // 工作模式为自动时使用 + public NET_DVR_CYCLE_TIME[] struTimeCycle = new NET_DVR_CYCLE_TIME[DAYS_A_WEEK/*7*/]; /*循环时间,周期为一个星期,年、月、日三个参数不使用。如:struTimeCycle[0]中的byValid的值是1,表示星期天执行该预案。星期取值区间为[0,6],其中0代表星期天,1代表星期一,以此类推*/ + public int dwWorkCount; // 预案内容执行次数 + public NET_DVR_PLAN_INFO[] strPlanEntry = new NET_DVR_PLAN_INFO[MAX_PLAN_ACTION_NUM/*32*/]; // 预案执行的内容 + public int dwPlanNo; //4字节预案号,客户端统一使用4字节的预案号,单字节的预案号不再使用 + public byte[] byRes2 = new byte[60]; + } + + public static class NET_DVR_WALLSCENECFG extends Structure { + public int dwSize; + public byte[] sSceneName = new byte[NAME_LEN]; //场景名称 + public byte byEnable; //场景是否有效,0-无效,1-有效 + public byte bySceneIndex; //场景号,只能获取。获取所有场景时使用该参数 + public byte[] byRes = new byte[78]; + } + + public static class NET_DVR_SUBWND_DECODE_OSD extends Structure { + public int dwSize = 0; + public int dwSubWndNo = 0; //子窗口号(4字节组合方式) + public int dwOSDNums = 0; //该子窗口配置的OSD信息的个数 + public NET_DVR_OSD_INFO[] struOSDList = new NET_DVR_OSD_INFO[MAX_NUM_OSD_ONE_SUBWND]; //OSD信息列表 + public byte[] byRes = new byte[32]; + } + + public static class NET_DVR_OSD_INFO extends Structure { + public byte byEnabled = 1; //是否使能,零-不使能,非零-使能 + public byte byEnabledFlash = 0; //是否闪烁,零-不闪烁,非零-闪烁 + public byte byFontSize = 1; //字体大小,1-大,2-中,3-小 + public byte byTransparent = 0; //透明度,取值范围0-100 + public NET_DVR_RGB_COLOR struColor = new NET_DVR_RGB_COLOR(); //字体颜色 + public short wCoordinateX = 0; //OSD左上角X坐标 + public short wCoordinateY = 0; //OSD左上角Y坐标 + public byte[] byContent = new byte[MAX_LEN_OSD_CONTENT]; //OSD信息 + public byte[] byRes = new byte[32]; + } + + public static class NET_DVR_DEV_CHAN_INFO_EX extends Structure { + public byte byChanType; //通道类型,0-普通通道,1-零通道,2-流ID,3-本地输入源,4-虚拟屏服务器通道,5-拼接通道,6-屏幕服务器,7-分布式网络源,8-多相机融合通道,9-网络输入源 + public byte[] byStreamId = new byte[STREAM_ID_LEN]; //流ID,当byChanType=2、9时,该字段用于指定流或者网络ipc的ID号 + public byte[] byRes1 = new byte[3]; + public int dwChannel; //通道号,通道类型为普通通道,零通道,本地输入源,虚拟屏服务器通道,拼接通道,屏幕服务器,分布式网络源时填此字段 + public byte[] byRes2 = new byte[24]; + public byte[] byAddress = new byte[MAX_DOMAIN_NAME]; //设备域名 + public short wDVRPort; //端口号 + public byte byChannel; //通道号,dwChannel不为0时此字段无效 + public byte byTransProtocol; //传输协议类型0-TCP,1-UDP + public byte byTransMode; //传输码流模式 0-主码流 1-子码流 + public byte byFactoryType; /*前端设备厂家类型,通过接口获取*/ + public byte byDeviceType; //设备类型(视频综合平台智能板使用),1-解码器(此时根据视频综合平台能力集中byVcaSupportChanMode字段来决定是使用解码通道还是显示通道),2-编码器 + public byte byDispChan;//显示通道号,智能配置使用 + public byte bySubDispChan;//显示通道子通道号,智能配置时使用 + public byte byResolution; //; 1-CIF 2-4CIF 3-720P 4-1080P 5-500w大屏控制器使用,大屏控制器会根据该参数分配解码资源 + public byte[] byRes = new byte[2]; + public byte[] sUserName = new byte[NAME_LEN]; //布防主机登陆帐号 + public byte[] sPassword = new byte[PASSWD_LEN]; //布防主机密码 + } + + public static class NET_DVR_STREAM_MEDIA_SERVER extends Structure { + public byte byValid; //是否启用,0-否,1-是 + public byte[] byRes1 = new byte[3]; + public byte[] byAddress = new byte[MAX_DOMAIN_NAME]; //IP或者域名 + public short wDevPort; /*流媒体服务器端口*/ + public byte byTransmitType; /*传输协议类型 0-TCP,1-UDP*/ + public byte[] byRes2 = new byte[5]; + } + + public static class NET_DVR_DEV_DDNS_INFO extends Structure { + public byte[] byDevAddress = new byte[MAX_DOMAIN_NAME]; //域名(IPServer或hiDDNS时可填序列号或者别名) + public byte byTransProtocol; //传输协议类型0-TCP,1-UDP, 2-MCAST + public byte byTransMode; //传输码流模式 0-主码流 1-子码流 + public byte byDdnsType; //域名服务器类型,0-IPServer 1-Dyndns 2-PeanutHull(花生壳),3- NO-IP, 4- hiDDNS + public byte byRes1; + public byte[] byDdnsAddress = new byte[MAX_DOMAIN_NAME]; //DDNS服务器地址 + public short wDdnsPort; //DDNS服务器端口号 + public byte byChanType; //0-普通通道,1-零通道,2-流ID + public byte byFactoryType; //前端设备厂家类型,通过接口获取 + public int dwChannel; //通道号 + public byte[] byStreamId = new byte[STREAM_ID_LEN]; //流ID + public byte[] sUserName = new byte[NAME_LEN]; //布防主机登陆帐号 + public byte[] sPassword = new byte[PASSWD_LEN]; //布防主机密码 + public short wDevPort; //前端设备通信端口 + public byte[] byRes2 = new byte[2]; + } + + public static class NET_DVR_DEC_STREAM_DEV_EX extends Structure { + public NET_DVR_STREAM_MEDIA_SERVER struStreamMediaSvrCfg = new NET_DVR_STREAM_MEDIA_SERVER(); + public NET_DVR_DEV_CHAN_INFO_EX struDevChanInfo = new NET_DVR_DEV_CHAN_INFO_EX(); + } + + //DDNS方式取流 + public static class NET_DVR_DEC_DDNS_DEV extends Structure { + public NET_DVR_DEV_DDNS_INFO struDdnsInfo; + public NET_DVR_STREAM_MEDIA_SERVER struMediaServer; + } + + public static class NET_DVR_DEC_STREAM_MODE extends Union { + public NET_DVR_DEC_STREAM_DEV_EX struDecStreamDev = new NET_DVR_DEC_STREAM_DEV_EX(); + public NET_DVR_PU_STREAM_URL struUrlInfo = new NET_DVR_PU_STREAM_URL(); + public NET_DVR_DEC_DDNS_DEV struDdnsDecInfo = new NET_DVR_DEC_DDNS_DEV(); + public byte[] byRes = new byte[300]; + } + + public static class NET_DVR_MATRIX_CHAN_INFO_V41 extends Structure { + public byte byEnable; //是否启用,0-否,1-是 + public byte byStreamMode;/*取流模式,0-无效,1-通过IP或域名取流,2-通过URL取流,3-通过动态域名解析向设备取流*/ + public byte[] byRes = new byte[2]; + public NET_DVR_DEC_STREAM_MODE uDecStreamMode = new NET_DVR_DEC_STREAM_MODE();//取流信息 + } + + public static class NET_DVR_MATRIX_LOOP_DECINFO_V41 extends Structure { + public int dwSize; + public int dwPoolTime; /*轮巡间隔*/ + public NET_DVR_MATRIX_CHAN_INFO_V41[] struchanConInfo = new NET_DVR_MATRIX_CHAN_INFO_V41[MAX_CYCLE_CHAN_V30]; + public byte byStreamEncrypt; //是否进行码流加密处理,0-不支持,1-支持 + public byte[] byRes = new byte[3]; + public byte[] sStreamPassword = new byte[STREAM_PASSWD_LEN]; //码流加密密码,需敏感信息加密 + } + + /************************************ + * 拼控(End) + ***************************************/ + + public static class NET_DVR_EMAILCFG extends Structure { /* 12 bytes */ + public int dwSize; + public byte[] sUserName = new byte[32]; + public byte[] sPassWord = new byte[32]; + public byte[] sFromName = new byte[32]; /* Sender *///字符串中的第一个字符和最后一个字符不能是"@",并且字符串中要有"@"字符 + public byte[] sFromAddr = new byte[48]; /* Sender address */ + public byte[] sToName1 = new byte[32]; /* Receiver1 */ + public byte[] sToName2 = new byte[32]; /* Receiver2 */ + public byte[] sToAddr1 = new byte[48]; /* Receiver address1 */ + public byte[] sToAddr2 = new byte[48]; /* Receiver address2 */ + public byte[] sEmailServer = new byte[32]; /* Email server address */ + public byte byServerType; /* Email server type: 0-SMTP, 1-POP, 2-IMTP…*/ + public byte byUseAuthen; /* Email server authentication method: 1-enable, 0-disable */ + public byte byAttachment; /* enable attachment */ + public byte byMailinterval; /* mail interval 0-2s, 1-3s, 2-4s. 3-5s*/ + } + + public static class NET_DVR_COMPRESSIONCFG_NEW extends Structure { + public int dwSize; + public NET_DVR_COMPRESSION_INFO_EX struLowCompression; //定šš时录像 + public NET_DVR_COMPRESSION_INFO_EX struEventCompression; //事件触发录像 + } + + //球机位置信息 + public static class NET_DVR_PTZPOS extends Structure { + public short wAction;//获取时该字段无效 + public short wPanPos;//水平参数 + public short wTiltPos;//垂直参数 + public short wZoomPos;//变倍参数 + } + + //球机范围信息 + public static class NET_DVR_PTZSCOPE extends Structure { + public short wPanPosMin;//水平参数min + public short wPanPosMax;//水平参数max + public short wTiltPosMin;//垂直参数min + public short wTiltPosMax;//垂直参数max + public short wZoomPosMin;//变倍参数min + public short wZoomPosMax;//变倍参数max + } + + public static class NET_DVR_PTZABSOLUTEEX_CFG extends Structure { + public int dwSize;//结构体大小 + public NET_PTZ_INFO struPTZCtrl = new NET_PTZ_INFO();//设备PTZF信息 + public int dwFocalLen;//焦距范围:0-100000MM + public float fHorizontalSpeed;//水平转动速度:0.01-1000.00度/S + public float fVerticalSpeed;//垂直转动速度:0.01-1000.00度/S + /*镜头变倍配置类型;absoluteZoom:通过变倍参数进行配置,选择为该类型时struPTZCtrl中的fZoom参数生效。focalLen:通过焦距参数进行配置,选择为该类型时,dwFocalLen参数生效。*/ + public byte byZoomType;// 镜头变倍配置类型0~ absoluteZoom,1~ focalLen + public byte[] byRes = new byte[123]; + } + + //rtsp配置 ipcamera专用 + public static class NET_DVR_RTSPCFG extends Structure { + public int dwSize; //长度 + public short wPort; //rtsp服务器侦听端口 + public byte[] byReserve = new byte[54]; //预留 + } + + /******************************** + * 接口参数结构(begin) + *********************************/ + +//NET_DVR_Login()参数结构 + public static class NET_DVR_DEVICEINFO extends Structure { + public byte[] sSerialNumber = new byte[SERIALNO_LEN]; //序列号 + public byte byAlarmInPortNum; //DVR报警输入个数 + public byte byAlarmOutPortNum; //DVR报警输出个数 + public byte byDiskNum; //DVR硬盘个数 + public byte byDVRType; //DVR类型, 1:DVR 2:ATM DVR 3:DVS ...... + public byte byChanNum; //DVR 通道个数 + public byte byStartChan; //起始通道号,例如DVS-1,DVR - 1 + } + + //NET_DVR_Login_V30()参数结构 + public static class NET_DVR_DEVICEINFO_V30 extends Structure { + public byte[] sSerialNumber = new byte[SERIALNO_LEN]; //序列号 + public byte byAlarmInPortNum; //报警输入个数 + public byte byAlarmOutPortNum; //报警输出个数 + public byte byDiskNum; //硬盘个数 + public byte byDVRType; //设备类型, 1:DVR 2:ATM DVR 3:DVS ...... + public byte byChanNum; //模拟通道个数 + public byte byStartChan; //起始通道号,例如DVS-1,DVR - 1 + public byte byAudioChanNum; //语音通道数 + public byte byIPChanNum; //最大数字通道个数,低位 + public byte byZeroChanNum; //零通道编码个数 //2010-01-16 + public byte byMainProto; //主码流传输协议类型 0-private, 1-rtsp,2-同时支持private和rtsp + public byte bySubProto; //子码流传输协议类型0-private, 1-rtsp,2-同时支持private和rtsp + public byte bySupport; //能力,位与结果为0表示不支持,1表示支持, + public byte bySupport1; // 能力集扩充,位与结果为0表示不支持,1表示支持 + public byte bySupport2; /*能力*/ + public short wDevType; //设备型号 + public byte bySupport3; //能力集扩展 + public byte byMultiStreamProto;//是否支持多码流,按位表示,0-不支持,1-支持,bit1-码流3,bit2-码流4,bit7-主码流,bit-8子码流 + public byte byStartDChan; //起始数字通道号,0表示无效 + public byte byStartDTalkChan; //起始数字对讲通道号,区别于模拟对讲通道号,0表示无效 + public byte byHighDChanNum; //数字通道个数,高位 + public byte bySupport4; //能力集扩展 + public byte byLanguageType;// 支持语种能力,按位表示,每一位0-不支持,1-支持 + // byLanguageType 等于0 表示 老设备 + // byLanguageType & 0x1表示支持中文 + // byLanguageType & 0x2表示支持英文 + public byte byVoiceInChanNum; //音频输入通道数 + public byte byStartVoiceInChanNo; //音频输入起始通道号 0表示无效 + public byte bySupport5; + public byte bySupport6; //能力 + public byte byMirrorChanNum; //镜像通道个数,<录播主机中用于表示导播通道> + public short wStartMirrorChanNo; //起始镜像通道号 + public byte bySupport7; //能力 + public byte byRes2; //保留 + } + + public static final int NET_DVR_DEV_ADDRESS_MAX_LEN = 129; + public static final int NET_DVR_LOGIN_USERNAME_MAX_LEN = 64; + public static final int NET_DVR_LOGIN_PASSWD_MAX_LEN = 64; + + public static interface FLoginResultCallBack extends Callback { + public int invoke(int lUserID, int dwResult, NET_DVR_DEVICEINFO_V30 lpDeviceinfo, Pointer pUser); + } + + //NET_DVR_Login_V40()参数 + public static class NET_DVR_USER_LOGIN_INFO extends Structure { + public byte[] sDeviceAddress = new byte[NET_DVR_DEV_ADDRESS_MAX_LEN]; + public byte byUseTransport; + public short wPort; + public byte[] sUserName = new byte[NET_DVR_LOGIN_USERNAME_MAX_LEN]; + public byte[] sPassword = new byte[NET_DVR_LOGIN_PASSWD_MAX_LEN]; + public FLoginResultCallBack cbLoginResult; + public Pointer pUser; + public boolean bUseAsynLogin; + public byte byProxyType; //0:不使用代理,1:使用标准代理,2:使用EHome代理 + public byte byUseUTCTime; //0-不进行转换,默认,1-接口上输入输出全部使用UTC时间,SDK完成UTC时间与设备时区的转换,2-接口上输入输出全部使用平台本地时间,SDK完成平台本地时间与设备时区的转换 + public byte byLoginMode; //0-Private 1-ISAPI 2-自适应 + public byte byHttps; //0-不适用tls,1-使用tls 2-自适应 + public int iProxyID; //代理服务器序号,添加代理服务器信息时,相对应的服务器数组下表值 + public byte byVerifyMode; //认证方式,0-不认证,1-双向认证,2-单向认证;认证仅在使用TLS的时候生效; + public byte[] byRes2 = new byte[119]; + } + + //NET_DVR_Login_V40()参数 + public static class NET_DVR_DEVICEINFO_V40 extends Structure { + public NET_DVR_DEVICEINFO_V30 struDeviceV30 = new NET_DVR_DEVICEINFO_V30(); + public byte bySupportLock; + public byte byRetryLoginTime; + public byte byPasswordLevel; + public byte byRes1; + public int dwSurplusLockTime; + public byte byCharEncodeType;//字符编码类型:0- 无字符编码信息(老设备),1- GB2312(简体中文),2- GBK,3- BIG5(繁体中文),4- Shift_JIS(日文),5- EUC-KR(韩文),6- UTF-8,7- ISO8859-1,8- ISO8859-2,9- ISO8859-3,…,依次类推,21- ISO8859-15(西欧) + public byte bySupportDev5; //支持v50版本的设备参数获取,设备名称和设备类型名称长度扩展为64字节 + public byte bySupport; //能力集扩展,位与结果:0- 不支持,1- 支持 + public byte byLoginMode; //登录模式 0-Private登录 1-ISAPI登录 + public int dwOEMCode; + public int iResidualValidity; //该用户密码剩余有效天数,单位:天,返回负值,表示密码已经超期使用,例如“-3表示密码已经超期使用3天” + public byte byResidualValidity; // iResidualValidity字段是否有效,0-无效,1-有效 + public byte bySingleStartDTalkChan; //独立音轨接入的设备,起始接入通道号,0-为保留字节,无实际含义,音轨通道号不能从0开始 + public byte bySingleDTalkChanNums; //独立音轨接入的设备的通道总数,0-表示不支持 + public byte byPassWordResetLevel; //0-无效,1-管理员创建一个非管理员用户为其设置密码,该非管理员用户正确登录设备后要提示“请修改初始登录密码”,未修改的情况下,用户每次登入都会进行提醒;2-当非管理员用户的密码被管理员修改,该非管理员用户再次正确登录设备后,需要提示“请重新设置登录密码”,未修改的情况下,用户每次登入都会进行提醒。 + public byte bySupportStreamEncrypt; //能力集扩展,位与结果:0- 不支持,1- 支持 bySupportStreamEncrypt & 0x1:表示是否支持RTP/TLS取流 bySupportStreamEncrypt & 0x2: 表示是否支持SRTP/UDP取流 bySupportStreamEncrypt & 0x4: 表示是否支持SRTP/MULTICAST取流 + public byte byMarketType;//0-无效(未知类型),1-经销型,2-行业型 + public byte[] byRes2 = new byte[238]; + } + + //sdk网络环境枚举变量,用于远程升级 + enum _SDK_NET_ENV { + LOCAL_AREA_NETWORK, + WIDE_AREA_NETWORK + } + + //显示模式 + enum DISPLAY_MODE { + NORMALMODE, + OVERLAYMODE + } + + //发送模式 + enum SEND_MODE { + PTOPTCPMODE, + PTOPUDPMODE, + MULTIMODE, + RTPMODE, + RESERVEDMODE + } + + ; + + //抓图模式 + enum CAPTURE_MODE { + BMP_MODE, //BMP模式 + JPEG_MODE //JPEG模式 + } + + ; + + //实时声音模式 + enum REALSOUND_MODE { + NONE, //SDK中无此模式,只是为了填补0这个位置 + MONOPOLIZE_MODE, //独占模式 1 + SHARE_MODE //共享模式 2 + } + + ; + + //软解码预览参数 + public static class NET_DVR_CLIENTINFO extends Structure { + public int lChannel; + public int lLinkMode; + public int hPlayWnd; + public String sMultiCastIP; + } + + //预览V40接口 + public static class NET_DVR_PREVIEWINFO extends Structure { + public int lChannel;//通道号 + public int dwStreamType; // 码流类型,0-主码流,1-子码流,2-码流3,3-码流4, 4-码流5,5-码流6,7-码流7,8-码流8,9-码流9,10-码流10 + public int dwLinkMode;// 0:TCP方式,1:UDP方式,2:多播方式,3 - RTP方式,4-RTP/RTSP,5-RSTP/HTTP ,6- HRUDP(可靠传输) ,7-RTSP/HTTPS + public HWND hPlayWnd;//播放窗口的句柄,为NULL表示不播放图象 + public int bBlocked; //0-非阻塞取流, 1-阻塞取流, 如果阻塞SDK内部connect失败将会有5s的超时才能够返回,不适合于轮询取流操作. + public int bPassbackRecord; //0-不启用录像回传,1启用录像回传 + public byte byPreviewMode;//预览模式,0-正常预览,1-延迟预览 + public byte[] byStreamID = new byte[32];//流ID,lChannel为0xffffffff时启用此参数 + public byte byProtoType; //应用层取流协议,0-私有协议,1-RTSP协议 + public byte byRes1; + public byte byVideoCodingType; //码流数据编解码类型 0-通用编码数据 1-热成像探测器产生的原始数据(温度数据的加密信息,通过去加密运算,将原始数据算出真实的温度值) + public int dwDisplayBufNum; //播放库播放缓冲区最大缓冲帧数,范围1-50,置0时默认为1 + public byte byNPQMode; //NPQ是直连模式,还是过流媒体 0-直连 1-过流媒体 + public byte[] byRes = new byte[215]; + } + + public static class NET_DVR_STREAM_INFO extends Structure { + public int dwSize; + public byte[] byID = new byte[32]; + public int dwChannel; + public byte[] byRes = new byte[32]; + } + + //配置条件 + public static class NET_DVR_CLOUDSTORAGE_COND extends Structure { + public int dwSize; + public int dwChannel; + public byte[] byRes1 = new byte[64]; + } + + public static class NET_DVR_STREAM_RECORD_STATUS extends Structure { + public int dwSize; + public byte byRecord; + public byte byOffLineRecord; + public byte[] byRes1 = new byte[2]; + public int dwRelatedHD; + public byte[] byRes2 = new byte[8]; + } + + //SDK状态信息(9000新增) + public static class NET_DVR_SDKSTATE extends Structure { + public int dwTotalLoginNum; //当前login用户数 + public int dwTotalRealPlayNum; //当前realplay路数 + public int dwTotalPlayBackNum; //当前回放或下载路数 + public int dwTotalAlarmChanNum; //当前建立报警通道路数 + public int dwTotalFormatNum; //当前硬盘格式化路数 + public int dwTotalFileSearchNum; //当前日志或文件搜索路数 + public int dwTotalLogSearchNum; //当前日志或文件搜索路数 + public int dwTotalSerialNum; //当前透明通道路数 + public int dwTotalUpgradeNum; //当前升级路数 + public int dwTotalVoiceComNum; //当前语音转发路数 + public int dwTotalBroadCastNum; //当前语音广播路数 + public int[] dwRes = new int[10]; + } + + //SDK功能支持信息(9000新增) + public static class NET_DVR_SDKABL extends Structure { + public int dwMaxLoginNum; //最大login用户数 MAX_LOGIN_USERS + public int dwMaxRealPlayNum; //最大realplay路数 WATCH_NUM + public int dwMaxPlayBackNum; //最大回放或下载路数 WATCH_NUM + public int dwMaxAlarmChanNum; //最大建立报警通道路数 ALARM_NUM + public int dwMaxFormatNum; //最大硬盘格式化路数 SERVER_NUM + public int dwMaxFileSearchNum; //最大文件搜索路数 SERVER_NUM + public int dwMaxLogSearchNum; //最大日志搜索路数 SERVER_NUM + public int dwMaxSerialNum; //最大透明通道路数 SERVER_NUM + public int dwMaxUpgradeNum; //最大升级路数 SERVER_NUM + public int dwMaxVoiceComNum; //最大语音转发路数 SERVER_NUM + public int dwMaxBroadCastNum; //最大语音广播路数 MAX_CASTNUM + public int[] dwRes = new int[10]; + } + + //报警设备信息 + public static class NET_DVR_ALARMER extends Structure { + public byte byUserIDValid; /* userid是否有效 0-无效,1-有效 */ + public byte bySerialValid; /* 序列号是否有效 0-无效,1-有效 */ + public byte byVersionValid; /* 版本号是否有效 0-无效,1-有效 */ + public byte byDeviceNameValid; /* 设备名字是否有效 0-无效,1-有效 */ + public byte byMacAddrValid; /* MAC地址是否有效 0-无效,1-有效 */ + public byte byLinkPortValid; /* login端口是否有效 0-无效,1-有效 */ + public byte byDeviceIPValid; /* 设备IP是否有效 0-无效,1-有效 */ + public byte bySocketIPValid; /* socket ip是否有效 0-无效,1-有效 */ + public int lUserID; /* NET_DVR_Login()返回值, 布防时有效 */ + public byte[] sSerialNumber = new byte[SERIALNO_LEN]; /* 序列号 */ + public int dwDeviceVersion; /* 版本信息 高16位表示主版本,低16位表示次版本*/ + public byte[] sDeviceName = new byte[NAME_LEN]; /* 设备名字 */ + public byte[] byMacAddr = new byte[MACADDR_LEN]; /* MAC地址 */ + public short wLinkPort; /* link port */ + public byte[] sDeviceIP = new byte[128]; /* IP地址 */ + public byte[] sSocketIP = new byte[128]; /* 报警主动上传时的socket IP地址 */ + public byte byIpProtocol; /* Ip协议 0-IPV4, 1-IPV6 */ + public byte[] byRes2 = new byte[11]; + + + } + + //硬解码显示区域参数(子结构) + public static class NET_DVR_DISPLAY_PARA extends Structure { + public int bToScreen; + public int bToVideoOut; + public int nLeft; + public int nTop; + public int nWidth; + public int nHeight; + public int nReserved; + } + + //硬解码预览参数 + public static class NET_DVR_CARDINFO extends Structure { + public int lChannel;//通道号 + public int lLinkMode; //最高位(31)为0表示主码流,为1表示子,0-30位表示码流连接方式:0:TCP方式,1:UDP方式,2:多播方式,3 - RTP方式,4-电话线,5-128k宽带,6-256k宽带,7-384k宽带,8-512k宽带; + public String sMultiCastIP; + public NET_DVR_DISPLAY_PARA struDisplayPara; + } + + //录象文件参数 + public static class NET_DVR_FIND_DATA extends Structure { + public byte[] sFileName = new byte[100];//文件名 + public NET_DVR_TIME struStartTime;//文件的开始时间 + public NET_DVR_TIME struStopTime;//文件的结束时间 + public int dwFileSize;//文件的大小 + } + + //录象文件参数(9000) + public static class NET_DVR_FINDDATA_V30 extends Structure { + public byte[] sFileName = new byte[100];//文件名 + public NET_DVR_TIME struStartTime;//文件的开始时间 + public NET_DVR_TIME struStopTime;//文件的结束时间 + public int dwFileSize;//文件的大小 + public byte[] sCardNum = new byte[32]; + public byte byLocked;//9000设备支持,1表示此文件已经被锁定,0表示正常的文件 + public byte[] byRes = new byte[3]; + } + + //录象文件参数(带卡号) + public static class NET_DVR_FINDDATA_CARD extends Structure { + public byte[] sFileName = new byte[100];//文件名 + public NET_DVR_TIME struStartTime;//文件的开始时间 + public NET_DVR_TIME struStopTime;//文件的结束时间 + public int dwFileSize;//文件的大小 + public byte[] sCardNum = new byte[32]; + } + + public static class NET_DVR_FILECOND_V40 extends Structure { + public int lChannel; + public int dwFileType; + public int dwIsLocked; + public int dwUseCardNo;//是否带ATM信息进行查询:0-不带ATM信息,1-按交易卡号查询,2-按交易类型查询,3-按交易金额查询,4-按卡号、交易类型及交易金额的组合查询 5-按课程名称查找,此时卡号表示课程名称 + public byte[] sCardNumber = new byte[CARDNUM_LEN_OUT]; + public NET_DVR_TIME struStartTime = new NET_DVR_TIME(); + public NET_DVR_TIME struStopTime = new NET_DVR_TIME(); + public byte byDrawFrame; //0:不抽帧,1:抽帧 + public byte byFindType; //0:查询普通卷,1:查询存档卷 + public byte byQuickSearch; //0:普通查询,1:快速(日历)查询 + public byte bySpecialFindInfoType; //专有查询条件类型 0-无效, 1-带ATM查询条件 + public int dwVolumeNum; //存档卷号 + public byte[] byWorkingDeviceGUID = new byte[GUID_LEN]; //工作机GUID,通过获取N+1得到 + public NET_DVR_SPECIAL_FINDINFO_UNION uSpecialFindInfo = new NET_DVR_SPECIAL_FINDINFO_UNION(); //专有查询条件 + public byte byStreamType; //0-同一个时间段只返回一种录像,优先级顺序为:主码流、子码流、三码流,1-子码流,2-三码流,3-主码流,254-双码流搜索(优先返回主码流录像,没有主码流录像时返回子码流录像) + public byte byAudioFile; //音频文件 0-非音频文件,1-音频文件 + public byte[] byRes2 = new byte[30]; //保留 + } + + public static class NET_DVR_SPECIAL_FINDINFO_UNION extends Union { + public byte[] byLenth = new byte[8]; + public NET_DVR_ATMFINDINFO struATMFindInfo = new NET_DVR_ATMFINDINFO(); //ATM查询 + } + + public static class NET_DVR_ATMFINDINFO extends Structure { + public byte byTransactionType; //交易类型 0-全部,1-查询, 2-取款, 3-存款, 4-修改密码,5-转账, 6-无卡查询 7-无卡存款, 8-吞钞 9-吞卡 10-自定义 + public byte[] byRes = new byte[3]; //保留 + public int dwTransationAmount; //交易金额 ; + } + + //录像文件查找条件结构V50 + public static class NET_DVR_FILECOND_V50 extends Structure { + public NET_DVR_STREAM_INFO struStreamID; //流ID或通道号 + public NET_DVR_TIME_SEARCH_COND struStartTime = new NET_DVR_TIME_SEARCH_COND(); //开始时间 + public NET_DVR_TIME_SEARCH_COND struStopTime = new NET_DVR_TIME_SEARCH_COND(); //结束时间 + public byte byFindType; //0-查询普通卷,1-查询存档卷 2-查询N+1录像文件 + public byte byDrawFrame; //是否抽帧 0-不抽帧 1-抽帧 + public byte byQuickSearch; //0-普通查询,1-快速(日历)查询 + public byte byStreamType; //0-主码流,1-子码流,2-3码流,0xff-全部 + public int dwFileType; // 文件类型 + public int dwVolumeNum; //存档卷号,byFindType为1时有效 + public byte byIsLocked; //是否锁定 0-正常文件,1-锁定文件, 0xff表示所有文件 + public byte byNeedCard; //是否需要查询卡,0-不需要 1-需要 + public byte byOnlyAudioFile; //音频文件 0-视频文件 1-音频文件 + public byte bySpecialFindInfoType; //0-无效, 1-带ATM查询条件 + public byte[] szCardNum = new byte[32]; //卡号,byNeedCard为1时有效 + public byte[] szWorkingDeviceGUID = new byte[16]; //工作机GUID,通过获取N+1得到,byFindType为2时有效 + public NET_DVR_SPECIAL_FINDINFO_UNION uSpecialFindInfo = new NET_DVR_SPECIAL_FINDINFO_UNION(); //专有查询条件联合体 + public int dwTimeout; //查找超时时间(指定NET_DVR_FindNextFile_V30/NET_DVR_FindNextFile_V40/NET_DVR_FindNextFile_V50接口的超时时间返回);单位:毫秒,不填写(默认为0时),接口行为跟以前一样 ;有效值:0, [5000 – 15000] + public byte[] byRes = new byte[252]; + } + + public static class NET_DVR_FINDDATA_V40 extends Structure { + public byte[] sFileName = new byte[100];//文件名 + public NET_DVR_TIME struStartTime = new NET_DVR_TIME();//文件的开始时间 + public NET_DVR_TIME struStopTime = new NET_DVR_TIME();//文件的结束时间 + public int dwFileSize;//文件的大小 + public byte[] sCardNum = new byte[32]; + public byte byLocked;//9000设备支持,1表示此文件已经被锁定,0表示正常的文件 + public byte byFileType; //文件类型:0-定时录像,1-移动侦测 ,2-报警触发, + //3-报警|移动侦测 4-报警&移动侦测 5-命令触发 6-手动录像,7-震动报警,8-环境报警,9-智能报警,10-PIR报警,11-无线报警,12-呼救报警,14-智能交通事件 + public byte byQuickSearch; //0:普通查询结果,1:快速(日历)查询结果 + public byte byRes; + public int dwFileIndex; //文件索引号 + public byte byStreamType; + public byte[] byRes1 = new byte[127]; + } + + public static class NET_DVR_TIME_SEARCH extends Structure { + public short wYear; //年,设备OSD时间 + public byte byMonth; //月,设备OSD时间 + public byte byDay; //日,设备OSD时间 + public byte byHour; //时,设备OSD时间 + public byte byMinute; //分,设备OSD时间 + public byte bySecond; //秒,设备OSD时间 + public byte cTimeDifferenceH; //与国际标准时间的时差(小时),-12 ... +14 + public byte cTimeDifferenceM; //与国际标准时间的时差(分钟),-30, 0, 30, 45 + public byte byLocalOrUTC; //0-时差无效,设备本地时间,即设备OSD时间 1-时差有效 + public short wMillisecond; //毫秒,精度不够,默认为0 + } + + public static class NET_DVR_ADDRESS extends Structure { + public NET_DVR_IPADDR struIP = new NET_DVR_IPADDR(); //IP地址 + public short wPort; //端口号 + public byte[] byRes = new byte[2]; + } + + public static class NET_DVR_FINDDATA_V50 extends Structure { + public byte[] sFileName = new byte[100]; + public NET_DVR_TIME_SEARCH struStartTime = new NET_DVR_TIME_SEARCH(); + public NET_DVR_TIME_SEARCH struStopTime = new NET_DVR_TIME_SEARCH(); + public NET_DVR_ADDRESS struAddr = new NET_DVR_ADDRESS(); //片段所在的地址信息,集群回放时用到 + public int dwFileSize; //文件大小 + public byte byLocked; //文件是否被锁定,1-文件已锁定;0-文件未锁定 + public byte byFileType; //文件类型,与V40相同 + public byte byQuickSearch; //0- 普通查询结果,1- 快速(日历)查询结果 + public byte byStreamType; //码流类型:0- 主码流,1- 子码流,2- 码流三 + public int dwFileIndex; //文件索引号 + public byte[] sCardNum = new byte[32]; //卡号 + public int dwTotalLenH; // 对于大文件搜索,时间段内数据总长度,高32字节 + public int dwTotalLenL; // 对于大文件搜索,时间段内数据总长度,低32字节 + public byte byBigFileType; // 0为普通片段搜索,1为大文件搜索 + public byte[] byRes = new byte[247]; + } + + public static class NET_DVR_FILECOND extends Structure //录象文件查找条件结构 + { + public int lChannel;//通道号 + public int dwFileType;//录象文件类型0xff-全部,0-定时录像,1-移动侦测 ,2-报警触发,3-报警|移动侦测 4-报警&移动侦测 5-命令触发 6-手动录像 + public int dwIsLocked;//是否锁定 0-正常文件,1-锁定文件, 0xff表示所有文件 + public int dwUseCardNo;//是否使用卡号 + public byte[] sCardNumber = new byte[32];//卡号 + public NET_DVR_TIME struStartTime;//开始时间 + public NET_DVR_TIME struStopTime;//结束时间 + } + + public static class NET_DVR_PLAYCOND extends Structure //回放或者下载信息结构体 + { + public int dwChannel;//通道号 + public NET_DVR_TIME struStartTime; + public NET_DVR_TIME struStopTime; + public byte byDrawFrame; //0:不抽帧,1:抽帧 + public byte byStreamType; //码流类型,0-主码流 1-子码流 2-码流三 + public byte[] byStreamID = new byte[STREAM_ID_LEN]; + public byte[] byRes = new byte[30];//保留 + } + + public static class NET_DVR_VOD_PARA extends Structure //回放或者下载信息结构体 + { + public int dwSize; + public NET_DVR_STREAM_INFO struIDInfo; + public NET_DVR_TIME struBeginTime; + public NET_DVR_TIME struEndTime; + public HWND hWnd; + public byte byDrawFrame; //0:不抽帧,1:抽帧 + public byte byVolumeType; //0-普通录像卷 1-存档卷 + public byte byVolumeNum; //卷号,目前指存档卷号 + public byte byStreamType; //码流类型 0-主码流, 1-子码流,2-码流三 + public int dwFileIndex; //存档卷上的录像文件索引,搜索存档卷录像时返回的值 + public byte byAudioFile; //音频文件0-否,1-是 + public byte byCourseFile; //课程文件0-否,1-是 + public byte byDownload; //是否下载 0-否,1-是 + public byte byOptimalStreamType; //是否按最优码流类型回放 0-否,1-是(对于双码流设备,某一段时间内的录像文件与指定码流类型不同,则返回实际码流类型的录像) + public byte[] byRes2 = new byte[20]; + } + + //图片查找条件 + public static class NET_DVR_FIND_PICTURE_PARAM extends Structure { + public int dwSize; // 结构体大小 + public int lChannel; // 通道号 + public byte byFileType; //图片查找类型 + public byte byNeedCard; // 是否需要卡号 + /* + 0-保留,1-澳,2-京,3-渝,4-闽,5-甘,6-粤,7-桂, + 8-贵,9-琼,10-冀,11-豫,12-黑,13-鄂,14-湘, + 15-吉,16-苏,17-赣,18-辽,19-蒙,20-宁,21-青, + 22-鲁,23-晋,24-陕,25-沪,26-川,27-台,28-津, + 29-藏,30-港,31-新,32-云,33-浙,34-皖,0xff-全部 + */ + public byte byProvince; //省份索引值 + public byte byEventType; // 事件类型:0保留,1-交通事件;2-违章取证;3-其他事件 + public byte[] sCardNum = new byte[CARDNUM_LEN_V30]; // 卡号 + public NET_DVR_TIME struStartTime = new NET_DVR_TIME();//查找图片的开始时间 + public NET_DVR_TIME struStopTime = new NET_DVR_TIME();// 查找图片的结束时间 + //ITC3.7 新增 + public int dwTrafficType; //图片检索生效项 参考 VCA_OPERATE _TYPE + public int dwVehicleType; //车辆类型 参考 VCA_VEHICLE_TYPE + //违规检测类型参考 VCA_ILLEGAL_TYPE 当前不支持复选 + public int dwIllegalType; + public byte byLaneNo; //车道号(1~99) + public byte bySubHvtType;//0-保留,1-机动车(机动车子类型中支持车牌检索,省份检索),2-非机动车,3-行人 + public byte[] byRes2 = new byte[2]; + public byte[] sLicense = new byte[MAX_LICENSE_LEN/*16*/]; //车牌号码 + public byte byRegion; // 区域索引值 0-保留,1-欧洲(Europe Region),3-欧洲&(EU&CIS), 4-中东(Middle East),0xff-所有 + public byte byCountry; // 国家索引值,参照:COUNTRY_INDEX + public byte byArea; //地区 + public byte byISO8601; //是否是8601的时间格式,即时差字段是否有效0-时差无效,年月日时分秒为设备本地时间 1-时差有效 + public byte cStartTimeDifferenceH; //开始时间与UTC的时差(小时),-12 ... +14, 正数表示东时区 + public byte cStartTimeDifferenceM; //开始时间与UTC的时差(分钟),-30, 0, 30, 45,正数表示东时区 + public byte cStopTimeDifferenceH; //结束时间与UTC的时差(小时),-12 ... +14,正数表示东时区 + public byte cStopTimeDifferenceM; //结束时间与UTC的时差(分钟),-30, 0, 30, 45,正数表示东时区 + } + + public static class NET_DVR_FIND_PICTURE extends Structure { + public byte[] sFileName = new byte[PICTURE_NAME_LEN];//图片名 + public NET_DVR_TIME struTime;//图片的时间 + public int dwFileSize;//图片的大小 + public byte[] sCardNum = new byte[CARDNUM_LEN_V30]; //卡号 + public byte byPlateColor;//参考结构 VCA_PLATE_COLOR + public byte byVehicleLogo;//参考结构 VLR_VEHICLE_CLASS + public byte byEventSearchStatus; //连续图片表示同一查找结果的时候,0-表示后面没有图片信息,1-表示后面还有图片信息。总共图片信息包括最后一张状态为0的图片。 + public byte byRecogResult;//识别结果参考结构VTR_RESULT + public byte[] sLicense = new byte[MAX_LICENSE_LEN/*16*/]; //车牌号码 + public byte[] byRes = new byte[12]; + } + + + public class NET_DVR_FIND_PICTURE_V50 extends Structure { + public byte[] sFileName = new byte[PICTURE_NAME_LEN];//图片名 + public NET_DVR_TIME struTime = new NET_DVR_TIME();//图片的时间 + public int dwFileSize;//图片的大小 + public byte[] sCardNum = new byte[CARDNUM_LEN_V30]; //卡号 + public byte byPlateColor;//参考结构 VCA_PLATE_COLOR + public byte byVehicleLogo;//参考结构 VLR_VEHICLE_CLASS + public byte byFileType; //文件类型, :0定时抓图1 移动侦测抓图 2 报警抓图3 报警 | 移动侦测抓图 4 报警 & 移动侦测抓图 6 手动抓图 ,9-智能图片,10- PIR报警,11- 无线报警,12- 呼救报警, 0xa 预览时截图,0xd 人脸侦测, 0xe 越界侦测,0xf 入侵区域侦测,0x10 场景变更侦测, 0x11-设备本地回放时截图, 0x12-智能侦测 + public byte byRecogResult;//识别结果参考结构VTR_RESULT + public byte[] sLicense = new byte[MAX_LICENSE_LEN/*16*/]; //车牌号码 + public byte byEventSearchStatus; //连续图片表示同一查找结果的时候,0-表示后面没有图片信息,1-表示后面还有图片信息。总共图片信息包括最后一张状态为0的图片。 + public NET_DVR_ADDRESS struAddr; //图片所在的地址信息,图片下载时用到 + public byte[] byRes = new byte[256]; // 保留字节 + public NET_DVR_PIC_EXTRA_INFO_UNION uPicExtraInfo; //图片附件信息 + } + + + public class NET_DVR_PIC_PARAM extends Structure { + public Pointer pDVRFileName; + public Pointer pSavedFileBuf; + public int dwBufLen; + public IntByReference lpdwRetLen; + public NET_DVR_ADDRESS struAddr; + public byte[] byRes = new byte[256]; + } + + + //查找结果结构体 + public static class NET_DVR_FIND_PICTURE_V40 extends Structure { + public byte[] sFileName = new byte[PICTURE_NAME_LEN];//图片名 + public NET_DVR_TIME struTime = new NET_DVR_TIME();//图片的时间 + public int dwFileSize;//图片的大小 + public byte[] sCardNum = new byte[CARDNUM_LEN_V30]; //卡号 + public byte byPlateColor;//参考结构 VCA_PLATE_COLOR + public byte byVehicleLogo;//参考结构 VLR_VEHICLE_CLASS + public byte byFileType; //文件类型, :0定时抓图1 移动侦测抓图 2 报警抓图3 报警 | 移动侦测抓图 4 报警 & 移动侦测抓图 6 手动抓图 ,9-智能图片,10- PIR报警,11- 无线报警,12- 呼救报警, 0xa 预览时截图,0xd 人脸侦测, 0xe 越界侦测,0xf 入侵区域侦测,0x10 场景变更侦测, 0x11-设备本地回放时截图, 0x12-智能侦测, 0x32-防区报警, 0x33-紧急求助, 0x34-业务咨询 + public byte byRecogResult;//识别结果参考结构VTR_RESULT + public byte[] sLicense = new byte[MAX_LICENSE_LEN/*16*/]; //车牌号码 + public byte byEventSearchStatus; //连续图片表示同一查找结果的时候,0-表示后面没有图片信息,1-表示后面还有图片信息。总共图片信息包括最后一张状态为0的图片。 + public byte[] byRes = new byte[75]; // 保留字节 + public NET_DVR_PIC_EXTRA_INFO_UNION uPicExtraInfo; //图片附件信息 + } + + public static class NET_DVR_FACE_EXTRA_INFO extends Union { + public NET_VCA_RECT[] struVcaRect = new NET_VCA_RECT[MAX_FACE_PIC_NUM]; //人脸子图坐标信息 + public byte[] byRes = new byte[64]; + } + + //图片附件信息联合体 + public static class NET_DVR_PIC_EXTRA_INFO_UNION extends Union { + public byte[] byUnionLen = new byte[544]; //联合体长度,无实际意义 + public NET_DVR_FACE_EXTRA_INFO struFaceExtraInfo; //人脸侦测信息 + } + + public static class NET_DVR_PACKET_INFO_EX extends Structure { + public short wWidth; //width + public short wHeight; //height + public int dwTimeStamp; //lower time stamp + public int dwTimeStampHigh;//higher time stamp + public int dwYear; //year + public int dwMonth; //month + public int dwDay; //day + public int dwHour; //hour + public int dwMinute; //minute + public int dwSecond; //second + public int dwMillisecond; //millisecond + public int dwFrameNum; //frame num + public int dwFrameRate; //frame rate,当帧率小于0时,0x80000002:表示1/2帧率,同理可推0x80000010为1/16帧率 + public int dwFlag; //flag E帧标记 + public int dwFilePos; //file pos + public int dwPacketType; //Packet type:0 -file head,1 -video I frame,2- video B frame, 3- video P frame, 10- audio packet, 11- private packet + public int dwPacketSize; //packet size + public Pointer pPacketBuffer; //packet buffer + public byte[] byRes1 = new byte[4]; + public int dwPacketMode; //打包方式:0-保留,1-FU_A打包方式 + public byte[] byRes2 = new byte[16]; + public int[] dwReserved = new int[6]; //reserved[0] 表示私有数据类型 + } + + + //云台区域选择放大缩小(HIK 快球专用) + public static class NET_DVR_POINT_FRAME extends Structure { + public int xTop; //方框起始点的x坐标 + public int yTop; //方框结束点的y坐标 + public int xBottom; //方框结束点的x坐标 + public int yBottom; //方框结束点的y坐标 + public int bCounter; //保留 + } + + //语音对讲参数 + public static class NET_DVR_COMPRESSION_AUDIO extends Structure { + public byte byAudioEncType; //0- G722,1- G711_U,2- G711_A,5- MP2L2,6- G726,7- AAC,8- PCM,9-G722,10-G723,11-G729,12-AAC_LC,13-AAC_LD,14-Opus,15-MP3,16-ADPCM + public byte byAudioSamplingRate;//音频采样率 0-默认,1-16kHZ,2-32kHZ,3-48kHZ, 4- 44.1kHZ,5-8kHZ + public byte byAudioBitRate;// 音频码率 参考 BITRATE_ENCODE_INDEX + public byte[] byres=new byte[4];//这里保留音频的压缩参数 + public byte bySupport;//bySupport Bit0表示 Mp2l2前4个字节的含义表示后面内容音频数据长度 + } + + public static class NET_DVR_AUDIODEC_INFO extends Structure { + public int nchans; /* 声道数 */ + public int sample_rate; /* 采样率 */ + public int aacdec_profile; /* 编码用的框架 */ + public int[] reserved = new int[16]; /* 保留 */ + } + + //音频解码 + public static class NET_DVR_AUDIODEC_PROCESS_PARAM extends Structure { + public Pointer in_buf; /* 输入数据buf */ + public Pointer out_buf; /* 输出数据buf */ + public int in_data_size; /* 输入in_buf内数据byte数 */ + public int proc_data_size; /* 输出解码库处理in_buf中数据大小bytes */ + public int out_frame_size; /* 解码一帧后数据BYTE数 */ + public NET_DVR_AUDIODEC_INFO dec_info = new NET_DVR_AUDIODEC_INFO(); /* 输出解码信息 */ + public int g726dec_reset; /* 重置开关 */ + public int g711_type; /* g711编码类型,0 - U law, 1- A law */ + public int[] reserved = new int[16]; /* 保留 */ + } + + public static class NET_DVR_AUDIOENC_INFO extends Structure { + public int in_frame_size; /* 输入一帧数据大小(BYTES),由GetInfoParam函数返回 */ + public int[] reserved = new int[16]; /* 保留 */ + } + + //音频编码 + public static class NET_DVR_AUDIOENC_PROCESS_PARAM extends Structure { + public Pointer in_buf; /* 输入buf */ + public Pointer out_buf; /* 输出buf */ + public int out_frame_size; /* 编码一帧后的BYTE数 */ + public int g726enc_reset; /* 重置开关 */ + public int g711_type; /* g711编码类型,0 - U law, 1- A law */ + public int enc_mode; /* 音频编码模式,AMR编码配置 */ + public int[] reserved = new int[16]; /* 保留 */ + } + + //用于接收报警信息的缓存区 + public static class RECV_ALARM extends Structure { + public byte[] RecvBuffer = new byte[4000];//此处的400应不小于最大报警报文长度 + } + + //布防参数 + public static class NET_DVR_SETUPALARM_PARAM extends Structure { + public int dwSize; + public byte byLevel; //布防优先级,0-一等级(高),1-二等级(中),2-三等级(低) + public byte byAlarmInfoType; //上传报警信息类型(抓拍机支持),0-老报警信息(NET_DVR_PLATE_RESULT),1-新报警信息(NET_ITS_PLATE_RESULT)2012-9-28 + public byte byRetAlarmTypeV40; //0--返回NET_DVR_ALARMINFO_V30或NET_DVR_ALARMINFO, 1--设备支持NET_DVR_ALARMINFO_V40则返回NET_DVR_ALARMINFO_V40,不支持则返回NET_DVR_ALARMINFO_V30或NET_DVR_ALARMINFO + public byte byRetDevInfoVersion; //CVR上传报警信息回调结构体版本号 0-COMM_ALARM_DEVICE, 1-COMM_ALARM_DEVICE_V40 + public byte byRetVQDAlarmType; //VQD报警上传类型,0-上传报报警NET_DVR_VQD_DIAGNOSE_INFO,1-上传报警NET_DVR_VQD_ALARM + public byte byFaceAlarmDetection; + public byte bySupport; + public byte byBrokenNetHttp; + public short wTaskNo; //任务处理号 和 (上传数据NET_DVR_VEHICLE_RECOG_RESULT中的字段dwTaskNo对应 同时 下发任务结构 NET_DVR_VEHICLE_RECOG_COND中的字段dwTaskNo对应) + public byte byDeployType; //布防类型:0-客户端布防,1-实时布防 + public byte[] byRes1 = new byte[3]; + public byte byAlarmTypeURL;//bit0-表示特征抓拍报警上传(INTER_FACESNAP_RESULT);0-表示二进制传输,1-表示URL传输(设备支持的情况下,设备支持能力根据具体报警能力集判断,同时设备需要支持URL的相关服务,当前是”云存储“) + public byte byCustomCtrl;//Bit0- 表示支持副驾驶人脸子图上传: 0-不上传,1-上传,(注:只在公司内部8600/8200等平台开放) + + + } + + public static class NET_DVR_SETUPALARM_PARAM_V50 extends Structure { + public int dwSize; + public byte byLevel; //布防优先级,0-一等级(高),1-二等级(中),2-三等级(低) + public byte byAlarmInfoType; //上传报警信息类型(抓拍机支持),0-老报警信息(NET_DVR_PLATE_RESULT),1-新报警信息(NET_ITS_PLATE_RESULT)2012-9-28 + public byte byRetAlarmTypeV40; //0--返回NET_DVR_ALARMINFO_V30或NET_DVR_ALARMINFO, 1--设备支持NET_DVR_ALARMINFO_V40则返回NET_DVR_ALARMINFO_V40,不支持则返回NET_DVR_ALARMINFO_V30或NET_DVR_ALARMINFO + public byte byRetDevInfoVersion; //CVR上传报警信息回调结构体版本号 0-COMM_ALARM_DEVICE, 1-COMM_ALARM_DEVICE_V40 + public byte byRetVQDAlarmType; //VQD报警上传类型,0-上传报报警NET_DVR_VQD_DIAGNOSE_INFO,1-上传报警NET_DVR_VQD_ALARM + //1-表示人脸侦测报警扩展(INTER_FACE_DETECTION),0-表示原先支持结构(INTER_FACESNAP_RESULT) + public byte byFaceAlarmDetection; + //Bit0- 表示二级布防是否上传图片: 0-上传,1-不上传 + //Bit1- 表示开启数据上传确认机制;0-不开启,1-开启 + //Bit6- 表示雷达检测报警(eventType:radarDetection)是否开启实时上传;0-不开启,1-开启(用于web插件实时显示雷达目标) + public byte bySupport; + //断网续传类型 + //bit0-车牌检测(IPC) (0-不续传,1-续传) + //bit1-客流统计(IPC) (0-不续传,1-续传) + //bit2-热度图统计(IPC) (0-不续传,1-续传) + //bit3-特征抓拍(IPC) (0-不续传,1-续传) + //bit4-人脸对比(IPC) (0-不续传,1-续传) + //bit5-JSON报警透传(IPC) (0-不续传,1-续传) + //bit6-热度图按人员停留时间统计数据上传事件(0-不续传,1-续传) + //bit7-热度图按人数统计数据上传事件的确认机制(0-不续传,1-续传) + public byte byBrokenNetHttp; + public short wTaskNo; //任务处理号 和 (上传数据NET_DVR_VEHICLE_RECOG_RESULT中的字段dwTaskNo对应 同时 下发任务结构 NET_DVR_VEHICLE_RECOG_COND中的字段dwTaskNo对应) + public byte byDeployType; //布防类型:0-客户端布防,1-实时布防 + public byte bySubScription; //订阅,按位表示,未开启订阅不上报 //占位 + //Bit7-移动侦测人车分类是否传图;0-不传图(V30上报),1-传图(V40上报) + public byte[] byRes1 = new byte[2]; + public byte byAlarmTypeURL;//bit0-表示特征抓拍报警上传(INTER_FACESNAP_RESULT);0-表示二进制传输,1-表示URL传输(设备支持的情况下,设备支持能力根据具体报警能力集判断,同时设备需要支持URL的相关服务,当前是”云存储“) + //bit1-表示EVENT_JSON中图片数据长传类型;0-表示二进制传输,1-表示URL传输(设备支持的情况下,设备支持能力根据具体报警能力集判断) + //bit2 - 人脸比对(报警类型为COMM_SNAP_MATCH_ALARM)中图片数据上传类型:0 - 二进制传输,1 - URL传输 + //bit3 - 异常行为检测(报警类型为COMM_ALARM_RULE)中图片数据上传类型:0 - 二进制传输,1 - URL传输,本字段设备是否支持,对应软硬件能力集中节点是否返回且为true + public byte byCustomCtrl;//Bit0- 表示支持副驾驶人脸子图上传: 0-不上传,1-上传 + public byte[] byRes4 = new byte[128]; + } + + + //区域框参数 + public static class NET_VCA_RECT extends Structure { + public float fX; + public float fY; + public float fWidth; + public float fHeight; + } + + //报警目标信息 + public static class NET_VCA_TARGET_INFO extends Structure { + public int dwID; + public NET_VCA_RECT struRect; + public byte[] byRes = new byte[4]; + } + + //前端设备信息 + public static class NET_VCA_DEV_INFO extends Structure { + public NET_DVR_IPADDR struDevIP; + public short wPort; + public byte byChannel; + public byte byIvmsChannel; + } + + //事件规则信息 + public static class NET_VCA_RULE_INFO extends Structure { + public byte byRuleID; + public byte byRes; + public short wEventTypeEx; + public byte[] byRuleName = new byte[NAME_LEN]; + public int dwEventType; + public NET_VCA_EVENT_UNION uEventParam; + + public void read() { + super.read(); + switch (wEventTypeEx) { + case 1: + uEventParam.setType(NET_VCA_TRAVERSE_PLANE.class); + break; + case 2: + uEventParam.setType(NET_VCA_AREA.class); + break; + case 3: + uEventParam.setType(NET_VCA_AREA.class); + break; + case 4: + uEventParam.setType(NET_VCA_INTRUSION.class); + break; + case 15: + uEventParam.setType(NET_VCA_LEAVE_POSITION.class); + break; + default: + break; + } + uEventParam.read(); + } + + public void write() { + super.write(); + uEventParam.write(); + } + + } + + //警戒规则参数联合体 + public static class NET_VCA_EVENT_UNION extends Union { + public int[] uLen = new int[23]; + public NET_VCA_TRAVERSE_PLANE struTraversePlane; //警戒参数 + public NET_VCA_AREA struArea; //进入/离开区域参数 + public NET_VCA_INTRUSION struIntrusion; //区域入侵参数 + public NET_VCA_LEAVE_POSITION struLeavePos; //参数 + + } + + //穿越警戒面参数 + public static class NET_VCA_TRAVERSE_PLANE extends Structure { + public NET_VCA_LINE struPlaneBottom; + public int dwCrossDirection; + public byte bySensitivity; + public byte byPlaneHeight; + public byte byDetectionTarget;/*检测目标:0- 所有目标,1- 人,2- 车 */ + public byte[] byRes2 = new byte[37]; + } + + + //根据报警延迟时间来标识报警中带图片,报警间隔和IO报警一致,1秒发送一个。 +//入侵参数 + public static class NET_VCA_INTRUSION extends Structure + { + public NET_VCA_POLYGON struRegion;//区域范围 + public short wDuration; //行为事件触发时间阈值: 1-120秒,建议5秒,判断是有效报警的时间 在ATM系统中触发文件阈值为 1-1000秒 + public byte bySensitivity; //灵敏度参数,范围[1-100] + public byte byRate; //占比:区域内所有未报警目标尺寸目标占区域面积的比重,归一化为-; + /* + 检测目标,可支持多选,具体定义为: + 0~所有目标(表示不锁定检测目标,所有目标都将进行检测) + 0x01 ~ 人, + 0x02 ~ 车, + 0x04 ~ 其他, + 该字段支持多选,按位取值,例如3表示1+2. + */ + public byte byDetectionTarget; + public byte byPriority;//优先级,0~低,1~中,2~高 + public byte byAlarmConfidence; //报警置信度, 0-低,1-较低,2-较高,3-高 + public byte byRecordConfidence; //录像置信度, 0-低,1-较低,2-较高,3-高 + } + + public static class NET_VCA_LEAVE_POSITION extends Structure { + public NET_VCA_POLYGON struRegion; //区域范围 + public short wLeaveDelay; //无人报警时间,单位:s + public short wStaticDelay; //睡觉报警时间,单位:s + public byte byMode; //模式,0-事件,,3-在岗(当人员回到岗位) + public byte byPersonType; //值岗人数类型,0-单人值岗,1-双人值岗 + public byte byOnPosition; //在岗人数,1-10,默认1 + public byte bySensitivity; //灵敏度参数,范围[1,5] + } + + public static class NET_DVR_HANDLEEXCEPTION_V40 extends Structure { + public int dwHandleType;/*处理方式,各种异常处理方式的"或"结果,异常处理方式: + 0x00: 无响应 0x01: 布防器上警告 0x02: 声音警告 0x04: 上传中心 + 0x08: 触发报警输出 0x10: Jpeg抓图并上传EMail + 0x20: 无线声光报警器联动 0x40: 联动电子地图(目前仅PCNVR支持) + 0x200:抓图并上传ftp 0x400: 虚焦侦测联动聚焦 + 0x800: PTZ联动(球机目标) + E.g. dwHandleType==0x01|0x04 表示配置报警发生时联动布防器上警告并且将报警信息上传中心。 */ + public int dwMaxRelAlarmOutChanNum;/*设备最大支持的触发报警输出通道数(只读) */ + public int dwRelAlarmOutChanNum;/*已配置的触发的报警输出通道个数,决定dwRelAlarmOut取前多少个数组下标 */ + public int[] dwRelAlarmOut = new int[MAX_CHANNUM_V30];/*触发报警输出通道,取数组前dwRelAlarmOutChanNum个值, + 其值表示报警输出通道号(从1开始),初始值是0xfffffffff(不关联通道)。 + 例如,dwRelAlarmOutChanNum=5,则可以配置触发报警输出通道dwRelAlarmOut[0]~dwRelAlarmOut[4]。 */ + public byte[] byRes = new byte[64]; /*保留,置为0 */ + } + + public static final int MAX_ALERTLINE_NUM = 8; + + public static class NET_VCA_TRAVERSE_PLANE_DETECTION extends Structure { + public int dwSize; + public byte byEnable;//使能 + public byte byEnableDualVca;// 启用支持智能后检索 0-不启用,1-启用 + public byte[] byRes1 = new byte[2]; + public NET_VCA_TRAVERSE_PLANE[] struAlertParam = new NET_VCA_TRAVERSE_PLANE[MAX_ALERTLINE_NUM]; //警戒线参数 + public NET_DVR_SCHEDTIMEWEEK[] struAlarmSched = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS]; + public NET_DVR_HANDLEEXCEPTION_V40 struHandleException; //异常处理方式 + public int dwMaxRelRecordChanNum; //报警触发的录象通道 数(只读)最大支持数量 + public int dwRelRecordChanNum; //报警触发的录象通道 数 实际支持的数量 + public int[] byRelRecordChan = new int[MAX_CHANNUM_V30];//触发录像的通道号 + public NET_DVR_SCHEDTIME[] struHolidayTime = new NET_DVR_SCHEDTIME[MAX_TIMESEGMENT_V30]; //假日布防时间 + public byte[] byRes2 = new byte[100]; + } + + + + + //快速移动参数 + public static class NET_VCA_RUN extends Structure { + public NET_VCA_POLYGON struRegion;//区域范围 + public float fRunDistance; //人快速移动最大距离, 范围: [0.1, 1.00] 像素模式 实际模式(1,20)m/s + public byte bySensitivity; //灵敏度参数,范围[1,5] + public byte byMode; // 0 像素模式 1 实际模式 + /* + 检测目标,可支持多选,具体定义为: + 0~所有目标(表示不锁定检测目标,所有目标都将进行检测) + 0x01 ~ 人, + 0x02 ~ 车,, + 0x04 ~ 其他, + 该字段支持多选,按位取值,例如3表示1+2. + */ + public byte byDetectionTarget; + public byte byRes; + } + + + //奔跑检测 + public static class NET_VCA_RUNNING extends Structure { + public NET_VCA_POLYGON struRegion; //区域范围 + public int dwSpeed; //奔跑速度,范围[1,10] + public short wDuration; // 触发报警时间阈值 + public byte byRunMode; //奔跑模式,0-保留,1:单人奔跑,2:多人奔跑 + public byte byRes; + } + + //倒地参数 + public static class NET_VCA_FALL_DOWN extends Structure { + public NET_VCA_POLYGON struRegion;//区域范围 + public short wDuration; /* 触发事件阈值 1-60s*/ + public short bySensitivity; /* 灵敏度参数,范围[1,5] */ + public short byHeightThreshold; //高度阈值,范围[0,250],默认90,单位:厘米 + public byte[] byRes = new byte[4]; + } + + public static final int MAX_INTRUSIONREGION_NUM = 8; //最大区域数数 + + public static class NET_VCA_FIELDDETECION extends Structure { + public int dwSize; + public byte byEnable; //使能,是否开启 + public byte byEnableDualVca;// 启用支持智能后检索 0-不启用,1-启用 + public byte byEnableHumanMisinfoFilter;// 启用人体去误报 0-不启用,1-启用 + public byte byEnableVehicleMisinfoFilter;// 启用车辆去误报 0-不启用,1-启用 + public NET_VCA_INTRUSION[] struIntrusion = new NET_VCA_INTRUSION[MAX_INTRUSIONREGION_NUM];//每个区域的参数设置 + public NET_DVR_SCHEDTIMEWEEK[] struAlarmSched = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS]; //布防时间 + public NET_DVR_HANDLEEXCEPTION_V40 struHandleException; //异常处理方式 + public int dwMaxRelRecordChanNum; //报警触发的录象通道 数(只读)最大支持数量 + public int dwRelRecordChanNum; //报警触发的录象通道 数 实际支持的数量 + public int[] byRelRecordChan = new int[MAX_CHANNUM_V30];//触发录像通道 + public NET_DVR_SCHEDTIME[] struHolidayTime = new NET_DVR_SCHEDTIME[MAX_TIMESEGMENT_V30]; //假日布防时间 + public byte[] byRes2 = new byte[100]; + } + + public static class NET_DVR_CHANNEL_GROUP extends Structure { + public int dwSize; + public int dwChannel; + public int dwGroup; + public byte byID; + public byte[] byRes1 = new byte[3]; + public int dwPositionNo; + public byte[] byRes = new byte[56]; + } + + //线结构参数 + public static class NET_VCA_LINE extends Structure { + public NET_VCA_POINT struStart; + public NET_VCA_POINT struEnd; + } + + //点坐标参数 + public static class NET_VCA_POINT extends Structure { + public float fX; + public float fY; + } + + //进入/离开区域参数 + public static class NET_VCA_AREA extends Structure { + public NET_VCA_POLYGON struRegion; + public byte bySensitivity; //灵敏度参数,范围[1,5] + /* + 检测目标,可支持多选,具体定义为: + 0~所有目标(表示不锁定检测目标,所有目标都将进行检测) + 0x01 ~ 人, + 0x02 ~ 车, + 0x04 ~ 其他, + 该字段支持多选,按位取值,例如3表示1+2. + */ + public byte byDetectionTarget; + public byte byPriority;//优先级,0~低,1~中,2~高 + public byte[] byRes = new byte[5]; + } + + //多边形结构体 + public static class NET_VCA_POLYGON extends Structure { + public int dwPointNum; + public NET_VCA_POINT[] struPos = new NET_VCA_POINT[VCA_MAX_POLYGON_POINT_NUM]; + } + + public static class NET_VCA_SIZE_FILTER extends Structure { + public byte byActive; //是否激活尺寸过滤器 0-否 非0-是 + public byte byMode; //过滤器模式SIZE_FILTER_MODE + public byte[] byRes = new byte[2]; //保留,置0 + public NET_VCA_RECT struMiniRect; //最小目标框,全0表示不设置 + public NET_VCA_RECT struMaxRect; //最大目标框,全0表示不设置 + } + + + //尺寸过滤策略 + public static class NET_VCA_FILTER_STRATEGY extends Structure { + public byte byStrategy; //尺寸过滤策略 0 - 不启用 1-高度和宽度过滤,2-面积过滤 + public byte[] byRes = new byte[11]; //保留 + } + + //异常行为检测报警 + public static class NET_VCA_RULE_ALARM extends Structure { + public int dwSize; + public int dwRelativeTime; + public int dwAbsTime; + public NET_VCA_RULE_INFO struRuleInfo; + public NET_VCA_TARGET_INFO struTargetInfo; + public NET_VCA_DEV_INFO struDevInfo; + public int dwPicDataLen; + public byte byPicType; + public byte byRelAlarmPicNum; //关联通道报警图片数量 + public byte bySmart;//IDS设备返回0(默认值),Smart Functiom Return 1 + public byte byPicTransType; //图片数据传输方式: 0-二进制;1-url + public int dwAlarmID; //报警ID,用以标识通道间关联产生的组合报警,0表示无效 + public short wDevInfoIvmsChannelEx; //与NET_VCA_DEV_INFO里的byIvmsChannel含义相同,能表示更大的值。老客户端用byIvmsChannel能继续兼容,但是最大到255。新客户端版本请使用wDevInfoIvmsChannelEx。 + public byte byRelativeTimeFlag; //dwRelativeTime字段是否有效 0-无效, 1-有效,dwRelativeTime表示UTC时间 + public byte byAppendInfoUploadEnabled; //附加信息上传使能 0-不上传 1-上传 + public Pointer pAppendInfo; //指向附加信息NET_VCA_APPEND_INFO的指针,byAppendInfoUploadEnabled为1时或者byTimeDiffFlag为1时有效 + public Pointer pImage; + } + + public static class NET_DVR_SYSTEM_TIME extends Structure { + public short wYear; //年 + public short wMonth; //月 + public short wDay; //日 + public short wHour; //时 + public short wMinute; //分 + public short wSecond; //秒 + public short wMilliSec; //毫秒 + public byte[] byRes = new byte[2]; + } + + //设备支持AI开放平台接入,上传视频检测数据 + public static class NET_AIOP_VIDEO_HEAD extends Structure { + public int dwSize; //dwSize = sizeof(NET_AIOP_VIDEO_HEAD) + public int dwChannel; //设备分析通道的通道号; + public NET_DVR_SYSTEM_TIME struTime = new NET_DVR_SYSTEM_TIME(); //时间 + public byte[] szTaskID = new byte[64]; //视频任务ID,来自于视频任务派发 + public int dwAIOPDataSize; //对应AIOPDdata数据长度 + public int dwPictureSize; //对应分析图片长度 + public byte[] szMPID = new byte[64]; //检测模型包ID,用于匹配AIOP的检测数据解析;可以通过URI(GET /ISAPI/Intelligent/AIOpenPlatform/algorithmModel/management?format=json)获取当前设备加载的模型包的label description信息; + public Pointer pBufferAIOPData; //AIOPDdata数据 + public Pointer pBufferPicture;//对应分析图片数据 + public byte byPictureMode;//图片数据传输模式 0-二进制,1-武汉云云存储,当byPictureMode为0时pBufferPicture为二进制数据,当byPictureMode为1时pBufferPicture为武汉云URL + public byte[] byRes2 = new byte[3];//保留字节 + public int dwPresetIndex; //预置点序号 + public byte[] byRes = new byte[176]; + } + + //设备支持AI开放平台接入,上传图片检测数据 + public static class NET_AIOP_PICTURE_HEAD extends Structure { + public int dwSize; //dwSize = sizeof(NET_AIOP_PICTURE_HEAD) + public NET_DVR_SYSTEM_TIME struTime = new NET_DVR_SYSTEM_TIME(); //时间 + public byte[] szPID = new byte[64]; //透传下发的图片ID,来自于图片任务派发 + public int dwAIOPDataSize; //对应AIOPDdata数据长度 + public byte byStatus; //状态值:0-成功,1-图片大小错误 + public byte[] byRes1 = new byte[3]; + public byte[] szMPID = new byte[64]; //检测模型包ID,用于匹配AIOP的检测数据解析; + public Pointer pBufferAIOPData;//AIOPDdata数据 + public int dwPresetIndex; //预置点序号 + public byte[] byRes = new byte[180]; + } + + + public static class NET_DVR_AI_PICTUR_UPLOAD extends Structure { + public int dwSize; + public byte[] szTaskID = new byte[64]; //任务id,strlen.max = 64,业务平台统一维护管理 + public byte[] szPID = new byte[64]; //图片id,strlen.max = 64,业务平台统一维护管理 + public byte[] byRes = new byte[128]; + } + + // AI开放平台接入轮询视频检测报警结构体。 + public static class NET_AIOP_POLLING_SNAP_HEAD extends Structure { + public int dwSize; //dwSize = sizeof(NET_AIOP_POLLING_SNAP_HEAD) + public int dwChannel; //设备分析通道的通道号(走SDK协议); + public NET_DVR_SYSTEM_TIME struTime = new NET_DVR_SYSTEM_TIME(); //时间 + public byte[] szTaskID = new byte[64]; //轮询抓图任务ID,来自于轮询抓图任务派发 + public int dwAIOPDataSize; //对应AIOPDdata数据长度 + public int dwPictureSize; //对应分析图片长度 + public byte[] szMPID = new byte[64]; //检测模型包ID,用于匹配AIOP的检测数据解析; + public Pointer pBufferAIOPData;//AIOPDdata数据 + public Pointer pBufferPicture;//分析图片数据 + public byte byPictureMode;//图片数据传输模式 0-二进制,1-武汉云云存储,当byPictureMode为0时pBufferPicture为二进制数据,当byPictureMode为1时pBufferPicture为武汉云URL + public byte[] byRes2 = new byte[3];//保留字节 + public int dwPresetIndex; //预置点序号 + public byte[] byRes = new byte[176]; + } + + // AI开放平台接入轮询视频检测报警结构体。 + public static class NET_AIOP_POLLING_VIDEO_HEAD extends Structure { + public int dwSize; //dwSize = sizeof(NET_AIOP_POLLING_VIDEO_HEAD) + public int dwChannel; //设备分析通道的通道号(走SDK协议); + public NET_DVR_SYSTEM_TIME struTime; //时间 + public byte[] szTaskID = new byte[64]; //轮询抓图任务ID,来自于轮询抓图任务派发 + public int dwAIOPDataSize; //对应AIOPDdata数据长度 + public int dwPictureSize; //对应分析图片长度 + public byte[] szMPID = new byte[64]; //检测模型包ID,用于匹配AIOP的检测数据解析; + public Pointer pBufferAIOPData;//AIOPDdata数据 + public Pointer pBufferPicture;//对应分析图片数据 + public byte byPictureMode;//图片数据传输模式 0-二进制,1-武汉云云存储,当byPictureMode为0时pBufferPicture为二进制数据,当byPictureMode为1时pBufferPicture为武汉云URL + public byte[] byRes2 = new byte[3];//保留字节 + public int dwPresetIndex; //预置点序号 + public byte[] byRes = new byte[176]; + } + + //规则触发参数 + public static class NET_VCA_RULE_TRIGGER_PARAM extends Structure { + public byte byTriggerMode; //规则的触发方式,0- 不启用,1- 点 2- 目标面积 + public byte byTriggerPoint; //触发点,触发方式为点时有效 0- 中,1-上,2-下 + public byte[] byRes1 = new byte[2]; //保留 + public float fTriggerArea; //触发目标面积百分比 [0,100],触发方式为目标面积时有效 + public byte[] byRes2 = new byte[4]; //保留 + } + + public static class NET_VCA_ONE_RULE_V42 extends Structure { + public byte byActive; //是否激活规则, 0-否,非0-是 + public byte byEventPriority;//事件优先级 0-低,1-中,2-高 + public byte[] byRes1 = new byte[4]; //保留,设置为0字段 + public short wEventType; //行为事件类型,参考VCA_RULE_EVENT_TYPE_EX + public byte[] byRuleName = new byte[NAME_LEN/*32*/]; //规则名称 + public NET_VCA_EVENT_UNION uEventParam; //异常行为检测事件参数 + public NET_VCA_SIZE_FILTER struSizeFilter; //尺寸过滤器 + public NET_DVR_SCHEDTIMEWEEK[] struAlarmTime = new NET_DVR_SCHEDTIMEWEEK[MAX_DAYS];//布防时间 + public NET_DVR_HANDLEEXCEPTION_V40 struAlarmHandleType; /*处理方式*/ + //异常处理方式中报警输出号与组号绑定,即组号为0时,表示关联的报警输出号范围为1-64,当组号为1时,表示关联的报警输出号范围为65-128, 且是组内紧凑排列,如果遇到0xffffffff表示本组 当前的及组内后续的报警出号无效 + public int[] dwRelRecordChan = new int[MAX_CHANNUM_V30]; /* 报警触发的录象通道(四字节的通道号,初始值是 0xffffffff)*/ + //关联的录像通道号与组号绑定,即组号为0时,表示关联的通道号范围为1-64,当组号为1时,表示关联的通道号范围为65-128, 且是组内紧凑排列,如果遇到0xffffffff表示本组 当前的及组内后续的关联通道号无效 + public short wAlarmDelay; //智能报警延时,0-5s,1-10,2-30s,3-60s,4-120s,5-300s,6-600s + public byte[] byRes2 = new byte[2]; //保留 + public NET_VCA_FILTER_STRATEGY struFilterStrategy; //尺寸过滤策略 + public NET_VCA_RULE_TRIGGER_PARAM struTriggerParam; //规则触发参数 + public byte[] byRes = new byte[32]; + } + + public static class NET_DVR_PTZ_POSITION extends Structure { + // 是否启用场景,在设置场景行为规则的时候该字段无效,在设置球机本地配置场景位置信息时作为使能位 + public byte byEnable; + public byte[] byRes1 = new byte[3]; //保留 + public byte[] byPtzPositionName = new byte[NAME_LEN]; //场景位置名称 + public NET_DVR_PTZPOS struPtzPos; //ptz 坐标 + public byte[] byRes2 = new byte[40]; + } + + //异常行为检测配置结构体 + public static class NET_VCA_RULECFG_V42 extends Structure { + public int dwSize; //结构图大小 + public byte byPicProType; //报警时图片处理方式 0-不处理 1-上传 + public byte byUpLastAlarm; //是否先上传最近一次的报警,0-否,1-是 + public byte byPicRecordEnable; //是否启用图片存储, 0-不启用, 1-启用 + public byte byRes1; + public NET_DVR_JPEGPARA struPicParam; //图片规格结构 + public NET_VCA_ONE_RULE_V42[] struRule = new NET_VCA_ONE_RULE_V42[16]; /* 规则数组*/ + public short[] wRelSnapChan = new short[3]; //关联抓图通道,当主通道报警时,同时会上传关联通道的抓拍图片,0表示不关联,其他值为关联通道号 + public byte byTrackEnable; //是否启用 + public byte byRes2; + public NET_DVR_PTZ_POSITION struPTZPosition; //场景位置信息 + public short wTrackDuration; //持续时间,单位s + public short wIntervalTime; //单次报警间隔时间(秒)[1-7200](ˆ默认为600) + public short wHeightLimit;//目标检测高度下限(厘米)[0-250](默认为80cm),小于此高度的目标将不作为目标进行检测 + public byte[] byRes = new byte[58];//保留 + } + + public static final int CID_CODE_LEN = 4; + public static final int DEV_SERIAL_LEN = 9; + public static final int ACCOUNTNUM_LEN = 6; + public static final int ACCOUNTNUM_LEN_32 = 32; + + public static class NET_DVR_CID_ALARM extends Structure { + public int dwSize; + public byte[] sCIDCode = new byte[CID_CODE_LEN/*4*/]; //CID事件号 + public byte[] sCIDDescribe = new byte[NAME_LEN/*32*/]; //CID事件名 + public NET_DVR_TIME_EX struTriggerTime = new NET_DVR_TIME_EX(); //触发报警的时间点 + public NET_DVR_TIME_EX struUploadTime = new NET_DVR_TIME_EX(); //上传报警的时间点 + public byte[] sCenterAccount = new byte[ACCOUNTNUM_LEN/*6*/]; //中心帐号 + public byte byReportType; //见定义NET_DVR_ALARMHOST_REPORT_TYPE + public byte byUserType; //用户类型,0-网络用户 1-键盘用户,2-手机用户,3-系统用户 + public byte[] sUserName = new byte[NAME_LEN/*32*/]; //网络用户用户名 + public short wKeyUserNo; //键盘用户号 0xFFFF表示无效 + public byte byKeypadNo; //键盘号 0xFF表示无效 + public byte bySubSysNo; //子系统号 0xFF表示无效 + public short wDefenceNo; //防区号 0xFFFF表示无效 + public byte byVideoChanNo; //视频通道号 0xFF表示无效 + public byte byDiskNo; //硬盘号 0xFF表示无效 + public short wModuleAddr; //模块地址 0xFFFF表示无效 + public byte byCenterType; //0-无效, 1-中心账号(长度6),2-扩展的中心账号(长度9) + public byte byRes1; + public byte[] sCenterAccountV40 = new byte[ACCOUNTNUM_LEN_32/*32*/]; //中心账号V40,使用此字段时sCenterAccount无效 + public byte[] byDevSerialNo = new byte[DEV_SERIAL_LEN]; /*产品序列号*/ + public byte byRepeaterNo; //中继器号,为0无效 + public short wRemoteCtrllerUserNo; //遥控器用户号,为0无效 + public int dwIOTChannelNo; //IOT通道号 + public byte[] byRes2 = new byte[12]; + } + + public static class NET_DVR_SENSOR_ALARM extends Structure { + public int dwSize; // 结构体大小 + public int dwAbsTime; // 绝对时标信息 OSD显示信息 + public byte[] byName = new byte[NAME_LEN]; // sensor 名称 + public byte bySensorChannel; // 模拟量通道 + public byte byType; // 模拟量类型 + public byte byAlarmType; // 1-上4、2-上3、3-上2、4-上1、5-下1、6-下2、7-下3、8-下4 和当前模式有关 + // 例如当为1000时,有上1下1,2,3报警四种报警 + public byte byAlarmMode; //报警模式,五种,-HHHH、-HHHL、-HHLL、HLLL、-LLLL, 作为平台报警程度判断功能,即:1111(上上上上),1110(上上上下),1100(上上下下),1000(上下下下),0000(下下下下) + public float fValue; // 但前模拟量的值 + public float fOriginalValue; //原始电流电压值,保留小数点后三位,具体值表示电流还是电压根据NET_DVR_SENSOR_INFO的bySensorStandard类型 + public byte[] byRes2 = new byte[28]; // 保留字节 + } + + //开关量报警上传 + public static class NET_DVR_SWITCH_ALARM extends Structure { + public int dwSize; + public byte[] byName = new byte[NAME_LEN]; // switch 名称 + public short wSwitchChannel; // 开关量通道, 0-255 + public byte byAlarmType; // 报警类型 0--正常,1--短路,2--断路,3-异常 + public byte[] byRes = new byte[41]; // 保留字节 + } + + public static class NET_DVR_ALARMHOST_EXCEPTION_ALARM extends Structure { + public int dwSize; // 结构体大小 + // 异常参数 1-设备防拆报警 2-设备防拆后后恢复正常 3-主电源掉电报警 4-主电源掉电后恢复正常 5-内部通信故障报警 + // 6-内部通信故障后恢复正常 7-电话线断线 8-电话线断线恢复 9-自检失败报警 10-自检失败后恢复正常 + // 11蓄电池欠压 12蓄电池电压恢复正常,13-蓄电池故障;14-MBUS模块掉线;15-MBUS模块掉线恢复;16-键盘掉线; + //17-键盘掉线恢复;18-设备被移动;19-设备被移动复位 20-485外设线路断报警 21-485外设线路断后恢复正常 + //25-子板1插上,26-子板1拔出, 27-子板2插上,28-子板2拔出 + public int dwExceptionType; + public byte[] byRes = new byte[36]; // 保留 + } + + + public static class NET_DVR_ALARMHOST_POINT_VALUE extends Structure { + public byte byChanType; //接入类型,1-本地模拟量通道,2-本地开关量通道,3-485通道,4-网络通道 + public byte byPointType; //点类型,1-遥测(模拟量),2-遥信(开关量) + public byte[] byRes1 = new byte[2]; //保留 + public int dwChanNo; //485通道号,0xffffffff表示无效,通道类型为1时:表示本地模拟量通道号,通道类型为2时表示本地开关量通道号,通道类型为3时表示485通道号。 + public int dwSubChanNo; //槽位号, 0xffffffff表示无效,通道类型为3时使用 + public int dwVariableNo; //变量编号,0xffffffff表示无效 + public int dwPointNo; //104点号,0xffffffff表示无效 + public int iValue; //监测点的值,表示低32位 + public int iValueEx; //监测点的值,表示高32位 + public byte[] byRes = new byte[12]; + } + + public static class NET_DVR_ALARMHOST_DATA_UNION extends Structure { + public byte[] byLength = new byte[40]; + public NET_DVR_ALARMHOST_POINT_VALUE struPointValue; //监测点实时数据 + } + + public static class NET_DVR_ALARMHOST_DATA_UPLOAD extends Structure { + public int dwSize; + public byte byDataType; //数据类型,1-监测点实时数据上传 + public byte[] byRes1 = new byte[3]; + public NET_DVR_ALARMHOST_DATA_UNION struAlarmData; + public byte[] byRes2 = new byte[32]; + } + + //车牌识别结果子结构 + public static class NET_DVR_PLATE_INFO extends Structure { + public byte byPlateType; //车牌类型 + public byte byColor; //车牌颜色 + public byte byBright; //车牌亮度 + public byte byLicenseLen; //车牌字符个数 + public byte byEntireBelieve; //整个车牌的置信度,-100 + public byte byRegion; // 区域索引值 0-保留,1-欧洲(EU),3-欧洲&(EU&CIS) ,4-中东(ME),0xff-所有 + public byte byCountry; // 国家索引值,参照枚举COUNTRY_INDEX(不支持"COUNTRY_ALL = 0xff, //ALL 全部") + public byte byArea; //区域(省份),各国家内部区域枚举,阿联酋参照 EMI_AREA + public byte byPlateSize; //车牌尺寸,0~未知,1~long, 2~short(中东车牌使用) + public byte byAddInfoFlag; + public short wCRIndex;//国家/地区索引,索引值参考_CR_ INDEX_ + public byte[] byRes = new byte[12]; //保留 + public byte[] sPlateCategory = new byte[8];//车牌附加信息, 即中东车牌中车牌号码旁边的小字信息,(目前只有中东地区支持) + public int dwXmlLen; //XML报警信息长度 + public Pointer pXmlBuf; // XML报警信息指针,报警类型为 COMM_ITS_PLATE_RESUL时有效,其XML对应到EventNotificationAlert XML Block + public NET_VCA_RECT struPlateRect = new NET_VCA_RECT(); //车牌位置 + public byte[] sLicense = new byte[MAX_LICENSE_LEN]; //车牌号码,注:中东车牌需求把小字也纳入车牌号码,小字和车牌号中间用空格分隔 + public byte[] byBelieve = new byte[MAX_LICENSE_LEN]; //各个识别字符的置信度,如检测到车牌"浙A12345", 置信度为,20,30,40,50,60,70,则表示"浙"字正确的可能性只有%,"A"字的正确的可能性是% + } + + public static class NET_DVR_VEHICLE_INFO extends Structure { + public int dwIndex; //车辆序号 + public byte byVehicleType; //车辆类型 0 表示其它车型,1 表示小型车,2 表示大型车 ,3表示行人触发 ,4表示二轮车触发 5表示三轮车触发(3.5Ver) + public byte byColorDepth; //车身颜色深浅 + public byte byColor; //车身颜色,参考VCR_CLR_CLASS + /*雷达异常状态: + 0~雷达正常, + 1~雷达故障 + 2~雷达一直发送某一个相同速度值 + 3~雷达送出数据为0 + 4~雷达送出数据过大或者过小 + */ + public byte byRadarState; + public short wSpeed; //单位km/h + public short wLength; //前一辆车的车身长度 + /*违规类型,0-正常,1-低速,2-超速,3-逆行,4-闯红灯,5-压车道线,6-不按导向,7-路口滞留, + 8-机占非,9-违法变道,10-不按车道 11-违反禁令,12-路口停车,13-绿灯停车, 14-未礼让行人(违法代码1357), + 15-违章停车,16-违章掉头,17-占用应急车道,18-禁右,19-禁左,20-压黄线,21-未系安全带,22-行人闯红灯,23-加塞,24-违法使用远光灯, + 25-驾驶时拨打接听手持电话,26-左转不让直行,27-右转不让左转,28-掉头不让直行,29-大弯小转, 30-闯绿灯,31-未带头盔, + 32-非机动车载人,33-非机动车占用机动车道,34-非机动车打伞棚, 35-黑烟车, 36-鸣笛*/ + public byte byIllegalType; + public byte byVehicleLogoRecog; //参考枚举类型 VLR_VEHICLE_CLASS + public byte byVehicleSubLogoRecog; //车辆品牌子类型识别;参考VSB_VOLKSWAGEN_CLASS等子类型枚举。 + public byte byVehicleModel; //车辆子品牌年款,0-未知,参考"车辆子品牌年款.xlsx" + public byte[] byCustomInfo = new byte[16]; //自定义信息 + public short wVehicleLogoRecog; //车辆主品牌,参考"车辆主品牌.xlsx" (该字段兼容byVehicleLogoRecog); + public byte byIsParking;//是否停车 0-无效,1-停车,2-未停车 + public byte byRes;//保留字节 + public int dwParkingTime; //停车时间,单位:s + public byte[] byRes3 = new byte[8]; + } + + //手动抓拍 + public static class NET_DVR_MANUALSNAP extends Structure { + public byte byOSDEnable;//0-不关闭(默认),1-关闭 + public byte byLaneNo;//车道号, 范围为1-6,默认为1(抓拍机内部测试使用) + public byte byChannel;//通道号 + public byte[] byRes = new byte[21]; //保留 + } + + //交通抓拍结果信息 + public static class NET_DVR_PLATE_RESULT extends Structure { + public int dwSize; + public byte byResultType; + public byte byChanIndex; + public short wAlarmRecordID; + public int dwRelativeTime; + public byte[] byAbsTime = new byte[32]; + public int dwPicLen; + public int dwPicPlateLen; + public int dwVideoLen; + public byte byTrafficLight; + public byte byPicNum; + public byte byDriveChan; + public byte byVehicleType; + public int dwBinPicLen; + public int dwCarPicLen; + public int dwFarCarPicLen; + public Pointer pBuffer3; + public Pointer pBuffer4; + public Pointer pBuffer5; + public byte[] byRes3 = new byte[8]; + public NET_DVR_PLATE_INFO struPlateInfo; + public NET_DVR_VEHICLE_INFO struVehicleInfo; + public Pointer pBuffer1; + public Pointer pBuffer2; + } + + public static class NET_DVR_TIME_V30 extends Structure { + public short wYear; + public byte byMonth; + public byte byDay; + public byte byHour; + public byte byMinute; + public byte bySecond; + public byte byRes; + public short wMilliSec; + public byte[] byRes1 = new byte[2]; + + + } + + public static class NET_ITS_PICTURE_INFO extends Structure { + public int dwDataLen; + public byte byType; + public byte byDataType; + public byte byCloseUpType; + public byte byPicRecogMode; + public int dwRedLightTime; + public byte[] byAbsTime = new byte[32]; + public NET_VCA_RECT struPlateRect = new NET_VCA_RECT(); + public NET_VCA_RECT struPlateRecgRect = new NET_VCA_RECT(); + public Pointer pBuffer; + public int dwUTCTime;//UTC时间 + public byte byCompatibleAblity;//兼容能力字段,按位表示,值:0- 无效,1- 有效 + public byte byTimeDiffFlag; /*时差字段是否有效 0-时差无效, 1-时差有效 */ + public byte cTimeDifferenceH; /*与UTC的时差(小时),-12 ... +14, +表示东区,,byTimeDiffFlag为1时有效*/ + public byte cTimeDifferenceM; /*与UTC的时差(分钟),-30, 30, 45, +表示东区,byTimeDiffFlag为1时有效*/ + public byte[] byRes2 = new byte[4]; + } + + public static class NET_ITS_PLATE_RESULT extends Structure { + public int dwSize; + public int dwMatchNo; + public byte byGroupNum; + public byte byPicNo; + public byte bySecondCam; + public byte byFeaturePicNo; + public byte byDriveChan; + public byte byVehicleType; + public byte byDetSceneID; + public byte byVehicleAttribute; + public short wIllegalType; + public byte[] byIllegalSubType = new byte[8]; + public byte byPostPicNo; + public byte byChanIndex; + public short wSpeedLimit; + public byte byChanIndexEx; //byChanIndexEx*256+byChanIndex表示真实通道号。 + public byte byRes2; + public NET_DVR_PLATE_INFO struPlateInfo = new NET_DVR_PLATE_INFO(); + public NET_DVR_VEHICLE_INFO struVehicleInfo = new NET_DVR_VEHICLE_INFO(); + public byte[] byMonitoringSiteID = new byte[48]; + public byte[] byDeviceID = new byte[48]; + public byte byDir; + public byte byDetectType; + public byte byRelaLaneDirectionType; + public byte byCarDirectionType; + public int dwCustomIllegalType; + public Pointer pIllegalInfoBuf; + public byte byIllegalFromatType; + public byte byPendant; + public byte byDataAnalysis; + public byte byYellowLabelCar; + public byte byDangerousVehicles; + public byte byPilotSafebelt; + public byte byCopilotSafebelt; + public byte byPilotSunVisor; + public byte byCopilotSunVisor; + public byte byPilotCall; + public byte byBarrierGateCtrlType; + public byte byAlarmDataType; + public NET_DVR_TIME_V30 struSnapFirstPicTime = new NET_DVR_TIME_V30(); + public int dwIllegalTime; + public int dwPicNum; + public NET_ITS_PICTURE_INFO[] struPicInfo = new NET_ITS_PICTURE_INFO[6]; + } + + public int MAX_PARKNO_LEN = 16; //车位编号长度 + public int MAX_ID_LEN = 48; //编号最大长度 + + //停车场数据上传 + public static class NET_ITS_PARK_VEHICLE extends Structure { + public int dwSize; //结构长度 + public byte byGroupNum; //图片组数量(单次轮询抓拍的图片数量) + public byte byPicNo; //连拍的图片组上传图片序号(接收到图片组数量后,表示接收完成 + //接收超时不足图片组数量时,根据需要保留或删除) + public byte byLocationNum; //单张图片所管理的车位数 + public byte byParkError; //停车异常,0-正常 1 异常 + public byte[] byParkingNo = new byte[MAX_PARKNO_LEN];//车位编号 + public byte byLocationStatus; //车位车辆状态,0-无车,1有车 + public byte bylogicalLaneNum;//逻辑车位号,0-3,一个相机最大能管4个车位 (0代表最左边,3代表最右边) + public short wUpLoadType;//第零位表示:0~轮训上传、1~变化上传 + public byte[] byRes1 = new byte[4]; //保留字节 + public int dwChanIndex; //通道号数字通道 + public NET_DVR_PLATE_INFO struPlateInfo; //车牌信息结构 + public NET_DVR_VEHICLE_INFO struVehicleInfo; //车辆信息 + public byte[] byMonitoringSiteID = new byte[MAX_ID_LEN]; //监测点编号 + public byte[] byDeviceID = new byte[MAX_ID_LEN]; //设备编号 + public int dwPicNum; //图片数量(与picGroupNum不同,代表本条信息附带的图片数量,图片信息由struVehicleInfoEx定义 + public NET_ITS_PICTURE_INFO[] struPicInfo = new NET_ITS_PICTURE_INFO[2]; //图片信息,单张回调,最多2张图,由序号区分 + public byte[] byRes2 = new byte[256]; + } + + public static class NET_DVR_SNAPCFG extends Structure { + + public int dwSize; + public byte byRelatedDriveWay;//触发IO关联的车道号 + public byte bySnapTimes; //线圈抓拍次数,0-不抓拍,非0-连拍次数,目前最大5次 + public short wSnapWaitTime; //抓拍等待时间,单位ms,取值范围[0,60000] + public short[] wIntervalTime = new short[MAX_INTERVAL_NUM];//连拍间隔时间,ms + public int dwSnapVehicleNum; //抓拍车辆序号。 + public NET_DVR_JPEGPARA struJpegPara;//抓拍图片参数 + public byte[] byRes2 = new byte[16]; + } + + // 道闸控制 + public static class NET_DVR_BARRIERGATE_CFG extends Structure { + public int dwSize; + public int dwChannel; //通道号 + public byte byLaneNo; //道闸号(0-表示无效值(设备需要做有效值判断),1-道闸1) + /* + 若老的平台不支持byUnlock字段,该字段将赋值为0,通过“0-关闭道闸,1-开启道闸,2-停止道闸”中的任何一种操作皆可进行解锁。 + 若新平台支持byUnlock字段,需byUnlock字段赋值为1,并结合4~解锁道闸来进行解锁。byUnlock字段赋值为1后,“0-关闭道闸,1-开启道闸,2-停止道闸”操作将不可用于解锁。 + */ + public byte byBarrierGateCtrl;//0-关闭道闸,1-开启道闸,2-停止道闸 3-锁定道闸,4~解锁道闸 + public byte byEntranceNo;//出入口编号 [1,8] + public byte byUnlock;//启用解锁使能,0~为不启用,1~启用 + public byte[] byRes = new byte[12]; + } + + + public static class NET_DVR_GROUP_PARAM extends Structure { + public int dwTeenage;//少年(人数) + public int dwYouth;//青年(人数) + public int dwMidLife;//中年(人数) + public int dwElderly;//老年(人数) + public int dwChild;//儿童(人数) + public int dwAdolescent;//青少年(人数) + public int dwPrime;//壮年(人数) + public int dwMidage;//中老年(人数) + public byte[] byRes = new byte[48]; + } + + public static class NET_DVR_SEXGROUP_PARAM extends Structure { + public int dwMale;//男(人数) + public int dwFemale;//女(人数) + public byte[] byRes = new byte[64]; + } + + public static class NET_DVR_PROGRAM_INFO extends Structure { + public int dwProgramNo; //节目编号 + public byte[] sProgramName = new byte[NAME_LEN]; //节目名称 + public byte[] byRes = new byte[16]; + } + + public static class NET_DVR_FACECAPTURE_STATISTICS_RESULT extends Structure { + public int dwSize; + public NET_DVR_TIME_EX struStartTime;/*间隔开始时间*/ + public NET_DVR_TIME_EX struEndTime;/*间隔结束时间*/ + public byte byStatType;//数据类型统计:Bit0-年龄段有效,Bit1-性别有效,Bit2-人数有效 + public byte[] byRes = new byte[7]; + public int dwPeopleNum;//人数统计 + public byte[] byRes2=new byte[80]; // + public NET_DVR_SEXGROUP_PARAM struSexGroupParam;//性别人数统计 + public NET_DVR_PROGRAM_INFO struProgramInfo; //节目信息 + public byte[] byRes1 = new byte[76]; + } + + //获取交通数据条件结构 + public static class NET_DVR_TRAFFIC_DATA_QUERY_COND extends Structure { + public int dwSize; + /* + Bit0-通道有效 + Bit1-时间有效 + Bit2-车牌号有效 + Bit3-车牌类型有效 + Bit4-车牌颜色有效 + Bit5-车身颜色有效 + Bit6-车辆类型有效 + Bit7-车辆品牌有效 + Bit8-车道号有效 + Bit9-监测方向有效 + Bit10-最低速度有效 + Bit11-最高速度有效 + Bit12-数据类型有效 + Bit13-布防方式类型有效 + Bit14-违法取证有效 + Bit15-事件类型有效 + Bit16-取证类型有效 + */ + public int dwQueryCond;//查询条件 0表示无效,1表示有效 + public int dwChannel;//默认是1([1~32],bit0表示通道1,依次类推bit31表示通道32) + public NET_DVR_TIME_V30 struStartTime;//开始时间 + public NET_DVR_TIME_V30 struEndTime;//结束时间 + public byte[] sLicense = new byte[MAX_LICENSE_LEN/*16*/];//(设备支持模糊查询, GB2312编码) + /* + Bit0-未知(其他) + Bit1-标准民用车与特种车 + Bit2-02式民用车牌 + Bit3- + Bit4-警车 + Bit5-民用车双行尾牌 + Bit6-使馆车牌 + Bit7-农用车 + Bit8-摩托车 + */ + public int dwPlateType;//车牌类型(支持按位表示,可以复选) + /* + Bit0-未知(其他) + Bit1-黄色 + Bit2-白色 + Bit3-黑色 + Bit4-绿色 + Bit5-蓝色 + */ + public int dwPlateColor;//车牌颜色(支持按位表示,可以复选) + /* + Bit0-未ª知(其他) + Bit1-白色 + Bit2-银色 + Bit3-灰色 + Bit4-黑色 + Bit5-红色 + Bit6-深蓝色 + Bit7-蓝色 + Bit8-黄色 + Bit9-绿色 + Bit10-棕色 + Bit11-粉色 + Bit12-紫色 + Bit13-深灰色 + */ + public int dwVehicleColor;//车身颜色(支持按位表示,可以复选) + /* + Bit0-未知(其他) + Bit1-客车 + Bit2-大货车 + Bit3-轿车 + Bit4-面包车 + Bit5-小货车 + Bit6-行人 + Bit7-二轮车 + Bit8-三轮车 + Bit9-SUV/MPV + Bit10-中型客车 + */ + public int dwVehicleType;//车辆类型(支持按位表示,可以复选) + /** + * Bit0-其他(保留) + * Bit1-低速 + * Bit2-超速 + * Bit3-逆行 + * Bit4-闯红灯 + * Bit5-压车道线 + * Bit6-不按导向 + * Bit7-路口滞留 + * Bit8-机占非 + * Bit9-违法变道 + * Bit10-不按车道 + * Bit11-违反禁令 + * Bit12-路口停车 + * Bit13-绿灯停车 + * Bit14-未礼让行人 + * Bit15-违章停车 + * Bit16-违章掉头 + * Bit17-占用应急车道 + * Bit18-未系安全带 + */ + public int dwIllegalType; + /** + * Bit0-其他(保留) + * Bit1-拥堵 + * Bit2-停车 + * Bit3-逆行 + * Bit4-行人 + * Bit5-抛洒物 + * Bit6-烟雾 + * Bit7-压线 + * Bit8-禁止名单 + * Bit9-超速 + * Bit10-变道 + * Bit11-掉头 + * Bit12-机占非 + * Bit13-加塞 + */ + public int dwEventType; + /** + * Bit0-其他(保留) + * Bit1-城市公路违法停车 + * Bit2-高速公路违法停车 + * Bit3-压线 + * Bit4-逆行 + * Bit5-违法变道 + * Bit6-机占非 + */ + public int dwForensiceType; + public short wVehicleLogoRecog; //车辆主品牌,参考"车辆主品牌.xlsx" (仅单选) + public byte byLaneNo;//车道号(0~255,0号车道 表示 车道号未知) + public byte byDirection;//监测方向,1-上行,2-下行,3-双向,4-由东向西,5-由南向北,6-由西向东,7-由北向南 + public short wMinSpeed;//最低速度(0~999)单位km/h + public short wMaxSpeed;//最高速度(0~999)单位km/h + public byte byDataType;//数据类型 0-卡口数据,1-违法数据,2-交通事件,3-取证数据 (仅单选) + public byte byExecuteCtrl;//布防 0-允许名单,1-禁止名单,0xff-其他 + public byte[] byRes = new byte[254]; + } + + public static final int MAX_TRAFFIC_PICTURE_NUM = 8; //交通图片数量 + + //交通数据结构体 + public static class NET_DVR_TRAFFIC_DATA_QUERY_RESULT extends Structure { + public int dwSize; + public int dwChannel;//默认是1([1~32]) + public byte[] sLicense = new byte[MAX_LICENSE_LEN/*16*/]; + /* + Bit0-未知(其他) + Bit1-标准民用车与特种车 + Bit2-02式民用车牌 + Bit4-警车 + Bit5-民用车双行尾牌 + Bit6-使馆车牌 + Bit7-农用车 + Bit8-摩托车 + */ + public int dwPlateType;//车牌类型 + /* + Bit0-未知(其他) + Bit1-黄色 + Bit2-白色 + Bit3-黑色 + Bit4-绿色 + Bit5-蓝色 + */ + public int dwPlateColor;//车牌颜色 + /* + Bit0-未知(其他) + Bit1-白色 + Bit2-银色 + Bit3-灰色 + Bit4-黑色 + Bit5-红色 + Bit6-深蓝色 + Bit7-蓝色 + Bit8-黄色 + Bit9-绿色 + Bit10-棕色 + Bit11-粉色 + Bit12-紫色 + Bit13-深灰色 + */ + public int dwVehicleColor;//车身颜色 + /* + Bit0-未知(其他) + Bit1-客车 + Bit2-大货车 + Bit3-轿车 + Bit4-面包车 + Bit5-小货车 + Bit6-行人 + Bit7-二轮车 + Bit8-三轮车 + Bit9-SUV/MPV + Bit10-中型客车 + Bit11-机动车 + Bit12-非机动车 + Bit13-小型轿车 + Bit14-微型轿车 + Bit15-皮卡车 + Bit16-集装箱卡车 + Bit17-微卡,栏板卡 + Bit18-渣土车 + Bit19-吊车,工程车 + Bit20-油罐车 + Bit21-混凝土搅拌车 + Bit22-平板拖车 + Bit23-两厢轿车 + Bit24-三厢轿车 + Bit25-轿跑 + Bit26-小型客车 + */ + public int dwVehicleType;//车辆类型 + /** + * Bit0-其他(保留) + * Bit1-低速 + * Bit2-超速 + * Bit3-逆行 + * Bit4-闯红灯 + * Bit5-压车道线 + * Bit6-不按导向 + * Bit7-路口滞留 + * Bit8-机占非 + * Bit9-违法变道 + * Bit10-不按车道 + * Bit11-违反禁令 + * Bit12-路口停车 + * Bit13-绿灯停车 + * Bit14-未礼让行人 + * Bit15-违章停车 + * Bit16-违章掉头 + * Bit17-占用应急车道 + * Bit18-未系安全带 + */ + public int dwIllegalType; + /** + * Bit0-其他(保留) + * Bit1-拥堵 + * Bit2-停车 + * Bit3-逆行 + * Bit4-行人 + * Bit5-抛洒物 + * Bit6-烟雾 + * Bit7-压线 + * Bit8-禁止名单 + * Bit9-超速 + * Bit10-变道 + * Bit11-掉头 + * Bit12-机占非 + * Bit13-加塞 + */ + public int dwEventType; + /** + * Bit0-其他(保留) + * Bit1-城市公路违法停车 + * Bit2-高速公路违法停车 + * Bit3-压线 + * Bit4-逆行 + * Bit5-违法变道 + * Bit6-机占非 + */ + public int dwForensiceType; + public short wVehicleLogoRecog; //车辆主品牌,参考"车辆主品牌.xlsx" + public byte byLaneNo;//车道号(0~255,0号车道 表示 车道号未知) + public byte byDirection;//监测方向,1-上行,2-下行,3-双向,4-由东向西,5-由南向北,6-由西向东,7-由北向南 + public short wSpeed;//速度(0~999)单位km/h + public byte byDataType;//数据类型: 0-卡口 1-违法 2-事件 3-取证 + public byte[] byRes = new byte[253]; + public NET_DVR_TRAFFIC_PICTURE_PARAM[] struTrafficPic = new NET_DVR_TRAFFIC_PICTURE_PARAM[MAX_TRAFFIC_PICTURE_NUM/*8*/]; + } + + //交通图片参数子结构 + public static final int PICTURE_NAME_LEN = 64; + + public static class NET_DVR_TRAFFIC_PICTURE_PARAM extends Structure { + public NET_DVR_TIME_V30 struRelativeTime = new NET_DVR_TIME_V30(); //抓拍相对时标 + public NET_DVR_TIME_V30 struAbsTime = new NET_DVR_TIME_V30(); //抓拍绝对时标 + public byte[] szPicName = new byte[PICTURE_NAME_LEN/*64*/]; + public byte byPicType;//图片类型 0-车牌图,1-抓拍原图,2-合成图,3-特写图 + public byte[] byRes = new byte[63]; + } + + public static class NET_DVR_VEHICLE_CONTROL_COND extends Structure { + public int dwChannel; + public int dwOperateType; + public byte[] sLicense = new byte[MAX_LICENSE_LEN]; + public byte[] sCardNo = new byte[48]; + public byte byListType; + public byte[] byRes1 = new byte[3]; + public int dwDataIndex; + public byte[] byRes = new byte[116]; + } + + public static class NET_DVR_VEHICLE_CONTROL_LIST_INFO extends Structure { + public int dwSize; + public int dwChannel; + public int dwDataIndex; + public byte[] sLicense = new byte[16]; + public byte byListType; + public byte byPlateType; + public byte byPlateColor; + public byte[] byRes = new byte[21]; + public byte[] sCardNo = new byte[48]; + public NET_DVR_TIME_V30 struStartTime = new NET_DVR_TIME_V30(); + public NET_DVR_TIME_V30 struStopTime = new NET_DVR_TIME_V30(); + public byte[] sOperateIndex = new byte[32]; + public byte[] byRes1 = new byte[224]; + } + + //车辆报警 + public static class NET_DVR_VEHICLE_CONTROL_ALARM extends Structure { + public int dwSize; + public byte byListType; //名单属性:0-允许名单,1-禁止名单,2-临时名单 + public byte byPlateType; //车牌类型 + public byte byPlateColor; //车牌颜色 + public byte byRes1; + public byte[] sLicense = new byte[MAX_LICENSE_LEN];//车牌号码 + public byte[] sCardNo = new byte[MAX_CARDNO_LEN]; // 卡号 + public NET_DVR_TIME_V30 struAlarmTime = new NET_DVR_TIME_V30(); //报警时间 + public int dwChannel; //设备通道号,如果直连的是IPC,则为ipc通道号;如果连的DVR\nvr,则为DVR\NVR的通道号 + public int dwPicDataLen; //图片数据大小,0表示无图片,不为0是表示后面带图片数据 + public byte byPicType; //图片类型,0-JPEG + public byte byPicTransType; //图片数据传输方式: 0-二进制;1-url + public byte[] byRes3 = new byte[2]; + public Pointer pPicData; + public byte[] byRes2 = new byte[48]; + } + + public int MAX_LED_INFO_LEN = 512; + public int MAX_VOICE_INFO_LEN = 128; + + //LED屏幕显示参数 + public static class NET_DVR_LEDDISPLAY_CFG extends Structure { + public int dwSize;//结构体大小 + public byte[] sDisplayInfo = new byte[MAX_LED_INFO_LEN/*512*/]; // LED显示内容 + public byte byDisplayMode;//显示方式:0~左移,1~右移,2~立即显示 + public byte bySpeedType;//速度类型:0~快,1~中,2~慢 + public byte byShowPlateEnable;//显示车牌使能,0~关闭,1~启用 + public byte byRes1; + public int dwShowTime;//显示时长,1~60秒 + public byte[] byRes = new byte[128]; + } + + //语音播报控制参数 + public static class NET_DVR_VOICEBROADCAST_CFG extends Structure { + public int dwSize;//结构体大小 + public byte[] sInfo = new byte[MAX_VOICE_INFO_LEN/*128*/]; //语音播报内容 + public byte byBroadcastNum;// 语音播报次数, 1~10次 + public byte byIntervalTime;// 语音播报间隔时间,1~5s + public byte[] byRes = new byte[126]; + } + + //缴费金额信息 + public static class NET_DVR_CHARGEACCOUNT_CFG extends Structure { + public int dwSize;//结构体大小 + public float fAccount;//实际收费金额 + public byte[] byRes = new byte[128]; + } + + public static final int DOOR_NAME_LEN = 32; //门名称 + public static final int STRESS_PASSWORD_LEN = 8; //胁迫密码长度 + public static final int SUPER_PASSWORD_LEN = 8; //胁迫密码长度 + public static final int UNLOCK_PASSWORD_LEN = 8; // 解除密码长度 + + public static class NET_DVR_DOOR_CFG extends Structure { + public int dwSize; + public byte[] byDoorName = new byte[DOOR_NAME_LEN]; //门名称 + public byte byMagneticType; //门磁类型,0-常闭,1-常开 + public byte byOpenButtonType; //开门按钮类型,0-常闭,1-常开 + public byte byOpenDuration; //开门持续时间,1-255s(楼层继电器动作时间) + public byte byDisabledOpenDuration; //卡开门持续时间,1-255s + public byte byMagneticAlarmTimeout; //门磁检测超时报警时间,0-255s,0表示不报警 + public byte byEnableDoorLock; //是否启用闭门回锁,0-否,1-是 + public byte byEnableLeaderCard; //是否启用首卡常开功能,0-否,1-是 + public byte byLeaderCardMode; //首卡模式,0-不启用首卡功能,1-首卡常开模式,2-首卡授权模式(使用了此字段,则byEnableLeaderCard无效) + public int dwLeaderCardOpenDuration; //首卡常开持续时间,1-1440min + public byte[] byStressPassword = new byte[STRESS_PASSWORD_LEN]; //胁迫密码 + public byte[] bySuperPassword = new byte[SUPER_PASSWORD_LEN]; //超级密码 + public byte[] byUnlockPassword = new byte[UNLOCK_PASSWORD_LEN]; //解除码NET_DVR_LOCAL_CONTROLLER_STATUS + public byte byUseLocalController; //只读,是否连接在就地控制器上,0-否,1-是 + public byte byRes1; + public short wLocalControllerID; //只读,就地控制器序号,1-64,0代表未注册 + public short wLocalControllerDoorNumber; //只读,就地控制器的门编号,1-4,0代表未注册 + public short wLocalControllerStatus; //只读,就地控制器在线状态:0-离线,1-网络在线,2-环路1上的RS485串口1,3-环路1上的RS485串口2,4-环路2上的RS485串口1,5-环路2上的RS485串口2,6-环路3上的RS485串口1,7-环路3上的RS485串口2,8-环路4上的RS485串口1,9-环路4上的RS485串口2(只读) + public byte byLockInputCheck; //是否启用门锁输入检测(1字节,0不启用,1启用,默认不启用) + public byte byLockInputType; //门锁输入类型(1字节,0常闭,1常开,默认常闭) + public byte byDoorTerminalMode; //门相关端子工作模式(1字节,0防剪防短,1普通,默认防剪防短) + public byte byOpenButton; //是否启用开门按钮(1字节,0是,1否,默认是) + public byte byLadderControlDelayTime; //梯控访客延迟时间,1-255min + public byte[] byRes2 = new byte[43]; + } + + public static class NET_DVR_DOOR_STATUS_PLAN extends Structure { + public int dwSize; + public int dwTemplateNo; //计划模板编号,为0表示取消关联,恢复默认状态(普通状态) + public byte[] byRes = new byte[64]; + } + + + public static class NET_DVR_EVENT_CARD_LINKAGE_COND extends Structure { + public int dwSize; + public int dwEventID; //事件ID + public short wLocalControllerID; //就地控制器序号[1,64] + public byte[] byRes = new byte[106]; + } + + public static final int MAX_ALARMHOST_ALARMIN_NUM = 512;//网络报警主机最大报警输入口数 + public static final int MAX_ALARMHOST_ALARMOUT_NUM = 512;//网络报警主机最大报警输出口数 + + public static class NET_DVR_EVENT_CARD_LINKAGE_CFG_V50 extends Structure { + public int dwSize; //结构体大小 + public byte byProMode; //联动方式,0-事件,1-卡号, 2-MAC地址 + public byte[] byRes1 = new byte[3]; + public int dwEventSourceID; //事件源ID,当主类型为设备事件时无效, 当主类型是门事件时为门编号;当主类型为读卡器事件时,为读卡器ID;当为报警输入事件时为防区报警输入ID或事件报警输入ID。0xffffffff表示联动全部 + public NET_DVR_EVETN_CARD_LINKAGE_UNION uLinkageInfo = new NET_DVR_EVETN_CARD_LINKAGE_UNION(); //联动方式参数 + public byte[] byAlarmout = new byte[MAX_ALARMHOST_ALARMOUT_NUM]; //关联的报警输出号,按位表示,为0表示不关联,为1表示关联 + public byte[] byRes2 = new byte[32]; //保留 + public byte[] byOpenDoor = new byte[MAX_DOOR_NUM_256]; //按位表示,是否联动开门,0-不联动,1-联动 + public byte[] byCloseDoor = new byte[MAX_DOOR_NUM_256]; //按位表示,是否联动关门,0-不联动,1-联动 + public byte[] byNormalOpen = new byte[MAX_DOOR_NUM_256]; //按位表示,是否联动常开,0-不联动,1-联动 + public byte[] byNormalClose = new byte[MAX_DOOR_NUM_256]; //按位表示,是否联动常关,0-不联动,1-联动 + public byte byMainDevBuzzer; //主机蜂鸣器 0-不联动,1-联动输出 + public byte byCapturePic; //是否联动抓拍,0-不联动抓拍,1-联动抓拍 + public byte byRecordVideo; //是否联动录像,0-不联动录像,1-联动录像 + public byte[] byRes3 = new byte[29]; //保留 + public byte[] byReaderBuzzer = new byte[MAX_CARD_READER_NUM_512]; //联动读卡器蜂鸣器,按位表示,0-不联动,1-联动 + public byte[] byAlarmOutClose = new byte[MAX_ALARMHOST_ALARMOUT_NUM]; //关联报警输出关闭,按字节表示,为0表示不关联,为1表示关联 + public byte[] byAlarmInSetup = new byte[MAX_ALARMHOST_ALARMIN_NUM]; //关联防区布防,按字节表示,为0表示不关联,为1表示关联 + public byte[] byAlarmInClose = new byte[MAX_ALARMHOST_ALARMIN_NUM]; //关联防区撤防,按字节表示,为0表示不关联,为1表示关联 + public byte[] byRes = new byte[500]; //保留 + } + + public static class NET_DVR_EVENT_LINKAGE_CARD_CFG_V51 extends Structure { + public int dwSize; //结构体大小 + public byte byProMode; //联动方式,0-事件,1-卡号,2-MAC地址,3-工号(人员ID) + public byte[] byRes1=new byte[3]; + public int dwEventSourceID; //事件源ID,当主类型为设备事件时无效, 当主类型是门事件时为门编号;当主类型为读卡器事件时,为读卡器ID;当为报警输入事件时为防区报警输入ID或事件报警输入ID。0xffffffff表示联动全部 + public NET_DVR_EVETN_CARD_LINKAGE_UNION uLinkageInfo; //联动方式参数 + public byte[] byAlarmout=new byte[MAX_ALARMHOST_ALARMOUT_NUM]; //关联的报警输出号,按位表示,为0表示不关联,为1表示关联 + public byte[] byRes2=new byte[32]; //保留 + public byte[] byOpenDoor=new byte[MAX_DOOR_NUM_256]; //按位表示,是否联动开门,0-不联动,1-联动 + public byte[] byCloseDoor=new byte[MAX_DOOR_NUM_256]; //按位表示,是否联动关门,0-不联动,1-联动 + public byte[] byNormalOpen=new byte[MAX_DOOR_NUM_256]; //按位表示,是否联动常开,0-不联动,1-联动 + public byte[] byNormalClose=new byte[MAX_DOOR_NUM_256]; //按位表示,是否联动常关,0-不联动,1-联动 + public byte byMainDevBuzzer; //主机蜂鸣器 0-不联动,1-联动输出 + public byte byCapturePic; //是否联动抓拍,0-不联动抓拍,1-联动抓拍 + public byte byRecordVideo; //是否联动录像,0-不联动录像,1-联动录像 + public byte byMainDevStopBuzzer; //主机停止蜂鸣 0-不联动,1-联动输出 + public short wAudioDisplayID; //联动语音播放ID:0-不联动,目前范围1-32 + public byte byAudioDisplayMode; //联动语音播放模式:0-关闭,1-单次播放,2-循环播放 + public byte[] byRes3=new byte[25]; //保留 + public byte[] byReaderBuzzer=new byte[MAX_CARD_READER_NUM_512]; //联动读卡器蜂鸣器,按位表示,0-不联动,1-联动 + public byte[] byAlarmOutClose=new byte[MAX_ALARMHOST_ALARMOUT_NUM]; //关联报警输出关闭,按字节表示,为0表示不关联,为1表示关联 + public byte[] byAlarmInSetup=new byte[MAX_ALARMHOST_ALARMIN_NUM]; //关联防区布防,按字节表示,为0表示不关联,为1表示关联 + public byte[] byAlarmInClose=new byte[MAX_ALARMHOST_ALARMIN_NUM]; //关联防区撤防,按字节表示,为0表示不关联,为1表示关联 + public byte[] byReaderStopBuzzer=new byte[MAX_CARD_READER_NUM_512]; //联动读卡器停止蜂鸣,按字节表示,0-不联动,1-联动 + public byte[] byRes=new byte[512]; //保留 + } + + + + + public static class NET_DVR_EVENT_LINKAGE_INFO extends Structure { + public short wMainEventType; //事件主类型,0-设备事件,1-报警输入事件,2-门事件,3-读卡器事件 + public short wSubEventType; //事件次类型 + public byte[] byRes = new byte[28]; + } + + public static class NET_DVR_EVETN_CARD_LINKAGE_UNION extends Union { + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //卡号 + public NET_DVR_EVENT_LINKAGE_INFO struEventLinkage; //事件联动时参数 + public byte[] byMACAddr = new byte[MACADDR_LEN]; //物理MAC地址 + public byte[] byEmployeeNo = new byte[NET_SDK_EMPLOYEE_NO_LEN]; //工号(人员ID) + } + + //卡参数配置条件 + public static class NET_DVR_CARD_CFG_COND extends Structure { + public int dwSize; + public int dwCardNum; + public byte byCheckCardNo; + public byte[] ibyRes = new byte[31]; + } + + //获取卡参数的发送数据 + public static class NET_DVR_CARD_CFG_SEND_DATA extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[32]; + public byte[] byRes = new byte[16]; + } + + public static class CARDRIGHTPLAN extends Structure { + public byte[] byRightPlan = new byte[4]; + } + + //卡参数 + public static class NET_DVR_CARD_CFG extends Structure { + public int dwSize; + public int dwModifyParamType; + public byte[] byCardNo = new byte[32]; + public byte byCardValid; + public byte byCardType; + public byte byLeaderCard; + public byte byRes1; + public int dwDoorRight; + public NET_DVR_VALID_PERIOD_CFG struValid; + public int dwBelongGroup; + public byte[] byCardPassword = new byte[8]; + public CARDRIGHTPLAN[] byCardRightPlan = new CARDRIGHTPLAN[32]; + public int dwMaxSwipeTime; + public int dwSwipeTime; + public short wRoomNumber; + public short wFloorNumber; + public byte[] byRes2 = new byte[20]; + } + + public int ACS_CARD_NO_LEN = 32; //门禁卡号长度 + public int MAX_GROUP_NUM_128 = 128; //最大群组数 + public int MAX_DOOR_NUM_256 = 256; //最大门数 + public int CARD_PASSWORD_LEN = 8; //卡密码长度 + public int MAX_CARD_READER_NUM = 64; //最大读卡器数 + public int MAX_DOOR_CODE_LEN = 8; //房间代码长度 + public int MAX_LOCK_CODE_LEN = 8; //锁代码长度 + public int MAX_CARD_RIGHT_PLAN_NUM = 4; //卡权限最大计划个数 + public int MAX_CASE_SENSOR_NUM = 8; //最大case sensor触发器数 + + public static class CARDRIGHTPLAN_WORD extends Structure { + public short[] wRightPlan = new short[MAX_CARD_RIGHT_PLAN_NUM]; + } + + public static class NET_DVR_CARD_CFG_V50 extends Structure { + public int dwSize; + public int dwModifyParamType;//需要修改的卡参数,设置卡参数时有效,按位表示,每位代表一种参数,1为需要修改,0为不修改 + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //卡号 + public byte byCardValid; //卡是否有效,0-无效,1-有效(用于删除卡,设置时置为0进行删除,获取时此字段始终为1) + public byte byCardType; //卡类型,1-普通卡,3-禁止名单卡,4-巡更卡,5-胁迫卡,6-超级卡,7-来宾卡,8-解除卡,9-员工卡,10-应急卡,11-应急管理卡,默认普通卡 + public byte byLeaderCard; //是否为首卡,1-是,0-否 + public byte byRes1; + public byte[] byDoorRight = new byte[MAX_DOOR_NUM_256]; //门权限(楼层权限),按位表示,1为有权限,0为无权限,从低位到高位表示对门1-N是否有权限 + public NET_DVR_VALID_PERIOD_CFG struValid; //有效期参数 + public byte[] byBelongGroup = new byte[MAX_GROUP_NUM_128]; //所属群组,按字节表示,1-属于,0-不属于 + public byte[] byCardPassword = new byte[CARD_PASSWORD_LEN]; //卡密码 + public CARDRIGHTPLAN_WORD[] wCardRightPlan = new CARDRIGHTPLAN_WORD[MAX_DOOR_NUM_256]; //卡权限计划,取值为计划模板编号,同个门不同计划模板采用权限或的方式处理 + public int dwMaxSwipeTime; //最大刷卡次数,0为无次数限制(开锁次数) + public int dwSwipeTime; //已刷卡次数 + public short wRoomNumber; //房间号 + public short wFloorNumber; //层号 + public int dwEmployeeNo; //工号 + public byte[] byName = new byte[NAME_LEN]; //姓名 + public short wDepartmentNo; //部门编号 + public short wSchedulePlanNo; //排班计划编号 + public byte bySchedulePlanType; //排班计划类型:0-无意义、1-个人、2-部门 + public byte byRightType; //下发权限类型:0-普通发卡权限、1-二维码权限、2-蓝牙权限(可视对讲设备二维码权限配置项:房间号、卡号(虚拟卡号)、最大刷卡次数(开锁次数)、有效期参数;蓝牙权限:卡号(萤石APP账号)、其他参数配置与普通发卡权限一致) + public byte[] byRes2 = new byte[2]; + public int dwLockID; //锁ID + public byte[] byLockCode = new byte[MAX_LOCK_CODE_LEN]; //锁代码 + public byte[] byRoomCode = new byte[MAX_DOOR_CODE_LEN]; //房间代码 + public int dwCardRight; //卡权限 + public int dwPlanTemplate; //计划模板(每天)各时间段是否启用,按位表示,0--不启用,1-启用 + public int dwCardUserId; //持卡人ID + public byte byCardModelType; //0-空,1- S50,2- S70,3- FM1208 CPU卡,4- FM1216 CPU卡,5-国密CPU卡,6-身份证,7- NFC + public byte[] byRes3 = new byte[83]; + } + //有效期参数结构体 + public static class NET_DVR_VALID_PERIOD_CFG extends Structure { + public byte byEnable; + public byte byBeginTimeFlag; //是否限制起始时间的标志,0-不限制,1-限制 + public byte byEnableTimeFlag; //是否限制终止时间的标志,0-不限制,1-限制 + public byte byTimeDurationNo; //有效期索引,从0开始(时间段通过SDK设置给锁,后续在制卡时,只需要传递有效期索引即可,以减少数据量) + public NET_DVR_TIME_EX struBeginTime; + public NET_DVR_TIME_EX struEndTime; + public byte byTimeType; //时间类型 + public byte[] byRes2 = new byte[31]; + } + + //扩展结构体信息 + public static class NET_DVR_ID_CARD_INFO_EXTEND extends Structure { + public byte byRemoteCheck; //是否需要远程核验(0-无效,1-不需要(默认),2-需要) + public byte byThermometryUnit; //测温单位(0-摄氏度(默认),1-华氏度,2-开尔文) + public byte byIsAbnomalTemperature; //特征抓拍测温是否温度异常:1-是,0-否 + public byte byRes2; + public float fCurrTemperature; //人脸温度(精确到小数点后一位) + public NET_VCA_POINT struRegionCoordinates = new NET_VCA_POINT(); //人脸温度坐标 + public int dwQRCodeInfoLen; //二维码信息长度,不为0是表示后面带数据 + public int dwVisibleLightDataLen; //热成像相机可见光图片长度,不为0是表示后面带数据 + public int dwThermalDataLen; //热成像图片长度,不为0是表示后面带数据 + public Pointer pQRCodeInfo; //二维码信息指针 + public Pointer pVisibleLightData; //热成像相机可见光图片指针 + public Pointer pThermalData; //热成像图片指针 + public byte[] byRes = new byte[1024]; + } + + //身份证信息报警 + public static class NET_DVR_ID_CARD_INFO_ALARM extends Structure { + public int dwSize; //结构长度 + public NET_DVR_ID_CARD_INFO struIDCardCfg = new NET_DVR_ID_CARD_INFO();//身份证信息 + public int dwMajor; //报警主类型,参考宏定义 + public int dwMinor; //报警次类型,参考宏定义 + public NET_DVR_TIME_V30 struSwipeTime = new NET_DVR_TIME_V30(); //时间 + public byte[] byNetUser = new byte[MAX_NAMELEN];//网络操作的用户名 + public NET_DVR_IPADDR struRemoteHostAddr = new NET_DVR_IPADDR();//远程主机地址 + public int dwCardReaderNo; //读卡器编号,为0无效 + public int dwDoorNo; //门编号,为0无效 + public int dwPicDataLen; //图片数据大小,不为0是表示后面带数据 + public Pointer pPicData; + public byte byCardType; //卡类型,1-普通卡,3-禁止名单卡,4-巡更卡,5-胁迫卡,6-超级卡,7-来宾卡,8-解除卡,为0无效 + public byte byDeviceNo; // 设备编号,为0时无效(有效范围1-255) + public byte byMask; //是否带口罩:0-保留,1-未知,2-不戴口罩,3-戴口罩 + public byte byCurrentEvent; //是否为实时事件:0-无效,1-是(实时事件),2-否(离线事件) + public int dwFingerPrintDataLen; // 指纹数据大小,不为0是表示后面带数据 + public Pointer pFingerPrintData; + public int dwCapturePicDataLen; // 抓拍图片数据大小,不为0是表示后面带数据 + public Pointer pCapturePicData; + public int dwCertificatePicDataLen; //证件抓拍图片数据大小,不为0是表示后面带数据 + public Pointer pCertificatePicData; + public byte byCardReaderKind; //读卡器属于哪一类,0-无效,1-IC读卡器,2-身份证读卡器,3-二维码读卡器,4-指纹头 + public byte[] byRes3 = new byte[2]; + public byte byIDCardInfoExtend; //pIDCardInfoExtend是否有效:0-无效,1-有效 + public Pointer pIDCardInfoExtend; //byIDCardInfoExtend为1时,表示指向一个NET_DVR_ID_CARD_INFO_EXTEND结构体 + public int dwSerialNo; //事件流水号,为0无效 + public byte[] byRes = new byte[168]; + } + + public static final int CARD_READER_DESCRIPTION = 32; //读卡器描述 + + public static class NET_DVR_CARD_READER_CFG_V50 extends Structure { + public int dwSize; + public byte byEnable; //是否使能,1-使能,0-不使能 + public byte byCardReaderType; //读卡器类型,1-DS-K110XM/MK/C/CK,2-DS-K192AM/AMP,3-DS-K192BM/BMP,4-DS-K182AM/AMP,5-DS-K182BM/BMP,6-DS-K182AMF/ACF,7-韦根或485不在线,8- DS-K1101M/MK,9- DS-K1101C/CK,10- DS-K1102M/MK/M-A,11- DS-K1102C/CK,12- DS-K1103M/MK,13- DS-K1103C/CK,14- DS-K1104M/MK,15- DS-K1104C/CK,16- DS-K1102S/SK/S-A,17- DS-K1102G/GK,18- DS-K1100S-B,19- DS-K1102EM/EMK,20- DS-K1102E/EK,21- DS-K1200EF,22- DS-K1200MF,23- DS-K1200CF,24- DS-K1300EF,25- DS-K1300MF,26- DS-K1300CF,27- DS-K1105E,28- DS-K1105M,29- DS-K1105C,30- DS-K182AMF,31- DS-K196AMF,32-DS-K194AMP,33-DS-K1T200EF/EF-C/MF/MF-C/CF/CF-C,34-DS-K1T300EF/EF-C/MF/MF-C/CF/CF-C,35-DS-K1T105E/E-C/M/M-C/C/C-C,36-DS-K1T803F/F-M/F-S/F-E,37-DS-K1A801F/F-M/F-S/F-E,38-DS-K1107M/MK,39-DS-K1107E/EK,40-DS-K1107S/SK,41-DS-K1108M/MK,42-DS-K1108E/EK,43-DS-K1108S/SK,44-DS-K1200F,45-DS-K1S110-I,46-DS-K1T200M-PG/PGC,47-DS-K1T200M-PZ/PZC,48-DS-K1109H + public byte byOkLedPolarity; //OK LED极性,0-阴极,1-阳极 + public byte byErrorLedPolarity; //Error LED极性,0-阴极,1-阳极 + public byte byBuzzerPolarity; //蜂鸣器极性,0-阴极,1-阳极 + public byte bySwipeInterval; //重复刷卡间隔时间,单位:秒 + public byte byPressTimeout; //按键超时时间,单位:秒 + public byte byEnableFailAlarm; //是否启用读卡失败超次报警,0-不启用,1-启用 + public byte byMaxReadCardFailNum; //最大读卡失败次数 + public byte byEnableTamperCheck; //是否支持防拆检测,0-disable ,1-enable + public byte byOfflineCheckTime; //掉线检测时间 单位秒 + public byte byFingerPrintCheckLevel; //指纹识别等级,1-1/10误认率,2-1/100误认率,3-1/1000误认率,4-1/10000误认率,5-1/100000误认率,6-1/1000000误认率,7-1/10000000误认率,8-1/100000000误认率,9-3/100误认率,10-3/1000误认率,11-3/10000误认率,12-3/100000误认率,13-3/1000000误认率,14-3/10000000误认率,15-3/100000000误认率,16-Automatic Normal,17-Automatic Secure,18-Automatic More Secure(目前门禁不支持) + public byte byUseLocalController; //只读,是否连接在就地控制器上,0-否,1-是 + public byte byRes1; + public short wLocalControllerID; //只读,就地控制器序号, byUseLocalController=1时有效,1-64,0代表未注册 + public short wLocalControllerReaderID; //只读,就地控制器的读卡器ID,byUseLocalController=1时有效,0代表未注册 + public short wCardReaderChannel; //只读,读卡器通信通道号,byUseLocalController=1时有效,0韦根或离线,1-RS485A,2-RS485B + public byte byFingerPrintImageQuality; //指纹图像质量,0-无效,1-低质量(V1),2-中等质量(V1),3-高质量(V1),4-最高质量(V1),5-低质量(V2),6-中等质量(V2),7-高质量(V2),8-最高质量(V2) + public byte byFingerPrintContrastTimeOut; //指纹对比超时时间,0-无效,范围1-20代表:1s-20s,0xff-无限大 + public byte byFingerPrintRecogizeInterval; //指纹连续识别间隔,0-无效,范围1-10代表:1s-10s,0xff-无延迟 + public byte byFingerPrintMatchFastMode; //指纹匹配快速模式,0-无效,范围1-5代表:快速模式1-快速模式5,0xff-自动 + public byte byFingerPrintModuleSensitive; //指纹模组灵敏度,0-无效,范围1-8代表:灵敏度级别1-灵敏度级别8 + public byte byFingerPrintModuleLightCondition; //指纹模组光线条件,0-无效,1-室外,2-室内 + public byte byFaceMatchThresholdN; //人脸比对阀值,范围0-100 + public byte byFaceQuality; //人脸质量,范围0-100 + public byte byFaceRecogizeTimeOut; //特征识别超时时间,范围1-20代表:1s-20s,0xff-无限大 + public byte byFaceRecogizeInterval; //人脸连续识别间隔,0-无效,范围1-10代表:1s-10s,0xff-无延迟 + public short wCardReaderFunction; //只读,读卡器种类,按位表示:第1位-指纹,第二位-人脸,第三位-指静脉 + public byte[] byCardReaderDescription = new byte[CARD_READER_DESCRIPTION]; //读卡器描述 + public short wFaceImageSensitometry; //只读,人脸图像曝光度,范围0-65535 + public byte byLivingBodyDetect; //真人检测,0-无效,1-不启用,2-启用 + public byte byFaceMatchThreshold1; //人脸1:1匹配阀值,范围0-100 + public short wBuzzerTime; //蜂鸣时间,范围0s-5999s(0-代表长鸣) + public byte byFaceMatch1SecurityLevel; //人脸1:1识别安全等级,0-无效,1-一般,2-较强,3-极强 + public byte byFaceMatchNSecurityLevel; //人脸1:N识别安全等级,0-无效,1-一般,2-较强,3-极强 + public byte byEnvirMode;//特征识别环境模式,0-无效,1-室内,2-其他; + public byte byLiveDetLevelSet;//活体检测阈值等级设置,0-无效,1-低,2-中,3-高; + public byte byLiveDetAntiAttackCntLimit;//活体检测防攻击次数, 0-无效,1-255次(客户端、设备统一次数限制,根据能力级限制); + public byte byEnableLiveDetAntiAttack;//活体检测防攻击使能,0-无效,1-不启用,2-启用 + public byte bySupportDelFPByID;//只读,读卡器是否支持按手指ID删除指纹,0-无效,1-不支持,2-支持 + public byte byFaceContrastMotionDetLevel;//人脸比对时移动侦测级别,0-无效,1-低,2-中,3-高,0xff-禁用 + public byte byDayFaceMatchThresholdN; //白天人脸1:N匹配阀值,范围0-100 + public byte byNightFaceMatchThresholdN; //夜晚人脸1:N匹配阀值,范围0-100 + public byte byFaceRecogizeEnable; //特征识别使能:0-无效,1-开启,2-关闭 + public byte byBlockListMatchThreshold; //禁止名单匹配阀值,范围0-100 + public byte byRes3; + public byte byDefaultVerifyMode; //只读,读卡器默认验证方式(出厂默认),1-休眠,2-刷卡+密码,3-刷卡,4-刷卡或密码,5-指纹,6-指纹+密码,7-指纹或刷卡,8-指纹+刷卡,9-指纹+刷卡+密码,10-人脸或指纹或刷卡或密码,11-人脸+指纹,12-人脸+密码,13-人脸+刷卡,14-人脸,15-工号+密码,16-指纹或密码,17-工号+指纹,18-工号+指纹+密码,19-人脸+指纹+刷卡,20-人脸+密码+指纹,21-工号+人脸,22-人脸或人脸+刷卡,23-指纹或人脸,24-刷卡或人脸或密码,25-刷卡或人脸,26-刷卡或人脸或指纹,27-刷卡或指纹或密码 + public int dwFingerPrintCapacity;//只读,指纹容量 + public int dwFingerPrintNum;//只读,已存在指纹数量 + public byte byEnableFingerPrintNum;//只读,指纹容量使能:0-不使能,1-使能(只有当该字段为1-使能时,dwFingerPrintCapacity和dwFingerPrintNum才有效) + public byte[] byRes = new byte[231]; + } + + /**************** + * 优化接口结构体定义开始 + *************/ + + public static final int NET_SDK_CONFIG_STATUS_SUCCESS = 1000; + public static final int NET_SDK_CONFIG_STATUS_NEED_WAIT = 1001; + public static final int NET_SDK_CONFIG_STATUS_FINISH = 1002; + public static final int NET_SDK_CONFIG_STATUS_FAILED = 1003; + public static final int NET_SDK_CONFIG_STATUS_EXCEPTION = 1004; + + public static final int NET_SDK_GET_NEXT_STATUS_SUCCESS = 1000; + public static final int NET_SDK_GET_NEXT_STATUS_NEED_WAIT = 1001; + public static final int NET_SDK_NEXT_STATUS__FINISH = 1002; + public static final int NET_SDK_GET_NEXT_STATUS_FAILED = 1003; + + public static class NET_DVR_CARD_COND extends Structure { + public int dwSize; + public int dwCardNum; //设置或获取卡数量,获取时置为0xffffffff表示获取所有卡信息 + public byte[] byRes = new byte[64]; + } + + public static class NET_DVR_CARD_SEND_DATA extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //卡号 + public byte[] byRes = new byte[16]; + } + + public static class NET_DVR_CARD_RECORD extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; + public byte byCardType; + public byte byLeaderCard; + public byte byUserType; + public byte byRes1; + public byte[] byDoorRight = new byte[MAX_DOOR_NUM_256]; + public NET_DVR_VALID_PERIOD_CFG struValid = new NET_DVR_VALID_PERIOD_CFG(); + public byte[] byBelongGroup = new byte[MAX_GROUP_NUM_128]; + public byte[] byCardPassword = new byte[CARD_PASSWORD_LEN]; + public short[] wCardRightPlan = new short[MAX_DOOR_NUM_256]; + public int dwMaxSwipeTimes; + public int dwSwipeTimes; + public int dwEmployeeNo; + public byte[] byName = new byte[NAME_LEN]; + //按位表示,0-无权限,1-有权限 + //第0位表示:弱电报警 + //第1位表示:开门提示音 + //第2位表示:限制客卡 + //第3位表示:通道 + //第4位表示:反锁开门 + //第5位表示:巡更功能 + public int dwCardRight; + public byte[] byRes = new byte[256]; + } + + public static class NET_DVR_CARD_STATUS extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; + public int dwErrorCode; + public byte byStatus; // 状态:0-失败,1-成功 + public byte[] byRes = new byte[23]; + } + + + public static class NET_DVR_FACE_COND extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; + public int dwFaceNum; + public int dwEnableReaderNo; + public byte[] byRes = new byte[124]; + } + + public static class NET_DVR_FACE_RECORD extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; + public int dwFaceLen; + public Pointer pFaceBuffer; + public byte[] byRes = new byte[128]; + } + + public static class NET_DVR_FACE_STATUS extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; + public byte[] byErrorMsg = new byte[ERROR_MSG_LEN]; + public int dwReaderNo; + public byte byRecvStatus; + public byte[] byRes = new byte[131]; + } + + public static class NET_DVR_FINGERPRINT_COND extends Structure { + public int dwSize; + public int dwFingerprintNum; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; + public int dwEnableReaderNo; + public byte byFingerPrintID; + public byte[] byRes = new byte[131]; + } + + public static class NET_DVR_FINGERPRINT_RECORD extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; + public int dwFingerPrintLen; //指纹数据长度 + public int dwEnableReaderNo; //需要下发指纹的读卡器编号 + public byte byFingerPrintID; //手指编号,有效值范围为1-10 + public byte byFingerType; //指纹类型 0-普通指纹,1-胁迫指纹 + public byte[] byRes1 = new byte[30]; + public byte[] byFingerData = new byte[MAX_FINGER_PRINT_LEN]; //指纹数据内容 + public byte[] byRes = new byte[96]; + } + + public static class NET_DVR_FINGERPRINT_STATUS extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //指纹关联的卡号 + public byte byCardReaderRecvStatus; //指纹读卡器状态,按字节表示,0-失败,1-成功,2-该指纹模组不在线,3-重试或指纹质量差,4-内存已满,5-已存在该指纹,6-已存在该指纹ID,7-非法指纹ID,8-该指纹模组无需配置 + public byte byFingerPrintID; //手指编号,有效值范围为1-10 + public byte byFingerType; //指纹类型 0-普通指纹,1-胁迫指纹 + public byte byRecvStatus; //主机错误状态:0-成功,1-手指编号错误,2-指纹类型错误,3-卡号错误(卡号规格不符合设备要求),4-指纹未关联工号或卡号(工号或卡号字段为空),5-工号不存在,6-指纹数据长度为0,7-读卡器编号错误,8-工号错误 + public byte[] byErrorMsg = new byte[ERROR_MSG_LEN]; //下发错误信息,当byCardReaderRecvStatus为5时,表示已存在指纹对应的卡号 + public int dwCardReaderNo; //当byCardReaderRecvStatus为5时,表示已存在指纹对应的指纹读卡器编号,可用于下发错误返回。0时表示无错误信息 + public byte[] byRes = new byte[20]; + } + + public static class NET_DVR_CAPTURE_FINGERPRINT_COND extends Structure { + public int dwSize; + public byte byFingerPrintPicType; //图片类型:0-无意义 + public byte byFingerNo; //手指编号,范围1-10 + public byte[] byRes = new byte[126]; + } + + // + public static class NET_DVR_CAPTURE_FINGERPRINT_CFG extends Structure { + public int dwSize; + public int dwFingerPrintDataSize; //指纹数据大小 + public byte[] byFingerData = new byte[MAX_FINGER_PRINT_LEN]; //图片类型:0-无意义 + public int dwFingerPrintPicSize; //指纹图片大小,等于0时,代表无指纹图片数据 + public Pointer pFingerPrintPicBuffer; //指纹图片缓存 + public byte byFingerNo; //手指编号,范围1-10 + public byte byFingerPrintQuality; //指纹质量,范围1-100 + public byte[] byRes = new byte[62]; + } + + public static class NET_DVR_FINGER_PRINT_INFO_CTRL_V50 extends Structure { + public int dwSize; + public byte byMode; //删除方式,0-按卡号(人员ID)方式删除,1-按读卡器删除 + public byte[] byRes1 = new byte[3]; //保留 + public NET_DVR_DEL_FINGER_PRINT_MODE_V50 struProcessMode; //处理方式 + public byte[] byRes = new byte[64]; //保留 + } + + public static class NET_DVR_DEL_FINGER_PRINT_MODE_V50 extends Union { + public byte[] uLen = new byte[588]; //联合体长度 + public NET_DVR_FINGER_PRINT_BYCARD_V50 struByCard; //按卡号(人员ID)的方式删除 + public NET_DVR_FINGER_PRINT_BYREADER_V50 struByReader; //按读卡器的方式删除 + } + + public static class NET_DVR_FINGER_PRINT_BYREADER_V50 extends Structure { + public int dwCardReaderNo; //按值表示,指纹读卡器编号 + public byte byClearAllCard; //是否删除所有卡的指纹信息,0-按卡号(人员ID)删除指纹信息,1-删除所有卡(人员ID)的指纹信息 + public byte[] byRes1 = new byte[3]; //保留 + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //指纹关联的卡号 + public byte[] byEmployeeNo = new byte[NET_SDK_EMPLOYEE_NO_LEN]; //工号(人员ID) + public byte[] byRes = new byte[516]; //保留 + } + + public static class NET_DVR_FINGER_PRINT_BYCARD_V50 extends Structure { + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //指纹关联的卡号 + public byte[] byEnableCardReader = new byte[MAX_CARD_READER_NUM_512]; //指纹的读卡器信息,按位表示 + public byte[] byFingerPrintID = new byte[10]; //需要删除的手指编号,按数组下标,值表示0-不删除,1-删除该指纹 + public byte[] byRes1 = new byte[2]; + public byte[] byEmployeeNo = new byte[NET_SDK_EMPLOYEE_NO_LEN]; //工号(人员ID) + } + + //人脸删除控制参数结构体 + public static class NET_DVR_FACE_PARAM_CTRL extends Structure { + public int dwSize; + public byte byMode; //删除方式,0-按卡号方式删除,1-按读卡器删除 + public byte[] byRes1 = new byte[3]; //保留 + public NET_DVR_DEL_FACE_PARAM_MODE struProcessMode = new NET_DVR_DEL_FACE_PARAM_MODE(); //处理方式 + public byte[] byRes = new byte[64]; //保留 + + public void read() { + super.read(); + switch (byMode) { + case 0: + struProcessMode.setType(NET_DVR_FACE_PARAM_BYCARD.class); + break; + case 1: + struProcessMode.setType(NET_DVR_FACE_PARAM_BYREADER.class); + break; + default: + break; + } + struProcessMode.read(); + } + + public void write() { + super.write(); + struProcessMode.write(); + } + } + + //指纹删除控制参数结构体 + public static class NET_DVR_FINGER_PRINT_INFO_CTRL extends Structure { + public int dwSize; + public byte byMode; //删除方式,0-按卡号方式删除,1-按读卡器删除 + public byte[] byRes1 = new byte[3]; //保留 + public NET_DVR_DEL_FINGER_PRINT_MODE struProcessMode = new NET_DVR_DEL_FINGER_PRINT_MODE(); //处理方式 + public byte[] byRes = new byte[64]; //保留 + + public void read() { + super.read(); + switch (byMode) { + case 0: + struProcessMode.setType(NET_DVR_FINGER_PRINT_BYCARD.class); + break; + case 1: + struProcessMode.setType(NET_DVR_FINGER_PRINT_BYREADER.class); + break; + default: + break; + } + struProcessMode.read(); + } + + public void write() { + super.write(); + struProcessMode.write(); + } + } + + public static class NET_DVR_DEL_FINGER_PRINT_MODE extends Union { + // public byte[] uLen = new byte[588]; //联合体长度 + public NET_DVR_FINGER_PRINT_BYCARD struByCard; //按卡号的方式删除 + public NET_DVR_FINGER_PRINT_BYREADER struByReader; //按读卡器的方式删除 + } + + public static class NET_DVR_FINGER_PRINT_BYCARD extends Structure { + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //人脸关联的卡号 + public byte[] byEnableCardReader = new byte[MAX_CARD_READER_NUM_512]; //人脸的读卡器信息,按数组表示 + public byte[] byFaceID = new byte[MAX_FACE_NUM]; //需要删除的人脸编号,按数组下标,值表示0-不删除,1-删除该人脸 + public byte[] byRes1 = new byte[34]; //保留 + } + + public static class NET_DVR_FINGER_PRINT_BYREADER extends Structure { + public int dwCardReaderNo; //按值表示,人脸读卡器编号 + public byte byClearAllCard; //是否删除所有卡的人脸信息,0-按卡号删除人脸信息,1-删除所有卡的人脸信息 + public byte[] byRes1 = new byte[3]; //保留 + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //人脸关联的卡号 + public byte[] byRes = new byte[548]; //保留 + } + + //门禁主机参数 + public static class NET_DVR_ACS_CFG extends Structure { + public int dwSize; //结构体大小 + public byte byRS485Backup; //是否启用下行RS485通信备份功能,0-不启用,1-启用 + public byte byShowCapPic; //是否显示抓拍图片, 0-不显示,1-显示 + public byte byShowCardNo; //是否显示卡号,0-不显示,1-显示 + public byte byShowUserInfo; //是否显示用户信息,0-不显示,1-显示 + public byte byOverlayUserInfo;//是否叠加用户信息,0-不叠加,1-叠加 + public byte byVoicePrompt; //是否启用语音提示,0-不启用,1-启用 + public byte byUploadCapPic; //联动抓拍是否上传图片,0-不上传,1-上传 + public byte bySaveCapPic; //是否保存抓拍图片,0-不保存,1-保存 + public byte byInputCardNo; //是否是否允许按键输入卡号,0-不允许,1-允许 + public byte byEnableWifiDetect; //是否启动wifi,0-不启动,1-启动 + public byte byEnable3G4G; //3G4G使能,0-不使能,1-使能 + public byte byProtocol;//读卡器通信协议类型,0-私有协议(默认),1-OSDP协议 + public byte[] byRes = new byte[500]; + } + + /************** + * 优化接口结构体定义结束 + ***************************/ + public static class NET_DVR_UPLOAD_ID_BLOCKLIST_COND extends Structure { + public int dwSize; + public int dwBlockListNum; //禁止名单数量 + public byte[] byRes = new byte[128]; + } + + public static class NET_DVR_UPLOAD_ID_BLOCKLIST_CFG extends Structure { + public int dwSize; + public NET_DVR_ID_CARD_INFO struIDCardCfg; //身份证信息(该结构体中姓名和身份证号码为必填项,其他字段为选填项) + public byte byBlockListValid; //身份证禁止名单是否有效:0-无效,1-有效(用于按身份证号码删除身份证禁止名单,该字段为0时代表删除) + public byte[] byRes = new byte[127]; //预留 + } + + public static class NET_DVR_UPLOAD_ID_BLOCKLIST_STATUS extends Structure { + public int dwSize; + public byte[] byIDNum = new byte[MAX_ID_NUM_LEN]; //身份证号码 + public byte byStatus; //状态:0-无效,1-处理中,2-上传失败,3-成功 + public byte[] byRes = new byte[63]; + } + + public static class REMOTECONFIGSTATUS extends Structure { + public byte[] byStatus = new byte[4]; + public byte[] byErrorCode = new byte[4]; + } + + + //开锁记录 + public static class NET_DVR_UNLOCK_RECORD_INFO extends Structure { + public byte byUnlockType; //开锁方式,参考UNLOCK_TYPE_ENUM + public byte[] byRes1 = new byte[3]; //保留 + public byte[] byControlSrc = new byte[NAME_LEN]; //操作发起源信息,刷卡开锁时为卡号,蓝牙开锁时为萤石的APP账号,二维码开锁时为访客的手机号,其余情况下为设备编号 + public int dwPicDataLen; //图片数据长度 + public Pointer pImage; //图片指针 + public int dwCardUserID; //持卡人ID + public short nFloorNumber;//刷卡开锁时有效,为楼层号 + public short wRoomNumber; //操作发起源附加信息,刷卡开锁时有效,为房间号, + public short wLockID; //(对于门口机,0-表示本机控制器上接的锁、1-表示外接控制器上接的锁) + public byte[] byRes2 = new byte[2]; + public byte[] byLockName = new byte[LOCK_NAME_LEN]; //刷卡开锁时有效,锁名称,对应门参数配置中门名称 + public byte[] byEmployeeNo = new byte[NET_SDK_EMPLOYEE_NO_LEN]; //工号(人员ID) + public byte[] byRes = new byte[136]; //保留 + } + + //公告信息阅读回执 + public static class NET_DVR_NOTICEDATA_RECEIPT_INFO extends Structure { + public byte[] byNoticeNumber = new byte[MAX_NOTICE_NUMBER_LEN]; //公告编号 + public byte[] byRes = new byte[224]; //保留 + } + + //认证记录(设备未实现) + public static class NET_DVR_AUTH_INFO extends Structure { + public byte byAuthResult; //认证结果:0-无效,1-认证成功,2-认证失败 + public byte byAuthType; //认证方式:0-无效,1-指纹,2-人脸 + public byte[] byRes1 = new byte[2]; //保留 + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN/*32*/]; //卡号 + public int dwPicDataLen; //图片数据长度(当认证方式byAuthType为人脸时有效) + public Pointer pImage; //图片指针(当认证方式byAuthType为人脸时有效) + public byte[] byRes = new byte[212]; //保留 + } + + //车牌信息上传 + public static class NET_DVR_UPLOAD_PLATE_INFO extends Structure { + public byte[] sLicense = new byte[MAX_LICENSE_LEN]; //车牌号码 + public byte byColor; //车牌颜色,参考结构VCA_PLATE_COLOR + public byte[] byRes = new byte[239]; //保留 + } + + public static class NET_DVR_SEND_CARD_INFO extends Structure { + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN/*32*/]; //卡号 + public byte[] byRes = new byte[224]; //保留 + } + + //防区报警信息结构体 + public static class NET_DVR_ZONE_ALARM_INFO extends Structure { + public byte[] byZoneName = new byte[NAME_LEN]; //防区名称 + public int dwZonendex;//防区号 + public byte byZoneType;//防区类型 ENUM_ALARM_ZONE_TYPE_MANUAL-紧急开关报警;ENUM_ALARM_ZONE_TYPE_MAGNETIC-门磁报警;ENUM_ALARM_ZONE_TYPE_SMOKE-烟感报警;ENUM_ALARM_ZONE_TYPE_ACTIVE_INFRARED-主动红外报警;ENUM_ALARM_ZONE_TYPE_PASSIVE_INFRARED-被动红外报警;ENUM_ALARM_ZONE_TYPE_GAS-煤气报警 + public byte[] byRes = new byte[219]; //保留,置为0 + } + //可视对讲报警信息联合体 + public static class NET_DVR_VIDEO_INTERCOM_ALARM_INFO_UNION extends Union { + public byte[] byLen = new byte[256]; //联合体大小 + public NET_DVR_ZONE_ALARM_INFO struZoneAlarm = new NET_DVR_ZONE_ALARM_INFO(); //开锁记录 + } + + //可视对讲报警信息结构体 + public static class NET_DVR_VIDEO_INTERCOM_ALARM extends Structure { + public int dwSize; //结构体大小 + public NET_DVR_TIME_EX struTime = new NET_DVR_TIME_EX(); //时间 + public byte[] byDevNumber = new byte[MAX_DEV_NUMBER_LEN]; //设备编号 + public byte byAlarmType;//报警类型:1- 防区报警,2- 防拆报警,3- 劫持报警,4- 多次密码开锁失败报警,5- 门没开,6- 门没关,7- SOS(呼救报警),8- 通话对讲,9- 智能锁劫持指纹报警, + // 10- 智能锁劫持密码报警,11- 智能锁撬门报警,12- 智能锁门锁锁定报警,13- 智能锁电量不足报警, 14-禁止名单报警, 15-智能锁掉线, 16-门禁安全模块防拆报警 + public byte[] byRes1 = new byte[3]; //保留 + public NET_DVR_VIDEO_INTERCOM_ALARM_INFO_UNION uAlarmInfo = new NET_DVR_VIDEO_INTERCOM_ALARM_INFO_UNION(); //报警信息,byAlarmType为1时有效 + public short wLockID; //锁ID,(0-表示门口机本机控制器上接的锁、1-表示外接控制器上接的锁)(报警类型为5和6时有效) + public byte[] byRes2 = new byte[254]; //保留,置为0 + } + + //可视对讲事件记录信息联合体 + public static class NET_DVR_VIDEO_INTERCOM_EVENT_INFO_UINON extends Union { + public byte[] byLen = new byte[256]; //联合体大小 + public NET_DVR_UNLOCK_RECORD_INFO struUnlockRecord = new NET_DVR_UNLOCK_RECORD_INFO(); //开锁记录 + public NET_DVR_NOTICEDATA_RECEIPT_INFO struNoticedataReceipt = new NET_DVR_NOTICEDATA_RECEIPT_INFO(); //公告信息阅读回执 + public NET_DVR_AUTH_INFO struAuthInfo = new NET_DVR_AUTH_INFO(); //认证记录(设备未实现) + public NET_DVR_UPLOAD_PLATE_INFO struUploadPlateInfo = new NET_DVR_UPLOAD_PLATE_INFO(); //车牌信息上传 + public NET_DVR_SEND_CARD_INFO struSendCardInfo = new NET_DVR_SEND_CARD_INFO(); //门口机发卡,对应设备处于发卡状态,刷卡时上传该事件 + } + + //可视对讲事件记录 + public static class NET_DVR_VIDEO_INTERCOM_EVENT extends Structure { + public int dwSize; //结构体大小 + public NET_DVR_TIME_EX struTime = new NET_DVR_TIME_EX(); //时间 + public byte[] byDevNumber = new byte[MAX_DEV_NUMBER_LEN]; //设备编号 + public byte byEventType; //事件信息类型,1-开锁记录,2-公告信息阅读回执,3-认证记录,4-车牌信息上传,5非法卡刷卡事件,6-门口机发卡记录(需要启动门口机发卡功能,刷卡时才会上传该事件) + public byte byPicTransType; //图片数据传输方式: 0-二进制;1-url + public byte[] byRes1 = new byte[2]; //保留 + public NET_DVR_VIDEO_INTERCOM_EVENT_INFO_UINON uEventInfo = new NET_DVR_VIDEO_INTERCOM_EVENT_INFO_UINON(); //事件信息,具体内容参考byEventType取值 + public int dwIOTChannelNo; //IOT通道号 + public byte[] byRes2 = new byte[252]; //保留 + } + + public static class NET_DVR_VIDEO_CALL_PARAM extends Structure + { + public int dwSize; + public int dwCmdType; //信令类型 0-请求呼叫,1-取消本次呼叫,2-接听本次呼叫 3-拒绝本地来电呼叫 4-被叫响铃超时 5-结束本次通话,6-设备正在通话中,7-客户端正在通话中,8室内机不在线 + public short wPeriod; //期号, 范围[0,9] + public short wBuildingNumber; //楼号 + public short wUnitNumber; //单元号 + public short wFloorNumber; //层号 + public short wRoomNumber; //房间号 + public short wDevIndex; //设备编号 + public byte byUnitType; //设备类型,1-门口机,2-管理机,3-室内机,4-围墙机,5-别墅门口机,6-二次确认机,7-8700客户端,8-4200客户端,9-APP + public byte[] byRes=new byte[115]; //保留 + } + + public static class NET_DVR_CONTROL_GATEWAY extends Structure { + public int dwSize; //结构体大小 + public int dwGatewayIndex; //门禁序号,从1开始 + public byte byCommand; //操作命令,0-关闭,1-打开,2-常开(通道状态),3-恢复(普通状态) + public byte byLockType; //锁类型,0-普通(以前默认都为0),1-智能锁 + public short wLockID; //锁ID,从1开始(远程开门口机锁时,0表示门口机本机控制器上接的锁、1表示外接控制器上接的锁) + public byte[] byControlSrc = new byte[NAME_LEN]; //操作发起源信息 + public byte byControlType; //开锁类型,1-布防,2-通话 + public byte[] byRes3 = new byte[3]; + public byte[] byPassword = new byte[PASSWD_LEN]; //锁密码,当byLockType为智能锁时有效 + public byte[] byRes2 = new byte[108]; //保留 + } + + + //公告图片信息结构体 + public static class NET_DVR_NOTICE_PIC extends Structure { + public Pointer pPicData; //图片指针 + public int dwPicDataLen; //图片数据长度 + public byte[] byRes = new byte[32]; //保留 + } + + //公告数据 + public static class NET_DVR_NOTICE_DATA extends Structure { + public int dwSize; //结构体大小 + public NET_DVR_TIME_EX struTime = new NET_DVR_TIME_EX(); //公告时间 + public byte[] byNoticeNumber = new byte[MAX_NOTICE_NUMBER_LEN]; //公告编号 + public byte[] byNoticeTheme = new byte[MAX_NOTICE_THEME_LEN];//公告主题 + public byte[] byNoticeDetail = new byte[MAX_NOTICE_DETAIL_LEN]; //公告详情 + public byte byLevel; //公告等级,1-广告类信息;2-物业信息;3-报警类信息;4-通知类信息 + public byte byPicNum; //公告图片数量 + public byte[] byRes1 = new byte[2]; //保留 + public NET_DVR_NOTICE_PIC[] struNoticePic = new NET_DVR_NOTICE_PIC[MAX_NOTICE_PIC_NUM]; //公告图片 + public byte[] byRes2 = new byte[128]; //保留 + } + + public static class NET_DVR_DATE extends Structure { + public short wYear; //年 + public byte byMonth; //月 + public byte byDay; //日 + } + + //身份证信息 + public static class NET_DVR_ID_CARD_INFO extends Structure { + public int dwSize; //结构长度 + public byte[] byName = new byte[MAX_ID_NAME_LEN]; //姓名 + public NET_DVR_DATE struBirth; //出生日期 + public byte[] byAddr = new byte[MAX_ID_ADDR_LEN]; //住址 + public byte[] byIDNum = new byte[MAX_ID_NUM_LEN]; //身份证号码 + public byte[] byIssuingAuthority = new byte[MAX_ID_ISSUING_AUTHORITY_LEN]; //签发机关 + public NET_DVR_DATE struStartDate; //有效开始日期 + public NET_DVR_DATE struEndDate; //有效截止日期 + public byte byTermOfValidity; //是否长期有效, 0-否,1-是(有效截止日期无效) + public byte bySex; //性别,1-男,2-女 + public byte byNation; // + public byte[] byRes = new byte[101]; + } + + public static class NET_DVR_ACS_EVENT_INFO_EXTEND_V20 extends Structure { + public byte byRemoteCheck; //是否需要远程核验(0-无效,1-不需要(默认),2-需要) + public byte byThermometryUnit; //测温单位(0-摄氏度(默认),1-华氏度,2-开尔文) + public byte byIsAbnomalTemperature; //特征抓拍测温是否温度异常:1-是,0-否 + public byte byRes2; + public float fCurrTemperature; //人脸温度(精确到小数点后一位) + public NET_VCA_POINT struRegionCoordinates = new NET_VCA_POINT(); //人脸温度坐标 + public int dwQRCodeInfoLen; //二维码信息长度,不为0是表示后面带数据 + public int dwVisibleLightDataLen; //热成像相机可见光图片长度,不为0是表示后面带数据 + public int dwThermalDataLen; //热成像图片长度,不为0是表示后面带数据 + public Pointer pQRCodeInfo; //二维码信息指针 + public Pointer pVisibleLightData; //热成像相机可见光图片指针 + public Pointer pThermalData; //热成像图片指针 + public byte[] byRes = new byte[1024]; + + + } + + //门禁主机报警信息结构体 + public static class NET_DVR_ACS_ALARM_INFO extends Structure { + public int dwSize; + public int dwMajor; //报警主类型,参考宏定义 + public int dwMinor; //报警次类型,参考宏定义 + public NET_DVR_TIME struTime = new NET_DVR_TIME(); //时间 + public byte[] sNetUser = new byte[MAX_NAMELEN];//网络操作的用户名 + public NET_DVR_IPADDR struRemoteHostAddr = new NET_DVR_IPADDR();//远程主机地址 + public NET_DVR_ACS_EVENT_INFO struAcsEventInfo = new NET_DVR_ACS_EVENT_INFO(); //详细参数 + public int dwPicDataLen; //图片数据大小,不为0是表示后面带数据 + public Pointer pPicData; + public short wInductiveEventType; //归纳事件类型,0-无效,客户端判断该值为非0值后,报警类型通过归纳事件类型区分,否则通过原有报警主次类型(dwMajor、dwMinor)区分 + public byte byPicTransType; //图片数据传输方式: 0-二进制;1-url + public byte byRes1; //保留字节 + public int dwIOTChannelNo; //IOT通道号 + public Pointer pAcsEventInfoExtend; //byAcsEventInfoExtend为1时,表示指向一个NET_DVR_ACS_EVENT_INFO_EXTEND结构体 + public byte byAcsEventInfoExtend; //pAcsEventInfoExtend是否有效:0-无效,1-有效 + public byte byTimeType; //时间类型:0-设备本地时间,1-UTC时间(struTime的时间) + public byte byRes2; //保留字节 + public byte byAcsEventInfoExtendV20; //pAcsEventInfoExtendV20是否有效:0-无效,1-有效 + public Pointer pAcsEventInfoExtendV20; //byAcsEventInfoExtendV20为1时,表示指向一个NET_DVR_ACS_EVENT_INFO_EXTEND_V20结构体 + public byte[] byRes = new byte[4]; + } + + //门禁主机事件信息 + public static class NET_DVR_ACS_EVENT_INFO extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[32]; + public byte byCardType; + public byte byAllowListNo; + public byte byReportChannel; + public byte byCardReaderKind; + public int dwCardReaderNo; + public int dwDoorNo; + public int dwVerifyNo; + public int dwAlarmInNo; + public int dwAlarmOutNo; + public int dwCaseSensorNo; + public int dwRs485No; + public int dwMultiCardGroupNo; + public short wAccessChannel; + public byte byDeviceNo; + public byte byDistractControlNo; + public int dwEmployeeNo; + public short wLocalControllerID; + public byte byInternetAccess; + public byte byType; + public byte[] byMACAddr = new byte[MACADDR_LEN]; //物理地址,为0无效 + public byte bySwipeCardType;//刷卡类型,0-无效,1-二维码 + public byte byMask; //是否带口罩:0-保留,1-未知,2-不戴口罩,3-戴口罩 + public int dwSerialNo; //事件流水号,为0无效 + public byte byChannelControllerID; //通道控制器ID,为0无效,1-主通道控制器,2-从通道控制器 + public byte byChannelControllerLampID; //通道控制器灯板ID,为0无效(有效范围1-255) + public byte byChannelControllerIRAdaptorID; //通道控制器红外转接板ID,为0无效(有效范围1-255) + public byte byChannelControllerIREmitterID; //通道控制器红外对射ID,为0无效(有效范围1-255) + public byte byHelmet;//可选,是否戴安全帽:0-保留,1-未知,2-不戴安全, 3-戴安全帽 + public byte[] byRes = new byte[3]; + } + + public static final int NET_DEV_NAME_LEN = 64; + + public static class NET_DVR_ACS_EVENT_INFO_EXTEND extends Structure { + public int dwFrontSerialNo; //事件流水号,为0无效(若该字段为0,平台根据dwSerialNo判断是否丢失事件;若该字段不为0,平台根据该字段和dwSerialNo字段共同判断是否丢失事件)(主要用于解决报警订阅后导致dwSerialNo不连续的情况) + public byte byUserType; //人员类型:0-无效,1-普通人(主人),2-来宾(访客),3-禁止名单人,4-管理员 + public byte byCurrentVerifyMode; //读卡器当前验证方式:0-无效,1-休眠,2-刷卡+密码,3-刷卡,4-刷卡或密码,5-指纹,6-指纹+密码,7-指纹或刷卡,8-指纹+刷卡,9-指纹+刷卡+密码,10-人脸或指纹或刷卡或密码,11-人脸+指纹,12-人脸+密码,13-人脸+刷卡,14-人脸,15-工号+密码,16-指纹或密码,17-工号+指纹,18-工号+指纹+密码,19-人脸+指纹+刷卡,20-人脸+密码+指纹,21-工号+人脸,22-人脸或人脸+刷卡,23-指纹或人脸,24-刷卡或人脸或密码,25-刷卡或人脸,26-刷卡或人脸或指纹,27-刷卡或指纹或密码 + public byte byCurrentEvent; //是否为实时事件:0-无效,1-是(实时事件),2-否(离线事件) + public byte byPurePwdVerifyEnable; //设备是否支持纯密码认证, 0-不支持,1-支持 + public byte[] byEmployeeNo = new byte[NET_SDK_EMPLOYEE_NO_LEN]; //工号(人员ID)(对于设备来说,如果使用了工号(人员ID)字段,byEmployeeNo一定要传递,如果byEmployeeNo可转换为dwEmployeeNo,那么该字段也要传递;对于上层平台或客户端来说,优先解析byEmployeeNo字段,如该字段为空,再考虑解析dwEmployeeNo字段) + public byte byAttendanceStatus; //考勤状态:0-未定义,1-上班,2-下班,3-开始休息,4-结束休息,5-开始加班,6-结束加班 + public byte byStatusValue; //考勤状态值 + public byte[] byRes2 = new byte[2]; + public byte[] byUUID = new byte[NET_SDK_UUID_LEN/*36*/]; //UUID(该字段仅在对接萤石平台过程中才会使用) + public byte[] byDeviceName = new byte[NET_DEV_NAME_LEN/*64*/]; //设备序列号 + public byte[] byRes = new byte[24]; + + } + + /* + 门禁主机报警事件细节结构体 + */ + public static class NET_DVR_ACS_EVENT_DETAIL extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //卡号(mac地址),为0无效 + public byte byCardType; //卡类型,1-普通卡,3-禁止名单卡,4-巡更卡,5-胁迫卡,6-超级卡,7-来宾卡,8-解除卡,为0无效 + public byte byAllowListNo; //允许名单单号,1-8,为0无效 + public byte byReportChannel; //报告上传通道,1-布防上传,2-中心组1上传,3-中心组2上传,为0无效 + public byte byCardReaderKind; //读卡器属于哪一类,0-无效,1-IC读卡器,2-身份证读卡器,3-二维码读卡器,4-指纹头 + public int dwCardReaderNo; //读卡器编号,为0无效 + public int dwDoorNo; //门编号(楼层编号),为0无效 + public int dwVerifyNo; //多重卡认证序号,为0无效 + public int dwAlarmInNo; //报警输入号,为0无效 + public int dwAlarmOutNo; //报警输出号,为0无效 + public int dwCaseSensorNo; //事件触发器编号 + public int dwRs485No; //RS485通道号,为0无效 + public int dwMultiCardGroupNo; //群组编号 + public short wAccessChannel; //人员通道号 + public byte byDeviceNo; //设备编号,为0无效(有效范围1-255) + public byte byDistractControlNo;//分控器编号,为0无效 + public int dwEmployeeNo; //工号,为0无效 + public short wLocalControllerID; //就地控制器编号,0-门禁主机,1-64代表就地控制器 + public byte byInternetAccess; //网口ID:(1-上行网口1,2-上行网口2,3-下行网口1) + public byte byType; //防区类型,0:即时防区,1-24小时防区,2-延时防区 ,3-内部防区,4-钥匙防区 5-火警防区 6-周界防区 7-24小时无声防区 8-24小时辅助防区,9-24小时震动防区,10-门禁紧急开门防区,11-门禁紧急关门防区 0xff-无 + public byte[] byMACAddr = new byte[MACADDR_LEN]; //物理地址,为0无效 + public byte bySwipeCardType;//刷卡类型,0-无效,1-二维码 + public byte byEventAttribute; //事件属性:0-未定义,1-合法认证,2-其它 + public int dwSerialNo; //事件流水号,为0无效 + public byte byChannelControllerID; //通道控制器ID,为0无效,1-主通道控制器,2-从通道控制器 + public byte byChannelControllerLampID; //通道控制器灯板ID,为0无效(有效范围1-255) + public byte byChannelControllerIRAdaptorID; //通道控制器红外转接板ID,为0无效(有效范围1-255) + public byte byChannelControllerIREmitterID; //通道控制器红外对射ID,为0无效(有效范围1-255) + public int dwRecordChannelNum; //录像通道数目 + public Pointer pRecordChannelData;//录像通道,大小为sizeof(DWORD)* dwRecordChannelNum + public byte byUserType; //人员类型:0-无效,1-普通人(主人),2-来宾(访客),3-禁止名单人,4-管理员 + public byte byCurrentVerifyMode; //读卡器当前验证方式:0-无效,1-休眠,2-刷卡+密码,3-刷卡,4-刷卡或密码,5-指纹,6-指纹+密码,7-指纹或刷卡,8-指纹+刷卡,9-指纹+刷卡+密码,10-人脸或指纹或刷卡或密码,11-人脸+指纹,12-人脸+密码, + //13-人脸+刷卡,14-人脸,15-工号+密码,16-指纹或密码,17-工号+指纹,18-工号+指纹+密码,19-人脸+指纹+刷卡,20-人脸+密码+指纹,21-工号+人脸,22-人脸或人脸+刷卡,23-指纹或人脸,24-刷卡或人脸或密码,25-刷卡或人脸,26-刷卡或人脸或指纹,27-刷卡或指纹或密码 + public byte byAttendanceStatus; //考勤状态:0-未定义,1-上班,2-下班,3-开始休息,4-结束休息,5-开始加班,6-结束加班 + public byte byStatusValue; //考勤状态值 + public byte[] byEmployeeNo = new byte[NET_SDK_EMPLOYEE_NO_LEN]; //工号(人员ID)(对于设备来说,如果使用了工号(人员ID)字段,byEmployeeNo一定要传递,如果byEmployeeNo可转换为dwEmployeeNo,那么该字段也要传递;对于上层平台或客户端来说,优先解析byEmployeeNo字段,如该字段为空,再考虑解析dwEmployeeNo字段) + public byte byRes1; //保留 + public byte byMask; //是否带口罩:0-保留,1-未知,2-不戴口罩,3-戴口罩 + public byte byThermometryUnit; //测温单位(0-摄氏度(默认),1-华氏度,2-开尔文) + public byte byIsAbnomalTemperature; //特征抓拍测温是否温度异常:1-是,0-否 + public float fCurrTemperature; //人脸温度(精确到小数点后一位) + public NET_VCA_POINT struRegionCoordinates; //人脸温度坐标 + public byte[] byRes = new byte[48]; + } + + /* + 门禁主机报警事件配置结构体 + */ + public static class NET_DVR_ACS_EVENT_CFG extends Structure { + public int dwSize; + public int dwMajor; //报警主类型,参考宏定义 + public int dwMinor; //报警次类型,参考宏定义 + public NET_DVR_TIME struTime = new NET_DVR_TIME(); //时间 + public byte[] sNetUser = new byte[MAX_NAMELEN];//网络操作的用户名 + public NET_DVR_IPADDR struRemoteHostAddr;//远程主机地址 + public NET_DVR_ACS_EVENT_DETAIL struAcsEventInfo; //详细参数 + public int dwPicDataLen; //图片数据大小,不为0是表示后面带数据 + public Pointer pPicData; + public short wInductiveEventType; //归纳事件类型,0-无效,其他值参见2.2章节,客户端判断该值为非0值后,报警类型通过归纳事件类型区分,否则通过原有报警主次类型(dwMajor、dwMinor)区分 + public byte byTimeType; //时间类型:0-设备本地时间(默认),1-UTC时间(struTime的时间) + public byte byRes1; + public int dwQRCodeInfoLen; //二维码信息长度,不为0是表示后面带数据 + public int dwVisibleLightDataLen; //热成像相机可见光图片长度,不为0是表示后面带数据 + public int dwThermalDataLen; //热成像图片长度,不为0是表示后面带数据 + public Pointer pQRCodeInfo; //二维码信息指针 + public Pointer pVisibleLightData; //热成像相机可见光图片指针 + public Pointer pThermalData; //热成像图片指针 + public byte[] byRes = new byte[36]; + } + + public static final int NET_SDK_MONITOR_ID_LEN = 64; + + public static class NET_DVR_ACS_EVENT_COND extends Structure { + public int dwSize; + public int dwMajor; //报警主类型,参考事件上传宏定义,0-全部 + public int dwMinor; //报警次类型,参考事件上传宏定义,0-全部 + public NET_DVR_TIME struStartTime; //开始时间 + public NET_DVR_TIME struEndTime; //结束时间 + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //卡号 + public byte[] byName = new byte[NAME_LEN]; //持卡人姓名 + public byte byPicEnable; //是否带图片,0-不带图片,1-带图片 + public byte byTimeType; //时间类型:0-设备本地时间(默认),1-UTC时间(struStartTime和struEndTime的时间) + public byte[] byRes2 = new byte[2]; //保留 + public int dwBeginSerialNo; //起始流水号(为0时默认全部) + public int dwEndSerialNo; //结束流水号(为0时默认全部) + public int dwIOTChannelNo; //IOT通道号,0-无效 + public short wInductiveEventType; //归纳事件类型,0-无效,其他值参见2.2章节,客户端判断该值为非0值后,报警类型通过归纳事件类型区分,否则通过原有报警主次类型(dwMajor、dwMinor)区分 + public byte bySearchType; //搜索方式:0-保留,1-按事件源搜索(此时通道号为非视频通道号),2-按布防点ID搜索 + public byte byEventAttribute; //事件属性:0-未定义,1-合法事件,2-其它 + public byte[] szMonitorID = new byte[NET_SDK_MONITOR_ID_LEN/*64*/]; //布防点ID(由设备序列号、通道类型、编号组成,例如门禁点:设备序列号+“DOOR”+门编号) + public byte[] byEmployeeNo = new byte[NET_SDK_EMPLOYEE_NO_LEN]; //工号(人员ID) + public byte[] byRes = new byte[140]; //保留 + } + + public static class NET_DVR_ACS_WORK_STATUS_V50 extends Structure { + public int dwSize; + public byte[] byDoorLockStatus = new byte[MAX_DOOR_NUM_256]; //门锁状态(继电器开合状态),0-正常关,1-正常开,2-短路报警,3-断路报警,4-异常报警 + public byte[] byDoorStatus = new byte[MAX_DOOR_NUM_256]; //门状态(楼层状态),1-休眠,2-常开状态(自由),3-常闭状态(禁用),4-普通状态(受控) + public byte[] byMagneticStatus = new byte[MAX_DOOR_NUM_256]; //门磁状态,0-正常关,1-正常开,2-短路报警,3-断路报警,4-异常报警 + public byte[] byCaseStatus = new byte[MAX_CASE_SENSOR_NUM]; //事件触发器状态,0-无输入,1-有输入 + public short wBatteryVoltage; //蓄电池电压值,实际值乘10,单位:伏特 + public byte byBatteryLowVoltage; //蓄电池是否处于低压状态,0-否,1-是 + public byte byPowerSupplyStatus; //设备供电状态,1-交流电供电,2-蓄电池供电 + public byte byMultiDoorInterlockStatus; //多门互锁状态,0-关闭,1-开启 + public byte byAntiSneakStatus; //反潜回状态,0-关闭,1-开启 + public byte byHostAntiDismantleStatus; //主机防拆状态,0-关闭,1-开启 + public byte byIndicatorLightStatus; //指示灯状态,0-掉线,1-在线 + public byte[] byCardReaderOnlineStatus = new byte[MAX_CARD_READER_NUM_512]; //读卡器在线状态,0-不在线,1-在线 + public byte[] byCardReaderAntiDismantleStatus = new byte[MAX_CARD_READER_NUM_512]; //读卡器防拆状态,0-关闭,1-开启 + public byte[] byCardReaderVerifyMode = new byte[MAX_CARD_READER_NUM_512]; //读卡器当前验证方式,1-休眠,2-刷卡+密码,3-刷卡,4-刷卡或密码 + public byte[] bySetupAlarmStatus = new byte[MAX_ALARMHOST_ALARMIN_NUM];//报警输入口布防状态,0-对应报警输入口处于撤防状态,1-对应报警输入口处于布防状态 + public byte[] byAlarmInStatus = new byte[MAX_ALARMHOST_ALARMIN_NUM]; //按位表示报警输入口报警状态,0-对应报警输入口当前无报警,1-对应报警输入口当前有报警 + public byte[] byAlarmOutStatus = new byte[MAX_ALARMHOST_ALARMOUT_NUM]; //按位表示报警输出口状态,0-对应报警输出口无报警,1-对应报警输出口有报警 + public int dwCardNum; //已添加的卡数量 + public byte byFireAlarmStatus; //消防报警状态显示:0-正常、1-短路报警、2-断开报警 + public byte byBatteryChargeStatus; //电池充电状态:0-无效;1-充电中;2-未充电 + public byte byMasterChannelControllerStatus; //主通道控制器在线状态:0-无效;1-不在线;2-在线 + public byte bySlaveChannelControllerStatus; //从通道控制器在线状态:0-无效;1-不在线;2-在线 + public byte byAntiSneakServerStatus; //反潜回服务器状态:0-无效,1-未启用,2-正常,3-断开 + public byte[] byRes3 = new byte[3]; + public int dwAllowFaceNum; //已添加的允许名单人脸数量(通过能力集判断) + public int dwBlockFaceNum; //已添加的禁止名单人脸数量(通过能力集判断) + public byte[] byRes2 = new byte[108]; + } + + public static final int ACS_PARAM_DOOR_STATUS_WEEK_PLAN = 0x00000001;//门状态周计划参数 + public static final int ACS_PARAM_VERIFY_WEEK_PALN = 0x00000002; //读卡器周计划参数 + public static final int ACS_PARAM_CARD_RIGHT_WEEK_PLAN = 0x00000004; //卡权限周计划参数 + public static final int ACS_PARAM_DOOR_STATUS_HOLIDAY_PLAN = 0x00000008; //门状态假日计划参数 + public static final int ACS_PARAM_VERIFY_HOLIDAY_PALN = 0x00000010; //读卡器假日计划参数 + public static final int ACS_PARAM_CARD_RIGHT_HOLIDAY_PLAN = 0x00000020; //卡权限假日计划参数 + public static final int ACS_PARAM_DOOR_STATUS_HOLIDAY_GROUP = 0x00000040; //门状态假日组参数 + public static final int ACS_PARAM_VERIFY_HOLIDAY_GROUP = 0x00000080;//读卡器验证方式假日组参数 + public static final int ACS_PARAM_CARD_RIGHT_HOLIDAY_GROUP = 0x00000100; //卡权限假日组参数 + public static final int ACS_PARAM_DOOR_STATUS_PLAN_TEMPLATE = 0x00000200;//门状态计划模板参数 + public static final int ACS_PARAM_VERIFY_PALN_TEMPLATE = 0x00000400; //读卡器验证方式计划模板参数 + public static final int ACS_PARAM_CARD_RIGHT_PALN_TEMPLATE = 0x00000800; //卡权限计划模板参数 + public static final int ACS_PARAM_CARD = 0x00001000; //卡参数 + public static final int ACS_PARAM_GROUP = 0x00002000; //群组参数 + public static final int ACS_PARAM_ANTI_SNEAK_CFG = 0x00004000; //反潜回参数 + public static final int ACS_PAPAM_EVENT_CARD_LINKAGE = 0x00008000; //事件及卡号联动参数 + public static final int ACS_PAPAM_CARD_PASSWD_CFG = 0x00010000; //密码开门使能参数 + public static final int ACS_PARAM_PERSON_STATISTICS_CFG = 0x00020000; //人数统计参数 + public static final int ACS_PARAM_BLOCKLIST_PICTURE = 0x00040000; //禁止名单图片参数 + public static final int ACS_PARAM_ID_BLOCKLIST = 0x00080000; //身份证禁止名单参数 + public static final int ACS_PARAM_EXAM_INFO = 0x00100000; //考试信息参数 + public static final int ACS_PARAM_EXAMINEE_INFO = 0x00200000; //考生信息参数 + public static final int ACS_PARAM_FAILED_FACE_INFO = 0x00400000; //升级设备人脸建模失败记录 + + public static class NET_DVR_ACS_PARAM_TYPE extends Structure { + public int dwSize; + public int dwParamType; //参数类型,按位表示 + + public short wLocalControllerID; //就地控制器序号[1,64],0代表门禁主机 + public byte[] byRes = new byte[30]; + } + + + public static class NET_DVR_FACE_PARAM_COND extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //人脸关联的卡号 + public byte[] byEnableCardReader = new byte[MAX_CARD_READER_NUM_512]; //人脸的读卡器是否有效,0-无效,1-有效 + public int dwFaceNum; //设置或获取人脸数量,获取时置为0xffffffff表示获取所有人脸信息 + public byte byFaceID; //人脸编号,有效值范围为1-2 0xff表示该卡所有人脸 + public byte[] byRes = new byte[127]; //保留 + } + + public static class NET_DVR_FACE_PARAM_CFG extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //人脸关联的卡号 + public int dwFaceLen; //人脸数据长度,设备端返回的即加密后的数据 + public Pointer pFaceBuffer; //人脸数据指针 + public byte[] byEnableCardReader = new byte[MAX_CARD_READER_NUM_512]; //需要下发人脸的读卡器,按数组表示,从低位到高位表示,0-不下发该读卡器,1-下发到该读卡器 + public byte byFaceID; //人脸编号,有效值范围为1-2 + public byte byFaceDataType; //人脸数据类型:0-模板(默认),1-图片 + public byte[] byRes = new byte[126]; + } + + public static class NET_DVR_FACE_PARAM_STATUS extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //人脸关联的卡号 + public byte[] byCardReaderRecvStatus = new byte[MAX_CARD_READER_NUM_512]; //人脸读卡器状态,按字节表示,0-失败,1-成功,2-重试或人脸质量差,3-内存已满,4-已存在该人脸,5-非法人脸ID + public byte[] byErrorMsg = new byte[ERROR_MSG_LEN]; //下发错误信息,当byCardReaderRecvStatus为4时,表示已存在人脸对应的卡号 + public int dwCardReaderNo; //纹读卡器编号,可用于下发错误返回 + public byte byTotalStatus; //下发总的状态,0-当前人脸未下完所有读卡器,1-已下完所有读卡器(这里的所有指的是门禁主机往所有的读卡器下发了,不管成功与否) + public byte byFaceID; //人脸编号,有效值范围为1-2 + public byte[] byRes = new byte[130]; + } + + public static class NET_DVR_FACE_PARAM_BYCARD extends Structure { + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //人脸关联的卡号 + public byte[] byEnableCardReader = new byte[MAX_CARD_READER_NUM_512]; //人脸的读卡器信息,按数组表示 + public byte[] byFaceID = new byte[MAX_FACE_NUM]; //需要删除的人脸编号,按数组下标,值表示0-不删除,1-删除该人脸 + public byte[] byRes1 = new byte[42]; //保留 + } + + public static class NET_DVR_FACE_PARAM_BYREADER extends Structure { + public int dwCardReaderNo; //按值表示,人脸读卡器编号 + public byte byClearAllCard; //是否删除所有卡的人脸信息,0-按卡号删除人脸信息,1-删除所有卡的人脸信息 + public byte[] byRes1 = new byte[3]; //保留 + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //人脸关联的卡号 + public byte[] byRes = new byte[548]; //保留 + } + + public static class NET_DVR_DEL_FACE_PARAM_MODE extends Union { + public byte[] uLen = new byte[588]; //联合体长度 + public NET_DVR_FACE_PARAM_BYCARD struByCard; //按卡号的方式删除 + public NET_DVR_FACE_PARAM_BYREADER struByReader; //按读卡器的方式删除 + } + + public static class NET_DVR_CHECK_FACE_PICTURE_COND extends Structure { + public int dwSize; + public int dwPictureNum; //图片数量 + public byte byCheckTemplate; //0-校验图片是否合法(默认),1-校验图片和建模数据是否匹配 + public byte[] byRes = new byte[127]; + } + + public static class NET_DVR_CHECK_FACE_PICTURE_CFG extends Structure { + public int dwSize; + public int dwPictureNo; //图片编号 + public int dwPictureLen; //图片长度(图片大小不超过200k) + public Pointer pPictureBuffer; //图片指针 + public int dwFaceTemplateLen; //人脸建模数据长度 + public Pointer pFaceTemplateBuffer; //人脸建模数据指针 + public byte[] byRes = new byte[248]; + } + + public static class NET_DVR_CHECK_FACE_PICTURE_STATUS extends Structure { + public int dwSize; + public int dwPictureNo; //图片编号 + public byte byCheckStatus; //校验结果:0-无效,1-建模成功,2-建模失败,3-人脸模块通讯异常,4-图像无人脸,5-人脸朝上,6-人脸朝下,7-人脸偏左,8-人脸偏右,9-人脸顺时旋转, + //10 - 人脸逆时旋转,11-人眼间距小,12-人脸和模板匹配,13-人脸和模板不匹配,14-传输数据有误 + public byte[] byRes = new byte[127]; + } + + public static class NET_DVR_FINGER_PRINT_CFG_V50 extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //指纹关联的卡号 + public int dwFingerPrintLen; //指纹数据长度 + public byte[] byEnableCardReader = new byte[MAX_CARD_READER_NUM_512]; //需要下发指纹的读卡器,按数组表示,从低位到高位表示,0-不下发该读卡器,1-下发到该读卡器 + public byte byFingerPrintID; //手指编号,有效值范围为1-10 + public byte byFingerType; //指纹类型 0-普通指纹,1-胁迫指纹,2-巡更指纹,3-超级指纹,4-解除指纹 + public byte[] byRes1 = new byte[30]; + public byte[] byFingerData = new byte[MAX_FINGER_PRINT_LEN]; //指纹数据内容 + public byte[] byEmployeeNo = new byte[NET_SDK_EMPLOYEE_NO_LEN]; //工号(人员ID) + public byte[] byLeaderFP = new byte[MAX_DOOR_NUM_256]; //对门是否有首次认证功能(按字节表示):0-无首次认证功能,1-有首次认证功能 + public byte[] byRes = new byte[128]; + } + + public static class NET_DVR_FINGER_PRINT_STATUS_V50 extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //指纹关联的卡号 + public byte[] byCardReaderRecvStatus = new byte[MAX_CARD_READER_NUM_512]; //指纹读卡器状态,按字节表示,0-失败,1-成功,2-该指纹模组不在线,3-重试或指纹质量差,4-内存已满,5-已存在该指纹,6-已存在该指纹ID,7-非法指纹ID,8-该指纹模组无需配置,10-指纹读卡器版本过低(无法支持工号) + public byte byFingerPrintID; //手指编号,有效值范围为1-10 + public byte byFingerType; //指纹类型 0-普通指纹,1-胁迫指纹,2-巡更指纹,3-超级指纹,4-解除指纹 + public byte byTotalStatus; //下发总的状态,0-当前指纹未下完所有读卡器,1-已下完所有读卡器(这里的所有指的是门禁主机往所有的读卡器下发了,不管成功与否) + public byte byRecvStatus; //主机错误状态:0-成功,1-手指编号错误,2-指纹类型错误,3-卡号错误(卡号规格不符合设备要求),4-指纹未关联工号或卡号(工号或卡号字段为空),5-工号不存在,6-指纹数据长度为0,7-读卡器编号错误,8-工号错误 + public byte[] byErrorMsg = new byte[ERROR_MSG_LEN]; //下发错误信息,当byCardReaderRecvStatus为5时,表示已存在指纹对应的卡号 + public int dwCardReaderNo; //当byCardReaderRecvStatus为5时,表示已存在指纹对应的指纹读卡器编号,可用于下发错误返回。0时表示无错误信息 + public byte[] byEmployeeNo = new byte[NET_SDK_EMPLOYEE_NO_LEN]; //工号(人员ID) + public byte[] byErrorEmployeeNo = new byte[NET_SDK_EMPLOYEE_NO_LEN]; //下发错误信息,当byCardReaderRecvStatus为5时,表示已存在指纹对应的工号(人员ID) + public byte[] byRes = new byte[128]; + } + + public static class NET_DVR_FINGER_PRINT_INFO_COND_V50 extends Structure { + public int dwSize; + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //指纹关联的卡号(该字段获取时有效,设置时无效) + public byte[] byEnableCardReader = new byte[MAX_CARD_READER_NUM_512]; //指纹的读卡器是否有效,0-无效,1-有效 + public int dwFingerPrintNum; //设置或获指纹数量,获取时置为0xffffffff表示获取所有指纹信息 + public byte byFingerPrintID; //手指编号,有效值范围为1-10 0xff表示该卡所有指纹 + public byte byCallBackMode; //设备回调方式,0-设备所有读卡器下完了返回,1-在时间段内下了部分也返回 + public byte[] byRes2 = new byte[2]; //保留 + public byte[] byEmployeeNo = new byte[NET_SDK_EMPLOYEE_NO_LEN]; //工号(人员ID) + public byte[] byRes1 = new byte[128]; //保留 + } + + public static class NET_DVR_GROUP_CFG extends Structure { + public int dwSize; + public byte byEnable; //是否启用,0-不启用,1-启用 + public byte[] byRes1 = new byte[3]; + public NET_DVR_VALID_PERIOD_CFG struValidPeriodCfg = new NET_DVR_VALID_PERIOD_CFG(); //群组有效期参数 + public byte[] byGroupName = new byte[32]; //群组名称 + public byte[] byRes2 = new byte[32]; + } + + public static class NET_DVR_MULTI_CARD_CFG_V50 extends Structure { + public int dwSize; + public byte byEnable; + public byte bySwipeIntervalTimeout; + public byte[] byRes1 = new byte[2]; + public NET_DVR_MULTI_CARD_GROUP_CFG_V50[] struGroupCfg = (NET_DVR_MULTI_CARD_GROUP_CFG_V50[]) new NET_DVR_MULTI_CARD_GROUP_CFG_V50().toArray(20); + public byte[] byRes2 = new byte[32]; + } + + public static class NET_DVR_MULTI_CARD_GROUP_CFG_V50 extends Structure { + public byte byEnable; + public byte byEnableOfflineVerifyMode; + public byte[] byRes1 = new byte[2]; + public int dwTemplateNo; + public NET_DVR_GROUP_COMBINATION_INFO_V50[] struGroupCombination = (NET_DVR_GROUP_COMBINATION_INFO_V50[]) new NET_DVR_GROUP_COMBINATION_INFO_V50().toArray(8); + } + + public static class NET_DVR_GROUP_COMBINATION_INFO_V50 extends Structure { + public byte byEnable; + public byte byMemberNum; + public byte bySequenceNo; + public byte byRes; + public int dwGroupNo; + } + + + //自定义结构体,用于二维数组转换 + public static class NET_DVR_SINGLE_PLAN_SEGMENT_WEEK extends Structure { + public NET_DVR_SINGLE_PLAN_SEGMENT[] struPlanCfgDay = new NET_DVR_SINGLE_PLAN_SEGMENT[MAX_TIMESEGMENT_V30]; //一天的计划参数 + } + + public static class NET_DVR_WEEK_PLAN_CFG extends Structure { + public int dwSize; + public byte byEnable; //是否使能,1-使能,0-不使能 + public byte[] byRes1 = new byte[3]; + public NET_DVR_SINGLE_PLAN_SEGMENT_WEEK[] struPlanCfg = new NET_DVR_SINGLE_PLAN_SEGMENT_WEEK[MAX_DAYS]; //周计划参数 + public byte[] byRes2 = new byte[16]; + } + + public static class NET_DVR_SINGLE_PLAN_SEGMENT extends Structure { + public byte byEnable; //是否使能,1-使能,0-不使能 + public byte byDoorStatus; //门状态模式(梯控模式),0-无效,1-常开状态(自由),2-常闭状态(禁用),3-普通状态(门状态计划使用) + public byte byVerifyMode; //验证方式,0-无效,1-刷卡,2-刷卡+密码(读卡器验证方式计划使用),3-刷卡,4-刷卡或密码(读卡器验证方式计划使用), 5-指纹,6-指纹+密码,7-指纹或刷卡,8-指纹+刷卡,9-指纹+刷卡+密码(无先后顺序),10-人脸或指纹或刷卡或密码,11-人脸+指纹,12-人脸+密码, + //13-人脸+刷卡,14-人脸,15-工号+密码,16-指纹或密码,17-工号+指纹,18-工号+指纹+密码,19-人脸+指纹+刷卡,20-人脸+密码+指纹,21-工号+人脸,22-人脸或人脸+刷卡 + public byte[] byRes = new byte[5]; + public NET_DVR_TIME_SEGMENT struTimeSegment; //时间段参数 + } + + + public static class NET_DVR_TIME_SEGMENT extends Structure { + public NET_DVR_SIMPLE_DAYTIME struBeginTime; //开始时间点 + public NET_DVR_SIMPLE_DAYTIME struEndTime; //结束时间点 + } + + public static class NET_DVR_SIMPLE_DAYTIME extends Structure { + public byte byHour; //时 + public byte byMinute; //分 + public byte bySecond; //秒 + public byte byRes; + } + + public static class NET_DVR_WEEK_PLAN_COND extends Structure { + public int dwSize; + public int dwWeekPlanNumber; //周计划编号 + public short wLocalControllerID; //就地控制器序号[1,64] + public byte[] byRes = new byte[106]; + } + + public static final int TEMPLATE_NAME_LEN = 32; //计划模板名称长度 + public static final int MAX_HOLIDAY_GROUP_NUM = 16; //计划模板最大假日组数 + + public static class NET_DVR_PLAN_TEMPLATE extends Structure { + public int dwSize; + public byte byEnable; //是否启用,1-启用,0-不启用 + public byte[] byRes1 = new byte[3]; + public byte[] byTemplateName = new byte[TEMPLATE_NAME_LEN]; //模板名称 + public int dwWeekPlanNo; //周计划编号,0为无效 + public int[] dwHolidayGroupNo = new int[MAX_HOLIDAY_GROUP_NUM]; //假日组编号,就前填充,遇0无效 + public byte[] byRes2 = new byte[32]; + } + + public static class NET_DVR_PLAN_TEMPLATE_COND extends Structure { + public int dwSize; + public int dwPlanTemplateNumber; //计划模板编号,从1开始,最大值从门禁能力集获取 + public short wLocalControllerID; //就地控制器序号[1,64],0无效 + public byte[] byRes = new byte[106]; + } + + public static class NET_DVR_CAPTURE_FACE_COND extends Structure { + public int dwSize; + public byte[] byRes = new byte[128]; + } + + public static class NET_DVR_FACE_FEATURE extends Structure { + public NET_VCA_RECT struFace; //人脸子图区域 + public NET_VCA_POINT struLeftEye; // 左眼坐标 + public NET_VCA_POINT struRightEye; // 右眼坐标 + public NET_VCA_POINT struLeftMouth; // 嘴左边坐标 + public NET_VCA_POINT struRightMouth; // 嘴右边坐标 + public NET_VCA_POINT struNoseTip; // 鼻子坐标 + } + + public static class NET_DVR_CAPTURE_FACE_CFG extends Structure { + public int dwSize; + public int dwFaceTemplate1Size; //人脸模板1数据大小,等于0时,代表无人脸模板1数据 + public Pointer pFaceTemplate1Buffer; //人脸模板1数据缓存(不大于2.5k) + public int dwFaceTemplate2Size; //人脸模板2数据大小,等于0时,代表无人脸模板2数据 + public Pointer pFaceTemplate2Buffer; //人脸模板2数据缓存(不大于2.5K) + public int dwFacePicSize; //人脸图片数据大小,等于0时,代表无人脸图片数据 + public Pointer pFacePicBuffer; //人脸图片数据缓存 + public byte byFaceQuality1; //人脸质量,范围1-100 + public byte byFaceQuality2; //人脸质量,范围1-100 + public byte byCaptureProgress; //采集进度,目前只有两种进度值:0-未采集到人脸,100-采集到人脸(只有在进度为100时,才解析人脸信息) + public byte byFacePicQuality; //人脸图片中人脸质量 + public int dwInfraredFacePicSize; //红外人脸图片数据大小,等于0时,代表无人脸图片数据 + public Pointer pInfraredFacePicBuffer; //红外人脸图片数据缓存 + public byte byInfraredFacePicQuality; //红外人脸图片中人脸质量 + public byte[] byRes1 = new byte[3]; + public NET_DVR_FACE_FEATURE struFeature = new NET_DVR_FACE_FEATURE(); //人脸抠图特征信息 + public byte[] byRes = new byte[56]; + } + + public static class NET_DVR_XML_CONFIG_INPUT extends Structure { + public int dwSize; + public Pointer lpRequestUrl; + public int dwRequestUrlLen; + public Pointer lpInBuffer; + public int dwInBufferSize; + public int dwRecvTimeOut; + public byte[] byRes = new byte[32]; + } + + public static class NET_DVR_STRING_POINTER extends Structure { + public byte[] byString; + + public NET_DVR_STRING_POINTER(int iLen) { + byString = new byte[iLen]; + } + } + + public static class NET_DVR_XML_CONFIG_OUTPUT extends Structure { + public int dwSize; + public Pointer lpOutBuffer; + public int dwOutBufferSize; + public int dwReturnedXMLSize; + public Pointer lpStatusBuffer; + public int dwStatusSize; + public byte[] byRes = new byte[32]; + } + + //报警场景信息 + public static class NET_DVR_SCENE_INFO extends Structure { + public int dwSceneID; //场景ID, 0 - 表示该场景无效 + public byte[] bySceneName = new byte[NAME_LEN]; //场景名称 + public byte byDirection; //监测方向 1-上行,2-下行,3-双向,4-由东向西,5-由南向北,6-由西向东,7-由北向南,8-其它 + public byte[] byRes1 = new byte[3]; //保留 + public NET_DVR_PTZPOS struPtzPos; //Ptz 坐标 + public byte[] byRes2 = new byte[64]; //保留 + } + + // 方向结构体 + public static class NET_DVR_DIRECTION extends Structure { + public NET_VCA_POINT struStartPoint = new NET_VCA_POINT(); // 方向起始点 + public NET_VCA_POINT struEndPoint = new NET_VCA_POINT(); // 方向结束点 + } + + // 交通事件信息 + public static class NET_DVR_AID_INFO extends Structure { + public byte byRuleID; // 规则序号,为规则配置结构下标,0-16 + public byte[] byRes1 = new byte[3]; + public byte[] byRuleName = new byte[NAME_LEN]; // 规则名称 + public int dwAIDType; // 报警事件类型 + public NET_DVR_DIRECTION struDirect = new NET_DVR_DIRECTION(); // 报警指向区域 + public byte bySpeedLimit; //限速值,单位km/h[0,255] + public byte byCurrentSpeed; //当前速度值,单位km/h[0,255] + public byte byVehicleEnterState; //车辆出入状态:0- 无效,1- 驶入,2- 驶出 + public byte byState; //0-变化上传,1-轮巡上传 + public byte[] byParkingID = new byte[16]; //停车位编号 + public int dwAIDTypeEx; // 报警事件类型扩展,参考TRAFFIC_AID_TYPE_EX + public byte[] byRes2 = new byte[16]; // 保留字节 + } + + public int ILLEGAL_LEN = 32; //违法代码长度 + public int MONITORSITE_ID_LEN = 48;//监测点编号长度 + public int DEVICE_ID_LEN = 48; + + //交通取证报警 + public static class NET_DVR_TFS_ALARM extends Structure { + public int dwSize; //结构体大小 + public int dwRelativeTime; //相对时标 + public int dwAbsTime; //绝对时标 + public int dwIllegalType; //违章类型,采用国标定义,当dwIllegalType值为0xffffffff时使用byIllegalCode + public int dwIllegalDuration; //违法持续时间(单位:秒) = 抓拍最后一张图片的时间 - 抓拍第一张图片的时间 + public byte[] byMonitoringSiteID = new byte[MONITORSITE_ID_LEN];//监测点编号(路口编号、内部编号) + public byte[] byDeviceID = new byte[DEVICE_ID_LEN]; //设备编号 + public NET_VCA_DEV_INFO struDevInfo = new NET_VCA_DEV_INFO(); //前端设备信息 + public NET_DVR_SCENE_INFO struSceneInfo = new NET_DVR_SCENE_INFO(); //场景信息 + public NET_DVR_TIME_EX struBeginRecTime = new NET_DVR_TIME_EX(); //录像开始时间 + public NET_DVR_TIME_EX struEndRecTime = new NET_DVR_TIME_EX(); //录像结束时间 + public NET_DVR_AID_INFO struAIDInfo = new NET_DVR_AID_INFO(); //交通事件信息 + public NET_DVR_PLATE_INFO struPlateInfo = new NET_DVR_PLATE_INFO(); //车牌信息 + public NET_DVR_VEHICLE_INFO struVehicleInfo = new NET_DVR_VEHICLE_INFO(); //车辆信息 + public int dwPicNum; //图片数量 + public NET_ITS_PICTURE_INFO[] struPicInfo = new NET_ITS_PICTURE_INFO[8]; //图片信息,最多8张 + public byte bySpecificVehicleType; //具体车辆种类 参考识别结果类型VTR_RESULT + public byte byLaneNo; //关联车道号 + public byte[] byRes1 = new byte[2]; //保留 + public NET_DVR_TIME_V30 struTime = new NET_DVR_TIME_V30();//手动定位,当前时间。 + public int dwSerialNo;//序号; + public byte byVehicleAttribute;//车辆属性,按位表示,0- 无附加属性(普通车),bit1- 黄标车(类似年检的标志),bit2- 危险品车辆,值:0- 否,1- 是 + public byte byPilotSafebelt;//0-表示未知,1-系安全带,2-不系安全带 + public byte byCopilotSafebelt;//0-表示未知,1-系安全带,2-不系安全带 + public byte byPilotSunVisor;//0-表示未知,1-不打开遮阳板,2-打开遮阳板 + public byte byCopilotSunVisor;//0-表示未知, 1-不打开遮阳板,2-打开遮阳板 + public byte byPilotCall;// 0-表示未知, 1-不打电话,2-打电话 + public byte[] byRes2 = new byte[2]; //保留 + public byte[] byIllegalCode = new byte[ILLEGAL_LEN/*32*/];//违法代码扩展,当dwIllegalType值为0xffffffff;使用这个值 + public short wCountry; // 国家索引值,参照枚举COUNTRY_INDEX + public byte byRegion; //区域索引值,0-保留,1-欧洲(Europe Region),,3-欧洲&(EU&CIS) , 4-中东(Middle East),0xff-所有 + public byte byCrossLine;//是否压线停车(侧方停车),0-表示未知,1-不压线,2-压线 + public byte[] byParkingSerialNO = new byte[16];//泊车位编号 + public byte byCrossSpaces;//是否跨泊车位停车(侧方停车),0-表示未知,1-未跨泊车位停车,2-跨泊车位停车 + public byte byAngledParking;//是否倾斜停车(侧方停车), 0-表示未知,1-未倾斜停车,2-倾斜停车 + public byte byAlarmValidity;//报警置信度,可以输出驶入驶出的置信度,范围0-100;置信度越高,事件真实性越高 + public byte byDoorsStatus;//车门状态 0-车门关闭 1-车门开启 + public int dwXmlLen;//XML报警信息长度 + public Pointer pXmlBuf; // XML报警信息指针,其XML对应到EventNotificationAlert XML Block + public byte byVehicleHeadTailStatus;//车头车尾状态 0-保留 1-车头 2-车尾 + public byte byBrokenNetHttp; //断网续传标志位,0-不重传数据,1-重传数据 + public byte[] byRes = new byte[30]; //保留 + } + + public static class NET_ITS_OVERLAPCFG_COND extends Structure { + public int dwSize; + public int dwChannel; + public int dwConfigMode; //配置模式,0-终端,1-前端(直连前端或终端接前端) + public byte byPicModeType;//0-表示小图(独立图),1-表示大图(合成图) + /* + 0表示关联 抓拍MPR模式(多帧触发抓拍 IPC使用) + 1 表示关联 抓拍 HVT 模式(混卡IPC使用) + */ + public byte byRelateType; + public byte[] byRes = new byte[14]; + + } + + //字符叠加每一条信息结构体 + public static class NET_ITS_OVERLAP_SINGLE_ITEM_PARAM_V50 extends Structure { + public byte[] byRes1 = new byte[2]; // 保留 + public byte byItemType; //类型,详见OVERLAP_ITEM_TYPE + public byte byChangeLineNum; //叠加项后的换行数[0-10](默认0) + public byte bySpaceNum; //叠加项后的空格数[0-255](默认0) + public byte[] byRes2 = new byte[2]; + public byte byEnablePos; //是否启用坐标显示 + public short wStartPosTop; //起始上坐标,只对图片内部叠加有效[0~2448](默认0) + public short wStartPosLeft; //起始左坐标,只对图片内部叠加有效[0~2448](默认0) + //自定义类型;与byItemType参数对应。可将byItemType参数类型自定义名称。若自定义内容为空,便默认以byItemType参数中的类型命名。 + public byte[] byItemTypeCustom = new byte[32]; + public byte[] byRes = new byte[8]; + + } + + public int MAX_OVERLAP_ITEM_NUM = 50; //最大字符叠加种数 + + public static class NET_ITS_OVERLAP_ITEM_PARAM_V50 extends Structure { + public NET_ITS_OVERLAP_SINGLE_ITEM_PARAM_V50[] struSingleItem = new NET_ITS_OVERLAP_SINGLE_ITEM_PARAM_V50[MAX_OVERLAP_ITEM_NUM]; //单条字符参数 + public int dwLinePercent; //叠加行百分比(0-100),(默认100) + public int dwItemsStlye; //叠加方式:0-横排,1-竖排(默认横排) + public short wStartPosTop; //起始上坐标,只对图片内部叠加有效[0~2448](默认0) + public short wStartPosLeft; //起始左坐标,只对图片内部叠加有效[0~2448](默认0) + public short wCharStyle; //字体类型,0-宋体1-魏体(默认) + public short wCharSize; //字符大小,0--16x16,1--32x32,2-48x48,3--64x64 (默认),8x128(Ver3.7) + public short wCharInterval; //字符间距,[0~16],可设单位:像素(默认) + public byte[] byRes1 = new byte[2]; + public int dwForeClorRGB; //前景色的RGB值bit0-1:(B) bit2-3:(G) bit4-5:(G) (默认x00FFFFFF-白) + public int dwBackClorRGB; //背景色的RGB值,只对图片外叠加有效bit0-1:(B) bit2-3:(G) bit4-5:(G) (默认x00000000-黑) + public byte byColorAdapt; //颜色是否自适应0-否1-是 + //(Ver3.7 新增) + // 参数补零使能 0-补零, 1-不补零(详细注释)速度,限速值 不足3位补0 + public byte byParamFillZeroEnble; + public byte byPlateLeftCornerEnable;// 车牌小图叠加左上角使能 0-不叠加, 1-叠加 + public byte byRes2; + public short wStartSPicPosTop; //起始上坐标,只对图片内部叠加有效[0~2448](默认0) + public short wStartSPicPosLeft; //起始左坐标,只对图片内部叠加有效[0~2448](默认0) + //OSD叠加位置 0-图片内,1-图片上边缘,2-图片下边缘(合成图专用的是上边缘外)(V3.7) + public byte byOsdLocate; + public byte[] byRes = new byte[63]; + + } + + //叠加项具体信息 + public static class NET_ITS_OVERLAP_INFO_PARAM extends Structure { + public byte[] bySite = new byte[128]; //地点描述 + public byte[] byRoadNum = new byte[32]; //路口编号 + public byte[] byInstrumentNum = new byte[32]; //设备编号 + public byte[] byDirection = new byte[32]; //方向编号 + public byte[] byDirectionDesc = new byte[32]; //方向描述 + public byte[] byLaneDes = new byte[32]; //车道描述 + public byte[] byRes1 = new byte[32]; //保留 + public byte[] byMonitoringSite1 = new byte[44]; //监测点1信息 + public byte[] byMonitoringSite2 = new byte[32]; //监测点2信息 + public byte[] byRes = new byte[64]; //保留 + } + + public static class NET_ITS_OVERLAP_CFG_V50 extends Structure { + public int dwSize; + public byte byEnable; //是否启用,0-不启用,1-启用 + public byte[] byRes1 = new byte[3]; + public NET_ITS_OVERLAP_ITEM_PARAM_V50 struOverLapItemV50 = new NET_ITS_OVERLAP_ITEM_PARAM_V50(); //字符串参数 + public NET_ITS_OVERLAP_INFO_PARAM struOverLapInfo = new NET_ITS_OVERLAP_INFO_PARAM(); //字符串内容信息 + public byte[] byRes = new byte[120]; + + } + + //人体特征识别结果结构体 + public static class NET_VCA_HUMAN_FEATURE extends Structure { + public byte byRes3; + public byte bySex; //性别, 0-表示“未知”(算法不支持),1 – 男 , 2 – 女, 0xff-算法支持,但是没有识别出来 + public byte byEyeGlass; //是否戴眼镜 0-表示“未知”(算法不支持),1 – 不戴, 2 – 戴,0xff-算法支持,但是没有识别出来 + //抓拍图片人脸年龄的使用方式,如byAge为15,byAgeDeviation为1,表示,实际人脸图片年龄的为14-16之间 + public byte byRes4;// 0-表示“未知”(算法不支持),0xff-算法支持,但是没有识别出来 + public byte byDeviation;//误差值 + public byte byRes0; //字段预留 + public byte byMask; //是否戴口罩 0-表示“未知”(算法不支持),1 – 不戴, 2 – 戴, 0xff-算法支持,但是没有识别出来 + public byte bySmile; //是否微笑 0-表示“未知”(算法不支持),1 – 不微笑, 2 – 微笑, 0xff-算法支持,但是没有识别出来 + public byte byFaceExpression; /* 表情,参见FACE_EXPRESSION_GROUP_ENUM*/ + public byte byRes1; + public byte byRes2; + public byte byHat; // 帽子, 0-不支持,1-不戴帽子,2-戴帽子,0xff-unknow表示未知,算法支持未检出 + public byte[] byRes = new byte[4]; //保留 + } + + //特征抓拍附加信息结构体 + public static class NET_VCA_FACESNAP_ADDINFO extends Structure { + //人脸矩形框,该坐标为人脸小图(头肩照)中人脸的坐标 + public NET_VCA_RECT struFacePicRect = new NET_VCA_RECT(); + public int iSwingAngle;//旋转角, -90~90度 + public int iTiltAngle;//俯仰角, -90~90度 + public int dwPupilDistance;//瞳距,范围为:最小值为10像素,最大值为当前分辨率宽度/1.6 + public byte byBlockingState;//目标遮挡状态, 0-表示“未知”(算法不支持),1~无遮挡,2~瞬时轻度遮挡,3~持续轻度遮挡,4~严重遮挡 + public byte byFaceSnapThermometryEnabled;//特征抓拍测温使能 1-开启 0-关闭 + public byte byIsAbnomalTemperature;//特征抓拍测温是否温度异常 1-是 0-否 + public byte byThermometryUnit;//测温单位: 0-摄氏度(℃),1-华氏度(℉),2-开尔文(K) + public NET_DVR_TIME_EX struEnterTime = new NET_DVR_TIME_EX(); // 最佳抓拍下进入时间 + public NET_DVR_TIME_EX struExitTime = new NET_DVR_TIME_EX(); // 最佳抓拍下离开时间 + public float fFaceTemperature; // 人脸温度( - 20.0℃~150.0℃,精确到小数点后1位) + public float fAlarmTemperature;// 测温报警警阈值(精确到小数点后1位) + public byte[] byRes = new byte[472];// 保留字节 + } + + //特征抓拍结果 + public static class NET_VCA_FACESNAP_RESULT extends Structure { + public int dwSize; // 结构大小 + public int dwRelativeTime; // 相对时标 + public int dwAbsTime; // 绝对时标 + public int dwFacePicID; //人脸图ID + public int dwFaceScore; //人脸评分,0-100 + public NET_VCA_TARGET_INFO struTargetInfo = new NET_VCA_TARGET_INFO();//报警目标信息 + public NET_VCA_RECT struRect = new NET_VCA_RECT(); //人脸子图区域 + public NET_VCA_DEV_INFO struDevInfo = new NET_VCA_DEV_INFO(); //前端设备信息 + public int dwFacePicLen; //人脸子图的长度,为0表示没有图片,大于0表示有图片 + public int dwBackgroundPicLen; //背景图的长度,为0表示没有图片,大于0表示有图片(保留) + public byte bySmart; //IDS设备返回0(默认值),Smart Functiom Return 1 + public byte byAlarmEndMark;//报警结束标记0-保留,1-结束标记(该字段结合人脸ID字段使用,表示该ID对应的下报警结束,主要提供给NVR使用,用于判断报警结束,提取识别图片数据中,清晰度最高的图片) + public byte byRepeatTimes; //重复报警次数,0-无意义 + public byte byUploadEventDataType;//人脸图片数据长传方式:0-二进制数据,1-URL + public NET_VCA_HUMAN_FEATURE struFeature = new NET_VCA_HUMAN_FEATURE(); //人体属性 + public float fStayDuration; //停留画面中时间(单位: 秒) + public byte[] sStorageIP = new byte[16]; //存储服务IP地址 + public short wStoragePort; //存储服务端口号 + public short wDevInfoIvmsChannelEx; //与NET_VCA_DEV_INFO里的byIvmsChannel含义相同,能表示更大的值。老客户端用byIvmsChannel能继续兼容,但是最大到255。新客户端版本请使用wDevInfoIvmsChannelEx。 + public byte byFacePicQuality; + public byte byUIDLen; // 上传报警的标识长度 + public byte byLivenessDetectionStatus;// 活体检测状态:0-保留,1-未知(检测失败),2-非真人人脸,3-真人人脸,4-未开启活体检测 + /*附加信息标识位(即是否有NET_VCA_FACESNAP_ADDINFO结构体),0-无附加信息, 1-有附加信息。*/ + public byte byAddInfo; + public Pointer pUIDBuffer; //标识指针 + //附加信息指针,指向NET_VCA_FACESNAP_ADDINFO结构体 + public Pointer pAddInfoBuffer; + public byte byTimeDiffFlag; /*时差字段是否有效 0-时差无效, 1-时差有效 */ + public byte cTimeDifferenceH; /*与UTC的时差(小时),-12 ... +14, +表示东区,,byTimeDiffFlag为1时有效*/ + public byte cTimeDifferenceM; /*与UTC的时差(分钟),-30, 30, 45, +表示东区,byTimeDiffFlag为1时有效*/ + public byte byBrokenNetHttp; //断网续传标志位,0-不是重传数据,1-重传数据 + public Pointer pBuffer1; //人脸子图的图片数据 + public Pointer pBuffer2; //背景图的图片数据(保留,通过查找背景图接口可以获取背景图) + } + + //特征抓拍信息 + public static class NET_VCA_FACESNAP_INFO_ALARM extends Structure { + public int dwRelativeTime; // 相对时标 + public int dwAbsTime; // 绝对时标 + public int dwSnapFacePicID; //抓拍人脸图ID + public int dwSnapFacePicLen; //抓拍人脸子图的长度,为0表示没有图片,大于0表示有图片 + public NET_VCA_DEV_INFO struDevInfo = new NET_VCA_DEV_INFO(); //前端设备信息 + public byte byFaceScore; //人脸评分,指人脸子图的质量的评分,0-100 + public byte bySex;//性别,0-未知,1-男,2-女 + public byte byGlasses;//是否带眼镜,0-未知,1-是,2-否 + //抓拍图片人脸年龄的使用方式,如byAge为15,byAgeDeviation为1,表示,实际人脸图片年龄的为14-16之间 + public byte byRes2;// + public byte byDeviation;//误差值 + public byte byGroup;//段,详见HUMAN_GROUP_ENUM,若传入0xff表示未知 + public byte byFacePicQuality; + public byte byRes1; // 保留字节 + public int dwUIDLen; // 上传报警的标识长度 + public Pointer pUIDBuffer; //标识指针 + public float fStayDuration; //停留画面中时间(单位: 秒) + public Pointer pBuffer1; //抓拍人脸子图的图片数据 + } + + //籍贯参数 + public static class NET_DVR_AREAINFOCFG extends Structure { + public short wNationalityID; //国籍 + public short wProvinceID; //省 + public short wCityID; //市 + public short wCountyID; //县 + public int dwCode; //国家标准的省份、城市、县级代码,当这个字段不为0的时候,使用这个值,新设备上传这个值表示籍贯参数,老设备这个值为0 + } + + //人员信息 + public int MAX_HUMAN_BIRTHDATE_LEN = 10; + + public static class NET_VCA_HUMAN_ATTRIBUTE extends Structure { + public byte bySex; //性别:0-男,1-女 + public byte byCertificateType; //证件类型:0-身份证,1-警官证 + public byte[] byBirthDate = new byte[MAX_HUMAN_BIRTHDATE_LEN]; //出生年月,如:201106 + public byte[] byName = new byte[NAME_LEN]; //姓名 + public NET_DVR_AREAINFOCFG struNativePlace = new NET_DVR_AREAINFOCFG(); //籍贯参数 + public byte[] byCertificateNumber = new byte[NAME_LEN]; //证件号 + public int dwPersonInfoExtendLen;// 人员标签信息扩展长度 + public Pointer pPersonInfoExtend; //人员标签信息扩展信息 + public byte byGroup;//段,,如传入0xff表示未知 + public byte[] byRes2 = new byte[11]; + } + + + //禁止名单报警信息 + public static class NET_VCA_BLOCKLIST_INFO_ALARM extends Structure { + public NET_VCA_BLOCKLIST_INFO struBlockListInfo = new NET_VCA_BLOCKLIST_INFO(); //禁止名单基本信息 + public int dwBlockListPicLen; //禁止名单人脸子图的长度,为0表示没有图片,大于0表示有图片 + public int dwFDIDLen;// 人脸库ID长度 + public Pointer pFDID; //人脸库Id指针 + public int dwPIDLen;// 人脸库图片ID长度 + public Pointer pPID; //人脸库图片ID指针 + public short wThresholdValue; //人脸库阈值[0,100] + public byte[] byRes = new byte[2]; // 保留字节 + public Pointer pBuffer1; //禁止名单人脸子图的图片数据 + } + + //禁止名单信息 + public static class NET_VCA_BLOCKLIST_INFO extends Structure { + public int dwSize; //结构大小 + public int dwRegisterID; //名单注册ID号(只读) + public int dwGroupNo; //分组号 + public byte byType; //禁止/运行允许名单标志:0-全部,1-允许名单,2-禁止名单 + public byte byLevel; //禁止名单等级,0-全部,1-低,2-中,3-高 + public byte[] byRes1 = new byte[2]; //保留 + public NET_VCA_HUMAN_ATTRIBUTE struAttribute = new NET_VCA_HUMAN_ATTRIBUTE(); //人员信息 + public byte[] byRemark = new byte[NAME_LEN]; //备注信息 + public int dwFDDescriptionLen;//人脸库描述数据长度 + public Pointer pFDDescriptionBuffer;//人脸库描述数据指针 + public int dwFCAdditionInfoLen;//抓拍库附加信息长度 + public Pointer pFCAdditionInfoBuffer;//抓拍库附加信息数据指针(FCAdditionInfo中包含相机PTZ坐标) + public byte[] byRes2 = new byte[4]; + } + + + //禁止名单比对结果报警上传 + public static class NET_VCA_FACESNAP_MATCH_ALARM extends Structure { + public int dwSize; // 结构大小 + public float fSimilarity; //相似度,[0.001,1] + public NET_VCA_FACESNAP_INFO_ALARM struSnapInfo = new NET_VCA_FACESNAP_INFO_ALARM(); //抓拍信息 + public NET_VCA_BLOCKLIST_INFO_ALARM struBlockListInfo = new NET_VCA_BLOCKLIST_INFO_ALARM(); //禁止名单信息 + public byte[] sStorageIP = new byte[16]; //存储服务IP地址 + public short wStoragePort; //存储服务端口号 + public byte byMatchPicNum; //匹配图片的数量,0-保留(老设备这个值默认0,新设备这个值为0时表示后续没有匹配的图片信息) + public byte byPicTransType;//图片数据传输方式: 0-二进制;1-url + public int dwSnapPicLen;//设备识别抓拍图片长度 + public Pointer pSnapPicBuffer;//设备识别抓拍图片指针 + public NET_VCA_RECT struRegion = new NET_VCA_RECT();//目标边界框,设备识别抓拍图片中,人脸子图坐标 + public int dwModelDataLen;//建模数据长度 + public Pointer pModelDataBuffer;// 建模数据指针 + public byte byModelingStatus;// 建模状态 + public byte byLivenessDetectionStatus;//活体检测状态:0-保留,1-未知(检测失败),2-非真人人脸,3-真人人脸,4-未开启活体检测 + public byte cTimeDifferenceH; /*与UTC的时差(小时),-12 ... +14, +表示东区,0xff无效*/ + public byte cTimeDifferenceM; /*与UTC的时差(分钟),-30, 30, 45, +表示东区,0xff无效*/ + public byte byMask; //抓拍图是否戴口罩,0-保留,1-未知,2-不戴口罩,3-戴口罩 + public byte bySmile; //抓拍图是否微笑,0-保留,1-未知,2-不微笑,3-微笑 + public byte byContrastStatus; //比对结果,0-保留,1-比对成功,2-比对失败 + public byte byBrokenNetHttp; //断网续传标志位,0-不是重传数据,1-重传数据 + } + + //交通事件报警(扩展) + public static class NET_DVR_AID_ALARM_V41 extends Structure { + public int dwSize; //结构长度 + public int dwRelativeTime; //相对时标 + public int dwAbsTime; //绝对时标 + public NET_VCA_DEV_INFO struDevInfo = new NET_VCA_DEV_INFO(); //前端设备信息 + public NET_DVR_AID_INFO struAIDInfo = new NET_DVR_AID_INFO(); //交通事件信息 + public NET_DVR_SCENE_INFO struSceneInfo = new NET_DVR_SCENE_INFO(); //场景信息 + public int dwPicDataLen; //图片长度 + public Pointer pImage; //指向图片的指针 + // 0-数据直接上传; 1-云存储服务器URL(3.7Ver)原先的图片数据变成URL数据,图片长度变成URL长度 + public byte byDataType; + public byte byLaneNo; //关联车道号 + public short wMilliSecond; //时标毫秒 + //监测点编号(路口编号、内部编号) + public byte[] byMonitoringSiteID = new byte[MONITORSITE_ID_LEN/*48*/]; + public byte[] byDeviceID = new byte[DEVICE_ID_LEN/*48*/];//设备编号 + public int dwXmlLen;//XML报警信息长度 + public Pointer pXmlBuf;// XML报警信息指针,其XML对应到EventNotificationAlert XML Block + public byte byTargetType;// 检测的目标类型,0~未知,1~行人、2~二轮车、3~三轮车(行人检测中返回) + public byte byRuleID;//规则ID,1-4,当congestion事件配置了规则区域时返回 + public short wDevInfoIvmsChannelEx; //与NET_VCA_DEV_INFO里的byIvmsChannel含义相同,能表示更大的值。老客户端用byIvmsChannel能继续兼容,但是最大到255。新客户端版本请使用wDevInfoIvmsChannelEx。 + public byte byBrokenNetHttp; // 断网续传标志位,0-不重传数据,1-重传数据 + public byte[] byRes = new byte[3]; // 保留字节 + public int dwPlateSmallPicDataLen; //车牌小图图片长度 + public Pointer pPlateSmallImage; // //指向车牌小图的指针 + } + + + //交通统计信息报警(扩展) + public static class NET_DVR_TPS_ALARM_V41 extends Structure { + public int dwSize; // 结构体大小 + public int dwRelativeTime; // 相对时标 + public int dwAbsTime; // 绝对时标 + public NET_VCA_DEV_INFO struDevInfo; // 前端设备信息 + public NET_DVR_TPS_INFO_V41 struTPSInfo; // 交通参数统计信息 + //监测点编号(路口编号、内部编号) + public byte[] byMonitoringSiteID = new byte[MONITORSITE_ID_LEN/*48*/]; + public byte[] byDeviceID = new byte[DEVICE_ID_LEN/*48*/];//设备编号 + public int dwStartTime; // 开始统计时间 + public int dwStopTime; // 结束统计时间 + public byte[] byRes = new byte[24]; // 保留 + } + + public static class NET_DVR_LANE_PARAM_V41 extends Structure { + public byte[] byRuleName = new byte[NAME_LEN]; // 车道规则名称 + public byte byRuleID; // 规则序号,为规则配置结构下标,0-7 + public byte byLaneType; // 车道上行或下行 + public byte byTrafficState; // 车道的交通状态,0-无效,1-畅通,2-拥挤,3-堵塞 + public byte byLaneNo; //车道号 + public int dwVaryType; // 车道交通参数变化类型参照 TRAFFIC_DATA_VARY_TYPE_EX_ENUM,按位区分 + public int dwTpsType; // 数据变化类型标志,表示当前上传的统计参数中,哪些数据有效,参照ITS_TPS_TYPE,按位区分 + public int dwLaneVolume; // 车道流量,统计有多少车子通过 + public int dwLaneVelocity; // 车道速度,公里计算 + public int dwTimeHeadway; // 车头时距,以秒计算 + public int dwSpaceHeadway; // 车头间距,以米来计算 + public float fSpaceOccupyRation; // 车道占有率,百分比计算(空间上) + public float fTimeOccupyRation; // 时间占有率,百分比计算 + public int dwLightVehicle; // 小型车数量 + public int dwMidVehicle; // 中型车数量 + public int dwHeavyVehicle; // 重型车数量 + public NET_DVR_LANE_QUEUE struLaneQueue; // 车道队列长度 + public NET_VCA_POINT struRuleLocation; // 规则位置虚拟线圈的中心 + public int dwOversizeVehicle; // 大型车数量 + public byte[] byRes2 = new byte[60]; // 保留 + } + + public int MAX_TPS_RULE = 8; // 最大参数规则数目 + + public static class NET_DVR_TPS_INFO_V41 extends Structure { + public int dwLanNum; // 交通参数的车道数目 + public NET_DVR_LANE_PARAM_V41[] struLaneParam = new NET_DVR_LANE_PARAM_V41[MAX_TPS_RULE]; + public int dwSceneID;//场景ID + public byte[] byRes = new byte[28]; //保留 + } + + // 车道队列结构体 + public static class NET_DVR_LANE_QUEUE extends Structure { + public NET_VCA_POINT struHead; //队列头 + public NET_VCA_POINT struTail; //队列尾 + public int dwLength; //实际队列长度 单位为米 [0-500] + } + + //TPS统计过车数据上传 + public static class NET_DVR_TPS_STATISTICS_INFO extends Structure { + public int dwSize; // 结构体大小 + public int dwChan;//通道号 + public NET_DVR_TPS_STATISTICS_PARAM struTPSStatisticsInfo;// 交通参数统计信息 + public byte[] byRes = new byte[128]; // 保留 + } + + + // 交通参数统计信息 + public static class NET_DVR_TPS_STATISTICS_PARAM extends Structure { + public byte byStart; // 开始码 + public byte byCMD; // 命令号, 08-定时成组数据指令 + public byte[] byRes = new byte[2]; // 预留字节 + public short wDeviceID; // 设备ID + public short wDataLen; // 数据长度 + public byte byTotalLaneNum; // 有效车道总数 + public byte[] byRes1 = new byte[15]; + public NET_DVR_TIME_V30 struStartTime; //统计开始时间 + public int dwSamplePeriod; //统计时间,单位秒 + public NET_DVR_TPS_LANE_PARAM[] struLaneParam = new NET_DVR_TPS_LANE_PARAM[8]; + } + + //统计信息 + public static class NET_DVR_TPS_LANE_PARAM extends Structure { + public byte byLane; // 对应车道号 + public byte bySpeed; // 车道过车平均速度 + public byte[] byRes = new byte[2]; // 保留 + public int dwLightVehicle; // 小型车数量 + public int dwMidVehicle; // 中型车数量 + public int dwHeavyVehicle; // 重型车数量 + public int dwTimeHeadway; // 车头时距,以秒计算 + public int dwSpaceHeadway; // 车头间距,以米来计算 + public float fSpaceOccupyRation; // 空间占有率,百分比计算,浮点数*1000 + public float fTimeOccupyRation; // 时间占有率,百分比计算,浮点数*1000 + public byte[] byRes1 = new byte[16]; // 保留 + } + + //TPS实时过车数据上传 + public static class NET_DVR_TPS_REAL_TIME_INFO extends Structure { + public int dwSize; // 结构体大小 + public int dwChan;//通道号 + public NET_DVR_TIME_V30 struTime; //检测时间 + public NET_DVR_TPS_PARAM struTPSRealTimeInfo;// 交通参数统计信息 + public Pointer pAddInfoBuffer; + /*附加信息标识(即是否有NET_DVR_TPS_ADDINFO结构体),0-无附加信息, 1-有附加信息。*/ + public byte byAddInfoFlag; + public byte[] byRes1 = new byte[3]; // 保留 + public int dwDeviceIDEx; // 设备ID扩展 + public byte[] byRes = new byte[8]; // 保留 + } + + //实时信息 + public static class NET_DVR_TPS_PARAM extends Structure { + public byte byStart; // 开始码 + public byte byCMD; // 命令号,01-进入指令,02-离开指令,03-拥堵状态指令(为03时,只有byLaneState和byQueueLen有效),04-多线圈状态(为04时,wLoopState和wStateMask有效,表示byLane车道上多个线圈的过车状态) + public short wSpaceHeadway; //车头间距,以米来计算 + public short wDeviceID; // 设备ID + public short wDataLen; // 数据长度 + public byte byLane; // 对应车道号 + public byte bySpeed; // 对应车速(KM/H) + public byte byLaneState; // 车道状态;0-无状态,1-畅通,2-拥挤,3-堵塞 + public byte byQueueLen; // 堵塞状态下排队长度(比如50米) + public short wLoopState; //线圈状态,第几位表示几号线圈状态。状态1-到达,0-离开,线圈编号从镜头由近到远依次增大,用户在解析时优先解析车道号,再解析线圈号,单个车道的线圈号是唯一的。 + public short wStateMask; //线圈状态掩码,掩码位为1对应wLoopState状态位有效,为0表示无效 + public int dwDownwardFlow; //当前车道 从上到下车流量 + public int dwUpwardFlow; //当前车道 从下到上车流量 + public byte byJamLevel; //拥堵等级,当byLaneState为3时有效,1-轻度,2-中度,3-重度 + public byte byVehicleDirection; //0-未知,1-由上而下,2-由下而上 + public byte byJamFlow; //拥堵新增流量,每新增一辆车就上报一次累计车辆的信息 + public byte byChannelizationLane; //渠化车道号(渠化表示,车道数量变化的情况,一般为路口车道的数目) + public byte byVehicleType; //车型识别:0- 未知,1- 客车(大型),2- 货车(大型),3- 轿车(小型),4- 非机动车 + public byte[] byRes1 = new byte[5]; //保留 + public short wTimeHeadway; // 车头时距,以秒计算 + } + + public static class NET_DVR_TIME_SEARCH_COND extends Structure { + public short wYear; //年 + public byte byMonth; //月 + public byte byDay; //日 + public byte byHour; //时 + public byte byMinute; //分 + public byte bySecond; //秒 + public byte byLocalOrUTC; //0-时差无效,设备本地时间,即设备OSD时间 1-时差有效 + public short wMillisecond; //毫秒,精度不够,默认为0 + public byte cTimeDifferenceH; //与UTC的时差(小时),-12 ... +14,+表示东区,byLocalOrUTC为1时有效 + public byte cTimeDifferenceM; //与UTC的时差(分钟),-30, 0, 30, 45,+表示东区,byLocalOrUTC为1时有效 + } + + //事件搜索条件 + public static class NET_DVR_SEARCH_EVENT_PARAM extends Structure { + public short wMajorType; //0-移动侦测,1-报警输入, 2-智能事件 5-pos录像 7-门禁事件, 8-非视频联动事件 + public short wMinorType; //搜索次类型- 根据主类型变化,0xffff表示全部 + public NET_DVR_TIME struStartTime = new NET_DVR_TIME(); //搜索的开始时间,停止时间: 同时为(0, 0) 表示从最早的时间开始,到最后,最前面的4000个事件 + public NET_DVR_TIME struEndTime = new NET_DVR_TIME(); //搜索的结束时间 + public byte byLockType; // 0xff-全部,0-未锁,1-锁定 + public byte byValue; //0-按位表示,1-按值表示 + public byte[] byRes = new byte[130]; // 保留 + public UNION_EVENT_PARAM uSeniorParam = new UNION_EVENT_PARAM(); + } + + public static class UNION_EVENT_PARAM extends Union { + public byte[] byLen = new byte[SEARCH_EVENT_INFO_LEN]; + public EVENT_INQUESTPARAM struInquestParam = new EVENT_INQUESTPARAM(); + } + + //审讯事件搜索条件 + public static class EVENT_INQUESTPARAM extends Structure { + public byte byRoomIndex; //审讯室编号,按值表示,从1开始 + public byte[] byRes1 = new byte[3]; + public byte[] sInquestInfo = new byte[INQUEST_CASE_LEN]; + public byte[] byRes2 = new byte[232]; //保留 + } + + //事件搜索条件 + public static class NET_DVR_SEARCH_EVENT_PARAM_V50 extends Structure { + public short wMajorType; //0-移动侦测,1-报警输入, 2-智能事件 5-pos录像 7-门禁事件, 8-非视频联动事件 + public short wMinorType; //搜索次类型- 根据主类型变化,0xffff表示全部 + public NET_DVR_TIME_SEARCH_COND struStartTime = new NET_DVR_TIME_SEARCH_COND(); //搜索的开始时间,停止时间: 同时为(0, 0) 表示从最早的时间开始,到最后,最前面的4000个事件 + public NET_DVR_TIME_SEARCH_COND struEndTime = new NET_DVR_TIME_SEARCH_COND(); //搜索的结束时间 + public byte byLockType; // 0xff-全部,0-未锁,1-锁定 + public byte byQuickSearch; // 是否启用快速查询,0-不启用,1-启用(快速查询不会返回文件大小,仅对设备数据库进行查询,避免频繁唤醒硬盘) + public byte[] byRes = new byte[254]; // 保留 + public UNION_EVENT_PARAM_V50 uSeniorParam = new UNION_EVENT_PARAM_V50(); + } + + public static class UNION_EVENT_PARAM_V50 extends Union { + public byte[] byLen = new byte[SEARCH_EVENT_INFO_LEN_V40/*800*/]; + public EVENT_ALARMPARAM_V50 struAlarmParam = new EVENT_ALARMPARAM_V50(); + public EVENT_MOTIONPARAM_V50 struMotionParam = new EVENT_MOTIONPARAM_V50(); + public EVENT_VCAPARAM_V50 struVcaParam = new EVENT_VCAPARAM_V50(); + public EVENT_INQUESTPARAM_V50 struInquestParam = new EVENT_INQUESTPARAM_V50(); + public EVENT_VCADETECTPARAM_V50 struVCADetect = new EVENT_VCADETECTPARAM_V50(); + public EVENT_STREAMIDPARAM_V50 struStreamIDParam = new EVENT_STREAMIDPARAM_V50(); + public EVENT_POSPARAM_V50 struPosAlarm = new EVENT_POSPARAM_V50(); + public EVENT_TRIALPARAM_V50 struTrialParam = new EVENT_TRIALPARAM_V50(); + public EVENT_ACSPARAM_V50 struACSAlarm = new EVENT_ACSPARAM_V50(); + public EVENT_IOTPARAM_V50 struIOTAlarm = new EVENT_IOTPARAM_V50(); + } + + public static class EVENT_ALARMPARAM_V50 extends Structure { + /*报警输入号,按值表示,采用紧凑型排列,0xffff表示后续无效*/ + public short[] wAlarmInNo = new short[128]; + public byte[] byRes = new byte[544]; //保留 + } + + //移动侦测 + public static class EVENT_MOTIONPARAM_V50 extends Structure { + /* 移动侦测通道,按值表示 ,采用紧凑型排列,0xffff表示后续无效*/ + public short[] wMotDetChanNo = new short[MAX_CHANNUM_V30]; + public byte[] byRes = new byte[672]; /*保留*/ + } + + //异常行为检测 + public static class EVENT_VCAPARAM_V50 extends Structure { + //异常行为检测对应的通道,按值表示,采用紧凑型排列,0xffff表示后续无效 + public short[] wChanNo = new short[MAX_CHANNUM_V30]; + public byte byRuleID; //异常行为检测类型,规则0xff表示全部,从0开始 + public byte byDriverBehaviortType; //司机驾驶行为类型:0-保留、1-抽烟、2-接打电话、3-疲劳驾驶、4-分神提醒、5-驾驶员异常、6-未系安全带、7-红外阻断墨镜 + public byte byADASType; //高级辅助驾驶类型:0-保留、1-前向碰撞、2-车道偏离、3-盲区检测、4-车距检测、5-行人防撞、6-急加速、7-急减速、8-急左转弯、9-急右转弯、10-车辆翻车、11-未礼让行人 + public byte byGSensorType; // G-Sensor事件:0-保留、1-急加速、2-急减速、3-急左转弯、4-急右转弯、5-车辆翻车、6-车辆碰撞 + public byte bySensorInType; // Sensor-In行为:0-保留、1-刹车、2-左转、3-右转、4-倒车 + public byte[] byRes = new byte[667]; /*保留*/ + } + + //审讯事件搜索条件 + public static class EVENT_INQUESTPARAM_V50 extends Structure { + public byte byRoomIndex; //审讯室编号,从1开始 + public byte[] byRes = new byte[799]; //保留 + } + + //智能侦测查找条件 ,通道号按值表示 + public static class EVENT_VCADETECTPARAM_V50 extends Structure { + public byte byAll; //查找全部通道,0-否,此时dwChanNo参数有效, + //1-查找全部通道,此时dwChanNo参数无效。 + public byte[] byRes1 = new byte[3]; + public short[] wChanNo = new short[MAX_CHANNUM_V30];// 触发通道号,按值表示,0xffff无效,且后续数据也表示无效值 + public byte[] byRes = new byte[668]; + } + + public static class EVENT_STREAMIDPARAM_V50 extends Structure { + public NET_DVR_STREAM_INFO struIDInfo = new NET_DVR_STREAM_INFO(); // 流id信息,72字节长 + public int dwCmdType; // 外部触发类型,NVR接入云存储使用 + public byte byBackupVolumeNum; //存档卷号,CVR使用 + public byte[] byRes1 = new byte[3]; + public byte[] byArchiveLabel = new byte[64]; //存档标签,CVR使用 + public byte[] byRes = new byte[656]; + } + + //pos录像 + public static class EVENT_POSPARAM_V50 extends Structure { + public short[] wChannel = new short[MAX_CHANNUM_V30]; //通道,按值表示,紧凑型排列,遇到0xffff时表示数组后续值无效 + public byte byAllChan; //是否查找全部通道,0-否,此时wChannel有效,1-全部通道,此时wChannel无效 + public byte byCaseSensitive; //0-不区分大小写, 1-区分大小写 + public byte byCombinateMode; //关键字组合方式,0-或,1-与 + public byte byRes1; //保留 + public byte[] sKeyWord = new byte[MAX_POS_KEYWORDS_NUM * MAX_POS_KEYWORD_LEN]; + //关键字查找时的条件 + public byte[] byRes = new byte[284]; //保留 + } + + public static class EVENT_TRIALPARAM_V50 extends Structure { + public byte[] byCaseNo = new byte[SEARCH_CASE_NO_LEN]; + public byte[] byCaseName = new byte[SEARCH_CASE_NAME_LEN]; + public byte[] byLitigant1 = new byte[SEARCH_LITIGANT_LEN]; + public byte[] byLitigant2 = new byte[SEARCH_LITIGANT_LEN]; + public byte[] byChiefJudge = new byte[SEARCH_CHIEF_JUDGE_LEN]; + public byte byCaseType; + public byte[] byRes = new byte[547]; + } + + //门禁事件搜索条件 + public static class EVENT_ACSPARAM_V50 extends Structure { + public int dwMajor; //报警主类型(与事件上传主类型一致,0代表全部) + public int dwMinor; //报警次类型(与事件上传主类型一致,0代表全部) + public byte[] byCardNo = new byte[ACS_CARD_NO_LEN]; //卡号 + public byte[] byName = new byte[NAME_LEN/*32*/]; //姓名 + public byte[] byMACAddr = new byte[MACADDR_LEN]; //物理MAC地址 + public byte[] byRes = new byte[722]; + } + + //非视频联动事件搜索条件 + public static class EVENT_IOTPARAM_V50 extends Structure { + public short wDeviceType; //设备类型,0-海康门禁主机,1-海康可视对讲设备, 2-海康报警主机(预留) 3-GJD报警主机 4-Luminite报警主机, 5-OPTEX报警主机,6-cameraDetector模拟相机传感器设备 + public short wEventType; //搜索次类型- 根据主类型变化,0xffff表示全部 + public short[] wChannel = new short[MAX_CHANNUM_V30/*64*/]; //通道号,按值表示,紧凑型排列,遇到0xffff时表示数组后续值无效 + public byte byAllChan; //是否查找全部通道,0-否,此时wChannel有效,1-全部通道,此时wChannel无效 + public byte byCaseSensitive; //0-不区分大小写, 1-区分大小写 + public byte byCombinateMode; //关键字组合方式,0-或,1-与 + public byte bySearchType; //搜索方式:0-按视频源搜索(此时通道号为视频通道号) + public byte[] sKeyWord = new byte[MAX_POS_KEYWORDS_NUM * MAX_POS_KEYWORD_LEN];//关键字查找时的条件 + public short wZoneNo; //防区号,仅当设备类型为海康报警主机,次类型为防区(wEventType为1)时有效 + public byte[] byRes = new byte[278]; //保留 + } + + //查找返回结果 + public static class NET_DVR_SEARCH_EVENT_RET extends Structure { + public short wMajorType; //主类型 + public short wMinorType; //次类型 + public NET_DVR_TIME struStartTime = new NET_DVR_TIME(); //事件开始的时间 + public NET_DVR_TIME struEndTime = new NET_DVR_TIME(); //事件停止的时间 + public byte[] byChan = new byte[MAX_CHANNUM_V30]; + public byte[] byChanEx = new byte[32]; //关联通道,按位表示,使用该字段后byChan可以不使用 + public byte[] byRes = new byte[4]; + public UNION_EVENT_RET uSeniorRet = new UNION_EVENT_RET(); + } + + public static class UNION_EVENT_RET extends Union { + public byte[] byLen = new byte[304]; + public EVENT_ALARMSTRET struAlarmRet = new EVENT_ALARMSTRET(); + public EVENT_INQUESTRET struInquestRet = new EVENT_INQUESTRET(); + } + + //报警输入结果 + public static class EVENT_ALARMSTRET extends Structure { + + public int dwAlarmInNo; //报警输入号 + public byte[] byRes = new byte[SEARCH_EVENT_INFO_LEN]; + } + + //审讯事件 + public static class EVENT_INQUESTRET extends Structure { + public byte byRoomIndex; //审讯室编号,从1开始 + public byte byDriveIndex; //刻录机编号,从1开始 + public byte[] byRes1 = new byte[6]; //保留 + public int dwSegmentNo; //本片断在本次审讯中的序号,从1开始 + public short wSegmetSize; //本片断的大小, 单位M + public short wSegmentState; //本片断状态 0 刻录正常,1 刻录异常,2 不刻录审讯 + public byte[] byRes2 = new byte[288]; //保留 + + @Override + protected List getFieldOrder() { + // Auto-generated method stub + return Arrays.asList("byRoomIndex", "byDriveIndex", "byRes1", "dwSegmentNo", "wSegmetSize", "wSegmentState", "byRes2"); + } + } + + //查找返回结果 + public static class NET_DVR_SEARCH_EVENT_RET_V50 extends Structure { + public short wMajorType; //主类型 + public short wMinorType; //次类型 + public NET_DVR_TIME_SEARCH struStartTime = new NET_DVR_TIME_SEARCH(); //事件开始的时间 + public NET_DVR_TIME_SEARCH struEndTime = new NET_DVR_TIME_SEARCH(); //事件停止的时间,脉冲事件时和开始时间一样 + public NET_DVR_ADDRESS struAddr = new NET_DVR_ADDRESS(); //片段所在的地址信息,集群回放时用到 + public short[] wChan = new short[MAX_CHANNUM_V40/*512*/]; //触发的通道号,0xffff表示后续无效 + public byte[] byRes = new byte[256]; + public UNION_EVENT_RET_V50 uSeniorRet = new UNION_EVENT_RET_V50(); + } + + public static class UNION_EVENT_RET_V50 extends Union { + public byte[] byLen = new byte[800]; + public EVENT_ALARMRET_V50 struAlarmRet = new EVENT_ALARMRET_V50(); + public EVENT_MOTIONRET_V50 struMotionRet = new EVENT_MOTIONRET_V50(); + public EVENT_VCARET_V50 struVcaRet = new EVENT_VCARET_V50(); + public EVENT_INQUESTRET_V50 struInquestRet = new EVENT_INQUESTRET_V50(); + public EVENT_STREAMIDRET_V50 struStreamIDRet = new EVENT_STREAMIDRET_V50(); + public EVENT_POSRET_V50 struPosRet = new EVENT_POSRET_V50(); + public EVENT_TRIALRET_V50 struTrialRet = new EVENT_TRIALRET_V50(); + public EVENT_IOTRET_V50 struIOTRet = new EVENT_IOTRET_V50(); + } + + //报警输入结果 + public static class EVENT_ALARMRET_V50 extends Structure { + public int dwAlarmInNo; //报警输入号 + public byte[] byRes = new byte[796]; + } + + //移动侦测结果 + public static class EVENT_MOTIONRET_V50 extends Structure { + public int dwMotDetNo; //移动侦测通道 + public byte[] byRes = new byte[796]; + } + + //异常行为检测结果 + public static class EVENT_VCARET_V50 extends Structure { + public int dwChanNo; //触发事件的通道号 + public byte byRuleID; //规则ID + public byte[] byRes1 = new byte[3]; //保留 + public byte[] byRuleName = new byte[NAME_LEN]; //规则名称 + public NET_VCA_EVENT_UNION uEvent = new NET_VCA_EVENT_UNION(); //行为事件参数 + public byte[] byRes = new byte[668]; //保留 + } + + //审讯事件 + public static class EVENT_INQUESTRET_V50 extends Structure { + public byte byRoomIndex; //审讯室编号,从1开始 + public byte byDriveIndex; //刻录机编号,从1开始 + public byte[] byRes1 = new byte[6]; //保留 + public int dwSegmentNo; //本片断在本次审讯中的序号,从1开始 + public short wSegmetSize; //本片断的大小, 单位M + public short wSegmentState; //本片断状态 0 刻录正常,1 刻录异常,2 不刻录审讯 + public byte[] byRes2 = new byte[784]; //保留 + } + + //流id录像查询结果 + public static class EVENT_STREAMIDRET_V50 extends Structure { + public int dwRecordType; //录像类型 0-定时录像 1-移动侦测 2-报警录像 3-报警|移动侦测 4-报警&移动侦测 5-命令触发 6-手动录像 7-震动报警 8-环境触发 9-智能报警 10-回传录像 + public int dwRecordLength; //录像大小 + public byte byLockFlag; // 锁定标志 0:没锁定 1:锁定 + public byte byDrawFrameType; // 0:非抽帧录像 1:抽帧录像 + public byte byPosition;// 文件所在存储位置:0-阵列上,1-带库机位上,可以直接下载,2-磁带库内,需要把磁盘切换到机位上,3-不在磁带库中,需要把磁盘插到磁带库中 + public byte byRes1; + public byte[] byFileName = new byte[NAME_LEN]; //文件名 + public int dwFileIndex; // 存档卷上的文件索引 + public byte[] byTapeIndex = new byte[NET_SDK_MAX_TAPE_INDEX_LEN]; //文件所在磁带编号 + public byte[] byFileNameEx = new byte[NET_SDK_MAX_FILE_LEN/*256*/]; //文件名扩展 + public byte[] byRes = new byte[464]; + } + + //POS录像查询结果 + public static class EVENT_POSRET_V50 extends Structure { + public int dwChanNo; //触发产生pos事件的通道 + public byte[] byRes = new byte[796]; + } + + public static class EVENT_TRIALRET_V50 extends Structure { + public byte byRoomIndex; //审讯室编号,从1开始 + public byte byDriveIndex; //刻录机编号,从1开始 + public short wSegmetSize; //本片断的大小, 单位M + public int dwSegmentNo; //本片断在本次审讯中的序号,从1开始 + public byte bySegmentState; //本片断状态,0-刻录正常,1-刻录异常,2-不刻录审讯 + public byte byCaseType; //案件类型;0-全部、1-刑事案件、2-民事案件 + public byte[] byRes = new byte[2]; + public byte[] byCaseNo = new byte[CASE_NO_RET_LEN]; //案件编号 + public byte[] byCaseName = new byte[CASE_NAME_RET_LEN]; //案件名称; + public byte[] byLitigant1 = new byte[LITIGANT_RET_LEN]; //当事人1; + public byte[] byLitigant2 = new byte[LITIGANT_RET_LEN]; //当事人2; + public byte[] byChiefJudge = new byte[CHIEF_JUDGE_RET_LEN];//审判长 + public byte[] byRes1 = new byte[600]; + } + + //非视频通道查询结果 + public static class EVENT_IOTRET_V50 extends Structure { + public int dwChanNo; //触发产生事件的通道号(事件源通道) + public byte[] byRes = new byte[796]; + } + + public static class NET_DVR_INQUEST_RESUME_SEGMENT extends Structure { + public NET_DVR_TIME struStartTime = new NET_DVR_TIME(); //事件起始时间 + public NET_DVR_TIME struStopTime = new NET_DVR_TIME(); //事件终止时间 + public byte byRoomIndex; //审讯室编号,从1开始 + public byte byDriveIndex; //刻录机编号,从1开始 + public short wSegmetSize; //本片断的大小, 单位M + public int dwSegmentNo; //本片断在本次审讯中的序号,从1开始 + public byte[] byRes = new byte[24]; //保留 + } + + public static class NET_DVR_INQUEST_RESUME_EVENT extends Structure { + public int dwResumeNum; //需恢复的事件个数 + public NET_DVR_INQUEST_RESUME_SEGMENT[] struResumeSegment = new NET_DVR_INQUEST_RESUME_SEGMENT[MAX_RESUME_SEGMENT]; + public byte byResumeMode; //恢复模式,0-单光盘恢复,1-双光盘恢复 + public byte[] byRes = new byte[199]; //保留 + } + + //报警信息查询条件结构体 + public static class NET_DVR_ALARM_SEARCH_COND extends Structure { + public int dwSize; + public NET_DVR_TIME_SEARCH_COND strStartTime; //开始时间,时间为空则代表不通过时间筛选。 + public NET_DVR_TIME_SEARCH_COND strStopTime; //结束时间, 时间为空则代表不通过时间筛选。 + /* + 报警命令,该字段值与报警布防类型相同,目前支持: + COMM_VCA_ALARM 0x4993 智能检测报警 + COMM_UPLOAD_FACESNAP_RESULT 0x1112 特征识别结果上传 + COMM_SNAP_MATCH_ALAR 0x2902 人脸比对结果上传 + */ + public int dwAlarmComm; //若该命令为空这代表不进行报警命令过滤。 + public byte[] sAlarmUID = new byte[64]; //UID标识(上传报警时设备返回的UID标识,64字节的长度,可以使用时间(精确到毫秒)加上随即数的方式组成),为空则代表不区分UID + public byte[] byRes = new byte[128]; + } + + //报警信息查询结果结构体 + public static class NET_DVR_ALARM_SEARCH_RESULT extends Structure { + public int dwSize; + /* + 报警命令,该字段值与报警布防类型相同,目前支持: + COMM_VCA_ALARM 0x4993 智能检测报警 + COMM_UPLOAD_FACESNAP_RESULT 0x1112 特征识别结果上传 + COMM_SNAP_MATCH_ALARM 0x2902 人脸比对结果上传 + */ + public int dwAlarmComm; + /* + 报警信息,该字段值与报警信息相同,目前支持: + 当COMM_VCA_ALARM时,该报警信息为JSON报文 + 当COMM_UPLOAD_FACESNAP_RESULT时,该报警信息为NET_VCA_FACESNAP_RESULT + 当COMM_SNAP_MATCH_ALARM—¶,该报警信息为NET_VCA_FACESNAP_MATCH_ALARM + */ + public int dwAlarmLen;//报警信息,即pAlarmInfo指针指向的数据长度 + public Pointer pAlarmInfo; + public NET_DVR_ALARMER struAlarmer = new NET_DVR_ALARMER(); + public byte[] byRes = new byte[128]; + } + + public static class NET_DVR_ALARM_ISAPI_INFO extends Structure { + public Pointer pAlarmData; // 报警数据(参见下表) + public int dwAlarmDataLen; // 报警数据长度 + public byte byDataType; // 0-invalid,1-xml,2-json + public byte byPicturesNumber; // 图片数量 + public byte[] byRes = new byte[2]; + public Pointer pPicPackData; // 图片变长部分 + //(byPicturesNumber个{NET_DVR_ALARM_ISAPI_PICDATA};) + public byte[] byRes1 = new byte[32]; + } + + public static class NET_DVR_LOCAL_GENERAL_CFG extends Structure { + public byte byExceptionCbDirectly; //0-通过线程池异常回调,1-直接异常回调给上层 + public byte byNotSplitRecordFile; //回放和预览中保存到本地录像文件不切片 0-默认切片,1-不切片 + public byte byResumeUpgradeEnable; //断网续传升级使能,0-关闭(默认),1-开启 + public byte byAlarmJsonPictureSeparate; //控制JSON透传报警数据和图片是否分离,0-不分离,1-分离(分离后走COMM_ISAPI_ALARM回调返回) + public byte[] byRes = new byte[4]; //保留 + public long i64FileSize; //单位:Byte + public int dwResumeUpgradeTimeout; //断网续传重连超时时间,单位毫秒 + public byte[] byRes1 = new byte[236]; //预留 + + } + + public static class NET_DVR_LOCAL_TCP_PORT_BIND_CFG extends Structure { + public short wLocalBindTcpMinPort; //本地绑定Tcp最小端口 + public short wLocalBindTcpMaxPort; //本地绑定Tcp最大端口 + public byte[] byRes = new byte[60]; //保留 + } + + + public static class NET_DVR_LOCAL_CHECK_DEV extends Structure { + public int dwCheckOnlineTimeout; //巡检时间间隔,单位ms 最小值为30s,最大值120s。为0时,表示用默认值(120s) + public int dwCheckOnlineNetFailMax; //由于网络原因失败的最大累加次数;超过该值SDK才回调用户异常,为0时,表示使用默认值1 + public byte[] byRes = new byte[256]; + } + + public static final int MAX_FILE_PATH_LEN = 256; //文件路径长度 + + public static class NET_DVR_ALARM_ISAPI_PICDATA extends Structure { + public int dwPicLen; + public byte byPicType; //图片格式: 1- jpg + public byte[] byRes = new byte[3]; + public byte[] szFilename = new byte[MAX_FILE_PATH_LEN]; + public Pointer pPicData; // 图片数据 + } + + public static class NET_DVR_FOCUSMODE_CFG extends Structure { + public int dwSize; + public byte byFocusMode; /* 聚焦模式,0-自动,1-手动,2-半自动 */ + public byte byAutoFocusMode; /* 自动聚焦模式,0-关,1-模式A,2-模式B,3-模式AB,4-模式C 自动聚焦模式,需要在聚焦模式为自动时才显示*/ + public short wMinFocusDistance; /* 最小聚焦距离,单位CM, 0-自动,0xffff-无穷远 */ + public byte byZoomSpeedLevel; /* 变倍速度,为实际取值,1-3 */ + public byte byFocusSpeedLevel; /* 聚焦速度,为实际取值,1-3 */ + public byte byOpticalZoom; /* 光学变倍,0-255 */ + public byte byDigtitalZoom; /* 数字变倍,0-255 */ + public float fOpticalZoomLevel; /* 光学变倍(倍率值) [1,32], 最小间隔0.5 ,内部设备交互的时候*1000 */ + public int dwFocusPos;/* dwFocusPos 是focus值(聚焦值),范围为[0x1000,0xC000],这个值是sony坐标值,使用这个值是为了对外统一,保证不同的镜头对外focus值都转换在这个范围内 (手动聚焦模式下下应用)*/ + public byte byFocusDefinitionDisplay;// 聚焦清晰度显示,0~不显示,1~显示, 开启会在码流上显示当前镜头目标的清晰度值,用于帮助客户调焦使相机抓拍能够达到最清晰的效果,该清晰度越大代表着越清晰,清晰度范围为:0~100.0000 + public byte byFocusSensitivity; //聚焦灵敏度,范围[0,2],聚焦模式为自动、半自动时生效 + public byte[] byRes1 = new byte[2]; + public int dwRelativeFocusPos;//相对focus值,其低16位表示聚焦值,0~4000;高16位代表当前聚焦值获取时的温度值 + public byte[] byRes = new byte[48]; + } + + public static class NET_DVR_SERIALSTART_V40 extends Structure { + public int dwSize; //结构体大小 + public int dwSerialType; //串口号(1-232串口,2-485串口) + public byte bySerialNum; //串口编号 + public byte[] byRes = new byte[255]; + + + } + + public static class NET_DVR_PRESET_NAME extends Structure { + public int dwSize; + public short wPresetNum; //预置点编号 + public byte[] byRes1 = new byte[2]; //字节对齐 + public byte[] byName = new byte[NAME_LEN]; + public short wPanPos; //水平参数 如果获取到的数据大于360默认减去360 + public short wTiltPos; //垂直参数 如果获取到的数据大于360默认减去360 + public short wZoomPos; //变倍参数如果获取到的数据大于360默认减去360 + public byte[] byRes = new byte[58]; + } + + //Sensor信息 + public static class NET_DVR_SENSOR_PARAM extends Structure { + public byte bySensorType;//SensorType:0-CCD,1-CMOS + public byte[] byRes = new byte[31]; + public float fHorWidth;//水平宽度 精确到小数点后两位 *10000 + public float fVerWidth;//垂直宽度 精确到小数点后两位 *10000 + public float fFold;//zoom=1没变时的焦距 精确到小数点后两位 *100 + } + + //球机位置信息 + public static class NET_DVR_PTZPOS_PARAM extends Structure { + public float fPanPos;//水平参数,精确到小数点后1位 + public float fTiltPos;//垂直参数,精确到小数点后1位 + public float fZoomPos;//变倍参数,精确到小数点后1位 + public byte[] byRes = new byte[16]; + } + + public static class NET_DVR_LLI_PARAM extends Structure { + public float fSec;//秒[0.000000,60.000000] + public byte byDegree;//度:纬度[0,90] 经度[0,180] + public byte byMinute;//分[0,59] + public byte[] byRes = new byte[6]; + } + + //GIS信息上传 + public static class NET_DVR_GIS_UPLOADINFO extends Structure { + public int dwSize;//结构体大小 + public int dwRelativeTime; //相对时标 + public int dwAbsTime; //绝对时标 + public NET_VCA_DEV_INFO struDevInfo = new NET_VCA_DEV_INFO();//前端设备 + public float fAzimuth;//电子罗盘的方位信息;方位角[0.00°,360.00°) + public byte byLatitudeType;//纬度类型,0-北纬,1-南纬 + public byte byLongitudeType;// 经度类型,0-东度,1-西度 + public byte[] byRes1 = new byte[2]; + public NET_DVR_LLI_PARAM struLatitude = new NET_DVR_LLI_PARAM(); /*纬度*/ + public NET_DVR_LLI_PARAM struLongitude = new NET_DVR_LLI_PARAM(); /*经度*/ + public float fHorizontalValue;//水平视场角,精确到小数点后面两位 + public float fVerticalValue;//垂直视场角,精确到小数点后面两位 + public float fVisibleRadius;//当前可视半径,精确到小数点后面两位 + public float fMaxViewRadius;//最大可视半径,精确到小数点后面0位(预留处理) + public NET_DVR_SENSOR_PARAM struSensorParam;//Sensor信息 + public NET_DVR_PTZPOS_PARAM struPtzPos; //ptz坐标 + public byte[] byRes = new byte[256]; + } + + public static class NET_DVR_DAYTIME extends Structure { + public byte byHour;//0~24 + public byte byMinute;//0~60 + public byte bySecond;//0~60 + public byte byRes; + public short wMilliSecond; //0~1000 + public byte[] byRes1 = new byte[2]; + } + + public static class NET_DVR_SCHEDULE_DAYTIME extends Structure { + public NET_DVR_DAYTIME struStartTime; //开始时间 + public NET_DVR_DAYTIME struStopTime; //结束时间 + } + + public static class NET_DVR_BUILTIN_SUPPLEMENTLIGHT extends Structure { + public int dwSize;//结构体大小 + public byte byMode;//补光灯模式 0-定时,1-开启,2-关闭,3-自动(非光敏,算法画面识别) + public byte byBrightnessLimit;//亮度限制[0,100] + public byte bySupplementLightMode;//补光灯类型,0~白光模式,1~混合模式 + public byte byMixedLightRegulatMode;//混合补光灯亮度调节模式,0~自动,1~手动,当bySupplementLightMode = 1时生效 + public byte byLrLightBrightness;//红外亮度控制[0,100],当byMixedLightRegulatMode = 1时生效。 + public byte byHighLrLightBrightness;// 远光红外光亮度配置[0,100],当byMixedLightRegulatMode = 1时生效 + public byte byHighBrightnessLimit;// 远光白光亮度配置[0,100],当byMixedLightRegulatMode = 1时生效 + public byte byLowLrLightBrightness;// 近光红外光亮度配置[0,100],当byMixedLightRegulatMode = 1时生效 + public NET_DVR_SCHEDULE_DAYTIME struSchedTime;//定时时间段 + public byte byLowBrightnessLimit;//近光白光亮度配置[0,100],当byMixedLightRegulatMode = 1时生效 + public byte byWhiteLightBrightness;// 白光灯亮度 + public byte[] byRes1 = new byte[254]; + } + + public static class NET_DVR_HANDLEEXCEPTION_V41 extends Structure { + public int dwHandleType; //异常处理,异常处理方式的"或"结果 + /*0x00: 无响应*/ + /*0x01: 布防器上警告*/ + /*0x02: 声音警告*/ + /*0x04: 上传中心*/ + /*0x08: 触发报警输出*/ + /*0x10: 触发JPRG抓图并上传Email*/ + /*0x20: 无线声光报警器联动*/ + /*0x40: 联动电子地图(目前只有PCNVR支持)*/ + /*0x200: 抓图并上传FTP*/ + /*0x400: 虚交侦测 联动 聚焦模式(提供可配置项,原先设备自动完成)IPC5.1.0*/ + /*0x800: PTZ(球机目标)*/ + /*0x4000:白光灯报警*/ + /*0x10000:短信报警*/ + public int dwMaxRelAlarmOutChanNum; //触发的报警输出通道数(只读)最大支持数 + public int[] dwRelAlarmOut = new int[MAX_ALARMOUT_V40]; //触发报警通道 + public byte[] byRes = new byte[64]; //保留 + } + + public static class NET_DVR_PRESETCHAN_INFO extends Structure { + public int dwEnablePresetChan; /*启用预置点的通道, 0xfffffff表示不调用预置点*/ + public int dwPresetPointNo; /*调用预置点通道对应的预置点序号, 0xfffffff表示不调用预置点。*/ + } + + public static class NET_DVR_CRUISECHAN_INFO extends Structure { + public int dwEnableCruiseChan; /*启用巡航的通道*/ + public int dwCruiseNo; /*巡航通道对应的巡航编号, 0xfffffff表示无效*/ + } + + public static class NET_DVR_PTZTRACKCHAN_INFO extends Structure { + public int dwEnablePtzTrackChan; /*启用云台的通道*/ + public int dwPtzTrackNo; /*云台通道对应的编号, 0xfffffff表示无效*/ + } + + public static class NET_DVR_EVENT_TRIGGER extends Structure { + public int dwSize;//结构体大小 + public NET_DVR_HANDLEEXCEPTION_V41 struHandleException; //异常处理方式 + public int[] dwRelRecordChan = new int[MAX_CHANNUM_V40]; //实际触发录像通道,按值表示,采用紧凑型排列,从下标0开始顺序读取,中间遇到0xffffffff则后续无效。 + public NET_DVR_PRESETCHAN_INFO[] struPresetChanInfo = new NET_DVR_PRESETCHAN_INFO[MAX_CHANNUM_V40]; //启用的预置点信息 + public NET_DVR_CRUISECHAN_INFO[] struCruiseChanInfo = new NET_DVR_CRUISECHAN_INFO[MAX_CHANNUM_V40]; //启用巡航功能通道的信息 + public NET_DVR_PTZTRACKCHAN_INFO[] struPtzTrackInfo = new NET_DVR_PTZTRACKCHAN_INFO[MAX_CHANNUM_V40]; //调用云台的通道信息 + public byte byDirection;//触发方向:0-保留;1-全部;2-正向;3-反向 + public byte[] byRes2 = new byte[255]; + } + + public static class NET_DVR_FACELIB_GUARD_COND extends Structure { + public int dwSize; + public int dwChannel; //通道号 + public byte[] szFDID = new byte[68];//人脸库的ID + public byte[] byRes = new byte[128]; + } + + //导入人脸数据条件 + public static class NET_DVR_FACELIB_COND extends Structure { + public int dwSize; + public byte[] szFDID = new byte[NET_SDK_MAX_FDID_LEN/*256*/];//人脸库ID + public byte byConcurrent;//设备并发处理 0-不开启,1-开始 + public byte byCover;//是否覆盖式导入 0-否,1-是 + public byte byCustomFaceLibID;//FDID是否是自定义,0-不是,1-是; + public byte byPictureSaveMode;//上传原图保存模式,0-保存,1-不保存; + public byte[] byIdentityKey = new byte[NET_SDK_MAX_INDENTITY_KEY_LEN/*64*/];//交互操作口令 + public byte[] byRes = new byte[60]; + } + + public static class NET_DVR_SEND_PARAM_IN extends Structure { + public Pointer pSendData; //发送的缓冲区,PicURL == 1 的时候,内存中存储的是 URL 字符串,byUploadModeling == 1 的时候,内存中存储的是 建模base64加密数据 + public int dwSendDataLen; //发送数据长度,PicURL == 1 的时候,表示的 URL 字符串的长度,byUploadModeling == 1 的时候,表示为建模数据base64后的加密长度 + public NET_DVR_TIME_V30 struTime = new NET_DVR_TIME_V30(); //图片时间 + public byte byPicType; //图片格式,1-jpg,2-bmp,3-png,4-SWF,5-GIF + public byte byPicURL; //图片数据采用URL方式 0-二进制图片数据,1-图片数据走URL方式 + /*是否上传建模数据; + 0- 二进制图片数据方式(pSendData指向二进制图片数据, dwPicDataLen为图片二进制数据长度), + 1- 直接上传建模数据(pSendData指向建模base64加密数据, dwPicDataLen为建模数据base64后的加密长度)。 + 注:建模数据采用base64加密方式,选择为建模数据上传后,byPicURL 无需。 + 当”/ISAPI/Intelligent/channels//faceContrast/capabilities”能力中返回isSupportUploadModeling能力节点时,支持上传建模数据. */ + public byte byUploadModeling; + public byte byRes1; + public int dwPicMangeNo; //图片管理号 + public byte[] sPicName = new byte[NAME_LEN]; //图片名称 + public int dwPicDisplayTime; //图片播放时长,单位秒 + public Pointer pSendAppendData; //发送图片的附加信息缓冲区,对应FaceAppendData 的XML描述; + public int dwSendAppendDataLen; //发送图片的附加信息数据长度 FaceAppendData XML的长度; + public byte[] byRes = new byte[192]; + } + + public static class NET_DVR_INQUEST_ROOM extends Structure { + public byte byRoomIndex; //审讯室编号 + public byte byFileType; //0-审讯文件,1-开庭上传文件 + public byte[] byRes = new byte[22]; //保留 + } + + public static class NET_DVR_INQUEST_CDRW_CFG extends Structure { + public int dwSize; + public int dwNum; //刻录机的数量 + public int[] dwRwSelectPara = new int[MAX_CHANNUM_V30];// 是否选中该光驱 + public int dwModeSelect; //0表示循环刻录模式 1表示并行刻录模式(默认模式) + public byte[] byRes = new byte[24]; //保留 + public int dwStartCDRW; //DVR 本地已经开始刻录 + public int dwHdExcp; //硬盘有异 常 + public int dwInterval; //时间间隔,10分钟(0)、20分钟(1)、30分钟(2) + public byte[] sLable = new byte[64]; //光盘名称 + } + + public static class NET_DVR_INQUEST_CDRW_STATUS extends Structure { + /*运行状态:0-审讯开始, + 1-审讯过程中刻录,2-审讯停止, + 3-刻录审讯文件, + 4-备份(事后备份和本地备份) + 5-空闲 + 6-初始化硬盘 + 7-恢复审讯*/ + public int dwType; + public NET_DVR_INQUEST_CDRW[] strCDRWNum = new NET_DVR_INQUEST_CDRW[MAX_INQUEST_CDRW_NUM]; //数组0表示刻录机1 + public NET_DVR_TIME_EX struInquestStartTime = new NET_DVR_TIME_EX(); //审讯开始的时间点 + public byte[] byRes = new byte[16]; //保留 + } + + public static class NET_DVR_INQUEST_CDRW extends Structure { + public int dwEnable; //刻录机状态是否有效,0-无效,1-有效 + public int dwStatus; /*当dwType=0时, 0-光盘正常,1-无光盘或光盘异常, + 当dwType=1或2时,0-刻录正常,1-无光盘或光盘异常,2-光盘已封盘(81不支持),3-光盘空间不足, 4-异常导致审讯终止(81不支持) + 当dwType=3时, 0-刻录正常,1-无光盘或光盘异常,2-光盘已封盘(81不支持),3-光盘空间不足 + 当dwType=4时,0-刻录正常,1-无光盘或光盘异常,2-光盘已封盘(81不支持),3-光盘空间不足 + 当dwType=5时,0-光盘正常, 1-无光盘或光盘异常,2-光盘已封盘(81不支持) + 当dwType=6或7时, 0-刻录正常, 1-无光盘或光盘异常, 2-光盘已封盘(81不支持), 3-光盘空间不足*/ + public int dwVolumn; //光盘容量,单位M + public int dwFreeSpace; //光盘剩余容量,单位M + public int dwTimeLeft; // 光盘剩余时间,单位秒 + public byte byCDType; // 光盘类型 + public byte[] byRes = new byte[3]; //保留字节 + } + + //实时温度检测条件参数 + public static class NET_DVR_REALTIME_THERMOMETRY_COND extends Structure { + public int dwSize; /*结构体大小*/ + public int dwChan; /*通道号,从1开始,0xffffffff代表获取全部通道*/ + public byte byRuleID;/*规则ID,0代表获取全部规则,具体规则ID从1开始*/ + public byte byMode; //长连接模式:0- 保留(兼容不支持该功能的老设备),1- 定时模式,2- 温差模式 + public short wInterval; //上传间隔(仅温差模式支持),取值范围:1-3600 秒,填0则默认3600S上传一次 + public byte[] byRes2 = new byte[60]; + } + + //点测温实时信息 + public static class NET_DVR_POINT_THERM_CFG extends Structure { + public float fTemperature; + public NET_VCA_POINT struPoint; + public byte[] byRes = new byte[120]; + } + + //框/线测温实时信息 + public static class NET_DVR_LINEPOLYGON_THERM_CFG extends Structure { + public float fMaxTemperature; + public float fMinTemperature; + public float fAverageTemperature; + public float fTemperatureDiff; + public NET_VCA_POLYGON struRegion; + public byte[] byRes = new byte[32]; + } + + //实时温度信息 + public static class NET_DVR_THERMOMETRY_UPLOAD extends Structure { + public int dwSize; /* 结构体大小 */ + public int dwRelativeTime; + public int dwAbsTime; + public byte[] szRuleName = new byte[NAME_LEN]; + public byte byRuleID;/* 规则ID,0代表获取全部规则,具体规则ID从1开始 */ + public byte byRuleCalibType; + public short wPresetNo; + public NET_DVR_POINT_THERM_CFG struPointThermCfg; + public NET_DVR_LINEPOLYGON_THERM_CFG struLinePolygonThermCfg; + public byte byThermometryUnit; + public byte byDataType; + public byte byRes1; + public byte bySpecialPointThermType; + public float fCenterPointTemperature; + public float fHighestPointTemperature; + public float fLowestPointTemperature; + public NET_VCA_POINT struHighestPoint; + public NET_VCA_POINT struLowestPoint; + public byte byIsFreezedata; + public byte[] byRes = new byte[95]; + } + + public static class NET_PTZ_INFO extends Structure { + public float fPan; + public float fTilt; + public float fZoom; + public int dwFocus;// 聚焦参数,聚焦范围:归一化0-100000 + public byte[] byRes = new byte[4]; + } + + //测温模式配置 + public static class NET_DVR_THERMOMETRY_MODE extends Structure { + public int dwSize;//结构体大小 + public byte byMode;//测温模式,0~普通模式,1~专家模式 + public byte byThermometryROIEnabled; //测温ROI使能 0-保留 1-不开启 2-开启(基于互斥兼容考虑) + public byte[] byRes = new byte[62]; + } + + public static class NET_DVR_THERMOMETRY_COND extends Structure { + public int dwSize;//结构体大小 + public int dwChannel; + public short wPresetNo;//0-保留 + public byte[] byRes = new byte[62]; + } + + public static class NET_DVR_THERMOMETRY_PRESETINFO_PARAM extends Structure { + public byte byEnabled; //是否使能:0- 否,1- 是 + public byte byRuleID;//规则ID 0-表示无效,从1开始 (list内部判断数据有效性) + public short wDistance;//距离(m)[0, 10000] + public float fEmissivity;//发射率(发射率 精确到小数点后两位)[0.01, 1.00](即:物体向外辐射能量的本领) + public byte byDistanceUnit;//距离单位: 0-米(m),1-英尺(feet),2-厘米(centimeter) + public byte[] byRes = new byte[2]; + public byte byReflectiveEnabled;//反射温度使能:0- 否,1- 是 + public float fReflectiveTemperature;//反射温度 精确到小数后2位 + public byte[] szRuleName = new byte[NAME_LEN/*32*/];//规则名称 + public byte byemissivityMode; //发射率配置类型 1-粗糙,2-较粗糙,3-较光滑, 4-光滑, 0xff-自定义 + public byte[] byRes1 = new byte[62]; + public byte byRuleCalibType;//规则标定类型 0-点,1-框,2-线 + public NET_VCA_POINT struPoint = new NET_VCA_POINT();//点测温坐标(当规则标定类型为"点"的时候生效) + public NET_VCA_POLYGON struRegion = new NET_VCA_POLYGON();//区域、线(当规则标定类型为"框"或者"线"的时候生效) + } + + public static class NET_DVR_THERMOMETRY_PRESETINFO extends Structure { + public int dwSize;//结构体大小 + public short wPresetNo;//0-保留 + public byte[] byRes = new byte[2]; + public NET_DVR_THERMOMETRY_PRESETINFO_PARAM[] struPresetInfo = new NET_DVR_THERMOMETRY_PRESETINFO_PARAM[40]; + } + + //温度报警(检测温度和配置温度比较报警) + public static class NET_DVR_THERMOMETRY_ALARM extends Structure { + public int dwSize; + public int dwChannel;//通道号 + public byte byRuleID;//规则ID + public byte byThermometryUnit;//测温单位: 0-摄氏度(℃),1-华氏度(℉),2-开尔文(K) + public short wPresetNo; //预置点号 + public NET_PTZ_INFO struPtzInfo = new NET_PTZ_INFO();//ptz坐标信息 + public byte byAlarmLevel;//0-预警 1-报警 + public byte byAlarmType;/*报警类型 0-最高温度 1-最低温度 2-平均温度 3-温差 4-温度突升 5-温度突降*/ + public byte byAlarmRule;//0-大于,1-小于 + public byte byRuleCalibType;//规则标定类型 0-点,1-框,2线 + public NET_VCA_POINT struPoint = new NET_VCA_POINT();//点测温坐标(当规则标定类型为点的时候生效) + public NET_VCA_POLYGON struRegion = new NET_VCA_POLYGON();//区域(当规则标定类型为框的时候生效) + public float fRuleTemperature;/*配置规则温度,精确到小数点后一位(-40-1000),(浮点数+100) */ + public float fCurrTemperature;/*当前温度,精确到小数点后一位(-40-1000),(浮点数+100) */ + public int dwPicLen;//可见光图片长度 + public int dwThermalPicLen;//热成像图片长度 + public int dwThermalInfoLen;//热成像附加信息长度 + public Pointer pPicBuff; ///可见光图片指针 + public Pointer pThermalPicBuff;// 热成像图片指针 + public Pointer pThermalInfoBuff; //热成像附加信息指针 + public NET_VCA_POINT struHighestPoint = new NET_VCA_POINT();//线、框测温最高温度位置坐标(当规则标定类型为线、框的时候生效) + public float fToleranceTemperature;/* 容差温度,精确到小数点后一位(-40-1000),(浮点数+100) */ + public int dwAlertFilteringTime;//温度预警等待时间 单位秒 范围为0-200秒,默认为0秒 + public int dwAlarmFilteringTime;//温度报警等待时间 单位秒 范围为0-200秒,默认为0秒 + public int dwTemperatureSuddenChangeCycle;//温度突变记录周期,单位秒 + public float fTemperatureSuddenChangeValue;//温度突变值,精确到小数点后一位(大于0) + public byte byPicTransType; //图片数据传输方式: 0-二进制;1-url + public byte[] byRes = new byte[39]; + } + + //温差报警 + public static class NET_DVR_THERMOMETRY_DIFF_ALARM extends Structure { + public int dwSize; + public int dwChannel;//通道号 + public byte byAlarmID1;//规则AlarmID1 + public byte byAlarmID2;//规则AlarmID2 + public short wPresetNo; //预置点号 + public byte byAlarmLevel;//0-预警 1-报警 + public byte byAlarmType;/*报警类型 0-最高温度 1-最低温度 2-平均温度*/ + public byte byAlarmRule;//0-大于,1-小于 + public byte byRuleCalibType;//规则标定类型 0-点,1-框,2线 + public NET_VCA_POINT[] struPoint = (NET_VCA_POINT[]) new NET_VCA_POINT().toArray(2);//点测温坐标(当规则标定类型为点的时候生效)数组下标0代表着AlarmID1,数组下标1代表着AlarmID2. + public NET_VCA_POLYGON[] struRegion = (NET_VCA_POLYGON[]) new NET_VCA_POLYGON().toArray(2);//区域(当规则标定类型为框的时候生效)数组下标0代表着AlarmID1,数组下标1代表着AlarmID2. + public float fRuleTemperatureDiff;/*配置规则温差,精确到小数点后一位(-40-1000))*/ + public float fCurTemperatureDiff;/*当前温差,精确到小数点后一位(-40-1000),(浮点数+100) */ + public NET_PTZ_INFO struPtzInfo;//ptz坐标信息 + public int dwPicLen;//可见光图片长度 + public int dwThermalPicLen;//热成像图片长度 + public int dwThermalInfoLen;//热成像附加信息长度 + public Pointer pPicBuff; ///可见光图片指针 + public Pointer pThermalPicBuff;// 热成像图片指针 + public Pointer pThermalInfoBuff; //热成像附加信息指针 + public byte byThermometryUnit;//测温单位: 0-摄氏度(℃),1-华氏度(℉),2-开尔文(K) + public byte byPicTransType; //图片数据传输方式: 0-二进制;1-url + public byte[] byRes1 = new byte[2]; + public float fToleranceTemperature;/*容差温度,精确到小数点后一位(-40-1000),(浮点数+100) */ + public int dwAlarmFilteringTime;//温度报警等待时间 单位秒 范围为0-200秒,默认为0秒 + public int dwVisibleChannel; //可见光通道通道号 + public byte[] byRes = new byte[48]; + } + + //船只检测报警上传 + public static class NET_DVR_SHIPSDETECTION_ALARM extends Structure { + public int dwSize; + public NET_VCA_DEV_INFO struDevInfo; //设备信息 + public int dwRelativeTime; //相对时标 + public int dwAbsTime; //绝对时标 + public byte byShipsNum; //船只数;(正跨越检测线的船只数) + public byte byShipsNumHead;//船只数;(船头检测船只数) + public byte byShipsNumEnd; //船只数;(船尾检测船只数) + public byte byPicTransType; //图片数据传输方式: 0-二进制;1-url + public NET_DVR_SHIPSINFO[] struShipInfo = (NET_DVR_SHIPSINFO[]) new NET_DVR_SHIPSINFO().toArray(MAX_SHIPS_NUM); /*20*///船只信息;最大支持20艘 + public int dwPicLen;//可见光图片长度 + public int dwThermalPicLen;//热成像图片长度 + public Pointer pPicBuffer; //可见光图片数据指针 + public Pointer pThermalPicBuffer; //热成像图片数据指针 + public short wDevInfoIvmsChannelEx; //与NET_VCA_DEV_INFO里的byIvmsChannel含义相同,能表示更大的值。老客户端用byIvmsChannel能继续兼容,但是最大到255。新客户端版本请使用wDevInfoIvmsChannelEx。 + public byte byTimeDiffFlag; /*时差字段是否有效 0-时差无效, 1-时差有效 */ + public byte cTimeDifferenceH; /*与UTC的时差(小时),-12 ... +14, +表示东区,,byTimeDiffFlag为1时有效*/ + public byte cTimeDifferenceM; /*与UTC的时差(分钟),-30, 30, 45, +表示东区,byTimeDiffFlag为1时有效*/ + public byte bySID;//场景ID + public byte[] byRes1 = new byte[2]; + public byte[] szSceneName = new byte[NAME_LEN];//场景名称,不超过32字符 + public byte[] byRes = new byte[216]; + } + + public static final int MAX_SHIPS_NUM = 20; //船只检测最大船只数 + + //船只信息 + public static class NET_DVR_SHIPSINFO extends Structure { + public float fShipsLength; //船只长度;1~1000.0m,精确到小数点后一位 + public float fShipsHeight; //船只高度;1~1000.0m,精确到小数点后一位 + public float fShipsWidth; //船只宽度;1~1000.0m,精确到小数点后一位 + public float fShipsSpeed; //船只速度;1~1000.0m/s,精确到小数点后一位 + public byte byShipsDirection;//船只方向;0~up,1~down,2~left,3~right + public byte byShipsDetState;//船只检测状态;0~正跨越检测线,1~船头检测,2~船尾检测 + public byte byTriggerLineID;//检测线ID + public byte[] byRes = new byte[61]; + public NET_VCA_POLYGON struShipsRect; //船只区域,归一化值,相对于大图(可见光图、热成像图)的分辨率 + } + + public static class NET_DVR_ARRAY_LIST extends Structure { + public int dwSize; // 结构体大小 + public int dwCount; // 阵列个数 + public NET_DVR_ARRAY_INFO[] struArrayInfo = new NET_DVR_ARRAY_INFO[SUPPORT_ARRAY_NUM]; + } + + public static class NET_DVR_BGA_INFO extends Structure { + public byte byBga; // 后台任务及类型 + public byte byBgaState; /*函数返回值--后台任务状态*/ + public short wBgaPercentage; /*函数返回值--后台任务执行百分比*/ + public byte[] byRes = new byte[4]; // 保留字节 + } + + // 阵列信息 + public static class NET_DVR_ARRAY_INFO extends Structure { + public short wArrayID; // 阵列ID + public byte byRaidMode; // raid模式 参照RAID_MODE + public byte byStatus; // 0-在线 1-磁盘丢失 2-下线 3-降级 4-异常 5-次正常 6-外来盘 7-已删除 8-SMART状态异常 0xff-不存在 + public int dwHCapacity; // 阵列容量高32位 + public int dwLCapacity; // 阵列容量低32位 + public int dwHFreeSpace; // 阵列剩余空间高32位 + public int dwLFreeSpace; // 阵列剩余空间高32位 + public byte[] byArrayName = new byte[MAX_NAMELEN]; // 阵列名称 + public byte byPDCount; // 物理磁盘数目 + public byte bySpareCount; // 热备数目 + public byte[] byRes1 = new byte[2]; + public short[] wPDSlots = new short[SUPPORT_PD_NUM]; // 物理磁盘索引 + public short[] wSparePDSlots = new short[SUPPORT_PD_NUM]; // 热备磁盘索引 + public NET_DVR_BGA_INFO struBgaInfo; // 后台任务运行状态 + public short[] wPDSlotsPartTwo = new short[SUPPORT_PD_NUM_PARTTWO]; //物理磁盘索引扩展,0表示无效 + public short[] wSparePDSlotsPartTwo = new short[SUPPORT_PD_NUM_PARTTWO]; // 热备磁盘索引扩展,0表示无效 + public byte[] byRes2 = new byte[48]; // 保留字节 + } + + //物理磁盘 + public static class NET_DVR_PHY_DISK_INFO extends Structure { + public short wPhySlot; // 硬盘槽位 + public byte byType; // 硬盘信息;0 普通,1全局热备,2-阵列热备 3-阵列盘 + public byte byStatus; // 硬盘状态; 0-正常 1-降级 2-已删除 3-磁盘丢失 4-下线 5-次正常 6-外来 7-异常 8-SMART状态异常 9-休眠 10-有坏块 0xff-不存在 + public byte[] byMode = new byte[40]; // 硬盘类型 字符串 + public int dwHCapacity; // 磁盘总量高32位 单位kb + public int dwLCapacity; // 磁盘总量低32位 + public byte[] byArrrayName = new byte[MAX_NAMELEN]; + public short wArrayID; // 所属阵列ID + public byte byArrayInformation; // 是否含有阵列信息:0 否,1是 + public byte[] byRes = new byte[101]; // 保留字节 + } + + public static class NET_DVR_WORKSTATE_V40 extends Structure { + public int dwSize; //结构体大小 + public int dwDeviceStatic; //设备的状态,0-正常,1-CPU占用率太高,超过85%,2-硬件错误,例如串口死掉 + public NET_DVR_DISKSTATE[] struHardDiskStatic = new NET_DVR_DISKSTATE[MAX_DISKNUM_V30]; //硬盘状态,一次最多只能获取33个硬盘信息 + public NET_DVR_CHANNELSTATE_V30[] struChanStatic = new NET_DVR_CHANNELSTATE_V30[MAX_CHANNUM_V40/*512*/];//通道的状态,从前往后顺序排列 + public int[] dwHasAlarmInStatic = new int[MAX_ALARMIN_V40]; //有报警的报警输入口,按值表示,按下标值顺序排列,值为0xffffffff时当前及后续值无效 + public int[] dwHasAlarmOutStatic = new int[MAX_ALARMOUT_V40]; //有报警输出的报警输出口,按值表示,按下标值顺序排列,值为0xffffffff时当前及后续值无效 + public int dwLocalDisplay; //本地显示状态,0-正常,1-不正常 + public byte[] byAudioInChanStatus = new byte[MAX_AUDIO_V30/*2*/]; //按位表示语音通道的状态 0-未使用,1-使用中,第0位表示第1个语音通道 + public byte[] byRes1 = new byte[2]; + public float fHumidity; //传感器获知的湿度,范围:0.0 ~100.0 + public float fTemperature; //传感器获知的温度,范围:-20.0 ~ 90.0 + public byte[] byRes = new byte[116]; //保留 + } + + public static class NET_DVR_GETWORKSTATE_COND extends Structure { + public int dwSize; //结构体长度 + public byte byFindHardByCond; /*0-查找全部磁盘(但一次最多只能查找33个),此时dwFindHardStatusNum无效*/ + public byte byFindChanByCond; /*0-查找全部通道,此时dwFindChanNum无效*/ + public byte[] byRes1 = new byte[2];//保留 + public int[] dwFindHardStatus = new int[MAX_DISKNUM_V30/*33*/]; /*要查找的硬盘号,按值表示,该值采用顺序排列, 遇到0xffffffff则认为后续无效 */ + public int[] dwFindChanNo = new int[MAX_CHANNUM_V40/*512*/]; /*要查找的通道号,按值表示,该值采用顺序排列, 遇到0xffffffff则认为后续无效 */ + public byte[] byRes = new byte[64]; //保留 + } + + //多边型结构体 + public static class NET_ITC_POLYGON extends Structure { + public int dwPointNum; //有效点 大于等于3,若是3点在一条线上认为是无效区域,线交叉认为是无效区域 + public NET_VCA_POINT[] struPos = new NET_VCA_POINT[ITC_MAX_POLYGON_POINT_NUM]; //多边形边界点,最多20个 + } + + public static class CUSTOM_uRegion extends Union { + public NET_VCA_RECT struRect = new NET_VCA_RECT(); + public NET_ITC_POLYGON struPolygon = new NET_ITC_POLYGON(); + } + + public static class NET_ITC_PLATE_RECOG_REGION_PARAM extends Structure { + public byte byMode; //区域类型,0-矩形,1-多边形 + public byte[] byRes1 = new byte[3]; + public CUSTOM_uRegion uRegion = new CUSTOM_uRegion(); + public byte[] byRes = new byte[16]; //保留 + } + + //单组IO测速参数 + public static class NET_ITC_SINGLE_IOSPEED_PARAM extends Structure { + public byte byEnable; //是否启用,0-不启用,1-启用 + public byte byTrigCoil1; //第一线圈关联IO,0-IO1,1-IO2,2-IO3,3-IO4,4-IO5,5-IO6 + public byte byCoil1IOStatus;//第一线圈IO输入口状态,0-下降沿(默认),1-上升沿,2-上升沿和下降沿,3-高电平,4-低电平 + public byte byTrigCoil2; //第二线圈关联IO,0-IO1,1-IO2,2-IO3,3-IO4,4-IO5,5-IO6 + public byte byCoil2IOStatus;//第二线圈IO输入口状态,0-下降沿(默认),1-上升沿,2-上升沿和下降沿,3-高电平,4-低电平 + public byte byRelatedDriveWay;//关联的车道号 + public byte byTimeOut;//超时时间(默认10),单位s + public byte byRelatedIOOutEx;//第0位表示IO输出口1,以此类推,0-不关联,1-关联 支持关联到8个(兼容byRelatedIOOut字段) + public int dwDistance;//线圈距离(默认1000),单位:厘米 + public byte byCapSpeed;//起拍速度(默认30),单位km/h + public byte bySpeedLimit;//限速值(默认60),单位km/h + public byte bySpeedCapEn; //是否启用超速抓拍,0-否,1-是 + public byte bySnapTimes1; //线圈1抓拍次数(默认不抓拍),0-不抓拍,非0-连拍次数,最大5次 + public byte bySnapTimes2; //线圈2抓拍次数(默认1),0-不抓拍,非0-连拍次数,最大5次 + public byte byBigCarSpeedLimit; //大车车速限制值 + public byte byBigCarSignSpeed;//标志限速(大车),单位km/h(3.7Ver) + public byte byIntervalType; //间隔类型(默认按时间),0-时间起效,1-距离起效 + public short[] wInterval1 = new short[MAX_INTERVAL_NUM];//线圈1连拍间隔时间(单位ms)或连拍间隔距离(单位分米),当byIntervalType为0时,表示间隔时间,当byIntervalType为1时,表示距离 + public short[] wInterval2 = new short[MAX_INTERVAL_NUM];//线圈2连拍间隔时间(单位ms)或连拍间隔距离(单位分米),当byIntervalType为0时,表示间隔时间,当byIntervalType为1时,表示距离 + public byte[] byRelatedIOOut = new byte[MAX_IOOUT_NUM]; //关联的IO输出口(可以同时关联多个),数组0表示IO输出口1,数组1表示IO输出口2,以此类推,0-不关联,1-关联 + public byte byFlashMode; //闪光灯闪烁模式,0-同时闪,1-轮流闪 + public byte byLaneType; //车道类型,0-未配置、1-高速公路、2-城市快速路、0xff-其他道路 + public byte byCarSignSpeed;//标志限速,单位km/h(3.7Ver) + public byte byUseageType; //车道用途类型,详见ITC_LANE_USEAGE_TYPE + public NET_ITC_PLATE_RECOG_REGION_PARAM[] struPlateRecog = new NET_ITC_PLATE_RECOG_REGION_PARAM[MAX_LANEAREA_NUM]; //牌识参数(可用牌识区域1个,保留一个) + //关联车道方向类型,参考ITC_RELA_LANE_DIRECTION_TYPE + //该参数为车道方向参数,与关联车道号对应,确保车道唯一性。 + public byte byRelaLaneDirectionType; + public byte byLowSpeedLimit; //小车限底速值,单位km/h + public byte byBigCarLowSpeedLimit; //大车限底速值,单位km/h + public byte byLowSpeedCapEn; //是否启用低速抓拍,0-否,1-是 + public byte byEmergencyCapEn; //是否启用应急车道抓拍,0-否,1-是 + public byte[] byRes = new byte[27]; + } + + //牌识参数 + public static class NET_ITC_PLATE_RECOG_PARAM extends Structure { + public byte[] byDefaultCHN = new byte[MAX_CHJC_NUM]; /*设备运行省份的汉字简写*/ + public byte byEnable; //是否启用该区域牌识,0-否,1-是 + public int dwRecogMode; + /*识别的类型, + bit0-背向识别:0-正向车牌识别,1-背向识别(尾牌识别) ; + bit1-大车牌识别或小车牌识别:0-小车牌识别,1-大车牌识别 ; + bit2-车身颜色识别:0-不采用车身颜色识别,在背向识别或小车牌识别时禁止启用,1-车身颜色识别; + bit3-农用车识别:0-不采用农用车识别,1-农用车识别; + bit4-模糊识别:0-不采用模糊识别,1-模糊识别; + bit5-帧定位或场定位:0-帧定位,1-场定位; + bit6-帧识别或场识别:0-帧识别,1-场识别; + bit7-晚上或白天:0-白天,1-晚上 + bit8-摩托车识别:0-不采用摩托车识别,1-摩托车识别; + bit9-场景模式:0-电警/多帧,1-卡口; + bit10-微小车牌:0-不启用,1-启用微小车牌识别(像素60~80) + bit11-安全带检测:0-不启用,1-启用安全带检测 + bit12-民航车牌识别: 0-不启用,1-开启民航车牌识别 + bit13-车牌过渡倾斜处理: 0-不启用,1-开启过渡倾斜处理(PRS) + bit14-超大车牌识别: 0-不启用,1-开启超大车牌识别(PRS) + bit15-遮阳板检测:0-不启用,1-启用遮阳板检测 + bit16-黄标车检测:0-不启用,1-启用黄标车检测 + bit17-危险品车辆检测:0-不启用,1-启用危险品车辆检测 + bit18-使馆车牌识别:0-不启用,1-启用使馆车牌识别 + bit19-车辆子品牌识别:0-不启用,1-启用车辆子品牌识别 + bit20-打电话识别:0-不启用,1-启用 + bit21-车窗悬挂物识别:0-不启用,1-启用 + */ + public byte byVehicleLogoRecog;//车标识别 0-不启用,1-启用 + /* + 0-保留,1-澳,2-京,3-渝,4-闽,5-甘,6-粤,7-桂,8-贵,9-琼,10-冀,11-豫, + 12-黑,13-鄂,14-湘,15-吉,16-苏,17-赣,18-辽,19-蒙,20-宁,21-青,22-鲁, + 23-晋,24-陕,25-沪,26-川,27-台,28-津,29-藏,30-港,31-新,32-云,33-浙, + 34-皖,0xff-全部 + */ + public byte byProvince;//省份索引值 + public byte byRegion;// 区域索引值 0-保留,1-欧洲, 3-欧洲&(EU&CIS),4-中东(Middle East) + public byte byCountry;//国家索引,参照枚举COUNTRY_INDEX(不支持“COUNTRY_ALL = 0xff,//ALL 全部”) + public short wPlatePixelWidthMin;//车牌像素识别宽度最小值(单位是像素)当前推荐范围[130,500] + public short wPlatePixelWidthMax;//车牌像素识别宽度最大值(单位是像素)当前推荐范围[130,500] + public byte[] byRes = new byte[24]; + } + + //卡口IO测速参数 + public static class NET_ITC_POST_IOSPEED_PARAM extends Structure { + public NET_ITC_PLATE_RECOG_PARAM struPlateRecog; //牌识参数 + public NET_ITC_SINGLE_IOSPEED_PARAM[] struSingleIOSpeed = new NET_ITC_SINGLE_IOSPEED_PARAM[MAX_IOSPEED_GROUP_NUM]; //单个IO测速组参数 + public byte[] byRes = new byte[32]; + } + + public static class NET_DVR_GEOGLOCATION extends Structure { + public int[] iRes = new int[2]; /*保留*/ + public int dwCity; /*城市,详见PROVINCE_CITY_IDX */ + } + + public static class NET_ITC_INTERVAL_PARAM extends Structure { + public byte byIntervalType; //间隔类型(默认按时间),0-时间起效,1-距离起效 + public byte[] byRes1 = new byte[3]; + public short[] wInterval = new short[MAX_INTERVAL_NUM];//连拍间隔时间(单位ms)或连拍间隔距离(单位分米),当byIntervalType为0时,表示间隔时间,当byIntervalType为1时,表示距离 + public byte[] byRes = new byte[8]; + } + + public static class NET_ITC_VTLANE_PARAM extends Structure { + public byte byRelatedDriveWay;//关联的车道号 + public byte bySpeedCapEn; //是否启用超速抓拍,0-否,1-是 + public byte bySignSpeed;//标志限速,单位km/h + public byte bySpeedLimit;//限速值,单位km/h + public byte bySnapTimes; //抓拍次数(默认1),0-不抓拍,非0-连拍次数,最大5 + public byte byBigCarSignSpeed;///*大车标志限速,单位km/h*/ + public byte byBigCarSpeedLimit;/*大车限速值,单位km/h*/ + public byte byRelatedIOOutEx;//第0位表示IO输出口1,以此类推,0-不关联,1-关联 支持关联到8个(兼容byRelatedIOOut字段) + public NET_ITC_INTERVAL_PARAM struInterval = new NET_ITC_INTERVAL_PARAM(); //抓拍间隔参数 + public byte[] byRelatedIOOut = new byte[MAX_IOOUT_NUM]; //关联的IO输出口,可以同时关联多个 + public byte byFlashMode; //闪光灯闪烁模式,0-同时闪,1-轮流闪 + public byte byLowSpeedLimit;/*限低速,单位km/h*/ + public byte byBigCarLowSpeedLimit; /*大车限低速,单位km/h*/ + //关联车道方向类型,参考ITC_RELA_LANE_DIRECTION_TYPE + //该参数为车道方向参数,与关联车道号对应,确保车道唯一性。 + public byte byRelaLaneDirectionType; + public NET_ITC_PLATE_RECOG_REGION_PARAM[] struPlateRecog = new NET_ITC_PLATE_RECOG_REGION_PARAM[MAX_LANEAREA_NUM]; //车道牌识参数 + public NET_VCA_LINE struLine = new NET_VCA_LINE(); //车道线 + } + + public static class NET_ITC_VTCOIL_INFO extends Structure { + public NET_VCA_RECT struLaneRect = new NET_VCA_RECT(); /*虚拟线圈区域*/ + public byte byTrigFlag; //触发标志,0-车头触发;1-车尾触发;2-车头/车尾都触发 + public byte byTrigSensitive; //触发灵敏度,1-100 + public byte[] byRelatedIOOut = new byte[MAX_IOOUT_NUM]; //关联的IO输出口(可以同时关联多个),数组0表示IO输出口1,数组1表示IO输出口2,以此类推,0-不关联,1-关联 + public byte byFlashMode; //闪光灯闪烁模式,0-同时闪,1-轮流闪 + public byte byLaneType; //车道类型,0-未配置、1-高速公路、2-城市快速路、0xff-其他道路 + public byte byEnableRadar; //是否启用雷达测速,0-否,1-是 + public NET_ITC_VTLANE_PARAM struLane = new NET_ITC_VTLANE_PARAM(); //关联的车道参数 + //车道用途类型,详见ITC_LANE_USEAGE_TYPE,使用1和8两种类型(3.7Ver) + public byte byUseageType; + //车辆行驶方向,详见ITC_LANE_CAR_DRIVE_DIRECT(3.7Ver) + public byte byCarDriveDirect; + public byte[] byRes = new byte[30]; + } + + public static class NET_ITC_RADAR_PARAM extends Structure { + public byte byRadarType; //雷达类型,0-无雷达,1-安道雷雷达,2-奥利维亚,3-川速微波4,雷达接IO扩展盒(此参数在卡口虚拟线圈、混行卡口界面中使用,卡口RS485雷达不使用),0xff-其它类型 + public byte byLevelAngle; //与水平线所成角度,默认为25°(0到90度) + public short wRadarSensitivity; //雷达灵敏度 + public short wRadarSpeedValidTime;//雷达速度有效时间(0~2000] ,0表示不支持 + public byte[] byRes1 = new byte[2]; + public float fLineCorrectParam;//线性矫正参数[0.0~2.0] + public int iConstCorrectParam;//常量矫正参数[-100~100] + public byte[] byRes2 = new byte[8]; + } + + //卡口虚拟线圈触发参数 + public static class NET_ITC_POST_VTCOIL_PARAM extends Structure { + public byte byRelatedLaneNum;//关联的车道个数 + public byte byIsDisplay; //视频中是否显示虚拟线圈,0-不显示,1-显示 + public byte byLoopPos; //晚间触发线圈的偏向(默认10) + public byte byPolarLenType; /*偏振镜类型,0:不加偏振镜;1:加施耐德偏振镜。*/ + public byte byDayAuxLightMode; /*白天辅助照明模式,0:无辅助照明;1:LED灯照明;2:闪光灯照明*/ + public byte byVideoLaneNO; //视频参考亮度的参考车道号 + public byte byVideoLowTh; /*视†频参考亮度低阈值初始化值(默认40)*/ + public byte byVideoHighTh; /*视频参考亮度高阈值初始化值(默认55)*/ + public byte byRecordMode; //录像标志:0-不录像,1-录像 + public byte bySnapMode;//抓拍模式:0-频闪模式;1-爆闪模式 + /*测速方式:0-不测速,0x1-雷达测速,0x2-视频测速*/ + public byte bySpeedDetector; + public byte byRes2; + public short wResolutionX;/* 设备当前分辨率宽*/ + public short wResolutionY;/* 设备当前分辨率高*/ + public int dwDayInitExp; /*视频白天曝光时间的初始值2000*/ + public int dwDayMaxExp; /*视频白天曝光时间的最大值20000*/ + public int dwNightExp; /*晚间视频曝光时间的设置值3000*/ + public int dwSnapExp; /*抓拍曝光时间*/ + public byte byDayInitGain; /*视频白天增益的初始值200*/ + public byte byDayMaxGain; /*视频白天增益的最大值400*/ + public byte byNightGain; /*晚间视频增益*/ + public byte bySnapGain; /*抓拍增益*/ + public int dwSceneMode; //场景模式, 详见SCENE_MODE + public NET_DVR_GEOGLOCATION struGeogLocation = new NET_DVR_GEOGLOCATION(); //地址位置(默认浙江) + public NET_ITC_PLATE_RECOG_PARAM struPlateRecog = new NET_ITC_PLATE_RECOG_PARAM(); //牌识参数 + public NET_ITC_VTCOIL_INFO[] struVtCoil = new NET_ITC_VTCOIL_INFO[MAX_VL_NUM]; //虚拟线圈参数 + public NET_ITC_RADAR_PARAM struRadar = new NET_ITC_RADAR_PARAM(); //雷达参数 + public NET_VCA_LINE struLine = new NET_VCA_LINE(); //右车道线 + //违规检测类型,按位表示,详见ITC_VIOLATION_DETECT_TYPE,0-不启用,1-启用(3.7Ver) + public int dwVioDetectType; + public byte byDebugMode; /*调试模式,0-不启用,1-启用*/ + public byte[] byRes = new byte[11]; + } + + //车道属性参数结构 + public static class NET_ITC_LANE_LOGIC_PARAM extends Structure { + public byte byUseageType; //车道用途类型,详见ITC_LANE_USEAGE_TYPE + public byte byDirectionType; //车道方向类型,详见ITC_LANE_DIRECTION_TYPE + public byte byCarDriveDirect; //车辆行驶方向,详见ITC_LANE_CAR_DRIVE_DIRECT + public byte[] byRes = new byte[33]; //保留 + } + + //视频电警线结构 + public static class NET_ITC_LINE extends Structure { + public NET_VCA_LINE struLine = new NET_VCA_LINE(); //线参数 + public byte byLineType; //线类型,详见ITC_LINE_TYPE + public byte[] byRes = new byte[7]; + } + + public static class NET_ITC_SNAPMODE_PARAM extends Structure { + public byte byVehicleCapMode;//机动车抓拍模式,0-频闪模式;1-爆闪模式 + public byte byNoVehicleCapMode;//非机动车抓拍模式,0-频闪模式;1-爆闪模式 + public byte byPasserCapMode;//行人抓拍模式,0-频闪模式;1-爆闪模式 + public byte[] byRes = new byte[29]; + } + + //size = 128 + public static class NET_ITC_HVT_EC_PARAM extends Structure { + public int dwCapShutter; //抓拍快门0~65535 + public short wCapGain; //抓拍增益0~100 + public byte[] byRes = new byte[2]; + public int dwDayTimeVideoShutter; //白天曝光时间最大值 + public short wDayTimeVideoGain; //白天增益最大值 + public short wNightVideoGain; //晚上增益最大值 + public short wNightVideoShutter; //晚上曝光时间最大值 + public byte[] byRes1 = new byte[108]; + } + + public static class NET_ITC_LANE_HVT_PARAM extends Structure { + public byte byLaneNO; //关联的车道号 1~255(用于叠加和上传) + public byte bySignSpeed; //标志限速,单位km/h 0~255 70 + public byte bySpeedLimit; //限速值,单位km/h 0~255 80 实际起效 + public byte byBigCarSignSpeed;///*大车标志限速,单位km/h*/ + public byte byBigCarSpeedLimit;/*大车限速值,单位km/h*/ + public byte bySpeedCapEn; //是否启用超速抓拍,0-否,1-是 + public byte byCaptureCount;//抓拍张数1~5(正常) + public byte byRelatedIOOut; /*关联的IO输出口(可以同时关联多个),按位表示IO输出口,第0位表示IO输出口1,以此类推,0-不关联,1-关联*/ + public byte byFlashMode; /*闪光灯闪烁模式,0-同时闪,1-轮流闪*/ + public byte byEnableRadar; //是否启用雷达测速,0-否,1-是 + public byte byChangeLaneEnable; //违章变道抓拍使能,0-关闭,1-开启 + public byte byChangeLaneCapNo; //违章变道抓拍张数2-3 + public int dwCapTarget; //抓拍类型 bit0 表示机动车 bit1 表示非机动车 bit2 表示行人 0~表示不选择 1~表示选择 + public NET_ITC_INTERVAL_PARAM struInterval; //抓拍间隔参数 + public byte[] byRes3 = new byte[24]; + public NET_ITC_LANE_LOGIC_PARAM struLane; //车道属性,用byUseageType和byCarDriveDirect + public NET_ITC_LINE struLeftLaneLine; //左车道线,线类型为虚线、实线、单黄线和双黄线 + public NET_ITC_LINE struRightLaneLine; //右车道线,线类型为虚线、实线、单黄线和双黄线 + public NET_ITC_POLYGON struPlateRecog; //牌识区域参数 + public NET_ITC_POLYGON struTraceArea; //视频触发焦点区域 + public NET_VCA_LINE struForwardTrigLine; //正向触发线:一条线段,关心端点位置,目前只支持水平配置,接口按线段的两个端点保存。(一般配置为正向车辆的最佳触发位置) + public NET_VCA_LINE struBackwardTrigLine; //背向触发线:一条线段,关心端点位置,目前只支持水平配置,接口按线段的两个端点保存(一般配置为背向车辆的最佳触发位置) + public NET_VCA_LINE struLeftTrigLine; //左边触发线:一条线段,关心端点位置,目前只支持垂直配置,接口按线段的两个端点保存(一般配置为从左边进入车辆的最佳触发位置) + public NET_VCA_LINE struRightTrigLine; //右边触发线:一条线段,关心端点位置,目前只支持垂直配置,接口按线段的两个端点保存(一般配置为从右边进入车辆的最佳触发位置) + public byte[] byRes4 = new byte[60]; + } + + public static class NET_ITC_POST_HVT_PARAM extends Structure { + public byte byLaneNum;//识别的车道个数,1-6 + public byte bySceneMode;//0-未知1-城区道路;2-小区出入口 + public byte byRoadExpBright;//路面期望亮度(视频曝光参数调整的依据之一。在无机动车时,依据此亮度期望值,调整视频曝光参数) + public byte byPlateExpBright;//车牌期望亮度(视频曝光参数调整的依据之一。在有机动车通过并识别到车牌时,依据此亮度期望值,对视频曝光参数调整) + public NET_ITC_POLYGON struDetectArea; //视频检测区域 + public NET_ITC_SNAPMODE_PARAM struCapMode = new NET_ITC_SNAPMODE_PARAM();//抓拍模式 + public NET_ITC_HVT_EC_PARAM struEcParam = new NET_ITC_HVT_EC_PARAM(); //曝光控制参数 + public NET_ITC_LANE_HVT_PARAM[] struLaneParam = new NET_ITC_LANE_HVT_PARAM[MAX_ITC_LANE_NUM]; //单车道属性 + public NET_ITC_PLATE_RECOG_PARAM struPlateRecog = new NET_ITC_PLATE_RECOG_PARAM(); //牌识参数 + public NET_DVR_GEOGLOCATION struGeogLocation = new NET_DVR_GEOGLOCATION(); //地址位置(默认浙江) + public byte[] byRes = new byte[324]; + } + + //抓拍机4.0新增 + public static class NET_ITC_LANE_HVT_PARAM_V50 extends Structure { + public byte byLaneNO; //关联的车道号1~255(用于叠加和上传) + public byte byFlashMode; //闪光灯闪烁模式,0-同时闪,1-轮流闪 + public byte bySignSpeed; //小车标志限高速,单位km/h + public byte bySpeedLimit; //小车限高速值,单位km/h + public byte bySignLowSpeed; //小车标志限底速,单位km/h + public byte byLowSpeedLimit; //小车限底速值,单位km/h + public byte byBigCarSignSpeed; //大车标志限高速,单位km/h(新交规) + public byte byBigCarSpeedLimit; //大车限高速值,单位km/h(新交规) + public byte byBigCarSignLowSpeed; //大车标志限底速,单位km/h + public byte byBigCarLowSpeedLimit; //大车限底速值,单位km/h + public byte bySnapTimes; //卡口抓拍张数,1~3 + public byte byDriveLineSnapTime;// 压线抓拍张数 1~3 + public byte byHighSpeedSnapTime;// 超高速抓拍张数1~3 + public byte byLowSpeedSnapTime;// 超低速抓拍张数1~3 + public byte byBanSnapTime;// 违反禁令抓拍张数 1~3 + public byte byReverseSnapTime;//逆行抓拍张数 1~3 + public byte byRelatedDriveWay; //关联车道号,用于匹配车检器 + public byte byLaneType; //车道类型,0-未配置、1-高速公路、2-城市快速路、0xff-其他道路 + //关联车道方向类型,参考ITC_RELA_LANE_DIRECTION_TYPE + //该参数为车道方向参数,与关联车道号byRelatedDriveWay对应,确保车道唯一性。 + public byte byRelaLaneDirectionType; + public byte[] byRes1 = new byte[27]; + public byte byChangeLaneEnable; //违章变道抓拍使能,0-关闭,1-开启 + public byte byChangeLaneCapNo; //违章变道抓拍张数2-3 + //目前仅使用第一个车道的,以后可能会扩展为多车道分别配置 + //类型, 按位表示,0-不启用,1-启用参考 ITC_VIOLATION_DETECT_TYPE + public int dwVioDetectType; + public int dwRelatedIOOut; //关联的IO输出口(可以同时关联多个),按位表示IO输出口,第0位表示IO输出口1,以此类推,0-不关联,1-关联 + public NET_ITC_LINE struTrigLine; //触发线,目前仅使用第一个车道的,以后可能会扩展为多车道分别配置 + public NET_ITC_LINE struLineLeft; //左车道线 + public NET_ITC_POLYGON struPlateRecog; //牌识区域 + public NET_ITC_LANE_LOGIC_PARAM struLane; //车道属性,用byUseageType和byCarDriveDirect + public NET_ITC_INTERVAL_PARAM struInterval;//抓拍间隔参数(20byte) + public byte[] byRes2 = new byte[280]; + } + + public static class NET_ITC_POST_HVT_PARAM_V50 extends Structure { + public byte byLaneNum; //识别的车道个数,1-6 + public byte byCapType; //抓拍类型,0-机、非、人(默认),1-机动车 + public byte byCapMode; //抓拍方式,0-视频抽帧,1-打断抓拍,2-混合模式, + public byte bySecneMode; //场景模式,0-城区道路(默认),1-小区出入口,2-高速公路 + public byte bySpeedMode; //测速模式,0-无测速,1-雷达测速,2-视频测速 + public byte byLineRuleEffect; //触发规则线有效性,每一位代表一条触发线,0-无效;1-有效。bit0-左触发线;bit1-右触发线;bit2-视频检测区域 + public byte[] byRes1 = new byte[78]; + public NET_ITC_LINE struLeftTrigLine; //左触发线(一条垂直线) + public NET_ITC_LINE struRigtTrigLine; //右触发线(一条垂直线) + public NET_ITC_LINE struLaneBoundaryLine; //车道边界线(最右边车道的右车道线) + public NET_ITC_POLYGON struDetectArea; //视频检测区域 + public NET_DVR_GEOGLOCATION struGeogLocation; //地理位置(默认浙江省)计算时区 + public NET_ITC_LANE_HVT_PARAM_V50[] struLaneParam = new NET_ITC_LANE_HVT_PARAM_V50[MAX_ITC_LANE_NUM/*6*/]; //单车道属性 + public NET_ITC_PLATE_RECOG_PARAM struPlateRecog; //牌识参数 + public byte[] byRes2 = new byte[260]; + } + + + public static class NET_ITC_LANE_PARAM extends Structure { + public byte byEnable; //是否启用该车道,0-不启用,1-启用 + public byte byRelatedDriveWay;//关联的车道号 + public short wDistance; //线圈距离,计算速度 + public short wTrigDelayTime; //触发延迟时间(默认200),单位:毫秒 + public byte byTrigDelayDistance; //触发延迟距离(默认0),单位:分米 + public byte bySpeedCapEn; //是否启用超速抓拍,0-否,1-是 + public byte bySignSpeed;//标志限速,单位km/h + public byte bySpeedLimit;//限速值,单位km/h + public byte bySnapTimes; //抓拍次数(默认1),0-不抓拍,非0-连拍次数,最大5 + public byte byOverlayDriveWay; //OSD叠加的车道号 + public NET_ITC_INTERVAL_PARAM struInterval; //抓拍间隔参数 + public byte[] byRelatedIOOut = new byte[MAX_IOOUT_NUM]; //关联的IO输出口,可以同时关联多个 + public byte byFlashMode; //闪光灯闪烁模式,0-同时闪,1-轮流闪 + public byte byCartSignSpeed;//标志限速(大车),单位km/h + public byte byCartSpeedLimit;//限速值(大车),单位km/h + public byte byRelatedIOOutEx;//第0位表示IO输出口1,以此类推,0-不关联,1-关联 支持关联到8个(兼容byRelatedIOOut字段) + public NET_ITC_PLATE_RECOG_REGION_PARAM[] struPlateRecog = new NET_ITC_PLATE_RECOG_REGION_PARAM[MAX_LANEAREA_NUM]; //车道牌识参数 + public byte byLaneType; //车道类型,0-未配置、1-高速公路、2-城市快速路、0xff-其他道路 + public byte byUseageType; //车道用途类型,详见ITC_LANE_USEAGE_TYPE + //关联车道方向类型,参考ITC_RELA_LANE_DIRECTION_TYPE + //该参数为车道方向参数,与关联车道号对应,确保车道唯一性。 + public byte byRelaLaneDirectionType; + public byte byLowSpeedLimit; //小车限底速值,单位km/h + public byte byBigCarLowSpeedLimit; //大车限底速值,单位km/h + public byte byLowSpeedCapEn; //是否启用低速抓拍,0-否,1-是 + public byte byEmergencyCapEn; //是否启用应急车道抓拍,0-否,1-是 + public byte[] byRes = new byte[9]; + } + + //卡口RS485车检器触发参数 + public static class NET_ITC_POST_RS485_PARAM extends Structure { + public byte byRelatedLaneNum;//关联的车道个数 + public byte byTriggerSpareMode; //触发备用模式,0-默认,1-卡口虚拟线圈模式,2-卡口混合车道模式 + public byte byFaultToleranceTime;//容错时间(单位:分钟),用于检测车检器是否正常的最大时间 + public byte byRes1; + public NET_ITC_PLATE_RECOG_PARAM struPlateRecog = new NET_ITC_PLATE_RECOG_PARAM(); //牌识参数 + public NET_ITC_LANE_PARAM[] struLane = new NET_ITC_LANE_PARAM[MAX_ITC_LANE_NUM]; //关联的车道参数 + public byte[] byRes = new byte[32]; + } + + //卡口RS485雷达触发参数 + public static class NET_ITC_POST_RS485_RADAR_PARAM extends Structure { + public byte byRelatedLaneNum;//关联的车道个数 + public byte[] byRes1 = new byte[3]; + public NET_ITC_PLATE_RECOG_PARAM struPlateRecog = new NET_ITC_PLATE_RECOG_PARAM(); //牌识参数 + public NET_ITC_LANE_PARAM[] struLane = new NET_ITC_LANE_PARAM[MAX_ITC_LANE_NUM]; //关联的车道参数 + public NET_ITC_RADAR_PARAM struRadar = new NET_ITC_RADAR_PARAM(); //雷达参数 + public byte[] byRes = new byte[32]; + } + + public static class NET_ITC_TRIGGER_PARAM_UNION extends Union { + public int[] uLen = new int[1070]; //参数 + public NET_ITC_POST_IOSPEED_PARAM struIOSpeed = new NET_ITC_POST_IOSPEED_PARAM(); //(卡口)IO测速参数 + // public NET_ITC_POST_SINGLEIO_PARAM struSingleIO = new NET_ITC_POST_SINGLEIO_PARAM(); //(卡口)单IO参数 + public NET_ITC_POST_RS485_PARAM struPostRs485 = new NET_ITC_POST_RS485_PARAM(); //(卡口)RS485车检器参数 + public NET_ITC_POST_RS485_RADAR_PARAM struPostRadar = new NET_ITC_POST_RS485_RADAR_PARAM(); //(卡口)RS485雷达参数 + public NET_ITC_POST_VTCOIL_PARAM struVtCoil = new NET_ITC_POST_VTCOIL_PARAM(); //(卡口)虚拟线圈参数 + public NET_ITC_POST_HVT_PARAM struHvt = new NET_ITC_POST_HVT_PARAM(); //(卡口)混行卡口参数 + // public NET_ITC_EPOLICE_IOTL_PARAM struIOTL = new NET_ITC_EPOLICE_IOTL_PARAM(); //(电警)IO红绿灯参数 +// public NET_ITC_EPOLICE_RS485_PARAM struEpoliceRs485 = new NET_ITC_EPOLICE_RS485_PARAM(); //(电警)RS485车检器触发参数 +// public NET_ITC_EPOLICE_RS485_PARAM struPERs485 = new NET_ITC_EPOLICE_RS485_PARAM(); //(卡式电警)RS485车检器触发参数 +// public NET_ITC_POST_MPR_PARAM struPostMpr = new NET_ITC_POST_MPR_PARAM(); //多帧检测触发(MPR) +// public NET_DVR_VIA_VTCOIL_PARAM struViaVtCoil = new NET_DVR_VIA_VTCOIL_PARAM(); //(VIA)视频检测参数 +// public NET_ITC_POST_IMT_PARAM struPostImt = new NET_ITC_POST_IMT_PARAM();//智慧布防触发 +// public NET_ITC_POST_PRS_PARAM struPostPrs = new NET_ITC_POST_PRS_PARAM();//视频检测触发 +// public NET_IPC_POST_HVT_PARAM struIpcHvt = new NET_IPC_POST_HVT_PARAM();//(IPC) 混行卡口参数 + public NET_ITC_POST_HVT_PARAM_V50 struHvtV50 = new NET_ITC_POST_HVT_PARAM_V50(); /*(卡口)混行卡口参数V50*/ +// public NET_ITC_POST_MOBILE_PARAM struPostMobile = new NET_ITC_POST_MOBILE_PARAM();// 移动交通触发模式 +// public NET_ITC_NOCOMITY_PEDESTRIAN_PARAM struNoComityPed = new NET_ITC_NOCOMITY_PEDESTRIAN_PARAM();//不礼让行人参数 +// public NET_ITC_REDLIGHT_PEDESTRIAN_PARAM struRedLightPed = new NET_ITC_REDLIGHT_PEDESTRIAN_PARAM();//行人闯红灯参数 + } + + //单个触发参数结构 + public static class NET_ITC_SINGLE_TRIGGERCFG extends Structure { + public byte byEnable; //是否启用该触发模式,0-否,1-是 + public byte[] byRes1 = new byte[3]; + public int dwTriggerType; //触发类型,详见ITC_TRIGGERMODE_TYPE + public NET_ITC_TRIGGER_PARAM_UNION uTriggerParam = new NET_ITC_TRIGGER_PARAM_UNION(); //触发参数 + public byte[] byRes = new byte[64]; + } + + //触发参数结构 + public static class NET_ITC_TRIGGERCFG extends Structure { + public int dwSize; //结构长度 + public NET_ITC_SINGLE_TRIGGERCFG struTriggerParam; //单个触发参数 + public byte[] byRes = new byte[32]; + } + + //单个IO接入信号灯参数 + public static class NET_ITC_SINGLE_IO_LIGHT_PARAM extends Structure { + public byte byLightType; //交通灯导向类型,0-左转灯,1-直行灯,2-右转灯 + public byte byRelatedIO; //关联的IO口号 + public byte byRedLightState; //红灯电平状态,0-高电平红灯,1-低电平红灯 + public byte[] byRes = new byte[17]; + } + + //IO接入信号灯参数 + public static class NET_ITC_IO_LIGHT_PARAM extends Structure { + public NET_ITC_SINGLE_IO_LIGHT_PARAM[] struIOLight = new NET_ITC_SINGLE_IO_LIGHT_PARAM[MAX_LIGHT_NUM]; //单个IO接入信号灯参数 + public byte[] byRes = new byte[8]; + } + + //单个485接入信号灯参数 + public static class NET_ITC_SINGLE_RS485_LIGHT_PARAM extends Structure { + public byte byLightType; //交通灯导向类型,0-左转灯,1-直行灯,2-右转灯 + public byte byRelatedLightChan; //关联的红绿灯检测器通道号 + public byte byInputLight; //接入的信号灯类型,0-接红灯,1-接绿灯 + public byte byRelatedYLightChan; //关联的黄灯检测器通道号 + public byte[] byRes = new byte[16]; + } + + //485接入信号灯参数 + public static class NET_ITC_RS485_LIGHT_PARAM extends Structure { + public NET_ITC_SINGLE_RS485_LIGHT_PARAM[] struRS485Light = new NET_ITC_SINGLE_RS485_LIGHT_PARAM[MAX_LIGHT_NUM]; //单个485接入信号灯参数 + public byte[] byRes = new byte[8]; + } + + public static class NET_POS_PARAM extends Structure { + public short wLeft; + public short wTop; + public short wRight; + public short wBottom; + } + + //单组视频检测交通信号灯参数结构 + public static class NET_ITC_SINGLE_VIDEO_DETECT_LIGHT_PARAM extends Structure { + public byte byLightNum; //交通灯个数 + public byte byStraightLight; //是否有直行标志灯,0-否 ,1-是 + public byte byLeftLight; //是否有左转标志灯,0-否,1-是 + public byte byRightLight; //是否有右转标志灯,0-否,1-是 + public byte byRedLight;//是否有红灯,0-否,1-是 + public byte byGreenLight; //是否有绿灯,0-否,1-是 + public byte byYellowLight; //是否有黄灯,0-否,1-是 + public byte byYellowLightTime;//取值范围(0~10s)(ITC3.7Ver) + public NET_POS_PARAM struLightRect; //交通灯区域 + public byte[] byRes = new byte[24]; + } + + //视频检测交通信号灯参数结构(最大可有12个区域检测,488字节) + public static class NET_ITC_VIDEO_DETECT_LIGHT_PARAM extends Structure { + public NET_ITC_SINGLE_VIDEO_DETECT_LIGHT_PARAM[] struTrafficLight = new NET_ITC_SINGLE_VIDEO_DETECT_LIGHT_PARAM[MAX_VIDEO_DETECT_LIGHT_NUM]; //单个视频检测信号灯参数 + public byte[] byRes = new byte[8]; + } + + //交通信号灯接入参数 + public static class NET_ITC_LIGHT_ACCESSPARAM_UNION extends Union { + public int[] uLen = new int[122]; + public NET_ITC_IO_LIGHT_PARAM struIOLight; //IO接入信号灯参数 + public NET_ITC_RS485_LIGHT_PARAM struRS485Light; //485接入信号灯参数 + public NET_ITC_VIDEO_DETECT_LIGHT_PARAM struVideoDelectLight; //视频检测信号灯参数 + } + + //交通信号灯参数结构 + public static class NET_ITC_TRAFFIC_LIGHT_PARAM extends Structure { + public byte bySource; //交通信号灯接入源,0-IO接入,1-RS485接入 + public byte[] byRes1 = new byte[3]; + public NET_ITC_LIGHT_ACCESSPARAM_UNION struLightAccess = new NET_ITC_LIGHT_ACCESSPARAM_UNION();//信号灯接入参数 + public byte[] byRes = new byte[32]; + } + + //违规检测参数结构 + public static class NET_ITC_VIOLATION_DETECT_PARAM extends Structure { + public int dwVioDetectType; //违规检测类型, 按位表示, 详见ITC_VIOLATION_DETECT_TYPE ,0-不启用,1-启用 + public byte byDriveLineSnapTimes; //压车道线抓拍张数,2-3 + public byte byReverseSnapTimes; //逆行抓拍,2-3 + public short wStayTime; //机占非停留时间(该时间后抓拍),单位s + public byte byNonDriveSnapTimes;//机占非抓拍张数2-3 + public byte byChangeLaneTimes;//违法变道抓拍张数 2-3 + public byte bybanTimes;//违法禁令抓拍张数2-3 + public byte byDriveLineSnapSen;// 压线灵敏度(0~100)(3.7Ver) + public short wSnapPosFixPixel; //第2,3张抓拍位置最小偏移(违反信号灯时起效)(单位:像素) 命名需改进 + public byte bySpeedTimes;//违法超速抓拍张数2-3(3.8Ver) + public byte byTurnAroundEnable;//违章掉头使能 0~关闭 1~开启 + public byte byThirdPlateRecogTime;//第三张牌识时间 0~180s + public byte byPostSnapTimes;//卡口抓拍张数,1-2张 + public byte[] byRes1 = new byte[18]; + public short wStopLineDis; //电警第2张违规图片与停止线的最短距离,[0,300]单位(像素) + public byte[] byRes = new byte[14]; + } + + //违规检测线参数结构 + public static class NET_ITC_VIOLATION_DETECT_LINE extends Structure { + public NET_ITC_LINE struLaneLine = new NET_ITC_LINE(); //车道线参数 + public NET_ITC_LINE struStopLine = new NET_ITC_LINE(); //停止线参数 + public NET_ITC_LINE struRedLightLine = new NET_ITC_LINE(); //闯红灯触发线参数 + public NET_ITC_LINE struCancelLine = new NET_ITC_LINE(); //直行触发位置取消线 + public NET_ITC_LINE struWaitLine = new NET_ITC_LINE(); //待行区停止线参数 + public NET_ITC_LINE[] struRes = new NET_ITC_LINE[8]; + } + + //单个车道视频电警触发参数结构 + public static class NET_ITC_LANE_VIDEO_EPOLICE_PARAM extends Structure { + public byte byLaneNO; //关联的车道号 + public byte bySensitivity; //线圈灵敏度,[1,100] + public byte byEnableRadar;//启用雷达测试0-不启用,1-启用 + //关联车道方向类型,参考ITC_RELA_LANE_DIRECTION_TYPE + //该参数为车道方向参数,与关联车道号对应,确保车道唯一性。 + public byte byRelaLaneDirectionType; + public NET_ITC_LANE_LOGIC_PARAM struLane; //车道参数 + public NET_ITC_VIOLATION_DETECT_PARAM struVioDetect; //违规检测参数 + public NET_ITC_VIOLATION_DETECT_LINE struLine; //违规检测线 + public NET_ITC_POLYGON struPlateRecog; //牌识区域参数 + public byte byRecordEnable;//闯红灯周期录像标志,0-不录像,1-录像 + public byte byRecordType;//闯红灯录像类型,0-预录,1-延时录像 + public byte byPreRecordTime;//闯红灯录像片段预录时间(默认0),单位:秒 + public byte byRecordDelayTime;//闯红灯录像片段延时时间(默认0),单位:秒 + public byte byRecordTimeOut;//闯红灯周期录像超时时间(秒) + public byte byCarSpeedLimit; //车速限制值,单位km/h + public byte byCarSignSpeed;//标志限速,单位km/h + public byte bySnapPicPreRecord; //抓拍图片预录时间点;0-默认值(第二张图片),1-第一张图片,2-第二张图片,3-第三张图片 + public NET_ITC_INTERVAL_PARAM struInterval;//抓拍间隔参数(20byte) + public byte[] byRes = new byte[36]; + } + + //视频电警触发参数结构 + public static class NET_ITC_VIDEO_EPOLICE_PARAM extends Structure { + public byte byEnable; //是否启用,0-不启用,1-启用 + public byte byLaneNum; //识别的车道个数 + public byte byLogicJudge;//闯红灯违规判断逻辑,设置值为:0-按方向,1-按车道 + public byte byRes1; + public NET_ITC_PLATE_RECOG_PARAM struPlateRecog; //牌识参数 + public NET_ITC_TRAFFIC_LIGHT_PARAM struTrafficLight; //交通信号灯参数 + public NET_ITC_LANE_VIDEO_EPOLICE_PARAM[] struLaneParam = new NET_ITC_LANE_VIDEO_EPOLICE_PARAM[MAX_ITC_LANE_NUM]; //单车道参数 + public NET_ITC_LINE struLaneBoundaryLine; //车道边界线(最右边车道的边界线) + public NET_ITC_LINE struLeftLine; //左转弯分界线 + public NET_ITC_LINE struRightLine; //右转弯分界线 + public NET_ITC_LINE struTopZebraLine; //上部斑马线 + public NET_ITC_LINE struBotZebraLine; //下部斑马线 + public byte[] byRes = new byte[32]; + } + + public static class NET_DVR_CURTRIGGERMODE extends Structure { + public int dwSize; + public int dwTriggerType; //触发类型,详见ITC_TRIGGERMODE_TYPE + public byte[] byRes = new byte[24]; + } + + public static class NET_ITC_VIDEO_TRIGGER_COND extends Structure { + public int dwSize; + public int dwChannel; + public int dwTriggerMode; //视频触发模式类型,详见ITC_TRIGGERMODE_TYPE + public byte[] byRes = new byte[16]; + } + + public static class NET_ITC_VIDEO_TRIGGER_PARAM_UNION extends Union { + public int[] uLen = new int[1150]; + public NET_ITC_VIDEO_EPOLICE_PARAM struVideoEP = new NET_ITC_VIDEO_EPOLICE_PARAM(); //视频电警参数 + } + + public static class NET_ITC_VIDEO_TRIGGER_PARAM extends Structure { + public int dwSize; + public int dwMode; //触发模式,详见ITC_TRIGGERMODE_TYPE + public NET_ITC_VIDEO_TRIGGER_PARAM_UNION uVideoTrigger = new NET_ITC_VIDEO_TRIGGER_PARAM_UNION(); //触发模式参数 + public byte[] byRes = new byte[32]; + } + + public static class NET_DVR_CMS_PARAM extends Structure { + public int dwSize; + public NET_DVR_IPADDR struAddr = new NET_DVR_IPADDR(); // 平台服务器IP + public short wServerPort; // 平台服务器侦听端口, + public byte bySeverProtocolType; //平台协议类型 1-私有,2-Ehome + public byte byStatus; //设备注册到该平台的状态,1-未注册,2-已注册 + public byte[] sDeviceId = new byte[NAME_LEN/*32*/]; //设备ID,由平台提供 + public byte[] sPassWord = new byte[PASSWD_LEN]; //密码 + /********* + * IPC5.1.7 新增参数 Begin 2014-03-21 + ***********/ + public byte[] sPlatformEhomeVersion = new byte[NAME_LEN];//平台EHOME协议版本 + /********* + * IPC5.1.7 新增参数 end 2014-03-21 + ***********/ + public byte byNetWork; //网络类型:0- 无意义,1-自动,2-有线网络优先,3-有线网络,4-3G网络(无线网络),5-有线网络1,6-有线网络2 + public byte byAddressType; //0 - 无意义, 1 - ipv4/ipv6地址,2 - 域名 + public byte byProtocolVersion; //协议版本 0 - 无意义, 1 – v2.0,2 – v4.0,3-v2.6 + public byte byRes1; + public byte[] sDomainName = new byte[MAX_DOMAIN_NAME/*64*/]; //平台服务器域名,byAddressType为2时有效 + public byte byEnable; //0-关闭,1-开启 + public byte[] byRes = new byte[139]; // 保留字节 + } + + //设置完全获取出厂值 + public static class NET_DVR_COMPLETE_RESTORE_INFO extends Structure { + public int dwSize; //结构体长度 + public int dwChannel; //通道号 + public byte[] byRes = new byte[64]; + } + + public static class NET_DVR_STD_ABILITY extends Structure { + public Pointer lpCondBuffer; //[in]条件参数(码字格式),例如通道号等.可以为NULL + public int dwCondSize; //[in] dwCondSize指向的内存大小 + public Pointer lpOutBuffer; //[out]输出参数(XML格式),不为NULL + public int dwOutSize; //[in] lpOutBuffer指向的内存大小 + public Pointer lpStatusBuffer; //[out]返回的状态参数(XML格式),获取成功时不会赋值,如果不需要,可以置NULL + public int dwStatusSize; //[in] lpStatusBuffer指向的内存大小 + public int dwRetSize; //[out]获取到的数据长度(lpOutBuffer或者lpStatusBuffer指向的实际数据长度) + public byte[] byRes = new byte[32]; //保留字节 + } + + public static class NET_DVR_STD_CONFIG extends Structure { + public Pointer lpCondBuffer; //[in]条件参数(结构体格式),例如通道号等.可以为NULL + public int dwCondSize; //[in] lpCondBuffer指向的内存大小 + public Pointer lpInBuffer; //[in]输入参数(结构体格式),设置时不为NULL,获取时为NULL + public int dwInSize; //[in] lpInBuffer指向的内存大小 + public Pointer lpOutBuffer; //[out]输出参数(结构体格式),获取时不为NULL,设置时为NULL + public int dwOutSize; //[in] lpOutBuffer指向的内存大小 + public Pointer lpStatusBuffer; //[out]返回的状态参数(XML格式),获取成功时不会赋值,如果不需要,可以置NULL + public int dwStatusSize; //[in] lpStatusBuffer指向的内存大小 + public Pointer lpXmlBuffer; //[in/out]byDataType = 1时有效,xml格式数据 + public int dwXmlSize; //[in/out]lpXmlBuffer指向的内存大小,获取时同时作为输入和输出参数,获取成功后会修改会实际长度,设置时表示实际长度,而不是整个内存大小 + public byte byDataType; //[in]输入/输出参数类型,0-使用结构体类型lpInBuffer/lpOutBuffer有效,1-使用XML类型lpXmlBuffer有效 + public byte[] byRes = new byte[23]; + } + + public static final int NET_SDK_MAX_FILE_PATH = 256;//路径长度 + + public static class NET_DVR_LOCAL_SDK_PATH extends Structure { + public byte[] sPath = new byte[NET_SDK_MAX_FILE_PATH];//组件库地址 + public byte[] byRes = new byte[128]; + } + + public static class BYTE_ARRAY extends Structure { + public byte[] byValue; + + public BYTE_ARRAY(int iLen) { + byValue = new byte[iLen]; + } + } + + public static class INT_ARRAY extends Structure { + public int[] intValue; + + public INT_ARRAY(int iLen) { + intValue = new int[iLen]; + } + } + + public static class INTRef_ARRAY extends Structure { + public IntByReference[] intValue; + + public INTRef_ARRAY(int iLen) { + intValue = new IntByReference[iLen]; + } + } + + + public static class NET_DVR_JSON_DATA_CFG extends Structure { + public int dwSize; //结构体大小 + public Pointer lpJsonData; //JSON报文 + public int dwJsonDataSize; //JSON报文大小 + public Pointer lpPicData; //图片内容 + public int dwPicDataSize; //图片内容大小 + public int lpInfraredFacePicBuffer; //红外人脸图片数据缓存 + public Pointer dwInfraredFacePicSize; //红外人脸图片数据大小,等于0时,代表无人脸图片数据(当JSON报文为当ResponseStatus(JSON)报文时,该字段无意义;当Inbound Data(JSON)报文中没有infraredFaceURL时,该字段需要带上二进制图片内容) + public byte[] byRes = new byte[248]; + } + + public static class CallBack_USER extends Structure { + public byte[] byDeviceID = new byte[16]; + public byte[] byCardNo = new byte[32]; + public byte[] byDevIP = new byte[16]; + } + + + public static class NET_DVR_CAMERAPARAMCFG_EX extends Structure { + public int dwSize; + public NET_DVR_VIDEOEFFECT struVideoEffect = new NET_DVR_VIDEOEFFECT();/*亮度、对比度、饱和度、锐度、色调配置*/ + public NET_DVR_GAIN struGain = new NET_DVR_GAIN();/*自动增益*/ + public NET_DVR_WHITEBALANCE struWhiteBalance = new NET_DVR_WHITEBALANCE();/*白平衡*/ + public NET_DVR_EXPOSURE struExposure = new NET_DVR_EXPOSURE(); /*曝光控制*/ + public NET_DVR_GAMMACORRECT struGammaCorrect = new NET_DVR_GAMMACORRECT();/*Gamma校正*/ + public NET_DVR_WDR struWdr = new NET_DVR_WDR();/*宽动态*/ + public NET_DVR_DAYNIGHT struDayNight = new NET_DVR_DAYNIGHT();/*日夜转换*/ + public NET_DVR_BACKLIGHT struBackLight = new NET_DVR_BACKLIGHT();/*背光补偿*/ + public NET_DVR_NOISEREMOVE struNoiseRemove = new NET_DVR_NOISEREMOVE();/*数字降噪*/ + public byte byPowerLineFrequencyMode; /*0-50HZ; 1-60HZ*/ + /* + 0-自动光圈, + 1-手动光圈, + 2-P-Iris1, + 3-Union 3-9mm F1.6-2.7 (T5280-PQ1) [IPC5.1.7] + 4-Union 2.8-12mm F1.6-2.7 (T5289-PQ1) [IPC5.1.7] + 5-HIK 3.8-16mm F1.5(HV3816P-8MPIR) + 6-HIK 11-40mm F1.7 (HV1140P-8MPIR) + 7-HIK 2.7-12mm F1.2(TV2712P-MPIR) + */ + public byte byIrisMode; + public byte byMirror; /* 镜像:0 off,1- leftright,2- updown,3-center 4-Auto*/ + public byte byDigitalZoom; /*数字缩放:0 dsibale 1 enable*/ + public byte byDeadPixelDetect; /*坏点检测,0 dsibale 1 enable*/ + public byte byBlackPwl;/*黑电平补偿 , 0-255*/ + public byte byEptzGate;// EPTZ开关变量:0-不启用电子云台,1-启用电子云台 + public byte byLocalOutputGate;//本地输出开关变量0-本地输出关闭1-本地BNC输出打开 2-HDMI输出关闭 + //20-HDMI_720P50输出开 + //21-HDMI_720P60输出开 + //22-HDMI_1080I60输出开 + //23-HDMI_1080I50输出开 + //24-HDMI_1080P24输出开 + //25-HDMI_1080P25输出开 + //26-HDMI_1080P30输出开 + //27-HDMI_1080P50输出开 + //28-HDMI_1080P60输出开 + public byte byCoderOutputMode;//编码器fpga输出模式0直通3像素搬家 + public byte byLineCoding; //是否开启行编码:0-否,1-是 + public byte byDimmerMode; //调光模式:0-半自动,1-自动 + public byte byPaletteMode; //调色板:0-白热,1-黑热,2-调色板2,…,8-调色板8, 9-融合1,10-彩虹,11-融合2,12-铁红1,13-铁红2,14-深褐色,15-色彩1,16-色彩2,17-冰火,18-雨,19-红热,20-绿热,21-深蓝,22-色彩3 + public byte byEnhancedMode; //增强方式(探测物体周边):0-不增强,1-1,2-2,3-3,4-4 + public byte byDynamicContrastEN; //动态对比度增强 0-1 + public byte byDynamicContrast; //动态对比度 0-100 + public byte byJPEGQuality; //JPEG图像质量 0-100 + public NET_DVR_CMOSMODECFG struCmosModeCfg = new NET_DVR_CMOSMODECFG();//CMOS模式下前端参数配置,镜头模式从能力集获取 + public byte byFilterSwitch; //滤波开关:0-不启用,1-启用 + public byte byFocusSpeed; //镜头调焦速度:0-10 + public byte byAutoCompensationInterval; //定时自动快门补偿:1-120,单位:分钟 + public byte bySceneMode; //场景模式:0-室外,1-室内,2-默认,3-弱光 + public NET_DVR_DEFOGCFG struDefogCfg = new NET_DVR_DEFOGCFG();//透雾参数 + public NET_DVR_ELECTRONICSTABILIZATION struElectronicStabilization = new NET_DVR_ELECTRONICSTABILIZATION();//电子防抖 + public NET_DVR_CORRIDOR_MODE_CCD struCorridorMode = new NET_DVR_CORRIDOR_MODE_CCD();//走廊模式 + public byte byExposureSegmentEnable; //0~不启用,1~启用 曝光时间和增益呈阶梯状调整,比如曝光往上调整时,先提高曝光时间到中间值,然后提高增益到中间值,再提高曝光到最大值,最后提高增益到最大值 + public byte byBrightCompensate;//亮度增强 [0~100] + /* + 0-关闭、1-640*480@25fps、2-640*480@30ps、3-704*576@25fps、4-704*480@30fps、5-1280*720@25fps、6-1280*720@30fps、 + 7-1280*720@50fps、8-1280*720@60fps、9-1280*960@15fps、10-1280*960@25fps、11-1280*960@30fps、 + 12-1280*1024@25fps、13--1280*1024@30fps、14-1600*900@15fps、15-1600*1200@15fps、16-1920*1080@15fps、 + 17-1920*1080@25fps、18-1920*1080@30fps、19-1920*1080@50fps、20-1920*1080@60fps、21-2048*1536@15fps、22-2048*1536@20fps、 + 23-2048*1536@24fps、24-2048*1536@25fps、25-2048*1536@30fps、26-2560*2048@25fps、27-2560*2048@30fps、 + 28-2560*1920@7.5fps、29-3072*2048@25fps、30-3072*2048@30fps、31-2048*1536@12.5、32-2560*1920@6.25、 + 33-1600*1200@25、34-1600*1200@30、35-1600*1200@12.5、36-1600*900@12.5、37-1280*960@12.5fps、38-800*600@25fps、39-800*600@30fps40、 + 4000*3000@12.5fps、41-4000*3000@15fps、42-4096*2160@20fps、43-3840*2160@20fps 、44-960*576@25fps、45-960*480@30fps、46-752*582@25fps、 + 47-768*494@30fps、48-2560*1440@25fps、49-2560*1440@30fps 、50-720P@100fps、51-720P@120fps、52-2048*1536@50fps、53-2048*1536@60fps、 + 54-3840*2160@25fps、55-3840*2160@30fps、56-4096*2160@25fps、57-4096*2160@30fps 、58-1280*1024@50fps、59-1280*1024@60fps、 + 60-3072*2048@50fps、61-3072*2048@60fps、62-3072*1728@25fps、63-3072*1728@30fps、64-3072*1728@50fps、65-3072*1728@60fps、66-336*256@50fps、67-336*256@60fps、 + 68-384*288@50fps、69-384*288@60fps 、70- 640 * 512@50fps 、71- 640 * 512@60fps、72-2592*1944@25fps、73-2592*1944@30fps、74-2688*1536@25fps、75-2688*1536@30fps + 76-2592*1944@20fps、77-2592*1944@15fps、78-2688*1520@20fps、79-2688*1520@15fps、80-2688*1520@25fps、81-2688*1520@30fps、82- 2720*2048@25fps、 83- 2720*2048@30fps、 + 84-336*256@25fps、85- 384*288@25fps、86-640*512@25fps、87-1280*960@50fps、88-1280*960@60fps、89-1280*960@100fps、90-1280*960@120fps、91-4000*3000@20fps、 + 92-1920*1200@25fps、93-1920*1200@30fps、94-2560*1920@25fps、95-2560*1920@20fps、96-2560*1920@30fps、97-1280*1920@25fps、98-1280*1920@30fps + 99-4000*3000@24fps、100-4000*3000@25fps、101-4000*3000@10fps、102- 384*288@30fps、103-2560*1920@15fps、104-2400*3840@25fps、105-1200*1920@25fps + 106-4096*1800@30fps、107-3840*1680@30fps、108-2560*1120@30fps、109-704*320@30fps、110-1280*560@30fps、111-4096*1800@25fps、112-3840*1680@25fps + 113-2560*1120@25fps、114-704*320@25fps、115-1280*560@25fps、116-2400*3840@24fps、117-3840*2400@24fps、118-3840*2400@25fps、119-2560*1920@12.5fps + 120-2560*2048@12fps、121-2560*2048@15fps、122-2560*1536@25fps、123-2560*1536@30fps、124-2256*2048@25fps、125-2256*2048@30fps、126-2592*2592@12.5fps、127-2592*2592@15fps、 + 128 - 640*512@30fps、129-2048*1520@30fps、130-2048*1520@25fps、131-3840*2160@24fps、132-2592*1520@25fps、133-2592*1520@30fps、134-2592*1536@25fps、135-2592*1536@30fps + 136-640*960@25fps、137-640*960@24fps、142-2992*2192@25fps、143-2992*2192@30fps、144-3008*2160@25fps、145-3008*2160@30fps、146-3072*1728@20fps、147-2560*1440@20fps、 + 148-2160*3840@25fps、149-2160*3840@30fps、150-7008*1080@25fps、151-7008*1080@30fps、152-3072*2048@20fps、153-1536*864@25fps、154-2560*1920@24fps、155-2400*3840@30fps、 + 156-3840*2400@30fps、157-3840*2160@15fps + 158-384*288@8.3fps、159-640*512@8.3fps、160-160*120@8.3fps、161-1024*768@8.3fps、162-640*480@8.3fps、163-3840*2160@12.5fps、164-2304*1296@30fps、165-2304*1296@25fps、 + 166-2560*1440@24fps、167-2688*1512@25fps、168-2688*1512@30fps、169-2688*1512@50fps、170-2688*1512@60fps、171-1536*864@30fps、172-2560*1440@50fps、173-2560*1440@60fps、 + 174-2048*2048@25fps、175-2048*2048@30fps、176-4000*3060@20fps、177-3060*3060@25fps、178-3060*3060@30fps、179-3000*3000@25fps、180-3000*3000@30fps、181-8160*3616@30fps、 + 182-8160*3616@25fps、183-3000*3000@20fps、184-3000*3000@15fps、185-3000*3000@12.5fps、186-5472*3648@25fps、187-5472*3648@30fps、188-7680*4320@25fps、189-7680*4320@30fps、 + 190-8160*2400@25fps、191-8160*2400@30fps、192-5520*2400@25fps、193-5520*2400@30fps、194-2560*1440@15fps、195-1944*1212@24fps、196-1944*1212@25fps、197-3456*1920@30fps、 + 198-4800*2688@25fps、199-4800*2688@30fps、200-6480*1080@25fps、201-6480*1080@30fps、202-8640*1440@25fps、203-8640*1440@30fps、204-3456*1920@25fps、205-2688*1520@50fps、 + 206-2688*1520@60fps、207-4976*1452@25fps、208-4976*1452@30fps、 209-3200*1800@25fps、210-3200*1800@30fps、211-5472*3648@24fps、212-1920*1080@12.5fps、213-2944*1656@20fps、 + 214-1920*1080@24fps、215-4800*1600@25fps、216-4800*1600@30fps、217-2560*1440@12.5fps、218-6560*3690@1fps、219-5120*1400@20fps*/ + public byte byCaptureModeN; //视频输入模式(N制) + public byte byCaptureModeP; //视频输入模式(P制) + public NET_DVR_SMARTIR_PARAM struSmartIRParam = new NET_DVR_SMARTIR_PARAM(); //红外放过爆配置信息 + public NET_DVR_PIRIS_PARAM struPIrisParam = new NET_DVR_PIRIS_PARAM();//PIris配置信息对应byIrisMode字段从2-PIris1开始生效 + //2014-02-25 新增参数 + public NET_DVR_LASER_PARAM_CFG struLaserParam = new NET_DVR_LASER_PARAM_CFG(); //激光参数 + public NET_DVR_FFC_PARAM struFFCParam = new NET_DVR_FFC_PARAM(); + public NET_DVR_DDE_PARAM struDDEParam = new NET_DVR_DDE_PARAM(); + public NET_DVR_AGC_PARAM struAGCParam = new NET_DVR_AGC_PARAM(); + public byte byLensDistortionCorrection;//镜头畸变校正 0-关闭,1-开启 + public byte byDistortionCorrectionLevel;//畸变校正等级:0-保留;1-等级一;2-等级二;3-等级三;255-自定义 + public byte byCalibrationAccurateLevel;// 畸变校正强度[0-100] + public byte byZoomedInDistantViewLevel;//远端放大等级[0-100] + public NET_DVR_SNAP_CAMERAPARAMCFG struSnapCCD = new NET_DVR_SNAP_CAMERAPARAMCFG(); //抓拍机CCD参数,只用于抓拍机 + public NET_DVR_OPTICAL_DEHAZE struOpticalDehaze = new NET_DVR_OPTICAL_DEHAZE();//光学透雾参数 + public NET_DVR_THERMOMETRY_AGC struThermAGC = new NET_DVR_THERMOMETRY_AGC();//测温AGC配置 + public byte byFusionMode;//双光谱视频融合模式,0~热成像模式,1~融合模式,2~画中画模式,3~可见光模式, 4~融合黑白模式, 5~融合彩色模式-草地,6~融合彩色模式-荒地,7~融合彩色模式-雪地,8~融合彩色模式-海洋,9~融合彩色模式-城市 + public byte byHorizontalFOV;//水平视场角[0-100] + public byte byVerticalFOV;//垂直视场角[0-100] + public byte byBrightnessSuddenChangeSuppression;//亮度突变抑制0-关闭,1-开启 + public byte byGPSEnabled;//GPS开关使能,0-关,1-开 + public byte[] byRes2 = new byte[155]; + } + + + public static class NET_DVR_VIDEOEFFECT extends Structure { + public byte byBrightnessLevel; /*0-100*/ + public byte byContrastLevel; /*0-100*/ + public byte bySharpnessLevel; /*0-100*/ + public byte bySaturationLevel; /*0-100*/ + public byte byHueLevel; /*0-100,(保留)*/ + public byte byEnableFunc; //使能,按位表示,bit0-SMART IR(防过曝),bit1-低照度,bit2-强光抑制使能,0-否,1-是 + public byte byLightInhibitLevel; //强光抑制等级,[1-3]表示等级 + public byte byGrayLevel; //灰度值域,0-[0-255],1-[16-235] + } + + + public static class NET_DVR_GAIN extends Structure { + public byte byGainLevel; /*增益:0-100*/ + public byte byGainUserSet; /*用户自定义增益;0-100,对于抓拍机,是CCD模式下的抓拍增益*/ + public byte[] byRes = new byte[2]; + public int dwMaxGainValue;/*最大增益值,单位dB*/ + } + + public static class NET_DVR_WHITEBALANCE extends Structure { + public byte byWhiteBalanceMode; /*0-手动白平衡(MWB),1-自动白平衡1(AWB1),2-自动白平衡2 (AWB2),3-自动控制改名为锁定白平衡(Locked WB), + 4-室外(Indoor),5-室内(Outdoor)6-日光灯(Fluorescent Lamp),7-钠灯(Sodium Lamp), + 8-自动(Auto-Track)9-一次白平衡(One Push),10-室外自动(Auto-Outdoor), + 11-钠灯自动 (Auto-Sodiumlight),12-水银灯(Mercury Lamp),13-自动白平衡(Auto), +14-白炽灯 (IncandescentLamp),15-暖光灯(Warm Light Lamp),16-自然光(Natural Light) */ + public byte byWhiteBalanceModeRGain; /*手动白平衡时有效,手动白平衡 R增益*/ + public byte byWhiteBalanceModeBGain; /*手动白平衡时有效,手动白平衡 B增益*/ + public byte[] byRes = new byte[5]; + } + + public static class NET_DVR_EXPOSURE extends Structure { + public byte byExposureMode; /*0 手动曝光 1自动曝光*/ + public byte byAutoApertureLevel; /* 自动光圈灵敏度, 0-10 */ + public byte[] byRes = new byte[2]; + public int dwVideoExposureSet; /* 自定义视频曝光时间(单位us)*//*注:自动曝光时该值为曝光最慢值 新增20-1s(1000000us)*/ + public int dwExposureUserSet; /* 自定义曝光时间,在抓拍机上应用时,CCD模式时是抓拍快门速度*/ + public int dwRes; + } + + public static class NET_DVR_GAMMACORRECT extends Structure { + public byte byGammaCorrectionEnabled; /*0 dsibale 1 enable*/ + public byte byGammaCorrectionLevel; /*0-100*/ + public byte[] byRes = new byte[6]; + } + + + public static class NET_DVR_WDR extends Structure { + public byte byWDREnabled; /*宽动态:0 dsibale 1 enable 2 auto*/ + public byte byWDRLevel1; /*0-F*/ + public byte byWDRLevel2; /*0-F*/ + public byte byWDRContrastLevel; /*0-100*/ + public byte[] byRes = new byte[16]; + } + + public static class NET_DVR_DAYNIGHT extends Structure { + public byte byDayNightFilterType; /*日夜切换:0-白天,1-夜晚,2-自动,3-定时,4-报警输入触发, 5-自动模式2(无光敏),6-黑光,7-黑光自动,8-黑光定时*/ + public byte bySwitchScheduleEnabled; /*0 dsibale 1 enable,(保留)*/ + //定时模式参数 + public byte byBeginTime; /*开始时间(小时),0-23*/ + public byte byEndTime; /*结束时间(小时),0-23*/ + //模式2 + public byte byDayToNightFilterLevel; //0-7 + public byte byNightToDayFilterLevel; //0-7 + public byte byDayNightFilterTime;//(60秒) + //定时模式参数 + public byte byBeginTimeMin; //开始时间(分),0-59 + public byte byBeginTimeSec; //开始时间(秒),0-59 + public byte byEndTimeMin; //结束时间(分),0-59 + public byte byEndTimeSec; //结束时间(秒),0-59 + //报警输入触发模式参数 + public byte byAlarmTrigState; //报警输入触发状态,0-白天,1-夜晚 + } + + public static class NET_DVR_BACKLIGHT extends Structure { + public byte byBacklightMode; /*背光补偿:0 off 1 UP、2 DOWN、3 LEFT、4 RIGHT、5MIDDLE、6自定义,10-开,11-自动,12-多区域背光补偿*/ + public byte byBacklightLevel; /*0x0-0xF*/ + public byte[] byRes1 = new byte[2]; + public int dwPositionX1; //(X坐标1) + public int dwPositionY1; //(Y坐标1) + public int dwPositionX2; //(X坐标2) + public int dwPositionY2; //(Y坐标2) + public byte[] byRes2 = new byte[4]; + } + + + public static class NET_DVR_NOISEREMOVE extends Structure { + public byte byDigitalNoiseRemoveEnable; /*0-不启用,1-普通模式数字降噪,2-专家模式数字降噪*/ + public byte byDigitalNoiseRemoveLevel; /*普通模式数字降噪级别:0x0-0xF*/ + public byte bySpectralLevel; /*专家模式下空域强度:0-100*/ + public byte byTemporalLevel; /*专家模式下时域强度:0-100*/ + public byte byDigitalNoiseRemove2DEnable; /* 抓拍帧2D降噪,0-不启用,1-启用 */ + public byte byDigitalNoiseRemove2DLevel; /* 抓拍帧2D降噪级别,0-100 */ + public byte[] byRes = new byte[2]; + } + + + public static class NET_DVR_CMOSMODECFG extends Structure { + public byte byCaptureMod; //抓拍模式:0-抓拍模式1;1-抓拍模式2 + public byte byBrightnessGate;//亮度阈值 + public byte byCaptureGain1; //抓拍增益1,0-100 + public byte byCaptureGain2; //抓拍增益2,0-100 + public int dwCaptureShutterSpeed1;//抓拍快门速度1 + public int dwCaptureShutterSpeed2;//抓拍快门速度2 + public byte[] byRes = new byte[4]; + } + + public static class NET_DVR_DEFOGCFG extends Structure { + public byte byMode; //模式,0-不启用,1-自动模式,2-常开模式 + public byte byLevel; //等级,0-100 + public byte[] byRes = new byte[6]; + } + + public static class NET_DVR_CMOSMODCFG extends Structure { + public byte byCaptureMod; //抓拍模式:0-抓拍模式1;1-抓拍模式2 + public byte byBrightnessGate;//亮度阈值 + public byte byCaptureGain1; //抓拍增益1,0-100 + public byte byCaptureGain2; //抓拍增益2,0-100 + public int dwCaptureShutterSpeed1;//抓拍快门速度1 + public int dwCaptureShutterSpeed2;//抓拍快门速度2 + public byte[] byRes = new byte[4]; + } + + public static class NET_DVR_ELECTRONICSTABILIZATION extends Structure { + public byte byEnable;//使能 0- 不启用,1- 启用 + public byte byLevel; //等级,0-100 + public byte[] byRes = new byte[6]; + } + + public static class NET_DVR_CORRIDOR_MODE_CCD extends Structure { + public byte byEnableCorridorMode; //是否启用走廊模式 0~不启用, 1~启用 + public byte[] byRes = new byte[11]; + } + + public static class NET_DVR_SMARTIR_PARAM extends Structure { + public byte byMode;//0~手动,1~自动 + public byte byIRDistance;//红外距离等级(等级,距离正比例)level:1~100 默认:50(手动模式下增加) + public byte byShortIRDistance;// 近光灯距离等级(1~100) + public byte byLongIRDistance;// 远光灯距离等级(1~100) + } + + public static class NET_DVR_PIRIS_PARAM extends Structure { + public byte byMode;//0-自动,1-手动 + public byte byPIrisAperture;//红外光圈大小等级(等级,光圈大小正比例)level:1~100 默认:50(手动模式下增加) + public byte[] byRes = new byte[6]; + } + + public static class NET_DVR_LASER_PARAM_CFG extends Structure { + public byte byControlMode; //控制模式 0-无效,1-自动,2-手动 默认自动 + public byte bySensitivity; //激光灯灵敏度 0-100 默认50 + public byte byTriggerMode; //激光灯触发模式 0-无效,1-机芯触发,2-光敏触发 默认机芯触发 + public byte byBrightness; //控制模式为手动模式下有效;激光灯亮度 0-255 默认100 + public byte byAngle; //激光灯角度 0-无效,范围1-36 默认12,激光灯照射范围为一个圆圈,调节激光角度是调节这个圆的半径的大小 + public byte byLimitBrightness; //控制模式为自动模式下有效;激光灯亮度限制 0~100 (新增)2014-01-26 + public byte byEnabled; //手动控制激光灯使能 0-关闭,1-启动 + public byte byIllumination; //激光灯强度配置0~100 + public byte byLightAngle; //补光角度 0~100 + public byte[] byRes = new byte[7]; //保留 + } + + public static class NET_DVR_FFC_PARAM extends Structure { + //1-Schedule Mode,2-Temperature Mode, 3-Off + public byte byMode; + //(时间:按能力显示,单位分钟,选项有10,20,30,40,50,60,120,180,240) + public byte byRes1; + public short wCompensateTime; //定时模式下生效 + public byte[] byRes2 = new byte[4]; + } + + public static class NET_DVR_DDE_PARAM extends Structure { + public byte byMode;//1-Off,2-Normal Mode,3-Expert Mode + public byte byNormalLevel;//普通模式等级范围[1,100],普通模式下生效 + public byte byExpertLevel;//专家模式等级范围[1,100],专家模式下生效 + public byte[] byRes = new byte[5]; + } + + public static class NET_DVR_AGC_PARAM extends Structure { + public byte bySceneType;//1-Normal Sence,2-Highlight Sence,3-Manual Sence + public byte byLightLevel;//亮度等级[1,100];手动模式下生效 + public byte byGainLevel; //增益等级[1,100];手动模式下生效 + public byte[] byRes = new byte[5]; + } + + public static class NET_DVR_SNAP_CAMERAPARAMCFG extends Structure { + public byte byWDRMode; // 宽动态模式;0~关闭,1~数字宽动态 2~宽动态 + public byte byWDRType; // 宽动态切换模式; 0~强制启用,1~按时间启用,2~按亮度启用 + public byte byWDRLevel; // 宽动态等级,0~6索引对应1-7,默认索引2(即3级); + public byte byRes1; + public NET_DVR_TIME_EX struStartTime = new NET_DVR_TIME_EX(); //开始宽动态时间 + public NET_DVR_TIME_EX struEndTime = new NET_DVR_TIME_EX(); //结束宽动态时间 + public byte byDayNightBrightness; //日夜转换亮度阈值,0-100,默认50; + //记忆色增强 + public byte byMCEEnabled;//记忆色增强使能,true:开启,false:关闭 + public byte byMCELevel;//记忆色增强强度,0~100,默认值50 + //自动对比度 + public byte byAutoContrastEnabled;//自动对比度使能,true:开启,false:关闭 + public byte byAutoContrastLevel;//自动对比等级(0-100),默认50 + //细节增强 + public byte byLSEDetailEnabled;//细节增强使能,true:开启,false:关闭 + public byte byLSEDetailLevel;//细节增强等级(0-100),默认50 + // License Plate Definition Enhancement车牌增强 + public byte byLPDEEnabled;//车牌增强使能,true:开启,false:关闭 + public byte byLPDELevel;//车牌增强等级(0-100),默认50 + //对比度增强 + public byte byLseEnabled; //对比度增强使能,true:开启,false:关闭 + public byte byLseLevel; //对比度增强等级(0-100),默认0 + public byte byLSEHaloLevel;//光晕抑制等级。范围 0-100,默认0 + public byte byLseType; //对比度增强切换模式; 0~强制启用,1~按时间启用,2~按亮度启用(该字段可同时控制byLseLevel、byLSEHaloLevel两个参数) + public byte[] byRes2 = new byte[3]; + public NET_DVR_TIME_EX struLSEStartTime = new NET_DVR_TIME_EX(); //开始对比度增强时间(当byLseType为1时生效) + public NET_DVR_TIME_EX struLSEEndTime = new NET_DVR_TIME_EX(); //结束对比度增强时间(当byLseType为1时生效) + public byte byLightLevel;//为亮度等级参数(0-100),默认0,(当byLseType为2时生效) + //车牌对比度 + public byte byPlateContrastLevel;//车牌对比度等级,0~100,默认0 + //车牌饱和度 + public byte byPlateSaturationLevel;//车牌饱和度等级,0~100,默认0 + public byte[] byRes = new byte[9]; + } + + public static class NET_DVR_OPTICAL_DEHAZE extends Structure { + public byte byEnable; //0~不启用光学透雾,1~启用光学透雾 + public byte[] byRes = new byte[7]; + } + + public static class NET_DVR_THERMOMETRY_AGC extends Structure { + public byte byMode;//AGC模式,0~无效,1~自动,2~手动 + public byte byRes1[] = new byte[3]; + public int iHighTemperature;//最高温度,范围为:-273~9999摄氏度(1~手动模式下生效) + public int iLowTemperature;//最低温度,范围为:-273~9999摄氏度(1~手动模式下生效) + public byte[] byRes = new byte[8]; + } + + public static class NET_DVR_CHECK_DEV_STATE extends Structure { + public int dwTimeout; //定时检测设备工作状态,单位ms,为0时,表示使用默认值(30000)。最小值为1000 + public DEV_WORK_STATE_CB fnStateCB; + Pointer pUserData; + public byte[] byRes = new byte[60]; + } + + public static class NET_DVR_FLOW_INFO extends Structure { + public int dwSize; //结构大小 + public int dwSendFlowSize; //发送流量大小,单位kbps + public int dwRecvFlowSize; //接收流量大小,单位kbps + public byte[] byRes = new byte[20]; //保留 + } + + public static class NET_DVR_AES_KEY_INFO extends Structure { + public byte[] sAESKey = new byte[16]; /*码流加密密钥*/ + public byte[] byRes = new byte[64]; /*保留字节*/ + } + + public static class NET_DVR_ALARM_RS485CFG extends Structure { + public int dwSize; // 结构体大小 + public byte[] sDeviceName = new byte[NAME_LEN]; // 前端设备名称 + public short wDeviceType; // 前端设备类型,通过NET_DVR_GetDeviceTypeList获取 + public short wDeviceProtocol; // 前端设备协议 通过获取协议列表获取 + public int dwBaudRate; //波特率(bps),0-50,1-75,2-110,3-150,4-300,5-600,6-1200,7-2400,8-4800,9-9600,10-19200,11-38400,12-57600,13-76800,14-115.2k + public byte byDataBit; // 数据有几位:0-5位,1-6位,2-7位,3-8位 + public byte byStopBit; // 停止位:0-1位,1-2位 + public byte byParity; //是否校验:0-无校验,1-奇校验,2-偶校验 + public byte byFlowcontrol; // 是否流控:0-无,1-软流控,2-硬流控 + public byte byDuplex; // 0 - 半双工1- 全双工 只有通道1可以是全双工其他都只能是半双工 + public byte byWorkMode; // 工作模式 0-控制台 1-透明通道,2-梯控,3-读卡器,4-门禁安全模块,0xfe-自定义,0xff-禁用 + public byte byChannel; //485通道号 + public byte bySerialType; //串口类型: 0--485, 1--232 + public byte byMode; //模式 0-连接读卡器 1-连接客户端 2-连接扩展模块 3-连接门禁主机 4-连接梯控主机 0xff-禁用 + public byte byOutputDataType; //0-无效,1-输出卡号,2-输出工号 + public byte byAddress; //串口地址 + public byte[] byRes = new byte[33]; // 保留字节 + } + + public static class NET_DVR_ALARMHOST_RS485_SLOT_CFG extends Structure { + public int dwSize; // 结构体大小 + public byte[] sDeviceName = new byte[NAME_LEN]; // 前端设备名称 + public short wDeviceType; // 前端设备类型ALARM_FRONT_DEVICE _TYPE + public byte wDeviceProtocol; // 前端设备协议 通过获取协议列表获取 + public short wAddress; //设备地址 + public byte byChannel; //485通道号 + public byte bySlotChan; //槽位号 + public byte[] byRes = new byte[60]; // 保留字节 + } + + + public static class NET_DVR_VIDEOWALLDISPLAYPOSITION extends Structure { + public int dwSize; + public byte byEnable; + public byte byCoordinateType;//坐标类型。0-基准坐标,1-实际坐标 + public byte[] byRes1 = new byte[2]; + //墙号,1字节墙号(高字节,对于合码器设备,为合码通道号)+3字节保留 + public int dwVideoWallNo; + public int dwDisplayNo;//显示输出号 + //坐标须为基准坐标的整数倍(1920*1920),宽度和高度值不用设置,即为基准值 + public NET_DVR_RECTCFG_EX struRectCfg; + public byte[] byRes2 = new byte[64]; + } + + public static final int MAX_DISPLAY_NUM = 512; //最大显示输出个数 + + public static class NET_DVR_DISPLAYCFG extends Structure { + public int dwSize; + public NET_DVR_DISPLAYPARAM[] struDisplayParam = new NET_DVR_DISPLAYPARAM[MAX_DISPLAY_NUM]; + public byte[] byRes2 = new byte[128]; + } + + public static class NET_DVR_DISPLAYPARAM extends Structure { + public int dwDisplayNo; + public byte byDispChanType; + public byte[] byRes = new byte[11]; + } + + public static class NET_DVR_WALLOUTPUTPARAM extends Structure { + public int dwSize; + public int dwResolution; //分辨率 + public NET_DVR_VIDEOEFFECT struRes; + public byte byVideoFormat; //视频制式,见VIDEO_STANDARD + public byte byDisplayMode;/*输出连接模式,1-BNC,2-VGA,3-HDMI,4-DVI,5-SDI, 6-FIBER, 7-RGB, 8-YPrPb, 9-VGA/HDMI/DVI自适应,0xff-无效*/ + public byte byBackgroundColor; //背景色,0-无效,不支持背景色,1-红,2-绿,3-蓝,4-黄,5-紫,6-青,7-黑,8-白,0xff-自定义 + public byte byUseEDIDResolution; //是否使用EDID分辨率,0-不使用,1-使用 + public short wLEDWidth; //LED屏输出分辨率宽 + public short wLEDHeight; //LED屏输出分辨率高 + public NET_DVR_RGB_COLOR struBackColor;//背景色,byBackgroundColor为0xff时有效 + public byte byLinkStatus;//输出口连接状态,0-无效,1-接入显示器,2-未接入显示器 + public byte[] byRes2 = new byte[51]; + } + + public static class WALLOUTPUTPARAM_ARRAY extends Structure { + public NET_DVR_WALLOUTPUTPARAM[] strWalloutputParm; + + public WALLOUTPUTPARAM_ARRAY(int iLen) { + strWalloutputParm = new NET_DVR_WALLOUTPUTPARAM[iLen]; + } + + } + + public static class NET_DVR_VIDEO_CALL_COND extends Structure{ + public int dwSize; + public byte[] byRes=new byte[128]; + } + + + /*** + * API函数声明,详细说明见API手册 + ***/ + public static interface FRealDataCallBack_V30 extends Callback { + public void invoke(int lRealHandle, int dwDataType, + Pointer pBuffer, int dwBufSize, Pointer pUser); + } + + public static interface FMSGCallBack extends Callback { + public void invoke(int lCommand, NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser); + } + + public static interface FMSGCallBack_V31 extends Callback { + public boolean invoke(int lCommand, NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser); + } + + public static interface FMessCallBack extends Callback { + public boolean invoke(int lCommand, String sDVRIP, String pBuf, int dwBufLen); + } + + public static interface FMessCallBack_EX extends Callback { + public boolean invoke(int lCommand, int lUserID, String pBuf, int dwBufLen); + } + + public static interface FMessCallBack_NEW extends Callback { + public boolean invoke(int lCommand, String sDVRIP, String pBuf, int dwBufLen, short dwLinkDVRPort); + } + + public static interface FMessageCallBack extends Callback { + public boolean invoke(int lCommand, String sDVRIP, String pBuf, int dwBufLen, int dwUser); + } + + public static interface FExceptionCallBack extends Callback { + public void invoke(int dwType, int lUserID, int lHandle, Pointer pUser); + } + + public static interface FDrawFun extends Callback { + public void invoke(int lRealHandle, W32API.HDC hDc, int dwUser); + } + + public static interface FStdDataCallBack extends Callback { + public void invoke(int lRealHandle, int dwDataType, Pointer pBuffer, int dwBufSize, int dwUser); + } + + public static interface FPlayDataCallBack extends Callback { + public void invoke(int lPlayHandle, int dwDataType, Pointer pBuffer, int dwBufSize, int dwUser); + } + public static interface FPlayESCallBack extends Callback { + public void invoke(int lPlayHandle, NET_DVR_PACKET_INFO_EX struPackInfo, Pointer pUser); + } + + public static interface FVoiceDataCallBack extends Callback { + public void invoke(int lVoiceComHandle, Pointer pRecvDataBuffer, int dwBufSize, byte byAudioFlag, int dwUser); + } + + public static interface FVoiceDataCallBack_V30 extends Callback { + public void invoke(int lVoiceComHandle, Pointer pRecvDataBuffer, int dwBufSize, byte byAudioFlag, int pUser); + } + + public static interface FVoiceDataCallBack_MR extends Callback { + public void invoke(int lVoiceComHandle, Pointer pRecvDataBuffer, int dwBufSize, byte byAudioFlag, int dwUser); + } + + public static interface FVoiceDataCallback_MR_V30 extends Callback { + public void invoke(int lVoiceComHandle, Pointer pRecvDataBuffer, int dwBufSize, byte byAudioFlag, Pointer pUser); + } + + public static interface FVoiceDataCallBack2 extends Callback { + public void invoke(String pRecvDataBuffer, int dwBufSize, Pointer pUser); + } + + public static interface FSerialDataCallBack extends Callback { + public void invoke(int lSerialHandle, String pRecvDataBuffer, int dwBufSize, int dwUser); + } + + public static interface FRowDataCallBack extends Callback { + public void invoke(int lUserID, String sIPAddr, int lRowAmout, String pRecvDataBuffer, int dwBufSize, int dwUser); + } + + public static interface FColLocalDataCallBack extends Callback { + public void invoke(int lUserID, String sIPAddr, int lColumnAmout, String pRecvDataBuffer, int dwBufSize, int dwUser); + } + + public static interface FColGlobalDataCallBack extends Callback { + public void invoke(int lUserID, String sIPAddr, int lColumnAmout, String pRecvDataBuffer, int dwBufSize, int dwUser); + } + + public static interface FJpegdataCallBack extends Callback { + public int invoke(int lCommand, int lUserID, String sDVRIP, String sJpegName, String pJpegBuf, int dwBufLen, int dwUser); + } + + public static interface FPostMessageCallBack extends Callback { + public int invoke(int dwType, int lIndex); + } + + public static interface DEV_WORK_STATE_CB extends Callback { + public boolean invoke(Pointer pUserdata, int iUserID, NET_DVR_WORKSTATE_V40 lpWorkState); + } + + public static interface FLOWTESTCALLBACK extends Callback { + public void invoke(int lFlowHandle, NET_DVR_FLOW_INFO pFlowInfo, + Pointer pUser); + } + + + boolean NET_DVR_Init(); + + boolean NET_DVR_Cleanup(); + + boolean NET_DVR_SetSDKInitCfg(int enumType, Pointer lpInBuff); + + boolean NET_DVR_SetSDKLocalCfg(int enumType, Pointer lpInBuff); + + boolean NET_DVR_GetSDKLocalCfg(int enumType, Pointer lpOutBuff); + + boolean NET_DVR_SetDVRMessage(int nMessage, int hWnd); + + //NET_DVR_SetDVRMessage的扩展 + boolean NET_DVR_SetExceptionCallBack_V30(int nMessage, int hWnd, FExceptionCallBack fExceptionCallBack, Pointer pUser); + + boolean NET_DVR_SetDVRMessCallBack(FMessCallBack fMessCallBack); + + boolean NET_DVR_SetDVRMessCallBack_EX(FMessCallBack_EX fMessCallBack_EX); + + + //2007-04-16增加查询结果带卡号的文件查找 + int NET_DVR_FindNextFile_Card(int lFindHandle, NET_DVR_FINDDATA_CARD lpFindData); + + int NET_DVR_FindFile_Card(int lUserID, int lChannel, int dwFileType, NET_DVR_TIME lpStartTime, NET_DVR_TIME lpStopTime); + + boolean NET_DVR_LockFileByName(int lUserID, String sLockFileName); + + boolean NET_DVR_UnlockFileByName(int lUserID, String sUnlockFileName); + + int NET_DVR_PlayBackByName(int lUserID, String sPlayBackFileName, HWND hWnd); + + int NET_DVR_PlayBackByTime(int lUserID, int lChannel, NET_DVR_TIME lpStartTime, NET_DVR_TIME lpStopTime, HWND hWnd); + + int NET_DVR_PlayBackByTime_V40(int lUserID, NET_DVR_VOD_PARA pVodPara); + + boolean NET_DVR_PlayBackControl(int lPlayHandle, int dwControlCode, int dwInValue, IntByReference LPOutValue); + + boolean NET_DVR_PlayBackControl_V40(int lPlayHandle, int dwControlCode, Pointer lpInBuffer, int dwInLen, Pointer lpOutBuffer, IntByReference lpOutLen); + + boolean NET_DVR_StopPlayBack(int lPlayHandle); + + boolean NET_DVR_SetPlayDataCallBack(int lPlayHandle, FPlayDataCallBack fPlayDataCallBack, int dwUser); + boolean NET_DVR_SetPlayDataCallBack_V40(int lPlayHandle, FPlayDataCallBack fPlayDataCallBack, Pointer dwUser); + boolean NET_DVR_SetPlayBackESCallBack(int lPlayHandle, FPlayESCallBack fPlayESCallBack, Pointer pUser); + + boolean NET_DVR_PlayBackSaveData(int lPlayHandle, String sFileName); + + boolean NET_DVR_StopPlayBackSave(int lPlayHandle); + + boolean NET_DVR_GetPlayBackOsdTime(int lPlayHandle, NET_DVR_TIME lpOsdTime); + + boolean NET_DVR_PlayBackCaptureFile(int lPlayHandle, String sFileName); + + int NET_DVR_GetFileByName(int lUserID, String sDVRFileName, byte[] sSavedFileName); + + int NET_DVR_GetFileByTime(int lUserID, int lChannel, NET_DVR_TIME lpStartTime, NET_DVR_TIME lpStopTime, String sSavedFileName); + + int NET_DVR_GetFileByTime_V40(int lUserID, String sSavedFileName, NET_DVR_PLAYCOND pDownloadCond); + + boolean NET_DVR_StopGetFile(int lFileHandle); + + int NET_DVR_GetDownloadPos(int lFileHandle); + + int NET_DVR_GetPlayBackPos(int lPlayHandle); + + //图片查找 + int NET_DVR_FindPicture(int lUserID, NET_DVR_FIND_PICTURE_PARAM pFindParam); + + int NET_DVR_FindNextPicture_V50(int lFindHandle, NET_DVR_FIND_PICTURE_V50 lpFindData); + + int NET_DVR_FindNextPicture(int lFindHandle, NET_DVR_FIND_PICTURE lpFindData); + + boolean NET_DVR_CloseFindPicture(int lFindHandle); + + boolean NET_DVR_GetPicture_V50(int lUserID, NET_DVR_PIC_PARAM lpPicParam); + + boolean NET_DVR_SetDVRMessCallBack_NEW(FMessCallBack_NEW fMessCallBack_NEW); + + + boolean NET_DVR_SetDVRMessageCallBack(FMessageCallBack fMessageCallBack, int dwUser); + + boolean NET_DVR_SetDVRMessageCallBack_V30(FMSGCallBack fMessageCallBack, Pointer pUser); + + boolean NET_DVR_SetDVRMessageCallBack_V31(FMSGCallBack_V31 fMessageCallBack, Pointer pUser); + + boolean NET_DVR_SetDVRMessageCallBack_V50(int iIndex, FMSGCallBack_V31 fMessageCallBack, Pointer pUser); + + boolean NET_DVR_SetConnectTime(int dwWaitTime, int dwTryTimes); + + boolean NET_DVR_SetReconnect(int dwInterval, boolean bEnableRecon); + + int NET_DVR_GetSDKVersion(); + + int NET_DVR_GetSDKBuildVersion(); + + int NET_DVR_IsSupport(); + + boolean NET_DVR_StartListen(String sLocalIP, short wLocalPort); + + boolean NET_DVR_StopListen(); + + int NET_DVR_StartListen_V30(String sLocalIP, short wLocalPort, FMSGCallBack DataCallBack, Pointer pUserData); + + boolean NET_DVR_StopListen_V30(int lListenHandle); + + int NET_DVR_Login(String sDVRIP, short wDVRPort, String sUserName, String sPassword, NET_DVR_DEVICEINFO lpDeviceInfo); + + int NET_DVR_Login_V30(String sDVRIP, short wDVRPort, String sUserName, String sPassword, NET_DVR_DEVICEINFO_V30 lpDeviceInfo); + + int NET_DVR_Login_V40(NET_DVR_USER_LOGIN_INFO pLoginInfo, NET_DVR_DEVICEINFO_V40 lpDeviceInfo); + + boolean NET_DVR_Logout(int lUserID); + + boolean NET_DVR_Logout_V30(int lUserID); + + int NET_DVR_GetLastError(); + + String NET_DVR_GetErrorMsg(IntByReference pErrorNo); + + boolean NET_DVR_SetShowMode(int dwShowType, int colorKey); + + boolean NET_DVR_GetDVRIPByResolveSvr(String sServerIP, short wServerPort, String sDVRName, short wDVRNameLen, String sDVRSerialNumber, short wDVRSerialLen, String sGetIP); + + boolean NET_DVR_GetDVRIPByResolveSvr_EX(String sServerIP, short wServerPort, String sDVRName, short wDVRNameLen, String sDVRSerialNumber, short wDVRSerialLen, String sGetIP, IntByReference dwPort); + + //预览相关接口 + int NET_DVR_RealPlay(int lUserID, NET_DVR_CLIENTINFO lpClientInfo); + + int NET_DVR_RealPlay_V30(int lUserID, NET_DVR_CLIENTINFO lpClientInfo, FRealDataCallBack_V30 fRealDataCallBack_V30, Pointer pUser, boolean bBlocked); + + int NET_DVR_RealPlay_V40(int lUserID, NET_DVR_PREVIEWINFO lpPreviewInfo, FRealDataCallBack_V30 fRealDataCallBack_V30, Pointer pUser); + + boolean NET_DVR_StopRealPlay(int lRealHandle); + + boolean NET_DVR_RigisterDrawFun(int lRealHandle, FDrawFun fDrawFun, int dwUser); + + boolean NET_DVR_SetPlayerBufNumber(int lRealHandle, int dwBufNum); + + boolean NET_DVR_ThrowBFrame(int lRealHandle, int dwNum); + + boolean NET_DVR_SetAudioMode(int dwMode); + + boolean NET_DVR_OpenSound(int lRealHandle); + + boolean NET_DVR_CloseSound(); + + boolean NET_DVR_OpenSoundShare(int lRealHandle); + + boolean NET_DVR_CloseSoundShare(int lRealHandle); + + boolean NET_DVR_Volume(int lRealHandle, short wVolume); + + boolean NET_DVR_SaveRealData(int lRealHandle, String sFileName); + + boolean NET_DVR_SaveRealData_V30(int lRealHandle, int dwTransType, Pointer sFileName); + + boolean NET_DVR_StopSaveRealData(int lRealHandle); + + boolean NET_DVR_SetRealDataCallBack(int lRealHandle, FRowDataCallBack fRealDataCallBack, int dwUser); + + boolean NET_DVR_SetESRealPlayCallBack(int iRealHandle, FPlayESCallBack fPlayESCallBack, Pointer pUser); + + boolean NET_DVR_SetStandardDataCallBack(int lRealHandle, FStdDataCallBack fStdDataCallBack,int dwUser); + + boolean NET_DVR_CapturePicture(int lRealHandle, String sPicFileName);//bmp + + //动态生成I帧 + boolean NET_DVR_MakeKeyFrame(int lUserID, int lChannel);//主码流 + + boolean NET_DVR_MakeKeyFrameSub(int lUserID, int lChannel);//子码流 + + //云台控制相关接口 + boolean NET_DVR_PTZControl(int lRealHandle, int dwPTZCommand, int dwStop); + + boolean NET_DVR_PTZControl_Other(int lUserID, int lChannel, int dwPTZCommand, int dwStop); + + boolean NET_DVR_TransPTZ(int lRealHandle, String pPTZCodeBuf, int dwBufSize); + + boolean NET_DVR_TransPTZ_Other(int lUserID, int lChannel, String pPTZCodeBuf, int dwBufSize); + + boolean NET_DVR_PTZPreset(int lRealHandle, int dwPTZPresetCmd, int dwPresetIndex); + + boolean NET_DVR_PTZPreset_Other(int lUserID, int lChannel, int dwPTZPresetCmd, int dwPresetIndex); + + boolean NET_DVR_TransPTZ_EX(int lRealHandle, String pPTZCodeBuf, int dwBufSize); + + boolean NET_DVR_PTZControl_EX(int lRealHandle, int dwPTZCommand, int dwStop); + + boolean NET_DVR_PTZPreset_EX(int lRealHandle, int dwPTZPresetCmd, int dwPresetIndex); + + boolean NET_DVR_PTZCruise(int lRealHandle, int dwPTZCruiseCmd, byte byCruiseRoute, byte byCruisePoint, short wInput); + + boolean NET_DVR_PTZCruise_Other(int lUserID, int lChannel, int dwPTZCruiseCmd, byte byCruiseRoute, byte byCruisePoint, short wInput); + + boolean NET_DVR_PTZCruise_EX(int lRealHandle, int dwPTZCruiseCmd, byte byCruiseRoute, byte byCruisePoint, short wInput); + + boolean NET_DVR_PTZTrack(int lRealHandle, int dwPTZTrackCmd); + + boolean NET_DVR_PTZTrack_Other(int lUserID, int lChannel, int dwPTZTrackCmd); + + boolean NET_DVR_PTZTrack_EX(int lRealHandle, int dwPTZTrackCmd); + + boolean NET_DVR_PTZControlWithSpeed(int lRealHandle, int dwPTZCommand, int dwStop, int dwSpeed); + + boolean NET_DVR_PTZControlWithSpeed_Other(int lUserID, int lChannel, int dwPTZCommand, int dwStop, int dwSpeed); + + boolean NET_DVR_PTZControlWithSpeed_EX(int lRealHandle, int dwPTZCommand, int dwStop, int dwSpeed); + + boolean NET_DVR_GetPTZCruise(int lUserID, int lChannel, int lCruiseRoute, NET_DVR_CRUISE_RET lpCruiseRet); + + boolean NET_DVR_PTZMltTrack(int lRealHandle, int dwPTZTrackCmd, int dwTrackIndex); + + boolean NET_DVR_PTZMltTrack_Other(int lUserID, int lChannel, int dwPTZTrackCmd, int dwTrackIndex); + + boolean NET_DVR_PTZMltTrack_EX(int lRealHandle, int dwPTZTrackCmd, int dwTrackIndex); + + //文件查找与回放 + int NET_DVR_FindFile(int lUserID, int lChannel, int dwFileType, NET_DVR_TIME lpStartTime, NET_DVR_TIME lpStopTime); + + int NET_DVR_FindNextFile(int lFindHandle, NET_DVR_FIND_DATA lpFindData); + + boolean NET_DVR_FindClose(int lFindHandle); + + int NET_DVR_FindNextFile_V30(int lFindHandle, NET_DVR_FINDDATA_V30 lpFindData); + + int NET_DVR_FindFile_V30(int lUserID, NET_DVR_FILECOND pFindCond); + + int NET_DVR_FindFile_V40(int lUserID, NET_DVR_FILECOND_V40 pFindCond); + + int NET_DVR_FindNextFile_V40(int lFindHandle, NET_DVR_FINDDATA_V40 lpFindData); + + int NET_DVR_FindFile_V50(int lUserID, NET_DVR_FILECOND_V50 pFindCond); + + int NET_DVR_FindNextFile_V50(int lFindHandle, NET_DVR_FINDDATA_V50 lpFindData); + + boolean NET_DVR_FindClose_V30(int lFindHandle); + + //按事件查找 + int NET_DVR_FindFileByEvent(int lUserID, NET_DVR_SEARCH_EVENT_PARAM lpSearchEventParam); + + int NET_DVR_FindNextEvent(int lSearchHandle, NET_DVR_SEARCH_EVENT_RET lpSearchEventRet); + + int NET_DVR_FindFileByEvent_V50(int lUserID, NET_DVR_SEARCH_EVENT_PARAM_V50 lpSearchEventParam); + + int NET_DVR_FindNextEvent_V50(int lFindHandle, NET_DVR_SEARCH_EVENT_RET_V50 lpSearchEventRet); + + + //升级 + int NET_DVR_Upgrade(int lUserID, String sFileName); + + int NET_DVR_GetUpgradeState(int lUpgradeHandle); + + int NET_DVR_GetUpgradeProgress(int lUpgradeHandle); + + boolean NET_DVR_CloseUpgradeHandle(int lUpgradeHandle); + + boolean NET_DVR_SetNetworkEnvironment(int dwEnvironmentLevel); + + //远程格式化硬盘 + int NET_DVR_FormatDisk(int lUserID, int lDiskNumber); + + boolean NET_DVR_GetFormatProgress(int lFormatHandle, IntByReference pCurrentFormatDisk, IntByReference pCurrentDiskPos, IntByReference pFormatStatic); + + boolean NET_DVR_CloseFormatHandle(int lFormatHandle); + + //报警 + int NET_DVR_SetupAlarmChan(int lUserID); + + boolean NET_DVR_CloseAlarmChan(int lAlarmHandle); + + int NET_DVR_SetupAlarmChan_V30(int lUserID); + + int NET_DVR_SetupAlarmChan_V41(int lUserID, NET_DVR_SETUPALARM_PARAM lpSetupParam); + + int NET_DVR_SetupAlarmChan_V50(int iUserID, NET_DVR_SETUPALARM_PARAM_V50 lpSetupParam, Pointer pSub, int dwSubSize); + + boolean NET_DVR_CloseAlarmChan_V30(int lAlarmHandle); + + //语音对讲 + int NET_DVR_StartVoiceCom(int lUserID, FVoiceDataCallBack fVoiceDataCallBack, int dwUser); + + int NET_DVR_StartVoiceCom_V30(int lUserID, int dwVoiceChan, boolean bNeedCBNoEncData, FVoiceDataCallBack_V30 fVoiceDataCallBack, Pointer pUser); + + boolean NET_DVR_SetVoiceComClientVolume(int lVoiceComHandle, short wVolume); + + boolean NET_DVR_StopVoiceCom(int lVoiceComHandle); + + //语音转发 + + boolean NET_DVR_GetCurrentAudioCompress(int lUserID, NET_DVR_COMPRESSION_AUDIO lpCompressAudio); + int NET_DVR_StartVoiceCom_MR(int lUserID, FVoiceDataCallBack_MR fVoiceDataCallBack, int dwUser); + + int NET_DVR_StartVoiceCom_MR_V30(int lUserID, int dwVoiceChan, FVoiceDataCallback_MR_V30 fVoiceDataCallBack, Pointer pUser); + + boolean NET_DVR_VoiceComSendData(int lVoiceComHandle, byte[] pSendBuf, int dwBufSize); + + //语音广播 + boolean NET_DVR_ClientAudioStart(); + + boolean NET_DVR_ClientAudioStart_V30(FVoiceDataCallBack2 fVoiceDataCallBack2, Pointer pUser); + + boolean NET_DVR_ClientAudioStop(); + + boolean NET_DVR_AddDVR(int lUserID); + + int NET_DVR_AddDVR_V30(int lUserID, int dwVoiceChan); + + boolean NET_DVR_DelDVR(int lUserID); + + boolean NET_DVR_DelDVR_V30(int lVoiceHandle); + + //////////////////////////////////////////////////////////// +//透明通道设置 + int NET_DVR_SerialStart(int lUserID, int lSerialPort, FSerialDataCallBack fSerialDataCallBack, int dwUser); + + public static interface FSerialDataCallBack_V40 extends Callback { + public void invoke(int lSerialHandle, int lCHannel, byte[] pRecvDataBuffer, int dwBufSize, Pointer pUser); + } + + int NET_DVR_SerialStart_V40(int lUserID, Pointer lpInBuffer, int dwInBufferSize, FSerialDataCallBack_V40 fSerialDataCallBack_V40, Pointer pUser); + + //485作为透明通道时,需要指明通道号,因为不同通道号485的设置可以不同(比如波特率) + boolean NET_DVR_SerialSend(int lSerialHandle, int lChannel, byte[] pSendBuf, int dwBufSize); + + boolean NET_DVR_SerialStop(int lSerialHandle); + + boolean NET_DVR_SendTo232Port(int lUserID, String pSendBuf, int dwBufSize); + + boolean NET_DVR_SendToSerialPort(int lUserID, int dwSerialPort, int dwSerialIndex, String pSendBuf, int dwBufSize); + + //Win64、Linux32、Linux64 + Pointer NET_DVR_InitG722Encoder(NET_DVR_AUDIOENC_INFO enc_info); + + boolean NET_DVR_EncodeG722Frame(Pointer handle, NET_DVR_AUDIOENC_PROCESS_PARAM param); + + void NET_DVR_ReleaseG722Encoder(Pointer pEncodeHandle); + + Pointer NET_DVR_InitG722Decoder(); + + boolean NET_DVR_DecodeG722Frame(Pointer handle, NET_DVR_AUDIODEC_PROCESS_PARAM param); + + void NET_DVR_ReleaseG722Decoder(Pointer pDecHandle); + + //G711: Win64、Linux32、Linux64 + Pointer NET_DVR_InitG711Encoder(NET_DVR_AUDIOENC_INFO enc_info);//NET_DVR_AUDIOENC_INFO//NET_DVR_AUDIOENC_INFO + + boolean NET_DVR_EncodeG711Frame(Pointer handle, NET_DVR_AUDIOENC_PROCESS_PARAM p_enc_proc_param); + + boolean NET_DVR_ReleaseG711Encoder(Pointer pEncodeHandle); + + Pointer NET_DVR_InitG711Decoder(); + + boolean NET_DVR_DecodeG711Frame(Pointer handle, NET_DVR_AUDIODEC_PROCESS_PARAM p_dec_proc_param); + + boolean NET_DVR_ReleaseG711Decoder(Pointer pDecHandle); + + //远程控制本地显示 + boolean NET_DVR_ClickKey(int lUserID, int lKeyIndex); + + //远程控制设备端手动录像 + boolean NET_DVR_StartDVRRecord(int lUserID, int lChannel, int lRecordType); + + boolean NET_DVR_StopDVRRecord(int lUserID, int lChannel); + + //解码卡 + boolean NET_DVR_InitDevice_Card(IntByReference pDeviceTotalChan); + + boolean NET_DVR_ReleaseDevice_Card(); + + boolean NET_DVR_InitDDraw_Card(int hParent, int colorKey); + + boolean NET_DVR_ReleaseDDraw_Card(); + + int NET_DVR_RealPlay_Card(int lUserID, NET_DVR_CARDINFO lpCardInfo, int lChannelNum); + + boolean NET_DVR_ResetPara_Card(int lRealHandle, NET_DVR_DISPLAY_PARA lpDisplayPara); + + boolean NET_DVR_RefreshSurface_Card(); + + boolean NET_DVR_ClearSurface_Card(); + + boolean NET_DVR_RestoreSurface_Card(); + + boolean NET_DVR_OpenSound_Card(int lRealHandle); + + boolean NET_DVR_CloseSound_Card(int lRealHandle); + + boolean NET_DVR_SetVolume_Card(int lRealHandle, short wVolume); + + boolean NET_DVR_AudioPreview_Card(int lRealHandle, boolean bEnable); + + int NET_DVR_GetCardLastError_Card(); + + Pointer NET_DVR_GetChanHandle_Card(int lRealHandle); + + boolean NET_DVR_CapturePicture_Card(int lRealHandle, String sPicFileName); + + //获取解码卡序列号此接口无效,改用GetBoardDetail接口获得(2005-12-08支持) + boolean NET_DVR_GetSerialNum_Card(int lChannelNum, IntByReference pDeviceSerialNo); + + //日志 + int NET_DVR_FindDVRLog(int lUserID, int lSelectMode, int dwMajorType, int dwMinorType, NET_DVR_TIME lpStartTime, NET_DVR_TIME lpStopTime); + + int NET_DVR_FindNextLog(int lLogHandle, NET_DVR_LOG lpLogData); + + boolean NET_DVR_FindLogClose(int lLogHandle); + + int NET_DVR_FindDVRLog_V30(int lUserID, int lSelectMode, int dwMajorType, int dwMinorType, NET_DVR_TIME lpStartTime, NET_DVR_TIME lpStopTime, boolean bOnlySmart); + + int NET_DVR_FindNextLog_V30(int lLogHandle, NET_DVR_LOG_V30 lpLogData); + + boolean NET_DVR_FindLogClose_V30(int lLogHandle); + + //截止2004年8月5日,共113个接口 +//ATM DVR + int NET_DVR_FindFileByCard(int lUserID, int lChannel, int dwFileType, int nFindType, String sCardNumber, NET_DVR_TIME lpStartTime, NET_DVR_TIME lpStopTime); +//截止2004年10月5日,共116个接口 + + //2005-09-15 + boolean NET_DVR_CaptureJPEGPicture(int lUserID, int lChannel, NET_DVR_JPEGPARA lpJpegPara, byte[] sPicFileName); + + //JPEG抓图到内存 + boolean NET_DVR_CaptureJPEGPicture_NEW(int lUserID, int lChannel, NET_DVR_JPEGPARA lpJpegPara, Pointer sJpegPicBuffer, int dwPicSize, IntByReference lpSizeReturned); + + //带全屏测温数据的设备抓图 + boolean NET_DVR_CaptureJPEGPicture_WithAppendData(int lUserID, int iChannelNum, NET_DVR_JPEGPICTURE_WITH_APPENDDATA m_strJpegWithAppendData); + + //2006-02-16 + int NET_DVR_GetRealPlayerIndex(int lRealHandle); + + int NET_DVR_GetPlayBackPlayerIndex(int lPlayHandle); + + //2006-08-28 704-640 缩放配置 + boolean NET_DVR_SetScaleCFG(int lUserID, int dwScale); + + boolean NET_DVR_GetScaleCFG(int lUserID, IntByReference lpOutScale); + + boolean NET_DVR_SetScaleCFG_V30(int lUserID, NET_DVR_SCALECFG pScalecfg); + + boolean NET_DVR_GetScaleCFG_V30(int lUserID, NET_DVR_SCALECFG pScalecfg); + + //2006-08-28 ATM机端口设置 + boolean NET_DVR_SetATMPortCFG(int lUserID, short wATMPort); + + boolean NET_DVR_GetATMPortCFG(int lUserID, ShortByReference LPOutATMPort); + + //2006-11-10 支持显卡辅助输出 + boolean NET_DVR_InitDDrawDevice(); + + boolean NET_DVR_ReleaseDDrawDevice(); + + int NET_DVR_GetDDrawDeviceTotalNums(); + + boolean NET_DVR_SetDDrawDevice(int lPlayPort, int nDeviceNum); + + boolean NET_DVR_PTZSelZoomIn(int lRealHandle, NET_DVR_POINT_FRAME pStruPointFrame); + + boolean NET_DVR_PTZSelZoomIn_EX(int lUserID, int lChannel, NET_DVR_POINT_FRAME pStruPointFrame); + + boolean NET_DVR_FocusOnePush(int lUserID, int lChannel); + + //解码设备DS-6001D/DS-6001F + boolean NET_DVR_StartDecode(int lUserID, int lChannel, NET_DVR_DECODERINFO lpDecoderinfo); + + boolean NET_DVR_StopDecode(int lUserID, int lChannel); + + boolean NET_DVR_GetDecoderState(int lUserID, int lChannel, NET_DVR_DECODERSTATE lpDecoderState); + + //2005-08-01 + boolean NET_DVR_SetDecInfo(int lUserID, int lChannel, NET_DVR_DECCFG lpDecoderinfo); + + boolean NET_DVR_GetDecInfo(int lUserID, int lChannel, NET_DVR_DECCFG lpDecoderinfo); + + boolean NET_DVR_SetDecTransPort(int lUserID, NET_DVR_PORTCFG lpTransPort); + + boolean NET_DVR_GetDecTransPort(int lUserID, NET_DVR_PORTCFG lpTransPort); + + boolean NET_DVR_DecPlayBackCtrl(int lUserID, int lChannel, int dwControlCode, int dwInValue, IntByReference LPOutValue, NET_DVR_PLAYREMOTEFILE lpRemoteFileInfo); + + boolean NET_DVR_StartDecSpecialCon(int lUserID, int lChannel, NET_DVR_DECCHANINFO lpDecChanInfo); + + boolean NET_DVR_StopDecSpecialCon(int lUserID, int lChannel, NET_DVR_DECCHANINFO lpDecChanInfo); + + boolean NET_DVR_DecCtrlDec(int lUserID, int lChannel, int dwControlCode); + + boolean NET_DVR_DecCtrlScreen(int lUserID, int lChannel, int dwControl); + + boolean NET_DVR_GetDecCurLinkStatus(int lUserID, int lChannel, NET_DVR_DECSTATUS lpDecStatus); + + //多路解码器 +//2007-11-30 V211支持以下接口 //11 + boolean NET_DVR_MatrixStartDynamic(int lUserID, int dwDecChanNum, NET_DVR_MATRIX_DYNAMIC_DEC lpDynamicInfo); + + boolean NET_DVR_MatrixStopDynamic(int lUserID, int dwDecChanNum); + + boolean NET_DVR_MatrixGetDecChanInfo(int lUserID, int dwDecChanNum, NET_DVR_MATRIX_DEC_CHAN_INFO lpInter); + + boolean NET_DVR_MatrixSetLoopDecChanInfo(int lUserID, int dwDecChanNum, NET_DVR_MATRIX_LOOP_DECINFO lpInter); + + boolean NET_DVR_MatrixGetLoopDecChanInfo(int lUserID, int dwDecChanNum, NET_DVR_MATRIX_LOOP_DECINFO lpInter); + + boolean NET_DVR_MatrixSetLoopDecChanEnable(int lUserID, int dwDecChanNum, int dwEnable); + + boolean NET_DVR_MatrixGetLoopDecChanEnable(int lUserID, int dwDecChanNum, IntByReference lpdwEnable); + + boolean NET_DVR_MatrixGetLoopDecEnable(int lUserID, IntByReference lpdwEnable); + + boolean NET_DVR_MatrixSetDecChanEnable(int lUserID, int dwDecChanNum, int dwEnable); + + boolean NET_DVR_MatrixGetDecChanEnable(int lUserID, int dwDecChanNum, IntByReference lpdwEnable); + + boolean NET_DVR_MatrixGetDecChanStatus(int lUserID, int dwDecChanNum, NET_DVR_MATRIX_DEC_CHAN_STATUS lpInter); + + boolean NET_DVR_MatrixStartDynamic_V41(int lUserID, int dwDecChanNum, Pointer lpDynamicInfo); + + boolean NET_DVR_MatrixGetLoopDecChanInfo_V41(int lUserID, int dwDecChanNum, NET_DVR_MATRIX_LOOP_DECINFO_V41 lpOuter); + + boolean NET_DVR_MatrixSetLoopDecChanInfo_V41(int lUserID, int dwDecChanNum, NET_DVR_MATRIX_LOOP_DECINFO_V41 lpInter); + + int NET_DVR_MatrixStartPassiveDecode(int lUserID, int dwDecChanNum, Pointer lpPassiveMode); + + boolean NET_DVR_MatrixSendData(int lPassiveHandle, Pointer pSendBuf, int dwBufSize); + + boolean NET_DVR_MatrixStopPassiveDecode(int lPassiveHandle); + + //2007-12-22 增加支持接口 //18 + boolean NET_DVR_MatrixSetTranInfo(int lUserID, NET_DVR_MATRIX_TRAN_CHAN_CONFIG lpTranInfo); + + boolean NET_DVR_MatrixGetTranInfo(int lUserID, NET_DVR_MATRIX_TRAN_CHAN_CONFIG lpTranInfo); + + boolean NET_DVR_MatrixSetRemotePlay(int lUserID, int dwDecChanNum, NET_DVR_MATRIX_DEC_REMOTE_PLAY lpInter); + + boolean NET_DVR_MatrixSetRemotePlayControl(int lUserID, int dwDecChanNum, int dwControlCode, int dwInValue, IntByReference LPOutValue); + + boolean NET_DVR_MatrixGetRemotePlayStatus(int lUserID, int dwDecChanNum, NET_DVR_MATRIX_DEC_REMOTE_PLAY_STATUS lpOuter); + + //end + boolean NET_DVR_RefreshPlay(int lPlayHandle); + + //恢复默认值 + boolean NET_DVR_RestoreConfig(int lUserID); + + //保存参数 + boolean NET_DVR_SaveConfig(int lUserID); + + //重启 + boolean NET_DVR_RebootDVR(int lUserID); + + //关闭DVR + boolean NET_DVR_ShutDownDVR(int lUserID); + + //参数配置 begin + boolean NET_DVR_GetDeviceConfig(int lUserID, int dwCommand, int dwCount, Pointer lpInBuffer, int dwInBufferSize, Pointer lpStatusList, Pointer lpOutBuffer, int dwOutBufferSize); + + boolean NET_DVR_SetDeviceConfig(int lUserID, int dwCommand, int dwCount, Pointer lpInBuffer, int dwInBufferSize, Pointer lpStatusList, Pointer lpInParamBuffer, int dwInParamBufferSize); + + boolean NET_DVR_SetDeviceConfigEx(int lUserID, int dwCommand, int dwCount, Pointer lpInParam, Pointer lpOutParam); + + boolean NET_DVR_GetDVRConfig(int lUserID, int dwCommand, int lChannel, Pointer lpOutBuffer, int dwOutBufferSize, IntByReference lpBytesReturned); + + boolean NET_DVR_SetDVRConfig(int lUserID, int dwCommand, int lChannel, Pointer lpInBuffer, int dwInBufferSize); + + boolean NET_DVR_GetSTDConfig(int lUserID, int dwCommand, NET_DVR_STD_CONFIG lpConfigParam); + + boolean NET_DVR_SetSTDConfig(int lUserID, int dwCommand, NET_DVR_STD_CONFIG lpConfigParam); + + boolean NET_DVR_GetDVRWorkState_V30(int lUserID, NET_DVR_WORKSTATE_V30 lpWorkState); + + boolean NET_DVR_GetDVRWorkState(int lUserID, NET_DVR_WORKSTATE lpWorkState); + + boolean NET_DVR_SetVideoEffect(int lUserID, int lChannel, int dwBrightValue, int dwContrastValue, int dwSaturationValue, int dwHueValue); + + boolean NET_DVR_GetVideoEffect(int lUserID, int lChannel, IntByReference pBrightValue, IntByReference pContrastValue, IntByReference pSaturationValue, IntByReference pHueValue); + + boolean NET_DVR_ClientGetframeformat(int lUserID, NET_DVR_FRAMEFORMAT lpFrameFormat); + + boolean NET_DVR_ClientSetframeformat(int lUserID, NET_DVR_FRAMEFORMAT lpFrameFormat); + + boolean NET_DVR_ClientGetframeformat_V30(int lUserID, NET_DVR_FRAMEFORMAT_V30 lpFrameFormat); + + boolean NET_DVR_ClientSetframeformat_V30(int lUserID, NET_DVR_FRAMEFORMAT_V30 lpFrameFormat); + + boolean NET_DVR_GetAlarmOut_V30(int lUserID, NET_DVR_ALARMOUTSTATUS_V30 lpAlarmOutState); + + boolean NET_DVR_GetAlarmOut(int lUserID, NET_DVR_ALARMOUTSTATUS lpAlarmOutState); + + boolean NET_DVR_SetAlarmOut(int lUserID, int lAlarmOutPort, int lAlarmOutStatic); + + //视频参数调节 + boolean NET_DVR_ClientSetVideoEffect(int lRealHandle, int dwBrightValue, int dwContrastValue, int dwSaturationValue, int dwHueValue); + + boolean NET_DVR_ClientGetVideoEffect(int lRealHandle, IntByReference pBrightValue, IntByReference pContrastValue, IntByReference pSaturationValue, IntByReference pHueValue); + + //配置文件 + boolean NET_DVR_GetConfigFile(int lUserID, String sFileName); + + boolean NET_DVR_SetConfigFile(int lUserID, String sFileName); + + boolean NET_DVR_GetConfigFile_V30(int lUserID, String sOutBuffer, int dwOutSize, IntByReference pReturnSize); + + boolean NET_DVR_GetConfigFile_EX(int lUserID, String sOutBuffer, int dwOutSize); + + boolean NET_DVR_SetConfigFile_EX(int lUserID, String sInBuffer, int dwInSize); + + //启用日志文件写入接口 + boolean NET_DVR_SetLogToFile(int bLogEnable, String strLogDir, boolean bAutoDel); + + boolean NET_DVR_GetSDKState(NET_DVR_SDKSTATE pSDKState); + + boolean NET_DVR_GetSDKAbility(NET_DVR_SDKABL pSDKAbl); + + boolean NET_DVR_GetPTZProtocol(int lUserID, NET_DVR_PTZCFG pPtzcfg); + + //前面板锁定 + boolean NET_DVR_LockPanel(int lUserID); + + boolean NET_DVR_UnLockPanel(int lUserID); + + boolean NET_DVR_SetRtspConfig(int lUserID, int dwCommand, NET_DVR_RTSPCFG lpInBuffer, int dwInBufferSize); + + boolean NET_DVR_GetRtspConfig(int lUserID, int dwCommand, NET_DVR_RTSPCFG lpOutBuffer, int dwOutBufferSize); + + boolean NET_DVR_ContinuousShoot(int lUserID, NET_DVR_SNAPCFG lpInter); + + boolean NET_DVR_ManualSnap(int lUserID, NET_DVR_MANUALSNAP lpInter, NET_DVR_PLATE_RESULT lpOuter); + + public static interface FRemoteConfigCallBack extends Callback { + public void invoke(int dwType, Pointer lpBuffer, int dwBufLen, Pointer pUserData); + } + + int NET_DVR_StartRemoteConfig(int lUserID, int dwCommand, Pointer lpInBuffer, int dwInBufferLen, FRemoteConfigCallBack cbStateCallBack, Pointer pUserData); + + boolean NET_DVR_SendRemoteConfig(int lHandle, int dwDataType, Pointer pSendBuf, int dwBufSize); + + int NET_DVR_GetNextRemoteConfig(int lHandle, Pointer lpOutBuff, int dwOutBuffSize); + + int NET_DVR_SendWithRecvRemoteConfig(int lHandle, Pointer lpInBuff, int dwInBuffSize, Pointer lpOutBuff, int dwOutBuffSize, IntByReference dwOutDataLen); + + boolean NET_DVR_StopRemoteConfig(int lHandle); + + boolean NET_DVR_RemoteControl(int lUserID, int dwCommand, Pointer lpInBuffer, int dwInBufferSize); + + boolean NET_DVR_STDXMLConfig(int lUserID, NET_DVR_XML_CONFIG_INPUT lpInputParam, NET_DVR_XML_CONFIG_OUTPUT lpOutputParam); + + boolean NET_DVR_GetSTDAbility(int lUserID, int dwAbilityType, NET_DVR_STD_ABILITY lpAbilityParam); + + boolean NET_DVR_GetDeviceAbility(int lUserID, int dwAbilityType, Pointer pInBuf, int dwInLength, Pointer pOutBuf, int dwOutLength); + + boolean NET_DVR_ControlGateway(int lUserID, int lGatewayIndex, int dwStaic); + + boolean NET_DVR_InquestStartCDW_V30(int lUserID, NET_DVR_INQUEST_ROOM lpInquestRoom, boolean bNotBurn); + + boolean NET_DVR_InquestStopCDW_V30(int lUserID, NET_DVR_INQUEST_ROOM lpInquestRoom, boolean bCancelWrite); + + boolean NET_DVR_GetArrayList(int lUserID, NET_DVR_ARRAY_LIST lpArrayList); + + int NET_DVR_InquestResumeEvent(int lUserID, NET_DVR_INQUEST_RESUME_EVENT lpResumeEvent); + + boolean NET_DVR_InquestGetResumeProgress(int lHandle, IntByReference pState); + + boolean NET_DVR_InquestStopResume(int lHandle); + + boolean NET_DVR_GetLocalIP(BYTE_TWODIM[] strIP, IntByReference pValidNum, boolean pEnableBind); + + boolean NET_DVR_SetValidIP(int dwIPIndex, boolean bEnableBind); + + boolean NET_DVR_AlarmHostAssistantControl(int lUserID, int dwType, int dwNumber, int dwCmdParam); + + boolean NET_DVR_GetPlanList(int lUserID, int dwDevNum, NET_DVR_PLAN_LIST lpPlanList); + + int NET_DVR_UploadFile_V40(int lUserID, int dwUploadType, Pointer lpInBuffer, int dwInBufferSize, String sFileName, Pointer lpOutBuffer, int dwOutBufferSize); + + int NET_DVR_UploadSend(int lUploadHandle, NET_DVR_SEND_PARAM_IN pstruSendParamIN, Pointer lpOutBuffer); + + int NET_DVR_GetUploadState(int lUploadHandle, Pointer pProgress); + + boolean NET_DVR_GetUploadResult(int lUploadHandle, Pointer lpOutBuffer, int dwOutBufferSize); + + boolean NET_DVR_UploadClose(int lUploadHandle); + + int NET_DVR_StartNetworkFlowTest(int lUserID, NET_DVR_FLOW_TEST_PARAM pFlowTest, FLOWTESTCALLBACK fFlowTestCallback, Pointer pUser); + + boolean NET_DVR_StopNetworkFlowTest(int lHandle); + + boolean NET_DVR_InquiryRecordTimeSpan(int lUserID, int dwChannel, NET_DVR_RECORD_TIME_SPAN_INQUIRY lpInquiry, NET_DVR_RECORD_TIME_SPAN lpResult); + + boolean NET_DVR_StartGetDevState(NET_DVR_CHECK_DEV_STATE pParams); + + //gps相关结构定义 + public static class TimeSegParam extends Structure { + //GPS数据查找起始时间 + public NET_DVR_TIME struBeginTime; + //GPS数据查找结束时间 + public NET_DVR_TIME struEndTime; + //GPS点时间间隔,单位:秒 + public int dwInterval; + //保留 + public byte[] byRes = new byte[76]; + } + + //按时间点查询 + public static class TimePointParam extends Structure { + //GPS数据查找时间点 + public NET_DVR_TIME struTimePoint; + //保留 + public byte[] byRes = new byte[104]; + } + + public static class GpsDataParamUion extends Union { + //按时间段查询 + public TimeSegParam timeSeg = new TimeSegParam(); + //按时间点查询 + public TimePointParam timePoint = new TimePointParam(); + } + + //gps查询参数定义 + public static class NET_DVR_GET_GPS_DATA_PARAM extends Structure { + //查找方式:0- 按时间段查找GPS数据,1- 按时间点查找GPS数据 + public int dwCmdType; + public GpsDataParamUion gpsDataParam; + + public void read() { + super.read(); + switch (dwCmdType) { + case 0: + gpsDataParam.setType(TimeSegParam.class); + break; + case 1: + gpsDataParam.setType(TimePointParam.class); + break; + default: + break; + } + gpsDataParam.read(); + } + + public void write() { + super.write(); + gpsDataParam.write(); + } + } + + //gps数据结构定义 + public static class NET_DVR_GPS_INFO extends Structure { + public byte[] byDirection = new byte[2]; + public byte bySvs; + public byte byLocateMode; + public short wHDOP; + public short wHeight; + public int dwLatitude; + public int dwLongitude; + public int dwVehicleSpeed; + public int dwVehicleDirection; + public byte[] byRes = new byte[8]; + } + + //gps返回数据结构定义 + public static class NET_DVR_GPS_DATA extends Structure { + public NET_DVR_GPS_INFO struGPSInfo; + public NET_DVR_TIME struTime; + public byte[] byRes = new byte[12]; + } + + public static interface fGPSDataCallback extends Callback { + public void invoke(int nHandle, int dwState, Pointer lpBuffer, int dwBufLen, Pointer pUser); + } + + int NET_DVR_GetVehicleGpsInfo(int lUserID, NET_DVR_GET_GPS_DATA_PARAM lpGPSDataParam, fGPSDataCallback cbGPSDataCallBack, Pointer pUser); + + /** + * 热成像相关 + */ + //设备抓图附加全屏测温数据结构体 + public static class NET_DVR_JPEGPICTURE_WITH_APPENDDATA extends Structure { + public int dwSize; + public int dwChannel;//通道号 + public int dwJpegPicLen;//Jpeg图片长度 + public Pointer pJpegPicBuff;//Jpeg图片指针 + public int dwJpegPicWidth; // 图像宽度 + public int dwJpegPicHeight; //图像高度 + public int dwP2PDataLen;//全屏测温数据长度 + public Pointer pP2PDataBuff; //全屏测温数据指针 + public byte byIsFreezedata;//是否数据冻结 0-否 1-是 + public byte[] byRes = new byte[255]; + } + + + public static class DATE_TIME extends Structure { + public short year; /*APP->DSP 年*/ + public short month; /*APP->DSP 月*/ + public short dayOfWeek; /*APP->DSP 0:星期日-6:星期六*/ + public short day; /*APP->DSP 日*/ + public short hour; /*APP->DSP 小时*/ + public short minute; /*APP->DSP 分钟*/ + public short second; /*APP->DSP 秒*/ + public short milliSecond; /*APP->DSP 毫秒*/ + } + + //全屏测温数据解析 + public static class STREAM_RT_DATA_INFO_S extends Structure { + public int u32RTDataType; // 1-14bit裸数据; 2-全屏测温结果数据; 3-YUV数据 + public int u32FrmNum; + public int u32StdStamp; //DSP相对时间戳 + public DATE_TIME stTime; //绝对时间戳 + public int u32Width; + public int u32Height; + public int u32Len; + public int u32Fps; + public int u32Chan; + } + + public static class STREAM_FS_SUPPLE_INFO_TEMP extends Structure { + public int u32TmDataMode; /* 0为4字节,1为2字节 */ + public int u32TmScale; /* 测温缩放比例 */ + public int u32TmOffset; /* 测温偏移量,当前固定为0 */ + public int byIsFreezedata; /*是否是冻结数据,1:冻结,0:非冻结*/ + } + + public static class STREAM_FARME_INFO_TEMP extends Structure { + public int u32MagicNo; //0x70827773 "FRMI"的ascii码 + public int u32HeaderSize; //结构体长度 + public int u32StreamType; //数据类型: h264/h265, JPEG, Audio, MetaData, RTData: 参见 STREAM_TYPE_E + public int u32StreamLen; //数据长度 + public STREAM_RT_DATA_INFO_S stRTDataInfo; + public STREAM_FS_SUPPLE_INFO_TEMP stFsSuppleInfo; + public int[] res = new int[12]; + public int u32CrcVal; //结构体校验码 对结构体前面数据进行校验 + } + + //测温规则温度信息 + public static class NET_DVR_THERMOMETRYRULE_TEMPERATURE_INFO extends Structure { + public float fMaxTemperature; + public float fMinTemperature; + public float fAverageTemperature; + public NET_VCA_POINT struHighestPoint; + public NET_VCA_POINT struLowestPoint; + public byte byIsFreezedata; + public byte[] byRes = new byte[15]; + } + + public static class REMOTECONFIGSTATUS_THERMOMETRY extends Structure { + public byte[] byStatus = new byte[4]; + public byte[] byErrorCode = new byte[4]; + } + + public static class NET_DVR_FIREDETECTION_ALARM extends Structure { + public int dwSize; //结构体大小 + public int dwRelativeTime; //相对时标 + public int dwAbsTime; //绝对时标 + public NET_VCA_DEV_INFO struDevInfo; //前端设备信息 + public short wPanPos; + public short wTiltPos; + public short wZoomPos; + public byte byPicTransType; //图片数据传输方式: 0-二进制;1-url + public byte byRes1; + public int dwPicDataLen; //报警抓拍图片长度 + public Pointer pBuffer; //数据指针 + public NET_VCA_RECT struRect; //火点框 + public NET_VCA_POINT struPoint; //火点框内最高温度点坐标 + public short wFireMaxTemperature; //火点最高温度[300℃~4000℃] + public short wTargetDistance; //目标距离[100m ~ 10000m] + public byte byStrategyType; //策略类型;0~任意报警,1~协同报警,2~多系统报警,3~指定火点报警,4~指定烟雾报警 + public byte byAlarmSubType; //报警子类型。0~火点检测报警,1~烟雾检测报警,2~烟火报警 + /*是否启用PTZ坐标扩展, + 0~不启用,PTZ坐标值以wPanPos、wTiltPos、wZoomPos为准。 + 1~启用,PTZ坐标值以struPtzPosEx为准。但是新老PTZ都需返回。struPtzPosEx的值需转化为wPanPos、wTiltPos、wZoomPos值。 + */ + public byte byPTZPosExEnable; + public byte byRes2; + public NET_PTZ_INFO struPtzPosEx; // ptz坐标扩展(支持高精度PTZ值,精确到小数点后三位) + public int dwVisiblePicLen; // 可见光图片长度 + public Pointer pVisiblePicBuf; // 可见光图片数据指针 + // pSmokeBuf参数当byAlarmSubType报警子类型为1(烟雾检测报警)、2(烟火报警)时生效。 + public Pointer pSmokeBuf; //烟雾检测报警数据指针,指向一个NET_DVR_SMOKEDETECTION_ALARM结构体 + public short wDevInfoIvmsChannelEx; //与NET_VCA_DEV_INFO里的byIvmsChannel含义相同,能表示更大的值。老客户端用byIvmsChannel能继续兼容,但是最大到255。新客户端版本请使用wDevInfoIvmsChannelEx。 + public byte byRes3; + public byte byFireScanWaitMode; //火点扫描等待模式 0-自动 1-手动 + public int dwVisibleChannel; //可见光通道通道号 + public byte byTimeDiffFlag; //时差字段是否有效 0-时差无效, 1-时差有效 + public char cTimeDifferenceH; //与UTC的时差(小时),-12 ... +14, +表示东区,,byTimeDiffFlag为1时有效 + public char cTimeDifferenceM; //与UTC的时差(分钟),-30, 30, 45, +表示东区,byTimeDiffFlag为1时有效 + public byte[] byRes = new byte[49]; + } + + //模块服务配置结构体 + public static class NET_DVR_DEVSERVER_CFG extends Structure { + public int dwSize; //结构体大小 + public byte byIrLampServer; //红外灯设置:0- 禁用,1- 启用 + public byte bytelnetServer; //telnet设置:0- 禁用,1- 启用 + public byte byABFServer; //ABF设置:0- 启用,1- 禁用,请注意此处参数取值0、1和其他参数取值含义不同 + public byte byEnableLEDStatus; //状态指示灯控制:0- 禁用,1- 启用 + public byte byEnableAutoDefog; //自动除雾控制:0- 启用,1- 禁用,请注意此处参数取值0、1和其他参数取值含义不同 + public byte byEnableSupplementLight; //补光灯控制:0- 启用,1- 禁用,请注意此处参数取值0、1和其他参数取值含义不同 + public byte byEnableDeicing; //除冰功能:0- 关闭,1- 开启 + public byte byEnableVisibleMovementPower; //可见光机芯电源开关(低功耗模式下有效):0- 关闭,1- 开启 + public byte byEnableThermalMovementPower; //热成像机芯电源开关(低功耗模式下有效):0- 关闭,1- 开启 + public byte byEnablePtzPower; //云台电源开关(低功耗模式下有效):0- 关闭,1- 开启 + public byte byPowerSavingControl; //低功耗策略:0- 保留,1- 休眠模式,2-低功耗模式(低功耗模式下,可见光机芯电源、热成像机芯电源、云台电源控制生效) + public byte byCaptureWithSupplimentLightEnabled; //启用抓拍补光使能 0-关闭,1-开启 + public byte[] byRes = new byte[244]; //保留,置为0 + } + + public static final int MAX_UPLOADFILE_URL_LEN = 240; + public static final int IMPORT_DATA_TO_FACELIB = 39; //导入人脸数据(人脸图片+图片附件信息 到设备人脸库) + + public static class NET_DVR_UPLOAD_FILE_RET extends Structure { + + public byte[] sUrl = new byte[MAX_UPLOADFILE_URL_LEN]; //url + public byte[] byRes = new byte[260]; + } + + public static class NET_DVR_FLOW_TEST_PARAM extends Structure { + public int dwSize; //结构大小 + public int lCardIndex; //网卡索引 + public int dwInterval; //设备上传流量时间间隔, 单位:100ms + public byte[] byRes = new byte[8]; //保留字节 + } + + public static class NET_DVR_RECORD_TIME_SPAN_INQUIRY extends Structure { + public int dwSize; //结构体大小 + public byte byType; //0 正常音视频录像, 1图片通道录像, 2ANR通道录像, 3抽帧通道录像 + public byte[] byRes = new byte[63]; + } + + public static class NET_DVR_RECORD_TIME_SPAN extends Structure { + public int dwSize; //结构体大小 + public NET_DVR_TIME strBeginTime; //开始时间 + public NET_DVR_TIME strEndTime; //结束时间 + public byte byType; //0 正常音视频录像, 1图片通道录像, 2ANR通道录像, 3抽帧通道录像 + public byte[] byRes = new byte[35]; //保留 + } + + /* + * 月历录像分布查询条件结构体 + */ + public static class NET_DVR_MRD_SEARCH_PARAM extends Structure { + public int dwSize; // 结构体大小 + public NET_DVR_STREAM_INFO struStreamInfo = new NET_DVR_STREAM_INFO(); // 布防点 + public short wYear; // 年 + public byte byMonth; // 月 + public byte byDrawFrame; // 0-不抽帧 1-抽帧 + public byte byStreamType; //0-主码流 1-子码流 + public byte byLocalOrUTC; //0-设备本地时区 1-UTC + public byte[] byRes = new byte[30]; + } + + /* + * 月历录像分布查询结果结构体 + */ + public static class NET_DVR_MRD_SEARCH_RESULT extends Structure { + + public int dwSize; // 结构体大小 + public byte[] byRecordDistribution = new byte[32]; // 录像分布,byRecordDistribution[0]=1表示1日存在录像,byRecordDistribution[0]=0表示没有录像,byRecordDistribution[1]表示2日,以此类推 + public byte[] byHasEventRecode = new byte[31]; //事件录像 0-无事件录像,1-有事件录像 + public byte byRes; //保留 + } + + public static final int NET_DVR_GET_GISINFO = 3711; + //GIS信息 + + public static class NET_DVR_GIS_INFO extends Structure { + public int dwSize; + public float fAzimuth; + public float fHorizontalValue; + public float fVerticalValue; + public float fVisibleRadius; + public float fMaxViewRadius; + public byte byLatitudeType; + public byte byLongitudeType; + public byte byPTZPosExEnable; + public byte byRes1; + public NET_DVR_LLI_PARAM struLatitude = new NET_DVR_LLI_PARAM(); + public NET_DVR_LLI_PARAM struLongitude = new NET_DVR_LLI_PARAM(); + public NET_DVR_PTZPOS_PARAM struPtzPos = new NET_DVR_PTZPOS_PARAM(); + public NET_DVR_SENSOR_PARAM struSensorParam = new NET_DVR_SENSOR_PARAM(); + public NET_PTZ_INFO struPtzPosEx = new NET_PTZ_INFO(); + public float fMinHorizontalValue; + public float fMaxHorizontalValue; + public float fMinVerticalValue; + public float fMaxVerticalValue; + public byte[] byRes = new byte[220]; + } + + //GBT28181协议的设备编码通道配置 + public static class NET_DVR_GBT28181_CHANINFO_CFG extends Structure { + public int dwSize; + public byte[] szVideoChannelNumID = new byte[64];//设备视频通道编码ID:64字节字符串,仅限数字 + public byte[] byRes = new byte[256]; + } + + // 巡航路径配置条件结构体 + public static class NET_DVR_CRUISEPOINT_COND extends Structure { + public int dwSize; + public int dwChan; + public short wRouteNo; + public byte[] byRes = new byte[30]; + } + + // 巡航路径配置结构体 + public static class NET_DVR_CRUISEPOINT_V40 extends Structure { + public int dwSize; + public NET_DVR_CRUISEPOINT_PARAM[] struCruisePoint = (NET_DVR_CRUISEPOINT_PARAM[]) new NET_DVR_CRUISEPOINT_PARAM().toArray(128); + public byte[] byRes = new byte[64]; + } + + // 巡航路径配置结构体 + public static class NET_DVR_CRUISEPOINT_V50 extends Structure { + public int dwSize; + public NET_DVR_CRUISEPOINT_PARAM[] struCruisePoint = (NET_DVR_CRUISEPOINT_PARAM[]) new NET_DVR_CRUISEPOINT_PARAM().toArray(256); + public byte[] byRes = new byte[64]; + } + + // 巡航点参数结构体 + public static class NET_DVR_CRUISEPOINT_PARAM extends Structure { + public short wPresetNo; + public short wDwell; + public byte bySpeed; + public byte bySupport256PresetNo; + public byte[] byRes = new byte[6]; + } + + //因为Java没有二维数组,BYTE_TWODIM是自定义的结构体 + public static class BYTE_TWODIM extends Structure { + public byte[] strIP = new byte[16]; + } + + //云台锁定配置结构体 + public static class NET_DVR_PTZ_LOCKCFG extends Structure { + public int dwSize;//结构体大小 + public byte byWorkMode ;//云台锁定控制:0- 解锁,1- 锁定 + public byte[] byRes = new byte[123]; + } +} + + +//播放库函数声明,PlayCtrl.dll +interface PlayCtrl extends Library { + public static final int STREAME_REALTIME = 0; + public static final int STREAME_FILE = 1; + + boolean PlayM4_GetPort(IntByReference nPort); + + boolean PlayM4_OpenStream(int nPort, Pointer pFileHeadBuf, int nSize, int nBufPoolSize); + + boolean PlayM4_InputData(int nPort, Pointer pBuf, int nSize); + + boolean PlayM4_CloseStream(int nPort); + + boolean PlayM4_SetStreamOpenMode(int nPort, int nMode); + + boolean PlayM4_Play(int nPort, HWND hWnd); + + boolean PlayM4_Stop(int nPort); + + boolean PlayM4_SetSecretKey(int nPort, int lKeyType, String pSecretKey, int lKeyLen); + + boolean PlayM4_GetPictureSize(int nPort, IntByReference pWidth, IntByReference pHeight); + + boolean PlayM4_GetJPEG(int nPort, Pointer pBitmap, int nBufSize, IntByReference pBmpSize); + + int PlayM4_GetLastError(int nPort); + + boolean PlayM4_SetDecCallBackExMend(int nPort, DecCallBack decCBFun, Pointer pDest, int nDestSize, int nUser); + + public static interface DecCallBack extends Callback { + void invoke(int nPort, Pointer pBuf, int nSize, FRAME_INFO pFrameInfo, int nReserved1, int nReserved2); + } + + public class FRAME_INFO extends Structure { + public int nWidth; /* 画面宽,单位像素。如果是音频数据,则为音频声道数 */ + public int nHeight; /* 画面高,单位像素。如果是音频数据,则为样位率 */ + public int nStamp; /* 时标信息,单位毫秒 */ + public int nType; /* 数据类型,T_AUDIO16, T_RGB32, T_YV12 */ + public int nFrameRate; /* 编码时产生的图像帧率,如果是音频数据则为采样率 */ + public int dwFrameNum; /* 帧号 */ + } + +} + +//windows gdi接口,gdi32.dll in system32 folder, 在设置遮挡区域,移动侦测区域等情况下使用 +interface GDI32 extends W32API { + GDI32 INSTANCE = (GDI32) Native.loadLibrary("gdi32", GDI32.class, DEFAULT_OPTIONS); + + public static final int TRANSPARENT = 1; + + int SetBkMode(HDC hdc, int i); + + HANDLE CreateSolidBrush(int icolor); +} + +//windows user32接口,user32.dll in system32 folder, 在设置遮挡区域,移动侦测区域等情况下使用 +interface USER32 extends W32API { + + USER32 INSTANCE = (USER32) Native.loadLibrary("user32", USER32.class, DEFAULT_OPTIONS); + + public static final int BF_LEFT = 0x0001; + public static final int BF_TOP = 0x0002; + public static final int BF_RIGHT = 0x0004; + public static final int BF_BOTTOM = 0x0008; + public static final int BDR_SUNKENOUTER = 0x0002; + public static final int BF_RECT = (BF_LEFT | BF_TOP | BF_RIGHT | BF_BOTTOM); + + boolean DrawEdge(HDC hdc, com.sun.jna.examples.win32.GDI32.RECT qrc, int edge, int grfFlags); + + int FillRect(HDC hDC, com.sun.jna.examples.win32.GDI32.RECT lprc, HANDLE hbr); +} + diff --git a/box-device/src/main/java/com/mathvision/box/device/service/BoxAlarmService.java b/box-device/src/main/java/com/mathvision/box/device/service/BoxAlarmService.java new file mode 100644 index 0000000..a72fc42 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/service/BoxAlarmService.java @@ -0,0 +1,236 @@ +package com.mathvision.box.device.service; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.mathvision.box.common.enums.DefectStatusEnum; +import com.mathvision.box.common.enums.DetectStatusEnum; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.dao.domain.entity.Defect; +import com.mathvision.box.dao.domain.entity.Detect; +import com.mathvision.box.dao.service.DefectService; +import com.mathvision.box.dao.service.DetectService; +import com.mathvision.box.device.common.dto.CoreainDefect; +import com.mathvision.box.device.common.enums.*; +import com.mathvision.box.device.config.BoxAlarmConfig; +import com.mathvision.box.device.core.factory.CorerainBox; +import com.mathvision.box.device.core.factory.DeviceAbstractFactory; +import com.mathvision.box.device.core.factory.IDevice; +import com.mathvision.box.device.core.factory.MockCamera; +import com.mathvision.box.device.core.strategy.AlarmStrategy; +import com.mathvision.box.device.utils.SDKUtil; +import com.mathvision.box.message.service.BoxMessageService; +import org.apache.commons.compress.utils.Lists; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +public class BoxAlarmService { + private static final Logger logger = LoggerFactory.getLogger(BoxAlarmService.class); + + @Resource + private DetectService detectService; + + @Resource + private DefectService defectService; + + @Resource + private BoxMessageService boxMessageService; + + @Resource + private BoxAlarmConfig alarmConfig; + + public void handle(List detectList) { + // 报警策略 + List filterDetect = alarmConfig.isFilterEnabled() ? filterDetect(detectList) : detectList; + // 获取报警结果(修正过程数据) + Map> fixDetect = detectService.fixDetect(filterDetect, alarmConfig.isFixProcess()); + List defectList = getDefect(fixDetect); + if (defectList == null || defectList.size() == 0) { + return; + } + defectService.saveOrUpdateBatchByProcess(defectList); + //实时推送 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("title", "defect"); + jsonObject.put("data", defectList); + Long deviceId = defectList.get(0).getDeviceId(); + //to do 消息订阅 + String[] target = new String[]{"all"}; + boxMessageService.sendWebSocket(deviceId, target, jsonObject.toJSONString()); + } + + @Scheduled(fixedRateString = "${box.corerain.trace}") + private void CoreaineTrace() { + DeviceAbstractFactory.getByVendor(DeviceVendor.CORERAIN_BOX).forEach(e -> { + CorerainBox corerainBox = (CorerainBox) e; + if (corerainBox == null) { + return; + } + String jobId = corerainBox.getJobId(); + CoreainDefect coreainDefect = corerainBox.getStepsByJobId(jobId); + boolean isFinished = coreainDefect.getIsFinished(); + if (isFinished) { + defectService.checkOilUnloadingComplete(coreainDefect.getProcessId()); + return; + } + List detectList = coreainDefect.getSteps().stream().map(step -> + Detect.builder().processId(coreainDefect.getProcessId()) + .detectId(coreainDefect.getProcessId() + "_" + step.getId() + "_" + step.getAlarmLevel()) + .time(step.getAlarmTime()) + .type(DetectType.toDesc(step.getId())) + .ip(corerainBox.params().get("ip").toString()) + .img("[{\"name\":\"" + DetectType.toDesc(step.getId()) + "\",\"url\":\"" + step.getPicUrl() + "\"}]") + .data("{}") + .status(DetectStatusEnum.getStatus(step.getAlarmLevel()).getCode()) + .build() + ).collect(Collectors.toList()); + handle(detectList); + }); + } + + @Scheduled(fixedRateString = "${box.alarm.mock-fixed-rate}") + private void MockCallBack() { + if (alarmConfig.isMockEnabled()) { + DeviceAbstractFactory.getByVendor(DeviceVendor.MOCK_CAMERA).forEach(e -> { + MockCamera mockCamera = (MockCamera) e; + if (mockCamera != null) { + handle(mockCamera.getDetect()); + } + }); + } + } + + /** + * 报警过滤策略 1. 报警类型 2. 报警次数 + */ + private List filterDetect(List detectList) { + return detectList.stream() + .filter(e -> alarmConfig.isTypeEnabled(e.getType())) + .filter(e -> AlarmStrategy.IsAlarm(AlarmStrategy.AlarmStrategyType.getType(alarmConfig.getFilterType()), e.getIp() + (e.getChannel() != null ? e.getChannel() : 0) + e.getType() + e.getStatus(), alarmConfig.getFilterCountThreshold(), alarmConfig.getFilterTimeThreshold()) + ).collect(Collectors.toList()); + } + + /** + * 获取报警结果信息 + */ + private List getDefect(Map> groupedDetects) { + List defectList = Lists.newArrayList(); + // 处理常规报警 + groupedDetects.getOrDefault("BLANK", Collections.emptyList()).forEach(item -> { + defectList.add(buildDefect(item)); + }); + + // 处理过程报警 + groupedDetects.forEach((processId, items) -> { + if (!"BLANK".equals(processId)) { + defectList.add(buildDefect(processId, groupedDetects.get(processId))); + } + }); + return defectList; + } + + /** + * 海康报警 + */ + private Defect buildDefect(Detect detect) { + Defect defect = new Defect(); + defect.setTime(detect.getTime()); + defect.setEndTime(detect.getTime()); + defect.setType(detect.getType()); + IDevice device = null; + if (detect.getIp() != null) { + device = DeviceAbstractFactory.getByParam("ip", detect.getIp()).stream().findFirst().orElse(null); + } + IDevice channelDevice = null; + if (device != null && detect.getChannel() != null && device.params().containsKey("id")) { + channelDevice = DeviceAbstractFactory.getByIdentity(SDKUtil.getChanelId(device.identity(), detect.getChannel().toString())); + } + defect.setIp(detect.getIp()); + defect.setDeviceId(device != null ? Long.valueOf(device.params().getOrDefault("id", 0L).toString()) : 0L); + defect.setDeviceName(device != null ? device.params().getOrDefault("name", "").toString() : ""); + defect.setChannel(detect.getChannel()); + defect.setChannelName(channelDevice != null ? channelDevice.params().getOrDefault("name", "").toString() : ""); + defect.setImg(detect.getImg()); + defect.setVideo(""); + defect.setStatus(DefectStatusEnum.unprocessed.getCode()); + + JSONObject originalData = JSONObject.parseObject(detect.getData()); + JSONObject newData = new JSONObject(); + if (DetectType.COMM_THERMOMETRY_ALARM.getDesc().equals(detect.getType())) { + Integer alarmLevel = originalData.getInteger("byAlarmLevel"); + HCNetThermometryAlarmType alarmType = HCNetThermometryAlarmType.get(originalData.getInteger("byAlarmType")); + newData.put("报警等级", alarmLevel == 0 ? "预警" : "报警"); + newData.put("报警类型", alarmType.getDesc()); + defect.setType(alarmType.getDefectType(alarmLevel).getDesc()); + String unit = HCNetThermometryUnit.get(originalData.getInteger("byThermometryUnit")).getDesc(); + newData.put("温度值", originalData.getBigDecimal("fCurrTemperature") + unit); + newData.put("报警阈值", originalData.getBigDecimal("fRuleTemperature") + unit); + } else if (DetectType.H930_MODEL_SPD.getDesc().equals(detect.getType())) { + JSONObject events = originalData.getJSONObject("events"); + if (events != null) { + JSONArray alertInfo = events.getJSONArray("alertInfo"); + if (alertInfo != null && !alertInfo.isEmpty()) { + JSONObject firstAlert = alertInfo.getJSONObject(0); + if (firstAlert != null) { + JSONObject ruleInfo = firstAlert.getJSONObject("ruleInfo"); + if (ruleInfo != null) { + newData.put("规则名称", ruleInfo.getString("ruleName")); + defect.setType(ruleInfo.getString("ruleName")); + } + } + } + } + } else { + newData.putAll(originalData); + } + defect.setData(newData.toJSONString()); + return defect; + } + + /** + * 鲲云报警 + */ + private Defect buildDefect(String processId, List detectList) { + if (detectList == null || detectList.isEmpty()) { + return null; + } + Defect defect = new Defect(); + defect.setProcessId(processId); + // 初次报警时间记录 + defect.setTime(DateUtils.getNowDate()); + defect.setType(DefectType.OIL_UNLOADING.getDesc()); + IDevice device = null; + String boxIp = detectList.get(0).getIp(); + if (boxIp != null) { + device = DeviceAbstractFactory.getByParam("ip", boxIp).stream().findFirst().orElse(null); + } + defect.setDeviceId(device != null ? Long.valueOf(device.params().getOrDefault("id", 0L).toString()) : 0L); + defect.setDeviceName(device != null ? device.params().getOrDefault("name", "").toString() : ""); + defect.setIp(boxIp); + defect.setPointIds(device != null ? (List) device.params().get("pointIds") : Lists.newArrayList()); + JSONArray imgJsonArray = new JSONArray(); + JSONArray dataJsonArray = new JSONArray(); + detectList.forEach(e -> { + imgJsonArray.addAll(JSONArray.parseArray(e.getImg())); + JSONObject dataJson = new JSONObject(); + dataJson.put("time", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, e.getTime())); + dataJson.put("type", e.getType()); + dataJson.put("img", JSONObject.parseArray(e.getImg()).getJSONObject(0).get("img")); + dataJson.put("status", e.getStatus()); + dataJsonArray.add(dataJson); + }); + defect.setImg(imgJsonArray.toJSONString()); + defect.setData(dataJsonArray.toJSONString()); + defect.setStatus(DefectStatusEnum.unfinished.getCode()); + return defect; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/service/BoxDeviceService.java b/box-device/src/main/java/com/mathvision/box/device/service/BoxDeviceService.java new file mode 100644 index 0000000..818017f --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/service/BoxDeviceService.java @@ -0,0 +1,282 @@ +package com.mathvision.box.device.service; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.mathvision.box.common.enums.DeviceStatus; +import com.mathvision.box.common.exception.box.BoxException; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.dao.domain.dto.DeviceAddDto; +import com.mathvision.box.dao.domain.dto.DeviceQueryDto; +import com.mathvision.box.dao.domain.entity.Device; +import com.mathvision.box.dao.domain.entity.PointDevice; +import com.mathvision.box.dao.mapper.PointDeviceMapper; +import com.mathvision.box.dao.service.DeviceService; +import com.mathvision.box.device.common.domin.SignIn; +import com.mathvision.box.device.common.enums.DeviceType; +import com.mathvision.box.device.common.enums.DeviceVendor; +import com.mathvision.box.device.core.factory.*; +import com.mathvision.box.device.sdk.HCNetSDK; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +@Service +public class BoxDeviceService { + private static final Logger logger = LoggerFactory.getLogger(BoxDeviceService.class); + + @Resource + private DeviceService deviceService; + + @Resource + private PointDeviceMapper pointDeviceMapper; + + @Autowired(required = false) + private HCNetSDK hcNetSDK; + + @PostConstruct + @Scheduled(cron = "0 0 0/6 * * *") + private void init() { + deviceService.list().forEach(d -> { + try { + initDevice(d); + } catch (Exception e) { + logger.error("初始化设备失败: [{}]", d.getName(), e); + } + }); + } + +// //@Autowired 关闭时会报错需更换为@Resource +// @PreDestroy +// private void destroy() { +// if (hcNetSDK != null) { +// hcNetSDK.NET_DVR_Cleanup(); +// } +// } + + public List query(DeviceQueryDto deviceDto) { + List list = deviceService.selectPages(deviceDto); + realTimeStatus(list); + return list; + } + + public List quarryTree(Long pointId) { + List list = Lists.newArrayList(); + if (pointId == null || pointId <= 0) { + list.addAll(deviceService.list()); + } else { + list.addAll(deviceService.quarryTree(pointId)); + } + realTimeStatus(list); + return list; + } + + public Device getById(Long id) { + Device d = deviceService.getById(id); + Assert.notNull(d, "设备不存在"); + realTimeStatus(d); + return d; + } + + public List getChild(Long id) { + Device d = deviceService.getById(id); + Assert.notNull(d, "设备不存在"); + DeviceVendor vendor = DeviceVendor.getVendor(d.getVendor(), d.getType()); + Assert.isTrue(vendor != null && DeviceType.box.equals(vendor.getType()), "设备类型错误,请选择边缘计算盒子"); + IDevice device = DeviceAbstractFactory.getByIdentity(d.getDeviceId()); + Assert.notNull(device, "设备未缓存"); + Assert.isTrue(device instanceof IBox, "设备类型错误,请选择边缘计算盒子"); + IBox box = (IBox) device; + return box.getChild(); + } + + public boolean save(DeviceAddDto deviceDto) throws Exception { + Assert.isTrue(checkDeviceNameUnique(null, deviceDto.getName()), "设备名称已存在"); + Assert.isTrue(checkDeviceIdUnique(null, deviceDto.getDeviceId()), "设备编号已存在"); + Device d = new Device(); + BeanUtils.copyProperties(deviceDto, d); + JSONObject config = new JSONObject(); + config.put("ip", deviceDto.getIp()); + config.put("port", deviceDto.getPort()); + config.put("username", deviceDto.getUsername()); + config.put("password", deviceDto.getPassword()); + /** + * 1、parentId为0时,正常创建 + * 2、parentId不为0时,调用盒子API创建子设备(暂未开发),子设备类型为surveillance_camera或network_sound_column + */ + if (deviceDto.getParentId() == 0) { + d.setConfig(config.toJSONString()); + if (!initDevice(d)) { + return false; + } + deviceService.save(d); + if (deviceDto.getPoints() != null && deviceDto.getPoints().size() > 0){ + deviceDto.getPoints().forEach(p -> pointDeviceMapper.insert(PointDevice.builder().pointId(p).deviceId(d.getId()).build())); + } + } else { + Device parent = deviceService.getById(deviceDto.getParentId()); + Assert.notNull(parent, "上级设备不存在"); + Assert.isTrue(deviceDto.getType().equals(DeviceType.surveillance_camera.name()) || deviceDto.getType().equals(DeviceType.network_sound_column.name()), "设备类型错误,请选择监控摄像头或网络音响"); + d.setConfig(config.toJSONString()); + if (!initDevice(d)) { + return false; + } + deviceService.save(d); + } + return true; + } + + public boolean update(DeviceAddDto deviceDto) throws Exception { + Assert.isTrue(checkDeviceNameUnique(deviceDto.getId(), deviceDto.getName()), "设备名称已存在"); + Assert.isTrue(checkDeviceIdUnique(deviceDto.getId(), deviceDto.getDeviceId()), "设备编号已存在"); + Device d = new Device(); + BeanUtils.copyProperties(deviceDto, d); + JSONObject config = new JSONObject(); + config.put("ip", deviceDto.getIp()); + config.put("port", deviceDto.getPort()); + config.put("username", deviceDto.getUsername()); + config.put("password", deviceDto.getPassword()); + d.setConfig(config.toJSONString()); + if (!initDevice(d)) { + return false; + } + deviceService.updateById(d); + pointDeviceMapper.delete(new QueryWrapper().eq("device_id", d.getId())); + deviceDto.getPoints().forEach(p -> pointDeviceMapper.insert(PointDevice.builder().pointId(p).deviceId(d.getId()).build())); + return true; + } + + public boolean delete(List idList) { + pointDeviceMapper.delete(new QueryWrapper().in("device_id", idList)); + deviceService.removeBatchByIds(idList); + return true; + } + + private boolean initDevice(Device d) throws Exception { + IDevice device = createDevice(d); + if (device == null) { + logger.error("创建设备实例失败: [{}]", d.getName()); + return false; + } + JSONObject config = buildDeviceConfig(d); + device.config(config); + return device.close(config) && device.open(config); + } + + /** + * 创建设备实例(含海康SDK检查) + */ + private IDevice createDevice(Device d) throws Exception { + IDevice Idevice = DeviceAbstractFactory.getByIdentity(d.getDeviceId()); + if (Idevice != null) { + return Idevice; + } + DeviceVendor vendor = DeviceVendor.getVendor(d.getVendor(), d.getType()); + if (vendor == null) { + throw new BoxException("不支持的厂商{" + d.getVendor() + "}设备类型{" + d.getType() + "}"); + } + // 海康设备需检查SDK状态 + if (DeviceVendor.HIKVISION_BOX.equals(vendor)) { + if (hcNetSDK == null) { + throw new BoxException("海康设备[" + d.getName() + "]加载失败: SDK未启用"); + } + HikvisionBox device = (HikvisionBox) vendor.getClazz().getDeclaredConstructor(String.class).newInstance(d.getDeviceId()); + device.init(hcNetSDK); // SDK注入 + return device; + }else if (DeviceVendor.HIKVISION_CAMERA.equals(vendor)) { + if (hcNetSDK == null) { + throw new BoxException("海康设备[" + d.getName() + "]加载失败: SDK未启用"); + } + HikvisionCamera device = (HikvisionCamera) vendor.getClazz().getDeclaredConstructor(String.class).newInstance(d.getDeviceId()); + device.init(hcNetSDK); // SDK注入 + return device; + } + // 其他厂商设备直接创建 + return vendor.getClazz().getDeclaredConstructor(String.class).newInstance(d.getDeviceId()); + } + + /** + * 构建带基础信息的设备配置 + */ + private JSONObject buildDeviceConfig(Device d) { + JSONObject config = Optional.ofNullable(d.getConfig()) + .map(JSON::parseObject) + .orElseGet(JSONObject::new); + config.put("id", d.getId()); + config.put("device_id", d.getDeviceId()); + config.put("parent_id", d.getParentId()); + config.put("name", d.getName()); + config.put("pointIds", d.getPointIds()); + return config; + } + + /** + * 定时心跳 + */ + @Scheduled(fixedRateString = "${box.heartbeat}") + private void heartbeat() { + Map temperatureMap = Maps.newHashMap(); + DeviceAbstractFactory.getByVendor(null).parallelStream().forEach(e -> { + e.heartbeat(); + if (e instanceof ICamera){ + ICamera camera = (ICamera) e; + //双光相机ip相同处理 + String ip = camera.params().get("ip").toString(); + if(StringUtils.isBlank(ip)){ + return; + } + if (temperatureMap.containsKey(ip)){ + camera.setTemperature(temperatureMap.get(ip)); + } else { + camera.setTemperature(null); + temperatureMap.put(ip,camera.getTemperature()); + } + } + }); + } + + private void realTimeStatus(List list) { + list.forEach(d -> realTimeStatus(d)); + } + + private void realTimeStatus(Device d) { + IDevice device = DeviceAbstractFactory.getByIdentity(d.getDeviceId()); + if (device != null) { + d.setStatus(device.status()); + if (device instanceof ICamera){ + ICamera camera = (ICamera) device; + d.setTemperature(camera.getTemperature()); + } + } else { + d.setStatus(DeviceStatus.error); + } + } + + /** + * 校验设备ID是否唯一 + */ + public boolean checkDeviceIdUnique(Long id, String deviceId) { + List list = deviceService.list(new QueryWrapper().eq("device_id", deviceId)); + return list.isEmpty() || (id != null && list.size() == 1 && list.get(0).getDeviceId().equals(deviceId)); + } + + /** + * 校验设备名称是否唯一 + */ + public boolean checkDeviceNameUnique(Long id, String name) { + List list = deviceService.list(new QueryWrapper().eq("name", name)); + return list.isEmpty() || (id != null && list.size() == 1 && list.get(0).getName().equals(name)); + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/service/BoxVideoService.java b/box-device/src/main/java/com/mathvision/box/device/service/BoxVideoService.java new file mode 100644 index 0000000..372bc2a --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/service/BoxVideoService.java @@ -0,0 +1,27 @@ +package com.mathvision.box.device.service; + +import com.mathvision.box.dao.domain.entity.Device; +import com.mathvision.box.dao.service.DeviceService; +import com.mathvision.box.device.common.domin.PlayBack; +import com.mathvision.box.device.core.factory.DeviceAbstractFactory; +import com.mathvision.box.device.core.factory.IDevice; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class BoxVideoService { + private static final Logger logger = LoggerFactory.getLogger(BoxVideoService.class); + + @Resource + private DeviceService deviceService; + + public String getVideoUrl(PlayBack playBack){ +// Device device = deviceService.getById(playBack.getId()); +// IDevice d = DeviceAbstractFactory.getByIdentity(device.getDeviceId()); +// return d.getVideoUrl(playBack); + return null; + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/utils/DataUtil.java b/box-device/src/main/java/com/mathvision/box/device/utils/DataUtil.java new file mode 100644 index 0000000..a7aff47 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/utils/DataUtil.java @@ -0,0 +1,67 @@ +package com.mathvision.box.device.utils; + +import com.mathvision.box.device.common.domin.NvrTime; +import com.mathvision.box.device.sdk.HCNetSDK; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class DataUtil { + public NvrTime dateToNum(Date date) { + NvrTime nvrTime = new NvrTime(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (date == null) { + date = new Date(); + } + String time = format.format(date); + nvrTime.setDwYear(Integer.parseInt(time.substring(0, 4))); + nvrTime.setDwMonth(Integer.parseInt(time.substring(5, 7))); + nvrTime.setDwDay(Integer.parseInt(time.substring(8, 10))); + nvrTime.setDwHour(Integer.parseInt(time.substring(11, 13))); + nvrTime.setDwMinute(Integer.parseInt(time.substring(14, 16))); + nvrTime.setDwSecond(Integer.parseInt(time.substring(17, 19))); + return nvrTime; + } + + + /** + * 获取海康录像机格式的时间 + * + * @param time + * @return + */ + public static HCNetSDK.NET_DVR_TIME getHkTime(Date time) { + HCNetSDK.NET_DVR_TIME structTime = new HCNetSDK.NET_DVR_TIME(); + String str = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(time); + String[] times = str.split("-"); + structTime.dwYear = Integer.parseInt(times[0]); + structTime.dwMonth = Integer.parseInt(times[1]); + structTime.dwDay = Integer.parseInt(times[2]); + structTime.dwHour = Integer.parseInt(times[3]); + structTime.dwMinute = Integer.parseInt(times[4]); + structTime.dwSecond = Integer.parseInt(times[5]); + return structTime; + } + + /** + * 组装视频流回放时间格式 + * @param date + * @return + */ + public static String backTimeAssemble(Date date) { + String str = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date); + StringBuffer buffer = new StringBuffer(); + buffer.append(str.substring(0,4)); + buffer.append(str.substring(5,7)); + buffer.append(str.substring(8,10)); + buffer.append("T"); + buffer.append(str.substring(11,13)); + buffer.append(str.substring(14,16)); + buffer.append(str.substring(17,19)); + buffer.append("Z"); + return buffer.toString(); + } + + +} diff --git a/box-device/src/main/java/com/mathvision/box/device/utils/ISAPIUtils.java b/box-device/src/main/java/com/mathvision/box/device/utils/ISAPIUtils.java new file mode 100644 index 0000000..40a8e9c --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/utils/ISAPIUtils.java @@ -0,0 +1,157 @@ +package com.mathvision.box.device.utils; + +import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; +import okhttp3.*; +import org.apache.commons.codec.digest.DigestUtils; + +import java.io.IOException; +import java.util.Map; + +@Slf4j +public class ISAPIUtils { + private static final boolean HTTPS = false; + + /** + * 海康ISAPI接口协议 GET 请求 + * + * @param url 地址 + * @param username Digest Auth Username + * @param password Digest Auth password + * @return XML结果 + */ + public static String ISAPI_GET(String url, String username, String password) { + return ISAPI_Request("GET", url, username, password, null); + } + + /** + * 海康ISAPI接口协议 PUT 请求 + * + * @param url 地址 + * @param username Digest Auth Username + * @param password Digest Auth password + * @param xml Request Body + * @return XML结果 + */ + public static String ISAPI_PUT(String url, String username, String password, String xml) { + return ISAPI_Request("PUT", url, username, password, xml); + } + + /** + * 海康ISAPI接口协议 POST 请求 + * + * @param url 地址 + * @param username Digest Auth Username + * @param password Digest Auth password + * @param xml Request Body + * @return XML结果 + */ + public static String ISAPI_POST(String url, String username, String password, String xml) { + return ISAPI_Request("POST", url, username, password, xml); + } + + /** + * 海康ISAPI接口协议 DELETE 请求 + * + * @param url 地址 + * @param username Digest Auth Username + * @param password Digest Auth password + * @return XML结果 + */ + public static String ISAPI_DELETE(String url, String username, String password) { + return ISAPI_Request("DELETE", url, username, password, null); + } + + /** + * 获取当前设备加载的模型包的label description信息 + * GET /ISAPI/Intelligent/AIOpenPlatform/algorithmModel/management?format=json + */ + public static String ISAPI_Intelligent_AIOpenPlatform_algorithmModel_management(String HOST, String PORT, String USERNAME, String PASSWORD) { + String url = HTTPS ? "https://" + HOST + ":" + PORT + "/ISAPI/Intelligent/AIOpenPlatform/algorithmModel/management?format=json" + : "http://" + HOST + ":" + PORT + "/ISAPI/Intelligent/AIOpenPlatform/algorithmModel/management?format=json"; + return ISAPI_GET(url, USERNAME, PASSWORD); + } + + /** + * 发送海康ISAPI请求 + * + * @param method 请求方法 + * @param url 地址 + * @param username Digest Auth Username + * @param password Digest Auth password + * @param xml 请求Body + * @return 请求结果 + */ + private static String ISAPI_Request(String method, String url, String username, String password, String xml) { + OkHttpClient client = new OkHttpClient(); + + RequestBody body = xml != null ? RequestBody.Companion.create(xml, MediaType.Companion.parse("application/xml")) : null; + + Request request = new Request.Builder() + .url(url) + .method(method, body) + .build(); + + try (Response firstResponse = client.newCall(request).execute()) { + if (firstResponse.code() == 401) { + String authHeader = firstResponse.header("WWW-Authenticate"); + if (authHeader != null && authHeader.startsWith("Digest")) { + String realm = getHeaderValue(authHeader, "realm"); + String nonce = getHeaderValue(authHeader, "nonce"); + String qop = getHeaderValue(authHeader, "qop"); + String opaque = getHeaderValue(authHeader, "opaque"); + String algorithm = getHeaderValue(authHeader, "algorithm"); + + // Generate Digest Auth credentials + String ha1 = DigestUtils.md5Hex(username + ":" + realm + ":" + password); + String ha2 = DigestUtils.md5Hex(method + ":" + url); + String nc = "00000001"; + String cnonce = DigestUtils.md5Hex(String.valueOf(System.currentTimeMillis())); + String responseDigest = DigestUtils.md5Hex(ha1 + ":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" + ha2); + + String authorization = String.format( + "Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", qop=%s, nc=%s, cnonce=\"%s\", response=\"%s\", opaque=\"%s\", algorithm=\"%s\"", + username, realm, nonce, url, qop, nc, cnonce, responseDigest, opaque, algorithm + ); + + // Retry with Digest Auth + Request digestRequest = new Request.Builder() + .url(url) + .method(method, body) + .header("Authorization", authorization) + .build(); + + try (Response secondResponse = client.newCall(digestRequest).execute()) { + return secondResponse.body().string(); + } + } + } else { + // Handle other status codes (e.g., 200) + return firstResponse.body().string(); + } + } catch (IOException e) { + log.error("ISAPI 接口协议报错: " + e.getMessage()); + } + return null; + } + + /** + * Helper function to parse the value from the WWW-Authenticate header + * + * @param header The WWW-Authenticate header + * @param key The key to extract + * @return The extracted value + */ + private static String getHeaderValue(String header, String key) { + int keyIndex = header.indexOf(key + "="); + if (keyIndex == -1) { + return null; + } + int start = keyIndex + key.length() + 1; + int end = header.indexOf(",", start); + if (end == -1) { + end = header.length(); + } + return header.substring(start, end).replace("\"", ""); + } +} diff --git a/box-device/src/main/java/com/mathvision/box/device/utils/SDKUtil.java b/box-device/src/main/java/com/mathvision/box/device/utils/SDKUtil.java new file mode 100644 index 0000000..50c6ca8 --- /dev/null +++ b/box-device/src/main/java/com/mathvision/box/device/utils/SDKUtil.java @@ -0,0 +1,139 @@ +package com.mathvision.box.device.utils; + +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.common.OSUtils; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.file.FileUtils; +import com.mathvision.box.common.utils.http.HttpUtil; +import com.mathvision.box.device.common.domin.SignIn; +import com.mathvision.box.device.exception.HCNetSDKException; +import com.mathvision.box.device.sdk.HCNetSDK; +import lombok.extern.slf4j.Slf4j; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URLDecoder; +import java.nio.file.Files; +import java.nio.file.Paths; + +@Slf4j +public class SDKUtil { + + private static final String NATIVE_HK_WINDOWS_DIR = "native\\hikvision\\win64\\"; + private static final String NATIVE_HK_LINUX_DIR = "native/hikvision/linux64/"; + private static final String profile = "/alarm"; + private static final String file_url = "/file"; + + /** + * 获取海康动态链接库文件路径 + * + * @return + */ + private static String getHKNetSDKPath() { + String path = SDKUtil.class.getClassLoader().getResource("").getPath(); + try { + // 中英文路径解码 + return URLDecoder.decode(path.replaceAll("%20", " "), "UTF-8").substring(1); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("路径解码失败", e); + } + } + + public static String getHKNetSDK() { + String path = getHKNetSDKPath(); + return OSUtils.isWindows() ? path + NATIVE_HK_WINDOWS_DIR + "HCNetSDK.dll" : path + NATIVE_HK_LINUX_DIR + "libhcnetsdk.so"; + } + + public static String getHKPlayCtrl() { + String path = getHKNetSDKPath(); + return OSUtils.isWindows() ? path + NATIVE_HK_WINDOWS_DIR + "PlayCtrl.dll" : path + NATIVE_HK_LINUX_DIR + "libPlayCtrl.so"; + } + + public static String checkImg(String ip, String port, String url) { + String filePath; + if (url.startsWith("/usm/download?")) { + filePath = AppConfig.getProfile() + profile + url.replace("/usm/download?filename=", "/"); + } else if (url.startsWith("/dw")) { + filePath = AppConfig.getProfile() + profile + url; + } else { + filePath = AppConfig.getProfile() + profile + url; + } + String urlStr = "http://" + ip + ":" + port + url; + if (!FileUtils.isExist(filePath)) { + HttpUtil.downloadImage(urlStr, filePath); + } + return ToFrontFileUrl(filePath); + } + + /** + * 文件路径转换 + * + * @param ulr 后端完整文件路径 + * @return 前端访问文件路径 + */ + public static String ToFrontFileUrl(String ulr) { + if (StringUtils.isNotBlank(ulr)) { + return StringUtils.replace(ulr, AppConfig.getProfile(), file_url); + } + return null; + } + + /** + * 海康SDK时间解析 + * + * @param time + * @return + */ + public static String parseTime(int time) { + int year = (time >> 26) + 2000; + int month = (time >> 22) & 15; + int day = (time >> 17) & 31; + int hour = (time >> 12) & 31; + int min = (time >> 6) & 63; + int second = (time >> 0) & 63; + String sTime = year + "-" + month + "-" + day + "-" + hour + ":" + min + ":" + second; + return sTime; + } + + public static String parseTime(HCNetSDK.NET_DVR_SYSTEM_TIME struTime) { + return String.format("%04d", struTime.wYear) + "-" + + String.format("%02d", struTime.wMonth) + "-" + + String.format("%02d", struTime.wDay) + "T" + + String.format("%02d", struTime.wHour) + ":" + + String.format("%02d", struTime.wMinute) + ":" + + String.format("%02d", struTime.wSecond) + "." + + String.format("%03d", struTime.wMilliSec) + "Z"; + } + + /** + * SDK路径校验 + */ + public static void validatePath(String path) throws HCNetSDKException { + if (!Files.exists(Paths.get(path))) { + throw new HCNetSDKException("动态库路径不存在", path); + } + } + + public static SignIn parseRTSPUrl(String rtspUrl) throws URISyntaxException { + SignIn signIn = new SignIn(); + URI uri = new URI(rtspUrl); + // 提取用户名和密码 + String userInfo = uri.getUserInfo(); + if (userInfo != null) { + String[] credentials = userInfo.split(":"); + signIn.setName(credentials[0]); + signIn.setPassword(credentials.length > 1 ? credentials[1] : ""); + } + + // 提取IP地址和端口 + signIn.setIp(uri.getHost()); + signIn.setPort(uri.getPort() == -1 ? 554 : uri.getPort()); + return signIn; + } + + public static String getChanelId(String parentId, String channel) { + return parentId + "_" + channel; + } +} diff --git a/box-device/src/main/resources/lib/examples.jar b/box-device/src/main/resources/lib/examples.jar new file mode 100644 index 0000000..8f0b457 Binary files /dev/null and b/box-device/src/main/resources/lib/examples.jar differ diff --git a/box-device/src/main/resources/lib/jna.jar b/box-device/src/main/resources/lib/jna.jar new file mode 100644 index 0000000..33461ec Binary files /dev/null and b/box-device/src/main/resources/lib/jna.jar differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libAudioIntercom.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libAudioIntercom.so new file mode 100644 index 0000000..49685d9 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libAudioIntercom.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCAlarm.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCAlarm.so new file mode 100644 index 0000000..a54dee3 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCAlarm.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCCoreDevCfg.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCCoreDevCfg.so new file mode 100644 index 0000000..5ada40f Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCCoreDevCfg.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCDisplay.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCDisplay.so new file mode 100644 index 0000000..9871c9e Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCDisplay.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCGeneralCfgMgr.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCGeneralCfgMgr.so new file mode 100644 index 0000000..7666233 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCGeneralCfgMgr.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCIndustry.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCIndustry.so new file mode 100644 index 0000000..4b11107 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCIndustry.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCPlayBack.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCPlayBack.so new file mode 100644 index 0000000..6137552 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCPlayBack.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCPreview.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCPreview.so new file mode 100644 index 0000000..035cd3d Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCPreview.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCVoiceTalk.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCVoiceTalk.so new file mode 100644 index 0000000..6a2ab90 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libHCVoiceTalk.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libStreamTransClient.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libStreamTransClient.so new file mode 100644 index 0000000..6b16337 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libStreamTransClient.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libSystemTransform.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libSystemTransform.so new file mode 100644 index 0000000..086c631 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libSystemTransform.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libanalyzedata.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libanalyzedata.so new file mode 100644 index 0000000..fa416e9 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libanalyzedata.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libiconv2.so b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libiconv2.so new file mode 100644 index 0000000..d17b0a8 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDKCom/libiconv2.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/HCNetSDK_Log_Switch.xml b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDK_Log_Switch.xml new file mode 100644 index 0000000..8b7e236 --- /dev/null +++ b/box-device/src/main/resources/native/hikvision/linux64/HCNetSDK_Log_Switch.xml @@ -0,0 +1,12 @@ + + + + 3 + ./SDKLOG/ + true + + + 120 + 1 + + \ No newline at end of file diff --git a/box-device/src/main/resources/native/hikvision/linux64/libAudioRender.so b/box-device/src/main/resources/native/hikvision/linux64/libAudioRender.so new file mode 100644 index 0000000..f39a4a1 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/libAudioRender.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/libHCCore.so b/box-device/src/main/resources/native/hikvision/linux64/libHCCore.so new file mode 100644 index 0000000..7846902 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/libHCCore.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/libNPQos.so b/box-device/src/main/resources/native/hikvision/linux64/libNPQos.so new file mode 100644 index 0000000..4972715 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/libNPQos.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/libPlayCtrl.so b/box-device/src/main/resources/native/hikvision/linux64/libPlayCtrl.so new file mode 100644 index 0000000..e255c22 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/libPlayCtrl.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/libSuperRender.so b/box-device/src/main/resources/native/hikvision/linux64/libSuperRender.so new file mode 100644 index 0000000..3f36846 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/libSuperRender.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/libcrypto.so.1.1 b/box-device/src/main/resources/native/hikvision/linux64/libcrypto.so.1.1 new file mode 100644 index 0000000..88c3746 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/libcrypto.so.1.1 differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/libhcnetsdk.so b/box-device/src/main/resources/native/hikvision/linux64/libhcnetsdk.so new file mode 100644 index 0000000..2607cee Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/libhcnetsdk.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/libhpr.so b/box-device/src/main/resources/native/hikvision/linux64/libhpr.so new file mode 100644 index 0000000..8efcabb Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/libhpr.so differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/libopenal.so.1 b/box-device/src/main/resources/native/hikvision/linux64/libopenal.so.1 new file mode 100644 index 0000000..a9dcb82 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/libopenal.so.1 differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/libssl.so.1.1 b/box-device/src/main/resources/native/hikvision/linux64/libssl.so.1.1 new file mode 100644 index 0000000..f3e4481 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/libssl.so.1.1 differ diff --git a/box-device/src/main/resources/native/hikvision/linux64/libz.so b/box-device/src/main/resources/native/hikvision/linux64/libz.so new file mode 100644 index 0000000..13b4ed9 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/linux64/libz.so differ diff --git a/box-device/src/main/resources/native/hikvision/win64/AudioRender.dll b/box-device/src/main/resources/native/hikvision/win64/AudioRender.dll new file mode 100644 index 0000000..4935684 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/AudioRender.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/ClientDemo.exe b/box-device/src/main/resources/native/hikvision/win64/ClientDemo.exe new file mode 100644 index 0000000..75aedfa Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/ClientDemo.exe differ diff --git a/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/ReadMe.txt b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/ReadMe.txt new file mode 100644 index 0000000..8006f36 --- /dev/null +++ b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/ReadMe.txt @@ -0,0 +1 @@ +The dll in this directoryiconv.dll,libxml2.dll,zlib1.dll,calib.dllonly used in ClientDemo. \ No newline at end of file diff --git a/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/calib.dll b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/calib.dll new file mode 100644 index 0000000..328c63e Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/calib.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/iconv.dll b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/iconv.dll new file mode 100644 index 0000000..df71882 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/iconv.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/libcrypto-1_1-x64.dll b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/libcrypto-1_1-x64.dll new file mode 100644 index 0000000..f2f96d7 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/libcrypto-1_1-x64.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/libssl-1_1-x64.dll b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/libssl-1_1-x64.dll new file mode 100644 index 0000000..8034d79 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/libssl-1_1-x64.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/libxml2.dll b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/libxml2.dll new file mode 100644 index 0000000..c8d57f3 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/libxml2.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/zlib1.dll b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/zlib1.dll new file mode 100644 index 0000000..82913fb Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/ClientDemoDll/zlib1.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/DemoLocalCfg.json b/box-device/src/main/resources/native/hikvision/win64/DemoLocalCfg.json new file mode 100644 index 0000000..e69de29 diff --git a/box-device/src/main/resources/native/hikvision/win64/DeviceCfg.json b/box-device/src/main/resources/native/hikvision/win64/DeviceCfg.json new file mode 100644 index 0000000..e69de29 diff --git a/box-device/src/main/resources/native/hikvision/win64/GdiPlus.dll b/box-device/src/main/resources/native/hikvision/win64/GdiPlus.dll new file mode 100644 index 0000000..b759ed6 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/GdiPlus.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/GdiPlus.lib b/box-device/src/main/resources/native/hikvision/win64/GdiPlus.lib new file mode 100644 index 0000000..6fb1bb6 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/GdiPlus.lib differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCCore.dll b/box-device/src/main/resources/native/hikvision/win64/HCCore.dll new file mode 100644 index 0000000..48f8411 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCCore.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCCore.lib b/box-device/src/main/resources/native/hikvision/win64/HCCore.lib new file mode 100644 index 0000000..495c74a Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCCore.lib differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDK.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDK.dll new file mode 100644 index 0000000..2ed412e Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDK.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDK.lib b/box-device/src/main/resources/native/hikvision/win64/HCNetSDK.lib new file mode 100644 index 0000000..ff8e9e2 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDK.lib differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/AnalyzeData.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/AnalyzeData.dll new file mode 100644 index 0000000..2317b39 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/AnalyzeData.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/AudioIntercom.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/AudioIntercom.dll new file mode 100644 index 0000000..071a5e2 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/AudioIntercom.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/AudioRender.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/AudioRender.dll new file mode 100644 index 0000000..4935684 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/AudioRender.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCAlarm.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCAlarm.dll new file mode 100644 index 0000000..bdb8406 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCAlarm.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCAlarm.lib b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCAlarm.lib new file mode 100644 index 0000000..0aa0d4c Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCAlarm.lib differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCCoreDevCfg.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCCoreDevCfg.dll new file mode 100644 index 0000000..7cd924e Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCCoreDevCfg.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCDisplay.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCDisplay.dll new file mode 100644 index 0000000..f0a2b7c Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCDisplay.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCGeneralCfgMgr.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCGeneralCfgMgr.dll new file mode 100644 index 0000000..3719694 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCGeneralCfgMgr.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCGeneralCfgMgr.lib b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCGeneralCfgMgr.lib new file mode 100644 index 0000000..7091c25 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCGeneralCfgMgr.lib differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCIndustry.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCIndustry.dll new file mode 100644 index 0000000..9af77a1 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCIndustry.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCPlayBack.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCPlayBack.dll new file mode 100644 index 0000000..8d8e8a7 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCPlayBack.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCPreview.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCPreview.dll new file mode 100644 index 0000000..005656d Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCPreview.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCPreview.lib b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCPreview.lib new file mode 100644 index 0000000..18d4d63 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCPreview.lib differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCVoiceTalk.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCVoiceTalk.dll new file mode 100644 index 0000000..eb04a1e Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/HCVoiceTalk.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/OpenAL32.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/OpenAL32.dll new file mode 100644 index 0000000..4b35df4 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/OpenAL32.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/StreamTransClient.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/StreamTransClient.dll new file mode 100644 index 0000000..a69e9bf Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/StreamTransClient.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/SystemTransform.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/SystemTransform.dll new file mode 100644 index 0000000..f704e49 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/SystemTransform.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/libiconv2.dll b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/libiconv2.dll new file mode 100644 index 0000000..978e2fa Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HCNetSDKCom/libiconv2.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HXVA.dll b/box-device/src/main/resources/native/hikvision/win64/HXVA.dll new file mode 100644 index 0000000..b7ebfcc Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HXVA.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/HmMerge.dll b/box-device/src/main/resources/native/hikvision/win64/HmMerge.dll new file mode 100644 index 0000000..d46a6ac Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/HmMerge.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/LocalSensorAdd.dat b/box-device/src/main/resources/native/hikvision/win64/LocalSensorAdd.dat new file mode 100644 index 0000000..e69de29 diff --git a/box-device/src/main/resources/native/hikvision/win64/LocalXml.zip b/box-device/src/main/resources/native/hikvision/win64/LocalXml.zip new file mode 100644 index 0000000..3620e68 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/LocalXml.zip differ diff --git a/box-device/src/main/resources/native/hikvision/win64/MP_Render.dll b/box-device/src/main/resources/native/hikvision/win64/MP_Render.dll new file mode 100644 index 0000000..e5cde63 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/MP_Render.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/NPQos.dll b/box-device/src/main/resources/native/hikvision/win64/NPQos.dll new file mode 100644 index 0000000..c709f56 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/NPQos.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/OpenAL32.dll b/box-device/src/main/resources/native/hikvision/win64/OpenAL32.dll new file mode 100644 index 0000000..4b35df4 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/OpenAL32.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/PlayCtrl.dll b/box-device/src/main/resources/native/hikvision/win64/PlayCtrl.dll new file mode 100644 index 0000000..2a5eb97 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/PlayCtrl.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/PlayCtrl.lib b/box-device/src/main/resources/native/hikvision/win64/PlayCtrl.lib new file mode 100644 index 0000000..ddcf2f4 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/PlayCtrl.lib differ diff --git a/box-device/src/main/resources/native/hikvision/win64/SuperRender.dll b/box-device/src/main/resources/native/hikvision/win64/SuperRender.dll new file mode 100644 index 0000000..b00c0c2 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/SuperRender.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/YUVProcess.dll b/box-device/src/main/resources/native/hikvision/win64/YUVProcess.dll new file mode 100644 index 0000000..d86ec3f Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/YUVProcess.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/hlog.dll b/box-device/src/main/resources/native/hikvision/win64/hlog.dll new file mode 100644 index 0000000..fe2298a Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/hlog.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/hpr.dll b/box-device/src/main/resources/native/hikvision/win64/hpr.dll new file mode 100644 index 0000000..eef0d55 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/hpr.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/libcrypto-1_1-x64.dll b/box-device/src/main/resources/native/hikvision/win64/libcrypto-1_1-x64.dll new file mode 100644 index 0000000..6731338 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/libcrypto-1_1-x64.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/libmmd.dll b/box-device/src/main/resources/native/hikvision/win64/libmmd.dll new file mode 100644 index 0000000..8becb5e Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/libmmd.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/libssl-1_1-x64.dll b/box-device/src/main/resources/native/hikvision/win64/libssl-1_1-x64.dll new file mode 100644 index 0000000..ac5e8fd Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/libssl-1_1-x64.dll differ diff --git a/box-device/src/main/resources/native/hikvision/win64/zlib1.dll b/box-device/src/main/resources/native/hikvision/win64/zlib1.dll new file mode 100644 index 0000000..9c37a84 Binary files /dev/null and b/box-device/src/main/resources/native/hikvision/win64/zlib1.dll differ diff --git a/box-framework/pom.xml b/box-framework/pom.xml new file mode 100644 index 0000000..c84ee4d --- /dev/null +++ b/box-framework/pom.xml @@ -0,0 +1,28 @@ + + + + box + com.mathvision + 1.0-SNAPSHOT + + 4.0.0 + + box-framework + framework框架核心 + + + + com.mathvision + box-dao + 1.0-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-aop + + + + \ No newline at end of file diff --git a/box-framework/src/main/java/com/mathvision/box/framework/aspect/DecryptAspect.java b/box-framework/src/main/java/com/mathvision/box/framework/aspect/DecryptAspect.java new file mode 100644 index 0000000..98623d3 --- /dev/null +++ b/box-framework/src/main/java/com/mathvision/box/framework/aspect/DecryptAspect.java @@ -0,0 +1,57 @@ +package com.mathvision.box.framework.aspect; + +import com.mathvision.box.common.annotation.aes.AesDecrypt; +import com.mathvision.box.common.utils.aes.AesEncryptUtil; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Field; +import java.util.Base64; + +@Aspect +@Component +public class DecryptAspect { + @Value("${aes.key}") + private String aesKey; + + @Around("@within(org.springframework.web.bind.annotation.RestController)") + public Object process(ProceedingJoinPoint joinPoint) throws Throwable { + Object[] args = joinPoint.getArgs(); + for (Object arg : args) { + if (arg != null) { + decryptFields(arg); // 递归处理对象字段 + } + } + return joinPoint.proceed(); + } + + // 解密字段 + private void decryptFields(Object obj) throws Exception { + Field[] fields = obj.getClass().getDeclaredFields(); + for (Field field : fields) { + if (field.isAnnotationPresent(AesDecrypt.class)) { + field.setAccessible(true); + Object value = field.get(obj); + if (value instanceof String) { + String encrypted = (String) value; + if (!isBase64(encrypted)) { + throw new IllegalArgumentException(field.getAnnotation(AesDecrypt.class).message()); + } + field.set(obj, AesEncryptUtil.aesDecrypt(encrypted, aesKey)); + } + } + } + } + + private boolean isBase64(String str) { + try { + Base64.getDecoder().decode(str); + return true; + } catch (IllegalArgumentException e) { + return false; + } + } +} \ No newline at end of file diff --git a/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalAuthAspect.java b/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalAuthAspect.java new file mode 100644 index 0000000..678db0f --- /dev/null +++ b/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalAuthAspect.java @@ -0,0 +1,48 @@ +package com.mathvision.box.framework.aspect; + +import com.mathvision.box.common.annotation.Auth; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.domain.entity.UserCache; +import com.mathvision.box.common.exception.base.BaseException; +import com.mathvision.box.common.utils.security.SessionHolder; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Method; + +/** + * 切面处理类,接口鉴权 + * + * @author fy + */ +@Aspect +@Component +public class GlobalAuthAspect { + @Pointcut("@annotation(com.mathvision.box.common.annotation.Auth)") + public void authAOP() { + // 切点定义 + } + + @Before("authAOP()") + public void checkAuth(JoinPoint joinPoint) { + String permission = ""; + UserCache user = SessionHolder.get(); + if (user == null) { + throw new BaseException(Result.NOT_LOGIN); + } + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + Auth auth = method.getAnnotation(Auth.class); + if (auth != null) { + permission = auth.permission(); + } + + if (user.getPermissions() != null && !user.getPermissions().contains(permission)) { + throw new BaseException(Result.NOT_PRIVILEGED); + } + } +} diff --git a/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalExceptionHandler.java b/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalExceptionHandler.java new file mode 100644 index 0000000..413d87d --- /dev/null +++ b/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalExceptionHandler.java @@ -0,0 +1,76 @@ +package com.mathvision.box.framework.aspect; + +/** + * @Author: fy + * @Date: 2024/03/21 + * @Description:全局异常处理 + */ + +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.exception.base.BaseException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.*; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.multipart.MultipartException; + +import javax.servlet.http.HttpServletRequest; + +@Slf4j +@Controller +@ControllerAdvice +public class GlobalExceptionHandler { + + @ResponseBody + @ExceptionHandler(BaseException.class) + public Result errorHandler(BaseException e) { + return _innerHandler(e.getResult(), e, false); + } + + @ResponseBody + @ExceptionHandler({MissingServletRequestParameterException.class, MissingPathVariableException.class, MissingRequestCookieException.class, MissingRequestHeaderException.class, MissingServletRequestParameterException.class}) + public Result errorHandler(MissingServletRequestParameterException e) { + return _innerHandler(Result.ILLEGAL_ARGUMENT, e, false); + } + + /** + * 参数校验异常处理 + */ + @ResponseBody + @ExceptionHandler(MethodArgumentNotValidException.class) + public Result errorHandler(MethodArgumentNotValidException e) { + return _innerHandler(new Result(Result.ILLEGAL_ARGUMENT.getCode(), e.getFieldError().getDefaultMessage()), e, false); + } + + @ResponseBody + @ExceptionHandler({MultipartException.class}) + public Result errorHandler(MultipartException e) { + return _innerHandler(Result.NOT_SUPPORT, e, false); + } + + @ResponseBody + @ExceptionHandler + public Result errorHandler(Exception e) { + return _innerHandler(new Result(Result.ERROR.getCode(), e.getMessage()), e, true); + } + + private Result _innerHandler(Result result, Exception e, boolean needExceptionTrace) { + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (requestAttributes != null) { + if (requestAttributes.getResponse() != null) { + requestAttributes.getResponse().setStatus(result.getCode()); + } + HttpServletRequest request = requestAttributes.getRequest(); + if (!needExceptionTrace) { + log.error("[GlobalExceptionHandler:" + request.getServletPath() + "] exception:" + e.getMessage()); + } else { + log.error("[GlobalExceptionHandler:" + request.getServletPath() + "] exception:" + e.getMessage(), e); + } + } + return result; + } +} \ No newline at end of file diff --git a/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalLogAspect.java b/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalLogAspect.java new file mode 100644 index 0000000..3d02eb6 --- /dev/null +++ b/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalLogAspect.java @@ -0,0 +1,133 @@ +package com.mathvision.box.framework.aspect; + + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.mathvision.box.common.annotation.Log; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.domain.entity.UserCache; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.security.SessionHolder; +import com.mathvision.box.dao.domain.entity.SysLog; +import com.mathvision.box.dao.service.SysLogService; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; + +import javax.servlet.http.HttpServletRequest; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +/** + * 切面处理类,系统日志记录 + * + * @author fy + */ +@Aspect +@Component +@Slf4j +public class GlobalLogAspect { + @Autowired + private SysLogService sysLogService; + + /** + * 设置操作日志切入点 记录操作日志 在注解的位置切入代码 + */ + @Pointcut("@annotation(com.mathvision.box.common.annotation.Log)") + public void logAOP() { + + } + + /** + * 正常返回通知,拦截用户操作日志,连接点正常执行完成后执行, 如果连接点抛出异常,则不会执行 + * + * @param joinPoint 切入点 + * @param keys 返回结果 + */ + @AfterReturning(value = "logAOP()", returning = "keys") + public void saveLog(JoinPoint joinPoint, Object keys) { + // 获取RequestAttributes + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + // 从获取RequestAttributes中获取HttpServletRequest的信息 + HttpServletRequest request = (HttpServletRequest) requestAttributes + .resolveReference(RequestAttributes.REFERENCE_REQUEST); + + SysLog operlog = new SysLog(); + UserCache user = SessionHolder.get(); + + try { + // 从切面织入点处通过反射机制获取织入点处的方法 + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + // 获取切入点所在的方法 + Method method = signature.getMethod(); + // 获取操作 + Log opLog = method.getAnnotation(Log.class); + if (opLog != null) { + String logType = opLog.logType(); + String logContent = opLog.logContent(); + operlog.setLogType(logType); // 操作类型 + operlog.setLogContent("操作账号:" + user.getLoginName() + ";操作内容" + logContent); // 操作描述 + } + // 获取请求的类名 + String className = joinPoint.getTarget().getClass().getName(); + // 获取请求的方法名 + String methodName = method.getName(); + methodName = className + "." + methodName; + + //operlog.setOperMethod(methodName); // 请求方法 + + // 请求的参数 + Map rtnMap = converMap(request.getParameterMap()); + // 将参数所在的数组转换成json + String params = JSON.toJSONString(rtnMap); + + + if (keys instanceof Result) { + Result result = (Result) keys; + if (result.isSuccess()) { + if (result.getBody() instanceof String && StringUtils.isNotBlank((String) result.getBody())) { + operlog.setLogContent("操作账号:" + user.getLoginName() + ";操作内容" + result.getBody()); + } else { + JSONObject jsonBody = JSON.parseObject(JSONObject.toJSONString(result.getBody())); + if (jsonBody.containsKey("logContent")) { + operlog.setLogContent("操作账号:" + user.getLoginName() + ";操作内容" + jsonBody.getString("logContent")); + } + } + } + } + +// operlog.setOperRequParam(params); // 请求参数 +// operlog.setOperRespParam(JSON.toJSONString(keys)); // 返回结果 +// operlog.setOperUserId(UserShiroUtil.getCurrentUserLoginName()); // 请求用户ID +// operlog.setOperUserName(UserShiroUtil.getCurrentUserName()); // 请求用户名称 +// operlog.setOperIp(IPUtil.getRemortIP(request)); // 请求IP +// operlog.setOperUri(request.getRequestURI()); // 请求URI +// operlog.setOperCreateTime(new Date()); // 创建时间 +// operlog.setOperVer(operVer); // 操作版本 + sysLogService.save(operlog); + } catch (Exception e) { + log.error("用户操作日志AOP异常通知:{}", e.getMessage()); + } + } + + /** + * 转换request 请求参数 + * + * @param paramMap request获取的参数数组 + */ + public Map converMap(Map paramMap) { + Map rtnMap = new HashMap(); + for (String key : paramMap.keySet()) { + rtnMap.put(key, paramMap.get(key)[0]); + } + return rtnMap; + } +} diff --git a/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalRequestAspect.java b/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalRequestAspect.java new file mode 100644 index 0000000..f3e9a44 --- /dev/null +++ b/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalRequestAspect.java @@ -0,0 +1,108 @@ +package com.mathvision.box.framework.aspect; + +import com.alibaba.fastjson.JSON; +import com.mathvision.box.common.constant.Constants; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.domain.entity.UserCache; +import com.mathvision.box.common.exception.base.BaseException; +import com.mathvision.box.common.utils.security.JwtUtils; +import com.mathvision.box.common.utils.security.SessionHolder; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.resource.ResourceHttpRequestHandler; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +/** + * @Author: fy + * @Date: 2024/03/21 + * @Description:全局请求拦截 + */ +@Slf4j +@Configuration +@ControllerAdvice +public class GlobalRequestAspect implements HandlerInterceptor, WebMvcConfigurer { + + @Autowired + JwtUtils jwtUtils; + @Value("${jwt.config.header}") + private String header; + @Value("${jwt.config.refreshTime}") + private Long refreshTime; + @Value("${jwt.config.expiresTime}") + private Long expiresTime; + @Value("${app.profile}") + private String profile; + + + /** + * 拦截器白名单 + */ + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(this).addPathPatterns("/api/**") + .excludePathPatterns("/api/oauth/**") + .excludePathPatterns("/api/sysConfig/query/UISetting") + ; + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**") + .addResourceLocations("file:" + profile + "/"); + } + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { + if (handler instanceof ResourceHttpRequestHandler) { + response.setStatus(Result.NOT_SUPPORT.getCode()); + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/json; charset=utf-8"); + response.getOutputStream().write(JSON.toJSONString(Result.NOT_SUPPORT).getBytes(StandardCharsets.UTF_8)); + return false; + } + + // 如果不是映射到方法直接通过,可以访问资源. + if (!(handler instanceof HandlerMethod)) { + return true; + } + + //为空就返回错误 + String token = request.getHeader(header); + if (null == token || "".equals(token.trim())) { + throw new BaseException(Result.NOT_LOGIN); + } + + UserCache user = jwtUtils.parseToken(token); + if (user == null) { + throw new BaseException(Result.NOT_LOGIN); + } + + long currentTime = System.currentTimeMillis(); + long timeOfUse = currentTime - user.getTimeStamp(); + + if (timeOfUse < refreshTime) { + user.setTimeStamp(currentTime); + SessionHolder.set(user); + return true; + } else if (timeOfUse >= refreshTime && timeOfUse < expiresTime) { + user.setTimeStamp(currentTime); + SessionHolder.set(user); + response.setHeader(header, jwtUtils.getToken(user)); + return true; + } else { + throw new BaseException(Result.NOT_LOGIN); + } + } +} diff --git a/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalResponseAspect.java b/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalResponseAspect.java new file mode 100644 index 0000000..e36f266 --- /dev/null +++ b/box-framework/src/main/java/com/mathvision/box/framework/aspect/GlobalResponseAspect.java @@ -0,0 +1,96 @@ +package com.mathvision.box.framework.aspect; + +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.alibaba.fastjson.support.config.FastJsonConfig; +import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; +import com.mathvision.box.common.annotation.aes.AesEncrypt; +import com.mathvision.box.common.constant.Constants; +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.domain.ResultCode; +import com.mathvision.box.common.utils.aes.AesEncryptUtil; +import com.mathvision.box.common.utils.security.SessionHolder; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.MethodParameter; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.server.ServerHttpRequest; +import org.springframework.http.server.ServerHttpResponse; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; + +import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.stream.Collectors; + +@Slf4j +@Configuration +@ControllerAdvice(assignableTypes = BaseController.class) +public class GlobalResponseAspect implements ResponseBodyAdvice { + + @Value("${aes.key}") + private String aesKey; + + @Override + public boolean supports(MethodParameter methodParameter, Class clazz) { + return true; + } + + @Bean + FastJsonHttpMessageConverter fastJsonHttpMessageConverters() { + FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); + FastJsonConfig jsonConfig = new FastJsonConfig(); + jsonConfig.setCharset(StandardCharsets.UTF_8); + jsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss"); + jsonConfig.setSerializerFeatures(SerializerFeature.BrowserCompatible); + jsonConfig.setSerializerFeatures(SerializerFeature.WriteEnumUsingToString); + jsonConfig.setSerializerFeatures(SerializerFeature.WriteMapNullValue);//输出为null的字段 + jsonConfig.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect);//禁用循环引用检测 + converter.setFastJsonConfig(jsonConfig); + converter.setDefaultCharset(StandardCharsets.UTF_8); + converter.setSupportedMediaTypes(Constants.SUPPORTED_MEDIA_TYPES); + return converter; + } + + @Override + public Object beforeBodyWrite(Object result, MethodParameter methodParameter, MediaType mediaType, Class> clazz, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) { + SessionHolder.clear(); + if (result instanceof Result) { + result = processEncryptFields(result); + return result; + } + return new Result(ResultCode.success, result); + } + + private Object processEncryptFields(Object obj) { + try { + if (obj == null) return null; + + if (obj instanceof Collection) { + return ((Collection) obj).stream().map(this::processEncryptFields).collect(Collectors.toList()); + } + + Class clazz = obj.getClass(); + Field[] fields = clazz.getDeclaredFields(); + + for (Field field : fields) { + if (field.isAnnotationPresent(AesEncrypt.class)) { + field.setAccessible(true); + Object value = field.get(obj); + if (value != null) { + String encrypted = AesEncryptUtil.aesEncrypt(value.toString(), aesKey); + field.set(obj, encrypted); + } + } + } + return obj; + } catch (Exception e) { + log.error("字段加密失败", e); + return obj; // 保持原始数据不中断流程 + } + } +} \ No newline at end of file diff --git a/box-framework/src/main/java/com/mathvision/box/framework/aspect/SqlHandler.java b/box-framework/src/main/java/com/mathvision/box/framework/aspect/SqlHandler.java new file mode 100644 index 0000000..b4a3d5d --- /dev/null +++ b/box-framework/src/main/java/com/mathvision/box/framework/aspect/SqlHandler.java @@ -0,0 +1,37 @@ +package com.mathvision.box.framework.aspect; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.util.Date; + +/** + * @Author: fy + * @Date: 2024/03/22 + * @Description:自动生成创建和修改日期 + */ +@Component +public class SqlHandler implements MetaObjectHandler { + /** + * 使用mp做添加操作时候,这个方法执行 + * + * @param metaObject + */ + @Override + public void insertFill(MetaObject metaObject) { + //设置属性值 + this.setFieldValByName("createTime", new Date(), metaObject); + this.setFieldValByName("updateTime", new Date(), metaObject); + } + + /** + * 使用mp做修改操作时候,这个方法执行 + * + * @param metaObject + */ + @Override + public void updateFill(MetaObject metaObject) { + this.setFieldValByName("updateTime", new Date(), metaObject); + } +} \ No newline at end of file diff --git a/box-framework/src/main/java/com/mathvision/box/framework/config/FilterConfig.java b/box-framework/src/main/java/com/mathvision/box/framework/config/FilterConfig.java new file mode 100644 index 0000000..9e194e1 --- /dev/null +++ b/box-framework/src/main/java/com/mathvision/box/framework/config/FilterConfig.java @@ -0,0 +1,43 @@ +package com.mathvision.box.framework.config; + +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.xss.XssFilter; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.DispatcherType; +import java.util.HashMap; +import java.util.Map; + +/** + * Filter配置 + */ +@Configuration +@ConditionalOnProperty(value = "xss.enabled", havingValue = "true") +public class FilterConfig +{ + @Value("${xss.excludes}") + private String excludes; + + @Value("${xss.urlPatterns}") + private String urlPatterns; + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Bean + public FilterRegistrationBean xssFilterRegistration() + { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setDispatcherTypes(DispatcherType.REQUEST); + registration.setFilter(new XssFilter()); + registration.addUrlPatterns(StringUtils.split(urlPatterns, ",")); + registration.setName("xssFilter"); + registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE); + Map initParameters = new HashMap(); + initParameters.put("excludes", excludes); + registration.setInitParameters(initParameters); + return registration; + } +} diff --git a/box-framework/src/main/java/com/mathvision/box/framework/config/MyBatisPlusConfig.java b/box-framework/src/main/java/com/mathvision/box/framework/config/MyBatisPlusConfig.java new file mode 100644 index 0000000..4e681c9 --- /dev/null +++ b/box-framework/src/main/java/com/mathvision/box/framework/config/MyBatisPlusConfig.java @@ -0,0 +1,47 @@ +package com.mathvision.box.framework.config; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; +import com.baomidou.mybatisplus.core.config.GlobalConfig; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.sql.DataSource; +import java.util.Date; + +@Configuration +@EnableTransactionManagement +@MapperScan({"com.mathvision.box.dao.mapper"}) +public class MyBatisPlusConfig { + /** + * 分页插件 + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2)); + return interceptor; + } + + @Bean + public PlatformTransactionManager transactionManager(DataSource dataSource) { + return new DataSourceTransactionManager(dataSource); + } + + /** + * SQLite 配置 + */ + @Bean + public ConfigurationCustomizer mybatisConfigurationCustomizer() { + return configuration -> { + configuration.getTypeHandlerRegistry().register(Date.class, new SQLiteDateTypeHandler()); + }; + } +} \ No newline at end of file diff --git a/box-framework/src/main/java/com/mathvision/box/framework/config/SQLiteDateTypeHandler.java b/box-framework/src/main/java/com/mathvision/box/framework/config/SQLiteDateTypeHandler.java new file mode 100644 index 0000000..6378388 --- /dev/null +++ b/box-framework/src/main/java/com/mathvision/box/framework/config/SQLiteDateTypeHandler.java @@ -0,0 +1,43 @@ +package com.mathvision.box.framework.config; + +import com.mathvision.box.common.utils.common.DateUtils; +import com.mathvision.box.common.utils.common.StringUtils; +import org.apache.ibatis.type.*; +import java.sql.*; +import java.util.Date; + +@MappedTypes(Date.class) +public class SQLiteDateTypeHandler extends BaseTypeHandler { + @Override + public void setNonNullParameter(PreparedStatement ps, int i, Date parameter, JdbcType jdbcType) throws SQLException { + ps.setString(i, DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, parameter)); + } + + @Override + public Date getNullableResult(ResultSet rs, String columnName) throws SQLException { + String dateStr = rs.getString(columnName); + if (StringUtils.isBlank(dateStr)){ + return null; + } + return DateUtils.parseDate(dateStr, DateUtils.YYYY_MM_DD_HH_MM_SS); + } + + @Override + public Date getNullableResult(ResultSet rs, int columnIndex) throws SQLException { + String dateStr = rs.getString(columnIndex); + if (StringUtils.isBlank(dateStr)){ + return null; + } + return DateUtils.parseDate(dateStr, DateUtils.YYYY_MM_DD_HH_MM_SS); + } + + @Override + public Date getNullableResult(CallableStatement cs, int columnIndex)throws SQLException { + String dateStr = cs.getString(columnIndex); + if (StringUtils.isBlank(dateStr)){ + return null; + } + return DateUtils.parseDate(dateStr, DateUtils.YYYY_MM_DD_HH_MM_SS); + } +} + diff --git a/box-framework/src/main/java/com/mathvision/box/framework/config/StringToListLongTypeHandler.java b/box-framework/src/main/java/com/mathvision/box/framework/config/StringToListLongTypeHandler.java new file mode 100644 index 0000000..157a1de --- /dev/null +++ b/box-framework/src/main/java/com/mathvision/box/framework/config/StringToListLongTypeHandler.java @@ -0,0 +1,56 @@ +package com.mathvision.box.framework.config; + +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + + +@MappedTypes(List.class) +@MappedJdbcTypes(JdbcType.VARCHAR) +public class StringToListLongTypeHandler extends BaseTypeHandler> { + + @Override + public void setNonNullParameter(PreparedStatement ps, int i, List parameter, JdbcType jdbcType) throws SQLException { + // 将List转为逗号分隔的字符串存入数据库 + String value = parameter.stream().map(String::valueOf).collect(Collectors.joining(",")); + ps.setString(i, value); + } + + @Override + public List getNullableResult(ResultSet rs, String columnName) throws SQLException { + String value = rs.getString(columnName); + return convertStringToList(value); + } + + @Override + public List getNullableResult(ResultSet rs, int columnIndex) throws SQLException { + String value = rs.getString(columnIndex); + return convertStringToList(value); + } + + @Override + public List getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { + String value = cs.getString(columnIndex); + return convertStringToList(value); + } + + private List convertStringToList(String value) { + if (value == null || value.isEmpty()) { + return Collections.emptyList(); + } + return Stream.of(value.split(",")) + .map(String::trim) + .map(Long::parseLong) + .collect(Collectors.toList()); + } +} \ No newline at end of file diff --git a/box-message/pom.xml b/box-message/pom.xml new file mode 100644 index 0000000..9671ec1 --- /dev/null +++ b/box-message/pom.xml @@ -0,0 +1,27 @@ + + + + box + com.mathvision + 1.0-SNAPSHOT + + 4.0.0 + + box-message + 消息推送 + + + + com.mathvision + box-dao + 1.0-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-websocket + + + \ No newline at end of file diff --git a/box-message/src/main/java/com/mathvision/box/message/config/WebSocketConfig.java b/box-message/src/main/java/com/mathvision/box/message/config/WebSocketConfig.java new file mode 100644 index 0000000..3dd1adb --- /dev/null +++ b/box-message/src/main/java/com/mathvision/box/message/config/WebSocketConfig.java @@ -0,0 +1,27 @@ +package com.mathvision.box.message.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.socket.config.annotation.EnableWebSocket; +import org.springframework.web.socket.server.standard.ServerEndpointExporter; + +/** + * Created with IntelliJ IDEA. + * + * @Author: fy + * @Date: 2023/04/27/9:26 + * @Description: + */ +@Configuration +@EnableWebSocket +public class WebSocketConfig { + /** + * 注入ServerEndpointExporter, + * 这个bean会自动注册使用了@ServerEndpoint注解声明的Websocket endpoint + */ + @Bean + public ServerEndpointExporter serverEndpointExporter() { + return new ServerEndpointExporter(); + } + +} diff --git a/box-message/src/main/java/com/mathvision/box/message/domain/Message.java b/box-message/src/main/java/com/mathvision/box/message/domain/Message.java new file mode 100644 index 0000000..09a27b8 --- /dev/null +++ b/box-message/src/main/java/com/mathvision/box/message/domain/Message.java @@ -0,0 +1,11 @@ +package com.mathvision.box.message.domain; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class Message { + private String type; + private String message; +} diff --git a/box-message/src/main/java/com/mathvision/box/message/service/BoxMessageService.java b/box-message/src/main/java/com/mathvision/box/message/service/BoxMessageService.java new file mode 100644 index 0000000..74c3e32 --- /dev/null +++ b/box-message/src/main/java/com/mathvision/box/message/service/BoxMessageService.java @@ -0,0 +1,81 @@ +package com.mathvision.box.message.service; + +import com.google.common.util.concurrent.RateLimiter; +import com.mathvision.box.common.enums.RecordType; +import com.mathvision.box.dao.domain.entity.BoxRecord; +import com.mathvision.box.dao.service.BoxRecordService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.concurrent.*; + +/** + * 盒子消息 + */ +@Slf4j +@Service +public class BoxMessageService { + private static final RecordType RECORD_TYPE = RecordType.message; + private static final ExecutorService EXECUTOR_SERVICE_POOL = Executors.newFixedThreadPool(10); + + @Value("${box.message.inhibition:10}") + private int inhibition; + + private final ConcurrentHashMap rateLimiters = new ConcurrentHashMap<>(); + + @Resource + private EmailMessageService emailMessageService; + + @Resource + private SMSMessageService smsMessageService; + + @Resource + private WebSocketMessageService webSocketMessageService; + + @Resource + private BoxRecordService boxRecordService; + + public void sendEmail(Long deviceId, String[] email, String context) { + if (!checkRate(deviceId, "sendEmail")) { + log.error("[BoxMessageService] sendEmail inhibition(per minutes): " + inhibition); + } + CompletableFuture.runAsync(() -> emailMessageService.send(email, context), EXECUTOR_SERVICE_POOL) + .thenRun(() -> Arrays.stream(email).forEach(x -> + boxRecordService.save(BoxRecord.builder().recordType(RECORD_TYPE.getDesc()).deviceId(deviceId).dataKey(x).dataType("邮件").content(context).build()) + )); + } + + public void sendMessage(Long deviceId, String[] phone, String context) { + if (!checkRate(deviceId, "sendMessage")) { + log.error("[BoxMessageService] sendMessage inhibition(per minutes): " + inhibition); + } + CompletableFuture.runAsync(() -> smsMessageService.send(phone, context), EXECUTOR_SERVICE_POOL) + .thenRun(() -> Arrays.stream(phone).forEach(x -> + boxRecordService.save(BoxRecord.builder().recordType(RECORD_TYPE.getDesc()).deviceId(deviceId).dataKey(x).dataType("短信").content(context).build()) + ) + ); + } + + public void sendWebSocket(Long deviceId, String[] target, String context) { + if (!checkRate(deviceId, "sendWebSocket")) { + log.error("[BoxMessageService] sendWebSocket inhibition(per minutes): " + inhibition); + } + CompletableFuture.runAsync(() -> webSocketMessageService.send(target, context), EXECUTOR_SERVICE_POOL) + .thenRun(() -> Arrays.stream(target).forEach(x -> + boxRecordService.save(BoxRecord.builder().recordType(RECORD_TYPE.getDesc()).deviceId(deviceId).dataKey(x).dataType("WebSocket").content(context).build()) + ) + ); + } + + private boolean checkRate(Long first, String... more) { + String limitKey = StringUtils.joinWith("+", first, more); + if (!rateLimiters.containsKey(limitKey)) { + rateLimiters.putIfAbsent(limitKey, RateLimiter.create(1, inhibition, TimeUnit.MINUTES)); + } + return rateLimiters.get(limitKey).tryAcquire(); + } +} diff --git a/box-message/src/main/java/com/mathvision/box/message/service/EmailMessageService.java b/box-message/src/main/java/com/mathvision/box/message/service/EmailMessageService.java new file mode 100644 index 0000000..abaa518 --- /dev/null +++ b/box-message/src/main/java/com/mathvision/box/message/service/EmailMessageService.java @@ -0,0 +1,14 @@ +package com.mathvision.box.message.service; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +public class EmailMessageService implements MessageService { + + @Override + public void send(String[] target, String message) { + log.info("发送邮件给:{},内容:{}", target, message); + } +} diff --git a/box-message/src/main/java/com/mathvision/box/message/service/MessageService.java b/box-message/src/main/java/com/mathvision/box/message/service/MessageService.java new file mode 100644 index 0000000..3eaa5d0 --- /dev/null +++ b/box-message/src/main/java/com/mathvision/box/message/service/MessageService.java @@ -0,0 +1,5 @@ +package com.mathvision.box.message.service; + +public interface MessageService { + void send(String[] target, String message); +} diff --git a/box-message/src/main/java/com/mathvision/box/message/service/SMSMessageService.java b/box-message/src/main/java/com/mathvision/box/message/service/SMSMessageService.java new file mode 100644 index 0000000..ea34fe7 --- /dev/null +++ b/box-message/src/main/java/com/mathvision/box/message/service/SMSMessageService.java @@ -0,0 +1,13 @@ +package com.mathvision.box.message.service; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +public class SMSMessageService implements MessageService { + @Override + public void send(String[] target, String message) { + log.info("发送短信给:{},内容:{}", target, message); + } +} diff --git a/box-message/src/main/java/com/mathvision/box/message/service/WebSocketMessageService.java b/box-message/src/main/java/com/mathvision/box/message/service/WebSocketMessageService.java new file mode 100644 index 0000000..91ebfc4 --- /dev/null +++ b/box-message/src/main/java/com/mathvision/box/message/service/WebSocketMessageService.java @@ -0,0 +1,18 @@ +package com.mathvision.box.message.service; + +import com.mathvision.box.message.websocket.WebSocket; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Slf4j +@Service +public class WebSocketMessageService implements MessageService { + @Resource + private WebSocket webSocket; + @Override + public void send(String[] target, String message) { + webSocket.sendAllMessage(message); + } +} diff --git a/box-message/src/main/java/com/mathvision/box/message/websocket/WebSocket.java b/box-message/src/main/java/com/mathvision/box/message/websocket/WebSocket.java new file mode 100644 index 0000000..9805c81 --- /dev/null +++ b/box-message/src/main/java/com/mathvision/box/message/websocket/WebSocket.java @@ -0,0 +1,128 @@ +package com.mathvision.box.message.websocket; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.websocket.*; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; +import java.util.Collection; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArraySet; + + +@Slf4j +@Component +@ServerEndpoint("/websocket/{userId}") // 接口路径 ws://localhost:8080/websocket/userId; +public class WebSocket { + /** + * 会话 + */ + private Session session; + + /** + * 用户ID + */ + private String userId; + + //concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。 + //虽然@Component默认是单例模式的,但springboot还是会为每个websocket连接初始化一个bean,所以可以用一个静态set保存起来。 + // 注:底下WebSocket是当前类名 + private static CopyOnWriteArraySet webSockets = new CopyOnWriteArraySet<>(); + // 用来存在线连接用户信息 + private static ConcurrentHashMap sessionPool = new ConcurrentHashMap<>(); + + /** + * 链接成功调用的方法 + */ + @OnOpen + public void onOpen(Session session, @PathParam(value = "userId") String userId) { + try { + this.session = session; + this.userId = userId; + webSockets.add(this); + sessionPool.put(userId, session); + log.info("【websocket消息】有新的连接:{},总数为:{}", userId, webSockets.size()); + } catch (Exception e) { + } + } + + /** + * 链接关闭调用的方法 + */ + @OnClose + public void onClose() { + try { + webSockets.remove(this); + sessionPool.remove(this.userId); + log.info("【websocket消息】连接断开:{},总数为:{}", this.userId, webSockets.size()); + } catch (Exception e) { + } + } + + /** + * 收到客户端消息后调用的方法 + * + * @param + * @param + */ + @OnMessage + public void onMessage(String message) { + log.info("【websocket消息】有新的消息:" + message); + //处理消息 + } + + /** + * 发送错误时的处理 + * + * @param session + * @param error + */ + @OnError + public void onError(Session session, Throwable error) { + log.error("用户错误,原因:{}", error.getMessage(), error); + } + + + // 此为广播消息 + public void sendAllMessage(String message) { + for (WebSocket webSocket : webSockets) { + try { + if (webSocket.session.isOpen()) { + synchronized (webSocket.session) { + webSocket.session.getAsyncRemote().sendText(message); + } + } + } catch (Exception e) { + log.error("【websocket消息】广播消息发送失败:{}", e); + } + } + } + + // 此为单点消息 + public void sendOneMessage(String userId, String message) { + Session session = sessionPool.get(userId); + if (session != null && session.isOpen()) { + try { + session.getAsyncRemote().sendText(message); + } catch (Exception e) { + log.error("【websocket消息】单点消息发送失败:{}", e); + } + } + } + + // 此为单点消息(多人) + public void sendMoreMessage(Collection userIds, String message) { + for (String userId : userIds) { + Session session = sessionPool.get(userId); + if (session != null && session.isOpen()) { + try { + session.getAsyncRemote().sendText(message); + } catch (Exception e) { + log.error("【websocket消息】单点消息(多人)发送失败:{}", e); + } + } + } + + } +} \ No newline at end of file diff --git a/box-web/pom.xml b/box-web/pom.xml new file mode 100644 index 0000000..ed648a6 --- /dev/null +++ b/box-web/pom.xml @@ -0,0 +1,58 @@ + + + + box + com.mathvision + 1.0-SNAPSHOT + + 4.0.0 + jar + box-web + web服务入口 + + + + com.mathvision + box-framework + 1.0-SNAPSHOT + + + + com.mathvision + box-device + 1.0-SNAPSHOT + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.7.18 + + true + + + + + repackage + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.0.0 + + false + ${project.artifactId} + + + + ${project.artifactId} + + \ No newline at end of file diff --git a/box-web/src/main/java/com/mathvision/box/Application.java b/box-web/src/main/java/com/mathvision/box/Application.java new file mode 100644 index 0000000..9fd6f86 --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/Application.java @@ -0,0 +1,16 @@ +package com.mathvision.box; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.scheduling.annotation.EnableScheduling; + + +@EnableScheduling +@EnableConfigurationProperties +@SpringBootApplication +public class Application { + public static void main(String[] args) { + SpringApplication.run(Application.class,args); + } +} diff --git a/box-web/src/main/java/com/mathvision/box/config/SwaggerConfig.java b/box-web/src/main/java/com/mathvision/box/config/SwaggerConfig.java new file mode 100644 index 0000000..4e3299b --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/config/SwaggerConfig.java @@ -0,0 +1,50 @@ +package com.mathvision.box.config; + +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; +import org.springframework.beans.factory.annotation.Value; +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.builders.RequestParameterBuilder; +import springfox.documentation.service.*; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; + +import java.util.Collections; + +/** + * @Description knife4j配置类, 访问url:http://ip:port/doc.html + **/ +@EnableKnife4j +@Configuration +public class SwaggerConfig { + @Value("${swagger.base-package}") + private String basePackage; + @Value("${swagger.description}") + private String description; + @Value("${swagger.version}") + private String version; + @Value("${swagger.title}") + private String title; + @Value("${swagger.enabled}") + private boolean enabled; + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .enable(enabled) + .apiInfo(apiInfo()) + .globalRequestParameters(Collections.singletonList(new RequestParameterBuilder().name("Authorization").in(ParameterType.HEADER).required(true).build())) + .produces(Collections.singleton("application/json")) + .consumes(Collections.singleton("application/json")).select() + .apis(RequestHandlerSelectors.basePackage(basePackage)) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder().description(description).version(version).title(title).build(); + } +} diff --git a/box-web/src/main/java/com/mathvision/box/controller/common/CommonController.java b/box-web/src/main/java/com/mathvision/box/controller/common/CommonController.java new file mode 100644 index 0000000..0feac62 --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/common/CommonController.java @@ -0,0 +1,161 @@ +package com.mathvision.box.controller.common; + +import com.alibaba.fastjson.JSONObject; +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.config.ServerConfig; +import com.mathvision.box.common.constant.Constants; +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.domain.ResultCode; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.file.FileUploadUtils; +import com.mathvision.box.common.utils.file.FileUtils; +import com.mathvision.box.dao.service.impl.CacheService; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @Author: fy + * @Date: 2024/03/21 + * @Description:通用请求处理 + */ +@RestController +@RequestMapping("/api/common") +public class CommonController extends BaseController { + private static final Logger log = LoggerFactory.getLogger(CommonController.class); + + private static final String FILE_DELIMETER = ","; + + @Autowired + private ServerConfig serverConfig; + + + /** + * 通用下载请求 + * + * @param fileName 文件名称 + * @param delete 是否删除 + */ + @ApiOperation(value = "通用下载请求") + @PostMapping("/download") + public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) { + try { + if (!FileUtils.checkAllowDownload(fileName)) { + throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); + } + String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); + String filePath = AppConfig.getDownloadPath() + fileName; + response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); + FileUtils.setAttachmentResponseHeader(response, realFileName); + FileUtils.writeBytes(filePath, response.getOutputStream()); + if (delete) { + FileUtils.deleteFile(filePath); + } + } catch (Exception e) { + log.error("下载文件失败", e); + } + } + + /** + * 通用上传请求(单个) + */ + @ApiOperation(value = "通用上传请求(单个)") + @PostMapping("/upload") + @ResponseBody + public Result uploadFile(MultipartFile file) throws Exception { + try { + // 上传文件路径 + String filePath = AppConfig.getUploadPath(); + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String url = serverConfig.getUrl() + fileName; + JSONObject result = new JSONObject(); + result.put("url", url); + result.put("fileName", fileName); + result.put("newFileName", FileUtils.getName(fileName)); + result.put("originalFilename", file.getOriginalFilename()); + return new Result(ResultCode.success, result); + } catch (Exception e) { + return new Result(ResultCode.operate_failure, e.getMessage()); + } + } + + /** + * 通用上传请求(多个) + */ + @ApiOperation(value = "通用上传请求(多个)") + @PostMapping("/uploads") + @ResponseBody + public Result uploadFiles(List files) throws Exception { + try { + // 上传文件路径 + String filePath = AppConfig.getUploadPath(); + List urls = new ArrayList(); + List fileNames = new ArrayList(); + List newFileNames = new ArrayList(); + List originalFilenames = new ArrayList(); + for (MultipartFile file : files) { + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String url = serverConfig.getUrl() + fileName; + urls.add(url); + fileNames.add(fileName); + newFileNames.add(FileUtils.getName(fileName)); + originalFilenames.add(file.getOriginalFilename()); + } + JSONObject result = new JSONObject(); + result.put("urls", StringUtils.join(urls, FILE_DELIMETER)); + result.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER)); + result.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER)); + result.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER)); + return new Result(ResultCode.success, result); + } catch (Exception e) { + return new Result(ResultCode.operate_failure, e.getMessage()); + } + } + + /** + * 本地资源通用下载 + */ + @ApiOperation(value = "本地资源通用下载") + @PostMapping("/download/resource") + public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response) + throws Exception { + try { + if (!FileUtils.checkAllowDownload(resource)) { + throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource)); + } + // 本地资源路径 + String localPath = AppConfig.getProfile(); + // 数据库资源地址 + String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX); + // 下载名称 + String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); + response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); + FileUtils.setAttachmentResponseHeader(response, downloadName); + FileUtils.writeBytes(downloadPath, response.getOutputStream()); + } catch (Exception e) { + log.error("下载文件失败", e); + } + } + + @ApiOperation(value = "字典枚举数据key+value") + @PostMapping("/enum") + public Result>> all(){ + return success(CacheService.getAll()); + } +} diff --git a/box-web/src/main/java/com/mathvision/box/controller/sys/AnalysisController.java b/box-web/src/main/java/com/mathvision/box/controller/sys/AnalysisController.java new file mode 100644 index 0000000..1061179 --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/sys/AnalysisController.java @@ -0,0 +1,58 @@ +package com.mathvision.box.controller.sys; + +import com.alibaba.fastjson.JSONObject; +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.dao.domain.entity.SysConfig; +import com.mathvision.box.dao.domain.vo.BigScreenVo; +import com.mathvision.box.dao.domain.vo.UISettingConfigVo; +import com.mathvision.box.dao.service.DefectService; +import com.mathvision.box.dao.service.SysConfigService; +import com.mathvision.box.device.service.BoxDeviceService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@Api(tags = "数据分析相关接口") +@RequestMapping("api/analysis") +public class AnalysisController extends BaseController { + private static final Logger logger = LoggerFactory.getLogger(AnalysisController.class); + + @Resource + private SysConfigService sysConfigService; + @Resource + private DefectService defectService; + @Resource + private BoxDeviceService boxDeviceService; + + @PostMapping("/bigScreen") + @ApiOperation(value = "数据大屏") + public Result query(@RequestParam Long PointId) { + BigScreenVo bigScreenVo = new BigScreenVo(); + SysConfig uiSettingConfig = sysConfigService.queryUISettingConfig(); + if (uiSettingConfig != null) { + UISettingConfigVo uiSettingConfigVo = JSONObject.parseObject(uiSettingConfig.getConfigValue(), UISettingConfigVo.class); + String bigScreenName = uiSettingConfigVo.getExt1(); + String bigScreenSlogan = uiSettingConfigVo.getExt2(); + if (StringUtils.isNotBlank(bigScreenName)){ + bigScreenVo.setBigScreenName(bigScreenName); + } + if (StringUtils.isNotBlank(bigScreenSlogan)){ + bigScreenVo.setBigScreenSlogan(bigScreenSlogan); + } + } + bigScreenVo.setDefectList(defectService.queryByPoint(PointId)); + bigScreenVo.setAlarmStatisticsList(defectService.queryAlarmStatisticsByPoint(PointId)); + bigScreenVo.setDeviceList(boxDeviceService.quarryTree(PointId)); + return success(bigScreenVo); + } +} diff --git a/box-web/src/main/java/com/mathvision/box/controller/sys/DefectController.java b/box-web/src/main/java/com/mathvision/box/controller/sys/DefectController.java new file mode 100644 index 0000000..2a9cdba --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/sys/DefectController.java @@ -0,0 +1,70 @@ +package com.mathvision.box.controller.sys; + +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.page.TableDataInfo; +import com.mathvision.box.common.enums.DefectStatusEnum; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.dao.domain.dto.DefectUpdateDto; +import com.mathvision.box.dao.domain.entity.Defect; +import com.mathvision.box.dao.domain.dto.DefectQueryDto; +import com.mathvision.box.dao.service.DefectService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@Api(tags = "报警数据相关接口") +@RequestMapping("api/defect") +public class DefectController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(DefectController.class); + + @Resource + private DefectService defectService; + + @PostMapping("/list") + @ApiOperation(value = "查询分页数据") + public TableDataInfo list(@RequestBody DefectQueryDto defectDto) { + startPage(); + List list = defectService.query(defectDto); + return getDataTable(list); + } + + @PostMapping("/list/point") + @ApiOperation(value = "查询分页数据-智能场景报警记录") + public TableDataInfo listByPoint(@RequestParam Long pointId) { + startPage(); + List list = defectService.queryByPoint(pointId); + return getDataTable(list); + } + + @PostMapping("/query") + @ApiOperation(value = "查询详情数据") + public Result query(@RequestParam Long id) { + return success(defectService.getById(id)); + } + + + @PostMapping("/update") + @ApiOperation(value = "修改数据(报警处置)") + public Result update(@Validated @RequestBody DefectUpdateDto defectDto) { + Defect defect = new Defect(); + BeanUtils.copyProperties(defectDto, defect); + defect.setStatus(DefectStatusEnum.unprocessed.getCode()); + return toResult(defectService.updateById(defect)); + } + + @PostMapping("/delete") + @ApiOperation(value = "删除数据") + public Result delete(@RequestBody List idList) { + return toResult(defectService.removeBatchByIds(idList)); + } +} + diff --git a/box-web/src/main/java/com/mathvision/box/controller/sys/DetectController.java b/box-web/src/main/java/com/mathvision/box/controller/sys/DetectController.java new file mode 100644 index 0000000..be4e38a --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/sys/DetectController.java @@ -0,0 +1,16 @@ +package com.mathvision.box.controller.sys; + +import com.mathvision.box.common.core.controller.BaseController; +import io.swagger.annotations.Api; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Api(tags = "检测过程数据") +@RequestMapping("api/detect") +public class DetectController extends BaseController { + private static final Logger logger = LoggerFactory.getLogger(DetectController.class); +} + diff --git a/box-web/src/main/java/com/mathvision/box/controller/sys/DeviceController.java b/box-web/src/main/java/com/mathvision/box/controller/sys/DeviceController.java new file mode 100644 index 0000000..4db018e --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/sys/DeviceController.java @@ -0,0 +1,75 @@ +package com.mathvision.box.controller.sys; + +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.page.TableDataInfo; +import com.mathvision.box.dao.domain.dto.DeviceQueryDto; +import com.mathvision.box.dao.domain.dto.DeviceAddDto; +import com.mathvision.box.dao.domain.entity.Device; +import com.mathvision.box.device.common.domin.SignIn; +import com.mathvision.box.device.service.BoxDeviceService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@Api(tags = "设备相关接口") +@RequestMapping("api/device") +public class DeviceController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(DeviceController.class); + + @Resource + private BoxDeviceService boxDeviceService; + + @PostMapping("/list") + @ApiOperation(value = "查询分页数据") + public TableDataInfo list(@RequestBody DeviceQueryDto deviceDto) { + startPage(); + List list = boxDeviceService.query(deviceDto); + return getDataTable(list); + } + @PostMapping("/quarryTree") + @ApiOperation(value = "查询设备树") + public Result> quarryTree(@RequestParam(required = false) Long pointId) { + return success(boxDeviceService.quarryTree(pointId)); + } + + @PostMapping("/query") + @ApiOperation(value = "查询详情数据") + public Result query(@RequestParam Long id) { + return success(boxDeviceService.getById(id)); + } + + @PostMapping("/getChild") + @ApiOperation(value = "自动搜索设备(仅支持盒子)") + public Result> getChild(@RequestParam Long id) { + return success(boxDeviceService.getChild(id)); + } + + + @PostMapping("/add") + @ApiOperation(value = "新增数据") + public Result add(@Validated @RequestBody DeviceAddDto deviceDto) throws Exception { + return toResult(boxDeviceService.save(deviceDto)); + } + + @PostMapping("/update") + @ApiOperation(value = "修改数据") + public Result update(@Validated @RequestBody DeviceAddDto deviceDto) throws Exception { + return toResult(boxDeviceService.update(deviceDto)); + } + + @PostMapping("/delete") + @ApiOperation(value = "删除数据") + public Result delete(@RequestBody List idList) { + return toResult(boxDeviceService.delete(idList)); + } +} + diff --git a/box-web/src/main/java/com/mathvision/box/controller/sys/PointController.java b/box-web/src/main/java/com/mathvision/box/controller/sys/PointController.java new file mode 100644 index 0000000..fc69232 --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/sys/PointController.java @@ -0,0 +1,83 @@ +package com.mathvision.box.controller.sys; + +import com.mathvision.box.common.annotation.Log; +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.page.TableDataInfo; +import com.mathvision.box.dao.domain.dto.PointAddDeviceDto; +import com.mathvision.box.dao.domain.dto.PointAddDto; +import com.mathvision.box.dao.domain.entity.Point; +import com.mathvision.box.dao.domain.dto.PointQueryDto; +import com.mathvision.box.dao.service.PointService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.List; + + +@RestController +@Api(tags = "检测点位(智能场景)相关接口") +@RequestMapping("api/point") +public class PointController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(PointController.class); + + @Resource + private PointService pointService; + + @PostMapping("/list") + @ApiOperation(value = "查询分页数据") + public TableDataInfo list(@RequestBody PointQueryDto pointDto) { + startPage(); + List list = pointService.query(pointDto); + return getDataTable(list); + } + + //todo 语音联动设置 + @PostMapping("/query") + @ApiOperation(value = "查询详情数据") + public Result query(@RequestParam Long id) { + return success(pointService.getById(id)); + } + + @PostMapping("/add") + @ApiOperation(value = "新增数据") + @Log(logType = "检测点-添加", logContent = "检测点-添加") + public Result add(@Validated @RequestBody PointAddDto pointDto) { + return toResult(pointService.add(pointDto)); + } + + @PostMapping("/add/device") + @ApiOperation(value = "关联设备") + @Log(logType = "检测点-添加关联设备", logContent = "检测点-添加关联设备") + public Result addDevice(@Validated @RequestBody PointAddDeviceDto dto) { + return toResult(pointService.addDevice(dto)); + } + + @PostMapping("/update") + @ApiOperation(value = "修改数据") + @Log(logType = "检测点-修改", logContent = "检测点-修改") + public Result update(@Validated @RequestBody PointAddDto pointDto) { + return toResult(pointService.update(pointDto)); + } + + @PostMapping("/delete") + @ApiOperation(value = "删除数据") + @Log(logType = "检测点-删除", logContent = "检测点-删除") + public Result delete(@RequestBody List idList) { + return toResult(pointService.delete(idList)); + } + + @PostMapping("/delete/device") + @ApiOperation(value = "删除关联设备") + @Log(logType = "检测点-删除关联设备", logContent = "检测点-删除关联设备") + public Result deleteDevice(@Validated @RequestBody PointAddDeviceDto dto) { + return toResult(pointService.deleteDevice(dto)); + } +} + diff --git a/box-web/src/main/java/com/mathvision/box/controller/sys/StationController.java b/box-web/src/main/java/com/mathvision/box/controller/sys/StationController.java new file mode 100644 index 0000000..16e8d34 --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/sys/StationController.java @@ -0,0 +1,73 @@ +package com.mathvision.box.controller.sys; + +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.page.TableDataInfo; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.dao.domain.dto.StationAddDto; +import com.mathvision.box.dao.domain.entity.Station; +import com.mathvision.box.dao.domain.dto.StationQueryDto; +import com.mathvision.box.dao.service.StationService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@Api(tags = "检测站点(加油站)相关接口") +@RequestMapping("api/station") +public class StationController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(StationController.class); + + @Resource + private StationService stationService; + + @PostMapping("/list") + @ApiOperation(value = "查询分页数据") + public TableDataInfo list(@RequestBody StationQueryDto stationDto) { + startPage(); + List list = stationService.query(stationDto); + return getDataTable(list); + } + + @PostMapping("/query") + @ApiOperation(value = "查询详情数据") + public Result query(@RequestParam Long id) { + return success(stationService.getById(id)); + } + + @PostMapping("/add") + @ApiOperation(value = "新增数据") + public Result add(@Validated @RequestBody StationAddDto stationDto) { + Assert.isTrue(stationService.checkStationIdUnique(null, stationDto.getStationId()), "编号已存在"); + Assert.isTrue(stationService.checkStationNameUnique(null, stationDto.getStationName()), "名称已存在"); + Station station = new Station(); + BeanUtils.copyProperties(stationDto, station); + return toResult(stationService.save(station)); + } + + + @PostMapping("/update") + @ApiOperation(value = "修改数据") + public Result update(@Validated @RequestBody StationAddDto stationDto) { + Assert.isTrue(stationService.checkStationIdUnique(stationDto.getId(), stationDto.getStationId()), "编号已存在"); + Assert.isTrue(stationService.checkStationNameUnique(stationDto.getId(), stationDto.getStationName()), "名称已存在"); + Station station = new Station(); + BeanUtils.copyProperties(stationDto, station); + return toResult(stationService.updateById(station)); + } + + @PostMapping("/delete") + @ApiOperation(value = "删除数据") + public Result delete(@RequestBody List idList) { + return toResult(stationService.removeBatchByIds(idList)); + } +} + diff --git a/box-web/src/main/java/com/mathvision/box/controller/sys/SysConfigController.java b/box-web/src/main/java/com/mathvision/box/controller/sys/SysConfigController.java new file mode 100644 index 0000000..5760647 --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/sys/SysConfigController.java @@ -0,0 +1,122 @@ +package com.mathvision.box.controller.sys; + +import com.alibaba.fastjson.JSONObject; +import com.mathvision.box.common.config.AppConfig; +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.utils.common.BigDecimalUtil; +import com.mathvision.box.common.utils.file.DiskUtils; +import com.mathvision.box.dao.domain.dto.DataStorageConfigDto; +import com.mathvision.box.dao.domain.dto.UISettingConfigDto; +import com.mathvision.box.dao.domain.entity.SysConfig; +import com.mathvision.box.dao.domain.dto.SysConfigDto; +import com.mathvision.box.dao.domain.vo.DataStorageConfigVo; +import com.mathvision.box.dao.domain.vo.UISettingConfigVo; +import com.mathvision.box.dao.service.SysConfigService; +import com.mathvision.box.message.domain.Message; +import com.mathvision.box.message.websocket.WebSocket; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; + +@RestController +@Api(tags = "系统设置相关接口") +@RequestMapping("api/sysConfig") +public class SysConfigController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(SysConfigController.class); + + + @Resource + private SysConfigService sysConfigService; + + @Resource + private WebSocket webSocket; + + +// //告警阈值-超过阈值报警提示 +// @Scheduled(cron = "0 0 0/1 * * *") +// public void checkDataStorage() throws IllegalAccessException { +// SysConfig config = sysConfigService.query(SysConfigDto.builder().configKey(DataStorageConfigKey).build()).stream().findFirst().orElse(null); +// if (config == null) { +// return; +// } +// DataStorageConfigVo vo = JSONObject.parseObject(config.getConfigValue(), DataStorageConfigVo.class); +// if (DiskUtils.checkDiskUsage(AppConfig.getProfile(), vo.getThreshold())) { +// vo.setPath(AppConfig.getProfile()); +// vo.setUsage(BigDecimalUtil.round(DiskUtils.getDiskUsage(AppConfig.getProfile()), 1)); +// Message msg = Message.builder().type("内存阈值告警").message("数据存储路径:" + vo.getPath() + ";内存用量:" + vo.getUsage() + ";告警阈值:" + vo.getThreshold() + ";").build(); +// webSocket.sendBoxMessage(msg); +// } +// } + + @PostMapping("/check/dataStorage") + @ApiOperation(value = "数据存储-用量检查(前端轮询)") + public Result checkDataStorage() throws IllegalAccessException { + SysConfig config = sysConfigService.queryDataStorageConfig(); + if (config == null) { + return error("数据存储管理信息未配置"); + } + DataStorageConfigVo vo = JSONObject.parseObject(config.getConfigValue(), DataStorageConfigVo.class); + if (DiskUtils.checkDiskUsage(AppConfig.getProfile(), vo.getThreshold())) { + vo.setPath(AppConfig.getProfile()); + vo.setUsage(BigDecimalUtil.round(DiskUtils.getDiskUsage(AppConfig.getProfile()), 1)); + String msg = "[内存阈值告警]:数据存储路径:" + vo.getPath() + ";内存用量:" + vo.getUsage() + ";告警阈值:" + vo.getThreshold() + ";"; + return error(msg); + }else { + return success(); + } + } + + @PostMapping("/query/dataStorage") + @ApiOperation(value = "查询-数据存储管理") + public Result queryDataStorage() throws IllegalAccessException { + SysConfig config = sysConfigService.queryDataStorageConfig(); + if (config == null) { + return error("数据存储管理未配置,请联系管理员"); + } + DataStorageConfigVo vo = JSONObject.parseObject(config.getConfigValue(), DataStorageConfigVo.class); + vo.setPath(AppConfig.getProfile()); + vo.setUsage(BigDecimalUtil.round(DiskUtils.getDiskUsage(AppConfig.getProfile()), 1)); + return success(vo); + } + + @PostMapping("/update/dataStorage") + @ApiOperation(value = "修改-数据存储管理") + public Result updateDataStorage(@Validated @RequestBody DataStorageConfigDto dto) { + SysConfig config = sysConfigService.queryDataStorageConfig(); + if (config == null) { + return error("数据存储管理未配置,请联系管理员"); + } + config.setConfigValue(JSONObject.toJSONString(dto)); + return toResult(sysConfigService.updateById(config)); + } + + @PostMapping("/query/UISetting") + @ApiOperation(value = "查询-界面设置") + public Result queryUISetting() { + SysConfig config = sysConfigService.queryUISettingConfig(); + if (config == null) { + return error("界面设置未配置,请联系管理员"); + } + return success(JSONObject.parseObject(config.getConfigValue(), UISettingConfigVo.class)); + } + + @PostMapping("/update/UISetting") + @ApiOperation(value = "修改-界面设置") + public Result updateUISetting(@Validated @RequestBody UISettingConfigDto dto) { + SysConfig config = sysConfigService.queryUISettingConfig(); + if (config == null) { + return error("数据存储管理未配置,请联系管理员"); + } + config.setConfigValue(JSONObject.toJSONString(dto)); + return toResult(sysConfigService.updateById(config)); + } +} + diff --git a/box-web/src/main/java/com/mathvision/box/controller/sys/SysFileController.java b/box-web/src/main/java/com/mathvision/box/controller/sys/SysFileController.java new file mode 100644 index 0000000..60bd835 --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/sys/SysFileController.java @@ -0,0 +1,71 @@ +package com.mathvision.box.controller.sys; + +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.page.TableDataInfo; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.dao.domain.dto.SysFileAddDto; +import com.mathvision.box.dao.domain.entity.SysFile; +import com.mathvision.box.dao.domain.dto.SysFileQueryDto; +import com.mathvision.box.dao.service.SysFileService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@Api(tags = "文件管理相关接口") +@RequestMapping("api/sysFile") +public class SysFileController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(SysFileController.class); + private static final String AUDIO = "Audio"; + + @Resource + private SysFileService sysFileService; + + @PostMapping("/list/audio") + @ApiOperation(value = "查询分页-音频文件", notes = "排序序号前端自动排序1,2,3,4....10") + public TableDataInfo list(@RequestBody SysFileQueryDto sysFileDto) { + sysFileDto.setFileType(AUDIO); + startPage(); + List list = sysFileService.query(sysFileDto); + return getDataTable(list); + } + + @PostMapping("/add/audio") + @ApiOperation(value = "新增-音频文件") + public Result add(@Validated @RequestBody SysFileAddDto sysFileDto) { + Assert.isTrue(sysFileService.checkNameUnique(null, sysFileDto.getFileName()), "文件名称已存在"); + SysFile sysFile = new SysFile(); + BeanUtils.copyProperties(sysFileDto, sysFile); + sysFile.setFileType(AUDIO); + sysFile.setCreateUser(getUserId()); + return toResult(sysFileService.save(sysFile)); + } + + @PostMapping("/update/audio") + @ApiOperation(value = "修改-音频文件") + public Result update(@Validated @RequestBody SysFileAddDto sysFileDto) { + Assert.isTrue(sysFileService.checkNameUnique(sysFileDto.getFileId(), sysFileDto.getFileName()), "文件名称已存在"); + SysFile sysFile = new SysFile(); + BeanUtils.copyProperties(sysFileDto, sysFile); + sysFile.setFileType(AUDIO); + return toResult(sysFileService.updateById(sysFile)); + } + + @PostMapping("/delete") + @ApiOperation(value = "删除数据") + public Result delete(@RequestBody List idList) { + return toResult(sysFileService.removeBatchByIds(idList)); + } + + //todo web端语音报警联动 +} + diff --git a/box-web/src/main/java/com/mathvision/box/controller/sys/VideoController.java b/box-web/src/main/java/com/mathvision/box/controller/sys/VideoController.java new file mode 100644 index 0000000..ce89d94 --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/sys/VideoController.java @@ -0,0 +1,31 @@ +package com.mathvision.box.controller.sys; + +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.device.common.domin.PlayBack; +import com.mathvision.box.device.service.BoxVideoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +@RestController +@Api(tags = "盒子视频流相关接口") +@RequestMapping("api/video") +public class VideoController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(VideoController.class); + + @Resource + private BoxVideoService boxVideoService; + + @PostMapping("/getVideoUrl") + @ApiOperation(value = "获取实时/回放视频流") + public Result getVideoUrl(@RequestBody PlayBack playBack) { + return success(boxVideoService.getVideoUrl(playBack)); + } +} + diff --git a/box-web/src/main/java/com/mathvision/box/controller/ums/OauthController.java b/box-web/src/main/java/com/mathvision/box/controller/ums/OauthController.java new file mode 100644 index 0000000..5da644e --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/ums/OauthController.java @@ -0,0 +1,89 @@ +package com.mathvision.box.controller.ums; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mathvision.box.common.annotation.Log; +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.domain.entity.UserCache; +import com.mathvision.box.common.utils.common.MD5Utils; +import com.mathvision.box.common.utils.security.JwtUtils; +import com.mathvision.box.common.utils.security.SessionHolder; +import com.mathvision.box.dao.domain.dto.LoginDto; +import com.mathvision.box.dao.domain.entity.SysLog; +import com.mathvision.box.dao.domain.entity.UmsUser; +import com.mathvision.box.dao.domain.vo.LoginVo; +import com.mathvision.box.dao.service.SysLogService; +import com.mathvision.box.dao.service.UmsMenuService; +import com.mathvision.box.dao.service.UmsRoleService; +import com.mathvision.box.dao.service.UmsUserService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Set; + +/** + * @Description:登录授权相关接口 + */ +@RestController +@Api(tags = "登录授权相关接口") +@RequestMapping("api/oauth") +public class OauthController extends BaseController { + private static final Logger logger = LoggerFactory.getLogger(OauthController.class); + /** + * 服务对象 + */ + @Resource + private UmsUserService umsUserService; + @Resource + private UmsRoleService roleService; + @Resource + private UmsMenuService umsMenuService; + @Resource + private JwtUtils jwtUtils; + @Resource + private SysLogService sysLogService; + + /** + * 登录 + */ + @PostMapping("/login") + @ApiOperation(value = "登录") + //@Log(logType = "系统登录", logContent = "登录系统") + public Result login(@RequestBody LoginDto loginDto, HttpServletRequest request) { + UmsUser user; + { + user = umsUserService.getOne(new QueryWrapper().eq("login_name", loginDto.getLoginName())); + if (user == null || !StringUtils.equals(user.getPassword(), MD5Utils.inputPassToDBPass(loginDto.getPassword(), user.getSalt()))) { + return Result.INVALID_USER_PASS; + } + } + Set roleSet = roleService.selectRoleKeys(user.getUserId()); + Set permsSet = umsMenuService.selectPermsByUserId(user.getUserId()); + UserCache cache = UserCache.builder().userId(user.getUserId()).userName(user.getUserName()).loginName(user.getLoginName()).permissions(permsSet).timeStamp(System.currentTimeMillis()).build(); + String Authorization = jwtUtils.getToken(cache); + SessionHolder.set(cache); + + sysLogService.save(SysLog.builder().logType("系统登录").logContent(user.getUserName() + "登录系统").build()); + return success(LoginVo.builder().userId(user.getUserId()).loginName(user.getLoginName()).userName(user.getUserName()).avatar(user.getAvatar()).phone(user.getPhone()).email(user.getEmail()).Authorization(Authorization).roles(roleSet).permissions(permsSet).build()); + } + + /** + * 登出 + */ + @PostMapping("/logout") + @ApiOperation(value = "登出") + @Log(logType = "系统登出", logContent = "登出系统") + public Result logout() { + SessionHolder.clear(); + return success(); + } +} diff --git a/box-web/src/main/java/com/mathvision/box/controller/ums/UmsMenuController.java b/box-web/src/main/java/com/mathvision/box/controller/ums/UmsMenuController.java new file mode 100644 index 0000000..0cd5464 --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/ums/UmsMenuController.java @@ -0,0 +1,77 @@ +package com.mathvision.box.controller.ums; + +import com.mathvision.box.common.annotation.Log; +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.page.TableDataInfo; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.dao.domain.dto.UmsMenuDto; +import com.mathvision.box.dao.domain.entity.UmsMenu; +import com.mathvision.box.dao.service.UmsMenuService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@Api(tags = "菜单表") +@RequestMapping("api/umsMenu") +public class UmsMenuController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(UmsMenuController.class); + + @Resource + private UmsMenuService umsMenuService; + + @PostMapping("/list") + @ApiOperation(value = "查询分页数据") + public TableDataInfo list(@RequestBody UmsMenuDto umsMenuDto) { + startPage(); + return getDataTable(umsMenuService.query(umsMenuDto)); + } + + @PostMapping("/listAll") + @ApiOperation(value = "查询所有数据") + public Result listAll() { + return success(umsMenuService.list()); + } + + @PostMapping("/query") + @ApiOperation(value = "查询详情数据") + public Result query(@RequestParam Long id) { + return success(umsMenuService.getById(id)); + } + + @PostMapping("/add") + @ApiOperation(value = "新增数据") + @Log(logType = "菜单-新建菜单", logContent = "新建菜单") + public Result add(@Validated @RequestBody UmsMenuDto umsMenuDto) { + UmsMenu umsMenu = new UmsMenu(); + BeanUtils.copyProperties(umsMenuDto, umsMenu); + umsMenu.setCreateUser(getUserId()); + return toResult(umsMenuService.save(umsMenu)); + } + + @PostMapping("/update") + @ApiOperation(value = "修改数据") + @Log(logType = "菜单-修改菜单", logContent = "修改菜单") + public Result update(@Validated @RequestBody UmsMenuDto umsMenuDto) { + UmsMenu umsMenu = new UmsMenu(); + BeanUtils.copyProperties(umsMenuDto, umsMenu); + umsMenu.setUpdateUser(getUserId()); + return toResult(umsMenuService.updateById(umsMenu)); + } + + @PostMapping("/delete") + @ApiOperation(value = "删除数据") + @Log(logType = "菜单-删除菜单", logContent = "删除菜单") + public Result delete(@RequestBody List idList) { + return toResult(umsMenuService.removeBatchByIds(idList)); + } +} + diff --git a/box-web/src/main/java/com/mathvision/box/controller/ums/UmsOrganizationController.java b/box-web/src/main/java/com/mathvision/box/controller/ums/UmsOrganizationController.java new file mode 100644 index 0000000..e8854dc --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/ums/UmsOrganizationController.java @@ -0,0 +1,73 @@ +package com.mathvision.box.controller.ums; + +import com.mathvision.box.common.annotation.Auth; +import com.mathvision.box.common.annotation.Log; +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.dao.domain.dto.UmsOrganizationDto; +import com.mathvision.box.dao.domain.entity.UmsOrganization; +import com.mathvision.box.dao.service.UmsOrganizationService; +import com.mathvision.box.dao.service.impl.CacheService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + +@RestController +@Api(tags = "组织信息表") +@RequestMapping("api/umsOrganization") +public class UmsOrganizationController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(UmsOrganizationController.class); + + @Resource + private UmsOrganizationService umsOrganizationService; + + + @PostMapping("/tree") + @ApiOperation(value = "组织树") +// @Auth(permission = "system-user:view") + public Result> tree() { +// return success(umsOrganizationService.quarryTree()); + return success(umsOrganizationService.list()); + } + + @PostMapping("/query") + @ApiOperation(value = "查询详情数据") + public Result query(@RequestParam Long id) { + return success(umsOrganizationService.getById(id)); + } + + @PostMapping("/add") + @ApiOperation(value = "新增数据") +// @Auth(permission = "api:umsOrganization:add") + @Log(logType = "组织架构-添加", logContent = "添加组织/岗位") + public Result add(@Validated @RequestBody UmsOrganizationDto umsOrganizationDto) { + umsOrganizationDto.setCreateUser(getUserId()); + return umsOrganizationService.add(umsOrganizationDto) ? success("添加组织/岗位:" + umsOrganizationDto.getOrganizationName()) : error(); + } + + @PostMapping("/update") + @ApiOperation(value = "修改数据") +// @Auth(permission = "api:umsOrganization:update") + @Log(logType = "组织架构-编辑", logContent = "修改组织/岗位") + public Result update(@Validated @RequestBody UmsOrganizationDto umsOrganizationDto) { + umsOrganizationDto.setUpdateUser(getUserId()); + return umsOrganizationService.update(umsOrganizationDto) ? success("修改组织/岗位:" + umsOrganizationDto.getOrganizationName()) : error(); + } + + @PostMapping("/delete") + @ApiOperation(value = "删除数据") +// @Auth(permission = "api:umsOrganization:delete") + @Log(logType = "组织架构-删除", logContent = "删除组织/岗位") + public Result delete(@RequestBody List idList) { + String msg = "删除组织/岗位:" + CacheService.getOrganization(idList.stream().toArray(Long[]::new)).stream().map(UmsOrganization::getOrganizationName).collect(Collectors.toList()); + return umsOrganizationService.delete(idList) ? success(msg) : error(); + } +} \ No newline at end of file diff --git a/box-web/src/main/java/com/mathvision/box/controller/ums/UmsRoleController.java b/box-web/src/main/java/com/mathvision/box/controller/ums/UmsRoleController.java new file mode 100644 index 0000000..7383c16 --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/ums/UmsRoleController.java @@ -0,0 +1,93 @@ +package com.mathvision.box.controller.ums; + +import com.mathvision.box.common.annotation.Auth; +import com.mathvision.box.common.annotation.Log; +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.page.TableDataInfo; +import com.mathvision.box.common.enums.ConfigEnum; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.dao.domain.dto.UmsRoleDto; +import com.mathvision.box.dao.domain.entity.UmsRole; +import com.mathvision.box.dao.service.UmsRoleService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.Assert; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +@RestController +@Api(tags = "角色表") +@RequestMapping("api/umsRole") +public class UmsRoleController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(UmsRoleController.class); + + @Resource + private UmsRoleService umsRoleService; + + @PostMapping("/list") + @ApiOperation(value = "查询分页数据") +// @Auth(permission = "system-role:view") + public TableDataInfo list(@RequestBody UmsRoleDto umsRoleDto) { + startPage(); + return getDataTable(umsRoleService.query(umsRoleDto)); + } + + @PostMapping("/query") + @ApiOperation(value = "查询详情数据") + public Result query(@RequestParam Long id) { + return success(umsRoleService.getById(id)); + } + + @PostMapping("/add") + @ApiOperation(value = "新增数据") +// @Auth(permission = "api:umsRole:add") + @Log(logType = "角色管理-新建", logContent = "新建角色") + public Result add(@Validated @RequestBody UmsRoleDto umsRoleDto) { + Assert.isTrue(umsRoleService.checkNameUnique(null, umsRoleDto.getRoleName()), "角色名称已存在!"); +// Assert.isTrue(umsRoleService.checkCodeUnique(null, umsRoleDto.getRoleKey()), "角色编码已存在!"); + UmsRole umsRole = new UmsRole(); + BeanUtils.copyProperties(umsRoleDto, umsRole); + umsRole.setCreateUser(getUserId()); + if (umsRoleService.save(umsRole)) { + umsRoleService.bindMenu(umsRole.getRoleId(), umsRoleDto.getMenuIdList()); + return success("新建角色:" + umsRoleDto.getRoleName()); + } else { + return error(); + } + } + + @PostMapping("/update") + @ApiOperation(value = "修改数据") +// @Auth(permission = "api:umsRole:update") + @Log(logType = "角色管理-修改", logContent = "修改角色") + public Result update(@Validated @RequestBody UmsRoleDto umsRoleDto) { + Assert.isTrue(umsRoleService.checkNameUnique(umsRoleDto.getRoleId(), umsRoleDto.getRoleName()), "角色名称已存在!"); +// Assert.isTrue(umsRoleService.checkCodeUnique(null, umsRoleDto.getRoleKey()), "角色编码已存在!"); + UmsRole umsRole = new UmsRole(); + BeanUtils.copyProperties(umsRoleDto, umsRole); + umsRole.setUpdateUser(getUserId()); + return umsRoleService.updateById(umsRole) && umsRoleService.bindMenu(umsRoleDto.getRoleId(), umsRoleDto.getMenuIdList()) ? success("修改角色:" + umsRoleDto.getRoleName()) : error(); + } + + @PostMapping("/delete") + @ApiOperation(value = "删除数据") +// @Auth(permission = "api:umsRole:delete") + @Log(logType = "角色管理-删除", logContent = "删除角色") + public Result delete(@RequestBody List idList) { + Assert.isTrue(Collections.disjoint(idList, Arrays.stream(ConfigEnum.DEFAULT_ROLE_IDS.getData().split(",")).map(String::trim).map(Long::valueOf).collect(Collectors.toList())), "基础信息不允许删除!"); + List list = umsRoleService.listByIds(idList); + List nameList = list.stream().map(e -> e.getRoleName()).collect(java.util.stream.Collectors.toList()); + return umsRoleService.removeBatchByIds(idList) ? success("删除角色:" + String.join(",", nameList)) : error(); + } +} + diff --git a/box-web/src/main/java/com/mathvision/box/controller/ums/UmsUserController.java b/box-web/src/main/java/com/mathvision/box/controller/ums/UmsUserController.java new file mode 100644 index 0000000..1b02eb9 --- /dev/null +++ b/box-web/src/main/java/com/mathvision/box/controller/ums/UmsUserController.java @@ -0,0 +1,154 @@ +package com.mathvision.box.controller.ums; + +import com.mathvision.box.common.annotation.Auth; +import com.mathvision.box.common.annotation.Log; +import com.mathvision.box.common.core.controller.BaseController; +import com.mathvision.box.common.core.domain.Result; +import com.mathvision.box.common.core.page.TableDataInfo; +import com.mathvision.box.common.utils.bean.BeanUtils; +import com.mathvision.box.common.utils.common.MD5Utils; +import com.mathvision.box.common.utils.common.StringUtils; +import com.mathvision.box.common.utils.poi.ExcelUtil; +import com.mathvision.box.dao.domain.dto.UmsUserAddDto; +import com.mathvision.box.dao.domain.dto.UmsUserPasswordDto; +import com.mathvision.box.dao.domain.dto.UmsUserQueryDto; +import com.mathvision.box.dao.domain.dto.UmsUserSelfDto; +import com.mathvision.box.dao.domain.entity.UmsUser; +import com.mathvision.box.dao.service.UmsUserService; +import com.mathvision.box.dao.service.impl.CacheService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.Assert; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +@RestController +@Api(tags = "用户表") +@RequestMapping("api/umsUser") +public class UmsUserController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(UmsUserController.class); + + @Resource + private UmsUserService umsUserService; + + @PostMapping("/list") + @ApiOperation(value = "分页查询数据") + public TableDataInfo list(@RequestBody UmsUserQueryDto umsUserDto) { + startPage(); + return getDataTable(umsUserService.list(umsUserDto)); + } + + @PostMapping("/query") + @ApiOperation(value = "查询详情") + public Result query(@RequestParam Long userId) { + return success(umsUserService.getById(userId)); + } + + @PostMapping("/queryByIds") + @ApiOperation(value = "查询多个") + public Result queryByIds(@RequestBody List idList) { + return success(umsUserService.listByIds(idList)); + } + + @PostMapping("/add") + @ApiOperation(value = "新增") +// @Auth(permission = "api:umsUser:add") + @Log(logType = "组织架构-新建员工", logContent = "新建用户") + public Result add(@Validated @RequestBody UmsUserAddDto umsUserDto) { + umsUserDto.setCreateUser(getUserId()); + return umsUserService.add(umsUserDto) ? success("新建用户:" + umsUserDto.getUserName()) : error(); + } + + @PostMapping("/update") + @ApiOperation(value = "修改") +// @Auth(permission = "api:umsUser:update") + @Log(logType = "组织架构-账号编辑", logContent = "编辑账号") + public Result update(@Validated @RequestBody UmsUserAddDto umsUserDto) { + umsUserDto.setUpdateUser(getUserId()); + return umsUserService.update(umsUserDto) ? success("编辑账号:" + umsUserDto.getUserName()) : error(); + } + + @PostMapping("/update/selfInfo") + @ApiOperation(value = "修改个人基本信息") + public Result selfInfo(@Validated @RequestBody UmsUserSelfDto userSelfDto) { + UmsUserAddDto umsUserDto = new UmsUserAddDto(); + BeanUtils.copyProperties(userSelfDto, umsUserDto); + umsUserDto.setUserId(getUserId()); + return umsUserService.update(umsUserDto) ? success() : error(); + } + + @PostMapping("/update/selfPassword") + @ApiOperation(value = "修改个人密码") + public Result selfPassword(@Validated @RequestBody UmsUserPasswordDto umsUserPasswordDto) { + UmsUser user = umsUserService.getById(getUserId()); + Assert.isTrue(user.getPassword().equals(MD5Utils.inputPassToDBPass(umsUserPasswordDto.getOldPassword(), user.getSalt())), "操作失败,旧密码错误,请重新输入!"); + Assert.isTrue(!umsUserPasswordDto.getOldPassword().equals(umsUserPasswordDto.getNewPassword()), "操作失败,旧密码与新密码一致,请重新输入!"); + Assert.isTrue(umsUserPasswordDto.getNewPassword().equals(umsUserPasswordDto.getCheckPassword()), "操作失败,两次输入的新密码不一致,请重新输入!"); + String salt = MD5Utils.randomSalt(); + user.setPassword(MD5Utils.inputPassToDBPass(umsUserPasswordDto.getNewPassword(), salt)); + user.setSalt(salt); + user.setCreateUser(getUserId()); + return umsUserService.updateById(user) ? success() : error(); + } + + @PostMapping("/delete") + @ApiOperation(value = "删除") +// @Auth(permission = "api:umsUser:delete") + @Log(logType = "组织架构-用户删除", logContent = "删除用户") + public Result delete(@RequestBody List idList) { + return umsUserService.delete(idList) ? success("删除用户:" + String.join(",", CacheService.getUserName(idList))) : error(); + } + + @PostMapping("/export") + @ApiOperation(value = "导出用户数据excel") + public void export(@RequestBody List idList, HttpServletResponse response) throws Exception { + List list = umsUserService.listByIds(idList); + ExcelUtil util = new ExcelUtil(UmsUser.class); + util.exportExcel(response, list, "用户数据"); + } + + @PostMapping("/importData") + @ApiOperation(value = "导入用户数据excel") + public Result importData(MultipartFile file, @RequestParam(required = false) Long organizationId) throws Exception { + ExcelUtil util = new ExcelUtil<>(UmsUser.class); + List userList = util.importExcel(file.getInputStream()); + String salt = MD5Utils.randomSalt(); + + for (UmsUser user : userList) { + if (StringUtils.isBlank(user.getPassword())) { + user.setPassword("123456"); + } + if (StringUtils.isBlank(user.getStatus())) { + user.setStatus("0"); + } + + user.setPassword(MD5Utils.inputPassToDBPass(user.getPassword(), salt)); + user.setSalt(salt); + user.setCreateUser(getUserId()); + UmsUserAddDto umsUserDto = new UmsUserAddDto(); + BeanUtils.copyProperties(user, umsUserDto); + + if (organizationId != null) { + umsUserDto.setOrganizationId(organizationId); + } + umsUserService.add(umsUserDto); + } + return success("用户数据导入成功"); + } + + @PostMapping("/importTemplate") + @ApiOperation(value = "导入用户数据excel模板") + public void importTemplate(HttpServletResponse response) { + ExcelUtil util = new ExcelUtil(UmsUser.class); + util.importTemplateExcel(response, "用户数据"); + } +} + diff --git a/box-web/src/main/resources/application-dev.yml b/box-web/src/main/resources/application-dev.yml new file mode 100644 index 0000000..eb60343 --- /dev/null +++ b/box-web/src/main/resources/application-dev.yml @@ -0,0 +1,108 @@ +# 项目相关配置 +app: + # 名称 + name: 盒子 + # 版本 + version: 1.0.0 + # 版权 + copyright: 成都积络科技版权所有 + # 版权年份 + copyrightYear: 2025 + # 文件路径 + profile: "D:/data/box" + # 数据相关配置 + data: + # 每次处理的批次大小 + batch-size: 100 + # 数据定时清理保存 + cleanup: + # 保留天数 + retention-days: 90 + + +# 开发环境配置 +server: + # 服务器的HTTP端口,默认为80 + port: 80 + servlet: + # 应用的访问路径 + context-path: / + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # 连接数满后的排队数,默认为100 + accept-count: 1000 + threads: + # tomcat最大线程数,默认为200 + max: 800 + # Tomcat启动初始化的线程数,默认值10 + min-spare: 100 + +# 日志配置 +logging: + level: + com.yyy: debug + org.mybatis: debug + org.springframework: debug + +# mysql连接信息 +spring: + datasource: + driver-class-name: org.sqlite.JDBC + url: jdbc:sqlite:D:\\data\\box\\db\\box.db + druid: + validation-query: SELECT 1 +# druid: +# login-timeout: 30000 +# # 连接池基础配置 +# initial-size: 1 +# max-active: 1 # SQLite建议设置为1 +# min-idle: 1 +# max-wait: 3000 +# # SQLite特殊优化参数 +# validation-query: SELECT 1 +# test-on-borrow: true +# test-while-idle: true + +box: # 盒子相关配置 + heartbeat: 600000 + hc: + sdk: # 海康SDK配置 + path: D:\\env\\hikvision\\libs\\HCNetSDK.dll # 必须\\转义否则会报错 + connect-timeout: 2000 + retry-count: 1 + reconnect-interval: 60000 + enable: true + corerain: # 鲲云相关配置 + trace: 20000 # 报警轮询间隔时间 + alarm: + # 报警修正 + fix-process: false # 是否修正过程 + fix-result: false # 是否修正结果 + # 报警过滤相关配置 + filter-enabled: false # 是否开启报警过滤 + filter-type: consecutive_times # 报警过滤类型:consecutive_times: 连续次数,interval_time: 时间间隔,window_count: 滑动窗口计数 + filter-count_threshold: 2 # 连续次数阈值 + filter-time_threshold: 10 # 时间间隔阈值 + # 报警模拟数据 + mock-enabled: true + mock-fixed-rate: 20000 + types: + # 海康报警类型 + COMM_THERMOMETRY_ALARM: true #温度报警 + H930_MODEL_SPD: true #抽烟打电话 + # 鲲云报警类型 + static_ground: true #静电接地 + oil_pipe_remove: true #油管拆除顺序 + car_location: true #车辆位置 + car_leave: true #车辆离场 + personnel_break_in: true #人员闯入 + fire_equipment_recover: true #设备回收 + protective_tools: true #防护工具 + plug_connection_status: true #油管连接 + static_wire_disconnect: true #静电连接断开 + protective_suit: true #防护穿戴 + anti_rolling_device: true #防溜车器 + stable_oil_time: true #稳油时间 + personnel_present: true #人员存在 + diff --git a/box-web/src/main/resources/application-prod.yml b/box-web/src/main/resources/application-prod.yml new file mode 100644 index 0000000..9fe1139 --- /dev/null +++ b/box-web/src/main/resources/application-prod.yml @@ -0,0 +1,94 @@ +# 项目相关配置 +app: + # 名称 + name: 盒子 + # 版本 + version: 1.0.0 + # 版权 + copyright: 成都积络科技版权所有 + # 版权年份 + copyrightYear: 2025 + # 文件路径 + profile: "/data/box" + # 数据相关配置 + data: + # 数据定时清理保存 + cleanup: + # 保留天数 + retention-days: 90 + # 每次处理的批次大小 + batch-size: 1000 + +# 开发环境配置 +server: + # 服务器的HTTP端口,默认为80 + port: 8380 + servlet: + # 应用的访问路径 + context-path: / + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # 连接数满后的排队数,默认为100 + accept-count: 1000 + threads: + # tomcat最大线程数,默认为200 + max: 800 + # Tomcat启动初始化的线程数,默认值10 + min-spare: 100 + +# 日志配置 +logging: + level: + com.mathvision: debug + org.springframework: warn + +# 数据源配置 +spring: + datasource: + driver-class-name: org.sqlite.JDBC + url: jdbc:sqlite:/data/box/db/box.db + druid: + validation-query: SELECT 1 + +box: # 盒子相关配置 + heartbeat: 600000 + hc: + sdk: # 海康SDK配置 + path: /opt/hikvision/libs/libhcnetsdk.so + connect-timeout: 2000 + retry-count: 1 + reconnect-interval: 60000 + enable: false + corerain: # 鲲云相关配置 + trace: 60000 # 报警轮询间隔时间 + alarm: + # 报警修正 + fix-process: false # 是否修正过程 + fix-result: false # 是否修正结果 + # 报警过滤相关配置 + filter-enabled: false # 是否开启报警过滤 + filter-type: consecutive_times # 报警过滤类型:consecutive_times: 连续次数,interval_time: 时间间隔,window_count: 滑动窗口计数 + filter-count_threshold: 2 # 连续次数阈值 + filter-time_threshold: 10 # 时间间隔阈值 + # 报警模拟数据 + mock-enabled: true + mock-fixed-rate: 30000 + types: + # 海康报警类型 + COMM_THERMOMETRY_ALARM: true #温度报警 + H930_MODEL_SPD: true #抽烟打电话 + # 鲲云报警类型 + static_ground: true #静电接地 + oil_pipe_remove: true #油管拆除顺序 + car_location: true #车辆位置 + car_leave: true #车辆离场 + personnel_break_in: true #人员闯入 + fire_equipment_recover: true #设备回收 + protective_tools: true #防护工具 + plug_connection_status: true #油管连接 + static_wire_disconnect: true #静电连接断开 + protective_suit: true #防护穿戴 + anti_rolling_device: true #防溜车器 + stable_oil_time: true #稳油时间 + personnel_present: true #人员存在 \ No newline at end of file diff --git a/box-web/src/main/resources/application.yml b/box-web/src/main/resources/application.yml new file mode 100644 index 0000000..0f1128c --- /dev/null +++ b/box-web/src/main/resources/application.yml @@ -0,0 +1,70 @@ +# Spring配置 +spring: + application: + name: box + profiles: + active: dev + jackson: + time-zone: GMT + date-format: yyyy-MM-dd HH:mm:ss + # 文件上传 + servlet: + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB + # mvc策略 + mvc: + pathmatch: + matching-strategy: ANT_PATH_MATCHER + +# MyBatis +mybatis: + # 搜索指定包别名 + typeAliasesPackage: com.mathvision.box.dao.domain.entity + # 配置mapper的扫描,找到所有的mapper.xml映射文件 + mapperLocations: classpath*:mapper/*Mapper.xml + # 加载全局的配置文件 + configLocation: classpath:mybatis/mybatis-config.xml + +# Swagger配置 +swagger: + base-package: "com.mathvision.box" + description: " + 接口中涉及password字段采用aes加密 + 返回结果码: + success(200, \"成功\"), + invalidUserOrPassword(300, \"用户名或者密码错误!\"), + illegal_argument(400, \"参数错误!\"), + need_login(401, \"未登录!\"), + not_support_operate(404, \"不支持的请求!\"), + not_privileged(405, \"无权限执行该操作!\"), + invalid_license(406, \"您的证书无效,请核查服务器是否取得授权或重新申请证书!\"), + system_error(500, \"系统异常!\"), + operate_failure(503, \"操作失败!\"); + 分页查询POST:/api/xxx/list?pageNum=1&pageSize=10&orderByColumn=createTime&isAsc=desc + pageNum:当前页码(可选 默认1)、pageSize:分页大小(可选 默认10)、orderByColumn:排序列(可选)、isAsc:排序规则(可选asc、desc) + " + version: "1.0" + title: "盒子接口文档" + enabled: true #是否开启swagger + +jwt: + config: + header: Authorization + refreshTime: 3600000 # 刷新时间 1小时 + expiresTime: 7200000 # 过期 2小时 + secretKey: "!Q@W#E$R_MATHVISION_###" + +aes: + key: "dbf13279f5bc85b038cbc9ee21dfbc03" + +# 防止XSS攻击 +xss: + # 过滤开关 + enabled: false + # 排除链接(多个用逗号分隔) + excludes: /system/notice/* + # 匹配链接 + urlPatterns: /system/*,/monitor/*,/tool/* diff --git a/box-web/src/main/resources/banner.txt b/box-web/src/main/resources/banner.txt new file mode 100644 index 0000000..de2209a --- /dev/null +++ b/box-web/src/main/resources/banner.txt @@ -0,0 +1,22 @@ +//////////////////////////////////////////////////////////////////// +// _ooOoo_ // +// o8888888o // +// 88" . "88 // +// (| ^_^ |) // +// O\ = /O // +// ____/`---'\____ // +// .' \\| |// `. // +// / \\||| : |||// \ // +// / _||||| -:- |||||- \ // +// | | \\\ - /// | | // +// | \_| ''\---/'' | | // +// \ .-\__ `-` ___/-. / // +// ___`. .' /--.--\ `. . ___ // +// ."" '< `.___\_<|>_/___.' >'"". // +// | | : `- \`.;`\ _ /`;.`/ - ` : | | // +// \ \ `-. \_ __\ /__ _/ .-` / / // +// ========`-.____`-.___\_____/___.-`____.-'======== // +// `=---=' // +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // +// 佛祖保佑 永不宕机 永无BUG // +//////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/box-web/src/main/resources/logback-spring.xml b/box-web/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..b09bcaa --- /dev/null +++ b/box-web/src/main/resources/logback-spring.xml @@ -0,0 +1,152 @@ + + + + + + + box + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${log.level} + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + ${log.path}/${log.name}/${log.name}-info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %.-${log.length}msg%n + UTF-8 + + + + ${log.path}/${log.name}/${log.name}-info-%d{yyyy-MM-dd}.%i.log + + ${log.max.file} + + ${log.max.history} + + ${log.max.size} + + + + INFO + ACCEPT + DENY + + + + + + ${log.path}/${log.name}/${log.name}-warn.log + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %.-${log.length}msg%n + UTF-8 + + + ${log.path}/${log.name}/${log.name}-warn-%d{yyyy-MM-dd}.%i.log + ${log.max.file} + ${log.max.history} + ${log.max.size} + + + WARN + ACCEPT + DENY + + + + + + ${log.path}/${log.name}/${log.name}-error.log + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %.-${log.length}msg%n + UTF-8 + + + ${log.path}/${log.name}/${log.name}-error-%d{yyyy-MM-dd}.%i.log + ${log.max.file} + ${log.max.history} + ${log.max.size} + + + ERROR + ACCEPT + DENY + + + + + + ${log.path}/${log.name}/${log.name}-protocol.log + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %.-${log.length}msg%n + UTF-8 + + + ${log.path}/${log.name}/${log.name}-protocol-%d{yyyy-MM-dd}.%i.log + ${log.max.file} + ${log.max.history} + ${log.max.size} + + + + + + ${log.path}/${log.name}/${log.name}-message.log + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %.-${log.length}msg%n + UTF-8 + + + ${log.path}/${log.name}/${log.name}-message-%d{yyyy-MM-dd}.%i.log + ${log.max.file} + ${log.max.history} + ${log.max.size} + + + + + + + + + + + + + + \ No newline at end of file diff --git a/box-web/src/main/resources/mybatis/mybatis-config.xml b/box-web/src/main/resources/mybatis/mybatis-config.xml new file mode 100644 index 0000000..7133b91 --- /dev/null +++ b/box-web/src/main/resources/mybatis/mybatis-config.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..0c09b75 --- /dev/null +++ b/pom.xml @@ -0,0 +1,251 @@ + + + 4.0.0 + + com.mathvision + box + pom + 1.0-SNAPSHOT + + box + http://127.0.0.1:80 + 盒子 + + + org.springframework.boot + spring-boot-starter-parent + 2.7.18 + + + + + 2.7.18 + 8 + 3.49.1.0 + 1.2.20 + 3.5.1 + 1.4.7 + 1.18.12 + 2.16.1 + 3.9 + 4.6.10 + 3.0.3 + 1.2.83 + 3.10.3 + 31.1-jre + 5.2.2 + 5.7.1 + 4.3.1 + + + + box-device + box-web + box-framework + box-message + box-common + box-dao + + + + + + + org.springframework.boot + spring-boot-starter-web + ${spring.version} + + + org.springframework.boot + spring-boot-starter-aop + ${spring.version} + + + org.springframework.boot + spring-boot-starter-validation + ${spring.version} + + + org.springframework.boot + spring-boot-starter-websocket + ${spring.version} + + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + org.xerial + sqlite-jdbc + ${sqlite.version} + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + + com.github.pagehelper + pagehelper-spring-boot-starter + ${pagehelper-boot.version} + + + + + org.projectlombok + lombok + ${lombok.version} + provided + + + commons-io + commons-io + ${commons-io.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + cn.hutool + hutool-all + ${hutool.version} + + + com.google.guava + guava + ${guava.version} + + + + + + com.github.xiaoymin + knife4j-spring-boot-starter + ${knife4j.version} + + + + + com.alibaba + fastjson + ${fastjson.version} + + + + + com.auth0 + java-jwt + ${jwt.version} + + + + + org.apache.poi + poi-ooxml + ${poi.version} + + + org.apache.poi + poi-scratchpad + ${poi.version} + + + + + com.opencsv + opencsv + ${opencsv.version} + + + + com.squareup.okhttp3 + okhttp + ${okhttp3.version} + + + + + + + org.projectlombok + lombok + provided + + + commons-io + commons-io + + + org.apache.commons + commons-lang3 + + + cn.hutool + hutool-all + + + com.alibaba + fastjson + + + com.google.guava + guava + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + + + + + + public + aliyun nexus + https://maven.aliyun.com/repository/public + + true + + + + + + + public + aliyun nexus + https://maven.aliyun.com/repository/public + + true + + + false + + + + \ No newline at end of file