src/main/java/com/zy/asrs/entity/BasDevp.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/model/protocol/StaProtocol.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/thread/MelsecCrnThread.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/thread/SiemensDevpThread.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/application.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/zy/asrs/entity/BasDevp.java
@@ -129,7 +129,7 @@ @ApiModelProperty(value= "条形码") private String barcode; @ApiModelProperty(value= "") @ApiModelProperty(value= "入库暂存数") @TableField("in_qty") private Integer inQty; src/main/java/com/zy/core/model/protocol/StaProtocol.java
@@ -49,6 +49,8 @@ // 锁定标记 private boolean pakMk = true; // 入库暂存数 private Short inQty; public BasDevp toSqlModel(){ BasDevp basDevp = new BasDevp(); @@ -62,6 +64,7 @@ basDevp.setLocType2((short) 0); // 宽窄类型{0:未知,1:窄库位,2:宽库位} basDevp.setLocType3((short) 0); // 轻重类型{0:未知,1:轻库位,2:重库位} basDevp.setLocType1(high != low && low ? (short) 1 : (short) 2); basDevp.setInQty(inQty !=null ?(int)inQty : 0); return basDevp; } src/main/java/com/zy/core/thread/MelsecCrnThread.java
@@ -229,29 +229,73 @@ log.error("堆垛机写入命令为空"); return false; } command.setCrnNo(slave.getId()); short[] array = new short[10]; array[0] = command.getAckFinish(); array[1] = command.getTaskNo(); array[2] = command.getTaskMode(); array[3] = command.getSourcePosX(); array[4] = command.getSourcePosY(); array[5] = command.getSourcePosZ(); array[6] = command.getDestinationPosX(); array[7] = command.getDestinationPosY(); array[8] = command.getDestinationPosZ(); array[9] = command.getCommand(); OperateResult result = melsecMcNet.Write("D0", array); try { Thread.sleep(200); OperateResult result = null; try{ Integer exeCount=0; do{ command.setCrnNo(slave.getId()); short[] array = new short[10]; array[0] = command.getAckFinish(); array[1] = command.getTaskNo(); array[2] = command.getTaskMode(); array[3] = command.getSourcePosX(); array[4] = command.getSourcePosY(); array[5] = command.getSourcePosZ(); array[6] = command.getDestinationPosX(); array[7] = command.getDestinationPosY(); array[8] = command.getDestinationPosZ(); array[9] = command.getCommand(); result = melsecMcNet.Write("D0", array); if(result.IsSuccess) { if (command.getAckFinish() == 0) { short commandFinish = 1; result = melsecMcNet.Write("D9", commandFinish); if(result.IsSuccess){ //写任务确认返回成功后,查询确认一次 Thread.sleep(200); OperateResultExOne<byte[]> result1 = melsecMcNet.Read("D9", (short)2); if(result1.IsSuccess){ short commandVal = melsecMcNet.getByteTransform().TransInt16(result1.Content,2); if(commandVal==1){ break; } else { exeCount++; } } else{ exeCount++; } }else{ exeCount++; } } }else{ exeCount++; } Thread.sleep(200); }while(exeCount>3); }catch (Exception e){ } if (command.getAckFinish() == 0) { short commandFinish = 1; result = melsecMcNet.Write("D9", commandFinish); } // command.setCrnNo(slave.getId()); // short[] array = new short[10]; // array[0] = command.getAckFinish(); // array[1] = command.getTaskNo(); // array[2] = command.getTaskMode(); // array[3] = command.getSourcePosX(); // array[4] = command.getSourcePosY(); // array[5] = command.getSourcePosZ(); // array[6] = command.getDestinationPosX(); // array[7] = command.getDestinationPosY(); // array[8] = command.getDestinationPosZ(); // array[9] = command.getCommand(); // OperateResult result = melsecMcNet.Write("D0", array); // // if (command.getAckFinish() == 0) { // short commandFinish = 1; // result = melsecMcNet.Write("D9", commandFinish); // } try { // 日志记录 @@ -276,7 +320,7 @@ bean.insert(basCrnOpt); } catch (Exception ignore) {} if (result.IsSuccess) { if (result != null && result.IsSuccess) { log.info("堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command)); OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); return true; src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -118,7 +118,7 @@ // updateIoMode(); OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) 186); if (result.IsSuccess) { for (int i = 0; i < 83; i++) { for (int i = 0; i < 93; i++) { Integer siteId = staNos.get(i); // 站点编号 StaProtocol staProtocol = station.get(siteId); if (null == staProtocol) { @@ -132,7 +132,7 @@ Thread.sleep(200); OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 186); if (result0.IsSuccess) { for (int i = 0; i < 83; i++) { for (int i = 0; i < 93; i++) { Integer siteId = staNos.get(i); // 站点编号 StaProtocol staProtocol = station.get(siteId); if (null == staProtocol) { @@ -146,7 +146,7 @@ Thread.sleep(200); OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB102.0", (short) 186); if (result1.IsSuccess) { for (int i = 0; i < 83; i++) { for (int i = 0; i < 93; i++) { Integer siteId = staNos.get(i); // 站点编号 boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 1); StaProtocol staProtocol = station.get(siteId); @@ -162,6 +162,41 @@ if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { staProtocol.setPakMk(true); } } } Thread.sleep(200); OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB300.0", (short) 10); if (result3.IsSuccess) { // Integer siteId = staNos.get(i); // 站点编号 Integer siteId = 0; for (int i = 0; i < 5; i++) { switch (i){ case 0: siteId = 100; break; case 1: siteId = 102; break; case 2: siteId = 104; break; case 3: siteId = 106; break; case 4: siteId = 108; break; } StaProtocol staProtocol = station.get(siteId); if (null == staProtocol) { staProtocol = new StaProtocol(); staProtocol.setSiteId(siteId); station.put(siteId, staProtocol); } short value = siemensS7Net.getByteTransform().TransInt16(result3.Content, i*2); staProtocol.setInQty(value); // 入库暂存数 String str=""; } } @@ -181,11 +216,13 @@ StaProtocol staProtocol = station.get(siteId); basDevps.add(staProtocol.toSqlModel()); } BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class); if (!basDevpService.updateBatchById(basDevps)) { 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())); log.error("更新数据库数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); } src/main/resources/application.yml
@@ -11,8 +11,8 @@ # url: jdbc:sqlserver://47.97.1.152:51433;databasename=xgmasrs # username: sa # password: Zoneyung@zy56$ # url: jdbc:sqlserver://10.10.10.238:1433;databasename=xgmasrs url: jdbc:sqlserver://localhost:1433;databasename=xgmasrs url: jdbc:sqlserver://10.10.10.238:1433;databasename=xgmasrs # url: jdbc:sqlserver://localhost:1433;databasename=xgmasrs username: sa password: sa@123 mvc: