| | |
| | | Date now = new Date(); |
| | | taskWrk.setStatus(TaskStatusType.COMPLETE.id); |
| | | taskWrk.setModiTime(now);//操作时间 |
| | | taskWrk.setModiUser(getUserId());//操作员 |
| | | try{ |
| | | taskWrk.setModiUser(getUserId());//操作员 |
| | | }catch (Exception e){ |
| | | taskWrk.setModiUser(9999L);//操作员 |
| | | } |
| | | taskWrk.setCompleteTime(now);//完结时间 |
| | | taskWrkService.updateById(taskWrk); |
| | | return R.ok(); |
| | |
| | | commandInfo.setStartTime(new Date()); |
| | | commandInfo.setDevice(SlaveType.Crn.toString()); |
| | | |
| | | commandPackage.setWrkNo(wrkNo); |
| | | commandPackage.setCommand(command); |
| | | commandPackage.setDevice("堆垛机"); |
| | | |
| | | commandInfo.setCommand(JSON.toJSONString(commandPackage)); |
| | | commandInfoService.insert(commandInfo);//插入指令 |
| | | |
| | | command.setCommandId(commandInfo.getId()); |
| | | commandPackage.setWrkNo(wrkNo); |
| | | commandPackage.setDevice("堆垛机"); |
| | | commandPackage.setCommand(command);//保存命令报文 |
| | | commandInfo.setCommand(JSON.toJSONString(commandPackage)); |
| | | commandInfoService.updateById(commandInfo); |
| | | |
| | | //将指令进行投递 |
| | | if (!MessageQueue.offer(type, id, task)) { |
| | |
| | | commandInfo.setStartTime(new Date()); |
| | | commandInfo.setDevice(SlaveType.Devp.toString()); |
| | | |
| | | commandPackage.setWrkNo(wrkNo); |
| | | commandPackage.setCommand(staProtocol); |
| | | commandPackage.setDevice("输送线"); |
| | | |
| | | commandInfo.setCommand(JSON.toJSONString(commandPackage)); |
| | | commandInfoService.insert(commandInfo);//插入指令 |
| | | |
| | | staProtocol.setCommandId(commandInfo.getId()); |
| | | commandPackage.setCommand(staProtocol); |
| | | commandPackage.setWrkNo(wrkNo); |
| | | commandPackage.setDevice("输送线"); |
| | | commandInfo.setCommand(JSON.toJSONString(commandPackage));//保存命令报文 |
| | | commandInfoService.updateById(commandInfo); |
| | | |
| | | //将指令进行投递 |
| | | if (!MessageQueue.offer(type, id, task)) { |
| | | return false; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 通过库位号获取 列 |
| | | */ |
| | | public static int getBay(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | return Integer.parseInt(locNo.substring(2, 5)); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | |
| | | /** |
| | | * 通过库位号获取 层 |
| | | */ |
| | | public static int getLev(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | return Integer.parseInt(locNo.substring(5, 7)); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | |
| | | /** |
| | | * 当检索到双深库位的浅库位时,如果深库位无货,则放入对应的深库位 |
| | | */ |
| | | public static void toDeepIfEmptyByShallow(String shallowLoc) { |
| | |
| | | // 任务确认 0:未确认 1:已确认 |
| | | private Short command = 0; |
| | | |
| | | //指令ID |
| | | private Integer commandId; |
| | | |
| | | public void setTaskMode(Short taskMode){ |
| | | this.taskMode = taskMode; |
| | | this.taskModeType = CrnTaskModeType.get(taskModeType); |
| | |
| | | // 隔壁站点(台车位置) |
| | | private String nearbySta; |
| | | |
| | | //指令ID |
| | | private Integer commandId; |
| | | |
| | | public BasDevp toSqlModel(){ |
| | | BasDevp basDevp = new BasDevp(); |
| | | basDevp.setDevNo(siteId); |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.BasCrnOpt; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.CommandInfo; |
| | | import com.zy.asrs.entity.TaskWrk; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.core.CrnThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | |
| | | } |
| | | } catch (Exception ignore) {} |
| | | |
| | | //更新命令日志 |
| | | CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class); |
| | | CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); |
| | | CommandInfo commandInfo = commandInfoService.selectById(command.getCommandId()); |
| | | CommandInfoLog commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); |
| | | commandInfoLog.setId(null); |
| | | |
| | | if (result.IsSuccess && result1.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))); |
| | | |
| | | //更新指令日志 |
| | | commandInfoLog.setDeviceLog("指令下发成功"); |
| | | commandInfoLogService.insert(commandInfoLog); |
| | | |
| | | //更新任务步序 |
| | | TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class); |
| | |
| | | } 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()); |
| | | |
| | | //更新指令日志 |
| | | commandInfoLog.setDeviceLog("指令下发失败"); |
| | | commandInfoLogService.insert(commandInfoLog); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.CommandInfo; |
| | | import com.zy.asrs.entity.CommandInfoLog; |
| | | import com.zy.asrs.entity.TaskWrk; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.CommandInfoService; |
| | | import com.zy.asrs.service.DeviceErrorService; |
| | | import com.zy.asrs.service.TaskWrkService; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | |
| | | array[1] = staProtocol.getStaNo(); |
| | | // OperateResult write = siemensS7Net.Write("DB100." + index*4, array); |
| | | |
| | | //更新命令日志 |
| | | CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class); |
| | | CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); |
| | | CommandInfo commandInfo = commandInfoService.selectById(staProtocol.getCommandId()); |
| | | CommandInfoLog commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); |
| | | commandInfoLog.setId(null); |
| | | |
| | | OperateResult writeResult; |
| | | //任务下发次数 |
| | | int writeCount = 0; |
| | |
| | | boolean writeFlag = false; |
| | | while(writeCount < 5){ |
| | | writeResult = siemensS7Net.Write("DB100." + index*4, array); // 工作号、目标站 |
| | | //更新指令日志 |
| | | commandInfoLog.setDeviceLog("指令下发成功"); |
| | | commandInfoLogService.insert(commandInfoLog); |
| | | |
| | | if(writeResult.IsSuccess){ |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> readResult = siemensS7Net.Read("DB100." + index*4, (short)4); |
| | |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线命令后读取失败。输送线plc编号={1},站点数据={2},写入次数={3}", |
| | | slave.getId(), JSON.toJSON(staProtocol), writeCount)); |
| | | log.error("写入输送线命令后读取失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | |
| | | //更新指令日志 |
| | | commandInfoLog.setDeviceLog("指令下发失败"); |
| | | commandInfoLogService.insert(commandInfoLog); |
| | | } |
| | | } else { |
| | | writeCount++; |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线命令失败。输送线plc编号={1},站点数据={2},写入次数={3}", |
| | | slave.getId(), JSON.toJSON(staProtocol),writeCount)); |
| | | log.error("写入输送线命令失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | |
| | | //更新指令日志 |
| | | commandInfoLog.setDeviceLog("指令下发失败"); |
| | | commandInfoLogService.insert(commandInfoLog); |
| | | } |
| | | Thread.sleep(200); |
| | | } |
| | |
| | | } |
| | | return ''; |
| | | }, |
| | | handleCommand(command, row) { |
| | | switch (command) { |
| | | case "showTask": |
| | | //查看任务 |
| | | this.showTask(row) |
| | | break; |
| | | case "executeCommand": |
| | | //执行指令 |
| | | this.executeCommand(row) |
| | | break; |
| | | case "completeCommand": |
| | | //完成指令 |
| | | this.completeWrk(row) |
| | | break; |
| | | } |
| | | }, |
| | | showTask(row) { |
| | | let wrkNo = row.wrkNo == null ? "" : row.wrkNo |
| | | console.log(wrkNo) |
| | | //查看指令 |
| | | $layui.layer.open({ |
| | | type: 2, |
| | | title: '任务管理', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: true, |
| | | content: '../taskWrk/taskWrk.html?taskNo=' + row.taskNo + "&wrkNo=" + wrkNo, |
| | | success: function(layero, index) {} |
| | | }); |
| | | }, |
| | | executeCommand(row) { |
| | | //执行指令 |
| | | let that = this |
| | | $.ajax({ |
| | | url: baseUrl + "/commandInfo/executeCommand", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: { |
| | | id: row.id |
| | | }, |
| | | method: 'POST', |
| | | success: function(res) { |
| | | if (res.code == 200) { |
| | | that.$message({ |
| | | message: "执行成功", |
| | | type: 'success' |
| | | }); |
| | | that.getTableData() |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | completeCommand(row) { |
| | | //完成指令 |
| | | let that = this |
| | | $.ajax({ |
| | | url: baseUrl + "/commandInfo/completeCommand", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: { |
| | | id: row.id |
| | | }, |
| | | method: 'POST', |
| | | success: function(res) { |
| | | if (res.code == 200) { |
| | | that.$message({ |
| | | message: "完成成功", |
| | | type: 'success' |
| | | }); |
| | | that.getTableData() |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | } |
| | | }) |
| | | </script> |
| | |
| | | data.curr = this.currentPage |
| | | data.limit = this.pageSize |
| | | $.ajax({ |
| | | url: baseUrl + "/commandInfo/list/auth", |
| | | url: baseUrl + "/commandInfoLog/list/auth", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | |
| | | </div> |
| | | </div> |
| | | <div class="bar-code"> |
| | | <div class="body-head" id="code">磅秤</div> |
| | | <div class="body-head" id="code">条码扫描器</div> |
| | | <div class="tablebox"> |
| | | <div class="table-head"> |
| | | <li><span>磅秤编号-磅秤重量</span><span class="right">称重时间</span></li> |
| | | <li><span>条码名称</span><span class="right">扫码时间</span></li> |
| | | </div> |
| | | <div id="scale1" class="table-body"> |
| | | <div id="barcode1" class="table-body"> |
| | | |
| | | </div> |
| | | </div> |
| | | <div class="tablebox"> |
| | | <div class="table-head"> |
| | | <li><span>磅秤编号-磅秤重量</span><span class="right">称重时间</span></li> |
| | | <li><span>条码名称</span><span class="right">扫码时间</span></li> |
| | | </div> |
| | | <div id="scale2" class="table-body"> |
| | | <div id="barcode2" class="table-body"> |
| | | |
| | | </div> |
| | | </div> |
| | | <div class="tablebox"> |
| | | <div class="table-head"> |
| | | <li><span>磅秤编号-磅秤重量</span><span class="right">称重时间</span></li> |
| | | <li><span>条码名称</span><span class="right">扫码时间</span></li> |
| | | </div> |
| | | <div id="scale3" class="table-body"> |
| | | <div id="barcode3" class="table-body"> |
| | | |
| | | </div> |
| | | </div> |
| | |
| | | </div> |
| | | </div> |
| | | <div class="bar-code"> |
| | | <div class="body-head" id="code">磅秤</div> |
| | | <div class="body-head" id="code">条码扫描器</div> |
| | | <div class="tablebox"> |
| | | <div class="table-head"> |
| | | <li><span>磅秤编号-磅秤重量</span><span class="right">称重时间</span></li> |
| | | <li><span>条码名称</span><span class="right">扫码时间</span></li> |
| | | </div> |
| | | <div id="scale1" class="table-body"> |
| | | <div id="barcode1" class="table-body"> |
| | | |
| | | </div> |
| | | </div> |
| | | <div class="tablebox"> |
| | | <div class="table-head"> |
| | | <li><span>磅秤编号-磅秤重量</span><span class="right">称重时间</span></li> |
| | | <li><span>条码名称</span><span class="right">扫码时间</span></li> |
| | | </div> |
| | | <div id="scale2" class="table-body"> |
| | | <div id="barcode2" class="table-body"> |
| | | |
| | | </div> |
| | | </div> |
| | | <div class="tablebox"> |
| | | <div class="table-head"> |
| | | <li><span>磅秤编号-磅秤重量</span><span class="right">称重时间</span></li> |
| | | <li><span>条码名称</span><span class="right">扫码时间</span></li> |
| | | </div> |
| | | <div id="scale3" class="table-body"> |
| | | <div id="barcode3" class="table-body"> |
| | | |
| | | </div> |
| | | </div> |