提交 df721376 authored 作者: zjm's avatar zjm

fix(区块链): 修改了装备以及装备日志,原本的hash上链,修改成文本上链

修改了装备以及装备日志,原本的hash上链,修改成文本上链
上级 8856482d
package com.tykj.dev.device.library.service.impl; package com.tykj.dev.device.library.service.impl;
import com.tykj.dev.blockcha.subject.entity.BcHash; import com.tykj.dev.blockcha.subject.entity.BcHash;
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.TaskBeanConfig; import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.device.library.repository.DeviceChangeDao; import com.tykj.dev.device.library.repository.DeviceChangeDao;
...@@ -34,7 +35,7 @@ public class DeviceChangeServiceImpl implements DeviceChangeService { ...@@ -34,7 +35,7 @@ public class DeviceChangeServiceImpl implements DeviceChangeService {
DeviceChange deviceChange1 = deviceChangeDao.save(deviceChange); DeviceChange deviceChange1 = deviceChangeDao.save(deviceChange);
CompletableFuture.runAsync(()->{ CompletableFuture.runAsync(()->{
DeviceChange deviceChange2 = getOne(deviceChange1.getId()); DeviceChange deviceChange2 = getOne(deviceChange1.getId());
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(deviceChange2)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(deviceChange2));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
deviceChange2.setRecordId(recordId); deviceChange2.setRecordId(recordId);
deviceChangeDao.save(deviceChange2); deviceChangeDao.save(deviceChange2);
......
...@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
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.BcHash;
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.TaskBeanConfig; import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.config.UpdateCache; import com.tykj.dev.config.UpdateCache;
...@@ -93,7 +94,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService { ...@@ -93,7 +94,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
DeviceLibrary deviceLibrary = deviceLibraryDao.save(deviceLibraryEntity); DeviceLibrary deviceLibrary = deviceLibraryDao.save(deviceLibraryEntity);
CompletableFuture.runAsync(()->{ CompletableFuture.runAsync(()->{
DeviceLibrary deviceLibrary1 = getOne(deviceLibrary.getId()); DeviceLibrary deviceLibrary1 = getOne(deviceLibrary.getId());
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(deviceLibrary1)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(deviceLibrary1));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
deviceLibrary1.setRecordId(recordId); deviceLibrary1.setRecordId(recordId);
deviceLibraryDao.save(deviceLibrary1); deviceLibraryDao.save(deviceLibrary1);
...@@ -108,7 +109,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService { ...@@ -108,7 +109,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Async @Async
public void sendHash(List<DeviceLibrary> deviceLibraries) { public void sendHash(List<DeviceLibrary> deviceLibraries) {
deviceLibraries.forEach(deviceLibrary -> { deviceLibraries.forEach(deviceLibrary -> {
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(deviceLibrary)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(deviceLibrary));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
deviceLibrary.setRecordId(recordId); deviceLibrary.setRecordId(recordId);
update(deviceLibrary); update(deviceLibrary);
......
package com.tykj.dev.device.library.service.impl; package com.tykj.dev.device.library.service.impl;
import com.tykj.dev.blockcha.subject.entity.BcHash; import com.tykj.dev.blockcha.subject.entity.BcHash;
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.TaskBeanConfig; import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.device.library.repository.DeviceLogDao; import com.tykj.dev.device.library.repository.DeviceLogDao;
...@@ -37,7 +38,7 @@ public class DeviceLogServiceImpl implements DeviceLogService { ...@@ -37,7 +38,7 @@ public class DeviceLogServiceImpl implements DeviceLogService {
DeviceLog deviceLog = deviceLogDao.save(deviceLogDto.toDo()); DeviceLog deviceLog = deviceLogDao.save(deviceLogDto.toDo());
CompletableFuture.runAsync(()->{ CompletableFuture.runAsync(()->{
DeviceLog deviceLog1 = deviceLogDao.findById(deviceLog.getId()).get(); DeviceLog deviceLog1 = deviceLogDao.findById(deviceLog.getId()).get();
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(deviceLog1)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(deviceLog1));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
deviceLog1.setRecordId(recordId); deviceLog1.setRecordId(recordId);
deviceLogDao.save(deviceLog1); deviceLogDao.save(deviceLog1);
...@@ -52,7 +53,7 @@ public class DeviceLogServiceImpl implements DeviceLogService { ...@@ -52,7 +53,7 @@ public class DeviceLogServiceImpl implements DeviceLogService {
CompletableFuture.runAsync(()->{ CompletableFuture.runAsync(()->{
deviceLogs.forEach(deviceLog -> { deviceLogs.forEach(deviceLog -> {
DeviceLog deviceLog1 = deviceLogDao.findById(deviceLog.getId()).get(); DeviceLog deviceLog1 = deviceLogDao.findById(deviceLog.getId()).get();
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(deviceLog1)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(deviceLog1));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
deviceLog1.setRecordId(recordId); deviceLog1.setRecordId(recordId);
deviceLogDao.save(deviceLog1); deviceLogDao.save(deviceLog1);
...@@ -77,7 +78,7 @@ public class DeviceLogServiceImpl implements DeviceLogService { ...@@ -77,7 +78,7 @@ public class DeviceLogServiceImpl implements DeviceLogService {
public void sendHash(List<DeviceLogDto> deviceLogDtos) { public void sendHash(List<DeviceLogDto> deviceLogDtos) {
deviceLogDtos.forEach(deviceLogDto -> { deviceLogDtos.forEach(deviceLogDto -> {
DeviceLog deviceLogEntity = deviceLogDto.toDo(); DeviceLog deviceLogEntity = deviceLogDto.toDo();
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(deviceLogEntity)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(deviceLogEntity));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
deviceLogEntity.setRecordId(recordId); deviceLogEntity.setRecordId(recordId);
deviceLogDao.save(deviceLogEntity); deviceLogDao.save(deviceLogEntity);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论