提交 c3a13f17 authored 作者: 133's avatar 133

[用户] [清退] [专管员统计] 代码提交

上级 548d1b8d
...@@ -63,6 +63,12 @@ public class BlockchaController { ...@@ -63,6 +63,12 @@ public class BlockchaController {
return ResponseEntity.ok(blockChainUtil.sendHash(index,code,"")); return ResponseEntity.ok(blockChainUtil.sendHash(index,code,""));
} }
@ApiOperation(value = "hash追加")
@GetMapping(value = "/sendHash3/{index}/{id}/{content}")
public ResponseEntity sendHash23(@PathVariable Integer index,@PathVariable String id,@PathVariable String content){
// content= HexUtil.string2HexUTF8(content);
return ResponseEntity.ok(blockChainUtil.appendHash(index,content,id));
}
@ApiOperation(value = "文本添加") @ApiOperation(value = "文本添加")
@GetMapping(value = "/sendHash1/{index}/{code}/{content}") @GetMapping(value = "/sendHash1/{index}/{code}/{content}")
...@@ -78,12 +84,13 @@ public class BlockchaController { ...@@ -78,12 +84,13 @@ public class BlockchaController {
return ResponseEntity.ok(blockChainUtil.appendText(index,content,id)); return ResponseEntity.ok(blockChainUtil.appendText(index,content,id));
} }
// @ApiOperation(value = "文本篡改验证") @ApiOperation(value = "key and id")
// @GetMapping(value = "/sendHash3/{key}/{id}") @GetMapping(value = "/sendHash5/{key}/{id}")
// public ResponseEntity sendHash3(@PathVariable String key,@PathVariable String id,@PathVariable String content){ public ResponseEntity sendHash5(@PathVariable String key,@PathVariable String id){
//// content= HexUtil.string2HexUTF8(content); // content= HexUtil.string2HexUTF8(content);
// return ResponseEntity.ok(blockChainUtil.verifyText(index,content,id));
// } return ResponseEntity.ok(blockChainUtil.verifyText1(id,key));
}
@GetMapping(value = "/fetchRecord/{id}") @GetMapping(value = "/fetchRecord/{id}")
......
...@@ -152,4 +152,6 @@ public interface BlockChainUtil { ...@@ -152,4 +152,6 @@ public interface BlockChainUtil {
BcVerify verifyText(String content, String recordId); BcVerify verifyText(String content, String recordId);
String verifyText1(String id, String key);
} }
...@@ -27,13 +27,17 @@ import java.util.UUID; ...@@ -27,13 +27,17 @@ import java.util.UUID;
@Component @Component
public class BlockChainUtilImpl implements BlockChainUtil { public class BlockChainUtilImpl implements BlockChainUtil {
// private static String SECRET_KEY = "3mdeM1dw2FfHrd5h6WAuhB3WYdDG6ZAgz96CcM1nzxbiYA8QaaZHW75Je9xKixTTD2rwujyb1gVUNPYm5W6FPZQ8"; private String SECRET_KEY = "3mdeM1dw2FfHrd5h6WAuhB3WYdDG6ZAgz96CcM1nzxbiYA8QaaZHW75Je9xKixTTD2rwujyb1gVUNPYm5W6FPZQ8";
// private static String SECRET_ID = "3yXRRiL9xsLfbt2kv7qRH2so6ChJX3rFkay7Njcsxfbp"; private String SECRET_ID = "3yXRRiL9xsLfbt2kv7qRH2so6ChJX3rFkay7Njcsxfbp";
//测试环境 //测试环境
public String SECRET_KEY = "3RJWStDCXN7mqJyZAB8rF59f87arGShdk9aKyDN3wKbzq9JnaXom1Hpe6mHT1k2yx9zfE7VFWidqwuxyT7DtPjCs";
public String SECRET_ID = "JAjQyTZdR8bmbHaU6iiFGvrCuUik4cG4U4ostk8KKrbS";
private final static String BLOCK_CHAIN_URL = "http://192.168.0.80:8076"; // public String SECRET_KEY;
// public String SECRET_ID;
//测试环境
// public String SECRET_KEY = "3RJWStDCXN7mqJyZAB8rF59f87arGShdk9aKyDN3wKbzq9JnaXom1Hpe6mHT1k2yx9zfE7VFWidqwuxyT7DtPjCs";
// public String SECRET_ID = "JAjQyTZdR8bmbHaU6iiFGvrCuUik4cG4U4ostk8KKrbS";
private final static String BLOCK_CHAIN_URL = "http://10.153.4.12:8076";
private final static String BLOCK_CHAIN_URL2 = "http://10.153.8.10:8076"; private final static String BLOCK_CHAIN_URL2 = "http://10.153.8.10:8076";
private final static String BLOCK_CHAIN_URL3 = "http://10.153.8.11:8076"; private final static String BLOCK_CHAIN_URL3 = "http://10.153.8.11:8076";
private final static String BLOCK_CHAIN_URL4 = "http://10.153.110.10:8076"; private final static String BLOCK_CHAIN_URL4 = "http://10.153.110.10:8076";
...@@ -374,6 +378,13 @@ public class BlockChainUtilImpl implements BlockChainUtil { ...@@ -374,6 +378,13 @@ public class BlockChainUtilImpl implements BlockChainUtil {
); );
} }
@Override
public String verifyText1(String id, String key) {
SECRET_KEY=key;
SECRET_ID=id;
return SECRET_KEY;
}
/** /**
* 存储通用参数 * 存储通用参数
* *
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.github.wenhao.jpa.Specifications; import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.blockcha.subject.entity.BcHash;
import com.tykj.dev.blockcha.subject.entity.BcText; import com.tykj.dev.blockcha.subject.entity.BcText;
import com.tykj.dev.blockcha.subject.service.BlockChainUtil; import com.tykj.dev.blockcha.subject.service.BlockChainUtil;
import com.tykj.dev.device.library.repository.DeviceLibraryDao; import com.tykj.dev.device.library.repository.DeviceLibraryDao;
...@@ -1674,11 +1675,11 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1674,11 +1675,11 @@ public class SendBackServiceImpl implements SendBackService {
private SendBackBill saveSendBackBill(SendBackBill sendBackBill){ private SendBackBill saveSendBackBill(SendBackBill sendBackBill){
SendBackBill sendBackBill1 = sendBackBillEntityDao.save(sendBackBill); SendBackBill sendBackBill1 = sendBackBillEntityDao.save(sendBackBill);
if (sendBackBill1.getRecordId()==null || sendBackBill1.getRecordId().equals("")){ if (sendBackBill1.getRecordId()==null || sendBackBill1.getRecordId().equals("")){
BcText bcText=blockChainUtil.sendText(1000,JacksonUtil.toJSon(sendBackBill1)); BcHash bcHash=blockChainUtil.sendHash(1000,JacksonUtil.toJSon(sendBackBill1));
sendBackBill1.setRecordId(bcText.getData().getRecordID()); sendBackBill1.setRecordId(bcHash.getData().getRecordID());
return sendBackBillEntityDao.save(sendBackBill1); return sendBackBillEntityDao.save(sendBackBill1);
}else { }else {
blockChainUtil.appendText(JacksonUtil.toJSon(sendBackBill1),sendBackBill1.getRecordId()); blockChainUtil.appendHash(JacksonUtil.toJSon(sendBackBill1),sendBackBill1.getRecordId());
return sendBackBill1; return sendBackBill1;
} }
} }
...@@ -1686,11 +1687,11 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1686,11 +1687,11 @@ public class SendBackServiceImpl implements SendBackService {
private SendBackBillDetail saveSendBackBillDetail(SendBackBillDetail sendBackBillDetail){ private SendBackBillDetail saveSendBackBillDetail(SendBackBillDetail sendBackBillDetail){
SendBackBillDetail sendBackBillDetail1 = sendBackBillDetailEntityDao.save(sendBackBillDetail); SendBackBillDetail sendBackBillDetail1 = sendBackBillDetailEntityDao.save(sendBackBillDetail);
if (sendBackBillDetail1.getRecordId()==null || sendBackBillDetail1.getRecordId().equals("")){ if (sendBackBillDetail1.getRecordId()==null || sendBackBillDetail1.getRecordId().equals("")){
BcText bcText=blockChainUtil.sendText(1000,JacksonUtil.toJSon(sendBackBillDetail1)); BcHash bcHash=blockChainUtil.sendHash(1000,JacksonUtil.toJSon(sendBackBillDetail1));
sendBackBillDetail1.setRecordId(bcText.getData().getRecordID()); sendBackBillDetail1.setRecordId(bcHash.getData().getRecordID());
return sendBackBillDetailEntityDao.save(sendBackBillDetail1); return sendBackBillDetailEntityDao.save(sendBackBillDetail1);
}else { }else {
blockChainUtil.appendText(JacksonUtil.toJSon(sendBackBillDetail1),sendBackBillDetail1.getRecordId()); blockChainUtil.appendHash(JacksonUtil.toJSon(sendBackBillDetail1),sendBackBillDetail1.getRecordId());
return sendBackBillDetail1; return sendBackBillDetail1;
} }
} }
......
package com.tykj.dev.device.train.controller; package com.tykj.dev.device.train.controller;
import com.tykj.dev.blockcha.subject.entity.BcHash;
import com.tykj.dev.blockcha.subject.entity.BcText; import com.tykj.dev.blockcha.subject.entity.BcText;
import com.tykj.dev.blockcha.subject.service.BlockChainUtil; import com.tykj.dev.blockcha.subject.service.BlockChainUtil;
import com.tykj.dev.config.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
...@@ -457,11 +458,11 @@ public class TrainJobController { ...@@ -457,11 +458,11 @@ public class TrainJobController {
private TrainUser saveTrainUser(TrainUser trainUser){ private TrainUser saveTrainUser(TrainUser trainUser){
TrainUser trainUser1 = trainUserDao.save(trainUser); TrainUser trainUser1 = trainUserDao.save(trainUser);
if (trainUser1.getRecordId()==null || trainUser1.getRecordId().equals("")){ if (trainUser1.getRecordId()==null || trainUser1.getRecordId().equals("")){
BcText bcText=blockChainUtil.sendText(1000,JacksonUtil.toJSon(trainUser1)); BcHash bcHash=blockChainUtil.sendHash(1000,JacksonUtil.toJSon(trainUser1));
trainUser1.setRecordId(bcText.getData().getRecordID()); trainUser1.setRecordId(bcHash.getData().getRecordID());
return trainUserDao.save(trainUser1); return trainUserDao.save(trainUser1);
}else { }else {
blockChainUtil.appendText(JacksonUtil.toJSon(trainUser1),trainUser1.getRecordId()); blockChainUtil.appendHash(JacksonUtil.toJSon(trainUser1),trainUser1.getRecordId());
return trainUser1; return trainUser1;
} }
} }
......
...@@ -3,6 +3,7 @@ package com.tykj.dev.device.train.service.impl; ...@@ -3,6 +3,7 @@ package com.tykj.dev.device.train.service.impl;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.github.wenhao.jpa.PredicateBuilder; import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications; import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.blockcha.subject.entity.BcHash;
import com.tykj.dev.blockcha.subject.entity.BcText; import com.tykj.dev.blockcha.subject.entity.BcText;
import com.tykj.dev.blockcha.subject.service.BlockChainUtil; import com.tykj.dev.blockcha.subject.service.BlockChainUtil;
import com.tykj.dev.device.task.subject.bto.TaskBto; import com.tykj.dev.device.task.subject.bto.TaskBto;
...@@ -66,11 +67,11 @@ public class TrainThemeServiceImpl implements TrainThemeService { ...@@ -66,11 +67,11 @@ public class TrainThemeServiceImpl implements TrainThemeService {
public TrainTheme save(TrainTheme trainTheme) { public TrainTheme save(TrainTheme trainTheme) {
TrainTheme trainTheme1 = trainThemeDao.save(trainTheme); TrainTheme trainTheme1 = trainThemeDao.save(trainTheme);
if (trainTheme1.getRecordId()==null || trainTheme1.getRecordId().equals("")){ if (trainTheme1.getRecordId()==null || trainTheme1.getRecordId().equals("")){
BcText bcText=blockChainUtil.sendText(1000,JacksonUtil.toJSon(trainTheme1)); BcHash bcHash=blockChainUtil.sendHash(1000,JacksonUtil.toJSon(trainTheme1));
trainTheme1.setRecordId(bcText.getData().getRecordID()); trainTheme1.setRecordId(bcHash.getData().getRecordID());
return trainThemeDao.save(trainTheme1); return trainThemeDao.save(trainTheme1);
}else { }else {
blockChainUtil.appendText(JacksonUtil.toJSon(trainTheme1),trainTheme1.getRecordId()); blockChainUtil.appendHash(JacksonUtil.toJSon(trainTheme1),trainTheme1.getRecordId());
return trainTheme1; return trainTheme1;
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论