智慧工地项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
7.3 KiB

package com.zilber.boot.dahua.controller;
import com.dahuatech.hutool.http.Method;
import com.dahuatech.hutool.json.JSONUtil;
import com.dahuatech.icc.exception.ClientException;
import com.dahuatech.icc.oauth.model.v202010.OauthConfigUserPwdInfo;
import com.dahuatech.icc.oauth.utils.HttpUtils;
import com.zilber.boot.dahua.accesscontrol.QueryRecordRequest;
import com.zilber.boot.dahua.accesscontrol.QueryRecordResponse;
import com.zilber.boot.dahua.attendance.GetRecordPageRequest;
import com.zilber.boot.dahua.attendance.GetRecordPageResponse;
import com.zilber.boot.dahua.attendance.GetResultPageRequest;
import com.zilber.boot.dahua.attendance.GetResultPageResponse;
import com.zilber.boot.dahua.config.OauthConfigUtil;
import com.zilber.boot.dahua.device.DevicePageRequest;
import com.zilber.boot.dahua.device.DevicePageResponse;
import com.zilber.boot.dahua.video.RtspUrlRequest;
import com.zilber.boot.dahua.video.RtspUrlResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Api(tags = "大华接口")
@RequestMapping("/dahua")
@Slf4j
public class DahuaController {
/**
* 打卡记录查询
* @param getRecordPageRequest
* @return
* @throws ClientException
* 参考APIhttps://open-icc.dahuatech.com/#/home?url=%3Fnav%3Dwiki%2Fevo-attendance%2Fatt_information.html%23%E6%89%93%E5%8D%A1%E8%AE%B0%E5%BD%95%E6%9F%A5%E8%AF%A2&version=enterprisebase/5.0.16&blank=true
*/
@ApiOperation(value = "打卡记录查询",notes = "打卡记录查询")
@PostMapping("/attendance/getRecordPage")
public GetRecordPageResponse getAttendanceRecordPage(@RequestBody GetRecordPageRequest getRecordPageRequest) {
OauthConfigUserPwdInfo config = OauthConfigUtil.getOauthConfig();
GetRecordPageResponse response=null;
try {
//log.info("InfoQueryDemo,getAttendanceRecordPage,request:{}", JSONUtil.toJsonStr(getRecordPageRequest));
response = HttpUtils.executeJson("/evo-apigw/evo-attendance/1.1.0/attendance/record/page", getRecordPageRequest,null, Method.POST , config, GetRecordPageResponse.class);
//log.info("InfoQueryDemo,getAttendanceRecordPage,response:{}", JSONUtil.toJsonStr(response));
} catch (ClientException e) {
log.error(e.getErrMsg(), e);
}
if(!response.isSuccess()) {
log.info("打卡记录查询失败:{}",response.getErrMsg());
}
return response;
}
/**
* 分页获取考勤结果
* @param getResultPageRequest
* @return
* @throws ClientException
*/
@ApiOperation(value = "分页获取考勤结果",notes = "分页获取考勤结果")
@PostMapping("/attendance/getResultPage")
public GetResultPageResponse getAttendanceResultPage(@RequestBody GetResultPageRequest getResultPageRequest) {
OauthConfigUserPwdInfo config = OauthConfigUtil.getOauthConfig();
GetResultPageResponse response=null;
try {
//log.info("InfoQueryDemo,getAttendanceRecordPage,request:{}", JSONUtil.toJsonStr(getResultPageRequest));
response = HttpUtils.executeJson("/evo-apigw/evo-attendance/1.1.0/attendance/result/page", getResultPageRequest,null, Method.POST , config, GetResultPageResponse.class);
//log.info("InfoQueryDemo,getAttendanceRecordPage,response:{}", JSONUtil.toJsonStr(response));
} catch (ClientException e) {
log.error(e.getErrMsg(), e);
}
if(!response.isSuccess()) {
log.info("分页获取考勤结果失败:{}",response.getErrMsg());
}
return response;
}
/**
* 门禁
* @return
* @throws ClientException
* 参考APIhttps://open-icc.dahuatech.com/#/home?url=%3Fnav%3Dwiki%2Fevo-accesscontrol%2Fevent.html&version=enterprisebase/5.0.16&blank=true
*/
@ApiOperation(value = "门禁记录查询",notes = "门禁记录查询")
@PostMapping("/accessControl/getRecordPage")
public QueryRecordResponse getRecordPage(@RequestBody QueryRecordRequest queryRecordRequest){
OauthConfigUserPwdInfo config = OauthConfigUtil.getOauthConfig();
QueryRecordResponse response=null;
try {
//log.info("DeviceDemo,getRecordPage,request:{}", JSONUtil.toJsonStr(queryRecordRequest));
response = HttpUtils.executeJson("/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combined", queryRecordRequest,null, Method.POST , config, QueryRecordResponse.class);
//log.info("DeviceDemo,getRecordPage,response:{}", JSONUtil.toJsonStr(response));
} catch (ClientException e) {
log.error(e.getErrMsg(), e);
}
if(!response.isSuccess()) {
log.info("门禁记录分页查询失败:{}",response.getErrMsg());
}
return response;
}
/**
* 设备分页查询
* @param devicePageRequest
* @return
* 参考API https://open-icc.dahuatech.com/#/home?url=%3Fnav%3Dwiki%2Fevo-brm%2Fdevice.html&version=enterprisebase/5.0.17&blank=true
*/
@ApiOperation(value = "设备分页查询",notes = "设备分页查询")
@PostMapping("/brm/getDevicePage")
public DevicePageResponse getDevicePage(@RequestBody DevicePageRequest devicePageRequest){
OauthConfigUserPwdInfo config = OauthConfigUtil.getOauthConfig();
DevicePageResponse response=null;
try {
//log.info("DeviceDemo,getDevicePage,request:{}", JSONUtil.toJsonStr(devicePageRequest));
response = HttpUtils.executeJson("/evo-apigw/evo-brm/1.2.0/device/subsystem/page", devicePageRequest,null, Method.POST , config, DevicePageResponse.class);
//log.info("DeviceDemo,getDevicePage,response:{}", JSONUtil.toJsonStr(response));
} catch (ClientException e) {
log.error(e.getErrMsg(), e);
}
if(!response.isSuccess()) {
log.info("设备信息分页查询失败:{}",response.getErrMsg());
}
return response;
}
/**
* rtsp实时预览
* @param rtspUrlRequest
* @return
* 参考API https://open-icc.dahuatech.com/#/home?url=%3Fnav%3Dwiki%2Fevo-brm%2Fdevice.html&version=enterprisebase/5.0.17&blank=true
*/
@ApiOperation(value = " rtsp实时预览",notes = " rtsp实时预览")
@PostMapping("/video/getRtspUrl")
public RtspUrlResponse getRtspUrl(@RequestBody RtspUrlRequest rtspUrlRequest){
RtspUrlResponse response=null;
OauthConfigUserPwdInfo config = OauthConfigUtil.getOauthConfig();
try {
//log.info("RealTimePreviewDemo,getRtspUrl,request:{}", JSONUtil.toJsonStr(rtspUrlRequest));
response = HttpUtils.executeJson("/evo-apigw/admin/API/MTS/Video/StartVideo", rtspUrlRequest,null, Method.POST , config, RtspUrlResponse.class);
log.info("RealTimePreviewDemo,getRtspUrl,response:{}", JSONUtil.toJsonStr(response));
} catch (ClientException e) {
log.error(e.getErrMsg(), e);
}
if(!response.getCode().equals("1000")) {
log.info("获取rtsp流地址失败:{}",response.getErrMsg());
}
return response;
}
}