Commit 6d498c6d by WeiCong

1.优化日志记录

2.优化数据库未关闭隐患
3.修复getCodeTable方法获取不到码表的缺陷
parent 113b921b
......@@ -116,31 +116,38 @@ public class PreHandle {
}
public static boolean initUserInr(String cid, String oid) {
Session session = HibernateUtils.openSession(null);
String ptySql = "select inr,ptytyp from pty where (ptytyp='2' or PTYTYP='1') and cid=?";
Query<Map> sqlQuery = session.createSQLQuery(ptySql);
sqlQuery.setParameter(1, cid);
sqlQuery.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
List<Map> ptyLst = sqlQuery.list();
if (ptyLst == null || ptyLst.size() == 0) {
return false;
}
Map ptyRs = ptyLst.get(0);
String ptyinr = (String) ptyRs.get("INR");
String usrSql = "select inr,lgnnam,oprnam from usr where oid=? and ptyinr=?";
sqlQuery = session.createSQLQuery(usrSql);
sqlQuery.setParameter(1, oid);
sqlQuery.setParameter(2, ptyinr);
sqlQuery.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
List<Map> usrLst = sqlQuery.list();
if (usrLst == null || usrLst.size() == 0) {
return false;
Session session = null;
try {
session = HibernateUtils.openSession(null);
String ptySql = "select inr,ptytyp from pty where (ptytyp='2' or PTYTYP='1') and cid=?";
Query<Map> sqlQuery = session.createSQLQuery(ptySql);
sqlQuery.setParameter(1, cid);
sqlQuery.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
List<Map> ptyLst = sqlQuery.list();
if (ptyLst == null || ptyLst.size() == 0) {
return false;
}
Map ptyRs = ptyLst.get(0);
String ptyinr = (String) ptyRs.get("INR");
String usrSql = "select inr,lgnnam,oprnam from usr where oid=? and ptyinr=?";
sqlQuery = session.createSQLQuery(usrSql);
sqlQuery.setParameter(1, oid);
sqlQuery.setParameter(2, ptyinr);
sqlQuery.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
List<Map> usrLst = sqlQuery.list();
if (usrLst == null || usrLst.size() == 0) {
return false;
}
Map usrRs = usrLst.get(0);
USRINR.set((String) usrRs.get("INR"));
return true;
} finally {
if (session != null) {
session.close();
}
}
Map usrRs = usrLst.get(0);
USRINR.set((String) usrRs.get("INR"));
session.close();
return true;
}
public static IModuleRoot getModuleRoot(IContext ctx, String trnName) throws Exception {
......
......@@ -15,6 +15,7 @@ import org.sss.presentation.noui.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
public class NoUiContextManager {
......@@ -55,6 +56,7 @@ public class NoUiContextManager {
noUiContext.setGui(new NoUiPresentation(noUiContext, noUiRequest));
noUiContext.setSession(session);
noUiContext.setNoUiRequest(noUiRequest);
noUiContext.setLocale(Locale.getDefault());
log.debug("Build context finished");
return noUiContext;
}
......
......@@ -281,7 +281,7 @@ public abstract class AbstractCommonController {
continue;
}
if (modifyEntry.getKey() == null) {
log.error("错误的modifymap:" + noUiRequest.getMappingUrl() + "--" + modifyMap);
log.error("modifymap中存在键为空的元素:" + noUiRequest.getMappingUrl());
continue;
}
if (aliasPath.startsWith(modifyEntry.getKey())) {
......
......@@ -14,38 +14,37 @@ import java.util.List;
public class NoUiApiInitListener implements ServletContextListener {
protected static final Log log = LogFactory.getLog(NoUiApiInitListener.class);
private static final String DATABASE_SUPPORT_TYPE = "DbSupportType";
private static final String NOUI_TIMEOUT = "nouiTimeout";
private static final String LOGIN_CONTEXT_NAME = "loginContextName";
private static final String OPEN_PREFIX = "openPrefix";
private static final String OPEN_TRANS = "openTrans";
private static final int ENDLESS_TIME = 5*24*60*60;
@Override
public void contextDestroyed(ServletContextEvent arg0) {
}
@Override
public void contextInitialized(ServletContextEvent contextEvent) {
ServletContext context = contextEvent.getServletContext();
String dbType = context.getInitParameter(DATABASE_SUPPORT_TYPE);
NoUiContextManager.dbType = dbType;
NoUiContextManager.loginContextName = context.getInitParameter(LOGIN_CONTEXT_NAME);
String openSource = context.getInitParameter(OPEN_PREFIX);
if(openSource!=null)
NoUiContextManager.openSourcePrefix = openSource;
String trans = context.getInitParameter(OPEN_TRANS);
if(!StringUtils.isEmpty(trans))
{
List<String> openTrans = Arrays.asList(trans.split(","));
NoUiContextManager.openTransactions.addAll( openTrans);
log.debug("开放的交易:"+trans+";"+openTrans);
}
}
protected static final Log log = LogFactory.getLog(NoUiApiInitListener.class);
private static final String DATABASE_SUPPORT_TYPE = "DbSupportType";
private static final String NOUI_TIMEOUT = "nouiTimeout";
private static final String LOGIN_CONTEXT_NAME = "loginContextName";
private static final String OPEN_PREFIX = "openPrefix";
private static final String OPEN_TRANS = "openTrans";
private static final int ENDLESS_TIME = 5 * 24 * 60 * 60;
@Override
public void contextDestroyed(ServletContextEvent arg0) {
}
@Override
public void contextInitialized(ServletContextEvent contextEvent) {
ServletContext context = contextEvent.getServletContext();
String dbType = context.getInitParameter(DATABASE_SUPPORT_TYPE);
NoUiContextManager.dbType = dbType;
NoUiContextManager.loginContextName = context.getInitParameter(LOGIN_CONTEXT_NAME);
String openSource = context.getInitParameter(OPEN_PREFIX);
if (openSource != null)
NoUiContextManager.openSourcePrefix = openSource;
String trans = context.getInitParameter(OPEN_TRANS);
if (!StringUtils.isEmpty(trans)) {
List<String> openTrans = Arrays.asList(trans.split(","));
NoUiContextManager.openTransactions.addAll(openTrans);
log.debug("开放" + openTrans.size() + "个交易:" + trans);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment