コード例 #1
0
  /**
   * 获取供应商的详细信息(保证金等信息)
   *
   * @param requirementId 需求编号
   * @param solution 需求方案信息
   * @param categoryIds 需求类目信息
   * @return SupplierSolutionDto 供应商详细信息
   */
  private SupplierSolutionDto querySupplierDto(
      Long requirementId, RequirementSolution solution, List<Long> categoryIds) {
    SupplierSolutionDto supplierSolutionDto = new SupplierSolutionDto();

    supplierSolutionDto.setSupplierId(solution.getSupplierId());
    supplierSolutionDto.setSupplierName(solution.getSupplierName());
    supplierSolutionDto.setUserId(solution.getUserId());
    // 是否已提交方案
    supplierSolutionDto.setDealTime(
        solution.getSolutionFile() == null ? null : solution.getUpdatedAt());

    // 写入供应商信用等级信息
    Response<SupplierCreditQualify> creditRes =
        supplierCreditQualifyService.findCreditQualifyByUserId(solution.getUserId());
    supplierSolutionDto.setCreditStatus(
        creditRes.isSuccess() ? creditRes.getResult().getStatus() : null);

    // 写入供应商资质验证信息
    Response<Integer> qualifyRes =
        supplierResourceMaterialService.getInfoInBcIds(solution.getSupplierId(), categoryIds);
    supplierSolutionDto.setQualifyStatus(qualifyRes.isSuccess() ? qualifyRes.getResult() : null);

    // 写入供应商针对需求是否提交保证金
    Response<Integer> depositRes =
        depositService.checkPaid(requirementId, solution.getSupplierId());
    supplierSolutionDto.setPaidStatus(
        depositRes.isSuccess() ? depositRes.getResult() : Deposit.Status.INIT.value());

    // 标注供应商是否可以进入配额流程
    supplierSolutionDto.setSolutionStatus(
        Objects.equal(
            RequirementSolution.Status.from(solution.getStatus()),
            RequirementSolution.Status.SEND_END));

    Response<User> userRes = accountService.findUserById(solution.getUserId());
    supplierSolutionDto.setSupplierTags(
        userRes.isSuccess() ? userRes.getResult().buildTags() : null);

    // 当阶段到达,已上传文件阶段则默认为全部承诺
    Integer interStatus =
        solution.getStatus() == 0 ? 1 : (solution.getStatus() >= 4 ? 2 : solution.getStatus());
    supplierSolutionDto.setInteractiveStatus(interStatus);

    return supplierSolutionDto;
  }
コード例 #2
0
  @Override
  public Response<Boolean> signSecrecy(Long requirementId, Integer signType, BaseUser user) {
    Response<Boolean> result = new Response<Boolean>();

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

    // 验证用户是否已登入
    if (user == null) {
      log.error("create requirement solution, user must login.");
      result.setError("user.not.login");
      return result;
    }

    try {
      // 是否是供应商
      if (Objects.equal(user.getType(), User.Type.SUPPLIER.value())) {
        // 验证供应商信息是否完整(不完整无法显示需求详情)
        Response<Boolean> checkRes = companyService.isComplete(user.getId());
        if (!checkRes.isSuccess()) {
          log.error("check user complete info failed, error code={}", checkRes.getError());
          result.setError(checkRes.getError());
          return result;
        }

        if (!checkRes.getResult()) {
          log.error("company info is not complete.");
          result.setError("requirement.company.noComplete");
          return result;
        }
      } else {
        // 采购商直接跳转
        result.setResult(true);
        return result;
      }

      // 查询供应商保密协议是否已签订
      if (signType == null) {
        // 查询登录的供应商是否已经淘汰
        Response<User> supplier = accountService.findUserById(user.getId());
        if (Objects.equal(supplier.getResult().getStep(), User.Step.DIE_OUT.value())) {
          log.error("supplier is die_out.");
          result.setError("supplier.is.dieout");
          return result;
        }
        // 查询登录供应商是否绩效的质量得分在60下
        Response<SupplierTQRDCInfo> suTQRDinfo =
            companyService.findSupplierLastTQRDCInfoByUserId(user.getId());
        if (suTQRDinfo.getResult().getQualityScore() != null) {
          if (suTQRDinfo.getResult().getQualityScore() < 60) {
            log.error("supplier quality score less.");
            result.setError("supplier.quality.less");
            return result;
          }
        }
        // 在淘汰供应商物料明细表中的也不让查看
        Response<Company> comtemp = companyService.findCompanyByUserId(user.getId());
        if (!comtemp.isSuccess()) {
          log.error("query company failed, error code={}", comtemp.getError());
          result.setError(comtemp.getError());
          return result;
        }
        if (comtemp.getResult().getSupplierCode() != null
            || comtemp.getResult().getSupplierCode() != "") {
          List<SupplierModuleDetail> templ =
              supplierModuleDetailService
                  .findBySupplierCode(comtemp.getResult().getSupplierCode())
                  .getResult();
          if (templ.size() > 0) {
            log.error("supplier module Detail have.");
            result.setError("supplier.module.detail.have.some");
            return result;
          }
        }

        RequirementSolution solution =
            requirementSolutionDao.findByUserId(requirementId, user.getId());
        result.setResult(solution != null);
      } else {
        RequirementSolution solution = new RequirementSolution();

        // 获取用户对应的供应商信息
        Response<Company> companyRes = companyService.findCompanyByUserId(user.getId());
        if (!companyRes.isSuccess()) {
          log.error("query company failed, error code={}", companyRes.getError());
          result.setError(companyRes.getError());
          return result;
        }

        // 判断供应商是否已经签订过协议
        Response<RequirementSolution> existRes =
            existSolution(requirementId, companyRes.getResult().getId());
        if (!existRes.isSuccess()) {
          log.error("check solution existed failed, error code={}", existRes.getError());
          result.setError(existRes.getError());
          return result;
        }
        if (existRes.getResult() != null) {
          log.error("supplier have send solution,can't send again.");
          result.setError("solution.sign.failed");
          return result;
        }

        // 获取需求信息
        Requirement requirement = requirementDao.findById(requirementId);
        solution.setRequirementId(requirementId);
        solution.setRequirementName(requirement.getName());
        solution.setSupplierId(companyRes.getResult().getId());
        solution.setSupplierName(companyRes.getResult().getCorporation());
        solution.setUserId(user.getId());
        // 默认的T评分
        solution.setTechnology(TECHNOLOGY);

        // 签订保证协议
        solution.setStatus(RequirementSolution.Status.SIGN_CONF.value());

        if (requirementSolutionDao.create(solution) != null) {
          // 增加供应商的方案统计数据
          SupplierSolutionCount supplierSolutionCount = new SupplierSolutionCount();
          supplierSolutionCount.setUserId(user.getId());
          supplierSolutionCount.setUserName(user.getName());
          supplierSolutionCount.setStatusCounts(ImmutableMap.of(requirement.getStatus(), 1));

          solutionCountService.setSupCount(supplierSolutionCount);

          // 供应商交互方案统计
          solutionCountService.setSolCountInfo(user.getId(), SolutionCountType.MUTUAL_SOL, 1);

          result.setResult(true);
        } else {
          result.setError("solution.sign.failed");
        }
      }
    } catch (Exception e) {
      log.error(
          "find user sign requirement solution failed, requirementId={}, userId={}, error code={}",
          requirementId,
          user.getId(),
          Throwables.getStackTraceAsString(e));
      result.setError("solution.find.failed");
    }

    return result;
  }