yearEndReport.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package service
  2. import (
  3. "fmt"
  4. "strings"
  5. "time"
  6. common "app.yhyue.com/moapp/jybase/common"
  7. util "app.yhyue.com/moapp/jybase/encrypt"
  8. . "bp.jydev.jianyu360.cn/BaseService/biService/entity"
  9. "bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. func AddProject(this *biservice.AddProjectReq, addCountLimit int) *biservice.AddProjectResp {
  13. infoIdArr := strings.Split(this.InfoId, ",")
  14. addCount := JyBiMysql.CountBySql(`select count(1) from dwd_f_report_data_baseinfo where position_id=?`, this.PositionId)
  15. if addCount+int64(len(infoIdArr)) > int64(addCountLimit) {
  16. return &biservice.AddProjectResp{
  17. ErrorCode: -1,
  18. ErrorMsg: "已超过可添加项目总数",
  19. Data: &biservice.AddProject{
  20. Status: 0,
  21. },
  22. }
  23. }
  24. for _, v := range infoIdArr {
  25. infoid := util.DecodeArticleId2ByCheck(v)[0]
  26. logx.Info("infoid", infoid)
  27. query := `{"query": {"bool": {"must": [{"term": {"_id": "%s"}}],"must_not": [],"should": []}}}`
  28. querys := fmt.Sprintf(query, infoid)
  29. data := Es.Get("bidding", "bidding", querys)
  30. // logx.Info("data", data)
  31. if data != nil && *data != nil && len(*data) > 0 {
  32. project := (*data)[0]
  33. nowTime := time.Now().Format("2006-01-02 15:04:05")
  34. area := common.ObjToString(project["area"])
  35. city := common.ObjToString(project["city"])
  36. district := common.ObjToString(project["district"])
  37. area_code, province_code, city_code, district_code := "", "", "", ""
  38. if area != "" && city != "" && district != "" {
  39. c := area + "," + city + "," + district
  40. area_code = AreaCode[c]
  41. district_code = AreaCode[c]
  42. } else if area != "" && city != "" {
  43. c := area + "," + city
  44. area_code = AreaCode[c]
  45. } else if area != "" {
  46. area_code = AreaCode[area]
  47. }
  48. if area != "" {
  49. province_code = AreaCode[area]
  50. }
  51. if area != "" && city != "" {
  52. c := area + "," + city
  53. city_code = AreaCode[c]
  54. }
  55. bidstatus := 1
  56. publishtime := common.Int64All(project["publishtime"])
  57. if common.ObjToString(project["s_winner"]) != "" {
  58. bidstatus = 0
  59. }
  60. JyBiMysql.Insert("dwd_f_report_data_baseinfo", map[string]interface{}{
  61. "infoid": infoid,
  62. "position_id": this.PositionId,
  63. "position_type": 0,
  64. "account_id": this.AccountId,
  65. "company_name": this.CompanyName,
  66. "user_id": this.UserId,
  67. "user_name": this.EntUserName,
  68. "ent_id": this.EntId,
  69. "status": 0,
  70. "projectname": common.ObjToString(project["projectname"]),
  71. "bidamount": common.Float64All(project["bidamount"]),
  72. "bidamount_private": common.Float64All(project["bidamount"]),
  73. "bidstatus": bidstatus,
  74. "updatetime": nowTime,
  75. "createtime": nowTime,
  76. "publishtime": time.Unix(publishtime, 0).Format("2006-01-02 15:04:05"),
  77. "jg_year": time.Unix(publishtime, 0).Format("2006"),
  78. "jg_y_month": time.Unix(publishtime, 0).Format("200601"),
  79. "jg_y_m_day": time.Unix(publishtime, 0).Format("20060102"),
  80. "source": this.Source,
  81. "buyer": common.ObjToString(project["buyer"]),
  82. "s_winner": common.ObjToString(project["s_winner"]),
  83. "area_code": area_code,
  84. "province_code": province_code,
  85. "city_code": city_code,
  86. "district_code": district_code,
  87. "jybxhref": `https://www.jianyu360.cn/article/content/` + util.CommonEncodeArticle("content", infoid) + `.html`,
  88. })
  89. } else {
  90. return &biservice.AddProjectResp{
  91. ErrorCode: -1,
  92. ErrorMsg: "未查询到数据",
  93. Data: &biservice.AddProject{
  94. Status: 0,
  95. },
  96. }
  97. }
  98. }
  99. return &biservice.AddProjectResp{
  100. ErrorCode: 0,
  101. Data: &biservice.AddProject{
  102. Status: 1,
  103. },
  104. }
  105. }
  106. func MyDataAsset(this *biservice.MyDataAssetReq) *biservice.MyDataAssetResp {
  107. collectInfoCount, followProjectCount, collectDocCount, claimCustomerCount, claimNzjCount := int64(0), int64(0), int64(0), int64(0), int64(0)
  108. collectInfoCount = JyMysql.CountBySql(`select count(1) from bdcollection where userid=?`, this.UserId)
  109. followProjectCount = JyTidb.CountBySql(`select count(1) from follow_project_monitor where s_userid=?`, this.UserId)
  110. claimCustomerCount = JyMysql.CountBySql(`select count(1) from entniche_user_customer where user_id=?`, this.EntUserId)
  111. collectDocCount = JyDocMysql.CountBySql(`select count(1) from user_doc where userId=? and docCategory=2 and isDelete=0`, this.UserId)
  112. claimNzjCount = JyBiTidb.CountBySql(`select count(1) from dwd_f_user_claim where user_id=? and status=0 and source_type=1`, this.NewUserId)
  113. return &biservice.MyDataAssetResp{
  114. ErrorCode: 0,
  115. Data: &biservice.MyDataAsset{
  116. CollectInfoCount: collectInfoCount,
  117. FollowProjectCount: followProjectCount,
  118. CollectDocCount: collectDocCount,
  119. ClaimCustomerCount: claimCustomerCount,
  120. ClaimNzjCount: claimNzjCount,
  121. },
  122. }
  123. }
  124. func GetInfoId(this *biservice.AddProjectReq) *biservice.GetInfoIdResp {
  125. data := JyBiMysql.Find("dwd_f_report_data_baseinfo", map[string]interface{}{"position_id": this.PositionId}, "", "", -1, -1)
  126. dataArr := []string{}
  127. if data != nil && len(*data) > 0 {
  128. for _, v := range *data {
  129. infoid := util.EncodeArticleId2ByCheck(common.ObjToString(v["infoid"]))
  130. dataArr = append(dataArr, infoid)
  131. }
  132. }
  133. return &biservice.GetInfoIdResp{
  134. ErrorCode: 0,
  135. Data: dataArr,
  136. }
  137. }