This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
SXS20240115/SRC/iMES_PAD/module/moduleWIP/program/mrs-eqp/mrs-home/mrs-home.js
2024-01-24 16:47:50 +08:00

1360 lines
66 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

define(["app", "moment",
"module/moduleWIP/program/mrs-eqp/mrs00/mrs00Service",
"module/moduleWIP/program/mrs-eqp/mrs05/mrs05Service",
"module/moduleWIP/program/mrs-eqp/mrs06/mrs06Service",
"module/moduleWIP/program/common/mrs07/mrs07Service",
"module/moduleWIP/program/mrs-eqp/mrs08/mrs08Service",
"module/moduleWIP/program/mrs-eqp/mrs09/mrs09Service",
"module/moduleWIP/program/dialog/accessory/accessoryService.js",
"module/moduleWIP/program/common/wp06_sop_list/wp06_sop_list.js",
'module/moduleWIP/program/dialog/wp03_e_runcard_info/wp03_e_runcard_info',
"module/moduleWIP/program/common/wp05_lot_erf_create/wp05_lot_erf_create.js",
"module/moduleWIP/program/common/wp07_lot_wait_create/wp07_lot_wait_create.js"
],
function(app, moment) {
return ["$scope", "$filter", "$rootScope", "config", "$mdDialog", "DashboardService", "$http", "$stateParams", "RouterExtendProvider",
"MMWService", "$location", "$timeout", "mrs00Service", "mrs05Service", 'mrs06Service', "mrs07Service", "mrs08Service", "mrs09Service", "accessoryService", "wp06_sop_list", "wp03_e_runcard_info","wp05_lot_erf_create","wp07_lot_wait_create",
function($scope, $filter, $rootScope, config, $mdDialog, $DashboardService, $http, $stateParams, $RouterExtendProvider,
$MMWService, $location, $timeout, $mrs00Service, $mrs05Service, $mrs06Service, $mrs07Service, $mrs08Service, $mrs09Service, $accessoryService, $wp06_sop_list, $wp03_e_runcard_info,$wp05_lot_erf_create,$wp07_lot_wait_create) {
var SYSParameter;
var TempAttrib;
var StrType;
var Strlength;
var statusOrder = { 'C': 0, 'R': 1, 'Q': 2 };
var mrs10dialog;
$scope.ParameterValue = '';
$scope.dashboardPanel = ['deviceInfo', 'qualityStatus', 'workMaterial', 'workOperator', 'workLog'];
$scope.filterItem = { plot_no: '' };
$scope.work_machine;
$rootScope.bindingEQP = config.setting.equipment;
$scope.lot_selector = false; //20200914 雋辰,false:顯示派工生產批/true:顯示區域生產批
$scope.lot_selector_show = false; //20200914 雋辰,false:不顯示派工按鈕/true:顯示派工按鈕
$scope.init = function() {
//========== 我的最愛功能 (Start) ==========
if(config.cache.eqpbind == undefined || config.cache.eqpbind == null ){
config.cache.eqpbind = [];
}
var templocStorage = JSON.parse(localStorage.getItem(config.appName + '_MyFavorite'));
if(templocStorage != null ){
config.cache.eqpbind = templocStorage;
}
var drSel;
drSel = config.cache.eqpbind.filter(item => item['account'] == config.cache.account &&
item['workStation'] == config.setting.workStation);
if(drSel.length > 0) {
$rootScope.Is_myfavorite = true;
config.setting.workStation = drSel[0]['workStation'];
config.setting.equipment = drSel[0]['equipment'];
}
//========== 我的最愛功能 (End) ==========
//2020-05-19 modify by yenru 判斷是否有設定設備
if (config.setting.workStation == '' && config.setting.equipment == '') {
$scope.menu_temp = $rootScope.menuList;
$rootScope.menuList = [];
$rootScope.loadSideMenu();
$mrs00Service.init({
Binding: false,
callback: function(confirm) {
if (confirm) {
$rootScope.menuList = $scope.menu_temp;
$rootScope.bindingEQP = config.setting.equipment;
init_Layout();
}
}
});
} else {
//init_Layout();
$rootScope.EQPCheck_ModuleWIP(config.setting.workStation, function(data, result) {
if (result == false) {
return;
}
init_Layout();
});
}
}
$rootScope.loadFinish = true;
$rootScope.change_machine = function(options) {
var bln_EQP_binding;
if (config.setting.equipment == '') {
bln_EQP_binding = false;
} else {
bln_EQP_binding = true;
}
$mrs00Service.init({
Binding: bln_EQP_binding,
callback: function(confirm) {
if (confirm) {
if (!bln_EQP_binding) {
$rootScope.menuList = $scope.menu_temp;
$rootScope.bindingEQP = config.setting.equipment;
}
//========== 我的最愛功能 (Start) ==========
$rootScope.Is_myfavorite = false;
var drSel;
drSel = config.cache.eqpbind.filter(item => item['account'] == config.cache.account &&
item['workStation'] == config.setting.workStation &&
item['equipment'] == config.setting.equipment );
if(drSel.length > 0) {
$rootScope.Is_myfavorite = true;
}
//========== 我的最愛功能 (End) ==========
init_Layout();
}
}
});
}
$scope.refresh = function() {
//refreshDashboards();
Load_All_Dashboards(config.cache.equipment, config.cache.workStation);
}
$rootScope.changeEqp = function(event) {
if (event.keyCode == 13 && $scope.dashboard['deviceInfo'].input_eqp_no != undefined) {
var eqpno = $scope.dashboard['deviceInfo'].input_eqp_no;
//檢查設備是否存在於此作業站點
getAllMachineData($scope.workStation, eqpno, function(data) {
data = JSON.parse(data.ResultJson);
if (data.all_machine_data_get.length > 0) {
//設備存在於此作業站
Load_All_Dashboards(eqpno.toUpperCase(), config.cache.workStation);
} else {
//設備不存在於此作業站
$scope.$root.showAlert($filter('translate')('mrs00.msg.cantGet') + eqpno + $filter('translate')('mrs00.msg.machineInfo'));
}
});
$scope.dashboard['deviceInfo'].input_eqp_no = '';
}
}
//我的最愛
$rootScope.my_favorite = function () {
//PK為 User和OPNo
var templocStorage = JSON.parse(localStorage.getItem(config.appName + '_MyFavorite'));
if(templocStorage == null || templocStorage == undefined){
templocStorage = [];
}
var myfavorite = templocStorage;
var drSel;
drSel = templocStorage.filter(item => item['account'] == config.cache.account &&
item['workStation'] == config.setting.workStation &&
item['equipment'] == config.setting.equipment);
//1.自己是我的最愛時候,移除全部
if(drSel.length > 0){
for (var i = 0;i< templocStorage.length ; i++) {
if (templocStorage[i]['account'] == config.cache.account && templocStorage[i]['workStation'] == config.setting.workStation) {
templocStorage.splice(i,1);
}
}
$rootScope.Is_myfavorite = false;
myfavorite = templocStorage;
}else{
drSel = templocStorage.filter(item => item['account'] == config.cache.account &&
item['workStation'] == config.setting.workStation);
var tempary = [];
if(drSel.length > 0) {
var IsSameData = false; //如果又是相同作業站時
for (var i = 0;i< templocStorage.length ; i++) {
if (templocStorage[i]['account'] == config.cache.account && templocStorage[i]['workStation'] == config.setting.workStation) {
templocStorage.splice(i,1);
IsSameData = true;
}
}
if(IsSameData){
tempary = { account:config.cache.account,
workStation:config.setting.workStation,
equipment:config.setting.equipment }
myfavorite.push(tempary);
$rootScope.Is_myfavorite = true;
}else{
$rootScope.Is_myfavorite = false;
myfavorite = templocStorage;
}
}else{
tempary = { account:config.cache.account,
workStation:config.setting.workStation,
equipment:config.setting.equipment }
myfavorite.push(tempary);
$rootScope.Is_myfavorite = true;
}
}
localStorage.setItem(config.appName + "_MyFavorite", JSON.stringify(myfavorite));
config.cache.eqpbind = JSON.parse(localStorage.getItem(config.appName + '_MyFavorite'));
}
$scope.btn_status_filter = function(clicktype, event) {
event.stopPropagation();
switch (clicktype) {
case 'queue':
$scope.filter_queue = !$scope.filter_queue;
break;
case 'running':
$scope.filter_running = !$scope.filter_running;
break;
case 'complete':
$scope.filter_complete = !$scope.filter_complete;
break;
}
}
$scope.formatDate = function(finish_time) {
if (finish_time != null) { return moment(finish_time).format('MM/DD HH:mm:ss'); }
}
$scope.CustomerFilter = function(item) {
isShow = true;
if ($scope.filterItem.plot_no == undefined || $scope.filterItem.plot_no == '') {
isShow = true;
if ($scope.filter_queue != true) {
if (item.status == 'Q') { isShow = false; }
}
if ($scope.filter_running != true) {
if (item.status == 'R') { isShow = false; }
}
if ($scope.filter_complete != true) {
if (item.status == 'C') { isShow = false; }
}
} else {
if (item.plot_no.match('/' && $scope.filterItem.plot_no)) {
isShow = true;
if ($scope.filter_queue != true) {
if (item.status == 'Q') { isShow = false; }
}
if ($scope.filter_running != true) {
if (item.status == 'R') { isShow = false; }
}
if ($scope.filter_complete != true) {
if (item.status == 'C') { isShow = false; }
}
} else {
isShow = false;
}
}
//2020/09/14 Grace 增加判斷派工顯示
if (isShow) {
//false:顯示手動派工生產批、true:顯示 區域生產批
if ($scope.lot_selector) {
//Dispatch:1 (1:手動派工、0:區域)
if (item.Dispatch == "0") { isShow = true; } else { isShow = false; }
} else {
if (item.Dispatch == "1" && item.status == 'Q' ||
item.Dispatch == "0" && item.status == 'R') { isShow = true; } else { isShow = false; }
}
}
return isShow;
}
$scope.changeSelector = function() {
$scope.lot_selector = !$scope.lot_selector;
}
$scope.togglePanel = function(sectionName, $event) {
var target = $scope.dashboard[sectionName];
if (config.cache.platform == 'SFT' && (sectionName == 'qualityStatus' || sectionName == 'workOperator')) {
$scope.isInnerContentHide = !$scope.isInnerContentHide;
$scope.dashboard['qualityStatus'].isContentHide = $scope.dashboard['workOperator'].isContentHide = $scope.isInnerContentHide;
if ($scope.isInnerContentHide) {
$scope.dashboard['qualityStatus'].titleIconStyle = $scope.dashboard['workOperator'].titleIconStyle = { transform: 'rotate(180deg)' };
} else {
$scope.dashboard['qualityStatus'].titleIconStyle = $scope.dashboard['workOperator'].titleIconStyle = {};
}
} else {
target.isContentHide = !target.isContentHide;
if (target.isContentHide) {
target.titleIconStyle = { transform: 'rotate(180deg)' };
} else {
target.titleIconStyle = {};
}
}
}
$scope.orderStatus = function(item) {
return statusOrder[item.status];
}
var statusCount = 0;
$scope.countStatus = function(item) {
if (item.status == 'C')
statusCount++;
}
$scope.goStatusR = function() {
//$timeout(function(){
// $location.hash("log_R");
//}, 300);
$timeout(function() {
var workLogList = document.getElementsByClassName('kmi-list__workLog')[0]; //angular.element(document).find('.workLog .kmi-list__row-content');
workLogList.scrollTop = (+statusCount) * 46 + 2;
console.log(workLogList.scrollTop);
});
};
//20170410 modify by megabytes for 將item整個物件傳入
$scope.goToTrack = function(item) {
/*
if(item.status == 'R'){
$rootScope.changeProgram("mrs04", {data:item});
} else if(item.status == 'Q'){
$rootScope.changeProgram("mrs03", {data:item});
}
*/
$scope.selectItem = item;
if ($scope.selectItem.STATUS != -1) {
$scope.openToolBar(item.status);
}
}
$scope.goToMRS01 = function(item) {
$rootScope.changeProgram("mrs01_lot", { data: item.employee_no });
};
$scope.goToMRS00 = function(event) {
$rootScope.hideMenu();
if ($scope.config.setting.opdatasetting == "eqp") {
//設備優先
//$scope.$root.showAlert($scope.config.setting.opdatasetting + ' changeprogram :mrs00');
$scope.$root.changeProgram('mrs10', { parent: 'moduleWIP' });
} else {
//作業站優先
//$scope.$root.showAlert($scope.config.setting.opdatasetting + ' changeprogram :mrs10');
$scope.$root.changeProgram('mrs00', { parent: 'moduleWIP' });
}
};
// $scope.goToMRS10 = function(event){
// $rootScope.hideMenu();
// $scope.$root.changeProgram('mrs10', {parent:'moduleWIP'});
// }
//取得系統參數"是否啟用eSOP功能"的設定值
$scope.sop_info_get_json = function () { /* SOP */
var attNo = 'SOP';
$MMWService.sendToMESSrv({
//20220822,13871,0117581: 【先之科】PAD上查看sop时候错误,改呼叫 EAI -> MESws_STD
uri: 'kcWIP.clsMDS.funGetSop',
content: {
LotNo: $scope.selectItem.LOTNO,
AttribNo: attNo
},
success: function (data) {
var data = JSON.parse(data.ResultJson);
var sop_path = data.ReturnValue;
//http:// "config.server.ip " + "/" +"config.server.name" + "tempSOP/" + " 檔名"
//20220822,13871,0117581: 【先之科】PAD上查看sop时候错误
if (!$rootScope.IsNullOrEmpty(sop_path)) {
var soptype = sop_path.substring(0, 4);
if (soptype == 'http' || soptype == 'https' || soptype == 'HTTP' || soptype == 'HTTPS') {
openDialog(sop_path);
} else {
var ip = config.setting.DNSMode ? config.server.DNS : config.server.ip;
openDialog('http://' + ip + ':' + config.server.port + '/' + config.server.name + '/tempSOP/' + sop_path);
}
} else {
$rootScope.showMessage('[%LOT%] [%ATTRIBNO%] [%IS NOT EXIST%],[%ATTRIBNO%]:' + attNo, '0000-200003')
}
},
error: function (data) {
//20220822,13871,0117581: 【先之科】PAD上查看sop时候错误,註解,error透過MMWServcie顯示錯誤訊息
//$scope.$root.showAlert($filter('translate')('開啟SOP失敗')); //0068344 SOP錯誤訊息提示
// $scope.$root.showAlert($filter('translate')('Setting.msg.connect.failure')+"<br>"+data.Exception);
}
});
}
$scope.LoadParameter = function() {
$MMWService.sendToMESSrv({
uri: 'kcSYS.clsSYSParameter.LoadParameter',
content: {
parametertype: 'SysInfo',
parameterno: 'Execute_eSOP'
},
success: function(data) {
var data = JSON.parse(data.ResultJson);
SYSParameter = data.SYSParameter.ParameterValue
$scope.ParameterValue = data.SYSParameter["0"]["PARAMETERVALUE"]
},
error: function(data) {
$scope.$root.showAlert($filter('translate')('Setting.msg.connect.failure') + "<br>" + data.Exception);
}
});
}
$scope.show_SOP = function() { /* SOP */
$MMWService.sendToMESSrv({
uri: 'KMI.sop_info_get_json',
content: {
plot_no: '$scope.selectItem.plot_no,',
attrib_no: 'SOP'
},
success: function(data) {
var data = JSON.parse(data.ResultJson1);
$scope.ParameterValue = data.sop_path;
openDialog($scope.ParameterValue);
},
error: function(data) {
$scope.$root.showAlert($filter('translate')('Setting.msg.connect.failure') + "<br>" + data.Exception);
// $scope.$root.showAlert($filter('translate')('開啟SOP失敗')); //0068344 SOP錯誤訊息提示
}
});
}
//取得是否有設定SOP的AttribNo
$scope.LoadTemp_AttribJoinBasis = function() {
$MMWService.sendToMESSrv({
uri: 'kcWIP.clsLot.LoadTemp_AttribJoinBasis',
content: {
lotno: $scope.selectItem.plot_no,
attribno: 'SOP'
},
success: function(data) {
var data = JSON.parse(data.ResultJson);
var AttribNo = data.TempAttrib["0"]["ATTRIBNO"]
var AttribValue = data.TempAttrib["0"]["ATTRIBVALUE"]
if (AttribValue != null) {
if (AttribValue.length >= 4) {
var StrAttribValue = AttribValue.substring(0, 4)
if (StrAttribValue == 'http') {
openDialog(AttribValue);
} else if (StrAttribValue == 'HTTP') {
//顯示出AttibValue所設定之網頁
openDialog(AttribValue);
} else {
$scope.$root.showAlert($filter('translate')('Setting.msg.AttibValue_Setting'));
}
} else {
$scope.$root.showAlert($filter('translate')('Setting.msg.AttibValue_Setting'));
}
} else {
$scope.$root.showAlert($filter('translate')('Setting.msg.SOP_Setting'));
}
},
error: function(data) {
$scope.$root.showAlert($filter('translate')('Setting.msg.connect.failure') + "<br>" + data.Exception);
}
});
}
var openDialog = function(sopFile) {
$mdDialog.dialog('module/moduleWIP/program/common/mrs07/mrs07.html',
function(dialog) {
var Strfour = sopFile.substring(sopFile.length - 4, sopFile.length);
if (Strfour === '.pdf') { StrType = '0' } else { StrType = '1' };
return {
esopList: {},
isListOpen: false,
currentFile: { esop_content: sopFile, content_type: StrType },
beforeShown: function() {
loadESOPFile(sopFile, dialog);
},
closeList: function() {
dialog.isListOpen = !dialog.isListOpen;
},
clickEsopFile: function(esopFile) {
loadESOPFile(esopFile, dialog);
},
back: function() {
dialog.hide();
}
}
}
);
}
function init_Layout() {
//$DashboardService.startSignalR();
$scope.menu = config.menu;
$scope.config = config;
//2019-06-25 yenru,需設定在dashboard前
config.cache.dashboard = 'eqp';
$scope.dashboard = $DashboardService.dashboard;
$scope.filter_queue = true;
$scope.filter_running = true;
$scope.filter_complete = true;
//2019-08-29 yenru,暫時不用dashboard auto refresh
if (config.cache.equipment == undefined) {
config.cache.equipment = config.setting.equipment;
}
if (config.cache.workStation == undefined) {
config.cache.workStation = config.setting.workStation;
}
//20221123,13871,不應該覆蓋生產批報工使用的op
//if (config.cache.op == undefined) {
// config.cache.op = config.setting.workStation;
//}
//2020-05-08 yenru add,UCD Layout menu top right working machine;
$scope.work_machine = config.cache.equipment;
$scope.lot_selector_show = config.cache.dashboard == "eqp" ? true : false;
$scope.LoadParameter();
//if(!$DashboardService.isStart){
// $DashboardService.startWatch();
//}
//else
//{
// refreshDashboards();
//}
$timeout(function() {
//2020-05-07 yenru add.
//UCD Layout Right Top Menu Button;
$scope.$root.btnList = [
//{
// //設備流程
// name:"button",
// icon_scr: 'image/icons/btn_home_01.png',
// class: [], //按鈕額外的class
// disabled: false,
// click: function () {
// //按鈕點擊
// }
//},
{
//重新整理
name: "button_refresh",
icon_scr: 'image/iMES_icon/icon_refresh@1x.png',
class: [], //按鈕額外的class
disabled: false,
title: $filter('translate')('mrs-home.btn.refresh'),
click: function() {
//按鈕點擊
Load_All_Dashboards(config.cache.equipment, config.cache.workStation);
}
},
{
//領用模治具
name: "button_accessory",
icon_scr: 'image/iMES_icon/icon_accessory@2x.png',
class: [], //按鈕額外的class
disabled: false,
title: $filter('translate')('mrs-home.btn.accessory'),
click: function() {
//按鈕點擊
$accessoryService.init({
//設備模式,模治具變動需要更新首頁資訊
AccessoryRefresh: function(accessory) {
try {
if (accessory) {
//$scope.dashboard['workAccessory'].accessory_detail = [];
//var i = 0;
//for (i = 0; i < accessory.length; i++) {
// var total;
// var bar;
// var color;
// if (accessory[i].REPAIRCYCLE == null || accessory[i].REPAIRCYCLE == 'N/A' || accessory[i].REPAIRCYCLE == undefined)
// total = "N/A";
// else
// total = accessory[i].REPAIRCYCLE;
//
// if (total == 'N/A') {
// bar = 0;
// color = '238,241,247';
// } else {
// bar = accessory[i].ACCUMULATEQTY / accessory[i].REPAIRCYCLE * 100;
// color = bar >= 50 ? '200,57,55' : '75,167,111';
// }
// $scope.dashboard['workAccessory'].accessory_detail.push({
// accessory_no: accessory[i].ACCESSORYNO,
// accessory_accumulateqty: accessory[i].ACCUMULATEQTY,
// accessory_acctotalusedqty: total,
// accessory_bar: bar,
// color: color
// });
//}
Load_All_Dashboards(config.cache.equipment, config.cache.workStation);
}
} catch (e) {
}
}
});
}
},
{
//設備稼動
name: "button_mobilize",
icon_scr: 'image/iMES_icon/icon_efficacy@2.png',
class: [], //按鈕額外的class
disabled: false,
title: $filter('translate')('mrs-home.btn.mobilize'),
click: function() {
//按鈕點擊
$mrs06Service.init({
callBack: function(result) {
$scope.$root.machine_info.mahcine_status = result.eqState;
$scope.$root.machine_info.status_name = result.eqName;
}
});
}
},
{
//設備點檢
name: "button_check",
icon_scr: 'image/iMES_icon/icon_check@2.png',
class: [], //按鈕額外的class
disabled: false,
title: $filter('translate')('mrs-home.btn.check'),
click: function () {
//按鈕點擊
$mrs05Service.init({
EquipmentNo: $scope.work_machine,
callBack: function(result) {
Load_All_Dashboards(config.cache.equipment, config.cache.workStation);
}
});
}
}
];
//$rootScope.loadMenu();
Load_All_Dashboards(config.cache.equipment, config.cache.workStation);
$rootScope.loadSideMenu();
//$DashboardService.stopWatch();
});
}
function loadESOPFile(esopFile, dialog) {
if (esopFile.content_type == '') {
openFile(esopFile.esop_content);
} else {
//dialog.currentFile = esopFile;
dialog.pdf_url = '';
dialog.video_url = '';
//document.getElementById('kmi-pdf-panel').innerHtml = '';
if (dialog.currentFile.content_type == '0') {
//PDF
dialog.pdf_url = 'JSplugins/pdfjs/web/viewer.html?file=' + dialog.currentFile.esop_content +
'&openfile=false&viewbookmark=false&printfile=false&download=false#auto';
} else if (dialog.currentFile.content_type == '1') {
//影片
dialog.video_url = dialog.currentFile.esop_content.replace('http://', '');
$timeout(function() {
var VideoPanel = document.getElementById('kmi-video-panel');
VideoPanel.innerHTML = '';
VideoPanel.innerHTML = "<source src='" + dialog.currentFile.esop_content + "' type=\"video/mp4\">";
});
} else if (dialog.currentFile.content_type == '2') {
var kmiImgPanel = document.getElementById('kmi-img-panel');
kmiImgPanel.style.width = '100%';
kmiImgPanel.style.height = '100%';
}
}
}
function plot_reverse_process(PlotNo, callback) {
$MMWService.sendToEAISrv({
uri: 'KMI.plot.reverse.triggerop.process',
content: {
plot: PlotNo,
userno: config.cache.account,
lotstamp: -1,
opno: config.cache.workStation
},
success: function(data) {
if (callback)
callback(data);
}
});
}
/****DialogList*************************************************************************************************************************************/
var dialogList = [
// //進站
// {
// name: $filter('translate')('menuTitle.checkin'),
// status: ['Q'],
// programName: 'mrs03',
// init: function() {
// $rootScope.changeProgram($scope.selectItem.cur_br.toLowerCase() + '|eqp', { data: $scope.selectItem });
// }
// },
// // 出站
// {
// name: $filter('translate')('menuTitle.checkout'),
// status: ['R'],
// programName: 'mrs04',
// init: function() {
// $rootScope.changeProgram($scope.selectItem.cur_br.toLowerCase() + '|eqp', { data: $scope.selectItem });
// }
// },
// //20201106 雋辰,品檢
// {
// name: $filter('translate')('menuTitle.spc'),
// status: ['SPC'],
// programName: 'br03_lot_spc',
// init: function() {
// $rootScope.changeProgram('br03_lot_spc', { data: $scope.selectItem });
// }
// },
//報工
{
name: $filter('translate')('wp_excute_lot.menuTitle'),
status: [],
programName: 'wp_excute_lot',
init: function() {
$rootScope.changeProgram('wp_excute_lot', { data: $scope.selectItem });
}
},
//SOP
{
name: $filter('translate')('mrs07.menuTitle'),
status: ['R'],
programName: 'mrs07',
init: function() {
if ($scope.ParameterValue == '2') {
//EAI 外部API
$wp06_sop_list.init({ plotItem: $scope.selectItem });
} else if ($scope.ParameterValue == '1') {
$scope.$root.showAlert($filter('translate')('開啟SOP失敗(目前系統參數(Execute_eSOP)1'));
} else
$scope.sop_info_get_json();
}
},
//E-RunCard
{
name: $filter('translate')('wp03_e_runcard.title'),
status: [],
programName: 'wp03_e_runcard',
init: function () {
$wp03_e_runcard_info.init({ LOTNO: $scope.selectItem.LOTNO });
}
},
//異常
{
name: $filter('translate')('imes_resources.HOLD'),
status: [],
programName: 'wp05_lot_erf_create',
init: function() {
//pChkWIP: WIP 開單
//pERFSource: '0:WIP,1:SPC,2:Receive
var ERFData = [];
ERFData.push({
pLotNo: $scope.selectItem.LOTNO,
pUserId: config.account,
pERFType: 2,
pERFSource: 0,
confirm: function(){
Load_All_Dashboards(config.cache.equipment, config.cache.workStation);
}
});
$wp05_lot_erf_create.init({ data: { ERFData}});
}
},
//等待
{
name: $filter('translate')('imes_resources.WAIT'),
status: ['R'],
programName: 'wp07_lot_wait_create',
init: function () {
//20221031,13871,0121333: [PAD]報工首頁部份生產批狀態完全空白,LotStamp改為前端傳入
var obj = {
LOTNO: $scope.selectItem.LOTNO,
LOTSTAMP: $scope.selectItem.LOTSTAMP,
confirm: function(){
Load_All_Dashboards(config.cache.equipment, config.cache.workStation);
}
}
$wp07_lot_wait_create.init(obj);
}
},
//wait & Relesase 暫時Mark 待功能完善再補回
//暫停
//{name: $filter('translate')('mrs08.menuTitle'), cur_br:['BR_L_CI_GEN.dll','BR_L_CIBatch_MultiUser.dll','BR_L_CO_GEN.dll','BR_L_COBatch_MultiUser.dll'], programName : 'mrs08',
//init : function(){
//$mrs08Service.init({
//plotItem : $scope.selectItem,
//feedback : refreshDashboards
//});
//}},
//解除暫停
//{name: $filter('translate')('mrs09.menuTitle'),cur_br:[], status:['W'], programName : 'mrs09',
//init : function(){
//$mrs09Service.init({
//plotItem : $scope.selectItem,
//feedback : refreshDashboards
//});
//}},
//還原
{
name: $filter('translate')('menuTitle.undo'),
status: ['R'],
programName: 'mrs03',
init: function() {
//console.log($scope.selectItem['plot_no']);
plot_reverse_process($scope.selectItem['plot_no'],
function() {
Load_All_Dashboards(config.cache.equipment, config.cache.workStation);
});
}
},
{ name: $filter('translate')('home.X'), status: [], programName: '', }
];
$scope.openToolBar = function(status) {
$scope.workLogStatus = status;
$mdDialog.dialog(
'module/moduleWIP/program/mrs-eqp/mrs-home/mrs_ToolBar.tmp.html',
ToolBarController
);
}
$scope.change_deviceInfo = function(num_of_days) {
$scope.dashboard.deviceInfo.num_of_days = num_of_days;
refreshDashboards();
}
function ToolBarController(dialog) {
return {
dialogList: dialogList,
buttonAction: function(button) {
dialog.hide();
if (button.init)
button.init($scope.workLogStatus);
},
btnFilter: function(button) {
if (button.status.length == 0) {
return button;
} else {
//20220822,13871,0117581: 【先之科】PAD上查看sop时候错误
if (button.programName == 'mrs07') {
if ($scope.selectItem && $scope.selectItem.STATUS > 0)
return button;
}
//20221031,13871,0121333: [PAD]報工首頁部份生產批狀態完全空白,禁止除了Status0|1|4顯示等待按鈕
if (button.programName == 'wp07_lot_wait_create') {
if ($scope.selectItem && ($scope.selectItem.STATUS == 0 || $scope.selectItem.STATUS == 1 || $scope.selectItem.STATUS == 4))
return button;
}
if (!config.cache.permissions || config.cache.permissions.indexOf(button.programName) != -1) {
if (button.status.indexOf($scope.workLogStatus) != -1) {
return button;
}
}
}
},
back: function() {
dialog.hide();
}
}
}
function refreshDashboards() {
Load_All_Dashboards(config.cache.equipment, config.cache.workStation);
//$DashboardService.getDashBoardData({
// equipment : config.cache.equipment,
// dataType :'1111',
// isShowLoading : true
//});
}
//2020/09/14 Grace 增加查詢, 依據綁定的設備與當站作業站編號, 取得已派工的生產批資料
function funShowEQPDispatchStateJoinLotState(eqpno, workStation, callback, isLoading) {
$MMWService.sendToMESSrv({
uri: 'kcWIP.clsMDS.ShowEQPDispatchStateJoinLotState',
content: {
EquipmentNo: eqpno,
OPNo: workStation
},
success: function(data) {
if (callback)
callback(data);
},
error: function(data) {
$scope.$root.showAlert(data.Exception);
}
}, isLoading);
}
function Load_All_Dashboards(eqpno, opno) {
var isShowLoading = true;
var temppp = [];
//移除EAI 架構直接呼叫KC
var uri = [];
var content = [];
// 1.設備資訊
uri.push("kcWIP.clsMDS.LoadEquipmentStateInfo");
content.push({
EquipmentNo: eqpno,
Days: $scope.dashboard['deviceInfo'].num_of_days
});
// 2.品質資訊
uri.push("kcWIP.clsMDS.LoadQualityDetail");
content.push({
EquipmentNo: eqpno
});
// 3.上工人員
uri.push("kcWIP.clsMDS.LoadWorkMemberDetail");
content.push({
EquipmentNo: eqpno
});
// 4.上料資訊
uri.push("kcWIP.clsMDS.LoadMaterialsDetail");
content.push({
EquipmentNo: eqpno
});
// 5.生產資訊
uri.push("kcWIP.clsMDS.LoadProductionInfoDetail");
content.push({
EquipmentNo: eqpno,
OPNO: opno
});
getEquipmentStatus(uri, content, function(data) {
data = JSON.parse(data.ResultJson);
if (Object.keys(data).length > 0) {
try {
//總機時加總
var int_eqp_total_time = 0;
var tmp = JSON.parse(data['kcWIP.clsMDS.LoadEquipmentStateInfo'])
tmp.rate_detail = [];
tmp.machine_utilization_rate_detail.forEach(function(detail) {
tmp.rate_detail.push({ label: detail.EQUIPMENTSTATE, value: detail.WORK_TIME, color: 'rgb(' + detail.STATUS_COLOR + ')', name: detail.STATENAME });
int_eqp_total_time = Number(int_eqp_total_time) + Number(detail.WORK_TIME);
});
angular.merge($scope.dashboard['deviceInfo'], tmp);
tmp.machine_no = tmp.machine_property_detail[0].EQUIPMENTNO;
tmp.machine_name = tmp.machine_property_detail[0].DESCRIPTION;
tmp.area_no = tmp.machine_property_detail[0].AREANO;
tmp.machine_status = tmp.machine_property_detail[0].EQUIPMENTSTATE;
tmp.status_name = tmp.machine_property_detail[0].STATENAME;
//2020-05-12 yenru add menu top right Equipment State & Chage EQP ICON
$scope.$root.machine_info = tmp;
$scope.dashboard['deviceInfo'].rate_detail = tmp.rate_detail;
$scope.dashboard['deviceInfo'].total_time = int_eqp_total_time.toFixed(1);
//20181108 modify by Dustdusk fro M#: 機台參數沒有更新
eqp_spec_bar(tmp.machine_property_detail, function(data) {
$scope.dashboard['deviceInfo'].machine_property_detail = data
//2019-09-10 yenru 若設備參數資料設定不完整,不顯示於看板。
$scope.dashboard['deviceInfo'].machine_property_detail.forEach(function(eletemp) {
if (eletemp.GUIDELINE_1 == '' || eletemp.GUIDELINE_2 == '' || eletemp.GUIDELINE_MAX == '' || eletemp.GUIDELINE_MIN == '' || eletemp.PROPERTY_VALUE == '') {
$scope.dashboard['deviceInfo'].machine_property_detail.splice(eletemp);
}
});
});
//2020-05-07 yenru UCD Layout 新增 模治具區塊
$scope.dashboard['workAccessory'].accessory_detail = tmp.machine_accessory_detail;
$scope.dashboard['workAccessory'].accessory_detail.forEach(function(item) {
if (item.ACCUMULATEQTY == 'N/A') {
item.accessory_bar = 0;
item.color = '238,241,247';
} else {
item.accessory_bar = item.ACCUMULATEQTY / item.REPAIRCYCLE * 100;
if (item.accessory_bar >= 50) {
item.color = '200,57,55';
} else {
item.color = '75,167,111';
}
}
});
//2020-05-07 yenru UCD Layout 新增 總機時區塊
$scope.dashboard['workTime'].machine_utilization_rate_detail = tmp.machine_utilization_rate_detail;
$scope.dashboard['workTime'].machine_totla_time = int_eqp_total_time;
//2020-05-07 yenru UCD Layout 新增 設備參數區塊
//整理設備參數不正常設定值,不顯示
var dash_Recipe = [];
tmp.machine_property_detail.forEach(function(temp) {
if (temp.PARAMETERNO == '' || temp.PARAMETERNO == null || temp.PARAMETERNO == undefined) {} else {
dash_Recipe.push(temp);
}
})
$scope.dashboard['workRecipe'].machine_Recipe = dash_Recipe;
//計算條列圖百分比
$scope.dashboard['workTime'].machine_utilization_rate_detail.forEach(function(item) {
var int_data_range = 0;
int_data_range = ((Number(item.WORK_TIME) / Number($scope.dashboard['workTime'].machine_totla_time).toFixed(2)) * 100);
item.BAR = int_data_range;
});
config.cache.equipment = eqpno;
config.setting.equipment = eqpno;
//儲存設定的作業站&設備
if (typeof(Storage) !== "undefined") {
localStorage.setItem(config.appName + "_setting", JSON.stringify(config.setting));
}
//人員上下工相關資料
var tmp = JSON.parse(data['kcWIP.clsMDS.LoadWorkMemberDetail']);
//$scope.dashboard['workOperator'].default_shift = data.shift;
$scope.dashboard['workOperator'].work_member_detail = tmp.work_member_detail;
//品質狀態相關資料
var tmp = JSON.parse(data['kcWIP.clsMDS.LoadQualityDetail']);
try {
//不良品數量
tmp.quality_detail[0].SHIFT_DEFECT_QTY = tmp.quality_detail[0].SHIFT_DEFECT_QTY || 0;
//總數量
tmp.quality_detail[0].SHIFT_WORK_QTY = tmp.quality_detail[0].SHIFT_WORK_QTY || 0;
//不良率
var qty_rate = tmp.quality_detail[0].SHIFT_DEFECT_QTY / tmp.quality_detail[0].SHIFT_WORK_QTY * 100;
if (isNaN(qty_rate)) {
tmp.quality_detail[0].QTY_RATE = 0;
} else {
tmp.quality_detail[0].QTY_RATE = qty_rate.toFixed(2);
}
//良品率
var g_qty_rate = 100 - qty_rate;
tmp.quality_detail[0].G_QTY_RATE = g_qty_rate;
tmp.quality_detail[0].LIGHTCOLOR = lightColor(tmp.quality_detail[0]);
} catch (e) {
tmp.quality_detail[0].QTY_RATE = 0;
}
$scope.dashboard['qualityStatus'].quality_detail = tmp.quality_detail[0];
//上料相關資料
var tmp = JSON.parse(data['kcWIP.clsMDS.LoadMaterialsDetail']);
var dash_Material = [];
tmp.materials_detail.forEach(function(temp) {
if (temp.MATERIALS_QTY == 0 || temp.MATERIALS_QTY == null) {} else {
dash_Material.push(temp);
}
})
$scope.dashboard['workMaterial'].materials_detail = dash_Material;
//2020/08/19 雋辰,新增成員status_order,排序用
var tmp = JSON.parse(data['kcWIP.clsMDS.LoadProductionInfoDetail']);
var i = 0;
$scope.dashboard['workLog'].production_info_detail = [];
for (i = 0; i < tmp.production_info_detail.length; i++) {
if (tmp.production_info_detail[i].status == 'C')
tmp.production_info_detail[i].status_order = 1;
else
tmp.production_info_detail[i].status_order = 0;
//2020/09/14 Grace 增加 Dispatch (1:手動派工、0:區域)
tmp.production_info_detail[i].Dispatch = 0;
temppp.push(tmp.production_info_detail[i]);
}
//生產資訊
//$scope.dashboard['workLog'].production_info_detail = data.production_info_detail;
$scope.dashboard['workLog'].production_info_detail = temppp;
$scope.dashboard.updateTime = new Date();
//2020/09/14 Grace 增加查詢, 依據綁定的設備與當站作業站編號, 取得已派工的生產批資料
funShowEQPDispatchStateJoinLotState(eqpno, opno, function(data) {
data = JSON.parse(data.ResultJson);
if (data.EQPDispatchStateJoinLotState) {
if (data.EQPDispatchStateJoinLotState.length > 0) {
for (var index in data.EQPDispatchStateJoinLotState) {
var item = data.EQPDispatchStateJoinLotState[index];
//已派工生產資訊
//$scope.dashboard['workLog'].production_info_detail.push({
temppp.push({
status: item.STATUS,
plot_no: item.PLOT_NO,
qty: item.QTY,
finish_time: item.FINISH_TIME,
cur_br: item.CUR_BR,
arrivetime: item.ARRIVETIME,
status_order: item.STATUS == 'C' ? 1 : 0,
Dispatch: item.DISPATCH
});
}
}
}
}, isShowLoading);
} catch (e) {
}
}
}, isShowLoading);
}
function getEquipmentStatus(uri, content, callback) {
$MMWService.sendToMESSrv_Multi({
uri: uri,
content: content,
success: function(data) {
if (callback)
callback(data);
}
});
}
function lightColor(item) { //0068461 20200310 設備報工燈號
if (item.QTY_RATE < item.QUALITY_GUIDELINE_Y) {
return 'green';
} else if (item.QTY_RATE >= item.QUALITY_GUIDELINE_Y && item.QTY_RATE < item.QUALITY_GUIDELINE_R) {
return 'yellow';
} else if (item.QTY_RATE >= item.QUALITY_GUIDELINE_R) {
return 'red';
}
return '';
}
function getAllMachineData(stationNo, machineNo, callback) {
$MMWService.sendToEAISrv({
uri: 'KMI.all.machine.data.get.json',
content: {
Station_No: stationNo,
machine_no: machineNo
},
success: function(data) {
if (callback)
callback(data);
}
});
}
//2020-05-18 yenru ,處理前端 狀態長條圖
function eqp_spec_bar(eqp_arraylist, callback) {
eqp_arraylist.forEach(function(data) {
switch (data.guideline_mode) {
case '0':
// 綠-黃-紅
if (data.PROPERTY_VALUE >= data.GUIDELINE_MIN && data.PROPERTY_VALUE <= data.GUIDELINE_2) {
data.COLOR = '75,167,111';
} else {
data.COLOR = '200,57,55';
}
break;
case '1':
// 紅-黃-綠
if (data.PROPERTY_VALUE >= data.GUIDELINE_1 && data.PROPERTY_VALUE <= data.GUIDELINE_MAX) {
data.COLOR = '75,167,111';
} else {
data.COLOR = '200,57,55';
}
break;
case '2':
// 紅-黃-紅
if (data.PROPERTY_VALUE >= data.GUIDELINE_2 && data.PROPERTY_VALUE <= data.GUIDELINE_MAX) {
data.COLOR = '75,167,111';
} else if (data.PROPERTY_VALUE >= data.GUIDELINE_MIN && data.PROPERTY_VALUE <= data.GUIDELINE_1) {
data.COLOR = '75,167,111';
} else {
data.COLOR = '200,57,55';
}
break;
}
});
$timeout(function() {
if (callback)
callback(eqp_arraylist);
});
}
/*KMI List*/
$scope.KMIListInitConfig = function(pageCount, columns) {
var obj = { header: [], columns: columns, filterColumn: {} };
var count;
if (pageCount !== undefined && pageCount != null && !isNaN(parseFloat(pageCount)))
count = pageCount;
else {
var doc = document.getElementById(pageCount);
if (!doc)
count = 5;
else {
var height = doc.offsetHeight;
if (height === undefined || height == null || height <= 28 + 37)
count = 5;
else
count = (height - 28 - 37) / 32;
}
}
obj.page_count = Math.floor(count);
return obj;
}
$scope.KMIListFilterDelete = function(PageConfig, index) {
if (PageConfig) {
PageConfig.header[index].isFilter = false;
if (PageConfig.columns[index] in PageConfig.filterColumn) {
delete PageConfig.filterColumn[PageConfig.columns[index]];
}
}
}
$scope.KMIListGetPage = function(list, PageConfig) {
if (list && list.length > 0) {
if (PageConfig) {
var header;
if ('qeryOrder' in PageConfig && PageConfig.header.length > 0) header = PageConfig.header[PageConfig.qeryOrder];
var temp_list = PageConfig.filterColumn !== undefined ? temp_list = $filter('filter')(list, PageConfig.filterColumn) : list;
if (header)
temp_list = $filter('orderBy')(temp_list, "'" + header.code + "'", header.order);
return temp_list;
} else {
return list;
}
} else {
PageConfig.page = 0;
PageConfig.total_page = 1;
return list;
}
}
$scope.KMIListChangeOrder = function(PageConfig, index) {
if (!PageConfig.header[index]) PageConfig.header[index] = {};
PageConfig.header[index].code = PageConfig.columns[index];
if (PageConfig.qeryOrder != index) {
PageConfig.header[index].order = false;
} else {
PageConfig.header[index].order = !PageConfig.header[index].order;
}
PageConfig.qeryOrder = index;
}
}
];
});