edb_data_table.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. case utils.DATA_SOURCE_LZ:
  29. tableName = "edb_data_lz"
  30. default:
  31. tableName = ""
  32. errors.New("无效的渠道:" + strconv.Itoa(source))
  33. return
  34. }
  35. return
  36. }
  37. func GetEdbInfoCalculateTableName(source int) (tableName string) {
  38. switch source {
  39. case utils.DATA_SOURCE_CALCULATE:
  40. tableName = "edb_info_calculate"
  41. case utils.DATA_SOURCE_CALCULATE_LJZZY:
  42. tableName = "edb_info_calculate_ljzzy"
  43. case utils.DATA_SOURCE_CALCULATE_TBZ:
  44. tableName = "edb_info_calculate_tbz"
  45. case utils.DATA_SOURCE_CALCULATE_TCZ:
  46. tableName = "edb_info_calculate_tcz"
  47. case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS:
  48. tableName = "edb_info_calculate_nszydpjjs"
  49. default:
  50. tableName = ""
  51. errors.New("无效的渠道:" + strconv.Itoa(source))
  52. return
  53. }
  54. return
  55. }
  56. func GetAddSql(edbInfoId, edbCode, dataTime, timestampStr,value string) (addSql string) {
  57. nowStr := time.Now().Format(utils.FormatDateTime)
  58. addSql += "("
  59. addSql += edbInfoId + "," + "'" + edbCode + "'" + "," + "'" + dataTime + "'" + "," + value + "," + "'" + nowStr + "'" +
  60. "," + "'" + nowStr + "'" + "," + "1"
  61. addSql += "," + "'" + timestampStr + "'"
  62. addSql += "),"
  63. return
  64. }