From 7bd7ad452e6a7a3fc60acfd1d6898c70e933773e Mon Sep 17 00:00:00 2001
From: yanghb <yangbhwork@163.com>
Date: 星期六, 05 七月 2025 21:44:14 +0800
Subject: [PATCH] feat: 修复安置库信息

---
 cz-bussiness/src/main/java/com/ruoyi/bussiness/service/impl/PlacementBatchServiceImpl.java |  140 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 125 insertions(+), 15 deletions(-)

diff --git a/cz-bussiness/src/main/java/com/ruoyi/bussiness/service/impl/PlacementBatchServiceImpl.java b/cz-bussiness/src/main/java/com/ruoyi/bussiness/service/impl/PlacementBatchServiceImpl.java
index 15ac4dc..67e7c1d 100644
--- a/cz-bussiness/src/main/java/com/ruoyi/bussiness/service/impl/PlacementBatchServiceImpl.java
+++ b/cz-bussiness/src/main/java/com/ruoyi/bussiness/service/impl/PlacementBatchServiceImpl.java
@@ -3,6 +3,7 @@
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ObjUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.excel.EasyExcelFactory;
 import com.alibaba.excel.write.builder.ExcelWriterBuilder;
@@ -22,6 +23,7 @@
 import com.ruoyi.bussiness.service.*;
 import com.ruoyi.bussiness.utils.BatchNumberUtils;
 import com.ruoyi.bussiness.utils.PaymentCycleHelper;
+import com.ruoyi.common.easyExcel.CommentWriteHandler;
 import com.ruoyi.common.exception.GlobalException;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.file.FileUtils;
@@ -387,6 +389,12 @@
                 } else {
                     record.setHouseholdHeadWarn(0);
                 }
