From d07b02f12c47f0e513d98a49d1106d22416868c0 Mon Sep 17 00:00:00 2001
From: CeDo <cedoogle@gmail.com>
Date: 星期五, 11 六月 2021 13:37:29 +0800
Subject: [PATCH] bugfixed

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java |   77 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
index 03a3485..62a9965 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -17,9 +17,7 @@
 import com.panzhihua.common.model.vos.area.AreaAddressVO;
 import com.panzhihua.common.model.vos.community.*;
 import com.panzhihua.common.model.vos.user.*;
-import com.panzhihua.common.utlis.AgeUtils;
-import com.panzhihua.common.utlis.IdCard;
-import com.panzhihua.common.utlis.PayUtil;
+import com.panzhihua.common.utlis.*;
 import com.panzhihua.service_community.dao.*;
 import com.panzhihua.service_community.model.dos.*;
 import com.panzhihua.service_community.service.ComMngPopulationHouseUserService;
@@ -31,7 +29,6 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
-import com.panzhihua.common.utlis.StringUtils;
 
 import javax.annotation.Resource;
 import javax.crypto.BadPaddingException;
@@ -198,6 +195,56 @@
         }
         page.setSize(pageSize);
         page.setCurrent(pageNum);
+
+        if(comMngPopulationVO.getHouseId() != null){
+            ComMngPopulationHouseDO houseDO = comMngPopulationHouseDAO.selectById(comMngPopulationVO.getHouseId());
+            if(houseDO != null){
+                switch (comMngPopulationVO.getLevel()){
+                    case 1:
+                        comMngPopulationVO.setRoad(houseDO.getAlley());
+                        break;
+                    case 2:
+                        comMngPopulationVO.setRoad(houseDO.getAlley());
+                        comMngPopulationVO.setDoorNo(houseDO.getHouseNum());
+                        break;
+                    case 3:
+                        comMngPopulationVO.setRoad(houseDO.getAlley());
+                        comMngPopulationVO.setDoorNo(houseDO.getHouseNum());
+                        comMngPopulationVO.setFloor(houseDO.getFloor());
+                        break;
+                    case 4:
+                        comMngPopulationVO.setRoad(houseDO.getAlley());
+                        comMngPopulationVO.setDoorNo(houseDO.getHouseNum());
+                        comMngPopulationVO.setFloor(houseDO.getFloor());
+                        comMngPopulationVO.setUnitNo(houseDO.getUnitNo());
+                        break;
+                    case 5:
+                        comMngPopulationVO.setRoad(houseDO.getAlley());
+                        comMngPopulationVO.setDoorNo(houseDO.getHouseNum());
+                        comMngPopulationVO.setFloor(houseDO.getFloor());
+                        comMngPopulationVO.setUnitNo(houseDO.getUnitNo());
+                        comMngPopulationVO.setHouseNo(houseDO.getHouseNo());
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        if(StringUtils.isNotEmpty(comMngPopulationVO.getAgeStart())){
+            String ageStartTime = DateUtils.getDateFormatString(DateUtils.yearAddNum(new Date(),-(Integer.parseInt(comMngPopulationVO.getAgeStart()) + 1)),"yyyy-MM-dd");
+            if(StringUtils.isNotEmpty(ageStartTime)){
+                comMngPopulationVO.setAgeStartTime(ageStartTime);
+            }
+        }
+
+        if(StringUtils.isNotEmpty(comMngPopulationVO.getAgeEnd())){
+            String ageEndTime = DateUtils.getDateFormatString(DateUtils.yearAddNum(new Date(),-(Integer.parseInt(comMngPopulationVO.getAgeEnd()) + 1)),"yyyy-MM-dd");
+            if(StringUtils.isNotEmpty(ageEndTime)){
+                comMngPopulationVO.setAgeEndTime(ageEndTime);
+            }
+        }
+
         IPage<ComMngPopulationVO> iPage = populationDAO.pagePopulation(page, comMngPopulationVO);
         if(!iPage.getRecords().isEmpty()){
             iPage.getRecords().forEach(populDO -> {
@@ -276,8 +323,12 @@
                 continue;
             }
 
+            if(!comMngVillageDO.getHouseNum().contains("号")){
+                comMngVillageDO.setHouseNum(comMngVillageDO.getHouseNum() + "号");
+            }
+
             address = areaAddressVO.getProvince() + areaAddressVO.getCity()
-                    + areaAddressVO.getDistrict() + street + comMngVillageDO.getAlley() + comMngVillageDO.getHouseNum() + "号"
+                    + areaAddressVO.getDistrict() + street + comMngVillageDO.getAlley() + comMngVillageDO.getHouseNum()
                     + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo();
             vo.setAddress(address);
 
@@ -308,6 +359,7 @@
                     populationHouseDO.setUnitNo(vo.getUnitNo());
                     populationHouseDO.setHouseNo(vo.getHouseNo());
                     populationHouseDO.setAddress(address);
+                    populationHouseDO.setUpdateAt(new Date());
                     if(StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())){
                         populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode());
                     }
@@ -369,6 +421,7 @@
                         populationDO.setVillageName(comMngVillageDO.getGroupAt());
                         populationDO.setHouseAddress(address);
                         populationDO.setHouseId(populationHouseDO.getId());
+                        populationDO.setUpdateAt(new Date());
                         this.baseMapper.insert(populationDO);
                         savePopulList.add(populationDO);
                         index++;
@@ -385,6 +438,7 @@
                     populationDO.setVillageName(comMngVillageDO.getGroupAt());
                     populationDO.setHouseAddress(address);
                     populationDO.setHouseId(populationHouseDO.getId());
+                    populationDO.setUpdateAt(new Date());
                     this.baseMapper.insert(populationDO);
                     savePopulList.add(populationDO);
                     index++;
@@ -527,7 +581,14 @@
      * @return
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public R deletePopulations(List<Long> Ids) {
+        if(!Ids.isEmpty()){
+            Ids.forEach(id -> {
+                //清除用户房屋居住信息
+                comMngPopulationHouseUserDAO.deletePopulationHouseByUserId(id);
+            });
+        }
         int delete = populationDAO.deleteBatchIds(Ids);
         if (delete > 0) {
             return R.ok();
@@ -580,6 +641,12 @@
             return R.fail();
         }
         BeanUtils.copyProperties(vo,populationDO);
+        if(StringUtils.isEmpty(vo.getLabel())){
+            populationDO.setLabel(null);
+        }
+        if(StringUtils.isEmpty(vo.getRemark())){
+            populationDO.setRemark(null);
+        }
         populationDO.setCardNo(null);
         populationDO.setPhone(AESUtil.encrypt128(vo.getPhone(), aesKey));
 

--
Gitblit v1.7.1