| | |
| | | import com.zy.asrs.domain.vo.SiteTableVo; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.utils.CommandUtils; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | |
| | | |
| | | @GetMapping("/io/mode/info/site") |
| | | @ManagerAuth(memo = "入出库模式") |
| | |
| | | Map<Integer, StaProtocol> station = devpThread.getStation(); |
| | | |
| | | for(Map.Entry<Integer, StaProtocol> entry : station.entrySet()) { |
| | | StaProtocol staProtocol = entry.getValue(); |
| | | // if (staProtocol) { |
| | | // PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | // vo.setNo(entry.getKey()); // 序号 |
| | | // |
| | | // vo.setPlcDesc(""); // todo:luxiaotao plc错误描述 |
| | | // vo.setError(""); // todo:luxiaotao 异常信息 |
| | | // list.add(vo); |
| | | // } |
| | | } |
| | | if (!Cools.isEmpty(staPlcErr(entry))){ |
| | | list.add(staPlcErr(entry).get(0)) ; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | list.sort((o1, o2) -> { |
| | | if (o1.getNo().compareTo(o2.getNo()) > 0){ |
| | | return 1; |
| | | }else if (o1.getNo().compareTo(o2.getNo()) < 0){ |
| | | return 0; |
| | | }else{ |
| | | return -1; |
| | | } |
| | | |
| | | }); |
| | | return R.ok().add(list); |
| | | } |
| | | |
| | |
| | | vo.setEmptyMk(staProtocol.isEmptyMk()?"Y":"N"); // 空板信号 |
| | | vo.setStaNo(staProtocol.getStaNo()); // 目标站 |
| | | vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "低" : "高"); //高低库位 |
| | | vo.setCar(staProtocol.isCar() ? "有": "无"); |
| | | return R.ok().add(vo); |
| | | } |
| | | } |
| | |
| | | basDevp.setOutEnable(outEnable ? "Y" : "N"); |
| | | } |
| | | basDevpService.updateById(basDevp); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | boolean result = CommandUtils.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol), false); |
| | | if (result) { |
| | | return R.ok(); |
| | | } else { |
| | |
| | | } |
| | | return R.error("更新失败"); |
| | | } |
| | | @PostMapping("/detl/out") |
| | | @ManagerAuth(memo = "修改站点数据") |
| | | public R siteDetlout(@RequestParam Integer devNo, |
| | | @RequestParam Short workNo, |
| | | @RequestParam Short staNo, |
| | | @RequestParam(required = false) String pakMk, |
| | | @RequestParam(required = false) Boolean inEnable, |
| | | @RequestParam(required = false) Boolean outEnable |
| | | ) { |
| | | BasDevp basDevp = basDevpService.selectById(devNo); |
| | | if (basDevp == null) { |
| | | return R.error("站点不存在"); |
| | | } |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | Map<Integer, StaProtocol> station = devpThread.getStation(); |
| | | for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) { |
| | | if (devNo.equals(entry.getKey())) { |
| | | StaProtocol staProtocol = entry.getValue(); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | if (pakMk != null) { |
| | | staProtocol.setPakMk(pakMk.equals("Y")); |
| | | } |
| | | if (inEnable != null) { |
| | | staProtocol.setInEnable(inEnable); |
| | | basDevp.setInEnable(inEnable ? "Y" : "N"); |
| | | } |
| | | if (outEnable != null) { |
| | | staProtocol.setOutEnable(outEnable); |
| | | basDevp.setOutEnable(outEnable ? "Y" : "N"); |
| | | } |
| | | staProtocol.setWorkNo((short) 0); |
| | | staProtocol.setStaNo((short) 0); |
| | | basDevpService.updateById(basDevp); |
| | | boolean result = CommandUtils.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol), false); |
| | | if (result) { |
| | | return R.ok(); |
| | | } else { |
| | | return R.error("下发命令失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return R.error("更新失败"); |
| | | } |
| | | @PostMapping("/detl/in") |
| | | @ManagerAuth(memo = "修改站点数据") |
| | | public R siteDetlint(@RequestParam Integer devNo, |
| | | @RequestParam Short workNo, |
| | | @RequestParam Short staNo, |
| | | @RequestParam(required = false) String pakMk, |
| | | @RequestParam(required = false) Boolean inEnable, |
| | | @RequestParam(required = false) Boolean outEnable |
| | | ) { |
| | | BasDevp basDevp = basDevpService.selectById(devNo); |
| | | if (basDevp == null) { |
| | | return R.error("站点不存在"); |
| | | } |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历入库口 |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { |
| | | if (!devNo.equals(inSta.getBackSta()) ){ |
| | | continue; |
| | | } |
| | | // 获取入库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getBackSta()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo(inSta.getStaNo().shortValue()); |
| | | boolean result = CommandUtils.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol), false); |
| | | if (result) { |
| | | return R.ok(); |
| | | } else { |
| | | return R.error("下发命令失败"); |
| | | } |
| | | } |
| | | } |
| | | return R.error("更新失败"); |
| | | } |
| | | |
| | | public List<PlcErrorTableVo> staPlcErr(Map.Entry<Integer, StaProtocol> entry){ |
| | | List<PlcErrorTableVo> list = new ArrayList<>(); |
| | | StaProtocol staProtocol = entry.getValue(); |
| | | if (staProtocol.getBreakerErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | vo.setPlcDesc("断路器故障"); |
| | | vo.setError("断路器故障"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.getInfraredErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | vo.setPlcDesc("光电异常"); |
| | | vo.setError("光电异常"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.getOutTimeErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | |
| | | vo.setPlcDesc("运行超时"); |
| | | vo.setError("运行超时"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.getSeizeSeatErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | |
| | | vo.setPlcDesc("占位超时"); |
| | | vo.setError("占位超时"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.getWrkYgoodsN()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | |
| | | vo.setPlcDesc("有任务无货故障"); |
| | | vo.setError("有任务无货故障"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.getInverterErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | |
| | | vo.setPlcDesc("变频器故障"); |
| | | vo.setError("变频器故障"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.getContactErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | |
| | | vo.setPlcDesc("电机接触器故障"); |
| | | vo.setError("电机接触器故障"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.getUpcontactErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | |
| | | vo.setPlcDesc("顶升电机接触器故障"); |
| | | vo.setError("顶升电机接触器故障"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.isFrontErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | vo.setPlcDesc("前超限"); |
| | | vo.setError("前超限"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.isBackErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | vo.setPlcDesc("后超限"); |
| | | vo.setError("后超限"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.isHighErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | vo.setPlcDesc("高超限"); |
| | | vo.setError("高超限"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.isLeftErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | vo.setPlcDesc("左超限"); |
| | | vo.setError("左超限"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.isRightErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | vo.setPlcDesc("右超限"); |
| | | vo.setError("右超限"); |
| | | list.add(vo); |
| | | } |
| | | if (staProtocol.isBarcodeErr()){ |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setNo(entry.getKey()); // 序号 |
| | | vo.setPlcDesc("扫码失败"); |
| | | vo.setError("扫码失败"); |
| | | list.add(vo); |
| | | } |
| | | |
| | | |
| | | return list; |
| | | } |
| | | |
| | | } |