|
@@ -3,12 +3,14 @@
|
|
|
*/
|
|
|
package com.fuzamei.util.blockchain;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.fuzamei.http.HttpRequest;
|
|
|
+import com.fuzamei.util.HexStringUtil;
|
|
|
import com.fuzamei.util.JSONUtil;
|
|
|
import com.fuzamei.util.ReadConfUtil;
|
|
|
|
|
@@ -121,7 +123,46 @@ public class BlockChainUtil {
|
|
|
protobufBean.setSignature(signMap.get("signdata").toString());
|
|
|
return protobufBean;
|
|
|
}
|
|
|
- public static void main(String[] args) {
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析错误信息
|
|
|
+ * @param qianming
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> sendBlockChain2(String qianming){
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ boolean flag = false; //区块链成功返回true,失败返回false,默认返回false
|
|
|
+ String fruit = "";
|
|
|
+ ProtobufBean protobufBean = new ProtobufBean(); //签名对象
|
|
|
+ Map<String, Object> mma = JSONUtil.jsonToMap(qianming);
|
|
|
+ long instructionId = Long
|
|
|
+ .parseLong(mma.get("sid").toString());
|
|
|
+ protobufBean.setInstructionId(instructionId);
|
|
|
+ protobufBean.setSignature(mma.get("signdata").toString());
|
|
|
+ String result = sendPostParam(protobufBean);
|
|
|
+ System.out.println(result);
|
|
|
+ flag = vilaResult(result); //区块链返回过来的结果
|
|
|
+ Map<String, Object> signMap = JSONUtil.jsonToMap(result);
|
|
|
+ Map<String, Object> resultMap = JSONUtil.jsonToMap(signMap.get("result").toString());
|
|
|
+ Map<String, Object> check_tx = JSONUtil.jsonToMap(resultMap.get("check_tx").toString());
|
|
|
+ Map<String, Object> deliver_tx = JSONUtil.jsonToMap(resultMap.get("deliver_tx").toString());
|
|
|
+ if(check_tx.get("data") != null){
|
|
|
+ if(!"".equals(check_tx.get("data").toString())){
|
|
|
+ String hexStr = check_tx.get("data").toString();
|
|
|
+ fruit = HexStringUtil.hexStringToString(hexStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(deliver_tx.get("data") != null){
|
|
|
+ if(!"".equals(deliver_tx.get("data").toString())){
|
|
|
+ String hexStr = deliver_tx.get("data").toString();
|
|
|
+ fruit = HexStringUtil.hexStringToString(hexStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("flag", flag);
|
|
|
+ map.put("data", fruit);
|
|
|
+ return map;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|