| | |
| | | import com.doumee.core.haikang.model.param.respose.*; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DESUtil; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.ImageBase64Util; |
| | | import com.doumee.dao.business.CompanyMapper; |
| | |
| | | return ; |
| | | } |
| | | Constants.DEALING_HK_VISIT =true; |
| | | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() |
| | | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode(); |
| | | List<DeviceRole> roleList = deviceRoleMapper.selectList(new QueryWrapper<DeviceRole>().lambda() |
| | | .eq(DeviceRole::getType, Constants.ONE)); |
| | | //标记是否走免登记预约 |
| | |
| | | String applyLwType =systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.MDJ_LW_REQUIRED).getCode(); |
| | | try { |
| | | //查询所有需要同步的数据 |
| | | List<Visits> alllist = getVisitList(); |
| | | List<Visits> list = getVisitList(); |
| | | //按照父级申请分批处理每次申请数据 |
| | | List<Visits> list = getParentList(alllist); |
| | | // List<Visits> list = getParentList(alllist); |
| | | if(list ==null || list.size()==0){ |
| | | return; |
| | | } |
| | |
| | | for(Visits c : list) { |
| | | //发起海康预约接口(需要登记),根据预约返回接口封装申请记录更新字段 |
| | | String type = Constants.equalsInteger(c.getType(),Constants.ONE)?applyType:applyLwType; |
| | | getUpdateModelByResponse(c,date,type,roleList); |
| | | getUpdateModelByResponse(c,date,type,roleList,path); |
| | | visitsMapper.updateById(c); |
| | | } |
| | | }catch (Exception e){ |
| | |
| | | * @param date |
| | | * @param type 0需要登记 1免登记 |
| | | */ |
| | | private void getUpdateModelByResponse( Visits c,Date date,String type,List<DeviceRole> roleList ) { |
| | | private void getUpdateModelByResponse( Visits c,Date date,String type,List<DeviceRole> roleList,String path ) { |
| | | String code = null; |
| | | String id = null; |
| | | //发起海康预约接口 |
| | | if(StringUtils.equals(type,"0")){ |
| | | //(需要登记) |
| | | BaseResponse<VisitAppointmentResponse> response = HKService.visitAppiontment(getHkRequestPara(c,roleList)); |
| | | VisitAppointmentRequest request = getHkRequestPara(c,roleList,path); |
| | | if(request == null){ |
| | | //海康下发成功 |
| | | c.setStatus(Constants.VisitStatus.xfFail);//下发海康失败 |
| | | c.setRemark("下发海康参数不正确!"); |
| | | c.setHkStatus(Constants.ONE); |
| | | c.setHkDate(date); |
| | | return; |
| | | } |
| | | BaseResponse<VisitAppointmentResponse> response = HKService.visitAppiontment(request); |
| | | code =response!=null ?response.getCode():null; |
| | | id = (response!=null && response.getData()!=null |
| | | && response.getData().getAppointmentInfoList() !=null |
| | | && response.getData().getAppointmentInfoList().size()>0)?response.getData().getAppointmentInfoList().get(0).getOrderId():null; |
| | | }else{ |
| | | //免登记 |
| | | BaseResponse<VisitAppointmentMDJResponse> response = HKService.visitAppiontmentMDJ(getHkMDJRequestPara(c) ); |
| | | VisitAppointmentMDJRequest request =getHkMDJRequestPara(c,roleList,path); |
| | | if(request == null){ |
| | | //海康下发成功 |
| | | c.setStatus(Constants.VisitStatus.xfFail);//下发海康失败 |
| | | c.setRemark("下发海康免登记参数不正确!"); |
| | | c.setHkStatus(Constants.ONE); |
| | | c.setHkDate(date); |
| | | return; |
| | | } |
| | | BaseResponse<VisitAppointmentMDJResponse> response = HKService.visitAppiontmentMDJ(request ); |
| | | code =response!=null ?response.getCode():null; |
| | | id = (response!=null && response.getData()!=null)?response.getData().getOrderId():null; |
| | | } |
| | | |
| | | if (code!= null && id!=null) { |
| | | //海康下发成功 |
| | | c.setHkId( id);//预约标识 |
| | | c.setRemark("下发海康成功!【"+type+"】"); |
| | | c.setStatus(Constants.VisitStatus.xfSuccess);//下发海康成功 |
| | | } else { |
| | | //海康下发成功 |
| | | c.setRemark("下发海康失败!【"+type+"】"); |
| | | c.setStatus(Constants.VisitStatus.xfFail);//下发海康失败 |
| | | } |
| | | c.setHkStatus(Constants.ONE); |
| | | c.setHkDate(date); |
| | | } |
| | | |
| | | private VisitAppointmentMDJRequest getHkMDJRequestPara(Visits c) { |
| | | return null; |
| | | } |
| | | |
| | | private VisitAppointmentRequest getHkRequestPara(Visits c,List<DeviceRole> roleList ) { |
| | | VisitAppointmentRequest request = new VisitAppointmentRequest(); |
| | | /** |
| | | * 免登记接口参数 |
| | | * @param c |
| | | * @return |
| | | */ |
| | | private VisitAppointmentMDJRequest getHkMDJRequestPara(Visits c,List<DeviceRole> roleList,String path) { |
| | | VisitAppointmentMDJRequest request = new VisitAppointmentMDJRequest(); |
| | | VisitAppointmentVistorRequest info =getRequestInfoByVisit(c,path); |
| | | if(info == null ){ |
| | | //人脸为空,不能进行推送 |
| | | return null; |
| | | } |
| | | request.setVisitStartTime(DateUtil.getISO8601Timestamp(c.getStarttime())); |
| | | request.setVisitEndTime(DateUtil.getISO8601Timestamp(c.getEndtime())); |
| | | request.setReceptionistId(c.getReceptMemberHkId());//被访人海康编码 |
| | | request.setVisitPurpose(c.getReason()); |
| | | request.setVisitorPermissionSet(new VisitAppointmentPermissonRequest()); |
| | | request.setVisitorInfo(info); |
| | | request.setVisitorPermissionSet(getVisitPermissonRequest(roleList,c)); |
| | | return request; |
| | | } |
| | | |
| | | /** |
| | | * 访客权限组 |
| | | * @param roleList |
| | | * @param c |
| | | * @return |
| | | */ |
| | | private VisitAppointmentPermissonRequest getVisitPermissonRequest(List<DeviceRole> roleList, Visits c) { |
| | | VisitAppointmentPermissonRequest p = new VisitAppointmentPermissonRequest(); |
| | | //获取权限组集合 |
| | | String[] roles = getHkRoles(c.getDoors(),roleList); |
| | | if(roles==null || roles.length ==0){ |
| | | //使用默认访客权限组 |
| | | request.getVisitorPermissionSet().setDefaultPrivilegeGroupFlag(Constants.ONE+""); |
| | | p.setDefaultPrivilegeGroupFlag(Constants.ONE+""); |
| | | }else{ |
| | | //指定有效海康访客权限组数据 |
| | | request.getVisitorPermissionSet().setDefaultPrivilegeGroupFlag(Constants.ZERO+""); |
| | | request.getVisitorPermissionSet().setPrivilegeGroupIds(roles); |
| | | p.setDefaultPrivilegeGroupFlag(Constants.ZERO+""); |
| | | p.setPrivilegeGroupIds(roles); |
| | | } |
| | | return p; |
| | | } |
| | | |
| | | private VisitAppointmentRequest getHkRequestPara(Visits c,List<DeviceRole> roleList,String path ) { |
| | | VisitAppointmentRequest request = new VisitAppointmentRequest(); |
| | | //申请人信息 |
| | | VisitAppointmentVistorRequest info =getRequestInfoByVisit(c,path); |
| | | if(info == null ){ |
| | | //人脸为空,不能进行推送 |
| | | return null; |
| | | } |
| | | request.setVisitStartTime(DateUtil.getISO8601Timestamp(c.getStarttime())); |
| | | request.setVisitEndTime(DateUtil.getISO8601Timestamp(c.getEndtime())); |
| | | request.setReceptionistId(c.getReceptMemberHkId());//被访人海康编码 |
| | | request.setVisitPurpose(c.getReason()); |
| | | //获取权限组集合 |
| | | request.setVisitorPermissionSet(getVisitPermissonRequest(roleList,c)); |
| | | List<VisitAppointmentVistorRequest> infolist = new ArrayList<>(); |
| | | //申请人 |
| | | infolist.add(getRequestInfoByVisit(c)); |
| | | if(c.getVisitsList() != null){ |
| | | //随访人 |
| | | for(Visits v : c.getVisitsList()){ |
| | | infolist.add(getRequestInfoByVisit(v)); |
| | | } |
| | | } |
| | | infolist.add(info); |
| | | request.setVisitorInfoList(infolist); |
| | | return request; |
| | | } |
| | | |
| | | private VisitAppointmentVistorRequest getRequestInfoByVisit(Visits c) { |
| | | private VisitAppointmentVistorRequest getRequestInfoByVisit(Visits c,String path) { |
| | | VisitAppointmentVistorRequest info = new VisitAppointmentVistorRequest(); |
| | | //人脸数据 |
| | | if(StringUtils.isBlank(c.getName()) |
| | | ||StringUtils.isBlank(c.getPhone()) |
| | | || StringUtils.isBlank(c.getFaceImg()) ){ |
| | | return null; |
| | | } |
| | | if(StringUtils.isNotBlank(c.getFaceImg())){ |
| | | info.setVisitorPhoto(ImageBase64Util.Image2Base64(path+c.getFaceImg())); |
| | | } |
| | | if(info.getVisitorPhoto() == null){ |
| | | return null; |
| | | } |
| | | info.setVisitorName(c.getName()); |
| | | info.setVisitorWorkUnit(c.getCompanyName()); |
| | | info.setPhoneNo(c.getPhone()); |
| | | info.setPlateNo(c.getCarNos()); |
| | | if(Constants.equalsInteger(c.getIdcardType(),Constants.ZERO)){ |
| | | info.setCertificateType(HKConstants.CertificateType.SHENFENZHENG.getKey()+""); |
| | | info.setCertificateNo(DESUtil.decrypt(Constants.EDS_PWD, c.getIdcardNo())); |
| | | } else if(Constants.equalsInteger(c.getIdcardType(),Constants.TWO)){ |
| | | info.setCertificateType(HKConstants.CertificateType.HUZHAO.getKey()+""); |
| | | info.setCertificateNo(DESUtil.decrypt(Constants.EDS_PWD, c.getIdcardNo())); |
| | | } |
| | | |
| | | return info; |
| | | } |