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

添加线程发送消息

parent 8b0152f2
...@@ -49,6 +49,7 @@ import com.mortals.xhx.module.workman.service.WorkmanService; ...@@ -49,6 +49,7 @@ import com.mortals.xhx.module.workman.service.WorkmanService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -75,6 +76,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -75,6 +76,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Autowired @Autowired
private RoleUserService roleUserService; private RoleUserService roleUserService;
@Lazy
@Autowired @Autowired
private IUserFeign userFeign; 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; ...@@ -5,6 +5,7 @@ import com.mortals.xhx.feign.device.IDeviceFeign;
import com.mortals.xhx.feign.selfsystem.ISelfSystemFeign; import com.mortals.xhx.feign.selfsystem.ISelfSystemFeign;
import com.mortals.xhx.feign.skin.ISkinFillFeign; import com.mortals.xhx.feign.skin.ISkinFillFeign;
import com.mortals.xhx.feign.skin.ISkinSampleFeign; import com.mortals.xhx.feign.skin.ISkinSampleFeign;
import com.mortals.xhx.feign.smartoffice.ISmartSystemFeign;
import com.mortals.xhx.utils.SpringUtils; import com.mortals.xhx.utils.SpringUtils;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -24,6 +25,7 @@ public class SendSubSystemTask implements Runnable { ...@@ -24,6 +25,7 @@ public class SendSubSystemTask implements Runnable {
private ISkinSampleFeign skinSampleFeign; private ISkinSampleFeign skinSampleFeign;
private ISkinFillFeign skinFillFeign; private ISkinFillFeign skinFillFeign;
private ISelfSystemFeign selfSystemFeign; private ISelfSystemFeign selfSystemFeign;
private ISmartSystemFeign smartSystemFeign;
public SendSubSystemTask() { public SendSubSystemTask() {
apiAreaFeign = SpringUtils.getBean(IApiAreaFeign.class); apiAreaFeign = SpringUtils.getBean(IApiAreaFeign.class);
...@@ -31,6 +33,7 @@ public class SendSubSystemTask implements Runnable { ...@@ -31,6 +33,7 @@ public class SendSubSystemTask implements Runnable {
skinSampleFeign = SpringUtils.getBean(ISkinSampleFeign.class); skinSampleFeign = SpringUtils.getBean(ISkinSampleFeign.class);
skinFillFeign = SpringUtils.getBean(ISkinFillFeign.class); skinFillFeign = SpringUtils.getBean(ISkinFillFeign.class);
selfSystemFeign = SpringUtils.getBean(ISelfSystemFeign.class); selfSystemFeign = SpringUtils.getBean(ISelfSystemFeign.class);
smartSystemFeign = SpringUtils.getBean(ISmartSystemFeign.class);
} }
@Override @Override
...@@ -46,6 +49,8 @@ public class SendSubSystemTask implements Runnable { ...@@ -46,6 +49,8 @@ public class SendSubSystemTask implements Runnable {
skinFillFeign.refreshUser(); skinFillFeign.refreshUser();
Thread.sleep(2000); Thread.sleep(2000);
selfSystemFeign.refreshUser(); selfSystemFeign.refreshUser();
Thread.sleep(2000);
smartSystemFeign.refreshUser();
} catch (Exception e) { } catch (Exception e) {
log.error("通知异常:", 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