| | |
| | | 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; |
| | | import com.doumee.config.DataSyncConfig; |
| | | import com.doumee.config.SpringContextUtil; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | 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.acs.EventAcsInfoRequest; |
| | | import com.doumee.core.haikang.model.param.request.event.acs.EventAcsRequest; |
| | |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.join.VisitsJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.dao.web.reqeust.SavePlatformWarnEventDTO; |
| | | import com.doumee.service.business.DeviceEventService; |
| | | import com.doumee.service.business.InterfaceLogService; |
| | | import com.doumee.service.business.MemberService; |
| | | import com.doumee.service.business.impl.PlatformWarnEventServiceImpl; |
| | | import com.github.yulichang.interfaces.MPJBaseJoin; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.hikvision.artemis.sdk.config.ArtemisConfig; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.yaml.snakeyaml.scanner.Constant; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | |
| | | @Autowired |
| | | private PlatformMapper platformMapper; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private PlatformDeviceMapper platformDeviceMapper; |
| | | @Autowired |
| | | private PlatformBroadcastLogMapper platformBroadcastLogMapper; |
| | | @Autowired |
| | | private PlatformJobMapper platformJobMapper; |
| | | @Autowired |
| | |
| | | //再插入最新的在厂人员 |
| | | retentionMapper.insert(retentionList); |
| | | } |
| | | log.error("【海康门禁事件推送】========成功======="); |
| | | log.info("【海康门禁事件推送】========成功======="); |
| | | }catch (Exception e) { |
| | | log.error("【海康门禁事件推送】========失败=======:\n" + e.getMessage()); |
| | | }finally { |
| | |
| | | //再插入最新的在厂人员 |
| | | retentionMapper.insert(retentionList); |
| | | } |
| | | log.error("【海康访客事件推送】========成功======="); |
| | | log.info("【海康访客事件推送】========成功======="); |
| | | }catch (Exception e){ |
| | | |
| | | log.error("【海康访客事件推送】========失败=======:\n"+e.getMessage()); |
| | |
| | | //再插入最新的在厂人员 |
| | | retentionMapper.insert(retentionList); |
| | | } |
| | | log.error("【海康访客事件推送】========成功======="); |
| | | log.info("【海康访客事件推送】========成功======="); |
| | | }catch (Exception e){ |
| | | log.error("【海康访客事件推送】========失败=======:\n"+e.getMessage()); |
| | | } |
| | |
| | | //再插入最新的在厂人员 |
| | | retentionMapper.insert(retentionList); |
| | | } |
| | | log.error("【海康停车场事件推送】========成功======="); |
| | | log.info("【海康停车场事件推送】========成功======="); |
| | | }catch (Exception e){ |
| | | |
| | | log.error("【海康停车场事件推送】========失败=======:\n"+e.getMessage()); |
| | |
| | | event.setReleaseResult(request.getData().getInResult().getRlsResult().getReleaseResult()); |
| | | event.setReleaseResultEx(request.getData().getInResult().getRlsResult().getReleaseResultEx()); |
| | | } |
| | | |
| | | if(request.getData().getPicUrl()!=null){ |
| | | //车辆和和车牌照片 |
| | | event.setVehiclePicUrl(getHkImgUrl(request.getData().getPicUrl().getVehiclePicUrl())); |
| | |
| | | delRetentionList.add(event.getPlateNos()); |
| | | } |
| | | } |
| | | |
| | | return event; |
| | | |
| | | } |
| | | |
| | | private Retention getRetentionModelByParkRequest(EventParkInfoRequest request) { |
| | |
| | | retention.setType(Constants.THREE); |
| | | // retention.setDeviceName(request.getSrcName()); |
| | | // retention.setDeviceIndex(request.getSrcIndex()); |
| | | |
| | | return retention; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | result = "成功"; |
| | | log.error("【海康月台工作状态事件推送】========成功======="); |
| | | log.info("【海康月台工作状态事件推送】========成功======="); |
| | | }catch (Exception e) { |
| | | result = "失败"+e.getMessage(); |
| | | log.error("【海康月台工作状态事件推送】========失败=======:\n" + e.getMessage()); |
| | |
| | | List<EventPlatformCarsInfoRequest> events = param.getParams().getEvents(); |
| | | List<PlatformEvent> eventList = new ArrayList<>(); |
| | | for(EventPlatformCarsInfoRequest request : events){ |
| | | if( request.getData() ==null || request.getData().size()==0){ |
| | | if( request.getData() ==null ){ |
| | | continue; |
| | | } |
| | | Integer workStatus = 0; |
| | | for(EventPlatformCarsDataRequest data : request.getData()){ |
| | | if( data.getHPVehicleStatus() ==null || data.getHPVehicleStatus().size() ==0){ |
| | | continue;//如何推送状态集合为空,不处理跳过 |
| | | EventPlatformCarsDataRequest data = request.getData(); |
| | | if( data.getHPVehicleStatus() ==null ){ |
| | | continue;//如何推送状态集合为空,不处理跳过 |
| | | } |
| | | //各车道车辆状态 |
| | | EventPlatformCarsStatusInfoRequest status = data.getHPVehicleStatus(); |
| | | PlatformEvent event = initPlatformEventModel(request,data,status); |
| | | if(StringUtils.isBlank(status.getPlateNo())){ |
| | | eventList.add(event);//封装事件(已月台通道为维度) |
| | | continue;//如果车辆信息为空,不处理直接跳过 |
| | | } |
| | | PlatformDevice model = platformDeviceMapper.selectOne(new QueryWrapper<PlatformDevice>().lambda() |
| | | .eq(PlatformDevice::getDeviceId,request.getSrcIndex()) |
| | | .eq(PlatformDevice::getIsdeleted,Constants.ZERO) |
| | | .last("limit 1")); |
| | | if(model ==null){ |
| | | eventList.add(event);//封装事件(已月台通道为维度) |
| | | continue;//监控点未同步,跳过处理 |
| | | } |
| | | event.setPlatformId(model.getPlatformId());//月台编码 |
| | | eventList.add(event);//封装事件(已月台通道为维度) |
| | | //截掉第一个颜色汉字,去掉“挂”字 |
| | | status.setPlateNo(status.getPlateNo().substring(1,status.getPlateNo().length()).replace("挂","")); |
| | | PlatformJob job = platformJobMapper.selectJoinOne(PlatformJob.class, new MPJLambdaWrapper<PlatformJob>() |
| | | .selectAll(PlatformJob.class) |
| | | .selectAs(Platform::getName,PlatformJob::getPlatformName) |
| | | .leftJoin(Platform.class,Platform::getId,PlatformJob::getPlatformId) |
| | | .eq(StringUtils.equals(status.getStockStatus(),"front"),PlatformJob::getCarCodeFront,status.getPlateNo() )//前车牌号 |
| | | .eq(!StringUtils.equals(status.getStockStatus(),"front"),PlatformJob::getCarCodeBack,status.getPlateNo() )//后车牌号 |
| | | .eq(PlatformJob::getIsdeleted,Constants.ZERO ) |
| | | .last("limit 1 ")); |
| | | if(job == null){ |
| | | continue;//如果作业为空,跳过处理 |
| | | } |
| | | PlatformJob update = new PlatformJob(); |
| | | update.setId(job.getId()); |
| | | update.setEditDate(new Date()); |
| | | if(StringUtils.equals(status.getMotionStatus(),"leave")){ |
| | | //如果是车辆离开,不做相关自动完成作业业务处理 |
| | | /* if(job ==null && !Constants.equalsInteger(job.getStatus(),Constants.PlatformJobStatus.WORKING.getKey())){ |
| | | continue;//如果没查到对应的作业或者作业并非作业中,不做业务处理 |
| | | } |
| | | PlatformDevice model = platformDeviceMapper.selectOne(new QueryWrapper<PlatformDevice>().lambda() |
| | | .eq(PlatformDevice::getDeviceId,request.getSrcIndex()) |
| | | .eq(PlatformDevice::getIsdeleted,Constants.ZERO) |
| | | .last("limit 1")); |
| | | if(model ==null){ |
| | | continue;//监控点未同步,跳过处理 |
| | | |
| | | if(Constants.equalsInteger(job.getType(), Constants.THREE) || Constants.equalsInteger(job.getType(), Constants.TWO)){ |
| | | //如果是wms推送的外协车辆外协车辆 |
| | | if(platformWmsDetailMapper.selectCount(new QueryWrapper<PlatformWmsDetail>().lambda() |
| | | .eq(PlatformWmsDetail::getIsdeleted,Constants.ZERO) |
| | | .eq(PlatformWmsDetail::getJobId,job.getId()) |
| | | .ne(PlatformWmsDetail::getLockStatus,Constants.ONE)) >0){ |
| | | continue;//如果外协任务作业,合同号有未上锁的情况,不做自动完成作业逻辑处理,跳过不处理 |
| | | } |
| | | } |
| | | //各车道车辆状态 |
| | | for(EventPlatformCarsStatusInfoRequest status : data.getHPVehicleStatus()){ |
| | | eventList.add(initPlatformEventModel(request,data,status));//封装事件(已月台通道为维度) |
| | | if(StringUtils.isBlank(status.getPlateNo())){ |
| | | continue;//如果车辆信息为空,不处理直接跳过 |
| | | } |
| | | PlatformJob job = platformJobMapper.selectOne(new QueryWrapper<PlatformJob>().lambda() |
| | | .eq(StringUtils.equals(status.getStockStatus(),"front"),PlatformJob::getCarCodeFront,status.getPlateNo() )//前车牌号 |
| | | .eq(!StringUtils.equals(status.getStockStatus(),"front"),PlatformJob::getCarCodeBack,status.getPlateNo() )//后车牌号 |
| | | .eq(PlatformJob::getIsdeleted,Constants.ZERO ) |
| | | .last("limit 1 ")); |
| | | PlatformJob update = new PlatformJob(); |
| | | update.setId(job.getId()); |
| | | update.setEditDate(new Date()); |
| | | if(StringUtils.equals(status.getMotionStatus(),"leave")){ |
| | | //如果是车辆离开,不做相关自动完成作业业务处理 |
| | | /* if(job ==null && !Constants.equalsInteger(job.getStatus(),Constants.PlatformJobStatus.WORKING.getKey())){ |
| | | continue;//如果没查到对应的作业或者作业并非作业中,不做业务处理 |
| | | } |
| | | if(Constants.equalsInteger(job.getType(), Constants.THREE) || Constants.equalsInteger(job.getType(), Constants.TWO)){ |
| | | //如果是wms推送的外协车辆外协车辆 |
| | | if(platformWmsDetailMapper.selectCount(new QueryWrapper<PlatformWmsDetail>().lambda() |
| | | .eq(PlatformWmsDetail::getIsdeleted,Constants.ZERO) |
| | | .eq(PlatformWmsDetail::getJobId,job.getId()) |
| | | .ne(PlatformWmsDetail::getLockStatus,Constants.ONE)) >0){ |
| | | continue;//如果外协任务作业,合同号有未上锁的情况,不做自动完成作业逻辑处理,跳过不处理 |
| | | } |
| | | } |
| | | //如果是正在作业的状态,标记作业已完成 |
| | | update.setStatus(Constants.PlatformJobStatus.DONE.getKey());//作业已完成 |
| | | update.setDoneDate(update.getEditDate());*/ |
| | | }else if(StringUtils.equals(status.getMotionStatus(),"enter")){ |
| | | //如果是车辆进入 |
| | | if(job ==null || !Constants.equalsInteger(job.getStatus(),Constants.PlatformJobStatus.CALLED.getKey())){ |
| | | //说明车辆进错月台 或者还未叫号状态,发起警告 |
| | | dealCarsInErrorPlatformBiz(job,status); |
| | | } |
| | | if(job.getStartDate() == null){ |
| | | update.setStartDate(update.getEditDate()); |
| | | } |
| | | update.setStatus(Constants.PlatformJobStatus.WORKING.getKey());//开始作业 |
| | | }else{ |
| | | continue;//其他状态不处理,跳过 |
| | | } |
| | | //如果是正在作业的状态,标记作业已完成 |
| | | update.setStatus(Constants.PlatformJobStatus.DONE.getKey());//作业已完成 |
| | | update.setDoneDate(update.getEditDate());*/ |
| | | }else if(StringUtils.equals(status.getMotionStatus(),"enter")){ |
| | | //如果是车辆进入 |
| | | if(job ==null || !Constants.equalsInteger(job.getStatus(),Constants.PlatformJobStatus.CALLED.getKey())){ |
| | | //说明车辆进错月台 或者还未叫号状态,发起警告 |
| | | dealCarsInErrorPlatformBiz(job,status); |
| | | } |
| | | if(job.getStartDate() == null){ |
| | | update.setStartDate(update.getEditDate()); |
| | | } |
| | | update.setStatus(Constants.PlatformJobStatus.WORKING.getKey());//开始作业 |
| | | }else{ |
| | | continue;//其他状态不处理,跳过 |
| | | } |
| | | //暂时不做相关自动完成作业业务处理 |
| | | // dealPlatformJobLogBiz(update,status);//记录作业日志 |
| | | } |
| | | break;//只处理第一个数据状态 |
| | | } |
| | | } |
| | | if(eventList.size()>0){ |
| | | //生成事件 |
| | | platformEventMapper.insert(eventList); |
| | | } |
| | | result = "成功"; |
| | | log.error("【海康月台车辆状态事件推送】========成功======="); |
| | | log.info("【海康月台车辆状态事件推送】========成功======="); |
| | | }catch (Exception e) { |
| | | result = "失败"+e.getMessage(); |
| | | log.error("【海康月台车辆状态事件推送】========失败=======:\n" + e.getMessage()); |
| | |
| | | savePlatformWarnEventDTO.setEventType(Constants.PlatformWarnEvent.STOP_ERROR.getKey()); |
| | | platformWarnEventService.savePlatformWarnEvent(savePlatformWarnEventDTO); |
| | | |
| | | int speed = 13; |
| | | try { |
| | | speed = Integer.parseInt(systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.LED_CONTENT_SPEED).getCode()); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | List<PlatformDevice> deviceList = platformDeviceMapper.selectList(new QueryWrapper<PlatformDevice>().lambda() |
| | | .eq(PlatformDevice::getPlatformId,model.getPlatformId()) |
| | | .eq(PlatformDevice::getIsdeleted,Constants.ZERO)); |
| | | if(deviceList ==null || deviceList.size() == 0){ |
| | | return; |
| | | } |
| | | String content ="车辆"+model.getCarCodeFront()+"停错月台了"; |
| | | String content =Constants.PlatformLedContent.WRONG_IN.getInfo(); |
| | | content = content.replace("${param}",model.getPlatformName()); |
| | | content = content.replace("${param2}",model.getCarCodeFront()); |
| | | List<String> broadcastList = new ArrayList<>(); |
| | | List<String> ledList = new ArrayList<>(); |
| | | String bNames = ""; |
| | | List<PlatformBroadcastLog> logList = new ArrayList<>(); |
| | | for(PlatformDevice device : deviceList){ |
| | | if(StringUtils.isNotBlank(device.getHkId())){ |
| | | continue; |
| | | } |
| | | if(Constants.equalsInteger(device.getType(),Constants.ZERO)){ |
| | | //如果是LED |
| | | TransparentChannelBodyRequest body = new TransparentChannelBodyRequest(); |
| | | TransparentChannelHeadRequest head = new TransparentChannelHeadRequest(); |
| | | TransparentChannelBodyParamRequest request = new TransparentChannelBodyParamRequest(); |
| | | TransparentChannelBodyRegionRequest regions = new TransparentChannelBodyRegionRequest(); |
| | | head.setAbility("cld");//固定值 |
| | | head.setTreatyType("haixuan_led_net");//固定值 |
| | | head.setDeviceIndexCode(device.getHkId()); |
| | | body.setMethod("ControlLedGereral");//固定值 |
| | | request.setIndexCode(device.getHkId()); |
| | | request.setOperationType(219);//固定值 |
| | | regions.setActionType(32); |
| | | regions.setContent(content); |
| | | regions.setRegionNo(1); |
| | | regions.setRegionType(14); |
| | | regions.setFontColor(1); |
| | | regions.setCircleTimes(1);//循环次数 |
| | | regions.setFontSize(32);// |
| | | regions.setStayTime(1);//单位?? |
| | | regions.setRegionLeftTopXPos(0); |
| | | regions.setRegionLeftTopYPos(0); |
| | | regions.setRegionRightBottomXPos(255); |
| | | regions.setRegionRightBottomYPos(31); |
| | | request.setRegions(new ArrayList<>()); |
| | | request.getRegions().add(regions); |
| | | regions.setSpeed(13); |
| | | body.setParams(request); |
| | | HKService.transparentchannel(head,body); |
| | | PlatformBroadcastLog log = dealLedContentBiz(device.getHkNo(),device.getName(),content,speed,1); |
| | | logList.add(log); |
| | | ledList.add(device.getHkId()); |
| | | }else if(Constants.equalsInteger(device.getType(),Constants.ZERO)){ |
| | | //如果是广播点 |
| | | bNames += device.getName()+";"; |
| | | broadcastList.add(device.getHkId()); |
| | | } |
| | | } |
| | | if(broadcastList.size()>0){ |
| | | CustomBroadcastRequest request = new CustomBroadcastRequest(); |
| | | request.setAudioPointIndexCode(broadcastList); |
| | | request.setPlayDuration(15);//单位秒 |
| | | request.setBroadCastMode("tts"); |
| | | request.setPriority(1); |
| | | request.setState(1);//播放/停止标识 1-播放,0-停止 |
| | | request.setPlayTtsContent(content); |
| | | HKService.customBroadcast(request); |
| | | PlatformBroadcastLog log = dealBroadcastBiz(model,broadcastList,bNames,Constants.PlatformBroadcastContent.WRONG_IN.getInfo()); |
| | | logList.add(log); |
| | | } |
| | | if(logList.size()>0){ |
| | | platformBroadcastLogMapper.insert(logList); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 广播通知 |
| | | * @param model |
| | | * @param broadcastList |
| | | * @param bNames |
| | | * @param content1 |
| | | * @return |
| | | */ |
| | | public static PlatformBroadcastLog dealBroadcastBiz(PlatformJob model, List<String> broadcastList,String bNames , String content1) { |
| | | PlatformBroadcastLog log = new PlatformBroadcastLog(); |
| | | content1 = content1.replace("${param}",model.getCarCodeFront()); |
| | | |
| | | log.setCreateDate(new Date()); |
| | | log.setBizType(Constants.ONE); |
| | | log.setHkDate(new Date()); |
| | | log.setObjType(Constants.ONE); |
| | | log.setInfo(content1); |
| | | log.setRemark(bNames); |
| | | log.setNum(Constants.ONE); |
| | | log.setIds(String.join(",",broadcastList)); |
| | | CustomBroadcastRequest request = new CustomBroadcastRequest(); |
| | | request.setAudioPointIndexCode(broadcastList); |
| | | request.setPlayDuration(15);//单位秒 |
| | | request.setBroadCastMode("tts"); |
| | | request.setPriority(1); |
| | | request.setState(1);//播放/停止标识 1-播放,0-停止 |
| | | request.setPlayTtsContent(content1); |
| | | BaseResponse response = HKService.customBroadcast(request); |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){ |
| | | log.setHkInfo("请求失败:"+JSONObject.toJSONString(response)); |
| | | log.setHkStatus(Constants.THREE); |
| | | }else{ |
| | | log.setHkInfo("请求成功"); |
| | | log.setHkStatus(Constants.TWO); |
| | | } |
| | | log.setDeviceType(Constants.ONE); |
| | | log.setName("发送广播播报内容"); |
| | | return log; |
| | | } |
| | | |
| | | public static PlatformBroadcastLog dealLedContentBiz(String hkNo,String hkName, String content,int speed,int color) { |
| | | PlatformBroadcastLog log = new PlatformBroadcastLog(); |
| | | log.setCreateDate(new Date()); |
| | | log.setBizType(Constants.ONE); |
| | | log.setHkDate(new Date()); |
| | | log.setObjType(Constants.ONE); |
| | | log.setIds(hkNo); |
| | | log.setRemark(hkName); |
| | | log.setInfo(content); |
| | | log.setNum(Constants.ONE); |
| | | |
| | | TransparentChannelBodyRequest body = new TransparentChannelBodyRequest(); |
| | | TransparentChannelHeadRequest head = new TransparentChannelHeadRequest(); |
| | | TransparentChannelBodyParamRequest request = new TransparentChannelBodyParamRequest(); |
| | | TransparentChannelBodyRegionRequest regions = new TransparentChannelBodyRegionRequest(); |
| | | head.setAbility("cld");//固定值 |
| | | head.setTreatyType("haixuan_led_net");//固定值 |
| | | head.setDeviceIndexCode(hkNo); |
| | | body.setMethod("ControlLedGereral");//固定值 |
| | | request.setIndexCode(hkNo); |
| | | request.setOperationType(219);//固定值 |
| | | regions.setActionType(32); |
| | | regions.setContent(content); |
| | | regions.setRegionNo(1); |
| | | regions.setRegionType(14); |
| | | regions.setFontColor(color>0?color:1); |
| | | regions.setCircleTimes(1);//循环次数 |
| | | regions.setFontSize(32);// |
| | | regions.setStayTime(1);//单位?? |
| | | regions.setRegionLeftTopXPos(0); |
| | | regions.setRegionLeftTopYPos(0); |
| | | regions.setRegionRightBottomXPos(255); |
| | | regions.setRegionRightBottomYPos(31); |
| | | request.setRegions(new ArrayList<>()); |
| | | request.getRegions().add(regions); |
| | | regions.setSpeed(speed>0?speed:13); |
| | | body.setParams(request); |
| | | BaseResponse response = HKService.transparentchannel(head,body); |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){ |
| | | log.setHkInfo("请求失败:"+JSONObject.toJSONString(response)); |
| | | log.setHkStatus(Constants.THREE); |
| | | }else{ |
| | | log.setHkInfo("请求成功"); |
| | | log.setHkStatus(Constants.TWO); |
| | | } |
| | | log.setDeviceType(Constants.ONE); |
| | | log.setName("设置LED屏显内容"); |
| | | return log; |
| | | } |
| | | } |