package com.bonus.canteen.core.notice.print.v2.business.impl;

import cn.hutool.core.util.ObjectUtil;
import com.bonus.canteen.core.common.thirdutils.jiabo.JbPrinterKeepLive;
import com.bonus.canteen.core.notice.print.v2.constant.PrinterDeviceTypeEnum;
import com.bonus.canteen.core.notice.print.v2.po.PrintResponsePO;
import com.bonus.canteen.core.notice.print.v2.vo.NoticePrintTemplateSettingVO;
import com.bonus.common.houqin.constant.LeConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Vector;

@Service
public class NoticePrinterJiaBoBusiness extends NoticePrinterAbstractJiaBoBusiness {
   private static final Logger log = LoggerFactory.getLogger(NoticePrinterJiaBoBusiness.class);

   public Integer getPrintStatus(String sn, String ip) {
      if (ObjectUtil.isEmpty(ip)) {
         return LeConstants.COMMON_NO;
      } else {
         try {
            String status = JbPrinterKeepLive.getPrinter().queryOnlineStatus(ip);
            return ObjectUtil.isEmpty(status) ? LeConstants.COMMON_NO : Integer.valueOf(status);
         } catch (Exception var4) {
            log.info("【佳博小票打印机查询状态】错误：{}", var4.getMessage(), var4);
            return LeConstants.COMMON_NO;
         }
      }
   }

//   protected PrintResponsePO executePrint(Map<String, String> paramMap, List<NoticePrintTemplateSettingVO> settingList, String sn, String ip, Long recordId) {
//      Vector<Byte> bytes = super.buildPrintData(paramMap, settingList);
//
//      try {
//         JbPrinterKeepLive.getPrinter().executePrint(bytes, ip, PrinterDeviceTypeEnum.TICKET_PRINTER.getKey());
//         return PrintResponsePO.getSuccessPO((String)null);
//      } catch (Exception var8) {
//         log.info("佳博打印机打印失败：ip:{},msg:{}", ip, var8.getMessage());
//         return PrintResponsePO.getFailPO((String)null);
//      }
//   }
}
