| | |
| | | } |
| | | 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<>(); |