97a050c53c60d04ef138b7fd02be237171820dc3.svn-base 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**
  2. *
  3. */
  4. package com.sinosoft.am.org.dept.outdept.busi;
  5. import java.util.ArrayList;
  6. import com.persistence.service.PersistenceFactory;
  7. import com.persistence.service.SysPersistence;
  8. import com.persistence.service.exception.PersistenceException;
  9. import com.sinosoft.am.org.dept.outdept.dao.OrgOutDeptDao;
  10. import com.sinosoft.am.org.dept.outdept.vo.OrgOutDeptStatistics;
  11. import com.sinosoft.am.org.dept.outdept.vo.OrgOutDeptVo;
  12. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  13. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  14. import org.apache.log4j.Logger;
  15. /**
  16. * @author 蒋云涛
  17. *
  18. */
  19. public class OrgOutDeptBean {
  20. private Logger log = Logger.getLogger(OrgOutDeptBean.class);
  21. private OrgOutDeptDao dao = new OrgOutDeptDao();
  22. public ArrayList<OrgOutDeptVo> getOrgOutDeptList(String parentId){
  23. return dao.getOrgOutDeptList(parentId);
  24. }
  25. public boolean deleteOrgOutDept(String deptId){
  26. return dao.deleteOrgOutDept(deptId);
  27. }
  28. public boolean editOrgOutDeptName(String deptId,String deptName){
  29. return dao.editOrgOutDeptName(deptId, deptName);
  30. }
  31. public boolean addOrgOutDept(String deptId,String parentId,String deptName){
  32. return dao.addOrgOutDept(deptId, parentId, deptName);
  33. }
  34. public boolean updateOrgOutDeptName(String deptId, String deptName){
  35. return dao.updateOrgOutDeptName(deptId, deptName);
  36. }
  37. public boolean shamDeleteOrgOutDept(String deptId){
  38. return dao.shamDeleteOrgOutDept(deptId);
  39. }
  40. /** 统计外部机构信息 根据传来的id 判断该id下的机构的人员信息
  41. * 1.先找到传来id下的所有机构信息 compids
  42. * 2.判断每一个id下的人员数量
  43. *
  44. * @param deptId
  45. * @return
  46. */
  47. public String getOutStatistics(String deptId) {
  48. StringBuffer json = new StringBuffer();
  49. //非空校验
  50. if(deptId==null||""==deptId){
  51. return json.toString();
  52. }
  53. ArrayList<String> compIds = new ArrayList<String>();
  54. OrgOutDeptDao oodd = new OrgOutDeptDao();
  55. ArrayList<OrgOutDeptVo> oodv = oodd.getOrgOutDeptList(deptId);
  56. for(int i = 0;i<oodv.size();i++){
  57. compIds.add(oodv.get(i).getFdObjectid());
  58. }
  59. json.append("{\"rows\":[");
  60. json.append(getOutOrgNumById(deptId));
  61. if (json.lastIndexOf(",") > -1) {
  62. json.deleteCharAt(json.lastIndexOf(","));
  63. }
  64. json.append("]}");
  65. return json.toString();
  66. }
  67. /**
  68. * @param string
  69. * @return
  70. */
  71. private String getOutOrgNumById(String compId) {
  72. SysModel sysmodel = ModelFactory.getSysmodel();
  73. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  74. StringBuffer json = new StringBuffer();
  75. StringBuffer sql = new StringBuffer();
  76. if("".equals(compId)||compId==null){
  77. return json.toString();
  78. };
  79. sql.append("-- 统计给定id的机构信息 \n");
  80. sql.append(" SELECT b.ORG_DEPT_NAME AS 部门名称 ,SUM(DECODE(a.ORG_TYPE,'1',1,0)) AS 政府机关, SUM(DECODE(a.ORG_TYPE,'2',1,0)) AS 教育, SUM(DECODE(a.ORG_TYPE,'4',1,0)) AS 卫生, SUM(DECODE(a.ORG_TYPE,'3',1,0)) AS 公安, SUM(DECODE(a.ORG_TYPE,'5',1,0)) AS 消防, \n");
  81. sql.append(" SUM(DECODE(a.ORG_TYPE,'6',1,0)) AS 三防, SUM(DECODE(a.ORG_TYPE,'7',1,0)) AS 厂家, SUM(DECODE(a.ORG_TYPE,'8',1,0)) AS 重要用户, SUM(DECODE(a.ORG_TYPE,'9',1,0)) AS 其他 ,SUM(1) AS 总计 FROM EMC_AM_ORG_OUTLINK a,EMC_AM_OUT_DEPARTMENT b \n");
  82. sql.append(" WHERE a.ORG_DEPT_ID = b.FD_OBJECTID AND a.ORG_DEPT_ID IN \n ");
  83. sql.append("( SELECT c.FD_OBJECTID FROM EMC_AM_OUT_DEPARTMENT c WHERE c.PARENT_ID='"+compId+"' AND c.IS_DEL='0') AND a.IS_DEL='0' \n");
  84. sql.append(" GROUP BY b.ORG_DEPT_NAME \n");
  85. log.info("sql=========="+sql);
  86. ArrayList<String[]> list;
  87. try {
  88. list = persistence.getSearchResult(99, sql.toString());
  89. for(int i = 0 ;i<list.size();i++){
  90. String[] temp = list.get(i);
  91. json.append("{");
  92. json.append("\"deptName\":\""+temp[0]+"\",");
  93. json.append("\"eduNum\":\""+temp[2]+"\",");
  94. json.append("\"elseNum\":\""+temp[9]+"\",");
  95. json.append("\"factoryNum\":\""+temp[7]+"\",");
  96. json.append("\"fireNum\":\""+temp[5]+"\",");
  97. json.append("\"policeNum\":\""+temp[3]+"\",");
  98. json.append("\"threeProofNum\":\""+temp[6]+"\",");
  99. json.append("\"totalNum\":\""+temp[10]+"\",");
  100. json.append("\"healthNum\":\""+temp[4]+"\",");
  101. json.append("\"govNum\":\""+temp[1]+"\",");
  102. json.append("\"importUserNum\":\""+temp[8]+"\"");
  103. json.append("},");
  104. }
  105. /*if (json.lastIndexOf(",") > -1) {
  106. json.deleteCharAt(json.lastIndexOf(","));
  107. }*/
  108. } catch (PersistenceException e) {
  109. e.printStackTrace();
  110. }
  111. return json.toString();
  112. }
  113. }