123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- /**
- *
- */
- package com.sinosoft.am.org.dept.outdept.busi;
- import java.util.ArrayList;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.SysPersistence;
- import com.persistence.service.exception.PersistenceException;
- import com.sinosoft.am.org.dept.outdept.dao.OrgOutDeptDao;
- import com.sinosoft.am.org.dept.outdept.vo.OrgOutDeptStatistics;
- import com.sinosoft.am.org.dept.outdept.vo.OrgOutDeptVo;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- import org.apache.log4j.Logger;
- /**
- * @author 蒋云涛
- *
- */
- public class OrgOutDeptBean {
- private Logger log = Logger.getLogger(OrgOutDeptBean.class);
- private OrgOutDeptDao dao = new OrgOutDeptDao();
-
- public ArrayList<OrgOutDeptVo> getOrgOutDeptList(String parentId){
-
- return dao.getOrgOutDeptList(parentId);
- }
- public boolean deleteOrgOutDept(String deptId){
-
- return dao.deleteOrgOutDept(deptId);
- }
- public boolean editOrgOutDeptName(String deptId,String deptName){
-
- return dao.editOrgOutDeptName(deptId, deptName);
- }
- public boolean addOrgOutDept(String deptId,String parentId,String deptName){
-
- return dao.addOrgOutDept(deptId, parentId, deptName);
-
- }
- public boolean updateOrgOutDeptName(String deptId, String deptName){
-
- return dao.updateOrgOutDeptName(deptId, deptName);
- }
- public boolean shamDeleteOrgOutDept(String deptId){
-
- return dao.shamDeleteOrgOutDept(deptId);
-
- }
- /** 统计外部机构信息 根据传来的id 判断该id下的机构的人员信息
- * 1.先找到传来id下的所有机构信息 compids
- * 2.判断每一个id下的人员数量
- *
- * @param deptId
- * @return
- */
- public String getOutStatistics(String deptId) {
- StringBuffer json = new StringBuffer();
- //非空校验
- if(deptId==null||""==deptId){
- return json.toString();
- }
- ArrayList<String> compIds = new ArrayList<String>();
- OrgOutDeptDao oodd = new OrgOutDeptDao();
- ArrayList<OrgOutDeptVo> oodv = oodd.getOrgOutDeptList(deptId);
- for(int i = 0;i<oodv.size();i++){
-
- compIds.add(oodv.get(i).getFdObjectid());
-
- }
- json.append("{\"rows\":[");
- json.append(getOutOrgNumById(deptId));
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- json.append("]}");
-
- return json.toString();
- }
- /**
- * @param string
- * @return
- */
- private String getOutOrgNumById(String compId) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json = new StringBuffer();
- StringBuffer sql = new StringBuffer();
- if("".equals(compId)||compId==null){
- return json.toString();
- };
- sql.append("-- 统计给定id的机构信息 \n");
- 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");
- 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");
- sql.append(" WHERE a.ORG_DEPT_ID = b.FD_OBJECTID AND a.ORG_DEPT_ID IN \n ");
- 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");
- sql.append(" GROUP BY b.ORG_DEPT_NAME \n");
- log.info("sql=========="+sql);
- ArrayList<String[]> list;
- try {
- list = persistence.getSearchResult(99, sql.toString());
- for(int i = 0 ;i<list.size();i++){
- String[] temp = list.get(i);
- json.append("{");
- json.append("\"deptName\":\""+temp[0]+"\",");
- json.append("\"eduNum\":\""+temp[2]+"\",");
- json.append("\"elseNum\":\""+temp[9]+"\",");
- json.append("\"factoryNum\":\""+temp[7]+"\",");
- json.append("\"fireNum\":\""+temp[5]+"\",");
- json.append("\"policeNum\":\""+temp[3]+"\",");
- json.append("\"threeProofNum\":\""+temp[6]+"\",");
- json.append("\"totalNum\":\""+temp[10]+"\",");
- json.append("\"healthNum\":\""+temp[4]+"\",");
- json.append("\"govNum\":\""+temp[1]+"\",");
- json.append("\"importUserNum\":\""+temp[8]+"\"");
- json.append("},");
- }
- /*if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }*/
-
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
-
- return json.toString();
- }
- }
|