+                //身份证重复
+                if(placementBatchAssetService.existsIdCard(record.getIdCard())){
+                    record.setIdCardRepeatWarn(1);
+                }else{
+                    record.setIdCardRepeatWarn(0);
+                }
                 //赔偿金额(判断新购房还是二手房,这两个只能存在一个)
                 if (ObjUtil.isNotEmpty(record.getPriceNewAmount())
                         && ObjUtil.isNotEmpty(record.getPriceOldAmount())) {
@@ -680,24 +688,32 @@
             placementApplyRecordLambdaQueryWrapper.eq(PlacementBatchHousehold::getPlacementBatchId, placementBatch.getId());
             //家庭成员
             List<PlacementBatchHousehold> households = placementBatchHouseholdService.list(placementApplyRecordLambdaQueryWrapper);
-            //户主
-            List<String> houseHead = households.stream().map(PlacementBatchHousehold::getHouseholdHead).collect(Collectors.toList());
-            if (ObjUtil.isNotEmpty(households)) {
-                List<String> familyNames = households.stream().map(PlacementBatchHousehold::getWaitFamilyNames).collect(Collectors.toList());
-                List<String> allFamilyNames = new ArrayList<>();
-                for(String familyName : familyNames) {
-                    List<String> names = Arrays.asList(familyName.split("、"));
-                    allFamilyNames.addAll(names);
-                }
-                LambdaUpdateWrapper<Placement> placementLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
-                placementLambdaUpdateWrapper.set(Placement::getStatus, 1);
-                placementLambdaUpdateWrapper.and(query -> query.in(Placement::getFamilyName, allFamilyNames));
-                placementService.update(placementLambdaUpdateWrapper);
 
+            if(ObjectUtil.isEmpty(households)){
+                return;
+            }
+            //修改户主安置状态
+            List<String> houseHead = households.stream().map(PlacementBatchHousehold::getHouseholdHead).collect(Collectors.toList());
+            if (ObjUtil.isNotEmpty(houseHead)) {
                 LambdaUpdateWrapper<Placement> placementHouseHeadUpdateWrapper = new LambdaUpdateWrapper<>();
                 placementHouseHeadUpdateWrapper.set(Placement::getStatus, 1);
                 placementHouseHeadUpdateWrapper.and(query -> query.in(Placement::getHouseholdHead, houseHead));
                 placementService.update(placementHouseHeadUpdateWrapper);
+            }
+            //修改家庭成员安置状态
+            for(PlacementBatchHousehold household : households){
+                if(ObjUtil.isEmpty(household.getWaitFamilyNames())){
+                    continue;
+                }
+                //购房表家庭成员姓名
+                List<String> names = Arrays.asList(household.getWaitFamilyNames().split("、"));
+                //购房表户主身份证
+                String headIdCard = household.getIdCard();
+                LambdaUpdateWrapper<Placement> placementLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+                placementLambdaUpdateWrapper.set(Placement::getStatus, 1);
+                placementLambdaUpdateWrapper.eq(Placement::getIdCard,headIdCard);
+                placementLambdaUpdateWrapper.and(query -> query.in(Placement::getFamilyName, names));
+                placementService.update(placementLambdaUpdateWrapper);
             }
         }
 
@@ -737,16 +753,66 @@
             FileUtils.setExcelResponseHeader(response, "问题数据.xlsx");
             //资金表
             if (request.getType() == 1) {
-                ExcelWriterBuilder write = EasyExcelFactory.write(response.getOutputStream(), AssetExportResponse.class);
+                Map<String, String> warnFieldToTarget = new HashMap<>();
+                warnFieldToTarget.put("householdHeadWarn","householdHead");
+                warnFieldToTarget.put("idCardWarn","idCard");
+                warnFieldToTarget.put("twoPriceWarn","priceNewAmount");
+                warnFieldToTarget.put("priceAmountWarn","priceNewAmount");
+                warnFieldToTarget.put("compensationSumWarn","compensationAmount");
+                warnFieldToTarget.put("downPaymentAmountWarn","downPaymentAmount");
+                warnFieldToTarget.put("quarterPayAmountWarn","quarterPayAmount");
+                warnFieldToTarget.put("subsidyAmountWarn","subsidyAmount");
+
+                Map<String, String> warnMessages = new HashMap<>();
+                warnMessages.put("householdHeadWarn","户主未通过安置申请提示");
+                warnMessages.put("idCardWarn","身份证不存在安置库");
+                warnMessages.put("twoPriceWarn","多个购房情况警告");
+                warnMessages.put("priceAmountWarn","补偿标准数据异常");
+                warnMessages.put("compensationSumWarn","补偿总价异常");
+                warnMessages.put("downPaymentAmountWarn","首付款警告");
+                warnMessages.put("quarterPayAmountWarn","每季度需支付款项警告");
+                warnMessages.put("subsidyAmountWarn","过渡补贴异常");
+
                 List<PlacementBatchAsset> assets = placementBatchAssetService.problemList(request);
                 List<AssetExportResponse> data = BeanUtil.copyToList(assets, AssetExportResponse.class);
+
+                ExcelWriterBuilder write = EasyExcelFactory.
+                        write(response.getOutputStream(), AssetExportResponse.class)
+                        .registerWriteHandler(new CommentWriteHandler<>(data,warnFieldToTarget,warnMessages));
                 write.sheet("sheet").doWrite(data);
                 response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
             } else {
-                ExcelWriterBuilder write = EasyExcelFactory.write(response.getOutputStream(), HouseholdExportResponse.class);
+                Map<String, String> warnFieldToTarget = new HashMap<>();
+                warnFieldToTarget.put("householdHeadWarn","householdHead");
+                warnFieldToTarget.put("idCardWarn","idCard");
+                warnFieldToTarget.put("waitFamilyNamesWarn","waitFamilyNames");
+                warnFieldToTarget.put("waitFamilyNamesNoWarn","waitFamilyNames");
+                warnFieldToTarget.put("waitFamilyAreaWarn","waitFamilyArea");
+                warnFieldToTarget.put("compensationAmountWarn","compensationNewAmount");
+                warnFieldToTarget.put("compensationSumWarn","compensationSum");
+                warnFieldToTarget.put("downPaymentAmountWarn","downPaymentAmount");
+                warnFieldToTarget.put("quarterPayAmountWarn","quarterPayAmount");
+                warnFieldToTarget.put("subsidyAmountWarn","subsidyAmount");
+
+                Map<String, String> warnMessages = new HashMap<>();
+                warnMessages.put("householdHeadWarn","未通过安置申请警告");
+                warnMessages.put("idCardWarn","身份证不存在安置库警告");
+                warnMessages.put("waitFamilyNamesWarn","家庭成员重复");
+                warnMessages.put("waitFamilyNamesNoWarn","待安置家庭成员不在安置库");
+                warnMessages.put("waitFamilyAreaWarn","待安置人员应安置面积警告");
+                warnMessages.put("compensationAmountWarn","多个购房情况警告");
+                warnMessages.put("compensationSumWarn","补偿金额异常");
+                warnMessages.put("downPaymentAmountWarn","首付款警告");
+                warnMessages.put("quarterPayAmountWarn","每季度需支付款项");
+                warnMessages.put("subsidyAmountWarn","过渡补贴异常");
+
                 //购房表
                 List<PlacementBatchHousehold> households = placementBatchHouseholdService.problemList(request);
                 List<HouseholdExportResponse> data = BeanUtil.copyToList(households, HouseholdExportResponse.class);
+
+                ExcelWriterBuilder write = EasyExcelFactory
+                        .write(response.getOutputStream(), HouseholdExportResponse.class)
+                        .registerWriteHandler(new CommentWriteHandler<>(data,warnFieldToTarget,warnMessages));
                 write.sheet("sheet").doWrite(data);
                 response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
             }
@@ -755,6 +821,50 @@
         }
     }
 
