count.jsp
2.81 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
<%@ page language="java" contentType="application/json" pageEncoding="UTF-8"%>
<%@page import="net.sf.json.*"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/maint/common/initNoCache.jsp" %>
<%@ page import="weaver.general.*" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="ps" class="weaver.mobile.plugin.ecology.service.PluginServiceImpl" scope="page" />
<%
response.setContentType("application/json;charset=UTF-8");
String module = Util.null2String(request.getParameter("module"));
String scope = Util.null2String(request.getParameter("scope"));
String sessionkey = Util.null2String(request.getParameter("sessionkey"));
if(ps.verify(sessionkey)) {
String countSql = "select count(t1.id) as amount ";
String func1 = "";
String operatedt = "";
String createdt = "";
if("sqlserver".equals(rs.getDBType())){
func1 = "isnull";
operatedt = "max(operatedate+' '+operatetime)";
createdt = "max(createdate+' '+createtime)";
}else if("mysql".equals(rs.getDBType())){
func1 = "ifnull";
operatedt = "max(concat(operatedate,' ',operatetime))";
createdt = "max(concat(createdate,' ',createtime))";
}else{
func1 = "nvl";
operatedt = "max(CONCAT(CONCAT(operatedate,' '),operatetime))";
createdt = "max(CONCAT(CONCAT(createdate,' '),createtime))";
}
int userid = user.getUID();
String sql1 = "from TM_TaskInfo t1 where (t1.deleted=0 or t1.deleted is null) and t1.creater<>"+userid
+" and (t1.principalid = "+userid
+" or exists (select 1 from TM_TaskPartner tp where tp.taskid=t1.id and tp.partnerid="+userid+")"
//+" or exists (select 1 from TM_TaskSharer ts where ts.taskid=t1.id and ts.sharerid="+userid+")"
+")"
+" and not exists (select 1 from TM_TaskLog t2 where t2.taskid=t1.id and t2.type=0 and t2.operator="+userid+")";
String sql2 = "from TM_TaskInfo t1 where (t1.deleted=0 or t1.deleted is null)"
+" and (t1.creater = "+userid+" or t1.principalid = "+userid
+" or exists (select 1 from TM_TaskPartner tp where tp.taskid=t1.id and tp.partnerid="+userid+")"
+" or exists (select 1 from TM_TaskSharer ts where ts.taskid=t1.id and ts.sharerid="+userid+")"
+")"
+" and "+func1+"((select "+createdt+" from TM_TaskFeedback t3 where t3.taskid=t1.id and t3.hrmid<>"+userid+"),'')"
+" > "+func1+"((select "+operatedt+" from TM_TaskLog t2 where t2.taskid=t1.id and t2.type=0 and t2.operator="+userid+"),'')";
int newcount = 0;
int fbcount = 0;
rs.executeSql(countSql+sql1);
if(rs.next()){
newcount = rs.getInt(1);
}
//System.out.println("newcount======"+newcount);
rs.executeSql(countSql+sql2);
if(rs.next()){
fbcount = rs.getInt(1);
}
//System.out.println("fbcount======"+fbcount);
Map result = new HashMap();
result.put("count",0);
result.put("unread",newcount+fbcount);
JSONObject jo = JSONObject.fromObject(result);
out.println(jo);
}
%>