1274 lines
55 KiB
JavaScript
1274 lines
55 KiB
JavaScript
define(['moment',
|
|
'module/moduleWIP/program/dialog/badreason_lot/badreason_lotService',
|
|
'module/moduleWIP/program/dialog/keyinattrib/keyinattrib',
|
|
'module/moduleWIP/program/dialog/wp03_e_runcard_info/wp03_e_runcard_info'],
|
|
function (moment) {
|
|
return ['$scope', '$filter', '$stateParams', '$mdDialog', 'config', 'DashboardService', 'MMWService', '$calculater', 'badreason_lotService',
|
|
'keyinattrib', 'RouterExtendProvider', '$rootScope', "mrs00Service", "wp03_e_runcard_info",
|
|
function ($scope, $filter, $stateParams, $mdDialog, config, $DashboardService, $MMWService, $calculater, $badreason_lotService,
|
|
$keyinattrib, $RouterExtendProvider, $rootScope, $mrs00Service, $wp03_e_runcard_info) {
|
|
/*html use parameter*/
|
|
$scope.plotNo = ""; //生產批輸入框
|
|
$scope.plotInfo = []; //生產批資訊
|
|
$scope.listSysAttrib = []; //系統、安裝特性
|
|
$scope.listKeyinAttrib = []; //輸入特性
|
|
$scope.listEquipment = []; //設備資訊
|
|
$scope.listMaterialLot = []; //物料資訊 前端顯示、實際刷入料號
|
|
$scope.scrapQty = 0;
|
|
$scope.defectQty = 0;
|
|
$scope.goodQty = 0;
|
|
|
|
/*parameter*/
|
|
var usePlot = "";
|
|
var opNo = config.cache.workStation;
|
|
var eqpNo = config.cache.equipment;
|
|
var shiftNo = "";
|
|
var listAttrib = []; //所有特性
|
|
var listBadReason = []; //不良原因
|
|
var listTempMaterial = []; //物料資訊
|
|
//var listSubMaterial = [];
|
|
var listAllMaterialLot = []; //所有物料批號
|
|
var listTempMaterialLot = [];
|
|
var listUseMaterialLot = []; //對應dtMLot
|
|
var listAccessory = []; //模治具
|
|
var listCalcAttrib = []; //計算特性
|
|
var desc = "";
|
|
var sysPar = [];
|
|
var OEMO = {};
|
|
var lotBasis = {};
|
|
var phase = -1;
|
|
var strTriggop = "";
|
|
//EAI轉STD過渡期(資料結構不一樣)
|
|
var EAIKeyIn = [];
|
|
var EAIBadReason = [];
|
|
|
|
/*CheckOut use parameter*/
|
|
var newLotStamp = -1;
|
|
var strLinkName; //固晶膠回溫卡控檢查結果
|
|
var intERFType; //固晶膠回溫卡控檢查結果
|
|
var strRuleNo; //固晶膠回溫卡控檢查結果
|
|
var strReturnMsg; //錯誤訊息
|
|
var dtMaterialNo = []; //合併後的主物料及其替代料資料, 且已檢查過用料量
|
|
var dtMaterialLotNo = []; //合併後的主物料及其替代料資料, 且已檢查過用料量
|
|
/*ChkControlRult*/
|
|
var chkRuleLinkName = "";
|
|
var chkRuleIntERFType = -1;
|
|
var chkRuleAttrib = [];
|
|
var chkRuleNo = "";
|
|
/*CheckSPCControlRule*/
|
|
var spcERFMsg = "";
|
|
var spcLinkName = "";
|
|
var spcIntERFType = -1;
|
|
var spcAttrib = [];
|
|
|
|
|
|
|
|
|
|
/*html form load*/
|
|
$scope.init = function () {
|
|
|
|
//2020/11/02 雋辰,檢查op模式 call common
|
|
$rootScope.EQPCheck_ModuleWIP(config.cache.workStation, function (data, result) {
|
|
if (result == false) {
|
|
return;
|
|
}
|
|
Init_Parameter();
|
|
});
|
|
|
|
//首頁直接執行Check Out
|
|
if ($stateParams.data.plot_no) {
|
|
$scope.plotNo = $stateParams.data.plot_no;
|
|
$scope.search($scope.plotNo);
|
|
}
|
|
|
|
//2020-05-15 yenru , top right button
|
|
$scope.$root.btnList = [
|
|
{
|
|
//20201201 雋辰,ERunCard
|
|
name: "button_eruncard",
|
|
icon_scr: 'image/icons/runcard.png',
|
|
class: [], //按鈕額外的class
|
|
disabled: false,
|
|
click: function () {
|
|
if (usePlot !== undefined && usePlot != '')
|
|
$wp03_e_runcard_info.init({ LOTNO: usePlot });
|
|
}
|
|
},
|
|
{
|
|
//特性輸入
|
|
name: "button_attrib",
|
|
icon_scr: 'image/iMES_icon/icon_exception@1.png',
|
|
class: [], //按鈕額外的class
|
|
disabled: false,
|
|
click: function () {
|
|
|
|
if (!usePlot)
|
|
return;
|
|
|
|
EAIKeyIn = Std2EAI_Keyin($scope.listKeyinAttrib);
|
|
|
|
//按鈕點擊
|
|
$keyinattrib.init({
|
|
keyinattribList: EAIKeyIn,
|
|
br: 'co',
|
|
callback: function (lotno, attrib) {
|
|
Change_Keyin(attrib);
|
|
}
|
|
});
|
|
}
|
|
},
|
|
{
|
|
//不良輸入
|
|
name: "button_badreason",
|
|
icon_scr: 'image/iMES_icon/icon_unusual@1.png',
|
|
class: [], //按鈕額外的class
|
|
disabled: false,
|
|
click: function () {
|
|
|
|
if (!usePlot)
|
|
return;
|
|
|
|
EAIBadReason = Std2EAI_BadReason(listBadReason);
|
|
|
|
$badreason_lotService.init({
|
|
plotItem: Create_BadReason_PLotInfo(),
|
|
badreasonlList: EAIBadReason,
|
|
callback: function (plotItem, badreason) {
|
|
Change_BadReason_Qty(plotItem, badreason);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
];
|
|
}
|
|
|
|
/*html event*/
|
|
$scope.barcodeScan = function () {
|
|
if (event.keyCode == 13)
|
|
$scope.search($scope.plotNo);
|
|
}
|
|
|
|
$scope.scanQrcode = function () {
|
|
$scope.$root.OpenScanner({
|
|
after: function (result) {
|
|
$scope.plotNo = result.text;
|
|
$scope.search($scope.plotNo);
|
|
},
|
|
exception: function () {
|
|
//目前裝置無法使用相機
|
|
$scope.$root.showAlert($filter('translate')('common.msg.camera_not_support'));
|
|
},
|
|
orientation: 'landscape'
|
|
});
|
|
}
|
|
|
|
$scope.search = function (plot) {
|
|
//2020/11/02 雋辰,檢查op模式 call common
|
|
if (false) {
|
|
Init_Parameter();
|
|
return;
|
|
}
|
|
|
|
Search(plot);
|
|
}
|
|
|
|
$scope.cancel = function () {
|
|
Init_Parameter();
|
|
}
|
|
|
|
$scope.confirm = function () {
|
|
//2020/11/02 雋辰,檢查op模式 call common
|
|
if (false) {
|
|
Init_Parameter();
|
|
return;
|
|
}
|
|
|
|
CheckOut();
|
|
}
|
|
|
|
//切換綁定
|
|
$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;
|
|
}
|
|
|
|
getEquipmentStatus(config.setting.equipment, function (data) {
|
|
data = JSON.parse(data.ResultJson);
|
|
$scope.$root.machine_info = data.machine_info[0];
|
|
});
|
|
|
|
Init_Parameter();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
function getEquipmentStatus(equipment, callback, isLoading) {
|
|
if (isLoading == undefined) {
|
|
isLoading = false;
|
|
}
|
|
$MMWService.sendToEAISrv({
|
|
uri: 'KMI.machine_status_get_json',
|
|
content: {
|
|
machine_no: equipment,
|
|
StationNo: config.setting.workStation,
|
|
num_of_days: 7
|
|
},
|
|
success: function (data) {
|
|
if (callback)
|
|
callback(data);
|
|
},
|
|
error: function (data) {
|
|
$rootScope.showAlert(data.Exception);
|
|
}
|
|
}, isLoading);
|
|
}
|
|
|
|
|
|
/*資料邏輯處理*/
|
|
//重置所有使用的參數
|
|
function Init_Parameter() {
|
|
/*html use parameter*/
|
|
$scope.plotNo = ""; //生產批輸入框
|
|
$scope.plotInfo = []; //生產批資訊
|
|
$scope.listSysAttrib = []; //系統、安裝特性
|
|
$scope.listKeyinAttrib = []; //輸入特性
|
|
$scope.listEquipment = []; //設備資訊
|
|
$scope.listMaterialLot = []; //物料資訊 前端顯示、實際刷入料號
|
|
$scope.scrapQty = 0;
|
|
$scope.defectQty = 0;
|
|
$scope.goodQty = 0;
|
|
|
|
/*parameter*/
|
|
usePlot = "";
|
|
opNo = config.cache.workStation;
|
|
eqpNo = config.cache.equipment;
|
|
shiftNo = "";
|
|
listAttrib = []; //所有特性
|
|
listBadReason = []; //不良原因
|
|
listTempMaterial = []; //物料資訊
|
|
// listSubMaterial = [];
|
|
listAllMaterialLot = []; //所有物料批號
|
|
listTempMaterialLot = [];
|
|
listUseMaterialLot = []; //對應dtMLot
|
|
listAccessory = []; //模治具
|
|
listCalcAttrib = []; //計算特性
|
|
desc = "";
|
|
sysPar = [];
|
|
OEMO = {
|
|
};
|
|
lotBasis = {
|
|
};
|
|
phase = -1;
|
|
strTriggop = "";
|
|
//EAI轉STD過渡期(資料結構不一樣)
|
|
EAIKeyIn = [];
|
|
EAIBadReason = [];
|
|
|
|
/*CheckOut use parameter*/
|
|
newLotStamp = -1;
|
|
strLinkName; //固晶膠回溫卡控檢查結果
|
|
intERFType; //固晶膠回溫卡控檢查結果
|
|
strRuleNo; //固晶膠回溫卡控檢查結果
|
|
strReturnMsg; //錯誤訊息
|
|
dtMaterialNo = []; //合併後的主物料及其替代料資料, 且已檢查過用料量
|
|
dtMaterialLotNo = []; //合併後的主物料及其替代料資料, 且已檢查過用料量
|
|
/*ChkControlRult*/
|
|
chkRuleLinkName = "";
|
|
chkRuleIntERFType = -1;
|
|
chkRuleAttrib = [];
|
|
chkRuleNo = "";
|
|
/*CheckSPCControlRule*/
|
|
spcERFMsg = "";
|
|
spcLinkName = "";
|
|
spcIntERFType = -1;
|
|
spcAttrib = [];
|
|
}
|
|
|
|
//變更keyin attrib value
|
|
function Change_Keyin(eaiKeyin) {
|
|
var breakException = {
|
|
};
|
|
eaiKeyin.forEach(item => {
|
|
try {
|
|
$scope.listKeyinAttrib.forEach(std=> {
|
|
if (std.ATTRIBNO == item.attrib_no) {
|
|
if (std.DATATYPE == 3)
|
|
std.ATTRIBVALUE = item.attrib_value.format("YYYY/MM/DD HH:mm:ss");
|
|
else
|
|
std.ATTRIBVALUE = item.attrib_value;
|
|
throw breakException;
|
|
}
|
|
})
|
|
} catch (e) {
|
|
|
|
}
|
|
});
|
|
}
|
|
function Std2EAI_Keyin(stdKeyIn) {
|
|
var result = [];
|
|
var i = 0;
|
|
stdKeyIn.forEach(item => {
|
|
var tmp = {
|
|
attrib_no: item.ATTRIBNO,
|
|
attrib_name: item.ATTRIBNAME,
|
|
data_type_name: item.DATATYPENAME,
|
|
data_type: item.DATATYPE,
|
|
attrib_source: item.ATTRIBSOURCE,
|
|
attrib_value: item.ATTRIBVALUE,
|
|
attrib_value_date: item.ATTRIBVALUE,
|
|
attrib_allownull: item.ALLOWNULL,
|
|
input_type: item.INPUTTYPE,
|
|
data_show: "1"
|
|
}
|
|
if (tmp.data_type == 4 && tmp.attrib_value)
|
|
tmp.attrib_value = tmp.attrib_value.toString().toLowerCase();
|
|
|
|
result.push(tmp);
|
|
});
|
|
|
|
return result;
|
|
}
|
|
|
|
//建立符合BadReason頁面所需資訊
|
|
function Create_BadReason_PLotInfo() {
|
|
var result = {
|
|
CheckOutQty: $scope.plotInfo[0].CURQTY,
|
|
scrapQty: 0,
|
|
defectQty: 0,
|
|
surplus: 0,
|
|
bad: 0,
|
|
OriQty: $scope.plotInfo[0].CURQTY,
|
|
Qty: $scope.plotInfo[0].CURQTY
|
|
};
|
|
|
|
return result;
|
|
}
|
|
function Std2EAI_BadReason(stdBadReason) {
|
|
var result = [];
|
|
stdBadReason.forEach(item => {
|
|
var tmp = {
|
|
AbnormalNo: item.ERRORNO,
|
|
DefectQty: item.ERRORQTY,
|
|
AbnormalLevel: item.ERRORLEVEL,
|
|
AbnormalType: item.ERRORTYPE,
|
|
AbnormalName: item.ERRORNAME
|
|
}
|
|
result.push(tmp);
|
|
});
|
|
|
|
return result;
|
|
}
|
|
function Change_BadReason_Qty(plotItem, eaiBadReason) {
|
|
$scope.scrapQty = plotItem.scrapQty;
|
|
$scope.defectQty = plotItem.defectQty;
|
|
$scope.goodQty = $scope.plotInfo[0].CURQTY - plotItem.scrapQty;
|
|
|
|
listBadReason = [];
|
|
eaiBadReason.forEach(item=> {
|
|
listBadReason.push({
|
|
ERRORNO: item.AbnormalNo,
|
|
ERRORQTY: item.DefectQty,
|
|
ERRORLEVEL: item.AbnormalLevel,
|
|
ERRORTYPE: item.AbnormalType,
|
|
ERRORNAME: item.AbnormalName
|
|
});
|
|
});
|
|
$scope.listKeyinAttrib.forEach(item=> {
|
|
if (item.ATTRIBNO == "ScrapQty")
|
|
item.ATTRIBVALUE = plotItem.scrapQty;
|
|
if (item.ATTRIBNO == "DefectQty")
|
|
item.ATTRIBVALUE = plotItem.dcrapQty;
|
|
if (item.ATTRIBNO == "GoodQty")
|
|
item.ATTRIBVALUE = $scope.goodQty;
|
|
});
|
|
}
|
|
|
|
//整理attrib
|
|
function Attrib_Data_Organize() {
|
|
|
|
var i = 0;
|
|
listAttrib.forEach(item => {
|
|
//處理預設值
|
|
|
|
//處理資料類型名稱
|
|
switch (item.DATATYPE) {
|
|
case 0:
|
|
item.DATATYPENAME = $filter('translate')('dialog.keyinattrib.attrib_type_int');
|
|
break;
|
|
case 1:
|
|
item.DATATYPENAME = $filter('translate')('dialog.keyinattrib.attrib_type_str');
|
|
break;
|
|
case 2:
|
|
item.DATATYPENAME = $filter('translate')('dialog.keyinattrib.attrib_type_percent');
|
|
break;
|
|
case 3:
|
|
item.DATATYPENAME = $filter('translate')('dialog.keyinattrib.attrib_type_time');
|
|
break;
|
|
case 4:
|
|
item.DATATYPENAME = $filter('translate')('dialog.keyinattrib.attrib_type_boolean');
|
|
if (!item.ATTRIBVALUE)
|
|
item.ATTRIBVALUE = false;
|
|
break;
|
|
}
|
|
|
|
//區分Keyin、sys
|
|
if (item.ATTRIBSOURCE != "1" && item.ATTRIBSOURCE != "0" && (item.ATTRIBPHASE == phase || item.ATTRIBPHASE == "99"))
|
|
$scope.listSysAttrib.push(item);
|
|
else if (item.ATTRIBSOURCE == "0" && item.ATTRIBPHASE == phase)
|
|
$scope.listKeyinAttrib.push(item);
|
|
else if (item.ATTRIBSOURCE == "1")
|
|
listCalcAttrib.push(item);
|
|
});
|
|
}
|
|
|
|
/*
|
|
//整理All Material Lot
|
|
function funAutoSetMaterialLot() {
|
|
funLoadAllMaterialLot();
|
|
|
|
|
|
funLoadTemp_MaterialLot();
|
|
}
|
|
|
|
function funLoadAllMaterialLot() {
|
|
|
|
if ($scope.plotInfo['MATERIALOPTION'] == "0") {
|
|
LoadSubstituteMaterial_Main(function () {
|
|
var breakException = {};
|
|
var defDate = "9999/12/31 00:00:00";
|
|
|
|
//物料批號
|
|
listSubMaterial.forEach(dtMaterialLot=> {
|
|
if ($scope.plotInfo[0]["MATERIALOPTION"] == "0") {
|
|
//給予基本值
|
|
dtMaterialLot.forEach(item=> {
|
|
item.SubstituteMaterialNo = item.MATERIALNO
|
|
if (!item.MANUFACTUREDATE)
|
|
item.MANUFACTUREDATE = defDate;
|
|
if (!item.EXPIREDATE)
|
|
item.EXPIREDATE = defDate;
|
|
else
|
|
item.EXPIREDATE = moment(item.EXPIREDATE).format("YYYY/MM/DD HH:mm:ss");
|
|
if (!item.INPUTDATE)
|
|
item.INPUTDATE = defDate;
|
|
else
|
|
item.INPUTDATE = moment(item.INPUTDATE).format("YYYY/MM/DD HH:mm:ss");
|
|
});
|
|
//排序
|
|
dtMaterialLot.sort((a, b) => {
|
|
if (a.MANUFACTUREDATE > b.MANUFACTUREDATE)
|
|
return 1;
|
|
else if (a.MANUFACTUREDATE == b.MANUFACTUREDATE) {
|
|
if (a.EXPIREDATE > b.EXPIREDATE)
|
|
return 1;
|
|
else if (a.EXPIREDATE == b.EXPIREDATE)
|
|
if (a.INPUTDATE > b.INPUTDATE)
|
|
return 1;
|
|
else if (a.INPUTDATE == b.INPUTDATE)
|
|
return 0;
|
|
else
|
|
return -1;
|
|
else
|
|
return -1;
|
|
} else
|
|
return -1;
|
|
});
|
|
//給予順序索引
|
|
var index = 0;
|
|
dtMaterialLot.forEach(item=> {
|
|
item.seqNo = index;
|
|
index++;
|
|
});
|
|
}
|
|
|
|
//行動報工前端顯示用
|
|
dtMaterialLot.forEach(item=> {
|
|
try {
|
|
listTempMaterial.forEach(item2=> {
|
|
if (item2.MATERIALNO == item.MATERIALNO) {
|
|
item.UNITNO = item2.UNITNO;
|
|
item.STDQTY = item2.STDQTY
|
|
item.useQty = item.STDQTY * $scope.plotInfo[0].CURQTY;
|
|
if (item.QTY < item.useQty) item.useQty = item.QTY;
|
|
throw breakException;
|
|
}
|
|
});
|
|
} catch (e) {
|
|
if (e !== breakException)
|
|
console.error(e);
|
|
}
|
|
$scope.listMaterialLot.push(item);
|
|
});
|
|
});
|
|
listSubMaterial.forEach(dtMaterialLot=> {
|
|
dtMaterialLot.forEach(item=> {
|
|
listAllMaterialLot.push(item);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
function funLoadTemp_MaterialLot() {
|
|
LoadTemp_MaterialLot(function () {
|
|
|
|
|
|
});
|
|
}
|
|
*/
|
|
|
|
//出站結束返回首頁
|
|
function Go_To_Home() {
|
|
var linkName = Get_Final_LinkName();
|
|
var lot = usePlot;
|
|
Init_Parameter();
|
|
|
|
$rootScope.CheckInOut_After(lot, linkName, false, 'moduleEQP');
|
|
}
|
|
|
|
function Get_Final_LinkName() {
|
|
var linkName = "";
|
|
|
|
if (strLinkName && strLinkName.toUpperCase() == "HOLD")
|
|
linkName = strLinkName;
|
|
else if (spcLinkName && spcLinkName != "")
|
|
linkName = spcLinkName;
|
|
else
|
|
linkName = chkRuleLinkName;
|
|
|
|
return linkName;
|
|
}
|
|
|
|
function Get_Final_RuleNo() {
|
|
var ruleNo = "";
|
|
|
|
if (strRuleNo && strRuleNo != "")
|
|
ruleNo = strRuleNo;
|
|
else if (chkRuleNo && chkRuleNo != "")
|
|
ruleNo = chkRuleNo;
|
|
|
|
return ruleNo;
|
|
}
|
|
|
|
function Get_Final_ERFType() {
|
|
var erfType = -1;
|
|
|
|
if (intERFType != -1)
|
|
erfType = intERFType;
|
|
else if (spcIntERFType != -1)
|
|
erfType = spcIntERFType;
|
|
else
|
|
erfType = chkRuleIntERFType;
|
|
|
|
return erfType;
|
|
}
|
|
|
|
/*檢查資料*/
|
|
//Check Keyin allownull
|
|
function Chk_Keyin_AllowNull() {
|
|
$scope.listKeyinAttrib.forEach(item=> {
|
|
if (item.ALLOWNULL != 1 && !item.ATTRIBVALUE && item.ATTRIBVALUE == "") {
|
|
return false;
|
|
}
|
|
});
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*Core functions*/
|
|
function Search(plot) {
|
|
if (plot) {
|
|
Init_Parameter();
|
|
search_plot(plot, function () {
|
|
if ($scope.plotInfo.length <= 0) {
|
|
$rootScope.showAlert($filter('translate')('mrs04.msg.lotNotFound'));
|
|
Init_Parameter();
|
|
return;
|
|
}
|
|
else {
|
|
var doesNotBelong = '';
|
|
if ($scope.plotInfo[0]["OPNO"] && $scope.plotInfo[0]["OPNO"] != opNo)
|
|
doesNotBelong = $filter('translate')('mrs04.msg.doesNotBelongOP');
|
|
if ($scope.plotInfo[0]["BRNO"] && $scope.plotInfo[0]["BRNO"] != "L_CO_GEN")
|
|
doesNotBelong = $filter('translate')('mrs04.msg.doesNotBelongBR');
|
|
if (doesNotBelong.length > 0) {
|
|
$rootScope.showAlert(doesNotBelong);
|
|
Init_Parameter();
|
|
return;
|
|
}
|
|
|
|
usePlot = plot; //set using plot no
|
|
$scope.plotNo = ""; //clear input plot
|
|
$scope.goodQty = $scope.plotInfo[0].CURQTY;
|
|
|
|
//2020/11/02 雋辰,檢查使用的設備
|
|
var eqpErrMsg = "";
|
|
if ($scope.listEquipment.length == 0)
|
|
eqpErrMsg = $filter('translate')('mrs04.msg.useEQPErrorNoneEQP');
|
|
if ($scope.listEquipment.length > 1)
|
|
eqpErrMsg = $filter('translate')('mrs04.msg.useEQPErrorMultiEQP');
|
|
if ($scope.listEquipment.length == 1 && $scope.listEquipment[0].EQUIPMENTNO != eqpNo)
|
|
eqpErrMsg = $filter('translate')('mrs04.msg.useEQPErrorNotMatchEQP');
|
|
if (eqpErrMsg.length > 0) {
|
|
Init_Parameter();
|
|
$rootScope.showAlert(eqpErrMsg);
|
|
return;
|
|
}
|
|
|
|
Attrib_Data_Organize();
|
|
|
|
//整理MaterialLot資訊
|
|
//funAutoSetMaterialLot();
|
|
funLoadCO_Material_Info(function () {
|
|
|
|
//整理前端所需material資訊
|
|
listUseMaterialLot.forEach(item=> {
|
|
var tmp = Object.assign({
|
|
}, item);
|
|
for (var index in listTempMaterial) {
|
|
var material = listTempMaterial[index];
|
|
if (material.MATERIALNO == tmp.MATERIALNO) {
|
|
tmp.STDQTY = material.STDQTY;
|
|
tmp.UNITNO = material.UNITNO;
|
|
break;
|
|
}
|
|
}
|
|
$scope.listMaterialLot.push(tmp);
|
|
});
|
|
});
|
|
|
|
//TriggerOP(plot);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function CheckOut() {
|
|
//計算物料使用量
|
|
listTempMaterial.forEach(item=> {
|
|
item.USEQTY = 0;
|
|
var listLot = $scope.listMaterialLot.filter(function (n) {
|
|
return n.MATERIALNO == item.MATERIALNO;
|
|
});
|
|
listLot.forEach(item2=> {
|
|
item.USEQTY += item2.USEQTY && item2.USEQTY.toString().length > 0 ? parseFloat(item2.USEQTY.toString()) : 0;
|
|
});
|
|
});
|
|
//物料useQty轉為數值,避免後端異常
|
|
$scope.listMaterialLot.forEach(item=> {
|
|
item.USEQTY = item.USEQTY && item.USEQTY.toString().length > 0 ? parseFloat(item.USEQTY.toString()) : 0;
|
|
});
|
|
listAllMaterialLot.forEach(item => {
|
|
item.USEQTY = item.USEQTY && item.USEQTY.toString().length > 0 ? parseFloat(item.USEQTY.toString()) : 0;
|
|
});
|
|
|
|
//將前端使用的物料量修改至後端
|
|
$scope.listMaterialLot.forEach(item=> {
|
|
var listLot = listUseMaterialLot.filter(function (n) {
|
|
return n.MATERIALLOTNO == item.MATERIALLOTNO && n.MATERIALNO == item.MATERIALNO;
|
|
});
|
|
if (listLot.length > 0)
|
|
listLot[0].USEQTY = item.USEQTY;
|
|
});
|
|
|
|
$scope.listKeyinAttrib.forEach(item=> {
|
|
if (item.ATTRIBNO.toUpperCase() == 'GOODQTY')
|
|
item.ATTRIBVALUE = $scope.goodQty;
|
|
else if (item.ATTRIBNO.toUpperCase() == 'DEFECTQTY')
|
|
item.ATTRIBVALUE = $scope.defectQty;
|
|
else if (item.ATTRIBNO.toUpperCase() == 'SCRAPQTY')
|
|
item.ATTRIBVALUE = $scope.scrapQty;
|
|
});
|
|
|
|
if (!Chk_Keyin_AllowNull()) {
|
|
//警告訊息$rootScope
|
|
return;
|
|
}
|
|
|
|
funCheckCO_Material_Info(function () {
|
|
|
|
if (strReturnMsg && strReturnMsg != "") {
|
|
$rootScope.showAlert(strReturnMsg);
|
|
return;
|
|
}
|
|
|
|
ChkLotStamp(function () {
|
|
if (newLotStamp < 0) {
|
|
$rootScope.showAlert($filter('translate')('mrs04.msg.lotstampError'));
|
|
return;
|
|
}
|
|
|
|
var listTmpAttrib = [];
|
|
|
|
$scope.listSysAttrib.forEach(item=> {
|
|
listTmpAttrib.push(item);
|
|
});
|
|
$scope.listKeyinAttrib.forEach(item=> {
|
|
listTmpAttrib.push(item);
|
|
});
|
|
listCalcAttrib.forEach(item=> {
|
|
listTmpAttrib.push(item);
|
|
});
|
|
|
|
$rootScope.ChkControlRule(usePlot, $scope.plotInfo[0].LOTSTAMP, listTmpAttrib, listBadReason, "", "", function (response) {
|
|
if (response.ChkControlRule != 0)
|
|
return;
|
|
|
|
chkRuleLinkName = response.LinkName;
|
|
chkRuleIntERFType = response.ERFType;
|
|
chkRuleNo = response.RuleNo;
|
|
chkRuleAttrib = response.Attrib;
|
|
|
|
CheckSPCContorl_Var(function () {
|
|
|
|
ExeBRCheckOut(function () {
|
|
var linkName = Get_Final_LinkName();
|
|
|
|
//2020/10/23 Grace BRTransferLot 移至共用
|
|
$rootScope.BRTransferLot(usePlot, config.cache.account, linkName, response.ERFType,
|
|
response.RuleNo, $scope.scrapQty, strReturnMsg, false, 'moduleEQP');
|
|
|
|
/*
|
|
var linkName = Get_Final_LinkName();
|
|
if (linkName == "HOLD" || linkName == "WAIT") {
|
|
Go_To_Home();
|
|
return;
|
|
}*/
|
|
/*
|
|
BRTransferLot(
|
|
function () {
|
|
Go_To_Home();
|
|
},
|
|
function () {
|
|
Go_To_Home();
|
|
});
|
|
*/
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*request web service*/
|
|
function search_plot(plot, callBack) {
|
|
var uri = [];
|
|
var content = [];
|
|
|
|
//load lot
|
|
uri.push("kcWIP.clsLot.LoadLotBasisJoinState");
|
|
content.push({
|
|
LotNo: plot,
|
|
m_transfer: [{
|
|
level: "S",
|
|
parname: "MONo",
|
|
value: "MONo"
|
|
}]
|
|
});
|
|
|
|
//load OEMO
|
|
uri.push("kcWIP.clsLot.LoadMOBasis")
|
|
content.push({
|
|
IssueState: 2
|
|
});
|
|
|
|
//load shift
|
|
uri.push("kcUSR.clsUSRDepartment.GetShift");
|
|
content.push({
|
|
UserNo: config.cache.account
|
|
});
|
|
|
|
//load attrib
|
|
uri.push("kcWIP.clsLot.LoadTemp_AttribJoinBasis")
|
|
content.push({
|
|
LotNo: plot
|
|
});
|
|
|
|
//load equipment
|
|
uri.push("kcWIP.clsLot.LoadTemp_Equipment")
|
|
content.push({
|
|
LotNo: plot,
|
|
GetRecipe: true,
|
|
GetContAccessory: true
|
|
});
|
|
|
|
//load material
|
|
uri.push("kcWIP.clsLot.LoadTemp_Material")
|
|
content.push({
|
|
LotNo: plot
|
|
});
|
|
|
|
//load lotbasis
|
|
uri.push("kcWIP.clsLot.LoadLotBasis")
|
|
content.push({
|
|
LotNo: plot
|
|
});
|
|
|
|
//load description
|
|
uri.push("kcWIP.clsLot.GetLotOPDescription")
|
|
content.push({
|
|
LotNo: plot
|
|
});
|
|
|
|
//load sysparameter
|
|
uri.push("kcSYS.clsSYSParameter.LoadParameter")
|
|
content.push({
|
|
});
|
|
|
|
$MMWService.sendToMESSrv_Multi({
|
|
uri: uri,
|
|
content: content,
|
|
success: function (data) {
|
|
search_plot_Transf(data, uri);
|
|
|
|
if (callBack)
|
|
callBack();
|
|
}
|
|
});
|
|
}
|
|
function search_plot_Transf(result, uri) {
|
|
if (result.Code == "0") {
|
|
var tmpJson = JSON.parse(result.ResultJson);
|
|
|
|
//lot
|
|
$scope.plotInfo = JSON.parse(tmpJson[uri[0]])["BasisJoinState"];
|
|
if ($scope.plotInfo && $scope.plotInfo.length > 0)
|
|
phase = $scope.plotInfo[0]["PHASENO"];
|
|
//load OEMO
|
|
OEMO = JSON.parse(tmpJson[uri[1]])["OEMOBasis"];
|
|
//shift
|
|
shiftNo = JSON.parse(tmpJson[uri[2]])["ReturnValue"];
|
|
//attrib
|
|
listAttrib = JSON.parse(tmpJson[uri[3]])["TempAttrib"];
|
|
//equipment
|
|
$scope.listEquipment = JSON.parse(tmpJson[uri[4]])["TempEquipment"];
|
|
//accessory
|
|
listAccessory = JSON.parse(tmpJson[uri[4]])["ContAcc"];
|
|
$scope.listEquipment.forEach(item=> {
|
|
item.listAccessory = [];
|
|
var breakExection = {
|
|
};
|
|
try {
|
|
listAccessory.forEach(item2=> {
|
|
if (item2.EQUIPMENTNO == item.EQUIPMENTNO) {
|
|
if (item2.STARTTIME)
|
|
item2.STARTTIME = moment(item2.STARTTIME).format("YYYY/MM/DD HH:mm:ss");
|
|
item.listAccessory.push(item2);
|
|
}
|
|
});
|
|
} catch (e) {
|
|
if (e !== breakExection)
|
|
console.error(e);
|
|
}
|
|
});
|
|
//material
|
|
listTempMaterial = JSON.parse(tmpJson[uri[5]])["TempMaterial"];
|
|
//load lotbasis
|
|
lotBasis = JSON.parse(tmpJson[uri[6]])["WIPLotBasis"];
|
|
//load description
|
|
desc = JSON.parse(tmpJson[uri[7]])["ReturnValue"];
|
|
//load sysparameter
|
|
sysPar = JSON.parse(tmpJson[uri[8]])["SYSParameter"];
|
|
}
|
|
}
|
|
|
|
/*
|
|
function LoadSubstituteMaterial_Main(callBack) {
|
|
var method = "kcWIP.clsLot.LoadSubstituteMaterial_Main"
|
|
var uri = [];
|
|
var content = [];
|
|
listTempMaterial.forEach(item=> {
|
|
uri.push(method);
|
|
|
|
var tmp = {
|
|
LotNo: $scope.plotInfo[0].LOTNO,
|
|
MaterialNo: item.MATERIALNO,
|
|
UnitNo: item.UNITNO
|
|
}
|
|
content.push(tmp);
|
|
});
|
|
|
|
if (uri.length != content.length || uri.length <= 0 || content.length <= 0)
|
|
return;
|
|
|
|
$MMWService.sendToMESSrv_Multi({
|
|
uri: uri,
|
|
content: content,
|
|
success: function (data) {
|
|
LoadSubstituteMaterial_Main_Transf(data, uri);
|
|
|
|
if (callBack)
|
|
callBack(listSubMaterial);
|
|
}
|
|
});
|
|
}
|
|
function LoadSubstituteMaterial_Main_Transf(result, uri) {
|
|
if (result.Code == "0") {
|
|
var tmpJson = JSON.parse(result.ResultJson);
|
|
|
|
uri.forEach(function (item, index) {
|
|
var strIndex = "";
|
|
if (index > 0)
|
|
strIndex = "(" + (index + 1) + ")";
|
|
|
|
listSubMaterial.push(JSON.parse(tmpJson[uri[index] + strIndex])["SubstituteMaterial"]);
|
|
});
|
|
}
|
|
}
|
|
|
|
function LoadTemp_MaterialLot() {
|
|
var uri = ["kcWIP.clsLot.LoadTemp_MaterialLot"];
|
|
var content = [{ LotNo: usePlot }];
|
|
|
|
$MMWService.sendToMESSrv_Multi({
|
|
uri: uri,
|
|
content: content,
|
|
success: function (data) {
|
|
LoadTemp_MaterialLot_Transf(data, uri);
|
|
|
|
if (callBack)
|
|
callBack();
|
|
}
|
|
});
|
|
}
|
|
function LoadTemp_MaterialLot_Transf(result, uri) {
|
|
var tmpJson = JSON.parse(result.ResultJson);
|
|
listTempMaterialLot = tmpJson[uri[0]]["TempMaterialLot"];
|
|
}
|
|
*/
|
|
|
|
function funLoadCO_Material_Info(callBack) {
|
|
var uri = ["kcWIP.clsMDS.funLoadCO_Material_Info"];
|
|
var content = [{
|
|
pLotNo: usePlot,
|
|
pCurQty: $scope.plotInfo[0].CURQTY,
|
|
strMaterialOption: $scope.plotInfo[0].MATERIALOPTION,
|
|
pOPNo: opNo,
|
|
pEquipmentNo: $scope.listEquipment.length > 0 ? $scope.listEquipment[0].EQUIPMENTNO : "",
|
|
dtTempMTL: [],
|
|
dtMLot: [],
|
|
dtTempMTLLot: [],
|
|
dtAllMTLLot: []
|
|
}];
|
|
|
|
$MMWService.sendToMESSrv_Multi({
|
|
uri: uri,
|
|
content: content,
|
|
success: function (data) {
|
|
funLoadCO_Material_Info_Transf(data, uri);
|
|
|
|
if (callBack)
|
|
callBack();
|
|
}
|
|
});
|
|
}
|
|
function funLoadCO_Material_Info_Transf(result, uri) {
|
|
var tmpJson = JSON.parse(result.ResultJson);
|
|
var obj = JSON.parse(tmpJson[uri[0]]);
|
|
|
|
listTempMaterial = obj.dtTempMTL;
|
|
listTempMaterialLot = obj.dtTempMTLLot;
|
|
listAllMaterialLot = obj.dtAllMTLLot;
|
|
listUseMaterialLot = obj.dtMLot;
|
|
}
|
|
|
|
//執行 標準check out 物料查核與物料整理
|
|
function funCheckCO_Material_Info(callBack) {
|
|
var tmpEquipment = $scope.listEquipment.slice()
|
|
tmpEquipment.forEach(item => {
|
|
if (item.listAccessory)
|
|
delete item.listAccessory;
|
|
});
|
|
|
|
var uri = ["kcWIP.clsMDS.funCheckCO_Material_Info"];
|
|
var content = [{
|
|
pLotNo: usePlot,
|
|
strMaterialOption: $scope.plotInfo[0].MATERIALOPTION,
|
|
dtTempMTL: listTempMaterial,
|
|
dtMLot: listUseMaterialLot,
|
|
dtTempMTLLot: listTempMaterialLot,
|
|
dtAllMTLLot: listAllMaterialLot,
|
|
dtEquipment: $scope.listEquipment,
|
|
strLinkName: "PASS",
|
|
intERFType: -1,
|
|
strRuleNo: "",
|
|
strReturnMsg: "",
|
|
dtMaterialNo: [],
|
|
dtMaterialLotNo: [],
|
|
LanguageMode: config.setting.lang
|
|
}];
|
|
|
|
$MMWService.sendToMESSrv_Multi({
|
|
uri: uri,
|
|
content: content,
|
|
success: function (data) {
|
|
funCheckCO_Material_Info_Transf(data, uri)
|
|
|
|
if (callBack)
|
|
callBack();
|
|
}
|
|
});
|
|
}
|
|
function funCheckCO_Material_Info_Transf(result, uri) {
|
|
if (result.Code == "0") {
|
|
var tmpJson = JSON.parse(result.ResultJson);
|
|
var obj = JSON.parse(tmpJson[uri[0]]);
|
|
|
|
if (obj.strLinkName)
|
|
strLinkName = obj.strLinkName;
|
|
|
|
if (obj.intERFType)
|
|
intERFType = obj.intERFType;
|
|
|
|
if (obj.strRuleNo)
|
|
strRuleNo = obj.strRuleNo;
|
|
|
|
if (obj.strReturnMsg)
|
|
strReturnMsg = obj.strReturnMsg;
|
|
|
|
if (obj.ReturnValue) {
|
|
//執行完成 true
|
|
if (obj.dtMaterialNo)
|
|
dtMaterialNo = obj.dtMaterialNo;
|
|
|
|
if (obj.dtMaterialLotNo)
|
|
dtMaterialLotNo = obj.dtMaterialLotNo;
|
|
}
|
|
}
|
|
}
|
|
|
|
function ChkLotStamp(callBack) {
|
|
var uri = ["kcWIP.clsLot.ChkLotStamp"];
|
|
var content = [{
|
|
LotNo: usePlot, LotStamp: $scope.plotInfo[0].LOTSTAMP
|
|
}];
|
|
|
|
$MMWService.sendToMESSrv_Multi({
|
|
uri: uri,
|
|
content: content,
|
|
success: function (data) {
|
|
ChkLotStamp_Transf(data, uri);
|
|
if (callBack)
|
|
callBack();
|
|
}
|
|
});
|
|
}
|
|
function ChkLotStamp_Transf(result, uri) {
|
|
if (result.Code == "0") {
|
|
var tmpJson = JSON.parse(result.ResultJson);
|
|
var obj = JSON.parse(tmpJson[uri[0]]);
|
|
newLotStamp = obj["ReturnValue"];
|
|
}
|
|
}
|
|
|
|
//執行 CheckSPCContorl_Var
|
|
function CheckSPCContorl_Var(callback) {
|
|
|
|
var tmpAttrib = [];
|
|
|
|
//新增check spc拋送/回的資料欄
|
|
for (var index in chkRuleAttrib) {
|
|
var item = chkRuleAttrib[index];
|
|
var temp = {
|
|
AttribType: item.ATTRIBTYPE,
|
|
AttribNo: item.ATTRIBNO,
|
|
AttribValue: item.ATTRIBVALUE.toString(),
|
|
AttribSource: item.ATTRIBSOURCE,
|
|
AttribPhase: item.ATTRIBPHASE,
|
|
AttribSequence: item.ATTRIBSEQUENCE,
|
|
SaveToLotPropertyNo: item.SAVETOLOTPROPERTYNO,
|
|
QCItemNo: item.QCITEMNO,
|
|
Result: '',
|
|
Result_INT: '',
|
|
FactorSerial: '',
|
|
ERFMsg: ''
|
|
};
|
|
tmpAttrib.push(temp);
|
|
}
|
|
|
|
$MMWService.sendToMESSrv({
|
|
uri: 'kcSPC.clsSPC.CheckSPCContorl_Var',
|
|
content: {
|
|
LotNo: usePlot,
|
|
UserNo: config.cache.account,
|
|
dtTestValue: tmpAttrib,
|
|
columns: []
|
|
},
|
|
success: function (data) {
|
|
CheckSPCContorl_Var_Transf(data);
|
|
if (callback) {
|
|
//回傳整理後的訊息
|
|
callback();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
function CheckSPCContorl_Var_Transf(data) {
|
|
var result = JSON.parse(data.ResultJson);
|
|
if (result.ReturnValue) {
|
|
//執行完成 true
|
|
var strSPCLinkName = "";
|
|
var intResult = 0;
|
|
var intMESResult = 0;
|
|
var dtAttrib = [];
|
|
|
|
if (result.dtTestValue != undefined) {
|
|
dtAttrib = result.dtTestValue;
|
|
spcAttrib = result.dtTestValue;
|
|
}
|
|
|
|
for (var index in dtAttrib) {
|
|
var item = dtAttrib[index];
|
|
|
|
//整理生產批品管項目結果
|
|
if (item.RESULT != undefined) {
|
|
switch (item.RESULT.toString()) {
|
|
case "HOLD":
|
|
strSPCLinkName = "HOLD";
|
|
intResult = 5;
|
|
break;
|
|
case "WAIT":
|
|
strSPCLinkName = "WAIT";
|
|
intResult = 4;
|
|
break;
|
|
case "WARNING":
|
|
strSPCLinkName = "WARNING";
|
|
intResult = 0;
|
|
break;
|
|
case "ALARM":
|
|
strSPCLinkName = "ALARM";
|
|
intResult = 0;
|
|
break;
|
|
case "ALERT":
|
|
strSPCLinkName = "ALERT";
|
|
intResult = 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//判斷MES LinkName對應結果
|
|
switch (strLinkName) {
|
|
case "HOLD":
|
|
intMESResult = 5;
|
|
break;
|
|
case "WAIT":
|
|
intMESResult = 4;
|
|
break;
|
|
case "WARNING":
|
|
intMESResult = 0;
|
|
break;
|
|
case "ALARM":
|
|
intMESResult = 0;
|
|
break;
|
|
case "ALERT":
|
|
intMESResult = 0;
|
|
break;
|
|
}
|
|
|
|
if (intMESResult < intResult) {
|
|
spcLinkName = strSPCLinkName;
|
|
|
|
if (spcLinkName == "HOLD") {
|
|
spcIntERFType = 1;
|
|
}
|
|
}
|
|
|
|
|
|
//整理 strERFMsg 訊息
|
|
for (var index in dtAttrib) {
|
|
var item = dtAttrib[index];
|
|
|
|
if (item.QCITEMNO != undefined) {
|
|
if (item.QCITEMNO != "") {
|
|
if (item.ERFMSG != undefined) {
|
|
spcERFMsg = spcERFMsg & item.ERFMsg.toString() & "<br />"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//執行BR Check Out
|
|
function ExeBRCheckOut(callback) {
|
|
var ruleNo = Get_Final_RuleNo();
|
|
var linkName = Get_Final_LinkName();
|
|
|
|
spcAttrib.forEach(item=> {
|
|
item.ATTRIBVALUE = item.ATTRIBVALUE.toString();
|
|
});
|
|
|
|
|
|
$MMWService.sendToMESSrv({
|
|
uri: 'kcWIP.clsLot.BR_CheckOut',
|
|
content: {
|
|
LotNo: usePlot,
|
|
LinkName: linkName,
|
|
LotStamp: $scope.plotInfo[0].LOTSTAMP,
|
|
ShiftNo: shiftNo,
|
|
dtAttrib: spcAttrib,
|
|
dtEquipment: $scope.listEquipment,
|
|
dtMaterial: dtMaterialNo,
|
|
dtMaterialLot: dtMaterialLotNo,
|
|
dtError: listBadReason,
|
|
LotRecord: 'execute check out by PAD',
|
|
RuleNo: ruleNo,
|
|
GoodQty: $scope.goodQty,
|
|
UserNo: config.cache.account,
|
|
},
|
|
success: function (data) {
|
|
if (callback) {
|
|
callback(data);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// BRTransferLot 因不管成功失敗都要執行, 因此獨立寫
|
|
function BRTransferLot(callback) {
|
|
var linkName = Get_Final_LinkName();
|
|
|
|
$MMWService.sendToMESSrv({
|
|
uri: 'wsWIP.TransferLot',
|
|
content: {
|
|
LotNo: usePlot,
|
|
LinkName: linkName,
|
|
},
|
|
success: function (data) {
|
|
if (callback) {
|
|
callback(data);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
]
|
|
});
|