From c471263ca1246ae8baf5f76387612d9308d92cf3 Mon Sep 17 00:00:00 2001 From: zhangjing <924187658@qq.com> Date: Fri, 16 Jan 2026 19:37:48 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E3=80=90=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E3=80=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fkzy/warn/controller/PdfController.java | 5 +++-- .../fkzy/warn/controller/PermissionController.java | 2 +- .../com/fkzy/warn/controller/ReportController.java | 16 +++++++++++++ src/main/java/com/fkzy/warn/model/Report.java | 14 ++++++++++++ .../warn/model/params/GenerateReportParams.java | 17 ++++++++++++++ .../fkzy/warn/model/params/PdfRequestParams.java | 13 +++++++++++ .../java/com/fkzy/warn/service/PdfService.java | 14 ++++++------ .../java/com/fkzy/warn/service/ReportService.java | 4 +++- .../fkzy/warn/service/impl/ReportServiceImpl.java | 26 ++++++++++++++++++++++ 9 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/fkzy/warn/model/params/GenerateReportParams.java create mode 100644 src/main/java/com/fkzy/warn/model/params/PdfRequestParams.java diff --git a/src/main/java/com/fkzy/warn/controller/PdfController.java b/src/main/java/com/fkzy/warn/controller/PdfController.java index b0c4774..4572a32 100644 --- a/src/main/java/com/fkzy/warn/controller/PdfController.java +++ b/src/main/java/com/fkzy/warn/controller/PdfController.java @@ -1,6 +1,7 @@ package com.fkzy.warn.controller; import com.fkzy.warn.model.Report; +import com.fkzy.warn.model.params.PdfRequestParams; import com.fkzy.warn.service.PdfService; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; @@ -24,8 +25,8 @@ public class PdfController { private PdfService pdfService; @PostMapping("download") - public ResponseEntity generateReport(@RequestBody String url) { - byte[] pdfBytes = pdfService.generatePdfFromUrl(url); + public ResponseEntity generateReport(@RequestBody PdfRequestParams params) { + byte[] pdfBytes = pdfService.generatePdfFromUrl(params.getUrl()); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_PDF); diff --git a/src/main/java/com/fkzy/warn/controller/PermissionController.java b/src/main/java/com/fkzy/warn/controller/PermissionController.java index 2a68752..6ab0a7e 100644 --- a/src/main/java/com/fkzy/warn/controller/PermissionController.java +++ b/src/main/java/com/fkzy/warn/controller/PermissionController.java @@ -26,7 +26,7 @@ import javax.annotation.Resource; @Slf4j public class PermissionController { @Resource - private PermissionService permissionService ; + private PermissionService permissionService; @RequestMapping(value = "save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ApiOperation(value = "新增") diff --git a/src/main/java/com/fkzy/warn/controller/ReportController.java b/src/main/java/com/fkzy/warn/controller/ReportController.java index 843f3b1..a3d098f 100644 --- a/src/main/java/com/fkzy/warn/controller/ReportController.java +++ b/src/main/java/com/fkzy/warn/controller/ReportController.java @@ -2,6 +2,7 @@ package com.fkzy.warn.controller; import com.alibaba.fastjson.JSONObject; import com.fkzy.warn.model.Report; +import com.fkzy.warn.model.params.GenerateReportParams; import com.fkzy.warn.service.ReportService; import com.fkzy.warn.common.constants.ResponseMsgConstants; import com.fkzy.warn.common.request.RequestParameter; @@ -96,4 +97,19 @@ public class ReportController { return apiResponse; } + @PostMapping(value = "generateReport") + @ApiOperation(value = "生成报告") + public ApiResponse generateReport(@ApiParam("{\n" + + "\"id\":\"报告id\",\n" + + "}") @RequestBody GenerateReportParams params, @RequestHeader String ticket) { + ApiResponse apiResponse = new ApiResponse(); + try { + apiResponse.setData(reportService.generateReport(params,ticket)); + apiResponse.setMessage(ResponseMsgConstants.OPERATE_SUCCESS); + } catch (Exception e) { + apiResponse.recordError(ResponseMsgConstants.OPERATE_FAIL); + } + return apiResponse; + } + } diff --git a/src/main/java/com/fkzy/warn/model/Report.java b/src/main/java/com/fkzy/warn/model/Report.java index e71de09..423c62d 100644 --- a/src/main/java/com/fkzy/warn/model/Report.java +++ b/src/main/java/com/fkzy/warn/model/Report.java @@ -40,6 +40,20 @@ public class Report extends BaseField{ @ApiModelProperty("报告时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private Date reportTime; + + /** + * 报告时间 + */ + @ApiModelProperty("范围开始时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private Date startTime; + + /** + * 报告时间 + */ + @ApiModelProperty("范围结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private Date endTime; /** * 企业名称 */ diff --git a/src/main/java/com/fkzy/warn/model/params/GenerateReportParams.java b/src/main/java/com/fkzy/warn/model/params/GenerateReportParams.java new file mode 100644 index 0000000..65c4216 --- /dev/null +++ b/src/main/java/com/fkzy/warn/model/params/GenerateReportParams.java @@ -0,0 +1,17 @@ +package com.fkzy.warn.model.params; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author zhangjing + * @date 2026/01/15 16:31 + * @description + */ +@Data +public class GenerateReportParams { + + private Integer id; +} diff --git a/src/main/java/com/fkzy/warn/model/params/PdfRequestParams.java b/src/main/java/com/fkzy/warn/model/params/PdfRequestParams.java new file mode 100644 index 0000000..c16c467 --- /dev/null +++ b/src/main/java/com/fkzy/warn/model/params/PdfRequestParams.java @@ -0,0 +1,13 @@ +package com.fkzy.warn.model.params; + +import lombok.Data; + +/** + * @author zhangjing + * @date 2026/01/13 11:14 + * @description + */ +@Data +public class PdfRequestParams { + private String url; +} diff --git a/src/main/java/com/fkzy/warn/service/PdfService.java b/src/main/java/com/fkzy/warn/service/PdfService.java index 84b66c8..83239f3 100644 --- a/src/main/java/com/fkzy/warn/service/PdfService.java +++ b/src/main/java/com/fkzy/warn/service/PdfService.java @@ -72,14 +72,14 @@ public class PdfService { byte[] pdfBytes = page.pdf(new Page.PdfOptions() .setFormat("A4") .setPrintBackground(true) - .setMargin(margin) +// .setMargin(margin) .setDisplayHeaderFooter(true) - .setHeaderTemplate("
公司名称
") - .setFooterTemplate( - "
" + - "© 2026 MyCompany" + - " 页 / 共 " + - "
") +// .setHeaderTemplate("
公司名称
") +// .setFooterTemplate( +// "
" + +// "© 2026 MyCompany" + +// " 页 / 共 " + +// "
") ); browser.close(); diff --git a/src/main/java/com/fkzy/warn/service/ReportService.java b/src/main/java/com/fkzy/warn/service/ReportService.java index ac65eed..d8e6981 100644 --- a/src/main/java/com/fkzy/warn/service/ReportService.java +++ b/src/main/java/com/fkzy/warn/service/ReportService.java @@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.fkzy.warn.model.Report; import com.fkzy.warn.common.request.RequestParameter; import com.fkzy.warn.common.response.ApiResponse; +import com.fkzy.warn.model.params.GenerateReportParams; import java.util.List; +import java.util.Map; /** * @author zhangjing @@ -44,5 +46,5 @@ public interface ReportService extends IService { Page queryPage(RequestParameter parameter); - + Map generateReport(GenerateReportParams params, String ticket); } diff --git a/src/main/java/com/fkzy/warn/service/impl/ReportServiceImpl.java b/src/main/java/com/fkzy/warn/service/impl/ReportServiceImpl.java index 22b61a9..5af7a13 100644 --- a/src/main/java/com/fkzy/warn/service/impl/ReportServiceImpl.java +++ b/src/main/java/com/fkzy/warn/service/impl/ReportServiceImpl.java @@ -4,14 +4,22 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fkzy.warn.mapper.ReportMapper; +import com.fkzy.warn.model.EnterpriseInfo; import com.fkzy.warn.model.Report; +import com.fkzy.warn.model.User; +import com.fkzy.warn.model.params.GenerateReportParams; +import com.fkzy.warn.service.EnterpriseInfoService; import com.fkzy.warn.service.ReportService; import com.fkzy.warn.common.constants.EntityConstants; import com.fkzy.warn.common.request.RequestParameter; import com.fkzy.warn.common.response.ApiResponse; +import com.fkzy.warn.service.UserService; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @author zhangjing @@ -22,6 +30,13 @@ import java.util.List; public class ReportServiceImpl extends ServiceImpl implements ReportService { + @Resource + EnterpriseInfoService enterpriseInfoService; + @Resource + UserService userService; + @Resource + ReportService reportService; + @Override public ApiResponse saveModel(Report entity, String ticket) { @@ -55,4 +70,15 @@ public class ReportServiceImpl extends ServiceImpl impleme Page result = this.page(page, eWrapper); return result; } + + @Override + public Map generateReport(GenerateReportParams params, String ticket) { + Report report = getById(params.getId()); + Map result = new HashMap<>(); + QueryWrapper enterpriseInfoQueryWrapper = new QueryWrapper<>(); + enterpriseInfoQueryWrapper.eq("CREDITCODE", report.getCreditCode()); + EnterpriseInfo enterpriseInfo = enterpriseInfoService.getOne(enterpriseInfoQueryWrapper); + result.put("basicEnterprise",enterpriseInfo); + return result; + } }