@Override public Response<Paging<RequirementSolution>> findByRequirementId( Long requirementId, String statusArray, Integer pageNo, Integer size) { Response<Paging<RequirementSolution>> result = new Response<Paging<RequirementSolution>>(); if (requirementId == null) { log.error("find requirement solutions need requirementId"); result.setError("solution.requirementId.null"); return result; } try { Map<String, Object> params = Maps.newHashMap(); PageInfo pageInfo = new PageInfo(pageNo, Objects.firstNonNull(size, 10)); params.putAll(pageInfo.toMap()); params.put( "statusArray", statusArray == null ? null : Splitters.COMMA.splitToList(statusArray)); result.setResult(requirementSolutionDao.findByParams(requirementId, params)); } catch (Exception e) { log.error( "find requirement solutions failed, requirementId={}, error code={}", requirementId, Throwables.getStackTraceAsString(e)); result.setError("solution.find.failed"); } return result; }
@Override public Response<Paging<SupplierSolutionDto>> findSignByParam( final Long requirementId, Integer pageNo, Integer size) { Response<Paging<SupplierSolutionDto>> result = new Response<Paging<SupplierSolutionDto>>(); if (requirementId == null) { log.error("find requirement solution need requirementId"); result.setError("solution.requirementId.null"); return result; } try { Map<String, Object> params = Maps.newHashMap(); params.put("requirementId", requirementId); PageInfo pageInfo = new PageInfo(pageNo, Objects.firstNonNull(size, 10)); params.putAll(pageInfo.toMap()); Requirement requirement = requirementDao.findById(requirementId); // 获取需求下的供应商提交的方案 Paging<RequirementSolution> solutionPaging = requirementSolutionDao.findSolutionsByParams(params); // 获取后台三级类目信息 List<BackendJSON> categoryList = JSON_MAPPER.fromJson( requirement.getSeriesIds(), JSON_MAPPER.createCollectionType(List.class, BackendJSON.class)); List<Long> categoryIds = Lists.newArrayList(); for (BackendJSON backendJSON : categoryList) { categoryIds.add(backendJSON.getBcId()); } List<SupplierSolutionDto> supplierSolutionDtoList = Lists.newArrayList(); for (RequirementSolution solution : solutionPaging.getData()) { supplierSolutionDtoList.add(querySupplierDto(requirementId, solution, categoryIds)); } result.setResult( new Paging<SupplierSolutionDto>(solutionPaging.getTotal(), supplierSolutionDtoList)); } catch (Exception e) { log.error( "find requirement solution have sign secrecy failed , requirementId={} error code={}", requirementId, Throwables.getStackTraceAsString(e)); result.setError("solution.supplier.findFailed"); } return result; }
@Override public Response<Paging<Requirement>> findByParams( BaseUser user, Integer qualifyStatus, Integer status, String reqName, String startAt, String endAt, Integer pageNo, Integer size) { Response<Paging<Requirement>> result = new Response<Paging<Requirement>>(); // 验证用户是否已登入 if (user == null) { log.error("create requirement solution, user must login."); result.setError("user.not.login"); return result; } // 获取用户对应的供应商信息 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; } try { Map<String, Object> params = Maps.newHashMap(); params.put("name", Strings.isNullOrEmpty(reqName) ? null : reqName); params.put("qualifyStatus", qualifyStatus); params.put("status", status); params.put("startAt", startAt); params.put("endAt", endAt); PageInfo pageInfo = new PageInfo(pageNo, Objects.firstNonNull(size, 10)); params.putAll(pageInfo.toMap()); result.setResult(requirementDao.findBySupplier(companyRes.getResult().getId(), params)); } catch (Exception e) { log.error( "find requirement solutions failed, supplierId={}, error code={}", companyRes.getResult().getId(), Throwables.getStackTraceAsString(e)); result.setError("solution.find.failed"); } return result; }