ce95d4c83ad928935ab3768f4f4a7e2da9ef814d.svn-base 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. /**
  2. *
  3. */
  4. package com.sinosoft.lz.common.generaldata;
  5. import java.io.UnsupportedEncodingException;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8. import javax.ws.rs.*;
  9. import net.sf.json.JSONObject;
  10. import org.apache.log4j.Logger;
  11. import com.formaction.Utils;
  12. import com.persistence.service.JDBCHelper;
  13. import com.persistence.service.PersistenceFactory;
  14. import com.persistence.service.SysPersistence;
  15. import com.persistence.service.exception.PersistenceException;
  16. import com.sysmodel.datamodel.xmlmodel.DataContent;
  17. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  18. import com.sysmodel.datamodel.xmlmodel.able.MdpClass;
  19. import com.sysmodel.datamodel.xmlmodel.able.MdpConstant;
  20. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  21. import com.sinosoft.lz.system.constant.vo.ConstantVo;
  22. import com.sinosoft.lz.system.constant.vo.ConstantVos;
  23. /**
  24. * @author IBM
  25. *
  26. */
  27. @Path("/GeneraDataService/")
  28. public class GeneraDataService{
  29. private final Logger log = Logger.getLogger(getClass());
  30. /**
  31. * 查询公路局树形数据(只包括公路局(单位))
  32. *
  33. * @return json
  34. */
  35. @SuppressWarnings("rawtypes")
  36. @ProduceMime("application/json")
  37. @POST
  38. @Path("/geCommonUnit")
  39. public String geCommonUnit(String params) {
  40. String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node",
  41. params);
  42. SysModel sysmodel = ModelFactory.getSysmodel();
  43. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  44. ArrayList list = new ArrayList();
  45. StringBuffer sb = new StringBuffer();
  46. String sql = "select Dept_Id ,Dept_Name,FD_OBJECTID,type from Sys_Department where Depts_Id ='"
  47. + node
  48. + "' and type in ('1','2') and DeptMent_Type in( '3','4','6','10','20') and Is_Del='0' ORDER BY DeptMent_Type DESC,SORT";
  49. log.info("管理单位查询-----------" + sql);
  50. try {
  51. list = persistence.getSearchResult(800, sql);
  52. } catch (PersistenceException e) {
  53. log.error(e.getMessage(), e);
  54. }
  55. sb.append("[");
  56. if (!list.isEmpty()) {
  57. for (int i = 0; i < list.size(); i++) {
  58. String[] rs = (String[]) list.get(i);
  59. String code = rs[0] == null ? "" : rs[0];
  60. String name = rs[1] == null ? "" : rs[1];
  61. String fd_objectid = rs[2] == null ? "" : rs[2];
  62. String type = rs[3] == null ? "" : rs[3];
  63. if (isLeaf(code)) {
  64. if ("1".equals(type)) {
  65. sb.append("{text:'" + name + "',id:'" + code
  66. + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'"
  67. + fd_objectid + "',leaf:false},");
  68. } else if ("2".equals(type)) {
  69. sb.append("{text:'" + name + "',id:'" + code
  70. + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'"
  71. + fd_objectid + "',leaf:false},");
  72. }
  73. } else {
  74. if ("1".equals(type)) {
  75. sb.append("{text:'" + name + "',id:'" + code
  76. + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'"
  77. + fd_objectid + "',leaf:true},");
  78. } else if ("2".equals(type)) {
  79. sb.append("{text:'" + name + "',id:'" + code
  80. + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'"
  81. + fd_objectid + "',leaf:true},");
  82. }
  83. }
  84. }
  85. }
  86. if (sb.lastIndexOf(",") > -1) {
  87. sb.deleteCharAt(sb.lastIndexOf(","));
  88. }
  89. sb.append("]");
  90. return sb.toString();
  91. }
  92. /**
  93. * 查询公路局树形数据(只包括公路局(单位))
  94. *
  95. * @return json
  96. */
  97. @SuppressWarnings("rawtypes")
  98. @ProduceMime("application/json")
  99. @POST
  100. @Path("/getUnitJson")
  101. public String getUnitJson(String params) {
  102. String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node",
  103. params);
  104. SysModel sysmodel = ModelFactory.getSysmodel();
  105. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  106. ArrayList list = new ArrayList();
  107. StringBuffer sb = new StringBuffer();
  108. String sql = "select t1.Dept_Id ,t1.Dept_Name,t1.FD_OBJECTID,t1.type from Sys_Department t1 where t1.Depts_Id ='"
  109. + node + "' and t1.type in ('1','2') and t1.Is_Del='0'";
  110. try {
  111. list = persistence.getSearchResult(800, sql);
  112. } catch (PersistenceException e) {
  113. log.error(e.getMessage(), e);
  114. }
  115. sb.append("[");
  116. if (!list.isEmpty()) {
  117. for (int i = 0; i < list.size(); i++) {
  118. String[] rs = (String[]) list.get(i);
  119. String code = rs[0] == null ? "" : rs[0];
  120. String name = rs[1] == null ? "" : rs[1];
  121. String fd_objectid = rs[2] == null ? "" : rs[2];
  122. String type = rs[3] == null ? "" : rs[3];
  123. if (isLeaf(code)) {
  124. if ("1".equals(type)) {
  125. sb.append("{text:'" + name + "',id:'" + code
  126. + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'"
  127. + fd_objectid + "',leaf:false},");
  128. } else if ("2".equals(type)) {
  129. sb.append("{text:'" + name + "',id:'" + code
  130. + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'"
  131. + fd_objectid + "',leaf:false},");
  132. }
  133. } else {
  134. if ("1".equals(type)) {
  135. sb.append("{text:'" + name + "',id:'" + code
  136. + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'"
  137. + fd_objectid + "',leaf:true},");
  138. } else if ("2".equals(type)) {
  139. sb.append("{text:'" + name + "',id:'" + code
  140. + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'"
  141. + fd_objectid + "',leaf:true},");
  142. }
  143. }
  144. }
  145. }
  146. if (sb.lastIndexOf(",") > -1) {
  147. sb.deleteCharAt(sb.lastIndexOf(","));
  148. }
  149. sb.append("]");
  150. return sb.toString();
  151. }
  152. /**
  153. * 养护巡查 综合查询 管理单位
  154. *
  155. * @return json
  156. */
  157. @SuppressWarnings("rawtypes")
  158. @ProduceMime("application/json")
  159. @POST
  160. @Path("/getManagementJson")
  161. public String getManagementJson(String params) {
  162. String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node",
  163. params);
  164. SysModel sysmodel = ModelFactory.getSysmodel();
  165. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  166. ArrayList list = new ArrayList();
  167. StringBuffer sb = new StringBuffer();
  168. String sql = "select t1.Dept_Id ,t1.Dept_Name,t1.FD_OBJECTID,t1.type from Sys_Department t1 where t1.Depts_Id ='"
  169. + node + "' and t1.deptment_type in ('1','2','10','20') and t1.Is_Del='0'";
  170. try {
  171. list = persistence.getSearchResult(800, sql);
  172. } catch (PersistenceException e) {
  173. log.error(e.getMessage(), e);
  174. }
  175. sb.append("[");
  176. if (!list.isEmpty()) {
  177. for (int i = 0; i < list.size(); i++) {
  178. String[] rs = (String[]) list.get(i);
  179. String code = rs[0] == null ? "" : rs[0];
  180. String name = rs[1] == null ? "" : rs[1];
  181. String fd_objectid = rs[2] == null ? "" : rs[2];
  182. String type = rs[3] == null ? "" : rs[3];
  183. if (isLeaf(code)) {
  184. if ("1".equals(type)) {
  185. sb.append("{text:'" + name + "',id:'" + code
  186. + "',icon:'/yxwh/images/p1.png',fd_objectid:'" + fd_objectid
  187. + "',leaf:false},");
  188. } else if ("2".equals(type)) {
  189. sb.append("{text:'" + name + "',id:'" + code
  190. + "',icon:'/yxwh/images/road/png-0702.png',fd_objectid:'"
  191. + fd_objectid + "',leaf:false},");
  192. }
  193. } else {
  194. if ("1".equals(type)) {
  195. sb.append("{text:'" + name + "',id:'" + code
  196. + "',icon:'/yxwh/images/p1.png',fd_objectid:'" + fd_objectid
  197. + "',leaf:true},");
  198. } else if ("2".equals(type)) {
  199. sb.append("{text:'" + name + "',id:'" + code
  200. + "',icon:'/yxwh/images/road/png-0702.png',fd_objectid:'"
  201. + fd_objectid + "',leaf:true},");
  202. }
  203. }
  204. }
  205. }
  206. if (sb.lastIndexOf(",") > -1) {
  207. sb.deleteCharAt(sb.lastIndexOf(","));
  208. }
  209. sb.append("]");
  210. return sb.toString();
  211. }
  212. @SuppressWarnings("rawtypes")
  213. @ProduceMime("application/json")
  214. @POST
  215. @Path("/getDepJson")
  216. public String getDepJson(String params) {
  217. String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node",
  218. params);
  219. SysModel sysmodel = ModelFactory.getSysmodel();
  220. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  221. ArrayList list = new ArrayList();
  222. StringBuffer sb = new StringBuffer();
  223. String sql = "select t1.Dept_Id ,t1.Dept_Name,t1.FD_OBJECTID,t1.type from Sys_Department t1 where t1.Depts_Id ='"
  224. + node + "' and t1.type='2' and t1.Is_Del='0'";
  225. try {
  226. list = persistence.getSearchResult(800, sql);
  227. } catch (PersistenceException e) {
  228. log.error(e.getMessage(), e);
  229. }
  230. log.info("sql: " + sql);
  231. sb.append("[");
  232. if (!list.isEmpty()) {
  233. for (int i = 0; i < list.size(); i++) {
  234. String[] rs = (String[]) list.get(i);
  235. String code = rs[0] == null ? "" : rs[0];
  236. String name = rs[1] == null ? "" : rs[1];
  237. String fd_objectid = rs[2] == null ? "" : rs[2];
  238. String type = rs[3] == null ? "" : rs[3];
  239. if (isLeaf(code)) {
  240. if ("1".equals(type)) {
  241. sb.append("{text:'" + name + "',id:'" + code
  242. + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'"
  243. + fd_objectid + "',leaf:false},");
  244. } else if ("2".equals(type)) {
  245. sb.append("{text:'" + name + "',id:'" + code
  246. + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'"
  247. + fd_objectid + "',leaf:false},");
  248. }
  249. } else {
  250. if ("1".equals(type)) {
  251. sb.append("{text:'" + name + "',id:'" + code
  252. + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'"
  253. + fd_objectid + "',leaf:true},");
  254. } else if ("2".equals(type)) {
  255. sb.append("{text:'" + name + "',id:'" + code
  256. + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'"
  257. + fd_objectid + "',leaf:true},");
  258. }
  259. }
  260. }
  261. }
  262. if (sb.lastIndexOf(",") > -1) {
  263. sb.deleteCharAt(sb.lastIndexOf(","));
  264. }
  265. sb.append("]");
  266. return sb.toString();
  267. }
  268. // 判定是否有子节点
  269. @SuppressWarnings("rawtypes")
  270. public boolean isLeaf(String node) {
  271. boolean flag = false;
  272. SysModel sysmodel = ModelFactory.getSysmodel();
  273. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  274. ArrayList childList = new ArrayList();
  275. String sql = "select distinct t1.Dept_Id from Sys_Department t1 where t1.Depts_Id ='"
  276. + node + "' and t1.type in ('1','2') and t1.Is_Del='0'";
  277. try {
  278. childList = persistence.getSearchResult(800, sql);
  279. } catch (PersistenceException e) {
  280. log.error(e.getMessage(), e);
  281. }
  282. if (childList.size() > 0) {
  283. flag = true;
  284. }
  285. return flag;
  286. }
  287. /**
  288. * 更加单位id获取该单位的部门
  289. *
  290. * @param 单位id
  291. * @return
  292. */
  293. @SuppressWarnings({ "unchecked", "rawtypes" })
  294. @ProduceMime("application/json")
  295. @POST
  296. @Path("/getDepartementJson")
  297. public String getDepartment(String params) {
  298. String unitid = Utils.getParameter("unitid", params) == null ? "" : Utils.getParameter(
  299. "unitid", params);
  300. SysModel sysmodel = ModelFactory.getSysmodel();
  301. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  302. ArrayList list = new ArrayList();
  303. ArrayList listvo = new ArrayList();
  304. String sql = "select t1.Dept_Id ,t1.Dept_Name from Sys_Department t1 where t1.Depts_Id ='"
  305. + unitid + "' and t1.type='2' and t1.Is_Del='0'";
  306. ConstantVos cvos = new ConstantVos();
  307. try {
  308. list = persistence.getSearchResult(800, sql);
  309. if (!list.isEmpty()) {
  310. for (int i = 0; i < list.size(); i++) {
  311. ConstantVo cvo = new ConstantVo();
  312. String[] rs = (String[]) list.get(i);
  313. String code = rs[0] == null ? "" : rs[0];
  314. String name = rs[1] == null ? "" : rs[1];
  315. cvo.setName(name);
  316. cvo.setValue(code);
  317. listvo.add(cvo);
  318. }
  319. cvos.setConstants(listvo);
  320. }
  321. } catch (PersistenceException e) {
  322. log.error(e.getMessage(), e);
  323. }
  324. return JSONObject.fromObject(cvos).toString();
  325. }
  326. /**
  327. * 查询宁波市行政区划树形数据
  328. *
  329. * @return json
  330. */
  331. @SuppressWarnings("unused")
  332. @ProduceMime("application/json")
  333. @GET
  334. @Path("/getDistJson")
  335. public String getDistJson(String params) {
  336. String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node",
  337. params);
  338. SysModel sysmodel = ModelFactory.getSysmodel();
  339. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  340. MdpConstant mdpConstant = sysmodel.getMdpConstantByName("BM$_Dists");
  341. List<DataContent> childDataContents = mdpConstant.getChildDataContentByNodeID(node);
  342. StringBuffer sb = new StringBuffer();
  343. sb.append("[");
  344. if (childDataContents.size() > 0) {
  345. for (int i = 0; i < childDataContents.size(); i++) {
  346. DataContent fieldValue = (DataContent) childDataContents.get(i);
  347. String fd_code = (String) fieldValue.getValue("fd_code") == null ? ""
  348. : (String) fieldValue.getValue("fd_code");
  349. String fd_Name = (String) fieldValue.getValue("fd_name") == null ? ""
  350. : (String) fieldValue.getValue("fd_name");
  351. String fd_parentcode = (String) fieldValue.getValue("fd_parentcode") == null ? ""
  352. : (String) fieldValue.getValue("fd_parentcode");
  353. String fd_parentname = (String) fieldValue.getValue("fd_parentname") == null ? ""
  354. : (String) fieldValue.getValue("fd_parentname");
  355. String fd_province = (String) fieldValue.getValue("fd_province") == null ? ""
  356. : (String) fieldValue.getValue("fd_province");
  357. String fd_city = (String) fieldValue.getValue("fd_city") == null ? ""
  358. : (String) fieldValue.getValue("fd_city");
  359. if (mdpConstant.getChildDataContentByNodeID(fd_code).isEmpty()) {
  360. sb.append("{text:'")
  361. .append(fd_Name)
  362. .append("',id:'")
  363. .append(fd_code)
  364. .append("',fd_parentcode:'" + fd_parentcode + "',fd_province:'"
  365. + fd_province + "',fd_city:'" + fd_city + "',leaf:true},");
  366. } else {
  367. sb.append("{text:'")
  368. .append(fd_Name)
  369. .append("',id:'")
  370. .append(fd_code)
  371. .append("',fd_parentcode:'" + fd_parentcode + "',fd_parentname:'"
  372. + fd_parentname + "',fd_province:'" + fd_province
  373. + "',fd_city:'" + fd_city + "',leaf:false},");
  374. }
  375. }
  376. };
  377. if (sb.lastIndexOf(",") > -1) {
  378. sb.deleteCharAt(sb.length() - 1);
  379. }
  380. sb.append("]");
  381. return sb.toString();
  382. }
  383. /**
  384. * 判断管理单位 路线是否重复
  385. *
  386. * @return String
  387. * @throws UnsupportedEncodingException
  388. */
  389. @SuppressWarnings("rawtypes")
  390. @ProduceMime("application/json")
  391. @POST
  392. @Path("/judgeRoute")
  393. public String judgeRoute(String params) {
  394. ArrayList list = new ArrayList();
  395. int reValue = 0;
  396. try {
  397. params = java.net.URLDecoder.decode(params, "UTF-8");
  398. String manageCode = Utils.getParameter("magCode", params);// 管理单位代码
  399. String roadCode = Utils.getParameter("roadCode", params);// 路线代码
  400. SysModel sysmodel = ModelFactory.getSysmodel();
  401. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  402. String sql = "select FD_OBJECTID from HBI_LP_BASIC_INFO where ManagementUnit_Code='"
  403. + manageCode + "' and Road_Code='" + roadCode + "' and IS_DEL='0'";
  404. list = persistence.getSearchResult(238, sql);
  405. if (list.size() > 0) {
  406. reValue = list.size();
  407. }
  408. } catch (PersistenceException e) {
  409. log.error(e.getMessage(), e);
  410. } catch (UnsupportedEncodingException e) {
  411. log.error(e.getMessage(), e);
  412. }
  413. return String.valueOf(reValue);
  414. }
  415. /**
  416. * 判断路线是否重复
  417. *
  418. * @return String
  419. * @throws UnsupportedEncodingException
  420. */
  421. @SuppressWarnings("rawtypes")
  422. @ProduceMime("application/json")
  423. @POST
  424. @Path("/judgeRoadCode")
  425. public String judgeRoadCode(String params) {
  426. ArrayList list = new ArrayList();
  427. int reValue = 0;
  428. try {
  429. params = java.net.URLDecoder.decode(params, "UTF-8");
  430. String roadCode = Utils.getParameter("roadCode", params);// 路线代码
  431. SysModel sysmodel = ModelFactory.getSysmodel();
  432. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  433. String sql = "select FD_OBJECTID from HBI_LP_INFO where Road_Code='" + roadCode
  434. + "' and IS_DEL='0'";
  435. list = persistence.getSearchResult(238, sql);
  436. if (list.size() > 0) {
  437. reValue = list.size();
  438. }
  439. } catch (PersistenceException e) {
  440. log.error(e.getMessage(), e);
  441. } catch (UnsupportedEncodingException e) {
  442. log.error(e.getMessage(), e);
  443. }
  444. return String.valueOf(reValue);
  445. }
  446. /**
  447. * 根据管理单位得到 路线代码
  448. *
  449. * @return String
  450. * @throws UnsupportedEncodingException
  451. */
  452. @SuppressWarnings("rawtypes")
  453. @ProduceMime("application/json")
  454. @POST
  455. @Path("/getRoadByMag")
  456. public String getRoadByMag(String params) {
  457. ArrayList list = new ArrayList();
  458. StringBuffer jsonStr = new StringBuffer();
  459. try {
  460. params = java.net.URLDecoder.decode(params, "UTF-8");
  461. String manageCode = Utils.getParameter("magCode", params);// 管理单位代码
  462. SysModel sysmodel = ModelFactory.getSysmodel();
  463. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  464. StringBuffer sb = new StringBuffer();
  465. sb.append(" SELECT ");
  466. sb.append(" ROAD_CODE,ROAD_NAME,ROAD_START , ");
  467. sb.append(" CASE when SUBSTR(Road_Code, 1, 1) = 'G' then 1 ");
  468. sb.append(" when SUBSTR(Road_Code, 1, 1) = 'S' then 2 ");
  469. sb.append(" else 3 ");
  470. sb.append(" end sequ ");
  471. sb.append(" from ");
  472. sb.append(" ( SELECT ");
  473. sb.append(" ROAD_CODE,ROAD_NAME,ROAD_START ");
  474. sb.append(" from HBI_LP_INFO ");
  475. sb.append(" where Is_Del = '0' and (ROAD_CODE like 'G%' OR ROAD_CODE LIKE 'S%') ");
  476. sb.append(" union ALL ");
  477. sb.append(" SELECT ");
  478. sb.append(" Substr(ROAD_CODE,0,Len(ROAD_CODE)-6),ROAD_NAME,ROAD_START ");
  479. sb.append(" from HBI_LP_BASIC_INFO ");
  480. sb.append(" where ManagementUnit_Code like '" + manageCode + "%'");
  481. sb.append(" and IS_DEL='0' and ROAD_CODE not like 'G%' ");
  482. sb.append(" and ROAD_CODE not like 'S%' ");
  483. sb.append(" )a ");
  484. sb.append(" order by sequ,ROAD_CODE ");
  485. log.info("根据管理单位查询路线:" + sb.toString());
  486. list = persistence.getSearchResult(99, sb.toString());
  487. jsonStr.append("{'constants':[");
  488. if (list.size() > 0) {
  489. for (int i = 0; i < list.size(); i++) {
  490. String[] data = (String[]) list.get(i);
  491. jsonStr.append("{'value':'" + data[0] + "','name':'" + data[0] + "(" + data[1]
  492. + ")'},");
  493. }
  494. }
  495. if (jsonStr.lastIndexOf(",") > -1) {
  496. jsonStr.deleteCharAt(jsonStr.lastIndexOf(","));
  497. }
  498. jsonStr.append("]}");
  499. } catch (PersistenceException e) {
  500. log.error(e.getMessage(), e);
  501. } catch (UnsupportedEncodingException e) {
  502. log.error(e.getMessage(), e);
  503. }
  504. return jsonStr.toString();
  505. }
  506. /**
  507. * 判断管理单位
  508. *
  509. * @return String
  510. * @throws UnsupportedEncodingException
  511. */
  512. @SuppressWarnings("rawtypes")
  513. @ProduceMime("application/json")
  514. @POST
  515. @Path("/judgeMagRoadTime")
  516. public String judgeMagRoadTime(String params) {
  517. ArrayList list = new ArrayList();
  518. int reValue = 0;
  519. try {
  520. params = java.net.URLDecoder.decode(params, "UTF-8");
  521. String manageCode = Utils.getParameter("magCode", params);// 管理单位代码
  522. String roadCode = Utils.getParameter("roadCode", params);// 路线代码
  523. String roadStart = Utils.getParameter("roadStart", params);// 起点桩号
  524. String tableName = Utils.getParameter("tableID", params);// 表名称
  525. SysModel sysmodel = ModelFactory.getSysmodel();
  526. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  527. MdpClass mapClass = sysmodel.getMdpClassByClassID(Integer.parseInt(tableName));
  528. tableName = mapClass.getName();
  529. String sql = "select FD_OBJECTID from " + tableName + " where MANAGEMENTUNIT_CODE='"
  530. + manageCode + "' and ROAD_CODE='" + roadCode + "' and ROAD_START='"
  531. + roadStart + "' and IS_DEL='0'";
  532. list = persistence.getSearchResult(238, sql);
  533. if (list.size() > 0) {
  534. reValue = list.size();
  535. }
  536. } catch (PersistenceException e) {
  537. log.error(e.getMessage(), e);
  538. } catch (UnsupportedEncodingException e) {
  539. log.error(e.getMessage(), e);
  540. }
  541. return String.valueOf(reValue);
  542. }
  543. /**
  544. * 判断若干字段是否重复
  545. *
  546. * @return String
  547. * @throws UnsupportedEncodingException
  548. */
  549. @SuppressWarnings("rawtypes")
  550. @ProduceMime("application/json")
  551. @POST
  552. @Path("/judgeCommonRepeat")
  553. public String judgeCommonRepeat(String params) {
  554. ArrayList list = new ArrayList();
  555. int reValue = 0;
  556. try {
  557. params = java.net.URLDecoder.decode(params, "UTF-8");
  558. String condtionStr = Utils.getParameter("condtion", params);// 需要判断的字符串
  559. String tableName = Utils.getParameter("tableID", params);// 表名称
  560. SysModel sysmodel = ModelFactory.getSysmodel();
  561. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  562. MdpClass mapClass = sysmodel.getMdpClassByClassID(Integer.parseInt(tableName));
  563. tableName = mapClass.getName();
  564. String[] array = condtionStr.split(",");
  565. StringBuffer conStr = new StringBuffer();
  566. for (int i = 0; i < array.length; i++) {
  567. String[] temp = array[i].split("'");
  568. conStr.append(" and " + temp[0] + "='" + temp[1] + "'");
  569. }
  570. String sql = "select FD_OBJECTID from " + tableName + " where "
  571. + conStr.substring(4).toString() + " and IS_DEL='0'";
  572. list = persistence.getSearchResult(238, sql);
  573. if (list.size() > 0) {
  574. reValue = list.size();
  575. }
  576. } catch (PersistenceException e) {
  577. log.error(e.getMessage(), e);
  578. } catch (UnsupportedEncodingException e) {
  579. log.error(e.getMessage(), e);
  580. }
  581. return String.valueOf(reValue);
  582. }
  583. /**
  584. * 根据管理单位得到行政区划
  585. *
  586. * @return String
  587. * @throws UnsupportedEncodingException
  588. */
  589. @SuppressWarnings("rawtypes")
  590. @ProduceMime("application/json")
  591. @POST
  592. @Path("/getAdminDivisionCode")
  593. public String getAdminDivisionCode(String params) {
  594. ArrayList list = new ArrayList();
  595. String reValue = "0";
  596. try {
  597. params = java.net.URLDecoder.decode(params, "UTF-8");
  598. String depCode = Utils.getParameter("depId", params);// 管理单位代码
  599. SysModel sysmodel = ModelFactory.getSysmodel();
  600. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  601. String sql = "select t2.FD_CODE,t2.FD_NAME from SYS_DEPARTMENT t1,bm$_dists t2 where t1.DEPT_ID='"
  602. + depCode + "' and t1.IS_DEL='0' and t1.ROAD_DIST=t2.FD_CODE";
  603. list = persistence.getSearchResult(238, sql);
  604. if (list.size() > 0) {
  605. String[] data = (String[]) list.get(0);
  606. reValue = data[0] + "," + data[1];
  607. }
  608. } catch (PersistenceException e) {
  609. log.error(e.getMessage(), e);
  610. } catch (UnsupportedEncodingException e) {
  611. log.error(e.getMessage(), e);
  612. }
  613. return reValue;
  614. }
  615. /**
  616. * 查询分局管理单位名称
  617. *
  618. * @return String
  619. * @throws UnsupportedEncodingException
  620. */
  621. @SuppressWarnings({ "rawtypes", "unchecked" })
  622. @ProduceMime("application/json")
  623. @POST
  624. @Path("/getManagementByCode")
  625. public String getManagementByCode(String params) {
  626. String management_unit = Utils.getParameter("name", params) == null ? "" : Utils
  627. .getParameter("name", params);
  628. log.info("管理单位代码:" + management_unit);
  629. SysModel sysmodel = ModelFactory.getSysmodel();
  630. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  631. ArrayList list = new ArrayList();
  632. ArrayList listvo = new ArrayList();
  633. String sql = "select fd_code,fd_name from BM$_MANAGEMENTUNIT where fd_code = '"
  634. + management_unit + "'";
  635. ConstantVos cvos = new ConstantVos();
  636. try {
  637. list = persistence.getSearchResult(99, sql);
  638. if (!list.isEmpty()) {
  639. for (int i = 0; i < list.size(); i++) {
  640. ConstantVo cvo = new ConstantVo();
  641. String[] rs = (String[]) list.get(i);
  642. String code = rs[0] == null ? "" : rs[0];
  643. String name = rs[1] == null ? "" : rs[1];
  644. cvo.setName(name);
  645. cvo.setValue(code);
  646. listvo.add(cvo);
  647. }
  648. cvos.setConstants(listvo);
  649. }
  650. } catch (PersistenceException e) {
  651. log.error(e.getMessage(), e);
  652. }
  653. return JSONObject.fromObject(cvos).toString();
  654. }
  655. /**
  656. * 查询绿化管理单位名称
  657. *
  658. * @return String
  659. * @throws UnsupportedEncodingException
  660. */
  661. @SuppressWarnings({ "rawtypes", "unchecked" })
  662. @ProduceMime("application/json")
  663. @POST
  664. @Path("/getManagementLhByCode")
  665. public String getManagementLhByCode(String params) {
  666. String management_unit = Utils.getParameter("name", params) == null ? "" : Utils
  667. .getParameter("name", params);
  668. log.info("管理单位代码:" + management_unit);
  669. SysModel sysmodel = ModelFactory.getSysmodel();
  670. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  671. ArrayList list = new ArrayList();
  672. ArrayList listvo = new ArrayList();
  673. String sql = "select fd_code,fd_description from HM_LH_DFCOFFICEEXCHANGE where fd_code = '"
  674. + management_unit + "'";
  675. ConstantVos cvos = new ConstantVos();
  676. try {
  677. list = persistence.getSearchResult(99, sql);
  678. if (!list.isEmpty()) {
  679. for (int i = 0; i < list.size(); i++) {
  680. ConstantVo cvo = new ConstantVo();
  681. String[] rs = (String[]) list.get(i);
  682. String code = rs[0] == null ? "" : rs[0];
  683. String name = rs[1] == null ? "" : rs[1];
  684. cvo.setName(name);
  685. cvo.setValue(code);
  686. listvo.add(cvo);
  687. }
  688. cvos.setConstants(listvo);
  689. }
  690. } catch (PersistenceException e) {
  691. log.error(e.getMessage(), e);
  692. }
  693. return JSONObject.fromObject(cvos).toString();
  694. }
  695. /**
  696. * 养护人员管理-工作单位
  697. */
  698. @SuppressWarnings("rawtypes")
  699. @ProduceMime("application/json")
  700. @POST
  701. @Path("/getPersonUnitJson")
  702. public String getPersonUnitJson(String params) {
  703. String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node",
  704. params);
  705. String deptid = Utils.getParameter("deptid", params) == null ? "" : Utils.getParameter(
  706. "deptid", params);
  707. SysModel sysmodel = ModelFactory.getSysmodel();
  708. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  709. ArrayList list = new ArrayList();
  710. StringBuffer sb = new StringBuffer();
  711. String sql = "select t1.Dept_Id ,t1.Dept_Name,t1.FD_OBJECTID,t1.type from Sys_Department t1 where t1.Depts_Id ='"
  712. + node
  713. + "' and t1.type in ('1','2') and t1.Is_Del='0' and t1.DEPT_ID like '"
  714. + deptid + "%'";
  715. if (node.equals("0")) {
  716. sql = "select t1.Dept_Id ,t1.Dept_Name,t1.FD_OBJECTID,t1.type from Sys_Department t1 where t1.Depts_Id ='"
  717. + node + "' and t1.type in ('1','2') and t1.Is_Del='0'";
  718. }
  719. log.info("sql:" + sql);
  720. try {
  721. list = persistence.getSearchResult(800, sql);
  722. } catch (PersistenceException e) {
  723. log.error(e.getMessage(), e);
  724. }
  725. sb.append("[");
  726. if (!list.isEmpty()) {
  727. for (int i = 0; i < list.size(); i++) {
  728. String[] rs = (String[]) list.get(i);
  729. String code = rs[0] == null ? "" : rs[0];
  730. String name = rs[1] == null ? "" : rs[1];
  731. String fd_objectid = rs[2] == null ? "" : rs[2];
  732. String type = rs[3] == null ? "" : rs[3];
  733. if (isLeaf(code)) {
  734. if ("1".equals(type)) {
  735. sb.append("{text:'" + name + "',id:'" + code
  736. + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'"
  737. + fd_objectid + "',leaf:false},");
  738. } else if ("2".equals(type)) {
  739. sb.append("{text:'" + name + "',id:'" + code
  740. + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'"
  741. + fd_objectid + "',leaf:false},");
  742. }
  743. } else {
  744. if ("1".equals(type)) {
  745. sb.append("{text:'" + name + "',id:'" + code
  746. + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'"
  747. + fd_objectid + "',leaf:true},");
  748. } else if ("2".equals(type)) {
  749. sb.append("{text:'" + name + "',id:'" + code
  750. + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'"
  751. + fd_objectid + "',leaf:true},");
  752. }
  753. }
  754. }
  755. }
  756. if (sb.lastIndexOf(",") > -1) {
  757. sb.deleteCharAt(sb.lastIndexOf(","));
  758. }
  759. sb.append("]");
  760. return sb.toString();
  761. }
  762. /**
  763. * 方法的作用 : 根据G,S.....筛选路线
  764. *
  765. * @param params
  766. * the params
  767. * @return json串,在combo中显示
  768. * @author赵瑞
  769. * @version 2013-10-29-09:15:31
  770. */
  771. @ProduceMime("application/json")
  772. @POST
  773. @Path("/getRoad")
  774. public String getRoad(String params) {
  775. String unitCode = Utils.getParameter("unitCode", params) == null ? "" : Utils.getParameter(
  776. "unitCode", params);
  777. String result = this.getChargeStanderTree(unitCode);
  778. return result;
  779. }
  780. /**
  781. * 方法的作用: 分配路线时,根据G,S.....筛选路线,且按照G.S.X排序
  782. *
  783. * @param name
  784. * the name
  785. * @param codition
  786. * the codition
  787. * @return commonServiceImp - charge stander tree
  788. * @author 赵瑞
  789. * @version 2013-10-28-09:16:44
  790. */
  791. public String getChargeStanderTree(String unitCode) {
  792. JDBCHelper jdbc = new JDBCHelper();
  793. jdbc.begin();
  794. StringBuffer sb = new StringBuffer();
  795. ArrayList<String[]> listG = new ArrayList<String[]>();
  796. try {
  797. sb.append(" SELECT ");
  798. sb.append(" ROAD_CODE,ROAD_NAME,ROAD_START ,ROAD_END, ");
  799. sb.append(" CASE when SUBSTR(Road_Code, 1, 1) = 'G' then 1 ");
  800. sb.append(" when SUBSTR(Road_Code, 1, 1) = 'S' then 2 ");
  801. sb.append(" else 3 ");
  802. sb.append(" end sequ ");
  803. sb.append(" from ");
  804. sb.append(" ( SELECT ");
  805. sb.append(" ROAD_CODE,ROAD_NAME,ROAD_START,ROAD_END ");
  806. sb.append(" from HBI_LP_INFO ");
  807. sb.append(" where Is_Del = '0' and (ROAD_CODE like 'G%' OR ROAD_CODE LIKE 'S%') ");
  808. sb.append(" union ALL ");
  809. sb.append(" SELECT ");
  810. sb.append(" Substr(ROAD_CODE,0,Len(ROAD_CODE)-6),ROAD_NAME,ROAD_START,ROAD_END ");
  811. sb.append(" from HBI_LP_BASIC_INFO ");
  812. sb.append(" where ManagementUnit_Code like '" + unitCode + "%'");
  813. sb.append(" and IS_DEL='0' and ROAD_CODE not like 'G%' ");
  814. sb.append(" and ROAD_CODE not like 'S%' ");
  815. sb.append(" )a ");
  816. sb.append(" order by sequ,ROAD_CODE ");
  817. log.info("sb.toString()==============" + sb.toString());
  818. listG = jdbc.getSearchResult(99, sb.toString());
  819. } catch (PersistenceException e) {
  820. log.error(e.getMessage(), e);
  821. }
  822. StringBuffer sb1 = new StringBuffer();
  823. sb1.append("{\"constants\":[");
  824. for (String[] temp : listG) {
  825. String info = temp[0] + temp[1] + "(" + (temp[2] == null ? "" : temp[2]) + "~"
  826. + (temp[3] == null ? "" : temp[3] + ")");
  827. log.info("info:" + info);
  828. sb1.append("{\"roadcode\":\"" + temp[0] + "\",\"roadname\":\"" + temp[1]
  829. + "\",\"start\":\"" + temp[2] + "\",\"end\":\"" + temp[3] + "\",\"info\":\""
  830. + info + "\"},");
  831. }
  832. if (sb1.lastIndexOf(",") > -1) {
  833. sb1.deleteCharAt(sb1.lastIndexOf(","));
  834. }
  835. sb1.append("]}");
  836. jdbc.release();
  837. log.info("sb1.toString()=================" + sb1.toString());
  838. return sb1.toString();
  839. }
  840. }