Commit 7d9bb3e1 authored by 赵啸非's avatar 赵啸非

添加设备上线和下线的业务日志记录

parent 197939ae
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("访问异常");
}
};
}
}
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment