|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.entity.BasDevp; | 
|---|
|  |  |  | import com.zy.asrs.entity.BasRgv; | 
|---|
|  |  |  | import com.zy.asrs.service.BasDevpService; | 
|---|
|  |  |  | import com.zy.asrs.service.BasRgvService; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasRgvService basRgvService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/io/mode/info/site") | 
|---|
|  |  |  | @ManagerAuth(memo = "入出库模式") | 
|---|
|  |  |  | 
|---|
|  |  |  | for (BasDevp devp : basDevps) { | 
|---|
|  |  |  | SiteTableVo vo = new SiteTableVo(); | 
|---|
|  |  |  | vo.setDevNo(devp.getDevNo());    // 站点编号 | 
|---|
|  |  |  | vo.setWorkNo(devp.getWrkNo()); | 
|---|
|  |  |  | 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.setStaNo(staProtocol.getStaNo());                // 目标站 | 
|---|
|  |  |  | //            vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "低" : "高");     //高低库位 | 
|---|
|  |  |  | vo.setLocType1(devp.getDevNo()==102 ? "高" : "低"); | 
|---|
|  |  |  | vo.setFull(staProtocol.isFull()?"Y":"N");   // 满 | 
|---|
|  |  |  | vo.setBarcode(staProtocol.getBarcode());   // 条码 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok().add(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/detl/update") | 
|---|
|  |  |  | @ManagerAuth(memo = "修改站点数据") | 
|---|
|  |  |  | public R siteDetlUpdate(@RequestParam Integer siteId, | 
|---|
|  |  |  | @RequestParam Short workNo, | 
|---|
|  |  |  | @RequestParam Integer workNo, | 
|---|
|  |  |  | @RequestParam Short staNo, | 
|---|
|  |  |  | @RequestParam String pakMk){ | 
|---|
|  |  |  | for (DevpSlave devp : slaveProperties.getDevp()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.error("plc已掉线"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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("顶升电机接触器故障"); | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | * 宜科定制  150站点异常信息:大托盘目的站错误 | 
|---|
|  |  |  | * */ | 
|---|
|  |  |  | if (entry.getKey()==150){ | 
|---|
|  |  |  | vo.setPlcDesc("150站点大托盘目的站错误"); | 
|---|
|  |  |  | vo.setError("150站点大托盘目的站错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|