783d433586b8bac57fc6c7ded5d255c1d1d36c1c.svn-base 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. package com.sinosoft.em.operation.dao;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.SQLException;
  5. import java.util.ArrayList;
  6. import java.util.HashMap;
  7. import java.util.List;
  8. import java.util.Map;
  9. import org.apache.log4j.Logger;
  10. import com.formaction.Parameter;
  11. import com.formaction.vo.Msg;
  12. import com.persistence.DbConnection;
  13. import com.persistence.service.PersistenceFactory;
  14. import com.persistence.service.SysPersistence;
  15. import com.sinosoft.am.org.jdbcUtil.ORGTemplate;
  16. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  17. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  18. public class OperationDao {
  19. private Logger log = Logger.getLogger(this.getClass());
  20. SysModel sysmodel = ModelFactory.getSysmodel();
  21. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  22. public Msg getPublish(String fd_id) throws ClassNotFoundException{
  23. Msg m=new Msg();
  24. String []arr=fd_id.split(",");
  25. String sql="UPDATE ECM_EM_GW_PHTOT SET STATE='2' WHERE FD_OBJECTID=?";
  26. Connection conn = null;
  27. PreparedStatement st = null;
  28. int num=0;
  29. DbConnection db = new DbConnection();
  30. try {
  31. conn = db.getConnection();
  32. conn.setAutoCommit(false);
  33. st = conn.prepareStatement(sql);
  34. for(int i=0;i<arr.length;i++){
  35. st.setString(1, arr[i]);
  36. st.executeUpdate();
  37. num++;
  38. }
  39. if(num==arr.length){
  40. log.info("发布----num===="+num);
  41. m.setSucsess(new Boolean(true).toString());
  42. m.setInfo(Parameter.OPER_SUCSESS);
  43. conn.commit();
  44. return m;
  45. }else{
  46. m.setSucsess(new Boolean(false).toString());
  47. m.setInfo(Parameter.OPER_FAILURE);
  48. conn.rollback();
  49. return m;
  50. }
  51. }catch (SQLException e) {
  52. this.log.error(e.getMessage(), e);
  53. throw new ClassNotFoundException("DAO Layou: 发布消息"
  54. + sql, e);
  55. } finally {
  56. db.close(st);
  57. db.close(conn);
  58. }
  59. }
  60. /***************************2016-08-30 唐群胜*****************************/
  61. public String getTranferMan1(Map<String, String> loadSysOrgInfo){
  62. // String Unit = Utils.getParameter("Unit", params)==null?"":Utils.getParameter("Unit", params);
  63. String deptid = loadSysOrgInfo.get("deptId");
  64. String id =loadSysOrgInfo.get("id");
  65. boolean isFirstLoad = (id==null||"".equals(id))?true:false;//是否是第一次加载
  66. String loadId = isFirstLoad?deptid:id;
  67. ORGTemplate org = new ORGTemplate();
  68. StringBuffer sql2 = new StringBuffer();
  69. StringBuffer sql3 = new StringBuffer();
  70. StringBuffer json = new StringBuffer();
  71. StringBuffer sql_man = new StringBuffer();
  72. String isOpen = "'true' \"isParent\", ";
  73. List<Map<String,String>> list2 = new ArrayList<Map<String,String>>();
  74. List<Map<String,String>> list3 = new ArrayList<Map<String,String>>();
  75. List<Map<String,String>> list_man = new ArrayList<Map<String,String>>();
  76. json.append("{\"treeNodes\":[");
  77. if(isFirstLoad){
  78. //下级以外
  79. sql2.append("select DEPT_ID \"id\" , PARENT_ID \"parentId\" , DEPT_NAME \"name\" , DEPT_LEVEL \"orgLevel\" , \n");
  80. sql2.append("DECODE(DEPT_ID, '"+loadId+"', 'true', 'false') \"open\", \n");
  81. sql2.append(isOpen);
  82. sql2.append("DECODE(IS_VIRTUAL, '1', '/nwyj/scripts/qui/libs/icons/selected.png', '/nwyj/scripts/qui/libs/icons/selected.png') \"icon\" \n");
  83. sql2.append("from( select dept_id ,dept_name, parent_id,sort,dept_type,DEPT_LEVEL,IS_VIRTUAL from sys_department where dept_id='"+loadId+"' \n");
  84. sql2.append("union select dept_id , dept_name, parent_id, sort, dept_type, DEPT_LEVEL, IS_VIRTUAL from sys_department where parent_id='"+loadId+"' ) where dept_type='2' order by dept_type, sort");
  85. //根节点
  86. sql3.append("select DEPT_ID \"id\" , PARENT_ID \"parentId\" , DEPT_NAME \"name\" , DEPT_LEVEL \"orgLevel\" , \n");
  87. sql3.append("DECODE(DEPT_ID, '"+loadId+"', 'true', 'false') \"open\", 'false' \"isParent\" , \n");
  88. sql3.append("DECODE(IS_VIRTUAL, '1', '/nwyj/scripts/qui/libs/icons/selected.png', '/nwyj/scripts/qui/libs/icons/selected.png') \"icon\" \n");
  89. sql3.append("from( select dept_id ,dept_name, parent_id,sort,dept_type,DEPT_LEVEL,IS_VIRTUAL from sys_department where dept_id='"+loadId+"' \n");
  90. sql3.append("union select dept_id , dept_name, parent_id, sort, dept_type, DEPT_LEVEL, IS_VIRTUAL from sys_department where parent_id='"+loadId+"' ) where dept_id='"+loadId+"' order by dept_type, sort");
  91. }else{
  92. //下级以外
  93. sql2.append("select DEPT_ID \"id\" , PARENT_ID \"parentId\" , DEPT_NAME \"name\" , DEPT_LEVEL \"orgLevel\" , \n");
  94. sql2.append("DECODE(DEPT_ID, '"+loadId+"', 'true', 'false') \"open\", \n");
  95. sql2.append(isOpen);
  96. sql2.append("DECODE(IS_VIRTUAL, '1', '/nwyj/scripts/qui/libs/icons/selected.png', '/nwyj/scripts/qui/libs/icons/selected.png') \"icon\" \n");
  97. sql2.append("from( select dept_id ,dept_name, parent_id,sort,dept_type,DEPT_LEVEL,IS_VIRTUAL from sys_department where dept_id='"+loadId+"' \n");
  98. sql2.append("union select dept_id , dept_name, parent_id, sort, dept_type, DEPT_LEVEL, IS_VIRTUAL from sys_department where parent_id='"+loadId+"' ) where dept_type='2' and dept_id!='"+loadId+"' order by dept_type, sort");
  99. //根节点
  100. sql3.append("select DEPT_ID \"id\" , PARENT_ID \"parentId\" , DEPT_NAME \"name\" , DEPT_LEVEL \"orgLevel\" , \n");
  101. sql3.append("DECODE(DEPT_ID, '"+loadId+"', 'true', 'false') \"open\", 'false' \"isParent\" , \n");
  102. sql3.append("DECODE(IS_VIRTUAL, '1', '/nwyj/scripts/qui/libs/icons/selected.png', '/nwyj/scripts/qui/libs/icons/selected.png') \"icon\" \n");
  103. sql3.append("from( select dept_id ,dept_name, parent_id,sort,dept_type,DEPT_LEVEL,IS_VIRTUAL from sys_department where dept_id='"+loadId+"' \n");
  104. sql3.append("union select dept_id , dept_name, parent_id, sort, dept_type, DEPT_LEVEL, IS_VIRTUAL from sys_department where parent_id='"+loadId+"' ) where dept_id='"+loadId+"' order by dept_type, sort");
  105. }
  106. sql_man.append("WITH D AS ( SELECT * FROM SYS_DEPARTMENT WHERE IS_DEL='0'),M AS((SELECT U.FD_OBJECTID \"userFdId\" ,U.REAL_NAME \"userRealName\",U.USER_ID \"userId\",D.DEPT_ID \"deptId\",D.DEPT_NAME \"deptName\",D.CORP_ID \"corpId\" ,"
  107. + "D.CORP_NAME \"corpName\",U.EMAIL \"userEmail\",U.GENDER \"userGender\",U.MOBILE \"userPhone\" FROM SYS_DEPARTMENT D,SYS_USER_INFO U,SYS_DEPT_USER DU WHERE U.USER_ID = DU.USER_ID AND DU.DEPT_ID = D.DEPT_ID AND U.IS_DEL='0') "
  108. + "UNION (SELECT EI.FD_OBJECTID,EI.INLINK_NAME, EI.INLINK_INDEX,EI.VIRTUAL_ORG_ID,D.DEPT_NAME,D.CORP_ID,D.CORP_NAME,EI.EMAIL, '1', EI.PHONE FROM EMC_AM_ORG_INLINK EI,SYS_DEPARTMENT D, SYS_DEPT_USER DU WHERE "
  109. + "EI.INLINK_INDEX = DU.USER_ID AND DU.DEPT_ID= D.DEPT_ID AND EI.IS_DEL='0' ))");
  110. sql_man.append("SELECT \"userFdId\" \"id\",\"userRealName\" \"name\",\"deptId\" \"parentId\", 'per' \"leafType\", '/nwyj/scripts/qui/libs/icons/user_group.gif\' \"icon\" FROM M WHERE \"deptId\"='"+loadId+"' \n");
  111. try {
  112. //将sql语句查询出来的结果封装成集合
  113. log.info("sql2========"+sql2.toString());
  114. log.info("sql3========"+sql3.toString());
  115. list3 = org.query(sql3.toString());
  116. list2 = org.query(sql2.toString());
  117. list_man.addAll(org.query(sql_man.toString()));
  118. } catch (SQLException e) {
  119. e.printStackTrace();
  120. }
  121. if(isFirstLoad){
  122. json.append(org.listToString(list3));
  123. json.append(",");
  124. }
  125. json.append(org.listToString(list2));
  126. json.append(",");
  127. if(json.substring(json.length()-2,json.length()-1).equals("[")){
  128. json.deleteCharAt(json.lastIndexOf(","));
  129. }
  130. json.append(org.listToString(list_man));
  131. if(json.substring(json.length()-1).equals(",")){
  132. json.deleteCharAt(json.lastIndexOf(","));
  133. }
  134. json.append("]}");
  135. log.info("json.toString======="+json.toString());
  136. return json.toString();
  137. }
  138. }