+    @Override
+    public void fixSettle() {
+        //修改安置状态为0
+        LambdaUpdateWrapper<Placement> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(Placement::getStatus, 0);
+        placementService.update(updateWrapper);
+
+        LambdaQueryWrapper<PlacementBatch> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(PlacementBatch::getStatus, 1);
+        List<PlacementBatch> list = this.baseMapper.selectList(queryWrapper);
+        List<Long> batchIds = list.stream().map(PlacementBatch::getId).collect(Collectors.toList());
+        //查询房产表
+        LambdaQueryWrapper<PlacementBatchHousehold> householdWrapper = new LambdaQueryWrapper<>();
+        householdWrapper.in(PlacementBatchHousehold::getPlacementBatchId, batchIds);
+        List<PlacementBatchHousehold> households = this.placementBatchHouseholdService.list(householdWrapper);
+
+        if (ObjectUtil.isEmpty(households)) {
+            return;
+        }
+        //修改户主安置状态
+        List<String> houseHead = households.stream().map(PlacementBatchHousehold::getHouseholdHead).collect(Collectors.toList());
+        if (ObjUtil.isNotEmpty(houseHead)) {
+            LambdaUpdateWrapper<Placement> placementHouseHeadUpdateWrapper = new LambdaUpdateWrapper<>();
+            placementHouseHeadUpdateWrapper.set(Placement::getStatus, 1);
+            placementHouseHeadUpdateWrapper.and(query -> query.in(Placement::getHouseholdHead, houseHead));
+            placementService.update(placementHouseHeadUpdateWrapper);
+        }
+        //修改家庭成员安置状态
+        for (PlacementBatchHousehold household : households) {
+            if (ObjUtil.isEmpty(household.getWaitFamilyNames())) {
+                continue;
+            }
+            //购房表家庭成员姓名
+            List<String> names = Arrays.asList(household.getWaitFamilyNames().split("、"));
+            //购房表户主身份证
+            String headIdCard = household.getIdCard();
+            LambdaUpdateWrapper<Placement> placementLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+            placementLambdaUpdateWrapper.set(Placement::getStatus, 1);
+            placementLambdaUpdateWrapper.eq(Placement::getIdCard, headIdCard);
+            placementLambdaUpdateWrapper.and(query -> query.in(Placement::getFamilyName, names));
+            placementService.update(placementLambdaUpdateWrapper);
+        }
+    }
+
     /**
      * 获取最近批次号
      *

--
Gitblit v1.7.1