Browse Source

房屋导入修改,存在的更新

dev
zxc 3 years ago
parent
commit
ed2033d26d
  1. 2
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java
  2. 19
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExistHouseInfoResultDTO.java
  3. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java
  4. 26
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java
  5. 62
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java
  6. 26
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java
  7. 30
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java
  8. 7
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml
  9. 44
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml

2
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java

@ -138,6 +138,8 @@ public class ImportGeneralDTO implements Serializable {
private Boolean existStatus = false;
private Boolean addStatus = false;
/**
* 楼栋重复状态
*/

19
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExistHouseInfoResultDTO.java

@ -0,0 +1,19 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2022/3/25 10:46
* @DESC
*/
@Data
public class ExistHouseInfoResultDTO implements Serializable {
private static final long serialVersionUID = -6350975846409029631L;
private String name;
private String houseId;
}

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java

@ -22,6 +22,7 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.ImportGeneralDTO;
import com.epmet.dto.result.BaseInfoFamilyBuildingResultDTO;
import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.ExistHouseInfoResultDTO;
import com.epmet.dto.result.UpdateBuildingHouseNumResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.entity.IcBuildingEntity;
@ -161,7 +162,7 @@ public interface IcBuildingDao extends BaseDao<IcBuildingEntity> {
* @author zxc
* @date 2022/2/14 5:32 下午
*/
List<String> selectExistHouse(@Param("ids")List<String> ids);
List<ExistHouseInfoResultDTO> selectExistHouse(@Param("ids")List<String> ids);
/**
* Desc: 查询客户下户数为空的

26
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java

@ -1,24 +1,8 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.ImportGeneralDTO;
import com.epmet.dto.result.HouseInfoDTO;
import com.epmet.dto.result.NeighborHoodManageDelResultDTO;
import com.epmet.entity.IcHouseEntity;
@ -100,4 +84,12 @@ public interface IcHouseDao extends BaseDao<IcHouseEntity> {
*/
List<String> selectHouseNames(@Param("ids")List<String> ids);
/**
* Desc: 批量更新房屋信息
* @param houses
* @author zxc
* @date 2022/3/25 10:22
*/
void houseUpdate(@Param("houses") List<ImportGeneralDTO> houses);
}

62
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java

@ -15,6 +15,7 @@ import com.epmet.dao.IcBuildingDao;
import com.epmet.dto.ImportGeneralDTO;
import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.result.ExistHouseInfoResultDTO;
import com.epmet.dto.result.ImportResultDTO;
import com.epmet.dto.result.UpdateBuildingHouseNumResultDTO;
import com.epmet.entity.IcHouseEntity;
@ -48,6 +49,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
List<ImportGeneralDTO> needDisposeList = new ArrayList<>();
List<ImportGeneralDTO> needInsertList = new ArrayList<>();
List<ImportGeneralDTO> needUpdateList = new ArrayList<>();
String gridName = null;
String agencyName = null;
@ -125,21 +127,6 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
disposeErrorMsg(info, "是否出租的值未填写");
return;
}
if(StringUtils.isBlank(data.getOwnerIdCard())){
nums.add(num);
disposeErrorMsg(info, "房主身份证的值未填写");
return;
}
if(StringUtils.isBlank(data.getOwnerName())){
nums.add(num);
disposeErrorMsg(info, "房主姓名的值未填写");
return;
}
if(StringUtils.isBlank(data.getOwnerPhone())){
nums.add(num);
disposeErrorMsg(info, "房主电话的值未填写");
return;
}
if(StringUtils.isBlank(data.getDoorName())){
nums.add(num);
disposeErrorMsg(info, "门牌号的值未填写");
@ -208,29 +195,46 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
if (CollectionUtils.isEmpty(needInsertList)){
return;
}
// 根据单元ID_doorName查询已存在的
List<String> ids = needInsertList.stream().filter(n -> StringUtils.isNotBlank(n.getBuildingUnitId())).map(m -> m.getBuildingUnitId() + "_" + m.getDoorName()).distinct().collect(Collectors.toList());
List<ExistHouseInfoResultDTO> existHouses = icBuildingDao.selectExistHouse(ids);
Map<String, Long> collect = needInsertList.stream().collect(Collectors.groupingBy(n -> n.getBuildingUnitId() + "_" + n.getDoorName(), Collectors.counting()));
collect.forEach((k,v) -> {
if (Integer.valueOf(v.toString()).compareTo(1) > 0){
if (Integer.valueOf(v.toString()).compareTo(1) != 0){
for (ImportGeneralDTO r : needInsertList) {
if (k.equals(r.getBuildingUnitId()+"_"+r.getDoorName())){
// 集合里重复的
nums.add(r.getNum());
/*nums.add(r.getNum());
disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR);
r.setExistStatus(true);
r.setExistStatus(true);*/
if (!r.getAddStatus()){
for (ExistHouseInfoResultDTO existHouse : existHouses) {
if (existHouse.getName().equals(r.getBuildingUnitId()+"_"+r.getDoorName())){
r.setHouseId(existHouse.getHouseId());
break;
}
}
needUpdateList.add(r);
r.setAddStatus(true);
r.setExistStatus(true);
}
}
}
}
});
// 根据单元ID_doorName查询已存在的
List<String> ids = needInsertList.stream().filter(n -> StringUtils.isNotBlank(n.getBuildingUnitId())).map(m -> m.getBuildingUnitId() + "_" + m.getDoorName()).distinct().collect(Collectors.toList());
List<String> existHouses = icBuildingDao.selectExistHouse(ids);
existHouses.forEach(e -> {
for (ImportGeneralDTO n : needInsertList) {
if ((n.getBuildingUnitId()+"_"+n.getDoorName()).equals(e)){
if ((n.getBuildingUnitId()+"_"+n.getDoorName()).equals(e.getName())){
// 库里存在的
nums.add(n.getNum());
disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR);
n.setExistStatus(true);
// nums.add(n.getNum());
// disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR);
// n.setExistStatus(true);
if (!n.getAddStatus()){
n.setHouseId(e.getHouseId());
needUpdateList.add(n);
n.setAddStatus(true);
n.setExistStatus(true);
}
}
}
});
@ -238,6 +242,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
Map<Boolean, List<ImportGeneralDTO>> groupByExistStatus = needInsertList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus));
List<ImportGeneralDTO> importGeneralDTOS = groupByExistStatus.get(false);
houseInsert(importGeneralDTOS);
houseUpdate(needUpdateList);
// 清除
needDisposeList = new ArrayList<>();
needInsertList = new ArrayList<>();
@ -576,4 +581,11 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
}
}
@Transactional(rollbackFor = Exception.class)
public void houseUpdate(List<ImportGeneralDTO> houses){
if (!CollectionUtils.isEmpty(houses)){
icHouseService.houseUpdate(houses);
}
}
}

