package com.ruoyi.bussiness.service.impl;
|
|
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.StrUtil;
|
import com.alibaba.excel.EasyExcelFactory;
|
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.ruoyi.bussiness.domain.*;
|
import com.ruoyi.bussiness.enums.MessageTypeEnum;
|
import com.ruoyi.bussiness.mapper.PlacementBatchMapper;
|
import com.ruoyi.bussiness.object.request.placementBatch.*;
|
import com.ruoyi.bussiness.object.request.report.ReportRequest;
|
import com.ruoyi.bussiness.object.response.placementApply.ProblemExportResponse;
|
import com.ruoyi.bussiness.object.response.placementBatch.*;
|
import com.ruoyi.bussiness.object.response.screen.*;
|
import com.ruoyi.bussiness.service.*;
|
import com.ruoyi.bussiness.utils.BatchNumberUtils;
|
import com.ruoyi.bussiness.utils.PaymentCycleHelper;
|
import com.ruoyi.common.exception.GlobalException;
|
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.file.FileUtils;
|
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.service.ISysNoticeService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.MediaType;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.File;
|
import java.io.IOException;
|
import java.math.BigDecimal;
|
import java.math.RoundingMode;
|
import java.text.ParseException;
|
import java.util.*;
|
import java.util.function.Function;
|
import java.util.stream.Collectors;
|
|
@Service
|
public class PlacementBatchServiceImpl extends ServiceImpl<PlacementBatchMapper, PlacementBatch> implements PlacementBatchService {
|
|
@Autowired
|
private PlacementBatchAssetService placementBatchAssetService;
|
@Autowired
|
private PlacementBatchHouseholdService placementBatchHouseholdService;
|
@Autowired
|
private ISysNoticeService sysNoticeService;
|
@Autowired
|
private PlacementApplyRecordService placementApplyRecordService;
|
@Autowired
|
private CompensateService compensateService;
|
@Autowired
|
private PlacementService placementService;
|
@Autowired
|
private PlacementErrorService placementErrorService;
|
|
@Override
|
public PlacementBatchPageResponse page(PlacementBatchPageRequest request) {
|
Page<PlacementBatch> page = new Page<>(request.getPageNum(), request.getPageSize());
|
LambdaQueryWrapper<PlacementBatch> wrapper = new LambdaQueryWrapper<>();
|
if (ObjUtil.isNotEmpty(request.getBatchNumber())) {
|
wrapper.like(PlacementBatch::getBatchNumber, request.getBatchNumber());
|
}
|
if(ObjUtil.isNotEmpty(request.getStatus())){
|
wrapper.eq(PlacementBatch::getStatus,request.getStatus());
|
}
|
wrapper.orderByDesc(PlacementBatch::getId);
|
|
Page<PlacementBatch> pageData = baseMapper.selectPage(page, wrapper);
|
|
PlacementBatchPageResponse response = new PlacementBatchPageResponse();
|
response.setRecords(pageData.getRecords());
|
response.setTotal(pageData.getTotal());
|
return response;
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
@Override
|
public void imports(PlacementBatchImportRequest request) {
|
//判断数据
|
if (ObjUtil.isEmpty(request.getId())) {
|
if (ObjUtil.isEmpty(request.getAssetFile())) {
|
throw new GlobalException("请上传资金表");
|
}
|
if (ObjUtil.isEmpty(request.getHouseholdFile())) {
|
throw new GlobalException("请上传房产表");
|
}
|
} else {
|
if (ObjUtil.isEmpty(request.getAssetFile())
|
&& ObjUtil.isEmpty(request.getHouseholdFile())) {
|
throw new GlobalException("请至少上传资金表或者房产表");
|
}
|
}
|
|
//新增安置批次表信息
|
PlacementBatch placementBatch;
|
if (ObjUtil.isEmpty(request.getId())) {
|
placementBatch = new PlacementBatch();
|
String batchNumber = BatchNumberUtils.getBatchNumber(getLastBatchNumber());
|
placementBatch.setBatchNumber(batchNumber);
|
placementBatch.setCreateId(SecurityUtils.getUserId());
|
placementBatch.setCreateUser(SecurityUtils.getLoginUser().getUser().getNickName());
|
save(placementBatch);
|
} else {
|
placementBatch = baseMapper.selectById(request.getId());
|
}
|
|
if (ObjUtil.isEmpty(placementBatch)) {
|
throw new GlobalException("安置批次信息不存在!");
|
}
|
|
//导入资金表
|
if (ObjUtil.isNotEmpty(request.getAssetFile())) {
|
importAsset(placementBatch.getId(), request.getAssetFile());
|
}
|
//导入房产表
|
if (ObjUtil.isNotEmpty(request.getHouseholdFile())) {
|
importHousehold(placementBatch.getId(), request.getHouseholdFile());
|
}
|
|
//汇总数据
|
sumPlacementBatch(placementBatch);
|
|
//同步待处理消息
|
new Thread(() -> {
|
//批注数据
|
placementBatch.setStatus(0);
|
dataTag(placementBatch);
|
countError(placementBatch);
|
//统计错误数据
|
syncApplyMessage();
|
}).start();
|
|
}
|
|
/**
|
* 统计数据
|
*/
|
public void countError(PlacementBatch placementBatch) {
|
// List<Map<String, Object>> error = this.baseMapper.countError(placementBatch.getId());
|
|
//查询当前批次资金信息
|
LambdaQueryWrapper<PlacementBatchAsset> assetLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
assetLambdaQueryWrapper.eq(PlacementBatchAsset::getPlacementBatchId,placementBatch.getId());
|
List<PlacementBatchAsset> assets = placementBatchAssetService.list(assetLambdaQueryWrapper);
|
|
List<PlacementError> placementErrors = new ArrayList<>();
|
if(ObjUtil.isNotEmpty(assets)){
|
for(PlacementBatchAsset asset : assets){
|
PlacementError placementError = new PlacementError();
|
/**
|
* sum(household_head_warn+id_card_warn+wait_family_area_warn+two_price_warn+
|
* price_amount_warn+compensation_sum_warn+quarter_pay_amount_warn+subsidy_amount_warn) as errorNum,
|
* sum(household_head_warn+id_card_warn) as settleNum,
|
* sum(wait_family_area_warn) as areaNum,
|
* sum(two_price_warn+price_amount_warn+compensation_sum_warn+quarter_pay_amount_warn+subsidy_amount_warn) as compensationNum,
|
*/
|
|
Integer settleNum = asset.getHouseholdHeadWarn() + asset.getIdCardWarn();
|
Integer areaNum = asset.getWaitFamilyAreaWarn();
|
Integer compensationNum = asset.getTwoPriceWarn() + asset.getPriceAmountWarn()
|
+ asset.getCompensationSumWarn()+asset.getQuarterPayAmountWarn()
|
+ asset.getSubsidyAmountWarn() + asset.getDownPaymentAmountWarn();
|
Integer errorNum = settleNum + areaNum + compensationNum;
|
|
placementError.setStreet(asset.getStreet());
|
placementError.setErrorNum(errorNum);
|
placementError.setSettleNum(settleNum);
|
placementError.setAreaNum(areaNum);
|
placementError.setCompensationNum(compensationNum);
|
placementErrors.add(placementError);
|
}
|
}
|
|
|
//查询当前批次购房信息
|
LambdaQueryWrapper<PlacementBatchHousehold> householdLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
householdLambdaQueryWrapper.eq(PlacementBatchHousehold::getPlacementBatchId,placementBatch.getId());
|
List<PlacementBatchHousehold> households = placementBatchHouseholdService.list(householdLambdaQueryWrapper);
|
if (ObjUtil.isNotEmpty(households)) {
|
for(PlacementBatchHousehold household : households){
|
PlacementError placementError = new PlacementError();
|
/**
|
* sum(household_head_warn+id_card_warn+wait_family_names_warn+wait_family_names_no_warn) as settleNum,
|
* sum(wait_family_area_warn) as areaNum,
|
* sum(compensation_amount_warn+compensation_sum_warn+quarter_pay_amount_warn+subsidy_amount_warn) as compensationNum,
|
* sum(area_warn) as houseNum
|
*/
|
Integer settleNum = household.getHouseholdHeadWarn()+household.getIdCardWarn()
|
+household.getWaitFamilyNamesWarn() + household.getWaitFamilyNamesNoWarn();
|
Integer areaNum = household.getWaitFamilyAreaWarn();
|
Integer compensationNum = household.getCompensationAmountWarn()
|
+ household.getCompensationSumWarn()
|
+household.getQuarterPayAmountWarn()+household.getSubsidyAmountWarn()
|
+household.getDownPaymentAmountWarn();
|
Integer houseNum = household.getAreaWarn();
|
|
Integer errorNum = settleNum + areaNum + compensationNum + houseNum;
|
|
placementError.setStreet(household.getStreet());
|
placementError.setErrorNum(errorNum);
|
placementError.setSettleNum(settleNum);
|
placementError.setAreaNum(areaNum);
|
placementError.setCompensationNum(compensationNum);
|
placementError.setHouseNum(houseNum);
|
placementErrors.add(placementError);
|
}
|
}
|
placementErrorService.saveBatch(placementErrors);
|
}
|
|
/**
|
* 更新消息
|
*/
|
private void syncApplyMessage() {
|
SysNotice sysNotice = sysNoticeService.getById(2);
|
LambdaQueryWrapper<PlacementBatch> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.eq(PlacementBatch::getStatus, 0);
|
List<PlacementBatch> batches = this.list(queryWrapper);
|
if (ObjUtil.isEmpty(batches)) {
|
return;
|
}
|
List<Long> batchIds = batches.stream().map(PlacementBatch::getId).collect(Collectors.toList());
|
LambdaQueryWrapper<PlacementBatchAsset> assetCountQuery = new LambdaQueryWrapper<>();
|
assetCountQuery.eq(PlacementBatchAsset::getPlacementBatchId, batchIds);
|
int assetCount = NumberUtil.parseInt(String.valueOf(placementBatchAssetService.count(assetCountQuery)));
|
|
LambdaQueryWrapper<PlacementBatchHousehold> householdCountQuery = new LambdaQueryWrapper<>();
|
householdCountQuery.eq(PlacementBatchHousehold::getPlacementBatchId, batchIds);
|
int houseHoldCount = NumberUtil.parseInt(String.valueOf(placementBatchHouseholdService.count(householdCountQuery)));
|
|
int count = assetCount + houseHoldCount;
|
String msg = MessageTypeEnum.PLACEMENT_BATCH.getMessage();
|
sysNotice.setNoticeTitle(StrUtil.format(msg, Integer.toString(count)));
|
sysNotice.setCountNum(new BigDecimal(count));
|
sysNoticeService.updateById(sysNotice);
|
|
//当月支付补偿款
|
SysNotice sysNotice2 = sysNoticeService.getById(3);
|
BigDecimal currentMonthMoney = placementBatchHouseholdService.sumCurrentMonth();
|
String payMsg = MessageTypeEnum.PLACEMENT_PAY.getMessage();
|
sysNotice2.setNoticeTitle(StrUtil.format(payMsg, currentMonthMoney));
|
sysNotice2.setCountNum(currentMonthMoney);
|
sysNoticeService.updateById(sysNotice2);
|
|
//审核通过的购房表的人,以及签订时间从当前日期算,不超过2个月的 合计个人数统计就行了
|
SysNotice sysNotice3 = sysNoticeService.getById(4);
|
BigDecimal sumPersonCount = placementBatchHouseholdService.countCurrentPerson();
|
String personMsg = MessageTypeEnum.PLACEMENT_FIRST_PAY.getMessage();
|
sysNotice3.setNoticeTitle(StrUtil.format(personMsg, sumPersonCount));
|
sysNotice3.setCountNum(sumPersonCount);
|
sysNoticeService.updateById(sysNotice3);
|
|
}
|
|
@Override
|
public PlacementBatchDetailResponse detail(PlacementBatchDetailRequest request) {
|
PlacementBatch placementBatch = this.getById(request.getPlacementBatchId());
|
if (ObjUtil.isEmpty(placementBatch)) {
|
throw new GlobalException("安置批次信息不存在!");
|
}
|
|
PlacementBatchDetailResponse response = new PlacementBatchDetailResponse();
|
response.setPlacementBatch(placementBatch);
|
//根据类型查询明细记录(资金)
|
if (request.getType() == 1) {
|
//分页
|
Page<PlacementBatchAsset> assetPage = placementBatchAssetService.page(request);
|
response.setAssetList(assetPage.getRecords());
|
response.setTotal(assetPage.getTotal());
|
return response;
|
} else {
|
Page<PlacementBatchHousehold> householdPage = placementBatchHouseholdService.page(request);
|
//填充集体面积、非集体面积
|
if (ObjUtil.isNotEmpty(householdPage.getRecords())) {
|
for (PlacementBatchHousehold placementBatchHousehold : householdPage.getRecords()) {
|
PlacementApplyRecord record = placementApplyRecordService.getRecordsByCardId(placementBatchHousehold.getIdCard());
|
if (ObjUtil.isNotEmpty(record)) {
|
placementBatchHousehold.setOrgArea(record.getOrgArea());
|
placementBatchHousehold.setNoOrgArea(record.getNoOrgArea());
|
}
|
}
|
}
|
response.setHouseholdList(householdPage.getRecords());
|
response.setTotal(householdPage.getTotal());
|
return response;
|
}
|
}
|
|
@Override
|
public void dataApprove(PlacementBatchIdRequest request) {
|
PlacementBatch placementBatch = this.getById(request.getId());
|
if (ObjUtil.isEmpty(placementBatch)) {
|
throw new GlobalException("数据不存在");
|
}
|
if(placementBatch.getStatus() != 0){
|
throw new GlobalException("已审核通过!");
|
}
|
dataTag(placementBatch);
|
}
|
|
@Override
|
public void assetCheck(IdRequest request) {
|
LambdaUpdateWrapper<PlacementBatchAsset> updateWrapper = new LambdaUpdateWrapper<>();
|
updateWrapper.set(PlacementBatchAsset::getChecks,1);
|
updateWrapper.set(PlacementBatchAsset::getHouseholdHeadWarn,0);
|
updateWrapper.set(PlacementBatchAsset::getIdCardWarn,0);
|
updateWrapper.set(PlacementBatchAsset::getWaitFamilyAreaWarn,0);
|
updateWrapper.set(PlacementBatchAsset::getTwoPriceWarn,0);
|
updateWrapper.set(PlacementBatchAsset::getPriceAmountWarn,0);
|
updateWrapper.set(PlacementBatchAsset::getCompensationSumWarn,0);
|
updateWrapper.set(PlacementBatchAsset::getQuarterPayAmountWarn,0);
|
updateWrapper.set(PlacementBatchAsset::getSubsidyAmountWarn,0);
|
|
updateWrapper.eq(PlacementBatchAsset::getId,request.getId());
|
placementBatchAssetService.update(updateWrapper);
|
}
|
|
@Override
|
public void householdCheck(IdRequest request) {
|
LambdaUpdateWrapper<PlacementBatchHousehold> updateWrapper = new LambdaUpdateWrapper<>();
|
updateWrapper.set(PlacementBatchHousehold::getChecks,1);
|
updateWrapper.set(PlacementBatchHousehold::getHouseholdHeadWarn,0);
|
updateWrapper.set(PlacementBatchHousehold::getIdCardWarn,0);
|
updateWrapper.set(PlacementBatchHousehold::getWaitFamilyNamesWarn,0);
|
updateWrapper.set(PlacementBatchHousehold::getWaitFamilyNamesNoWarn,0);
|
updateWrapper.set(PlacementBatchHousehold::getWaitFamilyAreaWarn,0);
|
updateWrapper.set(PlacementBatchHousehold::getCompensationAmountWarn,0);
|
updateWrapper.set(PlacementBatchHousehold::getCompensationSumWarn,0);
|
updateWrapper.set(PlacementBatchHousehold::getQuarterPayAmountWarn,0);
|
updateWrapper.set(PlacementBatchHousehold::getSubsidyAmountWarn,0);
|
updateWrapper.set(PlacementBatchHousehold::getAreaWarn,0);
|
|
updateWrapper.eq(PlacementBatchHousehold::getId,request.getId());
|
placementBatchHouseholdService.update(updateWrapper);
|
}
|
|
@Override
|
public void del(PlacementBatchIdRequest request) {
|
this.removeById(request.getId());
|
placementBatchHouseholdService.remove(new LambdaQueryWrapper<PlacementBatchHousehold>().
|
eq(PlacementBatchHousehold::getPlacementBatchId, request.getId()));
|
placementBatchAssetService.remove(new LambdaQueryWrapper<PlacementBatchAsset>().
|
eq(PlacementBatchAsset::getPlacementBatchId, request.getId()));
|
}
|
|
/**
|
* 数据标注
|
* @param placementBatch
|
*/
|
private void dataTag(PlacementBatch placementBatch) {
|
if (ObjUtil.isEmpty(placementBatch)) {
|
return;
|
}
|
//数据已经审核过了,不需要标注
|
if (placementBatch.getStatus() != 0) {
|
return;
|
}
|
//资产表
|
List<PlacementBatchAsset> assetRecords = placementBatchAssetService.allList(placementBatch.getId());
|
if (ObjUtil.isNotEmpty(assetRecords)) {
|
//去购房表取签订时间、拆迁时间
|
List<String> idsCard = assetRecords.stream().map(PlacementBatchAsset::getIdCard).collect(Collectors.toList());
|
//去申请表取安置人数类型
|
List<PlacementApplyRecord> placementApplyRecords = placementApplyRecordService.getRecordsByCardIds(idsCard);
|
//申请表
|
Map<String, PlacementApplyRecord> placementApplyRecordMap = placementApplyRecords.stream()
|
.collect(Collectors.toMap(
|
PlacementApplyRecord::getIdCard,
|
Function.identity(),
|
(existing, replacement) -> existing
|
));
|
for (PlacementBatchAsset record : assetRecords) {
|
if(record.getChecks() == 1){
|
continue;
|
}
|
//未通过安置申请
|
if (placementApplyRecordService.countPassIdCard(record.getIdCard()) == 0) {
|
record.setHouseholdHeadWarn(1);
|
}else{
|
record.setHouseholdHeadWarn(0);
|
}
|
//赔偿金额(判断新购房还是二手房,这两个只能存在一个)
|
if (record.getPriceNewAmount().compareTo(BigDecimal.ZERO) == 0 &&
|
record.getPriceOldAmount().compareTo(BigDecimal.ZERO) == 0) {
|
record.setPriceAmountWarn(1);
|
}else{
|
record.setPriceAmountWarn(0);
|
}
|
if (record.getPriceNewAmount().compareTo(BigDecimal.ZERO) > 0 &&
|
record.getPriceOldAmount().compareTo(BigDecimal.ZERO) > 0) {
|
record.setPriceAmountWarn(1);
|
}else{
|
record.setPriceAmountWarn(0);
|
}
|
//拆迁时间
|
PlacementApplyRecord applyRecord = placementApplyRecordMap.get(record.getIdCard());
|
if (ObjUtil.isEmpty(applyRecord)) {
|
continue;
|
}
|
//自主购房补贴、过渡补贴(如果购房情况异常则不判定自主购房补贴是否异常,自主购房补贴、过渡补贴 依赖赔偿金额信息)
|
if (record.getPriceAmountWarn() == 0) {
|
boolean warnFlag = compensateService.compensateBuyCalculateV2(applyRecord.getDemolitionTime(),
|
record.getStreet(),
|
applyRecord.getOrgArea(), applyRecord.getNoOrgArea(),
|
record.getPriceNewAmount(), record.getPriceOldAmount(),
|
record.getCompensationAmount());
|
record.setCompensationSumWarn(warnFlag ? 0 : 1);
|
|
//过渡补贴
|
if (compensateService.compensateSubsidyCalculate(applyRecord.getCurrentCount(), record.getSubsidyAmount())) {
|
record.setSubsidyAmountWarn(0);
|
}else{
|
record.setSubsidyAmountWarn(1);
|
}
|
|
//首付款警告
|
boolean downPaymentAmountWarn = true;
|
BigDecimal cateAmount = record.getCompensationAmount().multiply(new BigDecimal("0.25"));
|
if(cateAmount.compareTo(record.getDownPaymentAmount()) == 0){
|
downPaymentAmountWarn = false;
|
}
|
record.setDownPaymentAmountWarn(downPaymentAmountWarn ? 1 : 0);
|
}
|
}
|
placementBatchAssetService.updateBatchById(assetRecords);
|
}
|
|
List<PlacementBatchHousehold> householdsRecords = placementBatchHouseholdService.allList(placementBatch.getId());
|
if (ObjUtil.isNotEmpty(householdsRecords)) {
|
for (PlacementBatchHousehold record : householdsRecords) {
|
if(record.getChecks() == 1){
|
continue;
|
}
|
//未通过安置申请
|
int pass = placementApplyRecordService.countPassIdCard(record.getIdCard());
|
if (pass == 0) {
|
record.setHouseholdHeadWarn(1);
|
}else{
|
record.setHouseholdHeadWarn(0);
|
}
|
//不在安置库
|
int noSettle = placementService.countPlacementByIdCard(record.getIdCard());
|
if ( noSettle == 0) {
|
record.setIdCardWarn(1);
|
}else{
|
record.setIdCardWarn(0);
|
}
|
//判断家庭成员是否重复
|
if (ObjUtil.isNotEmpty(record.getWaitFamilyNames())) {
|
boolean familyNameWarn = false;
|
boolean familyNoWarn = false;
|
String[] familyNames = record.getWaitFamilyNames().split("、");
|
if (ObjUtil.isNotEmpty(familyNames)) {
|
//判断是否在安置库 =0不在安置库
|
for (String familyName : familyNames) {
|
if (placementService.countNamesExists(familyName) ==0) {
|
familyNoWarn = true;
|
break;
|
}
|
}
|
//判断重复
|
for(String familyName : familyNames){
|
int exists = selectNameExists(familyName);
|
if (exists > 1) {
|
familyNameWarn = true;
|
break;
|
}
|
}
|
record.setWaitFamilyNamesWarn(familyNameWarn ? 1 : 0);
|
record.setWaitFamilyNamesNoWarn(familyNoWarn ? 1 : 0);
|
}
|
}
|
//应安置面积警告标注
|
boolean warn = true;
|
BigDecimal waitFamilyArea = record.getWaitFamilyArea();
|
// Integer currentCollectiveNum = record.getCurrentCollectiveNum();
|
// Integer currentNoCollectiveNum = record.getCurrentNoCollectiveNum();
|
//查询申请表 面积
|
PlacementApplyRecord placementApplyRecord = placementApplyRecordService.getRecordsByCardId(record.getIdCard());
|
if (ObjUtil.isEmpty(placementApplyRecord)) {
|
warn = false;
|
}else {
|
warn = compensateService.compensateSettleAreaCalculate(placementApplyRecord.getOrgArea(), placementApplyRecord.getNoOrgArea(), waitFamilyArea);
|
}
|
record.setWaitFamilyAreaWarn(warn ? 0 : 1);
|
|
//赔偿金额(判断新购房还是二手房,这两个只能存在一个)
|
if (record.getCompensationNewAmount().compareTo(BigDecimal.ZERO) == 0 &&
|
record.getCompensationOldAmount().compareTo(BigDecimal.ZERO) == 0) {
|
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();
|
//自主购房补贴、过渡补贴(如果购房情况异常则不判定自主购房补贴是否异常,自主购房补贴、过渡补贴 依赖赔偿金额信息)
|
if (record.getCompensationAmountWarn() == 0) {
|
boolean warnFlag = compensateService.compensateBuyCalculateV2(record.getDemolitionTime(),
|
record.getStreet(),
|
orgArea, noOrgArea,
|
record.getCompensationNewAmount(), record.getCompensationOldAmount(),
|
record.getCompensationSum());
|
record.setCompensationSumWarn(warnFlag ? 0 : 1);
|
|
//过渡补贴
|
if (compensateService.compensateSubsidyCalculate(record.getCurrentCount(), record.getSubsidyAmount())) {
|
record.setSubsidyAmountWarn(0);
|
}else{
|
record.setSubsidyAmountWarn(1);
|
}
|
}
|
|
//每季度支付款项
|
BigDecimal pay = record.getCompensationSum().multiply(new BigDecimal("0.25"));
|
BigDecimal quarterPayAmount = (record.getCompensationSum().subtract(pay)).divide(new BigDecimal("20"), 10, RoundingMode.DOWN);
|
if (quarterPayAmount.compareTo(record.getQuarterPayAmount()) != 0) {
|
record.setQuarterPayAmountWarn(1);
|
}else{
|
record.setQuarterPayAmountWarn(0);
|
}
|
//首付款警告
|
boolean downPaymentAmountWarn = true;
|
BigDecimal cateAmount = record.getCompensationSum().multiply(new BigDecimal("0.25"));
|
if(cateAmount.compareTo(record.getDownPaymentAmount()) == 0){
|
downPaymentAmountWarn = false;
|
}
|
record.setDownPaymentAmountWarn(downPaymentAmountWarn ? 1 : 0);
|
//房源
|
BigDecimal area;
|
if(record.getOldHousingArea().compareTo(BigDecimal.ZERO) > 0){
|
area = record.getOldHousingArea();
|
}else if(record.getBuildHousingArea().compareTo(BigDecimal.ZERO) > 0){
|
area = record.getBuildHousingArea();
|
}else{
|
area = record.getNewHousingArea();
|
}
|
if(compensateService.houseCalculate(record.getCurrentCount(),area)){
|
record.setAreaWarn(1);
|
}else{
|
record.setAreaWarn(0);
|
}
|
}
|
placementBatchHouseholdService.updateBatchById(householdsRecords);
|
}
|
}
|
|
public Integer selectNameExists(String name) {
|
//排除驳回的数据
|
LambdaQueryWrapper<PlacementBatch> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.ne(PlacementBatch::getStatus,2);
|
List<PlacementBatch> batches = this.list(queryWrapper);
|
if (ObjUtil.isEmpty(batches)) {
|
return 0;
|
}
|
List<Long> batchIds = batches.stream().map(PlacementBatch::getId).collect(Collectors.toList());
|
LambdaQueryWrapper<PlacementBatchHousehold> childQueryWrapper = new LambdaQueryWrapper<>();
|
childQueryWrapper.in(PlacementBatchHousehold::getPlacementBatchId,batchIds);
|
childQueryWrapper.and(query->query.like(PlacementBatchHousehold::getWaitFamilyNames,name));
|
return NumberUtil.parseInt(String.valueOf(placementBatchHouseholdService.count(childQueryWrapper)));
|
}
|
|
@Override
|
public void assetEdit(PlacementBatchAsset request) {
|
PlacementBatch placementBatch = this.getById(request.getPlacementBatchId());
|
if (ObjUtil.isEmpty(placementBatch)) {
|
throw new GlobalException("安置批次不存在!");
|
}
|
placementBatchAssetService.updateById(request);
|
//调整汇总信息
|
sumPlacementBatch(placementBatch);
|
dataTag(placementBatch);
|
}
|
|
@Override
|
public void householdEdit(PlacementBatchHousehold request) {
|
PlacementBatch placementBatch = this.getById(request.getPlacementBatchId());
|
if (ObjUtil.isEmpty(placementBatch)) {
|
throw new GlobalException("安置批次不存在!");
|
}
|
placementBatchHouseholdService.updateById(request);
|
//调整汇总信息
|
sumPlacementBatch(placementBatch);
|
dataTag(placementBatch);
|
}
|
|
@Override
|
public void assetDel(IdRequest request) {
|
PlacementBatchAsset placementBatchAsset = placementBatchAssetService.getById(request.getId());
|
if (ObjUtil.isEmpty(placementBatchAsset)) {
|
throw new GlobalException("记录不存在!");
|
}
|
PlacementBatch placementBatch = this.getById(placementBatchAsset.getPlacementBatchId());
|
if (ObjUtil.isEmpty(placementBatch)) {
|
throw new GlobalException("安置批次不存在!");
|
}
|
placementBatchAssetService.removeById(request.getId());
|
//调整汇总信息
|
sumPlacementBatch(placementBatch);
|
}
|
|
@Override
|
public void householdDel(IdRequest request) {
|
PlacementBatchHousehold placementBatchHousehold = placementBatchHouseholdService.getById(request.getId());
|
if(ObjUtil.isEmpty(placementBatchHousehold)){
|
throw new GlobalException("记录不存在!");
|
}
|
PlacementBatch placementBatch = this.getById(placementBatchHousehold.getPlacementBatchId());
|
if (ObjUtil.isEmpty(placementBatch)) {
|
throw new GlobalException("安置批次不存在!");
|
}
|
placementBatchHouseholdService.removeById(request.getId());
|
//调整汇总信息
|
sumPlacementBatch(placementBatch);
|
}
|
|
@Override
|
public void householdAdd(PlacementBatchHousehold request) {
|
PlacementBatch placementBatch = this.getById(request.getPlacementBatchId());
|
if (ObjUtil.isEmpty(placementBatch)) {
|
throw new GlobalException("安置批次不存在!");
|
}
|
placementBatchHouseholdService.save(request);
|
//调整汇总信息
|
sumPlacementBatch(placementBatch);
|
}
|
|
@Override
|
public void assetAdd(PlacementBatchAsset request) {
|
PlacementBatch placementBatch = this.getById(request.getPlacementBatchId());
|
if (ObjUtil.isEmpty(placementBatch)) {
|
throw new GlobalException("安置批次不存在!");
|
}
|
placementBatchAssetService.save(request);
|
//调整汇总信息
|
sumPlacementBatch(placementBatch);
|
}
|
|
@Override
|
public PlacementBatchAsset assetDetail(IdRequest request) {
|
return placementBatchAssetService.getById(request.getId());
|
}
|
|
@Override
|
public PlacementBatchHousehold householdDetail(IdRequest request) {
|
return placementBatchHouseholdService.getById(request.getId());
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
@Override
|
public void approve(ApproveRequest request) {
|
PlacementBatch placementBatch = this.getById(request.getId());
|
if (ObjUtil.isEmpty(placementBatch)) {
|
throw new GlobalException("安置批次不存在!");
|
}
|
if (placementBatch.getStatus() != 0) {
|
throw new GlobalException("已经审核过了");
|
}
|
placementBatch.setStatus(request.getStatus());
|
placementBatch.setReason(request.getReason());
|
placementBatch.setApproveTime(new Date());
|
placementBatch.setApproveId(SecurityUtils.getUserId());
|
placementBatch.setApproveName(SecurityUtils.getLoginUser().getUser().getNickName());
|
updateById(placementBatch);
|
//记录审核周期
|
buildCycleTime(placementBatch.getId());
|
|
//审核通过,修改待安置库状态
|
if(request.getStatus() == 1) {
|
LambdaQueryWrapper<PlacementBatchHousehold> placementApplyRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
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);
|
|
LambdaUpdateWrapper<Placement> placementHouseHeadUpdateWrapper = new LambdaUpdateWrapper<>();
|
placementHouseHeadUpdateWrapper.set(Placement::getStatus, 1);
|
placementHouseHeadUpdateWrapper.and(query -> query.in(Placement::getHouseholdHead, houseHead));
|
placementService.update(placementHouseHeadUpdateWrapper);
|
}
|
}
|
|
//同步待处理消息
|
new Thread(() -> {
|
syncApplyMessage();
|
}).start();
|
}
|
|
/**
|
* 生成付款周期
|
* @param placementBatchId
|
*/
|
private void buildCycleTime(Long placementBatchId){
|
List<PlacementBatchHousehold> records = placementBatchHouseholdService.allList(placementBatchId);
|
if (ObjUtil.isEmpty(records)) {
|
return;
|
}
|
for(PlacementBatchHousehold placementBatchHousehold : records){
|
if(ObjUtil.isEmpty(placementBatchHousehold.getCompensationPayTime())){
|
continue;
|
}
|
String cycleTimes = PaymentCycleHelper.getQuarterlyPaymentCycles(placementBatchHousehold.getCompensationPayTime());
|
placementBatchHousehold.setCycle(cycleTimes);
|
}
|
placementBatchHouseholdService.updateBatchById(records);
|
}
|
|
@Override
|
public void problemExport(ProblemExportRequest request, HttpServletResponse response) {
|
try {
|
PlacementBatch placementBatch = getById(request.getPlacementBatchId());
|
//查询安置表是否存在
|
if (ObjUtil.isEmpty(placementBatch)) {
|
throw new GlobalException("安置批次信息不存在");
|
}
|
FileUtils.setExcelResponseHeader(response, "问题数据.xlsx");
|
//资金表
|
if (request.getType() == 1) {
|
ExcelWriterBuilder write = EasyExcelFactory.write(response.getOutputStream(), AssetExportResponse.class);
|
List<PlacementBatchAsset> assets = placementBatchAssetService.problemList(request);
|
List<AssetExportResponse> data = BeanUtil.copyToList(assets, AssetExportResponse.class);
|
write.sheet("sheet").doWrite(data);
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
} else {
|
ExcelWriterBuilder write = EasyExcelFactory.write(response.getOutputStream(), HouseholdExportResponse.class);
|
//购房表
|
List<PlacementBatchHousehold> households = placementBatchHouseholdService.problemList(request);
|
List<HouseholdExportResponse> data = BeanUtil.copyToList(households, HouseholdExportResponse.class);
|
write.sheet("sheet").doWrite(data);
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
}
|
} catch (Exception e) {
|
throw new GlobalException("导出问题数据失败");
|
}
|
}
|
|
/**
|
* 获取最近批次号
|
*
|
* @return
|
*/
|
@Override
|
public String getLastBatchNumber() {
|
LambdaQueryWrapper<PlacementBatch> wrapper = new LambdaQueryWrapper<>();
|
wrapper.orderByDesc(PlacementBatch::getId);
|
wrapper.last("limit 1");
|
PlacementBatch placementBatch = baseMapper.selectOne(wrapper);
|
if (ObjUtil.isEmpty(placementBatch)) {
|
return null;
|
}
|
return placementBatch.getBatchNumber();
|
}
|
|
@Override
|
public SelfBuyResponse getSelfBuyResponse() {
|
SelfBuyResponse selfBuyResponse = new SelfBuyResponse();
|
LambdaQueryWrapper<PlacementBatch> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.eq(PlacementBatch::getStatus,1);
|
List<PlacementBatch> batches = list(queryWrapper);
|
if (ObjUtil.isEmpty(batches)) {
|
return selfBuyResponse;
|
}
|
Integer householdCount = batches.stream().mapToInt(PlacementBatch::getHouseholdsNum).sum();
|
Integer personCount = batches.stream().mapToInt(PlacementBatch::getPersonNum).sum();
|
selfBuyResponse.setHouseholdNum(householdCount);
|
selfBuyResponse.setPersonNum(personCount);
|
return selfBuyResponse;
|
}
|
|
@Override
|
public List<StreetResponse> getStreetResponse() {
|
return placementBatchHouseholdService.getStreetResponse();
|
}
|
|
@Override
|
public List<ImportErrorResponse> getImportErrorResponse() {
|
return placementBatchHouseholdService.getImportErrorResponse();
|
}
|
|
@Override
|
public List<MapResponse> getMapResponse() {
|
return placementBatchHouseholdService.getMapResponse();
|
}
|
|
@Override
|
public List<QuarterProcessResponse> getQuarterProcessResponse(ReportRequest request) {
|
return placementBatchHouseholdService.getQuarterProcessResponse(request);
|
}
|
|
@Override
|
public List<PlacementTypeResponse> getPlacementTypeResponse() {
|
return placementBatchHouseholdService.getPlacementTypeResponse();
|
}
|
|
@Override
|
public List<MonthCompensationResponse> getMonthCompensationResponses(String month) {
|
return placementBatchHouseholdService.getMonthCompensationResponse(month);
|
}
|
|
@Override
|
public List<Map<String,Object>> getQuarterPayResponse(List<String> quarters) {
|
return placementBatchHouseholdService.getQuarterPayResponse(quarters);
|
}
|
|
|
/**
|
* 资金表导入
|
*
|
* @param assetFile
|
* @throws IOException
|
*/
|
public void importAsset(Long placementBatchId, MultipartFile assetFile) {
|
File file = FileUtils.convertToFile(assetFile);
|
List<Map<Integer, String>> maps = FileUtils.readExcelHead(file);
|
if (!Objects.equals(maps.get(0).get(0), "镇(街道)")
|
|| !Objects.equals(maps.get(0).get(1), "拆迁项目名称")
|
|| !Objects.equals(maps.get(0).get(2), "所在村(社区)")
|
|| !Objects.equals(maps.get(0).get(3), "户主姓名")
|
|| !Objects.equals(maps.get(0).get(4), "身份证号")
|
|| !Objects.equals(maps.get(0).get(5), "应安置人数(人)")
|
|| !Objects.equals(maps.get(0).get(6), "所有家庭人员应安置面积(m²)")
|
) {
|
throw new GlobalException("Excel表头格式不对");
|
}
|
List<PlacementAssetTemplateResponse> dataList;
|
try {
|
dataList = EasyExcelFactory.read(file)
|
.head(PlacementAssetTemplateResponse.class)
|
.sheet()
|
.doReadSync();
|
} catch (Exception e) {
|
throw new GlobalException("读取Excel文件失败");
|
}
|
|
if (CollectionUtils.isEmpty(dataList)) {
|
throw new GlobalException("未解析出数据");
|
}
|
|
//导入数据,直接导入库
|
List<PlacementBatchAsset> records = BeanUtil.copyToList(dataList, PlacementBatchAsset.class);
|
//校验数据(身份证必填)
|
for (PlacementBatchAsset record : records) {
|
record.setPlacementBatchId(placementBatchId);
|
if (ObjUtil.isEmpty(record.getIdCard())) {
|
throw new GlobalException(record.getHouseholdHead() + "身份证不能为空!");
|
}
|
if (ObjUtil.isEmpty(record.getProjectName())) {
|
throw new GlobalException("请输入拆迁项目名称");
|
}
|
if (ObjUtil.isEmpty(record.getStreet())) {
|
throw new GlobalException("请输入镇(街道)");
|
}
|
if (ObjUtil.isEmpty(record.getCommunity())) {
|
throw new GlobalException("请输入社区");
|
}
|
if (ObjUtil.isEmpty(record.getHouseholdHead())) {
|
throw new GlobalException("请输入户主");
|
}
|
if (ObjUtil.isEmpty(record.getResettledNum())) {
|
throw new GlobalException("请输入应安置人数");
|
}
|
if (ObjUtil.isEmpty(record.getResettledArea())) {
|
throw new GlobalException("请输入所有家庭人员应安置面积");
|
}
|
if (ObjUtil.isEmpty(record.getCompensationAmount())) {
|
throw new GlobalException("请输入补偿总价");
|
}
|
if (ObjUtil.isEmpty(record.getDownPaymentAmount())) {
|
throw new GlobalException("请输入25%首付款");
|
}
|
if (ObjUtil.isEmpty(record.getQuarterPayAmount())) {
|
throw new GlobalException("请输入每季度需支付款项");
|
}
|
if (ObjUtil.isEmpty(record.getSubsidyAmount())) {
|
throw new GlobalException("请输入过渡补贴");
|
}
|
}
|
placementBatchAssetService.saveBatch(records);
|
}
|
|
|
/**
|
* 购房表导入
|
*
|
* @param householdFile
|
* @throws IOException
|
*/
|
public void importHousehold(Long placementBatchId, MultipartFile householdFile) {
|
File file = FileUtils.convertToFile(householdFile);
|
List<Map<Integer, String>> maps = FileUtils.readExcelHead(file);
|
if (!Objects.equals(maps.get(0).get(0), "镇(街道)")
|
|| !Objects.equals(maps.get(0).get(1), "拆迁项目名称")
|
|| !Objects.equals(maps.get(0).get(2), "所在村(社区)")
|
|| !Objects.equals(maps.get(0).get(3), "拆迁时间")
|
|| !Objects.equals(maps.get(0).get(4), "户主姓名")
|
|| !Objects.equals(maps.get(0).get(5), "身份证号")
|
|| !Objects.equals(maps.get(0).get(6), "联系电话")
|
) {
|
throw new GlobalException("Excel表头格式不对");
|
}
|
List<PlacementHouseholdTemplateResponse> dataList = EasyExcelFactory.read(file)
|
.head(PlacementHouseholdTemplateResponse.class)
|
.sheet()
|
.doReadSync();
|
|
if (CollectionUtils.isEmpty(dataList)) {
|
throw new GlobalException("未解析出数据");
|
}
|
|
//导入数据,直接导入库
|
List<PlacementBatchHousehold> records = BeanUtil.copyToList(dataList, PlacementBatchHousehold.class);
|
//校验数据(身份证必填)
|
for (PlacementBatchHousehold record : records) {
|
record.setPlacementBatchId(placementBatchId);
|
if (ObjUtil.isEmpty(record.getIdCard())) {
|
throw new GlobalException(record.getHouseholdHead() + "身份证不能为空!");
|
}
|
if (ObjUtil.isEmpty(record.getStreet())) {
|
throw new GlobalException("请输入街道");
|
}
|
if (ObjUtil.isEmpty(record.getCommunity())) {
|
throw new GlobalException("请输入所在村(社区)");
|
}
|
if (ObjUtil.isEmpty(record.getProjectName())) {
|
throw new GlobalException("请输入项目名称");
|
}
|
if (ObjUtil.isEmpty(record.getDemolitionTime())) {
|
throw new GlobalException("请输入拆迁时间");
|
}
|
if (ObjUtil.isEmpty(record.getHouseholdHead())) {
|
throw new GlobalException("请输入户主名称");
|
}
|
// if (ObjUtil.isEmpty(record.getMobile())) {
|
// throw new GlobalException("请输入联系电话");
|
// }
|
if(ObjUtil.isEmpty(record.getCurrentCount())){
|
throw new GlobalException("请输入本次安置人数 - 合计");
|
}
|
if(ObjUtil.isEmpty(record.getWaitFamilyNames())){
|
throw new GlobalException("请输入待安置家庭成员");
|
}
|
if(ObjUtil.isEmpty(record.getWaitFamilyArea())){
|
throw new GlobalException("请输入待安置人员应安置面积合计");
|
}
|
// if(ObjUtil.isEmpty(record.getWaitFamilyArea())){
|
// throw new GlobalException("请输入待安置人员应安置面积合计");
|
// }
|
if(ObjUtil.isEmpty(record.getCompensationSum())){
|
throw new GlobalException("请输入补偿金额 - 合计");
|
}
|
if(ObjUtil.isEmpty(record.getDownPaymentAmount())){
|
throw new GlobalException("25%首付款");
|
}
|
if(ObjUtil.isEmpty(record.getQuarterPayAmount())){
|
throw new GlobalException("每季度需支付款项");
|
}
|
if(ObjUtil.isEmpty(record.getSubsidyAmount())){
|
throw new GlobalException("过渡补贴");
|
}
|
if(ObjUtil.isEmpty(record.getCertificateTime())){
|
throw new GlobalException("凭证发放时间");
|
}
|
if(ObjUtil.isEmpty(record.getBuyTime())){
|
throw new GlobalException("购房时间");
|
}
|
// if(ObjUtil.isEmpty(record.getDealAmount())){
|
// throw new GlobalException("成交金额");
|
// }
|
if(ObjUtil.isEmpty(record.getSignTime())){
|
throw new GlobalException("自主购房签订时间");
|
}
|
// if(ObjUtil.isEmpty(record.getSignTime())){
|
// throw new GlobalException("自主购房签订时间");
|
// }
|
// if(ObjUtil.isEmpty(record.getCompensationPayTime())){
|
// throw new GlobalException("25%补偿款及过渡补贴支付时间");
|
// }
|
}
|
placementBatchHouseholdService.saveBatch(records);
|
}
|
|
|
/**
|
* 计算汇总安置批次信息
|
*/
|
private void sumPlacementBatch(PlacementBatch placementBatch) {
|
//汇总资金表
|
LambdaQueryWrapper<PlacementBatchAsset> assetLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
assetLambdaQueryWrapper.eq(PlacementBatchAsset::getPlacementBatchId, placementBatch.getId());
|
List<PlacementBatchAsset> assets = placementBatchAssetService.list(assetLambdaQueryWrapper);
|
if (CollectionUtils.isNotEmpty(assets)) {
|
// 申请总户数
|
Integer householdsNum = Math.toIntExact(assets.stream().map(PlacementBatchAsset::getIdCard).distinct().count());
|
//申请总人数
|
Integer personNum = assets.stream().mapToInt(PlacementBatchAsset::getResettledNum).sum();
|
//25%首付款
|
BigDecimal downPaymentAmount = assets.stream().map(PlacementBatchAsset::getDownPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
//每季度需支付款项(万元)
|
BigDecimal quarterPayAmount = assets.stream().map(PlacementBatchAsset::getQuarterPayAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(new BigDecimal("20"));
|
//过渡补贴(万元)
|
BigDecimal subsidyAmount = assets.stream().map(PlacementBatchAsset::getSubsidyAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
//补偿金额(合计)
|
BigDecimal totalAmount = assets.stream().map(PlacementBatchAsset::getCompensationAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
placementBatch.setHouseholdsNum(householdsNum);
|
placementBatch.setPersonNum(personNum);
|
placementBatch.setDownPaymentAmount(downPaymentAmount);
|
placementBatch.setQuarterPayAmount(quarterPayAmount);
|
placementBatch.setSubsidyAmount(subsidyAmount);
|
placementBatch.setTotalAmount(totalAmount);
|
}
|
|
//汇总房产表
|
LambdaQueryWrapper<PlacementBatchHousehold> householdLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
householdLambdaQueryWrapper.eq(PlacementBatchHousehold::getPlacementBatchId, placementBatch.getId());
|
List<PlacementBatchHousehold> households = placementBatchHouseholdService.list(householdLambdaQueryWrapper);
|
if (CollectionUtils.isNotEmpty(households)) {
|
//汇总面积
|
//新建商品住房-面积
|
BigDecimal newHousingArea = households.stream().map(PlacementBatchHousehold::getNewHousingArea).reduce(BigDecimal.ZERO, BigDecimal::add);
|
//二手住房-面积
|
BigDecimal oldHousingArea = households.stream().map(PlacementBatchHousehold::getOldHousingArea).reduce(BigDecimal.ZERO, BigDecimal::add);
|
//新建商业住房
|
BigDecimal buildHousingArea = households.stream().map(PlacementBatchHousehold::getBuildHousingArea).reduce(BigDecimal.ZERO, BigDecimal::add);
|
//新建停车位-金额(万元)
|
Integer newStopArea = households.stream().mapToInt(PlacementBatchHousehold::getNewStopNum).sum();
|
|
placementBatch.setNewArea(newHousingArea);
|
placementBatch.setOldArea(oldHousingArea);
|
placementBatch.setBusinessArea(buildHousingArea);
|
placementBatch.setParkingArea(newStopArea);
|
}
|
//修改
|
updateById(placementBatch);
|
}
|
|
}
|