|  |  |  | 
|---|
|  |  |  | import com.doumee.core.utils.DESUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.ImageBase64Util; | 
|---|
|  |  |  | import com.doumee.core.wx.wxPlat.WxPlatConstants; | 
|---|
|  |  |  | import com.doumee.core.wx.wxPlat.WxPlatNotice; | 
|---|
|  |  |  | import com.doumee.dao.business.DeviceRoleMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.RetentionMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.WxNoticeConfigMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.VisitsJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.DeviceRole; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Member; | 
|---|
|  |  |  | 
|---|
|  |  |  | public class HkSyncVisitServiceImpl extends HkSyncBaseServiceImpl { | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private VisitsJoinMapper visitsMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WxPlatNotice wxPlatNotice; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WxNoticeConfigMapper wxNoticeConfigMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RetentionMapper retentionMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DeviceRoleMapper deviceRoleMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WxPlatNotice wxPlatNotice; | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 同步海康访客信息是否已签离状态 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //先删除原有的在场人员(普通访客) | 
|---|
|  |  |  | retentionMapper.delete(new UpdateWrapper<Retention>().lambda() | 
|---|
|  |  |  | .eq(Retention::getType,Constants.memberType.visitor) | 
|---|
|  |  |  | .eq(Retention::getType,Constants.RetentionMemberType.fk) | 
|---|
|  |  |  | .eq(Retention::getMemberId,c.getMemberId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | visitsMapper.updateById(update); | 
|---|
|  |  |  | //先删除原有的在场人员(普通访客) | 
|---|
|  |  |  | retentionMapper.delete(new UpdateWrapper<Retention>().lambda() | 
|---|
|  |  |  | .eq(Retention::getType,Constants.memberType.visitor) | 
|---|
|  |  |  | .eq(Retention::getType,Constants.RetentionMemberType.fk) | 
|---|
|  |  |  | .eq(Retention::getMemberId,c.getMemberId())); | 
|---|
|  |  |  | //再插入最新的在厂人员 | 
|---|
|  |  |  | retentionMapper.insert(getRetentionModelByVisitRequest(c,update.getInDate())); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //先删除原有的在场人员(普通访客) | 
|---|
|  |  |  | retentionMapper.delete(new UpdateWrapper<Retention>().lambda() | 
|---|
|  |  |  | .eq(Retention::getType,Constants.memberType.visitor) | 
|---|
|  |  |  | .eq(Retention::getType,Constants.RetentionMemberType.fk) | 
|---|
|  |  |  | .eq(Retention::getMemberId,c.getMemberId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | visitsMapper.updateById(update); | 
|---|
|  |  |  | //先删除原有的在场人员(普通访客) | 
|---|
|  |  |  | retentionMapper.delete(new UpdateWrapper<Retention>().lambda() | 
|---|
|  |  |  | .eq(Retention::getType,Constants.memberType.visitor) | 
|---|
|  |  |  | .eq(Retention::getType,Constants.RetentionMemberType.fk) | 
|---|
|  |  |  | .eq(Retention::getMemberId,c.getMemberId())); | 
|---|
|  |  |  | //再插入最新的在厂人员 | 
|---|
|  |  |  | retentionMapper.insert(getRetentionModelByVisitRequest(c,update.getInDate())); | 
|---|
|  |  |  | 
|---|
|  |  |  | //                getUpdateModelByResponse(c,date,roleList,path); | 
|---|
|  |  |  | getUpdateModelByResponseIccm(c,date,roleList,path); | 
|---|
|  |  |  | visitsMapper.updateById(c); | 
|---|
|  |  |  | //给申请人发送微信公众号 下发权限失败 | 
|---|
|  |  |  | if(StringUtils.isNotBlank(c.getOpenid()) && Constants.equalsInteger(c.getStatus(),Constants.VisitStatus.xfFail)){ | 
|---|
|  |  |  | wxPlatNotice.sendVisitTemplateNotice(systemDictDataBiz, | 
|---|
|  |  |  | wxNoticeConfigMapper,c, WxPlatConstants.visitContent.visitApplyHkFail, | 
|---|
|  |  |  | Arrays.asList(c.getOpenid().split(",")) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | 
|---|
|  |  |  | private void getUpdateModelByResponse(  Visits c,Date date, List<DeviceRole> roleList,String path ) { | 
|---|
|  |  |  | String code = null; | 
|---|
|  |  |  | String id = null; | 
|---|
|  |  |  | String recordid = null; | 
|---|
|  |  |  | String qrcode = null; | 
|---|
|  |  |  | String reson = ""; | 
|---|
|  |  |  | //发起海康预约接口 | 
|---|
|  |  |  | 
|---|
|  |  |  | code =response!=null ?response.getCode():null; | 
|---|
|  |  |  | if(response!=null && response.getData()!=null){ | 
|---|
|  |  |  | id = response.getData().getOrderId(); | 
|---|
|  |  |  | recordid = response.getData().getAppointRecordId(); | 
|---|
|  |  |  | qrcode =response.getData().getQRCode(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | reson = response!=null?JSONObject.toJSONString(response):""; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (code!= null && id!=null) { | 
|---|
|  |  |  | //海康下发成功 | 
|---|
|  |  |  | c.setHkId( id);//预约标识 | 
|---|
|  |  |  | c.setHkRecordId(recordid);//访客预约记录标识(用户取消预约) | 
|---|
|  |  |  | c.setQrcode(qrcode); | 
|---|
|  |  |  | c.setRemark("下发海康成功!"); | 
|---|
|  |  |  | c.setStatus(Constants.VisitStatus.xfSuccess);//下发海康成功 | 
|---|
|  |  |  | 
|---|
|  |  |  | public static void getUpdateModelByResponseIccm(  Visits c,Date date, List<DeviceRole> roleList,String path ) { | 
|---|
|  |  |  | String code = null; | 
|---|
|  |  |  | String id = null; | 
|---|
|  |  |  | String recordId = null; | 
|---|
|  |  |  | String qrcode = null; | 
|---|
|  |  |  | String reson = ""; | 
|---|
|  |  |  | //发起海康预约接口 | 
|---|
|  |  |  | 
|---|
|  |  |  | && response.getData().getAppointmentInfoList() !=null | 
|---|
|  |  |  | && response.getData().getAppointmentInfoList().size()>0)){ | 
|---|
|  |  |  | id =response.getData().getOrderId(); | 
|---|
|  |  |  | recordId = response.getData().getAppointRecordId(); | 
|---|
|  |  |  | //                qrcode =response.getData().getAppointmentInfoList().get(0).getQRCode(); | 
|---|
|  |  |  | qrcode =response.getData().getAppointmentInfoList().get(0).getVerificationCode(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | code =response!=null ?response.getCode():null; | 
|---|
|  |  |  | if(response!=null && response.getData()!=null){ | 
|---|
|  |  |  | id = response.getData().getOrderId(); | 
|---|
|  |  |  | recordId = response.getData().getAppointRecordId(); | 
|---|
|  |  |  | qrcode =response.getData().getQRCode(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | reson = response!=null?JSONObject.toJSONString(response):""; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (code!= null && id!=null) { | 
|---|
|  |  |  | //海康下发成功 | 
|---|
|  |  |  | c.setHkId( id);//预约标识 | 
|---|
|  |  |  | c.setHkRecordId(recordId); | 
|---|
|  |  |  | c.setQrcode(qrcode); | 
|---|
|  |  |  | c.setRemark("下发海康成功!"); | 
|---|
|  |  |  | c.setStatus(Constants.VisitStatus.xfSuccess);//下发海康成功 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | info.setPhoneNo(c.getPhone()); | 
|---|
|  |  |  | info.setPlateNo(c.getCarNos()); | 
|---|
|  |  |  | info.setGender(c.getSex()+""); | 
|---|
|  |  |  | info.setGender( "1" ); | 
|---|
|  |  |  | if(Constants.equalsInteger(c.getSex(),Constants.ONE) ||Constants.equalsInteger(c.getSex(),Constants.TWO)  ){ | 
|---|
|  |  |  | info.setGender( c.getSex()+""); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(c.getIdcardType(),Constants.ZERO)){ | 
|---|
|  |  |  | info.setCertificateType(HKConstants.CertificateType.SHENFENZHENG.getKey()+""); | 
|---|
|  |  |  | info.setCertificateNo(DESUtil.decrypt(Constants.EDS_PWD, c.getIdcardNo())); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | info.setPhoneNo(c.getPhone()); | 
|---|
|  |  |  | info.setPlateNo(c.getCarNos()); | 
|---|
|  |  |  | info.setGender(c.getSex()+""); | 
|---|
|  |  |  | info.setGender( "1"); | 
|---|
|  |  |  | if(Constants.equalsInteger(c.getSex(),Constants.ONE) ||Constants.equalsInteger(c.getSex(),Constants.TWO)  ){ | 
|---|
|  |  |  | info.setGender( c.getSex()+""); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(c.getIdcardType(),Constants.ZERO)){ | 
|---|
|  |  |  | info.setCertificateType(HKConstants.CertificateType.SHENFENZHENG.getKey()+""); | 
|---|
|  |  |  | info.setCertificateNo(DESUtil.decrypt(Constants.EDS_PWD, c.getIdcardNo())); | 
|---|