...
|
...
|
@@ -34,11 +34,12 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) { |
|
|
if collectionTime.IsZero() {
|
|
|
return
|
|
|
}
|
|
|
var mBytes []byte
|
|
|
for key, item := range payload {
|
|
|
if key == "WorkShop" || key == "UpTime" {
|
|
|
continue
|
|
|
}
|
|
|
mBytes, err := json.Marshal(item)
|
|
|
mBytes, err = json.Marshal(item)
|
|
|
if err != nil {
|
|
|
continue
|
|
|
}
|
...
|
...
|
@@ -49,11 +50,16 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) { |
|
|
StartupStatus: gjson.Get(string(message.Payload()), key+".StartupState").Int(),
|
|
|
ComStatus: gjson.Get(string(message.Payload()), key+".ComStatus").Int(),
|
|
|
}
|
|
|
if utils.SubStr(key, 0, 4) == domain.DeviceTypeMianBaoXieJi {
|
|
|
deviceCollection.DeviceType = domain.DeviceTypeMianBaoXieJi
|
|
|
} else {
|
|
|
deviceType4 := utils.SubStr(key, 0, 4)
|
|
|
deviceType := utils.SubStr(key, 0, 3)
|
|
|
deviceCollection.DeviceType = deviceType
|
|
|
|
|
|
if deviceType4 == domain.DeviceTypeMianBaoXieJi {
|
|
|
deviceCollection.DeviceType = domain.DeviceTypeMianBaoXieJi
|
|
|
}
|
|
|
if deviceType == domain.DeviceTypeYouZhaJi {
|
|
|
deviceType = deviceType4
|
|
|
}
|
|
|
switch deviceType {
|
|
|
//包馅机
|
|
|
case domain.DeviceTypeBaoXianJi:
|
...
|
...
|
@@ -121,15 +127,15 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) { |
|
|
break
|
|
|
//打浆机 //面包屑机
|
|
|
case domain.DeviceTypeDaJiangJi:
|
|
|
case domain.DeviceTypeChuanChuanJi:
|
|
|
break
|
|
|
default:
|
|
|
}
|
|
|
if deviceType != domain.DeviceTypeChuanChuanJi {
|
|
|
continue
|
|
|
}
|
|
|
//if deviceType != domain.DeviceTypeChuanChuanJi {
|
|
|
// continue
|
|
|
//}
|
|
|
// 发送数据
|
|
|
deviceCollectionService := service.NewDeviceCollectionService(nil)
|
|
|
_, err := deviceCollectionService.CreateDeviceCollection(&command.CreateDeviceCollectionCommand{
|
|
|
_, err = deviceCollectionService.CreateDeviceCollection(&command.CreateDeviceCollectionCommand{
|
|
|
WorkShopName: deviceCollection.WorkShopName,
|
|
|
StartupStatus: deviceCollection.StartupStatus,
|
|
|
CollectionTime: deviceCollection.CollectionTime,
|
...
|
...
|
@@ -143,12 +149,14 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) { |
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//TODO:日志先注释
|
|
|
//log.Logger.Info("MQTT", map[string]interface{}{
|
|
|
// "Topic": message.Topic(),
|
|
|
// "MessageId": message.MessageID(),
|
|
|
// "Message": payload,
|
|
|
//})
|
|
|
if err == nil {
|
|
|
log.Logger.Info("MQTT", map[string]interface{}{
|
|
|
"Topic": message.Topic(),
|
|
|
"MessageId": message.MessageID(),
|
|
|
"Message": payload,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |
...
|
...
|
|