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 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 * 参考API:https://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 * 参考API:https://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; } }