修改体检接口,新增字段,及修复部分bug
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
package com.guahao.common.listener;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextClosedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import javax.servlet.annotation.WebListener;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* MySQL连接清理监听器,用于在应用关闭时正确清理MySQL连接
|
||||
*/
|
||||
@Component
|
||||
@WebListener
|
||||
public class MysqlCleanupListener implements ServletContextListener, ApplicationListener<ContextClosedEvent> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MysqlCleanupListener.class);
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
// 应用启动时无需特殊处理
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextClosedEvent event) {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理MySQL连接和相关资源
|
||||
*/
|
||||
private void cleanup() {
|
||||
try {
|
||||
// 注销驱动程序,防止内存泄漏
|
||||
deregisterJdbcDrivers();
|
||||
|
||||
// 尝试停止MySQL的AbandonedConnectionCleanupThread
|
||||
stopMySqlAbandonedConnectionCleanupThread();
|
||||
|
||||
logger.info("MySQL连接及相关资源清理完成");
|
||||
} catch (Exception e) {
|
||||
logger.error("清理MySQL连接资源时发生错误", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销JDBC驱动程序
|
||||
*/
|
||||
private void deregisterJdbcDrivers() {
|
||||
try {
|
||||
DriverManager.getDrivers();
|
||||
java.sql.Driver driver;
|
||||
while (DriverManager.getDrivers().hasMoreElements()) {
|
||||
driver = DriverManager.getDrivers().nextElement();
|
||||
if (driver.getClass().getName().startsWith("com.mysql")) {
|
||||
DriverManager.deregisterDriver(driver);
|
||||
logger.info("已注销MySQL驱动: {}", driver.getClass().getName());
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.error("注销JDBC驱动时发生错误", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止MySQL的AbandonedConnectionCleanupThread线程
|
||||
*/
|
||||
private void stopMySqlAbandonedConnectionCleanupThread() {
|
||||
try {
|
||||
Class<?> clazz;
|
||||
try {
|
||||
clazz = Class.forName("com.mysql.jdbc.AbandonedConnectionCleanupThread");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// 对于MySQL 8.0+版本,类名可能不同
|
||||
try {
|
||||
clazz = Class.forName("com.mysql.cj.jdbc.AbandonedConnectionCleanupThread");
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.debug("未找到MySQL连接清理线程类,可能使用的是不同版本的驱动");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Method shutdownMethod = clazz.getMethod("shutdown");
|
||||
shutdownMethod.invoke(null);
|
||||
logger.info("已停止MySQL AbandonedConnectionCleanupThread线程");
|
||||
} catch (Exception e) {
|
||||
logger.warn("停止MySQL连接清理线程时发生错误", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -702,17 +702,20 @@ public class XmlUtil {
|
||||
str.append(vo.getPaynature());
|
||||
str.append("</PayNature>");
|
||||
// 当vo.getYbzhamount和ybtcamount都是0的时候,且zfamount>=0则此处用微信,其他情况用医保
|
||||
if ((vo.getYbzhamount() == null || vo.getYbzhamount().compareTo(BigDecimal.valueOf(0.00)) == 0) &&
|
||||
(vo.getYbtcamount() == null || vo.getYbtcamount().compareTo(BigDecimal.valueOf(0.00)) == 0) &&
|
||||
vo.getZfamount().compareTo(BigDecimal.valueOf(0.00)) >= 0) {
|
||||
str.append("<PayType>");
|
||||
str.append("微信");
|
||||
str.append("</PayType>");
|
||||
} else {
|
||||
str.append("<PayType>");
|
||||
str.append("医保");
|
||||
str.append("</PayType>");
|
||||
}
|
||||
// if ((vo.getYbzhamount() == null || vo.getYbzhamount().compareTo(BigDecimal.valueOf(0.00)) == 0) &&
|
||||
// (vo.getYbtcamount() == null || vo.getYbtcamount().compareTo(BigDecimal.valueOf(0.00)) == 0) &&
|
||||
// vo.getZfamount().compareTo(BigDecimal.valueOf(0.00)) >= 0) {
|
||||
// str.append("<PayType>");
|
||||
// str.append("微信");
|
||||
// str.append("</PayType>");
|
||||
// } else {
|
||||
// str.append("<PayType>");
|
||||
// str.append("医保");
|
||||
// str.append("</PayType>");
|
||||
// }
|
||||
str.append("<PayType>");
|
||||
str.append("微信");
|
||||
str.append("</PayType>");
|
||||
str.append("<PowerTranID>");
|
||||
str.append(vo.getPowertranid());
|
||||
str.append("</PowerTranID>");
|
||||
|
||||
Reference in New Issue
Block a user