#
lsh
2024-06-22 c2144e00a981be9093c2b1fe257881203d800810
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -4582,65 +4582,55 @@
    }
    /**
     *  JarWrkMastExecute任务创建   //未完成
     *  开门、入硫化罐
     *  JarWrkMastExecute任务创建   //完成
     */
    public synchronized void jarWrkMastExecuteGenerate() {
    public synchronized void jarWrkMastExecuteGenerate(Integer sign) {
        for (JarSlave jarSlave : slaveProperties.getJar()) {
            try{
                if (wrkMastExecuteService.getWrkMastByJarIdCount(jarSlave.getId())!=0){
                    continue;
                }
                List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{
                    add(0);
                    add(2);
                }});
                for (BasJarMast basJarMast : basJarMastList){
                    // 获取硫化罐信息
                    JarThread jarThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getId());
                    JarProtocol jarProtocol = jarThread.getJarProtocol();
                    if (jarProtocol == null) {
                        break;
                    }
                    if (jarProtocol.modeType != JarModeType.AUTO){
                        break;
                    }
                    JarThread jarOtherThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getJarOtherId());
                    JarProtocol jarOtherProtocol = jarOtherThread.getJarProtocol();
                    if (jarOtherProtocol == null) {
                        break;
                    }
                // 获取硫化罐信息
                JarThread jarThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getId());
                JarProtocol jarProtocol = jarThread.getJarProtocol();
                if (jarProtocol == null) {
                    break;
                }
                if (jarProtocol.modeType != JarModeType.AUTO){
                    break;
                }
                JarThread jarOtherThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getJarOtherId());
                JarProtocol jarOtherProtocol = jarOtherThread.getJarProtocol();
                if (jarOtherProtocol == null) {
                    break;
                }
//                    if (jarOtherProtocol.modeType != JarModeType.AUTO){
//                        continue;
//                    }
                    BasJar basJar = basJarMapper.selectById(jarProtocol.getJarNo());
                    if (Cools.isEmpty(basJar)){
                        log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
                        break;
                    }
                    //门作业  无
                    //自动、空闲、右门关闭、   Other左门关闭
                    if (jarProtocol.isAutoing() && !jarProtocol.isRightDoor() && jarProtocol.jarErr==0
                            && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0
                            && !jarOtherProtocol.isLeftDoor() && jarOtherProtocol.leftDoorOpen==0  && jarOtherProtocol.leftDoorClose==0){
                        if (jarProtocol.statusType == JarStatusType.IDLE && !jarProtocol.isLeftDoor() && basJarMast.getStatus()==0){
                            //生成开门任务 OpenTheDoor
                            if (!jarWrkMastExecuteGenerateExecute(basJar,basJarMast,new int[]{basJar.getEnterSteNo(),basJar.getEnterRgvId(),1,1})){
                                log.error("JarWrkMastExecute任务创建===>执行异常===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast));
                            }
                            return;
                        } else if (jarProtocol.statusType == JarStatusType.MOVING && jarProtocol.isLeftDoor()){
                            //生成入硫化罐任务
                            if (!jarWrkMastExecuteGenerateExecute(basJar,basJarMast,new int[]{basJar.getEnterSteNo(),basJar.getEnterRgvId(),5,1})){
                                log.error("JarWrkMastExecute任务创建===>执行异常===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast));
                            }
                            return;
                        }
                    }
                BasJar basJar = basJarMapper.selectById(jarProtocol.getJarNo());
                if (Cools.isEmpty(basJar)){
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
                    break;
                }
                //门作业  无
                //自动、空闲、右门关闭、   Other左门关闭
                if (jarProtocol.isAutoing() && jarProtocol.jarErr==0
                        && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0){
                    switch (sign){
                        case 0:
                        case 2:
                            if (jarWrkMastExecuteGenerate1(jarSlave,sign)){
                                break;
                            }
                        case 3:
//                            if (jarWrkMastExecuteGenerate2(jarSlave,sign)){
//                                break;
//                            }
                    }
                }
            } catch (Exception e){
                log.error("{}号硫化罐JarWrkMastExecute任务创建异常,异常原因={}",jarSlave.getId(),e.getMessage());
@@ -4649,10 +4639,147 @@
    }
    /**
     *  JarWrkMastExecute任务创建   //完成
     *  开门任务
     *  生成入硫化罐任务
     */
    public synchronized boolean jarWrkMastExecuteGenerate1(JarSlave jarSlave,Integer sign) {
        try{
            if (wrkMastExecuteService.getWrkMastByJarIdCount(jarSlave.getId())!=0){
                return false;
            }
            List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{
                add(0);
                add(2);
            }});
            for (BasJarMast basJarMast : basJarMastList){
                // 获取硫化罐信息
                JarThread jarThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getId());
                JarProtocol jarProtocol = jarThread.getJarProtocol();
                if (jarProtocol == null) {
                    return false;
                }
                if (jarProtocol.modeType != JarModeType.AUTO){
                    return false;
                }
                JarThread jarOtherThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getJarOtherId());
                JarProtocol jarOtherProtocol = jarOtherThread.getJarProtocol();
                if (jarOtherProtocol == null) {
                    return false;
                }
