package service import ( "fmt" "strings" "time" common "app.yhyue.com/moapp/jybase/common" util "app.yhyue.com/moapp/jybase/encrypt" . "bp.jydev.jianyu360.cn/BaseService/biService/entity" "bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice" "github.com/zeromicro/go-zero/core/logx" ) func AddProject(this *biservice.AddProjectReq, addCountLimit int) *biservice.AddProjectResp { infoIdArr := strings.Split(this.InfoId, ",") addCount := JyBiMysql.CountBySql(`select count(1) from dwd_f_report_data_baseinfo where position_id=?`, this.PositionId) if addCount+int64(len(infoIdArr)) > int64(addCountLimit) { return &biservice.AddProjectResp{ ErrorCode: -1, ErrorMsg: "已超过可添加项目总数", Data: &biservice.AddProject{ Status: 0, }, } } for _, v := range infoIdArr { infoid := util.DecodeArticleId2ByCheck(v)[0] logx.Info("infoid", infoid) query := `{"query": {"bool": {"must": [{"term": {"_id": "%s"}}],"must_not": [],"should": []}}}` querys := fmt.Sprintf(query, infoid) data := Es.Get("bidding", "bidding", querys) // logx.Info("data", data) if data != nil && *data != nil && len(*data) > 0 { project := (*data)[0] nowTime := time.Now().Format("2006-01-02 15:04:05") area := common.ObjToString(project["area"]) city := common.ObjToString(project["city"]) district := common.ObjToString(project["district"]) area_code, province_code, city_code, district_code := "", "", "", "" if area != "" && city != "" && district != "" { c := area + "," + city + "," + district area_code = AreaCode[c] district_code = AreaCode[c] } else if area != "" && city != "" { c := area + "," + city area_code = AreaCode[c] } else if area != "" { area_code = AreaCode[area] } if area != "" { province_code = AreaCode[area] } if area != "" && city != "" { c := area + "," + city city_code = AreaCode[c] } bidstatus := 1 publishtime := common.Int64All(project["publishtime"]) if common.ObjToString(project["s_winner"]) != "" { bidstatus = 0 } JyBiMysql.Insert("dwd_f_report_data_baseinfo", map[string]interface{}{ "infoid": infoid, "position_id": this.PositionId, "position_type": 0, "account_id": this.AccountId, "company_name": this.CompanyName, "user_id": this.UserId, "user_name": this.EntUserName, "ent_id": this.EntId, "status": 0, "projectname": common.ObjToString(project["projectname"]), "bidamount": common.Float64All(project["bidamount"]), "bidamount_private": common.Float64All(project["bidamount"]), "bidstatus": bidstatus, "updatetime": nowTime, "createtime": nowTime, "publishtime": time.Unix(publishtime, 0).Format("2006-01-02 15:04:05"), "jg_year": time.Unix(publishtime, 0).Format("2006"), "jg_y_month": time.Unix(publishtime, 0).Format("200601"), "jg_y_m_day": time.Unix(publishtime, 0).Format("20060102"), "source": this.Source, "buyer": common.ObjToString(project["buyer"]), "s_winner": common.ObjToString(project["s_winner"]), "area_code": area_code, "province_code": province_code, "city_code": city_code, "district_code": district_code, "jybxhref": `https://www.jianyu360.cn/article/content/` + util.CommonEncodeArticle("content", infoid) + `.html`, }) } else { return &biservice.AddProjectResp{ ErrorCode: -1, ErrorMsg: "未查询到数据", Data: &biservice.AddProject{ Status: 0, }, } } } return &biservice.AddProjectResp{ ErrorCode: 0, Data: &biservice.AddProject{ Status: 1, }, } } func MyDataAsset(this *biservice.MyDataAssetReq) *biservice.MyDataAssetResp { collectInfoCount, followProjectCount, collectDocCount, claimCustomerCount, claimNzjCount := int64(0), int64(0), int64(0), int64(0), int64(0) collectInfoCount = JyMysql.CountBySql(`select count(1) from bdcollection where userid=?`, this.UserId) followProjectCount = JyTidb.CountBySql(`select count(1) from follow_project_monitor where s_userid=?`, this.UserId) claimCustomerCount = JyMysql.CountBySql(`select count(1) from entniche_user_customer where user_id=?`, this.EntUserId) collectDocCount = JyDocMysql.CountBySql(`select count(1) from user_doc where userId=? and docCategory=2 and isDelete=0`, this.UserId) claimNzjCount = JyBiTidb.CountBySql(`select count(1) from dwd_f_user_claim where user_id=? and status=0 and source_type=1`, this.NewUserId) return &biservice.MyDataAssetResp{ ErrorCode: 0, Data: &biservice.MyDataAsset{ CollectInfoCount: collectInfoCount, FollowProjectCount: followProjectCount, CollectDocCount: collectDocCount, ClaimCustomerCount: claimCustomerCount, ClaimNzjCount: claimNzjCount, }, } } func GetInfoId(this *biservice.AddProjectReq) *biservice.GetInfoIdResp { data := JyBiMysql.Find("dwd_f_report_data_baseinfo", map[string]interface{}{"position_id": this.PositionId}, "", "", -1, -1) dataArr := []string{} if data != nil && len(*data) > 0 { for _, v := range *data { infoid := util.EncodeArticleId2ByCheck(common.ObjToString(v["infoid"])) dataArr = append(dataArr, infoid) } } return &biservice.GetInfoIdResp{ ErrorCode: 0, Data: dataArr, } }