ylx 7 vuotta sitten
vanhempi
commit
d81f8033c9

+ 1 - 1
saicLogistics/src/main/java/com/fuzamei/mapper/CargoTallyMapper.xml

@@ -33,7 +33,7 @@
 				and o.require_time between #{startTime} and #{endTime}
 			</if>
 		</where>
-		order by o.status_id asc,o.require_time desc
+		order by o.require_time desc
 		limit #{startPage},#{rowNum}
 	</select>
 	

+ 2 - 2
saicLogistics/src/main/java/com/fuzamei/service/serviceImpl/CargoConsignServiceImpl.java

@@ -72,8 +72,8 @@ public class CargoConsignServiceImpl implements CargoConsignService {
 		params.setOperationTime(currentTime);
 		params.setHash(hash);
 		operationHistoryMapper.addToHistory(params);
-		/*boolean flag = blockChainUtil.sendBlockChain(params.getSign());
-		if(!flag) throw new RuntimeException("区块链操作失败");*/
+		boolean flag = blockChainUtil.sendBlockChain(params.getSign());
+		if(!flag) throw new RuntimeException("区块链操作失败");
 	}
 
 	@Override

+ 2 - 2
saicLogistics/src/main/java/com/fuzamei/service/serviceImpl/CargoTallyServiceImpl.java

@@ -74,8 +74,8 @@ public class CargoTallyServiceImpl implements CargoTallyService {
 		params.setOperationTime(currentTime);
 		params.setHash(hash);
 		operationHistoryMapper.addToHistory(params);
-		/*boolean flag = blockChainUtil.sendBlockChain(params.getSign());
-		if(!flag) throw new RuntimeException("区块链操作失败");*/
+		boolean flag = blockChainUtil.sendBlockChain(params.getSign());
+		if(!flag) throw new RuntimeException("区块链操作失败");
 	}
 
 	@Override

+ 5 - 5
saicLogistics/src/main/java/com/fuzamei/service/serviceImpl/OrdersIssueServiceImpl.java

@@ -75,10 +75,10 @@ public class OrdersIssueServiceImpl implements OrdersIssueService {
 		params.setOperationTypeId(OperationType.SEND);
 		params.setOperatorId(params.getUserId());
 		params.setOperationTime(currentTime);
-		operationHistoryMapper.addToHistory(params);
 		params.setHash(hash);
-		/*boolean flag = blockChainUtil.sendBlockChain(params.getSign());
-		if(!flag) throw new RuntimeException("区块链操作失败");*/
+		operationHistoryMapper.addToHistory(params);
+		boolean flag = blockChainUtil.sendBlockChain(params.getSign());
+		if(!flag) throw new RuntimeException("区块链操作失败");
 	}
 
 	@Override
@@ -103,8 +103,8 @@ public class OrdersIssueServiceImpl implements OrdersIssueService {
 		params.setOperationTime(currentTime);
 		params.setHash(hash);
 		operationHistoryMapper.addToHistory(params);
-		/*boolean flag = blockChainUtil.sendBlockChain(params.getSign());
-		if(!flag) throw new RuntimeException("区块链操作失败");*/
+		boolean flag = blockChainUtil.sendBlockChain(params.getSign());
+		if(!flag) throw new RuntimeException("区块链操作失败");
 	}
 
 	@Override

+ 10 - 2
saicLogistics/src/main/java/com/fuzamei/util/blockchain/KeyUtils.java

