756873c148c4616d9e64b682ce51dc6a94702fa1.svn-base 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. /**
  2. *
  3. */
  4. package com.cockpit.service;
  5. import java.io.UnsupportedEncodingException;
  6. import java.net.URLDecoder;
  7. import java.sql.Connection;
  8. import java.sql.PreparedStatement;
  9. import java.sql.ResultSet;
  10. import java.sql.SQLException;
  11. import java.util.HashMap;
  12. import java.util.List;
  13. import java.util.Map;
  14. import java.util.StringTokenizer;
  15. import javax.servlet.http.HttpServletRequest;
  16. import javax.ws.rs.POST;
  17. import javax.ws.rs.Path;
  18. import javax.ws.rs.ProduceMime;
  19. import net.sf.json.JSONArray;
  20. import org.springframework.web.context.request.RequestContextHolder;
  21. import org.springframework.web.context.request.ServletRequestAttributes;
  22. import com.formaction.Utils;
  23. import com.google.gson.JsonArray;
  24. import com.persistence.DbConnection;
  25. import com.persistence.service.PersistenceFactory;
  26. import com.persistence.service.SysPersistence;
  27. import com.persistence.service.exception.PersistenceException;
  28. import com.cockpit.dao.OrganizationsBusi;
  29. import com.sinosoft.common.excel.JsonPluginsUtil;
  30. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  31. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  32. /**
  33. * @author 蒋云涛
  34. *
  35. */
  36. @Path("/IcingOrganizationsService/")
  37. public class OrganizationsService{
  38. /**
  39. * 将params 字符串转化为 map集合
  40. * @param params
  41. * @return
  42. */
  43. public Map<String,String> getMap(String params){
  44. Map<String,String> paramsMap = new HashMap<String,String>();
  45. StringTokenizer commaToker = new StringTokenizer(params, "&");
  46. String temp_str = "";
  47. while (commaToker.hasMoreTokens()) {
  48. temp_str = commaToker.nextToken();
  49. String[] key_value = temp_str.split("=");
  50. try {
  51. if(key_value.length==2){
  52. paramsMap.put(URLDecoder.decode(key_value[0], "utf-8"), URLDecoder.decode(key_value[1], "utf-8"));
  53. }else{
  54. paramsMap.put(URLDecoder.decode(key_value[0], "utf-8"),"");
  55. }
  56. } catch (UnsupportedEncodingException e) {
  57. e.printStackTrace();
  58. }
  59. }
  60. return paramsMap;
  61. }
  62. /**
  63. * 根据传来的的deptId 和id 判断是否为初次加载(因为初次加载时不会有id的值传入)
  64. * 如果是初次加载就加载传来id的机构信息和id下的一级子id 非初次加载就只显示 id下的一级子机构信息
  65. * 如果传来的参数中存在 per 表示要加载人员
  66. * @param params
  67. * @return
  68. */
  69. @ProduceMime("application/json")
  70. @POST
  71. @Path("/getOrgInfoById")
  72. public String getOrgInfoById(String params){
  73. boolean isFirstLoad=false;
  74. boolean getPerson = false;
  75. String deptid = Utils.getParameter("deptId", params) == null ? "" : Utils.getParameter(
  76. "deptId", params);
  77. String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter(
  78. "id", params);
  79. String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter(
  80. "type", params);
  81. String LoadCorp = Utils.getParameter("loadCorp", params) == null ? "" : Utils.getParameter(
  82. "loadCorp", params);
  83. boolean isOnlyLoadCorp = "loadCorp".equals(LoadCorp);
  84. String result = "";
  85. if(id==null||"".equals(id)){
  86. id=deptid;
  87. isFirstLoad=true;
  88. }
  89. if(type=="per"||"per".equals(type)){
  90. getPerson = true;
  91. }
  92. OrganizationsBusi orgbusi = new OrganizationsBusi();
  93. if(isOnlyLoadCorp){
  94. result = orgbusi.getOrgCorpById(id,isFirstLoad);
  95. }else{
  96. result = orgbusi.getOrgInfoById(id,getPerson,isFirstLoad);
  97. }
  98. return result;
  99. }
  100. /**
  101. * 内部机构的加载方法(也可以加载应急机构信息需在参数传入时添加loadOrgTable="emcOrg")
  102. * @param params
  103. * @return
  104. */
  105. @ProduceMime("application/json")
  106. @POST
  107. @Path("/loadSysOrgInfo")
  108. public String loadSysOrgInfo(String params){
  109. String result ="";
  110. Map<String,String> loadSysOrgInfo = new HashMap<String,String>();
  111. loadSysOrgInfo = getMap(params);
  112. OrganizationsBusi ob = new OrganizationsBusi();
  113. result = ob.loadSysOrgInfo2(loadSysOrgInfo);
  114. return result;
  115. }
  116. //新单位树除文件外的
  117. @ProduceMime("application/json")
  118. @POST
  119. @Path("/loadSysOrgInfo2")
  120. public String loadSysOrgInfo2(String params){
  121. String result ="";
  122. Map<String,String> loadSysOrgInfo = new HashMap<String,String>();
  123. loadSysOrgInfo = getMap(params);
  124. OrganizationsBusi ob = new OrganizationsBusi();
  125. result = ob.loadSysOrgInfo3(loadSysOrgInfo);
  126. return result;
  127. }
  128. @ProduceMime("application/json")
  129. @POST
  130. @Path("/loadSysOrgInfo20")
  131. public String loadSysOrgInfo20(String params){//通知单左侧数--gel
  132. String result ="";
  133. String uniteId = params.split("&")[0].split("=")[1];
  134. Map<String,String> loadSysOrgInfo = new HashMap<String,String>();
  135. loadSysOrgInfo = getMap(params);
  136. OrganizationsBusi ob = new OrganizationsBusi();
  137. result = ob.loadSysOrgInfo3(loadSysOrgInfo);
  138. //获取上级单位的ID和NAME
  139. String parentUnitMsg = getParentUnitMsg(uniteId);
  140. //System.out.println("//////////////"+parentUnitMsg);//78D3C3942A7E434DAB0D79F55C645232,广东电网有限责任公司
  141. Map<String, String> resultMap = JsonPluginsUtil.jsonToMap(result);
  142. Map<String, List<Map<String, String>>>tempList=new HashMap<String, List<Map<String,String>>>();
  143. String res = resultMap.get("treeNodes");
  144. List<Map<String, String>>resList=JsonPluginsUtil.jsonToMapList(res);
  145. Map<String, String> temMap = new HashMap<String, String>();
  146. temMap.put("id", parentUnitMsg.split(",")[0]);
  147. temMap.put("icon", "/nwyj/scripts/qui/libs/icons/folder.png");
  148. temMap.put("open", "true");
  149. temMap.put("parentId", "0");
  150. temMap.put("name", parentUnitMsg.split(",")[1]);
  151. temMap.put("isParent", "false");
  152. temMap.put("orgLevel", "null");
  153. resList.add(temMap);
  154. //resList=getTopComp(parentUnitMsg.split(",")[0],resList);
  155. tempList.put("treeNodes", resList);
  156. result=JSONArray.fromObject(tempList).toString();
  157. result=result.substring(1, result.length()-1);
  158. //System.out.println("***************"+result);
  159. return result;
  160. }
  161. public List<Map<String, String>> getTopComp(String dept_id,List<Map<String, String>>resultList){//递归钻去上级单位
  162. SysModel sysmodel = ModelFactory.getSysmodel();
  163. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  164. String sql="select dept_id,dept_name,parent_id from sys_department where dept_id='"+dept_id+"'";
  165. if(dept_id!="BBD3C37F68094363AABC3CAD5FEE0AF8"){//网公司ID
  166. try {
  167. List<String[]> colList = persistence.getSearchResult(99, sql.toString());
  168. if(colList!=null&&colList.size()>0){
  169. Map<String, String>temMap=new HashMap<String, String>();
  170. temMap.put("id",colList.get(0)[0]);
  171. temMap.put("icon", "/nwyj/scripts/qui/libs/icons/folder.png");
  172. temMap.put("open", "true");
  173. temMap.put("parentId", colList.get(0)[2]);
  174. temMap.put("name", colList.get(0)[1]);
  175. temMap.put("isParent", "false");
  176. temMap.put("orgLevel", "null");
  177. resultList.add(temMap);
  178. return getTopComp(colList.get(0)[2], resultList);
  179. }
  180. } catch (PersistenceException e) {
  181. // TODO Auto-generated catch block
  182. e.printStackTrace();
  183. }
  184. }else{
  185. return resultList;
  186. }
  187. return resultList;
  188. }
  189. public String getParentUnitMsg(String uniteId){//获取上级单位的单位ID和单位名称
  190. StringBuffer sb = new StringBuffer();
  191. String sql = "select DEPT_ID,DEPT_NAME from SYS_DEPARTMENT where DEPT_ID in (select PARENT_ID from SYS_DEPARTMENT where DEPT_ID='"+uniteId+"')";
  192. DbConnection dbConn = new DbConnection();//数据库连接
  193. Connection conn = null;
  194. PreparedStatement pstm = null;//sql语句的执行者
  195. ResultSet rs = null;//结果集
  196. try {
  197. conn = dbConn.getConnection();
  198. pstm = conn.prepareStatement(sql);
  199. rs = pstm.executeQuery();
  200. while(rs.next()){
  201. String a = rs.getString("DEPT_ID") == null ? "" : rs.getString("DEPT_ID");
  202. String b = rs.getString("DEPT_NAME") == null ? "" : rs.getString("DEPT_NAME");
  203. sb.append(a+","+b+",");
  204. }
  205. if(sb.lastIndexOf(",") > -1){
  206. sb.deleteCharAt(sb.lastIndexOf(","));
  207. }
  208. } catch (SQLException e) {
  209. e.printStackTrace();
  210. } catch (ClassNotFoundException e) {
  211. e.printStackTrace();
  212. }finally{
  213. try {
  214. if(rs!=null)
  215. rs.close();
  216. if(pstm!=null)
  217. pstm.close();
  218. if(conn!=null)
  219. conn.close();
  220. } catch (SQLException e) {
  221. e.printStackTrace();
  222. }
  223. }
  224. return sb.toString();
  225. }
  226. /**
  227. * 内部机构的加载方法(也可以加载应急机构信息需在参数传入时添加loadOrgTable="emcOrg")
  228. * @param params
  229. * @return
  230. */
  231. @ProduceMime("application/json")
  232. @POST
  233. @Path("/loadSysOrgInfo3")
  234. public String loadSysOrgInfo3(String params){
  235. String result ="";
  236. Map<String,String> loadSysOrgInfo = new HashMap<String,String>();
  237. loadSysOrgInfo = getMap(params);
  238. OrganizationsBusi ob = new OrganizationsBusi();
  239. result = ob.loadSysOrgInfo4(loadSysOrgInfo);
  240. return result;
  241. }
  242. //制度文件用简化型单位树
  243. @ProduceMime("application/json")
  244. @POST
  245. @Path("/loadSysOrgInfo4")
  246. public String loadSysOrgInfo4(String params){
  247. String result ="";
  248. Map<String,String> loadSysOrgInfo = new HashMap<String,String>();
  249. loadSysOrgInfo = getMap(params);
  250. OrganizationsBusi ob = new OrganizationsBusi();
  251. result = ob.loadSysOrgInfo5(loadSysOrgInfo);
  252. return result;
  253. }
  254. /**
  255. *
  256. * 外部机构的加载方法
  257. * @param params
  258. * @return
  259. */
  260. @ProduceMime("application/json")
  261. @POST
  262. @Path("/loadSysOrgOuterInfo")
  263. public String loadSysOrgOuterInfo(String params){
  264. String result ="";
  265. Map<String,String> loadSysOrgOuterInfo = new HashMap<String,String>();
  266. loadSysOrgOuterInfo = getMap(params);
  267. OrganizationsBusi ob = new OrganizationsBusi();
  268. result = ob.loadSysOrgOuterInfo(loadSysOrgOuterInfo);
  269. return result;
  270. }
  271. @ProduceMime("application/json")
  272. @POST
  273. @Path("/getOrgCorpById")
  274. public String getOrgCorpById(String params){
  275. boolean isFirstLoad=false;
  276. String deptid = Utils.getParameter("deptId", params) == null ? "" : Utils.getParameter(
  277. "deptId", params);
  278. String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter(
  279. "id", params);
  280. if(id==null||"".equals(id)){
  281. id=deptid;
  282. isFirstLoad=true;
  283. }
  284. OrganizationsBusi orgbusi = new OrganizationsBusi();
  285. String result = orgbusi.getOrgCorpById(id,isFirstLoad);
  286. return result;
  287. }
  288. /**
  289. * 根据传来的id加载出未显示的机构(人员)信息
  290. * @param params
  291. * @return
  292. */
  293. @ProduceMime("application/json")
  294. @POST
  295. @Path("/addOrgInfoById")
  296. public String addOrgInfoById(String params){
  297. HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
  298. String targetOrg = request.getParameter("targetOrg");
  299. /*String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter(
  300. "id", params);*/
  301. String orgLevel = Utils.getParameter("orgLevel", params) == null ? "" : Utils.getParameter(
  302. "orgLevel", params);
  303. String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter(
  304. "type", params);
  305. OrganizationsBusi orgbusi = new OrganizationsBusi();
  306. String LoadCorp = Utils.getParameter("loadCorp", params) == null ? "" : Utils.getParameter(
  307. "loadCorp", params);
  308. boolean isOnlyLoadCorp = "loadCorp".equals(LoadCorp);
  309. System.out.println(LoadCorp);
  310. String result = "";
  311. result = orgbusi.addOrgInfoById(targetOrg,orgLevel,type,isOnlyLoadCorp);
  312. return result;
  313. }
  314. /**
  315. * 根据传来的id 查询机构信息
  316. * @param params
  317. * @return
  318. */
  319. @ProduceMime("application/json")
  320. @POST
  321. @Path("/queryOrgInfo")
  322. public String queryOrgInfo(String params){
  323. String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter(
  324. "id", params);
  325. String role = Utils.getParameter("role", params) == null ? "" : Utils.getParameter(
  326. "role", params);
  327. OrganizationsBusi orgbusi = new OrganizationsBusi();
  328. String result = orgbusi.getParentOrgsInfoById(id,role);
  329. return result;
  330. }
  331. @ProduceMime("application/json")
  332. @POST
  333. @Path("/queryOrgByName")
  334. public String queryOrgByName(String params){
  335. String name = Utils.getParameter("name", params) == null ? "" : Utils.getParameter(
  336. "name", params);
  337. String type =Utils.getParameter("type", params) == null ? "" : Utils.getParameter(
  338. "type", params);
  339. String role =Utils.getParameter("role", params) == null ? "" : Utils.getParameter(
  340. "role", params);
  341. String LoadCorp = Utils.getParameter("loadCorp", params) == null ? "" : Utils.getParameter(
  342. "loadCorp", params);
  343. boolean isOnlyLoadCorp = "loadCorp".equals(LoadCorp);
  344. OrganizationsBusi orgbusi = new OrganizationsBusi();
  345. String result ="";
  346. if(isOnlyLoadCorp){
  347. result = orgbusi.getOrgCorpInfoByName(name,type,role);
  348. }else{
  349. result = orgbusi.getOrgInfoByName(name,type,role);
  350. }
  351. return result;
  352. }
  353. /***********************常用组织*****************************************/
  354. @ProduceMime("application/json")
  355. @POST
  356. @Path("/getCommonOrgInfoById")
  357. public String getCommonOrgInfoById(String params){
  358. String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter(
  359. "id", params);
  360. String type =Utils.getParameter("type", params) == null ? "" : Utils.getParameter(
  361. "type", params);
  362. String userId =Utils.getParameter("userId", params) == null ? "" : Utils.getParameter(
  363. "userId", params);
  364. String groupType =Utils.getParameter("groupType", params) == null ? "" : Utils.getParameter(
  365. "groupType", params);
  366. OrganizationsBusi orgbusi = new OrganizationsBusi();
  367. String result = orgbusi.getCommonOrgInfoById(id,type,userId,groupType);
  368. return result;
  369. }
  370. @ProduceMime("application/json")
  371. @POST
  372. @Path("/queryCommonOrgByName")
  373. public String queryCommonOrgByName(String params){
  374. String name = Utils.getParameter("name", params) == null ? "" : Utils.getParameter(
  375. "name", params);
  376. /*String type =Utils.getParameter("type", params) == null ? "" : Utils.getParameter(
  377. "type", params);*/
  378. String link_id =Utils.getParameter("link_id", params) == null ? "" : Utils.getParameter(
  379. "link_id", params);
  380. String userId =Utils.getParameter("userId", params) == null ? "" : Utils.getParameter(
  381. "userId", params);
  382. String groupType =Utils.getParameter("groupType", params) == null ? "" : Utils.getParameter(
  383. "groupType", params);
  384. OrganizationsBusi orgbusi = new OrganizationsBusi();
  385. String result = orgbusi.getCommonOrgInfoByName(name,link_id,userId,groupType);
  386. return result;
  387. }
  388. @ProduceMime("application/json")
  389. @POST
  390. @Path("/updateCommomGroupById")
  391. public String updateCommomGroupById(String params){
  392. String id = Utils.getParameter("id", params) == null ? "" :Utils.getParameter(
  393. "id", params);
  394. String name = Utils.getParameter("name", params) == null ? "" : Utils.getParameter(
  395. "name", params);
  396. String result="";
  397. if(!"".equalsIgnoreCase(id)){
  398. OrganizationsBusi orgbusi = new OrganizationsBusi();
  399. result = orgbusi.updateCommomGroupById(id,name);
  400. }
  401. return result;
  402. }
  403. @ProduceMime("application/json")
  404. @POST
  405. @Path("/addCommonOrgInfoById")
  406. public String addCommonOrgInfoById(String params){
  407. String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter(
  408. "id", params);
  409. String group_id = Utils.getParameter("group_id", params) == null ? "" : Utils.getParameter(
  410. "group_id", params);
  411. String groupType = Utils.getParameter("groupType", params) == null ? "" : Utils.getParameter(
  412. "groupType", params);
  413. OrganizationsBusi orgbusi = new OrganizationsBusi();
  414. //String[] ids=id.split(",");
  415. //Log.info(id+"========"+group_id);
  416. //String result = orgbusi.addCommonOrgInfoById(id,group_id);
  417. String result="";
  418. result = orgbusi.addCommonOrgInfoById(id,group_id,groupType);
  419. return result;
  420. }
  421. @ProduceMime("application/json")
  422. @POST
  423. @Path("/getCommonOrgGroupList")
  424. public String getCommonOrgGroupList(String params){
  425. String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter(
  426. "id", params);
  427. String userId =Utils.getParameter("userId", params) == null ? "" : Utils.getParameter(
  428. "userId", params);
  429. String groupType =Utils.getParameter("groupType", params) == null ? "" : Utils.getParameter(
  430. "groupType", params);
  431. OrganizationsBusi orgbusi = new OrganizationsBusi();
  432. String result = orgbusi.getCommonOrgGroupList(id,userId,groupType);
  433. return result;
  434. }
  435. @ProduceMime("application/json")
  436. @POST
  437. @Path("/addDiyGroup")
  438. public String addDiyGroup(String params){
  439. String linkCommId = Utils.getParameter("id", params) == null ? "" : Utils.getParameter(
  440. "id", params);
  441. String diyName = Utils.getParameter("diyName", params) == null ? "" : Utils.getParameter(
  442. "diyName", params);
  443. String userId =Utils.getParameter("userId", params) == null ? "" : Utils.getParameter(
  444. "userId", params);
  445. String outerOrInner =Utils.getParameter("outerOrInner", params) == null ? "" : Utils.getParameter(
  446. "outerOrInner", params);
  447. OrganizationsBusi orgbusi = new OrganizationsBusi();
  448. String result = orgbusi.addDiyGroup(linkCommId,diyName,userId,outerOrInner);
  449. return result;
  450. }
  451. @ProduceMime("application/json")
  452. @POST
  453. @Path("/deleteCommGroupById")
  454. public String deleteCommGroupById(String params){
  455. String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter(
  456. "id", params);
  457. String nodeType = Utils.getParameter("nodeType", params) == null ? "" : Utils.getParameter(
  458. "nodeType", params);
  459. OrganizationsBusi orgbusi = new OrganizationsBusi();
  460. String result = orgbusi.deleteCommGroupById(id,nodeType);
  461. return result;
  462. }
  463. /******************人员角色处理*****************/
  464. @ProduceMime("application/json")
  465. @POST
  466. @Path("/updateInlinkRole")
  467. public String updateInlinkRole(String params){
  468. String deptId = Utils.getParameter("deptId", params) == null ? "" : Utils.getParameter(
  469. "deptId", params);
  470. String userId = Utils.getParameter("userId", params) == null ? "" : Utils.getParameter(
  471. "userId", params);
  472. String roleId = Utils.getParameter("roleId", params) == null ? "" : Utils.getParameter(
  473. "roleId", params);
  474. OrganizationsBusi orgbusi = new OrganizationsBusi();
  475. String result = orgbusi.updateInlinkRole(deptId,userId,roleId);
  476. return result;
  477. }
  478. @ProduceMime("application/json")
  479. @POST
  480. @Path("/deleteInlinkRole")
  481. public String deleteInlinkRole(String params){
  482. String deptId = Utils.getParameter("deptId", params) == null ? "" : Utils.getParameter(
  483. "deptId", params);
  484. String userId = Utils.getParameter("userId", params) == null ? "" : Utils.getParameter(
  485. "userId", params);
  486. OrganizationsBusi orgbusi = new OrganizationsBusi();
  487. String result = orgbusi.deleteInlinkRole(deptId,userId);
  488. return result;
  489. }
  490. @ProduceMime("application/json")
  491. @POST
  492. @Path("/getUnitTree")
  493. public String getUnitTree(String params){//应急处置下的通知单,政府应急动态页面左侧的单位树
  494. String unitId = params.split("&")[0].split("=")[1];//本级单位ID
  495. StringBuffer sb = new StringBuffer();
  496. OrganizationsBusi ob = new OrganizationsBusi();
  497. String parentUnitId = ob.getParentUnitMsg(unitId);//获取上级单位的单位ID和单位NAME
  498. String unit_Id = ob.getUnitMsg(unitId);//获取本单位的单位NAME
  499. String childrenUnitId = ob.getchlidrenUnitMsg(unitId);//获取下级单位的单位ID和单位NAME
  500. int n = childrenUnitId.split(";").length;
  501. sb.append("{\"treeNodes\":[");
  502. if("".equals(parentUnitId)){
  503. }else{
  504. //上级单位
  505. sb.append("{\"id\":\""+parentUnitId.split(",")[0]+"\",\"name\":\""+parentUnitId.split(",")[1]+"\",\"parentId\":\"0\",\"open\":\"true\",\"icon\":\"/nwyj/scripts/qui/libs/icons/folder.png\"},");
  506. }
  507. //本级单位
  508. sb.append("{\"id\":\""+unit_Id.split(",")[0]+"\",\"name\":\""+unit_Id.split(",")[1]+"\",\"parentId\":\""+parentUnitId.split(",")[0]+"\",\"open\":\"true\",\"icon\":\"/nwyj/scripts/qui/libs/icons/folder.png\"},");
  509. if("".equals(childrenUnitId)){
  510. }else{
  511. //下级单位
  512. for(int i=0;i<n;i++){
  513. sb.append("{\"id\":\""+childrenUnitId.split(";")[i].split(",")[0]+"\",\"name\":\""+childrenUnitId.split(";")[i].split(",")[1]+"\",\"parentId\":\""+unitId+"\",\"open\":\"false\",\"icon\":\"/nwyj/scripts/qui/libs/icons/folder.png\"},");
  514. }
  515. }
  516. if(sb.lastIndexOf(",") > -1){
  517. sb.deleteCharAt(sb.lastIndexOf(","));
  518. }
  519. sb.append("]}");
  520. //System.out.println("************************"+sb.toString());
  521. return sb.toString();
  522. }
  523. }