| | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.File; |
| | | import java.nio.charset.Charset; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | |
| | | import com.dahua.netsdk.lib.NetSDKLib; |
| | | import com.dahua.netsdk.lib.ToolKits; |
| | | import com.ycl.entity.video.VideoAlarmReport; |
| | | import com.ycl.entity.video.VideoPoint; |
| | | import com.ycl.service.caseHandler.IViolationsService; |
| | | import com.ycl.service.oss.OssService; |
| | | import com.ycl.service.video.IVideoAlarmReportService; |
| | | import com.ycl.service.video.impl.IVideoPointService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 智能报警事件回调 |
| | | */ |
| | | @Component |
| | | public class AnalyzerDataCB implements NetSDKLib.fAnalyzerDataCallBack { |
| | | |
| | | |
| | | @Autowired |
| | | private OssService ossService; |
| | | |
| | | @Autowired |
| | | private IVideoPointService videoPointService; |
| | | |
| | | @Autowired |
| | | private IVideoAlarmReportService videoAlarmReportService; |
| | | |
| | | @Autowired |
| | | private IViolationsService violationsService; |
| | | |
| | | private final File picturePath; |
| | | private static AnalyzerDataCB instance; |
| | |
| | | } |
| | | case EVENT_IVS_CITY_MOTORPARKING: /// 1 城市机动车违停事件 |
| | | { |
| | | NetSDKLib.DEV_EVENT_CITY_MOTORPARKING_INFO msg = new NetSDKLib.DEV_EVENT_CITY_MOTORPARKING_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, msg); |
| | | stuFileInfo = msg.stuFileInfo; |
| | | System.out.println(" 城市机动车违停事件 时间(UTC):" + msg.UTC + " 通道号:" + msg.nChannelID + "违停持续时长(单位秒):" |
| | | + msg.nParkingDuration + "检测到的物体个数:" + msg.nObjectNum); |
| | | System.out.println("stuEventInfoEx = " + msg.stuEventInfoEx.toString()); |
| | | System.out.println("byVehicleHeadDirection = " + msg.byVehicleHeadDirection); |
| | | if (stuFileInfo != null) { // 保存图片 |
| | | String bigPicture = picturePath + File.separator |
| | | + String.format("Big_%d_%s_%d_%d_%d_%d.jpg", dwAlarmType, |
| | | stuFileInfo.stuFileTime.toStringTitle(), stuFileInfo.bCount, stuFileInfo.bIndex, |
| | | stuFileInfo.bFileType, stuFileInfo.nGroupId); |
| | | ToolKits.savePicture(pBuffer, 0, dwBufSize, bigPicture); |
| | | if (stPicInfo != null && stPicInfo.dwFileLenth > 0) { |
| | | String smallPicture = picturePath + File.separator |
| | | + String.format("Small_%d_%s_%d_%d_%d_%d.jpg", dwAlarmType, |
| | | stuFileInfo.stuFileTime.toStringTitle(), stuFileInfo.bCount, stuFileInfo.bIndex, |
| | | stuFileInfo.bFileType, stuFileInfo.nGroupId); |
| | | ToolKits.savePicture(pBuffer, stPicInfo.dwOffSet, stPicInfo.dwFileLenth, smallPicture); |
| | | } |
| | | } |
| | | if (msg.nImageInfoNum > 0) { |
| | | System.out.println("Picture Arr got, number +" + msg.nImageInfoNum); |
| | | NET_IMAGE_INFO_EX2[] pstuImageInfo = new NET_IMAGE_INFO_EX2[msg.nImageInfoNum]; |
| | | for (int i = 0; i < msg.nImageInfoNum; i++) { |
| | | pstuImageInfo[i] = new NET_IMAGE_INFO_EX2(); |
| | | } |
| | | ToolKits.GetPointerDataToStructArr(msg.pstuImageInfo, pstuImageInfo); |
| | | for (int i = 0; i < msg.nImageInfoNum; i++) { |
| | | System.out.println("pstuImageInfo[" + i + "].nOffset:" + pstuImageInfo[i].nOffset); |
| | | System.out.println("pstuImageInfo[" + i + "].nLength:" + pstuImageInfo[i].nLength); |
| | | if (pstuImageInfo != null && pstuImageInfo[i].nLength > 0) { |
| | | System.out.println("pstuImageInfo[" + i + "] picture received!"); |
| | | String bigPicture = picturePath + "\\" + System.currentTimeMillis() |
| | | + "related_MOTORPARKING_pstuImageInfo_" + i + ".jpg"; |
| | | ToolKits.savePicture(pBuffer, pstuImageInfo[i].nOffset, pstuImageInfo[i].nLength, bigPicture); |
| | | } |
| | | } |
| | | NetSDKLib.DEV_EVENT_CITY_MOTORPARKING_INFO info = new NetSDKLib.DEV_EVENT_CITY_MOTORPARKING_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, info); |
| | | |
| | | videoAlarmReport.setAlarmObj(JSON.toJSONString(info)); |
| | | videoAlarmReport.setAlarmTime(LocalDateTime.of(info.UTC.dwYear, info.UTC.dwMonth, info.UTC.dwDay, info.UTC.dwHour, info.UTC.dwMinute, info.UTC.dwSecond)); |
| | | |
| | | VideoPoint videoPoint = videoPointService.getByChannelId(info.nChannelID); |
| | | videoAlarmReport.setChannel(String.valueOf(info.nChannelID)); |
| | | videoAlarmReport.setAlarmId(String.valueOf(info.nEventID)); |
| | | videoAlarmReport.setAlarmName("非机动车乱停放"); |
| | | if (videoPoint != null) { |
| | | videoAlarmReport.setPlatResourceId(videoPoint.getPlatResourceId()); |
| | | } |
| | | |
| | | stuFileInfo = info.stuFileInfo; |
| | | System.out.println(" 城市机动车违停事件 时间(UTC):" + info.UTC + " 通道号:" + info.nChannelID + "违停持续时长(单位秒):" |
| | | + info.nParkingDuration + "检测到的物体个数:" + info.nObjectNum); |
| | | |
| | | // if (stuFileInfo != null) { // 保存图片 |
| | | // String bigPicture = picturePath + File.separator |
| | | // + String.format("Big_%d_%s_%d_%d_%d_%d.jpg", dwAlarmType, |
| | | // stuFileInfo.stuFileTime.toStringTitle(), stuFileInfo.bCount, stuFileInfo.bIndex, |
| | | // stuFileInfo.bFileType, stuFileInfo.nGroupId); |
| | | // ToolKits.savePicture(pBuffer, 0, dwBufSize, bigPicture); |
| | | // if (stPicInfo != null && stPicInfo.dwFileLenth > 0) { |
| | | // String smallPicture = picturePath + File.separator |
| | | // + String.format("Small_%d_%s_%d_%d_%d_%d.jpg", dwAlarmType, |
| | | // stuFileInfo.stuFileTime.toStringTitle(), stuFileInfo.bCount, stuFileInfo.bIndex, |
| | | // stuFileInfo.bFileType, stuFileInfo.nGroupId); |
| | | // ToolKits.savePicture(pBuffer, stPicInfo.dwOffSet, stPicInfo.dwFileLenth, smallPicture); |
| | | // } |
| | | // } |
| | | // if (msg.nImageInfoNum > 0) { |
| | | // System.out.println("Picture Arr got, number +" + msg.nImageInfoNum); |
| | | // NET_IMAGE_INFO_EX2[] pstuImageInfo = new NET_IMAGE_INFO_EX2[msg.nImageInfoNum]; |
| | | // for (int i = 0; i < msg.nImageInfoNum; i++) { |
| | | // pstuImageInfo[i] = new NET_IMAGE_INFO_EX2(); |
| | | // } |
| | | // ToolKits.GetPointerDataToStructArr(msg.pstuImageInfo, pstuImageInfo); |
| | | // for (int i = 0; i < msg.nImageInfoNum; i++) { |
| | | // System.out.println("pstuImageInfo[" + i + "].nOffset:" + pstuImageInfo[i].nOffset); |
| | | // System.out.println("pstuImageInfo[" + i + "].nLength:" + pstuImageInfo[i].nLength); |
| | | // if (pstuImageInfo != null && pstuImageInfo[i].nLength > 0) { |
| | | // System.out.println("pstuImageInfo[" + i + "] picture received!"); |
| | | // String bigPicture = picturePath + "\\" + System.currentTimeMillis() |
| | | // + "related_MOTORPARKING_pstuImageInfo_" + i + ".jpg"; |
| | | // ToolKits.savePicture(pBuffer, pstuImageInfo[i].nOffset, pstuImageInfo[i].nLength, bigPicture); |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | break; |
| | | } |
| | | case EVENT_IVS_CITY_NONMOTORPARKING: /// 2 城市非机动车违停事件 |
| | | { |
| | | NetSDKLib.DEV_EVENT_CITY_NONMOTORPARKING_INFO msg = new NetSDKLib.DEV_EVENT_CITY_NONMOTORPARKING_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, msg); |
| | | stuFileInfo = msg.stuFileInfo; |
| | | NetSDKLib.DEV_EVENT_CITY_NONMOTORPARKING_INFO info = new NetSDKLib.DEV_EVENT_CITY_NONMOTORPARKING_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, info); |
| | | |
| | | videoAlarmReport.setAlarmObj(JSON.toJSONString(info)); |
| | | videoAlarmReport.setAlarmTime(LocalDateTime.of(info.UTC.dwYear, info.UTC.dwMonth, info.UTC.dwDay, info.UTC.dwHour, info.UTC.dwMinute, info.UTC.dwSecond)); |
| | | |
| | | VideoPoint videoPoint = videoPointService.getByChannelId(info.nChannelID); |
| | | videoAlarmReport.setChannel(String.valueOf(info.nChannelID)); |
| | | videoAlarmReport.setAlarmId(String.valueOf(info.nEventID)); |
| | | videoAlarmReport.setAlarmName("非机动车乱停放"); |
| | | if (videoPoint != null) { |
| | | videoAlarmReport.setPlatResourceId(videoPoint.getPlatResourceId()); |
| | | } |
| | | |
| | | stuFileInfo = info.stuFileInfo; |
| | | System.out.println( |
| | | " 城市非机动车违停事件 时间(UTC):" + msg.UTC + " 通道号:" + msg.nChannelID + "检测到的物体个数:" + msg.nObjectNum); |
| | | " 城市非机动车违停事件 时间(UTC):" + info.UTC + " 通道号:" + info.nChannelID + "检测到的物体个数:" + info.nObjectNum); |
| | | break; |
| | | } |
| | | case EVENT_IVS_HOLD_UMBRELLA: /// 6 违规撑伞检测事件 |
| | | { |
| | | NetSDKLib.DEV_EVENT_HOLD_UMBRELLA_INFO msg = new NetSDKLib.DEV_EVENT_HOLD_UMBRELLA_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, msg); |
| | | stuFileInfo = msg.stuFileInfo; |
| | | NetSDKLib.DEV_EVENT_HOLD_UMBRELLA_INFO info = new NetSDKLib.DEV_EVENT_HOLD_UMBRELLA_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, info); |
| | | |
| | | videoAlarmReport.setAlarmObj(JSON.toJSONString(info)); |
| | | videoAlarmReport.setAlarmTime(LocalDateTime.of(info.UTC.dwYear, info.UTC.dwMonth, info.UTC.dwDay, info.UTC.dwHour, info.UTC.dwMinute, info.UTC.dwSecond)); |
| | | |
| | | VideoPoint videoPoint = videoPointService.getByChannelId(info.nChannelID); |
| | | videoAlarmReport.setChannel(String.valueOf(info.nChannelID)); |
| | | videoAlarmReport.setAlarmId(String.valueOf(info.nEventID)); |
| | | videoAlarmReport.setAlarmName("违规撑伞"); |
| | | if (videoPoint != null) { |
| | | videoAlarmReport.setPlatResourceId(videoPoint.getPlatResourceId()); |
| | | } |
| | | |
| | | stuFileInfo = info.stuFileInfo; |
| | | System.out.println( |
| | | " 违规撑伞检测事件 时间(UTC):" + msg.UTC + " 通道号:" + msg.nChannelID + "违法持续时长(单位秒)" + msg.nViolationDuration); |
| | | " 违规撑伞检测事件 时间(UTC):" + info.UTC + " 通道号:" + info.nChannelID + "违法持续时长(单位秒)" + info.nViolationDuration); |
| | | break; |
| | | } |
| | | case EVENT_IVS_SHOPPRESENCE: /// 7 占道经营 |
| | | { |
| | | NetSDKLib.DEV_EVENT_SHOPPRESENCE_INFO msg = new NetSDKLib.DEV_EVENT_SHOPPRESENCE_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, msg); |
| | | NetSDKLib.DEV_EVENT_SHOPPRESENCE_INFO info = new NetSDKLib.DEV_EVENT_SHOPPRESENCE_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, info); |
| | | |
| | | videoAlarmReport.setAlarmObj(JSON.toJSONString(info)); |
| | | videoAlarmReport.setAlarmTime(LocalDateTime.of(info.UTC.dwYear, info.UTC.dwMonth, info.UTC.dwDay, info.UTC.dwHour, info.UTC.dwMinute, info.UTC.dwSecond)); |
| | | |
| | | VideoPoint videoPoint = videoPointService.getByChannelId(info.nChannelID); |
| | | videoAlarmReport.setChannel(String.valueOf(info.nChannelID)); |
| | | videoAlarmReport.setAlarmId(String.valueOf(info.nEventID)); |
| | | videoAlarmReport.setAlarmName("占道经营"); |
| | | if (videoPoint != null) { |
| | | videoAlarmReport.setPlatResourceId(videoPoint.getPlatResourceId()); |
| | | } |
| | | |
| | | stuFileInfo = info.stuFileInfo; |
| | | System.out.println(" 占道经营检测事件 时间(UTC):" + info.UTC + " 通道号:" + info.nChannelID + "违法持续时长(单位秒)" |
| | | + info.nViolationDuration + "检测到的物体个数" + info.nObjectNum); |
| | | break; |
| | | } |
| | | case EVENT_IVS_DUSTBIN_OVER_FLOW: /// 9 垃圾桶满溢检测事件 |
| | | { |
| | | NetSDKLib.DEV_EVENT_DUSTBIN_OVER_FLOW_INFO msg = new NetSDKLib.DEV_EVENT_DUSTBIN_OVER_FLOW_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, msg); |
| | | stuFileInfo = msg.stuFileInfo; |
| | | System.out.println(" 垃圾桶满溢检测事件 时间(UTC):" + msg.UTC + " 通道号:" + msg.nChannelID + "违法持续时长(单位秒)" |
| | | + msg.nViolationDuration + "检测到的物体个数" + msg.nObjectNum); |
| | | NetSDKLib.DEV_EVENT_DUSTBIN_OVER_FLOW_INFO info = new NetSDKLib.DEV_EVENT_DUSTBIN_OVER_FLOW_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, info); |
| | | |
| | | videoAlarmReport.setAlarmObj(JSON.toJSONString(info)); |
| | | videoAlarmReport.setAlarmTime(LocalDateTime.of(info.UTC.dwYear, info.UTC.dwMonth, info.UTC.dwDay, info.UTC.dwHour, info.UTC.dwMinute, info.UTC.dwSecond)); |
| | | |
| | | VideoPoint videoPoint = videoPointService.getByChannelId(info.nChannelID); |
| | | videoAlarmReport.setChannel(String.valueOf(info.nChannelID)); |
| | | videoAlarmReport.setAlarmId(String.valueOf(info.nEventID)); |
| | | videoAlarmReport.setAlarmName("垃圾箱满溢"); |
| | | if (videoPoint != null) { |
| | | videoAlarmReport.setPlatResourceId(videoPoint.getPlatResourceId()); |
| | | } |
| | | |
| | | stuFileInfo = info.stuFileInfo; |
| | | System.out.println(" 垃圾桶满溢检测事件 时间(UTC):" + info.UTC + " 通道号:" + info.nChannelID + "违法持续时长(单位秒)" |
| | | + info.nViolationDuration + "检测到的物体个数" + info.nObjectNum); |
| | | break; |
| | | } |
| | | case EVENT_IVS_GARBAGE_PLASTICBAG: /// 10 打包垃圾 |
| | | { |
| | | NetSDKLib.DEV_EVENT_GARBAGE_EXPOSURE_INFO info = new NetSDKLib.DEV_EVENT_GARBAGE_EXPOSURE_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, info); |
| | | |
| | | videoAlarmReport.setAlarmObj(JSON.toJSONString(info)); |
| | | videoAlarmReport.setAlarmTime(LocalDateTime.of(info.UTC.dwYear, info.UTC.dwMonth, info.UTC.dwDay, info.UTC.dwHour, info.UTC.dwMinute, info.UTC.dwSecond)); |
| | | |
| | | VideoPoint videoPoint = videoPointService.getByChannelId(info.nChannelID); |
| | | videoAlarmReport.setChannel(String.valueOf(info.nChannelID)); |
| | | videoAlarmReport.setAlarmId(String.valueOf(info.nEventID)); |
| | | videoAlarmReport.setAlarmName("打包垃圾"); |
| | | if (videoPoint != null) { |
| | | videoAlarmReport.setPlatResourceId(videoPoint.getPlatResourceId()); |
| | | } |
| | | |
| | | stuFileInfo = info.stuFileInfo; |
| | | System.out.println(" 打包垃圾检测事件 时间(UTC):" + info.UTC + " 通道号:" + info.nChannelID + "违法持续时长(单位秒)" |
| | | + info.nViolationDuration + "检测到的物体个数" + info.nObjectNum); |
| | | break; |
| | | } |
| | | case EVENT_IVS_DOOR_FRONT_DIRTY: /// < 门前脏乱检测事件 |
| | | { |
| | |
| | | } |
| | | case EVENT_IVS_GARBAGE_EXPOSURE: /// 11 垃圾暴露检测事件 |
| | | { |
| | | NetSDKLib.DEV_EVENT_GARBAGE_EXPOSURE_INFO msg = new NetSDKLib.DEV_EVENT_GARBAGE_EXPOSURE_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, msg); |
| | | stuFileInfo = msg.stuFileInfo; |
| | | System.out.println(" 垃圾暴露检测事件 时间(UTC):" + msg.UTC + " 通道号:" + msg.nChannelID + "违法持续时长(单位秒)" |
| | | + msg.nViolationDuration + "检测到的物体个数" + msg.nObjectNum); |
| | | NetSDKLib.DEV_EVENT_GARBAGE_EXPOSURE_INFO info = new NetSDKLib.DEV_EVENT_GARBAGE_EXPOSURE_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, info); |
| | | |
| | | videoAlarmReport.setAlarmObj(JSON.toJSONString(info)); |
| | | videoAlarmReport.setAlarmTime(LocalDateTime.of(info.UTC.dwYear, info.UTC.dwMonth, info.UTC.dwDay, info.UTC.dwHour, info.UTC.dwMinute, info.UTC.dwSecond)); |
| | | |
| | | VideoPoint videoPoint = videoPointService.getByChannelId(info.nChannelID); |
| | | videoAlarmReport.setChannel(String.valueOf(info.nChannelID)); |
| | | videoAlarmReport.setAlarmId(String.valueOf(info.nEventID)); |
| | | videoAlarmReport.setAlarmName("暴露垃圾"); |
| | | if (videoPoint != null) { |
| | | videoAlarmReport.setPlatResourceId(videoPoint.getPlatResourceId()); |
| | | } |
| | | |
| | | stuFileInfo = info.stuFileInfo; |
| | | System.out.println(" 垃圾暴露检测事件 时间(UTC):" + info.UTC + " 通道号:" + info.nChannelID + "违法持续时长(单位秒)" |
| | | + info.nViolationDuration + "检测到的物体个数" + info.nObjectNum); |
| | | break; |
| | | } |
| | | case EVENT_IVS_VIOLENT_THROW_DETECTION: /// < 暴力抛物事件事件 |
| | |
| | | { |
| | | DEV_EVENT_STREET_SUNCURE_INFO info = new DEV_EVENT_STREET_SUNCURE_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, info); |
| | | |
| | | videoAlarmReport.setAlarmObj(JSON.toJSONString(info)); |
| | | videoAlarmReport.setAlarmTime(LocalDateTime.of(info.UTC.dwYear, info.UTC.dwMonth, info.UTC.dwDay, info.UTC.dwHour, info.UTC.dwMinute, info.UTC.dwSecond)); |
| | | |
| | | VideoPoint videoPoint = videoPointService.getByChannelId(info.nChannelID); |
| | | videoAlarmReport.setChannel(String.valueOf(info.nChannelID)); |
| | | videoAlarmReport.setAlarmId(String.valueOf(info.nEventID)); |
| | | videoAlarmReport.setAlarmName("沿街晾挂"); |
| | | if (videoPoint != null) { |
| | | videoAlarmReport.setPlatResourceId(videoPoint.getPlatResourceId()); |
| | | } |
| | | |
| | | stuFileInfo = info.stuFileInfo; |
| | | System.out.println(" 沿街晾晒事件 时间(UTC):" + info.UTC + " 通道号:" + info.nChannelID + " 违法持续时间: " |
| | | + info.nViolationDuration + " 检测到的物体数量: " + info.nObjectNum); |
| | | for (int i = 0; i < info.nObjectNum; i++) { |
| | | stPicInfo = info.stuObjects[i].stPicInfo; |
| | | if (stPicInfo != null && stPicInfo.dwFileLenth > 0) { |
| | | String smallPicture = picturePath + File.separator |
| | | + String.format("Small_%d_%s_%d_%d_%d_%d.jpg", dwAlarmType, |
| | | stuFileInfo.stuFileTime.toStringTitle(), stuFileInfo.bCount, stuFileInfo.bIndex, |
| | | stuFileInfo.bFileType, stuFileInfo.nGroupId); |
| | | ToolKits.savePicture(pBuffer, stPicInfo.dwOffSet, stPicInfo.dwFileLenth, smallPicture); |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | case EVENT_IVS_OUTDOOR_ADVERTISEMENT: // 14 户外广告事件 |
| | | { |
| | | DEV_EVENT_OUTDOOR_ADVERTISEMENT_INFO info = new DEV_EVENT_OUTDOOR_ADVERTISEMENT_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, info); |
| | | |
| | | videoAlarmReport.setAlarmObj(JSON.toJSONString(info)); |
| | | videoAlarmReport.setAlarmTime(LocalDateTime.of(info.UTC.dwYear, info.UTC.dwMonth, info.UTC.dwDay, info.UTC.dwHour, info.UTC.dwMinute, info.UTC.dwSecond)); |
| | | |
| | | VideoPoint videoPoint = videoPointService.getByChannelId(info.nChannelID); |
| | | videoAlarmReport.setChannel(String.valueOf(info.nChannelID)); |
| | | videoAlarmReport.setAlarmId(String.valueOf(info.nEventID)); |
| | | videoAlarmReport.setAlarmName("违规户外广告"); |
| | | if (videoPoint != null) { |
| | | videoAlarmReport.setPlatResourceId(videoPoint.getPlatResourceId()); |
| | | } |
| | | |
| | | stuFileInfo = info.stuFileInfo; |
| | | System.out.println(" 户外广告事件 时间(UTC):" + info.UTC + " 通道号:" + info.nChannelID + " 违法持续时间: " |
| | | + info.nViolationDuration + " 检测到的物体数量: " + info.nObjectNum); |
| | | for (int i = 0; i < info.nObjectNum; i++) { |
| | | stPicInfo = info.stuObjects[i].stPicInfo; |
| | | if (stPicInfo != null && stPicInfo.dwFileLenth > 0) { |
| | | String smallPicture = picturePath + File.separator |
| | | + String.format("Small_%d_%s_%d_%d_%d_%d.jpg", dwAlarmType, |
| | | stuFileInfo.stuFileTime.toStringTitle(), stuFileInfo.bCount, stuFileInfo.bIndex, |
| | | stuFileInfo.bFileType, stuFileInfo.nGroupId); |
| | | ToolKits.savePicture(pBuffer, stPicInfo.dwOffSet, stPicInfo.dwFileLenth, smallPicture); |
| | | } |
| | | } |
| | | |
| | | |
| | | break; |
| | | } |
| | | case EVENT_IVS_HUDDLE_MATERIAL:// 13 乱堆物料检测事件 id 648 |
| | | case EVENT_IVS_HUDDLE_MATERIAL:// 13 乱堆物料检测事件 id 648 乱堆物料 |
| | | { |
| | | DEV_EVENT_HUDDLE_MATERIAL_INFO info = new DEV_EVENT_HUDDLE_MATERIAL_INFO(); |
| | | ToolKits.GetPointerData(pAlarmInfo, info); |
| | | videoAlarmReport.setAlarmObj(JSON.toJSONString(info)); |
| | | videoAlarmReport.setAlarmTime(LocalDateTime.of(info.UTC.dwYear, info.UTC.dwMonth, info.UTC.dwDay, info.UTC.dwHour, info.UTC.dwMinute, info.UTC.dwSecond)); |
| | | |
| | | VideoPoint videoPoint = videoPointService.getByChannelId(info.nChannelID); |
| | | videoAlarmReport.setChannel(String.valueOf(info.nChannelID)); |
| | | videoAlarmReport.setAlarmId(String.valueOf(info.nEventID)); |
| | | videoAlarmReport.setAlarmName("乱堆物料"); |
| | | if (videoPoint != null) { |
| | | videoAlarmReport.setPlatResourceId(videoPoint.getPlatResourceId()); |
| | | } |
| | | |
| | | stuFileInfo = info.stuFileInfo; |
| | | System.out.println(" 乱堆物料检测事件 时间(UTC):" + info.UTC + " 通道号:" + info.nChannelID + " 违法持续时间: " |
| | | + info.nViolationDuration + " 检测到的物体数量: " + info.nObjectNum); |
| | | for (int i = 0; i < info.nObjectNum; i++) { |
| | | stPicInfo = info.stuObjects[i].stPicInfo; |
| | | if (stPicInfo != null && stPicInfo.dwFileLenth > 0) { |
| | | String smallPicture = picturePath + File.separator |
| | | + String.format("Small_%d_%s_%d_%d_%d_%d.jpg", dwAlarmType, |
| | | stuFileInfo.stuFileTime.toStringTitle(), stuFileInfo.bCount, stuFileInfo.bIndex, |
| | | stuFileInfo.bFileType, stuFileInfo.nGroupId); |
| | | ToolKits.savePicture(pBuffer, stPicInfo.dwOffSet, stPicInfo.dwFileLenth, smallPicture); |
| | | } |
| | | } |
| | | // for (int i = 0; i < info.nObjectNum; i++) { |
| | | // stPicInfo = info.stuObjects[i].stPicInfo; |
| | | // if (stPicInfo != null && stPicInfo.dwFileLenth > 0) { |
| | | // String smallPicture = picturePath + File.separator |
| | | // + String.format("Small_%d_%s_%d_%d_%d_%d.jpg", dwAlarmType, |
| | | // stuFileInfo.stuFileTime.toStringTitle(), stuFileInfo.bCount, stuFileInfo.bIndex, |
| | | // stuFileInfo.bFileType, stuFileInfo.nGroupId); |
| | | // ToolKits.savePicture(pBuffer, stPicInfo.dwOffSet, stPicInfo.dwFileLenth, smallPicture); |
| | | // } |
| | | // } |
| | | break; |
| | | } |
| | | case EVENT_IVS_TRASH_WITHOUT_COVER_DETECTION: //垃圾桶未盖盖子检测事件 |
| | |
| | | // stuFileInfo.bFileType, stuFileInfo.nGroupId); |
| | | // ToolKits.savePicture(pBuffer, stPicInfo.dwOffSet, stPicInfo.dwFileLenth, smallPicture); |
| | | // } |
| | | String extension = "jpg"; |
| | | String picData = ossService.uploadImages(new ByteArrayInputStream(pBuffer.getByteArray(stPicInfo.dwOffSet, dwBufSize)), extension); |
| | | videoAlarmReport.setPicData(picData); |
| | | } |
| | | try { |
| | | |
| | | String extension = "jpg"; |
| | | String picData = ossService.uploadImages(new ByteArrayInputStream(pBuffer.getByteArray(stPicInfo.dwOffSet, dwBufSize)), extension); |
| | | videoAlarmReport.setPicData(picData); |
| | | |
| | | } catch (Exception ex) { |
| | | System.out.println("保存图片错误:" + ex.getMessage()); |
| | | } |
| | | } |
| | | videoAlarmReportService.save(videoAlarmReport); |
| | | |
| | | List<VideoAlarmReport> videoAlarmReports = new ArrayList<>(); |
| | | videoAlarmReports.add(videoAlarmReport); |
| | | violationsService.saveFromVideo(videoAlarmReports); |
| | | |
| | | return 0; |
| | | } |