534533ee9d6cec217360b755d8f50d447ce9fb2e.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. package com.sinosoft.lz.system.menu.dao;
  2. import java.sql.SQLException;
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7. import net.sf.json.JSONArray;
  8. import org.apache.log4j.Logger;
  9. import com.sinosoft.am.org.jdbcUtil.ORGTemplate;
  10. import com.sinosoft.lz.system.menu.vo.NoticeVo;
  11. public class NoticeDao {
  12. private final Logger log = Logger.getLogger(getClass());
  13. public String getNotice(String params) throws ClassNotFoundException{
  14. // System.out.println("**********///////////***********"+params);
  15. /*String sql = "select A.FD_OBJECTID ,A.EARLY_WARNING_NAME,A.WRITE_TIME ,B.DEPT_NAME , A.CURRENT_EW_LEVEL , A.CURRENT_ER_LEVEL ,A.IS_ALERT "+
  16. "from ECM_EM_PUBLISH_ALERT_NOTICE A,SYS_DEPARTMENT B "+
  17. "where is_alert='0' AND A.RELEASE_UNIT IN "+
  18. "(select corp_id from sys_department where ( parent_id='"+params+"' or corp_id='"+params+"') and dept_type=1 "+
  19. "union select parent_id from sys_department where dept_id='"+params+"' ) AND "+
  20. "write_time IN (SELECT MAX(WRITE_TIME) FROM ECM_EM_PUBLISH_ALERT_NOTICE WHERE IS_ALERT='0' AND IS_SEND='5') AND IS_SEND='5' "+
  21. "UNION "+
  22. "select A.FD_OBJECTID ,A.EARLY_WARNING_NAME,A.WRITE_TIME, B.DEPT_NAME , A.CURRENT_EW_LEVEL , A.CURRENT_ER_LEVEL ,A.IS_ALERT "+
  23. "from ECM_EM_PUBLISH_ALERT_NOTICE A,SYS_DEPARTMENT B "+
  24. "where is_alert='1' AND A.RELEASE_UNIT IN "+
  25. "(select corp_id from sys_department where ( parent_id='"+params+"' or corp_id='"+params+"') and dept_type=1 "+
  26. "union select parent_id from sys_department where dept_id='"+params+"' )AND "+
  27. " write_time IN (SELECT MAX(WRITE_TIME) FROM ECM_EM_PUBLISH_ALERT_NOTICE WHERE IS_ALERT='1' AND IS_SEND='5') AND IS_SEND='5' " ;*/
  28. String sql = " select A.FD_OBJECTID , A.EARLY_WARNING_NAME, A.RELEASE_RELIEVE_DATE , B.CORP_NAME , A.CURRENT_EW_LEVEL , A.CURRENT_ER_LEVEL , A.IS_ALERT " +
  29. " from ECM_EM_PUBLISH_ALERT_NOTICE A, SYS_DEPARTMENT B " +
  30. " where A.is_alert ='0' AND A.RELEASE_RELIEVE_DATE IN " +
  31. " (SELECT MAX(RELEASE_RELIEVE_DATE) FROM ECM_EM_PUBLISH_ALERT_NOTICE C " +
  32. " WHERE C.IS_ALERT='0' AND C.IS_SEND ='5' and " +
  33. " RELEASE_UNIT IN (select corp_id from sys_department " +
  34. " where (parent_id='" +params+ "' or corp_id='" +params+ "' ) and dept_type='1' " +
  35. " union " +
  36. " select parent_id from sys_department where dept_id='" +params+ "') " +
  37. " )AND A.IS_SEND='5' AND A.RELEASE_UNIT=B.dept_id " +
  38. " UNION " +
  39. " select A.FD_OBJECTID , A.EARLY_WARNING_NAME, A.RELEASE_RELIEVE_DATE , B.CORP_NAME , A.CURRENT_EW_LEVEL , A.CURRENT_ER_LEVEL ,A.IS_ALERT " +
  40. " from ECM_EM_PUBLISH_ALERT_NOTICE A, SYS_DEPARTMENT B " +
  41. " where A.is_alert ='1' AND A.RELEASE_RELIEVE_DATE IN " +
  42. " (SELECT MAX(RELEASE_RELIEVE_DATE) FROM ECM_EM_PUBLISH_ALERT_NOTICE C " +
  43. " WHERE C.IS_ALERT='1' AND C.IS_SEND ='5' and " +
  44. " RELEASE_UNIT IN (select corp_id from sys_department " +
  45. " where (parent_id='" +params+ "' or corp_id='" +params+ "')and dept_type='1' " +
  46. " union " +
  47. " select parent_id from sys_department where dept_id='" +params+ "') " +
  48. " )AND A.IS_SEND='5' AND A.RELEASE_UNIT=B.dept_id " ;
  49. List<NoticeVo> list2 = new ArrayList<NoticeVo>();
  50. try {
  51. List<Map<String,String>> list = new ORGTemplate().query(sql);
  52. for(int i=0;i<list.size();i++){
  53. Map<String,String> map = list.get(i);
  54. NoticeVo vo = new NoticeVo();
  55. vo.setCorpName(map.get("CORP_NAME"));
  56. vo.setFd_objectid(map.get("FD_OBJECTID"));
  57. vo.setIsAlert(map.get("IS_ALERT"));
  58. vo.setWarningName(map.get("EARLY_WARNING_NAME"));
  59. vo.setWriteTime(map.get("RELEASE_RELIEVE_DATE"));
  60. vo.setAlertcol(map.get("CURRENT_EW_LEVEL"));
  61. vo.setResponsecol(map.get("CURRENT_ER_LEVEL"));
  62. list2.add(vo);
  63. }
  64. } catch (SQLException e) {
  65. log.error(e.getMessage(),e);
  66. }
  67. return JSONArray.fromObject(list2).toString();
  68. }
  69. public String getIndexNotice(String corp_id,String parentID, String flag) throws ClassNotFoundException {
  70. StringBuffer sql = new StringBuffer();
  71. sql.append(" select distinct A.FD_OBJECTID ,A.PLAN_TYPE_ID,A.UPDATEDATE, A.EARLY_WARNING_NAME, A.RELEASE_RELIEVE_DATE , B.CORP_NAME , A.CURRENT_EW_LEVEL ,A.IS_SEND, A.CURRENT_ER_LEVEL ,A.IS_ALERT ");
  72. sql.append(" from ECM_EM_PUBLISH_ALERT_NOTICE A left join SYS_DEPARTMENT B ON B.DEPT_ID = A.RELEASE_UNIT ");
  73. sql.append(" left join ECM_EM_TREATED_HUMAN H ON A.FD_OBJECTID = H.BUSINESS_ID ");
  74. sql.append(" where A.is_del='0' and A.IS_SEND =='5' ");
  75. if("3".equals(flag)){
  76. sql.append(" and A.RELEASE_UNIT in ('"+corp_id+"') ");
  77. }else if("2".equals(flag)){
  78. sql.append(" and A.RELEASE_UNIT in ( '"+parentID+"' ) ");
  79. }else if("4".equals(flag)){
  80. sql.append(" and A.RELEASE_UNIT in (select DEPT_ID from SYS_DEPARTMENT where PARENT_ID='"+corp_id+"' ) ");
  81. }else{
  82. sql.append(" and ( A.RELEASE_UNIT in ('"+corp_id+"') or A.RELEASE_UNIT in ( '"+parentID+"' ) or A.RELEASE_UNIT in (select DEPT_ID from SYS_DEPARTMENT where PARENT_ID='"+corp_id+"' ) ) ");
  83. }
  84. sql.append(" order by A.UPDATEDATE DESC ");
  85. log.info("新预警与响应:"+sql);
  86. List<NoticeVo> list2 = new ArrayList<NoticeVo>();
  87. try {
  88. List<Map<String,String>> list = new ORGTemplate().query(sql.toString());
  89. for(int i=0;i<list.size();i++){
  90. Map<String,String> map = list.get(i);
  91. NoticeVo vo = new NoticeVo();
  92. vo.setCorpName(map.get("CORP_NAME"));
  93. vo.setFd_objectid(map.get("FD_OBJECTID"));
  94. vo.setIsAlert(map.get("IS_ALERT"));
  95. vo.setWarningName(map.get("EARLY_WARNING_NAME"));
  96. vo.setWriteTime(map.get("RELEASE_RELIEVE_DATE"));
  97. vo.setAlertcol(map.get("CURRENT_EW_LEVEL"));
  98. vo.setResponsecol(map.get("CURRENT_ER_LEVEL"));
  99. list2.add(vo);
  100. }
  101. } catch (SQLException e) {
  102. log.error(e.getMessage(),e);
  103. }
  104. log.info("新预警与响应数据:"+JSONArray.fromObject(list2).toString());
  105. return JSONArray.fromObject(list2).toString();
  106. }
  107. public String getNumbData(String corp_id, String parentID, String flag) {
  108. String result = "";
  109. StringBuffer sql1 = new StringBuffer();
  110. StringBuffer sql2 = new StringBuffer();
  111. StringBuffer sql3 = new StringBuffer();
  112. sql1.append(" select distinct A.FD_OBJECTID ,A.PLAN_TYPE_ID,A.UPDATEDATE, A.EARLY_WARNING_NAME, A.RELEASE_RELIEVE_DATE , B.CORP_NAME , A.CURRENT_EW_LEVEL ,A.IS_SEND, A.CURRENT_ER_LEVEL ,A.IS_ALERT ");
  113. sql1.append(" from ECM_EM_PUBLISH_ALERT_NOTICE A left join SYS_DEPARTMENT B ON B.DEPT_ID = A.RELEASE_UNIT ");
  114. sql1.append(" left join ECM_EM_TREATED_HUMAN H ON A.FD_OBJECTID = H.BUSINESS_ID ");
  115. sql1.append(" where A.is_del='0' and A.IS_SEND =='5' ");
  116. sql1.append(" and A.RELEASE_UNIT in ( '"+parentID+"' ) ");
  117. sql1.append(" order by A.UPDATEDATE DESC ");
  118. //sql.append(" UNION ALL ");
  119. sql2.append(" select distinct A.FD_OBJECTID ,A.PLAN_TYPE_ID,A.UPDATEDATE, A.EARLY_WARNING_NAME, A.RELEASE_RELIEVE_DATE , B.CORP_NAME , A.CURRENT_EW_LEVEL ,A.IS_SEND, A.CURRENT_ER_LEVEL ,A.IS_ALERT ");
  120. sql2.append(" from ECM_EM_PUBLISH_ALERT_NOTICE A left join SYS_DEPARTMENT B ON B.DEPT_ID = A.RELEASE_UNIT ");
  121. sql2.append(" left join ECM_EM_TREATED_HUMAN H ON A.FD_OBJECTID = H.BUSINESS_ID ");
  122. sql2.append(" where A.is_del='0' and A.IS_SEND =='5' ");
  123. sql2.append(" and A.RELEASE_UNIT in ('"+corp_id+"') ");
  124. sql2.append(" order by A.UPDATEDATE DESC ");
  125. //sql.append(" UNION ALL ");
  126. sql3.append(" select distinct A.FD_OBJECTID ,A.PLAN_TYPE_ID,A.UPDATEDATE, A.EARLY_WARNING_NAME, A.RELEASE_RELIEVE_DATE , B.CORP_NAME , A.CURRENT_EW_LEVEL ,A.IS_SEND, A.CURRENT_ER_LEVEL ,A.IS_ALERT ");
  127. sql3.append(" from ECM_EM_PUBLISH_ALERT_NOTICE A left join SYS_DEPARTMENT B ON B.DEPT_ID = A.RELEASE_UNIT ");
  128. sql3.append(" left join ECM_EM_TREATED_HUMAN H ON A.FD_OBJECTID = H.BUSINESS_ID ");
  129. sql3.append(" where A.is_del='0' and A.IS_SEND =='5' ");
  130. sql3.append(" and A.RELEASE_UNIT in (select DEPT_ID from SYS_DEPARTMENT where PARENT_ID='"+corp_id+"' ) ");
  131. sql3.append(" order by A.UPDATEDATE DESC ");
  132. //log.info("新预警与响应SQL:"+sql);
  133. List<NoticeVo> list = new ArrayList<NoticeVo>();
  134. try {
  135. List<Map<String,String>> list1 = new ORGTemplate().query(sql1.toString());
  136. for(int i=0;i<list1.size();i++){
  137. Map<String,String> map = list1.get(i);
  138. NoticeVo vo = new NoticeVo();
  139. vo.setCorpName(map.get("CORP_NAME"));
  140. vo.setFd_objectid(map.get("FD_OBJECTID"));
  141. vo.setIsAlert(map.get("IS_ALERT"));
  142. vo.setWarningName(map.get("EARLY_WARNING_NAME"));
  143. vo.setWriteTime(map.get("RELEASE_RELIEVE_DATE"));
  144. vo.setAlertcol(map.get("CURRENT_EW_LEVEL"));
  145. vo.setResponsecol(map.get("CURRENT_ER_LEVEL"));
  146. list.add(vo);
  147. }
  148. List<Map<String,String>> list2 = new ORGTemplate().query(sql2.toString());
  149. for(int i=0;i<list2.size();i++){
  150. Map<String,String> map = list2.get(i);
  151. NoticeVo vo = new NoticeVo();
  152. vo.setCorpName(map.get("CORP_NAME"));
  153. vo.setFd_objectid(map.get("FD_OBJECTID"));
  154. vo.setIsAlert(map.get("IS_ALERT"));
  155. vo.setWarningName(map.get("EARLY_WARNING_NAME"));
  156. vo.setWriteTime(map.get("RELEASE_RELIEVE_DATE"));
  157. vo.setAlertcol(map.get("CURRENT_EW_LEVEL"));
  158. vo.setResponsecol(map.get("CURRENT_ER_LEVEL"));
  159. list.add(vo);
  160. }
  161. List<Map<String,String>> list3 = new ORGTemplate().query(sql3.toString());
  162. for(int i=0;i<list3.size();i++){
  163. Map<String,String> map = list3.get(i);
  164. NoticeVo vo = new NoticeVo();
  165. vo.setCorpName(map.get("CORP_NAME"));
  166. vo.setFd_objectid(map.get("FD_OBJECTID"));
  167. vo.setIsAlert(map.get("IS_ALERT"));
  168. vo.setWarningName(map.get("EARLY_WARNING_NAME"));
  169. vo.setWriteTime(map.get("RELEASE_RELIEVE_DATE"));
  170. vo.setAlertcol(map.get("CURRENT_EW_LEVEL"));
  171. vo.setResponsecol(map.get("CURRENT_ER_LEVEL"));
  172. list.add(vo);
  173. }
  174. int num1=list1.size();
  175. int num2=list2.size();
  176. int num3=list3.size();
  177. int num4=num1+num2+num3;
  178. List<Map<String,String>> list4 = new ArrayList<Map<String,String>>();
  179. Map<String,String> map1 = new HashMap<String, String>();
  180. map1.put("num1", num4+"");
  181. map1.put("num2", num1+"");
  182. map1.put("num3", num2+"");
  183. map1.put("num4", num3+"");
  184. list4.add(map1);
  185. result = "[{\"listData\":"+JSONArray.fromObject(list).toString()+",\"numbdata\":"+JSONArray.fromObject(list4).toString()+"}]";
  186. } catch (SQLException e) {
  187. log.error(e.getMessage(),e);
  188. }
  189. //log.info("新预警与响应数据:"+JSONArray.fromObject(list).toString());
  190. log.info("新预警与响应数据:"+result);
  191. return result;
  192. }
  193. }