WFSearchTemp.jsp 90.8 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 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.sql.Timestamp" %>
<%@ page import="weaver.systeminfo.menuconfig.LeftMenuInfoHandler" %>
<%@ page import="weaver.systeminfo.menuconfig.LeftMenuInfo" %>

<%@ page import="weaver.search.*" %>
<%@ page import="weaver.workflow.workflow.*" %>
<%@ page import="weaver.conn.*" %>

<%@page import="weaver.workflow.workflow.WorkflowVersion"%>

<%@ include file="/systeminfo/init_wev8.jsp" %>
<jsp:useBean id="SearchClause" class="weaver.search.SearchClause" scope="session" />
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="WorkflowComInfo" class="weaver.workflow.workflow.WorkflowComInfo" scope="page"/>
<jsp:useBean id="requestutil" class="weaver.workflow.request.todo.RequestUtil" scope="page" />
<%!

private String null2String(String s){
	if(s==null){
		return "";
	}
	return s;
}

//add by bpf on 2013-11-13
private void sendRedirect(JspWriter out,HttpServletRequest request,HttpServletResponse response,String url){
	//viewScope表示当前查看的是什么样的流程,共有四种状态:
	//complete:归档的


	//done:已办
	//mine:我的请求
	//doing:待办
	String viewScope=request.getParameter("viewScope");
	String numberType=request.getParameter("numberType");
	viewScope=null2String(viewScope);
	numberType=null2String(numberType);
	url+="&viewScope="+viewScope+"&numberType="+numberType;
	
	String reforward=request.getParameter("reforward");
	
	try{
		if(request.getParameter("getCount")!=null && Boolean.valueOf(request.getParameter("getCount"))==true){
			out.print(getCount(request,response));
			request.getSession().setAttribute("SearchClause",request.getSession().getAttribute("orientSearchClause"));
			request.getSession().removeAttribute("orientSearchClause");
			return;
		}
		
		if(Boolean.valueOf(reforward)==true){
			request.getRequestDispatcher(url).forward(request, response);
		}else{
			Enumeration<String> e=request.getParameterNames();
			while(e.hasMoreElements()){
				String paramenterName=e.nextElement();
				String value=request.getParameter(paramenterName);
				url+="&"+paramenterName+"="+value;
			}
			
			response.sendRedirect(url);
		}
	}catch(Exception e){
		
	}
}

%>

<%
session.removeAttribute("branchid");
session.setAttribute("orientSearchClause",SearchClause);
String whereclause="";
String whereclause2 = "";
String orderclause="";
String orderclause2="";

String resourceid = Util.null2String(request.getParameter("resourceid"));
String userid = "".equals(resourceid) ? Util.null2String((String)session.getAttribute("RequestViewResource")) : resourceid ;
resourceid = userid;
boolean isoracle = (RecordSet.getDBType()).equals("oracle") ;
boolean isdb2 = (RecordSet.getDBType()).equals("db2") ;
String logintype = ""+user.getLogintype();
String offical = Util.null2String(request.getParameter("offical"));
int officalType = Util.getIntValue(request.getParameter("officalType"),-1);
int usertype = 0;

if(userid.equals("")) {
	userid = ""+user.getUID();
	if(logintype.equals("2")) usertype= 1;
}

String belongtoshow = "";				
		RecordSet.executeSql("select * from HrmUserSetting where resourceId = "+userid);
		if(RecordSet.next()){
			belongtoshow = RecordSet.getString("belongtoshow");
		}
		//QC235172,如果不是查看自己的代办,主从账号统一显示不需要判断
		if(!"".equals(resourceid) && !userid.equals(resourceid)) belongtoshow = "";
		String userIDAll = String.valueOf(userid);	
String Belongtoids =user.getBelongtoids();
int Belongtoid=0;
String[] arr2 = null;
ArrayList<String> userlist = new ArrayList();
userlist.add(userid + "");
if(!"".equals(Belongtoids)){
userIDAll = userid+","+Belongtoids;
arr2 = Belongtoids.split(",");
for(int i=0;i<arr2.length;i++){
Belongtoid = Util.getIntValue(arr2[i]);
userlist.add(Belongtoid + "");
}
}

SearchClause.resetClause();
String method=Util.null2String(request.getParameter("method"));
String overtime=Util.null2String(request.getParameter("overtime"));
String fromPDA = Util.null2String((String)session.getAttribute("loginPAD"));   //从PDA登录
String complete1=Util.null2String(request.getParameter("complete"));
String workflowidtemp=Util.null2String(request.getParameter("workflowid"));
String wftypetemp=Util.null2String(request.getParameter("wftype"));
String cdepartmentid=Util.null2String(request.getParameter("cdepartmentid"));
int date2during=Util.getIntValue(Util.null2String(request.getParameter("date2during")),0);
int viewType=Util.getIntValue(Util.null2String(request.getParameter("viewType")),0);
int isajaxfresh = Util.getIntValue(Util.null2String(request.getParameter("isajaxfresh")),-1);
int viewcondition = Util.getIntValue(request.getParameter("viewcondition"),0);
//跳转到wfserachResult后是否需要头
boolean needHeader = "true".equals(Util.null2String(request.getParameter("needHeader")));
boolean isopenofs = requestutil.getOfsSetting().getIsuse()==1;
boolean showdone = requestutil.getOfsSetting().getShowdone().equals("1");
if (fromPDA.equals("1"))
{
	sendRedirect(out,request,response,"WFSearchResultPDA.jsp?offical="+offical+"&officalType="+officalType+"&workflowid="+workflowidtemp+"&wftype="+wftypetemp+"&complete="+complete1+"&viewType="+viewType);
	return;}

