|
@@ -3,13 +3,13 @@ package main
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"log"
|
|
|
+ "time"
|
|
|
+
|
|
|
// "log"
|
|
|
"math"
|
|
|
qu "qfw/util"
|
|
|
"sort"
|
|
|
"strings"
|
|
|
- "time"
|
|
|
-
|
|
|
//"gopkg.in/mgo.v2/bson"
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
@@ -456,37 +456,11 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
|
|
|
set[f] = tmp[f]
|
|
|
}
|
|
|
}
|
|
|
- if tmp["budget"] != nil {
|
|
|
- set["budget"] = thisinfo.Budget
|
|
|
- }
|
|
|
- if tmp["bidamount"] != nil {
|
|
|
- set["bidamount"] = thisinfo.Bidamount
|
|
|
- }
|
|
|
bidopentime := qu.Int64All(tmp["bidopentime"])
|
|
|
if bidopentime > 0 {
|
|
|
set["bidopentime"] = bidopentime
|
|
|
}
|
|
|
- if thisinfo.ProjectName != "" {
|
|
|
- set["s_projectname"] = tmp["projectname"]
|
|
|
- }
|
|
|
- now := time.Now().Unix()
|
|
|
- set["createtime"] = now
|
|
|
- set["sourceinfoid"] = thisinfo.Id
|
|
|
- set["sourceinfourl"] = tmp["href"]
|
|
|
- set["firsttime"] = tmp["publishtime"]
|
|
|
- set["lasttime"] = tmp["publishtime"]
|
|
|
- set["pici"] = p.pici
|
|
|
- set["ids"] = []string{thisinfo.Id}
|
|
|
- if thisinfo.TopType == "招标" {
|
|
|
- set["zbtime"] = tmp["publishtime"]
|
|
|
- } else if thisinfo.TopType == "结果" || thisinfo.SubType == "合同" {
|
|
|
- set["jgtime"] = tmp["publishtime"]
|
|
|
- }
|
|
|
- //废标、流标 处理时间
|
|
|
- if thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
|
|
|
- set["zbtime"] = int64(0)
|
|
|
- set["bidopentime"] = int64(0)
|
|
|
- }
|
|
|
+
|
|
|
//异常标记
|
|
|
if thisinfo.TopType != "招标" && thisinfo.TopType != "拟建" && thisinfo.TopType != "预告" {
|
|
|
set["exception"] = 1
|
|
@@ -508,12 +482,14 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
|
|
|
set["bidtype"] = bidtype[bs]
|
|
|
if bt == "招标" {
|
|
|
set["projectscope"] = qu.ObjToString(tmp["projectscope"])
|
|
|
- set["bidstatus"] = bs
|
|
|
+ set["bidstatus"] = bt
|
|
|
}else {
|
|
|
if bidstatus[bs] != "" {
|
|
|
set["bidstatus"] = thisinfo.SubType
|
|
|
} else if tmp["infoformat"] == 2 {
|
|
|
set["bidstatus"] = "拟建"
|
|
|
+ }else if bs == "" {
|
|
|
+ set["bidstatus"] = ""
|
|
|
} else {
|
|
|
set["bidstatus"] = "其它"
|
|
|
}
|
|
@@ -522,10 +498,45 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
|
|
|
|
|
|
pkg := PackageFormat(thisinfo, nil)
|
|
|
p1 := p.NewCachePinfo(pId, thisinfo, bt, pkg)
|
|
|
+
|
|
|
+ now := time.Now().Unix()
|
|
|
+ set["createtime"] = now
|
|
|
+ set["sourceinfoid"] = thisinfo.Id
|
|
|
+ set["sourceinfourl"] = tmp["href"]
|
|
|
+ set["firsttime"] = tmp["publishtime"]
|
|
|
+ set["lasttime"] = tmp["publishtime"]
|
|
|
+ set["pici"] = p.pici
|
|
|
+ set["ids"] = []string{thisinfo.Id}
|
|
|
+ if thisinfo.TopType == "招标" {
|
|
|
+ if thisinfo.SubType != "变更" && thisinfo.SubType != "其它" {
|
|
|
+ set["zbtime"] = tmp["publishtime"]
|
|
|
+ }
|
|
|
+ } else if thisinfo.TopType == "结果" || thisinfo.SubType == "合同" {
|
|
|
+ set["jgtime"] = tmp["publishtime"]
|
|
|
+ p1.Jgtime = thisinfo.Publishtime
|
|
|
+ }
|
|
|
+
|
|
|
if len(thisinfo.Subscopeclass) > 0 {
|
|
|
- s_subscopeclass := strings.Join(thisinfo.Subscopeclass, ",")
|
|
|
- set["s_subscopeclass"] = s_subscopeclass
|
|
|
+ set["s_subscopeclass"] = strings.Join(thisinfo.Subscopeclass, ",")
|
|
|
}
|
|
|
+
|
|
|
+ if tmp["budget"] != nil && tmp["budget"] != "" {
|
|
|
+ set["budget"] = thisinfo.Budget
|
|
|
+ p1.Budgettag = 0
|
|
|
+ set["budgettag"] = 0
|
|
|
+ }else {
|
|
|
+ p1.Budgettag = 1
|
|
|
+ set["budgettag"] = 1
|
|
|
+ }
|
|
|
+ if tmp["bidamount"] != nil && tmp["bidamount"] != "" {
|
|
|
+ set["bidamount"] = thisinfo.Bidamount
|
|
|
+ p1.Bidamounttag = 0
|
|
|
+ set["bidamounttag"] = 0
|
|
|
+ }else {
|
|
|
+ p1.Bidamounttag = 1
|
|
|
+ set["bidamounttag"] = 1
|
|
|
+ }
|
|
|
+
|
|
|
if len(thisinfo.Winners) > 0 {
|
|
|
set["s_winner"] = strings.Join(thisinfo.Winners, ",")
|
|
|
p1.Winners = thisinfo.Winners
|
|
@@ -537,6 +548,10 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
|
|
|
set["multipackage"] = 0
|
|
|
}
|
|
|
|
|
|
+ if thisinfo.Buyer == "" {
|
|
|
+ set["buyerclass"] = ""
|
|
|
+ }
|
|
|
+
|
|
|
p1.InfoFiled = make(map[string]InfoField)
|
|
|
infofiled := InfoField{
|
|
|
Budget: thisinfo.Budget,
|
|
@@ -596,6 +611,7 @@ var INFOFIELDS = []string{
|
|
|
"buyertel",
|
|
|
"area",
|
|
|
"city",
|
|
|
+ "district",
|
|
|
"spidercode",
|
|
|
"site",
|
|
|
}
|
|
@@ -658,22 +674,35 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
}
|
|
|
set := map[string]interface{}{}
|
|
|
pInfo.Ids = append(pInfo.Ids, thisinfo.Id)
|
|
|
-
|
|
|
- //1--firsttime
|
|
|
- if thisinfo.Publishtime < pInfo.FirstTime && thisinfo.Publishtime > 0 {
|
|
|
- pInfo.FirstTime = thisinfo.Publishtime
|
|
|
- set["firsttime"] = thisinfo.Publishtime
|
|
|
- if thisinfo.TopType == "招标" {
|
|
|
- set["zbtime"] = tmp["publishtime"]
|
|
|
- }
|
|
|
+ if len(pInfo.Ids) > 30 {
|
|
|
+ //异常标记
|
|
|
+ set["listtag"] = 1
|
|
|
}
|
|
|
- //2--lasttime
|
|
|
+
|
|
|
+ //zbtime、lasttime、jgtime
|
|
|
pInfo.LastTime = thisinfo.Publishtime
|
|
|
set["lasttime"] = thisinfo.Publishtime
|
|
|
if thisinfo.TopType == "招标" {
|
|
|
- set["zbtime"] = tmp["publishtime"]
|
|
|
- } else if thisinfo.TopType == "结果" || thisinfo.SubType == "合同" {
|
|
|
- set["jgtime"] = tmp["publishtime"]
|
|
|
+ if thisinfo.SubType != "变更" && thisinfo.SubType != "其它" {
|
|
|
+ set["zbtime"] = tmp["publishtime"]
|
|
|
+ }
|
|
|
+ if pInfo.Jgtime > 0 {
|
|
|
+ pInfo.Jgtime = int64(0)
|
|
|
+ set["jgtime"] = int64(0)
|
|
|
+ }
|
|
|
+ }else if thisinfo.TopType == "结果" {
|
|
|
+ pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ set["jgtime"] = thisinfo.Publishtime
|
|
|
+ } else if thisinfo.SubType == "合同" {
|
|
|
+ if pInfo.Jgtime <= 0 {
|
|
|
+ set["jgtime"] = tmp["publishtime"]
|
|
|
+ pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if thisinfo.Bidopentime > pInfo.Bidopentime {
|
|
|
+ pInfo.Bidopentime = thisinfo.Bidopentime
|
|
|
+ set["bidopentime"] = pInfo.Bidopentime
|
|
|
}
|
|
|
|
|
|
bt := qu.ObjToString(tmp["toptype"])
|
|
@@ -687,30 +716,25 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
if tmp["projectscope"] != nil {
|
|
|
set["projectscope"] = qu.ObjToString(tmp["projectscope"])
|
|
|
}
|
|
|
- set["bidstatus"] = bs
|
|
|
+ set["bidstatus"] = bt
|
|
|
+ pInfo.Bidstatus = bt
|
|
|
}else {
|
|
|
if bidstatus[bs] != "" {
|
|
|
set["bidstatus"] = thisinfo.SubType
|
|
|
+ pInfo.Bidstatus = thisinfo.SubType
|
|
|
} else if tmp["infoformat"] == 2 {
|
|
|
set["bidstatus"] = "拟建"
|
|
|
- } else {
|
|
|
+ pInfo.Bidstatus = "拟建"
|
|
|
+ }else if bs == "" {
|
|
|
+ set["bidstatus"] = ""
|
|
|
+ pInfo.Bidstatus = ""
|
|
|
+ }else {
|
|
|
set["bidstatus"] = "其它"
|
|
|
+ pInfo.Bidstatus = "其它"
|
|
|
}
|
|
|
}
|
|
|
p.mapBidLock.Unlock()
|
|
|
|
|
|
- //废标、流标 处理时间
|
|
|
- if thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
|
|
|
- pInfo.FirstTime = thisinfo.Publishtime
|
|
|
- pInfo.Bidopentime = int64(0)
|
|
|
- pInfo.LastTime = thisinfo.Publishtime
|
|
|
-
|
|
|
- set["firsttime"] = thisinfo.Publishtime
|
|
|
- set["zbtime"] = int64(0)
|
|
|
- set["publishtime"] = thisinfo.Publishtime
|
|
|
- set["bidopentime"] = int64(0)
|
|
|
- }
|
|
|
-
|
|
|
//异常标记
|
|
|
if ex > 0 {
|
|
|
set["exception"] = ex
|
|
@@ -775,11 +799,6 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
set["buyertel"] = pInfo.Buyertel
|
|
|
}
|
|
|
|
|
|
- if thisinfo.Bidopentime > pInfo.Bidopentime {
|
|
|
- pInfo.Bidopentime = thisinfo.Bidopentime
|
|
|
- set["bidopentime"] = pInfo.Bidopentime
|
|
|
- }
|
|
|
-
|
|
|
if len(thisinfo.Topscopeclass) > 0 {
|
|
|
sort.Strings(pInfo.Topscopeclass)
|
|
|
for _, k := range thisinfo.Topscopeclass {
|
|
@@ -805,7 +824,7 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
//winner
|
|
|
if len(thisinfo.Winners) > 0 {
|
|
|
if len(pInfo.Winners) <= 0 {
|
|
|
- set["winner"] = tmp["winner"].(string)
|
|
|
+ set["winner"] = qu.ObjToString(tmp["winner"])
|
|
|
}
|
|
|
|
|
|
sort.Strings(pInfo.Winners)
|
|
@@ -826,9 +845,20 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
set["multipackage"] = 0
|
|
|
}
|
|
|
//处理多包后,计算预算金额、中标金额
|
|
|
- CountAmount(pInfo, thisinfo)
|
|
|
- set["budget"] = pInfo.Budget
|
|
|
- set["bidamount"] = pInfo.Bidamount
|
|
|
+ CountAmount(pInfo, thisinfo, tmp)
|
|
|
+ if pInfo.Budget >= 0 && pInfo.Budgettag != 1 {
|
|
|
+ set["budget"] = pInfo.Budget
|
|
|
+ set["budgettag"] = 0
|
|
|
+ }else {
|
|
|
+ set["budgettag"] = 1
|
|
|
+ }
|
|
|
+ if pInfo.Bidamount >= 0 && pInfo.Bidamounttag != 1 {
|
|
|
+ set["bidamount"] = pInfo.Bidamount
|
|
|
+ set["bidamounttag"] = 0
|
|
|
+ }else {
|
|
|
+ set["bidamounttag"] = 1
|
|
|
+ }
|
|
|
+
|
|
|
infofiled := InfoField{
|
|
|
Budget: thisinfo.Budget,
|
|
|
Bidamount: thisinfo.Bidamount,
|
|
@@ -887,7 +917,9 @@ func (p *ProjectTask) CompareStatus(project *ProjectInfo, info *Info) (bool, int
|
|
|
if info.TopType == "拟建" || info.TopType == "预告" || info.TopType == "招标" {
|
|
|
if project.Bidstatus == "拟建" || project.Bidstatus == "预告" || project.Bidstatus == "招标" {
|
|
|
return false, 0
|
|
|
- } else {
|
|
|
+ }else if project.Bidstatus == "废标" || project.Bidstatus == "流标" {
|
|
|
+ return false, 0
|
|
|
+ }else {
|
|
|
return true, 0
|
|
|
}
|
|
|
} else if info.TopType == "结果" {
|
|
@@ -926,10 +958,10 @@ func ComparePlace(project *ProjectInfo, info *Info) bool {
|
|
|
return false
|
|
|
}
|
|
|
if info.Area == project.Area {
|
|
|
- if info.City == "" {
|
|
|
+ if info.City == "" || project.City == "" {
|
|
|
return false
|
|
|
} else if info.City == project.City {
|
|
|
- if info.District == "" || info.District == project.District {
|
|
|
+ if project.District == "" || info.District == "" || info.District == project.District {
|
|
|
return false
|
|
|
} else {
|
|
|
return true
|
|
@@ -1013,28 +1045,34 @@ func PackageFormat(info *Info, project *ProjectInfo) map[string]interface{} {
|
|
|
}
|
|
|
|
|
|
//计算预算(budget)、中标金额(bidamount)
|
|
|
-func CountAmount(project *ProjectInfo, info *Info) {
|
|
|
+func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
|
|
|
if info.HasPackage {
|
|
|
budget := 0.0
|
|
|
for _, v := range project.Package{
|
|
|
v1, _ := v.([]map[string]interface{})
|
|
|
for _, v2 := range v1{
|
|
|
- b1 := qu.Float64All(v2["budget"])
|
|
|
- if b1 > 0 {
|
|
|
- budget = budget + b1
|
|
|
- break
|
|
|
+ if v2["budget"] != nil {
|
|
|
+ b1 := qu.Float64All(v2["budget"])
|
|
|
+ if b1 > 0 {
|
|
|
+ budget = budget + b1
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ project.Budgettag = 1
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- if budget == 0 && info.Budget > 0 {
|
|
|
- budget = info.Budget
|
|
|
- }
|
|
|
if budget > 0 {
|
|
|
project.Budget = budget
|
|
|
+ project.Budgettag = 0
|
|
|
+ }else if budget == 0 && info.Budget > 0 {
|
|
|
+ project.Budget = info.Budget
|
|
|
+ project.Budgettag = 0
|
|
|
}
|
|
|
}else {
|
|
|
//招标没有多包
|
|
|
- k := KeyPackage.FindStringSubmatch(project.ProjectName)
|
|
|
+ k := KeyPackage.FindStringSubmatch(info.ProjectName)
|
|
|
if len(k) > 0 {
|
|
|
//招标是单包
|
|
|
if len(project.Package) > 0 {
|
|
@@ -1048,32 +1086,26 @@ func CountAmount(project *ProjectInfo, info *Info) {
|
|
|
}
|
|
|
if !flag {
|
|
|
project.Budget = project.Budget + info.Budget
|
|
|
+ project.Budgettag = 0
|
|
|
}
|
|
|
}else {
|
|
|
//项目没有多包
|
|
|
if info.Budget > 0 {
|
|
|
project.Budget = project.Budget + info.Budget
|
|
|
+ project.Budgettag = 0
|
|
|
+ }else if info.Budget == 0 && tmp["budget"] != nil {
|
|
|
+ project.Budgettag = 0
|
|
|
+ }else {
|
|
|
+ project.Budgettag = 1
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
- //招标不是单包
|
|
|
- //flag := false
|
|
|
- //if project.InfoFiled != nil && len(project.InfoFiled) > 0 {
|
|
|
- // for _, res := range project.InfoFiled {
|
|
|
- // if res.ProjectName == info.ProjectName {
|
|
|
- // if res.Budget < info.Budget {
|
|
|
- // project.Budget = project.Budget - res.Budget + info.Budget
|
|
|
- // }
|
|
|
- // flag = true
|
|
|
- // break
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if !flag {
|
|
|
- // project.Budget = project.Budget + info.Budget
|
|
|
- // }
|
|
|
- //}
|
|
|
if project.Budget < info.Budget {
|
|
|
project.Budget = info.Budget
|
|
|
+ project.Budgettag = 0
|
|
|
+ }
|
|
|
+ if tmp["budget"] == nil {
|
|
|
+ project.Budgettag = 1
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1083,17 +1115,27 @@ func CountAmount(project *ProjectInfo, info *Info) {
|
|
|
for _, v := range project.Package{
|
|
|
v1, _ := v.([]map[string]interface{})
|
|
|
for _, v2 := range v1{
|
|
|
- b1 := qu.Float64All(v2["bidamount"])
|
|
|
- if b1 > 0 {
|
|
|
- bidamount = bidamount + b1
|
|
|
- break
|
|
|
+ if tmp["bidamount"] != nil {
|
|
|
+ b1 := qu.Float64All(v2["bidamount"])
|
|
|
+ if b1 > 0 {
|
|
|
+ bidamount = bidamount + b1
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ project.Bidamount = 1
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- project.Bidamount = bidamount
|
|
|
+ if bidamount > 0 {
|
|
|
+ project.Bidamount = bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ }else if bidamount == 0 && info.Budget > 0 {
|
|
|
+ project.Bidamount = info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ }
|
|
|
}else {
|
|
|
//招标没有多包
|
|
|
- k := KeyPackage.FindStringSubmatch(project.ProjectName)
|
|
|
+ k := KeyPackage.FindStringSubmatch(info.ProjectName)
|
|
|
if len(k) > 0 {
|
|
|
//招标是单包
|
|
|
if len(project.Package) > 0 {
|
|
@@ -1101,49 +1143,30 @@ func CountAmount(project *ProjectInfo, info *Info) {
|
|
|
flag := false
|
|
|
for _, v := range project.Package{
|
|
|
v1, _ := v.([]map[string]interface{})
|
|
|
- if len(v1) > 0 {
|
|
|
+ if len(v1) > 0 && v1[0]["name"] == info.ProjectName {
|
|
|
flag = true
|
|
|
}
|
|
|
}
|
|
|
if !flag {
|
|
|
project.Bidamount = project.Bidamount + info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
}
|
|
|
}else {
|
|
|
//项目没有多包
|
|
|
if info.Bidamount > 0 {
|
|
|
project.Bidamount = project.Bidamount + info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ }else if info.Bidamount == 0 && tmp["bidamount"] != nil {
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ }else {
|
|
|
+ project.Bidamounttag = 1
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
- //招标不是单包
|
|
|
- //flag := false
|
|
|
- //if project.InfoFiled != nil && len(project.InfoFiled) > 0 {
|
|
|
- // for _, res := range project.InfoFiled {
|
|
|
- // if res.Bidstatus == "合同" && res.ContractCode != "" && info.SubType == "合同" && info.ContractCode != "" {
|
|
|
- // if res.ContractCode == info.ContractCode {
|
|
|
- // if res.Bidamount < info.Bidamount {
|
|
|
- // project.Bidamount = project.Bidamount - res.Bidamount + info.Bidamount
|
|
|
- // }
|
|
|
- // flag = true
|
|
|
- // break
|
|
|
- // }
|
|
|
- // }else {
|
|
|
- // if res.ProjectName == info.ProjectName {
|
|
|
- // if res.Bidamount < info.Bidamount {
|
|
|
- // project.Bidamount = project.Bidamount - res.Bidamount + info.Bidamount
|
|
|
- // }
|
|
|
- // flag = true
|
|
|
- // break
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if !flag {
|
|
|
- // project.Bidamount = project.Bidamount + info.Bidamount
|
|
|
- // }
|
|
|
- //}
|
|
|
if info.SubType == "中标" || info.SubType == "成交" {
|
|
|
if project.Bidamount < info.Bidamount {
|
|
|
project.Bidamount = info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
}else {
|
|
|
flag := false
|
|
|
if project.InfoFiled != nil && len(project.InfoFiled) > 0 {
|
|
@@ -1159,17 +1182,25 @@ func CountAmount(project *ProjectInfo, info *Info) {
|
|
|
}
|
|
|
if !flag {
|
|
|
project.Bidamount = project.Bidamount + info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
}else {
|
|
|
if project.Bidamount < info.Bidamount {
|
|
|
project.Bidamount = info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if tmp["bidamount"] == nil {
|
|
|
+ project.Budgettag = 1
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ }else {
|
|
|
+ project.Bidamounttag = 1
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//结构体转map
|