|
|
@ -20,16 +20,23 @@ package com.epmet.service.impl; |
|
|
|
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.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.IcResiUserDao; |
|
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
|
import com.epmet.dto.IcResiUserDTO; |
|
|
|
import com.epmet.dto.form.IcResiUserFormDTO; |
|
|
|
import com.epmet.entity.IcResiUserEntity; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.redis.IcResiUserRedis; |
|
|
|
import com.epmet.service.IcResiUserService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.logging.log4j.LogManager; |
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -37,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
/** |
|
|
|
* 用户基础信息 |
|
|
@ -46,9 +54,11 @@ import java.util.Map; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResiUserEntity> implements IcResiUserService { |
|
|
|
|
|
|
|
private Logger logger = LogManager.getLogger(IcResiUserServiceImpl.class); |
|
|
|
@Autowired |
|
|
|
private IcResiUserRedis icResiUserRedis; |
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IcResiUserDTO> page(Map<String, Object> params) { |
|
|
@ -107,7 +117,44 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
* @Description 党建互联平台--保存居民信息 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public void add(IcResiUserFormDTO formDTO) { |
|
|
|
public void add(TokenDto tokenDto, List<IcResiUserFormDTO> formDTO) { |
|
|
|
//循环自动拼接sql语句,往多个表新增数据
|
|
|
|
//1.先往主表新增数据
|
|
|
|
//主表Id
|
|
|
|
String resiUserId = UUID.randomUUID().toString().replaceAll("-", ""); |
|
|
|
formDTO.forEach(d -> { |
|
|
|
if ("ic_resi_user".equals(d.getTableName())) { |
|
|
|
Map<String, String> map = d.getList().get(0); |
|
|
|
map.put("id", resiUserId); |
|
|
|
map.put("customer_id", tokenDto.getCustomerId()); |
|
|
|
map.put("created_by", tokenDto.getUserId()); |
|
|
|
map.put("updated_by", tokenDto.getUserId()); |
|
|
|
//查询组织信息
|
|
|
|
String agencyId = (null == map.get("AGENCY_ID") ? map.get("agency_id") : map.get("AGENCY_ID")); |
|
|
|
Result<CustomerAgencyDTO> result = govOrgOpenFeignClient.getAgencyById(agencyId); |
|
|
|
if (result.success() && null != result.getData()) { |
|
|
|
map.put("pids", result.getData().getPids()); |
|
|
|
} else { |
|
|
|
throw new RenException(String.format("新增居民信息-根据agencyId查询组织信息失败,agencyId->%s", agencyId)); |
|
|
|
} |
|
|
|
//新增主表数据
|
|
|
|
baseDao.add(d.getTableName(), map); |
|
|
|
} |
|
|
|
}); |
|
|
|
//2.循环字表新增数据
|
|
|
|
formDTO.forEach(d -> { |
|
|
|
if (!"ic_resi_user".equals(d.getTableName())) { |
|
|
|
d.getList().forEach(map -> { |
|
|
|
map.put("id", UUID.randomUUID().toString().replaceAll("-", "")); |
|
|
|
map.put("ic_resi_user", resiUserId); |
|
|
|
map.put("customer_id", tokenDto.getCustomerId()); |
|
|
|
map.put("created_by", tokenDto.getUserId()); |
|
|
|
map.put("updated_by", tokenDto.getUserId()); |
|
|
|
//字表新增数据
|
|
|
|
baseDao.add(d.getTableName(), map); |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|