diff --git a/epmet-plugins-common/src/main/java/com/epmet/plugin/commons/redis/RedisKeys.java b/epmet-plugins-common/src/main/java/com/epmet/plugin/commons/redis/RedisKeys.java new file mode 100644 index 0000000..b5f3a6e --- /dev/null +++ b/epmet-plugins-common/src/main/java/com/epmet/plugin/commons/redis/RedisKeys.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.plugin.commons.redis; + +/** + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public class RedisKeys { + + /** + * redis前缀 + */ + private static String rootPrefix = "epmet:"; + + /** + * 海康accessToken + */ + public static String getHikTokenKey() { + return "hik:token"; + } + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/.gitkeep b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/HikCommunityInfoDTO.java b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/HikCommunityInfoDTO.java new file mode 100644 index 0000000..72e1d58 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/HikCommunityInfoDTO.java @@ -0,0 +1,94 @@ +package com.epmet.plugin.power.dto.hik; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 海康社区信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Data +public class HikCommunityInfoDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 删除标记 0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 客户ID + */ + private String customerId; + + /** + * 社区ID + */ + private String communityId; + + /** + * 社区名称 + */ + private String communityName; + + /** + * 省代号 + */ + private String provinceCode; + + /** + * 市代号 + */ + private String cityCode; + + /** + * 区代号 + */ + private String countyCode; + + /** + * 经度坐标值 + */ + private String longitude; + + /** + * 维度坐标值 + */ + private String latitude; + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/HikDeviceInfoDTO.java b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/HikDeviceInfoDTO.java new file mode 100644 index 0000000..dc9bac4 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/HikDeviceInfoDTO.java @@ -0,0 +1,94 @@ +package com.epmet.plugin.power.dto.hik; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 海康设备信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Data +public class HikDeviceInfoDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 删除标记 0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 客户ID + */ + private String customerId; + + /** + * 社区ID + */ + private String communityId; + + /** + * 设备ID + */ + private String deviceId; + + /** + * 设备名称 + */ + private String deviceName; + + /** + * 设备型号 + */ + private String deviceModel; + + /** + * 设备序列号 + */ + private String deviceSerial; + + /** + * 设备状态,0:离线,1:在线 + */ + private String deviceStatus; + + /** + * 设备路径 + */ + private String devicePath; + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/HikErrorInfoDTO.java b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/HikErrorInfoDTO.java new file mode 100644 index 0000000..a06778c --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/HikErrorInfoDTO.java @@ -0,0 +1,79 @@ +package com.epmet.plugin.power.dto.hik; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 海康设备推送失败信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-23 + */ +@Data +public class HikErrorInfoDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 删除标记 0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 客户ID + */ + private String customerId; + + /** + * 身份证号 + */ + private String idCard; + + /** + * 错误类型 0:token,1:人员,2权限 + */ + private String errorType; + + /** + * 错误详情 + */ + private String errorInfo; + + /** + * 引用ID + */ + private String referenceId; + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/form/HikAuthorityFormDTO.java b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/form/HikAuthorityFormDTO.java new file mode 100644 index 0000000..3f436c1 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/form/HikAuthorityFormDTO.java @@ -0,0 +1,27 @@ +package com.epmet.plugin.power.dto.hik.form; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 海康社区人员权限信息下放 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Data +public class HikAuthorityFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + private String communityId; + + private String personId; + + private Integer personType; + + private String deviceId; + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/form/HikPersonFormDTO.java b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/form/HikPersonFormDTO.java new file mode 100644 index 0000000..1a7eedc --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/hik/form/HikPersonFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.plugin.power.dto.hik.form; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 海康社区人员信息下放 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Data +public class HikPersonFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + private String unionId; + + private String personName; + + private Integer gender; + + private Integer credentialType; + + private String credentialNumber; + + private String mobile; + + private String faceUrl; + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/pom.xml b/epmet-plugins-module/pli-power-base/pli-power-base-server/pom.xml index af1b196..adfd171 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/pom.xml +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/pom.xml @@ -164,6 +164,11 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + https://api2.hik-cloud.com + 90688b09bb9d40088f7be404ccb347c7 + 7b1940707a4240be9c794c5a967a30c9 @@ -193,7 +198,7 @@ false - 192.168.43.104 + 192.168.43.186 false @@ -214,6 +219,11 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + https://api2.hik-cloud.com + 90688b09bb9d40088f7be404ccb347c7 + 7b1940707a4240be9c794c5a967a30c9 @@ -268,6 +278,11 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + https://api2.hik-cloud.com + 90688b09bb9d40088f7be404ccb347c7 + 7b1940707a4240be9c794c5a967a30c9 @@ -317,6 +332,11 @@ SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1 + + + https://api2.hik-cloud.com + 90688b09bb9d40088f7be404ccb347c7 + 7b1940707a4240be9c794c5a967a30c9 @@ -369,6 +389,11 @@ 60 epmet-user callerRunsPolicy + + + https://api2.hik-cloud.com + 90688b09bb9d40088f7be404ccb347c7 + 7b1940707a4240be9c794c5a967a30c9 diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/config/HikCloudProperties.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/config/HikCloudProperties.java new file mode 100644 index 0000000..815d47f --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/config/HikCloudProperties.java @@ -0,0 +1,54 @@ +package com.epmet.plugin.power.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * 海康设备参数 + * + * @author zhy + * @date 2022/5/20 14:59 + */ +@Configuration +@ConfigurationProperties(prefix = "hik.cloud") +public class HikCloudProperties { + + /** + * 应用ID + */ + private String url; + + /** + * 应用KEY + */ + private String client; + + /** + * 生成AccessToken密钥 + */ + private String secret; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + public String getSecret() { + return secret; + } + + public void setSecret(String secret) { + this.secret = secret; + } +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/controller/HikCommunityInfoController.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/controller/HikCommunityInfoController.java new file mode 100644 index 0000000..1639f11 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/controller/HikCommunityInfoController.java @@ -0,0 +1,94 @@ +package com.epmet.plugin.power.modules.hik.controller; + +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.plugin.power.dto.hik.HikCommunityInfoDTO; +import com.epmet.plugin.power.modules.hik.excel.HikCommunityInfoExcel; +import com.epmet.plugin.power.modules.hik.service.HikCommunityInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 海康社区信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@RestController +@RequestMapping("hikCommunityInfo") +public class HikCommunityInfoController { + + @Autowired + private HikCommunityInfoService hikCommunityInfoService; + + @RequestMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = hikCommunityInfoService.page(params); + return new Result>().ok(page); + } + + @RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET}) + public Result get(@PathVariable("id") String id){ + HikCommunityInfoDTO data = hikCommunityInfoService.get(id); + return new Result().ok(data); + } + + @NoRepeatSubmit + @PostMapping("save") + public Result save(@RequestBody HikCommunityInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + hikCommunityInfoService.save(dto); + return new Result(); + } + + @NoRepeatSubmit + @PostMapping("update") + public Result update(@RequestBody HikCommunityInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + hikCommunityInfoService.update(dto); + return new Result(); + } + + @RequestMapping(value = "delete", method = {RequestMethod.POST, RequestMethod.DELETE}) + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + hikCommunityInfoService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = hikCommunityInfoService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, HikCommunityInfoExcel.class); + } + + /** + * @Description: 同步社区列表信息 + * @Param: [formDto] + * @return: com.elink.esua.epdc.commons.tools.utils.Result<> + * @Author: wgf + * @Date: 2022-05-23 + */ + @GetMapping("getCommunityList") + public Result getCommunityList() { + return hikCommunityInfoService.getCommunityList(); + } + + + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/controller/HikDeviceInfoController.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/controller/HikDeviceInfoController.java new file mode 100644 index 0000000..f1bc823 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/controller/HikDeviceInfoController.java @@ -0,0 +1,94 @@ +package com.epmet.plugin.power.modules.hik.controller; + +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.plugin.power.dto.hik.HikDeviceInfoDTO; +import com.epmet.plugin.power.modules.hik.excel.HikDeviceInfoExcel; +import com.epmet.plugin.power.modules.hik.service.HikDeviceInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 海康设备信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@RestController +@RequestMapping("hikDeviceInfo") +public class HikDeviceInfoController { + + @Autowired + private HikDeviceInfoService hikDeviceInfoService; + + @RequestMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = hikDeviceInfoService.page(params); + return new Result>().ok(page); + } + + @RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET}) + public Result get(@PathVariable("id") String id){ + HikDeviceInfoDTO data = hikDeviceInfoService.get(id); + return new Result().ok(data); + } + + @NoRepeatSubmit + @PostMapping("save") + public Result save(@RequestBody HikDeviceInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + hikDeviceInfoService.save(dto); + return new Result(); + } + + @NoRepeatSubmit + @PostMapping("update") + public Result update(@RequestBody HikDeviceInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + hikDeviceInfoService.update(dto); + return new Result(); + } + + @RequestMapping(value = "delete", method = {RequestMethod.POST, RequestMethod.DELETE}) + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + hikDeviceInfoService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = hikDeviceInfoService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, HikDeviceInfoExcel.class); + } + + /** + * @Description: 同步设备列表信息 + * @Param: [formDto] + * @return: com.elink.esua.epdc.commons.tools.utils.Result<> + * @Author: wgf + * @Date: 2022-05-23 + */ + @GetMapping("getDeviceList") + public Result getDeviceList() { + return hikDeviceInfoService.getDeviceList(); + } + + + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/controller/HikErrorInfoController.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/controller/HikErrorInfoController.java new file mode 100644 index 0000000..abea6e8 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/controller/HikErrorInfoController.java @@ -0,0 +1,82 @@ +package com.epmet.plugin.power.modules.hik.controller; + +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.plugin.power.dto.hik.HikErrorInfoDTO; +import com.epmet.plugin.power.modules.hik.excel.HikErrorInfoExcel; +import com.epmet.plugin.power.modules.hik.service.HikErrorInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 海康设备推送失败信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-23 + */ +@RestController +@RequestMapping("hikErrorInfo") +public class HikErrorInfoController { + + @Autowired + private HikErrorInfoService hikErrorInfoService; + + @RequestMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = hikErrorInfoService.page(params); + return new Result>().ok(page); + } + + @RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET}) + public Result get(@PathVariable("id") String id){ + HikErrorInfoDTO data = hikErrorInfoService.get(id); + return new Result().ok(data); + } + + @NoRepeatSubmit + @PostMapping("save") + public Result save(@RequestBody HikErrorInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + hikErrorInfoService.save(dto); + return new Result(); + } + + @NoRepeatSubmit + @PostMapping("update") + public Result update(@RequestBody HikErrorInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + hikErrorInfoService.update(dto); + return new Result(); + } + + @RequestMapping(value = "delete", method = {RequestMethod.POST, RequestMethod.DELETE}) + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + hikErrorInfoService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = hikErrorInfoService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, HikErrorInfoExcel.class); + } + + + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/dao/HikCommunityInfoDao.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/dao/HikCommunityInfoDao.java new file mode 100644 index 0000000..c25e7b3 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/dao/HikCommunityInfoDao.java @@ -0,0 +1,21 @@ +package com.epmet.plugin.power.modules.hik.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.plugin.power.dto.hik.HikCommunityInfoDTO; +import com.epmet.plugin.power.modules.hik.entity.HikCommunityInfoEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 海康社区信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Mapper +public interface HikCommunityInfoDao extends BaseDao { + + List getCommunityInfoAll(); + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/dao/HikDeviceInfoDao.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/dao/HikDeviceInfoDao.java new file mode 100644 index 0000000..6b91224 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/dao/HikDeviceInfoDao.java @@ -0,0 +1,16 @@ +package com.epmet.plugin.power.modules.hik.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.plugin.power.modules.hik.entity.HikDeviceInfoEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 海康设备信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Mapper +public interface HikDeviceInfoDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/dao/HikErrorInfoDao.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/dao/HikErrorInfoDao.java new file mode 100644 index 0000000..95268f5 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/dao/HikErrorInfoDao.java @@ -0,0 +1,27 @@ +package com.epmet.plugin.power.modules.hik.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.plugin.power.modules.hik.entity.HikErrorInfoEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Map; + +/** + * 海康设备推送失败信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-23 + */ +@Mapper +public interface HikErrorInfoDao extends BaseDao { + + /** + * 物理删除 + * + * @param params + * @return void + * @author zhy + * @date 2022/4/24 14:08 + */ + void deletePhysical(Map params); +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/entity/HikCommunityInfoEntity.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/entity/HikCommunityInfoEntity.java new file mode 100644 index 0000000..3b3e83e --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/entity/HikCommunityInfoEntity.java @@ -0,0 +1,64 @@ +package com.epmet.plugin.power.modules.hik.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 海康社区信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("pli_hik_community_info") +public class HikCommunityInfoEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 社区ID + */ + private String communityId; + + /** + * 社区名称 + */ + private String communityName; + + /** + * 省代号 + */ + private String provinceCode; + + /** + * 市代号 + */ + private String cityCode; + + /** + * 区代号 + */ + private String countyCode; + + /** + * 经度坐标值 + */ + private String longitude; + + /** + * 维度坐标值 + */ + private String latitude; + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/entity/HikDeviceInfoEntity.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/entity/HikDeviceInfoEntity.java new file mode 100644 index 0000000..4ad17cc --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/entity/HikDeviceInfoEntity.java @@ -0,0 +1,64 @@ +package com.epmet.plugin.power.modules.hik.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 海康设备信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("pli_hik_device_info") +public class HikDeviceInfoEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 社区ID + */ + private String communityId; + + /** + * 设备ID + */ + private String deviceId; + + /** + * 设备名称 + */ + private String deviceName; + + /** + * 设备型号 + */ + private String deviceModel; + + /** + * 设备序列号 + */ + private String deviceSerial; + + /** + * 设备状态,0:离线,1:在线 + */ + private String deviceStatus; + + /** + * 设备路径 + */ + private String devicePath; + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/entity/HikErrorInfoEntity.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/entity/HikErrorInfoEntity.java new file mode 100644 index 0000000..134ea93 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/entity/HikErrorInfoEntity.java @@ -0,0 +1,48 @@ +package com.epmet.plugin.power.modules.hik.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 海康设备推送失败信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-23 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("pli_hik_error_info") +public class HikErrorInfoEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 身份证号 + */ + private String idCard; + + /** + * 错误类型 0:token,1:人员,2权限 + */ + private String errorType; + + /** + * 错误详情 + */ + private String errorInfo; + + /** + * 引用ID + */ + private String referenceId; +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/excel/HikCommunityInfoExcel.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/excel/HikCommunityInfoExcel.java new file mode 100644 index 0000000..c230129 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/excel/HikCommunityInfoExcel.java @@ -0,0 +1,63 @@ +package com.epmet.plugin.power.modules.hik.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 海康社区信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Data +public class HikCommunityInfoExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "删除标记 0:未删除,1:已删除") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + @Excel(name = "客户ID") + private String customerId; + + @Excel(name = "社区ID") + private String communityId; + + @Excel(name = "社区名称") + private String communityName; + + @Excel(name = "省代号") + private String provinceCode; + + @Excel(name = "市代号") + private String cityCode; + + @Excel(name = "区代号") + private String countyCode; + + @Excel(name = "经度坐标值") + private String longitude; + + @Excel(name = "维度坐标值") + private String latitude; + + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/excel/HikDeviceInfoExcel.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/excel/HikDeviceInfoExcel.java new file mode 100644 index 0000000..9cd4f02 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/excel/HikDeviceInfoExcel.java @@ -0,0 +1,63 @@ +package com.epmet.plugin.power.modules.hik.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 海康设备信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Data +public class HikDeviceInfoExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "删除标记 0:未删除,1:已删除") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + @Excel(name = "客户ID") + private String customerId; + + @Excel(name = "社区ID") + private String communityId; + + @Excel(name = "设备ID") + private String deviceId; + + @Excel(name = "设备名称") + private String deviceName; + + @Excel(name = "设备型号") + private String deviceModel; + + @Excel(name = "设备序列号") + private String deviceSerial; + + @Excel(name = "设备状态,0:离线,1:在线") + private String deviceStatus; + + @Excel(name = "设备路径") + private String devicePath; + + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/excel/HikErrorInfoExcel.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/excel/HikErrorInfoExcel.java new file mode 100644 index 0000000..7be08bd --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/excel/HikErrorInfoExcel.java @@ -0,0 +1,51 @@ +package com.epmet.plugin.power.modules.hik.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 海康设备推送失败信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-23 + */ +@Data +public class HikErrorInfoExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "删除标记 0:未删除,1:已删除") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + @Excel(name = "客户ID") + private String customerId; + + @Excel(name = "身份证号") + private String idCard; + + @Excel(name = "错误类型 0:token,1:人员,2权限") + private String errorType; + + @Excel(name = "错误详情") + private String errorInfo; + + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/redis/HikCommunityInfoRedis.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/redis/HikCommunityInfoRedis.java new file mode 100644 index 0000000..24a6b3a --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/redis/HikCommunityInfoRedis.java @@ -0,0 +1,30 @@ +package com.epmet.plugin.power.modules.hik.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 海康社区信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Component +public class HikCommunityInfoRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/redis/HikDeviceInfoRedis.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/redis/HikDeviceInfoRedis.java new file mode 100644 index 0000000..045d049 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/redis/HikDeviceInfoRedis.java @@ -0,0 +1,30 @@ +package com.epmet.plugin.power.modules.hik.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 海康设备信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Component +public class HikDeviceInfoRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/redis/HikErrorInfoRedis.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/redis/HikErrorInfoRedis.java new file mode 100644 index 0000000..970dac0 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/redis/HikErrorInfoRedis.java @@ -0,0 +1,30 @@ +package com.epmet.plugin.power.modules.hik.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 海康设备推送失败信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-23 + */ +@Component +public class HikErrorInfoRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/HikCommunityInfoService.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/HikCommunityInfoService.java new file mode 100644 index 0000000..9a47eb5 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/HikCommunityInfoService.java @@ -0,0 +1,87 @@ +package com.epmet.plugin.power.modules.hik.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.plugin.power.dto.hik.HikCommunityInfoDTO; +import com.epmet.plugin.power.modules.hik.entity.HikCommunityInfoEntity; + +import java.util.List; +import java.util.Map; + +/** + * 海康社区信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +public interface HikCommunityInfoService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2022-05-20 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-05-20 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return HikCommunityInfoDTO + * @author generator + * @date 2022-05-20 + */ + HikCommunityInfoDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-05-20 + */ + void save(HikCommunityInfoDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-05-20 + */ + void update(HikCommunityInfoDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-05-20 + */ + void delete(String[] ids); + + + /** + * 同步社区信息 + * @param + * @return + */ + Result getCommunityList(); +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/HikDeviceInfoService.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/HikDeviceInfoService.java new file mode 100644 index 0000000..abdbe1c --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/HikDeviceInfoService.java @@ -0,0 +1,86 @@ +package com.epmet.plugin.power.modules.hik.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.plugin.power.dto.hik.HikDeviceInfoDTO; +import com.epmet.plugin.power.modules.hik.entity.HikDeviceInfoEntity; + +import java.util.List; +import java.util.Map; + +/** + * 海康设备信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +public interface HikDeviceInfoService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2022-05-20 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-05-20 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return HikDeviceInfoDTO + * @author generator + * @date 2022-05-20 + */ + HikDeviceInfoDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-05-20 + */ + void save(HikDeviceInfoDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-05-20 + */ + void update(HikDeviceInfoDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-05-20 + */ + void delete(String[] ids); + + /** + * 同步设备信息 + * @param + * @return + */ + Result getDeviceList(); +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/HikErrorInfoService.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/HikErrorInfoService.java new file mode 100644 index 0000000..bde8c62 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/HikErrorInfoService.java @@ -0,0 +1,88 @@ +package com.epmet.plugin.power.modules.hik.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.plugin.power.dto.hik.HikErrorInfoDTO; +import com.epmet.plugin.power.modules.hik.entity.HikErrorInfoEntity; + +import java.util.List; +import java.util.Map; + +/** + * 海康设备推送失败信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-23 + */ +public interface HikErrorInfoService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2022-05-23 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-05-23 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return HikErrorInfoDTO + * @author generator + * @date 2022-05-23 + */ + HikErrorInfoDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-05-23 + */ + void save(HikErrorInfoDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-05-23 + */ + void update(HikErrorInfoDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-05-23 + */ + void delete(String[] ids); + + /** + * 物理删除 + * + * @param params + * @return void + * @author zhy + * @date 2022/4/24 14:08 + */ + void deletePhysical(Map params); +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/impl/HikCommunityInfoServiceImpl.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/impl/HikCommunityInfoServiceImpl.java new file mode 100644 index 0000000..56e441d --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/impl/HikCommunityInfoServiceImpl.java @@ -0,0 +1,167 @@ +package com.epmet.plugin.power.modules.hik.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; +import com.epmet.plugin.power.modules.hik.dao.HikCommunityInfoDao; +import com.epmet.plugin.power.dto.hik.HikCommunityInfoDTO; +import com.epmet.plugin.power.modules.hik.entity.HikCommunityInfoEntity; +import com.epmet.plugin.power.modules.hik.redis.HikCommunityInfoRedis; +import com.epmet.plugin.power.modules.hik.service.HikCommunityInfoService; +import com.epmet.plugin.power.modules.utils.HkDeviceUtil; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * 海康社区信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Service +public class HikCommunityInfoServiceImpl extends BaseServiceImpl implements HikCommunityInfoService { + + @Autowired + private HikCommunityInfoRedis hikCommunityInfoRedis; + + @Autowired + private HkDeviceUtil hkDeviceUtil; + + @Autowired + private LoginUserUtil loginUserUtil; + + // 参数 + private Integer pageNo = 1; + private Integer pageSize = 10; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, HikCommunityInfoDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, HikCommunityInfoDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + String communityName = (String)params.get("communityName"); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + wrapper.like(StringUtils.isNotBlank(communityName), "COMMUNITY_NAME", communityName); + + return wrapper; + } + + @Override + public HikCommunityInfoDTO get(String id) { + HikCommunityInfoEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, HikCommunityInfoDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(HikCommunityInfoDTO dto) { + HikCommunityInfoEntity entity = ConvertUtils.sourceToTarget(dto, HikCommunityInfoEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(HikCommunityInfoDTO dto) { + HikCommunityInfoEntity entity = ConvertUtils.sourceToTarget(dto, HikCommunityInfoEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public Result getCommunityList() { + // 请求路径 + String url = "https://api2.hik-cloud.com/api/v1/estate/system/communities/actions/list"; + + // token + String token =hkDeviceUtil.getAccessToken(); + token = "Bearer ".concat(token); + + Map headerMap = new HashMap<>(4); + headerMap.put("Authorization",token); + + Map paramsMap = new HashMap<>(4); + paramsMap.put("pageNo", pageNo); + paramsMap.put("pageSize", pageSize); + + JSONArray jsonArray = getJSONArrayListGET(url,false,paramsMap,headerMap,"请求社区列表信息失败"); + + List entityList = new ArrayList(); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObj = jsonArray.getJSONObject(i); + // 转成对象实体 + HikCommunityInfoEntity entity = JSONObject.toJavaObject(jsonObj ,HikCommunityInfoEntity.class); + entity.setCustomerId(loginUserUtil.getLoginUserCustomerId() == null ? "0001" : loginUserUtil.getLoginUserCustomerId()); + entityList.add(entity); + } + insertBatch(entityList); + + if(jsonArray != null && jsonArray.size() == 10){ + pageNo++; + getCommunityList(); + } + + return new Result(); + } + + /** + * sendGet请求 + * @param url + * @param isHttps + * @param paramsMap + * @param headerMap + * @param msg + * @return + */ + public JSONArray getJSONArrayListGET(String url,Boolean isHttps,Map paramsMap,Map headerMap,String msg){ + // 请求接口 + String data = HttpClientManager.getInstance().sendGet(url,false,paramsMap, headerMap).getData(); + if (null == data) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg); + } + JSONObject toResult = JSON.parseObject(data); + + JSONObject dataList = JSON.parseObject(toResult.get("data").toString()); + + JSONArray rows = JSONArray.parseArray(dataList.get("rows").toString()); + + return rows; + } + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/impl/HikDeviceInfoServiceImpl.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/impl/HikDeviceInfoServiceImpl.java new file mode 100644 index 0000000..fb05681 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/impl/HikDeviceInfoServiceImpl.java @@ -0,0 +1,170 @@ +package com.epmet.plugin.power.modules.hik.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; +import com.epmet.plugin.power.dto.hik.HikCommunityInfoDTO; +import com.epmet.plugin.power.modules.hik.dao.HikCommunityInfoDao; +import com.epmet.plugin.power.modules.hik.dao.HikDeviceInfoDao; +import com.epmet.plugin.power.dto.hik.HikDeviceInfoDTO; +import com.epmet.plugin.power.modules.hik.entity.HikCommunityInfoEntity; +import com.epmet.plugin.power.modules.hik.entity.HikDeviceInfoEntity; +import com.epmet.plugin.power.modules.hik.redis.HikDeviceInfoRedis; +import com.epmet.plugin.power.modules.hik.service.HikDeviceInfoService; +import com.epmet.plugin.power.modules.utils.HkDeviceUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * 海康设备信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-20 + */ +@Service +public class HikDeviceInfoServiceImpl extends BaseServiceImpl implements HikDeviceInfoService { + + @Autowired + private HikDeviceInfoRedis hikDeviceInfoRedis; + + @Autowired + private HkDeviceUtil hkDeviceUtil; + + @Autowired + private LoginUserUtil loginUserUtil; + + @Autowired + private HikCommunityInfoDao hikCommunityInfoDao; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, HikDeviceInfoDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, HikDeviceInfoDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + String communityId = (String)params.get("communityId"); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + wrapper.eq(StringUtils.isNotBlank(communityId), "COMMUNITY_ID", communityId); + + return wrapper; + } + + @Override + public HikDeviceInfoDTO get(String id) { + HikDeviceInfoEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, HikDeviceInfoDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(HikDeviceInfoDTO dto) { + HikDeviceInfoEntity entity = ConvertUtils.sourceToTarget(dto, HikDeviceInfoEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(HikDeviceInfoDTO dto) { + HikDeviceInfoEntity entity = ConvertUtils.sourceToTarget(dto, HikDeviceInfoEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public Result getDeviceList() { + // 请求路径 + String url = "https://api2.hik-cloud.com/api/v1/estate/devices/actions/listByCommunityId"; + + // token + String token =hkDeviceUtil.getAccessToken(); + token = "Bearer ".concat(token); + + Map headerMap = new HashMap<>(4); + headerMap.put("Authorization",token); + + // 获取社区列表 + List communityList = hikCommunityInfoDao.getCommunityInfoAll(); + + for(HikCommunityInfoDTO hikCommunityInfoDTO : communityList){ + // 参数 + Integer pageNo = 1; + Integer pageSize = 1000; + Map paramsMap = new HashMap<>(4); + paramsMap.put("pageNo", pageNo); + paramsMap.put("pageSize", pageSize); + paramsMap.put("communityId",hikCommunityInfoDTO.getCommunityId()); + JSONArray jsonArray = getJSONArrayListPOST(url,JSON.toJSONString(paramsMap),headerMap,"请求设备列表信息失败"); + + List entityList = new ArrayList(); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObj = jsonArray.getJSONObject(i); + // 转成对象实体 + HikDeviceInfoEntity entity = JSONObject.toJavaObject(jsonObj ,HikDeviceInfoEntity.class); + entity.setCustomerId(loginUserUtil.getLoginUserCustomerId() == null ? "0001" : loginUserUtil.getLoginUserCustomerId()); + entityList.add(entity); + } + insertBatch(entityList); + } + + return new Result(); + } + + /** + * sendGet请求 + * @param url + * @param jsonStrParam + * @param headerMap + * @param msg + * @return + */ + public JSONArray getJSONArrayListPOST(String url,String jsonStrParam,Map headerMap,String msg){ + // 请求接口 + String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url,jsonStrParam, headerMap).getData(); + if (null == data) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg); + } + JSONObject toResult = JSON.parseObject(data); + + JSONObject dataList = JSON.parseObject(toResult.get("data").toString()); + + JSONArray rows = JSONArray.parseArray(dataList.get("rows").toString()); + + return rows; + } + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/impl/HikErrorInfoServiceImpl.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/impl/HikErrorInfoServiceImpl.java new file mode 100644 index 0000000..1a6e31a --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/hik/service/impl/HikErrorInfoServiceImpl.java @@ -0,0 +1,95 @@ +package com.epmet.plugin.power.modules.hik.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.plugin.power.modules.hik.dao.HikErrorInfoDao; +import com.epmet.plugin.power.dto.hik.HikErrorInfoDTO; +import com.epmet.plugin.power.modules.hik.entity.HikErrorInfoEntity; +import com.epmet.plugin.power.modules.hik.redis.HikErrorInfoRedis; +import com.epmet.plugin.power.modules.hik.service.HikErrorInfoService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 海康设备推送失败信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-23 + */ +@Service +public class HikErrorInfoServiceImpl extends BaseServiceImpl implements HikErrorInfoService { + + @Autowired + private HikErrorInfoRedis hikErrorInfoRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, HikErrorInfoDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, HikErrorInfoDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public HikErrorInfoDTO get(String id) { + HikErrorInfoEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, HikErrorInfoDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(HikErrorInfoDTO dto) { + HikErrorInfoEntity entity = ConvertUtils.sourceToTarget(dto, HikErrorInfoEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(HikErrorInfoDTO dto) { + HikErrorInfoEntity entity = ConvertUtils.sourceToTarget(dto, HikErrorInfoEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deletePhysical(Map params) { + if (!params.isEmpty()) { + baseDao.deletePhysical(params); + } + } + +} \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentContractInfoController.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentContractInfoController.java index 3173018..5516860 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentContractInfoController.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentContractInfoController.java @@ -63,6 +63,23 @@ public class RentContractInfoController { return new Result(); } + @NoRepeatSubmit + @PostMapping("send") + public Result send(@RequestBody RentContractInfoDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + rentContractInfoService.send(dto); + return new Result(); + } + + @NoRepeatSubmit + @PostMapping("resend/{id}") + public Result resend(@PathVariable("id") String id) { + //效验数据 + rentContractInfoService.resend(id); + return new Result(); + } + @NoRepeatSubmit @PostMapping("update") public Result update(@RequestBody RentContractInfoDTO dto) { diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentTenantInfoController.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentTenantInfoController.java index e28ac56..4601409 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentTenantInfoController.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/controller/RentTenantInfoController.java @@ -7,8 +7,8 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.plugin.power.dto.rent.RentTenantInfoDTO; import com.epmet.plugin.power.modules.rent.excel.RentTenantInfoExcel; import com.epmet.plugin.power.modules.rent.service.RentTenantInfoService; @@ -91,5 +91,4 @@ public class RentTenantInfoController { ExcelUtils.exportExcelToTarget(response, null, list, RentTenantInfoExcel.class); } - } diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/RentContractInfoService.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/RentContractInfoService.java index 64d9e37..742834f 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/RentContractInfoService.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/RentContractInfoService.java @@ -67,6 +67,26 @@ public interface RentContractInfoService extends BaseService * @date 2022/4/24 14:08 */ void deletePhysical(Map params); + } \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/impl/RentContractInfoServiceImpl.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/impl/RentContractInfoServiceImpl.java index 66a9eed..c3634d2 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/impl/RentContractInfoServiceImpl.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/rent/service/impl/RentContractInfoServiceImpl.java @@ -20,9 +20,17 @@ import com.epmet.dto.form.IcHouseAddFormDTO; import com.epmet.dto.form.RentTenantFormDTO; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.plugin.power.dto.hik.HikCommunityInfoDTO; +import com.epmet.plugin.power.dto.hik.HikDeviceInfoDTO; +import com.epmet.plugin.power.dto.hik.HikErrorInfoDTO; +import com.epmet.plugin.power.dto.hik.form.HikAuthorityFormDTO; +import com.epmet.plugin.power.dto.hik.form.HikPersonFormDTO; import com.epmet.plugin.power.dto.rent.RentContractFileDTO; import com.epmet.plugin.power.dto.rent.RentContractInfoDTO; import com.epmet.plugin.power.dto.rent.RentTenantInfoDTO; +import com.epmet.plugin.power.modules.hik.service.HikCommunityInfoService; +import com.epmet.plugin.power.modules.hik.service.HikDeviceInfoService; +import com.epmet.plugin.power.modules.hik.service.HikErrorInfoService; import com.epmet.plugin.power.modules.rent.dao.RentContractInfoDao; import com.epmet.plugin.power.modules.rent.entity.RentContractFileEntity; import com.epmet.plugin.power.modules.rent.entity.RentContractInfoEntity; @@ -31,6 +39,7 @@ import com.epmet.plugin.power.modules.rent.redis.RentContractInfoRedis; import com.epmet.plugin.power.modules.rent.service.RentContractFileService; import com.epmet.plugin.power.modules.rent.service.RentContractInfoService; import com.epmet.plugin.power.modules.rent.service.RentTenantInfoService; +import com.epmet.plugin.power.modules.utils.HkDeviceUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -54,6 +63,9 @@ public class RentContractInfoServiceImpl extends BaseServiceImpl page(Map params) { params.put("customerId", loginUserUtil.getLoginUserCustomerId()); @@ -233,6 +254,66 @@ public class RentContractInfoServiceImpl extends BaseServiceImpl { + try { + Map delParams = new HashMap<>(); + delParams.put("idCard", item.getIdCard()); + hikErrorInfoService.deletePhysical(delParams); + + HikPersonFormDTO person = new HikPersonFormDTO(); + person.setFaceUrl(item.getImgList().get(0).getFileUrl()); + person.setMobile(item.getMobile()); + person.setCredentialType(NumConstant.ONE); + person.setCredentialNumber(item.getIdCard()); + person.setPersonName(item.getName()); + person.setGender(NumConstant.ONE_NEG); + String personId = hkDeviceUtil.sendPerson(person); + + if (StringUtils.isNotBlank(personId)) { + HikAuthorityFormDTO authority = new HikAuthorityFormDTO(); + authority.setPersonType(NumConstant.ONE); + authority.setPersonId(personId); + + Map communityParams = new HashMap<>(4); + communityParams.put("communityName", dto.getVillageName()); + List communityList = hikCommunityInfoService.list(communityParams); + + communityList.forEach(community -> { + authority.setCommunityId(community.getCommunityId()); + + Map deviceParams = new HashMap<>(4); + deviceParams.put("communityName", dto.getVillageName()); + List deviceList = hikDeviceInfoService.list(deviceParams); + + deviceList.forEach(device -> { + authority.setDeviceId(device.getDeviceId()); + + hkDeviceUtil.authorityIssued(authority); + }); + }); + } + } catch (EpmetException e) { + HikErrorInfoDTO error = new HikErrorInfoDTO(); + error.setIdCard(item.getIdCard()); + error.setErrorInfo(e.getMessage()); + error.setCustomerId(loginUserUtil.getLoginUserCustomerId()); + error.setReferenceId(dto.getId()); + hikErrorInfoService.save(error); + } + }); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void resend(String id) { + HikErrorInfoDTO errorDto = hikErrorInfoService.get(id); + RentContractInfoDTO dto = get(errorDto.getReferenceId()); + send(dto); + } + @Override @Transactional(rollbackFor = Exception.class) public void update(RentContractInfoDTO dto) { diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/utils/.gitkeep b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/utils/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/utils/HkDeviceUtil.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/utils/HkDeviceUtil.java new file mode 100644 index 0000000..f52f535 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/utils/HkDeviceUtil.java @@ -0,0 +1,148 @@ +package com.epmet.plugin.power.modules.utils; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; +import com.epmet.plugin.commons.redis.RedisKeys; +import com.epmet.plugin.power.config.HikCloudProperties; +import com.epmet.plugin.power.dto.hik.form.HikAuthorityFormDTO; +import com.epmet.plugin.power.dto.hik.form.HikPersonFormDTO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +/** + * 海康设备下放命令 + * + * @author zhy + * @date 2022/5/20 9:36 + */ +@Component +public class HkDeviceUtil { + private static Logger logger = LoggerFactory.getLogger(HkDeviceUtil.class); + + @Autowired + private HikCloudProperties hikCloudProperties; + + @Autowired + private RedisUtils redisUtils; + + private final String GET_ACCESS_TOKEN = "/oauth/token"; + private final String GET_DEVICES = "/api/v1/estate/devices"; + private final String SEND_PERSON = "/api/v1/estate/system/person"; + private final String ISSUE_AUTHORITY = "/api/v1/estate/entranceGuard/permissions/actions/authorityIssued"; + + private final String GRANT_TYPE = "client_credentials"; + + /** + * 获取accessToken + * + * @param + * @return void + * @author zhy + * @date 2022/5/20 16:40 + */ + public String getAccessToken() { + String key = RedisKeys.getHikTokenKey(); + Object obj = redisUtils.get(key); + if (null != obj) { + return (String) obj; + } + + String url = hikCloudProperties.getUrl().concat(GET_ACCESS_TOKEN); + Map paramsMap = new HashMap<>(8); + paramsMap.put("client_id", hikCloudProperties.getClient()); + paramsMap.put("client_secret", hikCloudProperties.getSecret()); + paramsMap.put("grant_type", GRANT_TYPE); +// paramsMap.put("scope", "app"); + + String data = HttpClientManager.getInstance().sendPost(url, paramsMap).getData(); + if (null == data) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "AccessToken获取失败"); + } + + JSONObject toResult = JSON.parseObject(data); + if (!toResult.containsKey("access_token")) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "AccessToken获取失败"); + } + String accessToken = "Bearer ".concat(toResult.get("access_token").toString()); + + redisUtils.set(key, accessToken, RedisUtils.HOUR_ONE_EXPIRE); + return accessToken; + } + + /** + * 下发人员 + * + * @param dto + * @return java.lang.String 人员ID + * @author zhy + * @date 2022/5/23 10:08 + */ + public String sendPerson(HikPersonFormDTO dto) { + String url = hikCloudProperties.getUrl().concat(SEND_PERSON); + + Map paramsMap = new HashMap<>(4); + paramsMap.put("Authorization", getAccessToken()); + + String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData(); + + if (null == data) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员信息下发失败"); + } + JSONObject toResult = JSON.parseObject(data); + Result result = ConvertUtils.mapToEntity(toResult, Result.class); + if (null != toResult.get("code")) { + result.setCode(((Integer) toResult.get("code")).intValue()); + } + if (NumConstant.TWO_HUNDRED != result.getCode()) { + logger.info(result.getMsg()); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员信息下发失败"); + } + Object RegisterResult = result.getData(); + JSONObject jsonObject = JSON.parseObject(RegisterResult.toString()); + return jsonObject.getString("personId"); + } + + /** + * 下发人员权限 + * + * @param dto + * @return java.lang.String + * @author zhy + * @date 2022/5/23 11:04 + */ + public String authorityIssued(HikAuthorityFormDTO dto) { + String url = hikCloudProperties.getUrl().concat(ISSUE_AUTHORITY); + + Map paramsMap = new HashMap<>(4); + paramsMap.put("Authorization", getAccessToken()); + + String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData(); + + if (null == data) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员权限下发失败"); + } + JSONObject toResult = JSON.parseObject(data); + Result result = ConvertUtils.mapToEntity(toResult, Result.class); + if (null != toResult.get("code")) { + result.setCode(((Integer) toResult.get("code")).intValue()); + } + if (NumConstant.TWO_HUNDRED != result.getCode()) { + logger.info(result.getMsg()); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员权限下发失败"); + } + return "success"; + } + +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/bootstrap.yml b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/bootstrap.yml index 66aedcd..f93c0cf 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/bootstrap.yml +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/bootstrap.yml @@ -127,6 +127,12 @@ dingTalk: webHook: @dingTalk.robot.webHook@ secret: @dingTalk.robot.secret@ +hik: + cloud: + url: @hik.cloud.url@ + client: @hik.cloud.client@ + secret: @hik.cloud.secret@ + # 停机选项 shutdown: graceful: diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/hik/HikCommunityInfoDao.xml b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/hik/HikCommunityInfoDao.xml new file mode 100644 index 0000000..978427b --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/hik/HikCommunityInfoDao.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/hik/HikDeviceInfoDao.xml b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/hik/HikDeviceInfoDao.xml new file mode 100644 index 0000000..ca5b5ee --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/hik/HikDeviceInfoDao.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/hik/HikErrorInfoDao.xml b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/hik/HikErrorInfoDao.xml new file mode 100644 index 0000000..43b53c7 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/hik/HikErrorInfoDao.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + DELETE + FROM + pli_hik_error_info + + + AND ID_CARD = #{idCard} + + + + \ No newline at end of file