| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("启动测试 ===>> 启动测试失败", e); |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据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(); |
| | | } |
| | | } |
| | | |
| | | } |