|
@@ -5,18 +5,13 @@ import fdage.back.sdk.base.entity.Result;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.time.Duration;
|
|
|
import java.time.Instant;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
@@ -54,25 +49,33 @@ public class FcbUtils {
|
|
|
long stepOneDuration = Duration.between(stepOneStart , stepOneEnd).toMillis();
|
|
|
log.info("步骤1耗时:{}" , stepOneDuration);
|
|
|
Instant stepTwoStart = Instant.now();
|
|
|
+ Map<String , Object> totalParam = new HashMap<>();
|
|
|
for (Map.Entry entry : params.entrySet()) {
|
|
|
//1、先剔除value值为null的键值对
|
|
|
- if(null == entry.getValue()){
|
|
|
- params.remove(entry.getKey());
|
|
|
+ if(null != entry.getValue()){
|
|
|
+ //这里需要转成小写
|
|
|
+ totalParam.put(entry.getKey().toString().toLowerCase() , entry.getValue());
|
|
|
}
|
|
|
}
|
|
|
//2、新增房车宝的client_secret作为噪点
|
|
|
- params.put("client_secret" , fcbClientSecret);
|
|
|
- params.put("client_code" , fcbClientCode);
|
|
|
- params.put("req_time" , timeStamp);
|
|
|
- params = DataUtils.sortMapByKey(params);
|
|
|
+ totalParam.put("client_secret" , fcbClientSecret);
|
|
|
+ totalParam.put("client_code" , fcbClientCode);
|
|
|
+ totalParam.put("req_time" , timeStamp);
|
|
|
+// params = DataUtils.sortMapByKey(params);
|
|
|
+ Collection<String> keyset= totalParam.keySet();
|
|
|
+ List<String> list=new ArrayList<String>(keyset);
|
|
|
+ Collections.sort(list);
|
|
|
Instant stepTwoEnd = Instant.now();
|
|
|
long stepTwoDuration = Duration.between(stepTwoStart , stepTwoEnd).toMillis();
|
|
|
log.info("步骤2耗时:{}" , stepTwoDuration);
|
|
|
|
|
|
Instant stepThreeStart = Instant.now();
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
- for ( Map.Entry entry : params.entrySet()) {
|
|
|
+ /*for ( Map.Entry entry : params.entrySet()) {
|
|
|
stringBuilder.append(entry.getValue());
|
|
|
+ }*/
|
|
|
+ for (String str: list) {
|
|
|
+ stringBuilder.append(String.valueOf(totalParam.get(str)));
|
|
|
}
|
|
|
//3、生成MD5密文,然后转成小写字母
|
|
|
String md5EncryptionStr = DataUtils.md5Encryption(stringBuilder.toString());
|