| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.param.BaseListPageResponse; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | | import com.doumee.core.haikang.model.param.request.*; |
| | | import com.doumee.core.haikang.model.param.request.event.visit.EventVisitInfoRequest; |
| | | 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.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())); |
| | |
| | | // 对相应状态下的数据进行【已签离】处理 |
| | | if(!Constants.equalsInteger(c.getStatus(),Constants.VisitStatus.signout)){ |
| | | Visits update = new Visits(); |
| | | //已失效 |
| | | //已签离 |
| | | update.setStatus(Constants.VisitStatus.signout); |
| | | update.setEditDate(date); |
| | | update.setId(c.getId()); |
| | | update.setInDate(DateUtil.getISO8601DateByStr2(data.getVisitStartTime())); |
| | | update.setOutDate(DateUtil.getISO8601DateByStr2(data.getVisitEndTime())); |
| | | update.setOutInfo(model.getVisitorStatus().equals(5)?"过期自动签离":"查询已签离"); |
| | | update.setRemark("已签离"); |
| | | 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())); |
| | | } |
| | | } |
| | |
| | | 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())); |
| | |
| | | return ; |
| | | } |
| | | Constants.DEALING_HK_VISIT =true; |
| | | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() |
| | | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_LOCAL_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)); |
| | |
| | | // getUpdateModelByResponse(c,date,roleList,path); |
| | | getUpdateModelByResponseIccm(c,date,roleList,path); |
| | | visitsMapper.updateById(c); |
| | | if(Objects.isNull(c.getParentId())){ |
| | | wxPlatNotice.sendVisitAuditTemplateNotice(c, |
| | | systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_PREFIX).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_AUDIT_VISIT).getCode()); |
| | | //给申请人发送微信公众号 下发权限失败 |
| | | 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){ |
| | |
| | | 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 = ""; |
| | | //发起海康预约接口 |
| | |
| | | && response.getData().getAppointmentInfoList() !=null |
| | | && response.getData().getAppointmentInfoList().size()>0)){ |
| | | id =response.getData().getAppointmentInfoList().get(0).getOrderId(); |
| | | qrcode =response.getData().getAppointmentInfoList().get(0).getQRCode(); |
| | | qrcode =response.getData().getAppointmentInfoList().get(0).getVerificationCode(); |
| | | // qrcode =response.getData().getAppointmentInfoList().get(0).getQRCode(); |
| | | } |
| | | reson = response!=null?JSONObject.toJSONString(response):""; |
| | | }else{ |
| | |
| | | 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(); |
| | | qrcode =response.getData().getAppointmentInfoList().get(0).getQRCode(); |
| | | recordId = response.getData().getAppointRecordId(); |
| | | // qrcode =response.getData().getAppointmentInfoList().get(0).getQRCode(); |
| | | qrcode =response.getData().getAppointmentInfoList().get(0).getVerificationCode(); |
| | | } |
| | | reson = response!=null?JSONObject.toJSONString(response):""; |
| | | }else{ |
| | |
| | | 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())); |
| | |
| | | return null; |
| | | } |
| | | if(StringUtils.isNotBlank(c.getFaceImg())){ |
| | | log.info("===================================="+path+c.getFaceImg()+"======start===="); |
| | | info.setVisitorPhoto(ImageBase64Util.Image2Base64(path+c.getFaceImg())); |
| | | log.info("===================================="+path+c.getFaceImg()+"========end==="); |
| | | } |
| | | if(info.getVisitorPhoto() == null){ |
| | | log.info("===================================="+path+c.getFaceImg()+"======imgerror====="); |
| | | return null; |
| | | } |
| | | if(StringUtils.isNotBlank(c.getName())){ |
| | |
| | | info.setVisitorName(c.getName()); |
| | | } |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(c.getCompanyName())){ |
| | | char[] charArray = c.getCompanyName().toCharArray(); |
| | | int length = charArray.length; |
| | |
| | | } |
| | | 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.setCertificateType(HKConstants.CertificateType.HUZHAO.getKey()+""); |
| | | info.setCertificateNo(DESUtil.decrypt(Constants.EDS_PWD, c.getIdcardNo())); |
| | | } |
| | | |
| | | return info; |
| | | } |
| | | |