import {InitPallet, InitGoods} from './StoreGoods.js'; // 输送线当前运行状态对象 function StaTask(staData, object) { let that = this; that.object = object; that.no = 0; that.readyIn = false; that.run = false; that.loaded = 0; that.wrkNo = null; that.inlet = -1; that.outlet = -1; that.position = null; let init = function () { that.no = staData.no; that.inlet = staData.inlet; that.outlet = staData.outlet; let item = getArrVal(conveyObjects.objects, "no", that.no+""); if (!that.position && item) { that.position = item.position; } } init(); that.modify = function (staData) { if (that.run || that.no === 0) { console.error(staData.no + "号输送线更新失败"); return; } // 页面切换导致货物覆盖 if (that.loaded === 1 && staData.loaded === 1 && staData.wrkNo > 0 && that.wrkNo > 0 && that.wrkNo !== staData.wrkNo) { if (that.inlet === 1) { // remove console.log("sta_" + that.no + " remove:" + that.wrkNo + "-Pallet; " + that.wrkNo + "-Goods"); that.object.removeObject(that.wrkNo + "-Pallet"); that.object.removeObject(that.wrkNo + "-Goods"); // add console.log("sta_" + that.no + " add:" + staData.wrkNo + "-Pallet + Goods; [up]"); InitPallet(that.object, [{wrkNo: staData.wrkNo}], {position: that.position}, 2); InitGoods(that.object, [{wrkNo: staData.wrkNo}], {position: that.position}, 2); } that.readyIn = false; } if (that.loaded === 0 && staData.loaded === 1) { that.readyIn = true; } if (that.readyIn && staData.wrkNo && staData.wrkNo !== '0') { // 无货 ===>> 有货 // 1.入库第一站 【新增】 if (that.inlet === 1) { console.log("sta_" + that.no + " add:" + staData.wrkNo + "-Pallet + Goods; [down]"); InitPallet(that.object, [{wrkNo: staData.wrkNo}], {position: that.position}, 2); InitGoods(that.object, [{wrkNo: staData.wrkNo}], {position: that.position}, 2); // 2.来自其他站点的货物 【移动】 } else { } that.readyIn = false; } if (that.loaded === 1 && staData.loaded === 0) { // 有货 ===>> 无货 // 1.出库最后一站 【移除】 if (that.outlet === 1) { let pallet = getArrVal(that.object.objects, "name", that.wrkNo + "-Pallet"); if (pallet != null) { that.object.removeObject(that.wrkNo + "-Pallet"); } let goods = getArrVal(that.object.objects, "name", that.wrkNo + "-Goods"); if (goods != null) { that.object.removeObject(that.wrkNo + "-Goods"); } } that.readyIn = false; } // 实时更新 that.loaded = staData.loaded; that.wrkNo = staData.wrkNo; // that.run = true; } that.change = function () { } } export {StaTask}