123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- package com.gzlh.device.led.handler.impl;
- import cn.hutool.core.util.StrUtil;
- import com.gzlh.bus.EventDataManager;
- import com.gzlh.config.SystemObject;
- import com.gzlh.device.led.action.LedAction;
- import com.gzlh.device.led.brand.LedBrandType;
- import com.gzlh.device.led.client.LedNettyConfig;
- import com.gzlh.device.led.handler.ILedHandler;
- import com.gzlh.device.led.utils.FengLiYuanPackUtils;
- import com.gzlh.device.led.utils.LedOptions;
- import com.gzlh.entity.ReqBO;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.stereotype.Service;
- import org.springframework.util.StringUtils;
- import javax.annotation.Resource;
- @Service
- @Slf4j
- public class LedHandlerFengLiYuan implements ILedHandler {
- @Resource
- LedNettyConfig ledNettyConfig;
- @Override
- public LedBrandType brandType() {
- return LedBrandType.FENGLIYUAN;
- }
- @Override
- public void sendMsg(String content, LedOptions options) {
- log.info("丰利源发送led消息:{}", content);
- String msgHex = FengLiYuanPackUtils.build(content, options);
- log.info("数据包:{}", msgHex);
- ledNettyConfig.send(msgHex);
- }
- @Override
- public void handlerAction(String action) {
- if (StrUtil.contains(action, LedAction.LED_SHOW_CONTENT)) {
- LedOptions ledOptions = new LedOptions();
- // 默认显示到第一行
- ledOptions.setLine("01");
- action = action.substring(action.indexOf("(") + 1, action.indexOf(")"));
- if (StrUtil.contains(action, "|")) {
- String[] split = action.split("\\|");
- ledOptions.setLine(split[0]);
- action = split[1];
- }
- switch (ledOptions.getLine()) {
- case "02":
- ledOptions.setColor("05");
- break;
- case "03":
- ledOptions.setColor("04");
- break;
- case "04":
- ledOptions.setColor("01");
- break;
- default:
- ledOptions.setColor("06");
- break;
- }
- ReqBO reqBO = null;
- //展示内容
- if (StrUtil.contains(action, "platNo")) {
- String carNo = "";
- reqBO = EventDataManager.getCacheData();
- if (reqBO != null) {
- if (!StringUtils.isEmpty(reqBO.getCarNo())) {
- carNo = reqBO.getCarNo();
- }
- }
- ledOptions.setColor("05").setLine("02").setShowType("0B");
- sendMsg(carNo, ledOptions);
- } else if (StrUtil.contains(action, "weight")) {
- String weight = "";
- reqBO = EventDataManager.getCacheData();
- if (reqBO != null && reqBO.getWeight() != null) {
- weight = String.format("%.0f", EventDataManager.getCacheData().getWeight()).concat("kg");
- }
- ledOptions.setColor("04").setLine("03").setShowType("0B");
- sendMsg(weight, ledOptions);
- }else if (StrUtil.contains(action, "channel")) {
- ledOptions.setColor("06").setLine("01").setShowType("0B");
- sendMsg(SystemObject.applicationConfig.getChannelName(), ledOptions);
- } else {
- ledOptions.setShowType("00");
- sendMsg(action, ledOptions);
- }
- }
- }
- }
|