network.go 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  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 := ""
  398. pType := ""
  399. for _, vv := range v.Children {
  400. tempId := vv.CompanyId
  401. if vv.Type == "middleman" {
  402. tempId = fmt.Sprint(vv.Id)
  403. }
  404. myChildIds, myChildTypes := "", ""
  405. if in.Id == "" && v.Name == "甲方" {
  406. for _, vvv := range firstpartyChild[vv.CompanyId] {
  407. if id != "" {
  408. id += ","
  409. }
  410. id += vvv.CompanyId
  411. if pType != "" {
  412. pType += ","
  413. }
  414. pType += vv.Type
  415. if myChildIds != "" {
  416. myChildIds += ","
  417. }
  418. myChildIds += vvv.CompanyId
  419. if myChildTypes != "" {
  420. myChildTypes += ","
  421. }
  422. myChildTypes += vv.Type
  423. }
  424. } else {
  425. if id != "" {
  426. id += ","
  427. }
  428. id += tempId
  429. if pType != "" {
  430. pType += ","
  431. }
  432. pType += vv.Type
  433. myChildIds = tempId
  434. myChildTypes = vv.Type
  435. }
  436. cm := map[string]interface{}{
  437. "NAME": vv.CompanyName,
  438. "ID": myChildIds,
  439. "SZ_PID0": v.Name,
  440. "SZ_PID1": v.Name + ":" + tempId,
  441. "CODE": v.Name + ":" + tempId,
  442. "PCODE": v.Name,
  443. "DATACOUNT": vv.Count,
  444. "SZ_LEVEL": 1,
  445. "SZ_LEAF": 1,
  446. "TYPE": myChildTypes,
  447. "MYID": tempId,
  448. }
  449. convList = append(convList, cm)
  450. }
  451. pm["ID"] = id
  452. pm["TYPE"] = pType
  453. convList = append(convList, pm)
  454. }
  455. reply = &types.Reply{
  456. Data: map[string]interface{}{
  457. "count": count,
  458. "list": convList,
  459. },
  460. }
  461. return reply
  462. }
  463. //人脉库-列表
  464. func (n *network) List(in *types.NetWorkListReq) *types.Reply {
  465. if in.Page_size <= 0 {
  466. in.Page_size = 10
  467. }
  468. if in.Current_page <= 0 {
  469. in.Current_page = 1
  470. }
  471. 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
  472. sqlAppendArgs := []interface{}{}
  473. sqlAppend1 := ""
  474. if dbPaging && in.Type != "" {
  475. sqlAppend1 += ` and a.itype=?`
  476. sqlAppendArgs = append(sqlAppendArgs, n.TypeStrConvert(in.Type))
  477. }
  478. comSqlAppend := ""
  479. comSqlArgs := []interface{}{}
  480. if in.Starttime != "" {
  481. comSqlAppend += ` and a.create_time>=?`
  482. comSqlArgs = append(comSqlArgs, in.Starttime+" 00:00:00")
  483. }
  484. if in.Endtime != "" {
  485. comSqlAppend += ` and a.create_time<=?`
  486. if in.Starttime == in.Endtime {
  487. in.Endtime += " 23:59:59"
  488. } else {
  489. in.Endtime += " 00:00:00"
  490. }
  491. comSqlArgs = append(comSqlArgs, in.Endtime)
  492. }
  493. if in.Name != "" {
  494. comSqlAppend += ` and a.company_name like ?`
  495. comSqlArgs = append(comSqlArgs, "%"+in.Name+"%")
  496. }
  497. sqlAppend1 += comSqlAppend
  498. sqlAppendArgs = append(sqlAppendArgs, comSqlArgs...)
  499. var count int64
  500. start := (in.Current_page - 1) * in.Page_size
  501. end := start + in.Page_size
  502. args := []interface{}{in.PositionId, in.PositionId, in.PositionId}
  503. args = append(args, sqlAppendArgs...)
  504. sqlAppend2 := ""
  505. firstparty_count, supplier_count, adiffb_count, middleman_count, agency_count := 0, 0, 0, 0, 0
  506. if dbPaging {
  507. newArgs := []interface{}{in.PositionId}
  508. newArgs = append(newArgs, sqlAppendArgs...)
  509. count = CrmMysql.CountBySql(`select count(1) as count from crm.connection a where a.position_id=?`+sqlAppend1, newArgs...)
  510. sqlAppend2 = ` limit ?,?`
  511. args = append(args, start, end)
  512. itemArgs := []interface{}{in.PositionId}
  513. itemArgs = append(itemArgs, comSqlArgs...)
  514. items := CrmMysql.SelectBySql(`SELECT itype,SUM(1) AS sum FROM crm.connection WHERE position_id=?`+comSqlAppend+` GROUP BY itype`, itemArgs...)
  515. if items != nil {
  516. for _, v := range *items {
  517. switch Int64All(v["itype"]) {
  518. case 1:
  519. firstparty_count = IntAll(v["sum"])
  520. case 2:
  521. supplier_count = IntAll(v["sum"])
  522. case 3:
  523. adiffb_count = IntAll(v["sum"])
  524. case 4:
  525. middleman_count = IntAll(v["sum"])
  526. case 5:
  527. agency_count = IntAll(v["sum"])
  528. }
  529. }
  530. }
  531. }
  532. //
  533. list := []*map[string]interface{}{}
  534. isTjProject := true
  535. probusfors := []string{}
  536. if in.Project_matchme == 1 {
  537. probusfors = NetworkCom.GetMyProbusfor(in.EntAccountId)
  538. if len(probusfors) == 0 {
  539. isTjProject = false
  540. }
  541. }
  542. if isTjProject {
  543. entMonitor := NetworkCom.EntMonitor(in.UserId)
  544. aio := n.AllIntroduceOwner(sqlAppend1, sqlAppend2, args, isTjProject, probusfors, entMonitor)
  545. for _, v := range aio.Networks {
  546. itype := ""
  547. buyer_count, project_count, expect_amount, monitor_count := int64(0), int64(0), float64(0), int64(0)
  548. export_id := []string{}
  549. jump_type, jump_id := "", ""
  550. switch v.Itype {
  551. case 1:
  552. itype = "甲方"
  553. jump_type = "firstparty"
  554. for _, vv := range aio.FirstpartyNetwork[v.Company_id] {
  555. if jump_id != "" {
  556. jump_id += ","
  557. }
  558. jump_id += vv.CompanyId
  559. }
  560. if aio.Firstparty[v.Company_id] != nil {
  561. buyer_count = aio.Firstparty[v.Company_id].BuyerCount
  562. project_count = aio.Firstparty[v.Company_id].ProjectCount
  563. expect_amount = aio.Firstparty[v.Company_id].ProjectAmount
  564. monitor_count = aio.Firstparty[v.Company_id].MonitorCount
  565. export_id = aio.Firstparty[v.Company_id].ExportId
  566. }
  567. case 2:
  568. itype = "供应商"
  569. jump_type = "supplier"
  570. jump_id = v.Company_id
  571. if aio.Supplier[v.Company_id] != nil {
  572. buyer_count = aio.Supplier[v.Company_id].BuyerCount
  573. project_count = aio.Supplier[v.Company_id].ProjectCount
  574. expect_amount = aio.Supplier[v.Company_id].ProjectAmount
  575. monitor_count = aio.Supplier[v.Company_id].MonitorCount
  576. export_id = aio.Supplier[v.Company_id].ExportId
  577. }
  578. case 3:
  579. itype = "同甲异业渠道"
  580. jump_type = "adiffb"
  581. jump_id = v.Company_id
  582. if aio.Adiffb[v.Company_id] != nil {
  583. buyer_count = aio.Adiffb[v.Company_id].BuyerCount
  584. project_count = aio.Adiffb[v.Company_id].ProjectCount
  585. expect_amount = aio.Adiffb[v.Company_id].ProjectAmount
  586. monitor_count = aio.Adiffb[v.Company_id].MonitorCount
  587. export_id = aio.Adiffb[v.Company_id].ExportId
  588. }
  589. case 4:
  590. itype = "中间人"
  591. jump_type = "middleman"
  592. jump_id = fmt.Sprint(v.Id)
  593. buyer_count = v.Buyer_count
  594. if v.Relate_buyer_id != "" {
  595. for _, v := range strings.Split(v.Relate_buyer_id, ",") {
  596. if v == "" {
  597. continue
  598. }
  599. if entMonitor[v] {
  600. monitor_count++
  601. }
  602. }
  603. }
  604. if v.Relate_project_id != "" {
  605. export_id = strings.Split(v.Relate_project_id, ",")
  606. for _, v := range export_id {
  607. if aio.Middleman[v] != nil {
  608. project_count++
  609. expect_amount += aio.Middleman[v].ProjectAmount
  610. }
  611. }
  612. }
  613. case 5:
  614. itype = "招标代理机构"
  615. jump_type = "agency"
  616. jump_id = v.Company_id
  617. if aio.Agency[v.Company_id] != nil {
  618. buyer_count = aio.Agency[v.Company_id].BuyerCount
  619. project_count = aio.Agency[v.Company_id].ProjectCount
  620. expect_amount = aio.Agency[v.Company_id].ProjectAmount
  621. monitor_count = aio.Agency[v.Company_id].MonitorCount
  622. export_id = aio.Agency[v.Company_id].ExportId
  623. }
  624. }
  625. if buyer_count < in.Buyercount_start {
  626. continue
  627. } else if in.Buyercount_end > 0 && buyer_count > in.Buyercount_end {
  628. continue
  629. } else if in.Monitor == 1 && monitor_count <= 0 {
  630. continue
  631. } else if in.Monitor == -1 && monitor_count > 0 {
  632. continue
  633. } else if monitor_count < in.Monitorcount_start {
  634. continue
  635. } else if in.Monitorcount_end > 0 && monitor_count > in.Monitorcount_end {
  636. continue
  637. } else if in.Project_matchme == 1 && project_count == 0 {
  638. continue
  639. }
  640. if !dbPaging {
  641. switch v.Itype {
  642. case 1:
  643. firstparty_count++
  644. case 2:
  645. supplier_count++
  646. case 3:
  647. adiffb_count++
  648. case 4:
  649. middleman_count++
  650. case 5:
  651. agency_count++
  652. }
  653. if in.Type != "" && n.TypeStrConvert(in.Type) != v.Itype {
  654. continue
  655. }
  656. }
  657. export_url := ""
  658. if len(export_id) > 0 {
  659. exportIdRepeat := map[string]bool{}
  660. exportId := ""
  661. for _, v := range export_id {
  662. if exportIdRepeat[v] {
  663. continue
  664. }
  665. exportIdRepeat[v] = true
  666. if exportId != "" {
  667. exportId += ","
  668. }
  669. exportId += v
  670. }
  671. export_url = "/subscribepay/network/projectExport?export_id=" + encrypt.SE.EncodeStringByCheck(exportId)
  672. }
  673. url := ""
  674. if v.Qyxy_id != "" && (jump_type == "supplier" || jump_type == "adiffb") {
  675. url = "/swordfish/page_big_pc/ent_portrait/" + encrypt.EncodeArticleId2ByCheck(v.Qyxy_id)
  676. } else if jump_type == "firstparty" && v.Company_name != "" {
  677. url = "/swordfish/page_big_pc/unit_portrayal/" + v.Company_name
  678. }
  679. list = append(list, &map[string]interface{}{
  680. "company_id": v.Company_id,
  681. "company_name": v.Company_name,
  682. "type": itype,
  683. "jump_type": jump_type,
  684. "jump_id": jump_id,
  685. "person": v.Person,
  686. "phone": v.Phone,
  687. "buyer_count": buyer_count,
  688. "monitor_count": monitor_count,
  689. "expect_amount": RetainDecimal(expect_amount/10000, 2),
  690. "project_count": project_count,
  691. "create_time": v.Create_time,
  692. "export_url": export_url,
  693. "url": url,
  694. "id": v.Id,
  695. })
  696. }
  697. }
  698. csList := &ComSortList{
  699. SortKeys: []*ComSortKey{
  700. &ComSortKey{
  701. Keys: []string{"expect_amount"},
  702. Order: 1,
  703. Type: "float",
  704. },
  705. },
  706. List: list,
  707. }
  708. if in.Order_amount == -1 {
  709. csList.SortKeys[0].Order = -1
  710. }
  711. if in.Order_amount != 0 {
  712. sort.Sort(csList)
  713. }
  714. finalList := []*map[string]interface{}{}
  715. if !dbPaging {
  716. count = int64(len(csList.List))
  717. if count > 0 && start < count {
  718. if end > count {
  719. end = count
  720. }
  721. finalList = csList.List[start:end]
  722. }
  723. } else {
  724. finalList = csList.List
  725. }
  726. total_page := int64(math.Ceil(float64(count) / float64(in.Page_size)))
  727. return &types.Reply{
  728. Data: map[string]interface{}{
  729. "count": count,
  730. "total_page": total_page,
  731. "firstparty_count": firstparty_count,
  732. "supplier_count": supplier_count,
  733. "adiffb_count": adiffb_count,
  734. "middleman_count": middleman_count,
  735. "agency_count": agency_count,
  736. "list": finalList,
  737. },
  738. }
  739. }
  740. //
  741. func (n *network) FirstpartyNetwork(name string, values []string) map[string][]*firstpartyNetwork {
  742. result := map[string][]*firstpartyNetwork{}
  743. wh, args := NetworkCom.WhArgs(values)
  744. 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
  745. inner join information.ent_code b on (a.a_id in (` + wh + `) and b.pcode in ('0100','0200') and a.code=b.code)`
  746. if name != "" {
  747. q += ` where c.company_name like ?`
  748. args = append(args, "%"+name+"%")
  749. }
  750. q += ` order by b.name,a.a_id,a.b_name`
  751. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  752. if err != nil {
  753. logx.Error(err)
  754. return result
  755. }
  756. for rows.Next() {
  757. var (
  758. a_id string
  759. company_id string
  760. company_name string
  761. name string
  762. )
  763. if err := rows.Scan(&a_id, &company_id, &company_name, &name); err != nil {
  764. logx.Error(err)
  765. continue
  766. }
  767. if company_id == "" || company_name == "" {
  768. continue
  769. }
  770. result[a_id] = append(result[a_id], &firstpartyNetwork{
  771. CompanyId: company_id,
  772. CompanyName: company_name,
  773. Name: name,
  774. })
  775. }
  776. return result
  777. }
  778. //
  779. func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
  780. values := []string{}
  781. vm := map[string]*projectInfo{}
  782. for _, v := range fpn {
  783. for _, vv := range v {
  784. vm[vv.CompanyId] = &projectInfo{}
  785. values = append(values, vv.CompanyId)
  786. }
  787. }
  788. result := map[string]*projectInfo{}
  789. if len(values) == 0 {
  790. return result
  791. }
  792. wh, args := NetworkCom.WhArgs(values)
  793. 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 + `)`
  794. if len(probusfors) > 0 {
  795. newWh, newArgs := NetworkCom.WhArgs(probusfors)
  796. q += ` and hasAny(property_form,[` + newWh + `])`
  797. args = append(args, newArgs...)
  798. }
  799. q += ` group by buyer_id`
  800. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  801. if err != nil {
  802. logx.Error(err)
  803. return nil
  804. }
  805. for rows.Next() {
  806. var (
  807. buyer_id string
  808. project_count uint64
  809. project_amount decimal.Decimal
  810. project_id []string
  811. )
  812. if err := rows.Scan(&buyer_id, &project_count, &project_amount, &project_id); err != nil {
  813. logx.Error(err)
  814. continue
  815. }
  816. if vm[buyer_id] == nil {
  817. continue
  818. }
  819. vm[buyer_id].ProjectCount += int64(project_count)
  820. pf, _ := project_amount.Float64()
  821. vm[buyer_id].ProjectAmount += pf
  822. vm[buyer_id].ExportId = project_id
  823. }
  824. rows.Close()
  825. if err := rows.Err(); err != nil {
  826. logx.Error(err)
  827. }
  828. for k, v := range fpn {
  829. if result[k] == nil {
  830. result[k] = &projectInfo{}
  831. }
  832. result[k].BuyerCount = int64(len(v))
  833. for _, vv := range v {
  834. if entMonitor[vv.CompanyName] {
  835. result[k].MonitorCount++
  836. }
  837. if vm[vv.CompanyId] == nil {
  838. continue
  839. }
  840. result[k].ProjectCount += vm[vv.CompanyId].ProjectCount
  841. result[k].ProjectAmount += vm[vv.CompanyId].ProjectAmount
  842. result[k].ExportId = append(result[k].ExportId, vm[vv.CompanyId].ExportId...)
  843. }
  844. }
  845. return result
  846. }
  847. //
  848. func (n *network) Introduce_Supplier(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
  849. if len(values) == 0 {
  850. return map[string]*projectInfo{}
  851. }
  852. wh, args := NetworkCom.WhArgs(values)
  853. vbs := map[string][]*idName{}
  854. repeat := map[string]bool{}
  855. whRepeat := map[string]map[string]bool{}
  856. buyers := []string{}
  857. q := `select winner_id,buyer_id,buyer from information.transaction_info where hasAny(winner_id,[` + wh + `])`
  858. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  859. if err != nil {
  860. logx.Error(err)
  861. } else {
  862. for rows.Next() {
  863. var (
  864. winner_id []string
  865. buyer_id string
  866. buyer string
  867. )
  868. if err := rows.Scan(&winner_id, &buyer_id, &buyer); err != nil {
  869. logx.Error(err)
  870. continue
  871. }
  872. if buyer_id == "" || buyer == "" {
  873. continue
  874. }
  875. if !repeat[buyer_id] {
  876. repeat[buyer_id] = true
  877. buyers = append(buyers, buyer_id)
  878. }
  879. for _, v := range winner_id {
  880. if whRepeat[v] != nil && whRepeat[v][buyer_id] {
  881. continue
  882. }
  883. if whRepeat[v] == nil {
  884. whRepeat[v] = map[string]bool{}
  885. }
  886. whRepeat[v][buyer_id] = true
  887. vbs[v] = append(vbs[v], &idName{
  888. Id: buyer_id,
  889. Name: buyer,
  890. })
  891. }
  892. }
  893. rows.Close()
  894. if err := rows.Err(); err != nil {
  895. logx.Error(err)
  896. }
  897. }
  898. return n.MakeProjectInfo(buyers, vbs, probusfors, entMonitor)
  899. }
  900. //
  901. func (n *network) Introduce_Agency(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
  902. if len(values) == 0 {
  903. return map[string]*projectInfo{}
  904. }
  905. wh, args := NetworkCom.WhArgs(values)
  906. q := `select DISTINCT agency_id,buyer_id,buyer from information.transaction_info where agency_id in (` + wh + `)`
  907. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  908. if err != nil {
  909. logx.Error(err)
  910. return nil
  911. }
  912. vbs := map[string][]*idName{}
  913. buyers := []string{}
  914. repeat := map[string]bool{}
  915. for rows.Next() {
  916. var (
  917. agency_id string
  918. buyer_id string
  919. buyer string
  920. )
  921. if err := rows.Scan(&agency_id, &buyer_id, &buyer); err != nil {
  922. logx.Error(err)
  923. continue
  924. }
  925. if buyer_id == "" || buyer == "" {
  926. continue
  927. }
  928. vbs[agency_id] = append(vbs[agency_id], &idName{
  929. Id: buyer_id,
  930. Name: buyer,
  931. })
  932. if !repeat[buyer_id] {
  933. repeat[buyer_id] = true
  934. buyers = append(buyers, buyer_id)
  935. }
  936. }
  937. rows.Close()
  938. if err := rows.Err(); err != nil {
  939. logx.Error(err)
  940. }
  941. return n.MakeProjectInfo(buyers, vbs, probusfors, entMonitor)
  942. }
  943. //
  944. func (n *network) Introduce_Middleman(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
  945. result := map[string]*projectInfo{}
  946. if len(values) == 0 {
  947. return result
  948. }
  949. wh, args := NetworkCom.WhArgs(values)
  950. q := `select DISTINCT project_id,project_money from information.transaction_info where project_id in (` + wh + `)`
  951. if len(probusfors) > 0 {
  952. newWh, newArgs := NetworkCom.WhArgs(probusfors)
  953. q += ` and hasAny(property_form,[` + newWh + `])`
  954. args = append(args, newArgs...)
  955. }
  956. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  957. if err != nil {
  958. logx.Error(err)
  959. return nil
  960. }
  961. for rows.Next() {
  962. var (
  963. project_id string
  964. project_money decimal.Decimal
  965. )
  966. if err := rows.Scan(&project_id, &project_money); err != nil {
  967. logx.Error(err)
  968. continue
  969. }
  970. pf, _ := project_money.Float64()
  971. result[project_id] = &projectInfo{
  972. ProjectAmount: pf,
  973. }
  974. }
  975. rows.Close()
  976. if err := rows.Err(); err != nil {
  977. logx.Error(err)
  978. }
  979. return result
  980. }
  981. //
  982. func (n *network) TypeStrConvert(itype string) int64 {
  983. //firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  984. switch itype {
  985. case "firstparty":
  986. return 1
  987. case "supplier":
  988. return 2
  989. case "adiffb":
  990. return 3
  991. case "middleman":
  992. return 4
  993. case "agency":
  994. return 5
  995. }
  996. return 0
  997. }
  998. //
  999. func (n *network) TypeIntConvert(itype int64) string {
  1000. //firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  1001. switch itype {
  1002. case 1:
  1003. return "firstparty"
  1004. case 2:
  1005. return "supplier"
  1006. case 3:
  1007. return "adiffb"
  1008. case 4:
  1009. return "middleman"
  1010. case 5:
  1011. return "agency"
  1012. }
  1013. return ""
  1014. }
  1015. //
  1016. func (n *network) GetQyxyId(ids []string) map[string]string {
  1017. wh, args := NetworkCom.WhArgs(ids)
  1018. q := `select id,company_id from information.ent_info where id in (` + wh + `)`
  1019. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  1020. m := map[string]string{}
  1021. if err != nil {
  1022. logx.Error(err)
  1023. } else {
  1024. for rows.Next() {
  1025. var (
  1026. id string
  1027. company_id string
  1028. )
  1029. if err := rows.Scan(&id, &company_id); err != nil {
  1030. logx.Error(err)
  1031. continue
  1032. }
  1033. m[id] = company_id
  1034. }
  1035. rows.Close()
  1036. if err := rows.Err(); err != nil {
  1037. logx.Error(err)
  1038. }
  1039. }
  1040. return m
  1041. }
  1042. //
  1043. func (n *network) BuyerProjectInfo(ids []string, probusfors []string) map[string]*projectInfo {
  1044. vm := map[string]*projectInfo{}
  1045. wh, args := NetworkCom.WhArgs(ids)
  1046. 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 + `)`
  1047. if len(probusfors) > 0 {
  1048. newWh, newArgs := NetworkCom.WhArgs(probusfors)
  1049. q += ` and hasAny(property_form,[` + newWh + `])`
  1050. args = append(args, newArgs...)
  1051. }
  1052. q += ` group by buyer_id`
  1053. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  1054. if err != nil {
  1055. logx.Error(err)
  1056. return nil
  1057. }
  1058. for rows.Next() {
  1059. var (
  1060. buyer_id string
  1061. project_count uint64
  1062. project_amount decimal.Decimal
  1063. project_id []string
  1064. )
  1065. if err := rows.Scan(&buyer_id, &project_count, &project_amount, &project_id); err != nil {
  1066. logx.Error(err)
  1067. continue
  1068. }
  1069. pf, _ := project_amount.Float64()
  1070. vm[buyer_id] = &projectInfo{
  1071. ProjectCount: int64(project_count),
  1072. ExportId: project_id,
  1073. ProjectAmount: pf,
  1074. }
  1075. }
  1076. rows.Close()
  1077. if err := rows.Err(); err != nil {
  1078. logx.Error(err)
  1079. }
  1080. return vm
  1081. }
  1082. //
  1083. func (n *network) MakeProjectInfo(buyers []string, vbs map[string][]*idName, probusfors []string, entMonitor map[string]bool) map[string]*projectInfo {
  1084. pis := n.BuyerProjectInfo(buyers, probusfors)
  1085. vm := map[string]*projectInfo{}
  1086. for k, v := range vbs {
  1087. pi := &projectInfo{
  1088. BuyerCount: int64(len(v)),
  1089. }
  1090. re := map[string]bool{}
  1091. for _, vv := range v {
  1092. if pis[vv.Id] != nil {
  1093. pi.ProjectCount += pis[vv.Id].ProjectCount
  1094. pi.ProjectAmount += pis[vv.Id].ProjectAmount
  1095. for _, vvv := range pis[vv.Id].ExportId {
  1096. if re[vvv] {
  1097. continue
  1098. }
  1099. pi.ExportId = append(pi.ExportId, vvv)
  1100. re[vvv] = true
  1101. }
  1102. }
  1103. if entMonitor[vv.Name] {
  1104. pi.MonitorCount++
  1105. }
  1106. }
  1107. vm[k] = pi
  1108. }
  1109. return vm
  1110. }
  1111. //
  1112. func (n *network) AllIntroduceOwner(sqlAppend1, sqlAppend2 string, args []interface{}, isTjProject bool, probusfors []string, entMonitor map[string]bool) *introduceOwnerProject {
  1113. 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
  1114. 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
  1115. listTemp := CrmMysql.SelectBySql(q, args...)
  1116. firstparty_array, supplier_array, adiffb_array, agency_array, middleman_project_array := []string{}, []string{}, []string{}, []string{}, []string{}
  1117. myNetworks := []*myNetwork{}
  1118. for _, v := range *listTemp {
  1119. myNetwork := &myNetwork{
  1120. Id: Int64All(v["id"]),
  1121. Company_id: ObjToString(v["company_id"]),
  1122. Company_name: ObjToString(v["company_name"]),
  1123. Qyxy_id: ObjToString(v["qyxy_id"]),
  1124. Itype: Int64All(v["itype"]),
  1125. Person: ObjToString(v["person"]),
  1126. Phone: ObjToString(v["phone"]),
  1127. Buyer_count: Int64All(v["buyer_count"]),
  1128. Project_count: Int64All(v["project_count"]),
  1129. Relate_buyer_id: ObjToString(v["relate_buyer_id"]),
  1130. Relate_project_id: ObjToString(v["relate_project_id"]),
  1131. Create_time: ObjToString(v["create_time"]),
  1132. }
  1133. switch myNetwork.Itype {
  1134. case 1:
  1135. firstparty_array = append(firstparty_array, myNetwork.Company_id)
  1136. case 2:
  1137. supplier_array = append(supplier_array, myNetwork.Company_id)
  1138. case 3:
  1139. adiffb_array = append(adiffb_array, myNetwork.Company_id)
  1140. case 4:
  1141. if myNetwork.Relate_project_id != "" {
  1142. middleman_project_array = append(middleman_project_array, strings.Split(myNetwork.Relate_project_id, ",")...)
  1143. }
  1144. case 5:
  1145. agency_array = append(agency_array, myNetwork.Company_id)
  1146. }
  1147. myNetworks = append(myNetworks, myNetwork)
  1148. }
  1149. iop := &introduceOwnerProject{
  1150. Networks: myNetworks,
  1151. FirstpartyNetwork: map[string][]*firstpartyNetwork{},
  1152. Firstparty: map[string]*projectInfo{},
  1153. Supplier: map[string]*projectInfo{},
  1154. Adiffb: map[string]*projectInfo{},
  1155. Agency: map[string]*projectInfo{},
  1156. Middleman: map[string]*projectInfo{},
  1157. }
  1158. if isTjProject {
  1159. iop.FirstpartyNetwork = n.FirstpartyNetwork("", firstparty_array)
  1160. iop.Firstparty = n.Introduce_Firstparty(iop.FirstpartyNetwork, entMonitor, probusfors)
  1161. iop.Supplier = n.Introduce_Supplier(supplier_array, entMonitor, probusfors)
  1162. iop.Adiffb = n.Introduce_Supplier(adiffb_array, entMonitor, probusfors)
  1163. iop.Agency = n.Introduce_Agency(agency_array, entMonitor, probusfors)
  1164. iop.Middleman = n.Introduce_Middleman(middleman_project_array, entMonitor, probusfors)
  1165. }
  1166. return iop
  1167. }