main.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/spf13/viper"
  5. "jygit.jydev.jianyu360.cn/data_processing/common_utils/log"
  6. "jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb"
  7. )
  8. var (
  9. GF GlobalConf
  10. MgoPA *mongodb.MongodbSim //凭安推送数据库
  11. MgoB *mongodb.MongodbSim //bidding 标讯数据库
  12. )
  13. // EntMapCode 映射关系表
  14. type EntMapCode struct {
  15. AId string `json:"a_id"`
  16. BId string `json:"b_id"`
  17. AName string `json:"a_name"`
  18. BName string `json:"b_name"`
  19. Code string `json:"code"` //关系属性代码
  20. InvestRatio string `json:"invest_ratio"` //投资比例
  21. InvestPrice string `json:"invest_price"` //投资金额
  22. CreateTime int64 `json:"create_time"`
  23. UpdateTime int64 `json:"update_time"`
  24. }
  25. func (EntMapCode) TableName() string {
  26. return "ent_map_code"
  27. }
  28. func InitConfig() (err error) {
  29. viper.SetConfigFile("config.toml") // 指定配置文件路径
  30. viper.SetConfigName("config") // 配置文件名称(无扩展名)
  31. viper.SetConfigType("toml") // 如果配置文件的名称中没有扩展名,则需要配置此项
  32. viper.AddConfigPath("./")
  33. viper.AddConfigPath("./conf/") // 还可以在工作目录中查找配置
  34. viper.AddConfigPath("../conf/") // 还可以在工作目录中查找配置
  35. err = viper.ReadInConfig() // 查找并读取配置文件
  36. if err != nil { // 处理读取配置文件的错误
  37. return
  38. }
  39. err = viper.Unmarshal(&GF)
  40. return err
  41. }
  42. func InitLog() {
  43. err := log.InitLog(
  44. log.Path("./logs/log.out"),
  45. //log.Path(""),
  46. log.Level("info"),
  47. log.Compress(true),
  48. log.MaxSize(10),
  49. log.MaxBackups(10),
  50. log.MaxAge(7),
  51. log.Format("json"),
  52. )
  53. if err != nil {
  54. fmt.Printf("InitLog failed: %v\n", err)
  55. }
  56. }
  57. func InitMgo() {
  58. MgoB = &mongodb.MongodbSim{
  59. MongodbAddr: GF.MongoB.Host,
  60. DbName: GF.MongoB.DB,
  61. Size: GF.MongoB.Size,
  62. UserName: GF.MongoB.Username,
  63. Password: GF.MongoB.Password,
  64. Direct: GF.MongoB.Direct,
  65. }
  66. MgoB.InitPool()
  67. MgoPA = &mongodb.MongodbSim{
  68. MongodbAddr: GF.MongoPA.Host,
  69. DbName: GF.MongoPA.DB,
  70. Size: GF.MongoPA.Size,
  71. UserName: GF.MongoPA.Username,
  72. Password: GF.MongoPA.Password,
  73. Direct: GF.MongoPA.Direct,
  74. }
  75. MgoPA.InitPool()
  76. }
  77. func main() {
  78. InitConfig()
  79. InitLog()
  80. InitMgo()
  81. //biddingAllData()//交易关系存量数据
  82. //organizeData() //管辖关系
  83. updateInfoId() // 更新映射表法库人ID
  84. //areaData()
  85. return
  86. //local, _ := time.LoadLocation("Asia/Shanghai")
  87. //c := cron.New(cron.WithLocation(local), cron.WithSeconds())
  88. ////1.处理投资关系,增量数据,凭安每周推送数据;每周三定时执行
  89. //
  90. //if GF.Env.Spec1 != "" {
  91. // _, err := c.AddFunc(GF.Env.Spec1, increInvest)
  92. // if err != nil {
  93. // log.Info("main", zap.Error(err))
  94. // }
  95. //}
  96. //
  97. ////2. 处理bidding标讯 交易关系数据
  98. //if GF.Env.Spec2 != "" {
  99. // _, err := c.AddFunc(GF.Env.Spec2, increBidding)
  100. // if err != nil {
  101. // log.Info("main", zap.Error(err))
  102. // }
  103. //}
  104. //
  105. ////3. 更新法人库表ID,更新映射表对应的法人库ID
  106. //if GF.Env.Spec3 != "" {
  107. // _, err := c.AddFunc(GF.Env.Spec3, updateInfoId)
  108. // if err != nil {
  109. // log.Info("main", zap.Error(err))
  110. // }
  111. //}
  112. //
  113. //c.Start()
  114. //defer c.Stop()
  115. //
  116. //select {}
  117. }
  118. type EntInfo struct {
  119. ID string `gorm:"primaryKey"`
  120. CompanyID *string `gorm:"column:company_id"`
  121. CompanyName *string `gorm:"column:company_name"`
  122. CompanyLabel uint64 `gorm:"column:company_label"` // Needs clarification on GORM handling of AggregateFunction
  123. CompanyCode *string `gorm:"column:company_code"`
  124. CreditNo *string `gorm:"column:credit_no"`
  125. OrgCode *string `gorm:"column:org_code"`
  126. TaxCode *string `gorm:"column:tax_code"`
  127. EstablishDate *int64 `gorm:"column:establish_date"`
  128. LegalPerson *string `gorm:"column:legal_person"`
  129. LegalPersonCaption *string `gorm:"column:legal_person_caption"`
  130. CompanyStatus *string `gorm:"column:company_status"`
  131. CompanyType *string `gorm:"column:company_type"`
  132. Authority *string `gorm:"column:authority"`
  133. IssueDate *int64 `gorm:"column:issue_date"`
  134. OperationStartDate *string `gorm:"column:operation_startdate"`
  135. OperationEndDate *string `gorm:"column:operation_enddate"`
  136. Capital *string `gorm:"column:capital"`
  137. CompanyAddress *string `gorm:"column:company_address"`
  138. BusinessScope *string `gorm:"column:business_scope"`
  139. CancelDate *int64 `gorm:"column:cancel_date"`
  140. CancelReason *string `gorm:"column:cancel_reason"`
  141. RevokeDate *int64 `gorm:"column:revoke_date"`
  142. RevokeReason *string `gorm:"column:revoke_reason"`
  143. Comeintime *int64 `gorm:"column:comeintime"`
  144. Updatetime *int64 `gorm:"column:updatetime"`
  145. LegalPersonType *int8 `gorm:"column:legal_person_type"`
  146. RealCapital *string `gorm:"column:real_capital"`
  147. EnName *string `gorm:"column:en_name"`
  148. CompanyArea *string `gorm:"column:company_area"`
  149. ListCode *string `gorm:"column:list_code"`
  150. EmployeeNo *int32 `gorm:"column:employee_no"`
  151. Website *string `gorm:"column:website"`
  152. BusinessType *int8 `gorm:"column:business_type"`
  153. Sourcetype *int8 `gorm:"column:sourcetype"`
  154. CompanyPhone *string `gorm:"column:company_phone"`
  155. CompanyEmail *string `gorm:"column:company_email"`
  156. CompanyUnitType *int8 `gorm:"column:company_unit_type"`
  157. LongitudeLatitude *string `gorm:"column:longitude_latitude"`
  158. AdminLevel *string `gorm:"column:admin_level"`
  159. }
  160. func (EntInfo) TableName() string {
  161. return "ent_info"
  162. }