edb_data_table.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package data_manage
  2. import (
  3. "errors"
  4. "hongze/hongze_task/utils"
  5. "strconv"
  6. "time"
  7. )
  8. func GetEdbDataTableName(source int) (tableName string) {
  9. switch source {
  10. case utils.DATA_SOURCE_THS:
  11. tableName = "edb_data_ths"
  12. case utils.DATA_SOURCE_WIND:
  13. tableName = "edb_data_wind"
  14. case utils.DATA_SOURCE_PB:
  15. tableName = "edb_data_pb"
  16. case utils.DATA_SOURCE_CALCULATE:
  17. tableName = "edb_data_calculate"
  18. case utils.DATA_SOURCE_CALCULATE_LJZZY:
  19. tableName = "edb_data_calculate_ljzzy"
  20. case utils.DATA_SOURCE_CALCULATE_TBZ:
  21. tableName = "edb_data_calculate_tbz"
  22. case utils.DATA_SOURCE_CALCULATE_TCZ:
  23. tableName = "edb_data_calculate_tcz"
  24. case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS:
  25. tableName = "edb_data_calculate_nszydpjjs"
  26. case utils.DATA_SOURCE_MANUAL:
  27. tableName = "edb_data_manual"
  28. default:
  29. tableName = ""
  30. errors.New("无效的渠道:" + strconv.Itoa(source))
  31. return
  32. }
  33. return
  34. }
  35. func GetEdbInfoCalculateTableName(source int) (tableName string) {
  36. switch source {
  37. case utils.DATA_SOURCE_CALCULATE:
  38. tableName = "edb_info_calculate"
  39. case utils.DATA_SOURCE_CALCULATE_LJZZY:
  40. tableName = "edb_info_calculate_ljzzy"
  41. case utils.DATA_SOURCE_CALCULATE_TBZ:
  42. tableName = "edb_info_calculate_tbz"
  43. case utils.DATA_SOURCE_CALCULATE_TCZ:
  44. tableName = "edb_info_calculate_tcz"
  45. case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS:
  46. tableName = "edb_info_calculate_nszydpjjs"
  47. default:
  48. tableName = ""
  49. errors.New("无效的渠道:" + strconv.Itoa(source))
  50. return
  51. }
  52. return
  53. }
  54. func GetAddSql(edbInfoId, edbCode, dataTime, timestampStr,value string) (addSql string) {
  55. nowStr := time.Now().Format(utils.FormatDateTime)
  56. addSql += "("
  57. addSql += edbInfoId + "," + "'" + edbCode + "'" + "," + "'" + dataTime + "'" + "," + value + "," + "'" + nowStr + "'" +
  58. "," + "'" + nowStr + "'" + "," + "1"
  59. addSql += "," + "'" + timestampStr + "'"
  60. addSql += "),"
  61. return
  62. }