//                    if (jarOtherProtocol.modeType != JarModeType.AUTO){
//                        continue;
//                    }
                BasJar basJar = basJarMapper.selectById(jarProtocol.getJarNo());
                if (Cools.isEmpty(basJar)){
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
                    return false;
                }
                //门作业  无
                //自动、空闲、右门关闭、   Other左门关闭
                if (jarProtocol.isAutoing() && !jarProtocol.isRightDoor() && jarProtocol.jarErr==0
                        && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0
                        && !jarOtherProtocol.isLeftDoor() && jarOtherProtocol.leftDoorOpen==0  && jarOtherProtocol.leftDoorClose==0){
                    if (jarProtocol.statusType == JarStatusType.IDLE && !jarProtocol.isLeftDoor() && basJarMast.getStatus()==0){
                        //生成开门任务 OpenTheDoor
                        if (!jarWrkMastExecuteGenerateExecute(basJar,basJarMast,new int[]{basJar.getEnterSteNo(),basJar.getEnterRgvId(),1,1})){
                            log.error("JarWrkMastExecute任务创建===>执行异常===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast));
                        }
                        return true;
                    } else if (jarProtocol.statusType == JarStatusType.MOVING && jarProtocol.isLeftDoor()){
                        //生成入硫化罐任务
                        if (!jarWrkMastExecuteGenerateExecute(basJar,basJarMast,new int[]{basJar.getEnterSteNo(),basJar.getEnterRgvId(),5,1})){
                            log.error("JarWrkMastExecute任务创建===>执行异常===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast));
                        }
                        return true;
                    } else if (jarProtocol.statusType == JarStatusType.IDLE && jarProtocol.isLeftDoor()){
                        log.error("JarWrkMastExecute任务创建===>执行异常===》硫化罐空闲但是门未关===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast));
                    }
                }
                return false;
            }
        } catch (Exception e){
            log.error("{}号硫化罐JarWrkMastExecute任务创建异常,异常原因={}",jarSlave.getId(),e.getMessage());
        }
        return false;
    }
    /**
     *  JarWrkMastExecute任务创建   //未完成
     *  关入料门、开出料门、关出料门
     */
    public synchronized boolean jarWrkMastExecuteGenerate2(JarSlave jarSlave,Integer sign) {
        try{
            if (wrkMastExecuteService.getWrkMastByJarIdCount(jarSlave.getId())!=0){
                return false;
            }
            List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{
                add(0);
                add(2);
            }});
            for (BasJarMast basJarMast : basJarMastList){
                // 获取硫化罐信息
                JarThread jarThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getId());
                JarProtocol jarProtocol = jarThread.getJarProtocol();
                if (jarProtocol == null) {
                    return false;
                }
                if (jarProtocol.modeType != JarModeType.AUTO){
                    return false;
                }
                JarThread jarOtherThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getJarOtherId());
                JarProtocol jarOtherProtocol = jarOtherThread.getJarProtocol();
                if (jarOtherProtocol == null) {
                    return false;
                }
