推送待阅代码优化
This commit is contained in:
parent
1c63df09b7
commit
898056f454
@ -1,8 +1,10 @@
|
||||
package com.awspaas.user.apps.docview;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@ -21,88 +23,95 @@ import com.actionsoft.bpms.server.bind.annotation.Mapping;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author lihy
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class DocumentsToReadController {
|
||||
|
||||
/**
|
||||
* xpage待阅
|
||||
*
|
||||
* @param
|
||||
* 获取待阅
|
||||
* @param sid
|
||||
* @param
|
||||
* @param
|
||||
* @param
|
||||
* @param viewType
|
||||
* @return
|
||||
* @throws ParseException
|
||||
* @throws SQLException
|
||||
*/
|
||||
@Mapping("com.yili.apps.pal.read_page")
|
||||
public String getView(String sid, String viewType) throws ParseException {
|
||||
Connection open = DBSql.open();
|
||||
public String getView(String sid, String viewType) throws ParseException, SQLException {
|
||||
System.err.println("加载待阅文件开始===>");
|
||||
Connection conn = DBSql.open();
|
||||
Date startTime = new Date();
|
||||
UserContext uc = UserContext.fromSessionId(sid);
|
||||
String uid = uc.getUID();
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
List<BO> list = SDK.getBOAPI().query("BO_EU_PAL_DOC_VIEW").list();
|
||||
for (BO bo : list) {
|
||||
String orgPerm = bo.getString("READINGSCOPE_ORG");
|
||||
String postPerm = bo.getString("READINGSCOPE_POST");
|
||||
String levelPerm = bo.getString("READINGSCOPE_LEVEL");
|
||||
String fileId = bo.getString("ID");
|
||||
String isFullCompany = bo.getString("ISFULLCOMPANY");
|
||||
if ("1".equals(isFullCompany)||"admin".equals(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,open);
|
||||
}
|
||||
// 职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm)
|
||||
&& UtilString.isEmpty(levelPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc) || getPostPerm(postPerm, uc)) {
|
||||
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,open);
|
||||
}
|
||||
// 组织为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isNotEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc) || getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 组织、岗位为空时
|
||||
} else if (UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(postPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 组织、职级为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc)) {
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
try {
|
||||
List<BO> list = SDK.getBOAPI().query("BO_EU_PAL_DOC_VIEW").list();
|
||||
for (BO bo : list) {
|
||||
String orgPerm = bo.getString("READINGSCOPE_ORG");
|
||||
String postPerm = bo.getString("READINGSCOPE_POST");
|
||||
String levelPerm = bo.getString("READINGSCOPE_LEVEL");
|
||||
//String fileId = bo.getString("ID");
|
||||
String isFullCompany = bo.getString("ISFULLCOMPANY");
|
||||
if ("1".equals(isFullCompany) || "admin".equals(uid)) {
|
||||
setArrayWfc(bo, conn, jsonArray, uid);
|
||||
// 三个都不为空
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm)
|
||||
&& UtilString.isNotEmpty(levelPerm)) {
|
||||
if ((getOrgPerm(orgPerm, uc) && getLevelPerm(levelPerm, uc)) || getPostPerm(postPerm, uc)) {
|
||||
setArrayWfc(bo, conn, jsonArray, uid);
|
||||
}
|
||||
// 职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm)
|
||||
&& UtilString.isEmpty(levelPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc) || getPostPerm(postPerm, uc)) {
|
||||
setArrayWfc(bo, conn, jsonArray, uid);
|
||||
}
|
||||
// 岗位为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(postPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc) && getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfc(bo, conn, jsonArray, uid);
|
||||
}
|
||||
// 组织为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isNotEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc) || getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfc(bo, conn, jsonArray, uid);
|
||||
}
|
||||
// 组织、岗位为空时
|
||||
} else if (UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(postPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfc(bo, conn, jsonArray, uid);
|
||||
}
|
||||
// 组织、职级为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc)) {
|
||||
setArrayWfc(bo,conn, jsonArray, uid);
|
||||
|
||||
}
|
||||
// 岗位、职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(postPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc)) {
|
||||
setArrayWfc(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 岗位、职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(postPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc)) {
|
||||
setArrayWfc(bo,conn,jsonArray, uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}finally {
|
||||
conn.close();
|
||||
|
||||
}
|
||||
|
||||
map.put("jsonArray", jsonArray);
|
||||
@ -112,216 +121,90 @@ public class DocumentsToReadController {
|
||||
if ("2".equals(viewType)) {
|
||||
html = "index_sub.html";
|
||||
}
|
||||
DBSql.close(open);
|
||||
Date endTime = new Date();
|
||||
long timeDifference = endTime.getTime() - startTime.getTime();
|
||||
System.err.println("加载待阅文件用时===>" + timeDifference);
|
||||
return HtmlPageTemplate.merge("com.awspaas.user.apps.docview", html, map);
|
||||
}
|
||||
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(open,sqlAll);
|
||||
if (map1.size()!=0) {
|
||||
getWFC(jsonArray, map1, uid,open);
|
||||
}
|
||||
}
|
||||
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(open,sqlAll);
|
||||
if (map1.size()!=0) {
|
||||
getWFH(jsonArray, map1, uid,open);
|
||||
}
|
||||
}
|
||||
//组织权限
|
||||
private boolean getOrgPerm(String orgPerm,UserContext uc) {
|
||||
if (UtilString.isNotEmpty(orgPerm)) {
|
||||
// 兼职
|
||||
Set<String> deptIdSet = new HashSet<>();
|
||||
String [] deptIds = orgPerm.split(",");
|
||||
for (int i = 0; i < deptIds.length; i++) {
|
||||
if (UtilString.isNotEmpty(deptIds[i])) {
|
||||
String deptId = deptIds[i];
|
||||
deptIdSet.add(deptId);
|
||||
queryChildDeptList(deptId, deptIdSet);
|
||||
}
|
||||
}
|
||||
// 判断用户的所属部门
|
||||
String currUserDeptId = uc.getDepartmentModel().getId();
|
||||
if (deptIdSet.contains(currUserDeptId)) {
|
||||
return true;
|
||||
}
|
||||
// 判断用户的兼职部门
|
||||
List<UserMapModel> userMapModels = UserMapCache.getMapListOfUser(uc.getUID());
|
||||
for (UserMapModel mapModel : userMapModels) {
|
||||
if (deptIdSet.contains(mapModel.getDepartmentId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
//岗位权限
|
||||
private boolean getPostPerm(String postPerm,UserContext uc) {
|
||||
if (UtilString.isNotEmpty(postPerm)) {
|
||||
String positionNo = uc.getUserModel().getPositionNo();
|
||||
String [] positionIds = postPerm.split(",");
|
||||
Set<String> positionIdSet = new HashSet<>();
|
||||
for (int i = 0; i < positionIds.length; i++) {
|
||||
positionIdSet.add(positionIds[i]);
|
||||
}
|
||||
if (positionIdSet.contains(positionNo)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
//职级权限
|
||||
private boolean getLevelPerm(String levelPerm,UserContext uc) {
|
||||
if (UtilString.isNotEmpty(levelPerm)) {
|
||||
String userLevelPerm = uc.getUserModel().getExt2();
|
||||
String[] levelPermspArray = levelPerm.split(",");
|
||||
Set<String> levelPermspSet = new HashSet<>();
|
||||
for (int i = 0; i < levelPermspArray.length; i++) {
|
||||
levelPermspSet.add(levelPermspArray[i]);
|
||||
}
|
||||
if(levelPermspSet.contains(userLevelPerm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void queryChildDeptList(String pid, Set<String> deptIdSet) {
|
||||
List<DepartmentModel> list = SDK.getORGAPI().getSubDepartments(pid);
|
||||
if (list != null && list.size() > 0) {
|
||||
for (DepartmentModel child : list) {
|
||||
deptIdSet.add(child.getId());
|
||||
queryChildDeptList(child.getId(), deptIdSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 获取待阅
|
||||
public JSONArray getWFC_bak(JSONArray jsonArray, List<RowMap> maps, String uid) {
|
||||
for (RowMap rowMap : maps) {
|
||||
String id = rowMap.getString("FILEID");
|
||||
String fileName = rowMap.getString("FILENAME");
|
||||
System.err.println("=======uid========>"+uid);
|
||||
System.err.println("=======fileName========>"+fileName);
|
||||
String read = DBSql.getString("SELECT ID FROM BO_ACT_DATAID WHERE READSTATE = '未读' AND TITLE LIKE '%"+fileName+"%' AND USER_ID = ?",new Object[] {uid});
|
||||
System.err.println("===========read=========="+read);
|
||||
if(UtilString.isNotEmpty(read)) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String fileUrl = rowMap.getString("FILEURL");
|
||||
String fileCreateDate = rowMap.getString("FILECREATEDATE");
|
||||
jsonObject.put("fileName", fileName);
|
||||
jsonObject.put("id", id);
|
||||
jsonObject.put("fileUrl", fileUrl);
|
||||
jsonObject.put("uid", uid);
|
||||
jsonObject.put("fileCreateDate", fileCreateDate);
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
return jsonArray;
|
||||
|
||||
}
|
||||
|
||||
// 获取待阅
|
||||
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(open,sqlt, new Object[] { id, uid });
|
||||
if (mapt == null) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String fileName = rowMap.getString("FILENAME");
|
||||
String fileUrl = rowMap.getString("FILEURL");
|
||||
String fileCreateDate = rowMap.getString("FILECREATEDATE");
|
||||
jsonObject.put("fileName", fileName);
|
||||
jsonObject.put("id", id);
|
||||
jsonObject.put("fileUrl", fileUrl);
|
||||
jsonObject.put("uid", uid);
|
||||
jsonObject.put("fileCreateDate", fileCreateDate);
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
return jsonArray;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* xpage已阅
|
||||
*
|
||||
* @param
|
||||
* 获取已阅
|
||||
* @param sid
|
||||
* @param
|
||||
* @param
|
||||
* @param
|
||||
* @param viewType
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
@Mapping("com.yili.apps.pal.read_page_y")
|
||||
public String getYyView(String sid, String viewType) {
|
||||
Connection open = DBSql.open();
|
||||
public String getYyView(String sid, String viewType) throws SQLException {
|
||||
System.err.println("加载已阅文件开始===>");
|
||||
Connection conn = DBSql.open();
|
||||
Date startTime = new Date();
|
||||
UserContext uc = UserContext.fromSessionId(sid);
|
||||
String uid = uc.getUID();
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
List<BO> list = SDK.getBOAPI().query("BO_EU_PAL_DOC_VIEW").list();
|
||||
for (BO bo : list) {
|
||||
String orgPerm = bo.getString("READINGSCOPE_ORG");
|
||||
String postPerm = bo.getString("READINGSCOPE_POST");
|
||||
String levelPerm = bo.getString("READINGSCOPE_LEVEL");
|
||||
String fileId = bo.getString("ID");
|
||||
String isFullCompany = bo.getString("ISFULLCOMPANY");
|
||||
if ("1".equals(isFullCompany)||"admin".equals(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,open);
|
||||
}
|
||||
// 职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm)&& UtilString.isEmpty(levelPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc) || getPostPerm(postPerm, uc)) {
|
||||
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,open);
|
||||
}
|
||||
// 组织为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isNotEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc) && getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 组织、岗位为空时
|
||||
} else if (UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(postPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 组织、职级为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc)) {
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
try {
|
||||
List<BO> list = SDK.getBOAPI().query("BO_EU_PAL_DOC_VIEW").list();
|
||||
for (BO bo : list) {
|
||||
String orgPerm = bo.getString("READINGSCOPE_ORG");
|
||||
String postPerm = bo.getString("READINGSCOPE_POST");
|
||||
String levelPerm = bo.getString("READINGSCOPE_LEVEL");
|
||||
//String fileId = bo.getString("ID");
|
||||
String isFullCompany = bo.getString("ISFULLCOMPANY");
|
||||
if ("1".equals(isFullCompany) || "admin".equals(uid)) {
|
||||
setArrayWfh(bo, conn, jsonArray, uid);
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm)
|
||||
&& UtilString.isNotEmpty(levelPerm)) {
|
||||
if ((getOrgPerm(orgPerm, uc) || getPostPerm(postPerm, uc)) && getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfh(bo, conn, jsonArray, uid);
|
||||
}
|
||||
// 职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(postPerm)
|
||||
&& UtilString.isEmpty(levelPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc) || getPostPerm(postPerm, uc)) {
|
||||
setArrayWfh(bo, conn, jsonArray, uid);
|
||||
}
|
||||
// 岗位为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isNotEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(postPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc) && getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfh(bo, conn, jsonArray, uid);
|
||||
}
|
||||
// 组织为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isNotEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc) && getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfh(bo, conn, jsonArray, uid);
|
||||
}
|
||||
// 组织、岗位为空时
|
||||
} else if (UtilString.isNotEmpty(levelPerm) && UtilString.isEmpty(postPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getLevelPerm(levelPerm, uc)) {
|
||||
setArrayWfh(bo, conn, jsonArray, uid);
|
||||
}
|
||||
// 组织、职级为空时
|
||||
} else if (UtilString.isNotEmpty(postPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(orgPerm)) {
|
||||
if (getPostPerm(postPerm, uc)) {
|
||||
setArrayWfh(bo, conn, jsonArray, uid);
|
||||
|
||||
}
|
||||
// 岗位、职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(postPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc)) {
|
||||
setArrayWfh(fileId, jsonArray, uid,open);
|
||||
}
|
||||
// 岗位、职级为空时
|
||||
} else if (UtilString.isNotEmpty(orgPerm) && UtilString.isEmpty(levelPerm)
|
||||
&& UtilString.isEmpty(postPerm)) {
|
||||
if (getOrgPerm(orgPerm, uc)) {
|
||||
setArrayWfh(bo, conn, jsonArray, uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}finally {
|
||||
conn.close();
|
||||
}
|
||||
|
||||
|
||||
map.put("jsonArray", jsonArray);
|
||||
map.put("sid", sid);
|
||||
map.put("portalUrl", portalUrl);
|
||||
@ -329,78 +212,31 @@ public class DocumentsToReadController {
|
||||
if ("2".equals(viewType)) {
|
||||
html = "index_sub_y.html";
|
||||
}
|
||||
DBSql.close(open);
|
||||
|
||||
Date endTime = new Date();
|
||||
long timeDifference = endTime.getTime() - startTime.getTime();
|
||||
System.err.println("加载已阅文件用时===>" + timeDifference);
|
||||
return HtmlPageTemplate.merge("com.awspaas.user.apps.docview", html, map);
|
||||
}
|
||||
|
||||
// 获取已阅
|
||||
public JSONArray getWFH_bak(JSONArray jsonArray, List<RowMap> maps, String uid) {
|
||||
for (RowMap rowMap : maps) {
|
||||
String id = rowMap.getString("FILEID");
|
||||
String fileName = rowMap.getString("FILENAME");
|
||||
RowMap map = DBSql.getMap("SELECT ID FROM BO_ACT_DATAID WHERE READSTATE = '已读' AND TITLE LIKE '%"+fileName+"%' AND USER_ID = '"+uid+"'");
|
||||
if(map!=null) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String fileUrl = rowMap.getString("FILEURL");
|
||||
String fileCreateDate = rowMap.getString("FILECREATEDATE");
|
||||
jsonObject.put("fileName", fileName);
|
||||
jsonObject.put("id", id);
|
||||
jsonObject.put("fileUrl", fileUrl);
|
||||
jsonObject.put("uid", uid);
|
||||
jsonObject.put("fileCreateDate", fileCreateDate);
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
return jsonArray;
|
||||
|
||||
}
|
||||
// 获取已阅
|
||||
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(open,sqlt, new Object[] { id, uid });
|
||||
if (mapt != null) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String fileName = rowMap.getString("FILENAME");
|
||||
String fileUrl = rowMap.getString("FILEURL");
|
||||
String fileCreateDate = rowMap.getString("FILECREATEDATE");
|
||||
jsonObject.put("fileName", fileName);
|
||||
jsonObject.put("id", id);
|
||||
jsonObject.put("fileUrl", fileUrl);
|
||||
jsonObject.put("uid", uid);
|
||||
jsonObject.put("fileCreateDate", fileCreateDate);
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
}
|
||||
|
||||
return jsonArray;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录阅读时间
|
||||
*
|
||||
*
|
||||
* @param sid
|
||||
* @param
|
||||
* @param
|
||||
* @param fileName
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Mapping("com.yili.apps.pal.read_page_record")
|
||||
public String setRecord(String sid, String params) {
|
||||
System.err.println("记录文件阅读开始===>");
|
||||
Date startTime = new Date();
|
||||
String[] split = params.split(",");
|
||||
String id = split[0];
|
||||
String fileName = split[1];
|
||||
String uid = UserContext.fromSessionId(sid).getUID();
|
||||
System.err.println("阅读文件===========》"+uid);
|
||||
String sql = "SELECT READFILECOUNT FROM BO_EU_PAL_RECORD WHERE FILEID = ? AND READFILENAME = ?";
|
||||
System.err.println("阅读文件===========》" + uid);
|
||||
String sql = "SELECT * FROM BO_EU_PAL_RECORD WHERE FILEID = ? AND READFILENAME = ?";
|
||||
RowMap map = DBSql.getMap(sql, new Object[] { id, uid });
|
||||
int num = 0;
|
||||
if (null != map) {
|
||||
@ -417,7 +253,140 @@ public class DocumentsToReadController {
|
||||
bo.set("READFILECOUNT", "1");
|
||||
num = SDK.getBOAPI().createDataBO("BO_EU_PAL_RECORD", bo, UserContext.fromSessionId(sid));
|
||||
}
|
||||
|
||||
Date endTime = new Date();
|
||||
long timeDifference = endTime.getTime() - startTime.getTime();
|
||||
System.err.println("记录文件阅读用时===>" + timeDifference);
|
||||
return num + "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断时候是待阅文件
|
||||
*
|
||||
* @param bo
|
||||
* @param fileId
|
||||
* @param jsonArray
|
||||
* @param uid
|
||||
*/
|
||||
private void setArrayWfc(BO bo,Connection conn, JSONArray jsonArray, String uid) {
|
||||
String id = bo.getString("FILEID");
|
||||
String sqlt = "SELECT COUNT(*) AS COUNT FROM BO_EU_PAL_RECORD WHERE FILEID = ? AND READFILENAME =?";
|
||||
String count = DBSql.getString(conn,sqlt, new Object[] { id, uid });
|
||||
if ("0".equals(count)) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String fileName = bo.getString("FILENAME");
|
||||
String fileUrl = bo.getString("FILEURL");
|
||||
String fileCreateDate = bo.getString("FILECREATEDATE");
|
||||
jsonObject.put("fileName", fileName);
|
||||
jsonObject.put("id", id);
|
||||
jsonObject.put("fileUrl", fileUrl);
|
||||
jsonObject.put("uid", uid);
|
||||
jsonObject.put("fileCreateDate", fileCreateDate);
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断时候是已阅文件
|
||||
*
|
||||
* @param bo
|
||||
* @param fileId
|
||||
* @param jsonArray
|
||||
* @param uid
|
||||
*/
|
||||
private void setArrayWfh(BO bo, Connection conn, JSONArray jsonArray, String uid) {
|
||||
String id = bo.getString("FILEID");
|
||||
String sqlt = "SELECT COUNT(*) AS COUNT FROM BO_EU_PAL_RECORD WHERE FILEID = ? AND READFILENAME =?";
|
||||
String count = DBSql.getString(conn,sqlt, new Object[] { id, uid });
|
||||
if (!"0".equals(count)) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String fileName = bo.getString("FILENAME");
|
||||
String fileUrl = bo.getString("FILEURL");
|
||||
String fileCreateDate = bo.getString("FILECREATEDATE");
|
||||
jsonObject.put("fileName", fileName);
|
||||
jsonObject.put("id", id);
|
||||
jsonObject.put("fileUrl", fileUrl);
|
||||
jsonObject.put("uid", uid);
|
||||
jsonObject.put("fileCreateDate", fileCreateDate);
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组织权限
|
||||
*
|
||||
* @param orgPerm
|
||||
* @param uc
|
||||
* @return
|
||||
*/
|
||||
private boolean getOrgPerm(String orgPerm, UserContext uc) {
|
||||
if (UtilString.isNotEmpty(orgPerm)) {
|
||||
// 兼职
|
||||
Set<String> deptIdSet = new HashSet<>();
|
||||
String[] deptIds = orgPerm.split(",");
|
||||
for (int i = 0; i < deptIds.length; i++) {
|
||||
if (UtilString.isNotEmpty(deptIds[i])) {
|
||||
String deptId = deptIds[i];
|
||||
deptIdSet.add(deptId);
|
||||
queryChildDeptList(deptId, deptIdSet);
|
||||
}
|
||||
}
|
||||
// 判断用户的所属部门
|
||||
String currUserDeptId = uc.getDepartmentModel().getId();
|
||||
if (deptIdSet.contains(currUserDeptId)) {
|
||||
return true;
|
||||
}
|
||||
// 判断用户的兼职部门
|
||||
List<UserMapModel> userMapModels = UserMapCache.getMapListOfUser(uc.getUID());
|
||||
for (UserMapModel mapModel : userMapModels) {
|
||||
if (deptIdSet.contains(mapModel.getDepartmentId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 岗位权限
|
||||
private boolean getPostPerm(String postPerm, UserContext uc) {
|
||||
if (UtilString.isNotEmpty(postPerm)) {
|
||||
String positionNo = uc.getUserModel().getPositionNo();
|
||||
String[] positionIds = postPerm.split(",");
|
||||
Set<String> positionIdSet = new HashSet<>();
|
||||
for (int i = 0; i < positionIds.length; i++) {
|
||||
positionIdSet.add(positionIds[i]);
|
||||
}
|
||||
if (positionIdSet.contains(positionNo)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// 职级权限
|
||||
private boolean getLevelPerm(String levelPerm, UserContext uc) {
|
||||
if (UtilString.isNotEmpty(levelPerm)) {
|
||||
String userLevelPerm = uc.getUserModel().getExt2();
|
||||
String[] levelPermspArray = levelPerm.split(",");
|
||||
Set<String> levelPermspSet = new HashSet<>();
|
||||
for (int i = 0; i < levelPermspArray.length; i++) {
|
||||
levelPermspSet.add(levelPermspArray[i]);
|
||||
}
|
||||
if (levelPermspSet.contains(userLevelPerm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void queryChildDeptList(String pid, Set<String> deptIdSet) {
|
||||
List<DepartmentModel> list = SDK.getORGAPI().getSubDepartments(pid);
|
||||
if (list != null && list.size() > 0) {
|
||||
for (DepartmentModel child : list) {
|
||||
deptIdSet.add(child.getId());
|
||||
queryChildDeptList(child.getId(), deptIdSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user