| | |
| | | package com.doumee.service.business.impl.hksync; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | |
| | | List<DeviceRole> roleList = deviceRoleMapper.selectList(new QueryWrapper<DeviceRole>().lambda() |
| | | .eq(DeviceRole::getType, Constants.ONE)); |
| | | //标记是否走免登记预约 |
| | | String applyType =systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.MDJ_VISIT_REQUIRED).getCode(); |
| | | String applyLwType =systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.MDJ_LW_REQUIRED).getCode(); |
| | | // String applyType =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.MDJ_VISIT_REQUIRED).getCode(); |
| | | // String applyLwType =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.MDJ_LW_REQUIRED).getCode(); |
| | | try { |
| | | //查询所有需要同步的数据 |
| | | List<Visits> list = getVisitList(); |
| | |
| | | Date date = new Date(); |
| | | for(Visits c : list) { |
| | | //发起海康预约接口(需要登记),根据预约返回接口封装申请记录更新字段 |
| | | String type = Constants.equalsInteger(c.getType(),Constants.ONE)?applyType:applyLwType; |
| | | getUpdateModelByResponse(c,date,type,roleList,path); |
| | | getUpdateModelByResponse(c,date,roleList,path); |
| | | visitsMapper.updateById(c); |
| | | if(Objects.isNull(c.getParentId())){ |
| | | wxPlatNotice.sendVisitAuditTemplateNotice(c, |
| | |
| | | * @param date |
| | | * @param type 0需要登记 1免登记 |
| | | */ |
| | | private void getUpdateModelByResponse( Visits c,Date date,String type,List<DeviceRole> roleList,String path ) { |
| | | private void getUpdateModelByResponse( Visits c,Date date, List<DeviceRole> roleList,String path ) { |
| | | String code = null; |
| | | String id = null; |
| | | String qrcode = null; |
| | | String reson = ""; |
| | | //发起海康预约接口 |
| | | if(StringUtils.equals(type,"0")){ |
| | | if(Constants.equalsInteger(c.getVisitType(),Constants.ZERO)){ |
| | | //(需要登记) |
| | | c.setVisitType(Constants.ZERO); |
| | | VisitAppointmentRequest request = getHkRequestPara(c,roleList,path); |
| | | if(request == null){ |
| | | //海康下发成功 |
| | |
| | | id =response.getData().getAppointmentInfoList().get(0).getOrderId(); |
| | | qrcode =response.getData().getAppointmentInfoList().get(0).getQRCode(); |
| | | } |
| | | reson = response!=null?JSONObject.toJSONString(response):""; |
| | | }else{ |
| | | //免登记 |
| | | c.setVisitType(Constants.ONE); |
| | | VisitAppointmentMDJRequest request =getHkMDJRequestPara(c,roleList,path); |
| | | if(request == null){ |
| | | //海康下发成功 |
| | |
| | | id = response.getData().getOrderId(); |
| | | qrcode =response.getData().getQRCode(); |
| | | } |
| | | reson = response!=null?JSONObject.toJSONString(response):""; |
| | | } |
| | | |
| | | if (code!= null && id!=null) { |
| | | //海康下发成功 |
| | | c.setHkId( id);//预约标识 |
| | | c.setQrcode(qrcode); |
| | | c.setRemark("下发海康成功!【"+type+"】"); |
| | | c.setRemark("下发海康成功!"); |
| | | c.setStatus(Constants.VisitStatus.xfSuccess);//下发海康成功 |
| | | } else { |
| | | //海康下发失败 |
| | | c.setRemark("下发海康失败!【"+type+"】"); |
| | | c.setRemark("下发海康失败,原因:"+ reson); |
| | | c.setStatus(Constants.VisitStatus.xfFail);//下发海康失败 |
| | | } |
| | | c.setHkStatus(Constants.ONE); |