QisdaDeviceController.java
27.2 KB
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
package com.myproject.webapp.controller.webService;
import com.myproject.bean.CodeBean;
import com.myproject.bean.qisda.*;
import com.myproject.bean.update.Barcode;
import com.myproject.bean.update.DataLog;
import com.myproject.bean.update.Storage;
import com.myproject.bean.update.qisda.OutInfo;
import com.myproject.bean.update.qisda.OutItem;
import com.myproject.dao.mongo.IDataLogDao;
import com.myproject.dao.mongo.IStoragePosDao;
import com.myproject.dao.mongo.qisda.IOutInfoDao;
import com.myproject.dao.mongo.qisda.IOutItemDao;
import com.myproject.manager.IBarcodeManager;
import com.myproject.manager.IComponentManager;
import com.myproject.util.StorageConstants;
import com.myproject.webapp.controller.storage.BaseController;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@Controller
@RequestMapping("/rest/api/qisda/device")
public class QisdaDeviceController extends BaseController {
@Autowired
protected ITaskService taskService;
@Autowired
protected IComponentManager componentManager;
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private IStoragePosDao storagePosDao;
@Autowired
private DataCache dataCache;
@Autowired
private IDataLogDao dataLogDao;
@Autowired
private IOutInfoDao outInfoDao;
@Autowired
private IOutItemDao outItemDao;
protected final static Logger log = LogManager.getLogger(QisdaDeviceController.class);
/**
* 需求单料架管理map, key为outInquiryId, value为料架信息
*/
InquiryShelfBean inquiryShelfBean = new InquiryShelfBean();
/**
* 第一台机器人缓存位置信息(流水线扫码后获取尺寸时更新)
*/
private DataLog firstRobotTask = null;
private DataLog firstScanTask = null;
/**
* 第二台机器人缓存位置信息(流水线扫码后获取尺寸时更新)
*/
private DataLog secondRobotTask = null;
private DataLog secondScanTask = null;
/**
* 流水线根据条码及机器人工位获取尺寸信息,同时为料盘锁定架位
*/
@RequestMapping(value = "/getSize")
@ResponseBody
public ResultBean getSize(HttpServletRequest request) {
try{
String robotIndex = request.getParameter("robotIndex");
String barcodeStr = request.getParameter("barcode");
log.info("料盘到达机器人["+robotIndex+"]扫码位置,开始获取["+ barcodeStr +"]的尺寸信息");
if(robotIndex == null){
return ResultBean.newErrorResult(-2, "参数错误:无robotIndex参数");
}
if(!robotIndex.equals("1") && !robotIndex.equals("2")){
return ResultBean.newErrorResult(-2, "参数错误:robotIndex参数只能为1或2");
}
//清空扫码缓存信息
updateScanTask(robotIndex, null);
Collection<CodeBean> codeBeans = dataCache.resolveCodeStr(barcodeStr);
Barcode barcode = null;
for (CodeBean codeBean : codeBeans) {
if(codeBean.isValid()){
if(barcode == null){
barcode = codeBean.getBarcode();
}else{
String msg = "找到多个有效的条码";
log.error(msg);
return ResultBean.newErrorResult(101, msg);
}
}
}
if(barcode == null){
String msg = "未找到有效的条码";
log.error(msg);
return ResultBean.newErrorResult(102, msg);
}
DataLog task = taskService.getFinishedTask(barcode.getBarcode());
if(task == null){
String msg = "未找到待分配位置的条码["+barcode.getBarcode()+"]尺寸信息";
log.error(msg);
return ResultBean.newErrorResult(103, msg);
}
updateScanTask(robotIndex, task);
log.info("返回机器人["+robotIndex+"]barcode=["+task.getBarcode()+"]的尺寸:" + task.getW());
return ResultBean.newOkResult(task.getW() + "");
}catch(Exception e){
log.error("流水线获取尺寸信息出错",e);
return ResultBean.newErrorResult(-1,"流水线获取尺寸信息内部错误:" + e.getMessage());
}
}
/**
* 更新相机扫码任务
* @param robotIndex
* @param task
*/
private void updateScanTask(String robotIndex, DataLog task){
if(robotIndex != null){
if(robotIndex.equals("1")){
//1号位机器人
firstScanTask = task;
}else if(robotIndex.equals("2")){
secondScanTask = task;
}
}
}
/**
* 相机扫码获取完尺寸后,料盘到达机器人取料位置
*/
@RequestMapping(value = "/arriveRobotLocation")
@ResponseBody
public Object arriveRobot(HttpServletRequest request){
String robotIndex = request.getParameter("robotIndex");
//更新位置任务,清空扫码任务
log.info("料盘到达机器人["+robotIndex+"]取料位置,更新位置任务,清空扫码任务");
if(robotIndex != null){
if(robotIndex.equals("1")){
//1号位机器人
firstRobotTask = firstScanTask;
}else if(robotIndex.equals("2")){
secondRobotTask = secondScanTask;
}
updateScanTask(robotIndex, null);
}
return "";
}
/**
* 3号机器人获取摆放位置信息
*/
@RequestMapping(value = "/getPackageLocation")
@ResponseBody
public Object getPackageLocation(HttpServletRequest request) {
try{
String bigRfid = request.getParameter("bigRfid");
//包装料RFID
String packageRfid = request.getParameter("packageRfid");
log.info("收到包装料摆放位置信息请求:[packageRfid=" + packageRfid + "]bigRfid=" + bigRfid);
ShelfInfo packageShelf = inquiryShelfBean.findPackageShelf(packageRfid);
ShelfInfo bigShelf = inquiryShelfBean.findBigShelf(bigRfid);
if(bigShelf != null){
Collection<DataLog> queueTasks = taskService.getQueueTasks();
List<DataLog> allTasks = taskService.getFinishedTasks();
if(!queueTasks.isEmpty()){
allTasks.addAll(queueTasks);
}
//剩余包装料任务
int packageTask = 0;
for (DataLog task : allTasks) {
if(!task.isFinished() && !task.isCancel() && task.isCheckOutTask()){
if(task.isPackageReel()){
if(!task.isCutReel()){
packageTask = packageTask + 1;
}
}
}
}
String barcode = "";
String packageLoc = "";
int reelInPackage = 0;
if(packageShelf == null){
log.info("未找到包装料架["+packageRfid+"]的信息");
}else{
//查找包装料架上的物料
Map<Integer, ShelfLoc> packageLocMap = packageShelf.getLocMap();
for (ShelfLoc shelfLoc : packageLocMap.values()) {
if(!shelfLoc.isEmpty()){
reelInPackage = reelInPackage + 1;
if(barcode.isEmpty()){
barcode = shelfLoc.getBarcode();
packageLoc = shelfLoc.getLoc() + "";
}
}
}
}
AppendInfo taskAppendInfo = null;
if(!barcode.isEmpty()){
//包装料架上有料,且大料架有空位,从大料架上查找空位
DataLog task = taskService.getFinishedTask(barcode);
if(task == null){
String msg = "未找到待包装料架上条码["+barcode+"]的任务";
log.error(msg);
return ResultBean.newErrorResult(103, msg);
}
taskAppendInfo = task.getAppendInfo();
}
//当前大料架上空位数
int emptyInBig = 0;
String bigLoc = "";
Map<Integer, ShelfLoc> bigShelfLocMap = bigShelf.getLocMap();
for (ShelfLoc shelfLoc : bigShelfLocMap.values()) {
//这里不能使用包装料的数量(补料盘的料架没有固定位置,不是包装料类型)
if(shelfLoc.isEmpty()){
emptyInBig = emptyInBig + 1;
if(taskAppendInfo != null){
//找到了包装料架上物料的任务才能查找位置
if(bigLoc.isEmpty()){
if(taskAppendInfo.isFirstReelAction()){
//首套料,需要固定位置
if(shelfLoc.isInThisLoc(barcode)){
bigLoc = shelfLoc.getLoc() + "";
}
}else{
//尾料,不需要固定位置
bigLoc = shelfLoc.getLoc() + "";
}
}
}
}
}
if(packageTask == 0){
log.info("已无包装料任务,更改料架可放包装料数量"+ emptyInBig + "为0");
//emptyInBig = 0;
}
Map<String,Object> resultMap = new HashMap<>();
resultMap.put("barcode", barcode);
//大料架上可放包装料数量
resultMap.put("emptyInBig", emptyInBig+ "");
//包装料架上剩余的包装料数量(包含当前获取的物料)
resultMap.put("reelInPackage", reelInPackage +"");
resultMap.put("packageTask", packageTask +"");
resultMap.put("packageRfid", packageRfid);
resultMap.put("packageLoc", packageLoc);
resultMap.put("bigRfid", bigRfid);
resultMap.put("bigLoc", bigLoc);
log.info("大料架信息返回:"+resultMap);
return ResultBean.newOkResult(resultMap);
}else{
return ResultBean.newErrorResult(-2, "未找到大料架["+bigRfid+"]");
}
}catch(Exception e){
log.error("包装料摆放位置信息获取出错",e);
return ResultBean.newErrorResult(-1,"包装料摆放位置信息获取出错:" + e.getMessage());
}
}
/**
* 1号2号机器人根据工位获取摆放位置信息
*/
@RequestMapping(value = "/getLocation")
@ResponseBody
public Object getLocation(HttpServletRequest request) {
try{
String robotIndex = request.getParameter("robotIndex");
String rfid = request.getParameter("rfid");
log.info("机器人["+robotIndex+"]获取摆放位置信息请求:rfid=" + rfid);
if(robotIndex == null){
return ResultBean.newErrorResult(-2, "参数错误:无robotIndex参数");
}
if(!robotIndex.equals("1") && !robotIndex.equals("2")){
return ResultBean.newErrorResult(-2, "参数错误:robotIndex参数只能为1或2");
}
if(rfid == null){
return ResultBean.newErrorResult(-2, "参数错误:无rfid参数");
}
DataLog task = null;
if(robotIndex != null){
if(robotIndex.equals("1")){
//1号位机器人
task = firstRobotTask;
}else if(robotIndex.equals("2")){
task = secondRobotTask;
}
}
if(task == null){
String msg = "机器人["+robotIndex+"]无缓存位置信息";
log.info(msg);
return ResultBean.newErrorResult(201, msg);
}
AppendInfo appendInfo = task.getAppendInfo();
ShelfLoc shelfLoc = null;
if(appendInfo.isFirstReelAction()){
//首盘料已经固定好库位了
shelfLoc = inquiryShelfBean.getLimitLoc(task);
}else{
shelfLoc = inquiryShelfBean.lockShelfLoc(task, rfid, robotIndex);
}
if(shelfLoc == null){
String msg = "机器人["+robotIndex+"]获取料架["+rfid+"]位置信息失败";
log.info(msg);
return ResultBean.newErrorResult(202, msg);
}
appendInfo.setRfid(shelfLoc.getRfid());
appendInfo.setRfidLoc(shelfLoc.getLoc());
task.setAppendInfo(appendInfo);
task.setStatus(StorageConstants.OP_STATUS.INROBOT.name());
task.setLocInfo(robotIndex);
task = dataLogDao.save(task);
taskService.updateFinishedTask(task);
Map<String,Object> resultMap = new HashMap<>();
resultMap.put("barcode", task.getBarcode());
resultMap.put("w", task.getW()+ "");
resultMap.put("h", task.getH() +"");
resultMap.put("rfid", shelfLoc.getRfid());
resultMap.put("rfidLoc", shelfLoc.getLoc() + "");
log.info("机器人["+robotIndex+"]位置信息返回:[rfid=" + shelfLoc.getRfid() + "["+shelfLoc.getLoc()+"] barcode=["+task.getBarcode()+"]尺寸"+task.getW()+"x"+task.getH());
return ResultBean.newOkResult(resultMap);
}catch(Exception e){
log.error("获取摆放位置信息出错",e);
return ResultBean.newErrorResult(-1,"获取摆放位置信息出错:" + e.getMessage());
}
}
/**
* 更新位置信息
*/
@RequestMapping(value = "/updateLocInfo")
@ResponseBody
public ResultBean updateLocInfo(HttpServletRequest request) {
String barcode = request.getParameter("barcode");
String statusStr = request.getParameter("status");
String locInfo = request.getParameter("locInfo");
log.info("收到料盘["+barcode+"]更新位置指令["+statusStr+"]=" + locInfo);
DataLog task = taskService.getFinishedTask(barcode);
if(task == null){
log.info("未从缓存中找到条码["+barcode+"]的任务信息,从数据库中查询");
task = dataLogDao.findLatestOutTask(barcode);
}
if(task == null){
log.error("料盘["+barcode+"]的任务不存在");
return ResultBean.newErrorResult(301, "任务不存在");
}
statusStr = statusStr.toUpperCase();
log.info("更新料盘的任务状态["+task.getStatus()+"=" + task.getLocInfo() + "]为["+statusStr+"="+locInfo+"]");
task.setStatus(statusStr);
task.setLocInfo(locInfo);
task = dataLogDao.save(task);
taskService.updateFinishedTask(task);
return ResultBean.newOkResult("");
}
/**
* 料盘放入料架时,更新信息
* @param cacheTask 条码任务
* @param rfid 料架RFID
* @param rfidLoc 料架位置
*/
private void reelPutInFinished(DataLog cacheTask, String rfid, String rfidLoc){
if(cacheTask != null){
cacheTask.setStatus(StorageConstants.OP_STATUS.FINISHED.name());
AppendInfo appendInfo = cacheTask.getAppendInfo();
appendInfo.setRfid(rfid);
appendInfo.setRfidLoc(Integer.valueOf(rfidLoc));
cacheTask.setAppendInfo(appendInfo);
cacheTask = dataLogDao.save(cacheTask);
taskService.updateFinishedTask(cacheTask);
inquiryShelfBean.putInShelf(cacheTask,rfid, Integer.valueOf(rfidLoc));
String hSerial = appendInfo.gethSerial();
if(Strings.isNotBlank(hSerial)){
OutInfo outInfo = outInfoDao.findByHSerial(hSerial);
if(outInfo != null){
outInfo.setTaskFinishNum(outInfo.getTaskFinishNum() + 1);
log.info("需求单["+outInfo.gethSerial()+"]任务完成数量:" + outInfo.getTaskFinishNum() + "/" + outInfo.getTaskNum() + "已出仓料盘数量:" + outInfo.getOutReelNum());
outInfo = outInfoDao.save(outInfo);
if(cacheTask.isUrgentReel() || cacheTask.isCutReel()){
log.info("分盘料和紧急料不需要通知Qisda");
}else{
if(DataCache.isProductionFor(DataCache.CUSTOMER.QISDA)){
Barcode barcodeObj = barcodeManager.findByBarcode(cacheTask.getBarcode());
if(barcodeObj.needToQisda()){
String latest = outInfo.getShelfLatest();
QisdaApiController.VMIMateriaRecAss(cacheTask, barcodeObj,latest);
//发料完成,更新发料数量
int slotSeq = appendInfo.getSlotIndex();
OutItem outItem = outItemDao.findItem(hSerial, slotSeq);
int sendQty = outItem.getSendQty();
sendQty = sendQty + cacheTask.getNum();
outItem.setSendQty(sendQty);
outItemDao.save(outItem);
}else{
log.info("放置小车完成,条码["+barcodeObj.getBarcode()+"]不需要通知Qisda");
}
}else{
log.info("放置小车完成通知Qisda接口关闭");
}
}
}
}
}
}
/**
* 包装线机器人从A包装料架放到C大料架上barcode
*/
@RequestMapping(value = "/putPackageFinished")
@ResponseBody
public Object putPackageFinished(HttpServletRequest request) {
//A料架肯定要存在
String packageRfid = request.getParameter("packageRfid");
String bigRfid = request.getParameter("bigRfid");
String packageLoc = request.getParameter("packageLoc");
String bigLoc = request.getParameter("bigLoc");
String barcode = request.getParameter("barcode");
log.info("收到包装线机器人放置料盘["+barcode+"]完成请求"+packageRfid+"["+packageLoc+"]=>"+bigRfid+"["+bigLoc+"]");
if(Strings.isNotBlank(barcode)) {
DataLog cacheTask = taskService.getFinishedTask(barcode);
if (cacheTask == null) {
return ResultBean.newErrorResult(501,"料盘[" + barcode + "]的任务不存在");
} else {
reelPutInFinished(cacheTask,bigRfid, bigLoc);
//清理包装料架的位置
ShelfInfo packageShelf = inquiryShelfBean.findPackageShelf(packageRfid);
if(packageShelf != null){
Map<Integer, ShelfLoc> packageLocMap = packageShelf.getLocMap();
for (ShelfLoc shelfLoc : packageLocMap.values()) {
if(shelfLoc.isInThisLoc(barcode)){
shelfLoc.setEmpty(true);
packageLocMap.put(shelfLoc.getLoc(), shelfLoc);
packageShelf.setLocMap(packageLocMap);
inquiryShelfBean.updateShelfInfo(packageShelf);
return ResultBean.newOkResult(null);
}
}
}else{
return ResultBean.newErrorResult(502,"包装料盘[" + barcode + "]放入完成时,未找到包装料架["+packageRfid+"]的缓存信息");
}
}
}
String msg = "包装线机器人放置料盘["+barcode+"]从"+packageRfid+"["+packageLoc+"]=>"+bigRfid+"["+bigLoc+"]失败";
return ResultBean.newErrorResult(501,msg);
}
/**
* 放置到料架动作完成,返回当前料架还可放置的数量,用任务总数
*/
@RequestMapping(value = "/putShelfFinished")
@ResponseBody
public Object putShelfFinished(HttpServletRequest request) {
try{
String robotIndex = request.getParameter("robotIndex");
String rfid = request.getParameter("rfid");
String rfidLoc = request.getParameter("rfidLoc");
String barcode = request.getParameter("barcode");
DataLog cacheTask = null;
if(Strings.isNotBlank(barcode)) {
cacheTask = taskService.getFinishedTask(barcode);
if (cacheTask == null) {
log.error("料盘[" + barcode + "]的任务不存在");
} else {
if(Strings.isNotBlank(robotIndex)){
if(robotIndex.equals("1") && firstRobotTask != null){
if(firstRobotTask.getBarcode().equals(barcode)){
log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,任务一致,清空机器人任务");
//1号位机器人
firstRobotTask = null;
}else{
log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,与当前任务["+firstScanTask.getBarcode()+"]不一致,不清空");
}
}else if(robotIndex.equals("2") && secondRobotTask != null){
if(secondRobotTask.getBarcode().equals(barcode)){
//1号位机器人
log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,任务一致,清空机器人任务");
secondRobotTask = null;
}else{
log.info("机器人["+robotIndex+"]将料盘["+barcode+"]放入料架["+rfid+"]["+rfidLoc+"]完成,与当前任务["+firstScanTask.getBarcode()+"]不一致,不清空");
}
}
}
reelPutInFinished(cacheTask,rfid, rfidLoc);
}
}
int packageTask = 0;
int cutPackageTask = 0;
int cutTask = 0;
int smallTask = 0;
int bigTask = 0;
Collection<DataLog> queueTasks = taskService.getQueueTasks();
List<DataLog> allTasks = taskService.getFinishedTasks();
if(!queueTasks.isEmpty()){
allTasks.addAll(queueTasks);
}
int totalTaskCount = 0;
for (DataLog task : allTasks) {
if(!task.isFinished() && !task.isCancel() && task.isCheckOutTask()){
totalTaskCount = totalTaskCount + 1;
if(task.isPackageReel()){
if(task.isCutReel()){
cutPackageTask = cutPackageTask + 1;
}else{
packageTask = packageTask + 1;
}
}else if(task.isCutReel() || task.isUrgentReel()){
cutTask = cutTask + 1;
}else if(task.isSmallReel()){
smallTask = smallTask + 1;
}else{
bigTask = bigTask + 1;
}
}
}
//当前料架还可放入的料盘数
int smallEmpty = 0;
int bigEmpty = 0;
int packageEmpty = 0;
if(cacheTask != null ){
AppendInfo appendInfo = cacheTask.getAppendInfo();
String hSerial = appendInfo.gethSerial();
ShelfInfo shelfInfo = inquiryShelfBean.findSameShelf(hSerial,rfid);
if(shelfInfo != null){
Map<Integer, ShelfLoc> locMap = shelfInfo.getLocMap();
for (ShelfLoc shelfLoc : locMap.values()) {
if(shelfLoc.isEmpty()){
if(shelfLoc.isSmallLoc()){
smallEmpty = smallEmpty + 1;
}else if(shelfLoc.isBigLoc()){
bigEmpty = bigEmpty + 1;
}else if(shelfLoc.isPackageLoc()){
//首套料,需要按顺序
if(appendInfo.isFirstReelAction()){
packageEmpty = packageEmpty + 1;
}else{
//补料盘不需要按顺序,具体还可以放多少,到包装料工位再确定
bigEmpty = bigEmpty + 1;
}
}
}
}
}
}
//剩余的任务数
Map<String,Object> resultMap = new HashMap<>();
if(cacheTask == null){
resultMap.put("barcode","");
}else{
resultMap.put("barcode",cacheTask.getBarcode());
}
resultMap.put("rfid", rfid);
resultMap.put("smallEmpty", smallEmpty + "");
resultMap.put("bigEmpty", bigEmpty + "");
resultMap.put("packageEmpty", packageEmpty + "");
resultMap.put("cutPackageTask", cutPackageTask + "");
resultMap.put("packageTask", packageTask + "");
resultMap.put("cutTask", cutTask + "");
resultMap.put("smallTask", smallTask + "");
resultMap.put("bigTask", bigTask + "");
log.info("当前任务数:" + resultMap);
return ResultBean.newOkResult(resultMap);
}catch(Exception e){
log.error("机器人放料完成信息出错",e);
}
return "";
}
/**
* 包装料仓空闲仓位数量
*/
@RequestMapping(value = "/emptyStoragePosCount")
@ResponseBody
public Object emptyStoragePosCount(HttpServletRequest request) {
Map<String,Object> resultMap = new HashMap<>();
try {
Map<String, Storage> allStorage = dataCache.getAllStorage();
for (Storage storage : allStorage.values()) {
if(storage.isPackage()){
//包装料仓
resultMap.put(storage.getCid(), storage.getEmptySlots()+"");
}
}
}catch (Exception e){
log.error("获取包装料仓空闲仓位出错",e);
}
return ResultBean.newOkResult(resultMap);
}
}