|
@@ -124,7 +124,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 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //地区(省、市、区)不同,直接新建项目
|
|
|
+ if ComparePlace(compareProject, info) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
info.PNBH = 0
|
|
|
info.PCBH = 0
|
|
|
info.PTCBH = 0
|
|
@@ -142,72 +151,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 +159,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 {
|
|
@@ -232,47 +173,60 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- bFindProject = true
|
|
|
- findPid = resN[0].Id.Hex()
|
|
|
- for k2, bv := range []int{bpn, bpc, bptc, bpb} {
|
|
|
- if bv > -1 {
|
|
|
- pids[bv].Arr = append(pids[bv].Arr, findPid)
|
|
|
- if k2 == 0 {
|
|
|
- if resN[0].ProjectName == "" {
|
|
|
- resN[0].ProjectName = info.ProjectName
|
|
|
- } else {
|
|
|
- if resN[0].MPN == nil {
|
|
|
- resN[0].MPN = []string{info.ProjectName}
|
|
|
+ ex := 0
|
|
|
+ resArr := []*ProjectInfo{}
|
|
|
+ for _, res := range resN {
|
|
|
+ choose, e := p.CompareStatus(resN[0], info)
|
|
|
+ if !choose {
|
|
|
+ ex = e
|
|
|
+ resArr = append(resArr, res)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(resArr) > 0 {
|
|
|
+ bFindProject = true
|
|
|
+ findPid = resArr[0].Id.Hex()
|
|
|
+ for k2, bv := range []int{bpn, bpc, bptc, bpb} {
|
|
|
+ if bv > -1 {
|
|
|
+ pids[bv].Arr = append(pids[bv].Arr, findPid)
|
|
|
+ if k2 == 0 {
|
|
|
+ if resArr[0].ProjectName == "" {
|
|
|
+ resArr[0].ProjectName = info.ProjectName
|
|
|
} else {
|
|
|
- resN[0].MPN = append(resN[0].MPN, info.ProjectName)
|
|
|
+ if resArr[0].MPN == nil {
|
|
|
+ resArr[0].MPN = []string{info.ProjectName}
|
|
|
+ } else {
|
|
|
+ resArr[0].MPN = append(resArr[0].MPN, info.ProjectName)
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- } else if k2 < 3 {
|
|
|
- if resN[0].ProjectCode == "" {
|
|
|
- resN[0].ProjectCode = qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)
|
|
|
- } else {
|
|
|
- if resN[0].MPC == nil {
|
|
|
- resN[0].MPC = []string{qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)}
|
|
|
+ } else if k2 < 3 {
|
|
|
+ if resArr[0].ProjectCode == "" {
|
|
|
+ resArr[0].ProjectCode = qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)
|
|
|
} else {
|
|
|
- resN[0].MPC = append(resN[0].MPC, qu.If(k2 == 1, info.ProjectCode, info.PTC).(string))
|
|
|
+ if resArr[0].MPC == nil {
|
|
|
+ resArr[0].MPC = []string{qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)}
|
|
|
+ } else {
|
|
|
+ resArr[0].MPC = append(resArr[0].MPC, qu.If(k2 == 1, info.ProjectCode, info.PTC).(string))
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- } else {
|
|
|
- if resN[0].Buyer == "" {
|
|
|
- resN[0].Buyer = info.Buyer
|
|
|
+ } else {
|
|
|
+ if resArr[0].Buyer == "" {
|
|
|
+ resArr[0].Buyer = info.Buyer
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ p.UpdateProject(tmp, info, resArr[0], kv+1, resArr[0].comStr, ex)
|
|
|
+ } else {
|
|
|
+ bFindProject = false
|
|
|
+ findPid = ""
|
|
|
}
|
|
|
- p.UpdateProject(tmp, info, resN[0], kv+1, resN[0].comStr)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if !bFindProject {
|
|
|
- //没有找到
|
|
|
id, p1 := p.NewProject(tmp, info)
|
|
|
p.AllIdsMapLock.Lock()
|
|
|
p.AllIdsMap[id] = &ID{Id: id, P: p1}
|
|
@@ -281,7 +235,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 +337,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 +432,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 {
|
|
@@ -454,7 +471,7 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
|
|
|
set["bidopentime"] = bidopentime
|
|
|
}
|
|
|
if thisinfo.ProjectName != "" {
|
|
|
- set["s_projectname"] = tmp["projectname"] //兼容老版本
|
|
|
+ set["s_projectname"] = tmp["projectname"]
|
|
|
}
|
|
|
now := time.Now().Unix()
|
|
|
set["createtime"] = now
|
|
@@ -469,19 +486,40 @@ 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"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//招标类型
|
|
|
+ p.mapBidLock.Lock()
|
|
|
bt := bidtype[thisinfo.SubType]
|
|
|
+ p.mapBidLock.Unlock()
|
|
|
if bt == "" {
|
|
|
bt = "招标"
|
|
|
}
|
|
|
set["bidtype"] = bt
|
|
|
- bs, _ := tmp["bidstatus"].(string)
|
|
|
- if bidstatus[bs] != "" {
|
|
|
- set["bidstatus"] = bs
|
|
|
- }
|
|
|
- if set["bidstatus"] == nil && thisinfo.TopType == "结果" {
|
|
|
- set["bidstatus"] = thisinfo.SubType
|
|
|
+ set["bidstatus"] = thisinfo.SubType
|
|
|
+
|
|
|
+ p1, pkg := p.NewCachePinfo(pId, thisinfo, bt)
|
|
|
+ //招标信息是中标或者成交,保存bidstatus、budget、bidamount
|
|
|
+ if thisinfo.SubType == "中标" || thisinfo.SubType == "成交" {
|
|
|
+ p1.IdStatusInfo = map[string]map[string]interface{}{
|
|
|
+ thisinfo.Id: {
|
|
|
+ "projectname": thisinfo.ProjectName,
|
|
|
+ "bidstatus": thisinfo.SubType,
|
|
|
+ "budget": thisinfo.Budget,
|
|
|
+ "bidamount": thisinfo.Bidamount,
|
|
|
+ },
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if len(thisinfo.Subscopeclass) > 0 {
|
|
|
s_subscopeclass := strings.Join(thisinfo.Subscopeclass, ",")
|
|
|
set["s_subscopeclass"] = s_subscopeclass
|
|
@@ -492,6 +530,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 +540,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 +573,7 @@ var INFOFIELDS = []string{
|
|
|
"buyertel",
|
|
|
"area",
|
|
|
"city",
|
|
|
+ "list",
|
|
|
}
|
|
|
|
|
|
//项目中list的信息
|
|
@@ -550,7 +590,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, 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 +615,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: thisinfo.SubType,
|
|
|
+ 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
|
|
@@ -603,33 +649,45 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
if thisinfo.Publishtime > pInfo.LastTime {
|
|
|
pInfo.LastTime = thisinfo.Publishtime
|
|
|
set["lasttime"] = thisinfo.Publishtime
|
|
|
+ p.mapBidLock.Lock()
|
|
|
+ defer p.mapBidLock.Unlock()
|
|
|
bt := bidtype[thisinfo.SubType]
|
|
|
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 {
|
|
|
+ } else if tmp["infoformat"] == 2 {
|
|
|
set["bidstatus"] = "拟建"
|
|
|
- }else if tmp["bidstatus"] == "招标" {
|
|
|
+ } else if tmp["subytpe"] == "招标" {
|
|
|
set["bidstatus"] = thisinfo.TopType
|
|
|
- }else {
|
|
|
- set["bidstatus"] = thisinfo.SubType
|
|
|
+ } else {
|
|
|
+ set["bidstatus"] = "其它"
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ //废标、流标 处理时间
|
|
|
+ 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
|
|
|
+ }
|
|
|
//3\4\5--省、市、县
|
|
|
if thisinfo.Area != "全国" {
|
|
|
- //xt := true
|
|
|
if pInfo.Area == "全国" {
|
|
|
pInfo.Area = thisinfo.Area
|
|
|
set["area"] = thisinfo.Area
|
|
@@ -646,10 +704,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) {
|
|
@@ -673,11 +727,6 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
if pInfo.Buyer == "" {
|
|
|
set["buyerclass"] = ""
|
|
|
}
|
|
|
- //if thisinfo.Buyerclass != "" && pInfo.Buyerclass == "" {
|
|
|
- // pInfo.Buyerclass = thisinfo.Buyerclass
|
|
|
- // set["buyerclass"] = pInfo.Buyerclass
|
|
|
- //}
|
|
|
-
|
|
|
|
|
|
//8--代理机构
|
|
|
if (pInfo.Agency == "" && thisinfo.Agency != "") || (len([]rune(pInfo.Agency)) < 5 && len([]rune(thisinfo.Agency)) > 5) {
|
|
@@ -699,15 +748,6 @@ 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
|
|
|
- set["bidamount"] = pInfo.Bidamount
|
|
|
- }
|
|
|
-
|
|
|
- if thisinfo.Budget > 0 && pInfo.Budget < 1 { //多包的会有问题,没有进行合计。
|
|
|
- pInfo.Budget = thisinfo.Budget
|
|
|
- set["budget"] = pInfo.Budget
|
|
|
- }
|
|
|
|
|
|
if len(thisinfo.Topscopeclass) > 0 {
|
|
|
sort.Strings(pInfo.Topscopeclass)
|
|
@@ -745,42 +785,23 @@ 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
|
|
|
}
|
|
|
+ //处理多包后,计算预算金额、中标金额
|
|
|
+ CountAmount(pInfo, thisinfo)
|
|
|
+ set["budget"] = pInfo.Budget
|
|
|
+ set["bidamount"] = pInfo.Bidamount
|
|
|
+ //
|
|
|
|
|
|
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
|
|
@@ -796,7 +817,7 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
}
|
|
|
if len(update) > 0 {
|
|
|
updateInfo := []map[string]interface{}{
|
|
|
- map[string]interface{}{
|
|
|
+ {
|
|
|
"_id": pInfo.Id,
|
|
|
},
|
|
|
update,
|
|
@@ -804,3 +825,212 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
p.updatePool <- updateInfo
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 更新项目时,项目状态的处理
|
|
|
+ * 返回是否新增项目,异常标记
|
|
|
+ * 1、项目时,新项目时,招标信息的状态(toptype)不是招标、拟建、预告 异常:1
|
|
|
+ * 异常1是在项目新建的时候才会产生
|
|
|
+ * 3、项目合并时,项目状态是”流标“/”废标“,招标信息状态不是”招标“ 异常:2
|
|
|
+ * 4、项目合并时,项目状态是”合同“/”其它“,招标信息类型是”结果“ 异常:3
|
|
|
+ */
|
|
|
+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 {
|
|
|
+ return true, 0
|
|
|
+ }
|
|
|
+ } else if info.TopType == "结果" {
|
|
|
+ if project.Bidstatus == "拟建" || project.Bidstatus == "预告" || project.Bidstatus == "招标" {
|
|
|
+ return false, 0
|
|
|
+ } else if project.Bidstatus == info.SubType {
|
|
|
+ //状态一样,根据发布时间判断是否合并
|
|
|
+ if (info.Publishtime - project.FirstTime) > p.statusTime {
|
|
|
+ return true, 0
|
|
|
+ } else {
|
|
|
+ return true, 0
|
|
|
+ }
|
|
|
+ } else if project.Bidstatus == "成交" && info.SubType == "中标" {
|
|
|
+ return true, 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{}, id string) map[string]interface{} {
|
|
|
+ p2 := map[string]interface{}{}
|
|
|
+ for _, k := range PackageEle {
|
|
|
+ if map1[k] != nil {
|
|
|
+ p2[k] = map1[k]
|
|
|
+ }
|
|
|
+ infoid := p2["infoid"]
|
|
|
+ if infoid == nil {
|
|
|
+ p2["infoid"] = id
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return p2
|
|
|
+}
|
|
|
+
|
|
|
+func PackageFormat(info *Info, project *ProjectInfo) map[string]interface{} {
|
|
|
+ budget := 0
|
|
|
+ bidamount := 0
|
|
|
+ p1 := map[string]interface{}{}
|
|
|
+ if project != nil && project.Package != nil && len(project.Package) > 0 {
|
|
|
+ p1 = project.Package
|
|
|
+ for k, v := range info.Package {
|
|
|
+ if v1, ok := v.(map[string]interface{}); ok {
|
|
|
+ v2 := map[string]interface{}{}
|
|
|
+ v2 = packageEle(v1, info.Id)
|
|
|
+ if v2["bidstatus"] == nil {
|
|
|
+ v2["bidstatus"] = info.SubType
|
|
|
+ }
|
|
|
+ if isCount(project, v2[""]) {
|
|
|
+
|
|
|
+ }
|
|
|
+ if v2["budget"] != nil {
|
|
|
+ budget = budget + v2["budget"].(float64)
|
|
|
+ }
|
|
|
+ if v2["bidamount"] != nil {
|
|
|
+ bidamount = bidamount + v2["bidamount"].(float64)
|
|
|
+ }
|
|
|
+ addFlag := false
|
|
|
+ for k1, v3 := range p1 {
|
|
|
+ if v4, ok := v3.([]map[string]interface{}); ok {
|
|
|
+ if qu.ObjToString(v4[0]["origin"]) == qu.ObjToString(v2["origin"]) && qu.ObjToString(v4[0]["name"]) == qu.ObjToString(v2["name"]) {
|
|
|
+ v4 = append(v4, v2)
|
|
|
+ p1[k1] = v4
|
|
|
+ addFlag = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !addFlag {
|
|
|
+ p1[k] = []map[string]interface{}{v2}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for k, v := range info.Package {
|
|
|
+ v1, _ := v.(map[string]interface{})
|
|
|
+ p2 := map[string]interface{}{}
|
|
|
+ p2 = packageEle(v1, info.Id)
|
|
|
+ if p2["bidstatus"] == nil {
|
|
|
+ p2["bidstatus"] = info.SubType
|
|
|
+ }
|
|
|
+ if p2["budget"] != nil {
|
|
|
+ budget = p2["budget"].(float64)
|
|
|
+ }
|
|
|
+ if p2["bidamount"] != nil {
|
|
|
+ bidamount = p2["bidamount"].(float64)
|
|
|
+ }
|
|
|
+ p1[k] = []map[string]interface{}{p2}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ info.Budget = budget
|
|
|
+ info.Bidamount = bidamount
|
|
|
+ return p1
|
|
|
+}
|
|
|
+
|
|
|
+//计算预算(budget)、中标金额(bidamount)
|
|
|
+func CountAmount(project *ProjectInfo, info *Info) {
|
|
|
+ //if project!= nil && project.Package != nil && len(project.Package) > 0 {
|
|
|
+ ////暂时未考虑太多情况,简单处理
|
|
|
+ //}
|
|
|
+
|
|
|
+ if info.Budget > 0 {
|
|
|
+ //项目中第一条招标信息是否是包/段项目
|
|
|
+ key := titleGetPc.FindStringSubmatch(project.ProjectName)
|
|
|
+ if len(key) > 0 {
|
|
|
+ //判断项目中是否已经计算过该包/段的预算
|
|
|
+ if !isCount(project, info.ProjectName) {
|
|
|
+ project.Budget = project.Budget + info.Budget
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if project.Budget < info.Budget {
|
|
|
+ project.Budget = info.Budget
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //中标、成交、合同 处理中标金额(bidamount)
|
|
|
+ if info.SubType == "中标" || info.SubType == "成交" || info.SubType == "合同" {
|
|
|
+ if info.Bidamount > 0 {
|
|
|
+ key := titleGetPc.FindStringSubmatch(project.ProjectName)
|
|
|
+ if len(key) > 0 {
|
|
|
+ if !isCount(project, info.ProjectName) {
|
|
|
+ project.Bidamount = project.Bidamount + info.Bidamount
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if project.Bidamount < project.Bidamount {
|
|
|
+ project.Bidamount = info.Bidamount
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存信息到IdStatusInfo
|
|
|
+ project.IdStatusInfo[info.Id] = map[string]interface{}{
|
|
|
+ "projectname": info.ProjectName,
|
|
|
+ "bidstatus": info.SubType,
|
|
|
+ "budget": info.Budget,
|
|
|
+ "bidamount": info.Bidamount,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func isCount(project *ProjectInfo, infoName string) bool {
|
|
|
+ if project.IdStatusInfo != nil && len(project.IdStatusInfo) > 0 {
|
|
|
+ for _, v := range project.IdStatusInfo{
|
|
|
+ if v["projectname"] == infoName {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|