prjservice.jsp
6.3 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
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.*" %>
<%@ page import="weaver.hrm.*" %>
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.regex.*" %>
<%
String opt = request.getParameter("opt");
int prjid = Util.getIntValue(request.getParameter("prjid"));
//User user = HrmUserVarify.getUser (request , response) ;
int userid = Util.getIntValue(request.getParameter("userid"));
UserManager userManager = new UserManager();
User user = userManager.getUserByUserIdAndLoginType(userid, "1");
ResourceComInfo rci = new ResourceComInfo();
RecordSet rs = new RecordSet();
String sql = "";
if("getRemindByPrj".equals(opt)){
String lastTime = "2001-01-01 00:00:00";
int countNewDaily = 0;
int countNewDailyReply = 0;
//某用户最后一次访问该项目的时间
sql = "select top 1 opdate+' '+optime as lastTime from proj_visitInfo where cbi_id="+prjid+" and uid="+userid+" order by opdate desc, optime desc";
rs.executeSql(sql);
if(rs.next()){
lastTime = rs.getString("lastTime");
}
//该项目新日报数量
sql = "select count(id) as c from proj_dailyCommunication a where cbie_id="+prjid+" and (opdate+' '+optime)>'"+lastTime+"'";
rs.executeSql(sql);
if(rs.next()){
countNewDaily = Util.getIntValue(rs.getString("c"), 0);
}
//该项目新日报回复数量
sql = "select count(id) as c from uf_proj_dailyreply a where prjid="+prjid+" and (opdate+' '+optime2)>'"+lastTime+"'";
rs.executeSql(sql);
if(rs.next()){
countNewDailyReply = Util.getIntValue(rs.getString("c"), 0);
}
out.print(countNewDaily + countNewDailyReply);
}else if("getDailyReplies".equals(opt)){
response.setContentType("text/plain");
String callbackFunName = request.getParameter("callbackparam");
int dailyid = Util.getIntValue(request.getParameter("dailyid"));
int replyid = 0;
String opusername = "";
String opdate = "";
String optime = "";
String opcontent = "";
String htmlReply = callbackFunName + "({htmlReply:\"";
sql = "select id, opuser, opdate, optime2, opcontent from uf_proj_dailyreply where dailyid="+dailyid+" order by opdate desc, optime2 desc";
rs.executeSql(sql);
while(rs.next()){
opdate = Util.null2String(rs.getString("opdate"));
optime = Util.null2String(rs.getString("optime2"));
if(optime.length()>=8){
optime = optime.substring(0,5);
}
opcontent = Util.null2String(rs.getString("opcontent"));
opusername = rci.getLastname(Util.null2String(rs.getString("opuser")));
htmlReply += "<div class='divReply'><div class='divReplyCreator'>"+opusername+" "+opdate+" "+optime+"</div><div class='divReplyContent'>"+delHTMLTag(opcontent)+"</div></div>";
}
htmlReply += "\"})";
out.print(htmlReply);
}else if("getMyDailyReplies".equals(opt)){
int beginNum = Util.getIntValue(request.getParameter("beginNum"), 1);
int pageNum = Util.getIntValue(request.getParameter("pageNum"), 1);
beginNum = (beginNum - 1) * pageNum + 1;
int total = 0;
StringBuffer sbJSON = new StringBuffer("");
int replyid = 0;
String opusername = "";
String opdate = "";
String optime = "";
String _opYear = "";
String _opDay = "";
String opcontent = "";
sql = "select b.projname, a.opuser, a.opdate, a.optime2, a.opcontent from uf_proj_dailyreply a left join proj_CardBaseInfo b on a.prjid=b.id where a.dailycreator="+userid+" order by a.opdate desc, a.optime2 desc";
rs.executeSql(sql);
total = rs.getCounts();
sbJSON.append("{\"totalSize\":\""+total+"\", \"datas\":[");
sql = "select * from (";
sql+= "select ROW_NUMBER() OVER(order by a.opdate desc, a.optime2 desc, a.id desc) as rownum, b.projname, a.prjid, a.opuser, a.opdate, a.optime2, a.opcontent ";
sql+= "from uf_proj_dailyreply a ";
sql+= "left join proj_CardBaseInfo b on a.prjid=b.id where a.dailycreator="+userid+") as t ";
sql+= "where rownum between "+beginNum+" and "+(beginNum+pageNum-1)+" ";
//out.println(sql);
rs.executeSql(sql);
while(rs.next()){
opdate = Util.null2String(rs.getString("opdate"));
if(opdate.length()>=10){
_opYear = opdate.substring(0,4);
_opDay = opdate.substring(5,10);
}
optime = Util.null2String(rs.getString("optime2"));
if(optime.length()>=8){
optime = optime.substring(0,5);
}
opcontent = Util.null2String(rs.getString("opcontent"));
opusername = rci.getLastname(Util.null2String(rs.getString("opuser")));
sbJSON.append("{\"prjid\":\""+rs.getString("prjid")+"\", \"projname\":\""+rs.getString("projname")+"\", \"opuser\":\""+opusername+"\", \"opyear\":\""+_opYear+"\", \"opday\":\""+_opDay+"\", \"opdate\":\""+opdate+"\", \"optime\":\""+optime+"\", \"opcontent\":\""+delHTMLTag(opcontent)+"\"},");
}
String strJSON = sbJSON.toString();
if(strJSON.endsWith(",")){
strJSON = strJSON.substring(0, strJSON.length()-1);
}
strJSON += "]}";
out.println(strJSON);
}else if("setVisitInfo".equals(opt)){
sql = "insert into proj_visitInfo (cbi_id, uid, opDate, opTime) values ("+prjid+", "+userid+", '"+TimeUtil.getCurrentDateString()+"', '"+TimeUtil.getOnlyCurrentTimeString()+"')";
rs.executeSql(sql);
}else if("setMsgInfo".equals(opt)){
sql = "insert into uf_proj_msg (mtype, userid, lastdate, lasttime) values (1, "+userid+", '"+TimeUtil.getCurrentDateString()+"', '"+TimeUtil.getOnlyCurrentTimeString()+"')";
//out.print(sql);
rs.executeSql(sql);
}
%>
<%!
String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
String delHTMLTag(String htmlStr) {
Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE);
Matcher m_script = p_script.matcher(htmlStr);
htmlStr = m_script.replaceAll(""); // 过滤script标签
Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE);
Matcher m_style = p_style.matcher(htmlStr);
htmlStr = m_style.replaceAll(""); // 过滤style标签
Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
Matcher m_html = p_html.matcher(htmlStr);
htmlStr = m_html.replaceAll(""); // 过滤html标签
htmlStr = htmlStr.replaceAll("\r\n", "");
htmlStr = htmlStr.replaceAll("[\\t\\n\\r]", "");
return htmlStr.trim(); // 返回文本字符串
}
%>