Authored by 王凤

合并分支 'swy' 到 'master'

不知道是干啥的,但就是缺少了



查看合并请求 !7
  1 +package com.sitech.database.dao;
  2 +
  3 +
  4 +import com.sitech.ismp.messageObject.TbAtoDynamicThreshold;
  5 +
  6 +import java.util.HashMap;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +import java.util.regex.Matcher;
  10 +import java.util.regex.Pattern;
  11 +
  12 +/**
  13 + * Created with IntelliJ IDEA.
  14 + * User: dongyj
  15 + * Date: 16-11-1
  16 + * Time: 上午10:12
  17 + * To change this template use File | Settings | File Templates.
  18 + */
  19 +public class TbAtoDynamicThresholdDao extends BaseDao {
  20 +
  21 + @SuppressWarnings("unchecked")
  22 + public List<TbAtoDynamicThreshold> queryDynamicCfgByKpiId(TbAtoDynamicThreshold tbAtoDynamicThreshold) {
  23 + try {
  24 + Map map = new HashMap();
  25 + map.put("UNIT_ID",tbAtoDynamicThreshold.getUNIT_ID().trim());
  26 + map.put("EXT_UNIT_ID",getExtUnitId(tbAtoDynamicThreshold.getUNIT_ID().trim()));
  27 + map.put("KPI_ID",tbAtoDynamicThreshold.getKPI_ID().trim());
  28 + map.put("CLL_TIME",tbAtoDynamicThreshold.getSTART_TIME());
  29 + map.put("DB_TIME",tbAtoDynamicThreshold.getEND_TIME());
  30 + return sqlmapClient.queryForList("queryDynamicCfgByKpiId", map);
  31 + } catch (Exception e) {
  32 + error.error("Exception while queryEventCfgByKpiId("+tbAtoDynamicThreshold+")", e);
  33 + return null;
  34 + }
  35 + }
  36 +
  37 + /**
  38 + * 新增动态阀值数据
  39 + * @param tbAtoDynamicThreshold
  40 + */
  41 + public void insertTbAtoDynamicThreshold(TbAtoDynamicThreshold tbAtoDynamicThreshold) {
  42 + try {
  43 + sqlmapClient.insert("insertTbAtoDynamicThreshold", tbAtoDynamicThreshold);
  44 + } catch (Exception e) {
  45 + error.error("Exception while insertTbAtoDynamicThreshold.", e);
  46 + }
  47 + }
  48 +
  49 + /**
  50 + * 删除表中所有动态阀值配置
  51 + * @return
  52 + */
  53 + public int deleteTbAtoDynamicThresholdAll() {
  54 + try {
  55 + return sqlmapClient.delete("deleteTbAtoDynamicThresholdAll", null);
  56 + } catch (Exception e) {
  57 + error.error("Exception while deleteTbAtoDynamicThresholdAll.", e);
  58 + return -1;
  59 + }
  60 + }
  61 +
  62 + /**
  63 + * 根据guid[]删除动态阀值配置
  64 + * @param id
  65 + * @return
  66 + */
  67 + public int deleteTbAtoDynamicThreshold(String[] id) {
  68 + HashMap<String, String[]> params = new HashMap<String, String[]>();
  69 + params.put("ID", id);
  70 +
  71 + try {
  72 + return sqlmapClient.delete("deleteTbAtoDynamicThreshold", params);
  73 + } catch (Exception e) {
  74 + error.error("Exception while deleteTbAtoDynamicThreshold.", e);
  75 + return -1;
  76 + }
  77 + }
  78 +
  79 + public static String getExtUnitId(String unitId) {
  80 + Matcher platform = Pattern.compile("^(10\\-\\d+\\-\\d++).*:([^\\-]+).*$").matcher(unitId);
  81 + if (platform.find()) {
  82 + return platform.group(1) + ":" + platform.group(2);
  83 + }
  84 + return "";
  85 + }
  86 +
  87 +}
@@ -189,31 +189,22 @@ public class SQLTarget extends CollBase { @@ -189,31 +189,22 @@ public class SQLTarget extends CollBase {
189 Vector recordSet = new Vector(); 189 Vector recordSet = new Vector();
190 PreparedStatement pstmt = null; 190 PreparedStatement pstmt = null;
191 ResultSet result = null; 191 ResultSet result = null;
192 - if (!getState()) {  
193 - return recordSet;  
194 - }  
195 -  
196 try { 192 try {
197 - pstmt = dbConnection.prepareStatement(sql);  
198 - } catch (SQLException e) {  
199 - throw new RuntimeException("Exception while exec sql :" + sql, e);  
200 - } 193 + if (!getState()) {
  194 + return recordSet;
  195 + }
201 196
202 - boolean hasResult = false;  
203 - try {  
204 - hasResult = pstmt.execute();  
205 - } catch (SQLException e) {  
206 - logger.error("pstmt.execute() has error!",e);  
207 - e.printStackTrace();  
208 - }  
209 - try { 197 + pstmt = dbConnection.prepareStatement(sql);
210 198
  199 + //避免在采集9i数据库时,在CollOracleBySql.getTableSpaces()方法中无法执行catch里面的方法,
  200 + // 将此处的捕捉异常去掉,统一捕获异常 2017-5-25 swy(代码之前是没有在这里捕获异常的)
  201 + boolean hasResult = pstmt.execute();
211 if (hasResult) { 202 if (hasResult) {
212 result = pstmt.getResultSet(); 203 result = pstmt.getResultSet();
213 ResultSetMetaData rsmd = result.getMetaData(); 204 ResultSetMetaData rsmd = result.getMetaData();
214 int iColumnCount = rsmd.getColumnCount(); 205 int iColumnCount = rsmd.getColumnCount();
215 while (result.next()) { 206 while (result.next()) {
216 - Vector vTemp = new Vector(); 207 + java.util.Vector vTemp = new Vector();
217 for (int i = 0; i < iColumnCount; i++) { 208 for (int i = 0; i < iColumnCount; i++) {
218 Object oTemp = result.getObject(i + 1); 209 Object oTemp = result.getObject(i + 1);
219 String sTemp = oTemp == null ? "" : oTemp.toString(); 210 String sTemp = oTemp == null ? "" : oTemp.toString();