employService.go 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. package service
  2. import (
  3. "database/sql"
  4. "fmt"
  5. "log"
  6. "strings"
  7. "time"
  8. "app.yhyue.com/moapp/jybase/common"
  9. "app.yhyue.com/moapp/jybase/date"
  10. elastic "app.yhyue.com/moapp/jybase/es"
  11. "app.yhyue.com/moapp/jypkg/ent/util"
  12. MC "bp.jydev.jianyu360.cn/CRM/application/api/common"
  13. "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
  14. "bp.jydev.jianyu360.cn/CRM/application/entity"
  15. "github.com/RoaringBitmap/roaring"
  16. "github.com/gogf/gf/v2/util/gconv"
  17. )
  18. const (
  19. BuyerIndex = "buyer" // 采购单位index
  20. BuyerType = "buyer"
  21. INDEX = "bidding"
  22. TYPE = "bidding"
  23. )
  24. type EmPloyService struct{}
  25. type PersonSmmary struct {
  26. EntUserId int64
  27. EntDeptId int64
  28. Summary map[int64]*roaring.Bitmap
  29. }
  30. // InfoEmployinfo 收录情况查询
  31. func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) ([]map[string]interface{}, int64) {
  32. var data []map[string]interface{}
  33. depIDArr := ""
  34. batchEmploy := int64(0)
  35. if in.EntNicheDis > 0 {
  36. //查询所有部门标识
  37. deptArr := MC.MainMysql.SelectBySql("select GROUP_CONCAT(DISTINCT b.id) as depIDArr from entniche_department_parent a"+
  38. " INNER JOIN entniche_department b "+
  39. "on (b.ent_id=? and (b.id=? or (a.pid=? and a.id=b.id)))", in.EntId, in.EntDeptId, in.EntDeptId)
  40. if len(*deptArr) == 0 {
  41. return data, batchEmploy
  42. }
  43. depIDArr = common.InterfaceToStr((*deptArr)[0]["depIDArr"])
  44. if depIDArr == "" {
  45. return data, batchEmploy
  46. }
  47. }
  48. //是否可以批量收录配置回显
  49. accountId := int64(0)
  50. if in.PositionType == 0 {
  51. accountId = in.AccountId
  52. } else {
  53. accountId = in.EntAccountId
  54. }
  55. configData := MC.CrmMysql.FindOne("config_tenant", map[string]interface{}{
  56. "account_id": accountId,
  57. }, "batch_employ", "")
  58. if configData != nil {
  59. batchEmploy = gconv.Int64((*configData)["batch_employ"])
  60. }
  61. //版本查询
  62. res := MC.Middleground.ResourceCenter.Haspowers(in.AccountId, in.EntAccountId, in.EntId, in.EntUserId)
  63. version := 0
  64. for _, pCode := range res.Powers {
  65. //0:通用版 1:物业专版
  66. if pCode == "bi_yx_wyzb" {
  67. version = 1
  68. }
  69. }
  70. infoId1Arr := []string{}
  71. niJianIdArr := []string{}
  72. infoId2Arr := []string{}
  73. wuye1Arr := []string{}
  74. wuye2Arr := []string{}
  75. infoMap := map[string]interface{}{}
  76. table, findKey, employKey, employData := employKeyFormat(in.EmployType, in.IdArr)
  77. for _, employ := range employData {
  78. source := employ.Source
  79. isNiJian := employ.IsNiJian
  80. if (employ.Subtype == "成交" || employ.Subtype == "中标" || employ.Subtype == "合同" || employ.Subtype == "验收" || employ.Subtype == "违规") && in.EmployType == 1 && version == 1 {
  81. infoMap[employ.Id] = employ.ProjectId
  82. if isNiJian {
  83. infoMap[employ.Id] = employ.ProjectId
  84. if source == 1 {
  85. wuye1Arr = append(wuye1Arr, employ.ProjectId)
  86. } else {
  87. wuye2Arr = append(wuye2Arr, employ.ProjectId)
  88. }
  89. } else {
  90. infoMap[employ.Id] = employ.SourceId
  91. if source == 1 {
  92. wuye1Arr = append(wuye1Arr, employ.SourceId)
  93. } else {
  94. wuye2Arr = append(wuye2Arr, employ.SourceId)
  95. }
  96. }
  97. } else if isNiJian {
  98. infoMap[employ.Id] = employ.ProjectId
  99. niJianIdArr = append(niJianIdArr, employ.ProjectId)
  100. } else if source == 2 {
  101. infoMap[employ.Id] = employ.SourceId
  102. infoId2Arr = append(infoId2Arr, employ.SourceId)
  103. } else if source == 1 {
  104. infoMap[employ.Id] = employ.SourceId
  105. infoId1Arr = append(infoId1Arr, employ.SourceId)
  106. }
  107. }
  108. //收录情况查询
  109. dataList := map[string]map[string]interface{}{}
  110. if in.EntNicheDis > 0 {
  111. dataList = employInfoEnt(table, employKey, findKey, depIDArr, in, version, infoId1Arr, infoId2Arr, niJianIdArr, wuye1Arr, wuye2Arr)
  112. } else {
  113. dataList = employInfoPerson(table, employKey, findKey, in, version, infoId1Arr, infoId2Arr, niJianIdArr, wuye1Arr, wuye2Arr)
  114. }
  115. for k, v := range infoMap {
  116. fool := true
  117. for sourceId, v1 := range dataList {
  118. if v == sourceId {
  119. v1["id"] = k
  120. data = append(data, v1)
  121. fool = false
  122. break
  123. }
  124. }
  125. if fool {
  126. data = append(data, map[string]interface{}{
  127. "id": k,
  128. "isIgnore": false,
  129. "isEmploy": false,
  130. "customCount": 0,
  131. "clueCount": 0,
  132. "chanceCount": 0,
  133. "type": 1,
  134. })
  135. }
  136. }
  137. return data, batchEmploy
  138. }
  139. // EmployOperate 收录操作
  140. func (e *EmPloyService) EmployOperate(in *types.EmployOperateReq) (bool, string) {
  141. log.Println("收录入参", in)
  142. //收录汇总表
  143. //summaryMap := SummaryFormat(in.PositionId)
  144. msg := ""
  145. return MC.CrmMysql.ExecTx("收录操作", func(tx *sql.Tx) bool {
  146. fool := false
  147. //id转中文
  148. table, _, employKey, data := employKeyFormat(in.EmployType, in.IdArr)
  149. for id, employ := range data {
  150. findMap := map[string]interface{}{}
  151. findMap["position_id"] = in.PositionId
  152. if employ.IsNiJian {
  153. findMap[employKey] = employ.ProjectId
  154. } else {
  155. findMap[employKey] = id
  156. }
  157. if employ.SourceId == "" {
  158. log.Println(employ.Id, in.EmployType, "该信息查询不到数据")
  159. continue
  160. }
  161. if in.IsEmploy {
  162. if MC.CrmMysql.Count(table, findMap) > 0 {
  163. MC.CrmMysql.UpdateByTx(tx, table, findMap, map[string]interface{}{
  164. "status": 1,
  165. })
  166. } else {
  167. //收录新增
  168. data := map[string]interface{}{}
  169. if in.EmployType == 1 || in.EmployType == 4 {
  170. data = infoFind(id, employ.Id)
  171. } else if in.EmployType == 2 {
  172. data = customFind(id, in.EmployType)
  173. data["jybx_url"] = "/swordfish/page_big_pc/ent_portrait/" + employ.Id
  174. data["source"] = employ.Source
  175. } else if in.EmployType == 3 {
  176. data = customFind(id, in.EmployType)
  177. data["jybx_url"] = "/publicapply/biTransfer?buyerName=" + employ.Id
  178. data["source"] = employ.Source
  179. }
  180. data["position_id"] = in.PositionId
  181. data["ent_id"] = in.EntId
  182. data["ent_dept_id"] = in.EntDeptId
  183. data["ent_user_id"] = in.EntUserId
  184. ok := MC.CrmMysql.InsertByTx(tx, table, data)
  185. if ok <= 0 {
  186. log.Println(employ.Id, id, in.EmployType, "收录失败")
  187. continue
  188. }
  189. }
  190. fool = true
  191. } else {
  192. //取消收录
  193. if in.From == "jhfp" {
  194. findMap["type"] = 3
  195. }
  196. if MC.CrmMysql.Count(table, findMap) > 0 {
  197. ok := MC.CrmMysql.UpdateByTx(tx, table, findMap, map[string]interface{}{
  198. "status": -1,
  199. })
  200. if !ok {
  201. log.Println(employ.Id, id, in.EmployType, "取消收录失败")
  202. continue
  203. }
  204. fool = true
  205. } else {
  206. if in.EmployType == 1 {
  207. msg = "该资讯已有员工收录,不可取消收录。"
  208. continue
  209. } else {
  210. msg = "该企业已有员工收录,不可取消收录。"
  211. continue
  212. }
  213. }
  214. }
  215. }
  216. if in.IsEmploy && !fool {
  217. msg = "收录失败"
  218. }
  219. return fool
  220. }), msg
  221. }
  222. // customFind 企业信息查询
  223. func customFind(id string, employType int64) map[string]interface{} {
  224. data := map[string]interface{}{}
  225. //company_id 企业id name户名称 address 地址 industry 行业
  226. if employType == 2 {
  227. //企业详情
  228. entinfo, _ := MC.MgoEnt.FindOneByField("qyxy_std", map[string]interface{}{"_id": id}, map[string]interface{}{
  229. "company_address": 1, //注册地
  230. "company_name": 1,
  231. })
  232. if entinfo != nil && len(*entinfo) > 0 {
  233. data["name"] = (*entinfo)["company_name"]
  234. data["address"] = (*entinfo)["company_address"]
  235. data["company_id"] = id
  236. }
  237. } else {
  238. //采购单位详情
  239. rs := elastic.Get(BuyerIndex, BuyerType, fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"_id":["%s"]}}]}},"size":1,"_source":["buyer_name","city"]}`, id))
  240. if rs != nil && len(*rs) > 0 {
  241. data["name"] = (*rs)[0]["buyer_name"]
  242. data["address"] = (*rs)[0]["city"]
  243. data["company_id"] = id
  244. }
  245. }
  246. data["status"] = 1
  247. data["create_time"] = time.Now().Format(date.Date_Full_Layout)
  248. return data
  249. }
  250. // infoFind 标讯信息查询
  251. func infoFind(id string, v1 string) map[string]interface{} {
  252. data := map[string]interface{}{}
  253. //source_id 信息id、项目id- title 标题-area 省 -city 市 -subtype 信息类型二级分类
  254. //buyerclass 采购单位行业 -budget 预算 -bidamount 中标金额 buyer采购单位 annex有无附件 publishtime发布时间 projectname 项目时间
  255. //ownerclass 业主类型(拟在建搜索) expurasing_time 预计采购时间 jybx_url 标讯详情页
  256. //标讯信息
  257. obj := map[string]interface{}{}
  258. aobj := elastic.Get(INDEX, TYPE, fmt.Sprintf(`{"query":{"bool":{"must":[{"match":{"id":"%s"}}],"must_not":[],"should":[]}},"from":0,"size":10,"_source":["_id","purchasinglist","projectname","projectcode","title","s_winner","buyertel","bidstatus","site","bidamount","toptype","winneraddr","winner","agency","buyer","detail","city","subtype","buyerclass","href","comeintime","winnertel","area","publishtime","buyeraddr","agencytel","budget","entidlist","buyerperson","winnerperson","agencyaddr","recommended_service","competehref","owner","total_investment","projectaddr","projectperiod","approvedept","approvecontent","approvecode","approvenumber","approvetime","approvestatus","project_scale"],"sort":[],"aggs":{}}`, id))
  259. log.Println(len(*aobj))
  260. if aobj != nil || *aobj != nil || len(*aobj) > 0 {
  261. obj = (*aobj)[0]
  262. }
  263. toptype := common.InterfaceToStr(obj["toptype"])
  264. subtype := common.InterfaceToStr(obj["subtype"])
  265. pushTime := ""
  266. if obj != nil && len(obj) > 0 {
  267. data["title"] = common.ObjToString(obj["title"])
  268. city := gconv.String(obj["city"])
  269. area := gconv.String(obj["area"])
  270. data["city"] = city
  271. data["area"] = area
  272. //省份代码处理
  273. areaCode := ""
  274. if MC.AreaCodeMap[city] != "" {
  275. areaCode = MC.AreaCodeMap[city]
  276. } else {
  277. areaCode = MC.AreaCodeMap[area]
  278. }
  279. data["area_code"] = areaCode
  280. data["subtype"] = obj["subtype"]
  281. data["buyerclass"] = obj["buyerclass"]
  282. data["budget"] = obj["budget"]
  283. data["bidamount"] = obj["bidamount"]
  284. data["annex"] = 0
  285. data["buyer"] = obj["buyer"]
  286. data["winner"] = obj["s_winner"]
  287. data["jybx_url"] = "/article/content/" + v1 + ".html"
  288. //类型处理
  289. pushTime = time.Unix(common.Int64All(obj["publishtime"]), 0).Format(date.Date_Full_Layout)
  290. data["source"] = 1
  291. data["source_id"] = id
  292. if subtype == "拟建" {
  293. data["source"] = 2
  294. }
  295. if toptype == "采购意向" || toptype == "预告" || toptype == "招标" || toptype == "" {
  296. data["type"] = 2
  297. } else {
  298. if subtype == "废标" || subtype == "流标" || subtype == "其它" {
  299. data["type"] = 2
  300. } else if subtype == "成交" || subtype == "中标" || subtype == "合同" || subtype == "验收" || subtype == "违规" {
  301. data["type"] = 3
  302. } else {
  303. data["type"] = 1
  304. }
  305. }
  306. if obj["projectinfo"] != nil {
  307. projectinfo := common.ObjToMap(obj["projectinfo"])
  308. if (*projectinfo)["attachments"] != nil {
  309. data["annex"] = 1
  310. }
  311. }
  312. data["publishtime"] = pushTime
  313. data["show_time"] = pushTime
  314. data["projectname"] = obj["projectname"]
  315. procurementlist, _ := obj["procurementlist"].([]interface{})
  316. for _, vs := range procurementlist { //1.采购意向清单数据集打码处理
  317. vsMap, _ := vs.(map[string]interface{})
  318. if vsMap["expurasingtime"] != nil {
  319. data["expurasing_time"] = vsMap["expurasingtime"]
  320. break
  321. }
  322. }
  323. }
  324. data["status"] = 1
  325. data["employ_way"] = 1
  326. data["create_time"] = time.Now().Format(date.Date_Full_Layout)
  327. if subtype == "拟建" {
  328. data = niJianHandle(id, data, v1, pushTime)
  329. data["type"] = 1
  330. }
  331. return data
  332. }
  333. // GetBuyerIdByName 通过采购单位名称获取id
  334. func getBuyerIdByName(buyerName string) (buyerId string) {
  335. r := elastic.Get(BuyerIndex, BuyerType, fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"buyer_name":"%s"}}]}},"size":1,"_source":["city","id"]}`, buyerName))
  336. if r == nil || len(*r) == 0 {
  337. return
  338. }
  339. buyerId, _ = (*r)[0]["_id"].(string)
  340. return
  341. }
  342. // IdFormat id解密
  343. func idFormat(encryptionId string, employType int64) string {
  344. decryptId := ""
  345. switch employType {
  346. case 1, 2:
  347. decryptId = util.DecodeId(encryptionId)
  348. case 3:
  349. if len(encryptionId) > 0 && len([]rune(encryptionId)) == len(encryptionId) {
  350. //此数据是id
  351. //获取中文名字
  352. decryptId = util.DecodeId(encryptionId)
  353. } else {
  354. //次数据传的名字
  355. decryptId = getBuyerIdByName(encryptionId)
  356. }
  357. }
  358. return decryptId
  359. }
  360. type Employ struct {
  361. Source int64
  362. IsNiJian bool
  363. ProjectId string
  364. Id string
  365. SourceId string
  366. Subtype string
  367. }
  368. // employKeyFormat 根据收录类型 字段处理 table,findKey,employKey,source
  369. func employKeyFormat(employType int64, idArrStr string) (string, string, string, map[string]Employ) {
  370. table := ""
  371. employKey := "company_id"
  372. findKey := "employ_custom_id"
  373. infoIdMap := map[string]Employ{}
  374. idArr := []string{}
  375. source := int64(0)
  376. switch employType {
  377. case 1:
  378. table = entity.EMPLOY_INFO
  379. employKey = "source_id"
  380. findKey = "employ_info_id"
  381. source = 1
  382. case 2:
  383. table = entity.EMPLOY_CUSTOM
  384. source = 1
  385. case 3:
  386. table = entity.EMPLOY_CUSTOM
  387. source = 2
  388. case 4:
  389. table = entity.EMPLOY_INFO
  390. source = 2
  391. employKey = "source_id"
  392. findKey = "employ_info_id"
  393. }
  394. for _, v := range strings.Split(idArrStr, ",") {
  395. id := idFormat(v, employType)
  396. idArr = append(idArr, id)
  397. infoIdMap[id] = Employ{
  398. Source: source,
  399. IsNiJian: false,
  400. ProjectId: "",
  401. Id: v,
  402. SourceId: id,
  403. }
  404. }
  405. if employType == 1 {
  406. table = entity.EMPLOY_INFO
  407. employKey = "source_id"
  408. findKey = "employ_info_id"
  409. source = 1
  410. aobj := elastic.Get(INDEX, TYPE, fmt.Sprintf(`{"query":{"bool":{"must_not":[],"should":[ {
  411. "terms": {
  412. "id": [
  413. "%s"
  414. ]
  415. }
  416. }]}},"from":0,"size":100,"_source":["_id","purchasinglist","projectname","projectcode","title","s_winner","buyertel","bidstatus","site","bidamount","toptype","winneraddr","winner","agency","buyer","detail","city","subtype","buyerclass","href","comeintime","winnertel","area","publishtime","buyeraddr","agencytel","budget","entidlist","buyerperson","winnerperson","agencyaddr","recommended_service","competehref","owner","total_investment","projectaddr","projectperiod","approvedept","approvecontent","approvecode","approvenumber","approvetime","approvestatus","project_scale"],"sort":[],"aggs":{}}`, strings.Join(idArr, `","`)))
  417. if aobj != nil && len(*aobj) > 0 || *aobj != nil {
  418. for _, v := range *aobj {
  419. id := common.InterfaceToStr(v["_id"])
  420. subtype := common.InterfaceToStr(v["subtype"])
  421. data, ok := infoIdMap[id]
  422. data.Subtype = subtype
  423. if subtype == "拟建" && ok {
  424. project, _ := MC.MgoProject.FindOne("projectset_proposed", map[string]interface{}{
  425. "ids": id,
  426. })
  427. data.Source = 2
  428. if project != nil && len(*project) > 0 {
  429. projectId := common.InterfaceToStr((*project)["_id"])
  430. data.IsNiJian = true
  431. data.ProjectId = projectId
  432. }
  433. }
  434. infoIdMap[id] = data
  435. }
  436. }
  437. }
  438. return table, findKey, employKey, infoIdMap
  439. }
  440. // IgnoreOperate 忽略操作
  441. func (e *EmPloyService) IgnoreOperate(in *types.IgnoreOperateReq) (bool, string) {
  442. //
  443. table := ""
  444. switch in.EmployType {
  445. case 1, 4:
  446. table = entity.EMPLOY_INFO
  447. case 2, 3:
  448. table = entity.EMPLOY_CUSTOM
  449. }
  450. msg := ""
  451. fool := true
  452. for _, v := range strings.Split(in.IdArr, ",") {
  453. id := idFormat(v, in.EmployType)
  454. if id == "" {
  455. log.Println(v, id, in.EmployType, "忽略处理,id解析失败")
  456. continue
  457. }
  458. findMap := map[string]interface{}{
  459. "position_id": in.PositionId,
  460. }
  461. if in.EmployType == 3 || in.EmployType == 2 {
  462. findMap["company_id"] = id
  463. } else {
  464. findMap["source_id"] = id
  465. }
  466. if MC.CrmMysql.Count(table, findMap) == 0 {
  467. log.Println(v, id, in.EmployType, "忽略处理,id所对应数据不存在")
  468. fool = false
  469. if in.EmployType == 1 {
  470. if in.IsIgnore {
  471. msg = "该资讯已有员工收录,不可忽略。"
  472. } else {
  473. msg = "该资讯已有员工收录,不可取消忽略。"
  474. }
  475. } else {
  476. if in.IsIgnore {
  477. msg = "该企业已有员工收录,不可忽略。"
  478. } else {
  479. msg = "该企业已有员工收录,不可取消忽略。"
  480. }
  481. }
  482. continue
  483. }
  484. if in.IsIgnore {
  485. MC.CrmMysql.Update(table, findMap, map[string]interface{}{
  486. "is_ignore": 1,
  487. "is_handle": 1,
  488. })
  489. } else {
  490. MC.CrmMysql.Update(table, findMap, map[string]interface{}{
  491. "is_ignore": 0,
  492. "is_handle": 1,
  493. })
  494. }
  495. }
  496. return fool, msg
  497. }
  498. // DistributePerson 分发操作
  499. func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
  500. return MC.CrmMysql.ExecTx("收录操作", func(tx *sql.Tx) bool {
  501. personMap := map[int64]PersonSmmary{}
  502. //人员信息处理
  503. for _, person := range in.Person {
  504. personMap[person.PositionId] = PersonSmmary{
  505. EntUserId: person.EntUserId,
  506. EntDeptId: person.EntDeptId,
  507. }
  508. }
  509. //分发数据处理
  510. infoMap := map[string]map[string]interface{}{}
  511. onlyMap := map[string]interface{}{}
  512. topMap := map[string]string{}
  513. topEnt := 0
  514. //标讯数据处理
  515. for _, v := range strings.Split(in.EmployIdArr, ",") {
  516. //查询信息
  517. infoDataList := MC.CrmMysql.SelectBySqlByTx(tx, "SELECT * FROM employ_info WHERE id=?", v)
  518. if infoDataList != nil && len(*infoDataList) > 0 {
  519. source_id := common.InterfaceToStr((*infoDataList)[0]["source_id"])
  520. isOut := common.IntAll((*infoDataList)[0]["is_timeout"]) // 拓普 超时未处理标签
  521. //if onlyMap[source_id] == nil {
  522. (*infoDataList)[0]["dis_id"] = v
  523. (*infoDataList)[0]["is_handle"] = 0
  524. (*infoDataList)[0]["is_ignore"] = 0
  525. (*infoDataList)[0]["is_dis"] = 0
  526. (*infoDataList)[0]["is_create_clue"] = 0
  527. (*infoDataList)[0]["is_create_chance"] = 0
  528. (*infoDataList)[0]["is_create_custom"] = 0
  529. (*infoDataList)[0]["create_time"] = time.Now().Format(date.Date_Full_Layout)
  530. delete((*infoDataList)[0], "id")
  531. MC.CrmMysql.UpdateByTx(tx, entity.EMPLOY_INFO, map[string]interface{}{
  532. "id": v,
  533. }, map[string]interface{}{
  534. "is_dis": 1,
  535. "is_handle": 1,
  536. "is_timeout": 0,
  537. })
  538. infoMap[source_id] = (*infoDataList)[0]
  539. onlyMap[source_id] = v
  540. if isOut == 1 {
  541. topMap[source_id] = v
  542. topEnt = common.IntAll((*infoDataList)[0]["ent_id"])
  543. }
  544. //} else {
  545. // log.Println(v, "查询不到改收录信息")
  546. // continue
  547. //}
  548. }
  549. }
  550. // 修改 topnet_info is_timeout
  551. log.Println("修改 topnet_info ", topEnt, topMap)
  552. if topEnt > 0 && len(topMap) > 0 {
  553. for k, _ := range topMap {
  554. c := MC.CrmMysql.Count(entity.EMPLOY_INFO, map[string]interface{}{"source_id": k, "is_timeout": 1, "ent_id": topEnt})
  555. if c <= 0 {
  556. MC.CrmMysql.ExecBySql("UPDATE crm.topnet_info SET is_timeout = 1 WHERE info_id = ?", k)
  557. }
  558. }
  559. }
  560. //普通人员分发
  561. for positionId, personSmmary := range personMap {
  562. //查询时候收录过
  563. for _, v := range infoMap {
  564. //查询时候收录过
  565. findMap := map[string]interface{}{
  566. "position_id": positionId,
  567. "source_id": v["source_id"],
  568. }
  569. if MC.CrmMysql.Count(entity.EMPLOY_INFO, findMap) == 0 {
  570. //新增
  571. v["ent_user_id"] = personSmmary.EntUserId
  572. v["ent_dept_id"] = personSmmary.EntDeptId
  573. v["position_id"] = positionId
  574. MC.CrmMysql.InsertByTx(tx, entity.EMPLOY_INFO, v)
  575. }
  576. }
  577. }
  578. if in.EntNicheDis > 0 {
  579. //查询分配员有没有该数据
  580. for _, v := range infoMap {
  581. //查询时候收录过
  582. findMap := map[string]interface{}{
  583. "position_id": in.PositionId,
  584. "source_id": v["source_id"],
  585. }
  586. employPositionId := v["position_id"]
  587. if employPositionId != in.PositionId {
  588. //分发消息不属于自己
  589. if MC.CrmMysql.Count(entity.EMPLOY_INFO, findMap) == 0 {
  590. v["ent_user_id"] = in.EntUserId
  591. v["position_id"] = in.PositionId
  592. v["is_handle"] = 1
  593. v["ent_dept_id"] = in.EntDeptId
  594. MC.CrmMysql.InsertByTx(tx, entity.EMPLOY_INFO, v)
  595. } else {
  596. MC.CrmMysql.UpdateByTx(tx, entity.EMPLOY_INFO, findMap, map[string]interface{}{
  597. "is_handle": 1,
  598. })
  599. }
  600. }
  601. }
  602. }
  603. return true
  604. })
  605. }
  606. func niJianHandle(infoId string, data map[string]interface{}, v1, pushTime string) map[string]interface{} {
  607. project, _ := MC.MgoProject.FindOne("projectset_proposed", map[string]interface{}{
  608. "ids": infoId,
  609. })
  610. if project != nil && len(*project) > 0 {
  611. city := common.InterfaceToStr((*project)["city"])
  612. area := common.InterfaceToStr((*project)["area"])
  613. category_code := common.InterfaceToStr((*project)["category_code"])
  614. lasttime := common.Int64All((*project)["lasttime"])
  615. ownerclass_code := common.InterfaceToStr((*project)["ownerclass_code"])
  616. total_investment := common.InterfaceToStr((*project)["total_investment"])
  617. project_stage_code := common.InterfaceToStr((*project)["project_stage_code"])
  618. infoList := gconv.SliceMap((*project)["list"])
  619. title := ""
  620. projectname := ""
  621. if len(infoList) > 0 {
  622. title = common.InterfaceToStr(infoList[0]["title"])
  623. projectname = common.InterfaceToStr(infoList[0]["projectname"])
  624. }
  625. category := ""
  626. ownerclass := ""
  627. project_stage := ""
  628. if category_code != "" {
  629. categoryData := MC.NiJian.FindOne("d_nzj_category_code", map[string]interface{}{
  630. "code": category_code,
  631. }, "name", "")
  632. category = common.InterfaceToStr((*categoryData)["name"])
  633. }
  634. if ownerclass_code != "" {
  635. ownerclassData := MC.NiJian.FindOne("d_nzj_ownerclass_code", map[string]interface{}{
  636. "code": ownerclass_code,
  637. }, "name", "")
  638. ownerclass = common.InterfaceToStr((*ownerclassData)["name"])
  639. }
  640. if project_stage_code != "" {
  641. projectStageData := MC.NiJian.FindOne("d_nzj_project_stage_code", map[string]interface{}{
  642. "code": project_stage_code,
  643. }, "name", "")
  644. project_stage = common.InterfaceToStr((*projectStageData)["name"])
  645. }
  646. data["title"] = title
  647. data["city"] = city
  648. data["area"] = area
  649. data["projectname"] = projectname
  650. data["ownerclass"] = ownerclass
  651. data["project_stage"] = project_stage
  652. data["project_category"] = category
  653. data["project_investment"] = total_investment
  654. lastTimeStr := common.If(lasttime == 0, pushTime, time.Unix(lasttime, 0).Format(date.Date_Full_Layout))
  655. data["project_evolve"] = lastTimeStr
  656. data["show_time"] = lastTimeStr
  657. data["publishtime"] = lastTimeStr
  658. pid := common.InterfaceToStr((*project)["_id"])
  659. data["jybx_url"] = "/succbi/nzj/app/nzj.app/nzj_detail_0.spg?pid=" + pid
  660. data["source"] = 2
  661. data["source_id"] = pid
  662. } else {
  663. data["source"] = 1
  664. data["source_id"] = infoId
  665. data["jybx_url"] = "/article/content/" + v1 + ".html"
  666. }
  667. return data
  668. }
  669. // 个人收录情况查询
  670. func employInfoPerson(table, employKey, findKey string, in *types.InfoEmployinfoReq, version int, infoId1Arr, infoId2Arr, niJianIdArr, wuye1Arr, wuye2Arr []string) map[string]map[string]interface{} {
  671. //
  672. data := map[string]map[string]interface{}{}
  673. infoData1 := &[]map[string]interface{}{}
  674. infoData2 := &[]map[string]interface{}{}
  675. niJianData := &[]map[string]interface{}{}
  676. wuyeData1 := &[]map[string]interface{}{}
  677. wuyeData2 := &[]map[string]interface{}{}
  678. orderKey := "type"
  679. if employKey == "company_id" {
  680. orderKey = "source"
  681. }
  682. if len(infoId1Arr) > 0 {
  683. infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, is_ignore,status,id,%s from %s where position_id =? and %s in ('%s') GROUP BY %s ,%s order by %s ", employKey, orderKey, table, employKey, strings.Join(infoId1Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
  684. }
  685. if len(infoId2Arr) > 0 {
  686. infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, is_ignore,status,id,%s from %s where position_id =? and %s in ('%s') GROUP BY %s ,%s order by %s ", employKey, orderKey, table, employKey, strings.Join(infoId2Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
  687. }
  688. if len(niJianIdArr) > 0 {
  689. niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, is_ignore,status,id,%s from %s where position_id =? and %s in ('%s') GROUP BY %s ,%s order by %s ", employKey, orderKey, table, employKey, strings.Join(niJianIdArr, "','"), employKey, orderKey, orderKey), in.PositionId)
  690. }
  691. if len(wuye1Arr) > 0 {
  692. wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, is_ignore,status,id,%s from %s where position_id =? and %s in ('%s') GROUP BY %s ,%s order by %s ", employKey, orderKey, table, employKey, strings.Join(wuye1Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
  693. }
  694. if len(wuye2Arr) > 0 {
  695. wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, is_ignore,status,id,%s from %s where position_id =? and %s in ('%s') GROUP BY %s ,%s order by %s ", employKey, orderKey, table, employKey, strings.Join(wuye2Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
  696. }
  697. for _, v := range *infoData1 {
  698. valueMap := map[string]interface{}{
  699. "id": v,
  700. "isIgnore": false,
  701. "isEmploy": false,
  702. "customCount": 0,
  703. "clueCount": 0,
  704. "chanceCount": 0,
  705. "type": 1,
  706. }
  707. sourceId := gconv.String(v[employKey])
  708. if _, ok := data[sourceId]; ok {
  709. data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  710. } else {
  711. data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  712. }
  713. }
  714. for _, v := range *infoData2 {
  715. valueMap := map[string]interface{}{
  716. "id": v,
  717. "isIgnore": false,
  718. "isEmploy": false,
  719. "customCount": 0,
  720. "clueCount": 0,
  721. "chanceCount": 0,
  722. "type": 1,
  723. }
  724. sourceId := gconv.String(v[employKey])
  725. if _, ok := data[sourceId]; ok {
  726. data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  727. } else {
  728. data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  729. }
  730. }
  731. for _, v := range *niJianData {
  732. valueMap := map[string]interface{}{
  733. "id": v,
  734. "isIgnore": false,
  735. "isEmploy": false,
  736. "customCount": 0,
  737. "clueCount": 0,
  738. "chanceCount": 0,
  739. "type": 1,
  740. }
  741. sourceId := gconv.String(v[employKey])
  742. if _, ok := data[sourceId]; ok {
  743. data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  744. } else {
  745. data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  746. }
  747. }
  748. for _, v := range *wuyeData1 {
  749. valueMap := map[string]interface{}{
  750. "id": v,
  751. "isIgnore": false,
  752. "isEmploy": false,
  753. "customCount": 0,
  754. "clueCount": 0,
  755. "chanceCount": 0,
  756. "type": 1,
  757. }
  758. sourceId := gconv.String(v[employKey])
  759. if _, ok := data[sourceId]; ok {
  760. data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  761. } else {
  762. data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  763. }
  764. }
  765. for _, v := range *wuyeData2 {
  766. valueMap := map[string]interface{}{
  767. "id": v,
  768. "isIgnore": false,
  769. "isEmploy": false,
  770. "customCount": 0,
  771. "clueCount": 0,
  772. "chanceCount": 0,
  773. "type": 1,
  774. }
  775. sourceId := gconv.String(v[employKey])
  776. if _, ok := data[sourceId]; ok {
  777. data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  778. } else {
  779. data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  780. }
  781. }
  782. return data
  783. }
  784. // 企业收录情况查询
  785. func employInfoEnt(table, employKey, findKey, depIDArr string, in *types.InfoEmployinfoReq, version int, infoId1Arr, infoId2Arr, niJianIdArr, wuye1Arr, wuye2Arr []string) map[string]map[string]interface{} {
  786. data := map[string]map[string]interface{}{}
  787. infoData1 := &[]map[string]interface{}{}
  788. infoData2 := &[]map[string]interface{}{}
  789. niJianData := &[]map[string]interface{}{}
  790. wuyeData1 := &[]map[string]interface{}{}
  791. wuyeData2 := &[]map[string]interface{}{}
  792. orderKey := "type"
  793. if employKey == "company_id" {
  794. orderKey = "source"
  795. }
  796. if len(infoId1Arr) > 0 {
  797. infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,GROUP_CONCAT(id) as employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status,%s from %s where %s in ('%s') and source=? and ent_dept_id in (%s) GROUP BY %s ,%s order by %s", employKey, orderKey, table, employKey, strings.Join(infoId1Arr, "','"), depIDArr, employKey, orderKey, orderKey), 1)
  798. }
  799. if len(infoId2Arr) > 0 {
  800. infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status,%s from %s where %s in ('%s') and source=? and ent_dept_id in (%s) GROUP BY %s ,%s order by %s", employKey, orderKey, table, employKey, strings.Join(infoId2Arr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
  801. }
  802. if len(niJianIdArr) > 0 {
  803. niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status,%s from %s where %s in ('%s') and source=? and ent_dept_id in (%s) GROUP BY %s ,%s order by %s", employKey, orderKey, table, employKey, strings.Join(niJianIdArr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
  804. }
  805. if len(wuye1Arr) > 0 {
  806. wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, id,is_ignore,status,%s from %s where %s in ('%s') and status =1 and source=? and ent_dept_id in (%s) GROUP BY %s ,%s order by %s", employKey, orderKey, table, employKey, strings.Join(wuye1Arr, "','"), depIDArr, employKey, orderKey, orderKey), 1)
  807. }
  808. if len(wuye2Arr) > 0 {
  809. wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, id,is_ignore,status,%s from %s where %s in ('%s') and status =1 and source=? and ent_dept_id in (%s) GROUP BY %s ,%s order by %s", employKey, orderKey, table, employKey, strings.Join(wuye2Arr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
  810. }
  811. for _, v := range *infoData1 {
  812. valueMap := map[string]interface{}{
  813. "id": v,
  814. "isIgnore": false,
  815. "isEmploy": false,
  816. "customCount": 0,
  817. "clueCount": 0,
  818. "chanceCount": 0,
  819. "type": 1,
  820. }
  821. sourceId := gconv.String(v[employKey])
  822. if _, ok := data[sourceId]; ok {
  823. data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  824. } else {
  825. data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  826. }
  827. }
  828. for _, v := range *infoData2 {
  829. valueMap := map[string]interface{}{
  830. "id": v,
  831. "isIgnore": false,
  832. "isEmploy": false,
  833. "customCount": 0,
  834. "clueCount": 0,
  835. "chanceCount": 0,
  836. "type": 1,
  837. }
  838. sourceId := gconv.String(v[employKey])
  839. if _, ok := data[sourceId]; ok {
  840. data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  841. } else {
  842. data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  843. }
  844. }
  845. for _, v := range *niJianData {
  846. valueMap := map[string]interface{}{
  847. "id": v,
  848. "isIgnore": false,
  849. "isEmploy": false,
  850. "customCount": 0,
  851. "clueCount": 0,
  852. "chanceCount": 0,
  853. "type": 1,
  854. }
  855. sourceId := gconv.String(v[employKey])
  856. if _, ok := data[sourceId]; ok {
  857. data[sourceId] = EmployHandle(data[sourceId], v, version, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  858. } else {
  859. data[sourceId] = EmployHandle(valueMap, v, version, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  860. }
  861. }
  862. for _, v := range *wuyeData1 {
  863. valueMap := map[string]interface{}{
  864. "id": v,
  865. "isIgnore": false,
  866. "isEmploy": false,
  867. "customCount": 0,
  868. "clueCount": 0,
  869. "chanceCount": 0,
  870. "type": 1,
  871. }
  872. sourceId := gconv.String(v[employKey])
  873. if _, ok := data[sourceId]; ok {
  874. data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  875. } else {
  876. data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  877. }
  878. }
  879. for _, v := range *wuyeData2 {
  880. valueMap := map[string]interface{}{
  881. "id": v,
  882. "isIgnore": false,
  883. "isEmploy": false,
  884. "customCount": 0,
  885. "clueCount": 0,
  886. "chanceCount": 0,
  887. "type": 1,
  888. }
  889. sourceId := gconv.String(v[employKey])
  890. if _, ok := data[sourceId]; ok {
  891. data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  892. } else {
  893. data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  894. }
  895. }
  896. return data
  897. }
  898. func EmployHandle(valueMap map[string]interface{}, employData map[string]interface{}, version int, originate string, single bool, findKey string, positionId, positionType, inEmployType int64) map[string]interface{} {
  899. employType := common.Int64All(employData["type"])
  900. employStatus := common.Int64All(employData["status"])
  901. employ2 := false
  902. employ3 := false
  903. employIgnore := false
  904. employId := int64(0)
  905. is_ignore := int64(0)
  906. employArrStr := ""
  907. //收录标识处理
  908. if common.Int64All(employData["id"]) == 0 {
  909. if len(gconv.String(employData["employIdArr"])) > 0 {
  910. employArrStr = gconv.String(employData["employIdArr"])
  911. employId = gconv.Int64(strings.Split(employArrStr, ",")[0])
  912. }
  913. } else {
  914. employId = common.Int64All(employData["id"])
  915. }
  916. if version == 1 {
  917. is_ignore = common.Int64All(employData["is_ignore"])
  918. switch employType {
  919. case 2:
  920. if valueMap["employ3"] != nil {
  921. employ3 = gconv.Bool(valueMap["employ3"])
  922. }
  923. if employStatus == 1 {
  924. employ2 = true
  925. }
  926. case 3:
  927. if valueMap["employ2"] != nil {
  928. employ2 = gconv.Bool(valueMap["employ2"])
  929. }
  930. if employStatus == 1 {
  931. employ3 = true
  932. }
  933. }
  934. if is_ignore > 0 {
  935. employIgnore = true
  936. }
  937. employType = common.Int64All(employData["type"])
  938. valueMap["isIgnore"] = employIgnore
  939. if originate == "jhfp" {
  940. valueMap["isEmploy"] = employ3
  941. } else {
  942. valueMap["isEmploy"] = common.If(employ2 && employ3, true, false)
  943. }
  944. valueMap["type"] = employType
  945. valueMap["employ2"] = employ2
  946. valueMap["employ3"] = employ3
  947. valueMap["employId"] = employId
  948. } else {
  949. valueMap["isIgnore"] = common.If(common.Int64All(employData["is_ignore"]) == 1, true, false)
  950. valueMap["isEmploy"] = common.If(common.Int64All(employData["status"]) == 1, true, false)
  951. valueMap["type"] = common.Int64All(employData["type"])
  952. valueMap["employId"] = employId
  953. }
  954. if employType == 2 {
  955. valueMap["intelligenceId"] = employId
  956. }
  957. if single && employArrStr != "" {
  958. //列表查询
  959. //是否忽略处理
  960. //客户数量
  961. customSql := ""
  962. clueSql := ""
  963. chanceSql := ""
  964. if positionType == 0 {
  965. customSql = fmt.Sprintf("select COUNT(1) from %s where %s in (%s) and position_id=%d", entity.CUSTOM, findKey, employArrStr, positionId)
  966. clueSql = fmt.Sprintf("select COUNT(1) from %s where employ_info_id in (%s) and position_id=%d", entity.SALE_CLUE, employArrStr, positionId)
  967. chanceSql = fmt.Sprintf("select COUNT(1) from %s where employ_info_id in (%s) and position_id=%d", entity.SALE_CHANCE, employArrStr, positionId)
  968. } else {
  969. customSql = fmt.Sprintf("select COUNT(1) from %s where %s in (%s)", entity.CUSTOM, findKey, employArrStr)
  970. clueSql = fmt.Sprintf("select COUNT(1) from %s where employ_info_id in (%s)", entity.SALE_CLUE, employArrStr)
  971. chanceSql = fmt.Sprintf("select COUNT(1) from %s where employ_info_id in (%s)", entity.SALE_CHANCE, employArrStr)
  972. }
  973. customCount := MC.CrmMysql.CountBySql(customSql)
  974. valueMap["customCount"] = customCount
  975. if inEmployType == 1 || inEmployType == 4 {
  976. //销售线索数量
  977. clueCount := MC.CrmMysql.CountBySql(clueSql)
  978. valueMap["clueCount"] = clueCount
  979. //销售机会数量
  980. chanceCount := MC.CrmMysql.CountBySql(chanceSql)
  981. valueMap["chanceCount"] = chanceCount
  982. }
  983. } else {
  984. valueMap["chanceCount"] = 0
  985. valueMap["clueCount"] = 0
  986. valueMap["customCount"] = 0
  987. }
  988. return valueMap
  989. }