src/main/java/com/zy/asrs/controller/LocMastController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/model/command/CrnCommand.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/thread/SiemensCrnThread.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/zy/asrs/controller/LocMastController.java
@@ -163,13 +163,13 @@ String locNo = String.format("%02d", r) + String.format("%03d", b) + String.format("%02d", l); // 获取堆垛机号 int crnNo = 0; Shelves shelves = new Shelves(param.getEndRow() - param.getStartRow() + 1, param.getCrnAmount()); for (List<Integer> node : shelves.nodes){ if (node.contains(r)) { crnNo = shelves.nodes.indexOf(node) + 1; break; } } // Shelves shelves = new Shelves(param.getEndRow() - param.getStartRow() + 1, param.getCrnAmount()); // for (List<Integer> node : shelves.nodes){ // if (node.contains(r)) { // crnNo = shelves.nodes.indexOf(node) + 1; // break; // } // } Date now = new Date(); LocMast locMast = new LocMast(); locMast.setLocNo(locNo); src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.common.Cools; import com.core.common.R; import com.core.exception.CoolException; import com.fasterxml.jackson.databind.ObjectMapper; import com.zy.asrs.domain.enums.TaskStatusType; import com.zy.asrs.entity.*; import com.zy.asrs.entity.param.WMSAndAGVInterfaceParam; @@ -23,6 +25,7 @@ import com.zy.core.model.CrnSlave; import com.zy.core.model.DevpSlave; import com.zy.core.model.Task; import com.zy.core.model.command.CommandPackage; import com.zy.core.model.command.CrnCommand; import com.zy.core.model.protocol.CrnProtocol; import com.zy.core.model.protocol.StaProtocol; @@ -39,8 +42,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.IOException; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 立体仓库WCS系统主流程业务 @@ -77,6 +83,9 @@ private StaDescMapper staDescMapper; @Autowired private CommandInfoService commandInfoService; @Autowired private OpenServiceImpl openServiceImpl; @Value("${wms.url}") private String wmsUrl; @@ -157,7 +166,29 @@ } String barcode = barcodeThread.getBarcode(); if(!Cools.isEmpty(barcode)) { // ToWmsDTO toWmsDTO = new ToWmsDTO(); // Map<String, Object> map = new HashMap<>(); // map.put("x-api-key","7a15b5db-29b6-552c-8cff-0cfec3756da2"); // List<Integer> list = openServiceImpl.getInEnableRoadway(); // // //TaskWrk taskWrk = taskWrkService.selectByTaskNo(param.getTaskNo()); // toWmsDTO.setWarehouseId("1688469798893297665"); // toWmsDTO.setContainerCode(param.getContainerCode()); // toWmsDTO.setApplyType("TUNNEL"); // toWmsDTO.setWharfSource(null); // toWmsDTO.setCanInboundTunnels(list); // String response = null; // try { // response = new HttpHandler.Builder() // .setHeaders(map) // .setUri(wmsUrl) // .setPath("wcsManager/wcsInterface/inboundTaskApply") // .setJson(JSON.toJSONString(toWmsDTO)) // .build() // .doPost(); // }catch (Exception e){ // // } } } @@ -211,9 +242,14 @@ if (commandInfos.isEmpty()) { continue;//命令空 } // CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//取出命令报文 // CrnCommand crnCommand = JSON.parseObject(commandPackage.getCommand().toString(), CrnCommand.class); Integer commandStep = taskWrk.getCommandStep(); CommandInfo commandInfo = commandInfos.get(commandStep); StaProtocol staProtocol1 = JSON.parseObject(commandInfo.getCommand(), StaProtocol.class); CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//取出命令报文 //StaProtocol staProtocol1 = JSON.parseObject(commandInfo.getCommand(), StaProtocol.class); StaProtocol staProtocol1 = JSON.parseObject(commandPackage.getCommand().toString(), StaProtocol.class); if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol1))) { log.error("输送线命令下方失败!!! [工作号:{}]", taskWrk.getWrkNo()); continue;//命令下发失败 @@ -234,7 +270,7 @@ /** * 入出库 ===>> 堆垛机入出库作业下发 */ public synchronized void crnIoExecute(){ public synchronized void crnIoExecute() throws IOException { for (CrnSlave crn : slaveProperties.getCrn()) { // 获取堆垛机信息 CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); @@ -279,7 +315,7 @@ /** * 入库 ===>> 堆垛机站到库位 */ public void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol){ public void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol) throws IOException { for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) { List<StaDesc> staDescs = staDescMapper.selectList(new EntityWrapper<StaDesc>().eq("crn_no", slave.getId()).eq("crn_stn", crnStn.getStaNo())); for (StaDesc staDesc : staDescs) { @@ -328,7 +364,8 @@ continue;//命令空 } CommandInfo commandInfo = commandInfos.get(commandStep); CrnCommand crnCommand = JSON.parseObject(commandInfo.getCommand(), CrnCommand.class);//取出命令报文 CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//取出命令报文 CrnCommand crnCommand = JSON.parseObject(commandPackage.getCommand().toString(), CrnCommand.class); if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); @@ -468,7 +505,8 @@ continue;//命令空 } CommandInfo commandInfo = commandInfos.get(commandStep); CrnCommand crnCommand = JSON.parseObject(commandInfo.getCommand(), CrnCommand.class);//取出命令报文 CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//取出命令报文 CrnCommand crnCommand = JSON.parseObject(commandPackage.getCommand().toString(), CrnCommand.class); if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); src/main/java/com/zy/core/model/command/CrnCommand.java
@@ -1,7 +1,6 @@ package com.zy.core.model.command; import com.alibaba.fastjson.annotation.JSONField; import com.zy.asrs.entity.CommandInfo; import com.zy.core.enums.CrnTaskModeType; import lombok.Data; src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Optional; /** * 堆垛机线程 @@ -76,7 +77,7 @@ break; // 写入数据 case 2: write((CrnCommand) task.getData()); write2((CrnCommand) task.getData()); break; // 复位 case 3: @@ -411,6 +412,93 @@ // }else if (rowFour.contains(command.getSourcePosX())){ // array[4] = (short)4; // }else { array[4] = command.getSourcePosX(); // } array[5] = command.getSourcePosY(); array[6] = command.getDestinationPosZ(); // if (rowOne.contains(command.getDestinationPosX())){ // array[7] = (short)1; // }else if (rowTwo.contains(command.getDestinationPosX())){ // array[7] = (short)2; // }else if (rowThree.contains(command.getDestinationPosX())){ // array[7] = (short)3; // }else if (rowFour.contains(command.getDestinationPosX())){ // array[7] = (short)4; // }else { array[7] = command.getDestinationPosX(); // } array[8] = command.getDestinationPosY(); array[9] = command.getCommand(); // 作业信息 OperateResult result = siemensNet.Write("DB100.0", array); if (command.getAckFinish() != 1) { BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class); BasCrnOpt basCrnOpt = new BasCrnOpt( command.getTaskNo().intValue(), // 任务号 command.getCrnNo(), // 堆垛机[非空] new Date(), // 下发时间 command.getTaskModeType() == null ? null : command.getTaskModeType().toString(), // 模式 command.getSourcePosX().intValue(), // 源排 command.getSourcePosY().intValue(), // 源列 command.getSourcePosZ().intValue(), // 源层 null, // 源站 command.getDestinationPosX().intValue(), // 目标排 command.getDestinationPosY().intValue(), // 目标列 command.getDestinationPosZ().intValue(), // 目标层 null, // 目标站 null, // 响应结果 null, // 修改时间 null // 修改人员 ); bean.insert(basCrnOpt); } if (result.IsSuccess) { log.warn("堆垛机命令下发[id:{},时间:{}] >>>>> {}", slave.getId(), DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmsssss_F), JSON.toJSON(command)); OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); return true; } else { OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [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("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); return false; } } /** * 写入数据 */ private boolean write2(CrnCommand command){ if (null == command) { log.error("堆垛机写入命令为空"); return false; } if (command.getTaskNo() == 0 && command.getAckFinish() == 0 && command.getAuto() != 1) { command.setTaskNo((short) 9999); } command.setCrnNo(slave.getId()); short[] array = new short[10]; if (Cools.isEmpty(command.getAckFinish())) { array[0] = 5; } else { array[0] = command.getAckFinish(); } array[1] = command.getTaskNo(); array[2] = command.getTaskMode(); array[3] = command.getSourcePosZ(); // if (rowOne.contains(command.getSourcePosX())){ // array[4] = (short)1; // }else if (rowTwo.contains(command.getSourcePosX())){ // array[4] = (short)2; // }else if (rowThree.contains(command.getSourcePosX())){ // array[4] = (short)3; // }else if (rowFour.contains(command.getSourcePosX())){ // array[4] = (short)4; // }else { array[4] = command.getSourcePosX(); // } array[5] = command.getSourcePosY(); @@ -453,7 +541,7 @@ command.getTaskNo().intValue(), // 任务号 command.getCrnNo(), // 堆垛机[非空] new Date(), // 下发时间 command.getTaskModeType().toString(), // 模式 command.getTaskModeType() == null ? null : command.getTaskModeType().toString(), // 模式 command.getSourcePosX().intValue(), // 源排 command.getSourcePosY().intValue(), // 源列 command.getSourcePosZ().intValue(), // 源层