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

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

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