提交 55eeda21 authored 作者: zjm's avatar zjm

feat(区块模块): 添加了区块链模块

添加了区块链模块
上级 a63357bc
......@@ -29,16 +29,19 @@ import javax.persistence.Table;
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update zt_block_data set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@Table(name = "zt_block_bill_data")
@Table(name = "zb_block_bill_data")
@Builder
public class BlockData extends BaseEntity {
@ApiModelProperty(value = "业务类型")
private Integer billType;
@ApiModelProperty(value = "业务id")
private Integer billId;
@ApiModelProperty(value = "记录id")
private String recordID;
@ApiModelProperty(value = "发起单位名称")
private String unitName;
......
......@@ -23,7 +23,7 @@ public interface BlockService {
* @param subCode 业务代码编号
* @param content 文本 200k以内
*/
BcText sendText(Integer systemId, Integer subCode, String content);
void sendText(Integer systemId, Integer subCode, String content,Integer billType,Integer billId,String unitName);
/**
* hash 上链
......
package com.tykj.dev.device.block.service.impl;
import com.tykj.dev.device.block.conf.ApI;
import com.tykj.dev.device.block.entity.BlockData;
import com.tykj.dev.device.block.entity.bc.*;
import com.tykj.dev.device.block.service.BlockDataService;
import com.tykj.dev.device.block.service.BlockService;
import com.tykj.dev.misc.exception.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
......@@ -17,11 +22,15 @@ import java.util.TreeMap;
* @create: 2022-11-02 11:25
**/
@Service
@Slf4j
public class BlockServiceImpl implements BlockService {
@Value("${block.carrier.ip}")
private String IP;
@Autowired
BlockDataService blockDataService;
@Override
public BcRegister subRegister(Integer systemId, String subName) {
......@@ -38,16 +47,30 @@ public class BlockServiceImpl implements BlockService {
}
@Override
public BcText sendText(Integer systemId, Integer subCode, String content) {
public void sendText(Integer systemId, Integer subCode, String content,Integer billType,Integer billId,String unitName) {
SortedMap<Object, Object> request = getRequest();
request.put("systemId", systemId);
request.put("subCode", subCode);
request.put("content", content);
return new RestTemplate().postForObject(
IP + ApI.CO_SEND_TEXT,
request,
BcText.class);
try {
BcText bcText = new RestTemplate().postForObject(
IP + ApI.CO_SEND_TEXT,
request,
BcText.class);
if (bcText.getCode() == 0) {
blockDataService.saveBlockData(BlockData.builder()
.billId(billId)
.unitName(unitName)
.billType(billType)
.recordID(bcText.getData().getRecordID()).build());
}else {
throw new ApiException(bcText.getInfo());
}
}catch (Exception e){
log.info("上链失败");
}
}
@Override
......
package com.tykj.dev.misc.base;
import lombok.AllArgsConstructor;
/**
* @author dengdiyi
* 业务枚举
*/
@AllArgsConstructor
public enum BlockBusinessEnum {
/**
* 入库业务
*/
STORAGE(2, "入库业务"),
/**
* 配发业务
*/
ALLOT(3, "配发业务"),
/**
* 自查业务
*/
SELF_CHECK(4, "自查业务"),
/**
* 维修业务
*/
REPAIR(5, "维修业务"),
/**
* 核查业务
*/
CONFIRM_CHECK(6, "核查业务"),
/**
* 核查统计业务
*/
CONFIRM_CHECK_STAT(7, "核查统计"),
/**
* 核查详情业务
*/
CONFIRM_CHECK_DETAIL(8, "核查详情"),
/**
* 申请业务
*/
APPLY(9, "申请业务"),
/**
* 维修退回
*/
REPAIR_BACK(10, "维修退回"),
/**
* 维修继续送修
*/
REPAIR_SEND(11, "维修业务"),
/**
* 销毁业务
*/
DESTROY(14, "销毁业务"),
/**
* 清退业务
*/
SEND_BACK(16, "清退业务"),
/**
* 清退异常处理
*/
DECOMMISSIONING(17, "退役业务"),
/**
* 新增配套设备
*/
ADD_MATCHING_DEVICE(19, "新增配套设备"),
/**
* 工作交接
*/
WORK_HANDOVER(21, "工作交接"),
/**
* 退回
*/
ALLOT_BACK(22, "退回业务"),
/**
* 报废
*/
SCRAP(23, "报废业务"),
/**
* 丢失
*/
LOSS(24,"丢失业务"),
/**
* 找回
*/
RETRIEVE(25,"找回业务"),
/**
* 重新入库
*/
AGAINSTORAGE(26,"装备状态转换业务");
public Integer subCode;
public String name;
}
......@@ -541,24 +541,24 @@
</plugin>
<!--打包插件-->
<!--<plugin>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-maven-plugin</artifactId>-->
<!--<configuration>-->
<!--<executable>true</executable>-->
<!--<includeSystemScope>true</includeSystemScope>-->
<!--<mainClass>com.tykj.dev.union.UnionApplication</mainClass>-->
<!--</configuration>-->
<!--</plugin>-->
<!--&lt;!&ndash;跳过测试插件&ndash;&gt;-->
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-surefire-plugin</artifactId>-->
<!--<version>2.20</version>-->
<!--<configuration>-->
<!--<skipTests>true</skipTests> &lt;!&ndash;默认关掉单元测试 &ndash;&gt;-->
<!--</configuration>-->
<!--</plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <executable>true</executable>-->
<!-- <includeSystemScope>true</includeSystemScope>-->
<!-- <mainClass>com.tykj.dev.union.UnionApplication</mainClass>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- &lt;!&ndash;跳过测试插件&ndash;&gt;-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-surefire-plugin</artifactId>-->
<!-- <version>2.20</version>-->
<!-- <configuration>-->
<!-- <skipTests>true</skipTests> &lt;!&ndash;默认关掉单元测试 &ndash;&gt;-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
</build>
</project>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论