|
|
@@ -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();
|