| 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.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 FakeUserOperationHandler 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.FAKEUSER; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void execute(CtuOperationConfig config) { |
| | | |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | Map<Integer, StaProtocol> stationMap = stationService.getStationMap(1); |
| | | StaProtocol staProtocol = stationMap.get(1004); |
| | | if (staProtocol == null) { |
| | | return; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | // 判断是否满足条件 |
| | | if (!staProtocol.isLoading()) { |
| | | return; |
| | | } |
| | | StaProtocol staProtocol5 = stationMap.get(1005); |
| | | if (staProtocol5.isLoading()) { |
| | | log.info("1005有物,等无物之后才入库"); |
| | | return; |
| | | } |
| | | if (staProtocol.getWorkNo() > 0 && staProtocol.isAutoing()) { |
| | | Job jobByWorkNo = jobService.getJobByJobNoAndJobSts(staProtocol.getWorkNo(), ConveyorStateType.OUTBOUND.getStatus()); |
| | | if (jobByWorkNo != null && jobByWorkNo.getJobSts() == ConveyorStateType.OUTBOUND.getStatus()) { |
| | | staProtocol.setWorkNo(9992); |
| | | staProtocol.setStaNo(1005); |
| | | redis.push(RedisConveyorConstant.CONVEYOR_TASK_FLAG, staProtocol); |
| | | |
| | | jobByWorkNo.setJobSts(3); |
| | | jobByWorkNo.setMemo("模拟按按钮"); |
| | | jobService.updateById(jobByWorkNo); |
| | | log.info("入库输送线下发:{},{}", staProtocol.getWorkNo(), 1006); |
| | | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | } |