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

上链

上级 d1d6a84f
......@@ -1259,5 +1259,24 @@ public class AllotBillController {
}
/**
* 区块验证
*/
@GetMapping(value ="/checkTrueData/{billId}")
@ApiOperation(value = "根据业务id进行对应业务的验证", notes = "根据业务id进行对应业务的验证")
public ResponseEntity checkTrueData( @PathVariable Integer billId){
return ResponseEntity.ok(allotBillService.checkTrueData(billId));
}
/**
* 区块溯源
*/
@GetMapping(value ="/traceabilityParsing/{billId}")
@ApiOperation(value = "根据业务id进行对应业务的溯源", notes = "根据业务id进行对应业务的溯源")
public ResponseEntity traceabilityParsing( @PathVariable Integer billId){
return ResponseEntity.ok(allotBillService.traceabilityParsing(billId));
}
}
......@@ -170,8 +170,8 @@ public class AllotBackBillServiceImpl implements AllotBackBillService {
@Override
public BlockTraceabilityParsing traceabilityParsing(Integer billId) {
BlockData billTypeAndBillId = blockDataService.findBillTypeAndBillId(BusinessEnum.ALLOT.id, billId);
BcRecord bcRecord = blockService.fetchRecord(BlockBusinessEnum.ALLOT.subCode, billTypeAndBillId.getRecordID());
BlockData billTypeAndBillId = blockDataService.findBillTypeAndBillId(BusinessEnum.ALLOT_BACK.id, billId);
BcRecord bcRecord = blockService.fetchRecord(BlockBusinessEnum.ALLOT_BACK.subCode, billTypeAndBillId.getRecordID());
AllotBackBill allotBackBill = queryAllotBill(billId);
AllotBackBill allotBackBill1 = JSON.parseObject(bcRecord.getData().getContent(), AllotBackBill.class);
BlockTraceabilityParsing blockTraceabilityParsing = bcRecord.getData().toBlockTraceabilityParsing();
......@@ -245,6 +245,11 @@ public class AllotBackBillServiceImpl implements AllotBackBillService {
allotBackBill.setApplyFileList(FilesUtil.stringFileToList(allotBackBill.getApplyFiles()));
allotBackBill.setSendFileList(FilesUtil.stringFileToList(allotBackBill.getSendFiles()));
allotBackBill.setReceiveFileList(FilesUtil.stringFileToList(allotBackBill.getReceiveFiles()));
allotBackBill.setSenderUserA(userPublicService.getOne(allotBackBill.getSendUseraId()).getName());
allotBackBill.setSenderUserB(userPublicService.getOne(allotBackBill.getSendUserbId()).getName());
allotBackBill.setReceiveUserA(userPublicService.getOne(allotBackBill.getReceiveUseraId()).getName());
allotBackBill.setReceiveUserB(userPublicService.getOne(allotBackBill.getReceiveUserbId()).getName());
allotBackBill.setScripts(JacksonUtil.readValue(allotBackBill.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {
}));
return allotBackBill;
......
......@@ -235,7 +235,7 @@ public class AllotBillServiceImpl implements AllotBillService {
taskLogBto.setOldStatus(taskBto.getBillStatus());
taskLogBto.setTaskId(taskId);
taskLogService.addLog(taskLogBto);
return update;
return update;
}
@Override
......@@ -321,6 +321,10 @@ public class AllotBillServiceImpl implements AllotBillService {
allotBill.setApplyFileList(FilesUtil.stringFileToList(allotBill.getApplyFiles()));
allotBill.setSendFileList(FilesUtil.stringFileToList(allotBill.getSendFiles()));
allotBill.setReceiveFileList(FilesUtil.stringFileToList(allotBill.getReceiveFiles()));
allotBill.setSenderUserA(userPublicService.getOne(allotBill.getSendUseraId()).getName());
allotBill.setSenderUserB(userPublicService.getOne(allotBill.getSendUserbId()).getName());
allotBill.setReceiveUserA(userPublicService.getOne(allotBill.getReceiveUseraId()).getName());
allotBill.setReceiveUserB(userPublicService.getOne(allotBill.getReceiveUserbId()).getName());
allotBill.setScripts(JacksonUtil.readValue(allotBill.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {
}));
return allotBill;
......@@ -329,6 +333,7 @@ public class AllotBillServiceImpl implements AllotBillService {
/**
* @param allotBillSelectVo 查询vo
* 查询统一筛选器
......
......@@ -24,6 +24,11 @@
<groupId>com.tykj</groupId>
<artifactId>dev-allot</artifactId>
</dependency>
<dependency>
<groupId>com.tykj</groupId>
<artifactId>dev-block</artifactId>
</dependency>
<dependency>
<groupId>com.tykj</groupId>
<artifactId>dev-library</artifactId>
......
......@@ -980,4 +980,23 @@ public class DeviceApplyController {
// }
/**
* 区块验证
*/
@GetMapping(value ="/checkTrueData/{billId}")
@ApiOperation(value = "根据业务id进行对应业务的验证", notes = "根据业务id进行对应业务的验证")
public ResponseEntity checkTrueData( @PathVariable Integer billId){
return ResponseEntity.ok(deviceApplyBillService.checkTrueData(billId));
}
/**
* 区块溯源
*/
@GetMapping(value ="/traceabilityParsing/{billId}")
@ApiOperation(value = "根据业务id进行对应业务的溯源", notes = "根据业务id进行对应业务的溯源")
public ResponseEntity traceabilityParsing( @PathVariable Integer billId){
return ResponseEntity.ok(deviceApplyBillService.traceabilityParsing(billId));
}
}
......@@ -3,6 +3,7 @@ package com.tykj.dev.device.apply.service;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
import com.tykj.dev.device.apply.subject.vo.*;
import com.tykj.dev.device.block.entity.vo.BlockTraceabilityParsing;
import com.tykj.dev.device.library.subject.vo.ScriptSaveVo;
import java.util.List;
......@@ -46,4 +47,21 @@ public interface DeviceApplyBillService {
ApplyRemoveSeqVo removeSameSeq(RemoveSameSeqVo removeSameSeqVo);
/**
* 溯源接口
* @param billId 业务id
* @return 溯源信息实体
*/
BlockTraceabilityParsing traceabilityParsing(Integer billId);
/**
* 历史数据上链
*/
void historyUpperChain();
boolean checkTrueData(Integer billId);
}
package com.tykj.dev.device.apply.service.impl;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tykj.dev.blockcha.subject.entity.BcHash;
import com.tykj.dev.blockcha.subject.service.BlockChainUtil;
......@@ -8,6 +9,12 @@ import com.tykj.dev.device.apply.repository.DeviceApplyBillDao;
import com.tykj.dev.device.apply.service.DeviceApplyBillService;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
import com.tykj.dev.device.apply.subject.vo.*;
import com.tykj.dev.device.block.entity.BlockData;
import com.tykj.dev.device.block.entity.bc.BcRecord;
import com.tykj.dev.device.block.entity.vo.BlockTraceabilityParsing;
import com.tykj.dev.device.block.entity.vo.TraceabilityParsingData;
import com.tykj.dev.device.block.service.BlockDataService;
import com.tykj.dev.device.block.service.BlockService;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.impl.CacheLibraryServiceImpl;
......@@ -21,11 +28,10 @@ import com.tykj.dev.device.user.read.service.MessageService;
import com.tykj.dev.device.user.read.subject.bto.MessageBto;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.base.BlockBusinessEnum;
import com.tykj.dev.misc.base.BusinessEnum;
import com.tykj.dev.misc.base.StatusEnum;
import com.tykj.dev.misc.utils.DeviceSeqUtil;
import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.StringSplitUtil;
import com.tykj.dev.misc.utils.StringUtils;
import com.tykj.dev.misc.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
......@@ -43,6 +49,12 @@ import static java.util.stream.Collectors.groupingBy;
@Service
public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
@Autowired
BlockService blockService;
@Autowired
BlockDataService blockDataService;
@Autowired
private DeviceApplyBillDao deviceApplyBillDao;
......@@ -73,18 +85,7 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
@Override
public DeviceApplyBill addEntity(DeviceApplyBill deviceApplyBillEntity) {
DeviceApplyBill deviceApplyBill = deviceApplyBillDao.save(deviceApplyBillEntity);
CompletableFuture.runAsync(()->{
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
DeviceApplyBill deviceApplyBill1 = getOne(deviceApplyBill.getId());
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(deviceApplyBill1));
String recordId = bcText.getData().getRecordID();
deviceApplyBill1.setRecordId(recordId);
deviceApplyBillDao.save(deviceApplyBill1);
}, TaskBeanConfig.getThreadPoolTaskScheduler());
sendText(deviceApplyBill.getId());
return deviceApplyBill;
}
......@@ -318,4 +319,88 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
applyRemoveSeqVo.setCount(selectDeviceSeqs.size());
return applyRemoveSeqVo;
}
/**
* 验证接口
*/
@Override
public BlockTraceabilityParsing traceabilityParsing(Integer billId) {
BlockData billTypeAndBillId = blockDataService.findBillTypeAndBillId(BusinessEnum.APPLY.id, billId);
BcRecord bcRecord = blockService.fetchRecord(BlockBusinessEnum.APPLY.subCode, billTypeAndBillId.getRecordID());
DeviceApplyBill deviceApplyBill = queryDeviceApplyBill(billId);
DeviceApplyBill deviceApplyBill1 = JSON.parseObject(bcRecord.getData().getContent(), DeviceApplyBill.class);
BlockTraceabilityParsing blockTraceabilityParsing = bcRecord.getData().toBlockTraceabilityParsing();
blockTraceabilityParsing.setBusinessTraceabilityParsingData(TraceabilityParsingData.builder()
.billTypeName("申请")
.applyNumber(deviceApplyBill.getApplyNumber())
.replayNumber(deviceApplyBill.getReplayNumber())
.fileMd5(deviceApplyBill.getFileMd5())
.unitName(deviceApplyBill.getApplyUnit())
.operationTime(DateUtil.getLocalDateTime(deviceApplyBill.getCreateTime()))
.operatorUserName(operatorName(deviceApplyBill))
.build());
blockTraceabilityParsing.setBlockTraceabilityParsingData(TraceabilityParsingData.builder()
.billTypeName("申请")
.applyNumber(deviceApplyBill1.getApplyNumber())
.replayNumber(deviceApplyBill1.getReplayNumber())
.fileMd5(deviceApplyBill1.getFileMd5())
.unitName(deviceApplyBill1.getApplyUnit())
.operationTime(DateUtil.getLocalDateTime(deviceApplyBill1.getCreateTime()))
.operatorUserName(operatorName(deviceApplyBill1))
.build());
blockTraceabilityParsing.setBlockData(deviceApplyBill1);
blockTraceabilityParsing.setCurrentData(deviceApplyBill);
return blockTraceabilityParsing;
}
@Override
public void historyUpperChain() {
}
private String operatorName(DeviceApplyBill deviceApplyBill) {
StringBuffer buf = new StringBuffer();
buf.append(deviceApplyBill.getApplyUser())
.append(",")
.append(deviceApplyBill.getAgent());
return buf.toString();
}
//验真
@Override
public boolean checkTrueData(Integer billId) {
BlockTraceabilityParsing blockTraceabilityParsing = traceabilityParsing(billId);
boolean contrast = blockDataService.contrast(blockTraceabilityParsing);
return contrast;
}
/**
* 上链接口
*/
public void sendText(Integer id){
DeviceApplyBill deviceApplyBill = queryDeviceApplyBill(id);
blockService.sendText(BlockBusinessEnum.APPLY.subCode, JacksonUtil.toJSon(deviceApplyBill), BusinessEnum.APPLY.id,id,deviceApplyBill.getApplyUnit());
}
private DeviceApplyBill queryDeviceApplyBill(Integer billId){
//获取账单
DeviceApplyBill deviceApplyBillEntity = getOne(billId);
if (deviceApplyBillEntity.getApplyUseraId() != null) {
deviceApplyBillEntity.setApplyUser(userPublicService.getOne(deviceApplyBillEntity.getApplyUseraId()).getName());
}
List<ApplyBillDetailVo> applyBillDetailVos = Objects.requireNonNull(JacksonUtil.readValue(deviceApplyBillEntity.getApplyStat(), new TypeReference<List<ApplyBillDetailVo>>() {
}));
deviceApplyBillEntity.setApplyBillDetailVos(applyBillDetailVos);
return deviceApplyBillEntity;
}
}
......@@ -181,4 +181,9 @@ public class DeviceApplyBill {
@ApiModelProperty(value = "申请装备序列号信息vo")
@Transient
private List<ApplyBillDetailVo> applyBillDetailVos = new ArrayList<>();
@Transient
@ApiModelProperty(value = "文件md5")
private String fileMd5;
}
......@@ -21,12 +21,10 @@ public class BlockRun implements CommandLineRunner {
BlockService blockService;
@Override
public void run(String... args) throws Exception {
// log.info("添加区块业务类型开始");
//// for (BlockBusinessEnum value : BlockBusinessEnum.values()) {
//// if (value.subCode>19) {
//// blockService.subRegister(value.name);
//// }
//// }
// log.info("添加区块业务类型结束");
log.info("添加区块业务类型开始");
for (BlockBusinessEnum value : BlockBusinessEnum.values()) {
blockService.subRegister(value.name);
}
log.info("添加区块业务类型结束");
}
}
......@@ -41,6 +41,10 @@
<groupId>com.tykj</groupId>
<artifactId>dev-file</artifactId>
</dependency>
<dependency>
<groupId>com.tykj</groupId>
<artifactId>dev-block</artifactId>
</dependency>
</dependencies>
......
......@@ -1276,4 +1276,22 @@ public class SelfCheckController {
return ResultUtil.success("1");
}
/**
* 区块验证
*/
@GetMapping(value ="/checkTrueData/{billId}")
@ApiOperation(value = "根据业务id进行对应业务的验证", notes = "根据业务id进行对应业务的验证")
public ResponseEntity checkTrueData( @PathVariable Integer billId){
return ResponseEntity.ok(selfCheckBillService.checkTrueData(billId));
}
/**
* 区块溯源
*/
@GetMapping(value ="/traceabilityParsing/{billId}")
@ApiOperation(value = "根据业务id进行对应业务的溯源", notes = "根据业务id进行对应业务的溯源")
public ResponseEntity traceabilityParsing( @PathVariable Integer billId){
return ResponseEntity.ok(selfCheckBillService.traceabilityParsing(billId));
}
}
......@@ -2,6 +2,7 @@ package com.tykj.dev.device.selfcheck.service;
import com.tykj.dev.config.domin.CheckUnitInfo;
import com.tykj.dev.device.block.entity.vo.BlockTraceabilityParsing;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
......@@ -68,4 +69,20 @@ public interface SelfCheckBillService {
* 只要2周后未完成
*/
List<CheckUnitInfo> selectNoFinSh2Weeks();
/**
* 溯源接口
* @param billId 业务id
* @return 溯源信息实体
*/
BlockTraceabilityParsing traceabilityParsing(Integer billId);
/**
* 历史数据上链
*/
void historyUpperChain();
boolean checkTrueData(Integer billId);
}
......@@ -183,4 +183,14 @@ public class SelfCheckBill {
@Transient
private Integer taskId;
@Transient
private List<DeviceLibrary> deviceLibraries;
@Transient
private List<HistoryDeviceBill> historyDeviceBills;
@Transient
@ApiModelProperty(value = "文件md5")
private String fileMd5;
}
......@@ -809,7 +809,7 @@ public class TrainJobController {
@GetMapping(value ="/traceabilityParsing/{billId}")
@ApiOperation(value = "根据业务id进行对应业务的溯源", notes = "根据业务id进行对应业务的溯源")
public BlockTraceabilityParsing traceabilityParsing(Integer billId) {
public BlockTraceabilityParsing traceabilityParsing(@PathVariable Integer billId) {
BlockData billTypeAndBillId = blockDataService.findBillTypeAndBillId(BusinessEnum.TRAIN.id, billId);
BcRecord bcRecord = blockService.fetchRecord(BlockBusinessEnum.TRAIN.subCode, billTypeAndBillId.getRecordID());
TrainDetailsVo trainDetailsVo = trainThemeService.findSelectDetailsVo(billId);
......@@ -857,7 +857,7 @@ public class TrainJobController {
@GetMapping(value ="/checkTrueData/{billId}")
@ApiOperation(value = "根据业务id进行对应业务的验证", notes = "根据业务id进行对应业务的验证")
public boolean checkTrueData(Integer billId) {
public boolean checkTrueData(@PathVariable Integer billId) {
BlockTraceabilityParsing blockTraceabilityParsing = traceabilityParsing(billId);
boolean contrast = blockDataService.contrast(blockTraceabilityParsing);
return contrast;
......
......@@ -11,4 +11,5 @@ block.flag=false
qrcode.path = /opt/qrcode/
qrcode.preview.path=http://10.153.4.11:8088/equipTest/code/
carrier.url = http://10.153.4.11:8088/carrierTest/configuration/saveConfiguration
file.matching.excel=/data/equipTest/matching/excel/
\ No newline at end of file
file.matching.excel=/data/equipTest/matching/excel/
block.carrier.ip=http://10.153.4.11:8088/blockTest
\ No newline at end of file
......@@ -18,4 +18,6 @@ qrcode.preview.path=http://localhost:8088/equip/code/
carrier.url = http://192.168.0.80:8088/carrier/configuration/saveConfiguration
file.matching.excel=/data/equip/excel/
\ No newline at end of file
file.matching.excel=/data/equip/excel/
block.carrier.ip=http://192.168.0.80:8088/block
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论