From d48de59b57bce614e17e91f1845789c071930a2f Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期二, 16 九月 2025 08:01:35 +0800
Subject: [PATCH] 1、大理片进片报表添加连续工作时间统计
---
UI-Project/src/lang/en.js | 2 +
UI-Project/src/lang/zh.js | 3 +
UI-Project/src/views/Reportmanage/reportBigFeed.vue | 84 ++++++++++++++++++++++++++++++++++++++++-
UI-Project/src/lang/kr.js | 2 +
4 files changed, 87 insertions(+), 4 deletions(-)
diff --git a/UI-Project/src/lang/en.js b/UI-Project/src/lang/en.js
index 7079170..052a95d 100644
--- a/UI-Project/src/lang/en.js
+++ b/UI-Project/src/lang/en.js
@@ -528,6 +528,8 @@
totalAreas: 'totalAreas',
totalDamages: 'totalDamages',
totalTakes: 'totalTakes',
+ workMinutes:'workMinutes',
+ timeInterval:'timeInterval',
productiontime: 'production time',
starttime: 'Start Time',
endtime: 'End Time',
diff --git a/UI-Project/src/lang/kr.js b/UI-Project/src/lang/kr.js
index 70753ac..b8039ee 100644
--- a/UI-Project/src/lang/kr.js
+++ b/UI-Project/src/lang/kr.js
@@ -535,6 +535,8 @@
totalAreas:'齑� 氅挫爜',
totalDamages:'齑� 韺岇啇',
totalTakes:'頃儊 臧�鞝戈皠雼�',
+ workMinutes:'鞐办啀 鞛戩梾 鞁滉皠',
+ timeInterval:'鞁滉皠 臧勱博',
productiontime :'靸濎偘 鞁滉皠',
starttime :'鞁滌瀾 鞁滉皠',
endtime :'膦呺 鞁滉皠',
diff --git a/UI-Project/src/lang/zh.js b/UI-Project/src/lang/zh.js
index 1800c5f..6ffcbdf 100644
--- a/UI-Project/src/lang/zh.js
+++ b/UI-Project/src/lang/zh.js
@@ -536,7 +536,8 @@
totalAreas:'鎬婚潰绉�',
totalDamages:'鎬荤牬鎹�',
totalTakes:'鎬绘嬁璧�',
-
+ workMinutes:'杩炵画宸ヤ綔鏃堕棿',
+ timeInterval:'鏃堕棿闂撮殧',
productiontime :'鐢熶骇鏃堕棿',
starttime :'寮�濮嬫椂闂�',
endtime :'缁撴潫鏃堕棿',
diff --git a/UI-Project/src/views/Reportmanage/reportBigFeed.vue b/UI-Project/src/views/Reportmanage/reportBigFeed.vue
index e89cfc8..b196d74 100644
--- a/UI-Project/src/views/Reportmanage/reportBigFeed.vue
+++ b/UI-Project/src/views/Reportmanage/reportBigFeed.vue
@@ -13,7 +13,7 @@
<el-option :label="$t('reportmanage.go')" value="1"></el-option>
<el-option :label="$t('reportmanage.nogo')" value="2"></el-option>
</el-select> -->
- <el-select v-model="report.taskState" :placeholder="$t('reportmanage.cstate')" style="margin-left: 10px;">
+ <el-select v-model="report.taskState" :placeholder="$t('reportmanage.cstate')" style="margin-left: 10px;width: 100px;">
<el-option :label="$t('reportmanage.all')" value="-1"></el-option>
<el-option :label="$t('reportmanage.scan')" value="0"></el-option>
<el-option :label="$t('reportmanage.feeding')" value="1"></el-option>
@@ -21,11 +21,13 @@
<el-option :label="$t('reportmanage.car')" value="3"></el-option>
<el-option :label="$t('reportmanage.cage')" value="4"></el-option>
</el-select>
- <el-select v-model="report.line" :placeholder="$t('reportmanage.cprocess')" style="margin-left: 10px;">
+ <el-select v-model="report.line" :placeholder="$t('reportmanage.cprocess')" style="margin-left: 10px;width: 100px;">
<el-option :label="$t('reportmanage.all')" value="0"></el-option>
<el-option :label="$t('reportmanage.oneline')" value="2001"></el-option>
<el-option :label="$t('reportmanage.twoline')" value="2002"></el-option>
</el-select>
+
+ <el-input v-model="timeInterval" style="margin-left: 15px;width: 100px" :placeholder="$t('reportmanage.timeInterval')"/>
<el-button type="primary" style="margin-left: 10px;" @click="selectReportData()">{{ $t('reportmanage.inquire')
}}</el-button>
</div>
@@ -57,6 +59,13 @@
<div id="dt" style="font-size: 15px;">
<el-form-item :label="$t('reportmanage.totalTakes')" style="width: 14vw">
{{ totalTakes }}
+ </el-form-item>
+ </div>
+ </el-col>
+ <el-col :span="3">
+ <div id="dt" style="font-size: 15px;">
+ <el-form-item :label="$t('reportmanage.workMinutes')" style="width: 14vw">
+ {{ totalMinutes }} min
</el-form-item>
</div>
</el-col>
@@ -97,8 +106,9 @@
taskState: '-1',
line: '0',
width: '',
- height: ''
+ height: '',
});
+const timeInterval= ref(120)
const reportData = ref([])
const endDate = new Date();
const startDate = new Date();
@@ -116,6 +126,9 @@
const totalAreas = ref(0);
const totalDamages = ref(0);
const totalTakes = ref(0);
+
+const workHours = ref(0);
+const totalMinutes = ref(0);
// 鏌ヨ鏁版嵁
const selectReportData = async () => {
@@ -152,10 +165,75 @@
totalDamages.value = totalDamage;
totalTakes.value = totalTake;
ElMessage.success(response.message);
+ const workTime = calculateWorkTime(response.data);
+ console.log(workTime);
+ workHours.value = workTime.totalHours;
+ totalMinutes.value =workTime.totalMinutes;
} else {
ElMessage.error(response.message);
}
};
+const calculateWorkTime = (tasks) =>{
+ // 澶勭悊绌烘暟鎹垨闈炴暟缁勬儏鍐�
+ if (!tasks || !Array.isArray(tasks) || tasks.length === 0) {
+ return {
+ totalSeconds: 0,
+ totalMinutes: 0,
+ totalHours: 0, // 纭繚鍒濆鍖�
+ periods: []
+ };
+ }
+
+ // 鎸夋椂闂存帓搴忎换鍔�
+ const sorted = [...tasks].sort((a, b) => new Date(a.createTime) - new Date(b.createTime));
+
+ // 鍒濆鍖栧彉閲�
+ const periods = [];
+ let start = new Date(sorted[0].createTime);
+ let end = start;
+
+ // 閬嶅巻璁$畻杩炵画鏃舵
+ for (let i = 1; i < sorted.length; i++) {
+ const prev = new Date(sorted[i - 1].createTime);
+ const curr = new Date(sorted[i].createTime);
+ const gap = (curr - prev) / 1000; // 闂撮殧绉掓暟
+ // alert(timeInterval.value)
+ if (gap <= timeInterval.value) {
+ end = curr;
+ } else {
+ periods.push({
+ start: new Date(start),
+ end: new Date(end),
+ duration: Math.round((end - start) / 1000)
+ });
+ start = curr;
+ end = curr;
+ }
+ }
+
+ // 娣诲姞鏈�鍚庝竴涓椂娈�
+ periods.push({
+ start: new Date(start),
+ end: new Date(end),
+ duration: Math.round((end - start) / 1000)
+ });
+
+ // 璁$畻鎬绘椂闀�
+ const totalSeconds = periods.reduce((sum, p) => sum + (p.duration > 0 ? p.duration : 0), 0);
+
+ // 纭繚鎵�鏈夋椂闂村瓧娈甸兘琚畾涔�
+ return {
+ totalSeconds: totalSeconds,
+ totalMinutes: Math.floor(totalSeconds / 60),
+ totalHours: (totalSeconds / 3600).toFixed(1), // 淇濈暀1浣嶅皬鏁�
+ periods: periods.map(p => ({
+ start: p.start.toLocaleString(),
+ end: p.end.toLocaleString(),
+ durationSeconds: p.duration,
+ durationMinutes: Math.floor(p.duration / 60)
+ }))
+ };
+}
</script>
\ No newline at end of file
--
Gitblit v1.8.0