From e7ee6502ce70f0aa1728b9a67780ec28f6218a45 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期二, 20 九月 2022 14:45:04 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/controller/SiteController.java | 107 ++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 80 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/SiteController.java b/src/main/java/com/zy/asrs/controller/SiteController.java index 0a5d393..122b07c 100644 --- a/src/main/java/com/zy/asrs/controller/SiteController.java +++ b/src/main/java/com/zy/asrs/controller/SiteController.java @@ -1,9 +1,12 @@ package com.zy.asrs.controller; +import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.annotations.ManagerAuth; import com.core.common.R; import com.zy.asrs.domain.vo.PlcErrorTableVo; import com.zy.asrs.domain.vo.SiteTableVo; +import com.zy.asrs.entity.BasDevp; +import com.zy.asrs.service.BasDevpService; import com.zy.core.cache.MessageQueue; import com.zy.core.cache.OutputQueue; import com.zy.core.cache.SlaveConnection; @@ -12,11 +15,13 @@ import com.zy.core.model.Task; import com.zy.core.model.protocol.StaProtocol; import com.zy.core.properties.SlaveProperties; -import com.zy.core.thread.DevpThread; +import com.zy.core.DevpThread; +import com.zy.core.thread.SiemensDevpThread; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,31 +35,71 @@ @Autowired private SlaveProperties slaveProperties; + @Autowired + private BasDevpService basDevpService; + + @GetMapping("/io/mode/info/site") + @ManagerAuth(memo = "鍏呯數妯″紡") + public R ioMode(){ + List<Map<String, Object>> res = new ArrayList<>(); + for (DevpSlave devp : slaveProperties.getDevp()) { + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + Map<String, Object> map1 = new HashMap<>(); + map1.put("floor", 1); + map1.put("modeVal", devpThread.charge0); + map1.put("modeDesc", devpThread.charge0?"鍏呯數涓�":"鍏抽棴"); + res.add(map1); + Map<String, Object> map2 = new HashMap<>(); + map2.put("floor", 2); + map2.put("modeVal", devpThread.charge1); + map2.put("modeDesc", devpThread.charge1?"鍏呯數涓�":"鍏抽棴"); + res.add(map2); + Map<String, Object> map3 = new HashMap<>(); + map3.put("floor", 3); + map3.put("modeVal", devpThread.charge2); + map3.put("modeDesc", devpThread.charge2?"鍏呯數涓�":"鍏抽棴"); + res.add(map3); + } + return R.ok().add(res); + } + + @PostMapping("/io/mode/action/site") + @ManagerAuth(memo = "鍏呯數鎺у埗") + public R ioModeAction(@RequestParam("floor") Integer floor, @RequestParam("charge") Boolean charge){ + for (DevpSlave devp : slaveProperties.getDevp()) { + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + boolean res = devpThread.charge(floor - 1, charge); + return res?R.ok():R.error(); + } + return R.ok(); + } @PostMapping("/table/site") @ManagerAuth(memo = "绔欑偣淇℃伅琛�") public R siteTable(){ List<SiteTableVo> list = new ArrayList<>(); - + // 鍐呭瓨鏁版嵁 + Map<Integer, StaProtocol> station = new HashMap<>(); 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()) { - StaProtocol staProtocol = entry.getValue(); - SiteTableVo vo = new SiteTableVo(); - - vo.setDevNo(entry.getKey()); // 绔欑偣缂栧彿 - vo.setWorkNo(staProtocol.getWorkNo()); // 宸ヤ綔鍙� - vo.setAutoing(staProtocol.isAutoing()?"Y":"N"); // 鑷姩 - vo.setLoading(staProtocol.isLoading()?"Y":"N"); // 鏈夌墿 - vo.setInEnable(staProtocol.isInEnable()?"Y":"N"); // 鍙叆 - vo.setOutEnable(staProtocol.isOutEnable()?"Y":"N"); // 鍙嚭 - vo.setInreq1(staProtocol.isInreq1()?"Y":"N"); // 闇�姹�1 - vo.setEmptyMk(staProtocol.isEmptyMk()?"Y":"N"); // 绌烘澘淇″彿 - vo.setStaNo(staProtocol.getStaNo()); // 鐩爣绔� - - list.add(vo); - } + station.putAll(devpThread.getStation()); + } + // 鎸佷箙鏁版嵁 + List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>().orderBy("dev_no")); + for (BasDevp devp : basDevps) { + SiteTableVo vo = new SiteTableVo(); + vo.setDevNo(devp.getDevNo()); // 绔欑偣缂栧彿 + list.add(vo); + StaProtocol staProtocol = station.get(devp.getDevNo()); + if (null == staProtocol) { continue; } + vo.setWorkNo(staProtocol.getWorkNo()); // 宸ヤ綔鍙� + vo.setAutoing(staProtocol.isAutoing()?"Y":"N"); // 鑷姩 + vo.setLoading(staProtocol.isLoading()?"Y":"N"); // 鏈夌墿 + vo.setInEnable(staProtocol.isInEnable()?"Y":"N"); // 鍙叆 + vo.setOutEnable(staProtocol.isOutEnable()?"Y":"N"); // 鍙嚭 + vo.setPakMk(staProtocol.isPakMk()?"Y":"N"); // 鍏ュ簱鏍囪 + vo.setEmptyMk(staProtocol.isEmptyMk()?"Y":"N"); // 绌烘澘淇″彿 + vo.setStaNo(staProtocol.getStaNo()); // 鐩爣绔� } return R.ok().add(list); } @@ -68,12 +113,15 @@ Map<Integer, StaProtocol> station = devpThread.getStation(); for(Map.Entry<Integer, StaProtocol> entry : station.entrySet()) { - PlcErrorTableVo vo = new PlcErrorTableVo(); - vo.setNo(entry.getKey()); // 搴忓彿 - - vo.setPlcDesc(""); // todo:luxiaotao plc閿欒鎻忚堪 - vo.setError(""); // todo:luxiaotao 寮傚父淇℃伅 - list.add(vo); + 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); +// } } } @@ -123,7 +171,7 @@ vo.setLoading(staProtocol.isLoading()?"Y":"N"); // 鏈夌墿 vo.setInEnable(staProtocol.isInEnable()?"Y":"N"); // 鍙叆 vo.setOutEnable(staProtocol.isOutEnable()?"Y":"N"); // 鍙嚭 - vo.setInreq1(staProtocol.isInreq1()?"Y":"N"); // 闇�姹�1 + vo.setPakMk(staProtocol.isPakMk()?"Y":"N"); // 闇�姹�1 vo.setEmptyMk(staProtocol.isEmptyMk()?"Y":"N"); // 绌烘澘淇″彿 vo.setStaNo(staProtocol.getStaNo()); // 鐩爣绔� return R.ok().add(vo); @@ -137,19 +185,24 @@ @ManagerAuth(memo = "淇敼绔欑偣鏁版嵁") public R siteDetlUpdate(@RequestParam Integer siteId, @RequestParam Short workNo, - @RequestParam Short staNo){ + @RequestParam Short staNo, + @RequestParam String pakMk){ 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 (siteId.equals(entry.getKey())) { StaProtocol staProtocol = entry.getValue(); + staProtocol = staProtocol.clone(); if (workNo != null) { staProtocol.setWorkNo(workNo); } if (staNo != null) { staProtocol.setStaNo(staNo); } + if (pakMk != null) { + staProtocol.setPakMk(pakMk.equals("Y")); + } boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); if (result) { return R.ok(); -- Gitblit v1.9.1