Commit 68f68315 LN

AGV接口

1 个父辈 ac69a2c4
......@@ -442,5 +442,16 @@ public class InquiryShelfBean {
return null;
}
public static ShelfInfo findShelfByRealRfid(String realRfid){
for (Map<String, ShelfInfo> shelfInfoMap : hSerialShelfMap.values()) {
for (ShelfInfo shelf : shelfInfoMap.values()) {
String shelfRFID=shelf.getRealRfid();
if(shelfRFID.equals(realRfid)){
return shelf;
}
}
}
return null;
}
}
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.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 OutInfoCache outInfoCache;
protected final static Logger log = LogManager.getLogger(QisdaDeviceController.class);
/**
* 获取当前任务数及料架的剩余空位
* 参数: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)) {
Integer emptyPos=0;
for (String rfid : rfids.split(",")) {
ShelfInfo shelfInfo = InquiryShelfBean.findShelfByRealRfid(rfid);
if(shelfInfo != null){
Map<Integer, ShelfLoc> locMap = shelfInfo.getLocMap();
for (ShelfLoc shelfLoc : locMap.values()) {
if(shelfLoc.isEmpty()){
emptyPos++;
}
}
}else{
//空料架
emptyPos = 100;
}
Integer hSerialTaskCount = hSerialTaskMap.get(shelfInfo.gethSerial());
if(hSerialTaskCount == null){
emptyPos = 0;
}
rfidMap.put(rfid,emptyPos);
}
}
return ResultBean.newOkResult(rfidMap);
}catch(Exception e){
log.error("获取剩余任务数出错:rfids="+rfids,e);
return ResultBean.newErrorResult(500,e.getMessage());
}
}
/**
* 获取rfid目的地出错
* 参数:rfid 料架rfid
*/
@RequestMapping(value = "/getRfidTargetP")
@ResponseBody
public Object getRfidTargetP(HttpServletRequest request) {
String rfid = request.getParameter("rfid");
try {
if (!Strings.isBlank(rfid)) {
ShelfInfo shelf = InquiryShelfBean.findShelfByRealRfid(rfid);
if (shelf != null) {
String hSerial = shelf.gethSerial();
OutInfo outInfo = outInfoCache.getOutInfoFromCache(hSerial);
if (outInfo != null) {
String line= outInfo.getLine();
log.error("获取rfid目的地成功:rfid=" + rfid + ",line=" + line + "");
return ResultBean.newOkResult(line);
} else {
log.error("获取rfid目的地失败:rfid=" + rfid + ",hSerial=" + hSerial + ",未找到工单信息");
return ResultBean.newErrorResult(3001,"未找到工单信息");
}
} else {
log.error("获取rfid目的地失败:rfid=" + rfid + ",未找到料架信息");
return ResultBean.newErrorResult(3002,"未找到料架信息");
}
}
} catch (Exception e) {
log.error("获取rfid目的地出错:rfid=" + rfid, e);
return ResultBean.newErrorResult(500,e.getMessage());
}
}
/**
* 料架放上AGV时,根据RFID清理料架的缓存信息,使料架可以重复使用
*/
@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);
}
return ResultBean.newOkResult("料架放上AGV时,清理["+realRfid+"]的缓存信息成功");
}
}
......@@ -17,8 +17,22 @@
</sourceRoots>
</configuration>
</facet>
<facet type="jpa" name="JPA">
<configuration>
<setting name="validation-enabled" value="true" />
<setting name="provider-name" value="Hibernate" />
<datasource-mapping>
<factory-entry name="ApplicationEntityManager" />
</datasource-mapping>
<naming-strategy-map />
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" />
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
......@@ -29,6 +43,8 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.2.10-b140310.1920" level="project" />
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:2.2.10-b140310.1920" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-orm:4.1.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.1.6.RELEASE" level="project" />
......@@ -129,8 +145,9 @@
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-wsdl:3.0.1" level="project" />
<orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-databinding-jaxb:3.0.1" level="project" />
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.2.10-b140310.1920" level="project" />
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:2.2.10-b140310.1920" level="project" />
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.1.14" level="project" />
<orderEntry type="library" name="Maven: com.sun.xml.fastinfoset:FastInfoset:1.2.12" level="project" />
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:2.1.14" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-xml:3.0.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-simple:3.0.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-addr:3.0.1" level="project" />
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!