PurpleLab核心功能解析:从MITRE ATTCK映射到日志模拟的全方位安全实验
2026/7/21 17:19:13
java
@Service public class QuotationService { @Autowired private QuotationRepository quotationRepository; @Autowired private MarketTrendService marketTrendService; @Autowired private TemplateRepository templateRepository; public BigDecimal calculateQuotation(Project project, Map<String, Object> params) { // 加载报价预测模型 QuotationModel model = QuotationModel.load(); BigDecimal predictedPrice = model.predict(project, params); // 结合市场行情调整报价 MarketTrend trend = marketTrendService.getCurrentTrend(); BigDecimal adjustedPrice = predictedPrice.multiply(trend.getAdjustmentFactor()); // 应用剪辑师预设模板 Template template = templateRepository.findByUserId(project.getClientId()); if (template != null) { adjustedPrice = template.apply(adjustedPrice); } // 校验报价合理性 if (adjustedPrice.compareTo(project.getBudget()) > 0) { throw new QuotationException("报价超出预算"); } return adjustedPrice.setScale(2, RoundingMode.HALF_UP); } }java
@Service public class ComparisonService { @Autowired private QuotationRepository quotationRepository; @Autowired private ReviewRepository reviewRepository; public List<ComparisonResult> compareQuotations(Long projectId) { List<Quotation> quotations = quotationRepository.findByProjectId(projectId); return quotations.stream() .map(quotation -> { // 获取剪辑师评价数据 Double avgRating = reviewRepository.avgRatingByUserId(quotation.getUserId()); // 计算综合得分(价格、评分、历史成交价等维度) Double score = calculateCompositeScore(quotation.getPrice(), avgRating, quotation.getHistoryPrice()); return new ComparisonResult(quotation, score); }) .sorted(Comparator.comparingDouble(ComparisonResult::getScore).reversed()) .collect(Collectors.toList()); } private Double calculateCompositeScore(BigDecimal price, Double rating, BigDecimal historyPrice) { // 标准化处理各维度数据 Double normalizedPrice = 1 - price.divide(new BigDecimal("2000"), 2, RoundingMode.HALF_UP).doubleValue(); Double normalizedRating = rating / 5.0; Double normalizedHistory = 1 - historyPrice.divide(new BigDecimal("3000"), 2, RoundingMode.HALF_UP).doubleValue(); // 加权求和(权重可动态配置) return 0.5 * normalizedPrice + 0.3 * normalizedRating + 0.2 * normalizedHistory; } }