소스 검색

统一entity_type

Joey 6 달 전
부모
커밋
67571b66c0
1개의 변경된 파일31개의 추가작업 그리고 6개의 파일을 삭제
  1. 31 6
      modules/sqlUtilities.dos

+ 31 - 6
modules/sqlUtilities.dos

@@ -92,6 +92,30 @@ def save_hedge_fund_nav_to_local(tb_nav) {
 }
 
 /*
+ *   未知形态的id转为MySQL需要的的逗号分隔字符串
+ * 
+ *   Example: ids_to_string("'a','b','c'");
+ *            ids_to_string(['a', 'b', 'c']);
+ */
+def ids_to_string(ids) {
+
+    s_ids = '';
+    
+    // 输入的 ids 是字符串标量
+    if (ids.form() == 0) {
+        s_ids = ids.trim();
+    // 输入的 ids 是字符串向量
+    } else if(ids.form() == 1) {
+        s_ids = "'" + ids.trim()concat("','") + "'";
+    // 缺省返回空
+    } else {
+    	s_ids = NULL;
+    }
+
+    return s_ids;
+}
+
+/*
  *  根据不同类型的主体返回其净值表的表名、字段名和ID前两位特征字符
  */
 def get_nav_table_description(entity_type) {
@@ -101,7 +125,8 @@ def get_nav_table_description(entity_type) {
                          [STRING, STRING, STRING, STRING, STRING, STRING]);
 
     // 分别对应:私募,公募,私有基金,股票,市场指数,图译指数,私有指数,图译因子,组合
-    INSERT INTO tmp_universe VALUES  ( ['HF', 'MF', 'CF', 'EQ', 'MI', 'FI', 'CI', 'FA', 'PF'],
+    INSERT INTO tmp_universe VALUES (
+        ['HF', 'MF', 'CF', 'EQ', 'MI', 'FI', 'CI', 'FA', 'PF'],
         ['mfdb.nav', 'mfdb.public_nav', 'pfdb.pf_cus_fund_nav', 'mfdb.stock_price', 'mfdb.market_indexes', 'mfdb.indexes_ty_index', 'pfdb.cm_udf_index_nav', 'pfdb.cm_factor_value', 'pfdb.pf_portfolio_nav'],
         ['fund_id', 'fund_id', 'fund_id', 'sec_id', 'index_id', 'index_id', 'index_id', 'factor_id', 'portfolio_id'],
         ['cumulative_nav', 'cumulative_nav', 'cumulative_nav', 'cumulative_nav', 'close', 'index_value', 'cumulative_nav', 'factor_value', 'cumulative_nav'],
@@ -121,12 +146,12 @@ def get_performance_table_description(entity_type) {
                          ['type', 'table_name', 'sec_id_col', 'cumulative_nav_col'],
                          [STRING, STRING, STRING, STRING]);
 
-    // 分别对应:公私募,私有基金,股票,市场/图译指数,私有指数,图译因子,组合
+    // 分别对应:私募,公募,私有基金,股票,市场指数,图译指数,私有指数,图译因子,组合
     INSERT INTO tmp_universe VALUES ( 
-        ['FD', 'CF', 'EQ', 'IX', 'CI', 'FA', 'PF'],
-        ['mfdb.fund_performance', 'pfdb.pf_cus_fund_performance', 'mfdb.stock_performance', 'mfdb.fund_performance', 'pfdb.cm_udf_index_performance', 'pfdb.cm_factor_performance', 'pfdb.pf_portfolio_performance'],
-        ['fund_id', 'fund_id', 'sec_id', 'fund_id', 'index_id', 'factor_id', 'portfolio_id'],
-        ['cumulative_nav', 'cumulative_nav', 'cumulative_nav', 'cumulative_nav', 'cumulative_nav', 'factor_value', 'cumulative_nav'] );
+        ['HF', 'MF', 'CF', 'EQ', 'MI', 'FI', 'CI', 'FA', 'PF'],
+        ['mfdb.fund_performance', 'mfdb.fund_performance', 'pfdb.pf_cus_fund_performance', 'mfdb.stock_performance', 'mfdb.fund_performance', 'mfdb.fund_performance', 'pfdb.cm_udf_index_performance', 'pfdb.cm_factor_performance', 'pfdb.pf_portfolio_performance'],
+        ['fund_id', 'fund_id', 'fund_id', 'sec_id', 'fund_id', 'fund_id', 'index_id', 'factor_id', 'portfolio_id'],
+        ['cumulative_nav', 'cumulative_nav', 'cumulative_nav', 'cumulative_nav', 'cumulative_nav', 'cumulative_nav', 'cumulative_nav', 'factor_value', 'cumulative_nav'] );
 
     return (SELECT * FROM tmp_universe u WHERE u.type = entity_type);