|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.core.annotations.ManagerAuth; | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.core.common.R; | 
|---|
|  |  |  | import com.zy.asrs.domain.vo.PlcErrorTableVo; | 
|---|
|  |  |  | import com.zy.asrs.domain.vo.SiteTableVo; | 
|---|
|  |  |  | import com.zy.asrs.domain.vo.SteDataVo; | 
|---|
|  |  |  | import com.zy.asrs.entity.BasDevp; | 
|---|
|  |  |  | import com.zy.asrs.entity.BasSte; | 
|---|
|  |  |  | import com.zy.asrs.service.BasDevpService; | 
|---|
|  |  |  | import com.zy.asrs.service.BasSteService; | 
|---|
|  |  |  | import com.zy.core.cache.MessageQueue; | 
|---|
|  |  |  | import com.zy.core.cache.OutputQueue; | 
|---|
|  |  |  | import com.zy.core.cache.SlaveConnection; | 
|---|
|  |  |  | import com.zy.core.enums.SlaveType; | 
|---|
|  |  |  | import com.zy.core.model.DevpSlave; | 
|---|
|  |  |  | import com.zy.core.model.SteSlave; | 
|---|
|  |  |  | import com.zy.core.model.Task; | 
|---|
|  |  |  | import com.zy.core.model.protocol.StaProtocol; | 
|---|
|  |  |  | import com.zy.core.properties.SlaveProperties; | 
|---|
|  |  |  | 
|---|
|  |  |  | public class SiteController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasSteService basSteService; | 
|---|
|  |  |  | @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> map2 = new HashMap<>(); | 
|---|
|  |  |  | map2.put("floor", 2); | 
|---|
|  |  |  | map2.put("modeVal", devpThread.ioModeOf2F.id); | 
|---|
|  |  |  | map2.put("modeDesc", devpThread.ioModeOf2F.desc); | 
|---|
|  |  |  | res.add(map2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(res); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/table/site") | 
|---|
|  |  |  | @ManagerAuth(memo = "站点信息表") | 
|---|
|  |  |  | 
|---|
|  |  |  | /************************** 详情操作 ******************************/ | 
|---|
|  |  |  | /****************************************************************/ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/detl/{siteId}") | 
|---|
|  |  |  | @GetMapping("/detl/wcs/{siteId}") | 
|---|
|  |  |  | public R siteDetl(@PathVariable("siteId") Integer siteId){ | 
|---|
|  |  |  | SiteTableVo vo = new SiteTableVo(); | 
|---|
|  |  |  | for (DevpSlave devp : slaveProperties.getDevp()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/detl/update") | 
|---|
|  |  |  | @ManagerAuth(memo = "修改站点数据") | 
|---|
|  |  |  | public R siteDetlUpdate(@RequestParam Integer siteId, | 
|---|
|  |  |  | @RequestParam Integer workNo, | 
|---|
|  |  |  | @RequestParam Long workNo, | 
|---|
|  |  |  | @RequestParam Integer staNo, | 
|---|
|  |  |  | @RequestParam String pakMk){ | 
|---|
|  |  |  | for (DevpSlave devp : slaveProperties.getDevp()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | if (pakMk != null) { | 
|---|
|  |  |  | staProtocol.setPakMk(pakMk.equals("Y")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(5, staProtocol)); | 
|---|
|  |  |  | if (result) { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.error("plc已掉线"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/detl/{steNo}") | 
|---|
|  |  |  | public R steDetl(@PathVariable("steNo") Integer steNo){ | 
|---|
|  |  |  | SteDataVo vo = new SteDataVo(); | 
|---|
|  |  |  | for (SteSlave ste : slaveProperties.getSte()) { | 
|---|
|  |  |  | if (steNo.equals(ste.getId())) { | 
|---|
|  |  |  | vo.setSteNo(ste.getId()); | 
|---|
|  |  |  | BasSte basSte = basSteService.selectById(ste.getId()); | 
|---|
|  |  |  | if (!Cools.isEmpty(basSte)) { | 
|---|
|  |  |  | vo.setRow(basSte.getRow()); | 
|---|
|  |  |  | vo.setBay(basSte.getBay()); | 
|---|
|  |  |  | vo.setLev(basSte.getLev()); | 
|---|
|  |  |  | vo.setCrnNo(basSte.getCrnNo()); | 
|---|
|  |  |  | vo.setWorkNo(basSte.getWrkNo()); | 
|---|
|  |  |  | vo.setPakMk(basSte.getPakMk()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|