|
@@ -1,8 +1,14 @@
|
|
|
package org.dromara.backstage.consumption.controller;
|
|
package org.dromara.backstage.consumption.controller;
|
|
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
+import com.itextpdf.kernel.geom.PageSize;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
import jakarta.validation.constraints.*;
|
|
import jakarta.validation.constraints.*;
|
|
@@ -11,7 +17,10 @@ import org.dromara.backstage.consumption.domain.bo.XfConsumeDetailBo;
|
|
|
import org.dromara.backstage.consumption.domain.vo.XfConsumeAnalyzeVo;
|
|
import org.dromara.backstage.consumption.domain.vo.XfConsumeAnalyzeVo;
|
|
|
import org.dromara.backstage.consumption.domain.vo.XfConsumeDetailCKBKVo;
|
|
import org.dromara.backstage.consumption.domain.vo.XfConsumeDetailCKBKVo;
|
|
|
import org.dromara.backstage.consumption.domain.vo.XfConsumeDetailVo;
|
|
import org.dromara.backstage.consumption.domain.vo.XfConsumeDetailVo;
|
|
|
|
|
+import org.dromara.common.core.utils.DateUtils;
|
|
|
|
|
+import org.dromara.common.core.utils.pdf.PdfUtil;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
|
|
+import org.dromara.system.api.model.LoginUser;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
|
@@ -141,6 +150,7 @@ public class XfConsumeDetailController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ @SaCheckPermission("consumption:xfConsumedetail:export")
|
|
|
@Log(title = "营业报表导出", businessType = BusinessType.EXPORT)
|
|
@Log(title = "营业报表导出", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/exportConsumeAnalyze")
|
|
@PostMapping("/exportConsumeAnalyze")
|
|
|
public void exportConsumeAnalyze(PageQuery pageQuery, String dateFormat, boolean groupByTerm,String accountIds
|
|
public void exportConsumeAnalyze(PageQuery pageQuery, String dateFormat, boolean groupByTerm,String accountIds
|
|
@@ -151,4 +161,60 @@ public class XfConsumeDetailController extends BaseController {
|
|
|
endDate).getRows();
|
|
endDate).getRows();
|
|
|
ExcelUtil.exportExcel(list, "营业报表", XfConsumeAnalyzeVo.class, response);
|
|
ExcelUtil.exportExcel(list, "营业报表", XfConsumeAnalyzeVo.class, response);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @SaCheckPermission("consumption:xfConsumedetail:export")
|
|
|
|
|
+ @Log(title = "营业报表PDF导出", businessType = BusinessType.EXPORT)
|
|
|
|
|
+ @PostMapping("/exportPDFConsumeAnalyze")
|
|
|
|
|
+ public void exportPDFConsumeAnalyze(PageQuery pageQuery, String dateFormat, boolean groupByTerm,String accountIds
|
|
|
|
|
+ ,String roomIds,String beginDate, String endDate, HttpServletResponse response) {
|
|
|
|
|
+ pageQuery.setPageSize(100000);
|
|
|
|
|
+ List<XfConsumeAnalyzeVo> list = xfConsumeDetailService.consumeAnalyze(pageQuery,dateFormat, groupByTerm, accountIds, roomIds
|
|
|
|
|
+ , beginDate,
|
|
|
|
|
+ endDate).getRows();
|
|
|
|
|
+ // 使用单位
|
|
|
|
|
+ LoginUser loginUser = Optional.ofNullable(LoginHelper.getLoginUser()).orElse(new LoginUser());
|
|
|
|
|
+ String useUint = loginUser.getDeptName();
|
|
|
|
|
+ // 制表人
|
|
|
|
|
+ String makeMan = loginUser.getUsername();
|
|
|
|
|
+ // 制表时间
|
|
|
|
|
+ String makeTime = DateUtils.getTime();
|
|
|
|
|
+ // 查询时间范围
|
|
|
|
|
+ String queryTime = beginDate + "至" + endDate;
|
|
|
|
|
+ String fileName = "_营业报表_" + DateUtils.dateTimeNow() + ".pdf";
|
|
|
|
|
+ if(DateUtils.YYYY.equals(dateFormat)){
|
|
|
|
|
+ // 查询年份的最后一天
|
|
|
|
|
+ queryTime = beginDate +" 01-01" + "~" + DateUtils.lastDayOfYear(Integer.parseInt(endDate));
|
|
|
|
|
+ fileName = endDate + "年"+ fileName;
|
|
|
|
|
+ }else if(DateUtils.YYYY_MM.equals(dateFormat)){
|
|
|
|
|
+ String year = endDate.split("-")[0];
|
|
|
|
|
+ String month = endDate.split("-")[1];
|
|
|
|
|
+ queryTime = beginDate +"-01" + "~" + DateUtils.lastDayOfMonth(Integer.parseInt(year), Integer.parseInt(month));
|
|
|
|
|
+ fileName = endDate + "年"+ month+"月" +fileName;
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, Object> hashMap = new HashMap<>();
|
|
|
|
|
+ hashMap.put("useUint", useUint);
|
|
|
|
|
+ hashMap.put("makeMan", makeMan);
|
|
|
|
|
+ hashMap.put("makeTime", makeTime);
|
|
|
|
|
+ hashMap.put("queryTime", queryTime);
|
|
|
|
|
+ hashMap.put("itemList", list);
|
|
|
|
|
+ // 合计金额
|
|
|
|
|
+ hashMap.put("totalAmount", list.stream().mapToDouble(e -> Double.parseDouble(e.getXiaoJiJinE())).sum());
|
|
|
|
|
+ // 合计笔数
|
|
|
|
|
+ hashMap.put("totalCount", list.stream().mapToInt(e -> Integer.parseInt(e.getXiaoJiCiShu())).sum());
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ response.reset();
|
|
|
|
|
+ response.addHeader("Access-Control-Allow-Origin", "*");
|
|
|
|
|
+ response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
|
|
|
+ response.setHeader("Content-Disposition", "inline; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
|
|
|
|
|
+ //response.addHeader("Content-Length", "" + data.length);
|
|
|
|
|
+ response.setContentType("application/pdf; charset=UTF-8");
|
|
|
|
|
+ response.setHeader("Content-Disposition", URLEncoder.encode(fileName, StandardCharsets.UTF_8));
|
|
|
|
|
+
|
|
|
|
|
+ PdfUtil.renderPdf("bussinessTemplate1.html",hashMap, response.getOutputStream(), PageSize.A4);
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|