package com.zy.asrs.service.impl;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.core.common.Cools;
|
import com.core.exception.CoolException;
|
import com.zy.asrs.entity.*;
|
import com.zy.asrs.mapper.BasCrnErrorMapper;
|
import com.zy.asrs.mapper.WrkMastMapper;
|
import com.zy.asrs.service.*;
|
import com.zy.asrs.utils.Utils;
|
import com.zy.common.model.LocTypeDto;
|
import com.zy.common.model.MatDto;
|
import com.zy.common.model.SearchLocParam;
|
import com.zy.common.model.StartupDto;
|
import com.zy.common.utils.CollectionUtils;
|
import com.zy.common.utils.HttpHandler;
|
import com.zy.core.CrnThread;
|
import com.zy.core.DevpThread;
|
import com.zy.core.cache.MessageQueue;
|
import com.zy.core.cache.SlaveConnection;
|
import com.zy.core.enums.*;
|
import com.zy.core.model.*;
|
import com.zy.core.model.command.CrnCommand;
|
import com.zy.core.model.command.LedCommand;
|
import com.zy.core.model.command.SteCommand;
|
import com.zy.core.model.protocol.CrnProtocol;
|
import com.zy.core.model.protocol.StaProtocol;
|
import com.zy.core.model.protocol.SteProtocol;
|
import com.zy.core.properties.SlaveProperties;
|
import com.zy.core.thread.BarcodeThread;
|
import com.zy.core.thread.LedThread;
|
import com.zy.core.thread.SteThread;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Set;
|
import java.util.stream.Collectors;
|
|
/**
|
* 立体仓库WCS系统主流程业务
|
* Created by vincent on 2020/8/6
|
*/
|
@Slf4j
|
@Service("mainService")
|
@Transactional
|
public class MainServiceImpl {
|
|
@Value("${wms.url}")
|
private String wmsUrl;
|
@Autowired
|
private SlaveProperties slaveProperties;
|
@Autowired
|
private WrkMastMapper wrkMastMapper;
|
@Autowired
|
private WrkDetlService wrkDetlService;
|
@Autowired
|
private LocMastService locMastService;
|
@Autowired
|
private StaDescService staDescService;
|
@Autowired
|
private BasCrnpService basCrnpService;
|
@Autowired
|
private BasDevpService basDevpService;
|
@Autowired
|
private BasErrLogService basErrLogService;
|
@Autowired
|
private BasCrnErrorMapper basCrnErrorMapper;
|
@Autowired
|
private BasSteService basSteService;
|
|
/**
|
* 组托
|
* 入库站,根据条码扫描生成入库工作档,工作状态 2
|
*/
|
@Async
|
public void generateStoreWrkFile() {
|
// 根据输送线plc遍历
|
for (DevpSlave devp : slaveProperties.getDevp()) {
|
// 遍历入库口
|
for (DevpSlave.Sta inSta : devp.getInSta()) {
|
// 获取入库站信息
|
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
|
StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
|
if (staProtocol == null) {
|
continue;
|
} else {
|
staProtocol = staProtocol.clone();
|
}
|
Short workNo = staProtocol.getWorkNo();
|
// 判断是否满足入库条件
|
if (staProtocol.isAutoing() && staProtocol.isLoading()
|
&& staProtocol.isInEnable()
|
&& !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999))
|
&& staProtocol.isPakMk()) {
|
|
// 获取条码扫描仪信息
|
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
|
if (barcodeThread == null) {
|
continue;
|
}
|
String barcode = barcodeThread.getBarcode();
|
if(!Cools.isEmpty(barcode)) {
|
log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
|
if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
|
continue;
|
}
|
} else {
|
continue;
|
}
|
|
// 判断重复工作档
|
WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
|
if (wrkMast != null) {
|
log.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
|
continue;
|
}
|
|
try {
|
LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
|
SearchLocParam param = new SearchLocParam();
|
param.setBarcode(barcode);
|
param.setIoType(1);
|
param.setSourceStaNo(inSta.getStaNo());
|
param.setLocType1(locTypeDto.getLocType1());
|
String response = new HttpHandler.Builder()
|
.setUri(wmsUrl)
|
.setPath("/rpc/pakin/loc/v1")
|
.setJson(JSON.toJSONString(param))
|
.build()
|
.doPost();
|
JSONObject jsonObject = JSON.parseObject(response);
|
if (jsonObject.getInteger("code").equals(200)) {
|
StartupDto dto = jsonObject.getObject("data", StartupDto.class);
|
// plc 处理
|
barcodeThread.setBarcode("");
|
staProtocol.setWorkNo(dto.getWorkNo().shortValue());
|
staProtocol.setStaNo(dto.getStaNo().shortValue());
|
devpThread.setPakMk(staProtocol.getSiteId(), false);
|
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
|
if (!result) {
|
throw new CoolException("更新plc站点信息失败");
|
}
|
} else {
|
log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
}
|
}
|
}
|
}
|
}
|
|
/**
|
* wms入库
|
* 入库站,根据条码扫描生成入库工作档,工作状态 1 ==>> 2
|
*/
|
@Async
|
public void generateStoreWrkFile0() {
|
// 根据输送线plc遍历
|
for (DevpSlave devp : slaveProperties.getDevp()) {
|
// 遍历入库口
|
for (DevpSlave.Sta inSta : devp.getInSta()) {
|
// 获取入库站信息
|
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
|
StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
|
if (staProtocol == null) {
|
continue;
|
} else {
|
staProtocol = staProtocol.clone();
|
}
|
Short workNo = staProtocol.getWorkNo();
|
// 判断是否满足入库条件
|
if (staProtocol.isAutoing() && staProtocol.isLoading()
|
&& staProtocol.isInEnable()
|
&& !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999))
|
&& staProtocol.isPakMk()) {
|
// 判断重复工作档
|
WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo());
|
if (wrkMast == null) { continue; }
|
|
// 命令下发区 --------------------------------------------------------------------------
|
|
// 更新站点信息 且 下发plc命令
|
staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
|
staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
|
devpThread.setPakMk(staProtocol.getSiteId(), false);
|
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
|
if (result) {
|
// 更新工作主档
|
wrkMast.setWrkSts(2L); // 工作状态:2.设备上走
|
wrkMast.setModiTime(new Date());
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("更新工作档失败!!! [工作号:{}]", wrkMast.getWrkNo());
|
}
|
} else {
|
log.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
|
}
|
}
|
}
|
}
|
}
|
|
/**
|
* 拣料、并板、盘点再入库
|
*/
|
public synchronized void stnToCrnStnPick(){
|
for (DevpSlave devp : slaveProperties.getDevp()) {
|
// 遍历拣料入库口
|
for (DevpSlave.Sta pickSta : devp.getPickSta()) {
|
|
// 获取拣料入库站信息
|
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
|
StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo());
|
if (staProtocol == null) {
|
continue;
|
} else {
|
staProtocol = staProtocol.clone();
|
}
|
if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()){
|
|
// 获取条码扫描仪信息
|
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
|
if (barcodeThread == null) {
|
continue;
|
}
|
String barcode = barcodeThread.getBarcode();
|
if(!Cools.isEmpty(barcode)) {
|
log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
|
if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
|
continue;
|
}
|
} else {
|
continue;
|
}
|
|
WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
|
if (wrkMast == null) {
|
// 无拣料数据
|
continue;
|
}
|
if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107)
|
|| Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) {
|
continue;
|
}
|
|
// 获取目标站
|
Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
|
.eq("type_no", wrkMast.getIoType() - 50)
|
.eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站
|
.eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号
|
StaDesc staDesc = staDescService.selectOne(wrapper);
|
if (Cools.isEmpty(staDesc)) {
|
log.error("入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
|
continue;
|
}
|
|
try {
|
// 保存工作明细档历史档
|
if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) {
|
throw new CoolException("保存工作明细档历史档失败");
|
}
|
// 保存工作主档历史档
|
if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
|
throw new CoolException("保存工作主档历史档失败");
|
}
|
|
// 堆垛机站点(目标站)
|
Integer staNo = staDesc.getCrnStn();
|
// 更新工作档数据状态
|
wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57
|
wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走
|
wrkMast.setSourceStaNo(wrkMast.getStaNo()); // 源站
|
wrkMast.setStaNo(staNo); // 目标站
|
wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 目标库位 = 出库时的源库位
|
wrkMast.setSourceLocNo(""); // 源库位清空
|
wrkMast.setModiTime(new Date());
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
throw new CoolException("更新工作档数据状态失败");
|
}
|
// 修改库位状态 Q.拣料/盘点/并板再入库
|
LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
|
locMast.setLocSts("Q");
|
locMast.setModiTime(new Date());
|
if (!locMastService.updateById(locMast)) {
|
throw new CoolException("修改库位状态失败");
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
continue;
|
}
|
|
// 更新站点信息 且 下发plc命令
|
staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
|
staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
|
devpThread.setPakMk(staProtocol.getSiteId(), false);
|
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
|
if (!result) {
|
log.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
|
}
|
|
}
|
|
}
|
|
}
|
}
|
|
/**
|
* 堆垛机站出库到出库站
|
*/
|
@Async
|
public void crnStnToOutStn() {
|
for (CrnSlave crnSlave : slaveProperties.getCrn()) {
|
// 遍历堆垛机出库站
|
for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) {
|
// 获取堆垛机出库站信息
|
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
|
StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
|
if (staProtocol == null) {
|
continue;
|
} else {
|
staProtocol = staProtocol.clone();
|
}
|
if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
|
// 查询工作档
|
WrkMast wrkMast = wrkMastMapper.selectPakOutStep16(staProtocol.getSiteId());
|
if (wrkMast == null) {
|
continue;
|
}
|
// 判断工作档条件
|
if (wrkMast.getIoType() < 100 || wrkMast.getStaNo() == null || wrkMast.getSourceStaNo() == null) {
|
continue;
|
}
|
// 判断吊车是否实际已完成,且电脑状态在move中,以备电脑进行更新工作档
|
CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, wrkMast.getCrnNo());
|
CrnProtocol crnProtocol = crnThread.getCrnProtocol();
|
if (crnProtocol.statusType == CrnStatusType.FETCHING || crnProtocol.statusType == CrnStatusType.PUTTING) {
|
// 移动中
|
continue;
|
}
|
// 判断堆垛机状态等待确认
|
if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue())
|
&& crnProtocol.statusType == CrnStatusType.WAITING
|
&& crnProtocol.forkPosType == CrnForkPosType.HOME) {
|
|
// 命令下发区 --------------------------------------------------------------------------
|
|
// 下发站点信息
|
staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
|
staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
|
if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol))) {
|
continue;
|
}
|
|
// 更新工作档状态为 17.出库完成
|
wrkMast.setWrkSts(17L);
|
wrkMast.setCrnEndTime(new Date());
|
if (wrkMastMapper.updateById(wrkMast) != 0) {
|
// 复位堆垛机
|
crnThread.setResetFlag(true);
|
} else {
|
log.error("更新工作档的工作状态为 17.出库完成 失败!!! [工作号:{}]", wrkMast.getWrkNo());
|
}
|
|
}
|
|
}
|
}
|
}
|
}
|
|
/**
|
* 入出库 ===>> 堆垛机入出库作业下发
|
*/
|
public synchronized void crnIoExecute(){
|
for (CrnSlave crn : slaveProperties.getCrn()) {
|
// 获取堆垛机信息
|
CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
|
CrnProtocol crnProtocol = crnThread.getCrnProtocol();
|
if (crnProtocol == null) { continue; }
|
BasCrnp basCrnp = basCrnpService.selectById(crn.getId());
|
if (basCrnp == null) {
|
log.error("{}号堆垛机尚未在数据库进行维护!", crn.getId());
|
continue;
|
}
|
// 只有当堆垛机空闲 并且 无任务时才继续执行
|
if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) {
|
// 如果最近一次是入库模式
|
if (crnProtocol.getLastIo().equals("I")) {
|
if (basCrnp.getInEnable().equals("Y")) {
|
// 入库
|
if (this.crnStnToLoc(crn, crnProtocol)) {
|
}
|
crnProtocol.setLastIo("O");
|
} else if (basCrnp.getOutEnable().equals("Y")) {
|
// 出库
|
if (this.locToCrnStn(crn, crnProtocol)) {
|
}
|
crnProtocol.setLastIo("I");
|
}
|
}
|
// 如果最近一次是出库模式
|
else if (crnProtocol.getLastIo().equals("O")) {
|
if (basCrnp.getOutEnable().equals("Y")) {
|
// 出库
|
if (this.locToCrnStn(crn, crnProtocol)) {
|
}
|
crnProtocol.setLastIo("I");
|
} else if (basCrnp.getInEnable().equals("Y")) {
|
// 入库
|
if (this.crnStnToLoc(crn, crnProtocol)) {
|
}
|
crnProtocol.setLastIo("O");
|
}
|
}
|
}
|
}
|
}
|
|
/**
|
* 入库 ===>> 堆垛机站到库位
|
*/
|
public boolean crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol){
|
for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) {
|
boolean flag = false;
|
// 获取堆垛机入库站信息
|
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
|
StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
|
if (staProtocol == null) {
|
continue;
|
} else {
|
staProtocol = staProtocol.clone();
|
}
|
// 查询站点详细信息
|
BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
|
if (staDetl == null) {
|
log.error("入库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo());
|
continue;
|
}
|
// 获取工作状态为 2,3,4,5,6 的入库工作档
|
WrkMast wrkMast = wrkMastMapper.selectPakInStep23456(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo());
|
if(null == wrkMast) {
|
log.error("{}站点查询无待入库数据 工作号={}", crnStn.getStaNo(), staProtocol.getWorkNo());
|
continue;
|
}
|
if (wrkMast.getWrkSts() < 3) {
|
if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable()
|
&& staDetl.getCanining()!=null && staDetl.getCanining().equals("Y")) {
|
flag = true;
|
}
|
if (!flag) {
|
continue;
|
}
|
}
|
// 获取库位信息
|
LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
|
if (locMast == null) {
|
log.error("查询库存无数据--库位号{}", wrkMast.getLocNo());
|
continue;
|
}
|
if (!locMast.getLocSts().equals("S") && !locMast.getLocSts().equals("Q")) {
|
log.error("入库操作库位状态不符合--状态, 库位号={},库位状态={}", wrkMast.getLocNo(), locMast.getLocSts());
|
continue;
|
}
|
|
// 目标库位 ===>> 最外层库位
|
if (locMastService.isOutMost(wrkMast.getLocNo())) {
|
// 判断小车是否在最外层库位,如果是则搬走,如果不是,则直接堆垛机入库
|
Integer steNo = this.hasCarOfIdle(wrkMast.getLocNo());
|
// 有小车
|
if (steNo != null) {
|
// 小车行走到堆垛机待搬移点
|
if (wrkMast.getWrkSts() == 2L && wrkMast.getSteNo() == null) {
|
this.letCarBeReady(wrkMast, steNo, wrkMast.getLocNo());
|
}
|
// 小车搬走
|
if (wrkMast.getWrkSts() == 3L) {
|
this.carMoveOut(wrkMast, steNo, crnProtocol);
|
}
|
// 没有小车
|
} else {
|
|
// 当前入库库位组没有小车 堆垛机则去站点取货入库
|
// case 1:从始至终库位组都没有小车,没有迁出小车动作,所以工作状态 = 2
|
// case 2:堆垛机已经搬出小车,有迁出小车动作,所以工作状态 = 6
|
if (wrkMast.getWrkSts() == 2L || wrkMast.getWrkSts() == 6L) {
|
|
// 已经存在吊车执行任务时,则过滤
|
if (wrkMastMapper.selectWorking(slave.getId()) != null) {
|
continue;
|
}
|
|
// 堆垛机入库 命令下发区 --------------------------------------------------------------------------
|
CrnCommand crnCommand = new CrnCommand();
|
crnCommand.setCrnNo(slave.getId()); // 堆垛机编号
|
crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号
|
crnCommand.setAckFinish((short) 0); // 任务完成确认位
|
crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转
|
crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 源库位排
|
crnCommand.setSourcePosY(crnStn.getBay().shortValue()); // 源库位列
|
crnCommand.setSourcePosZ(crnStn.getLev().shortValue()); // 源库位层
|
crnCommand.setDestinationPosX(locMast.getRow1().shortValue()); // 目标库位排
|
crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 目标库位列
|
crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 目标库位层
|
if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
|
log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
|
} else {
|
// 修改工作档状态 7.吊车入库中
|
Date now = new Date();
|
wrkMast.setWrkSts(7L);
|
wrkMast.setCrnStrTime(now);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 {} => 7.吊车入库中 失败!!,工作号={}", wrkMast.getWrkSts$(), wrkMast.getWrkNo());
|
}
|
return true;
|
}
|
}
|
|
}
|
|
// 目标库位 ===>> 非最外层库位
|
} else {
|
// 判断小车是否在当前组库位,如果是则将穿梭车移至最外层,等待堆垛机放货;如果不是,则堆垛机寻找穿梭车,并放置当前组最外层
|
Integer steNo = this.hasCarOfIdle(wrkMast.getLocNo());
|
// 有小车
|
if (steNo != null) {
|
// 小车行走到堆垛机待搬移点
|
if (wrkMast.getWrkSts() == 2L && wrkMast.getSteNo() == null) {
|
this.letCarBeWaiting(wrkMast, steNo, wrkMast.getLocNo());
|
}
|
// 堆垛机将货放至小车上 3.小车待搬(小车不用搬运,已经在当前组库位) / 6.小车待入 ===>> 7.吊车入库中
|
if (wrkMast.getWrkSts() == 3L || wrkMast.getWrkSts() == 6L) {
|
// 小车处于空闲
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
|
SteProtocol steProtocol = steThread.getSteProtocol();
|
if (steProtocol == null) { continue; }
|
if (steProtocol.isIdle()) {
|
|
// 已经存在吊车执行任务时,则过滤
|
if (wrkMastMapper.selectWorking(slave.getId()) != null) {
|
continue;
|
}
|
// 堆垛机入库 命令下发区 --------------------------------------------------------------------------
|
CrnCommand crnCommand = new CrnCommand();
|
crnCommand.setCrnNo(slave.getId()); // 堆垛机编号
|
crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号
|
crnCommand.setAckFinish((short) 0); // 任务完成确认位
|
crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转
|
crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 源库位排
|
crnCommand.setSourcePosY(crnStn.getBay().shortValue()); // 源库位列
|
crnCommand.setSourcePosZ(crnStn.getLev().shortValue()); // 源库位层
|
crnCommand.setDestinationPosX(Utils.getGroupRow(locMast.getLocNo()).shortValue()); // 目标库位排
|
crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 目标库位列
|
crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 目标库位层
|
if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
|
log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
|
} else {
|
// 修改工作档状态 3.小车待搬 ===>> 7.吊车入库中
|
Date now = new Date();
|
wrkMast.setWrkSts(7L);
|
wrkMast.setCrnStrTime(now);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 3.小车待搬/6.小车待入 => 7.吊车入库中 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
return true;
|
}
|
}
|
}
|
// 没有小车
|
} else {
|
if (wrkMast.getWrkSts() == 2L && wrkMast.getSteNo() == null) {
|
// 寻找当前堆垛机对应的小车
|
SteThread steThread = queryIdleCar(wrkMast);
|
if (steThread != null) {
|
// 让小车等待搬运待续
|
this.letCarBeReady(wrkMast, steThread.getSlave().getId(), wrkMast.getLocNo());
|
}
|
}
|
// 堆垛机搬运小车
|
if (wrkMast.getWrkSts() == 3L) {
|
this.carMoveIn(wrkMast, wrkMast.getSteNo(), crnProtocol);
|
}
|
}
|
}
|
|
}
|
return false;
|
}
|
|
/**
|
* 出库 ===>> 库位到堆垛机站
|
*/
|
public boolean locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){
|
for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) {
|
// 获取工作状态为11(生成出库ID)的出库工作档
|
WrkMast wrkMast = wrkMastMapper.selectPakOutStep11(slave.getId(), crnStn.getStaNo());
|
if (wrkMast == null) {
|
continue;
|
}
|
// 工作档状态判断
|
if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null){
|
log.error("查询工作档数据不符合条件--入出类型/站点, 工作号={},源库位={},入出类型={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType());
|
continue;
|
}
|
// 获取源库位信息
|
LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
|
if (!sourceSta.getLocSts().equals("R") &&!sourceSta.getLocSts().equals("P")) {
|
log.error("出库操作库位状态不符合--状态, 库位号={},库位状态={}", wrkMast.getLocNo(), sourceSta.getLocSts());
|
continue;
|
}
|
// 获取堆垛机出库站信息
|
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
|
StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
|
if (staProtocol == null) {
|
continue;
|
} else {
|
staProtocol = staProtocol.clone();
|
}
|
// 查询站点详细信息
|
BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
|
if (staDetl == null) {
|
log.error("出库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo());
|
continue;
|
}
|
// 判断堆垛机出库站状态
|
if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() !=null && staDetl.getCanouting().equals("Y")
|
&& staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) {
|
// 命令下发区 --------------------------------------------------------------------------
|
|
// 堆垛机控制过滤
|
if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
|
continue;
|
}
|
|
// 最外层库位,直接堆垛机出库
|
if (locMastService.isOutMost(wrkMast.getSourceLocNo())) {
|
// 已经存在吊车执行任务时,则过滤
|
if (wrkMastMapper.selectWorking(slave.getId()) != null) {
|
continue;
|
}
|
|
// 堆垛机出库 命令下发区 --------------------------------------------------------------------------
|
CrnCommand crnCommand = new CrnCommand();
|
crnCommand.setCrnNo(slave.getId()); // 堆垛机编号
|
crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号
|
crnCommand.setAckFinish((short) 0); // 任务完成确认位
|
crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转
|
crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 源库位排
|
crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 源库位列
|
crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 源库位层
|
crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 目标库位排
|
crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 目标库位列
|
crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 目标库位层
|
if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
|
log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
|
} else {
|
// 修改工作档状态 11.生成出库ID => 16.吊车出库中
|
Date now = new Date();
|
wrkMast.setWrkSts(16L);
|
wrkMast.setCrnStrTime(now);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 11.生成出库ID => 16.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
return true;
|
}
|
// 不是最外层库位,需要使用穿梭车搬运后,再堆垛机出库
|
} else {
|
// 当前组库位是否有穿梭车
|
Integer steNo = this.hasCarOfIdle(wrkMast.getSourceLocNo());
|
// 有小车
|
if (steNo != null) {
|
if (wrkMast.getWrkSts() == 11L && wrkMast.getSteNo() == null) {
|
|
// 给穿梭车下发命令 让其将货物挪至堆垛机搬运点
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
|
SteProtocol steProtocol = steThread.getSteProtocol();
|
if (steProtocol == null) { continue; }
|
if (steProtocol.isIdle()) {
|
|
// 命令下发区 --------------------------------------------------------------------------
|
SteCommand steCommand = new SteCommand();
|
steCommand.setSteNo(steNo); // 穿梭车编号
|
steCommand.setTaskNo(wrkMast.getWrkNo()); // 工作号
|
steCommand.setTaskMode(SteTaskModeType.findOutByLoc(wrkMast.getSourceLocNo())); // 任务模式: 去近点 等待堆垛机叉取
|
|
if (!MessageQueue.offer(SlaveType.Ste, steNo, new Task(2, steCommand))) {
|
log.error("穿梭车命令下发失败,穿梭车号={},任务数据={}", steNo, JSON.toJSON(steCommand));
|
} else {
|
// 修改工作档状态 11.生成出库ID => 14.小车搬出库
|
Date now = new Date();
|
wrkMast.setWrkSts(14L);
|
wrkMast.setSteNo(steNo);
|
wrkMast.setCrnStrTime(now);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 11.生成出库ID => 14.小车搬出库 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
}
|
}
|
}
|
if (wrkMast.getWrkSts() == 15L) {
|
// 已经存在吊车执行任务时,则过滤
|
if (wrkMastMapper.selectWorking(slave.getId()) != null) {
|
continue;
|
}
|
|
// 堆垛机出库 命令下发区 --------------------------------------------------------------------------
|
CrnCommand crnCommand = new CrnCommand();
|
crnCommand.setCrnNo(slave.getId()); // 堆垛机编号
|
crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号
|
crnCommand.setAckFinish((short) 0); // 任务完成确认位
|
crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转
|
crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 源库位排
|
crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 源库位列
|
crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 源库位层
|
crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 目标库位排
|
crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 目标库位列
|
crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 目标库位层
|
if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
|
log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
|
} else {
|
// 修改工作档状态 15.等待吊车 => 16.吊车出库中
|
Date now = new Date();
|
wrkMast.setWrkSts(16L);
|
wrkMast.setCrnStrTime(now);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 15.等待吊车 => 16.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
return true;
|
}
|
}
|
|
// 没有小车
|
} else {
|
if (wrkMast.getWrkSts() == 11L && wrkMast.getSteNo() == null) {
|
// 寻找最近的小车
|
SteThread steThread = queryIdleCar(wrkMast);
|
if (steThread != null) {
|
// 让小车等待搬运待续
|
this.letCarBeReady(wrkMast, steThread.getSlave().getId(), wrkMast.getSourceLocNo());
|
}
|
}
|
// 堆垛机搬运小车
|
if (wrkMast.getWrkSts() == 12L) {
|
this.carMoveIn(wrkMast, wrkMast.getSteNo(), crnProtocol);
|
}
|
}
|
}
|
|
}
|
}
|
return false;
|
}
|
|
/**
|
* 当前库位组是否存在空闲小车
|
*/
|
public Integer hasCarOfIdle(String locNo) {
|
for (SteSlave ste : slaveProperties.getSte()) {
|
// 获取堆垛机信息
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId());
|
SteProtocol steProtocol = steThread.getSteProtocol();
|
if (steProtocol == null) { continue; }
|
if (steProtocol.isIdle()) {
|
if (Utils.getGroupRow(locNo).equals(Utils.getGroupRow(steProtocol.getRow().intValue())) && steProtocol.getBay() == Utils.getBay(locNo) && steProtocol.getLev() == Utils.getLev(locNo)) {
|
return steProtocol.getSteNo().intValue();
|
}
|
}
|
}
|
return null;
|
}
|
|
/**
|
* 查找当前库位最适合的穿梭车来作业
|
*/
|
public SteThread queryIdleCar(WrkMast wrkMast) {
|
Integer crnNo = wrkMast.getCrnNo();
|
BasSte basSte = basSteService.findByCrnNo(crnNo);
|
// 获取穿梭车信息
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, basSte.getSteNo());
|
SteProtocol steProtocol = steThread.getSteProtocol();
|
if (steProtocol != null) {
|
if (steProtocol.isIdle()) {
|
return steThread;
|
}
|
}
|
return null;
|
}
|
|
/**
|
* 让小车从 远点 ====>> 待机
|
* 等待堆垛机搬运
|
*/
|
public void letCarBeWaiting(WrkMast wrkMast, Integer steNo, String locNo) {
|
// 获取穿梭车信息
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
|
SteProtocol steProtocol = steThread.getSteProtocol();
|
if (steProtocol == null) { return; }
|
if (steProtocol.isIdle()) {
|
|
// 命令下发区 --------------------------------------------------------------------------
|
SteCommand steCommand = new SteCommand();
|
steCommand.setSteNo(steNo); // 穿梭车编号
|
steCommand.setTaskNo(9999); // 工作号
|
steCommand.setTaskMode(SteTaskModeType.findWaiting(steProtocol.getRow().intValue())); // 任务模式: 去近点 等待堆垛机叉取
|
|
steCommand.setRow(Utils.getGroupRow(steProtocol.getRow().intValue()).shortValue());
|
steCommand.setBay(steProtocol.getBay());
|
steCommand.setLev(steProtocol.getLev());
|
|
if (!MessageQueue.offer(SlaveType.Ste, steNo, new Task(2, steCommand))) {
|
log.error("穿梭车命令下发失败,穿梭车号={},任务数据={}", steNo, JSON.toJSON(steCommand));
|
} else {
|
// 修改工作档状态 绑定穿梭车
|
wrkMast.setSteNo(steNo);
|
wrkMast.setModiTime(new Date());
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 绑定穿梭车 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
}
|
}
|
}
|
|
/**
|
* 让小车从 远点 ====>> 移动到近点
|
* 等待堆垛机搬运
|
*/
|
public void letCarBeReady(WrkMast wrkMast, Integer steNo, String locNo) {
|
// 获取穿梭车信息
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
|
SteProtocol steProtocol = steThread.getSteProtocol();
|
if (steProtocol == null) { return; }
|
if (steProtocol.isIdle()) {
|
|
// 命令下发区 --------------------------------------------------------------------------
|
SteCommand steCommand = new SteCommand();
|
steCommand.setSteNo(steNo); // 穿梭车编号
|
steCommand.setTaskNo(wrkMast.getWrkNo()); // 工作号
|
steCommand.setTaskMode(SteTaskModeType.findOriginByLoc(steProtocol)); // 任务模式: 去近点 等待堆垛机叉取
|
|
steCommand.setRow(Utils.getGroupRow(steProtocol.getRow().intValue()).shortValue());
|
steCommand.setBay(steProtocol.getBay());
|
steCommand.setLev(steProtocol.getLev());
|
|
if (!MessageQueue.offer(SlaveType.Ste, steNo, new Task(2, steCommand))) {
|
log.error("穿梭车命令下发失败,穿梭车号={},任务数据={}", steNo, JSON.toJSON(steCommand));
|
} else {
|
// 修改工作档状态 绑定穿梭车
|
wrkMast.setSteNo(steNo);
|
wrkMast.setModiTime(new Date());
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 绑定穿梭车 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
}
|
}
|
}
|
|
/**
|
* 入出库 ===>> 堆垛机搬入小车
|
*/
|
public void carMoveIn(WrkMast wrkMast, Integer steNo, CrnProtocol crnProtocol) {
|
// 获取堆垛机信息
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
|
SteProtocol steProtocol = steThread.getSteProtocol();
|
if (steProtocol == null) { return; }
|
if (steProtocol.isIdle()) {
|
// 堆垛机空闲
|
if (crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() == 0) {
|
LocMast locMast;
|
// 入库搬
|
if (wrkMast.getWrkSts() <= 10) {
|
locMast = locMastService.selectById(wrkMast.getLocNo());
|
// 堆垛机命令下发区 --------------------------------------------------------------------------
|
CrnCommand crnCommand = new CrnCommand();
|
crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 堆垛机编号
|
crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号
|
crnCommand.setAckFinish((short) 0); // 任务完成确认位
|
crnCommand.setTaskMode(CrnTaskModeType.STE_MOVE); // 任务模式: 库位移转
|
crnCommand.setSourcePosX(steProtocol.getRow()); // 源库位排
|
crnCommand.setSourcePosY(steProtocol.getBay()); // 源库位列
|
crnCommand.setSourcePosZ(steProtocol.getLev()); // 源库位层
|
crnCommand.setDestinationPosX(Utils.getGroupRow(locMast.getLocNo()).shortValue()); // 目标库位排
|
crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 目标库位列
|
crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 目标库位层
|
if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
|
log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
|
} else {
|
// 修改穿梭车运行中排列层
|
steThread.modifyPos(Utils.getGroupRow(locMast.getLocNo()), locMast.getBay1(), locMast.getLev1());
|
// 修改工作档状态 3.小车待搬 => 4.迁入小车
|
Date now = new Date();
|
wrkMast.setWrkSts(4L);
|
wrkMast.setCrnStrTime(now);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 3.小车待搬 => 4.迁入小车 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
}
|
// 出库搬
|
} else {
|
locMast = locMastService.selectById(wrkMast.getSourceLocNo());
|
// 堆垛机命令下发区 --------------------------------------------------------------------------
|
CrnCommand crnCommand = new CrnCommand();
|
crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 堆垛机编号
|
crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号
|
crnCommand.setAckFinish((short) 0); // 任务完成确认位
|
crnCommand.setTaskMode(CrnTaskModeType.STE_MOVE); // 任务模式: 库位移转
|
crnCommand.setSourcePosX(steProtocol.getRow()); // 源库位排
|
crnCommand.setSourcePosY(steProtocol.getBay()); // 源库位列
|
crnCommand.setSourcePosZ(steProtocol.getLev()); // 源库位层
|
crnCommand.setDestinationPosX(Utils.getGroupRow(locMast.getLocNo()).shortValue()); // 目标库位排
|
crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 目标库位列
|
crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 目标库位层
|
if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
|
log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
|
} else {
|
// 修改穿梭车运行中排列层
|
steThread.modifyPos(Utils.getGroupRow(locMast.getLocNo()), locMast.getBay1(), locMast.getLev1());
|
// 修改工作档状态 12.小车待搬 => 13.迁入小车
|
Date now = new Date();
|
wrkMast.setWrkSts(13L);
|
wrkMast.setCrnStrTime(now);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 12.小车待搬 => 13.迁入小车 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
}
|
}
|
}
|
|
}
|
}
|
|
/**
|
* 入库 ===>> 堆垛机搬出小车
|
*/
|
public void carMoveOut(WrkMast wrkMast, Integer steNo, CrnProtocol crnProtocol) {
|
// 获取穿梭车信息
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
|
SteProtocol steProtocol = steThread.getSteProtocol();
|
if (steProtocol == null) { return; }
|
// 穿梭车空闲
|
if (steProtocol.isIdle()) {
|
// 堆垛机空闲
|
if (crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() == 0) {
|
|
BasSte basSte = basSteService.selectById(steNo);
|
if (basSte == null) {
|
log.error("{}号穿梭车在数据库不存在!!!", steNo);
|
return;
|
}
|
String idleLocNo = basSte.getIdleLoc();
|
|
// 堆垛机命令下发区 --------------------------------------------------------------------------
|
CrnCommand crnCommand = new CrnCommand();
|
crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 堆垛机编号
|
crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号
|
crnCommand.setAckFinish((short) 0); // 任务完成确认位
|
crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转
|
crnCommand.setSourcePosX(steProtocol.getRow()); // 源库位排
|
crnCommand.setSourcePosY(steProtocol.getBay()); // 源库位列
|
crnCommand.setSourcePosZ(steProtocol.getLev()); // 源库位层
|
crnCommand.setDestinationPosX(Utils.getGroupRow(idleLocNo).shortValue()); // 目标库位排
|
crnCommand.setDestinationPosY((short) Utils.getBay(idleLocNo)); // 目标库位列
|
crnCommand.setDestinationPosZ((short) Utils.getLev(idleLocNo)); // 目标库位层
|
if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
|
log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
|
} else {
|
// 修改穿梭车运行中排列层
|
steThread.modifyPos(Utils.getGroupRow(idleLocNo), Utils.getBay(idleLocNo), Utils.getLev(idleLocNo));
|
// 修改工作档状态 3.小车待搬 => 5.迁出小车
|
Date now = new Date();
|
wrkMast.setWrkSts(5L);
|
wrkMast.setCrnStrTime(now);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 3.小车待搬 => 5.迁出小车 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
}
|
}
|
}
|
}
|
|
|
/**
|
* 执行对工作档的完成操作
|
*/
|
@Async
|
@Transactional
|
public void storeFinished() {
|
for (CrnSlave crn : slaveProperties.getCrn()) {
|
// 获取堆垛机信息
|
CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
|
CrnProtocol crnProtocol = crnThread.getCrnProtocol();
|
if (crnProtocol == null) { continue; }
|
// 状态:等待确认 并且 任务完成位 = 1
|
if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) {
|
// 获取入库待确认工作档
|
WrkMast wrkMast = wrkMastMapper.selectCrnWaiting(crnProtocol.getTaskNo().intValue());
|
if (wrkMast == null) {
|
log.error("堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo());
|
continue;
|
}
|
// 入库 ==>> 货物搬入库
|
if (wrkMast.getWrkSts() == 7){
|
// 判断是否需要小车入库
|
if (locMastService.isOutMost(wrkMast.getLocNo())) {
|
// ==> 9.入库完成
|
wrkMast.setWrkSts(9L);
|
Date now = new Date();
|
wrkMast.setCrnEndTime(now);
|
wrkMast.setModiTime(now);
|
// 修改成功后复位堆垛机
|
if (wrkMastMapper.updateById(wrkMast) > 0) {
|
// 堆垛机复位
|
crnThread.setResetFlag(true);
|
} else {
|
log.error("修改工作档状态 7.吊车入库中 => 9.入库完成 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
} else {
|
// 给穿梭车下发命令
|
Integer steNo = wrkMast.getSteNo();
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
|
SteProtocol steProtocol = steThread.getSteProtocol();
|
if (steProtocol == null) { continue; }
|
if (steProtocol.isIdle()) {
|
// 命令下发区 --------------------------------------------------------------------------
|
SteCommand steCommand = new SteCommand();
|
steCommand.setSteNo(steNo); // 穿梭车编号
|
steCommand.setTaskNo(wrkMast.getWrkNo()); // 工作号
|
steCommand.setTaskMode(SteTaskModeType.findInByLoc(wrkMast.getLocNo())); // 任务模式: 搬入库
|
if (!MessageQueue.offer(SlaveType.Ste, steNo, new Task(2, steCommand))) {
|
log.error("穿梭车命令下发失败,穿梭车号={},任务数据={}", steNo, JSON.toJSON(steCommand));
|
} else {
|
// 修改工作档状态 7.吊车入库中 => 8.小车搬入库
|
wrkMast.setWrkSts(8L);
|
Date now = new Date();
|
wrkMast.setCrnEndTime(now);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) > 0) {
|
// 堆垛机复位
|
crnThread.setResetFlag(true);
|
} else {
|
log.error("修改工作档状态 7.吊车入库中 => 8.小车搬入库 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
}
|
}
|
}
|
// 入库 ===>> 迁入小车 完成
|
} else if (wrkMast.getWrkSts() == 4) {
|
// 4.迁入小车 ==> 6.小车待入
|
wrkMast.setWrkSts(6L);
|
Date now = new Date();
|
wrkMast.setCrnEndTime(now);
|
wrkMast.setModiTime(now);
|
// 修改成功后复位堆垛机
|
if (wrkMastMapper.updateById(wrkMast) > 0) {
|
// 堆垛机复位
|
crnThread.setResetFlag(true);
|
// 穿梭车重新定位排列层
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, wrkMast.getSteNo());
|
if (!steThread.confirmPos()) {
|
log.error("{}号穿梭车重新定位失败!作业工作档任务号:{}", wrkMast.getSteNo(), wrkMast.getWrkNo());
|
}
|
// 穿梭车去待机位
|
BasSte basSte = basSteService.selectById(wrkMast.getSteNo());
|
SteCommand steCommand = new SteCommand();
|
steCommand.setSteNo(wrkMast.getSteNo()); // 穿梭车编号
|
steCommand.setTaskNo(9999); // 工作号
|
steCommand.setTaskMode(SteTaskModeType.findWaiting(basSte.getRow())); // 任务模式: 去近点 等待堆垛机叉取
|
// steCommand.setRow(Utils.getGroupRow(steProtocol.getRow().intValue()).shortValue());
|
// steCommand.setBay(steProtocol.getBay());
|
// steCommand.setLev(steProtocol.getLev());
|
if (!MessageQueue.offer(SlaveType.Ste, wrkMast.getSteNo(), new Task(2, steCommand))) {
|
log.error("穿梭车待机位命令下发失败,穿梭车号={},任务数据={}", wrkMast.getSteNo(), JSON.toJSON(steCommand));
|
}
|
} else {
|
log.error("修改工作档状态 4.迁入小车 => 6.小车待入 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
// 入库 ===>> 迁出小车 完成
|
} else if (wrkMast.getWrkSts() == 5) {
|
// 5.迁出小车 ==> 6.小车待入
|
wrkMast.setWrkSts(6L);
|
Date now = new Date();
|
wrkMast.setCrnEndTime(now);
|
wrkMast.setModiTime(now);
|
// 修改成功后复位堆垛机
|
if (wrkMastMapper.updateById(wrkMast) > 0) {
|
// 堆垛机复位
|
crnThread.setResetFlag(true);
|
// 穿梭车重新定位排列层
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, wrkMast.getSteNo());
|
if (!steThread.confirmPos()) {
|
log.error("{}号穿梭车重新定位失败!作业工作档任务号:{}", wrkMast.getSteNo(), wrkMast.getWrkNo());
|
}
|
// 穿梭车去待机位
|
BasSte basSte = basSteService.selectById(wrkMast.getSteNo());
|
SteCommand steCommand = new SteCommand();
|
steCommand.setSteNo(wrkMast.getSteNo()); // 穿梭车编号
|
steCommand.setTaskNo(9999); // 工作号
|
steCommand.setTaskMode(SteTaskModeType.findWaiting(basSte.getRow())); // 任务模式: 去近点 等待堆垛机叉取
|
// steCommand.setRow(Utils.getGroupRow(steProtocol.getRow().intValue()).shortValue());
|
// steCommand.setBay(steProtocol.getBay());
|
// steCommand.setLev(steProtocol.getLev());
|
if (!MessageQueue.offer(SlaveType.Ste, wrkMast.getSteNo(), new Task(2, steCommand))) {
|
log.error("穿梭车待机位命令下发失败,穿梭车号={},任务数据={}", wrkMast.getSteNo(), JSON.toJSON(steCommand));
|
}
|
} else {
|
log.error("修改工作档状态 5.迁出小车 => 6.小车待入 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
// 出库 ===>> 迁入小车 完成
|
} else if (wrkMast.getWrkSts() == 13) {
|
// 给穿梭车下发命令
|
Integer steNo = wrkMast.getSteNo();
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
|
SteProtocol steProtocol = steThread.getSteProtocol();
|
if (steProtocol == null) { continue; }
|
if (steProtocol.isIdle()) {
|
// 穿梭车重新定位排列层
|
if (!steThread.confirmPos()) {
|
log.error("{}号穿梭车重新定位失败!作业工作档任务号:{}", wrkMast.getSteNo(), wrkMast.getWrkNo());
|
}
|
// 命令下发区 --------------------------------------------------------------------------
|
SteCommand steCommand = new SteCommand();
|
steCommand.setSteNo(steNo); // 穿梭车编号
|
steCommand.setTaskNo(wrkMast.getWrkNo()); // 工作号
|
steCommand.setTaskMode(SteTaskModeType.findOutByLoc(wrkMast.getSourceLocNo())); // 任务模式: 搬出库
|
if (!MessageQueue.offer(SlaveType.Ste, steNo, new Task(2, steCommand))) {
|
log.error("穿梭车命令下发失败,穿梭车号={},任务数据={}", steNo, JSON.toJSON(steCommand));
|
} else {
|
// 13.迁入小车 ==> 14.小车搬出库
|
wrkMast.setWrkSts(14L);
|
Date now = new Date();
|
wrkMast.setCrnEndTime(now);
|
wrkMast.setModiTime(now);
|
// 修改成功后复位堆垛机
|
if (wrkMastMapper.updateById(wrkMast) > 0) {
|
// 堆垛机复位
|
crnThread.setResetFlag(true);
|
} else {
|
log.error("修改工作档状态 13.迁入小车 ==> 14.小车搬出库 失败!!,工作号={}", wrkMast.getWrkNo());
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
/**
|
* 执行对工作档的完成操作
|
*/
|
public void carGenerateStore() {
|
Date now = new Date();
|
for (SteSlave ste : slaveProperties.getSte()) {
|
// 获取穿梭车信息
|
SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId());
|
SteProtocol steProtocol = steThread.getSteProtocol();
|
if (steProtocol == null) { continue; }
|
if (steProtocol.getWaiting() && steProtocol.getTaskNo() != 0) {
|
if (steProtocol.getTaskNo() == 9999) {
|
steThread.setResetFlag(true);
|
} else {
|
// 查询是否有待入库的任务
|
WrkMast wrkMast = wrkMastMapper.selectCarWaiting(steProtocol.getTaskNo().intValue());
|
if (wrkMast == null) { continue; }
|
|
switch (wrkMast.getWrkSts().intValue()) {
|
case 2:
|
// 修改工作档状态 2.设备上走 => 3.小车待搬
|
wrkMast.setWrkSts(3L);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 2.设备上走 => 3.小车待搬 失败!!,工作号={}", wrkMast.getWrkNo());
|
} else {
|
steThread.setResetFlag(true);
|
}
|
break;
|
case 8:
|
// 修改工作档状态 8.小车搬入库 => 9.入库完成
|
wrkMast.setWrkSts(9L);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 8.小车搬入库 => 9.入库完成 失败!!,工作号={}", wrkMast.getWrkNo());
|
} else {
|
steThread.setResetFlag(true);
|
}
|
break;
|
case 11:
|
// 修改工作档状态 11.生成出库ID => 12.小车待搬
|
wrkMast.setWrkSts(12L);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 11.生成出库ID => 12.小车待搬 失败!!,工作号={}", wrkMast.getWrkNo());
|
} else {
|
steThread.setResetFlag(true);
|
}
|
break;
|
case 14:
|
// 修改工作档状态 14.小车搬出库 => 15.等待吊车
|
wrkMast.setWrkSts(15L);
|
wrkMast.setModiTime(now);
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
log.error("修改工作档状态 14.小车搬出库 => 15.等待吊车 失败!!,工作号={}", wrkMast.getWrkNo());
|
} else {
|
steThread.setResetFlag(true);
|
}
|
break;
|
}
|
}
|
}
|
}
|
}
|
|
/**
|
* 堆垛机异常信息记录
|
*/
|
@Async
|
public void recCrnErr(){
|
Date now = new Date();
|
for (CrnSlave crn : slaveProperties.getCrn()) {
|
// 获取堆垛机信息
|
CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
|
CrnProtocol crnProtocol = crnThread.getCrnProtocol();
|
if (crnProtocol == null) {
|
continue;
|
}
|
if (true) {
|
// if (crnProtocol.getModeType() != CrnModeType.STOP) {
|
// 有任务
|
if (crnProtocol.getTaskNo() != 0) {
|
BasErrLog latest = basErrLogService.findLatestByTaskNo(crn.getId(), crnProtocol.getTaskNo().intValue());
|
// 有异常
|
if (latest == null) {
|
if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) {
|
WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo());
|
if (wrkMast == null) {
|
continue;
|
}
|
BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
|
String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName();
|
BasErrLog basErrLog = new BasErrLog(
|
null, // 编号
|
wrkMast.getWrkNo(), // 工作号
|
now, // 发生时间
|
null, // 结束时间
|
wrkMast.getWrkSts(), // 工作状态
|
wrkMast.getIoType(), // 入出库类型
|
crn.getId(), // 堆垛机
|
null, // plc
|
wrkMast.getLocNo(), // 目标库位
|
wrkMast.getStaNo(), // 目标站
|
wrkMast.getSourceStaNo(), // 源站
|
wrkMast.getSourceLocNo(), // 源库位
|
wrkMast.getBarcode(), // 条码
|
(int) crnProtocol.getAlarm(), // 异常码
|
errName, // 异常
|
1, // 异常情况
|
now, // 添加时间
|
null, // 添加人员
|
now, // 修改时间
|
null, // 修改人员
|
"任务中异常" // 备注
|
);
|
if (!basErrLogService.insert(basErrLog)) {
|
log.error("堆垛机plc异常记录失败 ===>> [id:{}] [error:{}]", crn.getId(), errName);
|
}
|
}
|
} else {
|
// 异常修复
|
if (crnProtocol.getAlarm() == null || crnProtocol.getAlarm() == 0) {
|
latest.setEndTime(now);
|
latest.setUpdateTime(now);
|
latest.setStatus(2);
|
if (!basErrLogService.updateById(latest)) {
|
log.error("堆垛机plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
|
}
|
}
|
}
|
// 无任务
|
} else {
|
BasErrLog latest = basErrLogService.findLatest(crn.getId());
|
// 有异常
|
if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) {
|
// 记录新异常
|
if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm().intValue())) {
|
BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
|
String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName();
|
BasErrLog basErrLog = new BasErrLog(
|
null, // 编号
|
null, // 工作号
|
now, // 发生时间
|
null, // 结束时间
|
null, // 工作状态
|
null, // 入出库类型
|
crn.getId(), // 堆垛机
|
null, // plc
|
null, // 目标库位
|
null, // 目标站
|
null, // 源站
|
null, // 源库位
|
null, // 条码
|
(int)crnProtocol.getAlarm(), // 异常码
|
errName, // 异常
|
1, // 异常情况
|
now, // 添加时间
|
null, // 添加人员
|
now, // 修改时间
|
null, // 修改人员
|
"无任务异常" // 备注
|
);
|
if (!basErrLogService.insert(basErrLog)) {
|
log.error("堆垛机plc异常记录失败 ===>> [id:{}] [error:{}]", crn.getId(), errName);
|
}
|
}
|
// 无异常
|
} else {
|
// 异常修复
|
if (latest != null && latest.getStatus() == 1) {
|
latest.setEndTime(now);
|
latest.setUpdateTime(now);
|
latest.setStatus(2);
|
if (!basErrLogService.updateById(latest)) {
|
log.error("堆垛机plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
|
}
|
}
|
}
|
}
|
}
|
|
}
|
}
|
|
|
// -------------------------------------------------------------------------------
|
|
/**
|
* 空栈板初始化入库,叉车入库站放货
|
*/
|
@Async
|
public void storeEmptyPlt(){
|
for (DevpSlave devp : slaveProperties.getDevp()) {
|
// 遍历空板入库口
|
for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) {
|
// 获取空板入库站信息
|
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
|
StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo());
|
if (staProtocol == null) {
|
continue;
|
} else {
|
staProtocol = staProtocol.clone();
|
}
|
// 站点条件判断
|
if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
|
&& staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || (staProtocol.getWorkNo() >= 9990 && staProtocol.getWorkNo() <= 9999) || staProtocol.getWorkNo() == 9997) && staProtocol.isPakMk()) {
|
|
try {
|
LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
|
|
SearchLocParam param = new SearchLocParam();
|
param.setIoType(10);
|
param.setSourceStaNo(emptyInSta.getStaNo());
|
param.setLocType1(locTypeDto.getLocType1());
|
String response = new HttpHandler.Builder()
|
.setUri(wmsUrl)
|
.setPath("/rpc/pakin/loc/v1")
|
.setJson(JSON.toJSONString(param))
|
.build()
|
.doPost();
|
JSONObject jsonObject = JSON.parseObject(response);
|
if (jsonObject.getInteger("code").equals(200)) {
|
StartupDto dto = jsonObject.getObject("data", StartupDto.class);
|
|
// 更新站点信息 且 下发plc命令
|
staProtocol.setWorkNo(dto.getWorkNo().shortValue());
|
staProtocol.setStaNo(dto.getStaNo().shortValue());
|
devpThread.setPakMk(staProtocol.getSiteId(), false);
|
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
|
if (!result) {
|
throw new CoolException("更新plc站点信息失败");
|
}
|
} else {
|
log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
}
|
|
}
|
|
|
}
|
}
|
}
|
|
/**
|
* 出库 ===>> 工作档信息写入led显示器
|
*/
|
@Async
|
public void ledExecute() {
|
for (LedSlave led : slaveProperties.getLed()) {
|
// 获取输送线plc线程
|
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
|
// 命令集合
|
List<LedCommand> commands = new ArrayList<>();
|
// 工作档集合
|
List<WrkMast> wrkMasts = new ArrayList<>();
|
for (Integer staNo : led.getStaArr()) {
|
// 获取叉车站点
|
StaProtocol staProtocol = devpThread.getStation().get(staNo);
|
if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) {
|
continue;
|
} else {
|
staProtocol = staProtocol.clone();
|
}
|
// 获取工作档数据
|
WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo());
|
if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; }
|
wrkMasts.add(wrkMast);
|
// 组装命令
|
LedCommand ledCommand = new LedCommand();
|
ledCommand.setWorkNo(wrkMast.getWrkNo());
|
// 出库模式
|
switch (wrkMast.getIoType()) {
|
case 101:
|
ledCommand.setTitle("全板出库");
|
break;
|
case 103:
|
ledCommand.setTitle("拣料出库");
|
break;
|
case 104:
|
ledCommand.setTitle("并板出库");
|
break;
|
case 107:
|
ledCommand.setTitle("盘点出库");
|
break;
|
case 110:
|
ledCommand.setTitle("空板出库");
|
ledCommand.setEmptyMk(true);
|
break;
|
default:
|
log.error("任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
|
break;
|
}
|
ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
|
ledCommand.setStaNo(wrkMast.getStaNo());
|
if (wrkMast.getIoType() != 110) {
|
List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
|
wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme())));
|
}
|
commands.add(ledCommand);
|
}
|
Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet());
|
// 获取LED线程
|
LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
|
// 相同工作号集合则过滤
|
if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) {
|
continue;
|
}
|
// 命令下发 -------------------------------------------------------------------------------
|
if (!commands.isEmpty()) {
|
if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
|
log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
|
continue;
|
} else {
|
ledThread.setLedMk(false);
|
}
|
}
|
|
try {
|
// 修改主档led标记
|
for (WrkMast wrkMast : wrkMasts) {
|
wrkMast.setOveMk("Y");
|
wrkMast.setModiTime(new Date());
|
if (wrkMastMapper.updateById(wrkMast) == 0) {
|
throw new CoolException("更新工作档失败");
|
}
|
}
|
|
// 更新线程当前工作号集合
|
ledThread.setWorkNos(workNos);
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
}
|
|
}
|
}
|
|
/**
|
* 其他 ===>> LED显示器复位,显示默认信息
|
*/
|
@Async
|
public void ledReset() {
|
for (LedSlave led : slaveProperties.getLed()) {
|
// 获取输送线plc线程
|
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
|
// 命令集合
|
boolean reset = true;
|
for (Integer staNo : led.getStaArr()) {
|
// 获取叉车站点
|
StaProtocol staProtocol = devpThread.getStation().get(staNo);
|
if (staProtocol == null) {
|
continue;
|
}
|
if (staProtocol.getWorkNo() != 0) {
|
reset = false;
|
break;
|
}
|
}
|
// 获取led线程
|
LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId());
|
// led显示默认内容
|
if (reset && !ledThread.isLedMk()) {
|
ledThread.setLedMk(true);
|
if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) {
|
log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
|
} else {
|
|
}
|
}
|
}
|
}
|
|
|
|
|
|
}
|