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> addPrintFile(PrintFile file, User loginUser) {
    HashMap<String, Object> result = Maps.newHashMap();
    Map<String, Integer> params = Maps.newHashMap();

    logger.info("PrintFileService addPrintFile the file SHA1:{} ", file.getSha1());
    try {
      params.put("uid", loginUser.getId());
      // 根据唯一标识查找文件
      PrintFile tempFile = printFileDao.loadPrintFileBySHA1(file.getSha1());
      // 如果没有,则加入文件
      if (tempFile == null) {
        // 先添加文件到数据库
        printFileDao.addPrintFile(file);
        PrintFile fileBySHA1 = printFileDao.loadPrintFileBySHA1(file.getSha1());
        params.put("pid", fileBySHA1.getId());
        logger.info("PrintFileService addPrintFile the file is not existed, add the file success");
        // 如果有,则多个用户同用一个文件
      } else {
        /** 如果根据sha1找到了文件, 就根据登陆用户去找到这个文件的id,如果此id已经存在,则返回,如果不存在则添加关联 */
        params.put("pid", tempFile.getId());
        String pidByUid = printFileDao.loadPidByUid(params);
        if (!Strings.isNullOrEmpty(pidByUid) && (Integer.parseInt(pidByUid) == tempFile.getId())) {
          result.put("status", 1);
          result.put("message", "不能重复添加文件");
          logger.error(
              "PrintFileServiceImpl addPrintFile, with the same openId, file is not allowed to repeated");
          return result;
        }
        logger.info("PrintFileService addPrintFile the file is existed, only add the Relationship");
      }
      // 向中间表添加关联
      printFileDao.addTUP(params);
      logger.info("PrintFileService addPrintFile the Relationship:{}", params);
    } catch (Exception e) {
      result.put("status", 1);
      result.put("message", "添加文件失败,详情请查看日志");
      logger.error("PrintFileServiceImpl addPrintFile fail : {} ", e);
      return result;
    }
    result.put("status", 0);
    result.put("message", "添加文件成功");
    logger.info(
        "PrintFileServiceImpl addPrintFile success, The file:{}, the result:{}", file, result);
    return result;
  }