update:对账消息推送,军保账单统计,退款数据统计

This commit is contained in:
Yuan
2025-10-20 14:39:29 +08:00
parent 9fb2ea9cb4
commit ff5bad9967
35 changed files with 3649 additions and 100 deletions

View File

@@ -0,0 +1,47 @@
package com.saye.hospitalgd.service.FinancialReconciliation;
import java.util.HashMap;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: 退款数据统计报表服务接口
* @date 2024/12/19 10:00
*/
public interface RefundStatisticsService {
/**
* 查询退款统计报表数据
* @param map 查询参数
* @return 退款统计数据列表
* @throws Exception
*/
List<HashMap<Object, Object>> findRefundStatistics(HashMap<Object, Object> map) throws Exception;
/**
* 获取退款统计汇总数据
* @param map 查询参数
* @return 退款统计汇总数据
* @throws Exception
*/
HashMap<Object, Object> getRefundSummary(HashMap<Object, Object> map) throws Exception;
/**
* 获取退款趋势数据
* @param map 查询参数
* @return 退款趋势数据列表
* @throws Exception
*/
List<HashMap<Object, Object>> getRefundTrend(HashMap<Object, Object> map) throws Exception;
/**
* 导出退款统计报表
* @param map 查询参数
* @return 导出文件名
* @throws Exception
*/
String exportRefundStatistics(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,92 @@
package com.saye.hospitalgd.service.FinancialReconciliation.impl;
import com.saye.hospitalgd.commons.excel.RefundStatisticsExportXLSX;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.mapper.FinancialReconciliation.RefundStatisticsMapper;
import com.saye.hospitalgd.service.FinancialReconciliation.RefundStatisticsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.util.HashMap;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: 退款数据统计报表服务实现类
* @date 2024/12/19 10:00
*/
@Service
@Transactional
public class RefundStatisticsServiceImpl implements RefundStatisticsService {
private static final Logger log = LoggerFactory.getLogger(RefundStatisticsServiceImpl.class);
@Autowired
private RefundStatisticsMapper refundStatisticsMapper;
@Override
public List<HashMap<Object, Object>> findRefundStatistics(HashMap<Object, Object> map) throws Exception {
try {
return refundStatisticsMapper.findRefundStatistics(map);
} catch (Exception e) {
log.info("查询退款统计报表数据失败", e);
throw e;
}
}
@Override
public HashMap<Object, Object> getRefundSummary(HashMap<Object, Object> map) throws Exception {
try {
return refundStatisticsMapper.getRefundSummary(map);
} catch (Exception e) {
log.error("获取退款统计汇总数据失败", e);
throw e;
}
}
@Override
public List<HashMap<Object, Object>> getRefundTrend(HashMap<Object, Object> map) throws Exception {
try {
return refundStatisticsMapper.getRefundTrend(map);
} catch (Exception e) {
log.error("获取退款趋势数据失败", e);
throw e;
}
}
@Override
public String exportRefundStatistics(HashMap<Object, Object> map) throws Exception {
try {
// 获取统计数据
List<HashMap<Object, Object>> dataList = refundStatisticsMapper.findRefundStatistics(map);
// 获取汇总数据
HashMap<Object, Object> summaryData = refundStatisticsMapper.getRefundSummary(map);
// 创建导出文件
String fileName = "退款统计报表_" + System.currentTimeMillis() + ".xlsx";
String filePath = System.getProperty("user.dir") + File.separator + "downloadFile" + File.separator + fileName;
// 确保目录存在
File file = new File(filePath);
File parentDir = file.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
}
// 导出Excel
RefundStatisticsExportXLSX exportXLSX = new RefundStatisticsExportXLSX();
exportXLSX.exportRefundStatistics(dataList, summaryData, filePath);
return fileName;
} catch (Exception e) {
log.error("导出退款统计报表失败", e);
throw e;
}
}
}

View File

@@ -0,0 +1,41 @@
package com.saye.hospitalgd.service;
import com.saye.hospitalgd.model.FinanceUser;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: 消息推送服务接口
* @date 2024/12/19 18:00
*/
public interface NotifyService {
/**
* 发送对账完成通知
* @param tradeDate 对账日期
* @param status 对账状态 (1:成功 0:失败)
* @param message 对账消息
* @throws Exception 异常
*/
void sendReconciliationNotify(String tradeDate, String status, String message) throws Exception;
/**
* 获取用户OpenID
* @param wechatName 微信名
* @return OpenID
* @throws Exception 异常
*/
String getUserOpenId(String wechatName) throws Exception;
/**
* 根据手机号获取用户OpenID
* @param phone 手机号
* @return OpenID
* @throws Exception 异常
*/
String getUserOpenIdByPhone(String phone) throws Exception;
}

View File

@@ -12,6 +12,8 @@ import java.util.List;
public interface OperatorService {
List<HashMap<Object, Object>> findAllOperator(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findMilitaryOperators(HashMap<Object, Object> map) throws Exception;
void addOperator(HashMap<Object, Object> map) throws Exception;
void modifyOperator(HashMap<Object, Object> map) throws Exception;

View File

@@ -0,0 +1,263 @@
package com.saye.hospitalgd.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.model.FinanceUser;
import com.saye.hospitalgd.service.NotifyService;
import com.saye.hospitalgd.service.system.FinanceUserService;
import com.saye.hospitalgd.service.system.ServiceParamsService;
import com.saye.hospitalgd.util.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: 消息推送服务实现类
* @date 2024/12/19 18:00
*/
@Service
public class NotifyServiceImpl implements NotifyService {
private static final Logger log = LoggerFactory.getLogger(NotifyServiceImpl.class);
@Autowired
private FinanceUserService financeUserService;
@Autowired
private ServiceParamsService serviceParamsService;
@Override
public void sendReconciliationNotify(String tradeDate, String status, String message) throws Exception {
try {
// 获取所有启用的财务人员
List<FinanceUser> financeUsers = financeUserService.findActiveFinanceUsers();
if (financeUsers == null || financeUsers.isEmpty()) {
log.info("没有启用的财务人员,跳过消息推送");
return;
}
// 获取中转服务地址
List<HashMap<Object, Object>> serviceParams = serviceParamsService.findParamValByParamCode("hgd_dmz");
String transferUrl = StringDUtil.changeNullToEmpty(serviceParams.get(0).get("PARAM_VAL"));
if (transferUrl == null || transferUrl.trim().isEmpty()) {
log.error("未配置中转服务地址(hgd_dmz)");
return;
}
// 构建消息推送URL
String notifyUrl = transferUrl.endsWith("/") ?
transferUrl + "sendNotifyYJJ" :
transferUrl + "/sendNotifyYJJ";
// 为每个财务人员发送通知
for (FinanceUser financeUser : financeUsers) {
if (financeUser.getOpenId() != null && !financeUser.getOpenId().trim().isEmpty()) {
sendNotifyToFinanceUser(financeUser, tradeDate, status, message, notifyUrl);
} else {
log.warn("财务人员 {} 没有OpenID跳过消息推送", financeUser.getName());
}
}
} catch (Exception e) {
log.error("发送对账通知失败", e);
throw e;
}
}
/**
* 发送通知给指定财务人员
* @param financeUser 财务人员信息
* @param tradeDate 对账日期
* @param status 对账状态
* @param message 对账消息
* @param notifyUrl 通知URL
*/
private void sendNotifyToFinanceUser(FinanceUser financeUser, String tradeDate, String status,
String message, String notifyUrl) {
try {
// 构建通知参数
HashMap<String, Object> notifyParams = new HashMap<>();
notifyParams.put("openid", financeUser.getOpenId());
notifyParams.put("tradeDate", tradeDate);
notifyParams.put("status", status);
notifyParams.put("message", message);
notifyParams.put("userName", financeUser.getName());
// 发送通知
String response = HttpClientUtil.doPost(notifyUrl, notifyParams);
log.debug("发送对账通知响应: " + response);
// 增加空值检查
if (response == null || response.trim().isEmpty()) {
log.error("调用中转服务失败,返回为空,接收人: {}", financeUser.getName());
return;
}
JSONObject jsonResponse = JSON.parseObject(response);
// 兼容多种成功状态码格式
Integer code = jsonResponse.getInteger("code");
Integer errCode = jsonResponse.getInteger("errcode");
Integer errCodeInt = jsonResponse.getInteger("errCode");
// 判断成功条件code=0 或 errcode=0 或 errCode=0 或 errCode="0"
boolean isSuccess = (code != null && code == 0) ||
(errCode != null && errCode == 0) ||
(errCodeInt != null && errCodeInt == 0) ||
"0".equals(jsonResponse.getString("errCode"));
if (isSuccess) {
log.info("对账通知发送成功,接收人: {}", financeUser.getName());
} else {
// 兼容多种错误消息字段msg/errMsg
String errorMsg = jsonResponse.getString("msg");
if (errorMsg == null || errorMsg.trim().isEmpty()) {
errorMsg = jsonResponse.getString("errMsg");
}
log.error("对账通知发送失败,接收人: {}, 错误信息: {}",
financeUser.getName(), errorMsg);
}
} catch (Exception e) {
log.error("发送对账通知异常,接收人: {}", financeUser.getName(), e);
}
}
@Override
public String getUserOpenId(String wechatName) throws Exception {
try {
// 获取中转服务地址
List<HashMap<Object, Object>> serviceParams = serviceParamsService.findParamValByParamCode("hgd_dmz");
String transferUrl = StringDUtil.changeNullToEmpty(serviceParams.get(0).get("PARAM_VAL"));
if (transferUrl == null || transferUrl.trim().isEmpty()) {
throw new Exception("未配置中转服务地址(hgd_dmz)");
}
// 构建获取OpenID的URL
String openIdUrl = transferUrl.endsWith("/") ?
transferUrl + "getUserOpenId" :
transferUrl + "/getUserOpenId";
// 构建请求参数
HashMap<String, Object> params = new HashMap<>();
params.put("wechatName", wechatName);
// 发送请求
String response = HttpClientUtil.doPost(openIdUrl, params);
log.debug("获取OpenID响应: " + response);
// 增加空值检查
if (response == null || response.trim().isEmpty()) {
throw new Exception("调用中转服务失败,返回为空。请检查中转服务地址是否正确或网络是否可达");
}
JSONObject jsonResponse = JSON.parseObject(response);
// 兼容两种返回格式code/errCode
Integer code = jsonResponse.getInteger("code");
Integer errCode = jsonResponse.getInteger("errCode");
// 判断成功条件code=0 或 errCode="0"
boolean isSuccess = (code != null && code == 0) ||
(errCode != null && errCode == 0) ||
"0".equals(jsonResponse.getString("errCode"));
if (isSuccess) {
// 兼容两种数据字段data/openid
String openId = jsonResponse.getString("data");
if (openId == null || openId.trim().isEmpty()) {
openId = jsonResponse.getString("openid");
}
if (openId != null && !openId.trim().isEmpty()) {
log.info("成功获取OpenID: {} for 微信名: {}", openId, wechatName);
return openId;
} else {
throw new Exception("返回的OpenID为空");
}
} else {
// 兼容两种错误消息字段msg/errMsg
String errorMsg = jsonResponse.getString("msg");
if (errorMsg == null || errorMsg.trim().isEmpty()) {
errorMsg = jsonResponse.getString("errMsg");
}
throw new Exception("获取OpenID失败: " + errorMsg);
}
} catch (Exception e) {
log.error("获取OpenID异常微信名: {}", wechatName, e);
throw e;
}
}
@Override
public String getUserOpenIdByPhone(String phone) throws Exception {
try {
// 获取中转服务地址
List<HashMap<Object, Object>> serviceParams = serviceParamsService.findParamValByParamCode("hgd_dmz");
String transferUrl = StringDUtil.changeNullToEmpty(serviceParams.get(0).get("PARAM_VAL"));
if (transferUrl == null || transferUrl.trim().isEmpty()) {
throw new Exception("未配置中转服务地址(hgd_dmz)");
}
// 构建获取OpenID的URL
String openIdUrl = transferUrl.endsWith("/") ?
transferUrl + "getUserOpenId" :
transferUrl + "/getUserOpenId";
// 构建请求参数
HashMap<String, Object> params = new HashMap<>();
params.put("phone", phone);
params.put("yz", "joju@");
// 发送请求
String response = HttpClientUtil.doPost(openIdUrl, params);
log.debug("根据手机号获取OpenID响应: " + response);
// 增加空值检查
if (response == null || response.trim().isEmpty()) {
throw new Exception("调用中转服务失败,返回为空。请检查中转服务地址是否正确或网络是否可达");
}
JSONObject jsonResponse = JSON.parseObject(response);
// 兼容两种返回格式code/errCode
Integer code = jsonResponse.getInteger("code");
Integer errCode = jsonResponse.getInteger("errCode");
// 判断成功条件code=0 或 errCode="0"
boolean isSuccess = (code != null && code == 0) ||
(errCode != null && errCode == 0) ||
"0".equals(jsonResponse.getString("errCode"));
if (isSuccess) {
String openId = jsonResponse.getString("openid");
if (openId != null && !openId.trim().isEmpty()) {
log.info("成功根据手机号获取OpenID: {} for 手机号: {}", openId, phone);
return openId;
} else {
throw new Exception("返回的OpenID为空");
}
} else {
// 兼容两种错误消息字段msg/errMsg
String errorMsg = jsonResponse.getString("msg");
if (errorMsg == null || errorMsg.trim().isEmpty()) {
errorMsg = jsonResponse.getString("errMsg");
}
throw new Exception("根据手机号获取OpenID失败: " + errorMsg);
}
} catch (Exception e) {
log.error("根据手机号获取OpenID异常手机号: {}", phone, e);
throw e;
}
}
}

View File

@@ -29,6 +29,11 @@ public class OperatorServiceImpl implements OperatorService {
return operatorMapper.findAllOperator(map);
}
@Override
public List<HashMap<Object, Object>> findMilitaryOperators(HashMap<Object, Object> map) throws Exception {
return operatorMapper.findMilitaryOperators(map);
}
@Override
public void addOperator(HashMap<Object, Object> map) throws Exception {
String hisOperCode = StringDUtil.changeNullToEmpty(map.get("hisOperCode"));

View File

@@ -0,0 +1,72 @@
package com.saye.hospitalgd.service.system;
import com.saye.hospitalgd.model.FinanceUser;
import java.util.HashMap;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: 财务人员服务接口
* @date 2024/12/19 18:00
*/
public interface FinanceUserService {
/**
* 查询财务人员列表
* @param map 查询参数
* @return 财务人员列表
* @throws Exception 异常
*/
List<FinanceUser> findFinanceUserPageList(HashMap<Object, Object> map) throws Exception;
/**
* 添加财务人员
* @param financeUser 财务人员信息
* @throws Exception 异常
*/
void addFinanceUser(FinanceUser financeUser) throws Exception;
/**
* 修改财务人员
* @param financeUser 财务人员信息
* @throws Exception 异常
*/
void updateFinanceUser(FinanceUser financeUser) throws Exception;
/**
* 删除财务人员
* @param id 财务人员ID
* @throws Exception 异常
*/
void deleteFinanceUser(String id) throws Exception;
/**
* 根据ID查询财务人员
* @param id 财务人员ID
* @return 财务人员信息
* @throws Exception 异常
*/
FinanceUser findFinanceUserById(String id) throws Exception;
/**
* 获取所有启用的财务人员
* @return 启用的财务人员列表
* @throws Exception 异常
*/
List<FinanceUser> findActiveFinanceUsers() throws Exception;
}

View File

@@ -0,0 +1,102 @@
package com.saye.hospitalgd.service.system.impl;
import com.saye.hospitalgd.mapper.system.FinanceUserMapper;
import com.saye.hospitalgd.model.FinanceUser;
import com.saye.hospitalgd.service.system.FinanceUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: 财务人员服务实现类
* @date 2024/12/19 18:00
*/
@Service
@Transactional
public class FinanceUserServiceImpl implements FinanceUserService {
private static final Logger log = LoggerFactory.getLogger(FinanceUserServiceImpl.class);
@Autowired
private FinanceUserMapper financeUserMapper;
@Override
public List<FinanceUser> findFinanceUserPageList(HashMap<Object, Object> map) throws Exception {
try {
return financeUserMapper.findFinanceUserPageList(map);
} catch (Exception e) {
log.error("查询财务人员列表失败", e);
throw e;
}
}
@Override
public void addFinanceUser(FinanceUser financeUser) throws Exception {
try {
financeUserMapper.addFinanceUser(financeUser);
} catch (Exception e) {
log.error("添加财务人员失败", e);
throw e;
}
}
@Override
public void updateFinanceUser(FinanceUser financeUser) throws Exception {
try {
financeUserMapper.updateFinanceUser(financeUser);
} catch (Exception e) {
log.error("修改财务人员失败", e);
throw e;
}
}
@Override
public void deleteFinanceUser(String id) throws Exception {
try {
financeUserMapper.deleteFinanceUser(id);
} catch (Exception e) {
log.error("删除财务人员失败", e);
throw e;
}
}
@Override
public FinanceUser findFinanceUserById(String id) throws Exception {
try {
return financeUserMapper.findFinanceUserById(id);
} catch (Exception e) {
log.error("根据ID查询财务人员失败", e);
throw e;
}
}
@Override
public List<FinanceUser> findActiveFinanceUsers() throws Exception {
try {
return financeUserMapper.findActiveFinanceUsers();
} catch (Exception e) {
log.error("查询启用的财务人员失败", e);
throw e;
}
}
}