Commit 6263797d66e8e448274cae5c726ae03ee090064f

Authored by 张志伟
2 parents 5574a4b1 c7799eaf

Merge remote-tracking branch 'origin/test'

fw-shirasawa-rpc/src/main/java/cn/fw/shirasawa/rpc/ehr/EhrRpcService.java
... ... @@ -61,19 +61,26 @@ public class EhrRpcService extends AbsBaseRpcService {
61 61 final String key = generateKey(userId);
62 62 StaffInfoDTO dto = getFromCache(key, StaffInfoDTO.class);
63 63 if (Objects.nonNull(dto)) {
  64 + if (dto.getId() < 0L) {
  65 + return null;
  66 + }
64 67 return dto;
65 68 }
66 69 try {
67 70 final Message<StaffInfo> msg = staffApi.getStaffInfoById(userId);
68 71 log.info("StaffApi.queryStaffInfo: msg.code={}, msg.result={}, msg.data={}", msg.getCode(), msg.getResult(), msg.getData());
69   - if (msg.isSuccess() && !Objects.isNull(msg.getData())) {
  72 + if (msg.isSuccess()) {
70 73 final StaffInfoDTO staffInfoDTO = new StaffInfoDTO();
71   - BeanUtils.copyProperties(msg.getData(), staffInfoDTO);
  74 + if (Objects.nonNull(msg.getData())) {
  75 + BeanUtils.copyProperties(msg.getData(), staffInfoDTO);
  76 + } else {
  77 + staffInfoDTO.setId(-1L);
  78 + }
72 79 setToCache(key, JSONObject.toJSONString(staffInfoDTO), 60 * 60);
73 80 return staffInfoDTO;
74 81 }
75 82 } catch (Exception e) {
76   - e.printStackTrace();
  83 + log.error("通过userId查询员工信息失败:", e);
77 84 }
78 85 return null;
79 86 }
... ... @@ -86,19 +93,26 @@ public class EhrRpcService extends AbsBaseRpcService {
86 93 final String key = generateKey(mobile);
87 94 StaffInfoDTO dto = getFromCache(key, StaffInfoDTO.class);
88 95 if (Objects.nonNull(dto)) {
  96 + if (dto.getId() < 0L) {
  97 + return null;
  98 + }
89 99 return dto;
90 100 }
91 101 try {
92 102 final Message<StaffInfo> msg = staffApi.getStaffInfoByMobile(mobile);
93 103 log.info("StaffApi.queryStaffInfoByMobile: msg.code={}, msg.result={}, msg.data={}", msg.getCode(), msg.getResult(), msg.getData());
94   - if (msg.isSuccess() && !Objects.isNull(msg.getData())) {
  104 + if (msg.isSuccess()) {
95 105 final StaffInfoDTO staffInfoDTO = new StaffInfoDTO();
96   - BeanUtils.copyProperties(msg.getData(), staffInfoDTO);
  106 + if (!Objects.isNull(msg.getData())) {
  107 + BeanUtils.copyProperties(msg.getData(), staffInfoDTO);
  108 + } else {
  109 + staffInfoDTO.setId(-1L);
  110 + }
97 111 setToCache(key, JSONObject.toJSONString(staffInfoDTO), 60 * 60);
98 112 return staffInfoDTO;
99 113 }
100 114 } catch (Exception e) {
101   - e.printStackTrace();
  115 + log.error("通过手机号查询员工信息失败:", e);
102 116 }
103 117 return null;
104 118 }
... ...