if(overtime.equals("1")){
	sendRedirect(out,request,response,"WFTabForOverTime.jsp?isovertime=1"+"&viewType="+viewType+"&isFromMessage=1");
	return;
}
whereclause = " (t1.deleted=0 or t1.deleted is null)  ";
if(method.equals("viewhrm")){
	//String resourceid=Util.null2String(request.getParameter("resourceid"));
	
    if( isoracle ) {
	    whereclause+=" and (',' + TO_CHAR(t1.hrmids) + ',' LIKE '%,"+resourceid+",%') ";
    }else  if( isdb2 ) {
	    whereclause+=" and (',' + VARCHAR(t1.hrmids) + ',' LIKE '%,"+resourceid+",%') ";
	}
    else {
        whereclause+=" and (',' + CONVERT(varchar,t1.hrmids) + ',' LIKE '%,"+resourceid+",%') ";
    }

	SearchClause.setWhereClause(whereclause);
	sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&offical="+offical+"&officalType="+officalType+"&start=1"+"&viewType="+viewType);
	return;
}
String processing = "";
if(method.equals("all")){
	String complete=Util.null2String(request.getParameter("complete"));
    //System.out.println("complete= "+complete+" viewcondition="+viewcondition);
	if(complete.equals("0")){
	    
		if(viewcondition == 3){
	    	whereclause += " and (t2.isremark = '5' or (t2.isremark = '0' and isprocessed is not null ))  and (t1.currentnodetype <> '3' or  (t2.isremark in ('1', '8', '9') and t1.currentnodetype = '3'))  and (t1.deleted=0 or t1.deleted is null) and t2.islasttimes=1" ;
		}else if(viewcondition == 1 || viewcondition == 2 || viewcondition == 4){
		    whereclause += " and (((t2.isremark='0' and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7'))  or (t2.isremark = '0' and t2.isprocessed is null)) and (t1.deleted=0 or t1.deleted is null) and t2.islasttimes=1" ;
		}else{
		    whereclause += " and ((t2.isremark='0' and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7'))  and (t1.deleted=0 or t1.deleted is null) and t2.islasttimes=1" ;
		}
		//whereclause += " and (t2.isremark in('1','5','8','9','7') or (t2.isremark = '0' and (t2.isprocessed is null or (t2.isprocessed <> '2' and t2.isprocessed <> '3')))) and (t1.deleted=0 or t1.deleted is null) and t2.islasttimes=1" ;
	    
	    // 分页控件上方的控件  1:未读;2:反馈;3:超时;  	add by Dracula @2014-1-10
	    if(viewcondition == 1)
	    	whereclause += " and t2.viewtype = '0' and t2.isremark != '5' and (t1.currentnodetype <> '3' or  (t2.isremark in ('1', '8', '9') and t1.currentnodetype = '3'))  and t2.isprocessed is null ";
	    else if(viewcondition == 2)
	    	whereclause += " and t2.viewtype = '-1'";
	    //else if(viewcondition == 3)
	    //	whereclause += " and t2.isremark = '5'";
	    else if(viewcondition == 4)
	    	whereclause += " and t2.requestid in (select requestid from workflow_requestlog where logtype='s')";
	    processing = "0";	//待办

        if(isopenofs){
            if(viewcondition==0){//全部
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark='0' ";
            }else if(viewcondition==1){//未读
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark='0' and viewtype=0 ";
            }else{
                whereclause2 += " and 1=2 ";
            }
        }
	}else if(complete.equals("1")){
    //modify by xhheng @20030525 for TD1725
		whereclause += " and (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) and(t1.deleted=0 or t1.deleted is null) and t1.currentnodetype = '3'  and t2.islasttimes=1";
		processing = "1";  	//原办结,办结和已办已合并
	}else if(complete.equals("2")){
    //modify by xhheng @20030525 for TD1725
		whereclause += " and (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) and (t1.deleted=0 or t1.deleted is null) and t2.islasttimes=1";
		processing = "2";	//原已办,办结和已办已合并
		//已办/办结:
        //viewcondition=1表示未归档


        if(viewcondition == 1)
        	whereclause += " and (t2.isremark ='2' or (t2.isremark=0 and t2.takisremark =-2)) and t2.iscomplete=0 ";
        //viewcondition=2表示已归档


        else if(viewcondition == 2)
        	whereclause += " and t2.iscomplete=1 and t1.currentnodetype = 3 ";
        //viewcondition=4表示未读
        else if(viewcondition == 4)
        	whereclause += " and t2.viewtype=0  and (agentType <> '1' or agentType is null) "+WorkflowComInfo.getDateDuringSql(date2during);
        //viewcondition=3表示反馈
        else if(viewcondition == 3)
        	whereclause += " and t2.viewtype=-1 ";

        if(isopenofs&&showdone){
            if(viewcondition==0){//全部
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark in ('2','4') ";
            }else if(viewcondition==1){//未归档
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark='2' and iscomplete=0 ";
            }else if(viewcondition==2){//已归档
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark in ('2','4') and iscomplete=1";
            }else{
                whereclause2 += " and 1=2 ";
            }
        }else{
        	whereclause2 += " and 1=2 ";
        }
	}
	SearchClause.setWhereClause(whereclause);
    SearchClause.setWhereclauseOs(whereclause2);//统一待办条件
    
	if(complete.equals("0")){
        orderclause="t2.receivedate ,t2.receivetime ";
        orderclause2=orderclause;
    }else if(complete.equals("1") ||complete.equals("2")){
        //orderclause="t2.receivedate ,t2.receivetime ";
        orderclause="operatedate, operatetime ";
        orderclause2=orderclause;
    }
	SearchClause.setOrderClause(orderclause);
	SearchClause.setOrderClause2(orderclause2);
    SearchClause.setOrderclauseOs(" operatedate, operatetime ");
	if(isajaxfresh != -1)
	{
		return;
	}
	//TD10848 complete=4,表示待办黄色图标流程


	//modified by cyril on 2008-07-15 for td:8939 complete=3表示新到流程
	
	if(complete.equals("0") || complete.equals("3") || complete.equals("4")){
	 sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&viewcondition="+viewcondition+"&offical="+offical+"&officalType="+officalType+"&start=1&iswaitdo=1"+"&viewType="+viewType+"&processing="+processing);
	} else {
	  sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&viewcondition="+viewcondition+"&offical="+offical+"&officalType="+officalType+"&start=1&date2during="+date2during+"&viewType="+viewType+"&processing"+processing);
	}
	return;
}
if(method.equals("myall")){
	//String complete=Util.null2String(request.getParameter("complete"));
	
	//whereclause +=" t1.creater = "+userid+" and t1.creatertype = " + usertype;
	if("1".equals(belongtoshow)){
	whereclause +=" and t1.creater in ("+userIDAll+") and t1.creatertype = " + usertype;
	}else{
	whereclause +=" and t1.creater in ("+userid+") and t1.creatertype = " + usertype;
	}
    whereclause2 += requestutil.getSqlWhere("3",userid,"");
	if(viewcondition == 1){ //未归档
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype <> '3' and t2.islasttimes=1 ";
        whereclause2 += " and  iscomplete=0 ";
	}
	else if(viewcondition == 2){	//已归档的
		whereclause += " and (t2.isremark in('1', '2','4','5','8','9') or (t2.isremark=0 and t2.takisremark =-2)) and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype = '3'  and t2.islasttimes=1";
		whereclause2 += " and iscomplete=1 ";
	}else if(viewcondition == 0){	//未归档+已归档的总数,如果不加这个条件,有问题,可以看到t2.isremark in (2,4)
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and ((t1.currentnodetype <> '3') or (t2.isremark in('1', '2','4','5','8','9') and t1.currentnodetype = '3' )) and t2.islasttimes=1 ";
	}else if(viewcondition == 3){ //反馈
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and ((t1.currentnodetype <> '3') or (t2.isremark in('1', '2','4','5','8','9') and t1.currentnodetype = '3' )) and t2.islasttimes=1  and t2.viewtype=-1";
		whereclause2 += " and 1=2 ";
    }else if(viewcondition == 4) //未读

	{
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and ((t1.currentnodetype <> '3') or (t2.isremark in('1', '2','4','5','8','9') and t1.currentnodetype = '3' )) and t2.islasttimes=1 and t2.viewtype=0 ";
        whereclause2 += " and 1=2 ";
	}else if(viewcondition == 5) //超时
	{
		//whereclause += " and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype = '3'  and t2.isremark=5 ";
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype = '3'  and (t2.isremark=5 or (t2.isremark = '0' and isprocessed <> '1' ))  and t1.currentnodetype <> 3 ";
        whereclause2 += " and 1=2 ";
	}
	SearchClause.setWhereClause(whereclause);
    SearchClause.setWhereclauseOs(whereclause2);
	//我的请求,按照创建时间排序

    orderclause="t1.createdate, t1.createtime ";
    orderclause2=orderclause;    
    SearchClause.setOrderClause(orderclause);
    SearchClause.setOrderClause2(orderclause2);
    SearchClause.setOrderclauseOs("createdate,createtime");

    sendRedirect(out, request, response, "WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader + "&start=1&date2during=" + date2during + "&viewType=" + viewType + "&myrequest="+method);
	return;
}
if(method.equals("myreqeustbywftype")){
	String wftype=Util.null2String(request.getParameter("wftype"));
	String complete=Util.null2String(request.getParameter("complete"));
	//System.out.println(complete);
    /* edited by wdl 2006-06-14 left menu advanced menu */
    int fromAdvancedMenu = Util.getIntValue(request.getParameter("fromadvancedmenu"),0);
    String selectedContent = Util.null2String(request.getParameter("selectedContent"));
    int infoId = Util.getIntValue(request.getParameter("infoId"),0);
	whereclause2 += requestutil.getSqlWhere("3",userid,"");
    String selectedworkflow = "";
    String inSelectedWorkflowStr = "";
    if(fromAdvancedMenu==1){
	    LeftMenuInfoHandler infoHandler = new LeftMenuInfoHandler();
	    LeftMenuInfo info = infoHandler.getLeftMenuInfo(infoId);
	    if(info!=null){
	    	selectedworkflow = info.getSelectedContent();
	    }
	    if(!"".equals(selectedContent))
	    {
	    	selectedworkflow = selectedContent;
	    }
	    List selectedWorkflowIdList = Util.TokenizerString(selectedworkflow,"|");
	    for(Iterator it=selectedWorkflowIdList.iterator();it.hasNext();){
	    	String tmpstr = (String)it.next();
	    	if(tmpstr.indexOf("W")>-1)
	    		inSelectedWorkflowStr += "," + tmpstr.substring(1);
	    }
	    if(inSelectedWorkflowStr.substring(0,1).equals(",")) inSelectedWorkflowStr=inSelectedWorkflowStr.substring(1);
	    if(!whereclause.equals("")) whereclause += " and ";
	    whereclause += " t1.workflowid in (" + WorkflowVersion.getAllVersionStringByWFIDs(inSelectedWorkflowStr) + ") ";
    }
    /* edited end */    

	if(isopenofs){
        whereclause2 += " and workflowid in (select workflowid from ofs_workflow where sysid="+wftype+" and cancel=0 )";
    }
	
	if(whereclause.equals("")) {
		whereclause +=" t1.workflowid in( select id from workflow_base   where workflowtype = "+wftype+" and (isvalid='1' or isvalid='3') ) ";
	}
	else {
		whereclause +=" and t1.workflowid in( select id from workflow_base   where workflowtype = "+wftype+" and (isvalid='1' or isvalid='3')) ";
	}
		if("1".equals(belongtoshow)){
	whereclause +=" and t1.creater in ("+userIDAll+") and t1.creatertype = " + usertype;
	}else{
	whereclause +=" and t1.creater in ("+userid+") and t1.creatertype = " + usertype;
	}
	if(viewcondition == 1){	//未归档

		whereclause2 += " and iscomplete=0 ";
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype <> '3' and t2.islasttimes=1 ";
	}
	else if(viewcondition == 2){//已归档

		whereclause2 += " and iscomplete=1 ";
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype = '3'  and t2.islasttimes=1";
	}else if(viewcondition == 0)//全部
	{
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and t2.islasttimes=1 ";
	}else if(viewcondition == 3){//反馈
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and ((t1.currentnodetype <> '3') or (t2.isremark in('2','4') and t1.currentnodetype = '3' )) and t2.islasttimes=1  and t2.viewtype=-1";
		whereclause2 += " and 1=2 ";
	}else if(viewcondition == 4) //未读
	{
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and ((t1.currentnodetype <> '3') or (t2.isremark in('2','4') and t1.currentnodetype = '3' )) and t2.islasttimes=1  and t2.viewtype=0 ";
	}else if(viewcondition == 5) //超时
	{
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype = '3'  and (t2.isremark=5 or (t2.isremark = '0' and isprocessed <> '1' ))  and t1.currentnodetype <> 3 ";
		//whereclause += " and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype = '3'  and t2.isremark=5 ";
		whereclause2 += " and 1=2 ";
	}
	SearchClause.setWhereClause(whereclause);
	SearchClause.setWhereclauseOs(whereclause2);
	sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&date2during="+date2during+"&viewType="+viewType+"&myrequest="+method);
	return;
}
if(method.equals("myreqeustbywfid")){
	String workflowid=Util.null2String(request.getParameter("workflowid"));
	String complete=Util.null2String(request.getParameter("complete"));
	
	if(whereclause.equals("")) {
			if("1".equals(belongtoshow)){
	whereclause +=" and t1.creater in ("+userIDAll+") and t1.creatertype = " + usertype;
	}else{
	whereclause +=" and t1.creater in ("+userid+") and t1.creatertype = " + usertype;
	}
	}
	else {
	if("1".equals(belongtoshow)){
	whereclause +=" and t1.creater in ("+userIDAll+") and t1.creatertype = " + usertype;
	}else{
	whereclause +=" and t1.creater in ("+userid+") and t1.creatertype = " + usertype;
	}
	}
	whereclause2 += requestutil.getSqlWhere("3",userid,"");
	whereclause2 += " and workflowid="+workflowid ;
	if(viewcondition == 1){//未归档
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype <> '3' and t2.islasttimes=1 ";
		whereclause2 +=" and iscomplete=0 ";
	}
	else if(viewcondition == 2){//已归档
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype = '3'  and t2.islasttimes=1";
		whereclause2 +=" and iscomplete=1 ";
	}else if(viewcondition == 0){//全部
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and t2.islasttimes=1 ";
	}else if(viewcondition == 3)
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and ((t1.currentnodetype <> '3') or (t2.isremark in('2','4') and t1.currentnodetype = '3' )) and t2.islasttimes=1 and t2.viewtype=-1";
	else if(viewcondition == 4) //未读
	{
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and ((t1.currentnodetype <> '3') or (t2.isremark in('2','4') and t1.currentnodetype = '3' )) and t2.islasttimes=1 and t2.viewtype=0 ";
		whereclause2 +=" and viewtype=0 ";
	}else if(viewcondition == 5) //超时
	{
		//whereclause += " and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype = '3'  and t2.isremark=5 ";
		whereclause += " and (t1.deleted=0 or t1.deleted is null) and t1.currentnodetype = '3'  and (t2.isremark=5 or (t2.isremark = '0' and isprocessed <> '1' ))  and t1.currentnodetype <> 3 ";
		whereclause2 +=" and 1=2 ";
	}
	SearchClause.setWhereClause(whereclause);
	SearchClause.setWhereclauseOs(whereclause2);
    SearchClause.setWorkflowId(workflowid);
	sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&date2during="+date2during+"&viewType="+viewType+"&myrequest="+method);
	return;
}

if(method.equals("reqeustbywftype")){
	String wftype=Util.null2String(request.getParameter("wftype"));
	String complete=Util.null2String(request.getParameter("complete"));
	
    /* edited by wdl 2006-06-14 left menu advanced menu */
    int fromAdvancedMenu = Util.getIntValue(request.getParameter("fromadvancedmenu"),0);
    String selectedContent = Util.null2String(request.getParameter("selectedContent"));
    int infoId = Util.getIntValue(request.getParameter("infoId"),0);

    String selectedworkflow = "";
    String inSelectedWorkflowStr = "";
    if(fromAdvancedMenu==1){
	    LeftMenuInfoHandler infoHandler = new LeftMenuInfoHandler();
	    LeftMenuInfo info = infoHandler.getLeftMenuInfo(infoId);
	    if(info!=null){
	    	selectedworkflow = info.getSelectedContent();
	    }
	    if(!"".equals(selectedContent))
	    {
	    	selectedworkflow = selectedContent;
	    }
	    List selectedWorkflowIdList = Util.TokenizerString(selectedworkflow,"|");
	    for(Iterator it=selectedWorkflowIdList.iterator();it.hasNext();){
	    	String tmpstr = (String)it.next();
	    	if(tmpstr.indexOf("W")>-1)
	    		inSelectedWorkflowStr += "," + tmpstr.substring(1);
	    }
	    if(inSelectedWorkflowStr.substring(0,1).equals(",")) inSelectedWorkflowStr=inSelectedWorkflowStr.substring(1);
	    if(!whereclause.equals("")) whereclause += " and ";
        if(wftype.indexOf("-")!=-1){
            whereclause += " t1.workflowid in (0) ";
        }else {
            whereclause += " t1.workflowid in (" + WorkflowVersion.getAllVersionStringByWFIDs(inSelectedWorkflowStr) + ") ";
        }
    }
    /* edited end */    
	
	if(whereclause.equals("")) {
		whereclause +=" t1.workflowid in( select id from workflow_base   where workflowtype = "+wftype+") and (t1.deleted=0 or t1.deleted is null) ";
	}
	else {
		whereclause +=" and t1.workflowid in( select id from workflow_base   where workflowtype = "+wftype+") and (t1.deleted=0 or t1.deleted is null) ";
	}
    whereclause2 +=" and workflowid in ( select workflowid from ofs_workflow   where sysid = "+wftype+" and (cancel=0 or cancel is null) ) ";
	if(complete.equals("0")){
		whereclause +="  and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and t2.islasttimes=1";
		//whereclause += " and (t1.currentnodetype <> '3' or  (t2.isremark ='1' and t1.currentnodetype = '3') ) and t2.islasttimes=1";
	}
	else if(complete.equals("1")){
		whereclause += " and (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) and t1.currentnodetype = '3' and iscomplete=1 and islasttimes=1";
	}
    //complete=2表示已办/办结事宜
	else if(complete.equals("2")){
		whereclause += " and (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2))  and  t2.islasttimes=1";
		//已办/办结:
        //viewcondition=1表示未归档


        if(viewcondition == 1)
        	whereclause += " and t2.isremark ='2' and t2.iscomplete=0 ";
        //viewcondition=2表示已归档


        else if(viewcondition == 2)
        	whereclause += " and t2.iscomplete=1 and t1.currentnodetype = 3 ";
        //viewcondition=4表示未读
        else if(viewcondition == 4)
        	whereclause += " and t2.viewtype=0  and (agentType <> '1' or agentType is null) "+WorkflowComInfo.getDateDuringSql(date2during);
        //viewcondition=3表示反馈
        else if(viewcondition == 3)
        	whereclause += " and t2.viewtype=-1 ";

        if(isopenofs&&showdone){
            if(viewcondition==0){//全部
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark in ('2','4') ";
            }else if(viewcondition==1){//已办
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark=2 and iscomplete=0";
            }else if(viewcondition==2){//办结
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark in ('2','4') and iscomplete=1";
            }else{
                whereclause2 += " and 1=2 ";
            }
        }else{
        	whereclause2 += " and 1=2 ";
        }
	}
	//complete=50表示已办事宜,红色new标记
	else if(complete.equals("50")){
        if(whereclause.equals("")) {
            whereclause += " and ((t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) or (t2.isremark=0 and t2.takisremark =-2)) and t2.islasttimes=1 and t2.viewtype=0 and (agentType<>'1' or agentType is null) ";
        }else{
		    whereclause += " and (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) or (t2.isremark=0 and t2.takisremark =-2)) and t2.islasttimes=1 and t2.viewtype=0 and (agentType<>'1' or agentType is null) ";
        }
	}
	SearchClause.setWhereClause(whereclause);
    SearchClause.setWhereclauseOs(whereclause2);
    if(complete.equals("0")){
        orderclause="t2.receivedate ,t2.receivetime ";
        orderclause2=orderclause;
    }else if(complete.equals("1") ||complete.equals("2")){
        //orderclause="t2.receivedate ,t2.receivetime ";
        orderclause="operatedate, operatetime ";
        orderclause2=orderclause;
    }
    SearchClause.setOrderClause(orderclause);
    SearchClause.setOrderClause2(orderclause2);
  if(complete.equals("0") || complete.equals("3") || complete.equals("4"))//modified by cyril on 2008-07-15 for td:8939 complete=3表示新到流程
	  sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&iswaitdo=1&date2during="+date2during+"&viewType="+viewType);
  else
    sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&date2during="+date2during+"&viewType="+viewType);
	return;
}
//TD8778 褚俊 根据流程类型进入流程列表页面,精确到流程节点
if(method.equals("reqeustbywftypeNode")){
	String wftype=Util.null2String(request.getParameter("wftype"));
	String complete=Util.null2String(request.getParameter("complete"));
	
    /* edited by wdl 2006-06-14 left menu advanced menu */
    int fromAdvancedMenu = Util.getIntValue(request.getParameter("fromadvancedmenu"),0);
    int infoId = Util.getIntValue(request.getParameter("infoId"),0);
	String workFlowIDsRequest=Util.null2String(request.getParameter("workFlowIDsRequest"));
	String workFlowNodeIDsRequest=Util.null2String(request.getParameter("workFlowNodeIDsRequest"));
    String selectedworkflow = "";
    String inSelectedStr = "";
	List selectedWorkflowIdList = Util.TokenizerString(workFlowIDsRequest,",");
    if(fromAdvancedMenu==1){
		for(int i=0; i<selectedWorkflowIdList.size(); i++){
			String wfID = (String)selectedWorkflowIdList.get(i);
			if(!"".equals(workFlowNodeIDsRequest)){
				inSelectedStr += "or ( t1.workflowid = "+wfID+" and t1.currentnodeid in ("+WorkflowVersion.getAllRelationNodeStringByNodeIDs(workFlowNodeIDsRequest)+") ) ";
			}else{
				inSelectedStr += "or ( t1.workflowid = "+wfID+" ) ";
			}
		}
		if(!"".equals(inSelectedStr)){
			inSelectedStr = inSelectedStr.substring(2);
			if(!"".equals(whereclause)){
				whereclause = whereclause + " and ";
			}
			whereclause += " ( " + inSelectedStr + " ) ";
		}
    }
    /* edited end */    
	
	if(whereclause.equals("")) {
		whereclause +=" t1.workflowid in( select id from workflow_base   where workflowtype = "+wftype+") ";
	}
	else {
		whereclause +=" and t1.workflowid in( select id from workflow_base   where workflowtype = "+wftype+") ";
	}
	
	if(complete.equals("0")){
		whereclause +=" ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and t2.islasttimes=1";
		//whereclause += " and (t1.currentnodetype <> '3' or  (t2.isremark ='1' and t1.currentnodetype = '3') ) and t2.islasttimes=1";
	}
	else if(complete.equals("1")){
		whereclause += " and  ((t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) or (t2.isremark=0 and t2.takisremark =-2)) and t1.currentnodetype = '3' and iscomplete=1 and islasttimes=1";
	}
    //complete=2表示已办事宜
	else if(complete.equals("2")){
		whereclause += " and t2.isremark ='2' and t2.iscomplete=0  and  t2.islasttimes=1";
	}
	SearchClause.setWhereClause(whereclause);
    if(complete.equals("0")){
        orderclause="t2.receivedate ,t2.receivetime ";
        orderclause2=orderclause;
    }else if(complete.equals("1") ||complete.equals("2")){
        //orderclause="t2.receivedate ,t2.receivetime ";
        orderclause="operatedate, operatetime ";
        orderclause2=orderclause;
    }
    SearchClause.setOrderClause(orderclause);
    SearchClause.setOrderClause2(orderclause2);
  if(complete.equals("0") || complete.equals("3") || complete.equals("4"))//modified by cyril on 2008-07-15 for td:8939 complete=3表示新到流程
	  sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&iswaitdo=1&date2during="+date2during+"&viewType="+viewType);
  else
    sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&date2during="+date2during+"&viewType="+viewType);
	return;
}
//add by ben根据单据号得到流程 
if(method.equals("reqeustbybill")){
	String billid=Util.null2String(request.getParameter("billid"));
	String complete=Util.null2String(request.getParameter("complete"));
	
	if ("163".equals(billid)) {
		if(whereclause.equals("")) {
			whereclause +=" t1.workflowid in(select id from workflow_base where (formid = "+billid+" or formid in (select formid from carbasic where isuse=1)) and id not in (select workflowid from carbasic where isuse=0) and isbill='1') ";
		}
		else {
			whereclause +=" and t1.workflowid in(select id from workflow_base where (formid = "+billid+" or formid in (select formid from carbasic where isuse=1)) and id not in (select workflowid from carbasic where isuse=0) and isbill='1') ";
		}
	} else {
		if(whereclause.equals("")) {
			whereclause +=" t1.workflowid in( select id from workflow_base   where formid = "+billid+" and isbill='1') ";
		}
		else {
			whereclause +=" and t1.workflowid in( select id from workflow_base   where formid = "+billid+" and isbill='1') ";
		}
	}
	
	
	if(complete.equals("0")){  //未审批


		whereclause +=" and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and t2.islasttimes=1 ";
		//whereclause += " and (t1.currentnodetype <> '3' or ((t2.isremark ='1' or t2.isremark ='8' or t2.isremark ='9') and t1.currentnodetype = '3') ) and t2.islasttimes=1";
	}
	else if(complete.equals("1")){ 
		whereclause += " and (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) and t1.currentnodetype = '3' and iscomplete=1 and islasttimes=1";
	}
    //complete=2表示已办事宜
	else if(complete.equals("2")){  //已审批 (把办结和已办一起显示)
		whereclause += "   and ((t2.isremark ='2' and t1.currentnodetype <> 3 and t2.iscomplete=0) or  (t1.currentnodetype = '3')) and  t2.islasttimes=1";
	}
	SearchClause.setWhereClause(whereclause);
    if(complete.equals("0")){
        orderclause="t2.receivedate ,t2.receivetime ";
        orderclause2=orderclause;
    }else if(complete.equals("1") ||complete.equals("2")){
        //orderclause="t2.receivedate ,t2.receivetime ";
        orderclause="operatedate, operatetime ";
        orderclause2=orderclause;
    }
    SearchClause.setOrderClause(orderclause);
    SearchClause.setOrderClause2(orderclause2);
  if(complete.equals("0") || complete.equals("3") || complete.equals("4"))//modified by cyril on 2008-07-15 for td:8939 complete=3表示新到流程
	  sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&iswaitdo=1&date2during="+date2during+"&viewType="+viewType);
  else
    sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&date2during="+date2during+"&viewType="+viewType);
	return;
}
if(method.equals("reqeustbywfid")){
	String workflowid=Util.null2String(request.getParameter("workflowid"));
	String complete=Util.null2String(request.getParameter("complete"));
	//System.out.println();
	//complete=0表示已办事宜
	if(complete.equals("0")){
        if(whereclause.equals("")) {
            whereclause +=" ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and t2.islasttimes=1";
        }else{
		    whereclause +=" and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and t2.islasttimes=1";
        }
		//modify by mackjoe at 2005-09-29 td1772 转发特殊处理,转发信息本人未处理一直都在待办事宜中显示
        //whereclause += " and (t1.currentnodetype <> '3' or  (t2.isremark in ('1', '8', '9') and t1.currentnodetype = '3')) and t2.islasttimes=1";
	    whereclause2 += " and isremark='0' ";
	}
    //complete=1表示办结事宜
	else if(complete.equals("1")){
        if(whereclause.equals("")) {
            whereclause += " (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) and t1.currentnodetype = '3' and iscomplete=1 and islasttimes=1";
        }else{
		    whereclause += " and (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) and t1.currentnodetype = '3' and iscomplete=1 and islasttimes=1";
        }
        whereclause2 += " and isremark in ('2','4') and iscomplete = 1 ";
	}
    //complete=2表示已办/办结事宜
	else if(complete.equals("2")){
        if(whereclause.equals("")) {
            whereclause += " (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) and t2.islasttimes=1 ";
        }else{
		    whereclause += " and (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2))  and t2.islasttimes=1 ";
        }
        //已办/办结:
        //viewcondition=1表示未归档
        //whereclause2 += " and isremark in ('2','4') ";

        if(viewcondition == 1) {
            whereclause += " and t2.isremark ='2' and t2.iscomplete=0 ";
            //viewcondition=2表示已归档
            //whereclause2 += " and iscomplete = 1 ";

        }else if(viewcondition == 2) {
            whereclause += " and t2.iscomplete=1 and t1.currentnodetype = 3 ";
            //whereclause2 += " and iscomplete = 1 ";
            //viewcondition=4表示未读
        }else if(viewcondition == 4) {
            whereclause += " and t2.viewtype=0  and (agentType <> '1' or agentType is null) " + WorkflowComInfo.getDateDuringSql(date2during);
            whereclause2 += " and 1=2 ";
            //viewcondition=3表示反馈
        }else if(viewcondition == 3) {
            whereclause += " and t2.viewtype=-1 ";
            whereclause2 += " and 1=2 ";
        }
        if(isopenofs&&showdone){
            if(viewcondition==0){//全部
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark in (2,4) ";
            }else if(viewcondition==1){//未读
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark=2 and iscomplete=0";
            }else if(viewcondition==2){//未读
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark=4 and iscomplete=1";
            }else{
                whereclause2 += " and 1=2 ";
            }
        }else{
        	whereclause2 += " and 1=2 ";
        }
	}
    //complete=3表示待办事宜,红色new标记
	else if(complete.equals("3")){
        if(whereclause.equals("")) {
            whereclause +=" ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=0 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }else{
		    whereclause +=" and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=0 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }
        whereclause2 += " and 1=2 ";
	}
    //complete=4表示待办事宜,灰色new标记
	else if(complete.equals("4")){
        if(whereclause.equals("")) {
            whereclause +=" ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=-1 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }else{
		    whereclause +=" and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=-1 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }
        whereclause2 += " and 1=2 ";
	}
    //complete=5表示已办事宜,灰色new标记
	else if(complete.equals("5")){
        if(whereclause.equals("")) {
            whereclause += " t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=-1";
        }else{
		    whereclause += " and t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=-1";
        }
        whereclause2 += " and 1=2 ";
	}
    //complete=50表示已办事宜,红色new标记
	else if(complete.equals("50")){
        if(whereclause.equals("")) {
            whereclause += " t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=0 and (agentType<>'1' or agentType is null) ";
        }else{
		    whereclause += " and t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=0 and (agentType<>'1' or agentType is null) ";
        }
        whereclause2 += " and 1=2 ";
	}

    //complete=6表示办结事宜,红色new标记
	else if(complete.equals("6")){
        if(whereclause.equals("")) {
            whereclause += " t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=0";
        }else{
            whereclause += " and t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=0";
        }
        whereclause2 += " and 1=2 ";
	}
    //complete=7表示办结事宜,灰色new标记
	else if(complete.equals("7")){
        if(whereclause.equals("")) {
            whereclause += " t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=-1";
        }else{
            whereclause += " and t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=-1";
        }
        whereclause2 += " and 1=2 ";
	}
    //complete=8表示超时事宜,


	else if(complete.equals("8")){
        if(whereclause.equals("")) {
            whereclause +=" ((t2.isremark='0' and (t2.isprocessed='2' or t2.isprocessed='3'))  or t2.isremark='5') and t1.currentnodetype <> 3 ";
        }else{
            whereclause +=" and ((t2.isremark='0' and (t2.isprocessed='2' or t2.isprocessed='3'))  or t2.isremark='5') and t1.currentnodetype <> 3 ";
        }
        whereclause2 += " and 1=2 ";
	}

    whereclause2 += " and workflowid="+workflowid ;
    SearchClause.setWhereClause(whereclause);
    SearchClause.setWhereclauseOs(whereclause2);

    if(complete.equals("0")||complete.equals("3")||complete.equals("4")){
        orderclause="t2.receivedate ,t2.receivetime ";
        orderclause2=orderclause;
    }else if(complete.equals("1") ||complete.equals("2")||complete.equals("5")||complete.equals("6")||complete.equals("7")||complete.equals("8")){
        //orderclause="t2.receivedate ,t2.receivetime ";
        orderclause="operatedate, operatetime ";
        orderclause2=orderclause;
    }
    SearchClause.setOrderClause(orderclause);
    SearchClause.setOrderClause2(orderclause2);
    SearchClause.setWorkflowId(workflowid);
   
  if(complete.equals("0") || complete.equals("3") || complete.equals("4"))//modified by cyril on 2008-07-15 for td:8939 complete=3表示新到流程
	  sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&iswaitdo=1&date2during="+date2during+"&viewType="+viewType);
  else
    sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&date2during="+date2during+"&viewType="+viewType);
	return;
}
if(method.equals("reqeustbywfidNode")){
	String workflowid=Util.null2String(request.getParameter("workflowid"));
	String complete=Util.null2String(request.getParameter("complete"));
	String nodeids = Util.null2String(request.getParameter("nodeids"));
	if(!"".equals(workflowid)){
        String tempwfids = WorkflowVersion.getAllVersionStringByWFIDs(workflowid) ;
        if(workflowid.indexOf("-")!=-1) tempwfids=workflowid ;
        if(whereclause.equals("")) {
            whereclause +=" t1.workflowid in ("+tempwfids+") ";
        }else{
		    whereclause +=" and t1.workflowid in ("+tempwfids+") ";
        }
        whereclause2 += " and workflowid="+workflowid ;
	}
	if(!"".equals(nodeids)){
        if(whereclause.equals("")) {
            whereclause +=" t1.currentnodeid in ("+WorkflowVersion.getAllRelationNodeStringByNodeIDs(nodeids)+") ";
        }else{
		    whereclause +=" and t1.currentnodeid in ("+WorkflowVersion.getAllRelationNodeStringByNodeIDs(nodeids)+") ";
        }
        whereclause2 += " and 1=2 ";
	}
	//complete=0表示待办事宜
	if(complete.equals("0")){
        if(whereclause.equals("")) {
            whereclause +=" ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and t2.islasttimes=1";
        }else{
		    whereclause +=" and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and t2.islasttimes=1";
        }
		//modify by mackjoe at 2005-09-29 td1772 转发特殊处理,转发信息本人未处理一直都在待办事宜中显示
        //whereclause += " and (t1.currentnodetype <> '3' or  (t2.isremark in ('1', '8', '9') and t1.currentnodetype = '3')) and t2.islasttimes=1";
		// 分页控件上方的控件  1:未读;2:反馈;3:超时;  	add by Dracula @2014-1-10
	    if(viewcondition == 1)
	    	whereclause += " and t2.viewtype = '0' and (t1.currentnodetype <> '3' or  (t2.isremark in ('1', '8', '9') and t1.currentnodetype = '3'))  and t2.isprocessed is null and t2.isremark <> '5'";
	    else if(viewcondition == 2)
	    	whereclause += " and t2.viewtype = '-1' and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
	    else if(viewcondition == 3)
	    	whereclause += " and ((t2.isremark='0' and (t2.isprocessed='2' or t2.isprocessed='3'))  or t2.isremark='5') and t1.currentnodetype <> 3  ";
	    else if(viewcondition == 4)
	    	whereclause += " and t2.requestid in (select requestid from workflow_requestlog where logtype='s') ";
	    processing = "0";	//待办

        if(isopenofs){
            if(viewcondition==0){//全部
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark=0 ";
            }else if(viewcondition==1){//未读
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark=0 and viewtype=0 ";
            }else{
                whereclause2 += " and 1=2 ";
            }
        }
	}
    //complete=1表示办结事宜
	else if(complete.equals("1")){
        if(whereclause.equals("")) {
            whereclause += " (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) and t1.currentnodetype = '3' and iscomplete=1 and islasttimes=1";
        }else{
		    whereclause += " and (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) and t1.currentnodetype = '3' and iscomplete=1 and islasttimes=1";
        }
	}
    //complete=2表示已办事宜
	else if(complete.equals("2")){
        if(whereclause.equals("")) {
            whereclause += " t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 ";
        }else{
		    whereclause += " and t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 ";
        }
	}
    //complete=3表示待办事宜,红色new标记
	else if(complete.equals("3")){
        if(whereclause.equals("")) {
            whereclause +=" ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=0 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }else{
		    whereclause +=" and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=0 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }
	}
    //complete=4表示待办事宜,灰色new标记(反馈)
	else if(complete.equals("4")){
        if(whereclause.equals("")) {
            whereclause +=" ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=-1 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }else{
		    whereclause +=" and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=-1 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }
	}
    //complete=5表示已办事宜,灰色new标记
	else if(complete.equals("5")){
        if(whereclause.equals("")) {
            whereclause += " t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=-1";
        }else{
		    whereclause += " and t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=-1";
        }
	}
    //complete=50表示已办事宜,红色new标记
	else if(complete.equals("50")){
        if(whereclause.equals("")) {
            whereclause += " t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=0 and (agentType<>'1' or agentType is null) ";
        }else{
		    whereclause += " and t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=0 and (agentType<>'1' or agentType is null) ";
        }
	}
    //complete=6表示办结事宜,红色new标记
	else if(complete.equals("6")){
        if(whereclause.equals("")) {
            whereclause += " t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=0";
        }else{
            whereclause += " and t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=0";
        }
	}
    //complete=7表示办结事宜,灰色new标记
	else if(complete.equals("7")){
        if(whereclause.equals("")) {
            whereclause += " t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=-1";
        }else{
            whereclause += " and t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=-1";
        }
	}
    //complete=8表示超时事宜,


	else if(complete.equals("8")){
        if(whereclause.equals("")) {
            whereclause +=" and ((t2.isremark='0' and (t2.isprocessed='2' or t2.isprocessed='3'))  or t2.isremark='5') and t1.currentnodetype <> 3 ";
        }else{
            whereclause +=" and ((t2.isremark='0' and (t2.isprocessed='2' or t2.isprocessed='3'))  or t2.isremark='5') and t1.currentnodetype <> 3 ";
        }
	}
    SearchClause.setWhereClause(whereclause);
    SearchClause.setWhereclauseOs(whereclause2);

    if(complete.equals("0")||complete.equals("3")||complete.equals("4")){
        orderclause="t2.receivedate ,t2.receivetime ";
        orderclause2=orderclause;
    }else if(complete.equals("1") ||complete.equals("2")||complete.equals("5")||complete.equals("6")||complete.equals("7")||complete.equals("8")){
        //orderclause="t2.receivedate ,t2.receivetime ";
        orderclause="operatedate, operatetime ";
        orderclause2=orderclause;
    }
    SearchClause.setOrderClause(orderclause);
    SearchClause.setOrderClause2(orderclause2);
    SearchClause.setWorkflowId(workflowid);
   
  if(complete.equals("0") || complete.equals("3") || complete.equals("4"))//modified by cyril on 2008-07-15 for td:8939 complete=3表示新到流程
	  sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&iswaitdo=1&date2during="+date2during+"&viewType="+viewType+"&processing="+processing);
  else
    sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&date2during="+date2during+"&viewType="+viewType+"&processing="+processing);
	return;
}



//add by bpf on 2013-11-13
//新的流程页面中带数字的的左侧菜单的一级菜单(流程大类别)点击之后的跳转


//实现的方式为reqeustByWfType和reqeustbywfidNode两个分支的代码组合了一下


if(method.equals("reqeustByWfTypeAndComplete")){
	String wftype=Util.null2String(request.getParameter("wftype"));
	String complete=Util.null2String(request.getParameter("complete"));
	
    int fromAdvancedMenu = Util.getIntValue(request.getParameter("fromadvancedmenu"),0);
    String selectedContent = Util.null2String(request.getParameter("selectedContent"));
    int infoId = Util.getIntValue(request.getParameter("infoId"),0);

    String selectedworkflow = "";
    String inSelectedWorkflowStr = "";
    if(fromAdvancedMenu==1){
	    LeftMenuInfoHandler infoHandler = new LeftMenuInfoHandler();
	    LeftMenuInfo info = infoHandler.getLeftMenuInfo(infoId);
	    if(info!=null){
	    	selectedworkflow = info.getSelectedContent();
	    }
	    if(!"".equals(selectedContent))
	    {
	    	selectedworkflow = selectedContent;
	    }
	    List selectedWorkflowIdList = Util.TokenizerString(selectedworkflow,"|");
	    for(Iterator it=selectedWorkflowIdList.iterator();it.hasNext();){
	    	String tmpstr = (String)it.next();
	    	if(tmpstr.indexOf("W")>-1)
	    		inSelectedWorkflowStr += "," + tmpstr.substring(1);
	    }
	    if(inSelectedWorkflowStr.substring(0,1).equals(",")) inSelectedWorkflowStr=inSelectedWorkflowStr.substring(1);
	    if(!whereclause.equals("")) whereclause += " and ";
	    whereclause += " t1.workflowid in (" +WorkflowVersion.getAllVersionStringByWFIDs(inSelectedWorkflowStr) + ") ";
	    whereclause += " and ";
    }
	if(whereclause.equals("")) {
		whereclause +=" t1.workflowid in( select id from workflow_base   where workflowtype = "+wftype+") and (t1.deleted=0 or t1.deleted is null) ";
	}
	else {
		whereclause +=" and t1.workflowid in( select id from workflow_base   where workflowtype = "+wftype+") and (t1.deleted=0 or t1.deleted is null) ";
	}

    if(isopenofs){
        whereclause2 += " and workflowid in (select workflowid from ofs_workflow where sysid="+wftype+" and cancel=0 )";
    }
	String nodeids = Util.null2String(request.getParameter("nodeids"));

	if(!"".equals(nodeids)){
        if(whereclause.equals("")) {
            whereclause +=" t1.currentnodeid in ("+WorkflowVersion.getAllRelationNodeStringByNodeIDs(nodeids)+") ";
        }else{
		    whereclause +=" and t1.currentnodeid in ("+WorkflowVersion.getAllRelationNodeStringByNodeIDs(nodeids)+") ";
        }

        whereclause2 += " and 1=2 ";
	}
	//complete=0表示待办事宜
	if(complete.equals("0")){
        if(whereclause.equals("")) {
        	if(viewcondition == 3){
            	whereclause +=" ((t2.isremark='0' and (t2.isprocessed='2' or t2.isprocessed='3'))  or t2.isremark='5') and (t1.currentnodetype <> '3' or  (t2.isremark in ('1', '8', '9') and t1.currentnodetype = '3'))  and t2.islasttimes=1";
        	}else{
            	whereclause +=" ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and t2.islasttimes=1";
        	}
        }else{
        	if(viewcondition == 3){
        		whereclause +=" and ((t2.isremark='0' and (t2.isprocessed='2' or t2.isprocessed='3'))  or t2.isremark='5') and (t1.currentnodetype <> '3' or  (t2.isremark in ('1', '8', '9') and t1.currentnodetype = '3'))  and t2.islasttimes=1";
        	}else{
        		whereclause +=" and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and t2.islasttimes=1";
        	}
        }
		//modify by mackjoe at 2005-09-29 td1772 转发特殊处理,转发信息本人未处理一直都在待办事宜中显示
        //whereclause += " and (t1.currentnodetype <> '3' or  (t2.isremark in ('1', '8', '9') and t1.currentnodetype = '3')) and t2.islasttimes=1";
		// 分页控件上方的控件  1:未读;2:反馈;3:超时;  	add by Dracula @2014-1-10
	    if(viewcondition == 1)
	    	whereclause += " and t2.viewtype = '0' and t2.isremark != '5' and t2.isprocessed is null ";
	    else if(viewcondition == 2)
	    	whereclause += " and t2.viewtype = '-1'";
	    //else if(viewcondition == 3)
	    	//whereclause += " and t2.isremark = '5'";
	    else if(viewcondition == 4)
	    	whereclause += " and t2.requestid in (select requestid from workflow_requestlog where logtype='s')";
	    processing = "0";	//待办

        if(isopenofs){
            if(viewcondition==0){//全部
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark=0 ";
            }else if(viewcondition==1){//未读
                whereclause2 += " and userid="+user.getUID()+" and islasttimes=1 and isremark=0 and viewtype=0 ";
            }else{
                whereclause2 += " and 1=2 ";
            }
        }
	}
    //complete=1表示办结事宜
	else if(complete.equals("1")){
        if(whereclause.equals("")) {
            whereclause += " (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) and t1.currentnodetype = '3' and iscomplete=1 and islasttimes=1";
        }else{
		    whereclause += " and (t2.isremark in('2','4') or (t2.isremark=0 and t2.takisremark =-2)) and t1.currentnodetype = '3' and iscomplete=1 and islasttimes=1";
        }
	}
    //complete=2表示已办事宜
	else if(complete.equals("2")){
        if(whereclause.equals("")) {
            whereclause += " t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 ";
        }else{
		    whereclause += " and t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 ";
        }
	}
    //complete=3表示待办事宜,红色new标记
	else if(complete.equals("3")){
		
        if(whereclause.equals("")) {
            whereclause +=" ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=0 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }else{
		    whereclause +=" and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=0 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }
	}
    //complete=4表示待办事宜,灰色new标记
	else if(complete.equals("4")){
        if(whereclause.equals("")) {
            whereclause +=" ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=-1 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }else{
		    whereclause +=" and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','8','9','7')) and  t2.viewtype=-1 and t2.islasttimes=1 and ((t2.isremark='0' and (t2.isprocessed is null or (t2.isprocessed<>'2' and t2.isprocessed<>'3'))) or t2.isremark='1' or t2.isremark='8' or t2.isremark='9' or t2.isremark='5' or t2.isremark='7') ";
        }
	}
    //complete=5表示已办事宜,灰色new标记
	else if(complete.equals("5")){
        if(whereclause.equals("")) {
            whereclause += " t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=-1";
        }else{
		    whereclause += " and t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=-1";
        }
	}
    //complete=50表示已办事宜,红色new标记
	else if(complete.equals("50")){
        if(whereclause.equals("")) {
            whereclause += " t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=0 and (agentType<>'1' or agentType is null) ";
        }else{
		    whereclause += " and t2.isremark ='2'  and t2.iscomplete=0 and t2.islasttimes=1 and t2.viewtype=0 and (agentType<>'1' or agentType is null) ";
        }
	}
    //complete=6表示办结事宜,红色new标记
	else if(complete.equals("6")){
        if(whereclause.equals("")) {
            whereclause += " t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=0";
        }else{
            whereclause += " and t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=0";
        }
	}
    //complete=7表示办结事宜,灰色new标记
	else if(complete.equals("7")){
        if(whereclause.equals("")) {
            whereclause += " t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=-1";
        }else{
            whereclause += " and t1.currentnodetype = 3 and islasttimes=1 and t2.viewtype=-1";
        }
	}
    //complete=8表示超时事宜,


	else if(complete.equals("8")){
        if(whereclause.equals("")) {
            whereclause +=" and ((t2.isremark='0' and (t2.isprocessed='2' or t2.isprocessed='3'))  or t2.isremark='5') and t1.currentnodetype <> 3 ";
        }else{
            whereclause +=" and ((t2.isremark='0' and (t2.isprocessed='2' or t2.isprocessed='3'))  or t2.isremark='5') and t1.currentnodetype <> 3 ";
        }
	}
    SearchClause.setWhereClause(whereclause);
    SearchClause.setWhereclauseOs(whereclause2);
    if(complete.equals("0")||complete.equals("3")||complete.equals("4")){
        orderclause="t2.receivedate ,t2.receivetime ";
        orderclause2=orderclause;
    }else if(complete.equals("1") ||complete.equals("2")||complete.equals("5")||complete.equals("6")||complete.equals("7")||complete.equals("8")){
        //orderclause="t2.receivedate ,t2.receivetime ";
        orderclause="operatedate, operatetime ";
        orderclause2=orderclause;
    }
    SearchClause.setOrderClause(orderclause);
    SearchClause.setOrderClause2(orderclause2);
  if(complete.equals("0") || complete.equals("3") || complete.equals("4"))//modified by cyril on 2008-07-15 for td:8939 complete=3表示新到流程
	  sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&iswaitdo=1&date2during="+date2during+"&viewType="+viewType+"&processing="+processing);
  else
    sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&start=1&date2during="+date2during+"&viewType="+viewType+"&processing"+processing);
	return;
}














String createrid=Util.null2String(request.getParameter("createrid"));
String docids=Util.null2String(request.getParameter("docids"));
String crmids=Util.null2String(request.getParameter("crmids"));
String hrmids=Util.null2String(request.getParameter("hrmids"));
String prjids=Util.null2String(request.getParameter("prjids"));
String creatertype=Util.null2String(request.getParameter("creatertype"));
String workflowid=Util.null2String(request.getParameter("workflowid"));
String nodetype=Util.null2String(request.getParameter("nodetype"));
String fromdate=Util.null2String(request.getParameter("fromdate"));
String todate=Util.null2String(request.getParameter("todate"));
String lastfromdate=Util.null2String(request.getParameter("lastfromdate"));
String lasttodate=Util.null2String(request.getParameter("lasttodate"));
String requestmark=Util.null2String(request.getParameter("requestmark"));
String branchid=Util.null2String(request.getParameter("branchid"));
if (!branchid.equals("")) session.setAttribute("branchid",branchid);
int during=Util.getIntValue(request.getParameter("during"),0);
int order=Util.getIntValue(request.getParameter("order"),0);
int isdeleted=Util.getIntValue(request.getParameter("isdeleted"),0);
String requestname=Util.fromScreen2(request.getParameter("requestname"),user.getLanguage());
requestname=requestname.trim();
int subday1=Util.getIntValue(request.getParameter("subday1"),0);
int subday2=Util.getIntValue(request.getParameter("subday2"),0);
int maxday=Util.getIntValue(request.getParameter("maxday"),0);
int state=Util.getIntValue(request.getParameter("state"),0);
String requestlevel=Util.fromScreen(request.getParameter("requestlevel"),user.getLanguage());
//add by xhheng @20050414 for TD 1545
int iswaitdo= Util.getIntValue(request.getParameter("iswaitdo"),0) ;

Calendar now = Calendar.getInstance();
String today=Util.add0(now.get(Calendar.YEAR), 4) +"-"+
	Util.add0(now.get(Calendar.MONTH) + 1, 2) +"-"+
        Util.add0(now.get(Calendar.DAY_OF_MONTH), 2) ;
int year=now.get(Calendar.YEAR);
int month=now.get(Calendar.MONTH);
int day=now.get(Calendar.DAY_OF_MONTH);

Date newdate = new Date() ;
long datetime = newdate.getTime() ;
Timestamp timestamp = new Timestamp(datetime) ;
String CurrentTime = (timestamp.toString()).substring(11,13) + ":" + (timestamp.toString()).substring(14,16) + ":" +(timestamp.toString()).substring(17,19);


if(!createrid.equals("")){
	if(whereclause.equals("")) {whereclause+=" t1.creater='"+createrid+"'";}
	else {whereclause+=" and t1.creater='"+createrid+"'";}
	if(!creatertype.equals("")){
		if(whereclause.equals("")) {whereclause+=" t1.creatertype='"+creatertype+"'";}
		else {whereclause+=" and t1.creatertype='"+creatertype+"'";}
	}
}

//添加附件上传文档的查询


if(!docids.equals("")){
    RecordSet.executeSql("select fieldname from workflow_formdict where fieldhtmltype=6 ");
}

if( isoracle ) {
    if(!docids.equals("")){
        if(whereclause.equals("")) {whereclause+=" ((concat(concat(',' , To_char(t1.docids)) , ',') LIKE '%,"+docids+",%') ";}
        else {whereclause+=" and ((concat(concat(',' , To_char(t1.docids)) , ',') LIKE '%,"+docids+",%') ";}
        while(RecordSet.next()){
            String fieldname=RecordSet.getString("fieldname");
            whereclause+=" or (concat(concat(',' , To_char(t4."+fieldname+")) , ',') LIKE '%,"+docids+",%') ";
        }
        whereclause+=") ";
    }
    if(!crmids.equals("")){
        if(whereclause.equals("")) {whereclause+=" (concat(concat(',' , To_char(t1.crmids)) , ',') LIKE '%,"+crmids+",%') ";}
        else {whereclause+=" and (concat(concat(',' , To_char(t1.crmids)) , ',') LIKE '%,"+crmids+",%') ";}
    }
    if(!hrmids.equals("")){
        if(whereclause.equals("")) {whereclause+=" (concat(concat(',' , To_char(t1.hrmids)) , ',') LIKE '%,"+hrmids+",%') ";}
        else {whereclause+=" and (concat(concat(',' , To_char(t1.hrmids)) , ',') LIKE '%,"+hrmids+",%') ";}
    }
    if(!prjids.equals("")){
        if(whereclause.equals("")) {whereclause+=" (concat(concat(',' , To_char(t1.prjids)) , ',') LIKE '%,"+prjids+",%') ";}
        else {whereclause+=" and (concat(concat(',' , To_char(t1.prjids)) , ',') LIKE '%,"+prjids+",%') ";}
    }
}else if( isdb2 ) {
    if(!docids.equals("")){
        if(whereclause.equals("")) {whereclause+=" ((concat(concat(',' , varchar(t1.docids)) , ',') LIKE '%,"+docids+",%') ";}
        else {whereclause+=" and ((concat(concat(',' , varchar(t1.docids)) , ',') LIKE '%,"+docids+",%') ";}
        while(RecordSet.next()){
            String fieldname=RecordSet.getString("fieldname");
            whereclause+=" or (concat(concat(',' , varchar(t4."+fieldname+")) , ',') LIKE '%,"+docids+",%') ";
        }
        whereclause+=") ";
    }
    if(!crmids.equals("")){
        if(whereclause.equals("")) {whereclause+=" (concat(concat(',' , varchar(t1.crmids)) , ',') LIKE '%,"+crmids+",%') ";}
        else {whereclause+=" and (concat(concat(',' , varchar(t1.crmids)) , ',') LIKE '%,"+crmids+",%') ";}
    }
    if(!hrmids.equals("")){
        if(whereclause.equals("")) {whereclause+=" (concat(concat(',' , varchar(t1.hrmids)) , ',') LIKE '%,"+hrmids+",%') ";}
        else {whereclause+=" and (concat(concat(',' , varchar(t1.hrmids)) , ',') LIKE '%,"+hrmids+",%') ";}
    }
    if(!prjids.equals("")){
        if(whereclause.equals("")) {whereclause+=" (concat(concat(',' , varchar(t1.prjids)) , ',') LIKE '%,"+prjids+",%') ";}
        else {whereclause+=" and (concat(concat(',' , varchar(t1.prjids)) , ',') LIKE '%,"+prjids+",%') ";}
    }
}
else {
    if(!docids.equals("")){
        if(whereclause.equals("")) {whereclause+=" ((',' + CONVERT(varchar,t1.docids) + ',' LIKE '%,"+docids+",%') ";}
        else {whereclause+=" and ((',' + CONVERT(varchar,t1.docids) + ',' LIKE '%,"+docids+",%') ";}
        while(RecordSet.next()){
            String fieldname=RecordSet.getString("fieldname");
            whereclause+=" or (',' + CONVERT(varchar,t4."+fieldname+") + ',' LIKE '%,"+docids+",%') ";
        }
        whereclause+=") ";
    }
    if(!crmids.equals("")){
        if(whereclause.equals("")) {whereclause+=" (',' + CONVERT(varchar,t1.crmids) + ',' LIKE '%,"+crmids+",%') ";}
        else {whereclause+=" and (',' + CONVERT(varchar,t1.crmids) + ',' LIKE '%,"+crmids+",%') ";}
    }
    if(!hrmids.equals("")){
        if(whereclause.equals("")) {whereclause+=" (',' + CONVERT(varchar,t1.hrmids) + ',' LIKE '%,"+hrmids+",%') ";}
        else {whereclause+=" and (',' + CONVERT(varchar,t1.hrmids) + ',' LIKE '%,"+hrmids+",%') ";}
    }
    if(!prjids.equals("")){
        if(whereclause.equals("")) {whereclause+=" (',' + CONVERT(varchar,t1.prjids) + ',' LIKE '%,"+prjids+",%') ";}
        else {whereclause+=" and (',' + CONVERT(varchar,t1.prjids) + ',' LIKE '%,"+prjids+",%') ";}
    }
}
if(!workflowid.equals("")){
	if(whereclause.equals("")) 
	{whereclause+=" t1.workflowid in("+ WorkflowVersion.getAllVersionStringByWFIDs(workflowid) +")";}
	else 
	{
	 /*--xwj for td2045 on 2005-05-26 --查询流程时, 同时选择流程类型和创建人时出错*/
	 //whereclause+=" and t1.workflowid in("+workflowid+")";
	 whereclause = "t1.workflowid in("+ WorkflowVersion.getAllVersionStringByWFIDs(workflowid) + ") and " + whereclause; 
	}
}
if(!cdepartmentid.equals("")){
    String tempWhere = "";
    ArrayList tempArr = Util.TokenizerString(cdepartmentid,",");
    for(int i=0;i<tempArr.size();i++){
        String tempcdepartmentid = (String)tempArr.get(i);
        if(tempWhere.equals("")) tempWhere += "departmentid="+tempcdepartmentid;
        else tempWhere += " or departmentid="+tempcdepartmentid;
    }
    if(!tempWhere.equals("")){
        if(whereclause.equals("")) {whereclause+=" exists(select 1 from hrmresource where t1.creater=id and t1.creatertype='0' and ("+tempWhere+"))";}
        else {whereclause+=" and exists(select 1 from hrmresource where t1.creater=id and t1.creatertype='0' and ("+tempWhere+"))";}
    }
}
whereclause += WorkflowComInfo.getDateDuringSql(date2during);
if(!requestname.equals("")){
	if(whereclause.equals("")) {whereclause+=" t1.requestname like '%"+requestname+"%'";}
	else {whereclause+=" and t1.requestname like '%"+requestname+"%'";}
}
if(!nodetype.equals("")){
	if(whereclause.equals("")) {whereclause+=" t1.currentnodetype='"+nodetype+"'";}
	else {whereclause+=" and t1.currentnodetype='"+nodetype+"'";}
}
if(!requestmark.equals("")){
	if(whereclause.equals("")) {whereclause+=" t1.requestmark like '%"+requestmark+"%'";}
	else {whereclause+=" and t1.requestmark like '%"+requestmark+"%'";}
}

if(!lastfromdate.equals("")){
	if(whereclause.equals("")) {whereclause+=" t1.lastoperatedate>='"+lastfromdate+"'";}
	else {whereclause+=" and t1.lastoperatedate>='"+lastfromdate+"'";}
}
if(!lasttodate.equals("")){
	if(whereclause.equals("")) {whereclause+=" t1.lastoperatedate<='"+lasttodate+"'";}
	else {whereclause+=" and t1.lastoperatedate<='"+lasttodate+"'";}
}
if(during==0){
	if(!fromdate.equals("")){
		if(whereclause.equals("")){whereclause+=" t1.createdate>='"+fromdate+"'";}
		else {whereclause+=" and t1.createdate>='"+fromdate+"'";}
	}
	if(!todate.equals("")){
		if(whereclause.equals("")){whereclause+=" t1.createdate<='"+todate+"'";}
		else {whereclause+=" and t1.createdate<='"+todate+"'";}
	}
}
else{
	if(during==1){
		if(whereclause.equals(""))	whereclause+=" t1.createdate='"+today+"'";
		else  whereclause+=" and t1.createdate='"+today+"'";
	}
	if(during==2){
		Calendar tempday = Calendar.getInstance();
		tempday.clear();
		tempday.set(year,month,day-1);
		String lastday=Util.add0(tempday.get(Calendar.YEAR), 4) +"-"+
			Util.add0(tempday.get(Calendar.MONTH) + 1, 2) +"-"+
        		Util.add0(tempday.get(Calendar.DAY_OF_MONTH), 2) ;
        /* 刘煜 2004-05-08 修改,原来or 之间没有括号,造成系统死机 */
		if(whereclause.equals(""))	
			whereclause+=" ((t1.createdate='"+today+"' and t1.createtime<='"+CurrentTime+"')"+
			 " or (t1.createdate='"+lastday+"' and t1.createtime>='"+CurrentTime+"')) ";
		else  
			whereclause+=" and ((t1.createdate='"+today+"' and t1.createtime<='"+CurrentTime+"')"+
			 " or (t1.createdate='"+lastday+"' and t1.createtime>='"+CurrentTime+"')) ";
	}
	if(during==3){
		int days=now.getTime().getDay();
		Calendar tempday = Calendar.getInstance();
		tempday.clear();
		tempday.set(year,month,day-days);
		String lastday=Util.add0(tempday.get(Calendar.YEAR), 4) +"-"+
			Util.add0(tempday.get(Calendar.MONTH) + 1, 2) +"-"+
        		Util.add0(tempday.get(Calendar.DAY_OF_MONTH), 2) ;
        	if(whereclause.equals(""))
        		whereclause+=" t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
        	else
        		whereclause+=" and t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
	}
	if(during==4){
		Calendar tempday = Calendar.getInstance();
		tempday.clear();
		tempday.set(year,month,day-7);
		String lastday=Util.add0(tempday.get(Calendar.YEAR), 4) +"-"+
			Util.add0(tempday.get(Calendar.MONTH) + 1, 2) +"-"+
        		Util.add0(tempday.get(Calendar.DAY_OF_MONTH), 2) ;
        	if(whereclause.equals(""))
        		whereclause+=" t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
        	else
        		whereclause+=" and t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
	}
	if(during==5){
		Calendar tempday = Calendar.getInstance();
		tempday.clear();
		tempday.set(year,month,1);
		String lastday=Util.add0(tempday.get(Calendar.YEAR), 4) +"-"+
			Util.add0(tempday.get(Calendar.MONTH) + 1, 2) +"-"+
        		Util.add0(tempday.get(Calendar.DAY_OF_MONTH), 2) ;
        	if(whereclause.equals(""))
        		whereclause+=" t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
        	else
        		whereclause+=" and t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
	}
	if(during==6){
		Calendar tempday = Calendar.getInstance();
		tempday.clear();
		tempday.set(year,month,day-30);
		String lastday=Util.add0(tempday.get(Calendar.YEAR), 4) +"-"+
			Util.add0(tempday.get(Calendar.MONTH) + 1, 2) +"-"+
        		Util.add0(tempday.get(Calendar.DAY_OF_MONTH), 2) ;
        	if(whereclause.equals(""))
        		whereclause+=" t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
        	else
        		whereclause+=" and t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
	}
	if(during==7){
		Calendar tempday = Calendar.getInstance();
		tempday.clear();
		tempday.set(year,0,1);
		String lastday=Util.add0(tempday.get(Calendar.YEAR), 4) +"-"+
			Util.add0(tempday.get(Calendar.MONTH) + 1, 2) +"-"+
        		Util.add0(tempday.get(Calendar.DAY_OF_MONTH), 2) ;
        	if(whereclause.equals(""))
        		whereclause+=" t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
        	else
        		whereclause+=" and t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
	}
	if(during==8){
		Calendar tempday = Calendar.getInstance();
		tempday.clear();
		tempday.set(year,month,day-365);
		String lastday=Util.add0(tempday.get(Calendar.YEAR), 4) +"-"+
			Util.add0(tempday.get(Calendar.MONTH) + 1, 2) +"-"+
        		Util.add0(tempday.get(Calendar.DAY_OF_MONTH), 2) ;
        	if(whereclause.equals(""))
        		whereclause+=" t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
        	else
        		whereclause+=" and t1.createdate<='"+today+"' and t1.createdate>='"+lastday+"'";
	}
		
}

if( isoracle ) {
    if(subday1!=0){
        if(whereclause.equals(""))	
            whereclause+="  (to_date(t1.lastoperatedate,'YYYY-MM-DD')-to_date(t1.createdate,'YYYY-MM-DD'))>"+subday1;
        else
            whereclause+=" and (to_date(t1.lastoperatedate,'YYYY-MM-DD')-to_date(t1.createdate,'YYYY-MM-DD'))>"+subday1;
    }

    if(subday2!=0){
        if(whereclause.equals(""))	
            whereclause+="  (to_date(t1.lastoperatedate,'YYYY-MM-DD')-to_date(t1.createdate,'YYYY-MM-DD'))<="+subday2;
        else
            whereclause+=" and (to_date(t1.lastoperatedate,'YYYY-MM-DD')-to_date(t1.createdate,'YYYY-MM-DD'))<="+subday2;
    }

    if(maxday!=0){
        if(whereclause.equals(""))	
            whereclause+="  (to_date(t1.lastoperatedate,'YYYY-MM-DD')-to_date(t1.createdate,'YYYY-MM-DD'))="+maxday;
        else
            whereclause+=" and (to_date(t1.lastoperatedate,'YYYY-MM-DD')-to_date(t1.createdate,'YYYY-MM-DD'))="+maxday;
    }
}else if( isdb2 ) {
    if(subday1!=0){
        if(whereclause.equals(""))	
            whereclause+="  (date(t1.lastoperatedate,'YYYY-MM-DD')-date(t1.createdate,'YYYY-MM-DD'))>"+subday1;
        else
            whereclause+=" and (date(t1.lastoperatedate,'YYYY-MM-DD')-date(t1.createdate,'YYYY-MM-DD'))>"+subday1;
    }

    if(subday2!=0){
        if(whereclause.equals(""))	
            whereclause+="  (date(t1.lastoperatedate,'YYYY-MM-DD')-date(t1.createdate,'YYYY-MM-DD'))<="+subday2;
        else
            whereclause+=" and (date(t1.lastoperatedate,'YYYY-MM-DD')-date(t1.createdate,'YYYY-MM-DD'))<="+subday2;
    }

    if(maxday!=0){
        if(whereclause.equals(""))	
            whereclause+="  (date(t1.lastoperatedate,'YYYY-MM-DD')-date(t1.createdate,'YYYY-MM-DD'))="+maxday;
        else
            whereclause+=" and (date(t1.lastoperatedate,'YYYY-MM-DD')-date(t1.createdate,'YYYY-MM-DD'))="+maxday;
    }
}
else {
    if(subday1!=0){
        if(whereclause.equals(""))	
            whereclause+="  (convert(datetime,t1.lastoperatedate)-convert(datetime,t1.createdate))>"+subday1;
        else
            whereclause+=" and (convert(datetime,t1.lastoperatedate)-convert(datetime,t1.createdate))>"+subday1;
    }

    if(subday2!=0){
        if(whereclause.equals(""))	
            whereclause+="  (convert(datetime,t1.lastoperatedate)-convert(datetime,t1.createdate))<="+subday2;
        else
            whereclause+=" and (convert(datetime,t1.lastoperatedate)-convert(datetime,t1.createdate))<="+subday2;
    }

    if(maxday!=0){
        if(whereclause.equals(""))	
            whereclause+=" (convert(datetime,t1.lastoperatedate)-convert(datetime,t1.createdate))="+maxday;
        else
            whereclause+=" and (convert(datetime,t1.lastoperatedate)-convert(datetime,t1.createdate))="+maxday;
    }
}

if(state==1){
	if(whereclause.equals("")) {whereclause+=" t1.currentnodetype='3'";}
	else {whereclause+=" and t1.currentnodetype='3'";}
}
if(state==2){
	if(whereclause.equals("")) {whereclause+=" t1.currentnodetype<>'3'";}
	else {whereclause+=" and t1.currentnodetype<>'3'";}
}

if(isdeleted!=2){
	if(whereclause.equals(""))	{
        if(isdeleted == 0) whereclause+=" (exists (select 1 from workflow_base where (isvalid=1 or isvalid=3) and workflow_base.id=t2.workflowid)) ";
        else whereclause += " exists (select 1 from workflow_base where (isvalid=0  or isvalid is null) and workflow_base.id=t2.workflowid) ";
    }
	else {
        if(isdeleted == 0) whereclause+=" and (exists (select 1 from workflow_base where (isvalid=1 or isvalid=3) and workflow_base.id=t2.workflowid)) ";
        else whereclause+=" and exists (select 1 from workflow_base where (isvalid=0  or isvalid is null) and workflow_base.id=t2.workflowid) ";
    }
}

if(!requestlevel.equals("")){
	if(whereclause.equals(""))	whereclause+=" t1.requestlevel="+requestlevel;
	else	whereclause+=" and t1.requestlevel="+requestlevel;
}


if(whereclause.equals("")) whereclause+="  islasttimes=1 ";
else whereclause+=" and islasttimes=1 ";

orderclause="t2.receivedate ,t2.receivetime";
orderclause2="t2.receivedate ,t2.receivetime";

SearchClause.setOrderClause(orderclause);
SearchClause.setOrderClause2(orderclause2);
SearchClause.setWhereClause(whereclause);

SearchClause.setWorkflowId(workflowid);
SearchClause.setNodeType(nodetype);
SearchClause.setFromDate(fromdate);
SearchClause.setToDate(todate);
SearchClause.setCreaterType(creatertype);
SearchClause.setCreaterId(createrid);
SearchClause.setRequestLevel(requestlevel);
SearchClause.setDepartmentid(cdepartmentid);
sendRedirect(out,request,response,"WFSearchResult.jsp?resourceid=" + resourceid + "&needHeader=" + needHeader  + "&query=1&pagenum=1&iswaitdo="+iswaitdo+"&docids="+docids+"&date2during="+date2during+"&viewType="+viewType);


%>















































<%!
	private String getLike(HttpServletRequest request,String parameter){
		parameter=request.getParameter(parameter);
		if(parameter==null){
			parameter="'%'";
		}else{
			parameter="'%"+parameter+"%'";
		}
		return parameter;
	}
%>
	
<%!
	private String getCount(HttpServletRequest request,HttpServletResponse response){
		String flowTitle=getLike(request,"flowTitle");//流程名称
		String workflowid = "";
		String nodetype = "";
		String fromdate = "";
		String todate = "";
		String creatertype = "";
		String createrid = "";
		String requestlevel = "";
		String fromdate2 = "";
		String todate2 = "";
		String workcode = "";
		String querys = Util.null2String(request.getParameter("query"));
		String fromself = Util.null2String(request.getParameter("fromself"));
		String fromselfSql = Util.null2String(request.getParameter("fromselfSql"));
		String isfirst = Util.null2String(request.getParameter("isfirst"));
		String docids = Util.null2String(request.getParameter("docids"));
		String flag = Util.null2String(request.getParameter("flag"));
		String branchid = "";
		String cdepartmentid = "";
		WorkflowComInfo WorkflowComInfo=null;
		try{
			WorkflowComInfo=new WorkflowComInfo();
		}catch(Exception e){
			
		}
		
		RecordSet RecordSet=new RecordSet();
		User user = HrmUserVarify.getUser (request , response) ;
		int usertype = 0;
		int date2during = Util.getIntValue(Util.null2String(request.getParameter("date2during")), 0);
		try {
			branchid = Util.null2String((String) request.getSession().getAttribute("branchid"));
		} catch (Exception e) {
			branchid = "";
		}
		BaseBean baseBean = new BaseBean();
		SearchClause SearchClause=(SearchClause)request.getSession().getAttribute("SearchClause");
		int isovertime = Util.getIntValue(request.getParameter("isovertime"), 0);
		


		workflowid = SearchClause.getWorkflowId();
		nodetype = SearchClause.getNodeType();
		fromdate = SearchClause.getFromDate();
		todate = SearchClause.getToDate();
		creatertype = SearchClause.getCreaterType();
		createrid = SearchClause.getCreaterId();
		requestlevel = SearchClause.getRequestLevel();
		fromdate2 = SearchClause.getFromDate2();
		todate2 = SearchClause.getToDate2();
		cdepartmentid = SearchClause.getDepartmentid();
		
		String newsql = "";
		if (!workflowid.equals("") && !workflowid.equals("0"))
			newsql += " and t1.workflowid in(" + workflowid + ")";
		if (date2during > 0 && date2during < 37)
			newsql += WorkflowComInfo.getDateDuringSql(date2during);
		if (fromself.equals("1")) {

			if (!nodetype.equals(""))
				newsql += " and t1.currentnodetype='" + nodetype + "'";

			if (!fromdate.equals(""))
				newsql += " and t1.createdate>='" + fromdate + "'";

			if (!todate.equals(""))
				newsql += " and t1.createdate<='" + todate + "'";

			if (!fromdate2.equals(""))
				newsql += " and t2.receivedate>='" + fromdate2 + "'";

			if (!todate2.equals(""))
				newsql += " and t2.receivedate<='" + todate2 + "'";

			if (!workcode.equals(""))
				newsql += " and t1.creatertype= '0' and t1.creater in(select id from hrmresource where workcode like '%" + workcode + "%')";

			if (!createrid.equals("")) {
				newsql += " and t1.creater='" + createrid + "'";
				newsql += " and t1.creatertype= '" + creatertype + "' ";
			}
			if (!cdepartmentid.equals("")) {
				String tempWhere = "";
				ArrayList tempArr = Util.TokenizerString(cdepartmentid, ",");
				for (int i = 0; i < tempArr.size(); i++) {
					String tempcdepartmentid = (String) tempArr.get(i);
					if (tempWhere.equals(""))
						tempWhere += "departmentid=" + tempcdepartmentid;
					else
						tempWhere += " or departmentid=" + tempcdepartmentid;
				}
				if (!tempWhere.equals(""))
					newsql += " and exists(select 1 from hrmresource where t1.creater=id and t1.creatertype='0' and (" + tempWhere + "))";
			}

			if (!requestlevel.equals("")) {
				newsql += " and t1.requestlevel=" + requestlevel;
			}

			if (!querys.equals("1")) {
				if (!fromselfSql.equals(""))
					newsql += " and " + fromselfSql;
			} else {
				if (fromself.equals("1"))
					newsql += " and  islasttimes=1 ";
			}

		}
		String resourceid = Util.null2String(request.getParameter("resourceid"));
		String CurrentUser = "".equals(resourceid) ? Util.null2String((String) request.getSession().getAttribute("RequestViewResource")) : resourceid;
		String userID = String.valueOf(user.getUID());
		int userid=user.getUID();
		String belongtoshow = "";				
								RecordSet.executeSql("select * from HrmUserSetting where resourceId = "+userID);
								if(RecordSet.next()){
									belongtoshow = RecordSet.getString("belongtoshow");
								}
		String userIDAll = String.valueOf(user.getUID());
		
String Belongtoids =user.getBelongtoids();
int Belongtoid=0;
String[] arr2 = null;
ArrayList<String> userlist = new ArrayList();
userlist.add(userid + "");
if(!"".equals(Belongtoids)){
userIDAll = userID+","+Belongtoids;
arr2 = Belongtoids.split(",");
for(int i=0;i<arr2.length;i++){
Belongtoid = Util.getIntValue(arr2[i]);
userlist.add(Belongtoid + "");
}
}
		String logintype = "" + user.getLogintype();
		if (logintype.equals("2"))
			usertype = 1;
		if (CurrentUser.equals("")) {
			CurrentUser = "" + user.getUID();
		}
		boolean superior = false; //是否为被查看者上级或者本身


		if (userID.equals(CurrentUser)) {
			superior = true;
		} else {
			RecordSet.executeSql("SELECT * FROM HrmResource WHERE ID = " + CurrentUser + " AND managerStr LIKE '%," + userID + ",%'");

			if (RecordSet.next()) {
				superior = true;
			}
		}

		String sqlwhere = "";
		if("1".equals(belongtoshow)){
		if (isovertime == 1) {
			sqlwhere = "where t1.requestname like "+flowTitle+" and  (t1.deleted <> 1 or t1.deleted is null or t1.deleted='') and t1.requestid = t2.requestid and t2.id in (Select max(z1.id) from workflow_currentoperator z1 where exists(select 1 from SysPoppupRemindInfonew z2 where  z1.requestid=z2.requestid and z2.type=10 and z2.userid in ("
					+ userIDAll
					+ ") and z2.usertype='"
					+ (Util.getIntValue(logintype, 1) - 1)
					+ "' and exists (select 1 from workflow_currentoperator z3 where z2.requestid=z3.requestid and ((z3.isremark='0' and (z3.isprocessed='2' or z3.isprocessed='3' or z3.isprocessed is null))  or z3.isremark='5') and z3.islasttimes=1)) group by z1.requestid)";
		} else {
			if (superior && !flag.equals(""))
				CurrentUser = userID;
			sqlwhere = "where  t1.requestname like "+flowTitle+" and   (t1.deleted <> 1 or t1.deleted is null or t1.deleted='') and t1.requestid = t2.requestid and t2.userid in (" + userIDAll + ") and t2.usertype=" + usertype;
			if (!Util.null2String(SearchClause.getWhereClause()).equals("")) {
				sqlwhere += " and " + SearchClause.getWhereClause();
				//out.print("sql***********"+SearchClause.getWhereClause());
			}
		}

		if (RecordSet.getDBType().equals("oracle")) {
			sqlwhere += " and (nvl(t1.currentstatus,-1) = -1 or (nvl(t1.currentstatus,-1)=0 and t1.creater in (" + userIDAll + "))) ";
		} else if(RecordSet.getDBType().equals("mysql")){
			sqlwhere += " and (ifnull(t1.currentstatus,-1) = -1 or (ifnull(t1.currentstatus,-1)=0 and t1.creater in (" + userIDAll + "))) ";
		}else {
			sqlwhere += " and (isnull(t1.currentstatus,-1) = -1 or (isnull(t1.currentstatus,-1)=0 and t1.creater (" + userIDAll + "))) ";
		}
		}else{
			if (isovertime == 1) {
			sqlwhere = "where t1.requestname like "+flowTitle+" and  (t1.deleted <> 1 or t1.deleted is null or t1.deleted='') and t1.requestid = t2.requestid and t2.id in (Select max(z1.id) from workflow_currentoperator z1 where exists(select 1 from SysPoppupRemindInfonew z2 where  z1.requestid=z2.requestid and z2.type=10 and z2.userid in ("
					+ user.getUID()
					+ ") and z2.usertype='"
					+ (Util.getIntValue(logintype, 1) - 1)
					+ "' and exists (select 1 from workflow_currentoperator z3 where z2.requestid=z3.requestid and ((z3.isremark='0' and (z3.isprocessed='2' or z3.isprocessed='3' or z3.isprocessed is null))  or z3.isremark='5') and z3.islasttimes=1)) group by z1.requestid)";
		} else {
			if (superior && !flag.equals(""))
				CurrentUser = userID;
			sqlwhere = "where  t1.requestname like "+flowTitle+" and   (t1.deleted <> 1 or t1.deleted is null or t1.deleted='') and t1.requestid = t2.requestid and t2.userid = " + CurrentUser + " and t2.usertype=" + usertype;
			if (!Util.null2String(SearchClause.getWhereClause()).equals("")) {
				sqlwhere += " and " + SearchClause.getWhereClause();
				//out.print("sql***********"+SearchClause.getWhereClause());
			}
		}

		if (RecordSet.getDBType().equals("oracle")) {
			sqlwhere += " and (nvl(t1.currentstatus,-1) = -1 or (nvl(t1.currentstatus,-1)=0 and t1.creater=" + user.getUID() + ")) ";
		} else if(RecordSet.getDBType().equals("mysql")){
			sqlwhere += " and (ifnull(t1.currentstatus,-1) = -1 or (ifnull(t1.currentstatus,-1)=0 and t1.creater = " + userIDAll + ")) ";
		}else {
			sqlwhere += " and (isnull(t1.currentstatus,-1) = -1 or (isnull(t1.currentstatus,-1)=0 and t1.creater=" + user.getUID() + ")) ";
		}
		}
		String orderby = "";
		sqlwhere += " " + newsql;
		orderby = SearchClause.getOrderClause();
		if (orderby.equals("")) {
			orderby = "t2.receivedate ,t2.receivetime";
		}
		String strworkflowid = "";
		int startIndex = 0;

		String fromhp = Util.null2String(request.getParameter("fromhp"));
		if (fromhp.equals("1")) {
			String eid = Util.null2String(request.getParameter("eid"));
			String tabid = Util.null2String(request.getParameter("tabid"));
			RecordSet.execute("select count(content) as count from workflowcentersettingdetail where  type = 'flowid' and eid=" + eid + "and tabId = '" + tabid + "'");
			if (RecordSet.next()) {
				if (RecordSet.getInt("count") > 0) {
					strworkflowid = " in (select content from workflowcentersettingdetail where  type = 'flowid' and eid=" + eid + "and tabId = '" + tabid + "' )";
				}
			}
		} else {

			if (!Util.null2String(SearchClause.getWhereClause()).equals("")) {
				String tempstr = SearchClause.getWhereClause();
				if (tempstr.indexOf("t1.workflowid") != -1) {
					startIndex = tempstr.indexOf("t1.workflowid") + 13;//added by xwj for td2045 on 2005-05-26
					if (tempstr.indexOf("and") != -1) {
						if (tempstr.indexOf("(t1.deleted=0") != -1) {
							int startIndex1 = tempstr.indexOf("and");
							int startIndex2 = tempstr.indexOf("and", startIndex1 + 1);
							strworkflowid = tempstr.substring(startIndex, startIndex2);
						} else {
							strworkflowid = tempstr.substring(startIndex, tempstr.indexOf("and"));
						}
						if (strworkflowid.indexOf("(") != -1 && strworkflowid.indexOf(")") == -1)
							strworkflowid += ")";
					} else
						strworkflowid = tempstr.substring(startIndex, tempstr.indexOf(")") + 1);
					if (strworkflowid.indexOf("(") != -1 && strworkflowid.indexOf(")") == -1)
						strworkflowid += ")";
				}
			} else {
				if (!workflowid.equals(""))
					strworkflowid = " in (" + workflowid + ")";
			}
		}
			
		String tableString = "";
	
		String backfields = " t1.requestid, t1.createdate, t1.createtime,t1.creater, t1.creatertype, t1.workflowid, t1.requestname, t1.status,t1.requestlevel,t1.currentnodeid,t2.viewtype,t2.receivedate,t2.receivetime,t2.isremark,t2.nodeid,t2.agentorbyagentid,t2.agenttype,t2.isprocessed ";
		String fromSql = " from workflow_requestbase t1,workflow_currentoperator t2 ";//xxxxx
		String sqlWhere = sqlwhere;
		if (sqlWhere.indexOf("in (select id from workflow_base where isvalid=") < 0) {
			sqlWhere += " and t1.workflowid in (select id from workflow_base where (isvalid='1' or isvalid='3') )";
		}
		String para2 = "column:requestid+column:workflowid+column:viewtype+" + isovertime + "+" + user.getLanguage() + "+column:nodeid+column:isremark+" + userID
				+ "+column:agentorbyagentid+column:agenttype+column:isprocessed";
		if (!docids.equals("")) {
			fromSql = fromSql + ",workflow_form t4 ";
			sqlWhere = sqlWhere + " and t1.requestid=t4.requestid ";
		}
	
		if (!superior) {
if("1".equals(belongtoshow)){
			sqlWhere += " AND EXISTS (SELECT 1 FROM workFlow_CurrentOperator workFlowCurrentOperator WHERE t2.workflowid = workFlowCurrentOperator.workflowid AND t2.requestid = workFlowCurrentOperator.requestid AND workFlowCurrentOperator.userid in ("
					+ userIDAll + ") and workFlowCurrentOperator.usertype = " + usertype + ") ";
}else{
			sqlWhere += " AND EXISTS (SELECT 1 FROM workFlow_CurrentOperator workFlowCurrentOperator WHERE t2.workflowid = workFlowCurrentOperator.workflowid AND t2.requestid = workFlowCurrentOperator.requestid AND workFlowCurrentOperator.userid in ("
					+ userID + ") and workFlowCurrentOperator.usertype = " + usertype + ") ";
}
		}
	
		if (!branchid.equals("")) {
			sqlWhere += " AND t1.creater in (select id from hrmresource where subcompanyid1=" + branchid + ")  ";
		}
		
		//add by bpf on 2013-11-14
		String countSql="select count(1) as wfCount "+fromSql+sqlWhere;
		try{
			response.getWriter().print(countSql);
			response.getWriter().print("                     ");
		}catch(Exception e){
			
		}
		
		RecordSet.executeSql(countSql);
		String wfCount="0";
	       while(RecordSet.next()){
	       	wfCount=RecordSet.getString("wfCount");
	       }
	       return wfCount;
	       
}
		%>