12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package com.gzlh.device.led.handler.impl;
- import cn.hutool.core.util.NumberUtil;
- import cn.hutool.core.util.StrUtil;
- import com.gzlh.bus.EventDataManager;
- import com.gzlh.bus.SysConfig;
- import com.gzlh.config.SystemObject;
- import com.gzlh.device.led.action.LedAction;
- import com.gzlh.device.led.utils.LedOptions;
- import com.gzlh.entity.ReqBO;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.util.StringUtils;
- @Slf4j
- public class LedCommonHandler {
- public static void handlerAction(String action) {
- //log.info("led handler action:{}", action);
- if (StrUtil.contains(action, LedAction.LED_SHOW_CONTENT)) {
- LedOptions ledOptions = new LedOptions();
- // 默认显示到第一行---红色字体
- String line = "01";
- ledOptions.setColor("01").setShowType("0B");
- action = action.substring(action.indexOf("(") + 1, action.indexOf(")"));
- if (StrUtil.contains(action, "|")) {
- String[] split = action.split("\\|");
- line = NumberUtil.isNumber(split[0]) ? split[0] : line;
- ledOptions.setLine(line);
- action = split[1];
- if (split.length == 3) {
- ledOptions.setColor(split[2]);
- }
- }
- ReqBO reqBO;
- String msg = "";
- //展示内容
- if (StrUtil.contains(action, "platNo")) {
- String carNo = "";
- reqBO = EventDataManager.getCacheData();
- if (!StringUtils.isEmpty(reqBO.getCarNo())) {
- carNo = reqBO.getCarNo();
- }
- ledOptions.setLine(line).setShowType("0B");
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand()).sendMsg(carNo, ledOptions);
- // sendMsg(carNo, ledOptions);
- } else if (StrUtil.contains(action, "weight")) {
- String weight = "";
- weight = String.format("%.0f", EventDataManager.getCacheData().getWeight()).concat("kg");
- ledOptions.setLine(line).setShowType("0B");
- if (StrUtil.equals("0kg", weight)) {
- weight = "";
- }
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand()).sendMsg(weight, ledOptions);
- //sendMsg(weight, ledOptions);
- } else if (StrUtil.contains(action, "channel")) {
- ledOptions.setLine(line).setShowType("0B").setTime("00").setType("01");
- String channelName = SysConfig.channelSetting.getChannelName();
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand()).sendMsg(channelName, ledOptions);
- } else {
- ledOptions.setShowType("00");
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand()).sendMsg(action, ledOptions);
- }
- } else if (StrUtil.equalsIgnoreCase(action, LedAction.INIT)) {
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand()).init();
- }
- }
- }
|