Quellcode durchsuchen

临时增加海柔二期机器人操作口

Zhouzhendong vor 4 Jahren
Ursprung
Commit
b709b344db
1 geänderte Dateien mit 187 neuen und 13 gelöschten Zeilen
  1. 187 13
      resources/views/station/monitor/show.blade.php

+ 187 - 13
resources/views/station/monitor/show.blade.php

@@ -9,8 +9,14 @@
                     <div class="col-4 text-center h3 py-2 font-weight-bold text-info position-relative">
                         宝时云仓
                     </div>
-                    <div class="col text-center  h3 py-2 text-muted">
-                        智能分拣
+                    <div class="col h3 py-2 text-muted row">
+                        <select class="form-control col-2 offset-4" id="station" @change="listenerStation()">
+                            <option selected value=""></option>
+                            <option v-for="station in stations" :value="station.code">
+                                @{{ station.code }}
+                            </option>
+                        </select>
+                        <span class="col-2">智能分拣</span>
                     </div>
                 </div>
                 <div class="row pt-3">
@@ -95,8 +101,12 @@
                         <div class="row pt-2">
                             <div class="col text-center">
                                 <svg class="box-display" width="300" height="160" viewBox="0 0 300 160">
-                                    <rect x="0" y="80" width="300" height="80"
-                                          style="fill:#ffffff;stroke-width:3;stroke:rgb(11,51,71)"/>
+                                    <g><rect x="0" y="80" width="300" height="80"
+                                          style="fill:#ffffff;stroke-width:3;stroke:rgb(11,51,71)">
+                                        </rect>
+                                        <text x="10" y="135" font-family="Verdana" font-weight="bold" font-size="40" fill="green">
+                                            @{{ box }}</text>
+                                    </g>
                                     <polygon points="0,80 50,0 250,0 300,80"
                                              style="fill:#ffffff;stroke:rgb(11,51,71);stroke-width:3;" />
                                     <polygon v-if="grids.single.status"
@@ -206,7 +216,16 @@
                                 <textarea  name="" id="" cols="30" rows="3" class="form-control" v-model="inputs.manuallyTakeBox.text"
                                            placeholder="点选此处写入料箱号,可以省略IDE前缀和0,多个用空格分隔,例入:5121 156"></textarea>
                                             <button class="btn btn-info btn-lg" @click="manuallyTakeBoxOut">出库</button>
-                                            <button class="btn btn-sm btn-primary btn-lg" @click="paddingEmptyBox">填充空箱</button>
+                                            <button class="btn btn-success btn-lg" @click="manuallyTakeBoxOutTwo">二期出库</button>
+<!--                                            <button class="btn btn-sm btn-primary btn-lg" @click="paddingEmptyBox">填充空箱</button>-->
+                                            <div class="row mt-1">
+                                                <select class="form-control ml-3" v-model="type" style="width:150px">
+                                                    <option v-for="strategy in strategies" :value="strategy.code">@{{ strategy.name }}</option>
+                                                </select>
+                                                <select class="form-control ml-1" v-model="stationCode" style="width:150px">
+                                                    <option v-for="st in stations" :value="st.code">@{{ st.code }}</option>
+                                                </select>
+                                            </div>
                                         </div>
                                     </div>
                                 </div>
@@ -361,14 +380,113 @@
                         right:{top:{status:'',},bottom:{status:'',},},
                     },
                 },
