@Override public Response<Boolean> updateSolutionFile( Long requirementId, String solutionFile, BaseUser user) { Response<Boolean> result = new Response<Boolean>(); if (requirementId == null) { log.error("update requirement solution need requirementId"); result.setError("requirement.id.null"); return result; } if (Strings.isNullOrEmpty(solutionFile)) { log.error("update requirement solution file can't be null."); result.setError("solution.file.null"); return result; } // 验证用户是否已登入 if (user == null) { log.error("create requirement solution, user must login."); result.setError("user.not.login"); return result; } try { RequirementSolution solution = requirementSolutionDao.findByUserId(requirementId, user.getId()); // 处理历史文档 requirementSolutionDao.updateSolutionFile(solution.getId(), solutionFile); // 记录提交方案的供应商数量 requirementCountService.setReqCountInfo( solution.getRequirementId(), RequirementCountType.SEND_SO, 1); result.setResult(true); } catch (Exception e) { log.error( "update requirement solution failed, requirementId={}, solutionFile={}, error code={}.", requirementId, solutionFile, Throwables.getStackTraceAsString(e)); } return result; }
@Override public Response<Boolean> updateSolutionAccept( Long requirementId, String acceptInfo, BaseUser user) { Response<Boolean> result = new Response<Boolean>(); if (requirementId == null) { log.error("update requirement solution accept 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; } // 需要保证该方案处于3:方案交互 or 4:方案综投.需求才能被更改 RequirementStatus[] statuses = {RequirementStatus.SOL_INTERACTIVE, RequirementStatus.SOL_END}; Response<Boolean> statusRes = checkRequirementStatus(requirementId, statuses); if (!statusRes.isSuccess()) { log.error("check requirement status failed, error code={}", statusRes.getError()); result.setError(statusRes.getError()); return result; } if (!statusRes.getResult()) { log.error("requirement status can't allow suppler update solution."); result.setError("solution.status.notUpdate"); return result; } try { // 获取供应商提交的需求信息 RequirementSolution solution = requirementSolutionDao.findByUserId(requirementId, user.getId()); RequirementSolution newSolution = new RequirementSolution(); newSolution.setId(solution.getId()); newSolution.setNotAccept(acceptInfo); // 写入更改方案承诺后需求方案的状态 if (acceptInfo == null) { // 全部承诺 newSolution.setStatus(RequirementSolution.Status.ALL_ACCEPT.value()); // 记录提交方案的供应商数量 requirementCountService.setReqCountInfo(requirementId, RequirementCountType.SEND_SO, 1); // 记录供应商承诺目标的数量 solutionCountService.setSolCountInfo(user.getId(), SolutionCountType.ACCEPT_SOL, 1); } else { if (acceptInfo.length() > 2048) { log.error("accept info is to long"); result.setError("solution.accept.toLong"); return result; } newSolution.setStatus(RequirementSolution.Status.LITTLE_ACCEPT.value()); } // 更新需求的承诺信息 result.setResult(requirementSolutionDao.update(newSolution)); } catch (Exception e) { log.error( "update requirement solution accept failed, requirementId={}, error code={}", requirementId, Throwables.getStackTraceAsString(e)); result.setError("solution.update.failed"); } return result; }