Commit 1511b9d68ffd8a3b733e2d3b2389f831bde4f796
1 parent
c44f53ae1b
Exists in
master
and in
6 other branches
产筛无创添加字段
Showing 2 changed files with 39 additions and 1 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/Test.java
View file @
1511b9d
1 | 1 | package com.lyms.platform.operate.web; |
2 | 2 | |
3 | +import com.lyms.platform.common.utils.MD5; | |
3 | 4 | import com.lyms.platform.pojo.BasicConfig; |
4 | 5 | import net.sourceforge.pinyin4j.PinyinHelper; |
5 | 6 | import org.apache.log4j.Logger; |
6 | 7 | import sun.misc.Unsafe; |
7 | 8 | |
8 | 9 | import java.lang.reflect.Field; |
10 | +import java.text.SimpleDateFormat; | |
9 | 11 | import java.util.*; |
10 | 12 | |
11 | 13 | /** |
12 | 14 | |
... | ... | @@ -15,7 +17,41 @@ |
15 | 17 | |
16 | 18 | private static org.apache.log4j.Logger log = Logger.getLogger("HTTP-INVOKE"); |
17 | 19 | public static void main(String[] args) throws Exception { |
20 | + | |
21 | + Map<String, Object> resutl = getSignParams("bisp-czsfy", "czsfy123$"); | |
22 | + System.out.println(resutl); | |
23 | + | |
18 | 24 | } |
25 | + | |
26 | + public static Map<String, Object> getSignParams(String syscode, String secret) { | |
27 | + Map<String, Object> signParams = new HashMap<>(); | |
28 | + signParams.put("syscode", syscode); | |
29 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
30 | + signParams.put("timestamp", sdf.format(new Date())); | |
31 | + String unencryptedStr = getUnencryptedStr(signParams); | |
32 | + String sign2 = MD5.getMD5(secret + unencryptedStr + secret);//获取数字签名 | |
33 | + signParams.put("sign", sign2); | |
34 | + return signParams; | |
35 | + } | |
36 | + | |
37 | + public static String getUnencryptedStr(Map<String, Object> signParams) { | |
38 | + List<String> paramsList = new ArrayList<>(); | |
39 | + for (String key : signParams.keySet()) { | |
40 | + if ("sign".equals(key)) { | |
41 | + continue; | |
42 | + } | |
43 | + String value = (String) signParams.get(key); | |
44 | + paramsList.add(key + value);//将参数转换成key+value格式 | |
45 | + } | |
46 | + Object[] paramsArray = (Object[]) paramsList.toArray(); | |
47 | + Arrays.sort(paramsArray);//ascii码排序 | |
48 | + String unencryptedStr = "";//待加密字符串 | |
49 | + for (Object paramStr : paramsArray) { | |
50 | + unencryptedStr += paramStr; | |
51 | + } | |
52 | + return unencryptedStr; | |
53 | + } | |
54 | + | |
19 | 55 | |
20 | 56 | public static Integer getLevel(Integer total) { |
21 | 57 | if (total == null) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ApplyOrderFacade.java
View file @
1511b9d
... | ... | @@ -1631,7 +1631,9 @@ |
1631 | 1631 | timestamp = timestamp.replaceAll(" ", "%20");//空格替换成 %20 |
1632 | 1632 | String syscode = signParams.get("syscode").toString(); |
1633 | 1633 | String sign = signParams.get("sign").toString(); |
1634 | - System.out.println(sign + " saveSampleInfo param="+JsonUtil.obj2JsonString(map)); | |
1634 | + System.out.println("timestamp"+timestamp+" syscode="+" sign="+sign); | |
1635 | + | |
1636 | + System.out.println("saveSampleInfo param="+JsonUtil.obj2JsonString(map)); | |
1635 | 1637 | String s = HttpClientUtil.sendPost(HUADA_URL + "/intf?method=saveSampleInfo&" + "timestamp=" + timestamp + "&syscode=" + syscode + "&sign=" + sign, map); |
1636 | 1638 | System.out.println(s); |
1637 | 1639 | //{"code":"200","msg":"success","rows":{"successedList":[{"msg":"INSP190001417198 ,样例号: 18S4074733R 保存成功!","result":true,"canseqId":"2018101700007123"}],"failedList":[]}} |