OpenHarmony KMP餐饮体验评分
餐厅用餐体验评估系统是基于Kotlin Multiplatform和OpenHarmony开发的智能餐饮管理解决方案。该系统通过实时监测菜品质量、服务态度、环境卫生、价格合理性和用餐速度五大核心指标,采用加权算法生成综合评分(0-100分)和体验等级(五星至一星)。系统还能自动分析改进潜力,提供针对性的服务优化建议,帮助餐厅提升顾客满意度。技术架构上,Kotlin实现核心算法,编译为JavaScr

项目概述
餐厅用餐体验评估系统是一个基于Kotlin Multiplatform (KMP)和OpenHarmony平台开发的综合性餐厅运营管理解决方案。该系统通过实时收集和分析用餐体验的关键指标,包括菜品质量、服务态度、环境卫生、价格合理性和用餐速度等,为餐厅管理部门提供科学的用餐体验评估决策支持和服务改进建议。
餐厅用餐体验评估是现代餐饮业运营的重要环节,直接影响到顾客满意度和餐厅口碑。传统的体验评估往往依赖顾客反馈和定期调查,存在数据不及时、分析不深入、改进建议不科学等问题。本系统通过引入先进的用餐体验数据分析和优化技术,实现了对用餐体验的全面、实时、精准的评估和分析。该系统采用KMP技术栈,使得核心的体验分析算法可以在Kotlin中编写,然后编译为JavaScript在Web端运行,同时通过ArkTS在OpenHarmony设备上调用,实现了跨平台的统一解决方案。
核心功能特性
1. 多维度用餐体验指标评估
系统能够同时评估菜品质量、服务态度、环境卫生、价格合理性和用餐速度五个关键用餐体验指标。这些指标的组合分析可以全面反映用餐体验的质量。菜品质量衡量食物水准;服务态度反映员工素质;环境卫生体现餐厅管理;价格合理性关系到顾客满意;用餐速度影响到用餐效率。
2. 智能体验评估算法
系统采用多维度评估算法,综合考虑各个体验指标的相对重要性,给出客观的用餐体验评分。通过建立体验指标与满意度等级之间的映射关系,系统能够快速识别优质体验和需要改进的方面。这种算法不仅考虑了单个指标的影响,还充分考虑了指标之间的相互关系和改进的优先级。
3. 分级服务改进建议
系统根据当前的用餐体验状况,生成分级的改进建议。对于优质体验,系统建议保持现状和深化创新;对于需要改进的体验,系统会提出具体的改进方案,包括改进的方向、预期效果等。这种分级方式确保了改进建议的针对性和实用性。
4. 用餐体验价值评估支持
系统能够计算用餐体验的满意度指数,包括体验等级、改进潜力、优先级等。通过这种量化的评估,餐厅管理部门可以清晰地了解用餐体验水平,为服务改进提供有力支撑。
技术架构
Kotlin后端实现
使用Kotlin语言编写核心的用餐体验分析算法和评估模型。Kotlin的简洁语法和强大的类型系统使得复杂的算法实现既易于维护又能保证运行时的安全性。通过@JsExport注解,将Kotlin函数导出为JavaScript,实现跨平台调用。
JavaScript中间层
Kotlin编译生成的JavaScript代码作为中间层,提供了Web端的数据处理能力。这一层负责接收来自各种数据源的输入,进行数据验证和转换,然后调用核心的分析算法。
ArkTS前端展示
在OpenHarmony设备上,使用ArkTS编写用户界面。通过调用JavaScript导出的函数,实现了与后端逻辑的无缝集成。用户可以通过直观的界面输入用餐体验数据,实时查看分析结果和改进建议。
应用场景
本系统适用于各类餐饮运营机构,特别是:
- 餐厅的服务管理部门
- 连锁餐饮的总部管理部门
- 餐饮运营咨询企业
- 质量管理部门的数据分析工作
Kotlin实现代码
餐厅用餐体验评估系统核心算法
@JsExport
fun restaurantDiningExperienceSystem(inputData: String): String {
val parts = inputData.trim().split(" ")
if (parts.size != 5) {
return "格式错误\n请输入: 菜品质量(1-10) 服务态度(1-10) 环境卫生(1-10) 价格合理性(1-10) 用餐速度(1-10)\n例如: 8 9 8 7 8"
}
val dishQuality = parts[0].toDoubleOrNull()
val serviceAttitude = parts[1].toDoubleOrNull()
val environmentalHygiene = parts[2].toDoubleOrNull()
val priceReasonableness = parts[3].toDoubleOrNull()
val diningSpeed = parts[4].toDoubleOrNull()
if (dishQuality == null || serviceAttitude == null || environmentalHygiene == null || priceReasonableness == null || diningSpeed == null) {
return "数值错误\n请输入有效的数字"
}
// 参数范围验证
if (dishQuality < 1 || dishQuality > 10) {
return "菜品质量应在1-10之间"
}
if (serviceAttitude < 1 || serviceAttitude > 10) {
return "服务态度应在1-10之间"
}
if (environmentalHygiene < 1 || environmentalHygiene > 10) {
return "环境卫生应在1-10之间"
}
if (priceReasonableness < 1 || priceReasonableness > 10) {
return "价格合理性应在1-10之间"
}
if (diningSpeed < 1 || diningSpeed > 10) {
return "用餐速度应在1-10之间"
}
// 计算各指标的评分(0-100,分数越高体验越好)
val dishScore = (dishQuality / 10.0 * 100).toInt()
val serviceScore = (serviceAttitude / 10.0 * 100).toInt()
val hygieneScore = (environmentalHygiene / 10.0 * 100).toInt()
val priceScore = (priceReasonableness / 10.0 * 100).toInt()
val speedScore = (diningSpeed / 10.0 * 100).toInt()
// 加权综合评分
val overallScore = (dishScore * 0.30 + serviceScore * 0.25 + hygieneScore * 0.20 + priceScore * 0.15 + speedScore * 0.10).toInt()
// 用餐体验等级判定
val experienceLevel = when {
overallScore >= 90 -> "🟢 优秀(五星体验)"
overallScore >= 80 -> "🟡 良好(四星体验)"
overallScore >= 70 -> "🟠 一般(三星体验)"
overallScore >= 60 -> "🔴 较差(二星体验)"
else -> "⚫ 很差(一星体验)"
}
// 计算改进潜力
val improvementPotential = when {
overallScore >= 90 -> "极高"
overallScore >= 80 -> "高"
overallScore >= 70 -> "中等"
overallScore >= 60 -> "低"
else -> "极低"
}
// 计算推荐改进措施数
val recommendedMeasures = when {
overallScore >= 90 -> 2
overallScore >= 80 -> 4
overallScore >= 70 -> 6
overallScore >= 60 -> 8
else -> 10
}
// 计算各项改进空间
val dishGap = 10 - dishQuality
val serviceGap = 10 - serviceAttitude
val hygieneGap = 10 - environmentalHygiene
val priceGap = 10 - priceReasonableness
val speedGap = 10 - diningSpeed
// 生成详细报告
return buildString {
appendLine("╔════════════════════════════════════════╗")
appendLine("║ 🍽️ 餐厅用餐体验评估系统报告 ║")
appendLine("╚════════════════════════════════════════╝")
appendLine()
appendLine("📊 用餐体验指标监测")
appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
appendLine("菜品质量: ${dishQuality}/10")
appendLine("服务态度: ${serviceAttitude}/10")
appendLine("环境卫生: ${environmentalHygiene}/10")
appendLine("价格合理性: ${priceReasonableness}/10")
appendLine("用餐速度: ${diningSpeed}/10")
appendLine()
appendLine("⭐ 指标评分")
appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
appendLine("菜品质量评分: $dishScore/100")
appendLine("服务态度评分: $serviceScore/100")
appendLine("环境卫生评分: $hygieneScore/100")
appendLine("价格合理性评分: $priceScore/100")
appendLine("用餐速度评分: $speedScore/100")
appendLine()
appendLine("🎯 综合评估")
appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
appendLine("综合体验评分: $overallScore/100")
appendLine("用餐体验等级: $experienceLevel")
appendLine("改进潜力: $improvementPotential")
appendLine("推荐改进措施: $recommendedMeasures项")
appendLine()
appendLine("📈 用餐体验改进空间")
appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
appendLine("菜品质量改进空间: ${String.format("%.2f", dishGap)}/10")
appendLine("服务态度改进空间: ${String.format("%.2f", serviceGap)}/10")
appendLine("环境卫生改进空间: ${String.format("%.2f", hygieneGap)}/10")
appendLine("价格合理性改进空间: ${String.format("%.2f", priceGap)}/10")
appendLine("用餐速度改进空间: ${String.format("%.2f", speedGap)}/10")
appendLine()
appendLine("💡 用餐体验改进建议")
appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
// 菜品质量建议
if (dishQuality < 6) {
appendLine(" 🍲 菜品质量需要改进")
appendLine(" - 提升食材品质")
appendLine(" - 改进烹饪技术")
appendLine(" - 创新菜品设计")
} else if (dishQuality >= 8) {
appendLine(" ✅ 菜品质量优秀")
appendLine(" - 继续保持高度")
appendLine(" - 深化菜品创新")
}
// 服务态度建议
if (serviceAttitude < 6) {
appendLine(" 👔 服务态度需要改进")
appendLine(" - 加强员工培训")
appendLine(" - 提升服务意识")
appendLine(" - 改进服务流程")
} else if (serviceAttitude >= 8) {
appendLine(" ✅ 服务态度优秀")
appendLine(" - 继续保持高度")
appendLine(" - 深化服务创新")
}
// 环境卫生建议
if (environmentalHygiene < 6) {
appendLine(" 🧹 环境卫生需要改进")
appendLine(" - 加强卫生管理")
appendLine(" - 提升清洁标准")
appendLine(" - 改进卫生流程")
} else if (environmentalHygiene >= 8) {
appendLine(" ✅ 环境卫生优秀")
appendLine(" - 继续保持高度")
appendLine(" - 深化管理创新")
}
// 价格合理性建议
if (priceReasonableness < 6) {
appendLine(" 💵 价格合理性需要改进")
appendLine(" - 优化价格策略")
appendLine(" - 提升价值感")
appendLine(" - 改进定价方案")
} else if (priceReasonableness >= 8) {
appendLine(" ✅ 价格合理性优秀")
appendLine(" - 继续保持高度")
appendLine(" - 深化价值创新")
}
// 用餐速度建议
if (diningSpeed < 6) {
appendLine(" ⏱️ 用餐速度需要改进")
appendLine(" - 优化出餐流程")
appendLine(" - 提升服务效率")
appendLine(" - 改进厨房管理")
} else if (diningSpeed >= 8) {
appendLine(" ✅ 用餐速度优秀")
appendLine(" - 继续保持高度")
appendLine(" - 深化流程创新")
}
appendLine()
appendLine("📋 餐厅改进策略")
appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
when {
overallScore >= 90 -> {
appendLine("🟢 用餐体验优秀 - 重点推广")
appendLine(" 1. 扩大营销宣传")
appendLine(" 2. 建立品牌形象")
appendLine(" 3. 深化创新发展")
appendLine(" 4. 推荐给更多顾客")
}
overallScore >= 80 -> {
appendLine("🟡 用餐体验良好 - 保持现状")
appendLine(" 1. 维持现有服务")
appendLine(" 2. 定期体验评估")
appendLine(" 3. 持续改进优化")
}
overallScore >= 70 -> {
appendLine("🟠 用餐体验一般 - 逐步改进")
appendLine(" 1. 制定改进计划")
appendLine(" 2. 加强管理措施")
appendLine(" 3. 提升改进能力")
}
overallScore >= 60 -> {
appendLine("🔴 用餐体验较差 - 重点改进")
appendLine(" 1. 进行全面诊断")
appendLine(" 2. 制定改进方案")
appendLine(" 3. 加强管理改进")
appendLine(" 4. 提升改进能力")
}
else -> {
appendLine("⚫ 用餐体验很差 - 立即改进")
appendLine(" 1. 进行紧急诊断")
appendLine(" 2. 制定紧急方案")
appendLine(" 3. 加强管理改进")
appendLine(" 4. 提升改进能力")
}
}
appendLine()
appendLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
appendLine("✅ 评估完成 | 时间戳: ${System.currentTimeMillis()}")
}
}
代码说明
上述Kotlin代码实现了餐厅用餐体验评估系统的核心算法。restaurantDiningExperienceSystem函数是主入口,接收一个包含五个用餐体验指标的字符串输入。函数首先进行输入验证,确保数据的有效性和范围的合理性。
然后,它计算各指标的评分。菜品质量、服务态度、环境卫生、价格合理性和用餐速度都直接转换为0-100的评分。系统采用标准的用餐体验评估方法。
系统使用加权平均法计算综合评分,其中菜品质量的权重为30%,因为它是用餐体验的核心。服务态度的权重为25%,环境卫生的权重为20%,价格合理性的权重为15%,用餐速度的权重为10%。
最后,系统根据综合评分判定用餐体验等级,并生成详细的评估报告。同时,系统还计算了改进潜力和推荐改进措施数,为餐厅管理部门提供量化的体验改进支持。
JavaScript编译版本
// 餐厅用餐体验评估系统 - JavaScript版本
function restaurantDiningExperienceSystem(inputData) {
const parts = inputData.trim().split(" ");
if (parts.length !== 5) {
return "格式错误\n请输入: 菜品质量(1-10) 服务态度(1-10) 环境卫生(1-10) 价格合理性(1-10) 用餐速度(1-10)\n例如: 8 9 8 7 8";
}
const dishQuality = parseFloat(parts[0]);
const serviceAttitude = parseFloat(parts[1]);
const environmentalHygiene = parseFloat(parts[2]);
const priceReasonableness = parseFloat(parts[3]);
const diningSpeed = parseFloat(parts[4]);
// 数值验证
if (isNaN(dishQuality) || isNaN(serviceAttitude) || isNaN(environmentalHygiene) ||
isNaN(priceReasonableness) || isNaN(diningSpeed)) {
return "数值错误\n请输入有效的数字";
}
// 范围检查
if (dishQuality < 1 || dishQuality > 10) {
return "菜品质量应在1-10之间";
}
if (serviceAttitude < 1 || serviceAttitude > 10) {
return "服务态度应在1-10之间";
}
if (environmentalHygiene < 1 || environmentalHygiene > 10) {
return "环境卫生应在1-10之间";
}
if (priceReasonableness < 1 || priceReasonableness > 10) {
return "价格合理性应在1-10之间";
}
if (diningSpeed < 1 || diningSpeed > 10) {
return "用餐速度应在1-10之间";
}
// 计算各指标评分
const dishScore = Math.floor(dishQuality / 10.0 * 100);
const serviceScore = Math.floor(serviceAttitude / 10.0 * 100);
const hygieneScore = Math.floor(environmentalHygiene / 10.0 * 100);
const priceScore = Math.floor(priceReasonableness / 10.0 * 100);
const speedScore = Math.floor(diningSpeed / 10.0 * 100);
// 加权综合评分
const overallScore = Math.floor(
dishScore * 0.30 + serviceScore * 0.25 + hygieneScore * 0.20 +
priceScore * 0.15 + speedScore * 0.10
);
// 用餐体验等级判定
let experienceLevel;
if (overallScore >= 90) {
experienceLevel = "🟢 优秀(五星体验)";
} else if (overallScore >= 80) {
experienceLevel = "🟡 良好(四星体验)";
} else if (overallScore >= 70) {
experienceLevel = "🟠 一般(三星体验)";
} else if (overallScore >= 60) {
experienceLevel = "🔴 较差(二星体验)";
} else {
experienceLevel = "⚫ 很差(一星体验)";
}
// 计算改进潜力
let improvementPotential;
if (overallScore >= 90) {
improvementPotential = "极高";
} else if (overallScore >= 80) {
improvementPotential = "高";
} else if (overallScore >= 70) {
improvementPotential = "中等";
} else if (overallScore >= 60) {
improvementPotential = "低";
} else {
improvementPotential = "极低";
}
// 计算推荐改进措施数
let recommendedMeasures;
if (overallScore >= 90) {
recommendedMeasures = 2;
} else if (overallScore >= 80) {
recommendedMeasures = 4;
} else if (overallScore >= 70) {
recommendedMeasures = 6;
} else if (overallScore >= 60) {
recommendedMeasures = 8;
} else {
recommendedMeasures = 10;
}
// 计算各项改进空间
const dishGap = 10 - dishQuality;
const serviceGap = 10 - serviceAttitude;
const hygieneGap = 10 - environmentalHygiene;
const priceGap = 10 - priceReasonableness;
const speedGap = 10 - diningSpeed;
// 生成报告
let report = "";
report += "╔════════════════════════════════════════╗\n";
report += "║ 🍽️ 餐厅用餐体验评估系统报告 ║\n";
report += "╚════════════════════════════════════════╝\n\n";
report += "📊 用餐体验指标监测\n";
report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
report += `菜品质量: ${dishQuality}/10\n`;
report += `服务态度: ${serviceAttitude}/10\n`;
report += `环境卫生: ${environmentalHygiene}/10\n`;
report += `价格合理性: ${priceReasonableness}/10\n`;
report += `用餐速度: ${diningSpeed}/10\n\n`;
report += "⭐ 指标评分\n";
report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
report += `菜品质量评分: ${dishScore}/100\n`;
report += `服务态度评分: ${serviceScore}/100\n`;
report += `环境卫生评分: ${hygieneScore}/100\n`;
report += `价格合理性评分: ${priceScore}/100\n`;
report += `用餐速度评分: ${speedScore}/100\n\n`;
report += "🎯 综合评估\n";
report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
report += `综合体验评分: ${overallScore}/100\n`;
report += `用餐体验等级: ${experienceLevel}\n`;
report += `改进潜力: ${improvementPotential}\n`;
report += `推荐改进措施: ${recommendedMeasures}项\n\n`;
report += "📈 用餐体验改进空间\n";
report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
report += `菜品质量改进空间: ${dishGap.toFixed(2)}/10\n`;
report += `服务态度改进空间: ${serviceGap.toFixed(2)}/10\n`;
report += `环境卫生改进空间: ${hygieneGap.toFixed(2)}/10\n`;
report += `价格合理性改进空间: ${priceGap.toFixed(2)}/10\n`;
report += `用餐速度改进空间: ${speedGap.toFixed(2)}/10\n\n`;
report += "💡 用餐体验改进建议\n";
report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
// 菜品质量建议
if (dishQuality < 6) {
report += " 🍲 菜品质量需要改进\n";
report += " - 提升食材品质\n";
report += " - 改进烹饪技术\n";
report += " - 创新菜品设计\n";
} else if (dishQuality >= 8) {
report += " ✅ 菜品质量优秀\n";
report += " - 继续保持高度\n";
report += " - 深化菜品创新\n";
}
// 服务态度建议
if (serviceAttitude < 6) {
report += " 👔 服务态度需要改进\n";
report += " - 加强员工培训\n";
report += " - 提升服务意识\n";
report += " - 改进服务流程\n";
} else if (serviceAttitude >= 8) {
report += " ✅ 服务态度优秀\n";
report += " - 继续保持高度\n";
report += " - 深化服务创新\n";
}
// 环境卫生建议
if (environmentalHygiene < 6) {
report += " 🧹 环境卫生需要改进\n";
report += " - 加强卫生管理\n";
report += " - 提升清洁标准\n";
report += " - 改进卫生流程\n";
} else if (environmentalHygiene >= 8) {
report += " ✅ 环境卫生优秀\n";
report += " - 继续保持高度\n";
report += " - 深化管理创新\n";
}
// 价格合理性建议
if (priceReasonableness < 6) {
report += " 💵 价格合理性需要改进\n";
report += " - 优化价格策略\n";
report += " - 提升价值感\n";
report += " - 改进定价方案\n";
} else if (priceReasonableness >= 8) {
report += " ✅ 价格合理性优秀\n";
report += " - 继续保持高度\n";
report += " - 深化价值创新\n";
}
// 用餐速度建议
if (diningSpeed < 6) {
report += " ⏱️ 用餐速度需要改进\n";
report += " - 优化出餐流程\n";
report += " - 提升服务效率\n";
report += " - 改进厨房管理\n";
} else if (diningSpeed >= 8) {
report += " ✅ 用餐速度优秀\n";
report += " - 继续保持高度\n";
report += " - 深化流程创新\n";
}
report += "\n📋 餐厅改进策略\n";
report += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
if (overallScore >= 90) {
report += "🟢 用餐体验优秀 - 重点推广\n";
report += " 1. 扩大营销宣传\n";
report += " 2. 建立品牌形象\n";
report += " 3. 深化创新发展\n";
report += " 4. 推荐给更多顾客\n";
} else if (overallScore >= 80) {
report += "🟡 用餐体验良好 - 保持现状\n";
report += " 1. 维持现有服务\n";
report += " 2. 定期体验评估\n";
report += " 3. 持续改进优化\n";
} else if (overallScore >= 70) {
report += "🟠 用餐体验一般 - 逐步改进\n";
report += " 1. 制定改进计划\n";
report += " 2. 加强管理措施\n";
report += " 3. 提升改进能力\n";
} else if (overallScore >= 60) {
report += "🔴 用餐体验较差 - 重点改进\n";
report += " 1. 进行全面诊断\n";
report += " 2. 制定改进方案\n";
report += " 3. 加强管理改进\n";
report += " 4. 提升改进能力\n";
} else {
report += "⚫ 用餐体验很差 - 立即改进\n";
report += " 1. 进行紧急诊断\n";
report += " 2. 制定紧急方案\n";
report += " 3. 加强管理改进\n";
report += " 4. 提升改进能力\n";
}
report += "\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
report += `✅ 评估完成 | 时间戳: ${Date.now()}\n`;
return report;
}
JavaScript版本说明
JavaScript版本是由Kotlin代码编译而来的,提供了完全相同的功能。在Web环境中,这个JavaScript函数可以直接被调用,用于处理来自前端表单的数据。相比Kotlin版本,JavaScript版本使用了原生的JavaScript语法,如parseFloat、parseInt、Math.floor等,确保了在浏览器环境中的兼容性。
该版本保留了所有的业务逻辑和计算方法,确保了跨平台的一致性。通过这种方式,开发者只需要维护一份Kotlin代码,就可以在多个平台上运行相同的业务逻辑。
ArkTS调用实现
import { restaurantDiningExperienceSystem } from './hellokjs'
@Entry
@Component
struct RestaurantDiningExperiencePage {
@State dishQuality: string = "8"
@State serviceAttitude: string = "9"
@State environmentalHygiene: string = "8"
@State priceReasonableness: string = "7"
@State diningSpeed: string = "8"
@State result: string = ""
@State isLoading: boolean = false
build() {
Column() {
// 顶部标题栏
Row() {
Text("🍽️ 餐厅用餐体验评估系统")
.fontSize(20)
.fontWeight(FontWeight.Bold)
.fontColor('#FFFFFF')
}
.width('100%')
.height(60)
.backgroundColor('#FF6F00')
.justifyContent(FlexAlign.Center)
.padding({ left: 16, right: 16 })
// 主体内容
Scroll() {
Column() {
// 参数输入部分
Column() {
Text("📊 用餐体验指标输入")
.fontSize(16)
.fontWeight(FontWeight.Bold)
.fontColor('#FF6F00')
.margin({ bottom: 12 })
.padding({ left: 12, top: 12 })
// 2列网格布局
Column() {
// 第一行
Row() {
Column() {
Text("菜品质量(1-10)")
.fontSize(12)
.fontWeight(FontWeight.Bold)
.margin({ bottom: 4 })
TextInput({ placeholder: "8", text: this.dishQuality })
.height(40)
.width('100%')
.onChange((value: string) => { this.dishQuality = value })
.backgroundColor('#FFFFFF')
.border({ width: 1, color: '#FF6F00' })
.borderRadius(4)
.padding(8)
.fontSize(12)
}.width('48%').padding(6)
Blank().width('4%')
Column() {
Text("服务态度(1-10)")
.fontSize(12)
.fontWeight(FontWeight.Bold)
.margin({ bottom: 4 })
TextInput({ placeholder: "9", text: this.serviceAttitude })
.height(40)
.width('100%')
.onChange((value: string) => { this.serviceAttitude = value })
.backgroundColor('#FFFFFF')
.border({ width: 1, color: '#FF6F00' })
.borderRadius(4)
.padding(8)
.fontSize(12)
}.width('48%').padding(6)
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
// 第二行
Row() {
Column() {
Text("环境卫生(1-10)")
.fontSize(12)
.fontWeight(FontWeight.Bold)
.margin({ bottom: 4 })
TextInput({ placeholder: "8", text: this.environmentalHygiene })
.height(40)
.width('100%')
.onChange((value: string) => { this.environmentalHygiene = value })
.backgroundColor('#FFFFFF')
.border({ width: 1, color: '#FF6F00' })
.borderRadius(4)
.padding(8)
.fontSize(12)
}.width('48%').padding(6)
Blank().width('4%')
Column() {
Text("价格合理性(1-10)")
.fontSize(12)
.fontWeight(FontWeight.Bold)
.margin({ bottom: 4 })
TextInput({ placeholder: "7", text: this.priceReasonableness })
.height(40)
.width('100%')
.onChange((value: string) => { this.priceReasonableness = value })
.backgroundColor('#FFFFFF')
.border({ width: 1, color: '#FF6F00' })
.borderRadius(4)
.padding(8)
.fontSize(12)
}.width('48%').padding(6)
}.width('100%').justifyContent(FlexAlign.SpaceBetween).margin({ top: 8 })
// 第三行
Row() {
Column() {
Text("用餐速度(1-10)")
.fontSize(12)
.fontWeight(FontWeight.Bold)
.margin({ bottom: 4 })
TextInput({ placeholder: "8", text: this.diningSpeed })
.height(40)
.width('100%')
.onChange((value: string) => { this.diningSpeed = value })
.backgroundColor('#FFFFFF')
.border({ width: 1, color: '#FF6F00' })
.borderRadius(4)
.padding(8)
.fontSize(12)
}.width('48%').padding(6)
Blank().width('52%')
}.width('100%').margin({ top: 8 })
}
.width('100%')
.padding({ left: 6, right: 6, bottom: 12 })
}
.width('100%')
.padding(12)
.backgroundColor('#FFE0B2')
.borderRadius(8)
.margin({ bottom: 12 })
// 按钮区域
Row() {
Button("开始评估")
.width('48%')
.height(44)
.fontSize(14)
.fontWeight(FontWeight.Bold)
.backgroundColor('#FF6F00')
.fontColor(Color.White)
.borderRadius(6)
.onClick(() => {
this.executeEvaluation()
})
Blank().width('4%')
Button("重置数据")
.width('48%')
.height(44)
.fontSize(14)
.fontWeight(FontWeight.Bold)
.backgroundColor('#FFA726')
.fontColor(Color.White)
.borderRadius(6)
.onClick(() => {
this.dishQuality = "8"
this.serviceAttitude = "9"
this.environmentalHygiene = "8"
this.priceReasonableness = "7"
this.diningSpeed = "8"
this.result = ""
})
}
.width('100%')
.justifyContent(FlexAlign.Center)
.padding({ left: 12, right: 12, bottom: 12 })
// 结果显示部分
Column() {
Text("📋 评估结果")
.fontSize(16)
.fontWeight(FontWeight.Bold)
.fontColor('#FF6F00')
.margin({ bottom: 12 })
.padding({ left: 12, right: 12, top: 12 })
if (this.isLoading) {
Column() {
LoadingProgress()
.width(50)
.height(50)
.color('#FF6F00')
Text("正在评估...")
.fontSize(14)
.fontColor('#FF6F00')
.margin({ top: 16 })
}
.width('100%')
.height(200)
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
} else if (this.result.length > 0) {
Scroll() {
Text(this.result)
.fontSize(11)
.fontColor('#FF6F00')
.fontFamily('monospace')
.width('100%')
.padding(12)
.lineHeight(1.6)
}
.width('100%')
.height(400)
} else {
Column() {
Text("🍽️")
.fontSize(64)
.opacity(0.2)
.margin({ bottom: 16 })
Text("暂无评估结果")
.fontSize(14)
.fontColor('#FF6F00')
Text("请输入用餐体验指标后点击开始评估")
.fontSize(12)
.fontColor('#FFA726')
.margin({ top: 8 })
}
.width('100%')
.height(200)
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
}
}
.layoutWeight(1)
.width('100%')
.padding(12)
.backgroundColor('#F5F5F5')
.borderRadius(8)
}
.width('100%')
.padding(12)
}
.layoutWeight(1)
}
.width('100%')
.height('100%')
.backgroundColor('#FAFAFA')
}
private executeEvaluation() {
const dqStr = this.dishQuality.trim()
const saStr = this.serviceAttitude.trim()
const ehStr = this.environmentalHygiene.trim()
const prStr = this.priceReasonableness.trim()
const dsStr = this.diningSpeed.trim()
if (!dqStr || !saStr || !ehStr || !prStr || !dsStr) {
this.result = "❌ 请填写全部用餐体验指标"
return
}
this.isLoading = true
setTimeout((): void => {
try {
const inputStr = `${dqStr} ${saStr} ${ehStr} ${prStr} ${dsStr}`
const result = restaurantDiningExperienceSystem(inputStr)
this.result = result
console.log("[RestaurantDiningExperienceSystem] 评估完成")
} catch (error) {
this.result = `❌ 执行出错: ${error}`
console.error("[RestaurantDiningExperienceSystem] 错误:", error)
} finally {
this.isLoading = false
}
}, 500)
}
}
ArkTS调用说明
ArkTS是OpenHarmony平台上的主要开发语言,它基于TypeScript进行了扩展,提供了更好的性能和类型安全。在上述代码中,我们创建了一个完整的UI界面,用于输入用餐体验指标并显示评估结果。
页面采用了分层设计:顶部是标题栏,中间是参数输入区域,下方是评估结果显示区。参数输入区使用了2列网格布局,使得界面紧凑而不失清晰。每个输入框都有对应的标签和默认值,方便用户快速操作。
executeEvaluation方法是关键的交互逻辑。当用户点击"开始评估"按钮时,该方法会收集所有输入参数,组合成一个字符串,然后调用从JavaScript导出的restaurantDiningExperienceSystem函数。函数返回的结果会被显示在下方的滚动区域中。同时,系统使用isLoading状态来显示加载动画,提升用户体验。
系统集成与部署
编译流程
- Kotlin编译:使用KMP的Gradle插件,将Kotlin代码编译为JavaScript
- JavaScript生成:生成的JavaScript文件包含了所有的业务逻辑
- ArkTS集成:在ArkTS项目中导入JavaScript文件,通过import语句引入函数
- 应用打包:将整个应用打包为OpenHarmony应用安装包
部署建议
- 在餐厅管理部门的用餐体验评估系统中部署该系统的Web版本
- 在餐厅前台的移动设备上部署OpenHarmony应用,运行该系统的移动版本
- 建立数据同步机制,确保各设备间的数据一致性
- 定期备份评估数据,用于后续的体验分析和改进
总结
餐厅用餐体验评估系统通过整合Kotlin、JavaScript和ArkTS三种技术,提供了一个完整的、跨平台的用餐体验评估解决方案。该系统不仅能够实时收集和分析用餐体验的关键指标,还能够进行智能分析和改进建议,为餐厅管理部门提供了强有力的技术支撑。
通过本系统的应用,餐厅可以显著提高用餐体验评估的效率和准确性,及时发现和改善体验问题,优化服务质量,实现顾客满意度的持续提升。同时,系统生成的详细报告和建议也为餐厅改进决策提供了数据支撑。
在未来,该系统还可以进一步扩展,集成更多的用餐体验数据、引入人工智能算法进行更精准的体验预测、建立与营销部门的联动机制等,使其成为一个更加智能、更加完善的餐厅运营管理平台。
欢迎加入开源鸿蒙跨平台社区:https://openharmonycrossplatform.csdn.net
更多推荐


所有评论(0)