123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- package com.cockpit.dao;
- import java.sql.SQLException;
- import java.util.Calendar;
- import java.util.Collections;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.Iterator;
- import java.util.Map;
- import java.util.Set;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.List;
- import com.sinosoft.cm.common.ArrayList;
- public class TyphoonDao extends ConnDaoImpl {
-
- public String getDateAxis(String sql, String fd_id){
- List<Date> date = new ArrayList<Date>();
- rs = executeQuerySetPs(sql,fd_id);
- try{
- while(rs.next()){
- date.add(rs.getDate("CREATE_TIME"));
- }
- return listTransitionStrbuf(date);
- }catch(SQLException e){ e.printStackTrace(); }
-
- return null;
- }
-
- /**
- * 变电站历史添加
- * @param sql
- * @param obj
- * @return
- */
- public int addSmootFloddsAxis(String sql, Object...obj){
- return executeUpdate(sql,obj);
- }
-
- /**
- * 变电站历史记录查询
- * @param sql
- * @param fd_id
- * @return
- */
- public String getSmootFloddsAxis(String sql, String fd_id){
- StringBuffer sb = new StringBuffer();
- sb.append("[");
- rs = executeQuerySetPs(sql,fd_id);
- try{
- while(rs.next()){
- sb.append("{\"count\":\"" + rs.getString("RECORDDISC") +
- "\",\"data\":\"" + rs.getString("CREATE_TIME") +
- "\",\"fd_id\":\"" + rs.getString("FD_OBJECTID") + "\"},");
- }
- }catch(SQLException e){ e.printStackTrace(); }
-
- sb.deleteCharAt(sb.length()-1);
- if(sb.length()==0){ return null ; }
- sb.append("]") ;
- return sb.toString() ;
-
- }
-
- public String getHistoryPath(String sql, String sid){
- StringBuffer sb = new StringBuffer();
- StringBuffer tempX = new StringBuffer() ;
- StringBuffer tempY = new StringBuffer() ;
-
- sb.append("[");
- rs = executeQuerySetPs(sql,sid) ;
- // rs = executeQueryBySt(sql);
- /* try{
- if(rs.next()){
- sb.append("{\"FD_ID\":\"" + rs.getString("FD_ID") + "\",\"LONGITUDE\":" + rs.getDouble("LONGITUDE") +
- ",\"LATITUDE\":" + rs.getDouble("LATITUDE") + "\"," );
- if(rs.next()){
- sb.append("\"nextX\":" + rs.getDouble("LONGITUDE") + ",\"nextY\":" + rs.getDouble("LATITUDE") + ",");
- rs.previous();
- }else{
- sb.append("\"nextX\":" + rs.getDouble("LONGITUDE") + ",\"nextY\":" + rs.getDouble("LATITUDE") + ",");
- }
-
- sb.append("\"SEVEN_RADIUS\":\"" + rs.getString("SEVEN_RADIUS") +
- "\",\"TEN_RADIUS\":\"" + rs.getString("TEN_RADIUS") + "\",\"TWELVE_RADIUS\":\"" +
- rs.getString("TWELVE_RADIUS") + "\",\"MAX_STRENGTH\":\"" + rs.getString("MAX_STRENGTH") +
- "\",\"MAX_SPEED\":\"" + rs.getString("MAX_SPEED") + "\",\"MOVEMENT_SPEED\":\"" +
- rs.getString("MOVEMENT_SPEED") + "\",\"CENTRAL_PRESSURE\":\"" + rs.getString("CENTRAL_PRESSURE") +
- "\",\"ORIENTATION\":\"" + rs.getString("ORIENTATION") + "\",\"CREATE_TIME\":\"" +
- rs.getString("CREATE_TIME") + "\"},");
- }
- while(rs.next()){
- sb.append("{\"FD_ID\":\"" + rs.getString("FD_ID") + "\",\"LONGITUDE\":" + rs.getDouble("LONGITUDE") +
- ",\"LATITUDE\":" + rs.getDouble("LATITUDE") + "\"," );
- if(rs.next()){
- sb.append("\"nextX\":" + rs.getDouble("LONGITUDE") + ",\"nextY\":" + rs.getDouble("LATITUDE") + ",");
- rs.previous();
- }else{
- sb.append("\"nextX\":" + rs.getDouble("LONGITUDE") + ",\"nextY\":" + rs.getDouble("LATITUDE") + ",");
- }
- sb.append("\"SEVEN_RADIUS\":\"" + rs.getString("SEVEN_RADIUS") +
- "\",\"TEN_RADIUS\":\"" + rs.getString("TEN_RADIUS") + "\",\"TWELVE_RADIUS\":\"" +
- rs.getString("TWELVE_RADIUS") + "\",\"MAX_STRENGTH\":\"" + rs.getString("MAX_STRENGTH") +
- "\",\"MAX_SPEED\":\"" + rs.getString("MAX_SPEED") + "\",\"MOVEMENT_SPEED\":\"" +
- rs.getString("MOVEMENT_SPEED") + "\",\"CENTRAL_PRESSURE\":\"" + rs.getString("CENTRAL_PRESSURE") +
- "\",\"ORIENTATION\":\"" + rs.getString("ORIENTATION") + "\",\"CREATE_TIME\":\"" +
- rs.getString("CREATE_TIME") + "\"},");
- }
- } catch(SQLException e){ e.printStackTrace(); }*/
-
- try{
- if(rs.next()){
- sb.append("{\"FD_ID\":\"" + rs.getString("FD_ID") + "\",\"afterX\":\"" + rs.getString("LONGITUDE") +
- "\",\"afterY\":\"" + rs.getString("LATITUDE") + "\",\"LONGITUDE\":" + rs.getDouble("LONGITUDE") +
- ",\"LATITUDE\":" + rs.getDouble("LATITUDE") + ",\"SEVEN_RADIUS\":\"" + rs.getString("SEVEN_RADIUS") +
- "\",\"TEN_RADIUS\":\"" + rs.getString("TEN_RADIUS") + "\",\"TWELVE_RADIUS\":\"" +
- rs.getString("TWELVE_RADIUS") + "\",\"MAX_STRENGTH\":\"" + rs.getString("MAX_STRENGTH") +
- "\",\"MAX_SPEED\":\"" + rs.getString("MAX_SPEED") + "\",\"MOVEMENT_SPEED\":\"" +
- rs.getString("MOVEMENT_SPEED") + "\",\"CENTRAL_PRESSURE\":\"" + rs.getString("CENTRAL_PRESSURE") +
- "\",\"ORIENTATION\":\"" + rs.getString("ORIENTATION") + "\",\"CREATE_TIME\":\"" +
- rs.getString("CREATE_TIME") + "\",\"addIcon\":\"true\"},");
- tempX.append(rs.getString("LONGITUDE")) ;
- tempY.append(rs.getString("LATITUDE")) ;
- }
- while(rs.next()){
- double x1 = Double.parseDouble(tempX.toString());
- // double y1 = Double.parseDouble(tempY.toString());
- double x2 = rs.getDouble("LONGITUDE");
- // double y2 = rs.getDouble("LATITUDE");
-
- if(x1 > x2){
- sb.append(getPointStraightLineRightQuadrant(Double.parseDouble(tempX.toString()), Double.parseDouble(tempY.toString()),
- rs.getDouble("LONGITUDE"), rs.getDouble("LATITUDE"),
- rs.getString("FD_ID"), rs.getString("SEVEN_RADIUS"), rs.getString("TEN_RADIUS"),
- rs.getString("TWELVE_RADIUS"), rs.getString("MAX_STRENGTH"),rs.getString("MAX_SPEED"),
- rs.getString("MOVEMENT_SPEED"),rs.getString("CENTRAL_PRESSURE"),
- rs.getString("ORIENTATION"),rs.getString("CREATE_TIME")));
- }else{
-
- sb.append(getPointStraightLineLeftQuadrant(Double.parseDouble(tempX.toString()), Double.parseDouble(tempY.toString()),
- rs.getDouble("LONGITUDE"), rs.getDouble("LATITUDE"),
- rs.getString("FD_ID"), rs.getString("SEVEN_RADIUS"), rs.getString("TEN_RADIUS"),
- rs.getString("TWELVE_RADIUS"), rs.getString("MAX_STRENGTH"),rs.getString("MAX_SPEED"),
- rs.getString("MOVEMENT_SPEED"),rs.getString("CENTRAL_PRESSURE"),
- rs.getString("ORIENTATION"),rs.getString("CREATE_TIME")));
- }
-
-
-
-
- sb.append("{\"FD_ID\":\"" + rs.getString("FD_ID") + "\",\"afterX\":\"" + tempX + "\",\"afterY\":\"" + tempY +
- "\",\"LONGITUDE\":" + rs.getDouble("LONGITUDE") + ",\"LATITUDE\":" + rs.getDouble("LATITUDE") +
- ",\"SEVEN_RADIUS\":\"" + rs.getString("SEVEN_RADIUS") + "\",\"TEN_RADIUS\":\"" +
- rs.getString("TEN_RADIUS") + "\",\"TWELVE_RADIUS\":\"" + rs.getString("TWELVE_RADIUS") +
- "\",\"MAX_STRENGTH\":\"" + rs.getString("MAX_STRENGTH") + "\",\"MAX_SPEED\":\"" +
- rs.getString("MAX_SPEED") + "\",\"MOVEMENT_SPEED\":\"" + rs.getString("MOVEMENT_SPEED") +
- "\",\"CENTRAL_PRESSURE\":\"" + rs.getString("CENTRAL_PRESSURE") + "\",\"ORIENTATION\":\"" +
- rs.getString("ORIENTATION") + "\",\"CREATE_TIME\":\"" + rs.getString("CREATE_TIME") + "\",\"addIcon\":\"true\"},");
- tempX.delete(0, tempX.length()) ;
- tempY.delete(0, tempY.length()) ;
- tempX.append(rs.getString("LONGITUDE")) ;
- tempY.append(rs.getString("LATITUDE")) ;
- }
- } catch(SQLException e){ e.printStackTrace(); }
-
- sb.deleteCharAt(sb.length()-1);
- if(sb.length()==0){ return null ; }
- sb.append("]") ;
- return sb.toString() ;
- }
- public StringBuffer getPointStraightLineLeftQuadrant(double x1, double y1, double x2, double y2, String fd_id, String sev, String ten,
- String twe, String strength, String speed, String mspe, String central, String orie,
- String time){
- StringBuffer sb = new StringBuffer();
- double tempX = x1;
- double tempY = y1;
- double k = (y2-y1)/(x2-x1);
- double b = y1 - k*x1;
-
- double posX, posY;
- for(double i = x1 + .03; i < x2; i += .03){
-
- posX = i;
- posY = (k*i+b);
- sb.append("{\"FD_ID\":\"" + fd_id + "\",\"afterX\":\"" + tempX + "\",\"afterY\":\"" + tempY + "\",\"LONGITUDE\":" + posX +
- ",\"LATITUDE\":" + posY + ",\"SEVEN_RADIUS\":\"" + sev + "\",\"TEN_RADIUS\":\"" + ten +
- "\",\"TWELVE_RADIUS\":\"" + twe + "\",\"MAX_STRENGTH\":\"" + strength + "\",\"MAX_SPEED\":\"" + speed +
- "\",\"MOVEMENT_SPEED\":\"" + mspe + "\",\"CENTRAL_PRESSURE\":\"" + central + "\",\"ORIENTATION\":\"" + orie +
- "\",\"CREATE_TIME\":\"" + time + "\",\"addIcon\":\"false\"},");
-
- tempX = posX;
- tempY = posY;
-
- };
-
- return sb;
- }
-
- public StringBuffer getPointStraightLineRightQuadrant(double x1, double y1, double x2, double y2, String fd_id, String sev, String ten,
- String twe, String strength, String speed, String mspe, String central, String orie, String time){
-
- StringBuffer sb = new StringBuffer();
- double tempX = x1;
- double tempY = y1;
-
- double k = (y2-y1)/(x2-x1);
- double b = y1 - k*x1;
-
- double posX, posY;
- boolean flg = y1>=y2;// true:向下 false:向上
-
- for(double i = x1 + .03; i > x2; i -= .03){
-
- posX = i;
- posY = (k*i+b);
- if(flg){
- if(posY <= y1 && posY >= y2){
- sb.append("{\"FD_ID\":\"" + fd_id + "\",\"afterX\":\"" + tempX + "\",\"afterY\":\"" + tempY + "\",\"LONGITUDE\":" + posX +
- ",\"LATITUDE\":" + posY + ",\"SEVEN_RADIUS\":\"" + sev + "\",\"TEN_RADIUS\":\"" + ten +
- "\",\"TWELVE_RADIUS\":\"" + twe + "\",\"MAX_STRENGTH\":\"" + strength + "\",\"MAX_SPEED\":\"" + speed +
- "\",\"MOVEMENT_SPEED\":\"" + mspe + "\",\"CENTRAL_PRESSURE\":\"" + central + "\",\"ORIENTATION\":\"" + orie +
- "\",\"CREATE_TIME\":\"" + time + "\",\"addIcon\":\"false\"},");
- }
- }else{
- if(posY <= y2 && posY >= y1){
- sb.append("{\"FD_ID\":\"" + fd_id + "\",\"afterX\":\"" + tempX + "\",\"afterY\":\"" + tempY + "\",\"LONGITUDE\":" + posX +
- ",\"LATITUDE\":" + posY + ",\"SEVEN_RADIUS\":\"" + sev + "\",\"TEN_RADIUS\":\"" + ten +
- "\",\"TWELVE_RADIUS\":\"" + twe + "\",\"MAX_STRENGTH\":\"" + strength + "\",\"MAX_SPEED\":\"" + speed +
- "\",\"MOVEMENT_SPEED\":\"" + mspe + "\",\"CENTRAL_PRESSURE\":\"" + central + "\",\"ORIENTATION\":\"" + orie +
- "\",\"CREATE_TIME\":\"" + time + "\",\"addIcon\":\"false\"},");
- }
- }
-
-
- tempX = posX;
- tempY = posY;
-
- };
-
- return sb;
- }
-
-
- public String listTransitionStrbuf(List<Date> list){
-
- StringBuffer sb = new StringBuffer();
- sb.append("[");
-
- Calendar cal = Calendar.getInstance();
- Set<Integer> year = new HashSet<Integer>();
- Set<Integer> month = new HashSet<Integer>();
- ArrayList<Integer> yearo = new ArrayList<Integer>();
- ArrayList<Integer> montho = new ArrayList<Integer>();
-
- Map<Integer,ArrayList<Integer>> ym = new HashMap<Integer, ArrayList<Integer>>();
-
- for(Date key : list){
- cal.setTime(key);
- year.add(cal.get(Calendar.YEAR));
- }
-
- for(Integer key : year){
- yearo.add(key);
- }
-
- Collections.sort(yearo,Collections.reverseOrder());
-
- for(Integer keys : yearo){
- month = new HashSet<Integer>();
- for(Date key : list){
- cal.setTime(key);
- if(keys == cal.get(Calendar.YEAR)){
- month.add(cal.get(Calendar.MONTH) + 1);
- }
- }
- for(Integer key : month){
- montho.add(key);
- }
- Collections.sort(montho,Collections.reverseOrder());
- ym.put(keys, montho);
- }
-
- for(Integer key : yearo){
- sb.append("{\"year\":\"" + key + "\",\"mone\":[");
- for(Integer mo : ym.get(key)){
- sb.append("\"" + mo + "月\",");
- }
- sb.deleteCharAt(sb.length()-1);
- sb.append("]},");
- }
-
- sb.deleteCharAt(sb.length()-1);
- if(sb.length()==0){ return null ; }
- sb.append("]");
-
- return sb.toString();
- }
- }
|