network.go 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200
  1. package service
  2. import (
  3. "context"
  4. "database/sql"
  5. "fmt"
  6. "math"
  7. "sort"
  8. "strings"
  9. "time"
  10. . "app.yhyue.com/moapp/jybase/common"
  11. . "app.yhyue.com/moapp/jybase/date"
  12. "app.yhyue.com/moapp/jybase/encrypt"
  13. . "app.yhyue.com/moapp/jybase/es"
  14. . "app.yhyue.com/moapp/jybase/sort"
  15. . "bp.jydev.jianyu360.cn/CRM/application/api/common"
  16. "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
  17. "github.com/shopspring/decimal"
  18. "github.com/zeromicro/go-zero/core/logx"
  19. )
  20. var Network = &network{}
  21. type network struct {
  22. }
  23. type networkTree struct {
  24. Count int64 `json:"count"`
  25. Name string `json:"name"`
  26. Children []*networkTreeChild `json:"children"`
  27. }
  28. type networkTreeChild struct {
  29. Count int64 `json:"count"`
  30. Id int64 `json:"id"`
  31. CompanyId string `json:"companyId"`
  32. CompanyName string `json:"companyName"`
  33. Type string `json:"type"`
  34. CreateTime string `json:"createTime"`
  35. }
  36. func (s *networkTree) Len() int {
  37. return len(s.Children)
  38. }
  39. func (s *networkTree) Less(i, j int) bool {
  40. if s.Name == "甲方" {
  41. return s.Children[i].CompanyName < s.Children[j].CompanyName
  42. }
  43. it, err1 := time.ParseInLocation(Date_Full_Layout, s.Children[i].CreateTime, time.Local)
  44. if err1 != nil {
  45. return true
  46. }
  47. jt, err2 := time.ParseInLocation(Date_Full_Layout, s.Children[j].CreateTime, time.Local)
  48. if err2 != nil {
  49. return true
  50. }
  51. return it.Unix() < jt.Unix()
  52. }
  53. func (s *networkTree) Swap(i, j int) {
  54. s.Children[i], s.Children[j] = s.Children[j], s.Children[i]
  55. }
  56. type projectInfo struct {
  57. BuyerCount int64
  58. ProjectCount int64
  59. ProjectAmount float64
  60. MonitorCount int64
  61. ExportId []string
  62. }
  63. type firstpartyNetwork struct {
  64. CompanyId string
  65. CompanyName string
  66. Name string
  67. }
  68. type idName struct {
  69. Id string
  70. Name string
  71. }
  72. type introduceOwnerProject struct {
  73. Networks []*myNetwork
  74. FirstpartyNetwork map[string][]*firstpartyNetwork
  75. Firstparty map[string]*projectInfo
  76. Supplier map[string]*projectInfo
  77. Adiffb map[string]*projectInfo
  78. Agency map[string]*projectInfo
  79. Middleman map[string]*projectInfo
  80. }
  81. type myNetwork struct {
  82. Id int64
  83. Company_id string
  84. Company_name string
  85. Qyxy_id string
  86. Itype int64
  87. Person string
  88. Phone string
  89. Buyer_count int64
  90. Project_count int64
  91. Relate_buyer_id string
  92. Relate_project_id string
  93. Create_time string
  94. }
  95. //人脉库-添加/修改人脉
  96. func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
  97. reply := &types.Reply{Data: map[string]interface{}{
  98. "status": 0,
  99. }}
  100. if in.Type != "middleman" && in.Company_id == "" {
  101. return reply
  102. }
  103. if in.Company_name == "" {
  104. in.Company_name = "未填写"
  105. }
  106. nowFormat := NowFormat(Date_Full_Layout)
  107. var saveIntroduce = func(tx *sql.Tx, cid int64, isUpdate bool) bool {
  108. if in.Type != "middleman" {
  109. return true
  110. } else if in.Introduce_owner_id == "" || in.Introduce_project_id == "" {
  111. return false
  112. }
  113. values := []interface{}{}
  114. ioi := strings.Split(in.Introduce_owner_id, ",")
  115. ioqi := strings.Split(in.Introduce_owner_qyxy_id, ",")
  116. ion := strings.Split(in.Introduce_owner_name, ",")
  117. if len(ioi) != len(ion) || len(ioi) != len(ioqi) {
  118. return false
  119. }
  120. for k, v := range ioi {
  121. values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, ioqi[k], v, ion[k], 1, nowFormat)
  122. }
  123. ipi := strings.Split(in.Introduce_project_id, ",")
  124. ipn := strings.Split(in.Introduce_project_name, ",")
  125. if len(ipi) != len(ipn) {
  126. return false
  127. }
  128. for k, v := range ipi {
  129. values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, nil, v, ipn[k], 2, nowFormat)
  130. }
  131. var r2 int64
  132. if isUpdate {
  133. r2 = CrmMysql.UpdateOrDeleteBySqlByTx(tx, `delete from crm.connection_introduce where connection_id=? and position_id=?`, in.Id, in.PositionId)
  134. }
  135. r3, _ := CrmMysql.InsertBatchByTx(tx, "crm.connection_introduce", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "connection_id", "qyxy_id", "relate_id", "relate_name", "itype", "create_time"}, values)
  136. return r2 >= 0 && r3 > 0
  137. }
  138. itype := n.TypeStrConvert(in.Type)
  139. if in.Id > 0 {
  140. if CrmMysql.ExecTx("更新人脉", func(tx *sql.Tx) bool {
  141. if in.Company_id != "" {
  142. count := CrmMysql.CountBySql(`select count(1) as count from crm.connection where position_id=? and company_id=? and itype=? and id<>? and status=1`, in.PositionId, in.Company_id, itype, in.Id)
  143. if count == -1 {
  144. return false
  145. } else if count > 0 {
  146. reply.Data = map[string]interface{}{
  147. "status": -1,
  148. }
  149. return false
  150. }
  151. }
  152. r1 := CrmMysql.UpdateOrDeleteBySqlByTx(tx, `update crm.connection set company_name=?,company_id=?,contact_person=?,contact_phone=?,update_time=? where id=? and position_id=?`, in.Company_name, in.Company_id, in.Contact_person, in.Contact_phone, nowFormat, in.Id, in.PositionId)
  153. return r1 >= 0 && saveIntroduce(tx, in.Id, true)
  154. }) {
  155. reply.Data = map[string]interface{}{
  156. "status": 1,
  157. }
  158. }
  159. } else {
  160. if in.Company_id != "" {
  161. count := CrmMysql.CountBySql(`select count(1) as count from crm.connection where position_id=? and company_id=? and itype=? and status=1`, in.PositionId, in.Company_id, itype)
  162. if count == -1 {
  163. return reply
  164. } else if count > 0 {
  165. reply.Data = map[string]interface{}{
  166. "status": -1,
  167. }
  168. return reply
  169. }
  170. }
  171. var r1 int64
  172. if CrmMysql.ExecTx("新增人脉", func(tx *sql.Tx) bool {
  173. _, r1 = CrmMysql.InsertBatchByTx(tx, "crm.connection", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "itype", "company_name", "company_id", "qyxy_id", "contact_person", "contact_phone", "status", "create_time", "update_time"}, []interface{}{in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, itype, in.Company_name, in.Company_id, in.Qyxy_id, in.Contact_person, in.Contact_phone, 1, nowFormat, nowFormat})
  174. return r1 > 0 && saveIntroduce(tx, r1, false)
  175. }) {
  176. reply.Data = map[string]interface{}{
  177. "status": 1,
  178. "id": r1,
  179. }
  180. }
  181. }
  182. return reply
  183. }
  184. //人脉库-业主名称联想
  185. func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
  186. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 middleman_owner:中间人-业主 middleman_project:中间人-项目 agency:招标代理机构
  187. res := []map[string]string{}
  188. reply = &types.Reply{Data: res}
  189. in.Name = strings.TrimSpace(in.Name)
  190. if in.Name == "" {
  191. return
  192. }
  193. pageSize := 10
  194. if in.Type == "adiffb" {
  195. probusfors := NetworkCom.GetMyProbusfor(in.EntAccountId)
  196. if len(probusfors) > 0 {
  197. args := []interface{}{in.EntName}
  198. wh, newArgs := NetworkCom.WhArgs(probusfors)
  199. args = append(args, newArgs...)
  200. q := `select DISTINCT winner_id,winner from information.transaction_info where buyer_id in (select buyer_id from information.transaction_info where has(winner, ?) and buyer_id<>'') and hasAny(property_form,[` + wh + `])=0 ORDER BY project_id`
  201. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  202. if err != nil {
  203. logx.Error(err)
  204. } else {
  205. repeat := map[string]bool{}
  206. ids := []string{}
  207. for rows.Next() {
  208. var (
  209. winner_id []string
  210. winner []string
  211. )
  212. if err := rows.Scan(&winner_id, &winner); err != nil {
  213. logx.Error(err)
  214. continue
  215. }
  216. for k, v := range winner {
  217. if repeat[v] || !strings.Contains(v, in.Name) {
  218. continue
  219. }
  220. repeat[v] = true
  221. if k >= len(winner_id) {
  222. continue
  223. }
  224. ids = append(ids, winner_id[k])
  225. res = append(res, map[string]string{
  226. "company_name": v,
  227. "company_id": winner_id[k],
  228. })
  229. if len(res) == pageSize {
  230. break
  231. }
  232. }
  233. }
  234. rows.Close()
  235. if err := rows.Err(); err != nil {
  236. logx.Error(err)
  237. }
  238. qyxyId := n.GetQyxyId(ids)
  239. for _, v := range res {
  240. v["qyxy_id"] = qyxyId[v["company_id"]]
  241. }
  242. }
  243. }
  244. } else {
  245. must := []string{fmt.Sprintf(`{"multi_match":{"query":"%s","type":"phrase","fields":["company_name"]}}`, in.Name)}
  246. switch in.Type {
  247. case "firstparty":
  248. must = append(must, fmt.Sprintf(`{"terms":{"company_label":["%s"]}}`, strings.Join(NetworkCom.GetEntTagSeat(2), `","`)))
  249. must = append(must, `{"terms":{"company_unit_type":[1,2]}}`)
  250. case "supplier":
  251. must = append(must, fmt.Sprintf(`{"terms":{"company_label":["%s"]}}`, strings.Join(NetworkCom.GetEntTagSeat(2), `","`)))
  252. must = append(must, `{"term":{"company_unit_type":3}}`)
  253. case "middleman_owner":
  254. must = append(must, `{"terms":{"company_unit_type":[1,2]}}`)
  255. case "agency":
  256. must = append(must, `{"term":{"company_unit_type":4}}`)
  257. }
  258. q := fmt.Sprintf(`{"query":{"bool":{"must":[%s]}},"size":%d,"_source":["id","company_id","company_name"]}`, strings.Join(must, ","), pageSize)
  259. logx.Info("人脉库-业主名称联想", q)
  260. datas := VarEs.Get("ent_info", "ent_info", q)
  261. if datas != nil {
  262. for _, v := range *datas {
  263. res = append(res, map[string]string{
  264. "company_name": ObjToString(v["company_name"]),
  265. "company_id": ObjToString(v["id"]),
  266. "qyxy_id": ObjToString(v["company_id"]),
  267. })
  268. }
  269. }
  270. }
  271. reply.Data = res
  272. return
  273. }
  274. //人脉库-全部人脉项目
  275. func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
  276. reply = &types.Reply{}
  277. probusfors := NetworkCom.GetMyProbusfor(in.EntAccountId)
  278. var count int64
  279. var list []*networkTree
  280. firstpartyChild := map[string][]*firstpartyNetwork{}
  281. if in.Id != "" {
  282. if in.Type == "firstparty" {
  283. fpn := n.FirstpartyNetwork(in.Name, []string{in.Id})
  284. if fpn[in.Id] != nil {
  285. firstparty := n.Introduce_Firstparty(fpn, map[string]bool{}, probusfors)
  286. nameIndex := map[string]int{}
  287. for _, v := range fpn[in.Id] {
  288. if _, ok := nameIndex[v.Name]; !ok {
  289. nameIndex[v.Name] = len(list)
  290. list = append(list, &networkTree{
  291. Name: v.Name,
  292. })
  293. }
  294. ntc := &networkTreeChild{
  295. CompanyName: v.CompanyName,
  296. CompanyId: v.CompanyId,
  297. Type: "firstparty",
  298. }
  299. if firstparty[v.CompanyId] != nil {
  300. ntc.Count = firstparty[v.CompanyId].ProjectCount
  301. }
  302. count++
  303. list[nameIndex[v.Name]].Count += ntc.Count
  304. list[nameIndex[v.Name]].Children = append(list[nameIndex[v.Name]].Children, ntc)
  305. }
  306. }
  307. }
  308. } else {
  309. args := []interface{}{in.PositionId, in.PositionId, in.PositionId}
  310. sqlAppend1 := ""
  311. if in.Name != "" {
  312. sqlAppend1 += ` and a.company_name like ?`
  313. args = append(args, "%"+in.Name+"%")
  314. }
  315. aio := n.AllIntroduceOwner(sqlAppend1, "", args, true, probusfors, map[string]bool{})
  316. firstpartyChild = aio.FirstpartyNetwork
  317. list = []*networkTree{
  318. &networkTree{
  319. Name: "甲方",
  320. Children: []*networkTreeChild{},
  321. },
  322. &networkTree{
  323. Name: "供应商",
  324. Children: []*networkTreeChild{},
  325. },
  326. &networkTree{
  327. Name: "同甲异业渠道",
  328. Children: []*networkTreeChild{},
  329. },
  330. &networkTree{
  331. Name: "中间人",
  332. Children: []*networkTreeChild{},
  333. },
  334. &networkTree{
  335. Name: "招标代理",
  336. Children: []*networkTreeChild{},
  337. },
  338. }
  339. //
  340. for _, v := range aio.Networks {
  341. if v.Itype <= 0 || v.Itype > int64(len(list)) {
  342. return
  343. }
  344. ntc := &networkTreeChild{
  345. Id: v.Id,
  346. CompanyName: v.Company_name,
  347. CompanyId: v.Company_id,
  348. Type: n.TypeIntConvert(v.Itype),
  349. CreateTime: v.Create_time,
  350. }
  351. switch v.Itype {
  352. case 1:
  353. if aio.Firstparty[v.Company_id] != nil {
  354. ntc.Count = aio.Firstparty[v.Company_id].ProjectCount
  355. }
  356. case 2:
  357. if aio.Supplier[v.Company_id] != nil {
  358. ntc.Count = aio.Supplier[v.Company_id].ProjectCount
  359. }
  360. case 3:
  361. if aio.Adiffb[v.Company_id] != nil {
  362. ntc.Count = aio.Adiffb[v.Company_id].ProjectCount
  363. }
  364. case 4:
  365. if v.Relate_project_id != "" {
  366. for _, v := range strings.Split(v.Relate_project_id, ",") {
  367. if aio.Middleman[v] != nil {
  368. ntc.Count++
  369. }
  370. }
  371. }
  372. case 5:
  373. if aio.Agency[v.Company_id] != nil {
  374. ntc.Count = aio.Agency[v.Company_id].ProjectCount
  375. }
  376. }
  377. count += ntc.Count
  378. list[v.Itype-1].Count += ntc.Count
  379. list[v.Itype-1].Children = append(list[v.Itype-1].Children, ntc)
  380. }
  381. }
  382. convList := []map[string]interface{}{}
  383. for _, v := range list {
  384. pm := map[string]interface{}{
  385. "CODE": v.Name,
  386. "NAME": v.Name,
  387. "SZ_PID0": v.Name,
  388. "SZ_LEVEL": 0,
  389. "DATACOUNT": 0,
  390. }
  391. if len(v.Children) > 0 {
  392. pm["SZ_LEAF"] = 0
  393. } else {
  394. pm["SZ_LEAF"] = 1
  395. }
  396. sort.Sort(v)
  397. id, pType, pMyType, pMyId := "", "", "", ""
  398. for _, vv := range v.Children {
  399. myId := vv.CompanyId
  400. if vv.Type == "middleman" {
  401. myId = fmt.Sprint(vv.Id)
  402. }
  403. if pMyId != "" {
  404. pMyId += ","
  405. }
  406. pMyId += myId
  407. if pMyType != "" {
  408. pMyType += ","
  409. }
  410. pMyType += vv.Type
  411. myChildIds, myChildTypes := "", ""
  412. if in.Id == "" && v.Name == "甲方" {
  413. for _, vvv := range firstpartyChild[vv.CompanyId] {
  414. if id != "" {
  415. id += ","
  416. }
  417. id += vvv.CompanyId
  418. if pType != "" {
  419. pType += ","
  420. }
  421. pType += vv.Type
  422. if myChildIds != "" {
  423. myChildIds += ","
  424. }
  425. myChildIds += vvv.CompanyId
  426. if myChildTypes != "" {
  427. myChildTypes += ","
  428. }
  429. myChildTypes += vv.Type
  430. }
  431. } else {
  432. if id != "" {
  433. id += ","
  434. }
  435. id += myId
  436. if pType != "" {
  437. pType += ","
  438. }
  439. pType += vv.Type
  440. myChildIds = myId
  441. myChildTypes = vv.Type
  442. }
  443. cm := map[string]interface{}{
  444. "NAME": vv.CompanyName,
  445. "ID": myChildIds,
  446. "SZ_PID0": v.Name,
  447. "SZ_PID1": v.Name + ":" + myId,
  448. "CODE": v.Name + ":" + myId,
  449. "PCODE": v.Name,
  450. "DATACOUNT": vv.Count,
  451. "SZ_LEVEL": 1,
  452. "SZ_LEAF": 1,
  453. "TYPE": myChildTypes,
  454. "MYID": myId,
  455. "MYTYPE": vv.Type,
  456. }
  457. convList = append(convList, cm)
  458. }
  459. pm["ID"] = id
  460. pm["TYPE"] = pType
  461. pm["MYTYPE"] = pMyType
  462. pm["MYID"] = pMyId
  463. convList = append(convList, pm)
  464. }
  465. reply = &types.Reply{
  466. Data: map[string]interface{}{
  467. "count": count,
  468. "list": convList,
  469. },
  470. }
  471. return reply
  472. }
  473. //人脉库-列表
  474. func (n *network) List(in *types.NetWorkListReq) *types.Reply {
  475. if in.Page_size <= 0 {
  476. in.Page_size = 10
  477. }
  478. if in.Current_page <= 0 {
  479. in.Current_page = 1
  480. }
  481. dbPaging := in.Buyercount_start == 0 && in.Buyercount_end == 0 && in.Monitor == 0 && in.Monitorcount_start == 0 && in.Monitorcount_end == 0 && in.Project_matchme == 0 && in.Order_amount == 0
  482. sqlAppendArgs := []interface{}{}
  483. sqlAppend1 := ""
  484. if dbPaging && in.Type != "" {
  485. sqlAppend1 += ` and a.itype=?`
  486. sqlAppendArgs = append(sqlAppendArgs, n.TypeStrConvert(in.Type))
  487. }
  488. comSqlAppend := ""
  489. comSqlArgs := []interface{}{}
  490. if in.Starttime != "" {
  491. comSqlAppend += ` and a.create_time>=?`
  492. comSqlArgs = append(comSqlArgs, in.Starttime+" 00:00:00")
  493. }
  494. if in.Endtime != "" {
  495. comSqlAppend += ` and a.create_time<=?`
  496. if in.Starttime == in.Endtime {
  497. in.Endtime += " 23:59:59"
  498. } else {
  499. in.Endtime += " 00:00:00"
  500. }
  501. comSqlArgs = append(comSqlArgs, in.Endtime)
  502. }
  503. if in.Name != "" {
  504. comSqlAppend += ` and a.company_name like ?`
  505. comSqlArgs = append(comSqlArgs, "%"+in.Name+"%")
  506. }
  507. sqlAppend1 += comSqlAppend
  508. sqlAppendArgs = append(sqlAppendArgs, comSqlArgs...)
  509. var count int64
  510. start := (in.Current_page - 1) * in.Page_size
  511. end := start + in.Page_size
  512. args := []interface{}{in.PositionId, in.PositionId, in.PositionId}
  513. args = append(args, sqlAppendArgs...)
  514. sqlAppend2 := ""
  515. firstparty_count, supplier_count, adiffb_count, middleman_count, agency_count := 0, 0, 0, 0, 0
  516. if dbPaging {
  517. newArgs := []interface{}{in.PositionId}
  518. newArgs = append(newArgs, sqlAppendArgs...)
  519. count = CrmMysql.CountBySql(`select count(1) as count from crm.connection a where a.position_id=?`+sqlAppend1, newArgs...)
  520. sqlAppend2 = ` limit ?,?`
  521. args = append(args, start, end)
  522. itemArgs := []interface{}{in.PositionId}
  523. itemArgs = append(itemArgs, comSqlArgs...)
  524. items := CrmMysql.SelectBySql(`SELECT itype,SUM(1) AS sum FROM crm.connection WHERE position_id=?`+comSqlAppend+` GROUP BY itype`, itemArgs...)
  525. if items != nil {
  526. for _, v := range *items {
  527. switch Int64All(v["itype"]) {
  528. case 1:
  529. firstparty_count = IntAll(v["sum"])
  530. case 2:
  531. supplier_count = IntAll(v["sum"])
  532. case 3:
  533. adiffb_count = IntAll(v["sum"])
  534. case 4:
  535. middleman_count = IntAll(v["sum"])
  536. case 5:
  537. agency_count = IntAll(v["sum"])
  538. }
  539. }
  540. }
  541. }
  542. //
  543. list := []*map[string]interface{}{}
  544. isTjProject := true
  545. probusfors := []string{}
  546. if in.Project_matchme == 1 {
  547. probusfors = NetworkCom.GetMyProbusfor(in.EntAccountId)
  548. if len(probusfors) == 0 {
  549. isTjProject = false
  550. }
  551. }
  552. if isTjProject {
  553. entMonitor := NetworkCom.EntMonitor(in.UserId)
  554. aio := n.AllIntroduceOwner(sqlAppend1, sqlAppend2, args, isTjProject, probusfors, entMonitor)
  555. for _, v := range aio.Networks {
  556. itype := ""
  557. buyer_count, project_count, expect_amount, monitor_count := int64(0), int64(0), float64(0), int64(0)
  558. export_id := []string{}
  559. jump_type, jump_id := "", ""
  560. switch v.Itype {
  561. case 1:
  562. itype = "甲方"
  563. jump_type = "firstparty"
  564. for _, vv := range aio.FirstpartyNetwork[v.Company_id] {
  565. if jump_id != "" {
  566. jump_id += ","
  567. }
  568. jump_id += vv.CompanyId
  569. }
  570. if aio.Firstparty[v.Company_id] != nil {
  571. buyer_count = aio.Firstparty[v.Company_id].BuyerCount
  572. project_count = aio.Firstparty[v.Company_id].ProjectCount
  573. expect_amount = aio.Firstparty[v.Company_id].ProjectAmount
  574. monitor_count = aio.Firstparty[v.Company_id].MonitorCount
  575. export_id = aio.Firstparty[v.Company_id].ExportId
  576. }
  577. case 2:
  578. itype = "供应商"
  579. jump_type = "supplier"
  580. jump_id = v.Company_id
  581. if aio.Supplier[v.Company_id] != nil {
  582. buyer_count = aio.Supplier[v.Company_id].BuyerCount
  583. project_count = aio.Supplier[v.Company_id].ProjectCount
  584. expect_amount = aio.Supplier[v.Company_id].ProjectAmount
  585. monitor_count = aio.Supplier[v.Company_id].MonitorCount
  586. export_id = aio.Supplier[v.Company_id].ExportId
  587. }
  588. case 3:
  589. itype = "同甲异业渠道"
  590. jump_type = "adiffb"
  591. jump_id = v.Company_id
  592. if aio.Adiffb[v.Company_id] != nil {
  593. buyer_count = aio.Adiffb[v.Company_id].BuyerCount
  594. project_count = aio.Adiffb[v.Company_id].ProjectCount
  595. expect_amount = aio.Adiffb[v.Company_id].ProjectAmount
  596. monitor_count = aio.Adiffb[v.Company_id].MonitorCount
  597. export_id = aio.Adiffb[v.Company_id].ExportId
  598. }
  599. case 4:
  600. itype = "中间人"
  601. jump_type = "middleman"
  602. jump_id = fmt.Sprint(v.Id)
  603. buyer_count = v.Buyer_count
  604. if v.Relate_buyer_id != "" {
  605. for _, v := range strings.Split(v.Relate_buyer_id, ",") {
  606. if v == "" {
  607. continue
  608. }
  609. if entMonitor[v] {
  610. monitor_count++
  611. }
  612. }
  613. }
  614. if v.Relate_project_id != "" {
  615. export_id = strings.Split(v.Relate_project_id, ",")
  616. for _, v := range export_id {
  617. if aio.Middleman[v] != nil {
  618. project_count++
  619. expect_amount += aio.Middleman[v].ProjectAmount
  620. }
  621. }
  622. }
  623. case 5:
  624. itype = "招标代理机构"
  625. jump_type = "agency"
  626. jump_id = v.Company_id
  627. if aio.Agency[v.Company_id] != nil {
  628. buyer_count = aio.Agency[v.Company_id].BuyerCount
  629. project_count = aio.Agency[v.Company_id].ProjectCount
  630. expect_amount = aio.Agency[v.Company_id].ProjectAmount
  631. monitor_count = aio.Agency[v.Company_id].MonitorCount
  632. export_id = aio.Agency[v.Company_id].ExportId
  633. }
  634. }
  635. if buyer_count < in.Buyercount_start {
  636. continue
  637. } else if in.Buyercount_end > 0 && buyer_count > in.Buyercount_end {
  638. continue
  639. } else if in.Monitor == 1 && monitor_count <= 0 {
  640. continue
  641. } else if in.Monitor == -1 && monitor_count > 0 {
  642. continue
  643. } else if monitor_count < in.Monitorcount_start {
  644. continue
  645. } else if in.Monitorcount_end > 0 && monitor_count > in.Monitorcount_end {
  646. continue
  647. } else if in.Project_matchme == 1 && project_count == 0 {
  648. continue
  649. }
  650. if !dbPaging {
  651. switch v.Itype {
  652. case 1:
  653. firstparty_count++
  654. case 2:
  655. supplier_count++
  656. case 3:
  657. adiffb_count++
  658. case 4:
  659. middleman_count++
  660. case 5:
  661. agency_count++
  662. }
  663. if in.Type != "" && n.TypeStrConvert(in.Type) != v.Itype {
  664. continue
  665. }
  666. }
  667. export_url := ""
  668. if len(export_id) > 0 {
  669. exportIdRepeat := map[string]bool{}
  670. exportId := ""
  671. for _, v := range export_id {
  672. if exportIdRepeat[v] {
  673. continue
  674. }
  675. exportIdRepeat[v] = true
  676. if exportId != "" {
  677. exportId += ","
  678. }
  679. exportId += v
  680. }
  681. export_url = "/subscribepay/network/projectExport?export_id=" + encrypt.SE.EncodeStringByCheck(exportId)
  682. }
  683. url := ""
  684. if v.Qyxy_id != "" && (jump_type == "supplier" || jump_type == "adiffb") {
  685. url = "/swordfish/page_big_pc/ent_portrait/" + encrypt.EncodeArticleId2ByCheck(v.Qyxy_id)
  686. } else if jump_type == "firstparty" && v.Company_name != "" {
  687. url = "/swordfish/page_big_pc/unit_portrayal/" + v.Company_name
  688. }
  689. list = append(list, &map[string]interface{}{
  690. "company_id": v.Company_id,
  691. "company_name": v.Company_name,
  692. "type": itype,
  693. "jump_type": jump_type,
  694. "jump_id": jump_id,
  695. "person": v.Person,
  696. "phone": v.Phone,
  697. "buyer_count": buyer_count,
  698. "monitor_count": monitor_count,
  699. "expect_amount": RetainDecimal(expect_amount/10000, 2),
  700. "project_count": project_count,
  701. "create_time": v.Create_time,
  702. "export_url": export_url,
  703. "url": url,
  704. "id": v.Id,
  705. })
  706. }
  707. }
  708. csList := &ComSortList{
  709. SortKeys: []*ComSortKey{
  710. &ComSortKey{
  711. Keys: []string{"expect_amount"},
  712. Order: 1,
  713. Type: "float",
  714. },
  715. },
  716. List: list,
  717. }
  718. if in.Order_amount == -1 {
  719. csList.SortKeys[0].Order = -1
  720. }
  721. if in.Order_amount != 0 {
  722. sort.Sort(csList)
  723. }
  724. finalList := []*map[string]interface{}{}
  725. if !dbPaging {
  726. count = int64(len(csList.List))
  727. if count > 0 && start < count {
  728. if end > count {
  729. end = count
  730. }
  731. finalList = csList.List[start:end]
  732. }
  733. } else {
  734. finalList = csList.List
  735. }
  736. total_page := int64(math.Ceil(float64(count) / float64(in.Page_size)))
  737. return &types.Reply{
  738. Data: map[string]interface{}{
  739. "count": count,
  740. "total_page": total_page,
  741. "firstparty_count": firstparty_count,
  742. "supplier_count": supplier_count,
  743. "adiffb_count": adiffb_count,
  744. "middleman_count": middleman_count,
  745. "agency_count": agency_count,
  746. "list": finalList,
  747. },
  748. }
  749. }
  750. //
  751. func (n *network) FirstpartyNetwork(name string, values []string) map[string][]*firstpartyNetwork {
  752. result := map[string][]*firstpartyNetwork{}
  753. wh, args := NetworkCom.WhArgs(values)
  754. q := `select DISTINCT a.a_id,a.b_id as company_id,a.b_name as company_name,b.name from information.ent_map_code a
  755. inner join information.ent_code b on (a.a_id in (` + wh + `) and b.pcode in ('0100','0200') and a.code=b.code)`
  756. if name != "" {
  757. q += ` where c.company_name like ?`
  758. args = append(args, "%"+name+"%")
  759. }
  760. q += ` order by b.name,a.a_id,a.b_name`
  761. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  762. if err != nil {
  763. logx.Error(err)
  764. return result
  765. }
  766. for rows.Next() {
  767. var (
  768. a_id string
  769. company_id string
  770. company_name string
  771. name string
  772. )
  773. if err := rows.Scan(&a_id, &company_id, &company_name, &name); err != nil {
  774. logx.Error(err)
  775. continue
  776. }
  777. if company_id == "" || company_name == "" {
  778. continue
  779. }
  780. result[a_id] = append(result[a_id], &firstpartyNetwork{
  781. CompanyId: company_id,
  782. CompanyName: company_name,
  783. Name: name,
  784. })
  785. }
  786. return result
  787. }
  788. //
  789. func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
  790. values := []string{}
  791. vm := map[string]*projectInfo{}
  792. for _, v := range fpn {
  793. for _, vv := range v {
  794. vm[vv.CompanyId] = &projectInfo{}
  795. values = append(values, vv.CompanyId)
  796. }
  797. }
  798. result := map[string]*projectInfo{}
  799. if len(values) == 0 {
  800. return result
  801. }
  802. wh, args := NetworkCom.WhArgs(values)
  803. q := `select buyer_id,count(project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info where buyer_id in (` + wh + `)`
  804. if len(probusfors) > 0 {
  805. newWh, newArgs := NetworkCom.WhArgs(probusfors)
  806. q += ` and hasAny(property_form,[` + newWh + `])`
  807. args = append(args, newArgs...)
  808. }
  809. q += ` group by buyer_id`
  810. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  811. if err != nil {
  812. logx.Error(err)
  813. return nil
  814. }
  815. for rows.Next() {
  816. var (
  817. buyer_id string
  818. project_count uint64
  819. project_amount decimal.Decimal
  820. project_id []string
  821. )
  822. if err := rows.Scan(&buyer_id, &project_count, &project_amount, &project_id); err != nil {
  823. logx.Error(err)
  824. continue
  825. }
  826. if vm[buyer_id] == nil {
  827. continue
  828. }
  829. vm[buyer_id].ProjectCount += int64(project_count)
  830. pf, _ := project_amount.Float64()
  831. vm[buyer_id].ProjectAmount += pf
  832. vm[buyer_id].ExportId = project_id
  833. }
  834. rows.Close()
  835. if err := rows.Err(); err != nil {
  836. logx.Error(err)
  837. }
  838. for k, v := range fpn {
  839. if result[k] == nil {
  840. result[k] = &projectInfo{}
  841. }
  842. result[k].BuyerCount = int64(len(v))
  843. for _, vv := range v {
  844. if entMonitor[vv.CompanyName] {
  845. result[k].MonitorCount++
  846. }
  847. if vm[vv.CompanyId] == nil {
  848. continue
  849. }
  850. result[k].ProjectCount += vm[vv.CompanyId].ProjectCount
  851. result[k].ProjectAmount += vm[vv.CompanyId].ProjectAmount
  852. result[k].ExportId = append(result[k].ExportId, vm[vv.CompanyId].ExportId...)
  853. }
  854. }
  855. return result
  856. }
  857. //
  858. func (n *network) Introduce_Supplier(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
  859. if len(values) == 0 {
  860. return map[string]*projectInfo{}
  861. }
  862. wh, args := NetworkCom.WhArgs(values)
  863. vbs := map[string][]*idName{}
  864. repeat := map[string]bool{}
  865. whRepeat := map[string]map[string]bool{}
  866. buyers := []string{}
  867. q := `select winner_id,buyer_id,buyer from information.transaction_info where hasAny(winner_id,[` + wh + `])`
  868. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  869. if err != nil {
  870. logx.Error(err)
  871. } else {
  872. for rows.Next() {
  873. var (
  874. winner_id []string
  875. buyer_id string
  876. buyer string
  877. )
  878. if err := rows.Scan(&winner_id, &buyer_id, &buyer); err != nil {
  879. logx.Error(err)
  880. continue
  881. }
  882. if buyer_id == "" || buyer == "" {
  883. continue
  884. }
  885. if !repeat[buyer_id] {
  886. repeat[buyer_id] = true
  887. buyers = append(buyers, buyer_id)
  888. }
  889. for _, v := range winner_id {
  890. if whRepeat[v] != nil && whRepeat[v][buyer_id] {
  891. continue
  892. }
  893. if whRepeat[v] == nil {
  894. whRepeat[v] = map[string]bool{}
  895. }
  896. whRepeat[v][buyer_id] = true
  897. vbs[v] = append(vbs[v], &idName{
  898. Id: buyer_id,
  899. Name: buyer,
  900. })
  901. }
  902. }
  903. rows.Close()
  904. if err := rows.Err(); err != nil {
  905. logx.Error(err)
  906. }
  907. }
  908. return n.MakeProjectInfo(buyers, vbs, probusfors, entMonitor)
  909. }
  910. //
  911. func (n *network) Introduce_Agency(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
  912. if len(values) == 0 {
  913. return map[string]*projectInfo{}
  914. }
  915. wh, args := NetworkCom.WhArgs(values)
  916. q := `select DISTINCT agency_id,buyer_id,buyer from information.transaction_info where agency_id in (` + wh + `)`
  917. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  918. if err != nil {
  919. logx.Error(err)
  920. return nil
  921. }
  922. vbs := map[string][]*idName{}
  923. buyers := []string{}
  924. repeat := map[string]bool{}
  925. for rows.Next() {
  926. var (
  927. agency_id string
  928. buyer_id string
  929. buyer string
  930. )
  931. if err := rows.Scan(&agency_id, &buyer_id, &buyer); err != nil {
  932. logx.Error(err)
  933. continue
  934. }
  935. if buyer_id == "" || buyer == "" {
  936. continue
  937. }
  938. vbs[agency_id] = append(vbs[agency_id], &idName{
  939. Id: buyer_id,
  940. Name: buyer,
  941. })
  942. if !repeat[buyer_id] {
  943. repeat[buyer_id] = true
  944. buyers = append(buyers, buyer_id)
  945. }
  946. }
  947. rows.Close()
  948. if err := rows.Err(); err != nil {
  949. logx.Error(err)
  950. }
  951. return n.MakeProjectInfo(buyers, vbs, probusfors, entMonitor)
  952. }
  953. //
  954. func (n *network) Introduce_Middleman(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
  955. result := map[string]*projectInfo{}
  956. if len(values) == 0 {
  957. return result
  958. }
  959. wh, args := NetworkCom.WhArgs(values)
  960. q := `select DISTINCT project_id,project_money from information.transaction_info where project_id in (` + wh + `)`
  961. if len(probusfors) > 0 {
  962. newWh, newArgs := NetworkCom.WhArgs(probusfors)
  963. q += ` and hasAny(property_form,[` + newWh + `])`
  964. args = append(args, newArgs...)
  965. }
  966. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  967. if err != nil {
  968. logx.Error(err)
  969. return nil
  970. }
  971. for rows.Next() {
  972. var (
  973. project_id string
  974. project_money decimal.Decimal
  975. )
  976. if err := rows.Scan(&project_id, &project_money); err != nil {
  977. logx.Error(err)
  978. continue
  979. }
  980. pf, _ := project_money.Float64()
  981. result[project_id] = &projectInfo{
  982. ProjectAmount: pf,
  983. }
  984. }
  985. rows.Close()
  986. if err := rows.Err(); err != nil {
  987. logx.Error(err)
  988. }
  989. return result
  990. }
  991. //
  992. func (n *network) TypeStrConvert(itype string) int64 {
  993. //firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  994. switch itype {
  995. case "firstparty":
  996. return 1
  997. case "supplier":
  998. return 2
  999. case "adiffb":
  1000. return 3
  1001. case "middleman":
  1002. return 4
  1003. case "agency":
  1004. return 5
  1005. }
  1006. return 0
  1007. }
  1008. //
  1009. func (n *network) TypeIntConvert(itype int64) string {
  1010. //firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  1011. switch itype {
  1012. case 1:
  1013. return "firstparty"
  1014. case 2:
  1015. return "supplier"
  1016. case 3:
  1017. return "adiffb"
  1018. case 4:
  1019. return "middleman"
  1020. case 5:
  1021. return "agency"
  1022. }
  1023. return ""
  1024. }
  1025. //
  1026. func (n *network) GetQyxyId(ids []string) map[string]string {
  1027. wh, args := NetworkCom.WhArgs(ids)
  1028. q := `select id,company_id from information.ent_info where id in (` + wh + `)`
  1029. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  1030. m := map[string]string{}
  1031. if err != nil {
  1032. logx.Error(err)
  1033. } else {
  1034. for rows.Next() {
  1035. var (
  1036. id string
  1037. company_id string
  1038. )
  1039. if err := rows.Scan(&id, &company_id); err != nil {
  1040. logx.Error(err)
  1041. continue
  1042. }
  1043. m[id] = company_id
  1044. }
  1045. rows.Close()
  1046. if err := rows.Err(); err != nil {
  1047. logx.Error(err)
  1048. }
  1049. }
  1050. return m
  1051. }
  1052. //
  1053. func (n *network) BuyerProjectInfo(ids []string, probusfors []string) map[string]*projectInfo {
  1054. vm := map[string]*projectInfo{}
  1055. wh, args := NetworkCom.WhArgs(ids)
  1056. q := `select buyer_id,count(DISTINCT project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info where buyer_id in (` + wh + `)`
  1057. if len(probusfors) > 0 {
  1058. newWh, newArgs := NetworkCom.WhArgs(probusfors)
  1059. q += ` and hasAny(property_form,[` + newWh + `])`
  1060. args = append(args, newArgs...)
  1061. }
  1062. q += ` group by buyer_id`
  1063. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  1064. if err != nil {
  1065. logx.Error(err)
  1066. return nil
  1067. }
  1068. for rows.Next() {
  1069. var (
  1070. buyer_id string
  1071. project_count uint64
  1072. project_amount decimal.Decimal
  1073. project_id []string
  1074. )
  1075. if err := rows.Scan(&buyer_id, &project_count, &project_amount, &project_id); err != nil {
  1076. logx.Error(err)
  1077. continue
  1078. }
  1079. pf, _ := project_amount.Float64()
  1080. vm[buyer_id] = &projectInfo{
  1081. ProjectCount: int64(project_count),
  1082. ExportId: project_id,
  1083. ProjectAmount: pf,
  1084. }
  1085. }
  1086. rows.Close()
  1087. if err := rows.Err(); err != nil {
  1088. logx.Error(err)
  1089. }
  1090. return vm
  1091. }
  1092. //
  1093. func (n *network) MakeProjectInfo(buyers []string, vbs map[string][]*idName, probusfors []string, entMonitor map[string]bool) map[string]*projectInfo {
  1094. pis := n.BuyerProjectInfo(buyers, probusfors)
  1095. vm := map[string]*projectInfo{}
  1096. for k, v := range vbs {
  1097. pi := &projectInfo{
  1098. BuyerCount: int64(len(v)),
  1099. }
  1100. re := map[string]bool{}
  1101. for _, vv := range v {
  1102. if pis[vv.Id] != nil {
  1103. pi.ProjectCount += pis[vv.Id].ProjectCount
  1104. pi.ProjectAmount += pis[vv.Id].ProjectAmount
  1105. for _, vvv := range pis[vv.Id].ExportId {
  1106. if re[vvv] {
  1107. continue
  1108. }
  1109. pi.ExportId = append(pi.ExportId, vvv)
  1110. re[vvv] = true
  1111. }
  1112. }
  1113. if entMonitor[vv.Name] {
  1114. pi.MonitorCount++
  1115. }
  1116. }
  1117. vm[k] = pi
  1118. }
  1119. return vm
  1120. }
  1121. //
  1122. func (n *network) AllIntroduceOwner(sqlAppend1, sqlAppend2 string, args []interface{}, isTjProject bool, probusfors []string, entMonitor map[string]bool) *introduceOwnerProject {
  1123. q := `select a.id,a.company_id,a.company_name,a.qyxy_id,a.itype,a.contact_person as person,a.contact_phone as phone,count(DISTINCT if(b.itype=1,b.relate_id,null)) as buyer_count,count(DISTINCT if(b.itype=2,b.relate_id,null)) as project_count,GROUP_CONCAT(IF(b.itype=1,b.relate_id,NULL)) AS relate_buyer_id,GROUP_CONCAT(IF(b.itype=2,b.relate_id,NULL)) AS relate_project_id,a.create_time from crm.connection a
  1124. left join crm.connection_introduce b on (a.position_id=? and b.position_id=? and a.id=b.connection_id) where a.position_id=?` + sqlAppend1 + ` GROUP BY a.id order by a.create_time desc` + sqlAppend2
  1125. listTemp := CrmMysql.SelectBySql(q, args...)
  1126. firstparty_array, supplier_array, adiffb_array, agency_array, middleman_project_array := []string{}, []string{}, []string{}, []string{}, []string{}
  1127. myNetworks := []*myNetwork{}
  1128. for _, v := range *listTemp {
  1129. myNetwork := &myNetwork{
  1130. Id: Int64All(v["id"]),
  1131. Company_id: ObjToString(v["company_id"]),
  1132. Company_name: ObjToString(v["company_name"]),
  1133. Qyxy_id: ObjToString(v["qyxy_id"]),
  1134. Itype: Int64All(v["itype"]),
  1135. Person: ObjToString(v["person"]),
  1136. Phone: ObjToString(v["phone"]),
  1137. Buyer_count: Int64All(v["buyer_count"]),
  1138. Project_count: Int64All(v["project_count"]),
  1139. Relate_buyer_id: ObjToString(v["relate_buyer_id"]),
  1140. Relate_project_id: ObjToString(v["relate_project_id"]),
  1141. Create_time: ObjToString(v["create_time"]),
  1142. }
  1143. switch myNetwork.Itype {
  1144. case 1:
  1145. firstparty_array = append(firstparty_array, myNetwork.Company_id)
  1146. case 2:
  1147. supplier_array = append(supplier_array, myNetwork.Company_id)
  1148. case 3:
  1149. adiffb_array = append(adiffb_array, myNetwork.Company_id)
  1150. case 4:
  1151. if myNetwork.Relate_project_id != "" {
  1152. middleman_project_array = append(middleman_project_array, strings.Split(myNetwork.Relate_project_id, ",")...)
  1153. }
  1154. case 5:
  1155. agency_array = append(agency_array, myNetwork.Company_id)
  1156. }
  1157. myNetworks = append(myNetworks, myNetwork)
  1158. }
  1159. iop := &introduceOwnerProject{
  1160. Networks: myNetworks,
  1161. FirstpartyNetwork: map[string][]*firstpartyNetwork{},
  1162. Firstparty: map[string]*projectInfo{},
  1163. Supplier: map[string]*projectInfo{},
  1164. Adiffb: map[string]*projectInfo{},
  1165. Agency: map[string]*projectInfo{},
  1166. Middleman: map[string]*projectInfo{},
  1167. }
  1168. if isTjProject {
  1169. iop.FirstpartyNetwork = n.FirstpartyNetwork("", firstparty_array)
  1170. iop.Firstparty = n.Introduce_Firstparty(iop.FirstpartyNetwork, entMonitor, probusfors)
  1171. iop.Supplier = n.Introduce_Supplier(supplier_array, entMonitor, probusfors)
  1172. iop.Adiffb = n.Introduce_Supplier(adiffb_array, entMonitor, probusfors)
  1173. iop.Agency = n.Introduce_Agency(agency_array, entMonitor, probusfors)
  1174. iop.Middleman = n.Introduce_Middleman(middleman_project_array, entMonitor, probusfors)
  1175. }
  1176. return iop
  1177. }