26
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java

@ -1,20 +1,3 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
@ -22,6 +5,7 @@ import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.IcHouseDTO;
import com.epmet.dto.ImportGeneralDTO;
import com.epmet.dto.form.HouseFormDTO;
import com.epmet.dto.result.HouseListResultDTO;
import com.epmet.entity.IcHouseEntity;
@ -124,4 +108,12 @@ public interface IcHouseService extends BaseService<IcHouseEntity> {
*/
List<HouseListResultDTO> getHouseList(TokenDto tokenDto, HouseFormDTO formDTO);
/**
* Desc: 批量更新房屋信息
* @param houses
* @author zxc
* @date 2022/3/25 10:22
*/
void houseUpdate(List<ImportGeneralDTO> houses);
}

30
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java

@ -1,20 +1,3 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -33,6 +16,7 @@ import com.epmet.dao.IcHouseDao;
import com.epmet.dto.IcHouseDTO;
import com.epmet.dto.IcResiCategoryStatsConfigDTO;
import com.epmet.dto.IcResiUserDTO;
import com.epmet.dto.ImportGeneralDTO;
import com.epmet.dto.form.HouseFormDTO;
import com.epmet.dto.result.HouseListResultDTO;
import com.epmet.entity.IcHouseEntity;
@ -235,4 +219,16 @@ public class IcHouseServiceImpl extends BaseServiceImpl<IcHouseDao, IcHouseEntit
}).collect(Collectors.toList());
}
/**
* Desc: 批量更新房屋信息
* @param houses
* @author zxc
* @date 2022/3/25 10:22
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void houseUpdate(List<ImportGeneralDTO> houses) {
baseDao.houseUpdate(houses);
}
}

7
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml

@ -335,8 +335,11 @@
</select>
<!-- 查询已存在的房屋 -->
<select id="selectExistHouse" resultType="java.lang.String">
SELECT CONCAT(BUILDING_UNIT_ID,'_',DOOR_NAME) FROM ic_house
<select id="selectExistHouse" resultType="com.epmet.dto.result.ExistHouseInfoResultDTO">
SELECT
CONCAT(BUILDING_UNIT_ID,'_',DOOR_NAME) AS name,
ID AS houseId
FROM ic_house
WHERE DEL_FLAG = '0'
AND CONCAT(BUILDING_UNIT_ID,'_',DOOR_NAME) IN
(

44
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml

@ -26,6 +26,50 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!-- 批量更新房屋信息 -->
<update id="houseUpdate">
UPDATE ic_house
<trim prefix="set" suffixOverrides=",">
<trim prefix="HOUSE_TYPE =(case" suffix="end),">
<foreach collection="houses" item="h">
when id = #{h.houseId} then #{h.houseType}
</foreach>
</trim>
<trim prefix="PURPOSE =(case" suffix="end),">
<foreach collection="houses" item="h">
when id = #{h.houseId} then #{h.purpose}
</foreach>
</trim>
<trim prefix="RENT_FLAG =(case" suffix="end),">
<foreach collection="houses" item="h">
when id = #{h.houseId} then #{h.rentFlag}
</foreach>
</trim>
<trim prefix="OWNER_NAME =(case" suffix="end),">
<foreach collection="houses" item="h">
when id = #{h.houseId} then #{h.ownerName}
</foreach>
</trim>
<trim prefix="OWNER_PHONE =(case" suffix="end),">
<foreach collection="houses" item="h">
when id = #{h.houseId} then #{h.ownerPhone}
</foreach>
</trim>
<trim prefix="OWNER_ID_CARD =(case" suffix="end),">
<foreach collection="houses" item="h">
when id = #{h.houseId} then #{h.ownerIdCard}
</foreach>
</trim>
UPDATED_TIME = NOW()
</trim>
WHERE DEL_FLAG = '0'
AND ID IN (
<foreach collection="houses" item="h" separator=",">
#{h.houseId}
</foreach>
)
</update>
<!--<select id="searchHouseByPage" resultType="map">
select
a.ID as houseId,

Loading…
Cancel
Save