| | |
| | | package com.zy.core.operation.handler; |
| | | |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.Job; |
| | | import com.zy.asrs.service.CtuMainService; |
| | |
| | | import com.zy.core.operation.OperationHandler; |
| | | import com.zy.core.properties.CtuOperationConfig; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.BarcodeThread; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 入库 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void execute(CtuOperationConfig config) { |
| | | public synchronized void execute(CtuOperationConfig config) { |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | |
| | | return; |
| | | } |
| | | if (staProtocol.getWorkNo() > 0 && staProtocol.isAutoing()) { |
| | | //StaProtocol targetStaProtocol = devpThread.getStation().get(inSta.getTargetSta()); |
| | | //if (targetStaProtocol.getWorkNo() == 0 && targetStaProtocol.isAutoing() && !targetStaProtocol.isLoading()) { |
| | | Job job = jobService.getJobByJobNoAndJobSts(staProtocol.getWorkNo(), 2); |
| | | if (job != null) { |
| | | Integer workNo = staProtocol.getWorkNo(); |
| | | Integer targetSta = inSta.getTargetSta(); |
| | | staProtocol.setWorkNo(0); |
| | | staProtocol.setStaNo(0); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | | Thread.sleep(1500L); |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo(targetSta); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | | if (result) { |
| | | job.setJobSts(4); |
| | | job.setInTime(new Date()); |
| | | if (!jobService.updateById(job)) { |
| | | throw new CoolException("更新输送线任务失败," + " - " + staProtocol.getWorkNo()); |
| | | } |
| | | log.info("" + config.getMark() + "入库前进:{},{}", staProtocol.getWorkNo(), inSta.getTargetSta()); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, devp.getId()); |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if (Cools.isEmpty(barcode)){ |
| | | return; |
| | | } |
| | | Job job = jobService.getJobByBarcode(barcode); |
| | | if (job != null) { |
| | | Integer targetSta = inSta.getTargetSta(); |
| | | staProtocol.setWorkNo(job.getJobNo()); |
| | | staProtocol.setStaNo(targetSta); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | | if (result) { |
| | | job.setJobSts(5); |
| | | if (!jobService.updateById(job)) { |
| | | throw new CoolException("更新输送线任务失败," + " - " + staProtocol.getWorkNo()); |
| | | } |
| | | } else { |
| | | // 模拟操作逻辑 |
| | | log.info("" + config.getMark() + "入库前进:{},{}", staProtocol.getWorkNo(), inSta.getTargetSta()); |
| | | } |
| | | } else { |
| | | // 模拟操作逻辑 |
| | | } |
| | | //} |
| | | } |
| | | } |