//                    if (jarOtherProtocol.modeType != JarModeType.AUTO){
//                        continue;
//                    }
                BasJar basJar = basJarMapper.selectById(jarProtocol.getJarNo());
                if (Cools.isEmpty(basJar)){
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
                    return false;
                }
                //门作业  无
                //自动、空闲、右门关闭、   Other左门关闭
                if (jarProtocol.isAutoing() && !jarProtocol.isRightDoor() && jarProtocol.jarErr==0
                        && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0
                        && !jarOtherProtocol.isLeftDoor() && jarOtherProtocol.leftDoorOpen==0  && jarOtherProtocol.leftDoorClose==0){
                    if (jarProtocol.statusType == JarStatusType.IDLE && !jarProtocol.isLeftDoor() && basJarMast.getStatus()==0){
                        //生成开门任务 OpenTheDoor
                        if (!jarWrkMastExecuteGenerateExecute(basJar,basJarMast,new int[]{basJar.getEnterSteNo(),basJar.getEnterRgvId(),1,1})){
                            log.error("JarWrkMastExecute任务创建===>执行异常===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast));
                        }
                        return true;
                    } else if (jarProtocol.statusType == JarStatusType.MOVING && jarProtocol.isLeftDoor()){
                        //生成入硫化罐任务
                        if (!jarWrkMastExecuteGenerateExecute(basJar,basJarMast,new int[]{basJar.getEnterSteNo(),basJar.getEnterRgvId(),5,1})){
                            log.error("JarWrkMastExecute任务创建===>执行异常===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast));
                        }
                        return true;
                    } else if (jarProtocol.statusType == JarStatusType.IDLE && jarProtocol.isLeftDoor()){
                        log.error("JarWrkMastExecute任务创建===>执行异常===》硫化罐空闲但是门未关===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast));
                    }
                }
                return false;
            }
        } catch (Exception e){
            log.error("{}号硫化罐JarWrkMastExecute任务创建异常,异常原因={}",jarSlave.getId(),e.getMessage());
        }
        return false;
    }
    /**
     *  JarWrkMastExecute任务创建===>执行   //未完成
     */
    public synchronized boolean jarWrkMastExecuteGenerateExecute(BasJar basJar,BasJarMast basJarMast,int[] digit) {
        try{
        try {
            WrkMastExecute wrkMastExecute = new WrkMastExecute(basJarMast);
            wrkMastExecute.setJarId(digit[3]==2? basJar.getBurial():basJar.getJarNo());
            wrkMastExecute.setSteId(digit[0]);//穿梭板ID
@@ -4660,20 +4787,8 @@
            wrkMastExecute.setIoType(digit[2]);//任务类型 0: 未知  1: 开进料门  2: 关进料门  3: 开出料门  4: 关出料门  5: 入硫化罐  6: 入冷却槽  7: 穿梭车进冷却槽  8: 穿梭车离开冷却槽  9: 出冷却槽
            wrkMastExecute.setType(digit[3]);//设备  0: 未知  1: 硫化罐  2: 冷却槽  3: 硫化罐==>冷却槽
            return wrkMastExecuteService.insert(wrkMastExecute);
        }catch (Exception e){
        } catch (Exception e) {
            log.error("JarWrkMastExecute任务创建===>执行异常===》异常原因:"+e.getMessage());
        }
        return false;
    }
    /*
     * 开门任务创建
     * */
    public synchronized boolean jarWrkMastExecuteGenerate2(){
        try{
        } catch (Exception e){
            log.error("{}号硫化罐OpenTheDoorGenerate==》JarWrkMastExecute任务创建异常,异常原因={}",null,e.getMessage());
        }
        return false;
    }