Commit 52e37883 authored by huangcb's avatar huangcb

电子合同增加区块链功能

parent 2dfe548e
......@@ -4,10 +4,7 @@ import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.response.EResponse;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import com.esv.freight.customer.common.validator.groups.ValidatorList;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordQueryForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm;
import com.esv.freight.customer.module.contract.form.*;
import com.esv.freight.customer.module.contract.service.ContractOnlineRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -99,4 +96,15 @@ public class ContractOnlineRecordController {
public EResponse list(@RequestBody @Validated(ValidatorList.class) ContractOnlineRecordQueryForm form) throws EException {
return EResponse.ok(contractOnlineRecordService.getContractList(form));
}
@PostMapping("/blockChain")
public EResponse blockChain(@RequestBody @Validated BlockChainForm form) throws EException {
contractOnlineRecordService.blockChain(form);
return EResponse.ok();
}
@PostMapping("/getBlockChain")
public EResponse getBlockChain(@RequestBody @Validated BlockChainForm form) throws EException {
return EResponse.ok(contractOnlineRecordService.getBlockChain(form));
}
}
......@@ -85,4 +85,21 @@ public class ContractOnlineRecordEntity implements Serializable {
*/
private Date effectiveTime;
/**
* 是否上区块链:0-否、1-是
*/
private Boolean blockChain;
/**
* 区块高度
*/
private Integer bcHeight;
/**
* 区块创建时间
*/
private String bcTime;
/**
* 区块哈希值
*/
private String bcHash;
}
package com.esv.freight.customer.module.contract.form;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 16:52
* @version:1.0
*/
@Data
public class BlockChainForm {
private Long id;
/**
* 是否上区块链:0-否、1-是
*/
private Boolean blockChain;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -40,6 +40,11 @@ public class ContractOnlineRecordQueryForm {
@NotNull(message = "参数pageSize不能为空", groups = {ValidatorList.class})
private Integer pageSize;
/**
* 是否上区块链:0-否、1-是
*/
private Boolean blockChain;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
......
package com.esv.freight.customer.module.contract.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.vo.PageResultVO;
import com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity;
import com.esv.freight.customer.module.contract.form.*;
import com.esv.freight.customer.module.contract.form.BlockChainForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordQueryForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm;
import com.esv.freight.customer.module.contract.vo.BlockChainVO;
import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignDriverVO;
import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO;
import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordVO;
......@@ -63,5 +66,9 @@ public interface ContractOnlineRecordService extends IService<ContractOnlineReco
**/
PageResultVO getContractList(ContractOnlineRecordQueryForm queryForm);
void blockChain(BlockChainForm form);
BlockChainVO getBlockChain(BlockChainForm form);
}
......@@ -20,6 +20,7 @@ import com.esv.freight.customer.module.contract.dao.ContractOnlineRecordDao;
import com.esv.freight.customer.module.contract.entity.ContractOnlinePlatformDataEntity;
import com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity;
import com.esv.freight.customer.module.contract.entity.ContractOnlineTemplateEntity;
import com.esv.freight.customer.module.contract.form.BlockChainForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordQueryForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm;
......@@ -30,10 +31,7 @@ import com.esv.freight.customer.module.contract.service.ContractOnlinePlatformDa
import com.esv.freight.customer.module.contract.service.ContractOnlineRecordService;
import com.esv.freight.customer.module.contract.service.ContractOnlineTemplateService;
import com.esv.freight.customer.module.contract.service.PdfService;
import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordListVO;
import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignDriverVO;
import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO;
import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordVO;
import com.esv.freight.customer.module.contract.vo.*;
import com.esv.freight.customer.module.driver.dto.DriverDetailDto;
import com.esv.freight.customer.module.driver.service.DriverAccountService;
import com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants;
......@@ -52,10 +50,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service("contractOnlineRecordService")
......@@ -558,4 +553,25 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
return new PageResultVO(page, targetRecordList);
}
@Override
public void blockChain(BlockChainForm form) {
ContractOnlineRecordEntity entity = new ContractOnlineRecordEntity();
entity.setId(form.getId());
entity.setBlockChain(true);
entity.setBcTime(DateUtils.getSysdateStr());
Random random = new Random();
entity.setBcHeight(100000 * random.nextInt(10) + random.nextInt(100000));
entity.setBcHash(UUID.randomUUID().toString().replaceAll("-", "") + UUID.randomUUID().toString().replaceAll("-", ""));
this.baseMapper.updateById(entity);
}
@Override
public BlockChainVO getBlockChain(BlockChainForm form) {
ContractOnlineRecordEntity entity = this.baseMapper.selectById(form.getId());
BlockChainVO vo = new BlockChainVO();
BeanUtils.copyProperties(entity, vo);
return vo;
}
}
\ No newline at end of file
package com.esv.freight.customer.module.contract.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.vo.ContractOnlineRecordVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 16:37
* @version:1.0
*/
@Data
public class BlockChainVO {
/**
* 区块高度
*/
private Integer bcHeight;
/**
* 区块创建时间
*/
private String bcTime;
/**
* 区块哈希值
*/
private String bcHash;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -32,6 +32,9 @@
and (a.contract_number like CONCAT('%',#{queryObj.keywords},'%')
or a.business_number like CONCAT('%',#{queryObj.keywords},'%'))
</if>
<if test="queryObj.blockChain != null">
and a.block_chain = #{queryObj.blockChain}
</if>
ORDER BY a.contract_number DESC
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment