Xpage待阅sql修改,由原来的底层自动打开sql链接并关闭sql连接,修改为每一个cmd共用一个数据库连接,最后使用完成后再进行关闭sql链接
This commit is contained in:
parent
0cb5f11514
commit
8ed48a806c
@ -1,5 +1,6 @@
|
||||
package com.awspaas.user.apps.docview;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashSet;
|
||||
@ -34,16 +35,17 @@ public class DocumentsToReadController {
|
||||
/**
|
||||
* xpage待阅
|
||||
*
|
||||
* @param isIphone
|
||||
* @param
|
||||
* @param sid
|
||||
* @param processType
|
||||
* @param departmentId
|
||||
* @param uuid
|
||||
* @param
|
||||
* @param
|
||||
* @param
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
@Mapping("com.yili.apps.pal.read_page")
|
||||
public String getView(String sid, String viewType) throws ParseException {
|
||||
Connection open = DBSql.open();
|
||||
UserContext uc = UserContext.fromSessionId(sid);
|
||||
String uid = uc.getUID();
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
@ -57,48 +59,48 @@ public class DocumentsToReadController {
|
||||
String fileId = bo.getString("ID");
|
||||
String isFullCompany = bo.getString("ISFULLCOMPANY");
|
||||
if ("1".equals(isFullCompany)||"admin".equals(uid)) {
|
||||
setArrayWfc(fileId, jsonArray, uid);
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
//三个都不为空
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm)&& UtilString.isNotEmpty(levelPerm)) {
|
||||
if ((getOrgPerm(orgPerm, uc) && getLevelPerm(levelPerm, uc))|| getPostPerm(postPerm, uc) ) {
|
||||
setArrayWfc(fileId, jsonArray, uid);
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm)
|
||||
&& UtilString.isEmpty(levelPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc) || getPostPerm(postPerm, uc)) {
|
||||
setArrayWfc(fileId, jsonArray, uid);
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 岗位为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(postPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc) && getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfc(fileId, jsonArray, uid);
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 组织为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isNotEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc) || getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfc(fileId, jsonArray, uid);
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 组织、岗位为空时
|
||||
} else if (UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(postPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfc(fileId, jsonArray, uid);
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 组织、职级为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc)) {
|
||||
setArrayWfc(fileId, jsonArray, uid);
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
|
||||
}
|
||||
// 岗位、职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(postPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc)) {
|
||||
setArrayWfc(fileId, jsonArray, uid);
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,20 +112,21 @@ public class DocumentsToReadController {
|
||||
if ("2".equals(viewType)) {
|
||||
html = "index_sub.html";
|
||||
}
|
||||
DBSql.close(open);
|
||||
return HtmlPageTemplate.merge("com.awspaas.user.apps.docview", html, map);
|
||||
}
|
||||
private void setArrayWfc(String fileId,JSONArray jsonArray,String uid) {
|
||||
private void setArrayWfc(String fileId,JSONArray jsonArray,String uid,Connection open) {
|
||||
String sqlAll = "SELECT FILEID,FILENAME,FILEURL,FILECREATEDATE FROM BO_EU_PAL_DOC_VIEW WHERE ID = '"+fileId+"'";
|
||||
List<RowMap> map1 = DBSql.getMaps(sqlAll);
|
||||
List<RowMap> map1 = DBSql.getMaps(open,sqlAll);
|
||||
if (map1.size()!=0) {
|
||||
getWFC(jsonArray, map1, uid);
|
||||
getWFC(jsonArray, map1, uid,open);
|
||||
}
|
||||
}
|
||||
private void setArrayWfh(String fileId,JSONArray jsonArray,String uid) {
|
||||
private void setArrayWfh(String fileId,JSONArray jsonArray,String uid,Connection open) {
|
||||
String sqlAll = "SELECT FILEID,FILENAME,FILEURL,FILECREATEDATE FROM BO_EU_PAL_DOC_VIEW WHERE ID = '"+fileId+"'";
|
||||
List<RowMap> map1 = DBSql.getMaps(sqlAll);
|
||||
List<RowMap> map1 = DBSql.getMaps(open,sqlAll);
|
||||
if (map1.size()!=0) {
|
||||
getWFH(jsonArray, map1, uid);
|
||||
getWFH(jsonArray, map1, uid,open);
|
||||
}
|
||||
}
|
||||
//组织权限
|
||||
@ -225,11 +228,11 @@ public class DocumentsToReadController {
|
||||
}
|
||||
|
||||
// 获取待阅
|
||||
public JSONArray getWFC(JSONArray jsonArray, List<RowMap> maps, String uid) {
|
||||
public JSONArray getWFC(JSONArray jsonArray, List<RowMap> maps, String uid,Connection open) {
|
||||
for (RowMap rowMap : maps) {
|
||||
String id = rowMap.getString("FILEID");
|
||||
String sqlt = "SELECT ID FROM BO_EU_PAL_RECORD WHERE FILEID = ? AND READFILENAME =?";
|
||||
RowMap mapt = DBSql.getMap(sqlt, new Object[] { id, uid });
|
||||
RowMap mapt = DBSql.getMap(open,sqlt, new Object[] { id, uid });
|
||||
if (mapt == null) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String fileName = rowMap.getString("FILENAME");
|
||||
@ -251,15 +254,16 @@ public class DocumentsToReadController {
|
||||
/**
|
||||
* xpage已阅
|
||||
*
|
||||
* @param isIphone
|
||||
* @param
|
||||
* @param sid
|
||||
* @param processType
|
||||
* @param departmentId
|
||||
* @param uuid
|
||||
* @param
|
||||
* @param
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.yili.apps.pal.read_page_y")
|
||||
public String getYyView(String sid, String viewType) {
|
||||
Connection open = DBSql.open();
|
||||
UserContext uc = UserContext.fromSessionId(sid);
|
||||
String uid = uc.getUID();
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
@ -273,47 +277,47 @@ public class DocumentsToReadController {
|
||||
String fileId = bo.getString("ID");
|
||||
String isFullCompany = bo.getString("ISFULLCOMPANY");
|
||||
if ("1".equals(isFullCompany)||"admin".equals(uid)) {
|
||||
setArrayWfh(fileId, jsonArray, uid);
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm)
|
||||
&& UtilString.isNotEmpty(levelPerm)) {
|
||||
if ((getOrgPerm(orgPerm, uc) || getPostPerm(postPerm, uc)) && getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfh(fileId, jsonArray, uid);
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm)&& UtilString.isEmpty(levelPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc) || getPostPerm(postPerm, uc)) {
|
||||
setArrayWfh(fileId, jsonArray, uid);
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 岗位为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(postPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc) && getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfh(fileId, jsonArray, uid);
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 组织为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isNotEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc) && getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfh(fileId, jsonArray, uid);
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 组织、岗位为空时
|
||||
} else if (UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(postPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfh(fileId, jsonArray, uid);
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 组织、职级为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc)) {
|
||||
setArrayWfh(fileId, jsonArray, uid);
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
|
||||
}
|
||||
// 岗位、职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(postPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc)) {
|
||||
setArrayWfh(fileId, jsonArray, uid);
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -325,6 +329,7 @@ public class DocumentsToReadController {
|
||||
if ("2".equals(viewType)) {
|
||||
html = "index_sub_y.html";
|
||||
}
|
||||
DBSql.close(open);
|
||||
return HtmlPageTemplate.merge("com.awspaas.user.apps.docview", html, map);
|
||||
}
|
||||
|
||||
@ -351,13 +356,13 @@ public class DocumentsToReadController {
|
||||
|
||||
}
|
||||
// 获取已阅
|
||||
public JSONArray getWFH(JSONArray jsonArray, List<RowMap> maps, String uid) {
|
||||
public JSONArray getWFH(JSONArray jsonArray, List<RowMap> maps, String uid,Connection open) {
|
||||
|
||||
for (RowMap rowMap : maps) {
|
||||
try {
|
||||
String id = rowMap.getString("FILEID");
|
||||
String sqlt = "SELECT ID FROM BO_EU_PAL_RECORD WHERE FILEID = ? AND READFILENAME =?";
|
||||
RowMap mapt = DBSql.getMap(sqlt, new Object[] { id, uid });
|
||||
RowMap mapt = DBSql.getMap(open,sqlt, new Object[] { id, uid });
|
||||
if (mapt != null) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String fileName = rowMap.getString("FILENAME");
|
||||
@ -383,8 +388,8 @@ public class DocumentsToReadController {
|
||||
* 记录阅读时间
|
||||
*
|
||||
* @param sid
|
||||
* @param fileName
|
||||
* @param id
|
||||
* @param
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user