|
|
|
@@ -1128,198 +1128,15 @@ public class WxEnergyServiceImpl implements WxEnergyService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Map<Long,String> getFloorBuildingMoney(WxEnergyMeterReading reading,boolean isFloor) { |
|
|
|
// List<Map> list = null; |
|
|
|
// if (isFloor) { |
|
|
|
// list = wxEnergyMeterReadingMapper.findFloorSumMoney(reading); |
|
|
|
// }else { |
|
|
|
// wxEnergyMeterReadingMapper.findBuildingSumMoney(reading); |
|
|
|
// } |
|
|
|
// |
|
|
|
// if (null != list && list.size() > 0 ) { |
|
|
|
// Map<Long, String> buildinMap = new HashMap<Long, String>(); |
|
|
|
// for (int i = 0 ; i < list.size() ; i++) { |
|
|
|
// Map bup = list.get(i); |
|
|
|
// BigDecimal are = (BigDecimal)bup.get("money"); |
|
|
|
// if (null != are) { |
|
|
|
// buildinMap.put((Long)bup.get("building_id"), are.toPlainString()); |
|
|
|
// }else { |
|
|
|
// buildinMap.put((Long)bup.get("building_id"), "0"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// } |
|
|
|
// return buildinMap; |
|
|
|
// } |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Integer calcuteReading(WxEnergyReadingCalcute record, MallUserInfo user) { |
|
|
|
// //根据科目,区间,计算生成账单。 |
|
|
|
// WxEnergyMeterReading reading = new WxEnergyMeterReading(); |
|
|
|
// reading.updateTenantInfo(record); |
|
|
|
// reading.setTimeId(record.getTimeId()); |
|
|
|
// reading.setIsDel(EnumYesOrNo.NO.getCode()); |
|
|
|
// reading.setIsPublic(EnumYesOrNo.NO.getCode()); |
|
|
|
// |
|
|
|
// WxEnergyFees fq = new WxEnergyFees(); |
|
|
|
// fq.updateTenantInfo(record); |
|
|
|
// fq.setIsDel(EnumYesOrNo.NO.getCode()); |
|
|
|
// fq.setId(record.getFeesId()); |
|
|
|
// WxEnergyFees fees = this.getFeesById(fq); |
|
|
|
// if (null == fees) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"科目未查询到。"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// WxEnergyFeesTime tq = new WxEnergyFeesTime(); |
|
|
|
// tq.updateTenantInfo(record); |
|
|
|
// tq.setId(record.getTimeId()); |
|
|
|
// WxEnergyFeesTime time = this.getFeesTimeById(tq); |
|
|
|
// if (null == time) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"区间未查询到。"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// if (fees.getType().intValue() != time.getType().intValue()) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"科目和区间的表类型不匹配。"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// reading.setMeterType(time.getType()); |
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
// //用户表列表 |
|
|
|
// List<WxEnergyMeterReading> readingList = wxEnergyMeterReadingMapper.findList(reading); |
|
|
|
// if (null != readingList && readingList.size() > 0 ) { |
|
|
|
// |
|
|
|
// WxShop sq = new WxShop(); |
|
|
|
// sq.updateTenantInfo(record); |
|
|
|
// Map<Long, WxMerchant> shopMerchantMap = wxMerchantService.getShopMerchantMap(sq); |
|
|
|
// Map<Long, WxShop> shopMap = wxShopService.findShopMap(sq); |
|
|
|
// |
|
|
|
// WxEnergyMeter mq = new WxEnergyMeter(); |
|
|
|
// mq.updateTenantInfo(record); |
|
|
|
// mq.setIsDel(EnumYesOrNo.NO.getCode()); |
|
|
|
// Map<Long, WxEnergyMeter> meterMap = this.getMeterMap(mq); |
|
|
|
// if (null == meterMap) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"能源表未查询到。"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// String publicTotalArea = "0"; |
|
|
|
// BigDecimal publicTotalMoney = new BigDecimal(0); |
|
|
|
// BigDecimal b0 = new BigDecimal(0); |
|
|
|
// Map<Long,String> buildingFloorMoney = null; |
|
|
|
// Map<Long,String> buildingFloorArea = null; |
|
|
|
// if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.ALL.getCode().intValue()) { |
|
|
|
// //全部就查询所有公共表的费用 |
|
|
|
// reading.setIsPublic(EnumYesOrNo.YES.getCode()); |
|
|
|
// String publicMoney = wxEnergyMeterReadingMapper.findAllSumMoney(reading); |
|
|
|
// if (StringUtils.isNotBlank(publicMoney)) { |
|
|
|
// publicTotalMoney = new BigDecimal(publicMoney); |
|
|
|
// } |
|
|
|
// //公摊总面积 |
|
|
|
// WxMallFloor mf = new WxMallFloor(); |
|
|
|
// mf.updateTenantInfo(record); |
|
|
|
// publicTotalArea = wxMallFloorService.getAllPublicAreaSum(mf); |
|
|
|
// if (StringUtils.isBlank(publicTotalArea)) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置。"); |
|
|
|
// } |
|
|
|
// BigDecimal areaDecimal = new BigDecimal(publicTotalArea); |
|
|
|
// if (areaDecimal.compareTo(new BigDecimal(0)) <= 0 ) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置。"); |
|
|
|
// } |
|
|
|
// }else if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.BUILDING.getCode().intValue()) { |
|
|
|
// //如果是按楼栋计算,则要把每个楼栋的金额都要算出来 |
|
|
|
// reading.setIsPublic(EnumYesOrNo.YES.getCode()); |
|
|
|
// buildingFloorMoney = getFloorBuildingMoney(reading,false); |
|
|
|
// //各楼座总面积 |
|
|
|
// WxMallFloor mf = new WxMallFloor(); |
|
|
|
// mf.updateTenantInfo(record); |
|
|
|
// buildingFloorArea = wxMallFloorService.getBuildingPublicAreaSum(mf); |
|
|
|
// if (null == buildingFloorArea) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置。"); |
|
|
|
// } |
|
|
|
// }else if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.FLOOR.getCode().intValue()) { |
|
|
|
// //查询各楼层的费用 |
|
|
|
// reading.setIsPublic(EnumYesOrNo.YES.getCode()); |
|
|
|
// buildingFloorMoney = getFloorBuildingMoney(reading,true); |
|
|
|
// //各楼层面积 |
|
|
|
// //各楼座总面积 |
|
|
|
// WxMallFloor mf = new WxMallFloor(); |
|
|
|
// mf.updateTenantInfo(record); |
|
|
|
// buildingFloorArea = wxMallFloorService.getFloorPublicAreaSum(mf); |
|
|
|
// if (null == buildingFloorArea) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置。"); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// List<WxAllBill> billList = new ArrayList<WxAllBill>(); |
|
|
|
// for (int i = 0 ; i< readingList.size() ; i ++) { |
|
|
|
// WxEnergyMeterReading mr = readingList.get(i); |
|
|
|
// //用户表账单 |
|
|
|
// WxMerchant merchant = shopMerchantMap.get(mr.getShopId()); |
|
|
|
// if (null == merchant) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"铺位["+mr.getShopNumber()+"]未找到出租商户"); |
|
|
|
// } |
|
|
|
// WxEnergyMeter meter = meterMap.get(mr.getMeterId()); |
|
|
|
// if (null == meter) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"表["+mr.getMeterName()+"]不存在"); |
|
|
|
// } |
|
|
|
// WxShop shop = shopMap.get(mr.getShopId()); |
|
|
|
// WxAllBill userBill = mr.generateUserBill(record, merchant, user, meter); |
|
|
|
// userBill.setEnergyFeesId(fees.getId()); |
|
|
|
// if (null != userBill) { |
|
|
|
// billList.add(userBill); |
|
|
|
// } |
|
|
|
// /* |
|
|
|
// * 总表(分摊账单) |
|
|
|
// * 如果科目是根据总面积公摊,则根据总面积计算 |
|
|
|
// * 如果科目是根据楼栋公摊,则根据当前记录的楼栋面积计算 |
|
|
|
// * 如果科目是根据楼层公摊,则根据当前记录的楼层面积计算 |
|
|
|
// */ |
|
|
|
// WxAllBill publicBill = null; |
|
|
|
// if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.ALL.getCode().intValue()) { |
|
|
|
// if (publicTotalMoney.compareTo(b0) > 0 ) { |
|
|
|
// String needPay = publicTotalMoney.multiply(new BigDecimal(shop.getRentArea())).divide(new BigDecimal(publicTotalArea)).setScale(2,RoundingMode.HALF_UP).toPlainString(); |
|
|
|
// publicBill = mr.generatePublicBill(record, merchant, user, needPay); |
|
|
|
// } |
|
|
|
// }else if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.BUILDING.getCode().intValue()) { |
|
|
|
// String buildingArea = buildingFloorArea.get(mr.getBuildingId()); |
|
|
|
// if (StringUtils.isBlank(buildingArea) || new BigDecimal(buildingArea).compareTo(new BigDecimal(0)) <= 0 ) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置完全。"); |
|
|
|
// } |
|
|
|
// BigDecimal buildingMoney = new BigDecimal(0); |
|
|
|
// if (null != buildingFloorMoney ) { |
|
|
|
// String bMoney = buildingFloorMoney.get(mr.getBuildingId()); |
|
|
|
// if (StringUtils.isNotBlank(bMoney)) { |
|
|
|
// buildingMoney = new BigDecimal(bMoney); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// if (buildingMoney.compareTo(b0) > 0 ) { |
|
|
|
// String needPay = buildingMoney.multiply(new BigDecimal(shop.getRentArea())).divide(new BigDecimal(buildingArea)).setScale(2,RoundingMode.HALF_UP).toPlainString(); |
|
|
|
// publicBill = mr.generatePublicBill(record, merchant, user, needPay); |
|
|
|
// } |
|
|
|
// }else if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.FLOOR.getCode().intValue()) { |
|
|
|
// String floorArea = buildingFloorArea.get(mr.getFloorId()); |
|
|
|
// if (StringUtils.isBlank(floorArea) || new BigDecimal(floorArea).compareTo(new BigDecimal(0)) <= 0 ) { |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置完全。"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// BigDecimal floorMoney = new BigDecimal(0); |
|
|
|
// if (null != buildingFloorMoney ) { |
|
|
|
// String fMoney = buildingFloorMoney.get(mr.getFloorId()); |
|
|
|
// if (StringUtils.isNotBlank(fMoney)) { |
|
|
|
// floorMoney = new BigDecimal(fMoney); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// if (floorMoney.compareTo(b0) > 0 ) { |
|
|
|
// String needPay = floorMoney.multiply(new BigDecimal(shop.getRentArea())).divide(new BigDecimal(floorArea)).setScale(2,RoundingMode.HALF_UP).toPlainString(); |
|
|
|
// publicBill = mr.generatePublicBill(record, merchant, user, needPay); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// if (null != publicBill) { |
|
|
|
// publicBill.setEnergyFeesId(fees.getId()); |
|
|
|
// billList.add(publicBill); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// boolean allSuccess = true; |
|
|
|
// if (billList.size() > 0 ) { |
|
|
|
// try { |
|
|
|
|