Commit 61d035e8 authored by hezhuozhi's avatar hezhuozhi

去除重复的农户编号

parent a438487a
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -763,7 +764,12 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
if(da.getRegionalAddress()==null||da.getRegionalAddress().isEmpty()){
throw new BadRequest("区域公司省市区为空, 请设置省市区");
}
String code= NumberUtil.getCode(CodeEnum.农户.getCode(),da.getCompanyCode(),da.getRegionalAddress());
//为了去重,暂时这样处理加两位随机数,同时在查询一次
String code=NumberUtil.getCode(CodeEnum.农户.getCode(),da.getCompanyCode(),da.getRegionalAddress())+ RandomUtil.randomNumbers(2);
Integer count = peasantHouseholdMapper.selectCount(new LambdaQueryWrapper<PeasantHousehold>().eq(PeasantHousehold::getPeasantHouseholdNo, code));
if(count>0){
code= NumberUtil.getCode(CodeEnum.农户.getCode(),da.getCompanyCode(),da.getRegionalAddress())+ RandomUtil.randomNumbers(2);
}
return code;
}
......
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