From 108b01796963d0fd8acf437b42f11a6921160970 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Thu, 16 Nov 2023 14:48:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=88=BF=E5=B1=8B=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E5=85=A5=E4=BA=BA=E5=8F=A3=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=20=20--renpc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/population/IPopulationDao.java | 8 ++++ .../pojo/bos/population/PopulationBO.java | 7 ++++ .../population/pojo/dtos/house/HouseDTO.java | 13 +++++++ .../pojo/dtos/population/PopulationDTO.java | 10 +++++ .../pojo/pos/population/PopulationPO.java | 7 ++++ .../cm/population/pojo/vos/house/HouseVO.java | 13 +++++++ .../pojo/vos/population/PopulationVO.java | 20 ++++++++++ .../service/house/impl/HouseServiceImpl.java | 37 +++++++++++++++++++ .../mapper/population/population-mapper.xml | 26 +++++++++++++ 9 files changed, 141 insertions(+) diff --git a/src/main/java/com/cm/population/dao/population/IPopulationDao.java b/src/main/java/com/cm/population/dao/population/IPopulationDao.java index 29849ec..0401673 100644 --- a/src/main/java/com/cm/population/dao/population/IPopulationDao.java +++ b/src/main/java/com/cm/population/dao/population/IPopulationDao.java @@ -117,4 +117,12 @@ public interface IPopulationDao { */ Integer count(Map params) throws SearchException; + /** + * 通过房屋ID删除人员信息 + * + * @param populationId + * @throws UpdateException + */ + void deleteById(String populationId) throws RemoveException; + } \ No newline at end of file diff --git a/src/main/java/com/cm/population/pojo/bos/population/PopulationBO.java b/src/main/java/com/cm/population/pojo/bos/population/PopulationBO.java index 1cda964..580e426 100644 --- a/src/main/java/com/cm/population/pojo/bos/population/PopulationBO.java +++ b/src/main/java/com/cm/population/pojo/bos/population/PopulationBO.java @@ -22,6 +22,7 @@ public class PopulationBO { private String modifier; private String gmtModified; private Integer isDelete; + private String outHouse; public String getPopulationId() { return populationId == null ? "" : populationId.trim(); @@ -119,5 +120,11 @@ public class PopulationBO { this.isDelete = isDelete; } + public String getOutHouse() { + return outHouse; + } + public void setOutHouse(String outHouse) { + this.outHouse = outHouse; + } } diff --git a/src/main/java/com/cm/population/pojo/dtos/house/HouseDTO.java b/src/main/java/com/cm/population/pojo/dtos/house/HouseDTO.java index 1029c1c..e84fa92 100644 --- a/src/main/java/com/cm/population/pojo/dtos/house/HouseDTO.java +++ b/src/main/java/com/cm/population/pojo/dtos/house/HouseDTO.java @@ -1,8 +1,11 @@ package com.cm.population.pojo.dtos.house; +import com.cm.population.pojo.vos.population.PopulationVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.util.List; + /** * * @ClassName: HouseDTO @@ -124,6 +127,8 @@ public class HouseDTO { private String streetName; @ApiModelProperty(name = "houseType", value = "房屋类型") private String houseType; + @ApiModelProperty(name = "populationVOList", value = "同住人信息") + private List populationVOList; public String getHouseId() { return houseId; @@ -564,4 +569,12 @@ public class HouseDTO { public void setHouseType(String houseType) { this.houseType = houseType; } + + public List getPopulationVOList() { + return populationVOList; + } + + public void setPopulationVOList(List populationVOList) { + this.populationVOList = populationVOList; + } } diff --git a/src/main/java/com/cm/population/pojo/dtos/population/PopulationDTO.java b/src/main/java/com/cm/population/pojo/dtos/population/PopulationDTO.java index ee525fd..7feddfd 100644 --- a/src/main/java/com/cm/population/pojo/dtos/population/PopulationDTO.java +++ b/src/main/java/com/cm/population/pojo/dtos/population/PopulationDTO.java @@ -30,6 +30,8 @@ public class PopulationDTO { private String phone; @ApiModelProperty(name = "bindTime", value = "绑定时间") private String bindTime; + @ApiModelProperty(name = "outHouse", value = "离开状态") + private String outHouse; @ApiModelProperty(name = "creator", value = "创建人") private String creator; @ApiModelProperty(name = "gmtCreate", value = "创建时间") @@ -103,6 +105,14 @@ public class PopulationDTO { this.bindTime = bindTime; } + public String getOutHouse() { + return outHouse; + } + + public void setOutHouse(String outHouse) { + this.outHouse = outHouse; + } + public String getCreator() { return creator == null ? "" : creator.trim(); } diff --git a/src/main/java/com/cm/population/pojo/pos/population/PopulationPO.java b/src/main/java/com/cm/population/pojo/pos/population/PopulationPO.java index 174d75c..c867ae4 100644 --- a/src/main/java/com/cm/population/pojo/pos/population/PopulationPO.java +++ b/src/main/java/com/cm/population/pojo/pos/population/PopulationPO.java @@ -22,6 +22,7 @@ public class PopulationPO { private String modifier; private String gmtModified; private Integer isDelete; + private String outHouse; public String getPopulationId() { return populationId == null ? "" : populationId.trim(); @@ -119,5 +120,11 @@ public class PopulationPO { this.isDelete = isDelete; } + public String getOutHouse() { + return outHouse; + } + public void setOutHouse(String outHouse) { + this.outHouse = outHouse; + } } diff --git a/src/main/java/com/cm/population/pojo/vos/house/HouseVO.java b/src/main/java/com/cm/population/pojo/vos/house/HouseVO.java index 7e4beaa..27f7314 100644 --- a/src/main/java/com/cm/population/pojo/vos/house/HouseVO.java +++ b/src/main/java/com/cm/population/pojo/vos/house/HouseVO.java @@ -1,9 +1,12 @@ package com.cm.population.pojo.vos.house; import com.cm.common.annotation.CheckNumberAnnotation; +import com.cm.population.pojo.vos.population.PopulationVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.util.List; + /** * * @ClassName: HouseVO @@ -113,6 +116,8 @@ public class HouseVO { private String street; @ApiModelProperty(name = "streetName", value = "街道名称") private String streetName; + @ApiModelProperty(name = "populationVOList", value = "同住人信息") + private List populationVOList; public String getCommunity() { return community == null ? "" : community.trim(); @@ -481,4 +486,12 @@ public class HouseVO { public void setStreetName(String streetName) { this.streetName = streetName; } + + public List getPopulationVOList() { + return populationVOList; + } + + public void setPopulationVOList(List populationVOList) { + this.populationVOList = populationVOList; + } } diff --git a/src/main/java/com/cm/population/pojo/vos/population/PopulationVO.java b/src/main/java/com/cm/population/pojo/vos/population/PopulationVO.java index 1792d1c..3378495 100644 --- a/src/main/java/com/cm/population/pojo/vos/population/PopulationVO.java +++ b/src/main/java/com/cm/population/pojo/vos/population/PopulationVO.java @@ -14,6 +14,8 @@ import io.swagger.annotations.ApiModelProperty; @ApiModel public class PopulationVO { + @ApiModelProperty(name = "populationId", value = "主键UUID") + private String populationId; @ApiModelProperty(name = "houseId", value = "房屋ID") private String houseId; @ApiModelProperty(name = "populationInfoId", value = "人口信息ID") @@ -26,6 +28,16 @@ public class PopulationVO { private String bindTime; @ApiModelProperty(name = "phone", value = "联系方式") private String phone; + @ApiModelProperty(name = "outHouse", value = "离开状态") + private String outHouse; + + public String getPopulationId() { + return populationId; + } + + public void setPopulationId(String populationId) { + this.populationId = populationId; + } public String getHouseId() { return houseId == null ? "" : houseId.trim(); @@ -74,4 +86,12 @@ public class PopulationVO { public void setPhone(String phone) { this.phone = phone; } + + public String getOutHouse() { + return outHouse; + } + + public void setOutHouse(String outHouse) { + this.outHouse = outHouse; + } } diff --git a/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java b/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java index 4107a28..1b3425d 100644 --- a/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java +++ b/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java @@ -7,6 +7,7 @@ import com.cm.common.result.SuccessResultList; import com.cm.common.utils.HashMapUtil; import com.cm.common.utils.UUIDUtil; import com.cm.population.dao.house.IHouseDao; +import com.cm.population.dao.population.IPopulationDao; import com.cm.population.pojo.bos.house.HouseBO; import com.cm.population.pojo.dtos.building.BuildingDTO; import com.cm.population.pojo.dtos.house.AutoHouseDTO; @@ -16,14 +17,17 @@ import com.cm.population.pojo.dtos.residential.ResidentialDTO; import com.cm.population.pojo.pos.house.HousePO; import com.cm.population.pojo.vos.building.BuildingBatchVO; import com.cm.population.pojo.vos.house.HouseVO; +import com.cm.population.pojo.vos.population.PopulationVO; import com.cm.population.service.building.IBuildingService; import com.cm.population.service.house.IHouseService; +import com.cm.population.service.population.IPopulationService; import com.cm.population.service.residential.IResidentialService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; @@ -45,6 +49,10 @@ public class HouseServiceImpl extends AbstractService implements IHouseService { private IBuildingService buildingService; @Autowired private IResidentialService residentialService; + @Autowired + private IPopulationService populationService; + @Autowired + private IPopulationDao populationdao; @Override public void save(HouseVO houseVO) { @@ -77,6 +85,14 @@ public class HouseServiceImpl extends AbstractService implements IHouseService { setSaveInfo(token, params); } houseDao.save(params); + + if(!CollectionUtils.isEmpty(houseVO.getPopulationVOList())) { + List populationVOList = houseVO.getPopulationVOList(); + for (PopulationVO populationVO : populationVOList) { + populationVO.setHouseId(houseId); + populationService.saveReturnId(token, populationVO); + } + } return houseId; } @@ -124,6 +140,27 @@ public class HouseServiceImpl extends AbstractService implements IHouseService { setUpdateInfo(token, params); } houseDao.update(params); + + // 1. 判断创建房屋时,是否有人员信息一起 + // 2. 有的话,删除旧的人员信息,并录入新的人员信息 + if(!CollectionUtils.isEmpty(houseVO.getPopulationVOList())) { + List populationVOList = houseVO.getPopulationVOList(); + for (PopulationVO populationVO : populationVOList) { + if("1".equals(populationVO.getOutHouse())) { + populationService.update(populationVO.getPopulationId(), populationVO); + } else if(StringUtils.isEmpty(populationVO.getPopulationId())) { + populationService.save(token, populationVO); + }else { + populationdao.deleteById(populationVO.getPopulationId()); + } + } + populationdao.deleteById(houseId); + for (PopulationVO populationVO : populationVOList) { + if(!"1".equals(populationVO.getOutHouse())) { + populationService.save(token, populationVO); + } + } + } } @Override diff --git a/src/main/resources/mybatis/mapper/population/population-mapper.xml b/src/main/resources/mybatis/mapper/population/population-mapper.xml index b08d9fb..4f88d2a 100644 --- a/src/main/resources/mybatis/mapper/population/population-mapper.xml +++ b/src/main/resources/mybatis/mapper/population/population-mapper.xml @@ -10,6 +10,7 @@ + @@ -25,6 +26,7 @@ + @@ -40,6 +42,7 @@ + @@ -57,6 +60,7 @@ card_num, phone, bind_time, + out_house, creator, gmt_create, modifier, @@ -70,6 +74,7 @@ #{cardNum}, #{phone}, #{bindTime}, + #{outHouse}, #{creator}, #{gmtCreate}, #{modifier}, @@ -104,6 +109,15 @@ + + + DELETE FROM + house_population + WHERE + population_id = #{population_id} + AND out_house != 1 + + UPDATE @@ -126,6 +140,9 @@ bind_time = #{bindTime}, + + + out_house = #{outHouse}, gmt_modified = #{gmtModified}, modifier = #{modifier}, @@ -143,6 +160,7 @@ t1.card_num, t1.phone, t1.bind_time, + t1.out_house, t1.population_id FROM house_population t1 @@ -164,6 +182,7 @@ t1.card_num, t1.phone, t1.bind_time, + t1.out_house, t1.creator, t1.gmt_create, t1.modifier, @@ -189,6 +208,7 @@ t1.card_num, t1.phone, t1.bind_time, + t1.out_house, t1.creator, t1.gmt_create, t1.modifier, @@ -214,6 +234,7 @@ t1.card_num, t1.phone, t1.bind_time, + t1.out_house, t1.creator, t1.gmt_create, t1.modifier, @@ -240,6 +261,9 @@ AND t1.house_id = #{houseId} + + AND t1.out_house = #{outHouse} + AND LEFT(t1.gmt_create, 10) = ]]> #{startTime} @@ -267,6 +291,7 @@ t1.card_num, t1.phone, t1.bind_time, + t1.out_house, t1.creator, t1.gmt_create, t1.modifier, @@ -309,6 +334,7 @@ t1.card_num, t1.phone, t1.bind_time, + t1.out_house, t1.creator, t1.gmt_create, t1.modifier,