public HashMap<String, Object> print(String openid, String state) {
    HashMap<String, Object> result = Maps.newHashMap();
    HashMap<String, Object> params = Maps.newHashMap();
    logger.info("PrintFileService print openid:{}, state:{} ", openid, state);

    User tuser = userDao.loadUserByOpenId(openid);
    // 如果此用户没有绑定,或者微信号不相等,则打印错误
    if (tuser == null) {
      result.put("status", 1);
      result.put("message", "文件打印失败,此微信没有绑定,请用正确的微信号扫描");
      logger.error("PrintFileServiceImpl print error, error is : weixin is not bindinged");
      return result;
    }

    // 如果绑定,通过uid查找到所有待打印文件
    params.put("uid", tuser.getId());
    params.put("status", "0");
    params.put("rows", 0);
    params.put("offset", 100);
    logger.info("PrintFileServiceImpl print params:{}", params);
    List<PrintFile> files = printFileDao.findPrintFiles(params);
    logger.info("PrintFileServiceImpl print files:{}", files);
    if (files.size() <= 0) {
      result.put("status", 1);
      result.put("message", "没有待打印文件,请确认");
      logger.error("PrintFileServiceImpl printfiles There are no files being ready to printed");
      return result;
    }

    //     考虑要不要一次性将  files数组写过去
    for (int i = 0; i < files.size(); i++) {
      PrintFile file = files.get(i);
      logger.info("PrintFileServiceImpl printfiles The file is ready to printed, file:{}", file);
      // TODO 新建一个Task,调用客户端进行打印操作
      byte[] bytes = CPHelps.parseObjectToByte(file);
      CommonRes<String> toClient = CPHelps.writeByteToClient(bytes, state);
      if (!toClient.isSuccess()) {
        result.put("status", 1);
        result.put("message", toClient.getErrorMsg());
        logger.error("PrintFileServiceImpl printfiles go to client, e:{}", toClient.getErrorMsg());
        return result;
      }
    }

    result.put("status", 0);
    result.put("message", "文件打印成功");
    logger.info("PrintFileServiceImpl print success!!! result:{}", result);
    return result;
  }
  public HashMap<String, Object> findPrintFiles(int uid, int pageNow, int status) {
    HashMap<String, Object> result = Maps.newHashMap();
    HashMap<String, Object> params = Maps.newHashMap();
    logger.info(
        "PrintFileService findAllPrintFile uid:{}, pageNow:{}, status:{}", uid, pageNow, status);

    int pageNum = 0; // 总页数
    int offeset = CPConstant.OFFSET; // 每页默认显示10条
    List<PrintFile> files = null;
    try {
      params.put("uid", uid);
      params.put("status", status);
      int pageCount = printFileDao.findPrintFilesCount(params);
      pageNum =
          pageCount % CPConstant.SHOW_NUMBER == 0
              ? pageCount / CPConstant.SHOW_NUMBER
              : pageCount / CPConstant.SHOW_NUMBER + 1;

      int rows = pageNow * CPConstant.SHOW_NUMBER; // 从多少条开始
      params.put("rows", rows);
      params.put("offset", offeset);
      files = printFileDao.findPrintFiles(params);
      logger.info(
          "PrintFileServiceImpl findPrintFiles the sql of params:{}, pageCount:{}",
          params,
          pageCount);
    } catch (Exception e) {
      result.put("status", 1);
      result.put("message", "查找文件失败,详情请查看日志");
      logger.error("PrintFileServiceImpl findPrintFiles fail e:{} ", e);
    }

    result.put("status", 0);
    result.put("files", files);
    result.put("message", "查找文件成功");
    result.put("totalPage", pageNum); // 总页数
    result.put("nextPageNum", pageNow + 1); // 下一页
    logger.info("PrintFileServiceImpl findPrintFiles success, result:{}", result);
    return result;
  }