|
@@ -2,6 +2,8 @@ package main
|
|
|
|
|
|
import (
|
|
|
"log"
|
|
|
+ "strconv"
|
|
|
+
|
|
|
// "log"
|
|
|
"math"
|
|
|
qu "qfw/util"
|
|
@@ -124,7 +126,16 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
|
|
|
//问题出地LastTime!!!!!
|
|
|
diffTime := int64(math.Abs(float64(info.Publishtime - compareProject.LastTime)))
|
|
|
if diffTime <= p.validTime {
|
|
|
- //"A 相等 B 被包含 C 不相等 D不存在 E被包含
|
|
|
+
|
|
|
+ //代理机构完全不相同,直接新建项目
|
|
|
+ if CheckContain(compareProject.Agency, info.Agency) == 3 {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ //地区(省、市、区)不同,直接新建项目
|
|
|
+ if ComparePlace(compareProject, info) {
|
|
|
+ break
|
|
|
+ }
|
|
|
+
|
|
|
info.PNBH = 0
|
|
|
info.PCBH = 0
|
|
|
info.PTCBH = 0
|
|
@@ -142,72 +153,7 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
|
|
|
compareProject.pjVal = pjVal
|
|
|
compareProject.resVal = resVal
|
|
|
//log.Println(compareProject.comStr)
|
|
|
- eqV := 0
|
|
|
- switch resVal {
|
|
|
- case 3:
|
|
|
- if pjVal == 3 && comStr[3:] != "CCCDCCC" {
|
|
|
- eqV = 1
|
|
|
- } else if compareBuyer < "C" {
|
|
|
- if pjVal > 1 {
|
|
|
- eqV = 1
|
|
|
- } else { //if (compareCity[1:1] != "C" || compareTime != "D") && score2 > 0
|
|
|
- eqV = 2
|
|
|
- }
|
|
|
- } else if compareBuyer == "D" {
|
|
|
- if pjVal > 1 && (compareCity[1:1] != "C" || score2 > 0) {
|
|
|
- eqV = 2
|
|
|
- } else if compareCity[1:1] != "C" && compareTime == "A" && score2 > 0 {
|
|
|
- eqV = 3
|
|
|
- }
|
|
|
- } else {
|
|
|
- if pjVal == 3 && (score2 > 0 || compareCity[1:1] != "C") {
|
|
|
- eqV = 2
|
|
|
- } else if pjVal == 2 && compareCity[1:1] != "C" && compareTime == "A" && score2 > 0 {
|
|
|
- eqV = 3
|
|
|
- } else if compareCity == "AA" && compareTime == "A" && score2 > 0 {
|
|
|
- eqV = 3
|
|
|
- }
|
|
|
- }
|
|
|
- case 2:
|
|
|
- if compareBuyer < "C" {
|
|
|
- if pjVal > 1 {
|
|
|
- eqV = 2
|
|
|
- } else if compareCity[1:1] != "C" && compareTime == "A" || score2 > 0 {
|
|
|
- eqV = 3
|
|
|
- }
|
|
|
- } else if compareBuyer == "D" {
|
|
|
- if pjVal > 1 && (score2 > 0 || compareCity[1:1] != "C") {
|
|
|
- eqV = 2
|
|
|
- } else if compareCity[1:1] != "C" && compareTime == "A" && score2 > 0 {
|
|
|
- eqV = 3
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if pjVal > 1 && compareTime == "A" && (score2 > 0 || compareCity[1:1] != "C") {
|
|
|
- eqV = 2
|
|
|
- } else if compareCity[1:1] != "C" && compareTime == "A" && (compareAgency == "A" || score2 > 0) && (compareBudget == "A" || compareBidmount == "A") {
|
|
|
- eqV = 3
|
|
|
- }
|
|
|
- }
|
|
|
- case 1:
|
|
|
- if compareBuyer < "C" {
|
|
|
- if pjVal > 1 && (score2 > 0 || compareCity[1:1] != "C") {
|
|
|
- eqV = 2
|
|
|
- } else if compareCity[1:1] != "C" && compareTime == "A" && (compareAgency == "A" || score2 > 0) && (compareBudget == "A" || compareBidmount == "A") {
|
|
|
- eqV = 3
|
|
|
- }
|
|
|
- } else if compareBuyer == "D" {
|
|
|
- if pjVal > 1 && compareTime == "A" && (score2 > 0 || compareCity[1:1] != "C") {
|
|
|
- eqV = 2
|
|
|
- } else if compareCity[1:1] != "C" && compareTime == "A" && (compareAgency == "A" || score2 > 0) && (compareBudget == "A" || compareBidmount == "A") {
|
|
|
- eqV = 3
|
|
|
- }
|
|
|
- } else {
|
|
|
- if pjVal > 1 && compareTime == "A" && score2 > 0 && (compareBudget == "A" || compareBidmount == "A") && compareCity[1:1] != "C" {
|
|
|
- eqV = 3
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ eqV := compareResult(resVal, pjVal, score2, comStr, compareBuyer, compareCity, compareTime, compareAgency, compareBudget, compareBidmount)
|
|
|
if eqV == 1 {
|
|
|
comRes1 = append(comRes1, compareProject)
|
|
|
} else if eqV == 2 {
|
|
@@ -215,14 +161,11 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
|
|
|
} else if eqV == 3 {
|
|
|
comRes3 = append(comRes3, compareProject)
|
|
|
}
|
|
|
- // else if resVal == 3 || pjVal > 1 {
|
|
|
- // log.Println("===", resVal, pjVal, comStr, info.ProjectCode, compareProject.ProjectCode,
|
|
|
- // info.ProjectName, compareProject.ProjectName, info.Buyer, compareProject.Buyer, info.Id, compareProject.Id.Hex())
|
|
|
- // }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//--------------------------------对比完成-----------------------
|
|
|
+
|
|
|
//更新数组、更新项目
|
|
|
for kv, resN := range [][]*ProjectInfo{comRes1, comRes2, comRes3} {
|
|
|
if len(resN) > 0 {
|
|
@@ -266,13 +209,18 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- p.UpdateProject(tmp, info, resN[0], kv+1, resN[0].comStr)
|
|
|
+ log.Println("pid", findPid)
|
|
|
+ choose, ex := CompareStatus(resN[0], info)
|
|
|
+ if !choose {
|
|
|
+ p.UpdateProject(tmp, info, resN[0], kv+1, resN[0].comStr, ex)
|
|
|
+ }else {
|
|
|
+ bFindProject = false
|
|
|
+ }
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if !bFindProject {
|
|
|
- //没有找到
|
|
|
id, p1 := p.NewProject(tmp, info)
|
|
|
p.AllIdsMapLock.Lock()
|
|
|
p.AllIdsMap[id] = &ID{Id: id, P: p1}
|
|
@@ -281,7 +229,6 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
|
|
|
m.Arr = append(m.Arr, id)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
func (p *ProjectTask) compareBCTABB(info *Info, cp *ProjectInfo, diffTime int64, score int) (compareBuyer, compareCity, compareTime, compareAgency, compareBudget, compareBidmount string, score2 int) {
|
|
@@ -384,6 +331,76 @@ func (p *ProjectTask) compareBCTABB(info *Info, cp *ProjectInfo, diffTime int64,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func compareResult(resVal, pjVal, score2 int, comStr, compareBuyer, compareCity, compareTime, compareAgency, compareBudget, compareBidmount string) int {
|
|
|
+ eqV := 0
|
|
|
+ switch resVal {
|
|
|
+ case 3:
|
|
|
+ if pjVal == 3 && comStr[3:] != "CCCDCCC" {
|
|
|
+ eqV = 1
|
|
|
+ } else if compareBuyer < "C" {
|
|
|
+ if pjVal > 1 {
|
|
|
+ eqV = 1
|
|
|
+ } else { //if (compareCity[1:1] != "C" || compareTime != "D") && score2 > 0
|
|
|
+ eqV = 2
|
|
|
+ }
|
|
|
+ } else if compareBuyer == "D" {
|
|
|
+ if pjVal > 1 && (compareCity[1:1] != "C" || score2 > 0) {
|
|
|
+ eqV = 2
|
|
|
+ } else if compareCity[1:1] != "C" && compareTime == "A" && score2 > 0 {
|
|
|
+ eqV = 3
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if pjVal == 3 && (score2 > 0 || compareCity[1:1] != "C") {
|
|
|
+ eqV = 2
|
|
|
+ } else if pjVal == 2 && compareCity[1:1] != "C" && compareTime == "A" && score2 > 0 {
|
|
|
+ eqV = 3
|
|
|
+ } else if compareCity == "AA" && compareTime == "A" && score2 > 0 {
|
|
|
+ eqV = 3
|
|
|
+ }
|
|
|
+ }
|
|
|
+ case 2:
|
|
|
+ if compareBuyer < "C" {
|
|
|
+ if pjVal > 1 {
|
|
|
+ eqV = 2
|
|
|
+ } else if compareCity[1:1] != "C" && compareTime == "A" || score2 > 0 {
|
|
|
+ eqV = 3
|
|
|
+ }
|
|
|
+ } else if compareBuyer == "D" {
|
|
|
+ if pjVal > 1 && (score2 > 0 || compareCity[1:1] != "C") {
|
|
|
+ eqV = 2
|
|
|
+ } else if compareCity[1:1] != "C" && compareTime == "A" && score2 > 0 {
|
|
|
+ eqV = 3
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if pjVal > 1 && compareTime == "A" && (score2 > 0 || compareCity[1:1] != "C") {
|
|
|
+ eqV = 2
|
|
|
+ } else if compareCity[1:1] != "C" && compareTime == "A" && (compareAgency == "A" || score2 > 0) && (compareBudget == "A" || compareBidmount == "A") {
|
|
|
+ eqV = 3
|
|
|
+ }
|
|
|
+ }
|
|
|
+ case 1:
|
|
|
+ if compareBuyer < "C" {
|
|
|
+ if pjVal > 1 && (score2 > 0 || compareCity[1:1] != "C") {
|
|
|
+ eqV = 2
|
|
|
+ } else if compareCity[1:1] != "C" && compareTime == "A" && (compareAgency == "A" || score2 > 0) && (compareBudget == "A" || compareBidmount == "A") {
|
|
|
+ eqV = 3
|
|
|
+ }
|
|
|
+ } else if compareBuyer == "D" {
|
|
|
+ if pjVal > 1 && compareTime == "A" && (score2 > 0 || compareCity[1:1] != "C") {
|
|
|
+ eqV = 2
|
|
|
+ } else if compareCity[1:1] != "C" && compareTime == "A" && (compareAgency == "A" || score2 > 0) && (compareBudget == "A" || compareBidmount == "A") {
|
|
|
+ eqV = 3
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if pjVal > 1 && compareTime == "A" && score2 > 0 && (compareBudget == "A" || compareBidmount == "A") && compareCity[1:1] != "C" {
|
|
|
+ eqV = 3
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return eqV
|
|
|
+}
|
|
|
+
|
|
|
var FIELDS = []string{
|
|
|
"area",
|
|
|
"city",
|
|
@@ -409,33 +426,27 @@ var FIELDS = []string{
|
|
|
|
|
|
var bidtype = map[string]string{
|
|
|
"招标": "招标",
|
|
|
- "邀标": "邀标",
|
|
|
"询价": "询价",
|
|
|
"竞谈": "竞谈",
|
|
|
"单一": "单一",
|
|
|
"竞价": "竞价",
|
|
|
+ "变更": "变更",
|
|
|
+ "邀标": "邀标",
|
|
|
}
|
|
|
|
|
|
-//var bidstatus = map[string]string{
|
|
|
-// "中标": "中标",
|
|
|
-// "成交": "成交",
|
|
|
-// "废标": "废标",
|
|
|
-// "流标": "流标",
|
|
|
-// "合同": "合同",
|
|
|
-//}
|
|
|
var bidstatus = map[string]string{
|
|
|
"预告": "预告",
|
|
|
"中标": "中标",
|
|
|
"成交": "成交",
|
|
|
"废标": "废标",
|
|
|
"流标": "流标",
|
|
|
+ "合同": "合同",
|
|
|
}
|
|
|
|
|
|
//招标时间zbtime、中标时间jgtime、项目状态bidstatus、招标类型bidtype、最后发布时间lasttime、首次发布时间firsttime
|
|
|
|
|
|
func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (string, *ProjectInfo) {
|
|
|
pId := primitive.NewObjectID() //NewObjectId()
|
|
|
- p1 := p.NewCachePinfo(pId, thisinfo)
|
|
|
set := map[string]interface{}{}
|
|
|
set["_id"] = pId
|
|
|
for _, f := range FIELDS {
|
|
@@ -469,6 +480,17 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
|
|
|
} else if thisinfo.TopType == "结果" {
|
|
|
set["jgtime"] = tmp["publishtime"]
|
|
|
}
|
|
|
+ //异常标记
|
|
|
+ if thisinfo.TopType != "招标" && thisinfo.TopType != "拟建" && thisinfo.TopType != "预告" {
|
|
|
+ set["exception"] = 1
|
|
|
+ }
|
|
|
+ //projecthref保存
|
|
|
+ if jsonData, ok := tmp["jsondata"].(map[string]interface{}); ok {
|
|
|
+ if jsonData != nil && jsonData["projecthref"] != "" {
|
|
|
+ set["projecthref"] = jsonData["projecthref"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//招标类型
|
|
|
bt := bidtype[thisinfo.SubType]
|
|
|
if bt == "" {
|
|
@@ -480,8 +502,10 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
|
|
|
set["bidstatus"] = bs
|
|
|
}
|
|
|
if set["bidstatus"] == nil && thisinfo.TopType == "结果" {
|
|
|
+ bs = thisinfo.SubType
|
|
|
set["bidstatus"] = thisinfo.SubType
|
|
|
}
|
|
|
+ p1, pkg := p.NewCachePinfo(pId, thisinfo, bs, bt)
|
|
|
if len(thisinfo.Subscopeclass) > 0 {
|
|
|
s_subscopeclass := strings.Join(thisinfo.Subscopeclass, ",")
|
|
|
set["s_subscopeclass"] = s_subscopeclass
|
|
@@ -492,6 +516,7 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
|
|
|
}
|
|
|
if thisinfo.HasPackage {
|
|
|
set["multipackage"] = 1
|
|
|
+ set["package"] = pkg
|
|
|
} else {
|
|
|
set["multipackage"] = 0
|
|
|
}
|
|
@@ -501,10 +526,10 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
|
|
|
}
|
|
|
//p.savePool <- set
|
|
|
p.updatePool <- []map[string]interface{}{
|
|
|
- map[string]interface{}{
|
|
|
+ {
|
|
|
"_id": pId,
|
|
|
},
|
|
|
- map[string]interface{}{
|
|
|
+ {
|
|
|
"$set": set,
|
|
|
},
|
|
|
}
|
|
@@ -534,6 +559,7 @@ var INFOFIELDS = []string{
|
|
|
"buyertel",
|
|
|
"area",
|
|
|
"city",
|
|
|
+ "list",
|
|
|
}
|
|
|
|
|
|
//项目中list的信息
|
|
@@ -550,7 +576,11 @@ func (p *ProjectTask) PushListInfo(tmp map[string]interface{}, infoid string) bs
|
|
|
}
|
|
|
|
|
|
//生成存放在内存中的对象
|
|
|
-func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info) ProjectInfo {
|
|
|
+func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidstatus, bidtype string) (ProjectInfo, map[string]interface{}) {
|
|
|
+ pkg := map[string]interface{}{}
|
|
|
+ if thisinfo.HasPackage {
|
|
|
+ pkg, _, _ = PackageFormat(thisinfo, nil)
|
|
|
+ }
|
|
|
p1 := ProjectInfo{
|
|
|
Id: id,
|
|
|
Ids: []string{thisinfo.Id},
|
|
@@ -571,18 +601,20 @@ func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info) Proje
|
|
|
FirstTime: thisinfo.Publishtime,
|
|
|
LastTime: thisinfo.Publishtime,
|
|
|
Budget: thisinfo.Budget,
|
|
|
- Package: thisinfo.Package,
|
|
|
+ Package: pkg,
|
|
|
Bidamount: thisinfo.Bidamount,
|
|
|
+ Bidstatus: bidstatus,
|
|
|
+ Bidtype: bidtype,
|
|
|
}
|
|
|
if thisinfo.LenPTC > 5 {
|
|
|
p1.MPC = append(p1.MPC, thisinfo.PTC)
|
|
|
}
|
|
|
- return p1
|
|
|
+ return p1, pkg
|
|
|
}
|
|
|
|
|
|
//更新项目
|
|
|
-func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info, pInfo *ProjectInfo, weight int, comStr string) {
|
|
|
- if p.currentType != "ql" {
|
|
|
+func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info, pInfo *ProjectInfo, weight int, comStr string, ex int) {
|
|
|
+ if p.currentType != "ql" && p.currentType != "updateInfo" {
|
|
|
if BinarySearch(pInfo.Ids, thisinfo.Id) > -1 {
|
|
|
log.Println("repeat", thisinfo.Id)
|
|
|
return
|
|
@@ -607,29 +639,26 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
if bt != "" {
|
|
|
set["bidtype"] = bt
|
|
|
}
|
|
|
- //if thisinfo.TopType == "结果" {
|
|
|
- // set["bidstatus"] = thisinfo.SubType
|
|
|
- // set["jgtime"] = tmp["publishtime"]
|
|
|
- //}
|
|
|
- bs, _ := tmp["bidstatus"].(string)
|
|
|
+ bs, _ := tmp["subtype"].(string)
|
|
|
if bidstatus[bs] != "" {
|
|
|
set["bidstatus"] = thisinfo.SubType
|
|
|
- if bidstatus[bs] != "预告" {
|
|
|
+ if bidstatus[bs] != "预告" && bidstatus[bs] != "合同" {
|
|
|
set["jgtime"] = tmp["publishtime"]
|
|
|
}
|
|
|
}else if tmp["infoformat"] == 2 {
|
|
|
set["bidstatus"] = "拟建"
|
|
|
- }else if tmp["bidstatus"] == "招标" {
|
|
|
+ }else if tmp["subytpe"] == "招标" {
|
|
|
set["bidstatus"] = thisinfo.TopType
|
|
|
}else {
|
|
|
- set["bidstatus"] = thisinfo.SubType
|
|
|
+ set["bidstatus"] = "其它"
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+ //异常标记
|
|
|
+ if ex > 0 {
|
|
|
+ set["exception"] = ex
|
|
|
+ }
|
|
|
//3\4\5--省、市、县
|
|
|
if thisinfo.Area != "全国" {
|
|
|
- //xt := true
|
|
|
if pInfo.Area == "全国" {
|
|
|
pInfo.Area = thisinfo.Area
|
|
|
set["area"] = thisinfo.Area
|
|
@@ -646,10 +675,6 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
pInfo.District = thisinfo.District
|
|
|
set["district"] = thisinfo.District
|
|
|
}
|
|
|
- //省市县有不相同的
|
|
|
- // if !xt {
|
|
|
- // log.Println(pInfo.Area, pInfo.City, thisinfo.Area, thisinfo.District)
|
|
|
- // }
|
|
|
}
|
|
|
//6--项目名称
|
|
|
if (thisinfo.ProjectName != "" && pInfo.ProjectName == "") || (len([]rune(pInfo.ProjectName)) < 6 && thisinfo.LenPN > 6) {
|
|
@@ -699,13 +724,13 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
pInfo.Bidopentime = thisinfo.Bidopentime
|
|
|
set["bidopentime"] = pInfo.Bidopentime
|
|
|
}
|
|
|
- if thisinfo.Bidamount > 0 && pInfo.Bidamount < 1 {
|
|
|
- pInfo.Bidamount = thisinfo.Bidamount
|
|
|
+ if thisinfo.Bidamount > 0 {
|
|
|
+ pInfo.Bidamount = pInfo.Bidamount + thisinfo.Bidamount
|
|
|
set["bidamount"] = pInfo.Bidamount
|
|
|
}
|
|
|
|
|
|
- if thisinfo.Budget > 0 && pInfo.Budget < 1 { //多包的会有问题,没有进行合计。
|
|
|
- pInfo.Budget = thisinfo.Budget
|
|
|
+ if thisinfo.Budget > 0 {
|
|
|
+ pInfo.Budget = pInfo.Budget + thisinfo.Budget
|
|
|
set["budget"] = pInfo.Budget
|
|
|
}
|
|
|
|
|
@@ -745,42 +770,18 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
}
|
|
|
|
|
|
if thisinfo.HasPackage { //多包处理
|
|
|
- p2, _ := tmp["package"].(map[string]interface{})
|
|
|
- if p2 != nil {
|
|
|
- if pInfo.Package != nil {
|
|
|
- for pk2, pv2 := range p2 {
|
|
|
- if pInfo.Package[pk2] != nil { //合并
|
|
|
- item1, _ := pInfo.Package[pk2].(map[string]interface{})
|
|
|
- item2, _ := pv2.(map[string]interface{})
|
|
|
- if item1 != nil && item2 != nil { //原始项
|
|
|
- for ik1, iv1 := range item2 {
|
|
|
- if item1[ik1] == nil {
|
|
|
- item1[ik1] = iv1
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- pInfo.Package[pk2] = item1
|
|
|
- } else {
|
|
|
- pInfo.Package[pk2] = pv2
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- pInfo.Package = p2
|
|
|
- }
|
|
|
- }
|
|
|
+ set["multipackage"] = 1
|
|
|
+ pkg, _, _:= PackageFormat(thisinfo, pInfo)
|
|
|
+ pInfo.Package = pkg
|
|
|
set["package"] = pInfo.Package
|
|
|
+ }else {
|
|
|
+ set["multipackage"] = 0
|
|
|
}
|
|
|
|
|
|
set["mpn"] = pInfo.MPN
|
|
|
set["mpc"] = pInfo.MPC
|
|
|
set["pici"] = p.pici
|
|
|
|
|
|
- if thisinfo.HasPackage {
|
|
|
- set["multipackage"] = 1
|
|
|
- } else {
|
|
|
- set["multipackage"] = 0
|
|
|
- }
|
|
|
-
|
|
|
update := map[string]interface{}{}
|
|
|
if len(set) > 0 {
|
|
|
update["$set"] = set
|
|
@@ -804,3 +805,155 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
p.updatePool <- updateInfo
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 更新项目时,项目状态的处理
|
|
|
+ * 返回是否新增项目,异常标记
|
|
|
+ * 1、项目时,新项目时,招标信息的状态(toptype)不是招标、拟建、预告 异常:1
|
|
|
+ * 异常1是在项目新建的时候才会产生
|
|
|
+ * 3、项目合并时,项目状态是”流标“/”废标“,招标信息状态不是”招标“ 异常:2
|
|
|
+ * 4、项目合并时,项目状态是”合同“/”其它“,招标信息类型是”结果“ 异常:3
|
|
|
+ */
|
|
|
+func 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 {
|
|
|
+ return true, 0
|
|
|
+ }
|
|
|
+ }else if info.TopType == "结果" {
|
|
|
+ if project.Bidstatus == "拟建" || project.Bidstatus == "预告" || project.Bidstatus == "招标" {
|
|
|
+ return false, 0
|
|
|
+ }else if project.Bidstatus == info.SubType {
|
|
|
+ return true, 0
|
|
|
+ }else if project.Bidstatus == "成交" {
|
|
|
+ if info.SubType == "中标" {
|
|
|
+ return true, 0
|
|
|
+ }else {
|
|
|
+ return false, 0
|
|
|
+ }
|
|
|
+ }else if project.Bidstatus == "流标" || project.Bidstatus == "废标" {
|
|
|
+ return false, 2
|
|
|
+ }else if project.Bidstatus == "合同" || project.Bidstatus == "其它" {
|
|
|
+ return false, 3
|
|
|
+ }else {
|
|
|
+ return false, 0
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return false, 0
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * 对比地区(省、市、区),存在且不同,不能合并
|
|
|
+ * 返回是否新建项目
|
|
|
+ */
|
|
|
+func ComparePlace(project *ProjectInfo, info *Info) bool {
|
|
|
+ if info.Area == "全国" || info.Area == "" {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if project.Area == "全国" || project.Area == "" {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if info.Area == project.Area {
|
|
|
+ if info.City == "" {
|
|
|
+ return false
|
|
|
+ }else if info.City == project.City {
|
|
|
+ if info.District == "" || info.District == project.District {
|
|
|
+ return false
|
|
|
+ }else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var PackageEle = []string{
|
|
|
+ "origin",
|
|
|
+ "name",
|
|
|
+ "text",
|
|
|
+ "budget",
|
|
|
+ "winner",
|
|
|
+ "bidamount",
|
|
|
+ "bidamounttype",
|
|
|
+ "currency",
|
|
|
+ "bidstatus",
|
|
|
+}
|
|
|
+
|
|
|
+func packageEle(map1 map[string]interface{}) (map[string]interface{}, float64, float64) {
|
|
|
+ budget := 0.0
|
|
|
+ bidamount := 0.0
|
|
|
+ p2 := map[string]interface{}{}
|
|
|
+ for _, k := range PackageEle{
|
|
|
+ if map1[k] != nil {
|
|
|
+ p2[k] = map1[k]
|
|
|
+ }
|
|
|
+ if p2["budget"] != nil {
|
|
|
+ budget = budget + p2["budget"].(float64)
|
|
|
+ }
|
|
|
+ if p2["bidamount"] != nil {
|
|
|
+ bidamount = bidamount + p2["bidamount"].(float64)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return p2, budget, bidamount
|
|
|
+}
|
|
|
+
|
|
|
+func PackageFormat(info *Info, project *ProjectInfo) (map[string]interface{}, float64, float64) {
|
|
|
+ budget := 0.0
|
|
|
+ bidamount := 0.0
|
|
|
+ p1 := map[string]interface{}{}
|
|
|
+ if project != nil && project.Package != nil && len(project.Package) > 0 {
|
|
|
+ budget = project.Budget
|
|
|
+ bidamount = project.Bidamount
|
|
|
+ p1 = project.Package
|
|
|
+ ids := p1["ids"].([]string)
|
|
|
+ ids = append(ids, info.Id)
|
|
|
+ p1["ids"] = ids
|
|
|
+ for _, v := range info.Package {
|
|
|
+ if v1, ok := v.(map[string]interface{}); ok {
|
|
|
+ v2 := map[string]interface{}{}
|
|
|
+ v2, budget, bidamount = packageEle(v1)
|
|
|
+ if v2["bidstatus"] == nil {
|
|
|
+ v2["bidstatus"] = info.SubType
|
|
|
+ }
|
|
|
+ n := 0
|
|
|
+ addFlag := false
|
|
|
+ for k, v3 := range p1 {
|
|
|
+ if k == "ids" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if v4, ok := v3.([]map[string]interface{}); ok {
|
|
|
+ if v4[0]["origin"].(string) == v2["origin"].(string) && v4[0]["name"].(string) == v2["name"].(string) {
|
|
|
+ v4 = append(v4, v2)
|
|
|
+ p1[k] = v4
|
|
|
+ addFlag = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !addFlag {
|
|
|
+ n++
|
|
|
+ m := len(ids) + n
|
|
|
+ p1[strconv.Itoa(m)] = []map[string]interface{}{v2}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ p1["ids"] = []string{info.Id}
|
|
|
+ for k, v := range info.Package {
|
|
|
+ v1 := v.(map[string]interface{})
|
|
|
+ p2 := map[string]interface{}{}
|
|
|
+ p2, budget, bidamount = packageEle(v1)
|
|
|
+ if p2["bidstatus"] == nil {
|
|
|
+ p2["bidstatus"] = info.SubType
|
|
|
+ }
|
|
|
+ p1[k] = []map[string]interface{}{p2}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return p1, budget, bidamount
|
|
|
+}
|