| | |
| | | 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; |
| | |
| | | //发起海康预约接口(需要登记),根据预约返回接口封装申请记录更新字段 |
| | | AppointmentInfoResponse model = getVisitRecord(c.getHkId()); |
| | | if(model == null){ |
| | | Visits update = new Visits(); |
| | | continue; |
| | | /* Visits update = new Visits(); |
| | | //已失效 |
| | | update.setStatus(Constants.VisitStatus.invalid); |
| | | update.setEditDate(date); |
| | | update.setId(c.getId()); |
| | | update.setRemark("预约已被清除"); |
| | | visitsMapper.updateById(update); |
| | | continue; |
| | | continue;*/ |
| | | } |
| | | /** |
| | | * * 0:待审核(预约待审批)、 |
| | |
| | | if(!Constants.equalsInteger(c.getStatus(),Constants.VisitStatus.signout)){ |
| | | Visits update = new Visits(); |
| | | //已失效 |
| | | update.setStatus(Constants.VisitStatus.invalid); |
| | | update.setStatus(Constants.VisitStatus.signout); |
| | | update.setEditDate(date); |
| | | update.setId(c.getId()); |
| | | update.setInDate(DateUtil.getISO8601DateByStr2(model.getVisitStartTime())); |
| | |
| | | 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); |
| | |
| | | request.setVisitStartTime(DateUtil.getISO8601Timestamp2(c.getStarttime())); |
| | | request.setVisitEndTime(DateUtil.getISO8601Timestamp2(c.getEndtime())); |
| | | request.setReceptionistId(c.getReceptMemberHkId());//被访人海康编码 |
| | | request.setVisitPurpose(c.getReason()); |
| | | if(StringUtils.isNotBlank(c.getReason())){ |
| | | char[] charArray = c.getReason().toCharArray(); |
| | | int length = charArray.length; |
| | | if(length>32){ |
| | | request.setVisitPurpose(c.getReason().substring(0,32)); |
| | | }else{ |
| | | request.setVisitPurpose(c.getReason()); |
| | | } |
| | | } |
| | | request.setVisitorInfo(info); |
| | | request.setVisitorPermissionSet(getVisitPermissonRequest(roleList,c)); |
| | | return request; |
| | |
| | | if(info.getVisitorPhoto() == null){ |
| | | return null; |
| | | } |
| | | info.setVisitorName(c.getName()); |
| | | if(StringUtils.isNotBlank(c.getName())){ |
| | | char[] charArray = c.getName().toCharArray(); |
| | | int length = charArray.length; |
| | | if(length>32){ |
| | | info.setVisitorName(c.getName().substring(0,32)); |
| | | }else{ |
| | | info.setVisitorName(c.getName()); |
| | | } |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(c.getCompanyName())){ |
| | | char[] charArray = c.getCompanyName().toCharArray(); |
| | | int length = charArray.length; |