network.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. package service
  2. import (
  3. "context"
  4. "database/sql"
  5. "fmt"
  6. "log"
  7. "math"
  8. "strings"
  9. "sync"
  10. . "app.yhyue.com/moapp/jybase/common"
  11. . "app.yhyue.com/moapp/jybase/date"
  12. . "app.yhyue.com/moapp/jybase/es"
  13. . "bp.jydev.jianyu360.cn/CRM/application/api/common"
  14. "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
  15. "github.com/zeromicro/go-zero/core/logx"
  16. )
  17. var Network = &network{}
  18. type network struct {
  19. }
  20. type networkTree struct {
  21. Count int64
  22. Name string
  23. Children []*networkTreeChild
  24. }
  25. type networkTreeChild struct {
  26. Count int64
  27. Name string
  28. Id string
  29. Type int
  30. }
  31. type projectInfo struct {
  32. BuyerCount int
  33. ProjectCount int
  34. ProjectAmount float64
  35. }
  36. //人脉库-添加/修改人脉
  37. func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
  38. reply := &types.Reply{}
  39. nowFormat := NowFormat(Date_Full_Layout)
  40. var saveIntroduce = func(tx *sql.Tx, cid int64, isUpdate bool) bool {
  41. if in.Type != "middleman" {
  42. return true
  43. }
  44. values := []interface{}{}
  45. if in.Introduce_owner_id != "" {
  46. for k, v := range strings.Split(in.Introduce_owner_id, ",") {
  47. values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, strings.Split(in.Introduce_owner_name, ",")[k], 1, nowFormat)
  48. }
  49. }
  50. if in.Introduce_project_id != "" {
  51. for k, v := range strings.Split(in.Introduce_project_id, ",") {
  52. values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, strings.Split(in.Introduce_project_name, ",")[k], 2, nowFormat)
  53. }
  54. }
  55. if len(values) == 0 {
  56. return false
  57. }
  58. var r2 int64
  59. if isUpdate {
  60. r2 = CrmMysql.UpdateOrDeleteBySqlByTx(tx, `delete from crm.connection_introduce where connection_id=? and position_id=?`, in.Id, in.PositionId)
  61. }
  62. r3, _ := CrmMysql.InsertBatchByTx(tx, "crm.connection_introduce", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "connection_id", "relate_id", "relate_name", "itype", "create_time"}, values)
  63. return r2 >= 0 && r3 > 0
  64. }
  65. if in.Id > 0 {
  66. if CrmMysql.ExecTx("更新人脉", func(tx *sql.Tx) bool {
  67. 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)
  68. return r1 >= 0 && saveIntroduce(tx, in.Id, true)
  69. }) {
  70. reply.Data = map[string]interface{}{
  71. "status": 1,
  72. }
  73. } else {
  74. reply.Data = map[string]interface{}{
  75. "status": 0,
  76. }
  77. }
  78. } else {
  79. itype := n.TypeConvert(in.Type)
  80. var r1 int64
  81. if CrmMysql.ExecTx("新增人脉", func(tx *sql.Tx) bool {
  82. _, r1 = CrmMysql.InsertBatchByTx(tx, "crm.connection", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "itype", "company_name", "company_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.Contact_person, in.Contact_phone, 1, nowFormat, nowFormat})
  83. return r1 > 0 && saveIntroduce(tx, r1, false)
  84. }) {
  85. reply.Data = map[string]interface{}{
  86. "status": 1,
  87. "id": r1,
  88. }
  89. } else {
  90. reply.Data = map[string]interface{}{
  91. "status": 0,
  92. }
  93. }
  94. }
  95. return reply
  96. }
  97. //人脉库-业主名称联想
  98. func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
  99. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 middleman_owner:中间人-业主 middleman_project:中间人-项目 agency:招标代理机构
  100. res := []map[string]interface{}{}
  101. reply = &types.Reply{Data: res}
  102. in.Name = strings.TrimSpace(in.Name)
  103. if in.Name == "" {
  104. return
  105. }
  106. pageSize := 10
  107. if in.Type == "adiffb" {
  108. probusfors := NetworkCom.GetMyProbusfor(in.EntAccountId)
  109. if len(probusfors) > 0 {
  110. args := []interface{}{in.EntName}
  111. wh, newArgs := NetworkCom.WhArgs(probusfors)
  112. args = append(args, newArgs...)
  113. q := `select DISTINCT b.winner_id,b.winner from information.transaction_info a
  114. inner join information.transaction_info b on (has(a.winner, ?) and a.buyer_id<>'' and a.buyer_id=b.buyer_id and hasAny(b.property_form,[` + wh + `])) ORDER BY b.project_id`
  115. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  116. if err != nil {
  117. logx.Error(err)
  118. } else {
  119. repeat := map[string]bool{}
  120. for rows.Next() {
  121. var (
  122. winner_id []string
  123. winner []string
  124. )
  125. if err := rows.Scan(&winner_id, &winner); err != nil {
  126. logx.Error(err)
  127. continue
  128. }
  129. for k, v := range winner {
  130. if repeat[v] || !strings.Contains(v, in.Name) {
  131. continue
  132. }
  133. repeat[v] = true
  134. if k >= len(winner_id) {
  135. continue
  136. }
  137. res = append(res, map[string]interface{}{
  138. "company_name": v,
  139. "company_id": winner_id[k],
  140. })
  141. }
  142. }
  143. rows.Close()
  144. if err := rows.Err(); err != nil {
  145. logx.Error(err)
  146. }
  147. if len(res) > pageSize {
  148. res = res[:pageSize]
  149. }
  150. }
  151. }
  152. } else {
  153. must := []string{fmt.Sprintf(`{"multi_match":{"query":"%s","type":"phrase","fields":["company_name"]}}`, in.Name)}
  154. switch in.Type {
  155. case "firstparty":
  156. must = append(must, fmt.Sprintf(`{"terms":{"company_label":["%s"]}}`, strings.Join(NetworkCom.GetEntTagSeat(2), `","`)))
  157. must = append(must, `{"terms":{"company_unit_type":[1,2]}}`)
  158. case "supplier":
  159. must = append(must, fmt.Sprintf(`{"terms":{"company_label":["%s"]}}`, strings.Join(NetworkCom.GetEntTagSeat(2), `","`)))
  160. must = append(must, `{"term":{"company_unit_type":3}}`)
  161. case "middleman_owner":
  162. must = append(must, `{"terms":{"company_unit_type":[1,2]}}`)
  163. case "agency":
  164. must = append(must, `{"term":{"company_unit_type":4}}`)
  165. }
  166. q := fmt.Sprintf(`{"query":{"bool":{"must":[%s]}},"size":%d,"_source":["id","company_name"]}`, strings.Join(must, ","), pageSize)
  167. logx.Info("人脉库-业主名称联想", q)
  168. datas := VarEs.Get("ent_info", "ent_info", q)
  169. if datas != nil {
  170. for _, v := range *datas {
  171. res = append(res, map[string]interface{}{
  172. "company_name": ObjToString(v["company_name"]),
  173. "company_id": ObjToString(v["id"]),
  174. })
  175. }
  176. }
  177. }
  178. reply.Data = res
  179. return
  180. }
  181. //人脉库-全部人脉项目
  182. func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
  183. pool := make(chan bool, 5)
  184. wait := &sync.WaitGroup{}
  185. lock := &sync.Mutex{}
  186. reply = &types.Reply{}
  187. wh, newArgs := NetworkCom.WhArgs(NetworkCom.GetMyProbusfor(in.EntAccountId))
  188. if in.Id != "" {
  189. if in.Type == 1 {
  190. q := `select c.id as company_id,c.company_name,b.name from information.ent_map_code a
  191. inner join information.ent_code b on (a.a_id=? and b.pcode in ('0100','0200') and a.code=b.code)
  192. inner join information.ent_info c on (a.b_id=c.id)`
  193. args := []interface{}{in.Id}
  194. if in.Name != "" {
  195. q += ` where c.company_name like ?`
  196. args = append(args, "%"+in.Name+"%")
  197. }
  198. q += ` order by b.name,c.company_name`
  199. rows, err := ClickhouseConn.Query(context.Background(), q, args...)
  200. if err != nil {
  201. logx.Error(err)
  202. return
  203. }
  204. nameIndex := map[string]int{}
  205. list := []*networkTree{}
  206. for rows.Next() {
  207. var (
  208. company_id string
  209. company_name string
  210. name string
  211. )
  212. if err := rows.Scan(&company_id, &company_name, &name); err != nil {
  213. logx.Error(err)
  214. continue
  215. }
  216. log.Println(company_id, company_name, name)
  217. if _, ok := nameIndex[name]; !ok {
  218. nameIndex[name] = len(list)
  219. list = append(list, &networkTree{
  220. Name: name,
  221. })
  222. }
  223. pool <- true
  224. wait.Add(1)
  225. go func(cIndex int, cId, cName string) {
  226. defer func() {
  227. <-pool
  228. wait.Done()
  229. }()
  230. ntc := &networkTreeChild{
  231. Name: cName,
  232. Id: cId,
  233. Type: 1,
  234. }
  235. if wh != "" {
  236. thisArgs := []interface{}{ntc.Id}
  237. thisArgs = append(thisArgs, newArgs...)
  238. ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where buyer_id=? and hasAny(property_form,[`+wh+`])`, thisArgs...)
  239. }
  240. lock.Lock()
  241. list[cIndex].Count += ntc.Count
  242. list[cIndex].Children = append(list[cIndex].Children, ntc)
  243. lock.Unlock()
  244. }(nameIndex[name], company_id, company_name)
  245. }
  246. wait.Wait()
  247. rows.Close()
  248. if err := rows.Err(); err != nil {
  249. logx.Error(err)
  250. }
  251. }
  252. } else {
  253. q := `SELECT a.company_id,a.company_name,a.itype,COUNT(b.id) AS ipc FROM crm.connection a
  254. LEFT JOIN crm.connection_introduce b ON (b.position_id=? AND b.itype=2 AND a.id=b.connection_id) WHERE a.position_id=?`
  255. args := []interface{}{in.PositionId, in.PositionId}
  256. if in.Name != "" {
  257. q += ` and company_name like ?`
  258. args = append(args, "%"+in.Name+"%")
  259. }
  260. q += ` GROUP BY a.id ORDER BY a.create_time DESC`
  261. datas := CrmMysql.SelectBySql(q, args...)
  262. var count int64
  263. list := []*networkTree{
  264. &networkTree{
  265. Name: "甲方",
  266. },
  267. &networkTree{
  268. Name: "供应商",
  269. },
  270. &networkTree{
  271. Name: "同甲异业渠道",
  272. },
  273. &networkTree{
  274. Name: "中间人",
  275. },
  276. &networkTree{
  277. Name: "招标代理",
  278. },
  279. }
  280. //
  281. for _, vt := range *datas {
  282. pool <- true
  283. wait.Add(1)
  284. go func(v map[string]interface{}) {
  285. defer func() {
  286. <-pool
  287. wait.Done()
  288. }()
  289. itype := IntAll(v["itype"])
  290. if itype <= 0 || itype > len(list) {
  291. return
  292. }
  293. ntc := &networkTreeChild{
  294. Name: ObjToString(v["company_name"]),
  295. Id: ObjToString(v["company_id"]),
  296. Type: IntAll(v["itype"]),
  297. }
  298. if wh != "" {
  299. thisArgs := []interface{}{ntc.Id}
  300. thisArgs = append(thisArgs, newArgs...)
  301. if itype == 1 {
  302. ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where buyer_id=? and hasAny(b.property_form,[`+wh+`])`, thisArgs)
  303. } else if itype == 2 || itype == 3 {
  304. ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where winner_id=? and hasAny(b.property_form,[`+wh+`])`, thisArgs)
  305. } else if itype == 4 {
  306. ntc.Count = Int64All(v["ipc"])
  307. } else if itype == 5 {
  308. ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where agency_id=? and hasAny(b.property_form,[`+wh+`])`, thisArgs)
  309. }
  310. }
  311. lock.Lock()
  312. count += ntc.Count
  313. list[itype-1].Count += ntc.Count
  314. list[itype-1].Children = append(list[itype-1].Children, ntc)
  315. lock.Unlock()
  316. }(vt)
  317. }
  318. wait.Wait()
  319. reply = &types.Reply{
  320. Data: map[string]interface{}{
  321. "count": count,
  322. "list": list,
  323. },
  324. }
  325. }
  326. return reply
  327. }
  328. //人脉库-列表
  329. func (n *network) List(in *types.NetWorkListReq) *types.Reply {
  330. q := `select a.company_id,a.company_name,a.itype,a.contact_person as person,a.contact_phone as phone,count(if(b.itype=1,1,null)) as buyer_count,count(if(b.itype=2,1,null)) as project_count,GROUP_CONCAT(b.relate_id) as relate_id,a.create_time from crm.connection a
  331. left join crm.connection_introduce b on (a.id=b.connection_id) where a.position_id=?`
  332. args := []interface{}{in.PositionId}
  333. if in.Type != "" {
  334. q += ` and a.itype=?`
  335. args = append(args, n.TypeConvert(in.Type))
  336. }
  337. if in.Starttime != "" {
  338. q += ` and a.create_time>=?`
  339. args = append(args, in.Starttime)
  340. }
  341. if in.Endtime != "" {
  342. q += ` and a.create_time<=?`
  343. args = append(args, in.Endtime)
  344. }
  345. if in.Name != "" {
  346. q += ` and a.company_name like ?`
  347. args = append(args, "%"+in.Name+"%")
  348. }
  349. q += ` GROUP BY a.id order by a.create_time desc`
  350. listTemp := CrmMysql.SelectBySql(q, args...)
  351. supplier_array, adiffb_array, agency_array, middleman_array := []string{}, []string{}, []string{}, []string{}
  352. for _, v := range *listTemp {
  353. switch Int64All(v["itype"]) {
  354. case 2:
  355. supplier_array = append(supplier_array, ObjToString(v["company_id"]))
  356. case 3:
  357. adiffb_array = append(adiffb_array, ObjToString(v["company_id"]))
  358. case 4:
  359. if relate_id := ObjToString(v["relate_id"]); relate_id != "" {
  360. middleman_array = append(middleman_array, strings.Split(relate_id, ",")...)
  361. }
  362. case 5:
  363. agency_array = append(agency_array, ObjToString(v["company_id"]))
  364. }
  365. }
  366. //
  367. firstparty_count, supplier_count, adiffb_count, middleman_count, agency_count := 0, 0, 0, 0, 0
  368. list := []map[string]interface{}{}
  369. supplier_project := n.Introduce_Agency(supplier_array)
  370. adiffb_project := n.Introduce_Supplier(adiffb_array)
  371. agency_project := n.Introduce_Agency(agency_array)
  372. middleman_project := n.Introduce_Middleman(middleman_array)
  373. for _, v := range *listTemp {
  374. itype := ""
  375. buyer_count, project_count, expect_amount := 0, 0, float64(0)
  376. company_id := ObjToString(v["company_id"])
  377. switch Int64All(v["itype"]) {
  378. case 1:
  379. itype = "甲方"
  380. firstparty_count++
  381. case 2:
  382. itype = "供应商"
  383. supplier_count++
  384. if supplier_project[company_id] != nil {
  385. buyer_count = supplier_project[company_id].BuyerCount
  386. project_count = supplier_project[company_id].ProjectCount
  387. expect_amount = supplier_project[company_id].ProjectAmount
  388. }
  389. case 3:
  390. itype = "同甲异业渠道"
  391. adiffb_count++
  392. if adiffb_project[company_id] != nil {
  393. buyer_count = adiffb_project[company_id].BuyerCount
  394. project_count = adiffb_project[company_id].ProjectCount
  395. expect_amount = adiffb_project[company_id].ProjectAmount
  396. }
  397. case 4:
  398. itype = "中间人"
  399. middleman_count++
  400. buyer_count = IntAll(v["buyer_count"])
  401. project_count = IntAll(v["project_count"])
  402. if relate_id := ObjToString(v["relate_id"]); relate_id != "" {
  403. for _, v := range strings.Split(relate_id, ",") {
  404. if middleman_project[v] != nil {
  405. expect_amount += middleman_project[v].ProjectAmount
  406. }
  407. }
  408. }
  409. if middleman_project[company_id] != nil {
  410. expect_amount = middleman_project[company_id].ProjectAmount
  411. }
  412. case 5:
  413. itype = "招标代理机构"
  414. agency_count++
  415. if agency_project[company_id] != nil {
  416. buyer_count = agency_project[company_id].BuyerCount
  417. project_count = agency_project[company_id].ProjectCount
  418. expect_amount = agency_project[company_id].ProjectAmount
  419. }
  420. }
  421. list = append(list, map[string]interface{}{
  422. "company_id": company_id,
  423. "company_name": v["company_name"],
  424. "type": itype,
  425. "person": v["person"],
  426. "phone": v["phone"],
  427. "buyer_count": buyer_count,
  428. "monitor_count": 0,
  429. "expect_amount": expect_amount,
  430. "project_count": project_count,
  431. "create_time": v["create_time"],
  432. })
  433. }
  434. length := int64(len(list))
  435. var pageSize int64 = 10
  436. total_page := int64(math.Ceil(float64(length) / float64(pageSize)))
  437. finalList := []map[string]interface{}{}
  438. if length > 0 {
  439. if in.Current_page <= 0 {
  440. in.Current_page = 1
  441. }
  442. if in.Current_page > total_page {
  443. in.Current_page = total_page
  444. }
  445. start := (in.Current_page - 1) * pageSize
  446. end := start + pageSize
  447. if end > length {
  448. end = length
  449. }
  450. finalList = list[start:end]
  451. }
  452. return &types.Reply{
  453. Data: map[string]interface{}{
  454. "total_page": total_page,
  455. "firstparty_count": firstparty_count,
  456. "supplier_count": supplier_count,
  457. "adiffb_count": adiffb_count,
  458. "middleman_count": middleman_count,
  459. "agency_count": agency_count,
  460. "list": finalList,
  461. },
  462. }
  463. }
  464. //
  465. func (n *network) Introduce_Supplier(values []string) map[string]*projectInfo {
  466. vm := map[string]*projectInfo{}
  467. for _, v := range values {
  468. vm[v] = &projectInfo{}
  469. }
  470. wh, newArgs := NetworkCom.WhArgs(values)
  471. rows, err := ClickhouseConn.Query(context.Background(), `select a.winner_id,count(a.buyer_id) AS buyer_count,count(b.project_id) AS project_count,sum(b.project_money) AS project_amount from information.transaction_info a
  472. inner join information.transaction_info b on (hasAny(a.winner_id,[`+wh+`]) and a.buyer_id=b.buyer_id)
  473. group by a.winner_id`, newArgs...)
  474. if err != nil {
  475. logx.Error(err)
  476. return nil
  477. }
  478. for rows.Next() {
  479. var (
  480. winner_id []string
  481. buyer_count uint64
  482. project_count uint64
  483. project_amount float64
  484. )
  485. if err := rows.Scan(&winner_id, &buyer_count, &project_count, &project_amount); err != nil {
  486. logx.Error(err)
  487. continue
  488. }
  489. for _, v := range winner_id {
  490. if vm[v] == nil {
  491. continue
  492. }
  493. vm[v].BuyerCount += int(buyer_count)
  494. vm[v].ProjectCount += int(project_count)
  495. vm[v].ProjectAmount += project_amount
  496. }
  497. }
  498. rows.Close()
  499. if err := rows.Err(); err != nil {
  500. logx.Error(err)
  501. }
  502. return vm
  503. }
  504. //
  505. func (n *network) Introduce_Agency(values []string) map[string]*projectInfo {
  506. vm := map[string]*projectInfo{}
  507. for _, v := range values {
  508. vm[v] = &projectInfo{}
  509. }
  510. wh, newArgs := NetworkCom.WhArgs(values)
  511. rows, err := ClickhouseConn.Query(context.Background(), `select a.agency_id,count(a.buyer_id) AS buyer_count,count(b.project_id) AS project_count,sum(b.project_money) AS project_amount from information.transaction_info a
  512. inner join information.transaction_info b on (agency_id in (`+wh+`) and a.buyer_id=b.buyer_id)
  513. group by a.agency_id`, newArgs...)
  514. if err != nil {
  515. logx.Error(err)
  516. return nil
  517. }
  518. for rows.Next() {
  519. var (
  520. agency_id string
  521. buyer_count uint64
  522. project_count uint64
  523. project_amount float64
  524. )
  525. if err := rows.Scan(&agency_id, &buyer_count, &project_count, &project_amount); err != nil {
  526. logx.Error(err)
  527. continue
  528. }
  529. if vm[agency_id] == nil {
  530. continue
  531. }
  532. vm[agency_id].BuyerCount += int(buyer_count)
  533. vm[agency_id].ProjectCount += int(project_count)
  534. vm[agency_id].ProjectAmount += project_amount
  535. }
  536. rows.Close()
  537. if err := rows.Err(); err != nil {
  538. logx.Error(err)
  539. }
  540. return vm
  541. }
  542. //
  543. func (n *network) Introduce_Middleman(values []string) map[string]*projectInfo {
  544. vm := map[string]*projectInfo{}
  545. wh, newArgs := NetworkCom.WhArgs(values)
  546. rows, err := ClickhouseConn.Query(context.Background(), `select project_id,project_money from information.transaction_info where project_id in (`+wh+`)`, newArgs...)
  547. if err != nil {
  548. logx.Error(err)
  549. return nil
  550. }
  551. for rows.Next() {
  552. var (
  553. project_id string
  554. project_money float64
  555. )
  556. if err := rows.Scan(&project_id, &project_money); err != nil {
  557. logx.Error(err)
  558. continue
  559. }
  560. vm[project_id] = &projectInfo{
  561. ProjectAmount: project_money,
  562. }
  563. }
  564. rows.Close()
  565. if err := rows.Err(); err != nil {
  566. logx.Error(err)
  567. }
  568. return vm
  569. }
  570. //
  571. func (n *network) TypeConvert(itype string) int {
  572. //firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  573. switch itype {
  574. case "firstparty":
  575. return 1
  576. case "supplier":
  577. return 2
  578. case "adiffb":
  579. return 3
  580. case "middleman":
  581. return 4
  582. case "agency":
  583. return 5
  584. }
  585. return 0
  586. }