| | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.pagehelper.PageInfo; |
| | |
| | | import com.zzg.common.core.domain.entity.state.StateProjectCompensateStandard; |
| | | import com.zzg.common.core.domain.entity.state.StateProjectCompensation; |
| | | import com.zzg.common.core.domain.entity.system.SysDictData; |
| | | import com.zzg.common.enums.*; |
| | | import com.zzg.common.enums.CompensateTypeEnum; |
| | | import com.zzg.common.enums.CompensationCategoryEnum; |
| | | import com.zzg.common.enums.DeleteFlagEnum; |
| | | import com.zzg.common.enums.HouseOwnerTyeEnum; |
| | | import com.zzg.common.enums.HouseUsingTypeEnum; |
| | | import com.zzg.common.exception.GlobalException; |
| | | import com.zzg.common.utils.RoundingUtil; |
| | | import com.zzg.common.utils.StringUtils; |
| | | import com.zzg.system.convert.StateProjectConvert; |
| | | import com.zzg.system.domain.bo.*; |
| | | import com.zzg.system.domain.bo.AwardBO; |
| | | import com.zzg.system.domain.bo.CalculateCompensationBO; |
| | | import com.zzg.system.domain.bo.HomeCompensationBO; |
| | | import com.zzg.system.domain.bo.PolicyCompensationBO; |
| | | import com.zzg.system.domain.bo.PolicySubsidyBO; |
| | | import com.zzg.system.domain.bo.PolicySupplementBO; |
| | | import com.zzg.system.domain.vo.CalculateCompensationVO; |
| | | import com.zzg.system.domain.vo.OtherCompensationBO; |
| | | import com.zzg.system.domain.vo.StateHouseholdOwnerVO; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | //如果不是区间 就直接计算 |
| | | @Override |
| | | public CalculateCompensationVO calculateCompensation(CalculateCompensationBO calculateCompensationBO) { |
| | | |
| | | //获取对应房产信息 |
| | | StateHousehold household = stateHouseholdService.getById(calculateCompensationBO.getStateHouseholdId()); |
| | | if (Objects.isNull(household)) { |
| | | throw new GlobalException("未找到对应的房产"); |
| | | } |
| | | |
| | | String stateProjectId = household.getStateProjectId(); |
| | | //获取项目补偿标准信息 |
| | | StateProjectCompensation compensation = stateProjectCompensationService.getById(stateProjectId); |
| | | if (Objects.isNull(compensation)) { |
| | | throw new GlobalException("项目没有设置标准"); |
| | | } |
| | | //通过标准类型名称查询对应的标准信息 |
| | | List<String> compensationNameList = new ArrayList<>(); |
| | | compensationNameList.add(compensation.getPolicyCompensationType()); |
| | | compensationNameList.add(compensation.getPolicySubsidy()); |
| | |
| | | throw new GlobalException("未找到开启的标准"); |
| | | } |
| | | enableCompensateStandard = enableCompensateStandard.stream().filter(e -> Objects.nonNull(e.getSubType())).collect(Collectors.toList()); |
| | | Map<Integer, Map<Integer, List<StateProjectCompensateStandard>>> enableCompensateStandardMap = enableCompensateStandard.stream().collect(Collectors.groupingBy(StateProjectCompensateStandard::getCompensateType, Collectors.groupingBy(StateProjectCompensateStandard::getCategory))); |
| | | //根据类型分组后再根据子类型进行一次分组 |
| | | Map<Integer, Map<Integer, List<StateProjectCompensateStandard>>> enableCompensateStandardMap = enableCompensateStandard.stream() |
| | | .collect(Collectors.groupingBy(StateProjectCompensateStandard::getCompensateType, Collectors.groupingBy(StateProjectCompensateStandard::getCategory))); |
| | | |
| | | //征收房屋补偿费 |
| | | Double homeAmount = null; |
| | | // 从数据库查询的房产的预估价格附加信息不为空且calculateCompensationBO任意一个字段为空,则从数据库中房产的附加信息中获取 |
| | | if (org.apache.commons.lang3.StringUtils.isNotBlank(household.getAppendData()) && !areAllCompensationFieldsNotNull(calculateCompensationBO)) { |
| | | calculateCompensationBO = JSON.parseObject(household.getAppendData(), CalculateCompensationBO.class); |
| | | } |
| | |
| | | Integer houseUsingType = household.getHouseUsingType(); |
| | | |
| | | HomeCompensationBO homeCompensationBO = calculateCompensationBO.getHomeCompensationBO(); |
| | | |
| | | // 货币补偿 |
| | | if (Objects.nonNull(homeCompensationBO) && CompensationCategoryEnum.MONEY_COMPENSATION_1.getCode() == homeCompensationBO.getHomeCompensationType()) { |
| | | Map<Integer, List<StateProjectCompensateStandard>> integerListMap = enableCompensateStandardMap.get(CompensateTypeEnum.HOUSE_ACQUISITION_COMPENSATION_FEE.getCode()); |
| | | if (!CollectionUtils.isEmpty(integerListMap)) { |
| | |
| | | } |
| | | } |
| | | } |
| | | //产权置换 |
| | | } else if (Objects.nonNull(homeCompensationBO)) { |
| | | Map<Integer, List<StateProjectCompensateStandard>> integerListMap = enableCompensateStandardMap.get(CompensateTypeEnum.HOUSE_ACQUISITION_COMPENSATION_FEE.getCode()); |
| | | if (!CollectionUtils.isEmpty(integerListMap)) { |
| | | //产权置换标准 |
| | | List<StateProjectCompensateStandard> stateProjectCompensateStandards = integerListMap.get(CompensationCategoryEnum.PROPERTY_SWAP.getCode()); |
| | | if (!CollectionUtils.isEmpty(stateProjectCompensateStandards)) { |
| | | StateProjectCompensateStandard stateProjectCompensateStandard; |
| | | //根据房屋类型获取标准 |
| | | if (HouseUsingTypeEnum.PERSONAL_HOUSE.getValue().equals(houseUsingType)) { |
| | | stateProjectCompensateStandard = stateProjectCompensateStandards.stream().filter(e -> e.getSpecification().equals("住宅")).findFirst().get(); |
| | | } else { |
| | |
| | | compensationVO.getHomeCompensationBO().setTotalAmount(homeAmount); |
| | | } |
| | | //政策性补偿费 |
| | | //补偿费总金额 |
| | | Double policyAmount = 0.0; |
| | | PolicyCompensationBO policyCompensationBO = calculateCompensationBO.getPolicyCompensationBO(); |
| | | Map<Integer, List<StateProjectCompensateStandard>> integerListMap = enableCompensateStandardMap.get(CompensateTypeEnum.POLICY_COMPENSATION_FEE.getCode()); |
| | |
| | | } else { |
| | | stateProjectCompensateStandard = stateProjectCompensateStandards.stream().filter(e -> e.getSpecification().equals("非住宅")).findFirst().get(); |
| | | } |
| | | //电话移机费用 |
| | | Double telephoneRelocationAmount = 0.0; |
| | | if (!checkCompensateStandard(stateProjectCompensateStandard)) { |
| | | // Skip further calculations or set default values to avoid computation |
| | |
| | | ; |
| | | } |
| | | } |
| | | |
| | | // 有线电视迁装 |
| | | if (Objects.nonNull(policyCompensationBO.getCableTVRelocation()) && Objects.nonNull(integerListMap.get(CompensationCategoryEnum.CABLE_TV_RELOCATION.getCode()))) { |
| | | List<StateProjectCompensateStandard> stateProjectCompensateStandards = integerListMap.get(CompensationCategoryEnum.CABLE_TV_RELOCATION.getCode()); |
| | | StateProjectCompensateStandard stateProjectCompensateStandard = stateProjectCompensateStandards.stream().findFirst().get(); |
| | | // 有线电视迁装金额 |
| | | Double cableTVRelocationAmount = 0.0; |
| | | if (!checkCompensateStandard(stateProjectCompensateStandard)) { |
| | | // Skip further calculations or set default values to avoid computation |
| | |
| | | ; |
| | | } |
| | | } |
| | | // 宽带迁装 |
| | | if (Objects.nonNull(policyCompensationBO.getBroadbandRelocation()) && Objects.nonNull(integerListMap.get(CompensationCategoryEnum.BROADBAND_RELOCATION.getCode()))) { |
| | | List<StateProjectCompensateStandard> stateProjectCompensateStandards = integerListMap.get(CompensationCategoryEnum.BROADBAND_RELOCATION.getCode()); |
| | | StateProjectCompensateStandard stateProjectCompensateStandard = stateProjectCompensateStandards.stream().findFirst().get(); |
| | | // 宽带迁装金额 |
| | | Double broadbandRelocationAmount = 0.0; |
| | | if (!checkCompensateStandard(stateProjectCompensateStandard)) { |
| | | // Skip further calculations or set default values to avoid computation |
| | |
| | | ; |
| | | } |
| | | } |
| | | |
| | | // 空调移机 |
| | | if (Objects.nonNull(policyCompensationBO.getAirConditionerRelocation()) && Objects.nonNull(integerListMap.get(CompensationCategoryEnum.AIR_CONDITIONER_RELOCATION.getCode()))) { |
| | | List<StateProjectCompensateStandard> stateProjectCompensateStandards = integerListMap.get(CompensationCategoryEnum.AIR_CONDITIONER_RELOCATION.getCode()); |
| | | StateProjectCompensateStandard stateProjectCompensateStandard = stateProjectCompensateStandards.stream().findFirst().get(); |
| | | // 空调移机金额 |
| | | Double airConditionerRelocationAmount = 0.0; |
| | | if (!checkCompensateStandard(stateProjectCompensateStandard)) { |
| | | // Skip further calculations or set default values to avoid computation |
| | |
| | | ; |
| | | } |
| | | } |
| | | // 一户一表 |
| | | if (Objects.nonNull(policyCompensationBO.getIndividualMeterInstallation()) && Objects.nonNull(integerListMap.get(CompensationCategoryEnum.ONE_HOUSE_ONE_METER.getCode()))) { |
| | | List<StateProjectCompensateStandard> stateProjectCompensateStandards = integerListMap.get(CompensationCategoryEnum.ONE_HOUSE_ONE_METER.getCode()); |
| | | StateProjectCompensateStandard stateProjectCompensateStandard = stateProjectCompensateStandards.stream().findFirst().get(); |
| | | // 一户一表金额 |
| | | Double individualMeterInstallationAmount = 0.0; |
| | | if (!checkCompensateStandard(stateProjectCompensateStandard)) { |
| | | // Skip further calculations or set default values to avoid computation |
| | |
| | | ; |
| | | } |
| | | } |
| | | // 天然气初装 |
| | | if (Objects.nonNull(policyCompensationBO.getGasInitialInstallation()) && Objects.nonNull(integerListMap.get(CompensationCategoryEnum.GAS_INITIAL_INSTALLATION.getCode()))) { |
| | | List<StateProjectCompensateStandard> stateProjectCompensateStandards = integerListMap.get(CompensationCategoryEnum.GAS_INITIAL_INSTALLATION.getCode()); |
| | | StateProjectCompensateStandard stateProjectCompensateStandard = stateProjectCompensateStandards.stream().findFirst().get(); |
| | |
| | | } |
| | | compensationVO.getPolicyCompensationBO().calculateTotalAmount(); |
| | | //政策性补助费 |
| | | // 住宅临时安置补助费 |
| | | Double policySubsidyAmount = null; |
| | | //非住宅停产,停业经济损失补偿费 |
| | | Double nonResidentialEconomicLossAllowanceAmount = null; |
| | | // 搬家补助费 |
| | | Double movingAllowanceAmount = null; |
| | | PolicySubsidyBO policySubsidyBO = calculateCompensationBO.getPolicySubsidyBO(); |
| | | //货币补偿 |
| | | if (Objects.nonNull(policySubsidyBO) && CompensationCategoryEnum.MONEY_COMPENSATION_1.getCode() == policySubsidyBO.getCompensationType()) { |
| | | Map<Integer, List<StateProjectCompensateStandard>> policySubsidyMap = enableCompensateStandardMap.get(CompensateTypeEnum.POLICY_SUBSIDY_FEE.getCode()); |
| | | if (!CollectionUtils.isEmpty(policySubsidyMap)) { |
| | | // 住宅临时安置补助费 |
| | | List<StateProjectCompensateStandard> stateProjectCompensateStandards = policySubsidyMap.get(CompensationCategoryEnum.TEMPORARY_HOUSING_ALLOWANCE.getCode()); |
| | | if (!CollectionUtils.isEmpty(stateProjectCompensateStandards)) { |
| | | StateProjectCompensateStandard stateProjectCompensateStandard = stateProjectCompensateStandards.stream().findFirst().get(); |
| | |
| | | } |
| | | } |
| | | } |
| | | // 非住宅停产、停业经济损失补助费 |
| | | List<StateProjectCompensateStandard> nonResidentialEconomicLossAllowance = policySubsidyMap.get(CompensationCategoryEnum.NON_RESIDENTIAL_ECONOMIC_LOSS_ALLOWANCE.getCode()); |
| | | if (!CollectionUtils.isEmpty(nonResidentialEconomicLossAllowance)) { |
| | | StateProjectCompensateStandard stateProjectCompensateStandard = nonResidentialEconomicLossAllowance.stream().findFirst().get(); |
| | |
| | | } |
| | | } |
| | | } |
| | | // 搬家补助费 |
| | | List<StateProjectCompensateStandard> movingAllowance = policySubsidyMap.get(CompensationCategoryEnum.MOVING_ALLOWANCE.getCode()); |
| | | if (!CollectionUtils.isEmpty(movingAllowance)) { |
| | | StateProjectCompensateStandard stateProjectCompensateStandard = movingAllowance.stream().findFirst().get(); |
| | |
| | | } |
| | | } |
| | | } |
| | | } else if (Objects.nonNull(policySubsidyBO)) { |
| | | } else if (Objects.nonNull(policySubsidyBO)) { //产权置换 |
| | | Map<Integer, List<StateProjectCompensateStandard>> policySubsidyMap = enableCompensateStandardMap.get(CompensateTypeEnum.POLICY_SUBSIDY_FEE.getCode()); |
| | | if (!CollectionUtils.isEmpty(policySubsidyMap)) { |
| | | // 住宅临时安置补助费 |
| | | List<StateProjectCompensateStandard> stateProjectCompensateStandards = policySubsidyMap.get(CompensationCategoryEnum.TEMPORARY_HOUSING_ALLOWANCE.getCode()); |
| | | if (!CollectionUtils.isEmpty(stateProjectCompensateStandards)) { |
| | | StateProjectCompensateStandard stateProjectCompensateStandard = stateProjectCompensateStandards.stream().findFirst().get(); |
| | |
| | | } |
| | | } |
| | | } |
| | | // 非住宅停产、停业经济损失补助费 |
| | | List<StateProjectCompensateStandard> nonResidentialEconomicLossAllowance = policySubsidyMap.get(CompensationCategoryEnum.NON_RESIDENTIAL_ECONOMIC_LOSS_ALLOWANCE.getCode()); |
| | | if (!CollectionUtils.isEmpty(nonResidentialEconomicLossAllowance)) { |
| | | StateProjectCompensateStandard stateProjectCompensateStandard = nonResidentialEconomicLossAllowance.stream().findFirst().get(); |
| | |
| | | } |
| | | } |
| | | } |
| | | // 搬家补助费 |
| | | List<StateProjectCompensateStandard> movingAllowance = policySubsidyMap.get(CompensationCategoryEnum.MOVING_ALLOWANCE.getCode()); |
| | | if (!CollectionUtils.isEmpty(movingAllowance)) { |
| | | StateProjectCompensateStandard stateProjectCompensateStandard = movingAllowance.stream().findFirst().get(); |
| | |
| | | } |
| | | |
| | | //政策性补贴 |
| | | //购房补贴 |
| | | Double propertyManagementSubsidyAmount = null; |
| | | //物管费补贴 |
| | | Double housingSubsidyAmount = null; |
| | | PolicySupplementBO policySupplementBO = calculateCompensationBO.getPolicySupplementBO(); |
| | | if (Objects.isNull(calculateCompensationBO.getPolicySupplementBO())) { |
| | |
| | | } |
| | | Map<Integer, List<StateProjectCompensateStandard>> policyAllowanceMap = enableCompensateStandardMap.get(CompensateTypeEnum.POLICY_ALLOWANCE.getCode()); |
| | | if (!CollectionUtils.isEmpty(policyAllowanceMap)) { |
| | | // 物管费补贴 |
| | | if (Objects.nonNull(policyAllowanceMap.get(CompensationCategoryEnum.PROPERTY_MANAGEMENT_SUBSIDY.getCode()))) { |
| | | List<StateProjectCompensateStandard> stateProjectCompensateStandards = policyAllowanceMap.get(CompensationCategoryEnum.PROPERTY_MANAGEMENT_SUBSIDY.getCode()); |
| | | StateProjectCompensateStandard stateProjectCompensateStandard; |
| | |
| | | compensationVO.getPolicySupplementBO().setPropertyManagementSubsidy(propertyManagementSubsidyAmount); |
| | | } |
| | | } |
| | | // 购房补贴 |
| | | if (Objects.nonNull(policyAllowanceMap.get(CompensationCategoryEnum.HOUSE_PURCHASE_SUBSIDY.getCode()))) { |
| | | List<StateProjectCompensateStandard> stateProjectCompensateStandards = policyAllowanceMap.get(CompensationCategoryEnum.HOUSE_PURCHASE_SUBSIDY.getCode()); |
| | | StateProjectCompensateStandard stateProjectCompensateStandard; |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | // 提前搬迁奖励 |
| | | Double earlyRelocationRewardAmount = null; |
| | | AwardBO awardBO = compensationVO.getAwardBO(); |
| | | Map<Integer, List<StateProjectCompensateStandard>> earlyRelocationRewardMap = enableCompensateStandardMap.get(CompensateTypeEnum.EARLY_RELOCATION_REWARD.getCode()); |
| | |
| | | } |
| | | jsonObject.put("personalOwnerNum", personalOwnerNum); |
| | | return jsonObject; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, String> appendOwnerName(List<String> houseIds) { |
| | | Map<String, String> stringMap = new HashMap<>(); |
| | | |
| | | LambdaQueryWrapper<StateHouseholdOwner> stateHouseholdOwnerLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | stateHouseholdOwnerLambdaQueryWrapper.in(StateHouseholdOwner::getStateHouseholdId, houseIds.stream() |
| | | .distinct().collect(Collectors.toList())); |
| | | List<StateHouseholdOwner> stateHouseholdOwners = this.list(stateHouseholdOwnerLambdaQueryWrapper); |
| | | if (CollectionUtils.isEmpty(stateHouseholdOwners)) { |
| | | return stringMap; |
| | | } |
| | | Map<String, List<StateHouseholdOwner>> listMap = stateHouseholdOwners.stream() |
| | | .collect(Collectors.groupingBy(StateHouseholdOwner::getStateHouseholdId)); |
| | | |
| | | for (String houseId : houseIds) { |
| | | String fullName = getFullName(listMap.get(houseId)); |
| | | stringMap.put(houseId, fullName); |
| | | } |
| | | return stringMap; |
| | | } |
| | | |
| | | @Override |