iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiDataController.java
@@ -5,6 +5,7 @@ import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.framework.excel.core.util.ExcelUtils; import com.iailab.framework.tenant.core.context.TenantContextHolder; import com.iailab.module.data.api.dto.DeviceValueDTO; import com.iailab.module.data.api.dto.IndexQueryDTO; import com.iailab.module.data.api.dto.echarts.BarLineDTO; import com.iailab.module.data.api.dto.echarts.SeriesItem; @@ -18,33 +19,29 @@ import com.iailab.module.data.api.point.dto.ApiPointsValueQueryDTO; import com.iailab.module.data.common.ApiDataQueryDTO; import com.iailab.module.data.common.ApiDataValueDTO; import com.iailab.module.data.common.utils.ApiSecurityUtils; import com.iailab.module.data.ind.collection.IndItemCollector; import com.iailab.module.data.ind.item.vo.IndItemValueVO; import com.iailab.module.data.plan.item.entity.PlanItemEntity; import com.iailab.module.data.plan.item.service.PlanItemService; import com.iailab.module.data.plan.item.vo.PlanItemValueExportVO; import com.iailab.module.data.point.common.PointDataTypeEnum; import com.iailab.module.data.point.dto.DaPointDTO; import com.iailab.module.data.point.service.DaPointService; import com.iailab.module.data.api.dto.DeviceValueDTO; import com.iailab.module.data.common.utils.ApiSecurityUtils; import com.iailab.module.data.plan.item.service.PlanItemService; import com.iailab.module.data.point.vo.DaPointExcelVO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import javax.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.annotation.security.PermitAll; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; @@ -300,7 +297,7 @@ List<PlanItemValueExportVO> exportList = list.stream().map(item -> { PlanItemValueExportVO exportVO = new PlanItemValueExportVO(); exportVO.setDataTime(DateUtils.format(item.getDataTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); exportVO.setDataValue(new BigDecimal(item.getDataValue()).setScale(0, BigDecimal.ROUND_HALF_UP).toString()); exportVO.setDataValue(BigDecimal.valueOf(item.getDataValue()).setScale(0, RoundingMode.HALF_UP).toString()); return exportVO; }).collect(Collectors.toList()); ExcelUtils.write(response, "计划数据.xls", "计划数据", PlanItemValueExportVO.class, exportList); iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/plan/PlanItemApiImpl.java
@@ -2,14 +2,18 @@ import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.module.data.api.plan.dto.ApiPlanDataDTO; import com.iailab.module.data.api.plan.dto.ApiPlanItemDTO; import com.iailab.module.data.common.ApiDataQueryDTO; import com.iailab.module.data.common.ApiDataValueDTO; import com.iailab.module.data.plan.item.collection.PlanItemCollector; import com.iailab.module.data.plan.item.entity.PlanItemEntity; import com.iailab.module.data.plan.item.service.PlanItemService; import com.iailab.module.data.plan.item.vo.PlanItemDataVO; import com.iailab.module.data.plan.item.vo.PlanItemValueVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import java.util.LinkedHashMap; @@ -27,11 +31,16 @@ @Autowired private PlanItemCollector planItemCollector; @Autowired private PlanItemService planItemService; @Override public List<ApiDataValueDTO> queryPlanItemHistoryValue(ApiDataQueryDTO dto) { List<PlanItemValueVO> list = planItemCollector.queryValue(dto.getItemNo(), dto.getStart(), dto.getEnd()); return ConvertUtils.sourceToTarget(list, ApiDataValueDTO.class); } @Override public LinkedHashMap<String, List<ApiPlanDataDTO>> queryPlanItemRecordValue(ApiDataQueryDTO dto) { LinkedHashMap<String, List<ApiPlanDataDTO>> result = new LinkedHashMap<>(); if (CollectionUtils.isEmpty(dto.getItemNos())) { @@ -44,4 +53,10 @@ return result; } @Override public ApiPlanItemDTO getInfoByNo(String itemNo){ PlanItemEntity entity = planItemService.getInfoByNo(itemNo); return ConvertUtils.sourceToTarget(entity, ApiPlanItemDTO.class); } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/kio/collector/KingIOCollector.java
@@ -2,9 +2,12 @@ import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; import com.iailab.module.data.channel.opcua.collector.OpcUaUtils; import com.iailab.module.data.common.enums.CommonConstant; import com.iailab.module.data.common.enums.DataSourceType; import com.iailab.module.data.common.utils.TagUtils; import lombok.extern.slf4j.Slf4j; import org.eclipse.milo.opcua.sdk.client.OpcUaClient; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -50,9 +53,15 @@ return kingIOClient; } public String getTagValue(String sourceId, String tagName) throws Exception { KingIOClient client = this.getClient(sourceId); String value = client.getTagValue(tagName); public String getTagValue(String sourceId, String tagName) { String value = CommonConstant.BAD_VALUE.toString(); try{ KingIOClient client = this.getClient(sourceId); value = client.getTagValue(tagName); }catch (Exception ex){ ex.printStackTrace(); return value; } return value; } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/collector/OpcUaCollector.java
@@ -64,9 +64,15 @@ return opcUaClient; } public String getTagValue(String sourceId, String tagNo) throws Exception { OpcUaClient opcUaClient = this.getClient(sourceId); String value = OpcUaUtils.readNode(opcUaClient, tagNo); public String getTagValue(String sourceId, String tagNo) { String value = CommonConstant.BAD_VALUE.toString(); try{ OpcUaClient opcUaClient = this.getClient(sourceId); value = OpcUaUtils.readNode(opcUaClient, tagNo); }catch (Exception ex){ ex.printStackTrace(); return value; } return value; } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpRequest.java
@@ -1,6 +1,5 @@ package com.iailab.module.data.common.utils; import com.iailab.framework.security.core.util.SecurityFrameworkUtils; import com.iailab.framework.tenant.core.context.TenantContextHolder; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -250,6 +249,7 @@ * @return */ public static String doPost(String url, String json, String charset, String token) { Long tenantId = TenantContextHolder.getTenantId(); org.apache.http.client.HttpClient httpClient = null; HttpPost httpPost = null; String result = null; @@ -260,8 +260,7 @@ httpPost.addHeader("Accept", "application/json"); httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); httpPost.addHeader("token", token); //传递租户id httpPost.addHeader("Tenant-Id", String.valueOf(TenantContextHolder.getTenantId())); httpPost.addHeader("Tenant-Id", String.valueOf(tenantId)); StringEntity stringEntity = new StringEntity(json); stringEntity.setContentEncoding("UTF-8"); stringEntity.setContentType("application/json"); iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/DevCameraDahuaTask.java
@@ -9,6 +9,7 @@ import com.iailab.module.data.video.service.CameraService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -32,13 +33,15 @@ @Resource private CameraService cameraService; @Resource @Autowired private DHClientFactory dhClientFactory; @Override public void run(String params) { logger.info("devCameraDahuaTask定时任务正在执行,参数为:{}", params); //传递租户id System.out.println(TenantContextHolder.getTenantId()); String tenantId = String.valueOf(TenantContextHolder.getTenantId()); try { CameraPageReqVO cameraPageReqVO = new CameraPageReqVO(); cameraPageReqVO.setType("2"); iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/DevCameraHikvisionTask.java
对比新文件 @@ -0,0 +1,42 @@ package com.iailab.module.data.job.task; import com.iailab.module.data.video.controller.admin.camera.vo.CameraPageReqVO; import com.iailab.module.data.video.config.VideoConfiguration; import com.iailab.module.data.video.dto.CameraDTO; import com.iailab.module.data.video.hikvision.utils.HIKDevice; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.List; @Component("devCameraHikvisionTask") public class DevCameraHikvisionTask implements ITask { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private static HIKDevice hikDevice; @Autowired public void setHIKDevice(HIKDevice tHIKDevice) { DevCameraHikvisionTask.hikDevice = tHIKDevice; } @Override public void run(String params) { logger.info("devCameraDahuaTask定时任务正在执行,参数为:{}", params); CameraPageReqVO cameraPageReqVO = new CameraPageReqVO(); cameraPageReqVO.setType("1"); List<CameraDTO> list = VideoConfiguration.staticCameraService.list(cameraPageReqVO); if (CollectionUtils.isEmpty(list)) { logger.info("Alarm List 为空"); return; } list.stream().forEach(cameraDTO -> { hikDevice.loginDevice(cameraDTO); }); } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/config/VideoConfiguration.java
对比新文件 @@ -0,0 +1,64 @@ package com.iailab.module.data.video.config; import com.iailab.module.data.video.service.CameraService; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import javax.annotation.PostConstruct; import javax.annotation.Resource; /** * 摄像头配置文件 */ @Configuration public class VideoConfiguration { @Value("${video.capture-dir}") public String captureDir; @Value("${video.dahua.path.capture-path}") public String dhCapturePath; @Value("${video.dahua.path.model-path}") public String dhModelPath; @Value("${video.hikvision.path.capture-path}") public String hkCapturePath; @Value("${video.hikvision.path.model-path}") public String hkModelPath; @Value("${video.hikvision.pic-size}") public String picSize; @Value("${video.hikvision.pic-quality}") public String picQuality; @Resource public CameraService cameraService; public static String staticDhCapturePath; public static String staticDhModelPath; public static String staticHkCapturePath; public static String staticHkModelPath; public static String staticPicSize; public static String staticPicQuality; public static CameraService staticCameraService; @PostConstruct public void initUrl() { staticDhCapturePath = this.captureDir + this.dhCapturePath; staticDhModelPath = this.captureDir + this.dhModelPath; staticHkCapturePath = this.captureDir + this.hkCapturePath; staticHkModelPath = this.captureDir + this.hkModelPath; staticPicSize = this.picSize; staticPicQuality = this.picQuality; staticCameraService = this.cameraService; } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/controller/admin/camera/CameraController.java
@@ -12,10 +12,8 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.security.PermitAll; import javax.validation.Valid; import java.util.List; import java.util.Map; import static com.iailab.framework.common.pojo.CommonResult.error; import static com.iailab.framework.common.pojo.CommonResult.success; @@ -81,16 +79,16 @@ @DeleteMapping("/delete") @Operation(summary = "删除") @PreAuthorize("@ss.hasPermission('video:camera:delete')") public CommonResult delete(@RequestBody String[] ids) { cameraService.delete(ids); public CommonResult delete(@RequestParam("id") String id) { cameraService.delete(id); return success(); } @PostMapping("/DHCaptureCallback") @Operation(summary = "大华摄像头截图成功后回调存储处理图片") @PermitAll public CommonResult DHCaptureCallback(@RequestBody Map<String, String> params) { cameraService.dealCapture(params); return success(); } // @PostMapping("/DHCaptureCallback") // @Operation(summary = "大华摄像头截图成功后回调存储处理图片") // @PermitAll // public CommonResult DHCaptureCallback(@RequestBody Map<String, String> params) { // cameraService.dealCapture(params); // return success(); // } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/controller/admin/camera/ImageController.java
对比新文件 @@ -0,0 +1,64 @@ package com.iailab.module.data.video.controller.admin.camera; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.framework.common.pojo.PageResult; import com.iailab.module.data.video.controller.admin.camera.vo.ImagePageReqVO; import com.iailab.module.data.video.dto.ImageDTO; import com.iailab.module.data.video.service.ImageService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; import static com.iailab.framework.common.pojo.CommonResult.success; /** * @author Houzhongjian * @Description * @createTime 2024年11月01日 */ @RestController @RequestMapping("/data/video/image") @Tag(name = "截图管理") public class ImageController { @Autowired private ImageService imageService; @GetMapping("page") @Operation(summary = "分页") @PreAuthorize("@ss.hasPermission('video:image:query')") public CommonResult<PageResult<ImageDTO>> page(@Valid ImagePageReqVO imagePageReqVO) { return success(imageService.getPage(imagePageReqVO)); } @GetMapping("list") @PreAuthorize("@ss.hasPermission('video:image:query')") public CommonResult<List<ImageDTO>> list(@Valid ImagePageReqVO imagePageReqVO) { List<ImageDTO> list = imageService.list(imagePageReqVO); return success(list); } @GetMapping("/get") @Operation(summary = "信息") @PreAuthorize("@ss.hasPermission('video:image:query')") @Parameter(name = "id", description = "编号", required = true, example = "1024") public CommonResult<ImageDTO> get(@RequestParam("id") String id) { ImageDTO data = imageService.get(id); return success(data); } @DeleteMapping("/delete") @Operation(summary = "删除") @PreAuthorize("@ss.hasPermission('video:image:delete')") public CommonResult delete(@RequestParam("id") String id) { imageService.delete(id); return success(); } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/controller/admin/camera/vo/CameraPageReqVO.java
@@ -7,7 +7,7 @@ import lombok.ToString; /** * @author PanZhibao * @author Houzhongjian * @Description * @createTime 2024年08月17日 */ iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/controller/admin/camera/vo/ImagePageReqVO.java
对比新文件 @@ -0,0 +1,28 @@ package com.iailab.module.data.video.controller.admin.camera.vo; import com.iailab.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; /** * @author Houzhongjian * @Description * @createTime 2024年08月17日 */ @Schema(description = "截图图片 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class ImagePageReqVO extends PageParam { private String cameraId; private String brand; private String code; private String device; } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/controller/admin/nvr/NvrController.java
@@ -69,7 +69,7 @@ @DeleteMapping("/delete") @Operation(summary = "删除") @PreAuthorize("@ss.hasPermission('video:nvr:delete')") public CommonResult<Boolean> delete(@RequestParam("id") Long id) { public CommonResult<Boolean> delete(@RequestParam("id") String id) { devCameraService.delete(id); return success(true); } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/dahua/DHCapturePictureClient.java
@@ -1,7 +1,6 @@ package com.iailab.module.data.video.dahua; import com.alibaba.fastjson.JSON; import com.iailab.module.data.common.utils.HttpRequest; import com.iailab.module.data.video.config.VideoConfiguration; import com.iailab.module.data.video.dahua.frame.DHCapturePictureFrame; import com.iailab.netsdk.common.Res; import com.iailab.netsdk.demo.module.LoginModule; @@ -13,7 +12,6 @@ import com.sun.jna.ptr.IntByReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import java.awt.*; import java.io.File; @@ -26,10 +24,6 @@ */ public class DHCapturePictureClient { private Logger logger = LoggerFactory.getLogger(getClass()); // private String url = "http://localhost:48080/admin-api/data/video/camera/DHCaptureCallback"; // @Value("${video.dahua.callback.url}") // public String url; // 登陆句柄 public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE; @@ -299,11 +293,12 @@ return false; } else { System.out.println("CLIENT_CapturePicture success"); // 回调处理图片 // 处理图片 Map<String, String> params = new HashMap<>(); params.put("strFileName", strFileName); params.put("cmdSerial", cmdSerial); HttpRequest.doPost(DHConfiguration.staticUrl, JSON.toJSONString(params), "utf-8", ""); params.put("brand", "DH"); VideoConfiguration.staticCameraService.dealCapture(params); } return true; } catch (Exception ex) { iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/dahua/DHCaptureReceiveCB.java
@@ -1,12 +1,11 @@ package com.iailab.module.data.video.dahua; import com.alibaba.fastjson.JSON; import com.iailab.module.data.common.utils.HttpRequest; import com.iailab.module.data.video.config.VideoConfiguration; import com.iailab.module.data.video.service.CameraService; import com.iailab.netsdk.lib.NetSDKLib; import com.sun.jna.Pointer; import org.springframework.beans.factory.annotation.Value; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; @@ -25,12 +24,13 @@ */ public class DHCaptureReceiveCB implements NetSDKLib.fSnapRev { @Resource private CameraService cameraService; @Override public void invoke(NetSDKLib.LLong lLoginID, Pointer pBuf, int revLen, int encodeType, int cmdSerial, Pointer dwUser) { System.out.println("DHCaptureReceiveCB:"); Calendar calendar = Calendar.getInstance(); // calendar.set(Calendar.MONTH, 0); // calendar.set(Calendar.SECOND, 0); if (pBuf != null && revLen > 0) { String strFileName = DHSavePath.getSavePath().getSaveCapturePath(String.valueOf(cmdSerial), calendar.getTime()); System.out.println("cmdSerial=" + cmdSerial); @@ -48,12 +48,12 @@ e.printStackTrace(); } // 回调处理图片 // 处理图片 Map<String, String> params = new HashMap<>(); params.put("strFileName", strFileName); params.put("cmdSerial", Integer.valueOf(cmdSerial).toString()); HttpRequest.doPost(DHConfiguration.staticUrl, JSON.toJSONString(params), "utf-8", ""); params.put("brand", "DH"); cameraService.dealCapture(params); } } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/dahua/DHClientFactory.java
@@ -1,5 +1,6 @@ package com.iailab.module.data.video.dahua; import com.iailab.framework.tenant.core.context.TenantContextHolder; import com.iailab.module.data.video.dto.LogDTO; import com.iailab.module.data.video.dto.NvrDTO; import com.iailab.module.data.video.enums.CameraStatusEnum; iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/dahua/DHConfiguration.java
文件已删除 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/dahua/DHSavePath.java
@@ -1,9 +1,9 @@ package com.iailab.module.data.video.dahua; import com.iailab.module.data.video.config.VideoConfiguration; import com.iailab.netsdk.lib.ToolKits; import java.io.File; import java.io.IOException; import java.util.Date; /** @@ -27,12 +27,12 @@ * @return */ public String getSaveCapturePath(String channel, Date curDate) { File path1 = new File(DHConfiguration.staticCapturePath); File path1 = new File(VideoConfiguration.staticDhCapturePath); if (!path1.exists()) { path1.mkdir(); } File path2 = new File(DHConfiguration.staticCapturePath + ToolKits.getDay() + "/" + channel + "/"); File path2 = new File(VideoConfiguration.staticDhCapturePath + ToolKits.getDay() + "/" + channel + "/"); if (!path2.exists()) { path2.mkdirs(); } @@ -49,17 +49,17 @@ * @param curDate * @return */ public String getSaveModelPath(String cameraCode, Date curDate) throws IOException { // File path1 = new File(modelPath); // if (!path1.exists()) { // path1.mkdir(); // } File path2 = new File(DHConfiguration.staticModelPath + ToolKits.getDay() + "/" + cameraCode + "/"); // if (!path2.exists()) { // path2.mkdirs(); // } //return path2.getAbsolutePath() + "/"; return path2.getAbsolutePath(); } // public String getSaveModelPath(String cameraCode, Date curDate) throws IOException { //// File path1 = new File(modelPath); //// if (!path1.exists()) { //// path1.mkdir(); //// } // // File path2 = new File(DHConfiguration.staticModelPath + ToolKits.getDay() + "/" + cameraCode + "/"); //// if (!path2.exists()) { //// path2.mkdirs(); //// } // //return path2.getAbsolutePath() + "/"; // return path2.getAbsolutePath(); // } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/dao/ImageDao.java
@@ -1,7 +1,10 @@ package com.iailab.module.data.video.dao; import com.iailab.framework.common.dao.BaseDao; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.mybatis.core.mapper.BaseMapperX; import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; import com.iailab.framework.tenant.core.db.dynamic.TenantDS; import com.iailab.module.data.video.controller.admin.camera.vo.ImagePageReqVO; import com.iailab.module.data.video.entity.ImageEntity; import org.apache.ibatis.annotations.Mapper; @@ -12,5 +15,12 @@ */ @TenantDS @Mapper public interface ImageDao extends BaseDao<ImageEntity> { public interface ImageDao extends BaseMapperX<ImageEntity> { default PageResult<ImageEntity> selectPage(ImagePageReqVO pageReqVO) { return selectPage(pageReqVO, new LambdaQueryWrapperX<ImageEntity>() .likeIfPresent(ImageEntity::getCameraId, pageReqVO.getCameraId()) .orderByDesc(ImageEntity::getId)); } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/dto/ImageDTO.java
@@ -29,4 +29,11 @@ private String imageUrl; private Date createDate; private String brand; private String code; private String device; } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/hikvision/utils/HIKDevice.java
@@ -1,5 +1,9 @@ package com.iailab.module.data.video.hikvision.utils; import com.alibaba.fastjson.JSONException; import com.iailab.module.data.video.config.VideoConfiguration; import com.iailab.module.data.video.dto.CameraDTO; import com.iailab.module.data.video.enums.CameraStatusEnum; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.Platform; @@ -8,41 +12,43 @@ import javax.annotation.PreDestroy; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.HashMap; import java.util.Map; @Slf4j @Component public class HIKDevice { // 接口的实例,通过接口实例调用外部dll/so的函数 public static HCNetSDK hCNetSDK = null; // 接口的实例,通过接口实例调用外部dll/so的函数 public static HCNetSDK hCNetSDK = null; // 用户登录返回句柄 public static int lUserID; public static int lUserID; //构造函数 public HIKDevice(){ if (hCNetSDK == null) { public HIKDevice() { if (hCNetSDK == null) { synchronized (HCNetSDK.class) { try { if (Platform.isWindows()) { hCNetSDK = (HCNetSDK) Native.loadLibrary(MessageCode.HIK_WIN_PATH, HCNetSDK.class); } if (Platform.isLinux()) { hCNetSDK = (HCNetSDK) Native.loadLibrary(MessageCode.HIK_LINUX_PATH, HCNetSDK.class); } if (Platform.isWindows()) { hCNetSDK = (HCNetSDK) Native.loadLibrary(MessageCode.HIK_WIN_PATH, HCNetSDK.class); } if (Platform.isLinux()) { hCNetSDK = (HCNetSDK) Native.loadLibrary(MessageCode.HIK_LINUX_PATH, HCNetSDK.class); } } catch (Exception ex) { log.error("SdkInitService-init-hCNetSDK-error"); } } } } /** * 初始化资源配置 */ public int initDevices(){ System.out.println("进入构造函数"); /** * 初始化资源配置 */ public int initDevices() { System.out.println("进入构造函数"); // 初始化SDK boolean initSuc = hCNetSDK.NET_DVR_Init(); if (initSuc != true) { @@ -52,180 +58,154 @@ // 设置连接时间与重连时间 hCNetSDK.NET_DVR_SetConnectTime(2000, 1); System.out.println("初始化SDK资源完成"); return 0; } return 0; } //销毁函数 @PreDestroy public void destroy() throws Exception { hCNetSDK.NET_DVR_Cleanup(); } /* * 功能:登录设备 * 参数: * deviceIP-设备局域网IP地址 * devicePort-设备SDK服务端口 * userName-用户名 * passWord-密码 * */ // public String loginDevice() throws JSONException { // if (!getDeviceStatus()) { // int init = initDevices(); // if (init == 1) { // return "初始化失败"; // } // ArrayList<String> list = mZnfxCodeService.getDriverInfo("driverinfo"); // if (list != null && list.size() > 0) { // String driverip = list.get(0); // String driverport = list.get(1); // String username = list.get(2); // String password = list.get(3); // String returnVal = Login_V40(driverip, Short.parseShort(driverport), username, password); // System.out.println(returnVal); // return returnVal; // } else { // return "获取设备信息失败!"; // } // } // else // { // String result = captureJPEGPicture(); // System.out.println(result); // return result; // } // // } * 功能:登录设备 * 参数: * deviceIP-设备局域网IP地址 * devicePort-设备SDK服务端口 * userName-用户名 * passWord-密码 * */ public String loginDevice(CameraDTO camera) throws JSONException { if (!getDeviceStatus(camera.getId())) { int init = initDevices(); if (init == 1) { return "初始化失败"; } String driverip = camera.getIp(); String driverport = camera.getPort(); String username = camera.getUsername(); String password = camera.getPassword(); String returnVal = Login_V40(driverip, Short.parseShort(driverport), username, password, camera); System.out.println(returnVal); return returnVal; } else { String result = captureJPEGPicture(camera); System.out.println(result); return result; } } /** * * @param m_sDeviceIP 设备ip地址 * @param wPort 端口号,设备网络SDK登录默认端口8000 * @param m_sUsername 用户名 * @param m_sPassword 密码 */ public String Login_V40(String m_sDeviceIP,short wPort,String m_sUsername,String m_sPassword) { /* 注册 */ // 设备登录信息 HCNetSDK.NET_DVR_USER_LOGIN_INFO m_strLoginInfo = new HCNetSDK.NET_DVR_USER_LOGIN_INFO(); * @param m_sDeviceIP 设备ip地址 * @param wPort 端口号,设备网络SDK登录默认端口8000 * @param m_sUsername 用户名 * @param m_sPassword 密码 */ public String Login_V40(String m_sDeviceIP, short wPort, String m_sUsername, String m_sPassword, CameraDTO camera) { /* 注册 */ // 设备登录信息 HCNetSDK.NET_DVR_USER_LOGIN_INFO m_strLoginInfo = new HCNetSDK.NET_DVR_USER_LOGIN_INFO(); // 设备信息 HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40(); m_strLoginInfo.sDeviceAddress = new byte[HCNetSDK.NET_DVR_DEV_ADDRESS_MAX_LEN]; System.arraycopy(m_sDeviceIP.getBytes(), 0, m_strLoginInfo.sDeviceAddress, 0, m_sDeviceIP.length()); m_strLoginInfo.wPort =wPort ; m_strLoginInfo.sUserName = new byte[HCNetSDK.NET_DVR_LOGIN_USERNAME_MAX_LEN]; System.arraycopy(m_sUsername.getBytes(), 0, m_strLoginInfo.sUserName, 0, m_sUsername.length()); m_strLoginInfo.sPassword = new byte[HCNetSDK.NET_DVR_LOGIN_PASSWD_MAX_LEN]; System.arraycopy(m_sPassword.getBytes(), 0, m_strLoginInfo.sPassword, 0, m_sPassword.length()); // 是否异步登录:false- 否,true- 是 m_strLoginInfo.bUseAsynLogin = false; // write()调用后数据才写入到内存中 m_strLoginInfo.write(); // 设备信息 HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40(); m_strLoginInfo.sDeviceAddress = new byte[HCNetSDK.NET_DVR_DEV_ADDRESS_MAX_LEN]; System.arraycopy(m_sDeviceIP.getBytes(), 0, m_strLoginInfo.sDeviceAddress, 0, m_sDeviceIP.length()); m_strLoginInfo.wPort = wPort; m_strLoginInfo.sUserName = new byte[HCNetSDK.NET_DVR_LOGIN_USERNAME_MAX_LEN]; System.arraycopy(m_sUsername.getBytes(), 0, m_strLoginInfo.sUserName, 0, m_sUsername.length()); m_strLoginInfo.sPassword = new byte[HCNetSDK.NET_DVR_LOGIN_PASSWD_MAX_LEN]; System.arraycopy(m_sPassword.getBytes(), 0, m_strLoginInfo.sPassword, 0, m_sPassword.length()); // 是否异步登录:false- 否,true- 是 m_strLoginInfo.bUseAsynLogin = false; // write()调用后数据才写入到内存中 m_strLoginInfo.write(); lUserID = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo); if (lUserID == -1) { // updateZnfxPostalStatus(PostalStatus.ABNORMAL.value()); // mZnfxPostalStatusService.changeStatus(MessageCode.POSTAL_STATUS_TYPE_CAMERA, PostalStatus.ABNORMAL.value()); System.out.println("登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError()); return "登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError(); } else { System.out.println("登录成功!"); // read()后,结构体中才有对应的数据 m_strDeviceInfo.read(); // updateZnfxPostalStatus(PostalStatus.NORMAL.value()); // mZnfxPostalStatusService.changeStatus(MessageCode.POSTAL_STATUS_TYPE_CAMERA, PostalStatus.NORMAL.value()); String result = captureJPEGPicture(); return result; } } //注销设备 public String logoutDevice() { NativeLong nlUserID = new NativeLong(lUserID); if (!hCNetSDK.NET_DVR_Logout(nlUserID)) { System.out.println("注销失败,设备ID:"+ nlUserID.intValue() + "错误码:"+hCNetSDK.NET_DVR_GetLastError()); return "{\"result\":\"loginDevice Fail\",\"userID\":"+nlUserID.intValue()+",\"errorCode\":"+hCNetSDK.NET_DVR_GetLastError()+"}"; }else{ System.out.println("注销成功,设备ID:"+ nlUserID.intValue()); return "{\"result\":\"logoutDevice Success\",\"userID\":"+nlUserID.intValue()+",\"errorCode\":0}"; lUserID = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo); if (lUserID == -1) { VideoConfiguration.staticCameraService.setStatus(camera.getId(), CameraStatusEnum.OFFLINE.getCode()); System.out.println("登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError()); return "登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError(); } else { System.out.println("登录成功!"); // read()后,结构体中才有对应的数据 m_strDeviceInfo.read(); VideoConfiguration.staticCameraService.setStatus(camera.getId(), CameraStatusEnum.ONLIEN.getCode()); String result = captureJPEGPicture(camera); return result; } } /** * 设备抓图(无预览) * 单帧设备抓取保存的图片为JPG,具体注意问题需要详细查看【设备网络sdk使用手册】 * @return */ public String captureJPEGPicture() { // ArrayList<String> list = mZnfxCodeService.getDriverInfo("driverpic"); List<String> list = new ArrayList<>(); list.add("tlChannel"); list.add("tlPicSize"); list.add("tlPicQuality"); if (list != null && list.size() > 0) { int tlChannel = Integer.parseInt(list.get(0)); int tlPicSize = Integer.parseInt(list.get(1)); int tlPicQuality = Integer.parseInt(list.get(2)); NativeLong nlUserID = new NativeLong(lUserID); NativeLong nChannel = new NativeLong(tlChannel); HCNetSDK.NET_DVR_JPEGPARA lpJpegPara = new HCNetSDK.NET_DVR_JPEGPARA(); lpJpegPara.wPicSize = (short)tlPicSize; lpJpegPara.wPicQuality = (short)tlPicQuality; // 参数必须写入到结构体,否则在保存图片的时候异常图片 lpJpegPara.write(); String tFiledirName = CommonUtils.getCurrDate();//yyyyMMdd // 创建文件名称 String tDatePath = MessageCode.DvrPicSavePath+"/"+tFiledirName; // 判断文件夹是否创建 File tFile = new File(tDatePath); if (!tFile.exists()){ tFile.mkdirs(); } String tDate = CommonUtils.getCurrDate2();//yyyyMMddHHmmss // 文件名称 String tImageName = tDate +".png"; // 全路径 String tPath = tDatePath+"/"+tImageName; // 开始抓图 if (!hCNetSDK.NET_DVR_CaptureJPEGPicture(nlUserID, nChannel, lpJpegPara, tPath)) { return "失败编码:"+hCNetSDK.NET_DVR_GetLastError() ; }else { Long tImageId = CommonUtils.Getnum();//生成流水号 // saveZnfxImageInfo(tFiledirName,tImageName,tPath,tImageId); //注销设备 public String logoutDevice() { NativeLong nlUserID = new NativeLong(lUserID); if (!hCNetSDK.NET_DVR_Logout(nlUserID)) { System.out.println("注销失败,设备ID:" + nlUserID.intValue() + "错误码:" + hCNetSDK.NET_DVR_GetLastError()); return "{\"result\":\"loginDevice Fail\",\"userID\":" + nlUserID.intValue() + ",\"errorCode\":" + hCNetSDK.NET_DVR_GetLastError() + "}"; } else { System.out.println("注销成功,设备ID:" + nlUserID.intValue()); return "{\"result\":\"logoutDevice Success\",\"userID\":" + nlUserID.intValue() + ",\"errorCode\":0}"; } } return "success>>>>>>>>>>>" + tImageName; } } else { return "login fail>>>>>>>>>>>"; } } /** * 检查设备是否在线 /** * 设备抓图(无预览) * 单帧设备抓取保存的图片为JPG,具体注意问题需要详细查看【设备网络sdk使用手册】 * * @return */ private boolean getDeviceStatus() { boolean isOnLine = hCNetSDK.NET_DVR_RemoteControl(lUserID, 20005, null, 0); // if (!isOnLine) { //// updateZnfxPostalStatus(PostalStatus.ABNORMAL.value()); //离线 //// insertZnfxPostalStatusLog(PostalStatus.ABNORMAL.value()); // mZnfxPostalStatusService.changeStatus(MessageCode.POSTAL_STATUS_TYPE_CAMERA, PostalStatus.ABNORMAL.value()); // return false; // } else { // mZnfxPostalStatusService.changeStatus(MessageCode.POSTAL_STATUS_TYPE_CAMERA, PostalStatus.NORMAL.value()); //// updateZnfxPostalStatus(PostalStatus.NORMAL.value());//在线 // } return true; } public String captureJPEGPicture(CameraDTO camera) { int tlChannel = camera.getChannel(); String tlPicSize = VideoConfiguration.staticPicSize; String tlPicQuality = VideoConfiguration.staticPicQuality; NativeLong nlUserID = new NativeLong(lUserID); NativeLong nChannel = new NativeLong(tlChannel); HCNetSDK.NET_DVR_JPEGPARA lpJpegPara = new HCNetSDK.NET_DVR_JPEGPARA(); lpJpegPara.wPicSize = Short.parseShort(tlPicSize); lpJpegPara.wPicQuality = Short.parseShort(tlPicQuality); // 参数必须写入到结构体,否则在保存图片的时候异常图片 lpJpegPara.write(); String tFilename = CommonUtils.getCurrDate();//yyyyMMdd // 创建文件名称 String tDatePath = VideoConfiguration.staticHkCapturePath + tFilename; // 判断文件夹是否创建 File tFile = new File(tDatePath); if (!tFile.exists()) { tFile.mkdirs(); } String tDate = CommonUtils.getCurrDate2();//yyyyMMddHHmmss // 文件名称 String tImageName = tDate + ".png"; // 全路径 String tPath = tDatePath + "/" + tImageName; // 开始抓图 if (!hCNetSDK.NET_DVR_CaptureJPEGPicture(nlUserID, nChannel, lpJpegPara, tPath)) { return "失败编码:" + hCNetSDK.NET_DVR_GetLastError(); } else { Map<String, String> params = new HashMap<>(); params.put("strFileName", tPath); params.put("cmdSerial", camera.getCode()); params.put("brand", "HK"); VideoConfiguration.staticCameraService.dealCapture(params); return "success>>>>>>>>>>>" + tImageName; } } /** * 检查设备是否在线 * * @return */ private boolean getDeviceStatus(String id) { boolean isOnLine = hCNetSDK.NET_DVR_RemoteControl(lUserID, 20005, null, 0); if (!isOnLine) { VideoConfiguration.staticCameraService.setStatus(id, CameraStatusEnum.OFFLINE.getCode()); return false; } else { VideoConfiguration.staticCameraService.setStatus(id, CameraStatusEnum.ONLIEN.getCode()); } return true; } // /** // * 更新摄像头通讯状态 // * @param status iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/service/CameraService.java
@@ -29,7 +29,7 @@ void update(CameraDTO dto); void delete(String[] ids); void delete(String id); Long cheack(CameraDTO dto); @@ -38,4 +38,6 @@ CameraDTO getByCode(String code); void dealCapture(Map<String, String> params); void setStatus(String id, Integer status); } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/service/ImageService.java
@@ -1,35 +1,29 @@ package com.iailab.module.data.video.service; import com.iailab.framework.common.page.PageData; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.service.BaseService; import com.iailab.module.data.video.controller.admin.camera.vo.ImagePageReqVO; import com.iailab.module.data.video.dto.ImageDTO; import com.iailab.module.data.video.entity.DataEntity; import com.iailab.module.data.video.entity.ImageEntity; import javax.validation.Valid; import java.util.Date; import java.util.List; import java.util.Map; /** * @author PanZhibao * @author Houzhongjian * @Description * @createTime 2024年02月27日 */ public interface ImageService extends BaseService<ImageEntity> { PageData<ImageDTO> page(Map<String, Object> params); PageResult<ImageDTO> getPage(ImagePageReqVO imagePageReqVO); List<ImageDTO> list(@Valid ImagePageReqVO cameraPageReqVO); ImageDTO get(String id); List<DataEntity> getValueList(String cameraId, Date startTime, Date endTime); void save(ImageDTO dto); void update(ImageDTO dto); void delete(String[] ids); String getUrl(String cameraId, String imagePath); void delete(String id); ImageDTO get(String cameraId, Date createDate); iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/service/NvrService.java
@@ -30,7 +30,7 @@ String update(NvrSaveReqVO saveReqVO); void delete(Long id); void delete(String id); // Long cheack(DevNvrDTO dto); iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/service/impl/CameraServiceImpl.java
@@ -10,8 +10,7 @@ import com.iailab.framework.web.core.util.WebFrameworkUtils; import com.iailab.module.data.mq.consumer.ImageMessage; import com.iailab.module.data.video.controller.admin.camera.vo.CameraPageReqVO; import com.iailab.module.data.video.dahua.DHConfiguration; import com.iailab.module.data.video.dahua.DHSavePath; import com.iailab.module.data.video.config.VideoConfiguration; import com.iailab.module.data.video.dao.CameraDao; import com.iailab.module.data.video.dao.ImageDao; import com.iailab.module.data.video.dto.CameraDTO; @@ -21,6 +20,7 @@ import com.iailab.module.data.video.service.CameraService; import org.apache.commons.lang3.StringUtils; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -36,6 +36,9 @@ */ @Service public class CameraServiceImpl extends BaseServiceImpl<CameraDao, CameraEntity> implements CameraService { @Value("${video.capture-dir}") public String captureDir; @Resource private CameraDao cameraDao; @@ -94,20 +97,40 @@ public void dealCapture(Map<String, String> params) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 0); Date captureDate = calendar.getTime(); CameraDTO devCamera = getByCode(params.get("cmdSerial")); String strFileName = params.get("strFileName"); String brand = params.get("brand"); String capturePath = ""; String routingKey = ""; switch (brand) { case "DH": capturePath = VideoConfiguration.staticDhCapturePath; routingKey = ImageMessage.DAHUA_ROUTING_KEY; break; case "HK": capturePath = VideoConfiguration.staticHkCapturePath; routingKey = ImageMessage.HIKVISION_ROUTING_KEY; break; } String imagePath = strFileName.replace("\\", "/"); String imageUrl = imagePath.replace(DHConfiguration.staticCapturePath, ""); String imageUrl = imagePath.replace(capturePath, ""); ImageEntity image = new ImageEntity(); image.setCameraId(devCamera.getId()); image.setImagePath(imagePath); image.setImageUrl("/Capture/" + imageUrl); image.setImageUrl(capturePath.replace(captureDir, "") + imageUrl); image.setCreateDate(captureDate); imageDao.insert(image); //存入rabbitmq消息队列,等待模型处理 sendRabbitMQMessage(image); sendRabbitMQMessage(image, routingKey); } @Override public void setStatus(String id, Integer status) { CameraEntity cameraEntity = new CameraEntity(); cameraEntity.setId(id); cameraEntity.setStatus(status); baseDao.updateById(cameraEntity); } private QueryWrapper<CameraEntity> getWrapper(CameraPageReqVO cameraPageReqVO){ @@ -136,8 +159,8 @@ @Override @DSTransactional(rollbackFor = Exception.class) public void delete(String[] ids) { baseDao.deleteBatchIds(Arrays.asList(ids)); public void delete(String id) { baseDao.deleteById(id); } @Override @@ -151,14 +174,13 @@ } // 发送rabbitMQ消息 private void sendRabbitMQMessage(ImageEntity image) { private void sendRabbitMQMessage(ImageEntity image, String routingKey) { String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); ImageMessage imageMessage = new ImageMessage(); imageMessage.setMessageId(image.getId()); imageMessage.setCreateTime(createTime); imageMessage.setImageDTO(BeanUtils.toBean(image, ImageDTO.class)); rabbitTemplate.convertAndSend(ImageMessage.EXCHANGE, ImageMessage.DAHUA_ROUTING_KEY, imageMessage); rabbitTemplate.convertAndSend(ImageMessage.EXCHANGE, ImageMessage.HIKVISION_ROUTING_KEY, imageMessage); rabbitTemplate.convertAndSend(ImageMessage.EXCHANGE, routingKey, imageMessage); } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/service/impl/ImageServiceImpl.java
@@ -2,26 +2,26 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.iailab.framework.common.constant.Constant; import com.iailab.framework.common.page.PageData; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.module.data.video.controller.admin.camera.vo.ImagePageReqVO; import com.iailab.module.data.video.dao.ImageDao; import com.iailab.module.data.video.dto.ImageDTO; import com.iailab.module.data.video.entity.DataEntity; import com.iailab.module.data.video.entity.ImageEntity; import com.iailab.module.data.video.entity.DataEntity; import com.iailab.module.data.video.service.ImageService; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.validation.Valid; import java.util.*; /** * @author PanZhibao * @author Houzhongjian * @Description * @createTime 2024年02月27日 */ @@ -29,12 +29,17 @@ public class ImageServiceImpl extends BaseServiceImpl<ImageDao, ImageEntity> implements ImageService { @Override public PageData<ImageDTO> page(Map<String, Object> params) { IPage<ImageEntity> page = baseDao.selectPage( getPage(params, Constant.CREATE_DATE, false), getWrapper(params) ); return getPageData(page, ImageDTO.class); public PageResult<ImageDTO> getPage(ImagePageReqVO imagePageReqVO) { PageResult<ImageEntity> pageResult = baseDao.selectPage(imagePageReqVO); return BeanUtils.toBean(pageResult, ImageDTO.class); } @Override public List<ImageDTO> list(@Valid ImagePageReqVO imagePageReqVO) { QueryWrapper<ImageEntity> queryWrapper = getWrapper(imagePageReqVO); queryWrapper.orderByDesc(Constant.CREATE_DATE); List<ImageEntity> list = baseDao.selectList(queryWrapper); return ConvertUtils.sourceToTarget(list, ImageDTO.class); } @Override @@ -44,79 +49,11 @@ return ConvertUtils.sourceToTarget(entity, ImageDTO.class); } private QueryWrapper<ImageEntity> getWrapper(Map<String, Object> params){ String cameraId = (String)params.get("cameraId"); String startTime = (String)params.get("startTime"); String endTime = (String)params.get("endTime"); QueryWrapper<ImageEntity> wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(cameraId), "camera_id", cameraId) .ge(StringUtils.isNotBlank(startTime), "create_date", startTime) .le(StringUtils.isNotBlank(endTime), "create_date", endTime); return wrapper; } @Override public List<DataEntity> getValueList(String cameraId, Date startTime, Date endTime) { QueryWrapper<ImageEntity> wrapper = new QueryWrapper<>(); wrapper.eq( "camera_id", cameraId) .ge( "create_date", startTime) .le( "create_date", endTime) .orderByAsc("create_date"); List<DataEntity> result = new ArrayList<>(); List<ImageEntity> list = baseDao.selectList(wrapper); if (CollectionUtils.isEmpty(list)) { return result; } list.forEach(item -> { DataEntity dataEntity = new DataEntity(); dataEntity.setDataValue(item.getImagePath()); dataEntity.setTimeStamp(item.getCreateDate()); result.add(dataEntity); }); return result; } @Override public String getUrl(String cameraId, String imagePath) { String result = ""; QueryWrapper<ImageEntity> wrapper = new QueryWrapper<>(); wrapper.eq( "camera_id", cameraId) .eq( "image_path", imagePath) .orderByDesc("create_date"); List<ImageEntity> devImageEntities = baseDao.selectList(wrapper); ImageEntity entity = new ImageEntity(); if (ObjectUtils.isNotEmpty(devImageEntities)) { entity = devImageEntities.get(0); } if (entity != null) { return entity.getImageUrl(); } return result; } @Override public void save(ImageDTO dto) { ImageEntity entity = ConvertUtils.sourceToTarget(dto, ImageEntity.class); //保存菜单 insert(entity); } @Override public void update(ImageDTO dto) { ImageEntity entity = ConvertUtils.sourceToTarget(dto, ImageEntity.class); //更新菜单 updateById(entity); } @Override @DSTransactional(rollbackFor = Exception.class) public void delete(String[] ids) { public void delete(String id) { //删除菜单 baseDao.deleteBatchIds(Arrays.asList(ids)); baseDao.deleteById(id); } @Override @@ -132,4 +69,11 @@ return ConvertUtils.sourceToTarget(entity, ImageDTO.class); } private QueryWrapper<ImageEntity> getWrapper(ImagePageReqVO imagePageReqVO){ String cameraId = imagePageReqVO.getCameraId(); QueryWrapper<ImageEntity> wrapper = new QueryWrapper<>(); wrapper.eq( "camera_id", cameraId); return wrapper; } } iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/service/impl/NvrServiceImpl.java
@@ -115,7 +115,7 @@ @Override @DSTransactional(rollbackFor = Exception.class) public void delete(Long id) { public void delete(String id) { nvrDao.deleteById(id); } iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yaml
@@ -81,10 +81,15 @@ upload-dir: D:/DLUT/upload/ video: capture-dir: D:/iailab dahua: path: capturePath: D:/irs/Capture/ modelPath: D:/irs/Model/ callback: url: http://localhost:48080/admin-api/data/video/camera/DHCaptureCallback capture-path: /Dahua/Capture/ model-path: /Dahua/Model/ hikvision: path: capture-path: /Hikvision/Capture/ model-path: /Hikvision/Model/ pic-size: 2 # size of picture 0=CIF, 1=QCIF, 2=D1 3=UXGA(1600x1200), 4=SVGA(800x600), 5=HD720p(1280x720),6=VGA pic-quality: 0 # quality of picture 0-best 1-better 2-normal iailab-module-data/iailab-module-data-biz/src/main/resources/application-test.yaml
@@ -52,7 +52,7 @@ influx-db: org: iailab bucket: buk_shasteel token: Q2qsriQG3FEfZ35lik1KSkFToma3bsgfQLwJrNQfSK06MC569sZ9mrQ0vLtsVYn70HMfQcC9gf_yUG16JQtm8w== token: p-WkLXdPmHD4Cdij2PD-r92dLEQqjQ8V5KhyZYHYroBNVE0ZrW5VgzqWBNmXmiEdxEWaURC7rrKVzuM0XTEraQ== url: http://172.16.8.200:8086 username: root password: iailab12345678 @@ -61,10 +61,15 @@ upload-dir: D:/DLUT/upload/ video: capture-dir: D:/iailab dahua: path: capturePath: D:/irs/Capture/ modelPath: D:/irs/Model/ callback: url: http://localhost:48080/admin-api/data/video/camera/DHCaptureCallback capture-path: /Dahua/Capture/ model-path: /Dahua/Model/ hikvision: path: capture-path: /Hikvision/Capture/ model-path: /Hikvision/Model/ pic-size: 2 # size of picture 0=CIF, 1=QCIF, 2=D1 3=UXGA(1600x1200), 4=SVGA(800x600), 5=HD720p(1280x720),6=VGA pic-quality: 0 # quality of picture 0-best 1-better 2-normal