+                stations:[],
+                baseUrl:"https://swms.baoshi56.com/",
+                stationWs:null,
+                prodNum:null,
+                box:"",
+                list:[],
+                type:"",
+                stationCode:"",
+                strategies:[],
             },
             mounted() {
                 this._makeMenuHiding();
-                initEcho();
-                this._listenTaskBroadcast();
-                this._listenAllTaskBroadcast();
+                //initEcho();
+                //this._listenTaskBroadcast();
+                //this._listenAllTaskBroadcast();
+                this._loadStation();
             },
             methods:{
+                // 加载站点
+                _loadStation(){
+                    $.ajax({
+                        url : this.baseUrl+"equipment/getSortingStationList",
+                        type : "get",
+                        success : (res,status)=>{
+                            if (res.code === 200){
+                                this.stations = res.data;
+                                this.stationCode = this.stations[0].code;
+                            } else {
+                                window.tempTip.show(res.message);
+                            }
+                        },
+                        error : (err,status)=>{
+                            window.tempTip.show("分拣站信息获取失败");
+                        },
+                        timeout:3000,
+                    })
+                    $.ajax({
+                        url : this.baseUrl+"device/robot/hairou/getStrategies",
+                        type : "post",
+                        success : (res,status)=>{
+                            if (res.code === 200){
+                                this.strategies = res.data;
+                                this.type = this.strategies[0].code;
+                            } else {
+                                window.tempTip.show(res.message);
+                            }
+                        },
+                        error : (err,status)=>{
+                            window.tempTip.show("分配策略获取失败");
+                        },
+                        timeout:3000,
+                    })
+                },
+                listenerStation(){
+                   let val = document.getElementById("station").value;
+                   // 手动关闭不重试
+                   if (val === '' && this.stationWs != null){
+                       this.stationWs.close();
+                       window.clearInterval(this.prodNum);
+                       this.list = null;
+                       return;
+                   }
+                   this.stationWs = new WebSocket("wss://swms.baoshi56.com/ws/device/check/picking.info/"+val);
+                   this.stationWs.onopen = (event=> {
+                       console.info("Connection open success!");
+                   });
+                    this.stationWs.onmessage = (event => {
+                        let obj = JSON.parse(event.data);
+                        if(obj.dataType !== "heartbeat"){
+                            this.box = obj.code;
+                            let list = [];
+                            (JSON.parse(obj.list)).forEach(info => {
+                                list.push({
+                                    status : "待处理",
+                                    commodity : {
+                                        name : "",
+                                        barcodes : [
+                                            {code : info.barcode},
+                                            {code : info.barcodeAs},
+                                        ],
+                                    },
+                                    amount : info.quantity
+                                })
+                            })
+                            this.list = list;
+                        }
+                    });
+                    this.stationWs.onerror = function (event) {
+                        console.error(event);
+                    };
+                    this.prodNum = window.setInterval(()=>{
+                        if (this.stationWs != null){
+                            let obj = {
+                                "requestId" : "stationListener",
+                                "dataType" : "heartbeat",
+                            };
+                            this.stationWs.send(JSON.stringify(obj));
+                        }
+                    },15000);
+                    // 被关闭就五秒后重试
+                    this.stationWs.onclose = (event => {
+                        window.clearInterval(this.prodNum);
+                        setTimeout(()=>{
+                            this.listenerStation();
+                        },5000);
+                    });
+                },
                 _makeMenuHiding(){
                     $('.navbar,.nav1,.nav2').hide();
                     $('.nav3').on('mouseenter', function () {
@@ -380,7 +498,6 @@
                 },
                 _listenTaskBroadcast(){
                     let _this=this;
-                    console.log(this.taskBroadcastName,this.channelName);
                     window.Echo.channel(this.taskBroadcastName).listen(this.channelName,(msg)=> {
                         console.log('1:',(new Date()).toTimeString(),msg);
                         let taskIn = JSON.parse(msg.json);
@@ -400,11 +517,8 @@
                 },
                 _listenAllTaskBroadcast(){
                     let _this=this;
-                    console.log(this.allTaskBroadcastName,this.channelName);
                     window.Echo.channel(this.allTaskBroadcastName).listen(this.channelName,(msg)=> {
-                        console.log('2:',(new Date()).toTimeString(),msg);
                         let stationTasksIn = JSON.parse(msg.json);
-                        console.log(stationTasksIn);
                         if(!stationTasksIn||stationTasksIn.length===0)return;
                         stationTasksIn.forEach(function(stationTaskIn){
                             let stationTaskIn_toAdd=stationTaskIn;
@@ -425,7 +539,6 @@
                                 _this.$forceUpdate();
                             }
                         })
-
                     });
                 },
                 selectBatch(stationTaskBatch){
@@ -455,6 +568,66 @@
                         window.manuallyHairouRequesting=false;
                     })
                 },
+                _waveOutBound(waveCode){
+                    $.ajax({
+                        url: this.baseUrl+"device/robot/hairou/task/createOutBound/picking?code="+waveCode
+                            +"&strategy="+this.type+"&station="+this.stationCode,
+                        type: "get",
+                        success : (res,status)=>{
+                            if (res.code === 200 && res.data){
+                                window.tempTip.success("开始执行");
+                            } else {
+                                window.tempTip.show(res.message);
+                            }
+                        },
+                        error : (err,status)=>{
+                            window.tempTip.show("系统错误");
+                        },
+                        timeout:3000,
+                    })
+                },
+                manuallyTakeBoxOutTwo(){
+                    if (this.inputs.manuallyTakeBox.text.length === 13 && this.inputs.manuallyTakeBox.text.substring(0,1) === "W"){
+                        this._waveOutBound(this.inputs.manuallyTakeBox.text);
+                        return;
+                    }
+                    let arr = this.inputs.manuallyTakeBox.text.trim().split(/\s+/);
+                    if (arr.length===0){
+                        return;
+                    }
+                    let boxes = [];
+                    arr.forEach(box=>{
+                        if (box.length <= 10 && box.length > 0){
+                            let before = "IDE0000000";
+                            boxes.push(before.substring(0,before.length - box.length)+box);
+                        }
+                    });
+                    if (boxes.length === 0){
+                        return;
+                    }
+                    let obj = {
+                        "boxCodes":boxes,
+                        "typeName":this.type,
+                        "toLocation":this.stationCode
+                    }
+                    $.ajax({
+                        url: this.baseUrl+"device/robot/hairou/task/createOutBound/custom",
+                        type: "post",
+                        headers: {'Content-Type':'application/json;charset=utf8'},
+                        data: JSON.stringify(obj),
+                        success : (res,status)=>{
+                            if (res.code === 200 && res.data){
+                                window.tempTip.success("开始执行");
+                            } else {
+                                window.tempTip.show(res.message);
+                            }
+                        },
+                        error : (err,status)=>{
+                            window.tempTip.show("系统错误");
+                        },
+                        timeout:3000,
+                    })
+                },
                 paddingEmptyBox(){
                     window.tempTip.inputVal("调取数量",amount=>{
                         window.tempTip.postBasicRequest("{{url('/api/thirdPart/haiq/storage/paddingEmptyBox')}}",{amount:amount},res=>{
@@ -520,6 +693,7 @@
                     return this.current_stationTaskBatch.batch.code;
                 },
                 taskCommodities(){
+                    if (this.list)return this.list;
                     if(!this.task)return [];
                     return this.task['station_task_commodities'];
                 },