c22c60cd99fbe38e3e09d84c9b0e545c4dfb7e4b.svn-base 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package com.sinosoft.em.baobiao.xianlutingyun.dao;
  2. import java.sql.SQLException;
  3. import java.text.ParseException;
  4. import java.text.SimpleDateFormat;
  5. import java.util.ArrayList;
  6. import java.util.Date;
  7. import java.util.List;
  8. import java.util.Map;
  9. import net.sf.json.JSONArray;
  10. import com.sinosoft.am.org.jdbcUtil.ORGTemplate;
  11. public class GetSendPeopleDao {
  12. public ORGTemplate temp = null;
  13. public BaoBiaoDao dao = null;
  14. public ReportPlanDao plan = null;
  15. public GetSendPeopleDao(){
  16. temp = new ORGTemplate();
  17. dao = new BaoBiaoDao();
  18. plan = new ReportPlanDao();
  19. }
  20. public String getSendPeople(String roleId,String corpId,String wtData){
  21. String role = "";
  22. /*String compId = "";*/
  23. String sql ="";
  24. List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
  25. if("R002105430205".equals(roleId)){
  26. StringBuilder sb = new StringBuilder();
  27. StringBuilder s = new StringBuilder();
  28. String[] typeArr = wtData.split(",");
  29. for(int i=0;i<typeArr.length;i++){
  30. s.append("?,");
  31. }
  32. s = s.deleteCharAt(s.lastIndexOf(","));
  33. String getRole = "SELECT DISTINCT ROLE_ID FROM BM_MAPFORREPORT WHERE REPORT_TYPE IN ("+s.toString()+")";
  34. try {
  35. List<String> li = temp.getResultList(getRole, wtData+"_needUsein");
  36. for(int k=0;k<li.size();k++){
  37. sb.append("?,");
  38. role += li.get(k)+",";
  39. }
  40. sb = sb.deleteCharAt(sb.lastIndexOf(","));
  41. role = role.substring(0,role.lastIndexOf(","));
  42. sql = "SELECT DISTINCT A.REAL_NAME,A.MOBILE FROM SYS_USER_INFO A,SYS_DEPARTMENT B,SYS_USER_ROLE_REL C,SYS_ROLE D WHERE A.DEPT_ID = B.DEPT_ID AND "
  43. + " A.USER_ID = C.USER_ID AND C.ROLE_ID = D.ROLE_ID AND B.CORP_ID = ? AND D.ROLE_ID IN ("+sb.toString()+") AND A.MOBILE IS NOT NULL AND C.IS_DEL = '0'";
  44. resultList = temp.getSerachResult(sql, corpId,role+"_needUsein");
  45. } catch (SQLException e) {
  46. e.printStackTrace();
  47. }
  48. }else{
  49. //String compId = reportDept.split(":")[1].split(";")[1];
  50. int len = wtData.split(",").length;
  51. StringBuilder sb = new StringBuilder();
  52. for(int i=0;i<len;i++){
  53. sb.append("?,");
  54. }
  55. sb = sb.deleteCharAt(sb.lastIndexOf(","));
  56. sql = "SELECT DISTINCT A.REAL_NAME,A.MOBILE FROM SYS_USER_INFO A,SYS_DEPARTMENT B,SYS_USER_ROLE_REL C,SYS_ROLE D WHERE A.DEPT_ID = B.DEPT_ID AND "
  57. + "A.USER_ID = C.USER_ID AND C.ROLE_ID = D.ROLE_ID AND B.CORP_ID IN ("+sb.toString()+") AND D.ROLE_ID = ? AND A.MOBILE IS NOT NULL AND C.IS_DEL = '0'";
  58. try {
  59. resultList = temp.getSerachResult(sql, wtData+"_needUsein",roleId);
  60. } catch (SQLException e) {
  61. e.printStackTrace();
  62. }
  63. }
  64. System.out.println(JSONArray.fromObject(resultList).toString()+"========");
  65. return JSONArray.fromObject(resultList).toString();
  66. }
  67. }