Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
7d9bb3e1
Commit
7d9bb3e1
authored
1 year ago
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加设备上线和下线的业务日志记录
parent
197939ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
1 deletion
+75
-1
common-lib/src/main/java/com/mortals/xhx/feign/IFillDeviceFeign.java
...src/main/java/com/mortals/xhx/feign/IFillDeviceFeign.java
+56
-0
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+19
-1
No files found.
common-lib/src/main/java/com/mortals/xhx/feign/IFillDeviceFeign.java
0 → 100644
View file @
7d9bb3e1
package
com.mortals.xhx.feign
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.xhx.common.pdu.DeviceReq
;
import
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
* 设备 Feign接口
*
* @author zxfei
* @date 2023-02-25
*/
@FeignClient
(
name
=
"fill-manager"
,
path
=
"/fm"
,
fallbackFactory
=
FillDeviceFeignFallbackFactory
.
class
)
public
interface
IFillDeviceFeign
extends
IFeign
{
/**
* 设备回调
*
* @param deviceReq
* @return
*/
@PostMapping
(
value
=
"/api/device/callback"
)
Rest
<
String
>
deviceCall
(
@RequestBody
DeviceReq
deviceReq
);
}
@Slf4j
@Component
class
FillDeviceFeignFallbackFactory
implements
FallbackFactory
<
IFillDeviceFeign
>
{
@Override
public
IFillDeviceFeign
create
(
Throwable
t
)
{
return
new
IFillDeviceFeign
()
{
@Override
public
Rest
<
String
>
deviceCall
(
DeviceReq
deviceReq
)
{
return
Rest
.
fail
(
"访问异常"
);
}
};
}
}
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
7d9bb3e1
...
...
@@ -21,7 +21,9 @@ import com.mortals.xhx.common.model.MessageHeader;
import
com.mortals.xhx.common.pdu.DeviceReq
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.feign.IFillDeviceFeign
;
import
com.mortals.xhx.feign.IOfficeDeviceFeign
;
import
com.mortals.xhx.feign.ISampleDeviceFeign
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.device.dao.DeviceDao
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
...
...
@@ -84,6 +86,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
private
MessageService
messageService
;
@Autowired
private
IOfficeDeviceFeign
officeDeviceFeign
;
@Autowired
private
ISampleDeviceFeign
sampleDeviceFeign
;
@Autowired
private
IFillDeviceFeign
fillDeviceFeign
;
@Value
(
"${thirdPartyPath:/inter/device/deviceIn}"
)
private
String
thirdPartyPath
;
...
...
@@ -340,7 +346,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override
public
Rest
<
String
>
sendThirdParty
(
DeviceEntity
entity
,
ProductEntity
productEntity
,
PlatformEntity
platformEntity
,
DeviceMethodEnum
update
)
{
//todo 修改为异步发送消息,当前消息存放到redis的队列中
//todo 修改为异步发送消息,当前消息存放到redis的队列中
DeviceReq
deviceReq
=
new
DeviceReq
();
BeanUtils
.
copyProperties
(
entity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
deviceReq
.
setDeviceStatus
(
update
.
getValue
());
...
...
@@ -354,6 +360,18 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//todo 调用智慧办公系统
Rest
<
String
>
officeRest
=
officeDeviceFeign
.
deviceCall
(
deviceReq
);
log
.
info
(
"office resp ==>{}"
,
JSON
.
toJSONString
(
officeRest
));
}
if
(
"ybxt"
.
equals
(
platformEntity
.
getPlatformSn
()))
{
deviceReq
.
setReceiveMethod
(
update
.
getValue
());
//调用样表系统系统
Rest
<
String
>
sampleRest
=
sampleDeviceFeign
.
deviceCall
(
deviceReq
);
log
.
info
(
"sample resp ==>{}"
,
JSON
.
toJSONString
(
sampleRest
));
}
if
(
"tdxt"
.
equals
(
platformEntity
.
getPlatformSn
()))
{
deviceReq
.
setReceiveMethod
(
update
.
getValue
());
//调用样表系统系统
Rest
<
String
>
fillRest
=
fillDeviceFeign
.
deviceCall
(
deviceReq
);
log
.
info
(
"fill resp ==>{}"
,
JSON
.
toJSONString
(
fillRest
));
}
else
{
cacheService
.
lpush
(
RedisKey
.
KEY_DEVICE_THIRDPARTY_QUEUE
,
deviceReq
);
// log.info("lpush:{}",lpush);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment