Commit 6da6770a authored by 赵啸非's avatar 赵啸非

添加线程发送消息

parent 8b0152f2
......@@ -49,6 +49,7 @@ import com.mortals.xhx.module.workman.service.WorkmanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -75,6 +76,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Autowired
private RoleUserService roleUserService;
@Lazy
@Autowired
private IUserFeign userFeign;
......
package com.mortals.xhx.feign.smartoffice;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.feign.IFeign;
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;
/**
* 服务系统 Feign接口
*
* @author zxfei
* @date 2022-10-26
*/
@FeignClient(name = "smart-office-manager", path = "/office", fallbackFactory = SmartSystemFeignFallbackFactory.class)
public interface ISmartSystemFeign extends IFeign {
/**
* 用户刷新通知
*
* @param
* @return
*/
@PostMapping(value = "/user/refreshUser")
Rest<Void> refreshUser();
}
@Slf4j
@Component
class SmartSystemFeignFallbackFactory implements FallbackFactory<ISmartSystemFeign> {
@Override
public ISmartSystemFeign create(Throwable t) {
return new ISmartSystemFeign() {
/**
* @return
*/
@Override
public Rest<Void> refreshUser() {
return Rest.fail("暂时无法通知设备,请稍后再试!");
}
};
}
}
......@@ -5,6 +5,7 @@ import com.mortals.xhx.feign.device.IDeviceFeign;
import com.mortals.xhx.feign.selfsystem.ISelfSystemFeign;
import com.mortals.xhx.feign.skin.ISkinFillFeign;
import com.mortals.xhx.feign.skin.ISkinSampleFeign;
import com.mortals.xhx.feign.smartoffice.ISmartSystemFeign;
import com.mortals.xhx.utils.SpringUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
......@@ -24,6 +25,7 @@ public class SendSubSystemTask implements Runnable {
private ISkinSampleFeign skinSampleFeign;
private ISkinFillFeign skinFillFeign;
private ISelfSystemFeign selfSystemFeign;
private ISmartSystemFeign smartSystemFeign;
public SendSubSystemTask() {
apiAreaFeign = SpringUtils.getBean(IApiAreaFeign.class);
......@@ -31,6 +33,7 @@ public class SendSubSystemTask implements Runnable {
skinSampleFeign = SpringUtils.getBean(ISkinSampleFeign.class);
skinFillFeign = SpringUtils.getBean(ISkinFillFeign.class);
selfSystemFeign = SpringUtils.getBean(ISelfSystemFeign.class);
smartSystemFeign = SpringUtils.getBean(ISmartSystemFeign.class);
}
@Override
......@@ -46,6 +49,8 @@ public class SendSubSystemTask implements Runnable {
skinFillFeign.refreshUser();
Thread.sleep(2000);
selfSystemFeign.refreshUser();
Thread.sleep(2000);
smartSystemFeign.refreshUser();
} catch (Exception e) {
log.error("通知异常:", e);
}
......
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