| | |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.web.reqeust.SavePlatformWarnEventDTO; |
| | | import com.doumee.service.business.impl.PlatformWarnEventServiceImpl; |
| | | import com.doumee.service.business.third.TmsService; |
| | | import com.doumee.service.business.third.model.request.TmsOrderInfoRequest; |
| | | import com.doumee.service.business.third.model.response.TmsOrderInfoResponse; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.commons.net.ftp.FTP; |
| | | import org.checkerframework.checker.units.qual.C; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | @Autowired |
| | | private RetentionMapper retentionMapper; |
| | | @Autowired |
| | | private InoutRecordMapper inoutRecordMapper; |
| | | @Autowired |
| | | private PlatformMapper platformMapper; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | |
| | | private PlatformBroadcastLogMapper platformBroadcastLogMapper; |
| | | @Autowired |
| | | private PlatformJobMapper platformJobMapper; |
| | | @Autowired |
| | | private TmsService tmsService; |
| | | @Autowired |
| | | private PlatformWmsDetailMapper platformWmsDetailMapper; |
| | | @Autowired |
| | |
| | | List<DeviceEvent> list = new ArrayList<>(); |
| | | List<Integer> delRetentionLis = new ArrayList<>(); |
| | | List<Retention> retentionList = new ArrayList<>(); |
| | | List<InoutRecord> inoutRecordList = new ArrayList<>(); |
| | | InoutDayCount inoutDayCount = new InoutDayCount(); |
| | | for(EventAcsInfoRequest request : events){ |
| | | EventDeviceDataRequest model = request.getData(); |
| | |
| | | continue; |
| | | } |
| | | //根据推送人员编码,处理在场、离场人员数据记录 |
| | | dealMemberDataByRequest(request,delRetentionLis,retentionList,inoutDayCount); |
| | | dealMemberDataByRequest(request,delRetentionLis,retentionList,inoutDayCount,inoutRecordList); |
| | | //封装门禁事件信息表对象 |
| | | list.add(getDeviceEventModelByRequest(request)); |
| | | } |
| | |
| | | if(retentionList.size()>0){ |
| | | //再插入最新的在厂人员 |
| | | retentionMapper.insert(retentionList); |
| | | } |
| | | if(inoutRecordList.size()>0){ |
| | | //再插入最新的在厂人员 |
| | | inoutRecordMapper.insert(inoutRecordList); |
| | | } |
| | | dealInoutDayCountBiz(inoutDayCount); |
| | | log.info("【海康门禁事件推送】========成功======="); |
| | |
| | | * @param delRetentionLis |
| | | * @param retentionList |
| | | */ |
| | | private void dealMemberDataByRequest(EventAcsInfoRequest request, List<Integer> delRetentionLis, List<Retention> retentionList,InoutDayCount inoutDayCount) { |
| | | private void dealMemberDataByRequest(EventAcsInfoRequest request |
| | | , List<Integer> delRetentionLis |
| | | , List<Retention> retentionList |
| | | ,InoutDayCount inoutDayCount |
| | | ,List<InoutRecord> inoutRecordList) { |
| | | //海康人员编码 |
| | | String userNo = request.getData().getExtEventPersonNo(); |
| | | if(StringUtils.isNotBlank(userNo)){ |
| | | Member member = memberMapper.selectJoinOne(Member.class,new MPJLambdaWrapper<Member>() |
| | | .selectAll(Member.class) |
| | | .selectAs(Company::getCompanyNamePath,Member::getCompanyNamePath) |
| | | .selectAs(Company::getType,Member::getCompanyType) |
| | | .leftJoin(Company.class,Company::getId,Member::getCompanyId) |
| | | .eq(Member::getHkId,userNo) |
| | |
| | | .eq(Device::getDoorId,request.getSrcIndex()) |
| | | .eq(Device::getIsdeleted,Constants.ZERO) |
| | | .last("limit 1" )); |
| | | InoutRecord record = new InoutRecord(); |
| | | record.setCreateDate(DateUtil.getISO8601DateByStr2(request.getHappenTime())); |
| | | record.setType(Constants.ONE);//人员 |
| | | record.setMemberType(Constants.ZERO);//默认为未知人员(访客) |
| | | record.setIsdeleted(Constants.ZERO); |
| | | record.setInOrOut(Constants.ZERO); |
| | | record.setHkEventId(request.getEventId()); |
| | | record.setHkId(userNo); |
| | | if(d!=null && Constants.equalsInteger(d.getIsEntrance(),Constants.ONE)){ |
| | | if(Constants.formatIntegerNum(request.getData().getExtEventInOut()) != Constants.ONE){ |
| | | //如果是进门,录入人员的在场数据记录 |
| | | inoutDayCount.setInMemberNum(Constants.formatIntegerNum(inoutDayCount.getInMemberNum())+1);//入场人次 |
| | | }else{ |
| | | //如果是出门 |
| | | record.setInOrOut(Constants.ONE); |
| | | inoutDayCount.setOutMemberNum(Constants.formatIntegerNum(inoutDayCount.getOutMemberNum())+1);//离场人次 |
| | | } |
| | | } |
| | | if(member !=null){ |
| | | record.setMemberName(member.getName()); |
| | | record.setObjId(member.getId()); |
| | | record.setObjType(Constants.ONE); |
| | | record.setMemberPhone(member.getPhone()); |
| | | record.setCompanyId(member.getCompanyId()); |
| | | record.setCompanyName(member.getCompanyNamePath()); |
| | | if(d!=null && Constants.equalsInteger(d.getIsEntrance(),Constants.ONE)){ |
| | | delRetentionLis.add(member.getId()); |
| | | if( Constants.formatIntegerNum(request.getData().getExtEventInOut()) == Constants.ONE){ |
| | | //如果是进门,录入人员的在场数据记录 |
| | | retentionList.add(getRetentionModelByRequest(member,request)); |
| | | if(Constants.equalsInteger(member.getCompanyType(),Constants.ONE)){ |
| | | record.setMemberType(Constants.ONE); |
| | | inoutDayCount.setInSelfMemberNum(Constants.formatIntegerNum(inoutDayCount.getInSelfMemberNum())+1);//内部人员入场人次 |
| | | }else{ |
| | | record.setMemberType(Constants.TWO); |
| | | inoutDayCount.setInOtherMemberNum(Constants.formatIntegerNum(inoutDayCount.getInOtherMemberNum())+1);//相关方入场人次 |
| | | } |
| | | }else{ |
| | |
| | | } |
| | | } |
| | | } |
| | | inoutRecordList.add(record); |
| | | } |
| | | } |
| | | |
| | |
| | | List<VisitEvent> list = new ArrayList<>(); |
| | | List<Integer> delRetentionLis = new ArrayList<>(); |
| | | List<Retention> retentionList = new ArrayList<>(); |
| | | List<InoutRecord> inoutRecordList = new ArrayList<>(); |
| | | InoutDayCount inoutDayCount = new InoutDayCount(); |
| | | for(EventVisitIccmInfoRequest request : events){ |
| | | if(request.getData() ==null || request.getData().getVisitorInvoices() ==null){ |
| | |
| | | continue; |
| | | } |
| | | //海康访客记录编码 |
| | | dealVisitDataByRequstIccm(request,delRetentionLis,retentionList,inoutDayCount); |
| | | dealVisitDataByRequstIccm(request,delRetentionLis,retentionList,inoutDayCount,inoutRecordList); |
| | | list.add(getVisitEventModelByRequestIccm(request,request.getData().getVisitorInformationList().get(0))); |
| | | } |
| | | if(list.size()>0){ |
| | |
| | | //再插入最新的在厂人员 |
| | | retentionMapper.insert(retentionList); |
| | | } |
| | | if(inoutRecordList.size()>0){ |
| | | //批量插入人员出入记录 |
| | | inoutRecordMapper.insert(inoutRecordList); |
| | | } |
| | | dealInoutDayCountBiz(inoutDayCount); |
| | | log.info("【海康访客事件推送】========成功======="); |
| | | }catch (Exception e){ |
| | |
| | | /** |
| | | * 根据访客推送访客记录编码,处理访客记录、在场人员等信息 |
| | | */ |
| | | private void dealVisitDataByRequstIccm(EventVisitIccmInfoRequest request, List<Integer> delRetentionLis, List<Retention> retentionList, InoutDayCount inoutDayCount) { |
| | | private void dealVisitDataByRequstIccm(EventVisitIccmInfoRequest request |
| | | , List<Integer> delRetentionLis |
| | | , List<Retention> retentionList |
| | | , InoutDayCount inoutDayCount |
| | | ,List<InoutRecord> inoutRecordList) { |
| | | EventVisitIccmDataRequest model = request.getData(); |
| | | EventVisitIccmInvoiceParamRequest data = request.getData().getVisitorInvoices(); |
| | | MPJLambdaWrapper<Visits> queryWrapper = new MPJLambdaWrapper<>(); |
| | |
| | | }else{ |
| | | //如果人员信息存在,切是访客通行,则删除之前的所有进场数据(无论此次推送是进厂还是出场推送事件) |
| | | delRetentionLis.add(visits.getMemberId()); |
| | | InoutRecord record = new InoutRecord(); |
| | | record.setCreateDate(DateUtil.getISO8601DateByStr2(request.getHappenTime())); |
| | | record.setType(Constants.ONE);//人员 |
| | | record.setMemberType(Constants.ZERO); |
| | | record.setIsdeleted(Constants.ZERO); |
| | | record.setMemberName(visits.getName()); |
| | | record.setObjId(visits.getId()); |
| | | record.setObjType(Constants.TWO); |
| | | record.setMemberPhone(visits.getPhone()); |
| | | record.setCompanyName(visits.getCompanyName()); |
| | | record.setInOrOut(Constants.ZERO); |
| | | record.setHkEventId(request.getEventId()); |
| | | record.setHkId(visits.getHkId()); |
| | | //如果是访客通行 |
| | | if(request.getData()!=null&&request.getData().getParamValues()!=null && |
| | | StringUtils.equals(request.getData().getParamValues().getInOrOut(),"0")){ |
| | |
| | | if(request.getData()!=null&&request.getData().getParamValues()!=null && |
| | | !StringUtils.equals(request.getData().getParamValues().getInOrOut(),"0")){ |
| | | inoutDayCount.setOutVisitorNum(Constants.formatIntegerNum(inoutDayCount.getOutVisitorNum())+1); |
| | | record.setInOrOut(Constants.ONE); |
| | | } |
| | | inoutRecordList.add(record); |
| | | } |
| | | updateVistis.setEditDate(new Date()); |
| | | //更新访客来访或者签离时间信息 |
| | |
| | | Constants.PlatformJobStatus.TRANSFERING.getKey(), |
| | | Constants.PlatformJobStatus.EXCEPTION.getKey() |
| | | ) |
| | | )==Constants.ZERO){ |
| | | )==Constants.ZERO){//如果没进行中任务 |
| | | PlatformJob platformJob = platformJobMapper.selectOne(new QueryWrapper<PlatformJob>().lambda() |
| | | .eq(PlatformJob::getCarCodeFront,event.getPlateNos()) |
| | | .eq(PlatformJob::getIsdeleted,Constants.ZERO) |
| | |
| | | .last(" limit 1") |
| | | ); |
| | | if(Objects.nonNull(platformJob)){ |
| | | platformJob.setStatus(Constants.PlatformJobStatus.WAIT_CALL.getKey()); |
| | | platformJob.setArriveDate(new Date()); |
| | | platformJob.setSingType(Constants.TWO); |
| | | platformJob.setSignDate(new Date()); |
| | | List<PlatformJob> signList = platformJobMapper.selectList(new QueryWrapper<PlatformJob>().lambda().apply(" DATE(SIGN_DATE) = DATE(NOW()) and sign_date is not null ")); |
| | | if(CollectionUtils.isEmpty(signList)){ |
| | | platformJob.setSignNum(Constants.ONE); |
| | | } else{ |
| | | int maxNumber = Collections.max(signList.stream().map(i->i.getSignNum()).collect(Collectors.toList())); |
| | | platformJob.setSignNum(maxNumber + Constants.ONE); |
| | | if(Constants.equalsInteger(platformJob.getType(),Constants.ONE)){ |
| | | //如果是自有车装货自动签到 |
| | | jobAutoSignBiz(platformJob); |
| | | }else if(Constants.equalsInteger(platformJob.getType(),Constants.ZERO)){ |
| | | //如果是自有车卸货 查询TMS合同状态,决定是否自动签到 |
| | | checkTmsContractStatusBiz(platformJob); |
| | | } |
| | | platformJobMapper.updateById(platformJob); |
| | | |
| | | } |
| | | } |
| | | }; |
| | |
| | | return event; |
| | | } |
| | | |
| | | /** |
| | | * ;如果是卸货任务,需要通过TMS提供的“2.2合同列表接口”接口查询车辆对应的合同状态是否为在途状态(对应orderStatus值为3/4/5/6), |
| | | * 如果是自动签到,否则不自动签到;如果一个车辆对应多个合同号,则取运单下任一合同查询对应在途信息 |
| | | * @param platformJob |
| | | */ |
| | | private void checkTmsContractStatusBiz(PlatformJob platformJob) { |
| | | PlatformWmsDetail detail = platformWmsDetailMapper.selectOne(new QueryWrapper<PlatformWmsDetail>().lambda() |
| | | .eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO) |
| | | .eq(PlatformWmsDetail::getJobId, platformJob.getId()) |
| | | .isNotNull(PlatformWmsDetail::getContractNum) |
| | | .last("limit 1") |
| | | ); |
| | | if(detail!=null && StringUtils.isNotBlank(detail.getContractNum())){ |
| | | TmsOrderInfoRequest param = new TmsOrderInfoRequest(); |
| | | param.setContractNumber(detail.getContractNum()); |
| | | TmsOrderInfoResponse response = tmsService.orderInfo(param); |
| | | if(response!=null &&( StringUtils.equals(response.getOrderStatus(),"3") ) |
| | | ||StringUtils.equals(response.getOrderStatus(),"4") |
| | | ||StringUtils.equals(response.getOrderStatus(),"5") |
| | | ||StringUtils.equals(response.getOrderStatus(),"6")){ |
| | | //如果合同在途,则自动签到 |
| | | jobAutoSignBiz(platformJob); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void jobAutoSignBiz(PlatformJob platformJob) { |
| | | platformJob.setStatus(Constants.PlatformJobStatus.WAIT_CALL.getKey()); |
| | | platformJob.setArriveDate(new Date()); |
| | | platformJob.setSingType(Constants.TWO); |
| | | platformJob.setSignDate(new Date()); |
| | | List<PlatformJob> signList = platformJobMapper.selectList(new QueryWrapper<PlatformJob>().lambda().apply(" DATE(SIGN_DATE) = DATE(NOW()) and sign_date is not null ")); |
| | | if(CollectionUtils.isEmpty(signList)){ |
| | | platformJob.setSignNum(Constants.ONE); |
| | | } else{ |
| | | int maxNumber = Collections.max(signList.stream().map(i->i.getSignNum()).collect(Collectors.toList())); |
| | | platformJob.setSignNum(maxNumber + Constants.ONE); |
| | | } |
| | | platformJobMapper.updateById(platformJob); |
| | | } |
| | | |
| | | private Retention getRetentionModelByParkRequest(EventParkInfoRequest request,CarEvent event) { |
| | | Retention retention = new Retention(); |
| | | retention.setIsdeleted(Constants.ZERO); |