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

fix(区块链): 任务、培训 使用text上联

任务、培训 使用text上联
上级 c8e12c0f
...@@ -364,7 +364,6 @@ public class DeviceDecommissioningBusinessServiceImpl implements DeviceDecommiss ...@@ -364,7 +364,6 @@ public class DeviceDecommissioningBusinessServiceImpl implements DeviceDecommiss
deviceLibraryDao.findAllBySeqNumberIn(seqNumbers).forEach( deviceLibraryDao.findAllBySeqNumberIn(seqNumbers).forEach(
deviceLibrary -> { deviceLibrary -> {
logDtos.add(new DeviceLogDto(deviceLibrary.getId(),remark,null,userId,taskId).toDo()); logDtos.add(new DeviceLogDto(deviceLibrary.getId(),remark,null,userId,taskId).toDo());
} }
); );
......
...@@ -121,6 +121,7 @@ public class RepelBusinessServiceImpl implements RepelBusinessService { ...@@ -121,6 +121,7 @@ public class RepelBusinessServiceImpl implements RepelBusinessService {
*/ */
// @Override // @Override
// @Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
//原来的版本
public void initiateRepel1(DeviceRepel deviceRepel, Integer userId,SecurityUser securityUser) { public void initiateRepel1(DeviceRepel deviceRepel, Integer userId,SecurityUser securityUser) {
//生成一个清退任务 省清退任务 类型为 清退统计 17 16清退 //生成一个清退任务 省清退任务 类型为 清退统计 17 16清退
//参照选择的范围给单位都发送 市清退任务待执行 //参照选择的范围给单位都发送 市清退任务待执行
...@@ -197,8 +198,6 @@ public class RepelBusinessServiceImpl implements RepelBusinessService { ...@@ -197,8 +198,6 @@ public class RepelBusinessServiceImpl implements RepelBusinessService {
TaskBto taskBto = statsXTask(units.getUnitId(), deviceRepel1.getId(), "清退型号为" + StringSplitUtil.stringListToString(deviceRepel.getModels().stream() TaskBto taskBto = statsXTask(units.getUnitId(), deviceRepel1.getId(), "清退型号为" + StringSplitUtil.stringListToString(deviceRepel.getModels().stream()
.distinct() .distinct()
.collect(Collectors.toList())) + "设备任务", userId); .collect(Collectors.toList())) + "设备任务", userId);
//给本单位其他专管员阅知
// addMessage(new MessageBto(taskBto.getId(),taskBto.getBusinessType(),user.getName()+"发起清退任务["+deviceRepel1.getTitle()+"]",gainThisUser(userId,units.getUnitId())));
List<RepelTaskStatistical> list = new ArrayList<>(); List<RepelTaskStatistical> list = new ArrayList<>();
deviceRepel.getTaskScopes().forEach( deviceRepel.getTaskScopes().forEach(
unisId -> { unisId -> {
...@@ -207,7 +206,6 @@ public class RepelBusinessServiceImpl implements RepelBusinessService { ...@@ -207,7 +206,6 @@ public class RepelBusinessServiceImpl implements RepelBusinessService {
if (units1.getType() == 2) { if (units1.getType() == 2) {
directlUnderUnit.set(true); directlUnderUnit.set(true);
directlUnderUnitNames.add(units1.getName()); directlUnderUnitNames.add(units1.getName());
// directlUnderUnitDeviceIds.addAll(unitNameMap.get(units1.getName()));
} else if (units1.getType() == 1) { } else if (units1.getType() == 1) {
Area area1 = areaService.findByid(units1.getAreaId()); Area area1 = areaService.findByid(units1.getAreaId());
DeviceRepelDetail deviceRepelDetail = new DeviceRepelDetail(); DeviceRepelDetail deviceRepelDetail = new DeviceRepelDetail();
...@@ -266,7 +264,7 @@ public class RepelBusinessServiceImpl implements RepelBusinessService { ...@@ -266,7 +264,7 @@ public class RepelBusinessServiceImpl implements RepelBusinessService {
} }
//测试版本 //正式版
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void initiateRepel(DeviceRepel deviceRepel, Integer userId,SecurityUser securityUser) { public void initiateRepel(DeviceRepel deviceRepel, Integer userId,SecurityUser securityUser) {
......
package com.tykj.dev.device.task.service.impl; package com.tykj.dev.device.task.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.task.repository.TaskLogDao; import com.tykj.dev.device.task.repository.TaskLogDao;
...@@ -47,7 +48,7 @@ public class TaskLogServiceImpl implements TaskLogService { ...@@ -47,7 +48,7 @@ public class TaskLogServiceImpl implements TaskLogService {
TaskLog taskLog = taskLogDao.save(taskLogBto.toDo()); TaskLog taskLog = taskLogDao.save(taskLogBto.toDo());
CompletableFuture.runAsync(() ->{ CompletableFuture.runAsync(() ->{
TaskLog taskLog1 = taskLogDao.findById(taskLog.getId()).get(); TaskLog taskLog1 = taskLogDao.findById(taskLog.getId()).get();
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(taskLog1)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(taskLog1));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
taskLog1.setRecordId(recordId); taskLog1.setRecordId(recordId);
taskLogDao.save(taskLog1); taskLogDao.save(taskLog1);
...@@ -57,7 +58,7 @@ public class TaskLogServiceImpl implements TaskLogService { ...@@ -57,7 +58,7 @@ public class TaskLogServiceImpl implements TaskLogService {
@Async("taskScheduler") @Async("taskScheduler")
public void sendHash(TaskLog taskLog) { public void sendHash(TaskLog taskLog) {
CompletableFuture.runAsync(() ->{ CompletableFuture.runAsync(() ->{
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(taskLog)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(taskLog));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
taskLog.setRecordId(recordId); taskLog.setRecordId(recordId);
taskLogDao.save(taskLog); taskLogDao.save(taskLog);
......
...@@ -3,6 +3,7 @@ package com.tykj.dev.device.task.service.impl; ...@@ -3,6 +3,7 @@ package com.tykj.dev.device.task.service.impl;
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.GlobalMap; import com.tykj.dev.config.GlobalMap;
import com.tykj.dev.config.Log; import com.tykj.dev.config.Log;
...@@ -348,7 +349,7 @@ public class TaskServiceImpl implements TaskService { ...@@ -348,7 +349,7 @@ public class TaskServiceImpl implements TaskService {
e.printStackTrace(); e.printStackTrace();
} }
Task task1 = taskDao.findById(task.getId()).get(); Task task1 = taskDao.findById(task.getId()).get();
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(task1)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(task1));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
task1.setRecordId(recordId); task1.setRecordId(recordId);
taskDao.save(task1); taskDao.save(task1);
...@@ -364,7 +365,7 @@ public class TaskServiceImpl implements TaskService { ...@@ -364,7 +365,7 @@ public class TaskServiceImpl implements TaskService {
public void sendHash(List<TaskBto> taskBtos) { public void sendHash(List<TaskBto> taskBtos) {
taskBtos.forEach(taskBto -> { taskBtos.forEach(taskBto -> {
Task task = taskBto.toDo(); Task task = taskBto.toDo();
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(task)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(task));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
task.setRecordId(recordId); task.setRecordId(recordId);
update(task.parse2Bto()); update(task.parse2Bto());
...@@ -378,7 +379,7 @@ public class TaskServiceImpl implements TaskService { ...@@ -378,7 +379,7 @@ public class TaskServiceImpl implements TaskService {
@Async("taskScheduler") @Async("taskScheduler")
public void sendHash(TaskBto taskBto) { public void sendHash(TaskBto taskBto) {
Task task = taskBto.toDo(); Task task = taskBto.toDo();
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(task)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(task));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
task.setRecordId(recordId); task.setRecordId(recordId);
update(task.parse2Bto()); update(task.parse2Bto());
......
...@@ -2,6 +2,7 @@ package com.tykj.dev.device.train.controller; ...@@ -2,6 +2,7 @@ package com.tykj.dev.device.train.controller;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
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.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.file.service.FilesUtil; import com.tykj.dev.device.file.service.FilesUtil;
...@@ -747,7 +748,7 @@ public class TrainJobController { ...@@ -747,7 +748,7 @@ public class TrainJobController {
TrainUser trainUser1 = trainUserDao.save(trainUser); TrainUser trainUser1 = trainUserDao.save(trainUser);
//异步线程 //异步线程
CompletableFuture.runAsync(()-> { CompletableFuture.runAsync(()-> {
BcHash bcHash = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(trainUser1)); BcText bcHash = blockChainUtil.sendText(1000, JacksonUtil.toJSon(trainUser1));
trainUserDao.upDate(bcHash.getData().getRecordID(),trainUser1.getId()); trainUserDao.upDate(bcHash.getData().getRecordID(),trainUser1.getId());
}); });
} }
......
...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.type.TypeReference; ...@@ -4,6 +4,7 @@ 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.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.file.service.FilesUtil; import com.tykj.dev.device.file.service.FilesUtil;
...@@ -93,7 +94,7 @@ public class TrainThemeServiceImpl implements TrainThemeService { ...@@ -93,7 +94,7 @@ public class TrainThemeServiceImpl implements TrainThemeService {
e.printStackTrace(); e.printStackTrace();
} }
TrainTheme trainTheme2 = findById(trainTheme1.getTrainId()); TrainTheme trainTheme2 = findById(trainTheme1.getTrainId());
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(trainTheme2)); BcText bcText = blockChainUtil.sendText(1000, JacksonUtil.toJSon(trainTheme2));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
trainTheme2.setRecordId(recordId); trainTheme2.setRecordId(recordId);
trainThemeDao.save(trainTheme2); trainThemeDao.save(trainTheme2);
...@@ -108,7 +109,7 @@ public class TrainThemeServiceImpl implements TrainThemeService { ...@@ -108,7 +109,7 @@ public class TrainThemeServiceImpl implements TrainThemeService {
@Async @Async
public void sendHash(List<TrainTheme> trainThemes) { public void sendHash(List<TrainTheme> trainThemes) {
trainThemes.forEach(trainTheme1 -> { trainThemes.forEach(trainTheme1 -> {
BcHash bcHash=blockChainUtil.sendHash(1000,JacksonUtil.toJSon(trainTheme1)); BcText bcHash=blockChainUtil.sendText(1000,JacksonUtil.toJSon(trainTheme1));
trainTheme1.setRecordId(bcHash.getData().getRecordID()); trainTheme1.setRecordId(bcHash.getData().getRecordID());
trainThemeDao.save(trainTheme1); trainThemeDao.save(trainTheme1);
}); });
...@@ -379,7 +380,7 @@ public class TrainThemeServiceImpl implements TrainThemeService { ...@@ -379,7 +380,7 @@ public class TrainThemeServiceImpl implements TrainThemeService {
TrainUser trainUser1 = trainUserDao.save(trainUser); TrainUser trainUser1 = trainUserDao.save(trainUser);
//异步线程 //异步线程
CompletableFuture.runAsync(()-> { CompletableFuture.runAsync(()-> {
BcHash bcHash = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(trainUser1)); BcText bcHash = blockChainUtil.sendText(1000, JacksonUtil.toJSon(trainUser1));
trainUserDao.upDate(bcHash.getData().getRecordID(),trainUser1.getId()); trainUserDao.upDate(bcHash.getData().getRecordID(),trainUser1.getId());
}); });
return trainUser1; return trainUser1;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论