package com.cockpit.service; import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.ProduceMime; import net.sf.json.JSONArray; import org.slf4j.LoggerFactory; import com.cockpit.dao.CZYingjiziyuanDao; import com.cockpit.util.CockpitUtil; import com.cockpit.vo.YiJiZiYuan; import com.formaction.Utils; /** * 驾驶舱服务类--专题图表 * @author zhumingyue * */ @Path("/CockpitChartsService/") public class CockpitChartsService { private static final org.slf4j.Logger log = LoggerFactory.getLogger(CockpitChartsService.class); private CZYingjiziyuanDao czyDao = new CZYingjiziyuanDao(); private CockpitUtil cutil = new CockpitUtil(); @POST @ProduceMime("application/") @Path("/czYingjiziyuan/") public String czYingjiziyuan(String params){ log.info(params); String dept_id = Utils.getParameter("dept_id", params) ;//发布单位 String warning_number = Utils.getParameter("number", params);//预警响应单号 if(cutil.verifyParams(dept_id) && cutil.verifyParams(warning_number)){ /*String sql = "SELECT * FROM(SELECT CASE FLAG WHEN '' THEN '0' ELSE FLAG END FLAG,WARNING_NUMBER, " + "T4.DEPT_NAME,T4.PARENT_ID,T4.SORT,T2.COMP_ID, " + "T2.REPORT_ID,T2.PERSON_BD,T2.CAR_BD,T2.FADIAN_CAR_BD,T2.FADIAN_JI_BD,T2.PERSON_KQ," + "T2.CAR_KQ,T2.FADIAN_CAR_KQ,T2.FADIAN_JI_KQ,T2.DATA_TYPE,T1.REPORTER_ID,T1.APPEAR_TIME," + "T1.SEND_TIME,T1.REPORTER,ROW_NUMBER() OVER(PARTITION BY T2.COMP_ID ORDER BY APPEAR_TIME " + "DESC) AS NUM FROM NWYJ.REPORT_RECORDS T1 LEFT JOIN NWYJ.REPORT_YINGJI_ZIYUAN T2 ON " + "T1.FD_OBJECTID = T2.REPORT_ID LEFT JOIN NWYJ.REPORT_SCHEDULE T3 ON T1.REPORT_ID LIKE " + "'%'||T3.FD_OBJECTID||'%' LEFT JOIN NWYJ.SYS_DEPARTMENT T4 ON T2.COMP_ID = T4.DEPT_ID " + "WHERE REPORT_TYPE = '8' AND T2.COMP_ID <>'zj' AND APPEAR_DEL = '0' AND T1.SEND_STAT = '1' " + "AND T3.SEND_STAT = '1' AND T1.APPEAR_STAT = '1' AND WARNING_NUMBER = ? AND FLAG = ? " + "AND T4.PARENT_ID = ? OR T2.COMP_ID = ?) T1 WHERE NUM = '1' ORDER BY SORT NULLS LAST" ;*/ String sql = "SELECT * FROM ( SELECT CASE FLAG WHEN '' THEN '0' ELSE FLAG END FLAG, WARNING_NUMBER , T4.DEPT_NAME , T4.PARENT_ID , T4.SORT ," + " T3.COMP_ID , T3.REPORT_ID , T3.PERSON_BD , T3.CAR_BD , T3.FADIAN_CAR_BD , T3.FADIAN_JI_BD , T3.PERSON_KQ , T3.CAR_KQ , T3.FADIAN_CAR_KQ ," + " T3.FADIAN_JI_KQ , T3.DATA_TYPE , T2.REPORTER_ID , T2.APPEAR_TIME , T2.SEND_TIME , T2.REPORTER ," + " ROW_NUMBER() OVER(PARTITION BY T3.COMP_ID ORDER BY APPEAR_TIME DESC) AS NUM FROM REPORT_SCHEDULE T1 LEFT JOIN REPORT_RECORDS T2 on" + " T2.REPORT_ID LIKE '%' ||T1.FD_OBJECTID ||'%' left join REPORT_YINGJI_ZIYUAN T3 on T3.REPORT_ID = T2.FD_OBJECTID LEFT JOIN SYS_DEPARTMENT T4" + " ON T3.COMP_ID=T4.DEPT_ID where T2.REPORT_TYPE ='8' AND T1.SEND_STAT <> '0' and T3.COMP_ID <>'zj' AND T2.SEND_STAT = '1'" + " AND T2.APPEAR_STAT = '1' and T1.WARNING_NUMBER=? AND( T4.PARENT_ID = ? OR T3.COMP_ID = ?)) WHERE NUM='1' ORDER BY SORT NULLS LAST"; List list = new ArrayList(); list = czyDao.getYingjiziyuan(sql, warning_number, "0", dept_id, list); //list = czyDao.getYingjiziyuan(sql, warning_number, "1", dept_id, list); /*Map map = null; String sql = "SELECT * FROM(SELECT FLAG,WARNING_NUMBER,T4.DEPT_NAME,T4.PARENT_ID,T4.SORT,T2.COMP_ID, " + "T2.REPORT_ID,T2.PERSON_BD,T2.CAR_BD,T2.FADIAN_CAR_BD,T2.FADIAN_JI_BD,T2.PERSON_KQ," + "T2.CAR_KQ,T2.FADIAN_CAR_KQ,T2.FADIAN_JI_KQ,T2.DATA_TYPE,T1.REPORTER_ID,T1.APPEAR_TIME," + "T1.SEND_TIME,T1.REPORTER,ROW_NUMBER() OVER(PARTITION BY T2.COMP_ID ORDER BY APPEAR_TIME " + "DESC) AS NUM FROM NWYJ.REPORT_RECORDS T1 LEFT JOIN NWYJ.REPORT_YINGJI_ZIYUAN T2 ON " + "T1.FD_OBJECTID = T2.REPORT_ID LEFT JOIN NWYJ.REPORT_SCHEDULE T3 ON T1.REPORT_ID LIKE " + "'%'||T3.FD_OBJECTID||'%' LEFT JOIN NWYJ.SYS_DEPARTMENT T4 ON T2.COMP_ID = T4.DEPT_ID " + "WHERE REPORT_TYPE = '8' AND T2.COMP_ID <>'zj' AND APPEAR_DEL = '0' AND T1.SEND_STAT = '1' " + "AND T3.SEND_STAT = '1' AND T1.APPEAR_STAT = '1' AND WARNING_NUMBER = ? AND FLAG = ? " + "AND T4.PARENT_ID = ? ) T1 WHERE NUM = '1' ORDER BY SORT NULLS LAST" ; //本地跨区查询时分开查一起返回 map = czyDao.getYingjiziyuanNative(sql, warning_number, "0", dept_id); map = czyDao.getYingjiziyuanCross(sql, warning_number, "1", dept_id, map); List list = cutil.mapToList(map);*/ // return "{\"state\":\""+state+"\",\"total\":"+count+",\"rows\":"+data+"}"; String res= "{\"rows\":"+JSONArray.fromObject(list).toString()+"}"; log.info("返回结果 : "+res); return res; } return null; } }