Browse Source

居民信息采集-户主信息手动新增编辑功能

feature/syp_points
songyunpeng 5 years ago
parent
commit
9aa1af4621
  1. 37
      esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/PopulationInformationDTO.java
  2. 4
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/HouseResidentController.java
  3. 6
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/HousingInformationController.java
  4. 24
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/PopulationInformationController.java
  5. 2
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/HouseResidentDao.java
  6. 9
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/PopulationInformationDao.java
  7. 24
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/PopulationInformationEntity.java
  8. 24
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/HouseResidentService.java
  9. 5
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/HousingInformationService.java
  10. 5
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/PopulationInformationService.java
  11. 114
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/HouseResidentServiceImpl.java
  12. 63
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/HousingInformationServiceImpl.java
  13. 93
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/PopulationInformationServiceImpl.java
  14. 5
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/HouseResidentDao.xml
  15. 45
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/PopulationInformationDao.xml

37
esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/PopulationInformationDTO.java

@ -224,30 +224,6 @@ public class PopulationInformationDTO implements Serializable {
*/
private Date updatedTime;
/**
* 所属网格ID
*/
private Long gridId;
/**
* 父所有部门
*/
private String parentDeptIds;
/**
* 父所有部门
*/
private String parentDeptNames;
/**
* 所有部门ID
*/
private String allDeptIds;
/**
* 所有部门名称
*/
private String allDeptNames;
/**
* 现居住地址- 保存居住人使用
*/
@ -257,4 +233,17 @@ public class PopulationInformationDTO implements Serializable {
*/
private String houseHeadRelation;
/**
* 居住人ID
*/
private String residentId;
/**
* 房屋ID
*/
private String houseId;
/**
* 户主编辑是否确认提交字段
*/
private String isSubmit;
}

4
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/HouseResidentController.java

@ -66,14 +66,14 @@ public class HouseResidentController {
public Result save(@RequestBody HouseResidentDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
return houseResidentService.save(dto);
return houseResidentService.saveWithoutIdentifyNo(dto);
}
@PutMapping
public Result update(@RequestBody HouseResidentDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
return houseResidentService.update(dto);
return houseResidentService.updateWithoutIdentifyNo(dto);
}
@DeleteMapping

6
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/HousingInformationController.java

@ -65,16 +65,14 @@ public class HousingInformationController {
public Result save(@RequestBody HousingInformationDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
housingInformationService.save(dto);
return new Result();
return housingInformationService.save(dto);
}
@PutMapping
public Result update(@RequestBody HousingInformationDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
housingInformationService.update(dto);
return new Result();
return housingInformationService.update(dto);
}
@DeleteMapping

24
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/PopulationInformationController.java

@ -19,12 +19,13 @@ package com.elink.esua.epdc.controller;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
import com.elink.esua.epdc.commons.tools.utils.IdentityNoUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.dto.PopulationInformationDTO;
import com.elink.esua.epdc.excel.PopulationInformationExcel;
import com.elink.esua.epdc.service.PopulationInformationService;
@ -70,16 +71,14 @@ public class PopulationInformationController {
public Result save(@RequestBody PopulationInformationDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
populationInformationService.save(dto);
return new Result();
return populationInformationService.save(dto);
}
@PutMapping
public Result update(@RequestBody PopulationInformationDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
populationInformationService.update(dto);
return new Result();
return populationInformationService.update(dto);
}
@DeleteMapping
@ -95,5 +94,20 @@ public class PopulationInformationController {
List<PopulationInformationDTO> list = populationInformationService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, PopulationInformationExcel.class);
}
/**
* @Description 判断身份证是否合法
* @Author songyunpeng
* @Date 2020/8/24
* @Param [isIdentifyNo]
* @return com.elink.esua.epdc.commons.tools.utils.Result
**/
@GetMapping("isIdentifyNoLegal/{isIdentifyNo}")
public Result isIdentifyNoLegal(@PathVariable("isIdentifyNo") String isIdentifyNo){
String result = IdentityNoUtils.IdentityNoVerification(isIdentifyNo);
if(result != null){
return new Result().error(result);
}
return new Result();
}
}

2
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/HouseResidentDao.java

@ -49,7 +49,7 @@ public interface HouseResidentDao extends BaseDao<HouseResidentEntity> {
* @Param [id]
* @return com.elink.esua.epdc.dto.PopulationInformationDTO
**/
PopulationInformationDTO selectByHouseId(@Param("id") String id);
PopulationInformationDTO selectByHouseResidentId(@Param("id") String id);
/**
* @Description 根据居民ID获取关联关系表ID
* @Author songyunpeng

9
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/PopulationInformationDao.java

@ -18,6 +18,7 @@
package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.PopulationInformationDTO;
import com.elink.esua.epdc.entity.PopulationInformationEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -38,4 +39,12 @@ public interface PopulationInformationDao extends BaseDao<PopulationInformationE
* @return com.elink.esua.epdc.dto.PopulationInformationDTO
**/
PopulationInformationEntity getInfoByIdentityNo(@Param("residentsIdentityNo") String residentsIdentityNo);
/**
* @Description 取房屋户主信息
* @Author songyunpeng
* @Date 2020/8/24
* @Param [houseId]
* @return com.elink.esua.epdc.dto.PopulationInformationDTO
**/
PopulationInformationDTO getHouseHeadInfo(String houseId);
}

24
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/PopulationInformationEntity.java

@ -193,30 +193,6 @@ public class PopulationInformationEntity extends BaseEpdcEntity {
*/
private Integer familyMemberOutMonth;
/**
* 所属网格ID
*/
private Long gridId;
/**
* 父所有部门
*/
private String parentDeptIds;
/**
* 父所有部门
*/
private String parentDeptNames;
/**
* 所有部门ID
*/
private String allDeptIds;
/**
* 所有部门名称
*/
private String allDeptNames;
/**
* 现居住地址- 保存居住人使用
*/

24
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/HouseResidentService.java

@ -66,24 +66,24 @@ public interface HouseResidentService extends BaseService<HouseResidentEntity> {
PopulationInformationDTO get(String id);
/**
* 默认保存
* 带身份证的居民信息保存
*
* @param dto
* @return void
* @author generator
* @date 2020-08-19
*/
Result save(HouseResidentDTO dto);
Result saveWithIdentifyNo(HouseResidentDTO dto);
/**
* 默认更新
* 带身份证的居民信息更新
*
* @param dto
* @return void
* @author generator
* @date 2020-08-19
*/
Result update(HouseResidentDTO dto);
Result updateWithIdentifyNo(HouseResidentDTO dto);
/**
* 批量删除
@ -102,4 +102,20 @@ public interface HouseResidentService extends BaseService<HouseResidentEntity> {
* @return com.elink.esua.epdc.commons.tools.page.PageData<com.elink.esua.epdc.dto.HouseResidentDTO>
**/
PageData<PopulationInformationDTO> listPage(Map<String, Object> params);
/**
* @Description 不带身份证的居民信息保存
* @Author songyunpeng
* @Date 2020/8/24
* @Param [dto]
* @return com.elink.esua.epdc.commons.tools.utils.Result
**/
Result saveWithoutIdentifyNo(HouseResidentDTO dto);
/**
* @Description 不带身份证的居民信息更新
* @Author songyunpeng
* @Date 2020/8/24
* @Param [dto]
* @return com.elink.esua.epdc.commons.tools.utils.Result
**/
Result updateWithoutIdentifyNo(HouseResidentDTO dto);
}

5
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/HousingInformationService.java

@ -19,6 +19,7 @@ package com.elink.esua.epdc.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.HousingInformationDTO;
import com.elink.esua.epdc.entity.HousingInformationEntity;
@ -71,7 +72,7 @@ public interface HousingInformationService extends BaseService<HousingInformatio
* @author generator
* @date 2020-08-19
*/
void save(HousingInformationDTO dto);
Result save(HousingInformationDTO dto);
/**
* 默认更新
@ -81,7 +82,7 @@ public interface HousingInformationService extends BaseService<HousingInformatio
* @author generator
* @date 2020-08-19
*/
void update(HousingInformationDTO dto);
Result update(HousingInformationDTO dto);
/**
* 批量删除

5
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/PopulationInformationService.java

@ -19,6 +19,7 @@ package com.elink.esua.epdc.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.PopulationInformationDTO;
import com.elink.esua.epdc.entity.PopulationInformationEntity;
@ -71,7 +72,7 @@ public interface PopulationInformationService extends BaseService<PopulationInfo
* @author generator
* @date 2020-08-19
*/
void save(PopulationInformationDTO dto);
Result save(PopulationInformationDTO dto);
/**
* 默认更新
@ -81,7 +82,7 @@ public interface PopulationInformationService extends BaseService<PopulationInfo
* @author generator
* @date 2020-08-19
*/
void update(PopulationInformationDTO dto);
Result update(PopulationInformationDTO dto);
/**
* 批量删除

114
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/HouseResidentServiceImpl.java

@ -93,26 +93,31 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
@Override
public PopulationInformationDTO get(String id) {
PopulationInformationDTO populationInformationDTO = baseDao.selectByHouseId(id);
PopulationInformationDTO populationInformationDTO = baseDao.selectByHouseResidentId(id);
return populationInformationDTO;
}
/** 居住人的新增和更新逻辑
* 新增1.判断填写的身份证是否已存在
* 不存在直接新增人口信息和关联表信息
* 存在更新原有的人口信息和关联信息
* 存在更新原有的人口信息和关联信息若是有户主身份且在此是第一次新增居住信息则直接更新原有人口信息和新增关联信息
* 更新1.若是身份证被修改判断填写的身份证是否存在
* 不存在代表更新关联表信息和新增人口信息原先的人口信息如果只有居住人身份的话则直接删除
* ****存在只有人才才会走到这个逻辑
* 1.判断修改的身份证信息是不是在当前房屋下存在则返回错误信息
* 2.不在此房屋下
* 更新原先关联关系为表单的身份证和表单房子关联
* 更新原先的人口信息
* 删除被更新的人口信息非户主和人口关系
* 若是此身份证有户主身份
* 1更新原先的人口信息
* 2新增居民关联关系为表单的身份证和表单房子关联
* 3删除被更新的人口信息非户主和人口关系
* 若是此身份证有居住人身份(或者既有户主又有居民身份)
* (1)更新原先居民关联关系为表单的身份证和表单房子关联
* 2更新原先的人口信息
* 3删除被更新的人口信息非户主和人口关系
*
* */
@Override
@Transactional(rollbackFor = Exception.class)
public Result save(HouseResidentDTO dto) {
public Result saveWithIdentifyNo(HouseResidentDTO dto) {
//先判断身份证是否合法
String result = IdentityNoUtils.IdentityNoVerification(dto.getResidentsIdentityNo());
if(result != null){
@ -122,8 +127,6 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
String birthday = IdentityNoUtils.getBirthday(dto.getResidentsIdentityNo());
//根据身份证查询新人口信息
PopulationInformationEntity newPopulationInformationEntity = populationInformationService.getInfoByIdentityNo(dto.getResidentsIdentityNo());
//查询新的房屋的信息 - 赋值房子所在网格
HousingInformationEntity housingInformationEntity = housingInformationService.selectById(dto.getHouseId());
if(newPopulationInformationEntity==null){
newPopulationInformationEntity = new PopulationInformationEntity();
newPopulationInformationEntity.setResidentsName(dto.getResidentsName());
@ -136,11 +139,6 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
newPopulationInformationEntity.setCurrentAddress(dto.getCurrentAddress());
newPopulationInformationEntity.setResidentsSex(sex);
newPopulationInformationEntity.setResidentsBirthday(DateUtil.parse(birthday));
newPopulationInformationEntity.setGridId(housingInformationEntity.getGridId());
newPopulationInformationEntity.setAllDeptIds(housingInformationEntity.getAllDeptIds());
newPopulationInformationEntity.setAllDeptNames(housingInformationEntity.getAllDeptNames());
newPopulationInformationEntity.setParentDeptIds(housingInformationEntity.getParentDeptIds());
newPopulationInformationEntity.setParentDeptNames(housingInformationEntity.getParentDeptNames());
//插入人口信息
populationInformationService.insert(newPopulationInformationEntity);
//插入关联表信息
@ -152,13 +150,34 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
insert(entity);
}else if(newPopulationInformationEntity!=null){
//人口信息不是空,则新人口信息转变为旧人口信息
//查询表单身份证的人口的和房子的关联关系
//1.查询表单身份证的人口的和房子的关联关系(查询条件是非户主身份的)
HouseResidentEntity oldHouseResidentEntity = baseDao.getHouseResidentInfoByResidentId(newPopulationInformationEntity.getId());
//查询表单身份证的人口的房子的信息
if(oldHouseResidentEntity==null){
//此时说明此人有户主身份,则直接更新人口信息和新增关联信息
newPopulationInformationEntity.setResidentsName(dto.getResidentsName());
newPopulationInformationEntity.setResidentsNation(dto.getResidentsNation());
newPopulationInformationEntity.setEducationLevel(dto.getEducationLevel());
newPopulationInformationEntity.setPoliticsStatus(dto.getPoliticsStatus());
newPopulationInformationEntity.setResidentsIdentityNo(dto.getResidentsIdentityNo());
newPopulationInformationEntity.setResidentsPhone(dto.getResidentsPhone());
newPopulationInformationEntity.setCurrentEmployer(dto.getCurrentEmployer());
newPopulationInformationEntity.setCurrentAddress(dto.getCurrentAddress());
newPopulationInformationEntity.setResidentsSex(sex);
newPopulationInformationEntity.setResidentsBirthday(DateUtil.parse(birthday));
//更新人口信息
populationInformationService.updateById(newPopulationInformationEntity);
//新增关联表信息为当前房屋
oldHouseResidentEntity.setHouseId(dto.getHouseId());
oldHouseResidentEntity.setHouseHeadRelation(dto.getHouseHeadRelation());
oldHouseResidentEntity.setResidentId(newPopulationInformationEntity.getId());
insert(oldHouseResidentEntity);
return new Result();
}
//2.查询表单身份证的人口的房子的信息
HousingInformationEntity oldHousingInformationEntity = housingInformationService.selectById(oldHouseResidentEntity.getHouseId());
//第一次修改
//比较当前房屋和表单身份证的旧房屋信息
//如果不同则提示是否要进行修改
//3.第一次修改
//比较当前房屋和表单身份证的旧房屋信息
//如果不同则提示是否要进行修改
if("0".equals(dto.getIsEditResidentInfo()) && !dto.getHouseId().equals(oldHouseResidentEntity.getHouseId())){
return new Result().ok("您在地址为"+oldHousingInformationEntity.getHouseAddress()+"房屋下已有居住信息,确认要更新吗?");
}else if("1".equals(dto.getIsEditResidentInfo())){//第二次确认修改居住信息
@ -172,11 +191,6 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
newPopulationInformationEntity.setCurrentAddress(dto.getCurrentAddress());
newPopulationInformationEntity.setResidentsSex(sex);
newPopulationInformationEntity.setResidentsBirthday(DateUtil.parse(birthday));
newPopulationInformationEntity.setGridId(housingInformationEntity.getGridId());
newPopulationInformationEntity.setAllDeptIds(housingInformationEntity.getAllDeptIds());
newPopulationInformationEntity.setAllDeptNames(housingInformationEntity.getAllDeptNames());
newPopulationInformationEntity.setParentDeptIds(housingInformationEntity.getParentDeptIds());
newPopulationInformationEntity.setParentDeptNames(housingInformationEntity.getParentDeptNames());
//更新人口信息
populationInformationService.updateById(newPopulationInformationEntity);
//更新旧的关联表信息为当前房屋
@ -195,7 +209,7 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
@Override
@Transactional(rollbackFor = Exception.class)
public Result update(HouseResidentDTO dto) {
public Result updateWithIdentifyNo(HouseResidentDTO dto) {
//判断身份证是否发生修改
HouseResidentEntity oldHouseResident = baseDao.selectById(dto.getId());
PopulationInformationEntity oldPopulationInformation = populationInformationService.selectById(oldHouseResident.getResidentId());
@ -224,8 +238,6 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
//根据身份证判断此人是否已有居住信息
//新的居住人信息
PopulationInformationEntity populationInformationEntity = populationInformationService.getInfoByIdentityNo(dto.getResidentsIdentityNo());
//新的房子信息
HousingInformationEntity housingInformationEntity = housingInformationService.selectById(dto.getHouseId());
if(populationInformationEntity==null){
//新的居住人信息是空,代表添加新的人口信息到表中。并且由于此处是更新,则当前选择的被更新人的数据要从人口信息表中删除,且之前的关联关系也得更新
populationInformationEntity = new PopulationInformationEntity();
@ -239,11 +251,6 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
populationInformationEntity.setCurrentAddress(dto.getCurrentAddress());
populationInformationEntity.setResidentsSex(sex);
populationInformationEntity.setResidentsBirthday(DateUtil.parse(birthday));
populationInformationEntity.setGridId(housingInformationEntity.getGridId());
populationInformationEntity.setAllDeptIds(housingInformationEntity.getAllDeptIds());
populationInformationEntity.setAllDeptNames(housingInformationEntity.getAllDeptNames());
populationInformationEntity.setParentDeptIds(housingInformationEntity.getParentDeptIds());
populationInformationEntity.setParentDeptNames(housingInformationEntity.getParentDeptNames());
//获取原先关联表信息
HouseResidentEntity entity = selectById(dto.getId());
//查询原先绑定的居住人的信息,如果此居住人只有居住人身份则删除此人人口信息
@ -282,11 +289,6 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
populationInformationEntity.setResidentsPhone(dto.getResidentsPhone());
populationInformationEntity.setCurrentEmployer(dto.getCurrentEmployer());
populationInformationEntity.setCurrentAddress(dto.getCurrentAddress());
populationInformationEntity.setGridId(housingInformationEntity.getGridId());
populationInformationEntity.setAllDeptIds(housingInformationEntity.getAllDeptIds());
populationInformationEntity.setAllDeptNames(housingInformationEntity.getAllDeptNames());
populationInformationEntity.setParentDeptIds(housingInformationEntity.getParentDeptIds());
populationInformationEntity.setParentDeptNames(housingInformationEntity.getParentDeptNames());
//(2)删除被更新的人的人口信息和关联信息 - 组装信息
//获取原先关联表信息
HouseResidentEntity entity = selectById(dto.getId());
@ -295,19 +297,24 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
oldParams.put("RESIDENT_ID",entity.getResidentId());
oldParams.put("IS_HOUSE_HEAD","0");
List<HouseResidentEntity> oldHouseResidentEntities = baseDao.selectByMap(oldParams);
//(3)更新表单身份证与房屋关联关系为当前房屋
//(3)更新表单身份证与房屋关联关系为当前房屋(若是表单身份证存在户主身份,且第一次添加居住人,则新增关联关系)
//获取表单身份证之前的居住地关联关系表的信息
HouseResidentEntity newHouseResidentEntity = houseResidentDao.getHouseResidentInfoByResidentId(populationInformationEntity.getId());
newHouseResidentEntity.setHouseId(dto.getHouseId());
newHouseResidentEntity.setHouseHeadRelation(dto.getHouseHeadRelation());
// (4)进行修改!
if(newHouseResidentEntity==null){
//此处判断代表此人有户主身份,且第一次更新为居民身份,此时新增关联关系
newHouseResidentEntity.setHouseId(dto.getHouseId());
newHouseResidentEntity.setHouseHeadRelation(dto.getHouseHeadRelation());
newHouseResidentEntity.setResidentId(populationInformationEntity.getId());
houseResidentDao.insert(newHouseResidentEntity);
}else {
houseResidentDao.updateById(newHouseResidentEntity);
}
baseDao.deleteById(entity.getId());
if(oldHouseResidentEntities!=null && oldHouseResidentEntities.size()>0){
//没有户主身份,删除人口信息
populationInformationService.deleteById(entity.getResidentId());
}
houseResidentDao.updateById(newHouseResidentEntity);
populationInformationService.updateById(populationInformationEntity);
}else {
return new Result().error("参数传递出错");
@ -330,4 +337,29 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
return new PageData<>(list, page.getTotal());
}
@Override
public Result saveWithoutIdentifyNo(HouseResidentDTO dto) {
PopulationInformationEntity populationInformationEntity = ConvertUtils.sourceToTarget(dto,PopulationInformationEntity.class);
populationInformationService.insert(populationInformationEntity);
HouseResidentEntity houseResidentEntity = ConvertUtils.sourceToTarget(dto,HouseResidentEntity.class);
houseResidentEntity.setResidentId(populationInformationEntity.getId());
houseResidentEntity.setIsHouseHead("0");
this.insert(houseResidentEntity);
return new Result();
}
@Override
public Result updateWithoutIdentifyNo(HouseResidentDTO dto) {
PopulationInformationEntity populationInformationEntity = populationInformationService.selectById(dto.getResidentId());
populationInformationEntity.setResidentsName(dto.getResidentsName());
populationInformationEntity.setResidentsSex(dto.getResidentsSex());
populationInformationEntity.setResidentsNation(dto.getResidentsNation());
populationInformationEntity.setCurrentEmployer(dto.getCurrentEmployer());
populationInformationEntity.setCurrentAddress(dto.getCurrentAddress());
populationInformationService.updateById(populationInformationEntity);
HouseResidentEntity houseResidentEntity = ConvertUtils.sourceToTarget(dto,HouseResidentEntity.class);
this.updateById(houseResidentEntity);
return new Result();
}
}

63
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/HousingInformationServiceImpl.java

@ -24,28 +24,29 @@ import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.exception.RenException;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.utils.IdentityNoUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.constant.HouseUseConstant;
import com.elink.esua.epdc.dao.HouseResidentDao;
import com.elink.esua.epdc.dao.HousingInformationDao;
import com.elink.esua.epdc.dto.HousingInformationDTO;
import com.elink.esua.epdc.dto.ParentAndAllDeptDTO;
import com.elink.esua.epdc.entity.HouseBusinessInfoEntity;
import com.elink.esua.epdc.entity.HouseRentInfoEntity;
import com.elink.esua.epdc.entity.HouseResidentEntity;
import com.elink.esua.epdc.entity.HousingInformationEntity;
import com.elink.esua.epdc.feign.AdminFeignClient;
import com.elink.esua.epdc.redis.HousingInformationRedis;
import com.elink.esua.epdc.service.HouseBusinessInfoService;
import com.elink.esua.epdc.service.HouseRentInfoService;
import com.elink.esua.epdc.service.HousingInformationService;
import com.elink.esua.epdc.service.PopulationInformationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 房屋信息表
@ -69,6 +70,12 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
@Autowired
private AdminFeignClient adminFeignClient;
@Autowired
private HouseResidentDao houseResidentDao;
@Autowired
private PopulationInformationService populationInformationService;
@Override
public PageData<HousingInformationDTO> page(Map<String, Object> params) {
@ -116,23 +123,40 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
@Override
@Transactional(rollbackFor = Exception.class)
public void save(HousingInformationDTO dto) {
public Result save(HousingInformationDTO dto) {
if(HouseUseConstant.RENT.equals(dto.getHouseUse())){
//判断身份证是否合法
String result = IdentityNoUtils.IdentityNoVerification(dto.getTenantIdentityNo());
if(result != null){
return new Result().error(result);
}
}
HousingInformationEntity entity = ConvertUtils.sourceToTarget(dto, HousingInformationEntity.class);
//赋值部门信息
setDept(entity);
insert(entity);
//新增承租人信息和企业信息
insertOrUpdateHouseRentOrBusinessInfo(dto,entity);
return new Result();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(HousingInformationDTO dto) {
public Result update(HousingInformationDTO dto) {
if(HouseUseConstant.RENT.equals(dto.getHouseUse())){
//判断身份证是否合法
String result = IdentityNoUtils.IdentityNoVerification(dto.getTenantIdentityNo());
if(result != null){
return new Result().error(result);
}
}
HousingInformationEntity entity = ConvertUtils.sourceToTarget(dto, HousingInformationEntity.class);
//赋值部门信息
setDept(entity);
updateById(entity);
insertOrUpdateHouseRentOrBusinessInfo(dto,entity);
return new Result();
}
private void setDept(HousingInformationEntity entity){
Result<ParentAndAllDeptDTO> parentAndAllDept = adminFeignClient.getParentAndAllDept(String.valueOf(entity.getGridId()));
@ -188,7 +212,32 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
//删除房屋户主信息,房屋居住人信息
//1.根据房屋信息查询所有与房屋关联的人
Map<String,Object> params = new HashMap<>();
params.put("HOUSE_ID",ids[0]);
List<HouseResidentEntity> houseResidentEntities = houseResidentDao.selectByMap(params);
List<String> populationIds = new ArrayList<>();
if(houseResidentEntities!=null && houseResidentEntities.size()>0){
for (HouseResidentEntity houseResidentEntity : houseResidentEntities) {
//删除条件:与此房屋有关联的人有户主和居住人两个身份
//判断是否还有其他房子的关联关系,如果有只删除与此房子的关联关系,没有则删除人口信息+关联关系
Map<String,Object> residentParams = new HashMap<>();
params.put("RESIDENT_ID",houseResidentEntity.getResidentId());
List<HouseResidentEntity> allHouseResidentEntities = houseResidentDao.selectByMap(residentParams);
if(allHouseResidentEntities!=null && allHouseResidentEntities.size()==1){
//此人只与此房屋关联
populationIds.add(houseResidentEntity.getResidentId());
}
}
//删除人口信息 -- 只删与且仅与此房屋有关系的人口
if(populationIds.size()>0){
populationInformationService.deleteBatchIds(populationIds);
}
//删除关联关系 -- 全删
houseResidentDao.deleteByMap(params);
}
//删除房屋信息
baseDao.deleteBatchIds(Arrays.asList(ids));
}

93
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/PopulationInformationServiceImpl.java

@ -20,13 +20,19 @@ package com.elink.esua.epdc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dao.HouseResidentDao;
import com.elink.esua.epdc.dao.PopulationInformationDao;
import com.elink.esua.epdc.dto.PopulationInformationDTO;
import com.elink.esua.epdc.entity.HouseResidentEntity;
import com.elink.esua.epdc.entity.HousingInformationEntity;
import com.elink.esua.epdc.entity.PopulationInformationEntity;
import com.elink.esua.epdc.redis.PopulationInformationRedis;
import com.elink.esua.epdc.service.HouseResidentService;
import com.elink.esua.epdc.service.HousingInformationService;
import com.elink.esua.epdc.service.PopulationInformationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -34,6 +40,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -49,6 +56,13 @@ public class PopulationInformationServiceImpl extends BaseServiceImpl<Population
@Autowired
private PopulationInformationRedis populationInformationRedis;
@Autowired
private HouseResidentService houseResidentService;
@Autowired
private HouseResidentDao houseResidentDao;
@Autowired
private HousingInformationService housingInformationService;
@Override
public PageData<PopulationInformationDTO> page(Map<String, Object> params) {
IPage<PopulationInformationEntity> page = baseDao.selectPage(
@ -82,16 +96,81 @@ public class PopulationInformationServiceImpl extends BaseServiceImpl<Population
@Override
@Transactional(rollbackFor = Exception.class)
public void save(PopulationInformationDTO dto) {
public Result save(PopulationInformationDTO dto) {
//校验身份证信息
//1.获取表单身份证的人口信息
PopulationInformationEntity infoByIdentityNo = getInfoByIdentityNo(dto.getResidentsIdentityNo());
if(infoByIdentityNo!=null){
Map<String,Object> params = new HashMap<>();
params.put("RESIDENT_ID",infoByIdentityNo.getId());
List<HouseResidentEntity> houseResidentEntities = houseResidentDao.selectByMap(params);
if(houseResidentEntities.size()>0){
//2.此人有房屋信息,且为第一次提交则此时提示前端
if("0".equals(dto.getIsSubmit())){
StringBuffer sb = new StringBuffer();
for (HouseResidentEntity houseResidentEntity : houseResidentEntities) {
HousingInformationEntity housingInformationEntity = housingInformationService.selectById(houseResidentEntity.getHouseId());
sb.append(",\"").append(housingInformationEntity.getHouseAddress()).append("\"");
}
String result ="您在地址为"+sb.substring(1)+"下已有房产信息,点击确认则新增此房产且更新居民信息!";
return new Result().ok(result.substring(1));
}
//2.第二次提交,则更新户主信息且新增关联信息
PopulationInformationEntity entity = ConvertUtils.sourceToTarget(dto, PopulationInformationEntity.class);
entity.setId(infoByIdentityNo.getId());
updateById(entity);
//插入房屋关联关系表
HouseResidentEntity houseResidentEntity = new HouseResidentEntity();
houseResidentEntity.setIsHouseHead("1");
houseResidentEntity.setResidentId(entity.getId());
houseResidentEntity.setHouseId(dto.getHouseId());
houseResidentService.insert(houseResidentEntity);
return new Result();
}
}
PopulationInformationEntity entity = ConvertUtils.sourceToTarget(dto, PopulationInformationEntity.class);
insert(entity);
//插入房屋关联关系表
HouseResidentEntity houseResidentEntity = new HouseResidentEntity();
houseResidentEntity.setIsHouseHead("1");
houseResidentEntity.setResidentId(entity.getId());
houseResidentEntity.setHouseId(dto.getHouseId());
houseResidentService.insert(houseResidentEntity);
return new Result();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(PopulationInformationDTO dto) {
PopulationInformationEntity entity = ConvertUtils.sourceToTarget(dto, PopulationInformationEntity.class);
updateById(entity);
public Result update(PopulationInformationDTO dto) {
PopulationInformationEntity infoByIdentityNo = getInfoByIdentityNo(dto.getResidentsIdentityNo());
if(dto.getResidentsIdentityNo().equals(infoByIdentityNo)){
PopulationInformationEntity entity = ConvertUtils.sourceToTarget(dto, PopulationInformationEntity.class);
updateById(entity);
return new Result();
}else {
//修改了身份证信息 - 提示信息
Map<String,Object> params = new HashMap<>();
params.put("RESIDENT_ID",infoByIdentityNo.getId());
List<HouseResidentEntity> houseResidentEntities = houseResidentDao.selectByMap(params);
if(houseResidentEntities.size()>0){
//2.此人有房屋信息,且为第一次提交则此时提示前端
if("0".equals(dto.getIsSubmit())){
StringBuffer sb = new StringBuffer();
for (HouseResidentEntity houseResidentEntity : houseResidentEntities) {
HousingInformationEntity housingInformationEntity = housingInformationService.selectById(houseResidentEntity.getHouseId());
sb.append(",\"").append(housingInformationEntity.getHouseAddress()).append("\"");
}
String result ="您在地址为"+sb.substring(1)+"下已有房产信息,点击确认则新增此房产且更新居民信息!";
return new Result().ok(result.substring(1));
}
//2.第二次提交,则更新户主信息
PopulationInformationEntity entity = ConvertUtils.sourceToTarget(dto, PopulationInformationEntity.class);
entity.setId(infoByIdentityNo.getId());
updateById(entity);
return new Result();
}
}
return new Result();
}
@Override
@ -102,8 +181,8 @@ public class PopulationInformationServiceImpl extends BaseServiceImpl<Population
}
@Override
public PopulationInformationDTO getHouseHeadInfo(String id) {
return null;
public PopulationInformationDTO getHouseHeadInfo(String houseId) {
return baseDao.getHouseHeadInfo(houseId);
}
@Override

5
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/HouseResidentDao.xml

@ -35,7 +35,7 @@
where t.DEL_FLAG ='0' and t1.DEL_FLAG ='0' and t1.IS_HOUSE_HEAD = '0' and t1.HOUSE_ID = #{houseId}
order by t1.CREATED_TIME desc
</select>
<select id="selectByHouseId" resultType="com.elink.esua.epdc.dto.PopulationInformationDTO">
<select id="selectByHouseResidentId" resultType="com.elink.esua.epdc.dto.PopulationInformationDTO">
select
t1.ID,
t.RESIDENTS_NAME,
@ -48,7 +48,8 @@
t.RESIDENTS_PHONE,
t.CURRENT_EMPLOYER,
t.CURRENT_ADDRESS,
t1.HOUSE_HEAD_RELATION
t1.HOUSE_HEAD_RELATION,
t.ID as residentId
from epdc_population_information t left join epdc_house_resident t1 on t1.RESIDENT_ID = t.ID
where t.DEL_FLAG ='0' and t1.DEL_FLAG ='0' and t1.IS_HOUSE_HEAD = '0' and t1.ID = #{id}
</select>

45
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/PopulationInformationDao.xml

@ -42,15 +42,50 @@
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="gridId" column="GRID_ID"/>
<result property="parentDeptIds" column="PARENT_DEPT_IDS"/>
<result property="parentDeptNames" column="PARENT_DEPT_NAMES"/>
<result property="allDeptIds" column="ALL_DEPT_IDS"/>
<result property="allDeptNames" column="ALL_DEPT_NAMES"/>
</resultMap>
<select id="getInfoByIdentityNo" resultType="com.elink.esua.epdc.entity.PopulationInformationEntity">
select * from epdc_population_information where RESIDENTS_IDENTITY_NO = #{residentsIdentityNo} and DEL_FLAG = '0' limit 1
</select>
<select id="getHouseHeadInfo" resultType="com.elink.esua.epdc.dto.PopulationInformationDTO">
select
t.ID,
t.RESIDENTS_NAME,
t.RESIDENTS_SEX,
t.RESIDENTS_NATION,
t.RESIDENTS_BIRTHDAY,
t.EDUCATION_LEVEL,
t.POLITICS_STATUS,
t.JOIN_TIME,
t.ORGANIZATIONAL_RELATIONSHIP_LOCATION,
t.RESIDENTS_IDENTITY_NO,
t.RESIDENTS_PHONE,
t.BODY_STATUS,
t.MARITAL_STATUS,
t.ACCOUNT_TYPE,
t.MILITARY_SERVICE,
t.HOUSEHOLD_REGISTRATION_PLACE,
t.EMPLOYMENT_STATUS,
t.CURRENT_EMPLOYER,
t.CURRENT_EMPLOYER_ADDRESS,
t.UNEMPLOYMENT_REASON,
t.REEMPLOYMENT_PERMIT,
t.UNEMPLOYMENT_REGISTER,
t.UNEMPLOYMENT_REGISTER_TIME,
t.FAMILY_CATEGORY,
t.HELP_STATUS,
t.MOTOR_VEHICLE_NUM,
t.MOTOR_VEHICLE_CATEGORY,
t.DOG_STATUS,
t.FAMILY_MEMBER_NUM,
t.FAMILY_MEMBER_OUT_NUM,
t.FAMILY_MEMBER_OUT_REASON,
t.FAMILY_MEMBER_OUT_MONTH,
t.CURRENT_ADDRESS,
t1.HOUSE_ID as houseId
from epdc_population_information t
left join epdc_house_resident t1 on t1.RESIDENT_ID = t.ID
where t.DEL_FLAG ='0' and t1.DEL_FLAG ='0' and t1.IS_HOUSE_HEAD = '1' and t1.HOUSE_ID = #{houseId} limit 1
</select>
</mapper>
Loading…
Cancel
Save