DocSubscribeOperate.jsp
16.5 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.*" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.docs.docSubscribe.*" %>
<%@ page import="java.util.*" %>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<%@ include file="/docs/common.jsp" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="DocComInfo" class="weaver.docs.docs.DocComInfo" scope="page" />
<jsp:useBean id="SysRemindWorkflow" class="weaver.system.SysRemindWorkflow" scope="page" />
<jsp:useBean id="ResourceComInfo" class="weaver.hrm.resource.ResourceComInfo" scope="page"/>
<jsp:useBean id="UserDefaultManager" class="weaver.docs.tools.UserDefaultManager" scope="session" />
<jsp:useBean id="DocViewer" class="weaver.docs.docs.DocViewer" scope="page"/>
<jsp:useBean id="SptmForDoc" class="weaver.splitepage.transform.SptmForDoc" scope="page"/>
<%
char flag = 2 ;
String ProcPara = "";
int docIdsLength = 0 ;
String isdialog = Util.null2String(request.getParameter("isdialog"));
String operation = Util.null2String(request.getParameter("operation"));
String subscribeIds = Util.null2String(request.getParameter("subscribeIds"));
String docIds = Util.null2String(request.getParameter("docIds"));
Calendar today = Calendar.getInstance();
String currentData = Util.add0(today.get(Calendar.YEAR), 4) +"-"+
Util.add0(today.get(Calendar.MONTH) + 1, 2) +"-"+
Util.add0(today.get(Calendar.DAY_OF_MONTH), 2) ;
if (operation.equals("add")){ //来自文档订阅页面
String[] subscribeDocIds = request.getParameterValues("docids");
if (subscribeDocIds != null) docIdsLength = subscribeDocIds.length;
String searchCase = request.getParameter("searchCase");
String subscribeDesc = Util.fromScreen(request.getParameter("subscribeDesc"),7);
String state = "1"; //订阅状态 1.已申请,2.已批准3.已收回
int hrmId = user.getUID();
String subscribetype = user.getLogintype();
for (int i=0 ;i<docIdsLength;i++){
String docId = subscribeDocIds[i];
String owenerId = DocComInfo.getDocOwnerid(docId);
String owenerType= DocComInfo.getUsertype(docId);
ProcPara = docId ;
ProcPara += flag + ""+hrmId ;
ProcPara += flag + owenerId ;
ProcPara += flag + currentData ;
ProcPara += flag + "" ;
ProcPara += flag + searchCase ;
ProcPara += flag + subscribeDesc ;
ProcPara += flag + "" ;
ProcPara += flag + "" ;
ProcPara += flag + state ;
ProcPara += flag + subscribetype ;
ProcPara += flag + owenerType ;
//out.println(ProcPara+"<br>");
rs.executeProc("DocSubscribe_Insert",ProcPara);
String requestname=SptmForDoc.getName1(""+user.getUID(),user.getLogintype())+SystemEnv.getHtmlLabelName(83636,user.getLanguage())+" "+DocComInfo.getDocname(docId);
String remark=SystemEnv.getHtmlLabelName(83638,user.getLanguage())+" <a target=_blank href=/docs/docsubscribe/DocSubscribeApprove.jsp>"+SystemEnv.getHtmlLabelName(142,user.getLanguage())+"</a>";
SysRemindWorkflow.setDocSysRemind(requestname,0,user.getUID(),owenerId,remark);
}
//response.sendRedirect("/docs/search/DocCommonContent.jsp?urlType=7&ishow=false");
if(isdialog.equals("1")){
response.sendRedirect("/docs/docsubscribe/DocSubscribeAdd.jsp?isclose=1&isdialog=1");
}else{
response.sendRedirect("/docs/search/DocMain.jsp?urlType=6&ishow=false");
}
} else if (operation.equals("approve")){
ArrayList idList = Util.TokenizerString(subscribeIds,",");
ArrayList docidList = Util.TokenizerString(docIds,",");
String subScribeDescStr = "" ;
for (int i=0 ;i<idList.size();i++){
String id = (String)idList.get(i);
String docId = (String)docidList.get(i);
String otherSubscribe = Util.null2String(request.getParameter("otherDocId_"+id));
//修改subscribe表
String updateSql = "update DocSubscribe set state = '2' ,otherSubscribe = '"+otherSubscribe+"',approveDate='"+currentData+"' where id = "+id;
// out.println(updateSql);
rs.executeSql(updateSql);
//得到订阅者的id以及订阅者的type
String subscribeHrmId = "";
String subscribetype = "";
rs.executeSql("select hrmid,subscribetype from DocSubscribe where id ="+id);
if (rs.next()){
subscribeHrmId = Util.null2String(rs.getString("hrmid"));
subscribetype= Util.null2String(rs.getString("subscribetype")); //1:内部 2:外部
}
//修改共享表
if ("1".equals(subscribetype)){
ProcPara = docId;
ProcPara += flag+"1";
ProcPara += flag+"10";
ProcPara += flag+"0";
ProcPara += flag+"1";
ProcPara += flag+subscribeHrmId;
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0" ;
} else {
ProcPara = docId;
ProcPara += flag+"9";
ProcPara += flag+"10";
ProcPara += flag+"0";
ProcPara += flag+"1";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+subscribeHrmId ;
}
rs.executeProc("DocShare_IFromDocSecCategory",ProcPara);
DocViewer.setDocShareByDoc(docId);
subScribeDescStr+="<a target=_blank href=/docs/docs/DocDsp.jsp?id="+docId+"> "+DocComInfo.getDocname(docId)+" </a> ";
String otherSubscribeDocNames ="";
if (!"".equals(otherSubscribe)){
String[] tempStr = Util.TokenizerString2(otherSubscribe,",");
for (int j=0;j<tempStr.length;j++){
String docId2 = tempStr[j];
//修改共享表
if ("1".equals(subscribetype)){
ProcPara = docId2;
ProcPara += flag+"1";
ProcPara += flag+"10";
ProcPara += flag+"0";
ProcPara += flag+"1";
ProcPara += flag+subscribeHrmId;
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0" ;
} else {
ProcPara = docId2;
ProcPara += flag+"9";
ProcPara += flag+"10";
ProcPara += flag+"0";
ProcPara += flag+"1";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+"0";
ProcPara += flag+subscribeHrmId ;
}
rs.executeProc("DocShare_IFromDocSecCategory",ProcPara);
DocViewer.setDocShareByDoc(docId2);
otherSubscribeDocNames += " <a target=_blank href=/docs/docs/DocDsp.jsp?id="+docId2+"> "+DocComInfo.getDocname(docId2)+" </a> ";
}
}
//发送流程
String requestname=SystemEnv.getHtmlLabelName(30041,user.getLanguage())+" "+DocComInfo.getDocname(docId)+SystemEnv.getHtmlLabelName(83424,user.getLanguage());
String remark=SystemEnv.getHtmlLabelName(32485,user.getLanguage())+" <a target=_blank href=/docs/docs/DocDsp.jsp?id="+docId+">"+DocComInfo.getDocname(docId)+"</a> "+SystemEnv.getHtmlLabelName(83426,user.getLanguage())+SptmForDoc.getName1(""+user.getUID(),user.getLogintype())+SystemEnv.getHtmlLabelName(142,user.getLanguage())+"! ";
if (!"".equals(otherSubscribeDocNames)) remark += SystemEnv.getHtmlLabelName(83427,user.getLanguage())+otherSubscribeDocNames+SystemEnv.getHtmlLabelName(83428,user.getLanguage());
remark += SystemEnv.getHtmlLabelName(83429,user.getLanguage());
if ("1".equals(subscribetype)){
SysRemindWorkflow.setDocSysRemind(requestname,0,user.getUID(),subscribeHrmId,remark);
} else {
//外部用户目前没有默认提醒
}
}
response.sendRedirect("/docs/search/DocCommonContent.jsp?urlType=8&ishow=false");
}else if (operation.equals("reject")){
String subScribeDescStr = "" ;
ArrayList idList = Util.TokenizerString(subscribeIds,",");
ArrayList docidList = Util.TokenizerString(docIds,",");
for (int i=0 ;i<idList.size();i++){
String id = (String)idList.get(i);
String docId = (String)docidList.get(i);
//得到订阅者的id
String subscribeHrmId = "";
String subscribetype = "";
rs.executeSql("select hrmid,subscribetype from DocSubscribe where id ="+id);
if (rs.next()){
subscribeHrmId = Util.null2String(rs.getString("hrmid"));
subscribetype= Util.null2String(rs.getString("subscribetype")); //1:内部 2:外部
}
//修改共享表
if ("1".equals(subscribetype)){
rs.executeSql("delete from docshare where docid ="+docId+" and userid ="+subscribeHrmId +" and sharetype=1");
} else {
rs.executeSql("delete from docshare where docid ="+docId+" and crmid ="+subscribeHrmId +" and sharetype=1");
}
DocViewer.setDocShareByDoc(docId);
//发送流程
String docName = DocComInfo.getDocname(docId);
String requestname=SystemEnv.getHtmlLabelName(25452,user.getLanguage())+" <<"+docName+">> "+SystemEnv.getHtmlLabelName(83430,user.getLanguage());
String remark=SystemEnv.getHtmlLabelName(83431,user.getLanguage())+" <"+docName+"> "+SystemEnv.getHtmlLabelName(83426,user.getLanguage())+SptmForDoc.getName1(""+user.getUID(),user.getLogintype())+SystemEnv.getHtmlLabelName(25659,user.getLanguage())+"! ";
if ("1".equals(subscribetype)){
SysRemindWorkflow.setDocSysRemind(requestname,0,user.getUID(),subscribeHrmId,remark);
} else {
//外部用户目前没有默认提醒
}
//修改subscribe表
String updateSql = "delete from DocSubscribe where id = "+id;
// out.println(updateSql);
rs.executeSql(updateSql);
}
response.sendRedirect("/docs/search/DocCommonContent.jsp?urlType=8&ishow=false");
} else if (operation.equals("getback")){ //文档收回部分
ArrayList idList = Util.TokenizerString(subscribeIds,",");
for (int i=0 ;i<idList.size();i++){
String id = (String)idList.get(i);
String docId = "0";
String subscribeHrmId = "0";
String otherSubscribe="";
String subscribetype="";
String docids="";
rs.executeSql("select hrmid,docid,otherSubscribe,subscribetype from docsubscribe where id ="+id);
if (rs.next()){
docId = Util.null2String(rs.getString("docid"));
subscribeHrmId = Util.null2String(rs.getString("hrmid"));
otherSubscribe=Util.null2String(rs.getString("otherSubscribe"));
subscribetype= Util.null2String(rs.getString("subscribetype")); //1:内部 2:外部
docids=getAllVersions(docId,rs);
}
//修改subscribe表
rs.executeSql("update docsubscribe set state ='3' where id ="+id);
//删除相关docshare记录
String deleteShareSql = "";
if ("1".equals(subscribetype)){
deleteShareSql = "delete from DocShare where docid in("+docids+") and userid="+subscribeHrmId +" and sharelevel=1 and (sharesource='' or sharesource is null)";
} else {
deleteShareSql = "delete from DocShare where docid in("+docids+") and crmid="+subscribeHrmId +" and sharelevel=1 and (sharesource='' or sharesource is null)";
}
rs.executeSql(deleteShareSql);
//删除相关docsharedetail记录
String deleteShareDetailSql="";
if ("1".equals(subscribetype)){
deleteShareDetailSql="delete from ShareinnerDoc where sharelevel=1 and sharesource=0 and type=1 and sourceid in("+docids+") and content="+subscribeHrmId;
} else {
deleteShareDetailSql="delete from ShareouterDoc where type=9 and sharelevel=1 and sharesource=0 and docid in("+docids+") and content="+subscribeHrmId;
}
rs.executeSql(deleteShareDetailSql);
if (!"".equals(otherSubscribe)){
String[] tempStrs = Util.TokenizerString2(otherSubscribe,",");
for (int j=0 ;j<tempStrs.length;j++){
String tempDocid = tempStrs[j];
if(null==tempDocid||"".equals(tempDocid)) continue;
docids=getAllVersions(tempDocid,rs);
//删除相关docshare记录
if ("1".equals(subscribetype)){
deleteShareSql = "delete from DocShare where docid in("+docids+") and userid="+subscribeHrmId +" and sharelevel=1 and (sharesource='' or sharesource is null)";
} else {
deleteShareSql = "delete from DocShare where docid in("+docids+") and crmid="+subscribeHrmId +" and sharelevel=1 and (sharesource='' or sharesource is null)";
}
rs.executeSql(deleteShareSql);
//删除相关docsharedetail记录
if ("1".equals(subscribetype)){
deleteShareDetailSql="delete from ShareinnerDoc where sourceid in("+docids+") and content="+subscribeHrmId +" and sharelevel=1 and type=1 and sharesource=0";
} else {
deleteShareDetailSql="delete from ShareouterDoc where sourceid in("+docids+") and content="+subscribeHrmId +" and sharelevel=1 and type=9 and sharesource=0";
}
rs.executeSql(deleteShareDetailSql);
}
}
}
response.sendRedirect("/docs/search/DocCommonContent.jsp?urlType=9&ishow=false");
}
%>
<%!
private String getAllVersions(String docid,RecordSet rs) throws Exception{
if(null==rs) rs=new RecordSet();
int doceditionid=-1;
rs.executeSql("select doceditionid from docdetail where id="+docid);
if(rs.next()) {
doceditionid=rs.getInt(1);
}
//如果有版本控制,取出该版本下的所有文档id
String docids = "" + docid;
if(doceditionid>-1){
docids = "";
rs.executeSql(" select id from DocDetail where doceditionid = " + doceditionid);
while(rs.next()){
docids+=","+rs.getString("id");
}
}
docids = docids.startsWith(",")?docids.substring(1):docids;
return docids;
}
%>