|
@@ -21,10 +21,9 @@ import java.util.Date;
|
|
|
@Component
|
|
|
@Slf4j
|
|
|
public class SiUtil {
|
|
|
- private static int serial = 1000;
|
|
|
- private static final int MIN_VAL = 1000;
|
|
|
- private static final int MAX_VAL = 9999;
|
|
|
- private static final String REQ_HEADER_PREFIX = "";
|
|
|
+ private static int DEFAULT_SERIAL_NO = 1000;
|
|
|
+ private static final int MIN_SERIAL_NO = 1000;
|
|
|
+ private static final int MAX_SERIAL_NO = 9999;
|
|
|
public static final String INSTITUTION_AREA = "430105";
|
|
|
public static final String INSTITUTION_ID = "H43010500370";
|
|
|
public static final String INSTITUTION_NAME = "长沙泰和医院";
|
|
@@ -52,25 +51,17 @@ public class SiUtil {
|
|
|
}
|
|
|
|
|
|
public static synchronized String makeMsgId() {
|
|
|
- serial += 1;
|
|
|
- if (serial > MAX_VAL) {
|
|
|
- serial = MIN_VAL;
|
|
|
+ DEFAULT_SERIAL_NO += 1;
|
|
|
+ if (DEFAULT_SERIAL_NO > MAX_SERIAL_NO) {
|
|
|
+ DEFAULT_SERIAL_NO = MIN_SERIAL_NO;
|
|
|
}
|
|
|
- return INSTITUTION_ID + timestamp() + serial;
|
|
|
+ return INSTITUTION_ID + timestamp() + DEFAULT_SERIAL_NO;
|
|
|
}
|
|
|
|
|
|
public static HttpHeaders getHttpHeaders(SiFunction function) {
|
|
|
String timestamp = String.valueOf(System.currentTimeMillis());
|
|
|
String signature = getSignature(timestamp, function.getCode());
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
-// headers.add("_api_access_key", apiAccessKey);
|
|
|
-// headers.add("_api_secreKey", apiSecretKey);
|
|
|
-// headers.add("_api_name", REQ_HEADER_PREFIX + function.getCode());
|
|
|
-// headers.add("_api_version", API_VERSION);
|
|
|
-// headers.add("_api_timestamp", timestamp);
|
|
|
-// headers.add("_api_signature", getSignature(timestamp, function.getCode()));
|
|
|
-// headers.add("Content-Type", "application/json");
|
|
|
-
|
|
|
headers.add("apiAccessKey", apiAccessKey);
|
|
|
headers.add("apiSecreKey", apiSecretKey);
|
|
|
headers.add("apiName", function.getCode());
|
|
@@ -83,7 +74,7 @@ public class SiUtil {
|
|
|
public static String getSignature(String timestamp, String function) {
|
|
|
String source =
|
|
|
"_api_access_key=" + apiAccessKey +
|
|
|
- "&_api_name=" + REQ_HEADER_PREFIX + function +
|
|
|
+ "&_api_name=" + function +
|
|
|
"&_api_timestamp=" + timestamp +
|
|
|
"&_api_version=" + API_VERSION;
|
|
|
return hmacSha1(source);
|