Commit 6d498c6d by WeiCong

1.优化日志记录

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