|
@@ -16,6 +16,7 @@ import com.diagbot.util.DateUtil;
|
|
import com.diagbot.util.EnDecodeUtil;
|
|
import com.diagbot.util.EnDecodeUtil;
|
|
import com.diagbot.util.GsonUtil;
|
|
import com.diagbot.util.GsonUtil;
|
|
import com.diagbot.util.RSAEncrypt;
|
|
import com.diagbot.util.RSAEncrypt;
|
|
|
|
+import com.diagbot.util.RespDTOUtil;
|
|
import com.diagbot.util.StringUtil;
|
|
import com.diagbot.util.StringUtil;
|
|
import com.diagbot.vo.HospitalListVO;
|
|
import com.diagbot.vo.HospitalListVO;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -217,12 +218,25 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 更新licence剩余天数,减1
|
|
|
|
+ */
|
|
public void refreshLicenceMap() {
|
|
public void refreshLicenceMap() {
|
|
- tranServiceClient.refreshLicence();
|
|
|
|
- for (String key : licenceMap.keySet()) {
|
|
|
|
- if (key.indexOf(LICENCE_REMAIN) > -1) {
|
|
|
|
-
|
|
|
|
|
|
+ RespDTO<Boolean> res = tranServiceClient.refreshLicence();
|
|
|
|
+ RespDTOUtil.respIsNG(res);
|
|
|
|
+ if (res.data == false) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "更新licence剩余天数失败");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ for (String key : licenceMap.keySet()) {
|
|
|
|
+ if (key.indexOf(LICENCE_REMAIN) > -1) {
|
|
|
|
+ String val = licenceMap.get(key);
|
|
|
|
+ System.out.println(key + " : " + String.valueOf(Integer.parseInt(val) - 1));
|
|
|
|
+ licenceMap.put(key, String.valueOf(Integer.parseInt(val) - 1));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "更新licence剩余天数失败");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -234,16 +248,13 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
* @param serviceName 服务名称
|
|
* @param serviceName 服务名称
|
|
*/
|
|
*/
|
|
public void verifyLicenceExpire(String hospitalCode, String serviceName) {
|
|
public void verifyLicenceExpire(String hospitalCode, String serviceName) {
|
|
|
|
+ if (StringUtil.isEmpty(hospitalCode) || StringUtil.isEmpty(serviceName)) {
|
|
|
|
+ return ;
|
|
|
|
+ }
|
|
String licenceExpire = licenceMap.get(hospitalCode + LICENCE_EXPIRE + serviceName);
|
|
String licenceExpire = licenceMap.get(hospitalCode + LICENCE_EXPIRE + serviceName);
|
|
if (StringUtil.isNotEmpty(licenceExpire)) {
|
|
if (StringUtil.isNotEmpty(licenceExpire)) {
|
|
- String licence = "";
|
|
|
|
- try {
|
|
|
|
- licence = RSAEncrypt.decrypt(licenceExpire);
|
|
|
|
- } catch (Exception e) { // licence 被篡改
|
|
|
|
- throw new CommonException(CommonErrorCode.LICENCE_ERROR);
|
|
|
|
- }
|
|
|
|
String nowStr = DateUtil.format(new Date(), "YYYY-MM-dd HH:mm:ss");
|
|
String nowStr = DateUtil.format(new Date(), "YYYY-MM-dd HH:mm:ss");
|
|
- if (licence.compareTo(nowStr) < 0) { // licence 已到期
|
|
|
|
|
|
+ if (licenceExpire.compareTo(nowStr) < 0) { // licence 已到期
|
|
throw new CommonException(CommonErrorCode.LICENCE_EXPIRE);
|
|
throw new CommonException(CommonErrorCode.LICENCE_EXPIRE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -257,11 +268,14 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
* @param serviceName 服务名称
|
|
* @param serviceName 服务名称
|
|
*/
|
|
*/
|
|
public void verifyLicenceRemain(String hospitalCode, String serviceName) {
|
|
public void verifyLicenceRemain(String hospitalCode, String serviceName) {
|
|
|
|
+ if (StringUtil.isEmpty(hospitalCode) || StringUtil.isEmpty(serviceName)) {
|
|
|
|
+ return ;
|
|
|
|
+ }
|
|
String licenceRemain = licenceMap.get(hospitalCode + LICENCE_REMAIN + serviceName);
|
|
String licenceRemain = licenceMap.get(hospitalCode + LICENCE_REMAIN + serviceName);
|
|
if (StringUtil.isNotEmpty(licenceRemain)) {
|
|
if (StringUtil.isNotEmpty(licenceRemain)) {
|
|
int day = 0;
|
|
int day = 0;
|
|
try {
|
|
try {
|
|
- day = Integer.parseInt(RSAEncrypt.decrypt(licenceRemain));
|
|
|
|
|
|
+ day = Integer.parseInt(licenceRemain);
|
|
} catch (Exception e) { // licence 被篡改
|
|
} catch (Exception e) { // licence 被篡改
|
|
throw new CommonException(CommonErrorCode.LICENCE_ERROR);
|
|
throw new CommonException(CommonErrorCode.LICENCE_ERROR);
|
|
}
|
|
}
|
|
@@ -277,7 +291,6 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
*/
|
|
*/
|
|
public void initLicenceMap() {
|
|
public void initLicenceMap() {
|
|
// 初始化licence
|
|
// 初始化licence
|
|
- licenceMap.clear();
|
|
|
|
if (!initLicence) {
|
|
if (!initLicence) {
|
|
HospitalListVO hospitalListVO = new HospitalListVO();
|
|
HospitalListVO hospitalListVO = new HospitalListVO();
|
|
List<String> codeList = new ArrayList<>();
|
|
List<String> codeList = new ArrayList<>();
|
|
@@ -286,16 +299,21 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
codeList.add(LICENCE_START);
|
|
codeList.add(LICENCE_START);
|
|
hospitalListVO.setCodeList(codeList);
|
|
hospitalListVO.setCodeList(codeList);
|
|
RespDTO<List<SysSetInfoDTO>> respDTO = tranServiceClient.getSysSetInfoDataByList(hospitalListVO);
|
|
RespDTO<List<SysSetInfoDTO>> respDTO = tranServiceClient.getSysSetInfoDataByList(hospitalListVO);
|
|
- if (respDTO != null) {
|
|
|
|
|
|
+ if (respDTO != null && respDTO.data != null) {
|
|
for (SysSetInfoDTO setInfoDTO : respDTO.data) {
|
|
for (SysSetInfoDTO setInfoDTO : respDTO.data) {
|
|
String serName = SysTypeEnum.getName(setInfoDTO.getSysType());
|
|
String serName = SysTypeEnum.getName(setInfoDTO.getSysType());
|
|
if (LICENCE_START.equals(setInfoDTO.getCode())) {
|
|
if (LICENCE_START.equals(setInfoDTO.getCode())) {
|
|
licenceMap.put(setInfoDTO.getCode(), setInfoDTO.getValue());
|
|
licenceMap.put(setInfoDTO.getCode(), setInfoDTO.getValue());
|
|
} else {
|
|
} else {
|
|
- licenceMap.put(setInfoDTO.getHospitalCode() + setInfoDTO.getCode() + serName.substring(0, serName.indexOf("-")), setInfoDTO.getValue());
|
|
|
|
|
|
+ try {
|
|
|
|
+ licenceMap.put(setInfoDTO.getHospitalCode() + setInfoDTO.getCode() + serName.substring(0, serName.indexOf("-")), RSAEncrypt.decrypt(setInfoDTO.getValue()));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.LICENCE_ERROR);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ initLicence = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|