| | |
| | | @RequestMapping("/monitor") |
| | | public class MonitorController { |
| | | |
| | | private static final String[] WEEK = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"}; |
| | | private static final String[] WEEK = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}; |
| | | |
| | | @Autowired |
| | | private ReportQueryMapper reportQueryMapper; |
| | |
| | | calendar.setTime(now); |
| | | return R.ok( |
| | | Cools.add("year", calendar.get(Calendar.YEAR)) |
| | | .add("month", CommonService.zerofill(String.valueOf(calendar.get(Calendar.MONTH)+1), 2)) |
| | | .add("day", CommonService.zerofill(String.valueOf(calendar.get(Calendar.DATE)), 2)) |
| | | .add("hour", CommonService.zerofill(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)), 2)) |
| | | .add("minute", CommonService.zerofill(String.valueOf(calendar.get(Calendar.MINUTE)), 2)) |
| | | .add("second", CommonService.zerofill(String.valueOf(calendar.get(Calendar.SECOND)) , 2)) |
| | | .add("week", WEEK[calendar.get(Calendar.DAY_OF_WEEK)-1]) |
| | | .add("month", CommonService.zerofill(String.valueOf(calendar.get(Calendar.MONTH) + 1), 2)) |
| | | .add("day", CommonService.zerofill(String.valueOf(calendar.get(Calendar.DATE)), 2)) |
| | | .add("hour", CommonService.zerofill(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)), 2)) |
| | | .add("minute", CommonService.zerofill(String.valueOf(calendar.get(Calendar.MINUTE)), 2)) |
| | | .add("second", CommonService.zerofill(String.valueOf(calendar.get(Calendar.SECOND)), 2)) |
| | | .add("week", WEEK[calendar.get(Calendar.DAY_OF_WEEK) - 1]) |
| | | ); |
| | | } |
| | | |
| | |
| | | |
| | | return R.ok( |
| | | Cools.add("xSpeed", Arith.multiplys(1, Math.abs(xSpeed), 1)) // 行走速度 |
| | | .add("ySpeed", Arith.multiplys(1, Math.abs(ySpeed), 1)) // 升降速度 |
| | | .add("zSpeed", Arith.multiplys(1, Math.abs(zSpeed), 1)) // 叉牙速度 |
| | | .add("forkPos", forkPos) // 叉牙速度 |
| | | .add("xDistance", Arith.multiplys(1, Math.abs(xDistance), 1)) // 累计走行距离km |
| | | .add("yDistance", Arith.multiplys(1, Math.abs(yDistance), 1)) // 累计升降距离km |
| | | .add("xDuration", Arith.multiplys(1, Math.abs(xDuration), 1)) // 累计走行时长h |
| | | .add("yDuration", Arith.multiplys(1, Math.abs(yDuration), 1)) // 累计升降时长h |
| | | .add("isShow", !Cools.isEmpty(ledContent)) // 是否显示内容 |
| | | .add("content", ledContent) // 显示内容 |
| | | .add("ySpeed", Arith.multiplys(1, Math.abs(ySpeed), 1)) // 升降速度 |
| | | .add("zSpeed", Arith.multiplys(1, Math.abs(zSpeed), 1)) // 叉牙速度 |
| | | .add("forkPos", forkPos) // 叉牙速度 |
| | | .add("xDistance", Arith.multiplys(1, Math.abs(xDistance), 1)) // 累计走行距离km |
| | | .add("yDistance", Arith.multiplys(1, Math.abs(yDistance), 1)) // 累计升降距离km |
| | | .add("xDuration", Arith.multiplys(1, Math.abs(xDuration), 1)) // 累计走行时长h |
| | | .add("yDuration", Arith.multiplys(1, Math.abs(yDuration), 1)) // 累计升降时长h |
| | | .add("isShow", !Cools.isEmpty(ledContent)) // 是否显示内容 |
| | | .add("content", ledContent) // 显示内容 |
| | | ); |
| | | } |
| | | |
| | |
| | | * 入库报表 -- 折线图 |
| | | */ |
| | | @GetMapping("/pakin/rep") |
| | | public R monitorPakinRep(){ |
| | | public R monitorPakinRep() { |
| | | // 入库 |
| | | List<Map<String, Object>> pakinRep = reportQueryMapper.queryPakinRep(); |
| | | for (Map<String, Object> map : pakinRep) { |
| | | if (map.get("node")!=null) { |
| | | if (map.get("node") != null) { |
| | | map.put("node", String.valueOf(map.get("node")).substring(5, 10)); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @GetMapping("/line/charts") |
| | | public R locIoLineCharts(){ |
| | | Map<String,Object> map=new HashMap<String, Object>(); |
| | | public R locIoLineCharts() { |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | List<AxisBean> list = new ArrayList<AxisBean>(); |
| | | |
| | | List<WorkChartAxis> listChart = reportQueryMapper.getChartAxis(); |
| | | |
| | | if(listChart!=null) { |
| | | if (listChart != null) { |
| | | ArrayList<Integer> data1 = new ArrayList<Integer>(); |
| | | ArrayList<Integer> data2 = new ArrayList<Integer>(); |
| | | |
| | | SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.DATE, -12); |
| | | for(int i=0;i<12;i++) { |
| | | for (int i = 0; i < 12; i++) { |
| | | boolean flag = true; |
| | | calendar.add(Calendar.DATE, 1); |
| | | String str = sf.format(calendar.getTime()); |
| | | for(WorkChartAxis workChart : listChart) { |
| | | if(str.equals(workChart.getYmd())) { |
| | | for (WorkChartAxis workChart : listChart) { |
| | | if (str.equals(workChart.getYmd())) { |
| | | data1.add(workChart.getInqty()); |
| | | data2.add(workChart.getOutqty()); |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | if(flag) { |
| | | if (flag) { |
| | | data1.add(0); |
| | | data2.add(0); |
| | | } |
| | |
| | | outqty.setData(data2.toArray(array2)); |
| | | list.add(outqty); |
| | | } |
| | | map.put("rows",list); |
| | | map.put("rows", list); |
| | | return R.ok(map); |
| | | } |
| | | |
| | |
| | | * 库位使用情况统计 |
| | | */ |
| | | @GetMapping("/loc/rep") |
| | | public R monitorLocRep(){ |
| | | public R monitorLocRep() { |
| | | List<Map<String, Object>> pie = new ArrayList<>(); |
| | | |
| | | LocChartPie locUseRate = reportQueryMapper.getLocUseRate(); |
| | | if(locUseRate!=null) { |
| | | if (locUseRate != null) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("name", "在库"); |
| | | map.put("value", locUseRate.getFqty()); |
| | |
| | | |
| | | return R.ok( |
| | | Cools.add("pie", pie) |
| | | .add("stockCunt", locUseRate.getFqty()) |
| | | .add("emptyCount", locUseRate.getOqty()) |
| | | .add("noneCount", locUseRate.getXqty()) |
| | | .add("total", total) |
| | | .add("used", used) |
| | | .add("usedPr", usedPr) |
| | | .add("stockCunt", locUseRate.getFqty()) |
| | | .add("emptyCount", locUseRate.getOqty()) |
| | | .add("noneCount", locUseRate.getXqty()) |
| | | .add("total", total) |
| | | .add("used", used) |
| | | .add("usedPr", usedPr) |
| | | ); |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping("/led/error") |
| | | public R monitorLedError(@RequestParam("ledId") Integer ledId) { |
| | | if (Cools.isEmpty(ledId)) { |
| | | return R.ok(); |
| | | } |
| | | String errorMsg = ""; |
| | | // if (ledId == 5 || ledId == 6) { |
| | | // LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, ledId); |
| | | // if (null != ledThread) { |
| | | // errorMsg = ledThread.getErrorMsg().toString(); |
| | | // } |
| | | // return R.ok().add(errorMsg); |
| | | // } else { |
| | | for (LedSlave slave : slaveProperties.getLed()) { |
| | | if (slave.getStaArr().contains(ledId)) { |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, slave.getId()); |
| | |
| | | } |
| | | } |
| | | return R.ok().add(errorMsg); |
| | | // } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // public R monitorLedError2(Integer ledId) { |
| | | // ledId = 311; |
| | | // String errorMsg = ""; |
| | | // //for (LedSlave slave : slaveProperties.getLed()) { |
| | | // //if (slave.getStaArr().contains(ledId)) { |
| | | // LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, ledId); |
| | | // if (null != ledThread) { |
| | | // errorMsg = ledThread.getErrorMsg().toString(); |
| | | // System.out.println("-----------" + errorMsg + "----------" + ledId); |
| | | // } |
| | | // //} |
| | | // // } |
| | | // return R.ok().add(errorMsg); |
| | | |
| | | |
| | | /** |
| | | * 自动补零 |
| | | */ |
| | | private List<Map<String, Object>> fill(List<Map<String, Object>> list, int start, int end){ |
| | | for (int i = start ; i <= end; i++){ |
| | | private List<Map<String, Object>> fill(List<Map<String, Object>> list, int start, int end) { |
| | | for (int i = start; i <= end; i++) { |
| | | boolean exist = false; |
| | | for (Map seq : list){ |
| | | if (Integer.parseInt(String.valueOf(seq.get("node"))) == i){ |
| | | for (Map seq : list) { |
| | | if (Integer.parseInt(String.valueOf(seq.get("node"))) == i) { |
| | | exist = true; |
| | | } |
| | | } |
| | | if (!exist){ |
| | | if (!exist) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("node", i); |
| | | map.put("val", 0); |
| | |
| | | |
| | | /** |
| | | * x轴单位转换 |
| | | * |
| | | * @param dot y轴数值保留小数位 |
| | | */ |
| | | private List<Map<String, Object>> convert(List<Map<String, Object>> list, StatsType statsType, int dot){ |
| | | for (Map<String, Object> map : list){ |
| | | private List<Map<String, Object>> convert(List<Map<String, Object>> list, StatsType statsType, int dot) { |
| | | for (Map<String, Object> map : list) { |
| | | Object val = map.get("val"); |
| | | map.put("val", Arith.multiplys(dot, 1, (Number) val)); |
| | | Object node = map.get("node"); |
| | | switch (statsType){ |
| | | switch (statsType) { |
| | | case MONTH: |
| | | map.put("node", node + "号"); |
| | | break; |
| | |
| | | return list; |
| | | } |
| | | |
| | | enum StatsType{ |
| | | enum StatsType { |
| | | |
| | | YEAR(1,1, 12), |
| | | MONTH(2,1, 30), |
| | | ; |
| | | YEAR(1, 1, 12), |
| | | MONTH(2, 1, 30), |
| | | ; |
| | | |
| | | int id; |
| | | int start; |
| | | int end; |
| | | StatsType(int id, int start, int end) { |
| | | this.id = id; |
| | | this.start = start; |
| | | this.end = end; |
| | | } |
| | | int id; |
| | | int start; |
| | | int end; |
| | | |
| | | static StatsType get(int id) { |
| | | StatsType[] values = StatsType.values(); |
| | | for (StatsType statsType : values){ |
| | | if (statsType.id == id){ |
| | | return statsType; |
| | | } |
| | | } |
| | | throw new RuntimeException("找不到StatsType类型"); |
| | | } |
| | | |
| | | StatsType(int id, int start, int end) { |
| | | this.id = id; |
| | | this.start = start; |
| | | this.end = end; |
| | | } |
| | | |
| | | static StatsType get(int id) { |
| | | StatsType[] values = StatsType.values(); |
| | | for (StatsType statsType : values) { |
| | | if (statsType.id == id) { |
| | | return statsType; |
| | | } |
| | | } |
| | | throw new RuntimeException("找不到StatsType类型"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | List<WrkDetl> findByWorkNo(Integer workNo); |
| | | |
| | | int updateIoTime(@Param("workNo") Integer workNo, @Param("ioTime") Date ioTime); |
| | | |
| | | } |
| | |
| | | List<WrkDetl> findByWorkNo(Integer workNo); |
| | | |
| | | boolean updateIoTime(Integer workNo, Date ioTime); |
| | | |
| | | } |
| | |
| | | // 获取入库站信息 |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); |
| | | // LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); |
| | | /* |
| | | 无条码 |
| | | 没有可入信号 |
| | |
| | | if (!staProtocol.isPakMk()) { |
| | | continue; |
| | | } |
| | | // if (ledThread != null && !Cools.isEmpty(errMsg)) { |
| | | // //String errorMsg = jsonObject.getString("msg"); |
| | | // MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errMsg)); |
| | | // System.out.println("--------------"); |
| | | // } |
| | | staProtocol.setWorkNo(wrkNo); |
| | | News.warn("{}入库回退:{},任务号:{}", inSta.getStaNo(), errMsg, wrkNo); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | |
| | | // 工作档集合 |
| | | List<WrkMast> wrkMasts = new ArrayList<>(); |
| | | for (Integer staNo : led.getStaArr()) { |
| | | if (staNo == 104 || staNo == 204 || staNo == 304) { |
| | | if (staNo == 104 || staNo == 204 || staNo == 304|| staNo == 311) { |
| | | continue; |
| | | } |
| | | // 获取叉车站点 |
| | |
| | | } |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | if (!commands.isEmpty()) { |
| | | if (led.getId() == 3) { |
| | | if (led.getId() == 6 || led.getId() == 5) { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { |
| | | News.error("" + mark + " - 2" + " - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | } else { |
| | | ledThread.setLedMk(false); |
| | | } |
| | | } else if (led.getId() == 3) { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { |
| | | News.error("" + mark + " - 2" + " - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | |
| | | |
| | | try { |
| | | // 修改主档led标记 |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | wrkMast.setOveMk("Y"); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | News.errorNoLog("" + mark + " - 4" + " - 更新工作档失败"); |
| | | throw new CoolException("更新工作档失败"); |
| | | } |
| | | } |
| | | // for (WrkMast wrkMast : wrkMasts) { |
| | | // wrkMast.setOveMk("Y"); |
| | | // wrkMast.setModiTime(new Date()); |
| | | // if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | // News.errorNoLog("" + mark + " - 4" + " - 更新工作档失败"); |
| | | // throw new CoolException("更新工作档失败"); |
| | | // } |
| | | // } |
| | | |
| | | // 更新线程当前工作号集合 |
| | | ledThread.setWorkNos(workNos); |
| | |
| | | } |
| | | |
| | | if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { |
| | | if (crnProtocol.getBay() == 1 && crnProtocol.getLevel() == 1) { |
| | | |
| | | if ((crnProtocol.getCrnNo()==3 || crnProtocol.getCrnNo()==4) && crnProtocol.getBay()==0 && crnProtocol.getLevel() == 1) { |
| | | continue; |
| | | } |
| | | if ((crnProtocol.getCrnNo()==1 || crnProtocol.getCrnNo()==2) && crnProtocol.getBay()==1 && crnProtocol.getLevel() == 1) { |
| | | continue; |
| | | } |
| | | Page<BasCrnOpt> basCrnOptPage = crnOptService.selectPage(new Page<>(1, 1), new EntityWrapper<BasCrnOpt>().eq("crn_no", crn.getId()).orderBy("send_time", false)); |
| | |
| | | News.info("堆垛机无任务自动回入库口待机==>>" + crnProtocol.getCrnNo() + "号堆垛机"); |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 堆垛机编号 |
| | | crnCommand.setTaskNo((short) 9999); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.XY_MOVE); // 任务模式: 堆垛机移动 |
| | | crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY((short) 1); // 源库位列 |
| | | crnCommand.setSourcePosZ((short) 1); // 源库位层 |
| | | crnCommand.setDestinationPosX((short) 0); // 目标库位排 |
| | | crnCommand.setDestinationPosY((short) 0); // 目标库位列 |
| | | crnCommand.setDestinationPosZ((short) 0); // 目标库位层 |
| | | if (crnProtocol.getCrnNo()==3 || crnProtocol.getCrnNo()==4){ |
| | | crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 堆垛机编号 |
| | | crnCommand.setTaskNo((short) 9999); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 任务模式: 堆垛机移动 |
| | | crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY((short) 0); // 源库位列 |
| | | crnCommand.setSourcePosZ((short) 1); // 源库位层 |
| | | crnCommand.setDestinationPosX((short) 0); // 目标库位排 |
| | | crnCommand.setDestinationPosY((short) 0); // 目标库位列 |
| | | crnCommand.setDestinationPosZ((short) 0); // 目标库位层 |
| | | crnCommand.setCommand((short) 1); |
| | | }else { |
| | | crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 堆垛机编号 |
| | | crnCommand.setTaskNo((short) 9999); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 任务模式: 堆垛机移动 |
| | | crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY((short) 1); // 源库位列 |
| | | crnCommand.setSourcePosZ((short) 1); // 源库位层 |
| | | crnCommand.setDestinationPosX((short) 0); // 目标库位排 |
| | | crnCommand.setDestinationPosY((short) 0); // 目标库位列 |
| | | crnCommand.setDestinationPosZ((short) 0); // 目标库位层 |
| | | crnCommand.setCommand((short) 1); |
| | | } |
| | | if (!MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, crnCommand))) { |
| | | News.error("堆垛机移动命令下发失败,堆垛机号={},任务数据={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } |
| | |
| | | } |
| | | |
| | | // 演示 |
| | | // mainService.crnDemoOfLocMove1(); |
| | | //mainService.crnDemoOfLocMove1(); |
| | | // 入出库模式切换函数 |
| | | // mainService.ioConvert(); |
| | | // 入库 ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档 |
| | |
| | | // 读数据 |
| | | case 1: |
| | | read(); |
| | | Thread.sleep(100); |
| | | readsanqi(); |
| | | break; |
| | | // 写数据 ID+目标站 |
| | |
| | | } |
| | | // 心跳 |
| | | // heartbeat(); |
| | | Thread.sleep(300); |
| | | Thread.sleep(200); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | private void readsanqi() throws InterruptedException { |
| | | ArrayList<Integer> staNos = staNos3; |
| | | int staNoSize = staNos3.size(); |
| | | |
| | | // |
| | | OperateResultExOne<byte[]> resultsanqi = siemensS7Net.Read("DB101.120", (short) (staNoSize * 8)); |
| | | if (resultsanqi.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | staProtocol.setWorkNo((short) siemensS7Net.getByteTransform().TransInt32(resultsanqi.Content, i * 8)); // 工作号 |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(resultsanqi.Content, i * 8 + 4)); // 目标站 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultsanqi.Content, i * 8 + 6, 1); |
| | | staProtocol.setAutoing(status[0]); // 自动 |
| | | staProtocol.setLoading(status[1]); // 有物 |
| | | staProtocol.setInEnable(status[2]); // 可入 |
| | | staProtocol.setOutEnable(status[3]);// 可出 |
| | | staProtocol.setEmptyMk(status[4]); // 空板信号 |
| | | staProtocol.setFullPlt(status[5]); // 满托盘 |
| | | staProtocol.setHigh(status[6]); // 高库位 |
| | | staProtocol.setLow(status[7]); // 低库位 |
| | | // staProtocol.setWeight(status[8]); //是否为重货 |
| | | if (!staProtocol.isPakMk() && staProtocol.isLoading()) { |
| | | staProtocol.setPakMk(true); |
| | | } |
| | | } |
| | | } else { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】读取输送线plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | // log.error("读取输送线plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort()); |
| | | } |
| | | |
| | | |
| | | //外形检测 三期 |
| | | OperateResultExOne<byte[]> resultErrsanqi = siemensS7Net.Read("DB101.160", (short) (staNoSize * 8)); |
| | | if (resultErrsanqi.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErrsanqi.Content, i * 4, 1); |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | staProtocol.setFrontErr(status[0]); |
| | | staProtocol.setBackErr(status[1]); |
| | | staProtocol.setHighErr(status[2]); |
| | | staProtocol.setLeftErr(status[3]); |
| | | staProtocol.setRightErr(status[4]); |
| | | staProtocol.setWeightErr(status[5]); |
| | | staProtocol.setBarcodeErr(status[6]); |
| | | } |
| | | } |
| | | |
| | | |
| | | //条码扫描器 三期 |
| | | Thread.sleep(200); |
| | | ArrayList<Integer> barcodeListsanqi = barcode3; |
| | | OperateResultExOne<byte[]> result2siqi = siemensS7Net.Read("DB101.180", (short) (barcodeListsanqi.size() * 8)); |
| | | if (result2siqi.IsSuccess) { |
| | | for (int i = 0; i < barcodeListsanqi.size(); i++) { |
| | | Integer barcodeId = barcodeListsanqi.get(i); |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2siqi.Content, i * 8, 8, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId); |
| | | if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //故障 三期 |
| | | OperateResultExOne<byte[]> resultErrs = siemensS7Net.Read("DB101.220", (short) (staNoSize * 4)); |
| | | if (resultErrs.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErrs.Content, i * 4, 1); |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | staProtocol.setBreakerErr(status[0]); |
| | | staProtocol.setInfraredErr(status[1]); |
| | | staProtocol.setOutTimeErr(status[2]); |
| | | staProtocol.setSeizeSeatErr(status[3]); |
| | | staProtocol.setWrkYgoodsN(status[4]); |
| | | staProtocol.setInverterErr(status[5]); |
| | | staProtocol.setContactErr(status[6]); |
| | | staProtocol.setUpcontactErr(status[7]); |
| | | |
| | | } |
| | | |
| | | } |
| | | // 根据实时信息更新数据库 |
| | | try { |
| | | if (!station.isEmpty()) { |
| | | List<BasDevp> basDevps = new ArrayList<>(); |
| | | for (Integer siteId : staNos) { |
| | | if (slave.getId() == 2) { |
| | | // |
| | | OperateResultExOne<byte[]> resultsanqi = siemensS7Net.Read("DB101.120", (short) (staNoSize * 8)); |
| | | if (resultsanqi.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | basDevps.add(staProtocol.toSqlModel()); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | staProtocol.setWorkNo((short) siemensS7Net.getByteTransform().TransInt32(resultsanqi.Content, i * 8)); // 工作号 |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(resultsanqi.Content, i * 8 + 4)); // 目标站 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultsanqi.Content, i * 8 + 6, 1); |
| | | staProtocol.setAutoing(status[0]); // 自动 |
| | | staProtocol.setLoading(status[1]); // 有物 |
| | | staProtocol.setInEnable(status[2]); // 可入 |
| | | staProtocol.setOutEnable(status[3]);// 可出 |
| | | staProtocol.setEmptyMk(status[4]); // 空板信号 |
| | | staProtocol.setFullPlt(status[5]); // 满托盘 |
| | | staProtocol.setHigh(status[6]); // 高库位 |
| | | staProtocol.setLow(status[7]); // 低库位 |
| | | // staProtocol.setWeight(status[8]); //是否为重货 |
| | | if (!staProtocol.isPakMk() && staProtocol.isLoading()) { |
| | | staProtocol.setPakMk(true); |
| | | } |
| | | } |
| | | } else { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】读取输送线plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | // log.error("读取输送线plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort()); |
| | | } |
| | | |
| | | BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class); |
| | | if (null != basDevpService && !basDevpService.updateBatchById(basDevps)) { |
| | | throw new Exception("更新数据库数据失败"); |
| | | |
| | | //外形检测 三期 |
| | | OperateResultExOne<byte[]> resultErrsanqi = siemensS7Net.Read("DB101.162", (short) (staNoSize * 8)); |
| | | if (resultErrsanqi.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErrsanqi.Content, i * 4, 1); |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | staProtocol.setFrontErr(status[0]); |
| | | staProtocol.setBackErr(status[1]); |
| | | staProtocol.setHighErr(status[2]); |
| | | staProtocol.setLeftErr(status[3]); |
| | | staProtocol.setRightErr(status[4]); |
| | | staProtocol.setWeightErr(status[5]); |
| | | staProtocol.setBarcodeErr(status[6]); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】更新数据库数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); |
| | | |
| | | |
| | | //条码扫描器 三期 |
| | | Thread.sleep(200); |
| | | ArrayList<Integer> barcodeListsanqi = barcode3; |
| | | OperateResultExOne<byte[]> result2siqi = siemensS7Net.Read("DB101.180", (short) (barcodeListsanqi.size() * 8)); |
| | | if (result2siqi.IsSuccess) { |
| | | for (int i = 0; i < barcodeListsanqi.size(); i++) { |
| | | Integer barcodeId = barcodeListsanqi.get(i); |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2siqi.Content, i * 8, 8, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId); |
| | | if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //故障 三期 |
| | | OperateResultExOne<byte[]> resultErrs = siemensS7Net.Read("DB101.220", (short) (staNoSize * 4)); |
| | | if (resultErrs.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErrs.Content, i * 4, 1); |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | staProtocol.setBreakerErr(status[0]); |
| | | staProtocol.setInfraredErr(status[1]); |
| | | staProtocol.setOutTimeErr(status[2]); |
| | | staProtocol.setSeizeSeatErr(status[3]); |
| | | staProtocol.setWrkYgoodsN(status[4]); |
| | | staProtocol.setInverterErr(status[5]); |
| | | staProtocol.setContactErr(status[6]); |
| | | staProtocol.setUpcontactErr(status[7]); |
| | | |
| | | } |
| | | |
| | | } |
| | | // 根据实时信息更新数据库 |
| | | try { |
| | | if (!station.isEmpty()) { |
| | | List<BasDevp> basDevps = new ArrayList<>(); |
| | | for (Integer siteId : staNos) { |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | basDevps.add(staProtocol.toSqlModel()); |
| | | } |
| | | |
| | | BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class); |
| | | if (null != basDevpService && !basDevpService.updateBatchById(basDevps)) { |
| | | throw new Exception("更新数据库数据失败"); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】更新数据库数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | staNo: 311 |
| | | barcode: ${wcs-slave.barcode[3].id} |
| | | backSta: 312 |
| | | led: ${wcs-slave.led[5].id} |
| | | led: ${wcs-slave.led[4].id} |
| | | # 空板入库口1 |
| | | emptyInSta[1]: |
| | | staNo: 311 |
| | | barcode: ${wcs-slave.barcode[3].id} |
| | | led: ${wcs-slave.led[5].id} |
| | | led: ${wcs-slave.led[4].id} |
| | | backSta: 312 |
| | | # 拣料入库口1 |
| | | pickSta[1]: |
| | | staNo: 311 |
| | | barcode: ${wcs-slave.barcode[3].id} |
| | | led: ${wcs-slave.led[5].id} |
| | | led: ${wcs-slave.led[4].id} |
| | | # 出库口1 |
| | | outSta[1]: |
| | | staNo: 314 |
| | | led: ${wcs-slave.led[4].id} |
| | | led: ${wcs-slave.led[5].id} |
| | | # 条码扫描仪1 |
| | | barcode[0]: |
| | | id: 1 |
| | |
| | | led[4]: |
| | | id: 5 |
| | | ip: 10.10.10.110 |
| | | # ip: 172.17.20.183 |
| | | port: 5005 |
| | | devpPlcId: ${wcs-slave.devp[1].id} |
| | | staArr: 311 |
| | |
| | | led[5]: |
| | | id: 6 |
| | | ip: 10.10.10.111 |
| | | # ip: 172.17.20.182 |
| | | port: 5005 |
| | | devpPlcId: ${wcs-slave.devp[1].id} |
| | | staArr: 314 |