/**
   * 通过需求编号&需求状态数组判断当前的需求的状态是否符合
   *
   * @param requirementId 需求编号
   * @param statuses 需求状态编号
   * @return Boolean 返回需求状态是否符合条件
   */
  private Response<Boolean> checkRequirementStatus(
      Long requirementId, RequirementStatus[] statuses) {
    Response<Boolean> result = new Response<Boolean>();

    try {
      Requirement requirement = requirementDao.findById(requirementId);

      // 验证状态是否符合
      for (RequirementStatus status : statuses) {
        if (Objects.equal(status, RequirementStatus.from(requirement.getStatus()))) {
          result.setResult(true);
          return result;
        }
      }
    } catch (Exception e) {
      log.error(
          "check requirement status failed, requirementId={}, statuses={}, error code={}",
          requirementId,
          statuses,
          Throwables.getStackTraceAsString(e));
      result.setError("requirement.find.failed");
    }

    result.setResult(false);
    return result;
  }
  @Override
  public Response<List<RequirementSolution>> findAllSolution(Long requirementId, Integer status) {
    Response<List<RequirementSolution>> result = new Response<List<RequirementSolution>>();

    if (requirementId == null) {
      log.error("find requirement solution need requirementId");
      result.setError("solution.requirementId.null");
      return result;
    }

    if (RequirementStatus.from(status) == null) {
      log.error("can't find the status type.");
      result.setError("requirement.status.null");
      return result;
    }

    // 当查询阶段为空时默认方案交互阶段
    Objects.firstNonNull(status, 3);

    try {
      List<RequirementSolution> solutionList;
      if (Objects.equal(RequirementStatus.SOL_END, RequirementStatus.from(status))) {
        // 当处于方案终投阶段(只能查询到最终确认最终方案的供应商的方案)
        solutionList =
            requirementSolutionDao.findSolutionEnds(
                requirementId, null, 5, RequirementSolution.Status.SEND_END.value());
      } else {
        solutionList = requirementSolutionDao.findAllSolution(requirementId);
      }
      result.setResult(solutionList);
    } catch (Exception e) {
      log.error(
          "find requirement solution failed, requirementId={}, error code={}",
          requirementId,
          Throwables.getStackTraceAsString(e));
      result.setError("requirement.find.failed");
    }

    return result;
  }
  /**
   * 根据需求信息查询需求对应的阶段下的方案是否符合最终的提交要求
   *
   * @param requirement 需求信息
   * @param requirementSolution 用户的方案信息
   * @return Boolean 返回检验信息
   */
  private Response<Boolean> checkReqStatusWithSol(
      Requirement requirement, RequirementSolution requirementSolution) {
    Response<Boolean> result = new Response<Boolean>();

    // 是否是方案终投阶段
    if (Objects.equal(RequirementStatus.SOL_END, RequirementStatus.from(requirement.getStatus()))) {
      // 技术领先、差异化必须要提交方案(solutionFile:上传的详细的方案文档)其它场景不需要
      if (Objects.equal(Tactics.from(requirement.getTacticsId()), Tactics.TECHNOLOGY_NEW)
          || Objects.equal(Tactics.from(requirement.getTacticsId()), Tactics.DIFFERENTIATION)) {
        if (requirementSolution.getSolutionFile() == null
            || requirementSolution.getSolutionFile().isEmpty()) {
          log.error("jump to requirement solution end need send solution file.");
          result.setError("solution.file.null");
          return result;
        }
      }

      // todo 添加判断用户是否已经提交报价单文档

      // 模块方案信息
      List<ModuleSolution> solutions =
          moduleSolutionDao.findAllSolutions(requirementSolution.getId());

      // 模块报价信息
      List<ModuleQuotation> quotations =
          moduleQuotationDao.findAllQuotations(requirementSolution.getId());

      // 获取需求详细的模块数量
      Integer actualModuleNum = requirement.getModuleNum();

      // 判断模块的TQRD信息是否填写完整
      if (!Objects.equal(actualModuleNum, solutions.size())) {
        log.error("send solution to end status, the module solution info must be enter.");
        result.setError("moduleSol.info.null");
        return result;
      }

      // 判断是否填写完整的模块报价信息
      if (!Objects.equal(actualModuleNum, quotations.size())) {
        log.error("send solution to end status, the module quotation info must be enter.");
        result.setError("moduleQuo.info.null");
        return result;
      }

      // 验证TQRD数据是否已全部填写
      for (ModuleSolution solution : solutions) {
        if (solution.getTechnology() == null
            || solution.getQuality() == null
            || solution.getReaction() == null
            || solution.getDelivery() == null) {
          log.error("send solution to end status, the module solution info must be enter.");
          result.setError("moduleSol.info.null");
          return result;
        }
      }

      // 验证报价数据是否填写完整
      for (ModuleQuotation quotation : quotations) {
        if (quotation.getSolutionId() == null
            || quotation.getModuleId() == null
            || quotation.getPrice() == null
            || Strings.isNullOrEmpty(quotation.getCoinType())
            || quotation.getExchangeRate() == null) {
          log.error("send solution to end status, the module quotation info must be enter.");
          result.setError("moduleQuo.info.null");
          return result;
        }
      }

      result.setResult(true);
    } else {
      log.error("requirement status don't allow requirement solution end.");
      result.setError("solution.status.not.end");
      return result;
    }

    return result;
  }