a01eb6bccd904bac7315db660b74132714ba6c2a.svn-base 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. package com.sinosoft.cm.service;
  2. import java.sql.SQLException;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import javax.ws.rs.POST;
  7. import javax.ws.rs.Path;
  8. import javax.ws.rs.ProduceMime;
  9. import nl.justobjects.pushlet.util.Sys;
  10. import org.apache.log4j.Logger;
  11. import com.formaction.Utils;
  12. import com.persistence.service.exception.PersistenceException;
  13. import com.sinosoft.cm.common.StringUtils;
  14. import com.sinosoft.cm.common.vo.ResultState;
  15. import com.sinosoft.cm.dao.MaticDao;
  16. import com.sinosoft.cm.ex.SQLStringException;
  17. import com.sinosoft.cm.impl.LayerMaticDaoImpl;
  18. import com.sinosoft.cm.impl.MaticDaoImpl;
  19. import com.sinosoft.cm.matic.service.MaticServiceImpl;
  20. import com.sinosoft.cm.vo.Matic;
  21. import com.sinosoft.cm.vo.Result;
  22. import com.sinosoft.common.excel.JsonPluginsUtil;
  23. import flex.messaging.io.ArrayList;
  24. @Path("/MaticService/")
  25. public class MaticService {
  26. private final Logger log = Logger.getLogger(getClass());
  27. public MaticService() {}
  28. @ProduceMime("application/json")
  29. @POST
  30. @Path("/getMaticInfo")
  31. public String getMaticInfo() throws PersistenceException {
  32. MaticDao dao=new MaticDaoImpl();
  33. Result res=null;
  34. List<Matic> list=null;
  35. try {
  36. list=dao.findAll();
  37. res=new Result(JsonPluginsUtil.beanListToJson(list), Result.STATE_SUCCESS, 0, 0);
  38. } catch (SQLException e) {
  39. log.error(e);
  40. }
  41. return res.toJSONString().replace("\\\"", "\"").replace("\"[", "[").replace("]\"", "]");
  42. }
  43. /**
  44. * 获取视图列表信息
  45. * @return
  46. * @throws PersistenceException
  47. */
  48. @ProduceMime("application/json")
  49. @POST
  50. @Path("/getMaticMapInfo")
  51. public String getMaticMapInfo(String params) throws PersistenceException{
  52. MaticServiceImpl msi=new MaticServiceImpl();
  53. //LayerMaticDaoImpl dao=new LayerMaticDaoImpl();
  54. String comId=Utils.getParameter("comId", params) == null ? "" : Utils.getParameter("comId", params);
  55. List<Map<String, String>> list=null;
  56. String result=null;
  57. //List<Map<String,String>> list=msi.findAllByNameAndIN("getMatic",(List<String>)null,"785F409051A84412A75E8E44FE3F5C6E");
  58. Map<String,List<Map<String,String>>> mapList=new HashMap<String, List<Map<String,String>>>();
  59. try {
  60. list=msi.findAllByNameAndIN("getMatic",(List<String>)null,comId);
  61. // list=dao.findAll("getMaticMap");
  62. for(Map<String,String> map:list){
  63. if(!mapList.containsKey(map.get("AREA_NAME"))){
  64. mapList.put(map.get("AREA_NAME"), new ArrayList());
  65. /* mapList.get(map.get("AREA_NAME")).*/
  66. /* mapList.get(map.get("AREA_NAME")),map.get("TM_BEX"));*/
  67. }
  68. mapList.get(map.get("AREA_NAME")).add(map);
  69. }
  70. List<String> strList=StringUtils.MapToJson(mapList);
  71. result=StringUtils.resultToJSON(ResultState.SUCCESS, list.size(), JsonPluginsUtil.beanListToJson(strList));
  72. } catch (SQLStringException e) {
  73. log.info(e.getMessage());
  74. result=StringUtils.resultToJSON(ResultState.FAILURE, 0, null);
  75. e.printStackTrace();
  76. }finally{
  77. log.info("===getMaticMapInfo()===返回前台结果===result==="+result);
  78. return result;
  79. }
  80. }
  81. /**
  82. * 获取视图列表信息
  83. * @return
  84. * @throws PersistenceException
  85. */
  86. @ProduceMime("application/json")
  87. @POST
  88. @Path("/getMaticMapInfoThroughLikeInfo")
  89. public String getMaticMapInfoThroughLikeInfo(String params) throws PersistenceException{
  90. MaticServiceImpl msi=new MaticServiceImpl();
  91. //LayerMaticDaoImpl dao=new LayerMaticDaoImpl();
  92. String comId=Utils.getParameter("comId", params) == null ? "" : Utils.getParameter("comId", params);
  93. String like=Utils.getParameter("like", params) == null ? "" : Utils.getParameter("like", params);
  94. List<Map<String, String>> list=null;
  95. String result=null;
  96. //List<Map<String,String>> list=msi.findAllByNameAndIN("getMatic",(List<String>)null,"785F409051A84412A75E8E44FE3F5C6E");
  97. Map<String,List<Map<String,String>>> mapList=new HashMap<String, List<Map<String,String>>>();
  98. try {
  99. System.out.println(comId);
  100. System.out.println(like);
  101. list=msi.findAllByNameAndIN("getLikeMatic",(List<String>)null,comId,"%"+like+"%");
  102. // list=dao.findAll("getMaticMap");
  103. /* for(Map<String,String> map:list){
  104. if(!mapList.containsKey(map.get("AREA_NAME"))){
  105. mapList.put(map.get("AREA_NAME"), new ArrayList());
  106. }
  107. mapList.get(map.get("AREA_NAME")).add(map);
  108. }*/
  109. List<String> strList=StringUtils.MapToJson(mapList);
  110. result=StringUtils.resultToJSON(ResultState.SUCCESS, list.size(), JsonPluginsUtil.beanListToJson(list));
  111. } catch (SQLStringException e) {
  112. log.info(e.getMessage());
  113. result=StringUtils.resultToJSON(ResultState.FAILURE, 0, null);
  114. e.printStackTrace();
  115. }finally{
  116. log.info("===getMaticMapInfo()===返回前台结果===result==="+result);
  117. return result;
  118. }
  119. }
  120. /* public static void main(String[] args) {
  121. MaticService ms=new MaticService();
  122. String str=null;
  123. try {
  124. str=ms.getMaticMapInfoThroughLike("comId=785F409051A84412A75E8E44FE3F5C6E&&like=台区");
  125. System.out.println("str="+str);
  126. } catch (PersistenceException e) {
  127. e.printStackTrace();
  128. }
  129. }*/
  130. /**
  131. * 根据名字模糊查询
  132. * @return
  133. * @throws PersistenceException
  134. */
  135. @ProduceMime("application/json")
  136. @POST
  137. @Path("/getMaticMapByNameInfo")
  138. public String getMaticMapByNameInfo() throws PersistenceException{
  139. LayerMaticDaoImpl dao=new LayerMaticDaoImpl();
  140. List<Map<String, String>> list=null;
  141. String result=null;
  142. Map<String,List<Map<String,String>>> mapList=new HashMap<String, List<Map<String,String>>>();
  143. try {
  144. list=dao.findAll("getMaticMap");
  145. for(Map<String,String> map:list){
  146. if(!mapList.containsKey(map.get("AREA_NAME"))){
  147. mapList.put(map.get("AREA_NAME"), new ArrayList());
  148. }
  149. mapList.get(map.get("AREA_NAME")).add(map);
  150. }
  151. List<String> strList=StringUtils.MapToJson(mapList);
  152. result=StringUtils.resultToJSON(ResultState.SUCCESS, strList.size(), JsonPluginsUtil.beanListToJson(strList));
  153. } catch (SQLStringException e) {
  154. log.info(e.getMessage());
  155. result=StringUtils.resultToJSON(ResultState.FAILURE, 0, null);
  156. e.printStackTrace();
  157. }finally{
  158. log.info("===getMaticMapInfo()===返回前台结果===result==="+result);
  159. return result;
  160. }
  161. }
  162. }