| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.BasRgv; |
| | | import com.zy.asrs.entity.BasSte; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.News; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.RgvSlave; |
| | | import com.zy.core.model.SteSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.SteCommand; |
| | | import com.zy.core.model.protocol.RgvProtocol; |
| | | 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.DevpThread; |
| | | import com.zy.core.thread.RgvThread; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | 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.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 立体仓库WCS系统主流程业务 |
| | | * Created by vincent on 2020/8/6 |
| | | */ |
| | | @Slf4j |
| | | @Service("mainService") |
| | | @Transactional |
| | | public class MainServiceImpl { |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | @Autowired |
| | | private BasRgvServiceImpl basRgvService; |
| | | /** |
| | | * 入库站,根据条码扫描生成入库工作档,工作状态1 |
| | | * 站点任务检测 下发小车取放任务 |
| | | */ |
| | | @Transactional |
| | | public void generateStoreWrkFile() { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历入库口 |
| | | for (DevpSlave.InSta 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 |
| | | && !Cools.isEmpty(barcode)) { |
| | | // 生成工作档 |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | public synchronized void updateStePosition() { |
| | | |
| | | } |
| | | /** |
| | | * 站点任务检测 下发小车取放任务 |
| | | */ |
| | | public synchronized void DevpTaskNoRun() { |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历空板入库口 |
| | | for (DevpSlave.Sta sta : devp.getInSta()) { |
| | | // 获取空板入库站信息 |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(sta.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public synchronized void loopSteCharge() { |
| | | for (RgvSlave rgv : slaveProperties.getRgv()) { |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgv.getId()); |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | BasRgv basRgv = basRgvService.selectById(rgv.getId()); |
| | | if (Cools.isEmpty(rgvProtocol, basRgv)) { continue; } |
| | | try { |
| | | // 在线 空闲 无作业标记 不在充电 |
| | | if (rgvProtocol.getMode() == 0 |
| | | || !rgvProtocol.statusType.equals(RgvStatusType.IDLE) |
| | | || basRgv.getPakMk().equals("Y") |
| | | // || steProtocol.getChargeStatus() == 1 |
| | | ) { |
| | | continue; |
| | | } |
| | | } catch (Exception e) { |
| | | News.error("fail", e); |
| | | } |
| | | } |
| | | } |
| | | } |