870f6554972d0f88c9d49570b6e463c85ccc3c56.svn-base 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. package com.sinosoft.em.alert.notice.manage.dao;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8. import java.util.Map;
  9. import com.persistence.DbConnection;
  10. import com.persistence.service.JDBCHelper;
  11. import com.persistence.service.exception.PersistenceException;
  12. import com.sinosoft.em.alert.notice.manage.vo.TreatedHuman;
  13. import com.sinosoft.em.alert.report.manage.vo.ReportProgress;
  14. public class TreatedHumanDao {
  15. public ArrayList<TreatedHuman> queryData(String businessId) throws Exception {
  16. String sql = "select FD_OBJECTID,PERSON_ID,PERSON_NAME,UPDATEDATE,STATUES,DISPOSE,EXPLAIN,BUSINESS_ID from ECM_EM_TREATED_HUMAN where BUSINESS_ID=? and is_del=0 order by STATUES";
  17. DbConnection db = new DbConnection();
  18. Connection conn = null;
  19. PreparedStatement ps = null;
  20. ResultSet rs = null;
  21. try {
  22. conn = db.getConnection();
  23. ps = conn.prepareStatement(sql);
  24. ps.setString(1, businessId);
  25. rs = ps.executeQuery();
  26. ArrayList<TreatedHuman> datalist = new ArrayList<TreatedHuman>();
  27. while (rs.next()) {
  28. TreatedHuman person = new TreatedHuman();
  29. person.setFD_OBJECTID(rs.getString("FD_OBJECTID"));
  30. person.setPERSON_ID(rs.getString("PERSON_ID"));
  31. person.setPERSON_NAME(rs.getString("PERSON_NAME"));
  32. person.setSTATUES(rs.getString("STATUES"));
  33. String d = rs.getString("UPDATEDATE");
  34. if(d!=null&&d.length()>16){
  35. d = d.substring(0,19);
  36. }
  37. person.setUPDATEDATE(d);
  38. person.setDISPOSE(rs.getString("DISPOSE"));
  39. person.setEXPLAIN(rs.getString("EXPLAIN"));
  40. person.setBUSINESS_ID(rs.getString("BUSINESS_ID"));
  41. datalist.add(person);
  42. }
  43. return datalist;
  44. } catch (Exception e) {
  45. throw e;
  46. }finally{
  47. rs.close();
  48. ps.close();
  49. conn.close();
  50. }
  51. }
  52. /**
  53. * 根据公司Id,查询应急成员及手机号
  54. * @param companyIds
  55. * @return
  56. * @throws Exception
  57. */
  58. public Map<String,String> queryEmergencyPersonPhone(String companyIds) throws Exception {
  59. StringBuffer sql = new StringBuffer("SELECT o.MOBILE,o.REAL_NAME FROM SYS_USER_INFO o LEFT JOIN SYS_USER_ROLE_REL l ON o.USER_ID = l.USER_ID LEFT JOIN SYS_DEPT_USER r ON l.USER_ID = r.USER_ID LEFT JOIN SYS_DEPARTMENT t ON r.DEPT_ID = t.DEPT_ID ");
  60. sql.append(" WHERE l.ROLE_ID IN ('R002105430201', 'R002105430202', 'R002105430203', 'R002105430204', 'R002105430205')");
  61. sql.append(" AND t.CORP_ID IN ("+companyIds+");");
  62. DbConnection db = new DbConnection();
  63. Connection conn = null;
  64. PreparedStatement ps = null;
  65. ResultSet rs = null;
  66. try {
  67. conn = db.getConnection();
  68. ps = conn.prepareStatement(sql.toString());
  69. rs = ps.executeQuery();
  70. Map<String,String> mapList = new HashMap<String,String>();
  71. while (rs.next()) {
  72. mapList.put(rs.getString("MOBILE"),rs.getString("REAL_NAME"));
  73. }
  74. return mapList;
  75. } catch (Exception e) {
  76. throw e;
  77. }finally{
  78. rs.close();
  79. ps.close();
  80. conn.close();
  81. }
  82. }
  83. /**
  84. * 根据公司Id,查询应急成员及手机号
  85. * @param companyIds
  86. * @return
  87. * @throws Exception
  88. */
  89. public Map<String, Map<String, String>> queryEmergencyPersonName(String companyIds) throws Exception {
  90. StringBuffer sql = new StringBuffer("SELECT o.USER_ID,o.REAL_NAME,o.MOBILE,t.corp_name FROM SYS_USER_INFO o LEFT JOIN SYS_USER_ROLE_REL l ON o.USER_ID = l.USER_ID LEFT JOIN SYS_DEPT_USER r ON l.USER_ID = r.USER_ID LEFT JOIN SYS_DEPARTMENT t ON r.DEPT_ID = t.DEPT_ID ");
  91. sql.append(" WHERE l.ROLE_ID IN ('R002105430201', 'R002105430202', 'R002105430203', 'R002105430204', 'R002105430205')");
  92. sql.append(" AND t.CORP_ID IN ("+companyIds+");");
  93. DbConnection db = new DbConnection();
  94. Connection conn = null;
  95. PreparedStatement ps = null;
  96. ResultSet rs = null;
  97. try {
  98. conn = db.getConnection();
  99. ps = conn.prepareStatement(sql.toString());
  100. rs = ps.executeQuery();
  101. Map<String,String> mapList = new HashMap<String,String>();
  102. Map<String, Map<String, String>>tempMap=new HashMap<String, Map<String,String>>();//<公司名<人名,电话>>
  103. while (rs.next()) {
  104. if(tempMap.containsKey(rs.getString("CORP_NAME"))){
  105. Map<String, String>map=tempMap.get(rs.getString("CORP_NAME"));
  106. // map.put(rs.getString("USER_ID"),rs.getString("REAL_NAME"));
  107. map.put(rs.getString("MOBILE"),rs.getString("REAL_NAME"));
  108. tempMap.put(rs.getString("CORP_NAME"), map);
  109. }else{
  110. Map<String, String>map= new HashMap<String,String>();
  111. tempMap.put(rs.getString("CORP_NAME"), map);
  112. }
  113. // mapList.put(rs.getString("USER_ID"),rs.getString("REAL_NAME"));
  114. }
  115. return tempMap;
  116. } catch (Exception e) {
  117. throw e;
  118. }finally{
  119. rs.close();
  120. ps.close();
  121. conn.close();
  122. }
  123. }
  124. public Map<String, Map<String, String>> queryEmergencyPersonName1(String companyIds) throws Exception {
  125. // StringBuffer sql = new StringBuffer("SELECT o.USER_ID,o.REAL_NAME,o.MOBILE,t.corp_name FROM SYS_USER_INFO o LEFT JOIN SYS_USER_ROLE_REL l ON o.USER_ID = l.USER_ID LEFT JOIN SYS_DEPT_USER r ON l.USER_ID = r.USER_ID LEFT JOIN SYS_DEPARTMENT t ON r.DEPT_ID = t.DEPT_ID ");
  126. // sql.append(" WHERE l.ROLE_ID IN ('R002105430201', 'R002105430202', 'R002105430203', 'R002105430204', 'R002105430205')");
  127. // sql.append(" AND t.CORP_ID IN ("+companyIds+");");
  128. String sql = "select COMPID,NAME,TELPHONE,ISLEADER from SYS_MSG_USER where (COMPETENCY like '%R002105430201%' or COMPETENCY like '%R002105430201%' or COMPETENCY like '%R002105430202%' or COMPETENCY like '%R002105430203%' or COMPETENCY like '%R002105430204%' or COMPETENCY like '%R002105430205%') and COMPID in("+companyIds+") and is_del = '0'";
  129. StringBuffer sb = new StringBuffer();
  130. StringBuffer sbTel = new StringBuffer();
  131. DbConnection db = new DbConnection();
  132. Connection conn = null;
  133. PreparedStatement ps = null;
  134. ResultSet rs = null;
  135. try {
  136. conn = db.getConnection();
  137. ps = conn.prepareStatement(sql.toString());
  138. rs = ps.executeQuery();
  139. Map<String,String> mapList = new HashMap<String,String>();
  140. Map<String, Map<String, String>>tempMap=new HashMap<String, Map<String,String>>();//<公司名<人名,电话>>
  141. while (rs.next()) {
  142. if(tempMap.containsKey(getUniteName(rs.getString("COMPID")))){
  143. Map<String, String>map=tempMap.get(getUniteName(rs.getString("COMPID")));
  144. if(rs.getString("ISLEADER").equals("0")){//是领导
  145. map.put(rs.getString("TELPHONE")+"?",rs.getString("NAME"));
  146. }else{
  147. map.put(rs.getString("TELPHONE"),rs.getString("NAME"));
  148. }
  149. tempMap.put(getUniteName(rs.getString("COMPID")), map);
  150. }else{
  151. Map<String, String>map= new HashMap<String,String>();
  152. if(rs.getString("ISLEADER").equals("0")){//是领导
  153. map.put(rs.getString("TELPHONE")+"?",rs.getString("NAME"));
  154. }else{
  155. map.put(rs.getString("TELPHONE"),rs.getString("NAME"));
  156. }
  157. tempMap.put(getUniteName(rs.getString("COMPID")), map);
  158. }
  159. }
  160. return tempMap;
  161. } catch (Exception e) {
  162. throw e;
  163. }finally{
  164. rs.close();
  165. ps.close();
  166. conn.close();
  167. }
  168. }
  169. public String getUniteName(String unitID){//查询单位名称(通过单位ID)
  170. String sql = "select distinct CORP_NAME from SYS_DEPARTMENT where CORP_ID=?";
  171. StringBuffer sb = new StringBuffer();
  172. DbConnection db = new DbConnection();
  173. Connection conn = null;
  174. PreparedStatement ps = null;
  175. ResultSet rs = null;
  176. try {
  177. conn = db.getConnection();
  178. ps = conn.prepareStatement(sql);
  179. ps.setString(1, unitID);
  180. rs = ps.executeQuery();
  181. while(rs.next()){
  182. sb.append(rs.getString("CORP_NAME") == null ? "" : rs.getString("CORP_NAME"));
  183. }
  184. } catch (ClassNotFoundException e) {
  185. // TODO Auto-generated catch block
  186. e.printStackTrace();
  187. } catch (SQLException e) {
  188. // TODO Auto-generated catch block
  189. e.printStackTrace();
  190. }finally{
  191. try {
  192. if(rs!=null)
  193. rs.close();
  194. if(ps!=null)
  195. ps.close();
  196. if(conn!=null)
  197. conn.close();
  198. } catch (SQLException e) {
  199. e.printStackTrace();
  200. }
  201. }
  202. return sb.toString();
  203. }
  204. }