GreeDeviceController.java
5.6 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
package com.myproject.webapp.controller.webService;
import com.google.common.collect.Lists;
import com.myproject.bean.qisda.InquiryShelfBean;
import com.myproject.bean.qisda.ResultBean;
import com.myproject.bean.qisda.ShelfInfo;
import com.myproject.bean.qisda.ShelfLoc;
import com.myproject.bean.update.DataLog;
import com.myproject.bean.update.Storage;
import com.myproject.bean.update.qisda.OutInfo;
import com.myproject.dao.mongo.qisda.IOutInfoDao;
import com.myproject.util.StorageConstants;
import com.myproject.webapp.controller.qisda.util.OutInfoCache;
import org.apache.cxf.jaxws.handler.types.CString;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.Strings;
import org.apache.poi.util.Internal;
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.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/rest/api/dcs/device")
public class GreeDeviceController {
@Autowired
protected ITaskService taskService;
@Autowired
private IOutInfoDao outInfoDao;
@Autowired
private OutInfoCache outInfoCache;
protected final static Logger log = LogManager.getLogger(QisdaDeviceController.class);
/**
* /rest/api/dcs/device/getShelfEmptySlot
* 获取当前任务数及料架的剩余空位
* 参数:rfids 料架rfid列表,逗号分割,未发送rfids只返回当前剩余任务数量
*/
@RequestMapping(value = "/getShelfEmptySlot")
@ResponseBody
public Object getTaskInfo(HttpServletRequest request) {
String rfids = request.getParameter("rfids");
try{
List<DataLog> allTasks = taskService.getAllTasks();
Map<String,Integer> hSerialTaskMap = new HashMap<>();
for (DataLog task : allTasks) {
if (!task.isFinished() && !task.isCancel() && task.isCheckOutTask()) {
String hSerial = task.getAppendInfo().gethSerial();
Integer taskCount = hSerialTaskMap.get(hSerial);
if(taskCount == null){
taskCount = 0;
}
taskCount ++;
hSerialTaskMap.put(hSerial,taskCount);
}
}
String hSerial = QisdaCache.getCurrentOrderHSerial();
List<String> usedRfidList = InquiryShelfBean.getUsedRfidList(hSerial);
Map<String,Integer> rfidMap = new HashMap<>();
if (!Strings.isBlank(rfids)) {
for (String rfid : rfids.split(",")) {
Integer emptyPos=0;
ShelfInfo shelfInfo = InquiryShelfBean.findShelfByRealRfid(rfid);
if (shelfInfo != null) {
Map<Integer, ShelfLoc> locMap = shelfInfo.getLocMap();
for (ShelfLoc shelfLoc : locMap.values()) {
if (shelfLoc.isEmpty()) {
emptyPos++;
}
}
Integer hSerialTaskCount = hSerialTaskMap.get(shelfInfo.gethSerial());
if (hSerialTaskCount == null) {
emptyPos = 0;
}
} else {
//空料架
emptyPos = 100;
}
rfidMap.put(rfid,emptyPos);
}
}
return ResultBean.newOkResult(rfidMap);
}catch(Exception e){
log.error("获取剩余任务数出错:rfids="+rfids,e);
return ResultBean.newErrorResult(500,e.getMessage());
}
}
/**
* /rest/api/dcs/device/getRfidTargetP
* 获取rfid目的地
* 参数:rfid 料架rfid
* 返回 json格式:
* code: 结果码,0为正常,其他值表示异常
* msg:提示信息 ok为成功,其他表示异常
* data:表示目标位置
*/
@RequestMapping(value = "/shelfDestination")
@ResponseBody
public Object getRfidTargetP(HttpServletRequest request) {
String realRfid = request.getParameter("rfid");
String hSerial = QisdaCache.getShelfHSerial(realRfid);
String destination = "NONE";
if(hSerial != null){
OutInfo outInfo = outInfoDao.findByHSerial(hSerial);
if(outInfo != null){
destination = outInfo.getLine();
}
}
return ResultBean.newOkResult(destination);
}
/**
* /rest/api/dcs/device/agvRemoveRfid
* 料架放上AGV时,根据RFID清理料架的缓存信息,使料架可以重复使用
* 参数:rfid 料架rfid
* 返回 json格式:
* code: 结果码,0为正常,其他值表示异常
* msg:提示信息 ok为成功,其他表示异常
* data:
*/
@RequestMapping(value = "/agvRemoveRfid")
@ResponseBody
public ResultBean agvRemoveRfid(HttpServletRequest request){
String realRfid = request.getParameter("rfid");
log.info("料架放上AGV时,清理["+realRfid+"]的缓存信息");
if(Strings.isNotBlank(realRfid)){
InquiryShelfBean.agvRemoveRfid(realRfid);
QisdaCache.removeShelfHSerial(realRfid);
}
return ResultBean.newOkResult("料架放上AGV时,清理["+realRfid+"]的缓存信息成功");
}
}