|
|
@@ -1550,6 +1550,53 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ function calcRatePercent(actual, plan) {
|
|
|
+ actual = Number(actual) || 0;
|
|
|
+ plan = Number(plan) || 0;
|
|
|
+ if (plan <= 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ return Math.round(actual * 100 / plan);
|
|
|
+ }
|
|
|
+
|
|
|
+ function syncAchieveRateWithPlan() {
|
|
|
+ mockData.cards = mockData.cards || {};
|
|
|
+ mockData.achieveRate = mockData.achieveRate || { labels: [], actual: [] };
|
|
|
+ var planNums = Number(mockData.cards.planProduction) || 0;
|
|
|
+ var actualProduction = Number(mockData.cards.actualProduction) || 0;
|
|
|
+ var labels = mockData.achieveRate.labels || [];
|
|
|
+ var actualSeries = mockData.achieveRate.actual || [];
|
|
|
+ var targetSeries = [];
|
|
|
+ for (var i = 0; i < labels.length; i++) {
|
|
|
+ targetSeries.push(planNums);
|
|
|
+ }
|
|
|
+ var maxVal = Math.max.apply(null, targetSeries.concat(actualSeries).concat([10]));
|
|
|
+ mockData.achieveRate.target = targetSeries;
|
|
|
+ mockData.achieveRate.max = maxVal <= 0 ? 10 : Math.ceil(maxVal * 1.1);
|
|
|
+ mockData.achieveRate.min = 0;
|
|
|
+ mockData.todayRate = calcRatePercent(actualProduction, planNums);
|
|
|
+ mockData.monthRate = calcRatePercent(actualProduction, planNums);
|
|
|
+ renderTextData();
|
|
|
+ drawAllCharts();
|
|
|
+ }
|
|
|
+
|
|
|
+ function updateLatestPlanProductionByApi() {
|
|
|
+ $.ajax({
|
|
|
+ url: '${ctx}/mes/mesPlan/latestPlanNums',
|
|
|
+ type: 'POST',
|
|
|
+ dataType: 'json',
|
|
|
+ success: function(resp) {
|
|
|
+ if (!resp || resp.result !== 'true' || !resp.data) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var planNums = Number(resp.data.nums) || 0;
|
|
|
+ mockData.cards = mockData.cards || {};
|
|
|
+ mockData.cards.planProduction = planNums;
|
|
|
+ syncAchieveRateWithPlan();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
function isOpr240Family(oprno) {
|
|
|
var op = (oprno || '').replace(/\s/g, '').toUpperCase();
|
|
|
if (op.length < 5 || op.indexOf('OP240') !== 0) return false;
|
|
|
@@ -1594,6 +1641,13 @@
|
|
|
var maxPages = 200;
|
|
|
var pageNo = 1;
|
|
|
var totalOk = 0;
|
|
|
+
|
|
|
+ function applyActualProductionCount(n) {
|
|
|
+ mockData.cards = mockData.cards || {};
|
|
|
+ mockData.cards.actualProduction = n;
|
|
|
+ syncAchieveRateWithPlan();
|
|
|
+ }
|
|
|
+
|
|
|
function fetchPage() {
|
|
|
$.ajax({
|
|
|
url: '${ctx}/mes/mesProductRecord/listData',
|
|
|
@@ -1620,17 +1674,11 @@
|
|
|
pageNo++;
|
|
|
fetchPage();
|
|
|
} else {
|
|
|
- mockData.cards = mockData.cards || {};
|
|
|
- mockData.cards.actualProduction = totalOk;
|
|
|
- var target = document.getElementById('actualProduction');
|
|
|
- if (target) target.textContent = totalOk;
|
|
|
+ applyActualProductionCount(totalOk);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
- mockData.cards = mockData.cards || {};
|
|
|
- mockData.cards.actualProduction = totalOk;
|
|
|
- var target = document.getElementById('actualProduction');
|
|
|
- if (target) target.textContent = totalOk;
|
|
|
+ applyActualProductionCount(totalOk);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -1733,6 +1781,7 @@
|
|
|
renderTextData();
|
|
|
updateProductionPeopleByApi();
|
|
|
updateDeviceCountByApi();
|
|
|
+ updateLatestPlanProductionByApi();
|
|
|
updateActualProductionByApi();
|
|
|
updateProductTrend7DaysByApi();
|
|
|
updateDeviceAlarmAlertsByApi();
|