|
@@ -3,11 +3,12 @@ package main
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "gopkg.in/mgo.v2/bson"
|
|
|
"log"
|
|
|
mu "mfw/util"
|
|
|
-
|
|
|
"qfw/util"
|
|
|
"regexp"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
"sync"
|
|
|
"time"
|
|
@@ -229,25 +230,12 @@ func (p *ProjectTask) clearMem() {
|
|
|
}
|
|
|
})
|
|
|
c.Start()
|
|
|
- select {}
|
|
|
}
|
|
|
|
|
|
//全量合并
|
|
|
func (p *ProjectTask) taskQl(udpInfo map[string]interface{}) {
|
|
|
defer util.Catch()
|
|
|
- //1、检查pubilshtime索引
|
|
|
- db, _ := udpInfo["db"].(string)
|
|
|
- if db == "" {
|
|
|
- db = MongoTool.DbName
|
|
|
- }
|
|
|
- coll, _ := udpInfo["coll"].(string)
|
|
|
- if coll == "" {
|
|
|
- coll = ExtractColl
|
|
|
- }
|
|
|
- thread := util.IntAllDef(Thread, 4)
|
|
|
- if thread > 0 {
|
|
|
- p.thread = thread
|
|
|
- }
|
|
|
+ p.thread = util.IntAllDef(Thread, 4)
|
|
|
q, _ := udpInfo["query"].(map[string]interface{})
|
|
|
if q == nil {
|
|
|
q = map[string]interface{}{}
|
|
@@ -271,7 +259,7 @@ func (p *ProjectTask) taskQl(udpInfo map[string]interface{}) {
|
|
|
}
|
|
|
//生成查询语句执行
|
|
|
log.Println("查询语句:", q)
|
|
|
- p.enter(db, coll, q)
|
|
|
+ p.enter(MongoTool.DbName, ExtractColl, q)
|
|
|
|
|
|
}
|
|
|
|
|
@@ -351,6 +339,179 @@ func (p *ProjectTask) taskUpdateInfo(udpInfo map[string]interface{}) {
|
|
|
p.enter(db, coll, q)
|
|
|
}
|
|
|
|
|
|
+//修改公告信息的预算/中标金额
|
|
|
+func (p *ProjectTask) taskUpdateMoney(udpInfo map[string]interface{}) {
|
|
|
+ defer util.Catch()
|
|
|
+ id := udpInfo["id"].(string)
|
|
|
+ budget := util.ObjToString(udpInfo["budget"])
|
|
|
+ bidamount := util.ObjToString(udpInfo["bidamount"])
|
|
|
+ if budget == "" && bidamount == "" {
|
|
|
+ util.Debug("")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ client := Es.GetEsConn()
|
|
|
+ defer Es.DestoryEsConn(client)
|
|
|
+ esquery := `{"query": {"bool": {"must": [{"term": {"list.infoid": "`+id+`"}}]}}}`
|
|
|
+ data := Es.Get(Index, Itype, esquery)
|
|
|
+ util.Debug(*data)
|
|
|
+ if data != nil {
|
|
|
+ pid := util.ObjToString((*data)[0]["_id"])
|
|
|
+ pro := MongoTool.FindById(ProjectColl, pid)
|
|
|
+ var info *map[string]interface{}
|
|
|
+ for _, v := range []interface{}(pro["list"].(primitive.A)){
|
|
|
+ v1 := v.(map[string]interface{})
|
|
|
+ if util.ObjToString(v1["infoid"]) == id {
|
|
|
+ info = util.ObjToMap(v)
|
|
|
+ infoField := util.ObjToMap(pro["infofield"])
|
|
|
+ if budget != "" {
|
|
|
+ if budget != "del" {
|
|
|
+ newBudget, _ := strconv.ParseFloat(budget, 64)
|
|
|
+ if pro["budget"] == (*info)["budget"] {
|
|
|
+ pro["budget"] = newBudget
|
|
|
+ }
|
|
|
+ if util.IntAll(pro["multipackage"]) == 1 {
|
|
|
+ if packages, ok := pro["package"].(map[string]interface{}); ok {
|
|
|
+ M :
|
|
|
+ for _, v := range packages{
|
|
|
+ v1 := []interface{}(v.(primitive.A))
|
|
|
+ for _, v2 := range v1{
|
|
|
+ v3 := v2.(map[string]interface{})
|
|
|
+ if util.ObjToString(v3["infoid"]) == id {
|
|
|
+ if v3["budget"] != nil {
|
|
|
+ v3["budget"] = newBudget
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ break M
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if pro["sortprice"] == (*info)["budget"] {
|
|
|
+ pro["sortprice"] = newBudget
|
|
|
+ }
|
|
|
+ (*info)["budget"] = newBudget
|
|
|
+ (*util.ObjToMap((*infoField)[id]))["budget"] = newBudget
|
|
|
+ }else {
|
|
|
+ delete(*info, "budget")
|
|
|
+ delete(*util.ObjToMap((*infoField)[id]), "budget")
|
|
|
+ if pro["budget"] == (*info)["budget"] {
|
|
|
+ money := FindMoney("budget", pro)
|
|
|
+ if money >= 0 {
|
|
|
+ pro["budget"] = money
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if bidamount != "" {
|
|
|
+ if bidamount != "del" {
|
|
|
+ newBidamount, _ := strconv.ParseFloat(bidamount, 64)
|
|
|
+ if pro["bidamount"] == (*info)["bidamount"] {
|
|
|
+ pro["bidamount"] = newBidamount
|
|
|
+ }
|
|
|
+ if util.IntAll(pro["multipackage"]) == 1 {
|
|
|
+ if packages, ok := pro["package"].(map[string]interface{}); ok {
|
|
|
+ N :
|
|
|
+ for _, v := range packages{
|
|
|
+ v1 := []interface{}(v.(primitive.A))
|
|
|
+ for _, v2 := range v1{
|
|
|
+ v3 := v2.(map[string]interface{})
|
|
|
+ if util.ObjToString(v3["infoid"]) == id {
|
|
|
+ if v3["bidamount"] != nil {
|
|
|
+ v3["bidamount"] = newBidamount
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ break N
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if pro["sortprice"] == (*info)["bidamount"] {
|
|
|
+ pro["sortprice"] = newBidamount
|
|
|
+ }
|
|
|
+ (*info)["bidamount"] = newBidamount
|
|
|
+ (*util.ObjToMap((*infoField)[id]))["bidamount"] = newBidamount
|
|
|
+ }else {
|
|
|
+ delete((*info), "bidamount")
|
|
|
+ delete((*util.ObjToMap((*infoField)[id])), "bidamount")
|
|
|
+ if pro["bidamount"] == (*info)["bidamount"] {
|
|
|
+ money := FindMoney("bidamount", pro)
|
|
|
+ if money >= 0 {
|
|
|
+ pro["bidamount"] = money
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var project *ProjectInfo
|
|
|
+ var pInfo *Info
|
|
|
+ bys, _ := json.Marshal(pro)
|
|
|
+ _ = json.Unmarshal(bys, &project)
|
|
|
+ bys1, _ := json.Marshal(info)
|
|
|
+ _ = json.Unmarshal(bys1, &pInfo)
|
|
|
+ CountAmount(project, pInfo, *info)
|
|
|
+
|
|
|
+ if project.Budget > 0 {
|
|
|
+ util.Debug(project.Budget)
|
|
|
+ pro["budget"] = project.Budget
|
|
|
+ pro["budgettag"] = 0
|
|
|
+ }
|
|
|
+ if project.Bidamount > 0 {
|
|
|
+ util.Debug(project.Bidamount)
|
|
|
+ pro["bidamount"] = project.Bidamount
|
|
|
+ pro["bidamounttag"] = 0
|
|
|
+ }
|
|
|
+ set := map[string]interface{}{
|
|
|
+ "$set": pro,
|
|
|
+ }
|
|
|
+ MongoTool.UpdateById(ProjectColl, pid, set)
|
|
|
+
|
|
|
+ loadStart := util.Int64All(Sysconfig["loadStart"])
|
|
|
+ if loadStart > -1 && project.LastTime >loadStart {
|
|
|
+ util.Debug("内存中存在该项目信息", project.Id)
|
|
|
+ p.AllIdsMapLock.Lock()
|
|
|
+ p.AllIdsMap[pid].P = project
|
|
|
+ p.AllIdsMapLock.Unlock()
|
|
|
+ }
|
|
|
+
|
|
|
+ bol := Es.DelById(Index, Itype, pid)
|
|
|
+ if bol {
|
|
|
+ util.Debug("删除es索引, pid------", pid)
|
|
|
+ //调udp生索引
|
|
|
+ by, _ := json.Marshal(map[string]interface{}{
|
|
|
+ "query": map[string]interface{}{
|
|
|
+ "_id": bson.M{
|
|
|
+ "$gte": pid,
|
|
|
+ "$lte": pid,
|
|
|
+ }},
|
|
|
+ "stype": "project",
|
|
|
+ })
|
|
|
+ _ = udpclient.WriteUdp(by, mu.OP_TYPE_DATA, toaddr[1])
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func FindMoney(key string, project map[string]interface{}) float64 {
|
|
|
+ money := -0.1
|
|
|
+ for i, v := range []interface{}(project["list"].(primitive.A)){
|
|
|
+ v1 := v.(map[string]interface{})
|
|
|
+ if i == 0 {
|
|
|
+ if v1[key] != nil {
|
|
|
+ money = util.Float64All(v1[key])
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if v1[key] != nil && util.Float64All(v1[key]) > money {
|
|
|
+ money = util.Float64All(v1[key])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return money
|
|
|
+}
|
|
|
+
|
|
|
func StringTOBsonId(id string) primitive.ObjectID {
|
|
|
objectId, _ := primitive.ObjectIDFromHex(id)
|
|
|
return objectId
|