841 lines
31 KiB
JavaScript
841 lines
31 KiB
JavaScript
![]() |
define(["moment"], function (moment) {
|
|||
|
return ["$scope", "$rootScope", "$filter", "$stateParams", '$mdDialog', "config", "DashboardService", "MMWService", "$timeout", '$css', "mrs00Service",
|
|||
|
function ($scope, $rootScope, $filter, $stateParams, $mdDialog, config, $DashboardService, $MMWService, $timeout, $css, $mrs00Service) {
|
|||
|
/* Process
|
|||
|
Right Site
|
|||
|
1. Scan MoNo
|
|||
|
2. Scan MaterialNO
|
|||
|
3. Scan SubMaterialNo
|
|||
|
4. Scan MaterialLotNo
|
|||
|
5. Input Qty
|
|||
|
|
|||
|
Left Site
|
|||
|
1. Show Current EQP MaterialState
|
|||
|
2. Click Delete Remove EQP Material
|
|||
|
*/
|
|||
|
|
|||
|
/*html use parameter*/
|
|||
|
$scope.mo_no = '';
|
|||
|
$scope.material_no = '';
|
|||
|
$scope.product_lot_no = '';
|
|||
|
$scope.product_no = '';
|
|||
|
$scope.material_lot_no = 'N/A';
|
|||
|
$scope.qty = '';
|
|||
|
$scope.substitute_material_no = '';
|
|||
|
$scope.step_index = 0; //20200601 雋辰,改為使用step_index 操控流程
|
|||
|
$scope.step_index_semi = 0;
|
|||
|
$scope.materialList = []; //左側物料顯示List
|
|||
|
|
|||
|
|
|||
|
/*parameter*/
|
|||
|
var listMaterial = []; //20201110 雋辰,Mantis 0081381,物料資訊
|
|||
|
var listMaterial_semi = []; //半成品
|
|||
|
|
|||
|
$scope.menuIndex = 0;
|
|||
|
$scope.listMenu = [
|
|||
|
{ name: $filter('translate')('mrs02.rTitle') },
|
|||
|
{ name: $filter('translate')('mrs02.rTitle_SEMI') }
|
|||
|
];
|
|||
|
|
|||
|
$scope.changeMenu = function (index) {
|
|||
|
//上料類別若為物料,收集物料批號控制預設不開啟
|
|||
|
if (index == 0) $scope.blnbtnActive = false;
|
|||
|
$scope.menuIndex = index;
|
|||
|
}
|
|||
|
|
|||
|
$scope.blnbtnActive = false;
|
|||
|
$scope.switchBlnBtn = function () {
|
|||
|
if ($scope.step_index > 3) return;
|
|||
|
$scope.blnbtnActive = !$scope.blnbtnActive;
|
|||
|
$scope.material_lot_no = ($scope.blnbtnActive ? '' : 'N/A');
|
|||
|
}
|
|||
|
|
|||
|
/*前端Element供Focus用*/
|
|||
|
const scan_mono = document.getElementById('scan_mono');
|
|||
|
const scan_mono_semi = document.getElementById('scan_mono_semi');
|
|||
|
const scan_mtlno = document.getElementById('scan_mtlno');
|
|||
|
const scan_lotno = document.getElementById('scan_lotno');
|
|||
|
const scan_productno = document.getElementById('scan_productno');
|
|||
|
const scan_submtlno = document.getElementById('scan_submtlno');
|
|||
|
const scan_mtllotno = document.getElementById('scan_mtllotno');
|
|||
|
const scan_qty = document.getElementById('scan_qty');
|
|||
|
const scan_qty_semi = document.getElementById('scan_qty_semi');
|
|||
|
const step_conotrol = [
|
|||
|
scan_mono,
|
|||
|
scan_mtlno,
|
|||
|
scan_submtlno,
|
|||
|
scan_mtllotno,
|
|||
|
scan_qty
|
|||
|
];
|
|||
|
const step_conotrol_semi = [
|
|||
|
scan_mono_semi,
|
|||
|
scan_lotno,
|
|||
|
scan_productno,
|
|||
|
scan_qty_semi
|
|||
|
];
|
|||
|
|
|||
|
|
|||
|
/*html form load*/
|
|||
|
$scope.init = function () {
|
|||
|
|
|||
|
//init_Layout();
|
|||
|
$rootScope.EQPCheck_ModuleWIP(config.cache.workStation, function (data, result) {
|
|||
|
if (result == false) {
|
|||
|
return;
|
|||
|
}
|
|||
|
init_Layout();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
/*html event*/
|
|||
|
//MONO Input Box
|
|||
|
$scope.enter_input = function (event) {
|
|||
|
if (event.keyCode == 13) {
|
|||
|
enterInput();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//半成品輸入
|
|||
|
$scope.enter_input_semi = function (event) {
|
|||
|
if (event.keyCode == 13) {
|
|||
|
enterInputSEMI();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
$scope.scanQrcode = function () {
|
|||
|
$scope.$root.OpenScanner({
|
|||
|
after: function (result) {
|
|||
|
|
|||
|
//20231103,13871,0149473: 【华引芯】PAD物料扫描
|
|||
|
if (result.cancelled == true) return;
|
|||
|
|
|||
|
//物料輸入
|
|||
|
if ($scope.menuIndex == 0) {
|
|||
|
switch ($scope.step_index) {
|
|||
|
case 0:
|
|||
|
$scope.mo_no = result.text;
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
$scope.material_no = result.text;
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
$scope.substitute_material_no = result.text;
|
|||
|
break;
|
|||
|
case 3:
|
|||
|
$scope.material_lot_no = result.text;
|
|||
|
break;
|
|||
|
}
|
|||
|
//20231103,13871,改成呼叫callback才代表正確執行.允許自動開掃描
|
|||
|
enterInput(function () {
|
|||
|
if ($scope.step_index <= 3)
|
|||
|
$scope.scanQrcode();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
//半成品輸入
|
|||
|
if ($scope.menuIndex == 1) {
|
|||
|
switch ($scope.step_index_semi) {
|
|||
|
case 0:
|
|||
|
$scope.mo_no = result.text;
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
$scope.product_lot_no = result.text;
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
$scope.product_no = result.text;
|
|||
|
break;
|
|||
|
case 3:
|
|||
|
$scope.substitute_material_no = result.text;
|
|||
|
break;
|
|||
|
}
|
|||
|
//20231103,13871,改成呼叫callback才代表正確執行.允許自動開掃描
|
|||
|
enterInputSEMI(function () {
|
|||
|
if ($scope.step_index_semi <= 3)
|
|||
|
$scope.scanQrcode();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
},
|
|||
|
exception: function () {
|
|||
|
//目前裝置無法使用相機
|
|||
|
$scope.$root.showAlert($filter('translate')('common.msg.camera_not_support'));
|
|||
|
},
|
|||
|
orientation: "landscape"
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
$scope.add = function () {
|
|||
|
if ($scope.menuIndex == 0) {//物料
|
|||
|
Mount_Material();
|
|||
|
} else {//半成品
|
|||
|
Mount_SEMI();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
$scope.showCreateBtn = function () {
|
|||
|
if ($scope.menuIndex == 0) {//物料
|
|||
|
return $scope.step_index >= 3;
|
|||
|
} else {//半成品
|
|||
|
return $scope.step_index_semi >= 4;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
$scope.showScanBtn = function () {
|
|||
|
if ($scope.menuIndex == 0) {//物料
|
|||
|
return $scope.step_index < 3;
|
|||
|
} else {//半成品
|
|||
|
return $scope.step_index_semi < 4;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//20201110 雋辰,Mantis 0081381,清除輸入的資訊
|
|||
|
$scope.cancel = function () {
|
|||
|
reset_input_value(0);
|
|||
|
reset_input_value_semi(0);
|
|||
|
}
|
|||
|
|
|||
|
//未使用
|
|||
|
$scope.LoadParameter = function () {
|
|||
|
$MMWService.sendToMESSrv({
|
|||
|
uri: 'kcSYS.clsSYSParameter.LoadParameter',
|
|||
|
content: {
|
|||
|
parameterno: '2DBarCode Symbol'
|
|||
|
},
|
|||
|
success: function (data) {
|
|||
|
//data = JSON.parse(data.ResultJson);
|
|||
|
var data = JSON.parse(data.ResultJson);
|
|||
|
var parameterno = data.SYSParameter["0"]["PARAMETERNO"]
|
|||
|
|
|||
|
if (parameterno == '2DBarCode Symbol') {
|
|||
|
$scope.ParameterValue = data.SYSParameter["0"]["PARAMETERVALUE"]
|
|||
|
}
|
|||
|
|
|||
|
},
|
|||
|
error: function (data) {
|
|||
|
$scope.$root.showAlert($filter('translate')('Setting.msg.connect.failure') + "<br>" + data.Exception);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
//執行下料
|
|||
|
$scope.delete = function (index, item) {
|
|||
|
|
|||
|
$mdDialog.dialog('module/moduleWIP/program/mrs-eqp/mrs02/mrs02-dialog.html', function (dialog) {
|
|||
|
$css.add('module/moduleWIP/program/mrs-eqp/mrs02/mrs02-dialog.css');
|
|||
|
return {
|
|||
|
title: item.MONO,
|
|||
|
delete: function () {
|
|||
|
dialog.hide();
|
|||
|
|
|||
|
var content = {
|
|||
|
EquipmentNo: config.cache.equipment,
|
|||
|
MaterialNo: item.MATERIALNO,
|
|||
|
InputMaterialNo: item.INPUTMATERIALNO,
|
|||
|
MaterialLotNo: item.MATERIALLOTNO,
|
|||
|
Reviser: config.cache.account,
|
|||
|
ReviseDate: moment().format('YYYY/MM/DD HH:mm:ss'),
|
|||
|
MONo: item.MONO,
|
|||
|
PutInPlaceType: item.PUTINPLACETYPE
|
|||
|
};
|
|||
|
|
|||
|
Exe_EQPUnmountMaterial(content, function (data) {
|
|||
|
|
|||
|
if (data.Code === '0') {
|
|||
|
var result = JSON.parse(data.ResultJson);
|
|||
|
|
|||
|
//輸入區域恢復初始值
|
|||
|
reset_input_value(0);
|
|||
|
|
|||
|
$scope.materialList.splice(index, 1);
|
|||
|
}
|
|||
|
|
|||
|
});
|
|||
|
},
|
|||
|
back: function () {
|
|||
|
$css.remove('module/moduleSTD/program/mrs02/mrs02-dialog.css');
|
|||
|
this.hide();
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
/*切換綁訂*/
|
|||
|
$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_Layout();
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
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);
|
|||
|
}
|
|||
|
|
|||
|
/*core functions*/
|
|||
|
function Mount_Material() {
|
|||
|
if (!$scope.qty || $scope.qty <= 0)
|
|||
|
return;
|
|||
|
|
|||
|
CheckMTL(function () {
|
|||
|
Exe_EQPMountMaterial(function () {
|
|||
|
ShowWIPEQPMaterialState(function () {
|
|||
|
$scope.cancel();
|
|||
|
});
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function Mount_SEMI() {
|
|||
|
if (!$scope.qty || $scope.qty <= 0)
|
|||
|
return;
|
|||
|
|
|||
|
Exe_EQPMountMaterial(function () {
|
|||
|
ShowWIPEQPMaterialState(function () {
|
|||
|
$scope.cancel();
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
/*資料邏輯處理*/
|
|||
|
function init_Layout() {
|
|||
|
|
|||
|
$scope.materialList.length = 0;
|
|||
|
|
|||
|
$rootScope.work_machine = config.cache.equipment;
|
|||
|
|
|||
|
reset_input_value(0);
|
|||
|
|
|||
|
Init_Information();
|
|||
|
}
|
|||
|
|
|||
|
function reset_input_value(index) {
|
|||
|
blnExpireDate = false;
|
|||
|
|
|||
|
$scope.step_index = index;
|
|||
|
|
|||
|
if (index < 1) $scope.mo_no = '';
|
|||
|
if (index < 2) $scope.material_no = '';
|
|||
|
$scope.substitute_material_no = '';
|
|||
|
$scope.material_lot_no = 'N/A';
|
|||
|
$scope.qty = '';
|
|||
|
|
|||
|
$timeout(function () {
|
|||
|
step_conotrol[$scope.step_index].focus();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function reset_input_value_semi(index) {
|
|||
|
blnExpireDate = false;
|
|||
|
|
|||
|
$scope.step_index_semi = index;
|
|||
|
|
|||
|
if (index < 1) $scope.mo_no = '';
|
|||
|
if (index < 2) $scope.product_lot_no = '';
|
|||
|
$scope.product_no = '';
|
|||
|
$scope.material_lot_no = 'N/A';
|
|||
|
$scope.qty = '';
|
|||
|
|
|||
|
$timeout(function () {
|
|||
|
step_conotrol_semi[$scope.step_index_semi].focus();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function enterInput(callback) {
|
|||
|
if (!Check_Can_Use_Material()) {
|
|||
|
var material = $scope.step_index == 1 ? $scope.material_no : $scope.substitute_material_no;
|
|||
|
var msg = $filter('translate')('mrs02.itemNo') + ":" + material + $filter('translate')('mrs02.msg.materialNotFound');
|
|||
|
$rootScope.showAlert(msg);
|
|||
|
reset_input_value($scope.step_index);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!Check_Can_Use_SubstituteMaterial()) {
|
|||
|
$rootScope.showAlert($filter('translate')('mrs02.msg.notAllowToUseSubstitute'));
|
|||
|
reset_input_value(1);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
$scope.step_index++;
|
|||
|
|
|||
|
funAfterInputMaterialNo();
|
|||
|
funAfterInputSubstituteMaterialNo();
|
|||
|
|
|||
|
$timeout(function () {
|
|||
|
step_conotrol[$scope.step_index].focus();
|
|||
|
});
|
|||
|
|
|||
|
if (callback) callback();
|
|||
|
}
|
|||
|
|
|||
|
function funAfterInputMaterialNo() {
|
|||
|
if ($scope.step_index == 2) {
|
|||
|
var material = listMaterial.filter(function (item) {
|
|||
|
return item.MATERIALNO == $scope.material_no && item.MONO == $scope.mo_no;
|
|||
|
});
|
|||
|
|
|||
|
if (material.length > 0) {
|
|||
|
//若工單用料表中可以找到唯一的主料料號,自動將工單用料表中MaterialNo預設給替代料編號
|
|||
|
if (material.length == 1) {
|
|||
|
$scope.substitute_material_no = material[0].SUBSTITUTEMATERIALNO;
|
|||
|
$scope.step_index++; //20231103,13871,0149473: 【华引芯】PAD物料扫描,自動填入替料號必須步驟+1
|
|||
|
}
|
|||
|
|
|||
|
//物料主檔如果要管制料批,上方又選擇了無批號,顯示設定錯誤
|
|||
|
if (material[0].CHECKLOTNO == 1) {
|
|||
|
if (!$scope.blnbtnActive) {
|
|||
|
$rootScope.showAlert($filter('translate')('mrs02.msg.MaterialMustCheckLotNo'));
|
|||
|
$scope.blnbtnActive = true;
|
|||
|
$scope.material_lot_no = ($scope.blnbtnActive ? '' : 'N/A');
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
function funAfterInputSubstituteMaterialNo() {
|
|||
|
if ($scope.step_index == 3) {
|
|||
|
var material = listMaterial.filter(function (item) {
|
|||
|
return item.MATERIALNO == $scope.material_no &&
|
|||
|
item.MONO == $scope.mo_no && item.SUBSTITUTEMATERIALNO == $scope.substitute_material_no &&
|
|||
|
item.SUBSTITUTECHECKLOTNO == 0;
|
|||
|
});
|
|||
|
if (material.length > 0) {
|
|||
|
$scope.material_lot_no = ($scope.blnbtnActive ? '' : 'N/A');
|
|||
|
if (!$scope.blnbtnActive) $scope.step_index = 4;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function enterInputSEMI(callback) {
|
|||
|
Check_Can_Use_MONO_SEMI(function () {
|
|||
|
|
|||
|
$scope.step_index_semi++;
|
|||
|
|
|||
|
funAfterInputMoNo_semi(function () {
|
|||
|
funAfterInputLotNo_semi(function () {
|
|||
|
|
|||
|
$timeout(function () {
|
|||
|
step_conotrol_semi[$scope.step_index_semi].focus();
|
|||
|
});
|
|||
|
|
|||
|
if (callback) callback();
|
|||
|
});
|
|||
|
});
|
|||
|
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function funSetDefaultByBOM() {
|
|||
|
var material = listMaterial_semi.filter(function (item) {
|
|||
|
return item.MONO == $scope.mo_no && item.MATERIALNO == $scope.product_no;
|
|||
|
});
|
|||
|
|
|||
|
//若工單用料表中可以找到唯一的主料料號,自動將工單用料表中MaterialNo預設給替代料編號
|
|||
|
if (material.length == 1) {
|
|||
|
$scope.substitute_material_no = material[0].SUBSTITUTEMATERIALNO;
|
|||
|
$scope.step_index_semi = 4;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function funAfterInputMoNo_semi(callback) {
|
|||
|
if ($scope.step_index_semi == 1) {
|
|||
|
//半成品用料清單需要以工單重新搜尋 否則會找不到
|
|||
|
funLoadMOMaterialListByEQP($scope.mo_no, (data) => {
|
|||
|
listMaterial_semi = data;
|
|||
|
listMaterial_semi.forEach(item => {
|
|||
|
item.ORGMATERIALNO = item.MATERIALNO;
|
|||
|
});
|
|||
|
if (callback) callback();
|
|||
|
});
|
|||
|
}
|
|||
|
else
|
|||
|
if (callback) callback();
|
|||
|
}
|
|||
|
function funAfterInputLotNo_semi(callback) {
|
|||
|
|
|||
|
if ($scope.step_index_semi != 2) {
|
|||
|
if (callback) callback();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//找半成品倉
|
|||
|
funLoadWIPInventory_SEMI($scope.product_lot_no, function (listWIPInventory_SEMI) {
|
|||
|
|
|||
|
if (listWIPInventory_SEMI.length > 0) {
|
|||
|
$scope.product_no = listWIPInventory_SEMI[0].PRODUCTNO;
|
|||
|
$scope.qty = listWIPInventory_SEMI[0].QTY;
|
|||
|
$scope.step_index_semi = 3;
|
|||
|
funSetDefaultByBOM();
|
|||
|
if (callback) callback();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//找工單投料
|
|||
|
funLoadMOMaterialState($scope.mo_no, $scope.product_lot_no, (listMOMaterialState) => {
|
|||
|
|
|||
|
if (listMOMaterialState.length > 0) {
|
|||
|
$scope.product_no = listMOMaterialState[0].MATERIALNO;
|
|||
|
$scope.qty = listMOMaterialState[0].QTY;
|
|||
|
$scope.step_index_semi = 3;
|
|||
|
funSetDefaultByBOM();
|
|||
|
if (callback) callback();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
var msg = $filter('translate')('mrs02.lotNo') + ":" + $scope.product_lot_no + $filter('translate')('mrs02.msg.lotNoNotFound');
|
|||
|
$rootScope.showAlert(msg);
|
|||
|
reset_input_value_semi(1);
|
|||
|
return;
|
|||
|
});
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
function funLoadWIPInventory_SEMI(lotNo, callback) {
|
|||
|
$MMWService.sendToMESSrv({
|
|||
|
uri: 'kcWIP.clsLot.LoadWIPInventory_SEMI',
|
|||
|
content: {
|
|||
|
LotNo: lotNo
|
|||
|
},
|
|||
|
success: function (data) {
|
|||
|
var data = JSON.parse(data.ResultJson);
|
|||
|
data = data.WIPInventory_SEMI;
|
|||
|
if (callback) callback(data);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
function funLoadMOMaterialState(mono, productlotNo, callback) {
|
|||
|
$MMWService.sendToMESSrv({
|
|||
|
uri: 'kcOE.clsOEBasis.LoadMOMaterialState',
|
|||
|
content: {
|
|||
|
MONo: mono,
|
|||
|
MaterialLotNo: productlotNo
|
|||
|
},
|
|||
|
success: function (data) {
|
|||
|
var data = JSON.parse(data.ResultJson);
|
|||
|
data = data.MOMaterialState;
|
|||
|
if (callback) callback(data);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
function funLoadMOBasis(MoNo, callback) {
|
|||
|
$MMWService.sendToMESSrv({
|
|||
|
uri: 'kcOE.clsOEBasis.LoadMOBasis',
|
|||
|
content: {
|
|||
|
MOState: '0|1|2|3|6',
|
|||
|
MoNo: MoNo
|
|||
|
},
|
|||
|
success: function (data) {
|
|||
|
var data = JSON.parse(data.ResultJson);
|
|||
|
data = data.OEMOBasis;
|
|||
|
if (callback) callback(data);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
function funLoadMOMaterialListByEQP(MoNo, callback) {
|
|||
|
$MMWService.sendToMESSrv({
|
|||
|
uri: 'kcWIP.clsMaterialHandler.LoadMOMaterialListByEQP',
|
|||
|
content: {
|
|||
|
EquipmentNo: config.cache.equipment,
|
|||
|
MoNo: MoNo,
|
|||
|
columns: ['MONO', 'MATERIALNO', 'SUBSTITUTEMATERIALNO',
|
|||
|
'SUBSTITUTECHECKLOTNO', 'SPECIFIED', 'CHECKLOTNO', 'PUTINPLACETYPE']
|
|||
|
},
|
|||
|
success: function (data) {
|
|||
|
var data = JSON.parse(data.ResultJson);
|
|||
|
data = data.MOMaterialListByEQP;
|
|||
|
if (callback) callback(data);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function Check_Can_Use_Material() {
|
|||
|
var listTmp;
|
|||
|
|
|||
|
switch ($scope.step_index) {
|
|||
|
case 1:
|
|||
|
listTmp = listMaterial.filter(function (item) {
|
|||
|
return item.MONO == $scope.mo_no && item.MATERIALNO == $scope.material_no;
|
|||
|
});
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
listTmp = listMaterial.filter(function (item) {
|
|||
|
return item.MONO == $scope.mo_no && item.MATERIALNO == $scope.material_no &&
|
|||
|
item.SUBSTITUTEMATERIALNO == $scope.substitute_material_no;
|
|||
|
});
|
|||
|
break;
|
|||
|
default:
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
return listTmp.length > 0;
|
|||
|
}
|
|||
|
|
|||
|
function Check_Can_Use_MONO_SEMI(callback) {
|
|||
|
|
|||
|
if ($scope.step_index_semi != 0) {
|
|||
|
callback();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
funLoadMOBasis($scope.mo_no, (MOBasis) => {
|
|||
|
//工單不存在
|
|||
|
if (MOBasis.length <= 0) {
|
|||
|
$rootScope.showAlert($filter('translate')('mrs02.msg.MoNoNotFound'));
|
|||
|
reset_input_value_semi(0);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
var BOM = listMaterial.filter(function (item) {
|
|||
|
return item.MONO == $scope.mo_no;
|
|||
|
});
|
|||
|
|
|||
|
//工單沒有工單用料表
|
|||
|
if (BOM.length <= 0) {
|
|||
|
$rootScope.showAlert($filter('translate')('mrs02.msg.MoNoNotFound'));
|
|||
|
reset_input_value_semi(0);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
callback();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function Check_Can_Use_SubstituteMaterial() {
|
|||
|
|
|||
|
if ($scope.step_index != 2) return true;
|
|||
|
|
|||
|
var listTmp = listMaterial.filter(function (item) {
|
|||
|
return item.MONO == $scope.mo_no && item.MATERIALNO == $scope.material_no;
|
|||
|
});
|
|||
|
|
|||
|
if (!listTmp.length > 0 ||
|
|||
|
(listTmp[0].SPECIFIED == 1 && $scope.material_no != $scope.substitute_material_no)) return false;
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
/*request web service*/
|
|||
|
function Init_Information(callback) {
|
|||
|
|
|||
|
var uri = [];
|
|||
|
var content = [];
|
|||
|
|
|||
|
//物料資訊 TBLOEMOMATERIALLIST
|
|||
|
uri.push("kcWIP.clsMaterialHandler.LoadMOMaterialListByEQP");
|
|||
|
content.push({
|
|||
|
EquipmentNo: config.cache.equipment,
|
|||
|
columns: ['MONO', 'MATERIALNO', 'SUBSTITUTEMATERIALNO',
|
|||
|
'SUBSTITUTECHECKLOTNO', 'SPECIFIED', 'CHECKLOTNO', 'PUTINPLACETYPE']
|
|||
|
});
|
|||
|
|
|||
|
//設備上料資訊
|
|||
|
uri.push("kcWIP.clsMaterialHandler.ShowWIPEQPMaterialState");
|
|||
|
content.push({
|
|||
|
EquipmentNo: config.cache.equipment,
|
|||
|
columns: ['equipmentno', 'materialno', 'mono', 'materiallotno', 'inputqty', 'qty', 'InputMaterialNo', 'PutInPlaceType']
|
|||
|
});
|
|||
|
|
|||
|
$MMWService.sendToMESSrv_Multi({
|
|||
|
uri: uri,
|
|||
|
content: content,
|
|||
|
success: function (data) {
|
|||
|
Init_Information_Transf(data, uri);
|
|||
|
if (callback)
|
|||
|
callback();
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
function Init_Information_Transf(result, uri) {
|
|||
|
if (result.Code == "0") {
|
|||
|
var tmpJson = JSON.parse(result.ResultJson);
|
|||
|
|
|||
|
listMaterial = JSON.parse(tmpJson[uri[0]])["MOMaterialListByEQP"];
|
|||
|
listMaterial.forEach(item => {
|
|||
|
item.ORGMATERIALNO = item.MATERIALNO;
|
|||
|
});
|
|||
|
|
|||
|
$scope.materialList = JSON.parse(tmpJson[uri[1]])["EQPMaterialState"];
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function ShowWIPEQPMaterialState(callback) {
|
|||
|
var uri = [];
|
|||
|
var content = [];
|
|||
|
|
|||
|
//設備上料資訊
|
|||
|
//20221123,13871,增加需求欄位PutInPlaceType,下料需求此資訊
|
|||
|
uri.push("kcWIP.clsMaterialHandler.ShowWIPEQPMaterialState");
|
|||
|
content.push({
|
|||
|
EquipmentNo: config.cache.equipment,
|
|||
|
AdditionalXML: '<additional><condition>qty>0</condition></additional>',
|
|||
|
columns: ['equipmentno', 'materialno', 'mono', 'materiallotno', 'inputqty', 'qty', 'InputMaterialNo', 'PutInPlaceType']
|
|||
|
});
|
|||
|
|
|||
|
$MMWService.sendToMESSrv_Multi({
|
|||
|
uri: uri,
|
|||
|
content: content,
|
|||
|
success: function (data) {
|
|||
|
ShowWIPEQPMaterialState_Transf(data, uri);
|
|||
|
if (callback)
|
|||
|
callback();
|
|||
|
},
|
|||
|
error: function () {
|
|||
|
$scope.cancel();
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
function ShowWIPEQPMaterialState_Transf(result, uri) {
|
|||
|
if (result.Code == "0") {
|
|||
|
var tmpJson = JSON.parse(result.ResultJson);
|
|||
|
$scope.materialList = JSON.parse(tmpJson[uri[0]])["EQPMaterialState"];
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//20201110 雋辰,Mantis 0081381,改使用STD方式
|
|||
|
function Exe_EQPMountMaterial(callback) {
|
|||
|
|
|||
|
var checkLotNo, materialNo, inputMaterialNo, materialLotNo;
|
|||
|
|
|||
|
if ($scope.menuIndex == 0) {//物料
|
|||
|
var tmpList = listMaterial.filter(function (item) {
|
|||
|
return item.MONO == $scope.mo_no && item.MATERIALNO == $scope.material_no;
|
|||
|
});
|
|||
|
checkLotNo = tmpList.length > 0 ? tmpList[0].CHECKLOTNO : 0;
|
|||
|
materialNo = $scope.material_no;
|
|||
|
inputMaterialNo = $scope.substitute_material_no;
|
|||
|
materialLotNo = $scope.material_lot_no;
|
|||
|
|
|||
|
} else {//半成品
|
|||
|
var tmpList = listMaterial_semi.filter(function (item) {
|
|||
|
return item.MONO == $scope.mo_no && item.MATERIALNO == $scope.product_no;
|
|||
|
});
|
|||
|
checkLotNo = tmpList.length > 0 ? tmpList[0].CHECKLOTNO : 0;
|
|||
|
materialNo = $scope.product_no;
|
|||
|
inputMaterialNo = $scope.product_no;
|
|||
|
materialLotNo = $scope.product_lot_no;
|
|||
|
}
|
|||
|
|
|||
|
$MMWService.sendToMESSrv({
|
|||
|
uri: 'kcWIP.clsMaterialHandler.Exe_EQPMountMaterial',
|
|||
|
content: {
|
|||
|
EquipmentNo: config.cache.equipment,
|
|||
|
MaterialNo: materialNo,
|
|||
|
CheckLotNo: checkLotNo,
|
|||
|
InputMaterialNo: inputMaterialNo,
|
|||
|
InputQty: $scope.qty,
|
|||
|
MONo: $scope.mo_no,
|
|||
|
MaterialLotNo: materialLotNo,
|
|||
|
Reviser: config.cache.account,
|
|||
|
ReviseDate: moment().format("YYYY/MM/DD HH:mm:ss")
|
|||
|
},
|
|||
|
success: function (data) {
|
|||
|
if (callback)
|
|||
|
callback();
|
|||
|
},
|
|||
|
error: function () {
|
|||
|
$scope.cancel();
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
//EQP Unmount Material
|
|||
|
function Exe_EQPUnmountMaterial(content, callback) {
|
|||
|
$MMWService.sendToMESSrv({
|
|||
|
uri: 'kcWIP.clsMaterialHandler.Exe_EQPUnmountMaterial',
|
|||
|
content: content,
|
|||
|
success: function (data) {
|
|||
|
if (callback)
|
|||
|
callback(data);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
function GetDtTMaterial() {
|
|||
|
var dtTMaterial;
|
|||
|
if ($scope.menuIndex == 0) {//物料
|
|||
|
dtTMaterial = listMaterial.filter(function (item) {
|
|||
|
return item.MONO == $scope.mo_no && item.MATERIALNO == $scope.material_no;
|
|||
|
});
|
|||
|
|
|||
|
} else {//半成品
|
|||
|
dtTMaterial = listMaterial_semi.filter(function (item) {
|
|||
|
return item.MONO == $scope.mo_no && item.MATERIALNO == $scope.product_no;
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
return dtTMaterial
|
|||
|
}
|
|||
|
|
|||
|
function CheckMTL(callback) {
|
|||
|
|
|||
|
var uri = [];
|
|||
|
var content = [];
|
|||
|
|
|||
|
uri.push("kcWIP.clsMaterialHandler.CheckMTLForEQPMount");
|
|||
|
content.push({
|
|||
|
EquipmentNo: config.cache.equipment,
|
|||
|
MONo: $scope.mo_no,
|
|||
|
MaterialLotNo: $scope.material_lot_no,
|
|||
|
MaterialNo: $scope.material_no
|
|||
|
});
|
|||
|
|
|||
|
$MMWService.sendToMESSrv_Multi({
|
|||
|
uri: uri,
|
|||
|
content: content,
|
|||
|
success: function (data) {
|
|||
|
if (data.Code != "0") return;
|
|||
|
if (callback) callback();
|
|||
|
},
|
|||
|
error: function () {
|
|||
|
$scope.cancel();
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
]
|
|||
|
});
|