DocSearchMenu.jsp
9.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.*,weaver.systeminfo.SystemEnv" %>
<%@ page import="java.util.*,net.sf.json.*" %>
<%@ page import="weaver.docs.category.*" %>
<%@ page import="weaver.docs.category.security.*" %>
<%@ page import="weaver.hrm.*" %>
<%@ page import="weaver.systeminfo.setting.HrmUserSettingComInfo" %>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page"/>
<%
User user = HrmUserVarify.getUser (request , response) ;
HrmUserSettingComInfo userSetting=new HrmUserSettingComInfo();
String belongtoshow = userSetting.getBelongtoshowByUserId(user.getUID()+"");
String belongtoids = user.getBelongtoids();
String account_type = user.getAccount_type();
String subcompanyId = Util.null2String(request.getParameter("subCompanyId"));
String categoryname = Util.null2String(request.getParameter("categoryname"));
String url = Util.null2String(request.getParameter("url"));
String urlType = Util.null2String(request.getParameter("urlType"));
String offical = Util.null2String(request.getParameter("offical"));
int officalType = Util.getIntValue(request.getParameter("officalType"),-1);
String doccreatedateselect = Util.null2String(request.getParameter("doccreatedateselect"));
String searchType = Util.null2String(request.getParameter("searchType"));
Map<String,Object> params = new HashMap<String,Object>();
int operationcode = Util.getIntValue(request.getParameter("operationcode"),-1);
String onlyCount = Util.null2String(request.getParameter("onlyCount"));
JSONArray jsonArr = new JSONArray();
params.put("_url",url);
params.put("urlType",urlType);
params.put("offical",offical);
params.put("officalType",officalType);
params.put("doccreatedateselect",doccreatedateselect);
MultiAclManager am = new MultiAclManager();
if(operationcode==-1){
String whereclause = "";
String sql = "";
String docstatus = "'1','2','5'";
if(searchType.equals("1")){
docstatus = "";
}
String logintype = user.getLogintype();
String owner=Util.null2String(request.getParameter("owner"));
String departmentid=Util.null2String(request.getParameter("departmentid"));
String fromdate=Util.fromScreen(request.getParameter("fromdate"),user.getLanguage());
String todate=Util.fromScreen(request.getParameter("todate"),user.getLanguage());
String dspreply = Util.null2String(request.getParameter("dspreply"));
String doccreaterid = Util.null2String(request.getParameter("doccreaterid"));
String publishtype=Util.fromScreen(request.getParameter("publishtype"),user.getLanguage());
if(!doccreatedateselect.equals("") && !doccreatedateselect.equals("0")){
fromdate = TimeUtil.getDateByOption(doccreatedateselect,"0");
todate = TimeUtil.getDateByOption(doccreatedateselect,"1");
}
if(searchType.equals("1")){
doccreaterid = ""+user.getUID();
}
%>
<%@ include file="/docs/common.jsp" %>
<%
if(!doccreaterid.equals("")&&!doccreaterid.equals("0")){
if(belongtoshow.equals("1")&&account_type.equals("0")&&!belongtoids.equals("")){
whereclause+=" and doccreaterid in("+belongtoids+")";
}else{
whereclause+=" and doccreaterid="+doccreaterid;
}
}
if(!owner.equals("")){
if(belongtoshow.equals("1")&&account_type.equals("0")&&!belongtoids.equals("")){
whereclause+=" and ownerid in ("+belongtoids+")";
}else{
whereclause+=" and ownerid="+owner;
}
}
if(!departmentid.equals("")){
whereclause+=" and docdepartmentid="+departmentid;
}
if(!fromdate.equals("")){
whereclause+=" and doccreatedate>='"+fromdate+"'";
}
if(!todate.equals("")){
whereclause+=" and doccreatedate<='"+todate+"'";
}
if(!publishtype.equals("")){
whereclause+=" and docpublishtype='"+publishtype+"'";
}
if(searchType.equals("0")){
if(belongtoshow.equals("1")&&account_type.equals("0")&&!belongtoids.equals("")){
belongtoids+=","+user.getUID();
whereclause+=" and t1.id not in (select docid from docReadTag where userid in("
+ belongtoids + ") and usertype=" + logintype + ") and t1.doccreaterid not in ( "+belongtoids+")";
}else{
whereclause+=" and t1.id not in (select docid from docReadTag where userid="
+ user.getUID() + " and usertype=" + logintype + ") and t1.doccreaterid <> "+user.getUID();
}
}
/* added by wdl 2006-08-28 不显示历史版本 */
whereclause+=" and (ishistory is null or ishistory = 0) ";
/* added end */
Map<String,Integer> secAllCountMap = new HashMap<String,Integer>();
Map<String,Integer> secNewCountMap = new HashMap<String,Integer>();
if(logintype.equals("1")){ //内部用户的处理
if(belongtoshow.equals("1")&&account_type.equals("0")&&!belongtoids.equals("")){
sql = "select count(t1.id) count,t1.seccategory from DocDetail t1, "+tables+" t2 where ((docstatus = 7 and (sharelevel>1 or (doccreaterid in("+belongtoids+") or ownerid in ("+belongtoids+") ))) or ";
}else{
sql = "select count(t1.id) count,t1.seccategory from DocDetail t1, "+tables+" t2 where ((docstatus = 7 and (sharelevel>1 or (doccreaterid="+user.getUID()+" or ownerid="+user.getUID()+"))) or ";
}
if(searchType.equals("1")){
sql += "docstatus !=8 and docstatus!=9) and t1.id=t2.sourceid ";
}else{
sql += "docstatus in ("+docstatus+")) and t1.id=t2.sourceid ";
}
sql+=whereclause;
if(dspreply.equals("1")){
sql+= " and (t1.isreply is null or t1.isreply='' or t1.isreply=0)";
}else if(dspreply.equals("2")){
sql+= " and t1.isreply=1";
}
sql+=" group by t1.seccategory order by t1.seccategory ";
//System.out.println("total Count start------"+new Date().getTime());
RecordSet.executeSql(sql);
while(RecordSet.next()){
if(onlyCount.equals("1")){
JSONObject json = new JSONObject();
json.put("__domid__",MultiAclManager.PREFIX+RecordSet.getString("seccategory"));
JSONObject numbers = new JSONObject();
numbers.put("docAll",Util.getIntValue(RecordSet.getString("count"),0));
numbers.put("docNew",Util.getIntValue(RecordSet.getString("count"),0));
json.put("numbers",numbers);
jsonArr.add(json);
}
secAllCountMap.put(MultiAclManager.PREFIX+RecordSet.getString("seccategory"),Util.getIntValue(RecordSet.getString("count"),0));
// 将未读的总数初始化为开始的总数
secNewCountMap.put(MultiAclManager.PREFIX+RecordSet.getString("seccategory"),Util.getIntValue(RecordSet.getString("count"),0));
}
//System.out.println("total Count end------"+new Date().getTime());
//刘煜改为总的目录 看过的文章
sql="select count(t1.id) count,t1.seccategory from ";
sql += tables+" t2, ";
sql = sql + " DocDetail t1 ";
sql += " where ((docstatus = 7 ";
if(!urlType.equals("11")){
sql += "and (sharelevel>1 or (doccreaterid="+user.getUID()+" or ownerid="+user.getUID()+"))";
}
sql += ") or ";
if(searchType.equals("1")){
sql += "docstatus!=8 and docstatus!=9)";
}else{
sql+= "docstatus in ("+docstatus+"))";
}
sql+= " and t1.id=t2.sourceid";
if(dspreply.equals("1")){
sql+= " and (t1.isreply is null or t1.isreply='' or t1.isreply=0)";
}else if(dspreply.equals("2")){
sql+= " and t1.isreply=1";
}
//sql+=" and (t1.id in( select docid from docReadTag where userid=1 and usertype=1 ) or t1.doccreaterid=1 and t1.usertype=1)";
if(belongtoshow.equals("1")&&account_type.equals("0")&&!belongtoids.equals("")){
belongtoids+=","+user.getUID();
sql+=" and (t1.id in( select docid from docReadTag where userid in("+belongtoids+") and usertype=1 ) or (t1.doccreaterid in("+belongtoids+") and t1.usertype=1))";
}else{
sql+=" and (t1.id in( select docid from docReadTag where userid="+user.getUID()+" and usertype=1 ) or (t1.doccreaterid="+user.getUID()+" and t1.usertype=1))";
}
sql+=whereclause;
sql+=" group by t1.seccategory order by t1.seccategory ";
//System.out.println("new Count start------"+new Date().getTime());
RecordSet.executeSql(sql);
while(RecordSet.next()){
String tempsecid = Util.null2String( RecordSet.getString("seccategory") ) ;
int secidhasread = Util.getIntValue( RecordSet.getString("count") , 0 ) ;
int secallcount = 0;
try{
secallcount = secAllCountMap.get(MultiAclManager.PREFIX+tempsecid) ;
}catch(Exception e){
e.printStackTrace();
continue;
}
int secidhasnotread = secallcount - secidhasread ;
if(secidhasnotread < 0) secidhasnotread = 0 ;
if(onlyCount.equals("1")){
for(int i=0;i<jsonArr.size();i++){
JSONObject json = jsonArr.getJSONObject(i);
String domid = json.getString("__domid__");
if(domid.equals(MultiAclManager.PREFIX+tempsecid)){
JSONObject numbers = json.getJSONObject("numbers");
numbers.put("docNew",secidhasnotread);
break;
}
}
}
secNewCountMap.put(MultiAclManager.PREFIX+tempsecid,secidhasnotread);
}
}
params.put("dspreply",dspreply);
params.put("logintype",logintype);
params.put("secAllCountMap",secAllCountMap);
params.put("secNewCountMap",secNewCountMap);
//params.put("whereclause",whereclause);
params.put("addDiyDom","true");
}
if(onlyCount.equals("1")){
out.println(jsonArr.toString());
}else{
MultiCategoryTree tree = am.getPermittedTree(user.getUID(), user.getType(), Util.getIntValue(user.getSeclevel(),0), operationcode,categoryname,Util.getIntValue(subcompanyId,-1),params);
out.println(tree.getTreeCategories().toString());
}
%>