| New file |
| | |
| | | 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.service.JobService; |
| | | 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.Map; |
| | | |
| | | |
| | | /** |
| | | * 清理站点信号 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class ClearSingleOperationHandler implements OperationHandler { |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | |
| | | |
| | | @Autowired |
| | | private JobService jobService; |
| | | |
| | | |
| | | @Autowired |
| | | private StationService stationService; |
| | | |
| | | private final RedisSupport redis = RedisSupport.defaultRedisSupport; |
| | | |
| | | |
| | | @Override |
| | | public ConveyorStateType getType() { |
| | | return ConveyorStateType.CLEARSIGNAL; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void execute(CtuOperationConfig config) { |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历等待ctu取货站 |
| | | for (DevpSlave.Sta takeSta : devp.getTakeSta()) { |
| | | // 根据输送线plc遍历 |
| | | Map<Integer, StaProtocol> stationMap = stationService.getStationMap(devp.getId()); |
| | | StaProtocol staProtocol = stationMap.get(takeSta.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | // 判断是否满足条件 |
| | | if (staProtocol.isLoading()) { |
| | | continue; |
| | | } |
| | | if (staProtocol.getWorkNo() > 0 && staProtocol.isAutoing()) { |
| | | Job job = jobService.getJobByJobNo(staProtocol.getWorkNo()); |
| | | if (job != null && job.getJobSts() == ConveyorStateType.SENDTASK.getStatus()) { |
| | | //String s = ctuMainService.checkStationStatus(takeSta.getStaNo()); |
| | | staProtocol.setWorkNo(0); |
| | | staProtocol.setStaNo(0); |
| | | redis.push(RedisConveyorConstant.CONVEYOR_TASK_FLAG, staProtocol); |
| | | |
| | | log.info("" + config.getMark() + "站点清空失败:{},{}", takeSta.getStaNo(), staProtocol.getWorkNo()); |
| | | job.setJobSts(ConveyorStateType.CLEARSIGNAL.getStatus()); |
| | | jobService.updateById(job); |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | } |