自动化立体仓库 - WCS系统
#
18516761980
2022-10-06 40b3f1131c5d88ddc900bcfc6e53dfb7c3997df5
#
3个文件已修改
139 ■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 117 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/MainProcess.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -1989,63 +1989,23 @@
            for (DevpSlave devp : slaveProperties.getDevp()) {
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                if(null != devpThread){
                    int channel = 0;
                    for (int i = 0; i < 4; i++){
                        switch (i){
                            case 0:
                                channel = devpThread.startSignal1;
                                break;
                            case 1:
                                channel = devpThread.startSignal2;
                                break;
                            case 2:
                                channel = devpThread.startSignal3;
                                break;
                            case 3:
                                channel = devpThread.startSignal4;
                                break;
                        }
                        if (channel == 1){
                            TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
                                    .eq("channel",(i+1)).eq("status",0));
                            if(null != testMast){
                                Date now = new Date();
                                //http请求测试
                                TestDto testDto = new TestDto();
                                testDto.setLocNo(testMast.getLocNo());
                                testDto.setBarcode(testMast.getBarcode());
                                testDto.setUserId(testMast.getUserId());
                                testDto.setRequestTime(DateUtils.convert(now));
                                String response = new HttpHandler.Builder()
                                        .setUri(testUrl)
                                        .setPath("/testUrlPath")
                                        .setJson(JSON.toJSONString(testDto))
                                        .build()
                                        .doPost();
                                JSONObject jsonObject = JSON.parseObject(response);
                                if (jsonObject.getInteger("code").equals(200)) {
                                    //更新测试表状态
                                    testMast.setStatus(1);
                                    testMast.setModiTime(now);
                                    if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
                                            .eq("channel",1).eq("status",0))){
                                        throw new CoolException("更新产品测试状态失败");
                                    }
//                                    //更新库位状态,锁定pack状态,禁止入出库作业
//                                    LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",testMast.getLocNo()));
//                                    if(null != locMast){
//                                        locMast.setPackStatus(2);//测试中
//                                        locMast.setModiTime(now);
//                                        if(!locMastService.update(locMast,new EntityWrapper<LocMast>().eq("loc_no",testMast.getLocNo()))){
//                                            throw new CoolException("产品开始测试,更新目标库位锁定状态失败");
//                                        }
//                                    }
                                    //复位PLC信号
                                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, i*2));
                                } else {
                                    log.error("请求接口失败!!!url:{},request:{},response:{}", testUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(testDto), response);
                                }
                    for (int i = 0; i < 48; i++){
                        TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
                                .eq("channel",(i+1)).eq("status",0));//查找原来的状态
                        if(null != testMast && devpThread.startSignal[i] == 1){
                            testMast.setStatus(3);
                            testMast.setModiTime(new Date());
                            if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
                                    .eq("channel",(i+1)).eq("status",0))){
                                throw new CoolException("更新产品测试状态失败");
                            }
                            //复位PLC信号,借用输送站点实体类
                            StaProtocol staProtocol = new StaProtocol();
                            staProtocol.setSiteId(i*2);//寄存器地址
                            staProtocol.setStaNo((short)2);//修改PLC寄存器地址值,从1改为2
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
                            if(!result){
                                throw new CoolException("启动测试信号失败===>>" + i);
                            }
                        }
@@ -2054,7 +2014,6 @@
                }
            }
        } catch (Exception e) {
            log.error("启动测试  ===>> 启动测试失败", e);
            e.printStackTrace();
@@ -2062,4 +2021,46 @@
        }
    }
    /**
     * 根据PLC按钮测试信号,发送启动申请到测试系统
     */
    @Transactional
    public void finishTest() {
        try {
            // 根据输送线plc遍历
            for (DevpSlave devp : slaveProperties.getDevp()) {
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                if(null != devpThread){
                    for (int i = 0; i < 48; i++){
                        TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
                                .eq("channel",(i+1)).eq("status",0));//查找原来的状态,根据业务逻辑修改
                        if(null != testMast && devpThread.startSignal[i] == 3){
                            testMast.setStatus(3);
                            testMast.setModiTime(new Date());
                            if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
                                    .eq("channel",(i+1)).eq("status",0))){
                                throw new CoolException("更新产品测试状态失败");
                            }
                            //复位PLC信号,借用输送站点实体类
                            StaProtocol staProtocol = new StaProtocol();
                            staProtocol.setSiteId(i*2);//寄存器地址
                            staProtocol.setStaNo((short)0);//修改PLC寄存器地址值,从3改为0
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
                            if(!result){
                                throw new CoolException("完成测试信号失败===>>" + i);
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            log.error("完成测试  ===>> 完成测试失败", e);
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }
}
src/main/java/com/zy/core/MainProcess.java
@@ -70,6 +70,9 @@
                    //启动测试系统测试
                    mainService.startTest();
                    //测试系统完成测试确认
                    mainService.finishTest();
                } catch (Exception e) {
                    e.printStackTrace();
                }
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -53,10 +53,7 @@
    private int barcodeSize = 1;
    public IoModeType ioMode = IoModeType.NONE;
    public int startSignal1 = 0;
    public int startSignal2 = 0;
    public int startSignal3 = 0;
    public int startSignal4 = 0;
    public int[] startSignal = new int[48];
    public SiemensDevpThread(DevpSlave slave) {
        this.slave = slave;
@@ -84,7 +81,8 @@
                        break;
                    //复位测试信号
                    case 3:
                        siemensS7Net.Write("DB100." + (150 + (int)task.getData()), 0);
                        StaProtocol staProtocol = (StaProtocol)task.getData();
                        siemensS7Net.Write("DB200." + staProtocol.getSiteId(), staProtocol.getStaNo());
                        break;
                    default:
                        break;
@@ -190,12 +188,11 @@
        }
        Thread.sleep(200);
        OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.150", (short) 8);
        OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB200.0", (short) 96);
        if(result3.IsSuccess) {
            startSignal1 = siemensS7Net.getByteTransform().TransInt16(result.Content, 0);
            startSignal2 = siemensS7Net.getByteTransform().TransInt16(result.Content, 2);
            startSignal3 = siemensS7Net.getByteTransform().TransInt16(result.Content, 4);
            startSignal4 = siemensS7Net.getByteTransform().TransInt16(result.Content, 6);
            for(int i=0; i<48; i++){
                startSignal[i] = siemensS7Net.getByteTransform().TransInt16(result.Content, i*2);
            }
        }
//        OperateResultExOne<Short> result2 = siemensS7Net.ReadInt16("DB200.0");
//        if (result2.IsSuccess) {
@@ -238,7 +235,7 @@
            return;
        }
        int index = staNos.indexOf(staProtocol.getSiteId());
        short[] array = new short[10];
        short[] array = new short[2];
        array[0] = staProtocol.getWorkNo();
        array[1] = staProtocol.getStaNo();
        OperateResult write = siemensS7Net.Write("DB100." + index*4, array);