package com.saye.hospitalgd.controller; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.saye.hospitalgd.commons.date.DateDUtil; import com.saye.hospitalgd.commons.log.LogUtil; import com.saye.hospitalgd.scheduler.jobMethod.MedicalInsuranceReconciliationMethod; import com.saye.hospitalgd.service.MedicalInsuranceReconciliationService; 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.*; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.List; /** * @author thuang * @version 1.0 * @description: 医保对账Controller * @date 2025/10/24 */ @Api(value = "医保对账相关接口") @Controller @RequestMapping("/medicalInsuranceReconciliation") public class MedicalInsuranceReconciliationController { @Autowired private MedicalInsuranceReconciliationService medicalInsuranceReconciliationService; /** * 跳转到医保对账页面 */ @RequestMapping("/toMedicalInsuranceReconciliation") public String toMedicalInsuranceReconciliation(ModelMap modelMap) { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.add(Calendar.DATE, -1); 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); return "financialReconciliation/medicalInsuranceReconciliation"; } /** * 跳转到医保对账结果页面 */ @RequestMapping("/toMedicalInsuranceReconciliationResult") public String toMedicalInsuranceReconciliationResult(ModelMap modelMap) { return "financialReconciliation/medicalInsuranceReconciliationResult"; } /** * 执行医保对账 */ @ApiOperation(value = "执行医保对账", notes = "") @PostMapping("/executeMedicalInsuranceReconciliation") @ResponseBody public HashMap executeMedicalInsuranceReconciliation( @ApiParam(value = "对账日期") @RequestParam String trade_date) { HashMap responseMap = new HashMap<>(); try { LogUtil.info(this.getClass(), "开始执行医保对账,日期:" + trade_date); MedicalInsuranceReconciliationMethod reconciliationMethod = new MedicalInsuranceReconciliationMethod(); HashMap result = reconciliationMethod.executeMedicalInsuranceReconciliation(trade_date); responseMap.put("code", "0".equals(result.get("errCode")) ? 0 : 1); responseMap.put("msg", result.get("errMsg")); responseMap.put("data", result.get("reconciliationResults")); } catch (Exception e) { e.printStackTrace(); LogUtil.error(this.getClass(), "医保对账失败:" + e.getMessage()); responseMap.put("code", 1); responseMap.put("msg", "医保对账失败:" + e.getMessage()); } return responseMap; } /** * 查询医保对账结果 */ @ApiOperation(value = "查询医保对账结果", notes = "") @GetMapping("/findMedicalInsuranceReconciliationResult") @ResponseBody public HashMap findMedicalInsuranceReconciliationResult( @ApiParam(value = "开始日期") String startDate, @ApiParam(value = "结束日期") String endDate, @ApiParam(value = "险种类型") String insutype, @ApiParam(value = "清算类别") String clrType, @ApiParam(value = "对账结果") String stmtRslt, @ApiParam(value = "页码") int page, @ApiParam(value = "每页数量") int limit) { HashMap responseMap = new HashMap<>(); try { HashMap queryMap = new HashMap<>(); if (startDate != null && !"".equals(startDate)) { queryMap.put("startDate", startDate); } if (endDate != null && !"".equals(endDate)) { queryMap.put("endDate", endDate); } if (insutype != null && !"".equals(insutype)) { queryMap.put("insutype", insutype); } if (clrType != null && !"".equals(clrType)) { queryMap.put("clr_type", clrType); } if (stmtRslt != null && !"".equals(stmtRslt)) { queryMap.put("stmt_rslt", stmtRslt); } PageHelper.startPage(page, limit); PageInfo> pageInfo = new PageInfo<>( medicalInsuranceReconciliationService.findMedicalInsuranceReconciliationResult(queryMap) ); responseMap.put("code", 0); responseMap.put("msg", "OK"); responseMap.put("count", pageInfo.getTotal()); responseMap.put("data", pageInfo.getList()); } catch (Exception e) { e.printStackTrace(); LogUtil.error(this.getClass(), "查询医保对账结果失败:" + e.getMessage()); responseMap.put("code", 1); responseMap.put("msg", "查询失败:" + e.getMessage()); } return responseMap; } }