| | |
| | | |
| | | |
| | | public String getLocTypeStr() { |
| | | if (high){ |
| | | if (high) { |
| | | return "高"; |
| | | } |
| | | if (low){ |
| | | if (low) { |
| | | return "低"; |
| | | } |
| | | if (mid){ |
| | | if (mid) { |
| | | return "中"; |
| | | } |
| | | return "-"; |
| | |
| | | |
| | | private ScheduledExecutorService executorService; |
| | | |
| | | private final AtomicBoolean running = new AtomicBoolean(false); |
| | | |
| | | private long lastDbUpdateTime = 0; |
| | | |
| | |
| | | executorService = Executors.newSingleThreadScheduledExecutor(r -> { |
| | | Thread thread = new Thread(r); |
| | | thread.setName("cv-background-thread"); |
| | | thread.setDaemon(true); |
| | | //thread.setDaemon(true); |
| | | return thread; |
| | | }); |
| | | |
| | |
| | | properties.getInitialDelay(), |
| | | properties.getInterval(), |
| | | TimeUnit.MILLISECONDS); |
| | | running.set(true); |
| | | News.info("输送线后台服务线程初始化完成"); |
| | | } |
| | | |
| | | private void processConveyorTasks() { |
| | | // 系统运行状态判断 |
| | | if (!SystemProperties.WCS_RUNNING_STATUS.get() || !running.get()) { |
| | | if (!SystemProperties.WCS_RUNNING_STATUS.get()) { |
| | | News.info("系统未运行或服务已停止,跳过输送线任务处理"); |
| | | return; |
| | | } |
| | |
| | | News.info("执行输送线操作"); |
| | | lastDbUpdateTime = currentTime; |
| | | } |
| | | try { |
| | | // 执行配置的操作序列 |
| | | for (CtuOperationConfig config : properties.getOperations()) { |
| | | |
| | | // 执行配置的操作序列 |
| | | for (CtuOperationConfig config : properties.getOperations()) { |
| | | try { |
| | | operationExecutor.execute(config); |
| | | } catch (Exception e) { |
| | | News.error("输送线操作执行最终失败, type={}, error={}", config.getType(), e.getMessage()); |
| | | // 可选:发送告警、暂停调度等 |
| | | } |
| | | } catch (Exception e) { |
| | | News.error("输送线任务处理异常,{}", e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | @PreDestroy |
| | | public void shutDown() { |
| | | running.set(false); |
| | | if (executorService != null && !executorService.isShutdown()) { |
| | | News.info("正在关闭输送线后台服务线程..."); |
| | | executorService.shutdown(); |
| | |
| | | News.warn("未找到操作处理器: {}", config.getType()); |
| | | return; |
| | | } |
| | | |
| | | int retryCount = 0; |
| | | while (retryCount < config.getMaxRetries()) { |
| | | try { |
| | | handler.execute(config); |
| | | return; |
| | | } catch (Exception e) { |
| | | retryCount++; |
| | | if (retryCount >= config.getMaxRetries()) { |
| | | News.error("操作执行失败,已达到最大重试次数: {}", config.getType(), e); |
| | | } else { |
| | | News.warn("操作执行失败,正在重试({}/{})", |
| | | retryCount, config.getMaxRetries(), e); |
| | | try { |
| | | Thread.sleep(config.getRetryDelay()); |
| | | } catch (InterruptedException ie) { |
| | | Thread.currentThread().interrupt(); |
| | | News.error("重试休眠被中断", ie); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | try { |
| | | handler.execute(config); |
| | | } catch (Exception e) { |
| | | News.error("操作执行失败,等待下一周期重试: {}", config.getType(), e); |
| | | } |
| | | } |
| | | } |
| | |
| | | News.error("{}:站点:{},无物", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if (staProtocol.isErr()){ |
| | | if (staProtocol.isErr()) { |
| | | if (staProtocol.isFrontErr()) { |
| | | News.error("{}:站点:{},前超限", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | |
| | | News.error("{}:站点:{},后超限", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if ( staProtocol.isHighErr()) { |
| | | if (staProtocol.isHighErr()) { |
| | | News.error("{}:站点:{},高超限", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if ( staProtocol.isLeftErr()) { |
| | | if (staProtocol.isLeftErr()) { |
| | | News.error("{}:站点:{},左超限", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if ( staProtocol.isRightErr()) { |
| | | if (staProtocol.isRightErr()) { |
| | | News.error("{}:站点:{},右超限", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | |
| | | News.error("{}:站点:{},超重或", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | | if ( staProtocol.isBarcodeErr()) { |
| | | if (staProtocol.isBarcodeErr()) { |
| | | News.error("{}:站点:{},扫码失败", config.getMark(), staProtocol.getSiteId()); |
| | | continue; |
| | | } |
| | |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.conveyor.controller.vo.OpenBusSubmitParam; |
| | | import com.zy.acs.conveyor.controller.vo.TaskDto; |
| | | 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; |
| | |
| | | staProtocol.setStartUpFlag(false); |
| | | redis.push(RedisConveyorConstant.CONVEYOR_TASK_FLAG, staProtocol); |
| | | if (!jobService.insert(job)) { |
| | | News.info("{},启动入库:工作号:{},目标站点:{},满:{},空:{}", config.getMark(), staProtocol.getWorkNo(), staProtocol.getStaNo(),staProtocol.isFullPlt(),staProtocol.isEmptyMk()); |
| | | News.info("{},启动入库:工作号:{},目标站点:{},满:{},空:{}", config.getMark(), staProtocol.getWorkNo(), staProtocol.getStaNo(), staProtocol.isFullPlt(), staProtocol.isEmptyMk()); |
| | | } |
| | | } |
| | | |
| | |
| | | public class CtuOperationConfig { |
| | | private ConveyorStateType type; |
| | | private String mark; |
| | | private int maxRetries = 3; |
| | | private long retryDelay = 500; |
| | | private Map<String, Object> params = new HashMap<>(); |
| | | } |
| | |
| | | import HslCommunication.Profinet.Siemens.SiemensS7Net; |
| | | import com.zy.acs.common.utils.News; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.conveyor.core.constant.*; |
| | | import com.zy.acs.conveyor.core.constant.RedisConveyorConstant; |
| | | import com.zy.acs.conveyor.core.enums.DeviceField; |
| | | import com.zy.acs.conveyor.core.enums.PlcAlarmDefinition; |
| | | import com.zy.acs.conveyor.core.enums.SafeSignalField; |
| | |
| | | .setJson(JSON.toJSONString(applyInDto)) |
| | | .build() |
| | | .doPost(); |
| | | log.info("请求数据:{},WMS返回数据:{}", applyInDto,response); |
| | | log.info("请求数据:{},WMS返回数据:{}", applyInDto, response); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.get(code) != null && jsonObject.getInteger(code).equals(codeValue)) { |
| | | return JSONObject.parseObject(jsonObject.getString(dataCode), ApplyInRepsonseDto.class); |
| | |
| | | operations: |
| | | - type: OUTBOUND |
| | | mark: 出库流程 |
| | | max-retries: 3 |
| | | retry-delay: 800 |
| | | - type: STARTUP |
| | | mark: 启动入库流程 |
| | | max-retries: 2 |
| | | retry-delay: 800 |
| | | - type: APPLYLOC |
| | | mark: 申请入库流程 |
| | | max-retries: 2 |
| | | retry-delay: 2000 |
| | | - type: CLEARSIGNAL |
| | | mark: 清理信号流程 |
| | | max-retries: 2 |
| | | retry-delay: 800 |
| | | - type: SENDTASK |
| | | mark: 发送任务RCS流程 |
| | | max-retries: 2 |
| | | retry-delay: 800 |
| | | |
| | | mybatis-plus: |
| | | mapper-locations: classpath:mapper/*.xml |