|
@ -3,11 +3,15 @@ package com.storeroom.modules.storeroom3d.controller; |
|
|
import com.storeroom.annotaion.rest.AnonymousGetMapping; |
|
|
import com.storeroom.annotaion.rest.AnonymousGetMapping; |
|
|
import com.storeroom.annotaion.rest.AnonymousPostMapping; |
|
|
import com.storeroom.annotaion.rest.AnonymousPostMapping; |
|
|
import com.storeroom.exception.BaseException; |
|
|
import com.storeroom.exception.BaseException; |
|
|
|
|
|
import com.storeroom.modules.device.domain.CameraInfo; |
|
|
|
|
|
import com.storeroom.modules.device.domain.DeviceCamerBind; |
|
|
|
|
|
import com.storeroom.modules.device.domain.Storeroom; |
|
|
|
|
|
import com.storeroom.modules.device.service.CameraInfoService; |
|
|
|
|
|
import com.storeroom.modules.device.service.DeviceCamerBindService; |
|
|
|
|
|
import com.storeroom.modules.device.service.StoreroomService; |
|
|
import com.storeroom.modules.storeroom3d.domain.SecurityDoor; |
|
|
import com.storeroom.modules.storeroom3d.domain.SecurityDoor; |
|
|
import com.storeroom.modules.storeroom3d.service.SecurityDoorService; |
|
|
import com.storeroom.modules.storeroom3d.service.SecurityDoorService; |
|
|
import com.storeroom.utils.ApiResponse; |
|
|
|
|
|
import com.storeroom.utils.ExcelUtil; |
|
|
|
|
|
import com.storeroom.utils.StringUtils; |
|
|
|
|
|
|
|
|
import com.storeroom.utils.*; |
|
|
import com.storeroom.utils.enums.ResponseStatus; |
|
|
import com.storeroom.utils.enums.ResponseStatus; |
|
|
import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.ApiOperation; |
|
|
import io.swagger.annotations.ApiOperation; |
|
@ -24,10 +28,7 @@ import java.io.OutputStream; |
|
|
import java.io.UnsupportedEncodingException; |
|
|
import java.io.UnsupportedEncodingException; |
|
|
import java.net.URLEncoder; |
|
|
import java.net.URLEncoder; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.util.Date; |
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("/api/securitydoor/") |
|
|
@RequestMapping("/api/securitydoor/") |
|
@ -36,6 +37,10 @@ import java.util.Map; |
|
|
public class SecurityDoorController { |
|
|
public class SecurityDoorController { |
|
|
|
|
|
|
|
|
private final SecurityDoorService securityDoorService; |
|
|
private final SecurityDoorService securityDoorService; |
|
|
|
|
|
private final DeviceCamerBindService deviceCamerBindService; |
|
|
|
|
|
private final CameraInfoService cameraInfoService; |
|
|
|
|
|
private final StoreroomService storeroomService; |
|
|
|
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); |
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); |
|
|
|
|
|
|
|
|
@ApiOperation("创建记录") |
|
|
@ApiOperation("创建记录") |
|
@ -49,6 +54,24 @@ public class SecurityDoorController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
securityDoorService.create(securityDoor); |
|
|
securityDoorService.create(securityDoor); |
|
|
|
|
|
//获取当前时间 |
|
|
|
|
|
String StrNowtime = DateUtils.getNowTimeInMillis(); |
|
|
|
|
|
if (securityDoor.getAlarmLevel() == 0) { |
|
|
|
|
|
List<CameraInfo> cameraInfoList = new ArrayList<>(); |
|
|
|
|
|
List<DeviceCamerBind> list = deviceCamerBindService.queryDeviceInfoId(securityDoor.getDeviceId()); |
|
|
|
|
|
list.forEach(item -> { |
|
|
|
|
|
CameraInfo cameraInfo = new CameraInfo(); |
|
|
|
|
|
cameraInfo.setId(NanoIdUtils.randomNanoId()); |
|
|
|
|
|
cameraInfo.setDeviceCamerBindId(item); |
|
|
|
|
|
cameraInfo.setDescription(securityDoor.getAlarmMsg()); |
|
|
|
|
|
cameraInfo.setEvent("密集架报警"); |
|
|
|
|
|
//循环从第三方设备下载视频到服务器 |
|
|
|
|
|
String fileName = deviceCamerBindService.downloadVideo(StrNowtime, item.getDeviceInfoId(), item.getId()); |
|
|
|
|
|
cameraInfo.setDownloadLink(fileName); |
|
|
|
|
|
cameraInfoList.add(cameraInfo); |
|
|
|
|
|
}); |
|
|
|
|
|
cameraInfoService.createAll(cameraInfoList); |
|
|
|
|
|
} |
|
|
return ApiResponse.success(ResponseStatus.SUCCESS); |
|
|
return ApiResponse.success(ResponseStatus.SUCCESS); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -61,9 +84,9 @@ public class SecurityDoorController { |
|
|
@ApiOperation("门禁日志") |
|
|
@ApiOperation("门禁日志") |
|
|
@AnonymousGetMapping("initSecurityDoorLog") |
|
|
@AnonymousGetMapping("initSecurityDoorLog") |
|
|
public ApiResponse<Object> initSecurityDoorLog( |
|
|
public ApiResponse<Object> initSecurityDoorLog( |
|
|
String roomName, String deviceName,String startTime,String endTime, Pageable page |
|
|
|
|
|
|
|
|
String roomName, String deviceName, String startTime, String endTime, Pageable page |
|
|
) { |
|
|
) { |
|
|
return ApiResponse.success(securityDoorService.initSecurityDoorLog(roomName,deviceName,startTime,endTime,page)); |
|
|
|
|
|
|
|
|
return ApiResponse.success(securityDoorService.initSecurityDoorLog(roomName, deviceName, startTime, endTime, page)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ApiOperation("导出门禁日志") |
|
|
@ApiOperation("导出门禁日志") |
|
@ -71,30 +94,30 @@ public class SecurityDoorController { |
|
|
@ResponseBody |
|
|
@ResponseBody |
|
|
public void exportSecurityDoorLogList( |
|
|
public void exportSecurityDoorLogList( |
|
|
HttpServletResponse response, |
|
|
HttpServletResponse response, |
|
|
String roomName, String deviceName,String startTime,String endTime |
|
|
|
|
|
){ |
|
|
|
|
|
List<Map<String,Object>> logs = securityDoorService.initSecurityDoorLog(roomName,deviceName,startTime,endTime); |
|
|
|
|
|
String[] Etitle = {"序号","状态","库房","设备名称","档案信息","档号","事件","用户","警情描述","报警时间"}; |
|
|
|
|
|
String [][] content = new String[logs.size()][]; |
|
|
|
|
|
for(int i = 0;i<logs.size();i++){ |
|
|
|
|
|
|
|
|
String roomName, String deviceName, String startTime, String endTime |
|
|
|
|
|
) { |
|
|
|
|
|
List<Map<String, Object>> logs = securityDoorService.initSecurityDoorLog(roomName, deviceName, startTime, endTime); |
|
|
|
|
|
String[] Etitle = {"序号", "状态", "库房", "设备名称", "档案信息", "档号", "事件", "用户", "警情描述", "报警时间"}; |
|
|
|
|
|
String[][] content = new String[logs.size()][]; |
|
|
|
|
|
for (int i = 0; i < logs.size(); i++) { |
|
|
content[i] = new String[Etitle.length]; |
|
|
content[i] = new String[Etitle.length]; |
|
|
Map<String,Object> map = logs.get(i); |
|
|
|
|
|
content[i][0] = i+1+""; |
|
|
|
|
|
Integer alarmLevel = Integer.parseInt(map.get("alarmLevel")==null?"0":map.get("alarmLevel")+""); |
|
|
|
|
|
content[i][1] = alarmLevel ==0?"异常":"正常"; |
|
|
|
|
|
content[i][2] = map.get("roomName")+""; |
|
|
|
|
|
content[i][3] = map.get("deviceName")+""; |
|
|
|
|
|
content[i][4] = map.get("maintitle")+""; |
|
|
|
|
|
content[i][5] = map.get("archiveNo")+""; |
|
|
|
|
|
Integer alarmEvent = Integer.parseInt(map.get("alarmEvent")==null?"0":map.get("alarmEvent")+""); |
|
|
|
|
|
content[i][6] = alarmEvent==0?"出":"进"; |
|
|
|
|
|
content[i][7] = map.get("borrowerName")+""; |
|
|
|
|
|
content[i][8] = map.get("alarmMsg")+""; |
|
|
|
|
|
content[i][9] = map.get("createTime")+""; |
|
|
|
|
|
|
|
|
Map<String, Object> map = logs.get(i); |
|
|
|
|
|
content[i][0] = i + 1 + ""; |
|
|
|
|
|
Integer alarmLevel = Integer.parseInt(map.get("alarmLevel") == null ? "0" : map.get("alarmLevel") + ""); |
|
|
|
|
|
content[i][1] = alarmLevel == 0 ? "异常" : "正常"; |
|
|
|
|
|
content[i][2] = map.get("roomName") + ""; |
|
|
|
|
|
content[i][3] = map.get("deviceName") + ""; |
|
|
|
|
|
content[i][4] = map.get("maintitle") + ""; |
|
|
|
|
|
content[i][5] = map.get("archiveNo") + ""; |
|
|
|
|
|
Integer alarmEvent = Integer.parseInt(map.get("alarmEvent") == null ? "0" : map.get("alarmEvent") + ""); |
|
|
|
|
|
content[i][6] = alarmEvent == 0 ? "出" : "进"; |
|
|
|
|
|
content[i][7] = map.get("borrowerName") + ""; |
|
|
|
|
|
content[i][8] = map.get("alarmMsg") + ""; |
|
|
|
|
|
content[i][9] = map.get("createTime") + ""; |
|
|
} |
|
|
} |
|
|
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("sheet",Etitle,content,null); |
|
|
|
|
|
|
|
|
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("sheet", Etitle, content, null); |
|
|
try { |
|
|
try { |
|
|
ExcelUtil.setResponseHeader(response, "门禁日志"+format.format(new Date())); |
|
|
|
|
|
|
|
|
ExcelUtil.setResponseHeader(response, "门禁日志" + format.format(new Date())); |
|
|
OutputStream os = response.getOutputStream(); |
|
|
OutputStream os = response.getOutputStream(); |
|
|
wb.write(os); |
|
|
wb.write(os); |
|
|
os.flush(); |
|
|
os.flush(); |
|
|