network_test.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package service
  2. import (
  3. "encoding/json"
  4. "log"
  5. "testing"
  6. . "app.yhyue.com/moapp/jybase/common"
  7. "app.yhyue.com/moapp/jybase/es"
  8. . "app.yhyue.com/moapp/jybase/mongodb"
  9. "app.yhyue.com/moapp/jybase/mysql"
  10. . "bp.jydev.jianyu360.cn/CRM/application/api/common"
  11. "bp.jydev.jianyu360.cn/CRM/application/api/internal/config"
  12. "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
  13. )
  14. func initDb() {
  15. CrmMysql = &mysql.Mysql{
  16. Address: "192.168.3.217:4000",
  17. UserName: "root",
  18. PassWord: "=PDT49#80Z!RVv52_z",
  19. DBName: "crm",
  20. MaxOpenConns: 5,
  21. MaxIdleConns: 5,
  22. }
  23. CrmMysql.Init()
  24. ConnectClickhouse(&config.CHouseConfig{
  25. Addr: "192.168.3.207:19000",
  26. UserName: "jytop",
  27. Password: "pwdTopJy123",
  28. DbName: "information",
  29. MaxIdleConns: 2,
  30. MaxOpenConns: 2,
  31. })
  32. es.NewEs("v7", "http://192.168.3.149:9200", 5, "", "")
  33. log.Println("ccccccc")
  34. Mgo = MongodbSim{
  35. MongodbAddr: "192.168.3.149:27180",
  36. Size: 2,
  37. DbName: "qfw",
  38. }
  39. Mgo.InitPool()
  40. }
  41. func TestAddOrUpdate(t *testing.T) {
  42. defer Catch()
  43. initDb()
  44. res1 := Network.AddOrUpdate(&types.AddOrUpdateReq{
  45. PositionId: 943,
  46. Company_name: "王传进的89",
  47. Contact_person: "王传进",
  48. Contact_phone: "15037870765",
  49. Type: "middleman",
  50. Introduce_owner_id: "5aebc2c37a624e8bacc40c1802a57041",
  51. Introduce_owner_name: "北京影业(北京)有限公司",
  52. Introduce_project_id: "5aebc2c37a624e8bacc40c1802a57041,北京物业服务",
  53. })
  54. log.Println(res1)
  55. return
  56. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  57. for _, v := range []string{"firstparty", "supplier", "adiffb", "middleman", "agency"} {
  58. text := ""
  59. switch v {
  60. case "firstparty":
  61. text = "甲方"
  62. case "supplier":
  63. text = "供应商"
  64. case "adiffb":
  65. text = "同甲异业"
  66. case "middleman":
  67. text = "中间人"
  68. case "agency":
  69. text = "招标代理机构"
  70. }
  71. text += "_2"
  72. res := Network.AddOrUpdate(&types.AddOrUpdateReq{
  73. PositionId: 943,
  74. Company_id: "112233445566",
  75. Company_name: "王传进的" + text,
  76. Contact_person: "王传进",
  77. Contact_phone: "15037870765",
  78. Introduce_owner_id: "11,22,33",
  79. Introduce_owner_name: "aa,bb,cc",
  80. Introduce_project_id: "44,55,66",
  81. Introduce_project_name: "dd,ee,ff",
  82. Type: "middleman",
  83. })
  84. log.Println(res)
  85. }
  86. }
  87. func TestAssociate(t *testing.T) {
  88. initDb()
  89. //log.Println(NetworkCom.GetEntTagSeat(2))
  90. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 middleman_owner:中间人-业主 middleman_project:中间人-项目 agency:招标代理机构
  91. //
  92. res := Network.Associate(&types.AssociateReq{
  93. //EntName: "深圳市光明区马田街道市政管理和建设工程事务中心",
  94. //EntAccountId: 64,
  95. Name: "北京",
  96. Type: "middleman",
  97. })
  98. log.Println(res.Data)
  99. }
  100. func TestNetWorkList(t *testing.T) {
  101. initDb()
  102. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  103. res := Network.List(&types.NetWorkListReq{
  104. UserId: "1205591997",
  105. PositionId: 1205591997,
  106. //PositionId: 935,
  107. Current_page: 1,
  108. Page_size: 100,
  109. //PositionId: 935,
  110. //PositionId: 1205591998,
  111. //Order_amount: -1,
  112. // Monitorcount_start: 1,
  113. // Monitorcount_end: 1,
  114. //Monitor: 0,
  115. //Project_matchme: 1,
  116. //Starttime: "2024-04-23",
  117. //Endtime: "2024-04-23",
  118. //Type: "firstparty",
  119. //Name: "三亚市",
  120. })
  121. for k, v := range res.Data.(map[string]interface{}) {
  122. if k == "list" {
  123. continue
  124. }
  125. log.Println(k, v)
  126. }
  127. for _, v := range res.Data.(map[string]interface{})["list"].([]*map[string]interface{}) {
  128. log.Println(v)
  129. }
  130. }
  131. func TestAllProject(t *testing.T) {
  132. initDb()
  133. res := Network.AllProject(&types.AllprojectReq{
  134. EntAccountId: 64,
  135. //PositionId: 935,
  136. PositionId: 1205591997, //刘苗
  137. //PositionId: 1205592003,//刘亚丽
  138. //Id: "b57d8f87b1d748dab5b200a6f1da0d37",
  139. //Type: "firstparty",
  140. })
  141. b, _ := json.Marshal(res.Data)
  142. log.Println(string(b))
  143. }
  144. func TestOwner(t *testing.T) {
  145. initDb()
  146. ownerService := &OwnerService{
  147. Intermediary: "wcj_11111111f",
  148. PositionId: 935,
  149. PageIndex: 1,
  150. PageSize: 100,
  151. }
  152. data := ownerService.OwnerlList()
  153. b, _ := json.Marshal(data)
  154. log.Println(string(b))
  155. }