提交 57c22074 authored 作者: zjm's avatar zjm

上链信息接口提交

上级 93d722e6
......@@ -80,10 +80,8 @@ public class AllotBackBillServiceImpl implements AllotBackBillService {
public AllotBackBill addEntity(AllotBackBill allotBackBill) {
AllotBackBill allotBackBill1 = allotBackBillDao.save(allotBackBill);
//异步上链
CompletableFuture.runAsync(()->{
//延迟2s防止同时写入
sendText(allotBackBill1.getId());
}, TaskBeanConfig.getThreadPoolTaskScheduler());
return allotBackBill1;
}
......
......@@ -85,10 +85,9 @@ public class AllotBillServiceImpl implements AllotBillService {
public AllotBill addEntity(AllotBill allotBillEntity) {
AllotBill allotBill = allotBillDao.save(allotBillEntity);
//异步上链
CompletableFuture.runAsync(() ->{
//延迟2s防止同时写入
sendText(allotBill.getId());
}, TaskBeanConfig.getThreadPoolTaskScheduler());
return allotBill;
}
......@@ -321,10 +320,18 @@ 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());
if (allotBill.getSendUseraId() != null){
allotBill.setSenderUserA(userPublicService.getOne(allotBill.getSendUseraId()).getName());
}
if (allotBill.getSendUserbId() != null){
allotBill.setSenderUserB(userPublicService.getOne(allotBill.getSendUserbId()).getName());
}
if (allotBill.getReceiveUseraId() != null) {
allotBill.setReceiveUserA(userPublicService.getOne(allotBill.getReceiveUseraId()).getName());
}
if (allotBill.getReceiveUserbId() != null) {
allotBill.setReceiveUserB(userPublicService.getOne(allotBill.getReceiveUserbId()).getName());
}
allotBill.setScripts(JacksonUtil.readValue(allotBill.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {
}));
return allotBill;
......
package com.tykj.dev.device.block.controller;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.block.entity.bc.BcRegister;
import com.tykj.dev.device.block.service.BlockDataService;
import com.tykj.dev.device.block.service.BlockService;
import com.tykj.dev.misc.base.BlockBusinessEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* @program: carrier
* @description: todo
* @author: zjm
* @create: 2022-10-20 19:38
**/
......@@ -32,12 +37,13 @@ public class BlockController {
BlockDataService blockDataService;
// @ApiOperation(value = "test", notes = "区块链")
// @GetMapping("/test")
// public ResponseEntity test(){
// //AffQaQ55FCuQNqF3bj6nsMytMqbGUDrHe8VDXqb1cPgd7K1yB8X
// return ResponseEntity.ok(blockService.sendText(1,1004,"{text}"));
// }
@ApiOperation(value = "", notes = "区块链")
@GetMapping("/test/{code}/{content}")
public ResponseEntity test(@PathVariable Integer code, @PathVariable String content){
//AffQaQ55FCuQNqF3bj6nsMytMqbGUDrHe8VDXqb1cPgd7K1yB8X
blockService.sendText(code,content,9999,0,"1");
return ResponseEntity.ok("成功");
}
@ApiOperation(value = "查询最新的20条数据", notes = "区块大屏")
......@@ -48,5 +54,15 @@ public class BlockController {
@ApiOperation(value = "装备业务类型创建接口", notes = "区块大屏")
@GetMapping("/subRegister")
public ResponseEntity subRegister(){
List<BcRegister> bcRegisters=new ArrayList<>();
for (BlockBusinessEnum value : BlockBusinessEnum.values()) {
BcRegister bcRegister = blockService.subRegister(value.name);
bcRegisters.add(bcRegister);
}
return ResponseEntity.ok(bcRegisters);
}
}
......@@ -18,6 +18,6 @@ public interface BlockDataDao extends JpaRepository<BlockData,Integer>, JpaSpeci
List<BlockData> findAllByBillTypeAndBillId(Integer billType, Integer billId);
@Query(value = "select b from BlockData as b order by b.createTime desc")
@Query(value = "select b from BlockData as b order by b.id desc")
List<BlockData> queryCreateTimeLimit20(PageRequest pageRequest);
}
......@@ -21,10 +21,10 @@ public class BlockRun implements CommandLineRunner {
BlockService blockService;
@Override
public void run(String... args) throws Exception {
log.info("添加区块业务类型开始");
for (BlockBusinessEnum value : BlockBusinessEnum.values()) {
blockService.subRegister(value.name);
}
log.info("添加区块业务类型结束");
// log.info("添加区块业务类型开始");
// for (BlockBusinessEnum value : BlockBusinessEnum.values()) {
// blockService.subRegister(value.name);
// }
// log.info("添加区块业务类型结束");
}
}
......@@ -66,9 +66,11 @@ public class BlockServiceImpl implements BlockService {
.billType(billType)
.recordID(bcText.getData().getRecordID()).build());
}else {
throw new ApiException(bcText.getInfo());
}
}catch (Exception e){
log.error("错误:{}",e.getLocalizedMessage());
log.info("上链失败");
}
}
......
......@@ -94,7 +94,10 @@ public class DeviceDestroyBillServiceImpl implements DeviceDestroyBillService {
Optional<DeviceDestroyBill> byId = deviceDestroyBillDao.findById(scrapId);
if (byId.isPresent()){
DeviceDestroyBill deviceDestroyBill=byId.get();
deviceDestroyBill.setScripts(JacksonUtil.readValue(deviceDestroyBill.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {}));
if (deviceDestroyBill.getScriptJson()!=null) {
deviceDestroyBill.setScripts(JacksonUtil.readValue(deviceDestroyBill.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {
}));
}
deviceDestroyBill.setApplyFileList(FilesUtil.stringFileToList(deviceDestroyBill.getApplyFiles()));
deviceDestroyBill.setDestructionFileList(FilesUtil.stringFileToList(deviceDestroyBill.getDestructionFiles()));
deviceDestroyBill.setReplayFileList(FilesUtil.stringFileToList(deviceDestroyBill.getReplayFiles()));
......
......@@ -250,13 +250,16 @@ public class ScrapServiceImpl implements ScrapService {
Optional<Scrap> optional = scrapDao.findById(scrapId);
if (optional.isPresent()){
Scrap scrap=optional.get();
List<ScriptSaveVo> scriptSaveVos = JacksonUtil.readValue(scrap.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {
});
if (scrap.getScriptJson()!=null) {
List<ScriptSaveVo> scriptSaveVos = JacksonUtil.
readValue(scrap.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {
});
}
scrap.setBillFiles(FilesUtil.stringFileToList(scrap.getBillFile()));
scrap.setOutboundFiles(FilesUtil.stringFileToList(scrap.getOutboundFile()));
scrap.setReplyFileList(FilesUtil.stringFileToList(scrap.getReplyFiles()));
scrap.setApplyFileList(FilesUtil.stringFileToList(scrap.getApplyFiles()));
scrap.setScripts(scriptSaveVos);
scrap.setScripts(scrap.getScripts());
scrap.setFileMd5(FileMD5Util.fileRetToMd5(scrap.getOutboundFiles()));
return scrap;
}else {
......
......@@ -282,7 +282,7 @@ public class DeviceRepelDetailServiceImpl implements DeviceRepelDetailService {
*/
public void sendText(Integer id){
DeviceRepelDetail deviceRepelDetail = queryDeviceRepelDetail(id);
blockService.sendText(BlockBusinessEnum.SEND_BACK.subCode, JSON.toJSONStringWithDateFormat(deviceRepelDetail,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteDateUseDateFormat), BusinessEnum.DESTROY.id,id,deviceRepelDetail.getSendUnit());
blockService.sendText(BlockBusinessEnum.SEND_BACK.subCode, JSON.toJSONStringWithDateFormat(deviceRepelDetail,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteDateUseDateFormat), BusinessEnum.SEND_BACK.id,id,deviceRepelDetail.getSendUnit());
}
......@@ -290,16 +290,16 @@ public class DeviceRepelDetailServiceImpl implements DeviceRepelDetailService {
Optional<DeviceRepelDetail> optional = deviceRepelDetailDao.findById(repelDetailId);
if (optional.isPresent()){
DeviceRepelDetail deviceRepelDetail=optional.get();
deviceRepelDetail.setScripts(JacksonUtil.readValue(deviceRepelDetail.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {
}));
if (deviceRepelDetail.getScriptJson()!=null) {
deviceRepelDetail.setScripts(JacksonUtil.readValue(deviceRepelDetail.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {
}));
}
deviceRepelDetail.setBillFiles(FilesUtil.stringFileToList(deviceRepelDetail.getBillFile()));
deviceRepelDetail.setOutboundFiles(FilesUtil.stringFileToList(deviceRepelDetail.getOutboundFile()));
deviceRepelDetail.setInFiles(FilesUtil.stringFileToList(deviceRepelDetail.getInFile()));
deviceRepelDetail.setApplyFileList(FilesUtil.stringFileToList(deviceRepelDetail.getApplyFiles()));
deviceRepelDetail.setReplyFileList(FilesUtil.stringFileToList(deviceRepelDetail.getReplyFiles()));
deviceRepelDetail.setFileMd5(FileMD5Util.fileRetToMd5(deviceRepelDetail.getOutboundFiles()));
deviceRepelDetail.setDeviceIds(null);
deviceRepelDetail.setScriptJson(null);
return deviceRepelDetail;
}else {
log.info("[清退] 详情查看错误,id没有找到{}",repelDetailId);
......
......@@ -188,7 +188,6 @@
<dependency>
<groupId>com.tykj</groupId>
<artifactId>dev-block</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
......
......@@ -25,3 +25,4 @@ block.carrier.ip=http://localhost:8088
carrier.url = http://192.168.0.101:8087/configuration/saveConfiguration
file.matching.excel=/Users/zhoushaopan/excel/
check.time.last=/Users/zjm/code/test-tu/check
\ No newline at end of file
......@@ -12,4 +12,5 @@ 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/
block.carrier.ip=http://10.153.4.11:8088/blockTest
\ No newline at end of file
block.carrier.ip=http://10.153.4.11:8088/blockTest
check.time.last=/opt/zb/check
\ No newline at end of file
spring.datasource.driver-class-name=com.oscar.Driver
#spring.datasource.url=jdbc:oscar://10.153.4.10:2003/OSRDB
spring.datasource.url=jdbc:oscar://localhost:2003/OSRDB
spring.datasource.url=jdbc:oscar://192.168.0.80:2003/OSRDB
spring.datasource.username=SYSDBA
spring.datasource.password=szoscar55
spring.jpa.database-platform=org.hibernate.dialect.OscarDialect
......@@ -20,4 +20,5 @@ carrier.url = http://192.168.0.80:8088/carrier/configuration/saveConfiguration
file.matching.excel=/data/equip/excel/
block.carrier.ip=http://192.168.0.80:8088/block
\ No newline at end of file
block.carrier.ip=http://192.168.0.80:8088/block
check.time.last=/opt/zb/check
\ No newline at end of file
......@@ -107,7 +107,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.cors()
.and()
.authorizeRequests()
.antMatchers("/file/**","/actuator/**","/admin/**","/excel/**").permitAll()
.antMatchers("/file/**","/actuator/**","/admin/**","/excel/**","/chainOffer/**").permitAll()
.antMatchers("/file/llq/**").permitAll()
.antMatchers("/login/impersonate*").permitAll()
.antMatchers("/logout/impersonate*").permitAll()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论