#
lsh
2024-06-22 c2144e00a981be9093c2b1fe257881203d800810
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -4582,20 +4582,15 @@
    }
    /**
     *  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();
@@ -4623,6 +4618,68 @@
                    //门作业  无
                    //自动、空闲、右门关闭、   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());
            }
        }
    }
    /**
     *  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){
@@ -4631,23 +4688,91 @@
                            if (!jarWrkMastExecuteGenerateExecute(basJar,basJarMast,new int[]{basJar.getEnterSteNo(),basJar.getEnterRgvId(),1,1})){
                                log.error("JarWrkMastExecute任务创建===>执行异常===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast));
                            }
                            return;
                        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;
                        return true;
                        } else if (jarProtocol.statusType == JarStatusType.IDLE && jarProtocol.isLeftDoor()){
                            log.error("JarWrkMastExecute任务创建===>执行异常===》硫化罐空闲但是门未关===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast));
                        }
                    }
                    break;
                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;
    }
    /**
@@ -4664,18 +4789,6 @@
            return wrkMastExecuteService.insert(wrkMastExecute);
        }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;
    }