Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit dc46c783
由
LN
编写于
2023-06-06 10:20:00 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
部分mes对接代码
1 个父辈
23ed044d
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
483 行增加
和
66 行删除
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
src/main/java/com/neotel/smfcore/common/mqtt/MqttboundConfiguration.java
src/main/java/com/neotel/smfcore/core/api/SmfApi.java
src/main/java/com/neotel/smfcore/core/api/listener/BaseSmfApiListener.java
src/main/java/com/neotel/smfcore/core/api/listener/ISmfApiListener.java
src/main/java/com/neotel/smfcore/core/device/rest/DeviceController.java
src/main/java/com/neotel/smfcore/core/shelf/TaskShelfUtil.java
src/main/java/com/neotel/smfcore/core/shelf/rest/AgvShelfController.java
src/main/java/com/neotel/smfcore/core/system/util/DevicesStatusUtil.java
src/main/java/com/neotel/smfcore/custom/gree20242/GreeApiHandler.java
src/main/java/com/neotel/smfcore/custom/gree20242/GreeDeviceController.java
src/main/java/com/neotel/smfcore/custom/gree20242/GreeApi.java → src/main/java/com/neotel/smfcore/custom/gree20242/api/GreeApi.java
src/main/java/com/neotel/smfcore/custom/gree20242/api/GreeMsgCache.java
src/main/java/com/neotel/smfcore/custom/gree20242/api/GreeMsgHandlerImpl.java
src/main/java/com/neotel/smfcore/custom/gree20242/bean/GreeRequestMsg.java
src/main/java/com/neotel/smfcore/custom/gree20242/bean/GreeResponseMsg.java
src/main/resources/config/application.yml
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
查看文件 @
dc46c78
...
...
@@ -115,7 +115,7 @@ public class DataInitManager {
TaskShelfUtil
.
dataCache
=
dataCache
;
TaskShelfUtil
.
init
ShelfMap
();
TaskShelfUtil
.
init
Data
();
}
catch
(
Exception
exception
)
{
log
.
error
(
"初始化环境出错..."
+
exception
.
toString
(),
exception
);
...
...
src/main/java/com/neotel/smfcore/common/mqtt/MqttboundConfiguration.java
查看文件 @
dc46c78
package
com
.
neotel
.
smfcore
.
common
.
mqtt
;
import
com.neotel.smfcore.custom.gree20242.api.GreeMsgHandlerImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttConnectOptions
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -15,11 +16,8 @@ import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
import
org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter
;
import
org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler
;
import
org.springframework.integration.mqtt.support.DefaultPahoMessageConverter
;
import
org.springframework.integration.mqtt.support.MqttHeaders
;
import
org.springframework.messaging.Message
;
import
org.springframework.messaging.MessageChannel
;
import
org.springframework.messaging.MessageHandler
;
import
org.springframework.messaging.MessagingException
;
/**
...
...
@@ -73,29 +71,33 @@ public class MqttboundConfiguration {
log
.
info
(
"inbound:监听topic:"
+
mqttProperties
.
getTopics
());
return
adapter
;
}
@Bean
@ServiceActivator
(
inputChannel
=
"mqttInputChannel"
)
public
MessageHandler
mqttHandler
(
GreeMsgHandlerImpl
messageHandler
)
{
return
message
->
messageHandler
.
handleMessage
(
message
);
}
//通过通道获取数据
@Bean
@ServiceActivator
(
inputChannel
=
"mqttInputChannel"
)
//异步处理
public
MessageHandler
handler
()
{
return
new
MessageHandler
()
{
@Override
public
void
handleMessage
(
Message
<?>
message
)
throws
MessagingException
{
// System.out.println("message:"+message);
log
.
info
(
"---------handleMessage-------------"
);
log
.
info
(
"收到消息:message:"
+
message
.
getPayload
());
log
.
info
(
"收到消息:PacketId:"
+
message
.
getHeaders
().
getId
());
log
.
info
(
"收到消息:Qos:"
+
message
.
getHeaders
().
get
(
MqttHeaders
.
QOS
));
String
topic
=
(
String
)
message
.
getHeaders
().
get
(
MqttHeaders
.
RECEIVED_TOPIC
);
log
.
info
(
"收到消息:topic:"
+
topic
);
}
};
}
// //通过通道获取数据
// @Bean
// @ServiceActivator(inputChannel = "mqttInputChannel") //异步处理
// public MessageHandler handler() {
// return new MessageHandler() {
// @Override
// public void handleMessage(Message<?> message) throws MessagingException {
//// System.out.println("message:"+message);
// log.info("---------handleMessage-------------");
// log.info("收到消息:message:"+message.getPayload());
// log.info("收到消息:PacketId:"+message.getHeaders().getId());
// log.info("收到消息:Qos:"+message.getHeaders().get(MqttHeaders.QOS));
//
// String topic = (String) message.getHeaders().get(MqttHeaders.RECEIVED_TOPIC);
// log.info("收到消息:topic:"+topic);
//
// }
// };
// }
@Bean
@ServiceActivator
(
inputChannel
=
"mqttOutboundChannel"
)
...
...
src/main/java/com/neotel/smfcore/core/api/SmfApi.java
查看文件 @
dc46c78
...
...
@@ -76,6 +76,9 @@ public class SmfApi {
@Value
(
"${api.fetchOrderUrl:}"
)
protected
String
fetchOrderUrl
=
""
;
@Value
(
"${api.arriveLineUrl:}"
)
protected
String
arriveLineUrl
=
""
;
@PostConstruct
public
void
init
(){
apiName
=
dataCache
.
getConfigCache
(
"api.name"
,
apiName
);
...
...
@@ -89,6 +92,7 @@ public class SmfApi {
fetchInListUrl
=
dataCache
.
getConfigCache
(
"api.fetchInListUrl"
,
fetchInListUrl
);
fetchOrderUrl
=
dataCache
.
getConfigCache
(
"api.fetchOrderUrl"
,
fetchOrderUrl
);
loginCheckUrl
=
dataCache
.
getConfigCache
(
"api.loginCheckUrl"
,
loginCheckUrl
);
arriveLineUrl
=
dataCache
.
getConfigCache
(
"api.arriveLineUrl"
,
arriveLineUrl
);
}
/**
...
...
@@ -238,6 +242,24 @@ public class SmfApi {
}
return
true
;
}
public
void
shelfArriveLine
(
LiteOrder
liteOrder
,
String
shelfId
)
throws
ValidateException
{
if
(
shelfId
==
null
||
liteOrder
==
null
)
{
return
;
}
if
(
isUrlExist
(
arriveLineUrl
))
{
for
(
ISmfApiListener
apiListener
:
apiListenerList
)
{
if
(
apiListener
.
isForThisApi
(
apiName
))
{
try
{
apiListener
.
shelfArriveLine
(
arriveLineUrl
,
liteOrder
,
shelfId
);
}
catch
(
Exception
e
)
{
throw
new
ValidateException
(
"smfcore.api.error"
,
"API Error:"
+
e
.
getMessage
());
}
}
}
}
}
/**
* 判断URL是否存在,如果不存在不需要进行发送
* @param url
...
...
src/main/java/com/neotel/smfcore/core/api/listener/BaseSmfApiListener.java
查看文件 @
dc46c78
...
...
@@ -114,6 +114,10 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
public
boolean
canLogin
(
String
loginCheckUrl
,
String
userName
,
String
pwd
)
throws
ValidateException
{
return
true
;
}
@Override
public
void
shelfArriveLine
(
String
arriveLineUrl
,
LiteOrder
liteOrder
,
String
shelfId
)
{
}
protected
String
getData
(
Map
<
String
,
Object
>
dataMap
,
String
dataKey
)
{
Object
data
=
dataMap
.
get
(
dataKey
);
if
(
data
==
null
)
{
...
...
src/main/java/com/neotel/smfcore/core/api/listener/ISmfApiListener.java
查看文件 @
dc46c78
...
...
@@ -61,4 +61,12 @@ public interface ISmfApiListener {
* 是否可以登陆
*/
boolean
canLogin
(
String
loginCheckUrl
,
String
userName
,
String
pwd
)
throws
ValidateException
;
/**
* 料架到达产线
* @param arriveLineUrl
* @param liteOrder
* @param shelfId
*/
void
shelfArriveLine
(
String
arriveLineUrl
,
LiteOrder
liteOrder
,
String
shelfId
)
;
}
src/main/java/com/neotel/smfcore/core/device/rest/DeviceController.java
查看文件 @
dc46c78
...
...
@@ -629,4 +629,25 @@ public class DeviceController {
data
.
put
(
"plateH"
,
pos
.
getBarcode
().
getHeight
()
+
""
);
return
ResultBean
.
newOkResult
(
data
);
}
@ApiOperation
(
"更新设备数据"
)
@PostMapping
(
value
=
"/updateData"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
updateData
(
HttpServletRequest
request
)
{
String
key
=
request
.
getParameter
(
"key"
);
Object
value
=
request
.
getParameter
(
"value"
);
DevicesStatusUtil
.
updateDData
(
key
,
value
);
return
ResultBean
.
newOkResult
(
key
);
}
@ApiOperation
(
"获取设备数据"
)
@PostMapping
(
value
=
"/getData"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
getData
(
HttpServletRequest
request
)
{
String
key
=
request
.
getParameter
(
"key"
);
Object
value
=
DevicesStatusUtil
.
getDDate
(
key
);
return
ResultBean
.
newOkResult
(
value
);
}
}
src/main/java/com/neotel/smfcore/core/shelf/TaskShelfUtil.java
查看文件 @
dc46c78
...
...
@@ -27,12 +27,35 @@ public class TaskShelfUtil {
*/
public
static
Map
<
String
,
Map
<
String
,
ShelfInfo
>>
taskShelfMap
=
null
;
public
static
Map
<
String
,
String
>
shelfLocMap
=
null
;
private
static
String
HSERIAL_SHELF_MAP_KEY
=
"HSERIAL_SHELF_MAP_KEY"
;
private
static
String
SHELF_LOC_MAP_KEY
=
"SHELF_LOC_MAP_KEY"
;
private
static
String
DEFAULT_ORDERNO
=
"1"
;
public
static
void
initData
(){
initShelfMap
();
initShelfLocMap
();
}
private
static
void
initShelfLocMap
()
{
if
(
shelfLocMap
==
null
)
{
shelfLocMap
=
dataCache
.
getCache
(
SHELF_LOC_MAP_KEY
);
if
(
shelfLocMap
==
null
){
shelfLocMap
=
new
ConcurrentHashMap
<>();
}
}
}
private
static
void
saveShelfLocMap
(
Map
<
String
,
String
>
map
)
{
dataCache
.
updateCache
(
SHELF_LOC_MAP_KEY
,
map
);
}
p
ublic
static
void
initShelfMap
()
{
p
rivate
static
void
initShelfMap
()
{
if
(
taskShelfMap
==
null
)
{
taskShelfMap
=
dataCache
.
getCache
(
HSERIAL_SHELF_MAP_KEY
);
if
(
taskShelfMap
==
null
){
...
...
@@ -418,4 +441,12 @@ public class TaskShelfUtil {
}
return
null
;
}
public
static
void
updateShelfLoc
(
String
rfid
,
String
loc
){
shelfLocMap
.
put
(
rfid
,
loc
);
saveShelfLocMap
(
shelfLocMap
);
}
}
src/main/java/com/neotel/smfcore/core/shelf/rest/AgvShelfController.java
0 → 100644
查看文件 @
dc46c78
package
com
.
neotel
.
smfcore
.
core
.
shelf
.
rest
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.core.api.SmfApi
;
import
com.neotel.smfcore.core.order.LiteOrderCache
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.core.shelf.TaskShelfUtil
;
import
com.neotel.smfcore.core.shelf.bean.ShelfInfo
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
@Slf4j
@RestController
@Api
(
tags
=
"20242:格力agv取放料架接口"
)
@RequestMapping
(
"/rest/api/agv"
)
public
class
AgvShelfController
{
@Autowired
private
LiteOrderCache
liteOrderCache
;
@Autowired
private
SmfApi
smfApi
;
@ApiOperation
(
"agv获取指定料架的目标位置"
)
@PostMapping
(
value
=
"/getShelfTargetLoc"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
getShelfTargetLoc
(
HttpServletRequest
request
)
{
String
rfid
=
request
.
getParameter
(
"rfid"
);
ShelfInfo
shelfInfo
=
TaskShelfUtil
.
findShelfByRealRfid
(
rfid
);
if
(
shelfInfo
!=
null
)
{
String
orderNo
=
shelfInfo
.
getOrderNo
();
LiteOrder
order
=
liteOrderCache
.
getLiteOrder
(
orderNo
);
if
(
order
!=
null
)
{
String
line
=
order
.
getLine
();
log
.
info
(
"getShelfTargetLoc 料架 ,rfid=["
+
rfid
+
"],目标位置:["
+
line
+
"]"
);
return
ResultBean
.
newOkResult
(
line
);
}
}
else
{
log
.
info
(
"getShelfTargetLoc 未找到料架 ,rfid=["
+
rfid
+
"]"
);
}
return
ResultBean
.
newErrorResult
(
99
,
"smfcore.agvShelf.noLoc"
,
"未找到料架{0}目标位置"
,
new
String
[]{
rfid
});
}
@ApiOperation
(
"料架到达产线位置"
)
@PostMapping
(
value
=
"/shelfArriveLine"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
shelfArriveLine
(
HttpServletRequest
request
)
{
String
rfid
=
request
.
getParameter
(
"rfid"
);
String
loc
=
request
.
getParameter
(
"loc"
);
ShelfInfo
shelfInfo
=
TaskShelfUtil
.
findShelfByRealRfid
(
rfid
);
if
(
shelfInfo
!=
null
)
{
}
else
{
log
.
info
(
"updateShelfLoc 未找到料架 ,rfid=["
+
rfid
+
"]"
);
return
ResultBean
.
newErrorResult
(
99
,
"smfcore.agvShelf.noshelf"
,
"未找到料架{0}"
,
new
String
[]{
rfid
});
}
//更新记录
TaskShelfUtil
.
updateShelfLoc
(
rfid
,
loc
);
log
.
info
(
"updateShelfLoc 更新料架【"
+
rfid
+
"】位置=【"
+
loc
+
"】"
);
String
orderNo
=
shelfInfo
.
getOrderNo
();
LiteOrder
order
=
liteOrderCache
.
getLiteOrder
(
orderNo
);
if
(
order
!=
null
)
{
//如果目标位置是产线,通知mes
smfApi
.
shelfArriveLine
(
order
,
rfid
);
}
return
ResultBean
.
newOkResult
(
"ok"
);
}
}
src/main/java/com/neotel/smfcore/core/system/util/DevicesStatusUtil.java
查看文件 @
dc46c78
...
...
@@ -9,6 +9,7 @@ import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -221,4 +222,13 @@ public class DevicesStatusUtil {
log
.
error
(
"设备状态定时器执行出错:"
,
ex
);
}
}
private
static
Map
<
String
,
Object
>
deviceClientDataMap
=
new
HashMap
<>();
public
static
void
updateDData
(
String
key
,
Object
value
){
deviceClientDataMap
.
put
(
key
,
value
);
}
public
static
Object
getDDate
(
String
key
)
{
Object
value
=
deviceClientDataMap
.
getOrDefault
(
key
,
""
);
return
value
;
}
}
src/main/java/com/neotel/smfcore/custom/gree20242/GreeApiHandler.java
deleted
100644 → 0
查看文件 @
23ed044
package
com
.
neotel
.
smfcore
.
custom
.
gree20242
;
import
org.springframework.stereotype.Service
;
@Service
public
class
GreeApiHandler
{
}
src/main/java/com/neotel/smfcore/custom/gree20242/GreeDeviceController.java
0 → 100644
查看文件 @
dc46c78
package
com
.
neotel
.
smfcore
.
custom
.
gree20242
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
@Slf4j
@RestController
@Api
(
tags
=
"20242:格力流水线设备接口"
)
@RequestMapping
(
"/rest/gree/device"
)
public
class
GreeDeviceController
{
@Autowired
private
TaskService
taskService
;
@Autowired
private
DataCache
dataCache
;
@ApiOperation
(
"更新任务状态"
)
@PostMapping
(
value
=
"/updateLocInfo"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
updateLocInfo
(
HttpServletRequest
request
)
{
String
taskId
=
request
.
getParameter
(
"taskId"
);
String
barcode
=
request
.
getParameter
(
"barcode"
);
String
statusStr
=
request
.
getParameter
(
"status"
);
String
locInfo
=
request
.
getParameter
(
"locInfo"
);
log
.
info
(
"收到taskId["
+
taskId
+
"],料盘["
+
barcode
+
"]更新位置指令["
+
statusStr
+
"]="
+
locInfo
);
if
(
ObjectUtil
.
isEmpty
(
locInfo
))
{
locInfo
=
statusStr
;
}
DataLog
opTask
=
null
;
List
<
DataLog
>
allTasks
=
taskService
.
getAllTasks
();
for
(
DataLog
task
:
allTasks
)
{
if
(
task
.
isFinished
())
{
continue
;
}
if
(
ObjectUtil
.
isNotEmpty
(
task
)
&&
task
.
getId
().
equals
(
taskId
))
{
opTask
=
task
;
break
;
}
else
if
(
ObjectUtil
.
isNotEmpty
(
barcode
)
&&
task
.
getBarcode
().
equals
(
barcode
))
{
opTask
=
task
;
break
;
}
}
//如果任务为空,重新查找已完成的任务
if
(
opTask
==
null
)
{
for
(
DataLog
task
:
allTasks
)
{
if
(
ObjectUtil
.
isNotEmpty
(
task
)
&&
task
.
getId
().
equals
(
taskId
))
{
opTask
=
task
;
break
;
}
else
if
(
ObjectUtil
.
isNotEmpty
(
barcode
)
&&
task
.
getBarcode
().
equals
(
barcode
))
{
opTask
=
task
;
break
;
}
}
}
if
(
opTask
==
null
)
{
log
.
info
(
" taskId["
+
taskId
+
"],料盘["
+
barcode
+
"]更新位置指令["
+
statusStr
+
"]="
+
locInfo
+
",失败:任务不存在"
);
return
ResultBean
.
newErrorResult
(
301
,
"smfcore.task.notExist"
,
"任务不存在"
);
}
if
(
opTask
.
isFinished
())
{
log
.
info
(
" taskId["
+
taskId
+
"],料盘["
+
barcode
+
"]更新位置指令["
+
statusStr
+
"]="
+
locInfo
+
",失败:任务已完成"
);
return
ResultBean
.
newErrorResult
(
302
,
"smfcore.task.hasEnd"
,
"任务已完成"
);
}
if
(
opTask
.
isCancel
())
{
return
ResultBean
.
newErrorResult
(
303
,
"smfcore.task.hasCancel"
,
"更新状态时{0}的任务[{1}]已被取消"
,
new
String
[]{
opTask
.
getBarcode
(),
opTask
.
getId
()});
}
statusStr
=
statusStr
.
toUpperCase
();
String
inouType
=
opTask
.
isCheckOutTask
()
?
"出库"
:
"入库"
;
//若已经在此状态,不需要再更新
if
(
opTask
.
getStatus
().
equals
(
statusStr
)
&&
opTask
.
getLocInfo
().
equals
(
locInfo
))
{
log
.
warn
(
"更新料盘["
+
barcode
+
"]的["
+
inouType
+
"]任务状态已是["
+
opTask
.
getStatus
()
+
"="
+
opTask
.
getLocInfo
()
+
"]不需要重复更新为["
+
statusStr
+
"="
+
locInfo
+
"]"
);
}
else
{
log
.
info
(
"更新料盘["
+
barcode
+
"]的["
+
inouType
+
"]任务状态["
+
opTask
.
getStatus
()
+
"="
+
opTask
.
getLocInfo
()
+
"]为["
+
statusStr
+
"="
+
locInfo
+
"]"
);
opTask
.
setStatus
(
statusStr
);
opTask
.
setLocInfo
(
locInfo
);
if
(
opTask
.
isPutInTask
())
{
taskService
.
updateQueueTask
(
opTask
);
}
else
{
if
(
opTask
.
isFinished
())
{
taskService
.
removeQueueTask
(
opTask
);
}
taskService
.
updateFinishedTask
(
opTask
);
}
// try{
// if (opTask.isInRobot() || opTask.isInLine() || opTask.isBoxdoor()) {
// //保存状态
// MaterialLog m = new MaterialLog(opTask.getBarcode(), opTask.getPosName(), opTask.getType(), opTask.getStatus(), opTask.getLocInfo());
// log.info("记录料盘[" + inouType + "]日志[" + m.getBarcode() + "," + m.getPosName() + "," + m.getStatus() + "," + m.getLocInfo() + "]");
//
// materialLogManager.save(m);
// }}catch (Exception ex){
// log.info("记录料盘[" + inouType + "]日志[" + opTask.getBarcode() + "," + opTask.getPosName() + "," + opTask.getStatus() + "," + opTask.getLocInfo() + "]出错:"+ex.getMessage());
// }
}
return
ResultBean
.
newOkResult
(
""
);
}
@ApiOperation
(
"料盘到达出料机构入口"
)
@PostMapping
(
value
=
"/reelArriveOutBound"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
reelArriveOutBound
(
HttpServletRequest
request
)
{
String
barcode
=
request
.
getParameter
(
"barcode"
);
String
statusStr
=
request
.
getParameter
(
"status"
);
//OUTBOUND
if
(
ObjectUtil
.
isEmpty
(
statusStr
)){
statusStr
=
"OUTBOUND"
;
}
String
locInfo
=
request
.
getParameter
(
"locInfo"
);
//1=上层,2=下层,
log
.
info
(
"收到 reelArriveOutBound 料盘["
+
barcode
+
"]更新位置指令["
+
statusStr
+
"]="
+
locInfo
);
String
key
=
"OUTBOUND_IN_"
+
locInfo
+
"_REEL_KEY"
;
dataCache
.
updateCache
(
key
,
barcode
);
return
ResultBean
.
newOkResult
(
""
);
}
@ApiOperation
(
"获取出料机构入口的料"
)
@PostMapping
(
value
=
"/reelArriveOutBound"
)
@ResponseBody
@AnonymousAccess
public
ResultBean
getOutBoundReel
(
HttpServletRequest
request
)
{
String
statusStr
=
request
.
getParameter
(
"status"
);
//OUTBOUND
String
locInfo
=
request
.
getParameter
(
"locInfo"
);
//1=上层,2=下层,
String
key
=
"OUTBOUND_IN_"
+
locInfo
+
"_REEL_KEY"
;
String
barcode
=
dataCache
.
getCache
(
key
);
return
ResultBean
.
newOkResult
(
barcode
);
}
}
src/main/java/com/neotel/smfcore/custom/gree20242/GreeApi.java
→
src/main/java/com/neotel/smfcore/custom/gree20242/
api/
GreeApi.java
查看文件 @
dc46c78
package
com
.
neotel
.
smfcore
.
custom
.
gree20242
;
package
com
.
neotel
.
smfcore
.
custom
.
gree20242
.
api
;
import
com.neotel.smfcore.common.mqtt.MqttGateway
;
import
com.neotel.smfcore.common.utils.JsonUtil
;
import
com.neotel.smfcore.core.api.listener.BaseSmfApiListener
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.custom.gree20242.bean.GreeRequestMsg
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.HashMap
;
import
java.util.Map
;
@Slf4j
public
class
GreeApi
extends
BaseSmfApiListener
{
@Override
public
boolean
isForThisApi
(
String
apiName
)
{
return
apiName
!=
null
&&
apiName
.
equalsIgnoreCase
(
"20242"
);
}
@Autowired
private
MqttGateway
mqttGateway
;
@Override
public
void
inTaskStatusChange
(
String
inNotifyUrl
,
DataLog
task
)
{
if
(
task
.
isPutInTask
()
&&
task
.
isFinished
())
{
...
...
@@ -23,39 +31,46 @@ public class GreeApi extends BaseSmfApiListener {
params
.
put
(
"slot"
,
task
.
getPosName
());
params
.
put
(
"deviceId"
,
task
.
getStorageId
());
GreeRequestMsg
msg
=
GreeRequestMsg
.
newMsg
(
inNotifyUrl
,
params
);
boolean
result
=
SendMsg
(
inNotifyUrl
,
msg
);
boolean
result
=
SendMsg
(
inNotifyUrl
,
msg
);
}
}
@Override
public
void
onOrderStatusChange
(
String
orderNotifyUrl
,
LiteOrder
liteOrder
)
{
Map
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"shelfId"
,
liteOrder
.
getOrderNo
()
);
params
.
put
(
"hSerial
"
,
liteOrder
.
getOrderNo
());
params
.
put
(
"so"
,
liteOrder
.
getS
o
());
params
.
put
(
"line"
,
liteOrder
.
getLine
());
if
(
liteOrder
.
isClosed
()||
liteOrder
.
isTaskFinished
())
{
Map
<
String
,
String
>
params
=
new
HashMap
<>(
);
params
.
put
(
"shelfId
"
,
liteOrder
.
getOrderNo
());
params
.
put
(
"hSerial"
,
liteOrder
.
getOrderN
o
());
params
.
put
(
"so"
,
liteOrder
.
getSo
());
params
.
put
(
"line"
,
liteOrder
.
getLine
());
GreeRequestMsg
msg
=
GreeRequestMsg
.
newMsg
(
orderNotifyUrl
,
params
);
boolean
result
=
SendMsg
(
orderNotifyUrl
,
msg
);
GreeRequestMsg
msg
=
GreeRequestMsg
.
newMsg
(
orderNotifyUrl
,
params
);
boolean
result
=
SendMsg
(
orderNotifyUrl
,
msg
);
}
}
public
void
ShelfArriveLine
(
String
arriveLineUrl
,
LiteOrder
liteOrder
)
{
@Override
public
void
shelfArriveLine
(
String
arriveLineUrl
,
LiteOrder
liteOrder
,
String
shelfId
)
{
Map
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"shelfId"
,
liteOrder
.
getOrderNo
()
);
params
.
put
(
"shelfId"
,
shelfId
);
params
.
put
(
"hSerial"
,
liteOrder
.
getOrderNo
());
params
.
put
(
"so"
,
liteOrder
.
getSo
());
params
.
put
(
"line"
,
liteOrder
.
getLine
());
GreeRequestMsg
msg
=
GreeRequestMsg
.
newMsg
(
arriveLineUrl
,
params
);
boolean
result
=
SendMsg
(
arriveLineUrl
,
msg
);
boolean
result
=
SendMsg
(
arriveLineUrl
,
msg
);
}
public
boolean
SendMsg
(
String
url
,
GreeRequestMsg
msg
)
{
public
boolean
SendMsg
(
String
url
,
GreeRequestMsg
msg
Bean
)
{
return
true
;
//url地址配置为发送主题
String
msg
=
JsonUtil
.
toJsonStr
(
msgBean
);
mqttGateway
.
sendToMqtt
(
url
,
msg
);
log
.
info
(
"GreeApi SendMsg: topic=["
+
url
+
"],sendData="
+
msg
);
GreeMsgCache
.
addSendMsg
(
msgBean
);
return
true
;
}
}
src/main/java/com/neotel/smfcore/custom/gree20242/api/GreeMsgCache.java
0 → 100644
查看文件 @
dc46c78
package
com
.
neotel
.
smfcore
.
custom
.
gree20242
.
api
;
import
com.neotel.smfcore.custom.gree20242.bean.GreeRequestMsg
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
GreeMsgCache
{
private
static
Map
<
String
,
GreeRequestMsg
>
sendEndMsgMap
=
new
HashMap
<>();
private
static
Map
<
String
,
GreeRequestMsg
>
sendMsgMap
=
new
HashMap
<>();
public
static
void
addSendMsg
(
GreeRequestMsg
msg
){
sendMsgMap
.
put
(
msg
.
getId
(),
msg
);
}
public
static
boolean
isSendId
(
String
id
){
GreeRequestMsg
msg
=
sendMsgMap
.
get
(
id
);
if
(
msg
!=
null
){
//放入发送结束的msg
sendEndMsgMap
.
put
(
id
,
msg
);
return
true
;
}
return
false
;
}
}
src/main/java/com/neotel/smfcore/custom/gree20242/api/GreeMsgHandlerImpl.java
0 → 100644
查看文件 @
dc46c78
此文件的差异被折叠,
点击展开。
src/main/java/com/neotel/smfcore/custom/gree20242/bean/GreeRequestMsg.java
查看文件 @
dc46c78
...
...
@@ -5,21 +5,30 @@ import lombok.Data;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.UUID
;
@Data
public
class
GreeRequestMsg
implements
Serializable
{
public
class
GreeRequestMsg
<
T
>
implements
Serializable
{
public
static
GreeRequestMsg
newMsg
(
String
suject
,
Map
<
String
,
String
>
params
){
public
static
String
getUUID
()
{
System
.
out
.
println
(
UUID
.
randomUUID
());
String
uuid
=
UUID
.
randomUUID
().
toString
().
trim
().
replaceAll
(
"-"
,
""
);
return
uuid
;
}
public
static
GreeRequestMsg
newMsg
(
String
suject
,
Object
params
){
GreeRequestMsg
msg
=
new
GreeRequestMsg
()
;
msg
.
setSpecVersion
(
"1.0"
);
msg
.
setType
(
"com.github.pull_request.opened"
);
msg
.
setSource
(
"https://github.com/cloudevents/spec/pull"
);
msg
.
setSubject
(
"pull_request"
);
msg
.
setDatacontentType
(
"application/json"
);
msg
.
setSubject
(
suject
);
msg
.
setData
(
params
);
String
time
=
DateUtil
.
toDateString
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
String
uid
=
DateUtil
.
toDateString
(
new
Date
(),
"yyyyMMddHHmmss"
);
//
String uid=DateUtil.toDateString(new Date(),"yyyyMMddHHmmss");
msg
.
setTime
(
time
);
msg
.
setId
(
uid
);
msg
.
setId
(
getUUID
()
);
return
msg
;
}
...
...
@@ -29,33 +38,35 @@ public class GreeRequestMsg implements Serializable {
/**
* specVersion CloudEvents 规范版本 String 是"1.0"
*/
private
String
specVersion
=
"1.0"
;
private
String
specVersion
;
/**
* type 事件类型 String 是 com.github.pull_request.opened
*/
private
String
type
=
"com.github.pull_request.opened"
;
private
String
type
;
/**
* source 事件来源上下文 String 是 https://github.com/cloudevents/spec/pull
*/
private
String
source
=
"https://github.com/cloudevents/spec/pull"
;
private
String
source
;
/**
* subject 事件主题 String 是 pull_request
*/
private
String
subject
=
"pull_request"
;
private
String
subject
;
/**
* id 事件 ID String 是 UUID 标识唯一
*/
private
String
id
=
"UUID 标识唯一"
;
private
String
id
;
/**
* time 事件时间 String 是 格式:yyyy-MM-dd HH:mm:ss
*/
private
String
time
=
"格式:yyyy-MM-dd HH:mm:ss"
;
private
String
time
;
/**
* datacontentType 数据格式类型 String 是 application/json
*/
private
String
datacontentType
=
"application/json"
;
private
String
datacontentType
;
/**
*
*/
private
Map
<
String
,
String
>
data
=
new
HashMap
<>();
private
T
data
;
}
src/main/java/com/neotel/smfcore/custom/gree20242/bean/GreeResponseMsg.java
查看文件 @
dc46c78
package
com
.
neotel
.
smfcore
.
custom
.
gree20242
.
bean
;
import
com.neotel.smfcore.common.utils.DateUtil
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
public
class
GreeResponseMsg
implements
Serializable
{
public
class
GreeResponseMsg
<
T
>
implements
Serializable
{
/**
* id 事件 ID String 是 与请求的事件 ID 一一对应
...
...
@@ -17,7 +20,7 @@ public class GreeResponseMsg implements Serializable {
/**
* code 结果码 Integer 是 0=成功, 其他为失败(如1001为参数错误)
*/
private
String
code
;
private
Integer
code
=-
1
;
/**
* message 消息内容 String 是 消息内容
*/
...
...
@@ -25,5 +28,22 @@ public class GreeResponseMsg implements Serializable {
/**
* data 返回的数据 Object 是 JSON 格式
*/
private
String
data
;
private
T
data
;
public
static
GreeResponseMsg
newOkMsg
(
GreeRequestMsg
requestMsg
,
Object
data
){
return
GreeResponseMsg
.
newMsg
(
requestMsg
,
0
,
""
,
data
);
}
public
static
GreeResponseMsg
newMsg
(
GreeRequestMsg
requestMsg
,
Integer
code
,
String
message
,
Object
data
){
GreeResponseMsg
msg
=
new
GreeResponseMsg
();
msg
.
setCode
(
code
);
if
(
requestMsg
!=
null
)
{
msg
.
setId
(
requestMsg
.
getId
());
}
String
time
=
DateUtil
.
toDateString
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
msg
.
setFeedbackTime
(
time
);
msg
.
setData
(
data
);
msg
.
setMessage
(
message
);
return
msg
;
}
}
src/main/resources/config/application.yml
查看文件 @
dc46c78
...
...
@@ -7,6 +7,19 @@ api:
outNotifyUrl
:
inNotifyUrl
:
#mqtt配置
com
:
mqtt
:
url
:
tcp://127.0.0.1:1883
clientId
:
mqtt_smf-core_20242
topics
:
topic01,topic02
username
:
admin
password
:
admin
timeout
:
10
keepalive
:
20
hella
:
#host: 127.0.0.1
#port: 3333
...
...
@@ -34,6 +47,7 @@ spring:
encoding
:
utf-8
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
#密码加密传输,前端公钥加密,后端私钥解密
rsa
:
...
...
@@ -48,3 +62,5 @@ menu:
show
:
hide
:
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论