| | |
| | | package com.zy.acs.conveyor.core.operation.handler; |
| | | |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.conveyor.core.constant.RedisConveyorConstant; |
| | | import com.zy.acs.conveyor.core.enums.ConveyorStateType; |
| | | import com.zy.acs.conveyor.core.model.StaProtocol; |
| | | import com.zy.acs.conveyor.core.operation.OperationHandler; |
| | | import com.zy.acs.conveyor.core.properties.CtuOperationConfig; |
| | | import com.zy.acs.conveyor.core.properties.DevpSlave; |
| | | import com.zy.acs.conveyor.core.properties.SlaveProperties; |
| | | import com.zy.acs.conveyor.core.service.StationService; |
| | | import com.zy.acs.conveyor.entity.Job; |
| | | import com.zy.acs.conveyor.enums.WorkNoTypeType; |
| | | import com.zy.acs.conveyor.service.CtuMainService; |
| | | import com.zy.acs.conveyor.service.JobService; |
| | | import com.zy.acs.conveyor.service.WrkLastnoService; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.conveyor.core.cache.MessageQueue; |
| | | import com.zy.acs.conveyor.core.cache.SlaveConnection; |
| | | import com.zy.acs.conveyor.core.enums.ConveyorStateType; |
| | | import com.zy.acs.conveyor.core.enums.SlaveType; |
| | | import com.zy.acs.conveyor.core.enums.TaskType; |
| | | import com.zy.acs.conveyor.core.properties.DevpSlave; |
| | | import com.zy.acs.conveyor.core.model.Task; |
| | | import com.zy.acs.conveyor.core.model.protocol.StaProtocol; |
| | | import com.zy.acs.conveyor.core.operation.OperationHandler; |
| | | import com.zy.acs.conveyor.core.properties.CtuOperationConfig; |
| | | import com.zy.acs.conveyor.core.properties.SlaveProperties; |
| | | import com.zy.acs.conveyor.core.thread.SiemensDevpThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Component |
| | |
| | | @Autowired |
| | | private JobService jobService; |
| | | |
| | | @Autowired |
| | | private StationService stationService; |
| | | |
| | | private final RedisSupport redis = RedisSupport.defaultRedisSupport; |
| | | |
| | | |
| | | @Override |
| | | public ConveyorStateType getType() { |
| | |
| | | // 遍历出库口 |
| | | for (DevpSlave.Sta releaseSta : devp.getReleaseSta()) { |
| | | // 获取入库站信息 |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(releaseSta.getStaNo()); |
| | | Map<Integer, StaProtocol> stationMap = stationService.getStationMap(devp.getId()); |
| | | StaProtocol staProtocol = stationMap.get(releaseSta.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | |
| | | if (!jobService.insert(job)) { |
| | | throw new CoolException("插入输送线任务失败," + jobBySeqNum + " - " + workNo); |
| | | } |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(TaskType.WRITE, staProtocol)); |
| | | if (result) { |
| | | log.info("输送线下发:{},{}", staProtocol.getWorkNo(), releaseSta.getTargetSta()); |
| | | } else { |
| | | log.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | } |
| | | redis.push(RedisConveyorConstant.CONVEYOR_TASK_FLAG, staProtocol); |
| | | log.info("输送线下发:{},{}", staProtocol.getWorkNo(), releaseSta.getTargetSta()); |
| | | } |
| | | } else { |
| | | log.info("站点信息不符合入库条件!!!" + " 调用RCS检验未通过,站点:{}", staProtocol.getSiteId()); |