liuwei преди 2 месеца
родител
ревизия
c9b92a7951

+ 57 - 10
src/main/resources/views/modules/mes/mesScreen3.html

@@ -1569,20 +1569,65 @@
 		return t >= day.startMs && t <= day.endMs;
 	}
 
-	// 综合大屏 - 当天返修数量(mes_repair) / 报废数量(mes_scrap)
+	function extractPageCount(resp) {
+		if (!resp) return 0;
+		if (typeof resp.count === 'number') return resp.count;
+		if (resp.data && typeof resp.data.count === 'number') return resp.data.count;
+		var list = extractList(resp);
+		return list.length;
+	}
+
+	// 中间卡:返修数量 ← mesRepair/listData;报废数量 ← mesScrap/listData(按当天 updateDate)
 	function updateRepairScrapCountByApi() {
+		var dayRange = getCalendarDayUpdateDateRange();
+		var pending = 2;
+		var repairCount = 0;
+		var scrapCount = 0;
+
+		function done() {
+			pending--;
+			if (pending > 0) return;
+			mockData.cards = mockData.cards || {};
+			mockData.cards.repairCount = repairCount;
+			mockData.cards.scrapCount = scrapCount;
+			renderTextData();
+		}
+
 		$.ajax({
-			url: '${ctx}/mes/mesProduct/dashboardCount',
+			url: '${ctx}/mes/mesRepair/listData',
 			type: 'POST',
 			dataType: 'json',
+			data: {
+				pageNo: 1,
+				pageSize: 1,
+				updateDate_gte: dayRange.gte,
+				updateDate_lte: dayRange.lte
+			},
 			success: function(resp) {
-				if (!resp || resp.result !== 'true' || !resp.data) {
-					return;
-				}
-				mockData.cards = mockData.cards || {};
-				mockData.cards.repairCount = Number(resp.data.repair) || 0;
-				mockData.cards.scrapCount = Number(resp.data.scrap) || 0;
-				renderTextData();
+				repairCount = extractPageCount(resp);
+				done();
+			},
+			error: function() {
+				done();
+			}
+		});
+
+		$.ajax({
+			url: '${ctx}/mes/mesScrap/listData',
+			type: 'POST',
+			dataType: 'json',
+			data: {
+				pageNo: 1,
+				pageSize: 1,
+				updateDate_gte: dayRange.gte,
+				updateDate_lte: dayRange.lte
+			},
+			success: function(resp) {
+				scrapCount = extractPageCount(resp);
+				done();
+			},
+			error: function() {
+				done();
 			}
 		});
 	}
@@ -1676,6 +1721,7 @@
 		}
 	}
 
