yanghb
2025-06-30 e24b2e3e67489527148cdd644c2c7e1b4ef36d61
cz-bussiness/src/main/java/com/ruoyi/bussiness/service/impl/PlacementBatchServiceImpl.java
@@ -22,6 +22,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;
@@ -378,26 +379,29 @@
                            (existing, replacement) -> existing
                    ));
            for (PlacementBatchAsset record : assetRecords) {
                if(record.getChecks() == 1){
                if (record.getChecks() == 1) {
                    continue;
                }
                //未通过安置申请
                if (placementApplyRecordService.countPassIdCard(record.getIdCard()) == 0) {
                    record.setHouseholdHeadWarn(1);
                }else{
                } else {
                    record.setHouseholdHeadWarn(0);
                }
                //赔偿金额(判断新购房还是二手房,这两个只能存在一个)
                if (record.getPriceNewAmount().compareTo(BigDecimal.ZERO) == 0 &&
                        record.getPriceOldAmount().compareTo(BigDecimal.ZERO) == 0) {
                    record.setPriceAmountWarn(1);
                //身份证重复
                if(placementBatchAssetService.existsIdCard(record.getIdCard())){
                    record.setIdCardRepeatWarn(1);
                }else{
                    record.setPriceAmountWarn(0);
                    record.setIdCardRepeatWarn(0);
                }
                if (record.getPriceNewAmount().compareTo(BigDecimal.ZERO) > 0 &&
                        record.getPriceOldAmount().compareTo(BigDecimal.ZERO) > 0) {
                //赔偿金额(判断新购房还是二手房,这两个只能存在一个)
                if (ObjUtil.isNotEmpty(record.getPriceNewAmount())
                        && ObjUtil.isNotEmpty(record.getPriceOldAmount())) {
                    record.setPriceAmountWarn(1);
                }else{
                } else if (ObjUtil.isEmpty(record.getPriceNewAmount())
                        && ObjUtil.isEmpty(record.getPriceOldAmount())) {
                    record.setPriceAmountWarn(1);
                } else {
                    record.setPriceAmountWarn(0);
                }
                //拆迁时间
@@ -406,7 +410,7 @@
                    continue;
                }
                //自主购房补贴、过渡补贴(如果购房情况异常则不判定自主购房补贴是否异常,自主购房补贴、过渡补贴 依赖赔偿金额信息)
                if (record.getPriceAmountWarn() == 0) {
                if (record.getPriceAmountWarn() == 0 && record.getPriceAmountWarn() == 0) {
                    boolean warnFlag = compensateService.compensateBuyCalculateV2(applyRecord.getDemolitionTime(),
                            record.getStreet(),
                            applyRecord.getOrgArea(), applyRecord.getNoOrgArea(),
@@ -417,14 +421,14 @@
                    //过渡补贴
                    if (compensateService.compensateSubsidyCalculate(applyRecord.getCurrentCount(), record.getSubsidyAmount())) {
                        record.setSubsidyAmountWarn(0);
                    }else{
                    } else {
                        record.setSubsidyAmountWarn(1);
                    }
                    //首付款警告
                    boolean downPaymentAmountWarn = true;
                    BigDecimal cateAmount = record.getCompensationAmount().multiply(new BigDecimal("0.25"));
                    if(cateAmount.compareTo(record.getDownPaymentAmount()) == 0){
                    if (cateAmount.compareTo(record.getDownPaymentAmount()) == 0) {
                        downPaymentAmountWarn = false;
                    }
                    record.setDownPaymentAmountWarn(downPaymentAmountWarn ? 1 : 0);
@@ -492,19 +496,18 @@
                }
                record.setWaitFamilyAreaWarn(warn ? 0 : 1);
                //赔偿金额(判断新购房还是二手房,这两个只能存在一个)
                if (record.getCompensationNewAmount().compareTo(BigDecimal.ZERO) == 0 &&
                        record.getCompensationOldAmount().compareTo(BigDecimal.ZERO) == 0) {
                //判断是否两个都填写了
                if (ObjUtil.isNotEmpty(record.getCompensationOldAmount())
                        && ObjUtil.isNotEmpty(record.getCompensationNewAmount())) {
                    record.setCompensationAmountWarn(1);
                }else{
                }else if(ObjUtil.isEmpty(record.getCompensationNewAmount())
                    && ObjUtil.isEmpty(record.getCompensationOldAmount())){
                    record.setCompensationAmountWarn(1);
                } else {
                    record.setCompensationAmountWarn(0);
                }
                if (record.getCompensationNewAmount().compareTo(BigDecimal.ZERO) > 0 &&
                        record.getCompensationOldAmount().compareTo(BigDecimal.ZERO) > 0) {
                    record.setCompensationAmountWarn(1);
                }else{
                    record.setCompensationAmountWarn(0);
                }
                BigDecimal orgArea = placementApplyRecord == null ? BigDecimal.ZERO : placementApplyRecord.getOrgArea();
                BigDecimal noOrgArea = placementApplyRecord == null ? BigDecimal.ZERO : placementApplyRecord.getNoOrgArea();
                //自主购房补贴、过渡补贴(如果购房情况异常则不判定自主购房补贴是否异常,自主购房补贴、过渡补贴 依赖赔偿金额信息)
@@ -519,7 +522,7 @@
                    //过渡补贴
                    if (compensateService.compensateSubsidyCalculate(record.getCurrentCount(), record.getSubsidyAmount())) {
                        record.setSubsidyAmountWarn(0);
                    }else{
                    } else {
                        record.setSubsidyAmountWarn(1);
                    }
                }
@@ -741,16 +744,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);
            }