|
|
@ -17,25 +17,42 @@ |
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
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.enums.GenderEnum; |
|
|
|
import com.epmet.commons.tools.enums.HouseTypeEnum; |
|
|
|
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.utils.Result; |
|
|
|
import com.epmet.constant.UserConstant; |
|
|
|
import com.epmet.dao.IcResiUserDao; |
|
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
|
import com.epmet.dto.IcResiUserDTO; |
|
|
|
import com.epmet.dto.form.CustomerFormQueryDTO; |
|
|
|
import com.epmet.dto.form.IcResiDetailFormDTO; |
|
|
|
import com.epmet.dto.form.IcResiUserFormDTO; |
|
|
|
import com.epmet.dto.form.IcResiUserPageFormDTO; |
|
|
|
import com.epmet.dto.result.AllGridsByUserIdResultDTO; |
|
|
|
import com.epmet.dto.result.HomeUserResultDTO; |
|
|
|
import com.epmet.dto.result.HouseInfoDTO; |
|
|
|
import com.epmet.dto.result.IcFormResColumnDTO; |
|
|
|
import com.epmet.entity.IcResiUserEntity; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.feign.OperCustomizeOpenFeignClient; |
|
|
|
import com.epmet.redis.IcResiUserRedis; |
|
|
|
import com.epmet.service.IcResiUserService; |
|
|
|
import oracle.sql.NUMBER; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.logging.log4j.LogManager; |
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
@ -44,6 +61,8 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 用户基础信息 |
|
|
@ -51,6 +70,7 @@ import java.util.*; |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2021-10-26 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResiUserEntity> implements IcResiUserService { |
|
|
|
private Logger logger = LogManager.getLogger(IcResiUserServiceImpl.class); |
|
|
@ -58,6 +78,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
private IcResiUserRedis icResiUserRedis; |
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IcResiUserDTO> page(Map<String, Object> params) { |
|
|
@ -216,4 +240,177 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param homeId |
|
|
|
* @Description 获取房间内人员 |
|
|
|
* @Param homeId |
|
|
|
* @Return {@link List< HomeUserResultDTO >} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2021/11/1 10:52 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<HomeUserResultDTO> getPeopleByRoom(String homeId) { |
|
|
|
if(StringUtils.isBlank(homeId)) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
LambdaQueryWrapper<IcResiUserEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(IcResiUserEntity::getHomeId, homeId); |
|
|
|
wrapper.orderByAsc(IcResiUserEntity::getYhzgx); |
|
|
|
List<IcResiUserEntity> list = baseDao.selectList(wrapper); |
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
return list.stream().map(item -> { |
|
|
|
HomeUserResultDTO dto = new HomeUserResultDTO(); |
|
|
|
dto.setUserId(item.getId()); |
|
|
|
dto.setName(item.getName()); |
|
|
|
return dto; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<Map<String, Object>> pageResiMap(IcResiUserPageFormDTO formDTO) { |
|
|
|
// 查询列表展示项,如果没有,直接返回
|
|
|
|
CustomerFormQueryDTO queryDTO1=new CustomerFormQueryDTO(); |
|
|
|
queryDTO1.setCustomerId(formDTO.getCustomerId()); |
|
|
|
queryDTO1.setFormCode(formDTO.getFormCode()); |
|
|
|
Result<List<IcFormResColumnDTO>> resultColumnRes=operCustomizeOpenFeignClient.queryConditions(queryDTO1); |
|
|
|
if (!resultColumnRes.success() || CollectionUtils.isEmpty(resultColumnRes.getData())) { |
|
|
|
log.warn("没有配置列表展示列"); |
|
|
|
return new PageData(new ArrayList(), NumConstant.ZERO); |
|
|
|
} |
|
|
|
List<IcFormResColumnDTO> resultColumns = resultColumnRes.getData(); |
|
|
|
// 查询列表展示项需要用到哪些子表
|
|
|
|
Result<List<String>> subTablesRes=operCustomizeOpenFeignClient.querySubTables(queryDTO1); |
|
|
|
List<String> subTables =subTablesRes.getData(); |
|
|
|
PageInfo<Map<String, Object>> pageInfo=new PageInfo<>(); |
|
|
|
if (null == formDTO.getPageFlag()||formDTO.getPageFlag()) { |
|
|
|
//分页
|
|
|
|
pageInfo= PageHelper.startPage(formDTO.getPageNo(), |
|
|
|
formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectListResiMap(formDTO.getCustomerId(), |
|
|
|
formDTO.getFormCode(), |
|
|
|
formDTO.getConditions(), |
|
|
|
resultColumns, |
|
|
|
subTables)); |
|
|
|
}else{ |
|
|
|
List<Map<String,Object>> list=baseDao.selectListResiMap(formDTO.getCustomerId(), |
|
|
|
formDTO.getFormCode(), |
|
|
|
formDTO.getConditions(), |
|
|
|
resultColumns, |
|
|
|
subTables); |
|
|
|
pageInfo.setTotal(CollectionUtils.isEmpty(list)?NumConstant.ZERO:list.size()); |
|
|
|
pageInfo.setList(list); |
|
|
|
} |
|
|
|
|
|
|
|
List<Map<String, Object>> list = pageInfo.getList(); |
|
|
|
//查询网格名称
|
|
|
|
List<String> gridIds = new ArrayList<>(); |
|
|
|
Set<String> houseIds = new HashSet<>(); |
|
|
|
for (Map<String, Object> map : list) { |
|
|
|
log.warn(JSON.toJSONString(map)); |
|
|
|
if (map.containsKey(UserConstant.GRID_ID) && null != map.get(UserConstant.GRID_ID) && StringUtils.isNotBlank(map.get(UserConstant.GRID_ID).toString())) { |
|
|
|
gridIds.add(map.get(UserConstant.GRID_ID).toString()); |
|
|
|
} |
|
|
|
if (map.containsKey("HOME_ID") && null != map.get("HOME_ID") && StringUtils.isNotBlank(map.get("HOME_ID").toString())) { |
|
|
|
houseIds.add(map.get("HOME_ID").toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
Result<List<AllGridsByUserIdResultDTO>> gridInfoRes=govOrgOpenFeignClient.getGridListByGridIds(gridIds); |
|
|
|
List<AllGridsByUserIdResultDTO> gridInfoList = gridInfoRes.success() && !CollectionUtils.isEmpty(gridInfoRes.getData()) ? gridInfoRes.getData() : new ArrayList<>(); |
|
|
|
Map<String, AllGridsByUserIdResultDTO> gridInfoMap = gridInfoList.stream().collect(Collectors.toMap(AllGridsByUserIdResultDTO::getGridId, Function.identity())); |
|
|
|
|
|
|
|
//查询房子名称
|
|
|
|
Result<List<HouseInfoDTO>> houseInfoRes=govOrgOpenFeignClient.queryListHouseInfo(houseIds); |
|
|
|
List<HouseInfoDTO> houseInfoDTOList = houseInfoRes.success() && !CollectionUtils.isEmpty(houseInfoRes.getData()) ? houseInfoRes.getData() : new ArrayList<>(); |
|
|
|
Map<String, HouseInfoDTO> houseInfoMap = houseInfoDTOList.stream().collect(Collectors.toMap(HouseInfoDTO::getHomeId, Function.identity())); |
|
|
|
for (Map<String, Object> resultMap : list) { |
|
|
|
String gridIdValue = null != resultMap.get(UserConstant.GRID_ID) ? resultMap.get(UserConstant.GRID_ID).toString() : StrConstant.EPMETY_STR; |
|
|
|
resultMap.put("GRID_ID_VALUE", gridIdValue); |
|
|
|
if (null != gridInfoMap && gridInfoMap.containsKey(gridIdValue) && null != gridInfoMap.get(gridIdValue)) { |
|
|
|
//GRID_NAME
|
|
|
|
resultMap.put(UserConstant.GRID_ID, gridInfoMap.get(gridIdValue).getGridName()); |
|
|
|
} |
|
|
|
|
|
|
|
String homeId = null != resultMap.get("HOME_ID") ? resultMap.get("HOME_ID").toString() : StrConstant.EPMETY_STR; |
|
|
|
resultMap.put("HOME_ID_VALUE", homeId); |
|
|
|
if (null != houseInfoMap && houseInfoMap.containsKey(homeId) && null != houseInfoMap.get(homeId)) { |
|
|
|
HouseInfoDTO houseInfoDTO = houseInfoMap.get(homeId); |
|
|
|
String buildName = StringUtils.isNotBlank(houseInfoDTO.getBuildingName()) ? houseInfoDTO.getBuildingName() : StrConstant.EPMETY_STR; |
|
|
|
resultMap.put("BUILD_NAME", buildName); |
|
|
|
|
|
|
|
String neighBorName = StringUtils.isNotBlank(houseInfoDTO.getNeighborHoodName()) ? houseInfoDTO.getNeighborHoodName() : StrConstant.EPMETY_STR; |
|
|
|
resultMap.put("VILLAGE_NAME", neighBorName); |
|
|
|
|
|
|
|
String unitName = StringUtils.isNotBlank(houseInfoDTO.getUnitName()) ? houseInfoDTO.getUnitName() : StrConstant.EPMETY_STR; |
|
|
|
resultMap.put("UNIT_NAME", unitName); |
|
|
|
|
|
|
|
String doorName = StringUtils.isNotBlank(houseInfoDTO.getDoorName()) ? houseInfoDTO.getDoorName() : StrConstant.EPMETY_STR; |
|
|
|
resultMap.put("DOOR_NAME", doorName); |
|
|
|
|
|
|
|
String houseType = StringUtils.isNotBlank(houseInfoDTO.getHouseType()) ? houseInfoDTO.getHouseType() : StrConstant.EPMETY_STR; |
|
|
|
//房屋类型,1楼房,2平房,3别墅
|
|
|
|
resultMap.put(UserConstant.HOUSE_TYPE_KEY, ""); |
|
|
|
if (HouseTypeEnum.LOUFANG.getCode().equals(houseType)) { |
|
|
|
resultMap.put(UserConstant.HOUSE_TYPE_KEY, HouseTypeEnum.LOUFANG.getName()); |
|
|
|
} else if (HouseTypeEnum.PINGFANG.getCode().equals(houseType)) { |
|
|
|
resultMap.put(UserConstant.HOUSE_TYPE_KEY, HouseTypeEnum.PINGFANG.getName()); |
|
|
|
} else if (HouseTypeEnum.BIESHU.getCode().equals(houseType)) { |
|
|
|
resultMap.put(UserConstant.HOUSE_TYPE_KEY, HouseTypeEnum.BIESHU.getName()); |
|
|
|
} |
|
|
|
|
|
|
|
resultMap.put("HOME_ID", neighBorName.concat(buildName).concat(unitName).concat(doorName)); |
|
|
|
} |
|
|
|
|
|
|
|
if (resultMap.containsKey(UserConstant.GENDER)) { |
|
|
|
String genderValue = null != resultMap.get(UserConstant.GENDER) ? resultMap.get(UserConstant.GENDER).toString() : StrConstant.EPMETY_STR; |
|
|
|
if (GenderEnum.MAN.getCode().equals(genderValue)) { |
|
|
|
resultMap.put(UserConstant.GENDER, GenderEnum.MAN.getName()); |
|
|
|
} else if (GenderEnum.WOMAN.getCode().equals(genderValue)) { |
|
|
|
resultMap.put(UserConstant.GENDER, GenderEnum.WOMAN.getName()); |
|
|
|
} else if (GenderEnum.UN_KNOWN.getCode().equals(genderValue)) { |
|
|
|
resultMap.put(UserConstant.GENDER, GenderEnum.UN_KNOWN.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
pageInfo.setList(list); |
|
|
|
return new PageData<>(pageInfo.getList(), pageInfo.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 编辑页面,显示居民信息详情 |
|
|
|
* |
|
|
|
* @param pageFormDTO |
|
|
|
* @return java.util.Map |
|
|
|
* @author yinzuomei |
|
|
|
* @date 2021/10/28 10:29 上午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map queryIcResiDetail(IcResiDetailFormDTO pageFormDTO) { |
|
|
|
Map resultMap = new HashMap(); |
|
|
|
// 先查询主表,主表没有记录,直接返回空
|
|
|
|
List<Map<String, Object>> icResiUserMapList = baseDao.selectListMapById(pageFormDTO.getIcResiUserId()); |
|
|
|
if (CollectionUtils.isEmpty(icResiUserMapList)) { |
|
|
|
return new HashMap(); |
|
|
|
} |
|
|
|
resultMap.put("ic_resi_user", icResiUserMapList); |
|
|
|
CustomerFormQueryDTO queryDTO=ConvertUtils.sourceToTarget(pageFormDTO,CustomerFormQueryDTO.class); |
|
|
|
//循环查询每个子表的记录
|
|
|
|
Result<Set<String>> subTableRes=operCustomizeOpenFeignClient.queryIcResiSubTables(queryDTO); |
|
|
|
if(subTableRes.success()&&!CollectionUtils.isEmpty(subTableRes.getData())){ |
|
|
|
for (String subTalbeName : subTableRes.getData()) { |
|
|
|
List<Map<String, Object>> list = baseDao.selectSubTableRecords(pageFormDTO.getIcResiUserId(), subTalbeName); |
|
|
|
if (!CollectionUtils.isEmpty(list)) { |
|
|
|
resultMap.put(subTalbeName, list); |
|
|
|
} |
|
|
|
//else{
|
|
|
|
// resultMap.put(subTalbeName,new ArrayList<>());
|
|
|
|
//}
|
|
|
|
} |
|
|
|
} |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
} |