|
|
|
@ -102,25 +102,15 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup name="WmsImportResult">
|
|
|
|
<script setup name="WmsImportResult">
|
|
|
|
import { ref, reactive, toRefs, getCurrentInstance, shallowRef } from 'vue'
|
|
|
|
import { ref, reactive, shallowRef } from 'vue'
|
|
|
|
import { listWmsImportResult, getWmsImportResult, delWmsImportResult, addWmsImportResult, updateWmsImportResult } from "@/api/warehouse/WmsImportResult"
|
|
|
|
|
|
|
|
import { API_CONFIG } from "@/config/api"
|
|
|
|
import { API_CONFIG } from "@/config/api"
|
|
|
|
import ParetoAnalysis from './ParetoAnalysis.vue'
|
|
|
|
import ParetoAnalysis from './ParetoAnalysis.vue'
|
|
|
|
import EmptyContent from './EmptyContent.vue'
|
|
|
|
import EmptyContent from './EmptyContent.vue'
|
|
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const WmsImportResultList = ref([])
|
|
|
|
|
|
|
|
const open = ref(false)
|
|
|
|
|
|
|
|
const loading = ref(true)
|
|
|
|
|
|
|
|
const showSearch = ref(true)
|
|
|
|
const showSearch = ref(true)
|
|
|
|
const ids = ref([])
|
|
|
|
|
|
|
|
const single = ref(true)
|
|
|
|
const single = ref(true)
|
|
|
|
const multiple = ref(true)
|
|
|
|
const multiple = ref(true)
|
|
|
|
const total = ref(0)
|
|
|
|
|
|
|
|
const title = ref("")
|
|
|
|
|
|
|
|
const message = ref("")
|
|
|
|
const message = ref("")
|
|
|
|
const selectedTimeRange = ref("近1年")
|
|
|
|
|
|
|
|
const timeRangeOptions = ref([
|
|
|
|
const timeRangeOptions = ref([
|
|
|
|
{ value: "近1年", label: "近1年" },
|
|
|
|
{ value: "近1年", label: "近1年" },
|
|
|
|
{ value: "近2年", label: "近2年" },
|
|
|
|
{ value: "近2年", label: "近2年" },
|
|
|
|
@ -134,9 +124,6 @@ const dateRange = ref({
|
|
|
|
start_date: '',
|
|
|
|
start_date: '',
|
|
|
|
end_date: ''
|
|
|
|
end_date: ''
|
|
|
|
})
|
|
|
|
})
|
|
|
|
const aiDialogVisible = ref(false)
|
|
|
|
|
|
|
|
const aiAnalysisResult = ref("")
|
|
|
|
|
|
|
|
const aiAnalysisLoading = ref(false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 当前显示的组件
|
|
|
|
// 当前显示的组件
|
|
|
|
const currentComponent = shallowRef(EmptyContent)
|
|
|
|
const currentComponent = shallowRef(EmptyContent)
|
|
|
|
@ -159,9 +146,6 @@ const data = reactive({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const { queryParams, form, rules } = toRefs(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handlePareto() {
|
|
|
|
function handlePareto() {
|
|
|
|
// 根据选择的时间范围计算开始和结束日期
|
|
|
|
// 根据选择的时间范围计算开始和结束日期
|
|
|
|
const endDate = new Date();
|
|
|
|
const endDate = new Date();
|
|
|
|
@ -186,7 +170,7 @@ function handlePareto() {
|
|
|
|
const startDateStr = formatDate(startDate);
|
|
|
|
const startDateStr = formatDate(startDate);
|
|
|
|
const endDateStr = formatDate(endDate);
|
|
|
|
const endDateStr = formatDate(endDate);
|
|
|
|
|
|
|
|
|
|
|
|
console.log(startDateStr, endDateStr);
|
|
|
|
// console.log(startDateStr, endDateStr);
|
|
|
|
// 调用质检API并显示结果
|
|
|
|
// 调用质检API并显示结果
|
|
|
|
fetch(`${API_CONFIG.BASE_URL}${API_CONFIG.ENDPOINTS.PARETO_ANALYSIS}?start_date=${startDateStr}&end_date=${endDateStr}`)
|
|
|
|
fetch(`${API_CONFIG.BASE_URL}${API_CONFIG.ENDPOINTS.PARETO_ANALYSIS}?start_date=${startDateStr}&end_date=${endDateStr}`)
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(response => response.json())
|
|
|
|
@ -214,84 +198,6 @@ function handleAIAnalysisComplete(result) {
|
|
|
|
message.value = result;
|
|
|
|
message.value = result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// getList()
|
|
|
|
|
|
|
|
// 根据缺陷百分比设置进度条颜色
|
|
|
|
|
|
|
|
function getProgressColor(percentage) {
|
|
|
|
|
|
|
|
if (percentage >= 30) return '#f56c6c'; // 红色 - 高缺陷率
|
|
|
|
|
|
|
|
if (percentage >= 15) return '#e6a23c'; // 橙色 - 中等缺陷率
|
|
|
|
|
|
|
|
if (percentage >= 5) return '#409eff'; // 蓝色 - 低缺陷率
|
|
|
|
|
|
|
|
return '#67c23a'; // 绿色 - 很低缺陷率
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AI分析功能
|
|
|
|
|
|
|
|
async function handleAIAnalysis() {
|
|
|
|
|
|
|
|
if (paretoData.value.length === 0) {
|
|
|
|
|
|
|
|
message.value = '请先获取帕累托分析数据'
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
aiAnalysisLoading.value = true
|
|
|
|
|
|
|
|
aiDialogVisible.value = true
|
|
|
|
|
|
|
|
aiAnalysisResult.value = '正在分析中,请稍候...'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// 准备分析提示词
|
|
|
|
|
|
|
|
const prompt = `请分析以下帕累托分析数据,提供专业的质量控制见解:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
数据范围: ${dateRange.value.start_date} 至 ${dateRange.value.end_date}
|
|
|
|
|
|
|
|
检测项目总数: ${paretoData.value.length}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
详细数据:
|
|
|
|
|
|
|
|
${paretoData.value.map(item =>
|
|
|
|
|
|
|
|
`- ${item.item_name}: 缺陷数 ${item.defect_count}, 缺陷占比 ${item.defect_percentage}%, 累计占比 ${item.cumulative_percentage}%`
|
|
|
|
|
|
|
|
).join('\n')}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
请从以下角度进行分析:
|
|
|
|
|
|
|
|
1. 主要缺陷项及其影响程度
|
|
|
|
|
|
|
|
2. 帕累托原理(80/20法则)在此数据中的体现
|
|
|
|
|
|
|
|
3. 针对高缺陷率项的改进建议
|
|
|
|
|
|
|
|
4. 质量控制重点优化方向`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 调用DeepSeek API进行分析
|
|
|
|
|
|
|
|
const response = await fetch('https://api.deepseek.com/v1/chat/completions', {
|
|
|
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
|
|
|
'Authorization': `Bearer sk-4fa66e674e57479d961e4ad2036cbc52`
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
|
|
|
model: 'deepseek-chat',
|
|
|
|
|
|
|
|
messages: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
role: 'system',
|
|
|
|
|
|
|
|
content: '你是一位专业的质量控制专家,擅长分析缺陷数据并提供专业的改进建议。'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
role: 'user',
|
|
|
|
|
|
|
|
content: prompt
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
temperature: 0.7,
|
|
|
|
|
|
|
|
max_tokens: 1500
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
|
|
|
throw new Error(`API调用失败: ${response.status}`)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const data = await response.json()
|
|
|
|
|
|
|
|
const analysisResult = data.choices[0].message.content
|
|
|
|
|
|
|
|
aiAnalysisResult.value = analysisResult
|
|
|
|
|
|
|
|
// 同时将分析结果输出到消息显示文本框
|
|
|
|
|
|
|
|
message.value = analysisResult
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error('AI分析失败:', error)
|
|
|
|
|
|
|
|
aiAnalysisResult.value = `AI分析失败: ${error.message}\n\n请检查网络连接或稍后再试。`
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
aiAnalysisLoading.value = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|