liukangdong
2024-09-29 8ed7183c1d062263a9564169f3190070b514b0a1
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPushServiceImpl.java
@@ -3,10 +3,12 @@
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;
@@ -75,7 +77,11 @@
    @Autowired
    private PlatformMapper platformMapper;
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @Autowired
    private PlatformDeviceMapper platformDeviceMapper;
    @Autowired
    private PlatformBroadcastLogMapper platformBroadcastLogMapper;
    @Autowired
    private PlatformJobMapper platformJobMapper;
    @Autowired
@@ -864,12 +870,12 @@
            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){
                EventPlatformCarsDataRequest data = request.getData();
                if( data.getHPVehicleStatus() ==null  ){
                        continue;//如何推送状态集合为空,不处理跳过
                    }
                    PlatformDevice model = platformDeviceMapper.selectOne(new QueryWrapper<PlatformDevice>().lambda()
@@ -881,12 +887,15 @@
                    }
                    //各车道车辆状态
                    for(EventPlatformCarsStatusInfoRequest status : data.getHPVehicleStatus()){
                EventPlatformCarsStatusInfoRequest status = data.getHPVehicleStatus();
                        eventList.add(initPlatformEventModel(request,data,status));//封装事件(已月台通道为维度)
                        if(StringUtils.isBlank(status.getPlateNo())){
                            continue;//如果车辆信息为空,不处理直接跳过
                        }
                        PlatformJob job = platformJobMapper.selectOne(new QueryWrapper<PlatformJob>().lambda()
                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 )
@@ -926,9 +935,6 @@
                        }
                        //暂时不做相关自动完成作业业务处理
//                        dealPlatformJobLogBiz(update,status);//记录作业日志
                    }
                    break;//只处理第一个数据状态
                }
            }
            if(eventList.size()>0){
                //生成事件
@@ -1039,35 +1045,107 @@
        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<>();
        List<PlatformBroadcastLog> logList = new ArrayList<>();
        for(PlatformDevice device : deviceList){
            if(StringUtils.isNotBlank(device.getHkId())){
                continue;
            }
            if(Constants.equalsInteger(device.getType(),Constants.ZERO)){
                //如果是LED
                PlatformBroadcastLog log = new PlatformBroadcastLog();
                log.setCreateDate(new Date());
                log.setBizType(Constants.ONE);
                log.setHkDate(new Date());
                log.setObjType(Constants.ONE);
                log.setIds(device.getHkNo());
                log.setInfo(content);
                log.setNum(Constants.ONE);
                BaseResponse response = dealLedContentBiz(device.getHkNo(),content,speed,1);
                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屏显内容");
                logList.add(log);
                ledList.add(device.getHkId());
            }else  if(Constants.equalsInteger(device.getType(),Constants.ZERO)){
                //如果是广播点
                broadcastList.add(device.getHkId());
            }
        }
        if(broadcastList.size()>0){
            String content1 =Constants.PlatformBroadcastContent.WRONG_IN.getInfo();
            content1 = content1.replace("${param}",model.getCarCodeFront());
            PlatformBroadcastLog log = new PlatformBroadcastLog();
            log.setCreateDate(new Date());
            log.setBizType(Constants.ONE);
            log.setHkDate(new Date());
            log.setObjType(Constants.ONE);
            log.setInfo(content1);
            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("发送广播播报内容");
            logList.add(log);
        }
        if(logList.size()>0){
            platformBroadcastLogMapper.insert(logList);
        }
    }
    public static BaseResponse dealLedContentBiz(String hkNo, String content,int speed,int color) {
                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());
        head.setDeviceIndexCode(hkNo);
                body.setMethod("ControlLedGereral");//固定值
                request.setIndexCode(device.getHkId());
        request.setIndexCode(hkNo);
                request.setOperationType(219);//固定值
                regions.setActionType(32);
                regions.setContent(content);
                regions.setRegionNo(1);
                regions.setRegionType(14);
                regions.setFontColor(1);
        regions.setFontColor(color>0?color:1);
                regions.setCircleTimes(1);//循环次数
                regions.setFontSize(32);//
                regions.setStayTime(1);//单位??
@@ -1077,24 +1155,8 @@
                regions.setRegionRightBottomYPos(31);
                request.setRegions(new ArrayList<>());
                request.getRegions().add(regions);
                regions.setSpeed(13);
        regions.setSpeed(speed>0?speed:13);
                body.setParams(request);
                HKService.transparentchannel(head,body);
            }else  if(Constants.equalsInteger(device.getType(),Constants.ZERO)){
                //如果是广播点
                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);
        }
       return HKService.transparentchannel(head,body);
    }
}