| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.export.PlatformLedgerReportExport; |
| | | import com.ruoyi.system.export.ProcurementReportClinicExport; |
| | | import com.ruoyi.system.export.ProcurementReportPlatformExport; |
| | | import com.ruoyi.system.export.ProcurementReportSupplierExport; |
| | | import com.ruoyi.system.model.TCrmClinic; |
| | | import com.ruoyi.system.model.TCrmSupplier; |
| | | import com.ruoyi.system.model.TErpProcurement; |
| | | import com.ruoyi.system.model.TSysAppUser; |
| | | import com.ruoyi.system.query.ClinicProcurementReportQuery; |
| | | import com.ruoyi.system.query.DataStatisticsQuery; |
| | | import com.ruoyi.system.query.DetectionPaymentReportQuery; |
| | | import com.ruoyi.system.query.PerformanceReportQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.BranchPerformanceReportVO; |
| | | import com.ruoyi.system.vo.ClinicProcurementReportVO; |
| | | import com.ruoyi.system.vo.DetectionPaymentReportVO; |
| | | import com.ruoyi.system.vo.SalespersonPerformanceReportVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.http.entity.ContentType; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.util.HashMap; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.net.URL; |
| | | import java.net.URLEncoder; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | @Api(tags = "财务报表") |
| | |
| | | private final TSysAppUserService sysAppUserService; |
| | | private final TCrmClinicPointsService crmClinicPointsService; |
| | | private final TSysOrderService sysOrderService; |
| | | private final TSysPayRecordService sysPayRecordService; |
| | | |
| | | @Autowired |
| | | public FinancialStatementsController(TErpProcurementService erpProcurementService, TokenService tokenService, ISysUserService sysUserService, TCrmSupplierService crmSupplierService, TCrmClinicService crmClinicService, TSysAppUserService sysAppUserService, TCrmClinicPointsService crmClinicPointsService, TSysOrderService sysOrderService) { |
| | | public FinancialStatementsController(TErpProcurementService erpProcurementService, TokenService tokenService, ISysUserService sysUserService, TCrmSupplierService crmSupplierService, TCrmClinicService crmClinicService, TSysAppUserService sysAppUserService, TCrmClinicPointsService crmClinicPointsService, TSysOrderService sysOrderService, TSysPayRecordService sysPayRecordService) { |
| | | this.erpProcurementService = erpProcurementService; |
| | | this.tokenService = tokenService; |
| | | this.sysUserService = sysUserService; |
| | |
| | | this.sysAppUserService = sysAppUserService; |
| | | this.crmClinicPointsService = crmClinicPointsService; |
| | | this.sysOrderService = sysOrderService; |
| | | this.sysPayRecordService = sysPayRecordService; |
| | | } |
| | | |
| | | /** |
| | | * 诊所采购报表 |
| | | */ |
| | | @ApiOperation(value = "诊所采购报表") |
| | | @ApiOperation(value = "诊所采购报表-平台-供应商-诊所共用") |
| | | @PostMapping(value = "/clinicProcurementReport") |
| | | public R<PageInfo<ClinicProcurementReportVO>> clinicProcurementReport(@RequestBody ClinicProcurementReportQuery query) { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @Log(title = "财务报表-诊所采购报表导出-诊所", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "诊所采购报表导出-诊所") |
| | | @PostMapping("/exportProcurementReportClinic") |
| | | public void exportProcurementReportClinic(@RequestBody ClinicProcurementReportQuery query){ |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | query.setRoleType(roleType); |
| | | if (Objects.equals(roleType, 4)) { |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setSupplierId(crmSupplier.getId()); |
| | | } |
| | | if (Objects.equals(roleType, 5)) { |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setClinicId(crmClinic.getId()); |
| | | } |
| | | List<ProcurementReportClinicExport> procurementReportClinicExports = erpProcurementService.exportProcurementReportClinic(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), ProcurementReportClinicExport.class, procurementReportClinicExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("诊所采购报表.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Log(title = "财务报表-诊所采购报表导出-供应商", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "诊所采购报表导出-供应商") |
| | | @PostMapping("/exportProcurementReportSupplier") |
| | | public void exportProcurementReportSupplier(@RequestBody ClinicProcurementReportQuery query){ |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | query.setRoleType(roleType); |
| | | if (Objects.equals(roleType, 4)) { |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setSupplierId(crmSupplier.getId()); |
| | | } |
| | | if (Objects.equals(roleType, 5)) { |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setClinicId(crmClinic.getId()); |
| | | } |
| | | List<ProcurementReportSupplierExport> procurementReportSupplierExports = erpProcurementService.exportProcurementReportSupplier(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), ProcurementReportSupplierExport.class, procurementReportSupplierExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("诊所采购报表.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Log(title = "财务报表-诊所采购报表导出-平台", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "诊所采购报表导出-平台") |
| | | @PostMapping("/exportProcurementReportPlatform") |
| | | public void exportProcurementReportPlatform(@RequestBody ClinicProcurementReportQuery query){ |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | query.setRoleType(roleType); |
| | | if (Objects.equals(roleType, 4)) { |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setSupplierId(crmSupplier.getId()); |
| | | } |
| | | if (Objects.equals(roleType, 5)) { |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setClinicId(crmClinic.getId()); |
| | | } |
| | | List<ProcurementReportPlatformExport> procurementReportPlatformExports = erpProcurementService.exportProcurementReportPlatform(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), ProcurementReportPlatformExport.class, procurementReportPlatformExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("诊所采购报表.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AI检测支付报表 |
| | | */ |
| | | @ApiOperation(value = "AI检测支付报表") |
| | | @PostMapping(value = "/detectionPaymentReport") |
| | | public R<PageInfo<DetectionPaymentReportVO>> detectionPaymentReport(@RequestBody DetectionPaymentReportQuery query) { |
| | | PageInfo<DetectionPaymentReportVO> pageInfo = sysPayRecordService.detectionPaymentReport(query); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @Log(title = "财务报表-AI检测支付报表导出", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "AI检测支付报表导出") |
| | | @PostMapping("/exportDetectionPaymentReport") |
| | | public void exportDetectionPaymentReport(@RequestBody DetectionPaymentReportQuery query){ |
| | | List<DetectionPaymentReportVO> list = sysPayRecordService.exportDetectionPaymentReport(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), DetectionPaymentReportVO.class, list); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("AI检测支付报表.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 平台分账报表 |
| | | */ |
| | | @ApiOperation(value = "平台分账报表") |
| | | @PostMapping(value = "/platformLedgerReport") |
| | | public R<PageInfo<ClinicProcurementReportVO>> platformLedgerReport(@RequestBody ClinicProcurementReportQuery query) { |
| | | PageInfo<ClinicProcurementReportVO> pageInfo = erpProcurementService.platformLedgerReport(query); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @Log(title = "财务报表-平台分账报表导出", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "平台分账报表导出") |
| | | @PostMapping("/exportPlatformLedgerReport") |
| | | public void exportPlatformLedgerReport(@RequestBody ClinicProcurementReportQuery query){ |
| | | List<PlatformLedgerReportExport> list = erpProcurementService.exportPlatformLedgerReport(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), PlatformLedgerReportExport.class, list); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("平台分账报表.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 分公司业绩报表 |
| | | */ |
| | | @ApiOperation(value = "分公司业绩报表") |
| | | @PostMapping(value = "/branchPerformanceReport") |
| | | public R<PageInfo<BranchPerformanceReportVO>> branchPerformanceReport(@RequestBody PerformanceReportQuery query) { |
| | | PageInfo<BranchPerformanceReportVO> pageInfo = erpProcurementService.branchPerformanceReport(query); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @Log(title = "财务报表-分公司业绩报表导出", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "分公司业绩报表导出") |
| | | @PostMapping("/exportBranchPerformanceReport") |
| | | public void exportBranchPerformanceReport(@RequestBody PerformanceReportQuery query){ |
| | | List<BranchPerformanceReportVO> list = erpProcurementService.exportBranchPerformanceReport(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), BranchPerformanceReportVO.class, list); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("分公司业绩报表.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 业务员业绩报表 |
| | | */ |
| | | @ApiOperation(value = "业务员业绩报表") |
| | | @PostMapping(value = "/salespersonPerformanceReport") |
| | | public R<PageInfo<SalespersonPerformanceReportVO>> salespersonPerformanceReport(@RequestBody PerformanceReportQuery query) { |
| | | PageInfo<SalespersonPerformanceReportVO> pageInfo = erpProcurementService.salespersonPerformanceReport(query); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @Log(title = "财务报表-业务员业绩报表导出", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "业务员业绩报表导出") |
| | | @PostMapping("/exportSalespersonPerformanceReport") |
| | | public void exportSalespersonPerformanceReport(@RequestBody PerformanceReportQuery query){ |
| | | List<SalespersonPerformanceReportVO> list = erpProcurementService.exportSalespersonPerformanceReport(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), SalespersonPerformanceReportVO.class, list); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("业务员业绩报表.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |