|
|
@@ -4,25 +4,28 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.converters.longconverter.LongStringConverter;
|
|
|
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.yc.ship.framework.common.pojo.PageResult;
|
|
|
import com.yc.ship.framework.excel.core.util.ExcelUtils;
|
|
|
+import com.yc.ship.framework.tenant.core.aop.TenantIgnore;
|
|
|
import com.yc.ship.module.resource.helper.DateHelper;
|
|
|
import com.yc.ship.module.resource.helper.MathHelper;
|
|
|
import com.yc.ship.module.product.dal.dataobject.voyage.VoyageDO;
|
|
|
import com.yc.ship.module.product.dal.mysql.voyage.VoyageMapper;
|
|
|
-import com.yc.ship.module.trade.controller.admin.report.vo.CruiseOpsDailyReqVO;
|
|
|
-import com.yc.ship.module.trade.controller.admin.report.vo.CruiseOpsDailyRespVO;
|
|
|
-import com.yc.ship.module.trade.controller.admin.report.vo.YangtzePassengerSummaryPageReqVO;
|
|
|
-import com.yc.ship.module.trade.controller.admin.report.vo.YangtzePassengerSummaryRemarkReqVO;
|
|
|
-import com.yc.ship.module.trade.controller.admin.report.vo.YangtzePassengerSummaryRespVO;
|
|
|
+import com.yc.ship.module.trade.controller.admin.report.vo.*;
|
|
|
+import com.yc.ship.module.trade.dal.dataobject.consumption.ConsumptionIncomeDailyDO;
|
|
|
+import com.yc.ship.module.trade.dal.dataobject.consumption.ConsumptionIncomeVoyageDO;
|
|
|
+import com.yc.ship.module.trade.dal.mysql.consumption.ConsumptionIncomeDailyMapper;
|
|
|
+import com.yc.ship.module.trade.dal.mysql.consumption.ConsumptionIncomeVoyageMapper;
|
|
|
import com.yc.ship.module.trade.dal.mysql.report.OpsDailyMapper;
|
|
|
import com.yc.ship.module.trade.dal.mysql.report.YangtzePassengerSummaryMapper;
|
|
|
import com.yc.ship.module.trade.service.report.OpsDailyService;
|
|
|
import com.yc.ship.module.trade.utils.excel.CruiseOpsDailyExportStyleHandler;
|
|
|
import com.yc.ship.module.trade.utils.excel.YangtzePassengerSummaryExportStyleHandler;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
@@ -49,6 +52,11 @@ public class OpsDailyServiceImpl implements OpsDailyService {
|
|
|
|
|
|
@Resource
|
|
|
private OpsDailyMapper cruiseOpsDailyMapper;
|
|
|
+ @Resource
|
|
|
+ private ConsumptionIncomeVoyageMapper consumptionIncomeVoyageMapper;
|
|
|
+ @Resource
|
|
|
+ private ConsumptionIncomeDailyMapper consumptionIncomeDailyMapper;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<CruiseOpsDailyRespVO> getCruiseOpsDailyList(CruiseOpsDailyReqVO reqVO) {
|
|
|
@@ -818,5 +826,834 @@ public class OpsDailyServiceImpl implements OpsDailyService {
|
|
|
voyageMapper.updateById(updateDO);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @TenantIgnore
|
|
|
+ public List<ConsumptionIncomeVoyageRespVO> getConsumptionIncomeVoyageList(ConsumptionIncomeVoyageReqVO reqVO) {
|
|
|
+ log.info("查询省际度假游轮二消情况航次表任务开始时间{}", LocalDateTime.now());
|
|
|
+
|
|
|
+ List<ConsumptionIncomeVoyageDO> doList = consumptionIncomeVoyageMapper.selectList(reqVO);
|
|
|
+ log.info("查询省际度假游轮二消情况航次表任务结束时间{}", LocalDateTime.now());
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(doList)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ConsumptionIncomeVoyageRespVO> respList = convertToList(doList);
|
|
|
+
|
|
|
+ return buildReportWithSubtotalAndCumulative(respList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ConsumptionIncomeVoyageRespVO> convertToList(List<ConsumptionIncomeVoyageDO> doList) {
|
|
|
+ List<ConsumptionIncomeVoyageRespVO> respList = new ArrayList<>();
|
|
|
+ int index = 1;
|
|
|
+ for (ConsumptionIncomeVoyageDO item : doList) {
|
|
|
+ ConsumptionIncomeVoyageRespVO respVO = new ConsumptionIncomeVoyageRespVO();
|
|
|
+ BeanUtils.copyProperties(item, respVO);
|
|
|
+ respVO.setIndex(index++);
|
|
|
+ respVO.setRoute(item.getRoute());
|
|
|
+ respList.add(respVO);
|
|
|
+ }
|
|
|
+ return respList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ConsumptionIncomeVoyageRespVO> buildReportWithSubtotalAndCumulative(
|
|
|
+ List<ConsumptionIncomeVoyageRespVO> currentDataList) {
|
|
|
+
|
|
|
+ List<ConsumptionIncomeVoyageRespVO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<String, List<ConsumptionIncomeVoyageRespVO>> currentMonthMap = currentDataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ item -> item.getStatMonth() != null ? item.getStatMonth() : "",
|
|
|
+ TreeMap::new, Collectors.toList()));
|
|
|
+
|
|
|
+ int globalIdx = 1;
|
|
|
+ List<ConsumptionIncomeVoyageRespVO> allDailyDataForCumulative = new ArrayList<>();
|
|
|
+
|
|
|
+ int monthIndex = 0;
|
|
|
+ for (Map.Entry<String, List<ConsumptionIncomeVoyageRespVO>> entry : currentMonthMap.entrySet()) {
|
|
|
+ String month = entry.getKey();
|
|
|
+ List<ConsumptionIncomeVoyageRespVO> dailyItems = entry.getValue();
|
|
|
+
|
|
|
+ for (ConsumptionIncomeVoyageRespVO item : dailyItems) {
|
|
|
+ item.setIndex(globalIdx++);
|
|
|
+ }
|
|
|
+
|
|
|
+ result.addAll(dailyItems);
|
|
|
+ allDailyDataForCumulative.addAll(dailyItems);
|
|
|
+
|
|
|
+ ConsumptionIncomeVoyageRespVO subtotalData = buildConsumptionSubtotalRow(dailyItems, month);
|
|
|
+ result.add(subtotalData);
|
|
|
+
|
|
|
+ ConsumptionIncomeVoyageRespVO lastYearSubtotal = buildConsumptionSubtotalRow(new ArrayList<>(), "");
|
|
|
+ ConsumptionIncomeVoyageRespVO subtotalYoy = buildConsumptionYoyRow(subtotalData, lastYearSubtotal);
|
|
|
+ result.add(subtotalYoy);
|
|
|
+
|
|
|
+ if (monthIndex > 0) {
|
|
|
+ ConsumptionIncomeVoyageRespVO cumData = buildConsumptionSubtotalRow(allDailyDataForCumulative, "累计");
|
|
|
+ result.add(cumData);
|
|
|
+
|
|
|
+ ConsumptionIncomeVoyageRespVO lastYearCumData = buildConsumptionSubtotalRow(new ArrayList<>(), "");
|
|
|
+ ConsumptionIncomeVoyageRespVO cumYoy = buildConsumptionYoyRow(cumData, lastYearCumData);
|
|
|
+ result.add(cumYoy);
|
|
|
+ }
|
|
|
+
|
|
|
+ monthIndex++;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private ConsumptionIncomeVoyageRespVO buildConsumptionSubtotalRow(List<ConsumptionIncomeVoyageRespVO> items, String monthLabel) {
|
|
|
+ ConsumptionIncomeVoyageRespVO row = new ConsumptionIncomeVoyageRespVO();
|
|
|
+
|
|
|
+ if ("累计".equals(monthLabel)) {
|
|
|
+ row.setVoyageName("累计");
|
|
|
+ } else if (!"累计".equals(monthLabel) && monthLabel.contains("小计")) {
|
|
|
+ row.setVoyageName(monthLabel);
|
|
|
+ } else {
|
|
|
+ row.setVoyageName(monthLabel + "小计");
|
|
|
+ }
|
|
|
+ row.setRoute("");
|
|
|
+ row.setVoyageNo("数据");
|
|
|
+ row.setIsSubtotal(!"累计".equals(row.getVoyageName()));
|
|
|
+ row.setIsCumulative("累计".equals(row.getVoyageName()));
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(items)) {
|
|
|
+ return row;
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal targetPeopleSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal frontDeskSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal restaurantSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barPrepackedSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barMixedSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barKtvSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barMahjongSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barBarbecueSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barOtherSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal culturalSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal roomSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal selfSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal otherSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal partnerPhotoSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal partnerSuperSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal partnerSpaSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal partnerClinicSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal totalIncomeSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payOnlineSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payCashSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal receivableSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payOtherSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payablePhotoSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payableSuperSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payableSpaSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payableClinicSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal partnerTotalPayableSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal changjiangSum = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ for (ConsumptionIncomeVoyageRespVO item : items) {
|
|
|
+ targetPeopleSum = targetPeopleSum.add(safeBigDecimal(item.getTargetPeople()));
|
|
|
+ frontDeskSum = frontDeskSum.add(safeBigDecimal(item.getFrontDeskIncome()));
|
|
|
+ restaurantSum = restaurantSum.add(safeBigDecimal(item.getRestaurantIncome()));
|
|
|
+ barPrepackedSum = barPrepackedSum.add(safeBigDecimal(item.getBarPrepackedWine()));
|
|
|
+ barMixedSum = barMixedSum.add(safeBigDecimal(item.getBarMixedWine()));
|
|
|
+ barKtvSum = barKtvSum.add(safeBigDecimal(item.getBarKtv()));
|
|
|
+ barMahjongSum = barMahjongSum.add(safeBigDecimal(item.getBarMahjong()));
|
|
|
+ barBarbecueSum = barBarbecueSum.add(safeBigDecimal(item.getBarBarbecue()));
|
|
|
+ barOtherSum = barOtherSum.add(safeBigDecimal(item.getBarOther()));
|
|
|
+ culturalSum = culturalSum.add(safeBigDecimal(item.getCulturalIncome()));
|
|
|
+ roomSum = roomSum.add(safeBigDecimal(item.getRoomIncome()));
|
|
|
+ selfSum = selfSum.add(safeBigDecimal(item.getSelfIncome()));
|
|
|
+ otherSum = otherSum.add(safeBigDecimal(item.getOtherIncome()));
|
|
|
+ partnerPhotoSum = partnerPhotoSum.add(safeBigDecimal(item.getPartnerPhotography()));
|
|
|
+ partnerSuperSum = partnerSuperSum.add(safeBigDecimal(item.getPartnerSupermarket()));
|
|
|
+ partnerSpaSum = partnerSpaSum.add(safeBigDecimal(item.getPartnerSpa()));
|
|
|
+ partnerClinicSum = partnerClinicSum.add(safeBigDecimal(item.getPartnerClinic()));
|
|
|
+ totalIncomeSum = totalIncomeSum.add(safeBigDecimal(item.getTotalIncome()));
|
|
|
+ payOnlineSum = payOnlineSum.add(safeBigDecimal(item.getPayOnline()));
|
|
|
+ payCashSum = payCashSum.add(safeBigDecimal(item.getPayCash()));
|
|
|
+ receivableSum = receivableSum.add(safeBigDecimal(item.getReceivable()));
|
|
|
+ payOtherSum = payOtherSum.add(safeBigDecimal(item.getPayOther()));
|
|
|
+ payablePhotoSum = payablePhotoSum.add(safeBigDecimal(item.getPayablePhotography()));
|
|
|
+ payableSuperSum = payableSuperSum.add(safeBigDecimal(item.getPayableSupermarket()));
|
|
|
+ payableSpaSum = payableSpaSum.add(safeBigDecimal(item.getPayableSpa()));
|
|
|
+ payableClinicSum = payableClinicSum.add(safeBigDecimal(item.getPayableClinic()));
|
|
|
+ partnerTotalPayableSum = partnerTotalPayableSum.add(safeBigDecimal(item.getPartnerTotalPayable()));
|
|
|
+ changjiangSum = changjiangSum.add(safeBigDecimal(item.getChangjiangIncome()));
|
|
|
+ }
|
|
|
+
|
|
|
+ row.setTargetPeople(targetPeopleSum);
|
|
|
+
|
|
|
+ if (targetPeopleSum.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ row.setAvgPerPerson(totalIncomeSum.divide(targetPeopleSum, 2, RoundingMode.HALF_UP));
|
|
|
+ } else {
|
|
|
+ row.setAvgPerPerson(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ row.setFrontDeskIncome(frontDeskSum);
|
|
|
+ row.setRestaurantIncome(restaurantSum);
|
|
|
+ row.setBarPrepackedWine(barPrepackedSum);
|
|
|
+ row.setBarMixedWine(barMixedSum);
|
|
|
+ row.setBarKtv(barKtvSum);
|
|
|
+ row.setBarMahjong(barMahjongSum);
|
|
|
+ row.setBarBarbecue(barBarbecueSum);
|
|
|
+ row.setBarOther(barOtherSum);
|
|
|
+ row.setCulturalIncome(culturalSum);
|
|
|
+ row.setRoomIncome(roomSum);
|
|
|
+ row.setSelfIncome(selfSum);
|
|
|
+ row.setOtherIncome(otherSum);
|
|
|
+ row.setPartnerPhotography(partnerPhotoSum);
|
|
|
+ row.setPartnerSupermarket(partnerSuperSum);
|
|
|
+ row.setPartnerSpa(partnerSpaSum);
|
|
|
+ row.setPartnerClinic(partnerClinicSum);
|
|
|
+ row.setTotalIncome(totalIncomeSum);
|
|
|
+ row.setPayOnline(payOnlineSum);
|
|
|
+ row.setPayCash(payCashSum);
|
|
|
+ row.setReceivable(receivableSum);
|
|
|
+ row.setPayOther(payOtherSum);
|
|
|
+ row.setPayablePhotography(payablePhotoSum);
|
|
|
+ row.setPayableSupermarket(payableSuperSum);
|
|
|
+ row.setPayableSpa(payableSpaSum);
|
|
|
+ row.setPayableClinic(payableClinicSum);
|
|
|
+ row.setPartnerTotalPayable(partnerTotalPayableSum);
|
|
|
+ row.setChangjiangIncome(changjiangSum);
|
|
|
+
|
|
|
+ return row;
|
|
|
+ }
|
|
|
+
|
|
|
+ private ConsumptionIncomeVoyageRespVO buildConsumptionYoyRow(ConsumptionIncomeVoyageRespVO currentRow, ConsumptionIncomeVoyageRespVO lastYearRow) {
|
|
|
+ ConsumptionIncomeVoyageRespVO yoyRow = new ConsumptionIncomeVoyageRespVO();
|
|
|
+ yoyRow.setIndex(null);
|
|
|
+ yoyRow.setVoyageName("");
|
|
|
+ yoyRow.setVoyageNo("同比");
|
|
|
+ yoyRow.setIsSubtotal(currentRow.getIsSubtotal() != null && currentRow.getIsSubtotal());
|
|
|
+ yoyRow.setIsCumulative(currentRow.getIsCumulative() != null && currentRow.getIsCumulative());
|
|
|
+
|
|
|
+ yoyRow.setFrontDeskIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getFrontDeskIncome()), safeBigDecimal(lastYearRow.getFrontDeskIncome())));
|
|
|
+ yoyRow.setRestaurantIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getRestaurantIncome()), safeBigDecimal(lastYearRow.getRestaurantIncome())));
|
|
|
+ yoyRow.setBarPrepackedWine(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarPrepackedWine()), safeBigDecimal(lastYearRow.getBarPrepackedWine())));
|
|
|
+ yoyRow.setBarMixedWine(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarMixedWine()), safeBigDecimal(lastYearRow.getBarMixedWine())));
|
|
|
+ yoyRow.setBarKtv(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarKtv()), safeBigDecimal(lastYearRow.getBarKtv())));
|
|
|
+ yoyRow.setBarMahjong(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarMahjong()), safeBigDecimal(lastYearRow.getBarMahjong())));
|
|
|
+ yoyRow.setBarBarbecue(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarBarbecue()), safeBigDecimal(lastYearRow.getBarBarbecue())));
|
|
|
+ yoyRow.setBarOther(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarOther()), safeBigDecimal(lastYearRow.getBarOther())));
|
|
|
+ yoyRow.setCulturalIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getCulturalIncome()), safeBigDecimal(lastYearRow.getCulturalIncome())));
|
|
|
+ yoyRow.setRoomIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getRoomIncome()), safeBigDecimal(lastYearRow.getRoomIncome())));
|
|
|
+ yoyRow.setSelfIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getSelfIncome()), safeBigDecimal(lastYearRow.getSelfIncome())));
|
|
|
+ yoyRow.setOtherIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getOtherIncome()), safeBigDecimal(lastYearRow.getOtherIncome())));
|
|
|
+ yoyRow.setPartnerPhotography(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPartnerPhotography()), safeBigDecimal(lastYearRow.getPartnerPhotography())));
|
|
|
+ yoyRow.setPartnerSupermarket(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPartnerSupermarket()), safeBigDecimal(lastYearRow.getPartnerSupermarket())));
|
|
|
+ yoyRow.setPartnerSpa(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPartnerSpa()), safeBigDecimal(lastYearRow.getPartnerSpa())));
|
|
|
+ yoyRow.setPartnerClinic(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPartnerClinic()), safeBigDecimal(lastYearRow.getPartnerClinic())));
|
|
|
+ yoyRow.setTotalIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getTotalIncome()), safeBigDecimal(lastYearRow.getTotalIncome())));
|
|
|
+ yoyRow.setPayOnline(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayOnline()), safeBigDecimal(lastYearRow.getPayOnline())));
|
|
|
+ yoyRow.setPayCash(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayCash()), safeBigDecimal(lastYearRow.getPayCash())));
|
|
|
+ yoyRow.setReceivable(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getReceivable()), safeBigDecimal(lastYearRow.getReceivable())));
|
|
|
+ yoyRow.setPayOther(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayOther()), safeBigDecimal(lastYearRow.getPayOther())));
|
|
|
+ yoyRow.setPayablePhotography(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayablePhotography()), safeBigDecimal(lastYearRow.getPayablePhotography())));
|
|
|
+ yoyRow.setPayableSupermarket(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayableSupermarket()), safeBigDecimal(lastYearRow.getPayableSupermarket())));
|
|
|
+ yoyRow.setPayableSpa(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayableSpa()), safeBigDecimal(lastYearRow.getPayableSpa())));
|
|
|
+ yoyRow.setPayableClinic(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayableClinic()), safeBigDecimal(lastYearRow.getPayableClinic())));
|
|
|
+ yoyRow.setPartnerTotalPayable(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPartnerTotalPayable()), safeBigDecimal(lastYearRow.getPartnerTotalPayable())));
|
|
|
+ yoyRow.setChangjiangIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getChangjiangIncome()), safeBigDecimal(lastYearRow.getChangjiangIncome())));
|
|
|
+
|
|
|
+ return yoyRow;
|
|
|
+ }
|
|
|
+
|
|
|
+ private BigDecimal calcYoyPercentBigDecimal(BigDecimal current, BigDecimal last) {
|
|
|
+ if (current == null || last == null || last.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ BigDecimal diff = current.subtract(last);
|
|
|
+ BigDecimal percent = diff.divide(last, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
|
|
|
+ return percent.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.debug("calcYoyPercentBigDecimal error: {},{}", current, last);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @TenantIgnore
|
|
|
+ public void exportConsumptionIncomeVoyageExcel(ConsumptionIncomeVoyageReqVO reqVO, HttpServletResponse response) throws IOException {
|
|
|
+ List<ConsumptionIncomeVoyageRespVO> dataList = getConsumptionIncomeVoyageList(reqVO);
|
|
|
+ if (CollUtil.isEmpty(dataList)) {
|
|
|
+ ExcelUtils.exportEmpty(response, "省际度假游轮二消情况航次表");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<List<String>> head = buildConsumptionIncomeVoyageHeaders();
|
|
|
+ List<List<Object>> exportData = transformConsumptionIncomeVoyageExportData(dataList);
|
|
|
+
|
|
|
+ EasyExcel.write(response.getOutputStream())
|
|
|
+ .head(head)
|
|
|
+ .autoCloseStream(false)
|
|
|
+ .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
|
|
+ .registerConverter(new LongStringConverter())
|
|
|
+ .sheet("省际度假游轮二消情况航次表")
|
|
|
+ .doWrite(exportData);
|
|
|
+
|
|
|
+ response.addHeader("Content-Disposition",
|
|
|
+ "attachment;filename=" + URLEncoder.encode("省际度假游轮二消情况航次表.xls", StandardCharsets.UTF_8.name()));
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<List<String>> buildConsumptionIncomeVoyageHeaders() {
|
|
|
+ List<List<String>> head = new ArrayList<>();
|
|
|
+
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("序号")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("航次")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("船舶")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("航线")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("航次号")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("指标人数")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("人均金额(元/人)")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("前台收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("餐厅收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","预包装酒水")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","调制酒水")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","KTV")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","麻将")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","烧烤")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","其他")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("文创收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("客房收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("自营收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("其他收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("联营商", "摄影收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("联营商", "商超收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("联营商", "SPA收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("联营商", "医务室收入")));
|
|
|
+
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("收入合计")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("微信/支付宝/刷卡支付")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("现金支付")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("应收款")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("其他支付")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("应付摄影款")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("应付商超款")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("应付SPA款")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("应付医务室款")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("联营商应付款合计")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("长江收入")));
|
|
|
+
|
|
|
+ return head;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<List<Object>> transformConsumptionIncomeVoyageExportData(List<ConsumptionIncomeVoyageRespVO> dataList) {
|
|
|
+ List<List<Object>> result = new ArrayList<>(dataList.size());
|
|
|
+ for (ConsumptionIncomeVoyageRespVO row : dataList) {
|
|
|
+ List<Object> rowData = new ArrayList<>(40);
|
|
|
+ boolean isYoy = "同比".equals(row.getVoyageNo());
|
|
|
+
|
|
|
+ if (isYoy) {
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("同比");
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getTargetPeople()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getAvgPerPerson()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getFrontDeskIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getRestaurantIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarPrepackedWine()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarMixedWine()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarKtv()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarMahjong()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarBarbecue()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarOther()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getCulturalIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getRoomIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getSelfIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getOtherIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPartnerPhotography()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPartnerSupermarket()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPartnerSpa()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPartnerClinic()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getTotalIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPayOnline()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPayCash()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getReceivable()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPayOther()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPayablePhotography()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPayableSupermarket()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPayableSpa()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPayableClinic()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPartnerTotalPayable()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getChangjiangIncome()));
|
|
|
+ } else {
|
|
|
+ rowData.add(row.getIndex() != null ? String.valueOf(row.getIndex()) : "");
|
|
|
+ rowData.add(row.getVoyageName() != null ? row.getVoyageName() : "");
|
|
|
+ rowData.add(row.getShipName() != null ? row.getShipName() : "");
|
|
|
+ rowData.add(row.getRoute() != null ? row.getRoute() : "");
|
|
|
+ rowData.add(row.getVoyageNo() != null ? row.getVoyageNo() : "");
|
|
|
+ rowData.add(formatBigDecimal(row.getTargetPeople()));
|
|
|
+ rowData.add(formatBigDecimal(row.getAvgPerPerson()));
|
|
|
+ rowData.add(formatBigDecimal(row.getFrontDeskIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getRestaurantIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarPrepackedWine()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarMixedWine()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarKtv()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarMahjong()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarBarbecue()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarOther()));
|
|
|
+ rowData.add(formatBigDecimal(row.getCulturalIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getRoomIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getSelfIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getOtherIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPartnerPhotography()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPartnerSupermarket()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPartnerSpa()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPartnerClinic()));
|
|
|
+ rowData.add(formatBigDecimal(row.getTotalIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPayOnline()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPayCash()));
|
|
|
+ rowData.add(formatBigDecimal(row.getReceivable()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPayOther()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPayablePhotography()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPayableSupermarket()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPayableSpa()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPayableClinic()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPartnerTotalPayable()));
|
|
|
+ rowData.add(formatBigDecimal(row.getChangjiangIncome()));
|
|
|
+ }
|
|
|
+ result.add(rowData);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private String formatBigDecimal(BigDecimal value) {
|
|
|
+ if (value == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ return value.setScale(2, RoundingMode.HALF_UP).toPlainString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String formatYoyBigDecimal(BigDecimal value) {
|
|
|
+ if (value == null) {
|
|
|
+ return "-";
|
|
|
+ }
|
|
|
+ double num = value.doubleValue();
|
|
|
+ if (num > 0) {
|
|
|
+ return "↑ +" + value.setScale(2, RoundingMode.HALF_UP).toPlainString() + "%";
|
|
|
+ } else if (num < 0) {
|
|
|
+ return "↓ " + value.setScale(2, RoundingMode.HALF_UP).toPlainString() + "%";
|
|
|
+ } else {
|
|
|
+ return "— 0.00%";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @TenantIgnore
|
|
|
+ public List<ConsumptionIncomeDailyRespVO> getConsumptionIncomeDailyList(ConsumptionIncomeDailyReqVO reqVO) {
|
|
|
+ log.info("查询省际度假游轮二消情况日报表任务开始时间{}", LocalDateTime.now());
|
|
|
+
|
|
|
+ List<ConsumptionIncomeDailyDO> doList = consumptionIncomeDailyMapper.selectList(reqVO);
|
|
|
+ log.info("查询省际度假游轮二消情况日报表任务结束时间{}", LocalDateTime.now());
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(doList)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ConsumptionIncomeDailyRespVO> respList = convertDailyToList(doList);
|
|
|
+
|
|
|
+ return buildDailyReportWithSubtotalAndCumulative(respList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ConsumptionIncomeDailyRespVO> convertDailyToList(List<ConsumptionIncomeDailyDO> doList) {
|
|
|
+ List<ConsumptionIncomeDailyRespVO> respList = new ArrayList<>();
|
|
|
+ int index = 1;
|
|
|
+ for (ConsumptionIncomeDailyDO item : doList) {
|
|
|
+ ConsumptionIncomeDailyRespVO respVO = new ConsumptionIncomeDailyRespVO();
|
|
|
+ BeanUtils.copyProperties(item, respVO);
|
|
|
+ respVO.setIndex(index++);
|
|
|
+ respVO.setRoute(item.getRoute());
|
|
|
+ respList.add(respVO);
|
|
|
+ }
|
|
|
+ return respList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ConsumptionIncomeDailyRespVO> buildDailyReportWithSubtotalAndCumulative(
|
|
|
+ List<ConsumptionIncomeDailyRespVO> currentDataList) {
|
|
|
+
|
|
|
+ List<ConsumptionIncomeDailyRespVO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<String, List<ConsumptionIncomeDailyRespVO>> currentMonthMap = currentDataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ item -> item.getStatMonth() != null ? item.getStatMonth() : "",
|
|
|
+ TreeMap::new, Collectors.toList()));
|
|
|
+
|
|
|
+ int globalIdx = 1;
|
|
|
+ List<ConsumptionIncomeDailyRespVO> allDailyDataForCumulative = new ArrayList<>();
|
|
|
+
|
|
|
+ int monthIndex = 0;
|
|
|
+ for (Map.Entry<String, List<ConsumptionIncomeDailyRespVO>> entry : currentMonthMap.entrySet()) {
|
|
|
+ String month = entry.getKey();
|
|
|
+ List<ConsumptionIncomeDailyRespVO> dailyItems = entry.getValue();
|
|
|
+
|
|
|
+ for (ConsumptionIncomeDailyRespVO item : dailyItems) {
|
|
|
+ item.setIndex(globalIdx++);
|
|
|
+ }
|
|
|
+
|
|
|
+ result.addAll(dailyItems);
|
|
|
+ allDailyDataForCumulative.addAll(dailyItems);
|
|
|
+
|
|
|
+ ConsumptionIncomeDailyRespVO subtotalData = buildDailySubtotalRow(dailyItems, month);
|
|
|
+ result.add(subtotalData);
|
|
|
+
|
|
|
+ ConsumptionIncomeDailyRespVO lastYearSubtotal = buildDailySubtotalRow(new ArrayList<>(), "");
|
|
|
+ ConsumptionIncomeDailyRespVO subtotalYoy = buildDailyYoyRow(subtotalData, lastYearSubtotal);
|
|
|
+ result.add(subtotalYoy);
|
|
|
+
|
|
|
+ if (monthIndex > 0) {
|
|
|
+ ConsumptionIncomeDailyRespVO cumData = buildDailySubtotalRow(allDailyDataForCumulative, "累计");
|
|
|
+ result.add(cumData);
|
|
|
+
|
|
|
+ ConsumptionIncomeDailyRespVO lastYearCumData = buildDailySubtotalRow(new ArrayList<>(), "");
|
|
|
+ ConsumptionIncomeDailyRespVO cumYoy = buildDailyYoyRow(cumData, lastYearCumData);
|
|
|
+ result.add(cumYoy);
|
|
|
+ }
|
|
|
+
|
|
|
+ monthIndex++;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private ConsumptionIncomeDailyRespVO buildDailySubtotalRow(List<ConsumptionIncomeDailyRespVO> items, String monthLabel) {
|
|
|
+ ConsumptionIncomeDailyRespVO row = new ConsumptionIncomeDailyRespVO();
|
|
|
+
|
|
|
+ if ("累计".equals(monthLabel)) {
|
|
|
+ row.setVoyageName("累计");
|
|
|
+ } else if (!"累计".equals(monthLabel) && monthLabel.contains("小计")) {
|
|
|
+ row.setVoyageName(monthLabel);
|
|
|
+ } else {
|
|
|
+ row.setVoyageName(monthLabel + "小计");
|
|
|
+ }
|
|
|
+ row.setVoyageNo("数据");
|
|
|
+ row.setIsSubtotal(!"累计".equals(row.getVoyageName()));
|
|
|
+ row.setIsCumulative("累计".equals(row.getVoyageName()));
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(items)) {
|
|
|
+ return row;
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal frontDeskSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal restaurantSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barPrepackedSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barMixedSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barKtvSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barMahjongSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barBarbecueSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal barOtherSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal culturalSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal roomSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal selfSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal otherSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal partnerPhotoSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal partnerSuperSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal partnerSpaSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal partnerClinicSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal totalIncomeSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payOnlineSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payCashSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payOtherSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal receivableSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payablePhotoSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payableSuperSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payableSpaSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal payableClinicSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal partnerTotalPayableSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal changjiangSum = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ for (ConsumptionIncomeDailyRespVO item : items) {
|
|
|
+ frontDeskSum = frontDeskSum.add(safeBigDecimal(item.getFrontDeskIncome()));
|
|
|
+ restaurantSum = restaurantSum.add(safeBigDecimal(item.getRestaurantIncome()));
|
|
|
+ barPrepackedSum = barPrepackedSum.add(safeBigDecimal(item.getBarPrepackedWine()));
|
|
|
+ barMixedSum = barMixedSum.add(safeBigDecimal(item.getBarMixedWine()));
|
|
|
+ barKtvSum = barKtvSum.add(safeBigDecimal(item.getBarKtv()));
|
|
|
+ barMahjongSum = barMahjongSum.add(safeBigDecimal(item.getBarMahjong()));
|
|
|
+ barBarbecueSum = barBarbecueSum.add(safeBigDecimal(item.getBarBarbecue()));
|
|
|
+ barOtherSum = barOtherSum.add(safeBigDecimal(item.getBarOther()));
|
|
|
+ culturalSum = culturalSum.add(safeBigDecimal(item.getCulturalIncome()));
|
|
|
+ roomSum = roomSum.add(safeBigDecimal(item.getRoomIncome()));
|
|
|
+ selfSum = selfSum.add(safeBigDecimal(item.getSelfIncome()));
|
|
|
+ otherSum = otherSum.add(safeBigDecimal(item.getOtherIncome()));
|
|
|
+ partnerPhotoSum = partnerPhotoSum.add(safeBigDecimal(item.getPartnerPhotography()));
|
|
|
+ partnerSuperSum = partnerSuperSum.add(safeBigDecimal(item.getPartnerSupermarket()));
|
|
|
+ partnerSpaSum = partnerSpaSum.add(safeBigDecimal(item.getPartnerSpa()));
|
|
|
+ partnerClinicSum = partnerClinicSum.add(safeBigDecimal(item.getPartnerClinic()));
|
|
|
+ totalIncomeSum = totalIncomeSum.add(safeBigDecimal(item.getTotalIncome()));
|
|
|
+ payOnlineSum = payOnlineSum.add(safeBigDecimal(item.getPayOnline()));
|
|
|
+ payCashSum = payCashSum.add(safeBigDecimal(item.getPayCash()));
|
|
|
+ payOtherSum = payOtherSum.add(safeBigDecimal(item.getPayOther()));
|
|
|
+ receivableSum = receivableSum.add(safeBigDecimal(item.getReceivable()));
|
|
|
+ payablePhotoSum = payablePhotoSum.add(safeBigDecimal(item.getPayablePhotography()));
|
|
|
+ payableSuperSum = payableSuperSum.add(safeBigDecimal(item.getPayableSupermarket()));
|
|
|
+ payableSpaSum = payableSpaSum.add(safeBigDecimal(item.getPayableSpa()));
|
|
|
+ payableClinicSum = payableClinicSum.add(safeBigDecimal(item.getPayableClinic()));
|
|
|
+ partnerTotalPayableSum = partnerTotalPayableSum.add(safeBigDecimal(item.getPartnerTotalPayable()));
|
|
|
+ changjiangSum = changjiangSum.add(safeBigDecimal(item.getChangjiangIncome()));
|
|
|
+ }
|
|
|
+
|
|
|
+ row.setFrontDeskIncome(frontDeskSum);
|
|
|
+ row.setRestaurantIncome(restaurantSum);
|
|
|
+ row.setBarPrepackedWine(barPrepackedSum);
|
|
|
+ row.setBarMixedWine(barMixedSum);
|
|
|
+ row.setBarKtv(barKtvSum);
|
|
|
+ row.setBarMahjong(barMahjongSum);
|
|
|
+ row.setBarBarbecue(barBarbecueSum);
|
|
|
+ row.setBarOther(barOtherSum);
|
|
|
+ row.setCulturalIncome(culturalSum);
|
|
|
+ row.setRoomIncome(roomSum);
|
|
|
+ row.setSelfIncome(selfSum);
|
|
|
+ row.setOtherIncome(otherSum);
|
|
|
+ row.setPartnerPhotography(partnerPhotoSum);
|
|
|
+ row.setPartnerSupermarket(partnerSuperSum);
|
|
|
+ row.setPartnerSpa(partnerSpaSum);
|
|
|
+ row.setPartnerClinic(partnerClinicSum);
|
|
|
+ row.setTotalIncome(totalIncomeSum);
|
|
|
+ row.setPayOnline(payOnlineSum);
|
|
|
+ row.setPayCash(payCashSum);
|
|
|
+ row.setPayOther(payOtherSum);
|
|
|
+ row.setReceivable(receivableSum);
|
|
|
+ row.setPayablePhotography(payablePhotoSum);
|
|
|
+ row.setPayableSupermarket(payableSuperSum);
|
|
|
+ row.setPayableSpa(payableSpaSum);
|
|
|
+ row.setPayableClinic(payableClinicSum);
|
|
|
+ row.setPartnerTotalPayable(partnerTotalPayableSum);
|
|
|
+ row.setChangjiangIncome(changjiangSum);
|
|
|
+
|
|
|
+ return row;
|
|
|
+ }
|
|
|
+
|
|
|
+ private ConsumptionIncomeDailyRespVO buildDailyYoyRow(ConsumptionIncomeDailyRespVO currentRow, ConsumptionIncomeDailyRespVO lastYearRow) {
|
|
|
+ ConsumptionIncomeDailyRespVO yoyRow = new ConsumptionIncomeDailyRespVO();
|
|
|
+ yoyRow.setIndex(null);
|
|
|
+ yoyRow.setVoyageName("");
|
|
|
+ yoyRow.setVoyageNo("同比");
|
|
|
+ yoyRow.setIsSubtotal(currentRow.getIsSubtotal() != null && currentRow.getIsSubtotal());
|
|
|
+ yoyRow.setIsCumulative(currentRow.getIsCumulative() != null && currentRow.getIsCumulative());
|
|
|
+
|
|
|
+ yoyRow.setFrontDeskIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getFrontDeskIncome()), safeBigDecimal(lastYearRow.getFrontDeskIncome())));
|
|
|
+ yoyRow.setRestaurantIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getRestaurantIncome()), safeBigDecimal(lastYearRow.getRestaurantIncome())));
|
|
|
+ yoyRow.setBarPrepackedWine(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarPrepackedWine()), safeBigDecimal(lastYearRow.getBarPrepackedWine())));
|
|
|
+ yoyRow.setBarMixedWine(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarMixedWine()), safeBigDecimal(lastYearRow.getBarMixedWine())));
|
|
|
+ yoyRow.setBarKtv(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarKtv()), safeBigDecimal(lastYearRow.getBarKtv())));
|
|
|
+ yoyRow.setBarMahjong(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarMahjong()), safeBigDecimal(lastYearRow.getBarMahjong())));
|
|
|
+ yoyRow.setBarBarbecue(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarBarbecue()), safeBigDecimal(lastYearRow.getBarBarbecue())));
|
|
|
+ yoyRow.setBarOther(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getBarOther()), safeBigDecimal(lastYearRow.getBarOther())));
|
|
|
+ yoyRow.setCulturalIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getCulturalIncome()), safeBigDecimal(lastYearRow.getCulturalIncome())));
|
|
|
+ yoyRow.setRoomIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getRoomIncome()), safeBigDecimal(lastYearRow.getRoomIncome())));
|
|
|
+ yoyRow.setSelfIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getSelfIncome()), safeBigDecimal(lastYearRow.getSelfIncome())));
|
|
|
+ yoyRow.setOtherIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getOtherIncome()), safeBigDecimal(lastYearRow.getOtherIncome())));
|
|
|
+ yoyRow.setPartnerPhotography(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPartnerPhotography()), safeBigDecimal(lastYearRow.getPartnerPhotography())));
|
|
|
+ yoyRow.setPartnerSupermarket(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPartnerSupermarket()), safeBigDecimal(lastYearRow.getPartnerSupermarket())));
|
|
|
+ yoyRow.setPartnerSpa(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPartnerSpa()), safeBigDecimal(lastYearRow.getPartnerSpa())));
|
|
|
+ yoyRow.setPartnerClinic(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPartnerClinic()), safeBigDecimal(lastYearRow.getPartnerClinic())));
|
|
|
+ yoyRow.setTotalIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getTotalIncome()), safeBigDecimal(lastYearRow.getTotalIncome())));
|
|
|
+ yoyRow.setPayOnline(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayOnline()), safeBigDecimal(lastYearRow.getPayOnline())));
|
|
|
+ yoyRow.setPayCash(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayCash()), safeBigDecimal(lastYearRow.getPayCash())));
|
|
|
+ yoyRow.setPayOther(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayOther()), safeBigDecimal(lastYearRow.getPayOther())));
|
|
|
+ yoyRow.setReceivable(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getReceivable()), safeBigDecimal(lastYearRow.getReceivable())));
|
|
|
+ yoyRow.setPayablePhotography(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayablePhotography()), safeBigDecimal(lastYearRow.getPayablePhotography())));
|
|
|
+ yoyRow.setPayableSupermarket(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayableSupermarket()), safeBigDecimal(lastYearRow.getPayableSupermarket())));
|
|
|
+ yoyRow.setPayableSpa(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayableSpa()), safeBigDecimal(lastYearRow.getPayableSpa())));
|
|
|
+ yoyRow.setPayableClinic(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPayableClinic()), safeBigDecimal(lastYearRow.getPayableClinic())));
|
|
|
+ yoyRow.setPartnerTotalPayable(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getPartnerTotalPayable()), safeBigDecimal(lastYearRow.getPartnerTotalPayable())));
|
|
|
+ yoyRow.setChangjiangIncome(calcYoyPercentBigDecimal(
|
|
|
+ safeBigDecimal(currentRow.getChangjiangIncome()), safeBigDecimal(lastYearRow.getChangjiangIncome())));
|
|
|
+
|
|
|
+ return yoyRow;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @TenantIgnore
|
|
|
+ public void exportConsumptionIncomeDailyExcel(ConsumptionIncomeDailyReqVO reqVO, HttpServletResponse response) throws IOException {
|
|
|
+ List<ConsumptionIncomeDailyRespVO> dataList = getConsumptionIncomeDailyList(reqVO);
|
|
|
+ if (CollUtil.isEmpty(dataList)) {
|
|
|
+ ExcelUtils.exportEmpty(response, "省际度假游轮二消情况日报表");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<List<String>> head = buildConsumptionIncomeDailyHeaders();
|
|
|
+ List<List<Object>> exportData = transformConsumptionIncomeDailyExportData(dataList);
|
|
|
+
|
|
|
+ EasyExcel.write(response.getOutputStream())
|
|
|
+ .head(head)
|
|
|
+ .autoCloseStream(false)
|
|
|
+ .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
|
|
+ .registerConverter(new LongStringConverter())
|
|
|
+ .sheet("省际度假游轮二消情况日报表")
|
|
|
+ .doWrite(exportData);
|
|
|
+
|
|
|
+ response.addHeader("Content-Disposition",
|
|
|
+ "attachment;filename=" + URLEncoder.encode("省际度假游轮二消情况日报表.xls", StandardCharsets.UTF_8.name()));
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<List<String>> buildConsumptionIncomeDailyHeaders() {
|
|
|
+ List<List<String>> head = new ArrayList<>();
|
|
|
+
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("序号")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("统计")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("船舶")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("航线")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("航次号")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("日期")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("前台")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("餐厅")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","预包装酒水")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","调制酒水")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","KTV")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","麻将")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","烧烤")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("酒吧","其他")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("文创收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("客房收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("自营收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("其他收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("联营商", "摄影收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("联营商", "商超收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("联营商", "SPA收入")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("联营商", "医务室收入")));
|
|
|
+
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("收入合计")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("应付","摄影款")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("应付","商超款")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("应付","SPA款")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("应付","医务室款")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("应付","联营商应付款合计")));
|
|
|
+ head.add(new ArrayList<>(Arrays.asList("长江收入")));
|
|
|
+
|
|
|
+ return head;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<List<Object>> transformConsumptionIncomeDailyExportData(List<ConsumptionIncomeDailyRespVO> dataList) {
|
|
|
+ List<List<Object>> result = new ArrayList<>(dataList.size());
|
|
|
+ for (ConsumptionIncomeDailyRespVO row : dataList) {
|
|
|
+ List<Object> rowData = new ArrayList<>(40);
|
|
|
+ boolean isYoy = "同比".equals(row.getVoyageNo());
|
|
|
+
|
|
|
+ if (isYoy) {
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("同比");
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getFrontDeskIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getRestaurantIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarPrepackedWine()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarMixedWine()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarKtv()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarMahjong()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarBarbecue()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getBarOther()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getCulturalIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getRoomIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getSelfIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getOtherIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPartnerPhotography()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPartnerSupermarket()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPartnerSpa()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPartnerClinic()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getTotalIncome()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPayablePhotography()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPayableSupermarket()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPayableSpa()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPayableClinic()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getPartnerTotalPayable()));
|
|
|
+ rowData.add(formatYoyBigDecimal(row.getChangjiangIncome()));
|
|
|
+ } else {
|
|
|
+ rowData.add(row.getIndex() != null ? String.valueOf(row.getIndex()) : "");
|
|
|
+ rowData.add(row.getVoyageName() != null ? row.getVoyageName() : "");
|
|
|
+ rowData.add(row.getShipName() != null ? row.getShipName() : "");
|
|
|
+ rowData.add(row.getRoute() != null ? row.getRoute() : "");
|
|
|
+ rowData.add(row.getVoyageNo() != null ? row.getVoyageNo() : "");
|
|
|
+ rowData.add(row.getStatDate() != null ? row.getStatDate() : "");
|
|
|
+ rowData.add(formatBigDecimal(row.getFrontDeskIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getRestaurantIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarPrepackedWine()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarMixedWine()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarKtv()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarMahjong()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarBarbecue()));
|
|
|
+ rowData.add(formatBigDecimal(row.getBarOther()));
|
|
|
+ rowData.add(formatBigDecimal(row.getCulturalIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getRoomIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getSelfIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getOtherIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPartnerPhotography()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPartnerSupermarket()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPartnerSpa()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPartnerClinic()));
|
|
|
+ rowData.add(formatBigDecimal(row.getTotalIncome()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPayablePhotography()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPayableSupermarket()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPayableSpa()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPayableClinic()));
|
|
|
+ rowData.add(formatBigDecimal(row.getPartnerTotalPayable()));
|
|
|
+ rowData.add(formatBigDecimal(row.getChangjiangIncome()));
|
|
|
+ }
|
|
|
+ result.add(rowData);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
}
|