+	/** 实际产量:OP400 当天完成(OK)数 */
 	function updateActualProductionByApi() {
 		var dayRange = getCalendarDayUpdateDateRange();
 		var pageSize = 3000;
@@ -1685,8 +1731,9 @@
 
 		function applyActualProductionCount(n) {
 			mockData.cards = mockData.cards || {};
-			mockData.cards.actualProduction = n;
+			mockData.cards.actualProduction = Number(n) || 0;
 			syncAchieveRateWithPlan();
+			renderTextData();
 		}
 
 		function fetchPage() {

+ 26 - 73
src/main/resources/views/modules/mes/mesScreen4.html

@@ -1036,83 +1036,35 @@
 
 	function applyActualProductionCount(n) {
 		mockData.cards = mockData.cards || {};
-		mockData.cards.actualProduction = n;
-		syncAchieveRateWithPlan();
-	}
-
-	function getCalendarDayUpdateDateRange() {
-		var now = new Date();
-		var pad = function(n) { return n < 10 ? '0' + n : '' + n; };
-		var dateStr = now.getFullYear() + '-' + pad(now.getMonth() + 1) + '-' + pad(now.getDate());
-		return {
-			gte: dateStr + ' 00:00:00',
-			lte: dateStr + ' 23:59:59',
-			startMs: new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime(),
-			endMs: new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999).getTime()
-		};
-	}
-
-	function parseRecordDateMs(val) {
-		if (val == null || val === '') {
-			return NaN;
-		}
-		if (typeof val === 'number' && !isNaN(val)) {
-			return val;
-		}
-		var s = String(val).trim().replace(/-/g, '/');
-		var t = Date.parse(s);
-		return isNaN(t) ? NaN : t;
-	}
-
-	function isRecordWithinToday(r, day) {
-		var t = parseRecordDateMs(r.updateDate || r.update_date);
-		if (isNaN(t)) {
-			return false;
-		}
-		return t >= day.startMs && t <= day.endMs;
+		mockData.cards.actualProduction = Number(n) || 0;
+		var el = document.getElementById('actualProduction');
+		if (el) el.textContent = mockData.cards.actualProduction;
 	}
 
+	/** 实际产量:取本阶段末工位当天 OK 数(半成品 OP100) */
 	function updateActualProductionByApi() {
-		var dayRange = getCalendarDayUpdateDateRange();
-		var pageSize = 3000;
-		var maxPages = 200;
-		var pageNo = 1;
-		var totalOk = 0;
-		function fetchPage() {
-			$.ajax({
-				url: '${ctx}/mes/mesProductRecord/listData',
-				type: 'POST',
-				dataType: 'json',
-				data: {
-					pageNo: pageNo,
-					pageSize: pageSize,
-					oprno: 'OP100',
-					content: 'OK',
-					lineSn: LINE_SN,
-					updateDate_gte: dayRange.gte,
-					updateDate_lte: dayRange.lte
-				},
-				success: function(resp) {
-					var list = extractUserList(resp);
-					for (var i = 0; i < list.length; i++) {
-						var r = list[i] || {};
-						if (isOprnoInRange(r.oprno, 100, 100) && isRecordContentOk(r.content) && isRecordWithinToday(r, dayRange) && String(r.lineSn || r.line_sn || '').toUpperCase() === LINE_SN) {
-							totalOk++;
-						}
-					}
-					if (list.length === pageSize && pageNo < maxPages) {
-						pageNo++;
-						fetchPage();
-					} else {
-						applyActualProductionCount(totalOk);
-					}
-				},
-				error: function() {
-					applyActualProductionCount(totalOk);
+		var oprno = HOURLY_API_CFG.offlineOprno || 'OP100';
+		$.ajax({
+			url: '${ctx}/mes/mesProductRecord/dayCapacityData',
+			type: 'POST',
+			dataType: 'json',
+			data: {
+				lineSn: LINE_SN,
+				oprnos: oprno
+			},
+			success: function(resp) {
+				if (!resp || resp.result !== 'true' || !resp.data) {
+					applyActualProductionCount(0);
+					return;
 				}
-			});
-		}
-		fetchPage();
+				var map = resp.data || {};
+				var formatted = oprno.length === 6 ? oprno.substring(0, 5) : oprno;
+				applyActualProductionCount(Number(map[oprno] != null ? map[oprno] : map[formatted]) || 0);
+			},
+			error: function() {
+				applyActualProductionCount(0);
+			}
+		});
 	}
 
 	function drawAllCharts() {
@@ -1127,6 +1079,7 @@
 		renderAlerts();
 		renderTable();
 		updateScreenConfigByApi();
+		updateActualProductionByApi();
 		updateLineProcessTableByApi();
 		updateDeviceAlarmAlertsByApi();
 		updateHourlyUpDownByApi();

+ 26 - 73
src/main/resources/views/modules/mes/mesScreen5.html

@@ -1117,83 +1117,35 @@
 
 	function applyActualProductionCount(n) {
 		mockData.cards = mockData.cards || {};
-		mockData.cards.actualProduction = n;
-		syncAchieveRateWithPlan();
-	}
-
-	function getCalendarDayUpdateDateRange() {
-		var now = new Date();
-		var pad = function(n) { return n < 10 ? '0' + n : '' + n; };
-		var dateStr = now.getFullYear() + '-' + pad(now.getMonth() + 1) + '-' + pad(now.getDate());
-		return {
-			gte: dateStr + ' 00:00:00',
-			lte: dateStr + ' 23:59:59',
-			startMs: new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime(),
-			endMs: new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999).getTime()
-		};
-	}
-
-	function parseRecordDateMs(val) {
-		if (val == null || val === '') {
-			return NaN;
-		}
-		if (typeof val === 'number' && !isNaN(val)) {
-			return val;
-		}
-		var s = String(val).trim().replace(/-/g, '/');
-		var t = Date.parse(s);
-		return isNaN(t) ? NaN : t;
-	}
-
-	function isRecordWithinToday(r, day) {
-		var t = parseRecordDateMs(r.updateDate || r.update_date);
-		if (isNaN(t)) {
-			return false;
-		}
-		return t >= day.startMs && t <= day.endMs;
+		mockData.cards.actualProduction = Number(n) || 0;
+		var el = document.getElementById('actualProduction');
+		if (el) el.textContent = mockData.cards.actualProduction;
 	}
 
+	/** 实际产量:取本阶段末工位当天 OK 数(机加 OP160) */
 	function updateActualProductionByApi() {
-		var dayRange = getCalendarDayUpdateDateRange();
-		var pageSize = 3000;
-		var maxPages = 200;
-		var pageNo = 1;
-		var totalOk = 0;
-		function fetchPage() {
-			$.ajax({
-				url: '${ctx}/mes/mesProductRecord/listData',
-				type: 'POST',
-				dataType: 'json',
-				data: {
-					pageNo: pageNo,
-					pageSize: pageSize,
-					oprno: 'OP180',
-					content: 'OK',
-					lineSn: 'XT',
-					updateDate_gte: dayRange.gte,
-					updateDate_lte: dayRange.lte
-				},
-				success: function(resp) {
-					var list = extractUserList(resp);
-					for (var i = 0; i < list.length; i++) {
-						var r = list[i] || {};
-						if (isOpr180Family(r.oprno) && isRecordContentOk(r.content) && isRecordWithinToday(r, dayRange) && String(r.lineSn || r.line_sn || '').toUpperCase() === 'XT') {
-							totalOk++;
-						}
-					}
-					if (list.length === pageSize && pageNo < maxPages) {
-						pageNo++;
-						fetchPage();
-					} else {
-						applyActualProductionCount(totalOk);
-					}
-				},
-				error: function() {
-					applyActualProductionCount(totalOk);
+		var oprno = HOURLY_API_CFG.offlineOprno || 'OP160';
+		$.ajax({
+			url: '${ctx}/mes/mesProductRecord/dayCapacityData',
+			type: 'POST',
+			dataType: 'json',
+			data: {
+				lineSn: LINE_SN,
+				oprnos: oprno
+			},
+			success: function(resp) {
+				if (!resp || resp.result !== 'true' || !resp.data) {
+					applyActualProductionCount(0);
+					return;
 				}
-			});
-		}
-		fetchPage();
+				var map = resp.data || {};
+				var formatted = oprno.length === 6 ? oprno.substring(0, 5) : oprno;
+				applyActualProductionCount(Number(map[oprno] != null ? map[oprno] : map[formatted]) || 0);
+			},
+			error: function() {
+				applyActualProductionCount(0);
+			}
+		});
 	}
 
 	function drawAllCharts() {
@@ -1210,6 +1162,7 @@
 		renderTable();
 		startOpTablePageRotate();
 		updateScreenConfigByApi();
+		updateActualProductionByApi();
 		updateLineProcessTableByApi();
 		updateDeviceAlarmAlertsByApi();
 		updateHourlyUpDownByApi();