Operation.jsp
7.56 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
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="net.sf.json.JSONObject"%>
<%@ page import="java.util.*" %>
<%@ page import="weaver.general.*"%>
<%@ page import="weaver.hrm.UserManager"%>
<%@ page import="weaver.hrm.User"%>
<%@ page import="org.apache.commons.lang.StringUtils"%>
<%@ page import="org.jsoup.Jsoup"%>
<%@ page import="weaver.conn.RecordSet"%>
<%@ page import="weaver.mobile.plugin.ecology.service.DocumentService"%>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rci" class="weaver.hrm.resource.ResourceComInfo" scope="page"/>
<jsp:useBean id="cici" class="weaver.crm.Maint.CustomerInfoComInfo" scope="page"/>
<jsp:useBean id="sptmForDoc" class="weaver.splitepage.transform.SptmForDoc" scope="page"/>
<jsp:useBean id="formatter" class="weaver.mobile.HtmlToPlainText" scope="page"/>
<%!
private String getDocTypeByDocId(String docid,String docextendname,String doccontent){
BaseBean baseBean = new BaseBean();
String doctype=docextendname;
try {
if((!"".equals(docextendname))&&(!"html".equals(docextendname))){
return doctype;
}
//html编辑框有内容则返回html
int tmppos = doccontent.indexOf("!@#$%^&*");
if(tmppos!=-1){
doccontent = doccontent.substring(tmppos+8,doccontent.length());
}
//替换HTML标签
String strDoccontent=Util.replace(doccontent,"<[^>]*>","",0);
//替换空字符串
strDoccontent=Util.replace(strDoccontent," ","",0);
//替换换行
strDoccontent=Util.replace(strDoccontent,"\r\n","",0);
//替换空格
strDoccontent=Util.replace(strDoccontent," ","",0);
if("initFlashVideo();".equals(strDoccontent)||"".equals(strDoccontent)){
int fileNum=0;
RecordSet rs = new RecordSet();
rs.executeSql("select count(distinct id) as fileNum from DocImageFile where docid="+docid);
if(rs.next()){
fileNum=Util.getIntValue(rs.getString("fileNum"));
}
if(fileNum==1){
rs.executeSql("select imageFileName from DocImageFile where docid="+docid+" order by imageFileId desc");
if(rs.next()){
String imageFileName=Util.null2String(rs.getString("imageFileName"));
if(imageFileName.lastIndexOf(".")>=0){
if(!(imageFileName.endsWith("."))){
doctype=imageFileName.substring(imageFileName.lastIndexOf(".")+1);
}
}
}
}
}else{
return doctype;
}
}catch (Exception e) {
baseBean.writeLog(e);
}
return doctype;
}
/**
* @param extendName - 文件扩展名
* @return 根据扩展名返回相应文件类型的图标路径
*
* 根据扩展名返回相应文件类型的图标路径
*
*/
public static String getIconPathByExtendName(String extendName) {
String returnValue="universal_icon_wev8.png";
RecordSet rs = new RecordSet();
rs.executeSql("select iconPath from workflow_filetypeicon where extendName='"+extendName.toLowerCase()+"'");
if (rs.next())
returnValue=rs.getString(1);
return returnValue;
}
%>
<%
try{
out.clear();
int _userid = Util.getIntValue(request.getParameter("userid"));
UserManager userManager = new UserManager();
User user = userManager.getUserByUserIdAndLoginType(_userid, "1");
String operation = Util.null2String(request.getParameter("operation"));
String sql = "";
StringBuffer restr = new StringBuffer();
//获取列表数据
List<Map<String, String>> imglist = new ArrayList<Map<String, String>>();
String querysql = (String)request.getSession().getAttribute("DOC_LIST_SQL");
String orderby = Util.null2String((String)request.getSession().getAttribute("DOC_LIST_SQL_ORDERBY")).trim();
int module = Util.getIntValue(request.getParameter("module"));
int columnid = Util.getIntValue(request.getParameter("columnid"));
int currentpage = Util.getIntValue(request.getParameter("currentpage"),0);
int pagesize = Util.getIntValue(request.getParameter("pagesize"),0);
int total = Util.getIntValue(request.getParameter("total"),0);
int iNextNum = currentpage * pagesize;
if(rs.getDBType().equals("oracle")){
sql = "select rownum rownum_,t1.* from(" + querysql + " "+orderby+" nulls last) t1 ";
sql = "select * from ("+sql+") t12 where rownum_ > " + (iNextNum - pagesize) + " and rownum_ <= " + iNextNum;
}else{
sql = "select ROW_NUMBER() OVER ("+orderby+") AS rownum_,* from (" + querysql + ") t1 ";
sql = "select * from (" + sql + ") t12 where rownum_> " + (iNextNum - pagesize) + " and rownum_ <= " + iNextNum;
}
rs.executeSql(sql);
restr.append("{\"totalSize\":"+total+",\"datas\":[");
int _index = 0;
while(rs.next()){
_index++;
Map<String, String> doc = new HashMap<String, String>();
String docid = rs.getString("id");
doc.put("docid", docid);
String docsubject_tmp = rs.getString("docsubject");
docsubject_tmp = docsubject_tmp.replaceAll("\n", "");// TD11607
doc.put("docsubject",docsubject_tmp);
String ownerid = rs.getString("ownerid");
String owner = rs.getInt("ownerType") == 1 ? rci.getResourcename(ownerid) : cici.getCustomerInfoname(ownerid);
doc.put("ownerid", ownerid);
doc.put("owner", owner);
doc.put("ownermobile", rci.getMobile(ownerid));
doc.put("ownerloginid", rci.getLoginID(ownerid));
doc.put("doccreatedate", rs.getString("doccreatedate")+" "+rs.getString("doccreatetime"));
sql = "select count(0) as c from DocDetail t where t.id="+docid+" and t.doccreaterid<>"+user.getUID()+" and not exists (select 1 from docReadTag where userid="+user.getUID()+" and docid=t.id)";
rs1.execute(sql);
if(rs1.next()&&rs1.getInt("c")>0) {
doc.put("isnew", "1");
} else {
doc.put("isnew", "0");
}
String doccontent = Util.null2String(rs.getString("doccontent"));
String docextendname=Util.null2String(rs.getString("docextendname"));
String doctype=getDocTypeByDocId(docid,docextendname,doccontent);
doc.put("doctype", doctype);
String iconpath = getIconPathByExtendName(doctype);
doc.put("iconpath",iconpath);
if(module == 2) {
String docimg = "";
sql = "select i.imagefileid from docimagefile di,imagefile i where di.imagefileid=i.imagefileid and di.docid="+docid+" and di.docfiletype='1' order by i.imagefileid";
rs1.execute(sql);
if(rs1.next()) {
docimg = rs1.getString("imagefileid");
}
doc.put("docimg", docimg);
String summary = "";
if(StringUtils.isNotBlank(doccontent)) {
int tmppos = doccontent.indexOf("!@#$%^&*");
if(tmppos!=-1){
summary = doccontent.substring(0,tmppos);
} else {
summary = formatter.getPlainText(Jsoup.parse(doccontent));
summary = StringUtils.replace(summary, "\n", "");
}
summary = (summary.length()) > 100 ? summary.substring(0, 100) : summary;
}
doc.put("summary", summary);
if(currentpage == 1 && Util.getIntValue(docimg) > 0 && imglist.size() < 5) {
Map<String, String> img = new HashMap<String, String>();
img.put("docimg", docimg);
img.put("docid", docid);
img.put("docsubject", docsubject_tmp);
imglist.add(img);
}
} else {
if(columnid == DocumentService.COLUMN_MINE) {
int docstatus = rs.getInt("docstatus");
doc.put("docstatusid", ""+docstatus);
int seccategory = rs.getInt("seccategory");
String docstatusname = sptmForDoc.getDocStatus3(docid, ""+user.getLanguage()+"+"+docstatus+"+"+seccategory);
doc.put("docstatus", docstatusname);
}
}
doc.put("showtype","0");
JSONObject jsonObject = JSONObject.fromObject(doc);
if(_index>1){
restr.append(",");
}
restr.append(jsonObject.toString());
}
restr.append("]}");
out.print(restr.toString());
}catch(Exception e){
out.print("error: "+e.toString());
}
out.flush();
out.close();
%>