package com.saye.hospitalgd.controller.FinancialReconciliation; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.saye.hospitalgd.commons.date.DateDUtil; import com.saye.hospitalgd.commons.log.ExceptionDUtil; import com.saye.hospitalgd.commons.log.LogUtil; import com.saye.hospitalgd.model.Dicinfo; import com.saye.hospitalgd.service.FinancialReconciliation.RefundStatisticsService; import com.saye.hospitalgd.service.system.DicinfoService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.List; /** * @author thuang * @version 1.0 * @description: 退款数据统计报表 * @date 2024/12/19 10:00 */ @Api(tags = "退款数据统计报表") @Controller @RequestMapping("/refundStatistics") public class RefundStatisticsController { @Autowired private RefundStatisticsService refundStatisticsService; @Autowired private DicinfoService dicinfoService; /** * @description: 到退款统计报表页面 * @author thuang * @date 2024/12/19 10:00 * @version 1.0 */ @RequestMapping("/toRefundStatistics") public String toRefundStatistics(ModelMap modelMap) { try { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); // 默认查询最近365天的数据(一年) calendar.add(Calendar.DATE, -365); Date startDate = calendar.getTime(); String startTime = DateDUtil.DateToStr(DateDUtil.yyyy_MM_dd, startDate); String endTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd); modelMap.addAttribute("startTime", startTime); modelMap.addAttribute("endTime", endTime); //支付方式 List payType = dicinfoService.findDicinfoTreeNodeList("PAY_TYPE"); modelMap.addAttribute("payTypeList", payType); //退款类型 List refundType = dicinfoService.findDicinfoTreeNodeList("REFUND_TYPE"); modelMap.addAttribute("refundTypeList", refundType); } catch (Exception e) { e.printStackTrace(); } return "financialReconciliation/refundStatistics"; } /** * @description: 查询退款统计报表数据 * @author thuang * @date 2024/12/19 10:00 * @version 1.0 */ @RequestMapping("/findRefundStatistics") @ResponseBody @ApiOperation("查询退款统计报表数据") public HashMap findRefundStatistics( @ApiParam("开始时间") String startTime, @ApiParam("结束时间") String endTime, @ApiParam("支付方式") String payType, @ApiParam("退款类型") String refundType, @ApiParam("统计维度") String dimension, @ApiParam("页码") int page, @ApiParam("每页数量") int limit) { HashMap responseMap = new HashMap(); try { HashMap map = new HashMap(); map.put("startTime", startTime); map.put("endTime", endTime); map.put("payType", payType); map.put("refundType", refundType); map.put("dimension", dimension); PageHelper.startPage(page, limit); PageInfo> pageInfo = new PageInfo>(refundStatisticsService.findRefundStatistics(map)); responseMap.put("code", 0); responseMap.put("msg", "OK"); responseMap.put("count", pageInfo.getTotal()); responseMap.put("data", pageInfo.getList()); } catch (Exception e) { e.printStackTrace(); String msg = e.getMessage(); responseMap.put("code", 1); responseMap.put("msg", "查询失败,原因:" + msg); } return responseMap; } /** * @description: 获取退款统计汇总数据 * @author thuang * @date 2024/12/19 10:00 * @version 1.0 */ @RequestMapping("/getRefundSummary") @ResponseBody @ApiOperation("获取退款统计汇总数据") public HashMap getRefundSummary( @ApiParam("开始时间") String startTime, @ApiParam("结束时间") String endTime, @ApiParam("支付方式") String payType, @ApiParam("退款类型") String refundType) { HashMap responseMap = new HashMap(); try { HashMap map = new HashMap(); map.put("startTime", startTime); map.put("endTime", endTime); map.put("payType", payType); map.put("refundType", refundType); HashMap summaryData = refundStatisticsService.getRefundSummary(map); responseMap.put("code", 0); responseMap.put("msg", "OK"); responseMap.put("data", summaryData); } catch (Exception e) { e.printStackTrace(); String msg = e.getMessage(); responseMap.put("code", 1); responseMap.put("msg", "查询失败,原因:" + msg); } return responseMap; } /** * @description: 获取退款趋势数据 * @author thuang * @date 2024/12/19 10:00 * @version 1.0 */ @RequestMapping("/getRefundTrend") @ResponseBody @ApiOperation("获取退款趋势数据") public HashMap getRefundTrend( @ApiParam("开始时间") String startTime, @ApiParam("结束时间") String endTime, @ApiParam("支付方式") String payType, @ApiParam("退款类型") String refundType) { HashMap responseMap = new HashMap(); try { HashMap map = new HashMap(); map.put("startTime", startTime); map.put("endTime", endTime); map.put("payType", payType); map.put("refundType", refundType); List> trendData = refundStatisticsService.getRefundTrend(map); responseMap.put("code", 0); responseMap.put("msg", "OK"); responseMap.put("data", trendData); } catch (Exception e) { e.printStackTrace(); String msg = e.getMessage(); responseMap.put("code", 1); responseMap.put("msg", "查询失败,原因:" + msg); } return responseMap; } /** * @description: 导出退款统计报表 * @author thuang * @date 2024/12/19 10:00 * @version 1.0 */ @RequestMapping("/exportRefundStatistics") @ResponseBody @ApiOperation("导出退款统计报表") public HashMap exportRefundStatistics( @ApiParam("开始时间") String startTime, @ApiParam("结束时间") String endTime, @ApiParam("支付方式") String payType, @ApiParam("退款类型") String refundType, @ApiParam("统计维度") String dimension) { HashMap responseMap = new HashMap(); try { HashMap map = new HashMap(); map.put("startTime", startTime); map.put("endTime", endTime); map.put("payType", payType); map.put("refundType", refundType); map.put("dimension", dimension); String fileName = refundStatisticsService.exportRefundStatistics(map); responseMap.put("code", 0); responseMap.put("msg", "导出成功"); responseMap.put("fileName", fileName); } catch (Exception e) { e.printStackTrace(); String msg = e.getMessage(); responseMap.put("code", 1); responseMap.put("msg", "导出失败,原因:" + msg); } return responseMap; } }