/** * 通过需求编号&需求状态数组判断当前的需求的状态是否符合 * * @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; }
private List<Requirement> getRequirementList(String ReqProCSV) { ArrayList<Requirement> requirements = new ArrayList<Requirement>(); String[] lines = ReqProCSV.split("\n"); // Read File Line By Line int i = 0; for (String line : lines) { if (i == 0) { i++; continue; } if (line.startsWith("\"")) { String[] values = line.split("\",\""); Requirement requirement = new Requirement(); requirement.title = values[2]; if (requirement.title.endsWith("\"")) { requirement.title = requirement.title.substring(0, requirement.title.length() - 1); } requirement.description = values[1]; requirements.add(requirement); } } return requirements; }
public void testMergeRequirements() { Compiler compiler = createCompiler(); ConformanceConfig.Builder builder = ConformanceConfig.newBuilder(); builder.addRequirementBuilder().setRuleId("a").addWhitelist("x").addWhitelistRegexp("m"); builder.addRequirementBuilder().setExtends("a").addWhitelist("y").addWhitelistRegexp("n"); List<Requirement> requirements = CheckConformance.mergeRequirements(compiler, ImmutableList.of(builder.build())); assertThat(requirements).hasSize(1); Requirement requirement = requirements.get(0); assertEquals(2, requirement.getWhitelistCount()); assertEquals(2, requirement.getWhitelistRegexpCount()); }
void setRequirements(List<Requirement> requirements) { allRequirements = requirements; requirementMap = new HashMap<String, List<Requirement>>(); for (Requirement requirement : requirements) { List<Requirement> list = requirementMap.get(requirement.getNamespace()); if (list == null) { list = new LinkedList<Requirement>(); requirementMap.put(requirement.getNamespace(), list); } list.add(requirement); } }
@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; }
private static List<String> getRequirementList(Requirement requirement, String field) { switch (field) { case "whitelist": return requirement.getWhitelistList(); case "whitelist_regexp": return requirement.getWhitelistRegexpList(); case "only_apply_to": return requirement.getOnlyApplyToList(); case "only_apply_to_regexp": return requirement.getOnlyApplyToRegexpList(); default: throw new AssertionError("Unrecognized field: " + field); } }
@Override public Response<SupplierSolutionDto> findSolutionSupplier(Long requirementId, BaseUser user) { Response<SupplierSolutionDto> result = new Response<SupplierSolutionDto>(); if (requirementId == null) { log.error("find supplier info need requirementId"); result.setError("solution.requirementId.null"); return result; } // 验证用户是否已登入 if (user == null) { log.error("find supplier info, user must login."); result.setError("user.not.login"); return result; } try { if (Objects.equal(User.Type.from(user.getType()), User.Type.SUPPLIER)) { RequirementSolution solution = requirementSolutionDao.findByUserId(requirementId, user.getId()); Requirement requirement = requirementDao.findById(requirementId); // 获取后台三级类目信息 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()); } result.setResult(querySupplierDto(requirementId, solution, categoryIds)); } else { result.setResult(null); } } catch (Exception e) { log.error( "find supplier detail info failed, requirementId={}, error code={}", requirementId, Throwables.getStackTraceAsString(e)); result.setError("query.supplier.fail"); } return result; }
public CustomRuleReport(AbstractCompiler compiler, Requirement requirement) throws InvalidRequirementSpec { super(compiler, requirement); if (requirement.getValueCount() == 0) { throw new InvalidRequirementSpec("missing value"); } }
private static Rule initRule(AbstractCompiler compiler, Requirement requirement) { try { switch (requirement.getType()) { case CUSTOM: return new ConformanceRules.CustomRuleProxy(compiler, requirement); case BANNED_CODE_PATTERN: return new ConformanceRules.BannedCodePattern(compiler, requirement); case BANNED_DEPENDENCY: return new ConformanceRules.BannedDependency(compiler, requirement); case BANNED_NAME: return new ConformanceRules.BannedName(compiler, requirement); case BANNED_PROPERTY: case BANNED_PROPERTY_READ: case BANNED_PROPERTY_WRITE: case BANNED_PROPERTY_CALL: return new ConformanceRules.BannedProperty(compiler, requirement); case RESTRICTED_NAME_CALL: return new ConformanceRules.RestrictedNameCall(compiler, requirement); case RESTRICTED_METHOD_CALL: return new ConformanceRules.RestrictedMethodCall(compiler, requirement); default: reportInvalidRequirement(compiler, requirement, "unknown requirement type"); return null; } } catch (InvalidRequirementSpec e) { reportInvalidRequirement(compiler, requirement, e.getMessage()); return null; } }
/** * 根据需求信息查询需求对应的阶段下的方案是否符合最终的提交要求 * * @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; }
public ViewProject(int id) { initComponents(); currentProject = new Project(); currentProject.setProjectID(id); try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection( "jdbc:mysql://127.0.0.1:3306/projectmanagementsystem?zeroDateTimeBehavior=convertToNull", "root", "password"); String query2 = "select * from project where idproject = ?"; PreparedStatement pst2 = con.prepareStatement(query2); int projectid = id + 1; pst2.setInt(1, projectid); ResultSet rs = pst2.executeQuery(); if (rs.next()) { projectname.setText(rs.getString("projectname")); projectdescription.setText(rs.getString("projectdesc")); } String query3 = "select * from teammember where teammember_FK = ?"; PreparedStatement pst3 = con.prepareStatement(query3); pst3.setInt(1, projectid); ResultSet rs2 = pst3.executeQuery(); while (rs2.next()) { Person p = new Person(); p.setFirstName(rs2.getString("firstname")); p.setLastName(rs2.getString("lastname")); p.setPosition(rs2.getString("position")); p.setPersonID(rs2.getInt("idteammember")); teammembers.add(p); teammodel.addElement(p.getFirstName() + " " + p.getLastName() + " " + p.getPosition()); } teamlist.setModel(teammodel); String query4 = "select * from goal where goal_FK = ?"; PreparedStatement pst4 = con.prepareStatement(query4); pst4.setInt(1, projectid); ResultSet rs3 = pst4.executeQuery(); while (rs3.next()) { Goal g = new Goal(); g.setGoalID(rs3.getInt("idgoal")); g.setGoalDesc(rs3.getString("goaldesc")); g.setGoalType(rs3.getString("goaltype")); goals.add(g); goalmodel.addElement(g.getGoalType() + " " + g.getGoalDesc()); } goallist.setModel(goalmodel); String query5 = "select * from requirement where requirement_FK = ?"; PreparedStatement pst5 = con.prepareStatement(query5); pst5.setInt(1, projectid); ResultSet rs4 = pst5.executeQuery(); while (rs4.next()) { Requirement r = new Requirement(); String type; r.setRequirementID(rs4.getInt("idrequirement")); r.setRequirementDescription(rs4.getString("requirementdesc")); if (rs4.getInt("isFunctionalRequirement") == 0) { r.setIsFunctionalRequirement(false); type = "Non-functional"; } else type = "Functional"; requirements.add(r); requirementmodel.addElement(type + " " + r.getRequirementDescription()); } requirementlist.setModel(requirementmodel); String query6 = "select * from risk where risk_FK = ?"; PreparedStatement pst6 = con.prepareStatement(query6); pst6.setInt(1, projectid); ResultSet rs5 = pst6.executeQuery(); while (rs5.next()) { Risk r = new Risk(); r.setRiskID(rs5.getInt("idrisk")); r.setRiskName(rs5.getString("riskname")); r.setRiskStatus(rs5.getString("riskstatus")); risks.add(r); riskmodel.addElement(r.getRiskStatus() + " " + r.getRiskName()); } risklist.setModel(riskmodel); String query7 = "select * from effort join requirement on effort.effort_FK = requirement.idrequirement" + " where requirement.requirement_FK = ?"; PreparedStatement pst7 = con.prepareStatement(query7); pst7.setInt(1, projectid); ResultSet rs6 = pst7.executeQuery(); while (rs6.next()) { Effort e = new Effort(); e.setEffortID(rs6.getInt("ideffort")); e.setEffortDate(rs6.getString("effortdate")); e.setEffortDevPhase(rs6.getString("effortdevphase")); e.setEffortHours(rs6.getInt("efforthours")); e.setRequirementID(rs6.getInt("effort_FK")); e.setRequirementDesc(rs6.getString("requirementdesc")); efforts.add(e); effortmodel.addElement( "For req: " + e.getRequirementDesc() + " " + e.getEffortDevPhase() + " " + e.getEffortDate() + " " + e.getEffortHours()); } effortlist.setModel(effortmodel); } catch (Exception e) { System.out.println(e.toString()); } }
/** * This will return all of the sections and meetings wrapped in a CourseListing object for any * course given as a requirement * * @param requirement requirement object * @return CourseListing course listing object * @author Jason Beck */ public CourseListing getSections(Requirement requirement) { try { meetingsForCourse.setString(1, requirement.getReqCourseNumber()); meetingsForCourse.setString(2, requirement.getReqCoursePrefix()); ResultSet rs = meetingsForCourse.executeQuery(); ArrayList<ClassObj> classObjList = new ArrayList<ClassObj>(); String coursePrefix = "", courseNumber = "", courseTitle = ""; while (rs.next()) { // packs the record into a ClassObj object and adds to arraylist int callNumber = rs.getInt("callNumber"); coursePrefix = rs.getString("coursePrefix"); courseNumber = rs.getString("courseNumber").trim(); courseTitle = rs.getString("courseTitle"); String days = rs.getString("days"); String periodBegin = rs.getString("periodBegin"); String periodEnd = rs.getString("periodEnd"); String bldg = rs.getString("bldg"); String room = rs.getString("room"); classObjList.add( new ClassObj( callNumber, coursePrefix, courseNumber, courseTitle, days.trim(), periodBegin, periodEnd, bldg, room)); } CourseListing courseListing = new CourseListing(coursePrefix, courseNumber, courseTitle); for (int i = 0; i < classObjList.size(); ) { // packages up each ClassObj into appropriate sections and meetings under the CourseListing // object ClassObj classes = classObjList.get(i); ClassSection section = new ClassSection(classes.getCallNumber()); int tempCallNumber = classes.getCallNumber(); int j = i; while (tempCallNumber == classes.getCallNumber() && j < classObjList.size()) { // packages up a meeting(s) object and adds it to the list of meeting object in the // ClassSection object // when there are multiple class meetings under a single line of a class section if (classes.getDays().length() > 1) { String day = classes.getDays(); while (day.length() >= 1) { // packages up meeting objects and adds it to the list of meeting objects in the // ClassSection object // (for a single section that have multiple meeting days in it) ClassMeeting meeting = new ClassMeeting( day.substring(0, 1), classes.getPeriodBegin(), classes.getPeriodEnd(), classes.getBldg(), classes.getRoom()); // adds meeting to section object section.addClassMeetingList(meeting); // still more than 1 day left if (day.length() > 1) { day = day.substring(2); } // only 1 day left so break else break; } } // only meets 1 day for this section else { ClassMeeting meeting = new ClassMeeting( classes.getDays(), classes.getPeriodBegin(), classes.getPeriodEnd(), classes.getBldg(), classes.getRoom()); // adds meeting to section object section.addClassMeetingList(meeting); } i = ++j; // must check to make sure increment will not go out of bounds if (j < classObjList.size()) classes = classObjList.get(j); } // adds section to courseListing object courseListing.addClassSectionList(section); } return courseListing; } catch (SQLException e) { System.out.println(e.getClass().getName() + ": " + e.getMessage()); } return null; }
/** * Gets requirements from all configs. Merges whitelists of requirements with 'extends' equal to * 'rule_id' of other rule. */ static List<Requirement> mergeRequirements( AbstractCompiler compiler, List<ConformanceConfig> configs) { List<Requirement.Builder> builders = new ArrayList<>(); Map<String, Requirement.Builder> extendable = new HashMap<>(); for (ConformanceConfig config : configs) { for (Requirement requirement : config.getRequirementList()) { Requirement.Builder builder = requirement.toBuilder(); if (requirement.hasRuleId()) { if (requirement.getRuleId().isEmpty()) { reportInvalidRequirement(compiler, requirement, "empty rule_id"); continue; } if (extendable.containsKey(requirement.getRuleId())) { reportInvalidRequirement( compiler, requirement, "two requirements with the same rule_id: " + requirement.getRuleId()); continue; } extendable.put(requirement.getRuleId(), builder); } if (!requirement.hasExtends()) { builders.add(builder); } } } for (ConformanceConfig config : configs) { for (Requirement requirement : config.getRequirementList()) { if (requirement.hasExtends()) { Requirement.Builder existing = extendable.get(requirement.getExtends()); if (existing == null) { reportInvalidRequirement( compiler, requirement, "no requirement with rule_id: " + requirement.getExtends()); continue; } for (Descriptors.FieldDescriptor field : requirement.getAllFields().keySet()) { if (!EXTENDABLE_FIELDS.contains(field.getName())) { reportInvalidRequirement( compiler, requirement, "extending rules allow only " + EXTENDABLE_FIELDS); } } existing.addAllWhitelist(requirement.getWhitelistList()); existing.addAllWhitelistRegexp(requirement.getWhitelistRegexpList()); existing.addAllOnlyApplyTo(requirement.getOnlyApplyToList()); existing.addAllOnlyApplyToRegexp(requirement.getOnlyApplyToRegexpList()); } } } List<Requirement> requirements = new ArrayList<>(builders.size()); for (Requirement.Builder builder : builders) { Requirement requirement = builder.build(); checkRequirementList(compiler, requirement, "whitelist"); checkRequirementList(compiler, requirement, "whitelist_regexp"); checkRequirementList(compiler, requirement, "only_apply_to"); checkRequirementList(compiler, requirement, "only_apply_to_regexp"); requirements.add(requirement); } return requirements; }
@Override public Response<Boolean> createSolution(RequirementSolution solution, BaseUser user) { Response<Boolean> result = new Response<Boolean>(); // 验证用户是否已登入 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; } // 判断供应商是否已经对于需求进行了承诺 Response<RequirementSolution> existRes = existSolution(solution.getRequirementId(), 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.existed.error"); return result; } // 需要保证该方案处于3:方案交互 or 4:方案综投(采购商才能够创建方案) RequirementStatus[] statuses = {RequirementStatus.SOL_INTERACTIVE, RequirementStatus.SOL_END}; Response<Boolean> statusRes = checkRequirementStatus(solution.getRequirementId(), 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 send solution."); result.setError("solution.status.stop"); return result; } try { // 获取需求方案信息 Requirement requirement = requirementDao.findById(solution.getRequirementId()); solution.setRequirementName(requirement.getName()); solution.setSupplierId(companyRes.getResult().getId()); solution.setSupplierName(companyRes.getResult().getCorporation()); solution.setUserId(user.getId()); // 默认的T评分 solution.setTechnology(TECHNOLOGY); // 写入方案承诺后需求方案的状态 if (solution.getNotAccept() == null) { // 全部承诺 solution.setStatus(RequirementSolution.Status.ALL_ACCEPT.value()); } else { solution.setStatus(RequirementSolution.Status.LITTLE_ACCEPT.value()); } result.setResult(requirementSolutionDao.create(solution) != null); } catch (Exception e) { log.error( "create requirement solution failed, error code={}", Throwables.getStackTraceAsString(e)); result.setError("solution.create.failed"); } return result; }
@Override public Response<CheckSolEndDto> solutionEnd(Long requirementId, BaseUser user) { Response<CheckSolEndDto> result = new Response<CheckSolEndDto>(); // 验证用户是否已登入 if (user == null) { log.error("create requirement solution, user must login."); result.setError("user.not.login"); return result; } if (requirementId == null) { log.error("update requirement solution need requirementId"); result.setError("requirementId.id.null"); return result; } try { // 获取用户的需求方案信息 RequirementSolution requirementSolution = requirementSolutionDao.findByUserId(requirementId, user.getId()); // 获取需求信息 Requirement requirement = requirementDao.findById(requirementSolution.getRequirementId()); Response<Boolean> checkSupplier = checkSupplierInfo(requirementId, user); if (!checkSupplier.isSuccess()) { log.error( "check supplier info for requirement failed, error code={}", checkSupplier.getError()); result.setError(checkSupplier.getError()); return result; } Response<Boolean> checkRes = checkReqStatusWithSol(requirement, requirementSolution); if (!checkRes.isSuccess()) { log.error("check requirement & solution info failed, error code={}", checkRes.getError()); result.setError(checkRes.getError()); return result; } else { CheckSolEndDto checkSolEndDto = new CheckSolEndDto(); // 获取全部报价信息 List<ModuleQuotation> quotations = moduleQuotationDao.findAllQuotations(requirementSolution.getId()); // 获取全部的TQRDC信息 List<ModuleSolution> solutions = moduleSolutionDao.findAllSolutions(requirementSolution.getId()); Map<Long, ModuleSolution> solutionMap = Maps.newHashMap(); for (ModuleSolution solution : solutions) { solutionMap.put(solution.getModuleId(), solution); } // 计算整个需求的Q&R数据用于显示 Integer qualityValue = 0; Date maxReaction = null; Date cpmDate; List<Module> moduleList = moduleDao.findModules(requirementId); // 计算总的模块报价总权值 int error = 0; Integer totalValue = 0; for (ModuleQuotation quotation : quotations) { for (Module module : moduleList) { // 校验报价不能低于模块的价格(统计数量) if (Objects.equal(quotation.getModuleId(), quotation.getModuleId()) && quotation.getPrice() > module.getCost()) { log.error("module quotation cost price can't more than module default price"); error++; } } // 计算总报价 totalValue += quotation.getTotal() * quotation.getPrice(); // 计算总Q qualityValue += quotation.getTotal() * solutionMap.get(quotation.getModuleId()).getQuality(); // 计算最大R cpmDate = solutionMap.get(quotation.getModuleId()).getReaction(); maxReaction = maxReaction == null ? cpmDate : (maxReaction.after(cpmDate) ? maxReaction : cpmDate); } if (error == 0) { // 方案终投阶段只允许提交一次 RequirementSolution solution = new RequirementSolution(); solution.setId(requirementSolution.getId()); solution.setQuality(qualityValue); // 整体的Q solution.setReaction(maxReaction); // 整体的R solution.setCost(totalValue); // 整体的C solution.setStatus(RequirementSolution.Status.SEND_END.value()); requirementSolutionDao.update(solution); } // 判断采购商是否已经提交了保证金 Response<Integer> paidRes = depositService.checkPaid(requirement.getId(), requirementSolution.getSupplierId()); if (!paidRes.isSuccess()) { log.error( "check supplier send deposit fee result failed, error code={}", result.getError()); result.setError(paidRes.getError()); return result; } checkSolEndDto.setPaidResult(paidRes.getResult()); checkSolEndDto.setCostResult(error == 0); result.setResult(checkSolEndDto); } } catch (Exception e) { log.error( "change requirement solution status failed, requirementId={}, userId={}, error code={}", requirementId, user.getId(), Throwables.getStackTraceAsString(e)); result.setError("solution.update.failed"); } return result; }
@Override public Response<Boolean> checkSupplierInfo(Long requirementId, BaseUser user) { Response<Boolean> result = new Response<Boolean>(); Requirement requirement = requirementDao.findById(requirementId); // 写入供应商信用等级信息 Response<SupplierCreditQualify> creditRes = supplierCreditQualifyService.findCreditQualifyByUserId(user.getId()); if (!creditRes.isSuccess()) { log.error("find supplier credit qualify info failed, error code={}", creditRes.getError()); result.setError(creditRes.getError()); return result; } if (!creditRes.getResult().isCreditQualified()) { log.error("supplier credit is not allow to do."); result.setError("supplier.credit.failed"); return result; } // 获取公司信息 Response<Company> companyRes = companyService.findCompanyByUserId(user.getId()); if (!companyRes.isSuccess()) { result.setError(companyRes.getError()); return result; } // 获取后台三级类目信息 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()); } // 获取供应商资质验证信息 Response<Integer> qualifyRes = supplierResourceMaterialService.getInfoInBcIds(companyRes.getResult().getId(), categoryIds); if (!qualifyRes.isSuccess()) { log.error( "find user qualify failed, userId={}, error code={}", user.getId(), qualifyRes.getError()); result.setError(qualifyRes.getError()); return result; } // 资质是否全部验证通过 if (!Objects.equal( SupplierResourceMaterialInfo.Status.from(qualifyRes.getResult()), SupplierResourceMaterialInfo.Status.QUALIFIED)) { log.error("supplier resource is not allow to do."); result.setError("supplier.resource.failed"); return result; } result.setResult(true); return result; }
@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; }
private void addrequirementActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_addrequirementActionPerformed // TODO add your handling code here: String[] types = {"Functional", "Non-functional"}; JComboBox typeList = new JComboBox(types); typeList.setSelectedIndex(0); JTextArea description = new JTextArea(); description.setRows(5); description.setColumns(10); description.setLineWrap(true); JScrollPane pane = new JScrollPane(description); Object[] message = { "Requirement Type:", typeList, "Description:", pane, }; int option = JOptionPane.showConfirmDialog( this, message, "Enter Requirement Information", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { Requirement req = new Requirement(); req.setRequirementDescription(description.getText()); if (typeList.getSelectedItem().toString().equals("Functional")) { req.setIsFunctionalRequirement(true); } else req.setIsFunctionalRequirement(false); currentProject.getRequirements().add(req); requirementmodel.addElement(typeList.getSelectedItem() + " " + description.getText()); requirementlist.setModel(requirementmodel); } } // GEN-LAST:event_addrequirementActionPerformed