@@ -92,6 +92,14 @@ public class KeyUtils {
 		ProtobufBean protobufBean = ProtobufUtils.requestUserCreate(userUid, userPublicKey, privateKey,userName);	//管理员的公钥
 		String result = BlockChainUtil.sendPostParam(protobufBean);
 		System.out.println(result);*/
+    	
+    	long Uid = 23233L;
+    	String random = "caoXSy856H";
+    	String publicKey = getPublicKey(getPrivateKey("123456", random));
+    	System.out.println(publicKey);
+//    	ProtobufBean protobufBean = ProtobufUtils.requestUserCreate(Uid,publicKey);
+//    	String result = BlockChainUtil.sendPostParam(protobufBean);
+//		System.out.println(result);
 		
 		/** 先平台初始化  **/
 		/*ProtobufBean protobufBean = ProtobufUtils.initPlatform();	
@@ -135,10 +143,10 @@ public class KeyUtils {
 		String result = BlockChainUtil.sendPostParam(protobufBean);
 		System.out.println("平台初始化区块链返回的结果>>:"+result);*/
     	
-    	String privkey = getPrivateKey("123456", "1094015313");
+    	/*String privkey = getPrivateKey("123456", "1094015313");
     	String publicKey =  getPublicKey(privkey);
     	System.out.println(privkey);
-    	System.out.println(publicKey);
+    	System.out.println(publicKey);*/
 	}
 
 

+ 15 - 8
saicLogistics/src/main/java/com/fuzamei/util/blockchain/ProtobufUtils.java

@@ -1,6 +1,6 @@
 package com.fuzamei.util.blockchain;
 
-//import gfp2p.Api;
+import smsc.Api;
 
 import java.lang.reflect.Method;
 import java.security.InvalidKeyException;
@@ -76,14 +76,21 @@ public class ProtobufUtils {
         }
         return protobufBean;
 	}*/
-	/*public static ProtobufBean requestUserCreate(long userUid,String pubkey,String privateKey,String userName) {	//用户公钥,调用者的公钥
+	public static ProtobufBean requestUserCreate(long userUid,String adminPubKey) {	//用户公钥,调用者的公钥
 //    	String operatorPrivateKey = "90b289fda1fb0439158f837bbe60cc1ec99616dd0bc6335d6fd0bf3d22888e20";
-        ProtobufBean protobufBean = new ProtobufBean();
+        
+		String platformPrivateKey = "90b289fda1fb0439158f837bbe60cc1ec99616dd0bc6335d6fd0bf3d22888e20"; 	//平台私钥
+		String pubkey = "b15a4f6c5c1163b5f80715c9bd87d5118ec4b5668cb29f148eeceec61ddeadc2"; 				//平台公钥
+
+		
+		
+		ProtobufBean protobufBean = new ProtobufBean();
         //创建 RequestUserCreate 对象,设置参数
         Api.RequestSetAdmin.Builder builder = Api.RequestSetAdmin.newBuilder();
         try {
 //        	builder.setUserUid(userUid);
 //        	builder.setUserName(userName);
+        	builder.setPubkey(ByteString.copyFrom(HexUtil.hexString2Bytes(adminPubKey)));
         	SecureRandom secureRandom = new SecureRandom();
             long instructionId = secureRandom.nextLong();	//随机数
             protobufBean.setInstructionId(instructionId);
@@ -98,7 +105,7 @@ public class ProtobufUtils {
             request.setUid(userUid);
             Api.Request request1 = request.build();
 //            用操作者的私钥签名
-            byte[] bytePrivateKey = HexUtil.hexString2Bytes(privateKey);
+            byte[] bytePrivateKey = HexUtil.hexString2Bytes(platformPrivateKey);
             //签名啊
             ByteString signByteString = getSign(request1.toByteArray(), bytePrivateKey);
             //签名后的结果也给request
@@ -110,11 +117,11 @@ public class ProtobufUtils {
             String signdateBase64 = encodeBase64(requestByte);
             protobufBean.setSignature(signdateBase64);
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException("生成签名对象出现异常");
         }
         return protobufBean;
-    }*/
-   /* private static ByteString getSign(byte[] requestByte, byte[] bytePrivateKey) {
+    }
+   private static ByteString getSign(byte[] requestByte, byte[] bytePrivateKey) {
         EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName("Ed25519");
         byte[] signbyte = new byte[0];
         try {
@@ -132,7 +139,7 @@ public class ProtobufUtils {
             e.printStackTrace();
         }
         return ByteString.copyFrom(signbyte,0,64);
-    }*/
+    }
     public static String encodeBase64(byte[]input) throws Exception{  
         Class clazz=Class.forName("com.sun.org.apache.xerces.internal.impl.dv.util.Base64");  
         Method mainMethod= clazz.getMethod("encode", byte[].class);