合同录入
环境复杂度
- [合同编号重复]
Snowflake snowflake = IdUtil.getSnowflake();
String id = "HT"+snowlake.nextId();
- [身份证号码格式不正确]
/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|[xX])$/
- 租客身份证和租客姓名不真实 api服务入口
@PostMapping("/verify")
public Result<Boolean> verify(@RequestBody Contract contract) {
Map<String,Object> map = new HashMap<>();
map.put("idNo", contract.getIdNo());
map.put("name", contract.getName());
String body = HttpRequest.post("https://idenauthen.market.alicloudapi.com/idenAuthentication")
.header("Authorization", "APPCODE b30006ab97e44f33b9398fd90094e676")
.form(map)
.execute()
.body();
System.out.println(body);
int index = body.indexOf("身份证信息匹配");
return Result.ok(index>0);
}
- [计算合同金额精度缺失]
- 主要涉及BigDecimal的计算。
BigDecimal first = BigDecimal.valueOf(10.22);
BigDecimal second = BigDecimal.valueOf(8);
BigDecimal sum = first.add(second);
BigDecimal subtract = first.subtract(second);
BigDecimal subtract2 = second.subtract(first);
BigDecimal multiply = first.multiply(second);
BigDecimal divide = first.divide(second);
boolean bigger = first.compareTo(second) > 0;
boolean equal = first.compareTo(BigDecimal.valueOf(10.220)) == 0;
boolean less = second.compareTo(first) < 0;
- [reddssion 分布式锁]
引入依赖:
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.15.5</version>
</dependency>
添加配置:
spring:
redis:
redisson:
singleServerConfig:
password: 123456
address: "/redis:127.0.0.1:6379"
使用代码:
@GetMapping("/lock/test")
public boolean lock(int id) {
RLock lock = redissonClient.getLock("test-lock-reddison" + id);
try {
lock.lock(1, TimeUnit.SECONDS);
Thread.sleep(10000);
return true;
}catch (InterruptedException e) {
}finally {
lock.unlock();
}
return false;
}
收房合同录入功能
- 合同信息录入
- 合同录入选择房产
- 附件处理
- 付款单生成