333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<template>
  <div id="wrapper">
    <main>
      <el-row :gutter="10" class="padding-10">
        <el-col :span="12">
          <span class="title">执行日志</span>
 
          <el-scrollbar :noresize="false" :native="false" wrap-class="log-container scrollbar-wrap" class="scrollbar-box">
            <div class="content-box">
              <div v-for="(item,index) in textarray" :key="index" class="row">
                <span>{{ item.msg }}</span>
              </div>
            </div>
          </el-scrollbar>
        </el-col>
        <el-col :span="12">
          <el-form ref="form" :model="formData" label-width="120px" label-position="top">
            <el-row>
              <el-col :span="8">
                <el-form-item label="选择输送机设备">
                  <el-select v-model="formData.transId" placeholder="请选择设备编号">
                    <el-option label="1" value="1"></el-option>
                    <el-option label="2" value="2"></el-option>
                    <el-option label="3" value="3"></el-option>
                    <el-option label="4" value="4"></el-option>
                    <el-option label="5" value="5"></el-option>
                    <el-option label="6" value="6"></el-option>
                    <el-option label="7" value="7"></el-option>
                    <el-option label="65" value="65"></el-option>
                    <el-option label="66" value="66"></el-option>
                    <el-option label="67" value="67"></el-option>
                    <el-option label="68" value="68"></el-option>
                    <el-option label="69" value="69"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="选择堆垛机设备">
                  <el-select v-model="formData.srmId" placeholder="请选择设备编号">
                    <el-option label="1" value="1"></el-option>
                    <el-option label="2" value="2"></el-option>
                    <el-option label="3" value="3"></el-option>
                    <el-option label="4" value="4"></el-option>
                    <el-option label="5" value="5"></el-option>
                    <el-option label="6" value="6"></el-option>
                    <el-option label="7" value="7"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="选择RGV设备">
                  <el-select v-model="formData.rgvId" placeholder="请选择设备编号">
                    <el-option label="1" value="1"></el-option>
                    <el-option label="2" value="2"></el-option>
                    <el-option label="3" value="3"></el-option>
                    <el-option label="4" value="4"></el-option>
                    <el-option label="5" value="5"></el-option>
                    <el-option label="6" value="6"></el-option>
                    <el-option label="7" value="7"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="立库输送机操作">
              <el-button type="primary" @click="getSrmConveyorStationInfo">设备详情</el-button>
              <el-button type="primary" @click="getGoodsWeight">读取重量</el-button>
              <el-button type="primary" @click="rgvIsPassed">外形检测</el-button>
            </el-form-item>
            <el-form-item label="RGV操作">
              <el-button type="primary" @click="getRgvInfo">设备详情</el-button>
              <el-button type="primary" @click="sendRgvCmd">发送RGV运送指令</el-button>
              <el-button type="primary" @click="checkRgvFinished">检查任务完成</el-button>
              <el-button type="primary" @click="sendRgvFinishConfirm">完成确认</el-button>
            </el-form-item>
            <el-form-item label="立库堆垛机操作">
              <el-button type="primary" @click="getSrmInfo">设备详情</el-button>
              <el-button type="primary" @click="sendSrmTask">发送移动任务</el-button>
              <el-button type="primary" @click="srmIsTaskFinish">完成确认</el-button>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </main>
  </div>
</template>
 
<script>
import { srm, tran, rgv } from "@/utils/webServiceHelper";
 
export default {
  name: "landing-page",
  components: {},
  data: () => ({
    textarray: [
      {
        // msg: "系统监控开始..."
      }
    ],
    formData: {
      // 当前堆垛机设备ID
      srmId: "1",
      // 当前rgv设备ID
      rgvId: "1",
      // 当前输送机ID
      transId: "1",
      // 任务ID
      taskId: "1001"
    }
  }),
  created() {
    // this.initWS();
    srm.common = this.common;
    tran.common = this.common;
    rgv.common = this.common;
  },
  methods: {
    log(title, msg) {
      if (typeof msg === "object") {
        msg = JSON.stringify(msg);
      }
      this.textarray.push({
        msg: title + (msg || ""),
        color: "black"
      });
    },
    logError(title, msg) {
      if (typeof msg === "object") {
        msg = JSON.stringify(msg);
      }
      this.textarray.push({
        msg: title + (msg || ""),
        color: "red"
      });
    },
    // 开启websocket
    initWS() {
      this.log("启动websocket...");
      const WebSocket = require("ws");
      const wss = new WebSocket.Server({ port: 8020 });
      wss.on("connection", function connection(ws) {
        ws.on("message", function incoming(message) {
          console.log("received: %s", message);
        });
 
        ws.send("something");
      });
      this.log("启动websocket成功");
    },
    // 获取输送机信息
    async getSrmConveyorStationInfo() {
      const result = await tran.getSrmConveyorStationInfo(this.formData.transId);
      this.log("输送机设备状态:" + JSON.stringify(result));
    },
    // 获取堆垛机状态
    async getSrmStatus() {
      const result = await srm.isReady(this.formData.srmId);
      this.log("设备状态:" + JSON.stringify(result));
    },
    // 获取堆垛机详细信息
    async getSrmInfo() {
      const result = await srm.getSrmInfo(this.formData.srmId);
      this.log(`设备ID为 ${this.formData.srmId} 详情:` + JSON.stringify(result));
    },
    // 获取设备重量
    async getGoodsWeight() {
      const result = await tran.getGoodsWeight(this.formData.transId);
      this.log("获取设备重量:" + JSON.stringify(result));
      if (result.data && result.data.GetGoodsWeightResult) {
        const datas = result.data.GetGoodsWeightResult.split(",");
        this.log("称重器具编号:", datas);
        const sizeInfo = await this.updatedYnamicWeight(datas[0], datas[1]);
        this.log("获取到长宽高编号:", sizeInfo);
        const sendSizeResult = await tran.sendGoodsSize(this.formData.transId, sizeInfo.data.length, sizeInfo.data.width, sizeInfo.data.height);
        this.log("发送长宽高:", sendSizeResult);
        const sendGoodsResult = await tran.sendGoodsReady(this.formData.transId, 66, 111);
        this.log("通知输送线进料:", sendGoodsResult);
        const isPassedResult = await tran.isPassed(this.formData.transId);
        this.log("外形检测通过后:", isPassedResult);
      }
    },
    // 外形检测
    async rgvIsPassed() {
      const isPassedResult = await tran.isPassed(this.formData.transId);
      this.log("外形检测通过后:", isPassedResult);
    },
    // 更新入库标签打印中的“动态称重”
    async updatedYnamicWeight(plateCode, dynamicWeight) {
      return new Promise((resolve, reject) => {
        const url = "/api/wcs/updatedYnamicWeight";
        const params = {
          plateCode: plateCode,
          dynamicWeight: dynamicWeight,
          transId: this.formData.transId
        };
        this.common.ajax(
          url,
          params,
          async res => {
            this.log(res.msg);
            if (res.result) {
              const data = res.data;
              const isOverWeight = data.isOverWeight;
              if (isOverWeight === 0) {
                await tran.sendGoodsSize(this.formData.srmId, data);
              }
            }
            resolve(res);
          },
          true
        );
      });
    },
    // 判断外形检测通过后
 
    // 1.1.2.发送RGV运送指令
    async sendRgvCmd() {
      const isRgvReadyResult = await rgv.isRgvReady(this.formData.rgvId);
      this.log("判断对应RGV是否空闲:" + JSON.stringify(isRgvReadyResult));
      // int deviceId, int taskId, int sourcePlce, int toPlace, int taskType
      const sendRgvTaskResult = await rgv.sendRgvTask(4, 1, 66, 58, 1);
      this.log("RGV移动:" + JSON.stringify(sendRgvTaskResult));
      const isTaskFinishResult = await rgv.isTaskFinish(this.formData.rgvId);
      this.log("RGV运送任务完成:" + JSON.stringify(isTaskFinishResult));
      if (isTaskFinishResult.data.IsTaskFinishResult === "true") {
        const isRgvConfirmResult = await rgv.sendRgvFinishConfirm(this.formData.rgvId);
        this.log("RGV运送任务完成确认:" + JSON.stringify(isRgvConfirmResult));
      }
 
      // let result = await tran.isPassed(this.formData.srmId);
      // this.log("输送机外形检测是否完成:" + JSON.stringify(result));
 
      // result = await this.getRgvEnable(this.formData.srmId);
      // this.log("当前入库口RGV是否可用详情:" + JSON.stringify(result));
 
      // result = await rgv.getRgvInfo(this.formData.srmId);
      // this.log("对应RGV是否断线或报警详情:" + JSON.stringify(result));
 
      // result = await rgv.isTaskFinish(this.rgvId, this.formData.taskId);
      // this.log("对应RGV是否空闲详情:" + JSON.stringify(result));
    },
    // 获取RGV详细信息
    async getRgvInfo() {
      const result = await rgv.getRgvInfo(this.formData.rgvId);
      this.log("RGV设备详情:" + JSON.stringify(result));
    },
    // 当前入库口RGV是否可用:是否可用由WMS的设备管理中读取对应入库口的RGV的是否可用为“是”的
    async getRgvEnable(rgvId) {
      const result = await rgv.getRgvEnable(this.formData.rgvId);
      this.log("RGV设备详情:" + JSON.stringify(result));
    },
    // 1.1.2.4.RGV运送任务完成
    async checkRgvFinished() {
      const isTaskFinishResult = await rgv.isTaskFinish(this.formData.rgvId);
      this.log("RGV运送任务完成:" + JSON.stringify(isTaskFinishResult));
    },
    // 1.1.2.4.RGV运送任务完成
    async sendRgvFinishConfirm() {
      const isTaskFinishResult = await rgv.isTaskFinish(this.formData.rgvId);
      this.log("RGV运送任务完成:" + JSON.stringify(isTaskFinishResult));
      if (isTaskFinishResult.data.IsTaskFinishResult === "true") {
        const isRgvConfirmResult = await rgv.sendRgvFinishConfirm(this.formData.rgvId);
        this.log("RGV运送任务完成确认:" + JSON.stringify(isRgvConfirmResult));
      }
    },
    // 堆垛机移动
    async sendSrmTask() {
      const isReadyResult = await srm.isReady(this.formData.srmId);
      this.log("先判断堆垛机是否空闲:" + JSON.stringify(isReadyResult));
      const sendSrmTaskResult = await srm.sendSrmTask(2, 5930, "03-19-01", "03-19-03", 1);
      this.log("堆垛机移动:" + JSON.stringify(sendSrmTaskResult));
      const isTaskFinishResult = await srm.isTaskFinish(this.formData.srmId);
      this.log("堆垛机上架任务完成:" + JSON.stringify(isTaskFinishResult));
      if (isTaskFinishResult.data.IsTaskFinishResult === 1) {
        const isSrmConfirmResult = await srm.sendSrmTaskFinishConfirm(this.formData.srmId);
        this.log("堆垛机上架任务完成确认:" + JSON.stringify(isSrmConfirmResult));
      }
    },
    // 堆垛机上架任务完成
    async srmIsTaskFinish() {
      const isTaskFinishResult = await srm.isTaskFinish(this.formData.srmId);
      this.log("堆垛机上架任务完成:" + JSON.stringify(isTaskFinishResult));
      if (isTaskFinishResult.data.IsTaskFinishResult === 1) {
        const isSrmConfirmResult = await srm.sendSrmTaskFinishConfirm(this.formData.srmId);
        this.log("堆垛机上架任务完成确认:" + JSON.stringify(isSrmConfirmResult));
      }
    }
  }
};
</script>
 
<style lang="less" scoped>
@deep: ~">>>";
 
body {
  font-family: "Source Sans Pro", sans-serif;
}
 
#wrapper {
  padding: 10px;
}
 
#logo {
  height: auto;
  margin-bottom: 20px;
  width: 420px;
}
 
.scrollbar-box {
  border: 1px solid #efefef;
  margin-top: 10px;
  @{deep} .log-container.scrollbar-wrap {
    max-height: 600px;
    overflow-x: hidden;
    padding: 0px;
    .content-box {
      padding: 10px;
    }
  }
}
 
.left-side {
  display: flex;
  flex-direction: column;
}
 
.welcome {
  color: #555;
  font-size: 23px;
  margin-bottom: 10px;
}
 
.title {
  color: #2c3e50;
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 6px;
}
 
.title.alt {
  font-size: 18px;
  margin-bottom: 10px;
}
.doc {
  margin-bottom: 20px;
}
.doc p {
  color: black;
  margin-bottom: 10px;
}
.row {
  word-wrap: break-word;
}
</style>