| | |
| | | import com.zy.asrs.mapper.WrkMastMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.CrnStatusType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.CrnSlave; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.Task; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 立体仓库WCS系统主流程业务 |
| | | * Created by vincent on 2020/8/6 |
| | | */ |
| | | @Slf4j |
| | | @Service("mainService") |
| | | @Transactional |
| | | public class MainServiceImpl { |
| | | |
| | | @Autowired |
| | |
| | | /** |
| | | * 入库站,根据条码扫描生成入库工作档,工作状态 2 |
| | | */ |
| | | @Transactional |
| | | @Async |
| | | public void generateStoreWrkFile() { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历入库口 |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { |
| | | // 获取条码 |
| | | // 获取条码扫描仪信息 |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); |
| | | String barcode = barcodeThread.getBarcode(); |
| | | // 获取入库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); |
| | | // 判断是否满足入库条件 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInreq1() |
| | | && !staProtocol.isEmptyMk() && staProtocol.isInreq1() && staProtocol.getWorkNo() ==0 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() |
| | | && !staProtocol.isEmptyMk() && staProtocol.isInreq1() && staProtocol.getWorkNo()==0 |
| | | && staProtocol.isPakMk() && !Cools.isEmpty(barcode)) { |
| | | // 判断重复工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); |
| | | if (wrkMast != null) { |
| | | log.warn("工作档中已存在该站状态为1的数据,工作号-{}", wrkMast.getWrkNo()); |
| | | log.warn("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo()); |
| | | continue; |
| | | } |
| | | // 获取入库通知档 |
| | | List<WaitPakin> waitPakins = waitPakinMapper.selectList(new EntityWrapper<WaitPakin>().eq("barcode", barcode)); |
| | | List<WaitPakin> waitPakins = waitPakinMapper.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode).eq("io_status", "N")); |
| | | if (waitPakins.isEmpty()) { |
| | | log.warn("无此入库条码数据。条码号={}", barcode); |
| | | continue; |
| | | } |
| | | // 工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | // 检索库位 |
| | | List<String> matNos = waitPakins.stream().map(WaitPakin::getMatnr).distinct().collect(Collectors.toList()); |
| | | StartupDto startupDto = commonService.getLocNo(1, 1, inSta.getStaNo(), matNos); |
| | | String locNo = startupDto.getLocNo(); |
| | | if (!waitPakins.isEmpty()) { |
| | | // 插入工作明细档 |
| | | wrkDetlService.createWorkDetail(workNo, waitPakins, barcode); |
| | | } else { |
| | | log.warn("无此入库条码数据---{}", barcode); |
| | | continue; |
| | | } |
| | | // 插入工作明细档 |
| | | wrkDetlService.createWorkDetail(workNo, waitPakins, barcode); |
| | | |
| | | // 插入工作主档 |
| | | wrkMast = new WrkMast(); |
| | |
| | | if (!locMastService.updateById(locMast)){ |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | // 将入库通知档修改为已启动 |
| | | if (wrkMastMapper.updateWaitPakInStep1(barcode) == 0) { |
| | | throw new CoolException("修改入库通知档状态为已启动"); |
| | | } |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | |
| | | // 更新站点信息 且 下发plc命令 |
| | | barcodeThread.setBarcode(""); |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo(startupDto.getStaNo()); |
| | | staProtocol.setWorkNo((short) workNo); |
| | | staProtocol.setStaNo(startupDto.getStaNo().shortValue()); |
| | | staProtocol.setPakMk(false); |
| | | staProtocol.setInreq1(false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task<>(4, staProtocol)); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | |
| | | /** |
| | | * 拣料、并板、盘点再入库 |
| | | */ |
| | | @Async |
| | | public void stnToCrnStnPick(){ |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历拣料入库口 |
| | |
| | | |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInreq1() |
| | | && staProtocol.getWorkNo() > 0 && staProtocol.isPakMk()){ |
| | | WrkMast wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo()); |
| | | WrkMast wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo().intValue()); |
| | | if (wrkMast == null) { |
| | | // 无拣料数据 |
| | | continue; |
| | |
| | | } |
| | | |
| | | // 更新站点信息 且 下发plc命令 |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo()); |
| | | staProtocol.setStaNo(wrkMast.getStaNo()); |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | staProtocol.setPakMk(false); |
| | | staProtocol.setInreq1(false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task<>(4, staProtocol)); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | |
| | | /** |
| | | * 堆垛机站出库到出库站 |
| | | */ |
| | | @Async |
| | | public void crnStnToOutStn() { |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历拣料入库口 |
| | |
| | | continue; |
| | | } |
| | | // 更新工作档状态为14失败 todo:luxiaotao |
| | | if (crnProtocol.mode == 3 && crnProtocol.getTaskNo() == wrkMast.getWrkNo() |
| | | if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue()) |
| | | && crnProtocol.statusType == CrnStatusType.IDLE |
| | | && crnProtocol.forkPos==0) { |
| | | && crnProtocol.forkPosType == CrnForkPosType.HOME) { |
| | | wrkMast.setWrkSts(14L); |
| | | wrkMast.setCrnEndTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | |
| | | // 1.复位堆垛机 更新堆垛机信息 且 下发plc命令 todo:luxiaotao |
| | | crnProtocol.setStatus(CrnStatusType.IDLE); |
| | | crnProtocol.setTaskNo((short)0); |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task<>(4, crnProtocol))) { |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(4, crnProtocol))) { |
| | | throw new CoolException("更新堆垛机信息失败"); |
| | | } |
| | | |
| | | // 2.下发站点信息 |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo()); |
| | | staProtocol.setStaNo(wrkMast.getStaNo()); |
| | | if (!MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task<>(4, staProtocol))) { |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | if (!MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol))) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 入出库 ===>> 堆垛机站到库位 堆垛机入出库作业下发 |
| | | * 入出库 ===>> 堆垛机入出库作业下发 |
| | | */ |
| | | @Async |
| | | public void crnIoExecute(){ |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // 获取堆垛机信息 |
| | |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); |
| | | if (basCrnp == null) { |
| | | log.error("{}号堆垛机尚未在数据库进行维护!", crn.getId()); |
| | | continue; |
| | | } |
| | | // 只有当堆垛机空闲 并且 无任务时才继续执行 |
| | |
| | | } |
| | | } |
| | | // 库位移转 |
| | | this.locToLoc(); |
| | | |
| | | this.locToLoc(crn); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 入库 ===>> 堆垛机站到库位 |
| | | */ |
| | | private void crnStnToLoc(CrnSlave slave){ |
| | | @Async |
| | | public void crnStnToLoc(CrnSlave slave){ |
| | | for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) { |
| | | boolean flag = false; |
| | | // 获取堆垛机入库站信息 |
| | |
| | | // 查询站点详细信息 |
| | | BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); |
| | | if (staDetl == null) { |
| | | log.error("入库库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo()); |
| | | log.error("入库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo()); |
| | | continue; |
| | | } |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staDetl.getCanining().equals("Y")) { |
| | |
| | | continue; |
| | | } |
| | | // 获取工作状态为2(设备上走)的入库工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo()); |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue()); |
| | | if(null == wrkMast) { |
| | | log.error("查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo()); |
| | | continue; |
| | |
| | | } |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | // CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, slave.getId()); |
| | | // CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | | crnCommand.setTaskNo(wrkMast.getWrkNo().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))) { |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.PAKIN); // 任务模式: 库位移转 |
| | | 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 { |
| | | // 修改工作档状态 2.设备上走 => 3.吊车入库中 |
| | | Date now = new Date(); |
| | | wrkMast.setWrkSts(3L); |
| | | wrkMast.setCrnStrTime(now); |
| | | wrkMast.setModiTime(now); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 出库 ===>> 库位到堆垛机站 |
| | | */ |
| | | private void locToCrnStn(CrnSlave slave){ |
| | | @Async |
| | | public void locToCrnStn(CrnSlave slave){ |
| | | for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) { |
| | | // 获取工作状态为11(生成出库ID)的出库工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId()); |
| | |
| | | && staProtocol.getWorkNo() == 0) { |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | |
| | | // 1.堆垛机开始移动 |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | | crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号 |
| | | crnCommand.setAckFinish((short) 1); // 任务完成确认位 |
| | | |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task<>(2, crnCommand))) { |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.PAKOUT); // 任务模式: 库位移转 |
| | | 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 => 12.吊车出库中 |
| | | Date now = new Date(); |
| | | wrkMast.setWrkSts(12L); |
| | | wrkMast.setCrnStrTime(now); |
| | | wrkMast.setModiTime(now); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 库位移转 |
| | | */ |
| | | private void locToLoc(){ |
| | | |
| | | @Async |
| | | public void locToLoc(CrnSlave slave){ |
| | | // 获取工作档信息 |
| | | WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId()); |
| | | if (null == wrkMast) { |
| | | return; |
| | | } |
| | | // 获取源库位信息 |
| | | LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (null == sourceSta) { |
| | | log.error("工作档库位移转失败,原因:检索源库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo()); |
| | | return; |
| | | } |
| | | // 源库位 库位状态判断 |
| | | if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("S")) { |
| | | return; |
| | | } |
| | | // 获取目标库位信息 |
| | | LocMast sta = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (null == sta) { |
| | | log.error("工作档库位移转失败,原因:检索目标库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getLocNo()); |
| | | return; |
| | | } |
| | | // 获取堆垛机信息 并 判断是否可入出 |
| | | BasCrnp basCrnp = basCrnpService.selectById(slave.getId()); |
| | | if (!basCrnp.getInEnable().equals("Y") && !basCrnp.getOutEnable().equals("Y")) { |
| | | return; |
| | | } |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | 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(sta.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(sta.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(sta.getLev1().shortValue()); // 目标库位层 |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 执行对工作档的入库完成 |
| | | * 执行对工作档的完成操作 |
| | | */ |
| | | @Async |
| | | public void storeFinished() { |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // 获取堆垛机信息 |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | // 状态:等待确认 并且 任务完成位 = 1 |
| | | if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) { |
| | | // 获取入库待确认工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue()); |
| | | if (wrkMast == null) { |
| | | log.error("堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo()); |
| | | continue; |
| | | } |
| | | // 入库 + 库位转移 ==> 4.入库完成 |
| | | if (wrkMast.getWrkSts() == 3 || (wrkMast.getWrkSts() == 12 && wrkMast.getIoType() == 11)){ |
| | | wrkMast.setWrkSts(4L); |
| | | // 出库 + 拣料/盘点/并板出库中:12.吊车出库中 ==> 14.出库完成 |
| | | } else if (wrkMast.getWrkSts() == 12) { |
| | | wrkMast.setWrkSts(14L); |
| | | } else { |
| | | continue; |
| | | } |
| | | Date now = new Date(); |
| | | wrkMast.setCrnEndTime(now); |
| | | wrkMast.setModiTime(now); |
| | | // 修改成功后复位堆垛机 |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | // 命令下发区 ------------------------------------------------------------------------- |
| | | if (crnProtocol.getStatusType().equals(CrnStatusType.WAITING)) { |
| | | // 堆垛机复位 |
| | | if (!MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(3, new CrnCommand()))) { |
| | | log.error("堆垛机复位命令下发失败,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 完成通知档 |
| | | if (wrkMastMapper.updateWaitPakInStep2(wrkMast.getBarcode()) == 0) { |
| | | log.error("入库通知档修改结束状态失败,workNo=[{}]", wrkMast.getWrkNo()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新堆垛机移动时工作档状态 |
| | | * 堆垛机异常信息记录 |
| | | */ |
| | | public void updateCrnMove() { |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // 获取堆垛机信息 |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | // todo |
| | | if (crnProtocol.getStatusType() == CrnStatusType.FETCH_POSITION) { |
| | | public void recCrnErr(){ |
| | | |
| | | WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo()); |
| | | } |
| | | |
| | | |
| | | // ------------------------------------------------------------------------------- |
| | | |
| | | /** |
| | | * 空栈板初始化入库,叉车入库站放货 |
| | | */ |
| | | @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.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() |
| | | && staProtocol.isEmptyMk() && staProtocol.getWorkNo() == 0 && staProtocol.isPakMk()) { |
| | | // 工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | // 检索库位 |
| | | StartupDto startupDto = commonService.getLocNo(1, 1, emptyInSta.getStaNo(), null); |
| | | |
| | | // 插入工作主档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(2L); // 工作状态:2.设备上走 |
| | | wrkMast.setIoType(10); // 入出库状态:10.空板入库 |
| | | wrkMast.setIoPri(10D); // 优先级:10 |
| | | wrkMast.setCrnNo(startupDto.getCrnNo()); |
| | | wrkMast.setSourceStaNo(startupDto.getSourceStaNo()); |
| | | wrkMast.setStaNo(startupDto.getStaNo()); |
| | | wrkMast.setLocNo(startupDto.getLocNo()); |
| | | wrkMast.setFullPlt("N"); // 满板 |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | // wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型 |
| | | // 操作人员数据 |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | Integer insert = wrkMastMapper.insert(wrkMast); |
| | | if (insert == 0) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(startupDto.getLocNo()); |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)){ |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | |
| | | // 更新站点信息 且 下发plc命令 |
| | | staProtocol.setWorkNo((short) workNo); |
| | | staProtocol.setStaNo(startupDto.getStaNo().shortValue()); |
| | | staProtocol.setPakMk(false); |
| | | staProtocol.setInreq1(false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | |
| | | staProtocol.setPakMk(false); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | } |