network_test.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package service
  2. import (
  3. "encoding/json"
  4. "log"
  5. "testing"
  6. "app.yhyue.com/moapp/jybase/es"
  7. "app.yhyue.com/moapp/jybase/mysql"
  8. . "bp.jydev.jianyu360.cn/CRM/application/api/common"
  9. "bp.jydev.jianyu360.cn/CRM/application/api/internal/config"
  10. "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
  11. )
  12. func initDb() {
  13. CrmMysql = &mysql.Mysql{
  14. Address: "192.168.3.14:4000",
  15. UserName: "root",
  16. PassWord: "=PDT49#80Z!RVv52_z",
  17. DBName: "crm",
  18. MaxOpenConns: 5,
  19. MaxIdleConns: 5,
  20. }
  21. CrmMysql.Init()
  22. ConnectClickhouse(&config.CHouseConfig{
  23. Addr: "192.168.3.207:19000",
  24. UserName: "jytop",
  25. Password: "pwdTopJy123",
  26. DbName: "jianyu",
  27. MaxIdleConns: 2,
  28. MaxOpenConns: 2,
  29. })
  30. es.NewEs("v7", "http://192.168.3.149:9200", 5, "", "")
  31. }
  32. func TestAddOrUpdate(t *testing.T) {
  33. initDb()
  34. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  35. for _, v := range []string{"firstparty", "supplier", "adiffb", "middleman", "agency"} {
  36. text := ""
  37. switch v {
  38. case "firstparty":
  39. text = "甲方"
  40. case "supplier":
  41. text = "供应商"
  42. case "adiffb":
  43. text = "同甲异业"
  44. case "middleman":
  45. text = "中间人"
  46. case "agency":
  47. text = "招标代理机构"
  48. }
  49. text += "_2"
  50. res := Network.AddOrUpdate(&types.AddOrUpdateReq{
  51. PositionId: 943,
  52. Company_id: "112233445566",
  53. Company_name: "王传进的" + text,
  54. Contact_person: "王传进",
  55. Contact_phone: "15037870765",
  56. Introduce_owner_id: "11,22,33",
  57. Introduce_owner_name: "aa,bb,cc",
  58. Introduce_project_id: "44,55,66",
  59. Introduce_project_name: "dd,ee,ff",
  60. Type: "middleman",
  61. })
  62. log.Println(res)
  63. }
  64. }
  65. func TestAssociate(t *testing.T) {
  66. initDb()
  67. //log.Println(NetworkCom.GetEntTagSeat(2))
  68. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 middleman_owner:中间人-业主 middleman_project:中间人-项目 agency:招标代理机构
  69. //
  70. res := Network.Associate(&types.AssociateReq{
  71. EntName: "深圳市光明区马田街道市政管理和建设工程事务中心",
  72. EntAccountId: 64,
  73. Name: "公司",
  74. Type: "adiffb",
  75. })
  76. log.Println(res.Data)
  77. }
  78. func TestNetWorkList(t *testing.T) {
  79. initDb()
  80. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  81. res := Network.List(&types.NetWorkListReq{
  82. PositionId: 943,
  83. Order_amount: 1,
  84. Monitorcount_start: 1,
  85. Monitorcount_end: 1,
  86. //Monitor: 0,
  87. //Project_matchme: 1,
  88. })
  89. for k, v := range res.Data.(map[string]interface{}) {
  90. if k == "list" {
  91. continue
  92. }
  93. log.Println(k, v)
  94. }
  95. for _, v := range res.Data.(map[string]interface{})["list"].([]*map[string]interface{}) {
  96. log.Println(v)
  97. }
  98. }
  99. func TestAllProject(t *testing.T) {
  100. initDb()
  101. res := Network.AllProject(&types.AllprojectReq{
  102. EntAccountId: 64,
  103. PositionId: 943,
  104. //Id: "wcj_11111111a",
  105. //Type: 1,
  106. })
  107. b, _ := json.Marshal(res.Data)
  108. log.Println(string(b))
  109. }