|
|
@ -17,12 +17,14 @@ |
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
@ -31,10 +33,13 @@ import com.epmet.dao.AreaCodeChildDao; |
|
|
|
import com.epmet.dao.AreaCodeDao; |
|
|
|
import com.epmet.dto.AreaCodeChildDTO; |
|
|
|
import com.epmet.dto.AreaCodeDTO; |
|
|
|
import com.epmet.dto.form.AddAreaCodeDictFormDTO; |
|
|
|
import com.epmet.dto.form.AreaCodeDictFormDTO; |
|
|
|
import com.epmet.dto.result.AddAreaCodeDictResultDTO; |
|
|
|
import com.epmet.dto.result.AreaCodeDictResultDTO; |
|
|
|
import com.epmet.entity.AreaCodeEntity; |
|
|
|
import com.epmet.redis.AreaCodeRedis; |
|
|
|
import com.epmet.service.AreaCodeChildService; |
|
|
|
import com.epmet.service.AreaCodeService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -58,7 +63,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
private AreaCodeRedis areaCodeRedis; |
|
|
|
@Autowired |
|
|
|
private AreaCodeChildDao childDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AreaCodeChildService areaCodeChildService; |
|
|
|
@Override |
|
|
|
public PageData<AreaCodeDTO> page(Map<String, Object> params) { |
|
|
|
IPage<AreaCodeEntity> page = baseDao.selectPage( |
|
|
@ -554,4 +560,44 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn |
|
|
|
} |
|
|
|
return threeDto; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @author yinzuomei |
|
|
|
* @description 003、新增街道或者社区地区编码 |
|
|
|
* @Date 2021/2/5 17:39 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public AddAreaCodeDictResultDTO addStreetCommAreaCode(AddAreaCodeDictFormDTO formDTO) { |
|
|
|
AreaCodeChildDTO parent = childDao.selectByCode(formDTO.getParentAreaCode().trim()); |
|
|
|
if (null == parent) { |
|
|
|
throw new RenException("parentAreaCode不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
//同一级不允许重名
|
|
|
|
List<AreaCodeChildDTO> list = childDao.selectByPCodeAndName(formDTO.getParentAreaCode().trim(), formDTO.getName().trim()); |
|
|
|
if (CollUtil.isNotEmpty(list)) { |
|
|
|
throw new RenException("name已存在"); |
|
|
|
} |
|
|
|
AreaCodeChildDTO areaCodeChildDTO = new AreaCodeChildDTO(); |
|
|
|
areaCodeChildDTO.setName(formDTO.getName().trim()); |
|
|
|
areaCodeChildDTO.setPCode(formDTO.getParentAreaCode().trim()); |
|
|
|
//4:街道;5:社区或村委会
|
|
|
|
areaCodeChildDTO.setLevel(formDTO.getParentAreaCode().length() == NumConstant.SIX ? NumConstant.FOUR : NumConstant.FIVE); |
|
|
|
//获取子级中最大的编码
|
|
|
|
AreaCodeChildDTO maxChildDto = childDao.selectMaxChild(formDTO.getParentAreaCode().trim()); |
|
|
|
if (null == maxChildDto) { |
|
|
|
//默认添加001
|
|
|
|
areaCodeChildDTO.setCode(formDTO.getParentAreaCode().concat("001_UD")); |
|
|
|
} else { |
|
|
|
//去掉_UD +1赋值;370124001225_UD 锦源社区
|
|
|
|
String[] codeArr = maxChildDto.getCode().split(StrConstant.UNDER_LINE); |
|
|
|
long code = Long.parseLong(codeArr[NumConstant.ZERO]) + NumConstant.ONE; |
|
|
|
areaCodeChildDTO.setCode(String.valueOf(code)); |
|
|
|
} |
|
|
|
//保存到area_code_child表
|
|
|
|
areaCodeChildService.save(areaCodeChildDTO); |
|
|
|
return new AddAreaCodeDictResultDTO(areaCodeChildDTO.getCode()); |
|
|
|
} |
|
|
|
|
|
|
|
} |