123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- package com.sinosoft.cm.service;
- import java.sql.SQLException;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import javax.ws.rs.POST;
- import javax.ws.rs.Path;
- import javax.ws.rs.ProduceMime;
- import nl.justobjects.pushlet.util.Sys;
- import org.apache.log4j.Logger;
- import com.formaction.Utils;
- import com.persistence.service.exception.PersistenceException;
- import com.sinosoft.cm.common.StringUtils;
- import com.sinosoft.cm.common.vo.ResultState;
- import com.sinosoft.cm.dao.MaticDao;
- import com.sinosoft.cm.ex.SQLStringException;
- import com.sinosoft.cm.impl.LayerMaticDaoImpl;
- import com.sinosoft.cm.impl.MaticDaoImpl;
- import com.sinosoft.cm.matic.service.MaticServiceImpl;
- import com.sinosoft.cm.vo.Matic;
- import com.sinosoft.cm.vo.Result;
- import com.sinosoft.common.excel.JsonPluginsUtil;
- import flex.messaging.io.ArrayList;
- @Path("/MaticService/")
- public class MaticService {
- private final Logger log = Logger.getLogger(getClass());
- public MaticService() {}
- @ProduceMime("application/json")
- @POST
- @Path("/getMaticInfo")
- public String getMaticInfo() throws PersistenceException {
-
- MaticDao dao=new MaticDaoImpl();
- Result res=null;
- List<Matic> list=null;
- try {
- list=dao.findAll();
- res=new Result(JsonPluginsUtil.beanListToJson(list), Result.STATE_SUCCESS, 0, 0);
-
- } catch (SQLException e) {
- log.error(e);
- }
- return res.toJSONString().replace("\\\"", "\"").replace("\"[", "[").replace("]\"", "]");
- }
- /**
- * 获取视图列表信息
- * @return
- * @throws PersistenceException
- */
- @ProduceMime("application/json")
- @POST
- @Path("/getMaticMapInfo")
- public String getMaticMapInfo(String params) throws PersistenceException{
- MaticServiceImpl msi=new MaticServiceImpl();
- //LayerMaticDaoImpl dao=new LayerMaticDaoImpl();
- String comId=Utils.getParameter("comId", params) == null ? "" : Utils.getParameter("comId", params);
- List<Map<String, String>> list=null;
- String result=null;
- //List<Map<String,String>> list=msi.findAllByNameAndIN("getMatic",(List<String>)null,"785F409051A84412A75E8E44FE3F5C6E");
- Map<String,List<Map<String,String>>> mapList=new HashMap<String, List<Map<String,String>>>();
- try {
- list=msi.findAllByNameAndIN("getMatic",(List<String>)null,comId);
- // list=dao.findAll("getMaticMap");
- for(Map<String,String> map:list){
- if(!mapList.containsKey(map.get("AREA_NAME"))){
- mapList.put(map.get("AREA_NAME"), new ArrayList());
- /* mapList.get(map.get("AREA_NAME")).*/
- /* mapList.get(map.get("AREA_NAME")),map.get("TM_BEX"));*/
- }
- mapList.get(map.get("AREA_NAME")).add(map);
- }
- List<String> strList=StringUtils.MapToJson(mapList);
- result=StringUtils.resultToJSON(ResultState.SUCCESS, list.size(), JsonPluginsUtil.beanListToJson(strList));
- } catch (SQLStringException e) {
- log.info(e.getMessage());
- result=StringUtils.resultToJSON(ResultState.FAILURE, 0, null);
- e.printStackTrace();
- }finally{
- log.info("===getMaticMapInfo()===返回前台结果===result==="+result);
- return result;
- }
- }
-
-
- /**
- * 获取视图列表信息
- * @return
- * @throws PersistenceException
- */
- @ProduceMime("application/json")
- @POST
- @Path("/getMaticMapInfoThroughLikeInfo")
- public String getMaticMapInfoThroughLikeInfo(String params) throws PersistenceException{
- MaticServiceImpl msi=new MaticServiceImpl();
- //LayerMaticDaoImpl dao=new LayerMaticDaoImpl();
- String comId=Utils.getParameter("comId", params) == null ? "" : Utils.getParameter("comId", params);
- String like=Utils.getParameter("like", params) == null ? "" : Utils.getParameter("like", params);
- List<Map<String, String>> list=null;
- String result=null;
- //List<Map<String,String>> list=msi.findAllByNameAndIN("getMatic",(List<String>)null,"785F409051A84412A75E8E44FE3F5C6E");
- Map<String,List<Map<String,String>>> mapList=new HashMap<String, List<Map<String,String>>>();
- try {
- System.out.println(comId);
- System.out.println(like);
- list=msi.findAllByNameAndIN("getLikeMatic",(List<String>)null,comId,"%"+like+"%");
- // list=dao.findAll("getMaticMap");
- /* for(Map<String,String> map:list){
- if(!mapList.containsKey(map.get("AREA_NAME"))){
- mapList.put(map.get("AREA_NAME"), new ArrayList());
- }
- mapList.get(map.get("AREA_NAME")).add(map);
- }*/
- List<String> strList=StringUtils.MapToJson(mapList);
- result=StringUtils.resultToJSON(ResultState.SUCCESS, list.size(), JsonPluginsUtil.beanListToJson(list));
- } catch (SQLStringException e) {
- log.info(e.getMessage());
- result=StringUtils.resultToJSON(ResultState.FAILURE, 0, null);
- e.printStackTrace();
- }finally{
- log.info("===getMaticMapInfo()===返回前台结果===result==="+result);
- return result;
- }
- }
-
-
- /* public static void main(String[] args) {
- MaticService ms=new MaticService();
- String str=null;
- try {
- str=ms.getMaticMapInfoThroughLike("comId=785F409051A84412A75E8E44FE3F5C6E&&like=台区");
- System.out.println("str="+str);
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
-
- }*/
- /**
- * 根据名字模糊查询
- * @return
- * @throws PersistenceException
- */
- @ProduceMime("application/json")
- @POST
- @Path("/getMaticMapByNameInfo")
- public String getMaticMapByNameInfo() throws PersistenceException{
- LayerMaticDaoImpl dao=new LayerMaticDaoImpl();
- List<Map<String, String>> list=null;
- String result=null;
- Map<String,List<Map<String,String>>> mapList=new HashMap<String, List<Map<String,String>>>();
- try {
- list=dao.findAll("getMaticMap");
- for(Map<String,String> map:list){
- if(!mapList.containsKey(map.get("AREA_NAME"))){
- mapList.put(map.get("AREA_NAME"), new ArrayList());
- }
- mapList.get(map.get("AREA_NAME")).add(map);
- }
- List<String> strList=StringUtils.MapToJson(mapList);
- result=StringUtils.resultToJSON(ResultState.SUCCESS, strList.size(), JsonPluginsUtil.beanListToJson(strList));
- } catch (SQLStringException e) {
- log.info(e.getMessage());
- result=StringUtils.resultToJSON(ResultState.FAILURE, 0, null);
- e.printStackTrace();
- }finally{
- log.info("===getMaticMapInfo()===返回前台结果===result==="+result);
- return result;
- }
- }
-
- }
|