|
@@ -2,13 +2,16 @@ package main
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "fmt"
|
|
|
"github.com/go-xweb/log"
|
|
|
"github.com/goinggo/mapstructure"
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
"math"
|
|
|
mu "mfw/util"
|
|
|
+ "mongodb"
|
|
|
qu "qfw/util"
|
|
|
+ "qfw/util/redis"
|
|
|
"reflect"
|
|
|
"sort"
|
|
|
"strings"
|
|
@@ -86,17 +89,17 @@ func (p *ProjectTask) mergeAndModify(pInfoId string, index, position int, tmp ma
|
|
|
flag := true // 标记是否需要删除原有项目信息
|
|
|
for _, v := range proList {
|
|
|
v1 := v.(map[string]interface{})
|
|
|
- temp := MongoTool.FindById(ExtractColl, qu.ObjToString(v1["infoid"]))
|
|
|
- if len(temp) == 0 {
|
|
|
- temp = MongoTool.FindById(ExtractColl1, qu.ObjToString(v1["infoid"]))
|
|
|
- if len(temp) == 0 {
|
|
|
+ temp, _ := MongoTool.FindById(ExtractColl, qu.ObjToString(v1["infoid"]), nil)
|
|
|
+ if len(*temp) == 0 {
|
|
|
+ temp, _ = MongoTool.FindById(ExtractColl1, qu.ObjToString(v1["infoid"]), nil)
|
|
|
+ if len(*temp) == 0 {
|
|
|
qu.Debug("extract not find id...", v1["infoid"])
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
- tempInfo := ParseInfo(temp)
|
|
|
+ tempInfo := ParseInfo(*temp)
|
|
|
if flag {
|
|
|
- merge := p.ReMerge(tempInfo, temp, tmpPro)
|
|
|
+ merge := p.ReMerge(tempInfo, *temp, tmpPro)
|
|
|
if !merge {
|
|
|
flag = false
|
|
|
break
|
|
@@ -195,12 +198,12 @@ func (p *ProjectTask) mergeAndModify(pInfoId string, index, position int, tmp ma
|
|
|
|
|
|
// 删除
|
|
|
func (p *ProjectTask) delJudge(infoid, pid string) {
|
|
|
- tmpPro := MongoTool.FindById(ProjectColl, pid)
|
|
|
- ids := []interface{}(tmpPro["ids"].(primitive.A))
|
|
|
- proList := []interface{}(tmpPro["list"].(primitive.A))
|
|
|
+ tmpPro, _ := MongoTool.FindById(ProjectColl, pid, nil)
|
|
|
+ ids := []interface{}((*tmpPro)["ids"].(primitive.A))
|
|
|
+ proList := []interface{}((*tmpPro)["list"].(primitive.A))
|
|
|
if len(ids) == 1 {
|
|
|
- tmpPro["reason"] = "删除项目信息"
|
|
|
- backupPro(tmpPro)
|
|
|
+ (*tmpPro)["reason"] = "删除项目信息"
|
|
|
+ backupPro(*tmpPro)
|
|
|
c := MongoTool.Delete(ProjectColl, pid)
|
|
|
if c > 0 {
|
|
|
client := Es.GetEsConn()
|
|
@@ -222,25 +225,25 @@ func (p *ProjectTask) delJudge(infoid, pid string) {
|
|
|
}
|
|
|
}
|
|
|
if index == 0 {
|
|
|
- tmpPro["reason"] = "删除list中第一个条招标公告信息"
|
|
|
- backupPro(tmpPro)
|
|
|
- delete(tmpPro, "reason")
|
|
|
+ (*tmpPro)["reason"] = "删除list中第一个条招标公告信息"
|
|
|
+ backupPro(*tmpPro)
|
|
|
+ delete(*tmpPro, "reason")
|
|
|
proList = deleteSlice1(proList, proList[0])
|
|
|
- var pro *ProjectInfo
|
|
|
+ var pro *ProjectCache
|
|
|
flag := true // 标记是否需要删除原有项目信息
|
|
|
for _, v := range proList {
|
|
|
v1 := v.(map[string]interface{})
|
|
|
- temp := MongoTool.FindById(ExtractColl, qu.ObjToString(v1["infoid"]))
|
|
|
- if len(temp) == 0 {
|
|
|
- temp = MongoTool.FindById(ExtractColl1, qu.ObjToString(v1["infoid"]))
|
|
|
- if len(temp) == 0 {
|
|
|
+ temp, _ := MongoTool.FindById(ExtractColl, qu.ObjToString(v1["infoid"]), nil)
|
|
|
+ if len(*temp) == 0 {
|
|
|
+ temp, _ = MongoTool.FindById(ExtractColl1, qu.ObjToString(v1["infoid"]), nil)
|
|
|
+ if len(*temp) == 0 {
|
|
|
qu.Debug("extract not find id...", v1["infoid"])
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
- tempInfo := ParseInfo(temp)
|
|
|
+ tempInfo := ParseInfo(*temp)
|
|
|
if flag {
|
|
|
- merge := p.ReMerge(tempInfo, temp, tmpPro)
|
|
|
+ merge := p.ReMerge(tempInfo, *temp, *tmpPro)
|
|
|
if !merge {
|
|
|
flag = false
|
|
|
break
|
|
@@ -250,7 +253,7 @@ func (p *ProjectTask) delJudge(infoid, pid string) {
|
|
|
if flag {
|
|
|
delOldPro(pid)
|
|
|
} else {
|
|
|
- tmpPro, pro = p.innerMerge(proList, tmpPro)
|
|
|
+ *tmpPro, pro = p.innerMerge(proList, *tmpPro)
|
|
|
bol := MongoTool.UpdateById(ProjectColl, pid, map[string]interface{}{"$set": tmpPro})
|
|
|
if bol {
|
|
|
by, _ := json.Marshal(map[string]interface{}{
|
|
@@ -272,11 +275,11 @@ func (p *ProjectTask) delJudge(infoid, pid string) {
|
|
|
p.AllIdsMapLock.Unlock()
|
|
|
}
|
|
|
} else if index == 1 {
|
|
|
- tmpPro["reason"] = "删除list中间某一条招标公告信息"
|
|
|
- backupPro(tmpPro)
|
|
|
- delete(tmpPro, "reason")
|
|
|
- var pro *ProjectInfo
|
|
|
- tmpPro, pro = p.innerMerge1(proList, infoid, tmpPro)
|
|
|
+ (*tmpPro)["reason"] = "删除list中间某一条招标公告信息"
|
|
|
+ backupPro(*tmpPro)
|
|
|
+ delete(*tmpPro, "reason")
|
|
|
+ var pro *ProjectCache
|
|
|
+ *tmpPro, pro = p.innerMerge1(proList, infoid, *tmpPro)
|
|
|
bol := MongoTool.UpdateById(ProjectColl, pid, map[string]interface{}{"$set": tmpPro})
|
|
|
if bol {
|
|
|
by, _ := json.Marshal(map[string]interface{}{
|
|
@@ -297,13 +300,13 @@ func (p *ProjectTask) delJudge(infoid, pid string) {
|
|
|
}
|
|
|
p.AllIdsMapLock.Unlock()
|
|
|
} else if index == 2 {
|
|
|
- tmpPro["reason"] = "删除list中最后一条招标公告信息"
|
|
|
- backupPro(tmpPro)
|
|
|
- delete(tmpPro, "reason")
|
|
|
+ (*tmpPro)["reason"] = "删除list中最后一条招标公告信息"
|
|
|
+ backupPro(*tmpPro)
|
|
|
+ delete(*tmpPro, "reason")
|
|
|
w := len(proList) - 1
|
|
|
proList = deleteSlice1(proList, proList[w])
|
|
|
- var pro *ProjectInfo
|
|
|
- tmpPro, pro = p.innerMerge(proList, tmpPro)
|
|
|
+ var pro *ProjectCache
|
|
|
+ *tmpPro, pro = p.innerMerge(proList, *tmpPro)
|
|
|
bol := MongoTool.UpdateById(ProjectColl, pid, map[string]interface{}{"$set": tmpPro})
|
|
|
if bol {
|
|
|
by, _ := json.Marshal(map[string]interface{}{
|
|
@@ -339,9 +342,9 @@ func (p *ProjectTask) ReMerge(info *Info, tmp map[string]interface{}, tmpPro map
|
|
|
|
|
|
bFindProject := false
|
|
|
findPid := ""
|
|
|
- comRes1 := []*ProjectInfo{}
|
|
|
- comRes2 := []*ProjectInfo{}
|
|
|
- comRes3 := []*ProjectInfo{}
|
|
|
+ comRes1 := []*ProjectCache{}
|
|
|
+ comRes2 := []*ProjectCache{}
|
|
|
+ comRes3 := []*ProjectCache{}
|
|
|
for _, v := range IDArr {
|
|
|
comStr := ""
|
|
|
compareProject := v.P
|
|
@@ -377,7 +380,7 @@ func (p *ProjectTask) ReMerge(info *Info, tmp map[string]interface{}, tmpPro map
|
|
|
}
|
|
|
}
|
|
|
//--------------------------------对比完成-----------------------
|
|
|
- for kv, resN := range [][]*ProjectInfo{comRes1, comRes2, comRes3} {
|
|
|
+ for kv, resN := range [][]*ProjectCache{comRes1, comRes2, comRes3} {
|
|
|
if len(resN) > 0 {
|
|
|
if len(resN) > 1 {
|
|
|
sort.Slice(resN, func(i, j int) bool {
|
|
@@ -386,7 +389,7 @@ func (p *ProjectTask) ReMerge(info *Info, tmp map[string]interface{}, tmpPro map
|
|
|
}
|
|
|
|
|
|
ex := 0
|
|
|
- resArr := []*ProjectInfo{}
|
|
|
+ resArr := []*ProjectCache{}
|
|
|
for i, res := range resN {
|
|
|
choose, e := p.CompareStatus(resN[i], info)
|
|
|
if !choose {
|
|
@@ -397,7 +400,7 @@ func (p *ProjectTask) ReMerge(info *Info, tmp map[string]interface{}, tmpPro map
|
|
|
if len(resArr) > 0 {
|
|
|
bFindProject = true
|
|
|
findPid = resArr[0].Id.Hex()
|
|
|
- if findPid == BsonIdToSId(tmpPro["_id"]) {
|
|
|
+ if findPid == mongodb.BsonIdToSId(tmpPro["_id"]) {
|
|
|
return false
|
|
|
}
|
|
|
p.updateProFiled(tmp, info, resArr[0], kv+1, resArr[0].comStr, ex)
|
|
@@ -453,93 +456,104 @@ func (p *ProjectTask) ReMerge(info *Info, tmp map[string]interface{}, tmpPro map
|
|
|
}
|
|
|
|
|
|
//内部合并
|
|
|
-func (p *ProjectTask) innerMerge(infoList []interface{}, tmpPro map[string]interface{}) (map[string]interface{}, *ProjectInfo) {
|
|
|
+func (p *ProjectTask) innerMerge(infoList []interface{}, tmpPro map[string]interface{}) (map[string]interface{}, *ProjectCache) {
|
|
|
newP := make(map[string]interface{})
|
|
|
newP["_id"] = tmpPro["_id"]
|
|
|
- var p1 *ProjectInfo
|
|
|
+ var p1 *ProjectCache
|
|
|
for k, m := range infoList {
|
|
|
m1 := m.(map[string]interface{})
|
|
|
- temp := MongoTool.FindById(ExtractColl, qu.ObjToString(m1["infoid"]))
|
|
|
- if len(temp) == 0 {
|
|
|
- temp = MongoTool.FindById(ExtractColl1, qu.ObjToString(m1["infoid"]))
|
|
|
- if len(temp) == 0 {
|
|
|
+ temp, _ := MongoTool.FindById(ExtractColl, qu.ObjToString(m1["infoid"]), nil)
|
|
|
+ if len(*temp) == 0 {
|
|
|
+ temp, _ = MongoTool.FindById(ExtractColl1, qu.ObjToString(m1["infoid"]), nil)
|
|
|
+ if len(*temp) == 0 {
|
|
|
qu.Debug("extract not find id...", m1["infoid"])
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
- tempInfo := ParseInfo(temp)
|
|
|
+ tempInfo := ParseInfo(*temp)
|
|
|
if k == 0 {
|
|
|
- p1 = p.newPro(temp, newP, tempInfo)
|
|
|
+ p1 = p.newPro(*temp, newP, tempInfo)
|
|
|
} else {
|
|
|
- p.updateOldProField(p1, tempInfo, newP, temp, m1)
|
|
|
+ p.updateOldProField(p1, tempInfo, newP, *temp, m1)
|
|
|
}
|
|
|
}
|
|
|
return newP, p1
|
|
|
}
|
|
|
|
|
|
-func (p *ProjectTask) innerMerge1(infoList []interface{}, infoid string, tmpPro map[string]interface{}) (map[string]interface{}, *ProjectInfo) {
|
|
|
+func (p *ProjectTask) innerMerge1(infoList []interface{}, infoid string, tmpPro map[string]interface{}) (map[string]interface{}, *ProjectCache) {
|
|
|
newP := make(map[string]interface{})
|
|
|
newP["_id"] = tmpPro["_id"]
|
|
|
- var p1 *ProjectInfo
|
|
|
+ var p1 *ProjectCache
|
|
|
for k, m := range infoList {
|
|
|
m1 := m.(map[string]interface{})
|
|
|
if m1["infoid"] == infoid {
|
|
|
continue
|
|
|
}
|
|
|
- temp := MongoTool.FindById(ExtractColl, qu.ObjToString(m1["infoid"]))
|
|
|
- if len(temp) == 0 {
|
|
|
- temp = MongoTool.FindById(ExtractColl1, qu.ObjToString(m1["infoid"]))
|
|
|
- if len(temp) == 0 {
|
|
|
+ temp, _ := MongoTool.FindById(ExtractColl, qu.ObjToString(m1["infoid"]), nil)
|
|
|
+ if len(*temp) == 0 {
|
|
|
+ temp, _ = MongoTool.FindById(ExtractColl1, qu.ObjToString(m1["infoid"]), nil)
|
|
|
+ if len(*temp) == 0 {
|
|
|
qu.Debug("extract not find id...", m1["infoid"])
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
- tempInfo := ParseInfo(temp)
|
|
|
+ tempInfo := ParseInfo(*temp)
|
|
|
if k == 0 {
|
|
|
- p1 = p.newPro(temp, newP, tempInfo)
|
|
|
+ p1 = p.newPro(*temp, newP, tempInfo)
|
|
|
} else {
|
|
|
- p.updateOldProField(p1, tempInfo, newP, temp, m1)
|
|
|
+ p.updateOldProField(p1, tempInfo, newP, *temp, m1)
|
|
|
}
|
|
|
}
|
|
|
return newP, p1
|
|
|
}
|
|
|
|
|
|
// 更新招标公告到新的项目中
|
|
|
-func (p *ProjectTask) updateProFiled(tmp map[string]interface{}, thisinfo *Info, pInfo *ProjectInfo, weight int, comStr string, ex int) {
|
|
|
+func (p *ProjectTask) updateProFiled(tmp map[string]interface{}, thisinfo *Info, pInfo *ProjectCache, weight int, comStr string, ex int) {
|
|
|
+ pdata := redis.Get("project", pInfo.Id.Hex())
|
|
|
+ projectMap := pdata.(map[string]interface{})
|
|
|
+ bys, _ := json.Marshal(projectMap)
|
|
|
+ var project *Project
|
|
|
+ err := json.Unmarshal(bys, &project)
|
|
|
+ if err != nil {
|
|
|
+ qu.Debug("project Unmarshal err,", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
set := map[string]interface{}{}
|
|
|
pInfo.Ids = append(pInfo.Ids, thisinfo.Id)
|
|
|
+ project.Ids = append(project.Ids, thisinfo.Id)
|
|
|
if len(pInfo.Ids) > 30 {
|
|
|
//异常标记
|
|
|
set["listtag"] = 1
|
|
|
}
|
|
|
if thisinfo.Publishtime > pInfo.LastTime {
|
|
|
pInfo.LastTime = thisinfo.Publishtime
|
|
|
+ project.LastTime = thisinfo.Publishtime
|
|
|
set["lasttime"] = thisinfo.Publishtime
|
|
|
}
|
|
|
if thisinfo.TopType == "招标" {
|
|
|
- if thisinfo.SubType != "变更" && thisinfo.SubType != "其它" && pInfo.Zbtime <= 0 {
|
|
|
+ if thisinfo.SubType != "变更" && thisinfo.SubType != "其它" && project.Zbtime <= 0 {
|
|
|
set["zbtime"] = tmp["publishtime"]
|
|
|
}
|
|
|
} else if thisinfo.TopType == "结果" {
|
|
|
if thisinfo.SubType == "中标" || thisinfo.SubType == "成交" || thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
|
|
|
- if pInfo.Jgtime > 0 {
|
|
|
- jg1 := int64(math.Abs(float64(pInfo.Jgtime - thisinfo.Publishtime)))
|
|
|
+ if project.Jgtime > 0 {
|
|
|
+ jg1 := int64(math.Abs(float64(project.Jgtime - thisinfo.Publishtime)))
|
|
|
//公告状态和项目状态同样都是中标或者成交,
|
|
|
if (thisinfo.SubType == "中标" || thisinfo.SubType == "成交") && (pInfo.Bidstatus == "中标" || pInfo.Bidstatus == "成交") {
|
|
|
if jg1 > p.jgTime {
|
|
|
set["jgtime"] = tmp["publishtime"]
|
|
|
- pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
}
|
|
|
} else if (thisinfo.SubType == "流标" || thisinfo.SubType == "废标") && (pInfo.Bidstatus == "流标" || pInfo.Bidstatus == "废标") {
|
|
|
//公告状态和项目状态同样是流标或者废标
|
|
|
if jg1 > p.jgTime {
|
|
|
set["jgtime"] = tmp["publishtime"]
|
|
|
- pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
set["jgtime"] = tmp["publishtime"]
|
|
|
- pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
}
|
|
|
}
|
|
|
} else if thisinfo.SubType == "合同" {
|
|
@@ -547,15 +561,16 @@ func (p *ProjectTask) updateProFiled(tmp map[string]interface{}, thisinfo *Info,
|
|
|
//中标、成交不更新jgtime
|
|
|
} else {
|
|
|
set["jgtime"] = tmp["publishtime"]
|
|
|
- pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
}
|
|
|
}
|
|
|
- if thisinfo.Bidopentime > pInfo.Bidopentime {
|
|
|
- pInfo.Bidopentime = thisinfo.Bidopentime
|
|
|
- set["bidopentime"] = pInfo.Bidopentime
|
|
|
+ if thisinfo.Bidopentime > project.Bidopentime {
|
|
|
+ project.Bidopentime = thisinfo.Bidopentime
|
|
|
+ set["bidopentime"] = thisinfo.Bidopentime
|
|
|
}
|
|
|
// bidtype、bidstatus
|
|
|
pInfo.Bidtype, pInfo.Bidstatus = p.GetBidTypeAndBidStatus(thisinfo)
|
|
|
+ project.Bidtype, project.Bidstatus = p.GetBidTypeAndBidStatus(thisinfo)
|
|
|
set["bidtype"] = pInfo.Bidtype
|
|
|
set["bidstatus"] = pInfo.Bidstatus
|
|
|
|
|
@@ -566,52 +581,58 @@ func (p *ProjectTask) updateProFiled(tmp map[string]interface{}, thisinfo *Info,
|
|
|
//相同城市的公告才会合并到一起(全国列外)
|
|
|
if thisinfo.Area != "全国" {
|
|
|
pInfo.Area = thisinfo.Area
|
|
|
+ project.Area = thisinfo.Area
|
|
|
set["area"] = thisinfo.Area
|
|
|
pInfo.City = thisinfo.City
|
|
|
+ project.City = thisinfo.City
|
|
|
set["city"] = thisinfo.City
|
|
|
if thisinfo.District != "" {
|
|
|
pInfo.District = thisinfo.District
|
|
|
+ project.District = thisinfo.District
|
|
|
set["district"] = thisinfo.District
|
|
|
}
|
|
|
}
|
|
|
// 项目名称
|
|
|
if (thisinfo.ProjectName != "" && pInfo.ProjectName == "") || (len([]rune(pInfo.ProjectName)) < 6 && thisinfo.LenPN > 6) {
|
|
|
pInfo.ProjectName = thisinfo.ProjectName
|
|
|
+ project.ProjectName = thisinfo.ProjectName
|
|
|
set["projectname"] = thisinfo.ProjectName
|
|
|
}
|
|
|
// 项目编号
|
|
|
if (pInfo.ProjectCode == "" && thisinfo.ProjectCode != "") || (len([]rune(pInfo.ProjectCode)) < 6 && len([]rune(thisinfo.ProjectCode)) > 6) {
|
|
|
pInfo.ProjectCode = thisinfo.ProjectCode
|
|
|
+ project.ProjectCode = thisinfo.ProjectCode
|
|
|
set["projectcode"] = thisinfo.ProjectCode
|
|
|
}
|
|
|
// 采购单位
|
|
|
if (pInfo.Buyer == "" && thisinfo.Buyer != "") || (len([]rune(pInfo.Buyer)) < 5 && len([]rune(thisinfo.Buyer)) > 5) {
|
|
|
pInfo.Buyer = thisinfo.Buyer
|
|
|
set["buyer"] = thisinfo.Buyer
|
|
|
- pInfo.Buyerclass = thisinfo.Buyerclass
|
|
|
+ project.Buyerclass = thisinfo.Buyerclass
|
|
|
set["buyerclass"] = thisinfo.Buyerclass
|
|
|
}
|
|
|
if pInfo.Buyer == "" {
|
|
|
+ project.Buyerclass = ""
|
|
|
set["buyerclass"] = ""
|
|
|
}
|
|
|
// 采购单位联系人
|
|
|
if thisinfo.Buyerperson != "" {
|
|
|
- pInfo.Buyerperson = thisinfo.Buyerperson
|
|
|
- set["buyerperson"] = pInfo.Buyerperson
|
|
|
+ project.Buyerperson = thisinfo.Buyerperson
|
|
|
+ set["buyerperson"] = thisinfo.Buyerperson
|
|
|
} else {
|
|
|
- pInfo.Buyerperson = ""
|
|
|
+ project.Buyerperson = ""
|
|
|
set["buyerperson"] = ""
|
|
|
}
|
|
|
// 采购单位電話
|
|
|
if thisinfo.Buyertel != "" {
|
|
|
- pInfo.Buyertel = thisinfo.Buyertel
|
|
|
- set["buyertel"] = pInfo.Buyertel
|
|
|
+ project.Buyertel = thisinfo.Buyertel
|
|
|
+ set["buyertel"] = thisinfo.Buyertel
|
|
|
} else {
|
|
|
- pInfo.Buyertel = ""
|
|
|
+ project.Buyertel = ""
|
|
|
set["buyertel"] = ""
|
|
|
}
|
|
|
if thisinfo.ContractCode != "" {
|
|
|
- set["contractcode"] = pInfo.ContractCode + "," + thisinfo.ContractCode
|
|
|
+ set["contractcode"] = project.ContractCode + "," + thisinfo.ContractCode
|
|
|
}
|
|
|
// 代理机构 相同的代理机构才会合并到一个项目 2020.11.9
|
|
|
//if (pInfo.Agency == "" && thisinfo.Agency != "") || (len([]rune(pInfo.Agency)) < 5 && len([]rune(thisinfo.Agency)) > 5) {
|
|
@@ -619,26 +640,26 @@ func (p *ProjectTask) updateProFiled(tmp map[string]interface{}, thisinfo *Info,
|
|
|
// set["agency"] = thisinfo.Agency
|
|
|
//}
|
|
|
if len(thisinfo.Topscopeclass) > 0 && thisinfo.Publishtime > pInfo.LastTime {
|
|
|
- sort.Strings(pInfo.Topscopeclass)
|
|
|
+ sort.Strings(project.Topscopeclass)
|
|
|
for _, k := range thisinfo.Topscopeclass {
|
|
|
- if BinarySearch(pInfo.Topscopeclass, k) == -1 {
|
|
|
- pInfo.Topscopeclass = append(pInfo.Topscopeclass, k)
|
|
|
- sort.Strings(pInfo.Topscopeclass)
|
|
|
+ if BinarySearch(project.Topscopeclass, k) == -1 {
|
|
|
+ project.Topscopeclass = append(project.Topscopeclass, k)
|
|
|
+ sort.Strings(project.Topscopeclass)
|
|
|
}
|
|
|
}
|
|
|
- set["topscopeclass"] = pInfo.Topscopeclass
|
|
|
+ set["topscopeclass"] = project.Topscopeclass
|
|
|
}
|
|
|
// 项目评审专家
|
|
|
if len(thisinfo.ReviewExperts) > 0 && thisinfo.Publishtime > pInfo.LastTime {
|
|
|
set["review_experts"] = thisinfo.ReviewExperts
|
|
|
- pInfo.ReviewExperts = thisinfo.ReviewExperts
|
|
|
+ project.ReviewExperts = thisinfo.ReviewExperts
|
|
|
}
|
|
|
if thisinfo.Purchasing != "" && thisinfo.Publishtime > pInfo.LastTime {
|
|
|
- if pInfo.Purchasing == "" {
|
|
|
- pInfo.Purchasing = thisinfo.Purchasing
|
|
|
+ if project.Purchasing == "" {
|
|
|
+ project.Purchasing = thisinfo.Purchasing
|
|
|
set["purchasing"] = thisinfo.Purchasing
|
|
|
} else {
|
|
|
- list := strings.Split(pInfo.Purchasing, ",")
|
|
|
+ list := strings.Split(project.Purchasing, ",")
|
|
|
for _, k := range list {
|
|
|
if BinarySearch(strings.Split(thisinfo.Purchasing, ","), k) == -1 {
|
|
|
list = append(list, k)
|
|
@@ -657,56 +678,57 @@ func (p *ProjectTask) updateProFiled(tmp map[string]interface{}, thisinfo *Info,
|
|
|
}
|
|
|
}
|
|
|
set["winnerorder"] = list
|
|
|
- pInfo.Winnerorder = list
|
|
|
+ project.Winnerorder = list
|
|
|
}
|
|
|
|
|
|
if len(thisinfo.Subscopeclass) > 0 && thisinfo.Publishtime > pInfo.LastTime {
|
|
|
- sort.Strings(pInfo.Subscopeclass)
|
|
|
+ sort.Strings(project.Subscopeclass)
|
|
|
for _, k := range thisinfo.Subscopeclass {
|
|
|
- if BinarySearch(pInfo.Subscopeclass, k) == -1 {
|
|
|
- pInfo.Subscopeclass = append(pInfo.Subscopeclass, k)
|
|
|
- sort.Strings(pInfo.Subscopeclass)
|
|
|
+ if BinarySearch(project.Subscopeclass, k) == -1 {
|
|
|
+ project.Subscopeclass = append(project.Subscopeclass, k)
|
|
|
+ sort.Strings(project.Subscopeclass)
|
|
|
}
|
|
|
}
|
|
|
- set["subscopeclass"] = pInfo.Subscopeclass
|
|
|
- set["s_subscopeclass"] = strings.Join(pInfo.Subscopeclass, ",")
|
|
|
+ set["subscopeclass"] = project.Subscopeclass
|
|
|
+ set["s_subscopeclass"] = strings.Join(project.Subscopeclass, ",")
|
|
|
}
|
|
|
|
|
|
if len(thisinfo.Winners) > 0 && thisinfo.Publishtime > pInfo.LastTime {
|
|
|
- if len(pInfo.Winners) <= 0 {
|
|
|
+ winners := strings.Split(project.Winners, ",")
|
|
|
+ if len(winners) <= 0 {
|
|
|
set["winner"] = qu.ObjToString(tmp["winner"])
|
|
|
}
|
|
|
-
|
|
|
- sort.Strings(pInfo.Winners)
|
|
|
for _, k := range thisinfo.Winners {
|
|
|
if thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
|
|
|
- if BinarySearch(pInfo.Winners, k) != -1 {
|
|
|
- deleteSlice(pInfo.Winners, k, "")
|
|
|
- sort.Strings(pInfo.Winners)
|
|
|
+ if BinarySearch(winners, k) != -1 {
|
|
|
+ deleteSlice(winners, k, "")
|
|
|
+ sort.Strings(winners)
|
|
|
}
|
|
|
} else {
|
|
|
- if BinarySearch(pInfo.Winners, k) == -1 {
|
|
|
- pInfo.Winners = append(pInfo.Winners, k)
|
|
|
- sort.Strings(pInfo.Winners)
|
|
|
+ if BinarySearch(winners, k) == -1 {
|
|
|
+ winners = append(winners, k)
|
|
|
+ sort.Strings(winners)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- set["s_winner"] = strings.Join(pInfo.Winners, ",")
|
|
|
+ set["s_winner"] = strings.Join(winners, ",")
|
|
|
}
|
|
|
|
|
|
if thisinfo.HasPackage { //多包处理
|
|
|
set["multipackage"] = 1
|
|
|
- pkg := PackageFormat(thisinfo, pInfo)
|
|
|
- pInfo.Package = pkg
|
|
|
- set["package"] = pInfo.Package
|
|
|
+ pkg := PackageFormat(thisinfo, project)
|
|
|
+ project.Package = pkg
|
|
|
+ set["package"] = project.Package
|
|
|
}
|
|
|
//处理多包后,计算预算金额、中标金额
|
|
|
- CountAmount(pInfo, thisinfo, tmp)
|
|
|
- if pInfo.Budget >= 0 && pInfo.Budgettag != 1 {
|
|
|
+ CountAmount(project, thisinfo, tmp)
|
|
|
+ if project.Budget >= 0 && project.Budgettag != 1 {
|
|
|
+ pInfo.Budget = project.Budget
|
|
|
set["budget"] = pInfo.Budget
|
|
|
set["budgettag"] = 0
|
|
|
}
|
|
|
- if pInfo.Bidamount >= 0 && pInfo.Bidamounttag != 1 {
|
|
|
+ if pInfo.Bidamount >= 0 && project.Bidamounttag != 1 {
|
|
|
+ pInfo.Bidamount = project.Bidamount
|
|
|
set["bidamount"] = pInfo.Bidamount
|
|
|
set["bidamounttag"] = 0
|
|
|
}
|
|
@@ -726,19 +748,20 @@ func (p *ProjectTask) updateProFiled(tmp map[string]interface{}, thisinfo *Info,
|
|
|
ProjectCode: thisinfo.ProjectCode,
|
|
|
Bidstatus: pInfo.Bidstatus,
|
|
|
}
|
|
|
- copyMap := Copy(pInfo.InfoFiled).(map[string]InfoField)
|
|
|
+ copyMap := Copy(project.InfoFiled).(map[string]InfoField)
|
|
|
copyMap[thisinfo.Id] = infofield
|
|
|
tmpMap := make(map[string]interface{})
|
|
|
for k, v := range copyMap {
|
|
|
tmpMap[k] = StructToMap(v)
|
|
|
}
|
|
|
tmpMap[thisinfo.Id] = StructToMap(infofield)
|
|
|
- pInfo.InfoFiled = copyMap
|
|
|
+ project.InfoFiled = copyMap
|
|
|
set["infofield"] = tmpMap
|
|
|
|
|
|
set["mpn"] = pInfo.MPN
|
|
|
set["mpc"] = pInfo.MPC
|
|
|
set["updatetime"] = p.pici
|
|
|
+ redis.PutCKV("project", project.Id.Hex(), set)
|
|
|
update := map[string]interface{}{}
|
|
|
if len(set) > 0 {
|
|
|
update["$set"] = set
|
|
@@ -768,7 +791,7 @@ func (p *ProjectTask) updateProFiled(tmp map[string]interface{}, thisinfo *Info,
|
|
|
}
|
|
|
|
|
|
// 内部合并时,原有项目id基础上新建项目
|
|
|
-func (p *ProjectTask) newPro(tmp, tmpPro map[string]interface{}, thisinfo *Info) *ProjectInfo {
|
|
|
+func (p *ProjectTask) newPro(tmp, tmpPro map[string]interface{}, thisinfo *Info) *ProjectCache {
|
|
|
for _, f := range FIELDS {
|
|
|
if tmp[f] != nil && tmp[f] != "" {
|
|
|
tmpPro[f] = tmp[f]
|
|
@@ -796,7 +819,7 @@ func (p *ProjectTask) newPro(tmp, tmpPro map[string]interface{}, thisinfo *Info)
|
|
|
tmpPro["bidtype"] = bs
|
|
|
tmpPro["bidstatus"] = bt
|
|
|
pkg := PackageFormat(thisinfo, nil)
|
|
|
- p1 := p.NewCachePinfo(tmpPro["_id"].(primitive.ObjectID), thisinfo, bs, bt, pkg)
|
|
|
+ p1 := p.NewCachePinfo(tmpPro["_id"].(primitive.ObjectID), thisinfo, bs, bt)
|
|
|
|
|
|
now := time.Now().Unix()
|
|
|
tmpPro["createtime"] = now
|
|
@@ -809,18 +832,15 @@ func (p *ProjectTask) newPro(tmp, tmpPro map[string]interface{}, thisinfo *Info)
|
|
|
if thisinfo.TopType == "招标" {
|
|
|
if thisinfo.SubType != "变更" && thisinfo.SubType != "其它" {
|
|
|
tmpPro["zbtime"] = tmp["publishtime"]
|
|
|
- p1.Zbtime = qu.Int64All(tmp["publishtime"])
|
|
|
}
|
|
|
} else if thisinfo.TopType == "结果" || thisinfo.SubType == "合同" {
|
|
|
tmpPro["jgtime"] = tmp["publishtime"]
|
|
|
- p1.Jgtime = thisinfo.Publishtime
|
|
|
}
|
|
|
if len(thisinfo.Subscopeclass) > 0 {
|
|
|
tmpPro["s_subscopeclass"] = strings.Join(thisinfo.Subscopeclass, ",")
|
|
|
}
|
|
|
if len(thisinfo.Winners) > 0 {
|
|
|
tmpPro["s_winner"] = strings.Join(thisinfo.Winners, ",")
|
|
|
- p1.Winners = thisinfo.Winners
|
|
|
}
|
|
|
if thisinfo.HasPackage {
|
|
|
tmpPro["multipackage"] = 1
|
|
@@ -831,12 +851,10 @@ func (p *ProjectTask) newPro(tmp, tmpPro map[string]interface{}, thisinfo *Info)
|
|
|
//项目评审专家
|
|
|
if len(thisinfo.ReviewExperts) > 0 {
|
|
|
tmpPro["review_experts"] = thisinfo.ReviewExperts
|
|
|
- p1.ReviewExperts = thisinfo.ReviewExperts
|
|
|
}
|
|
|
//标的物
|
|
|
if thisinfo.Purchasing != "" {
|
|
|
tmpPro["purchasing"] = thisinfo.Purchasing
|
|
|
- p1.Purchasing = thisinfo.Purchasing
|
|
|
}
|
|
|
//中标候选人
|
|
|
if len(thisinfo.WinnerOrder) > 0 {
|
|
@@ -847,9 +865,7 @@ func (p *ProjectTask) newPro(tmp, tmpPro map[string]interface{}, thisinfo *Info)
|
|
|
}
|
|
|
}
|
|
|
tmpPro["winnerorder"] = list
|
|
|
- p1.Winnerorder = list
|
|
|
}
|
|
|
- p1.InfoFiled = make(map[string]InfoField)
|
|
|
infofield := InfoField{
|
|
|
Budget: thisinfo.Budget,
|
|
|
Bidamount: thisinfo.Bidamount,
|
|
@@ -858,25 +874,20 @@ func (p *ProjectTask) newPro(tmp, tmpPro map[string]interface{}, thisinfo *Info)
|
|
|
ProjectCode: thisinfo.ProjectCode,
|
|
|
Bidstatus: bs,
|
|
|
}
|
|
|
- p1.InfoFiled[thisinfo.Id] = infofield
|
|
|
res := StructToMap(infofield)
|
|
|
tmpPro["infofield"] = map[string]interface{}{
|
|
|
thisinfo.Id: res,
|
|
|
}
|
|
|
if tmp["budget"] != nil && tmp["budget"] != "" {
|
|
|
tmpPro["budget"] = thisinfo.Budget
|
|
|
- p1.Budgettag = 0
|
|
|
tmpPro["budgettag"] = 0
|
|
|
} else {
|
|
|
- p1.Budgettag = 1
|
|
|
tmpPro["budgettag"] = 1
|
|
|
}
|
|
|
if tmp["bidamount"] != nil && tmp["bidamount"] != "" {
|
|
|
tmpPro["bidamount"] = thisinfo.Bidamount
|
|
|
- p1.Bidamounttag = 0
|
|
|
tmpPro["bidamounttag"] = 0
|
|
|
} else {
|
|
|
- p1.Bidamounttag = 1
|
|
|
tmpPro["bidamounttag"] = 1
|
|
|
}
|
|
|
if p1.Bidamount > 0 {
|
|
@@ -893,39 +904,49 @@ func (p *ProjectTask) newPro(tmp, tmpPro map[string]interface{}, thisinfo *Info)
|
|
|
}
|
|
|
|
|
|
// 合并字段到老项目中
|
|
|
-func (p *ProjectTask) updateOldProField(pInfo *ProjectInfo, thisinfo *Info, tmpPro, tmp, m1 map[string]interface{}) {
|
|
|
+func (p *ProjectTask) updateOldProField(pInfo *ProjectCache, thisinfo *Info, tmpPro, tmp, m1 map[string]interface{}) {
|
|
|
+ pdata := redis.Get("project", pInfo.Id.Hex())
|
|
|
+ projectMap := pdata.(map[string]interface{})
|
|
|
+ bys, _ := json.Marshal(projectMap)
|
|
|
+ var project *Project
|
|
|
+ err := json.Unmarshal(bys, &project)
|
|
|
+ if err != nil {
|
|
|
+ qu.Debug("project Unmarshal err,", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
if len(pInfo.Ids) > 30 {
|
|
|
//异常标记
|
|
|
tmpPro["listtag"] = 1
|
|
|
}
|
|
|
if thisinfo.Publishtime > pInfo.LastTime {
|
|
|
pInfo.LastTime = thisinfo.Publishtime
|
|
|
+ project.LastTime = thisinfo.Publishtime
|
|
|
tmpPro["lasttime"] = thisinfo.Publishtime
|
|
|
}
|
|
|
if thisinfo.TopType == "招标" {
|
|
|
- if thisinfo.SubType != "变更" && thisinfo.SubType != "其它" && pInfo.Zbtime <= 0 {
|
|
|
+ if thisinfo.SubType != "变更" && thisinfo.SubType != "其它" && project.Zbtime <= 0 {
|
|
|
tmpPro["zbtime"] = tmp["publishtime"]
|
|
|
}
|
|
|
} else if thisinfo.TopType == "结果" {
|
|
|
if thisinfo.SubType == "中标" || thisinfo.SubType == "成交" || thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
|
|
|
- if pInfo.Jgtime > 0 {
|
|
|
- jg1 := int64(math.Abs(float64(pInfo.Jgtime - thisinfo.Publishtime)))
|
|
|
+ if project.Jgtime > 0 {
|
|
|
+ jg1 := int64(math.Abs(float64(project.Jgtime - thisinfo.Publishtime)))
|
|
|
//公告状态和项目状态同样都是中标或者成交,
|
|
|
if (thisinfo.SubType == "中标" || thisinfo.SubType == "成交") && (pInfo.Bidstatus == "中标" || pInfo.Bidstatus == "成交") {
|
|
|
if jg1 > p.jgTime {
|
|
|
tmpPro["jgtime"] = tmp["publishtime"]
|
|
|
- pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
}
|
|
|
} else if (thisinfo.SubType == "流标" || thisinfo.SubType == "废标") && (pInfo.Bidstatus == "流标" || pInfo.Bidstatus == "废标") {
|
|
|
//公告状态和项目状态同样是流标或者废标
|
|
|
if jg1 > p.jgTime {
|
|
|
tmpPro["jgtime"] = tmp["publishtime"]
|
|
|
- pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
tmpPro["jgtime"] = tmp["publishtime"]
|
|
|
- pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
}
|
|
|
}
|
|
|
} else if thisinfo.SubType == "合同" {
|
|
@@ -933,67 +954,74 @@ func (p *ProjectTask) updateOldProField(pInfo *ProjectInfo, thisinfo *Info, tmpP
|
|
|
//中标、成交不更新jgtime
|
|
|
} else {
|
|
|
tmpPro["jgtime"] = tmp["publishtime"]
|
|
|
- pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
}
|
|
|
}
|
|
|
- if thisinfo.Bidopentime > pInfo.Bidopentime {
|
|
|
- pInfo.Bidopentime = thisinfo.Bidopentime
|
|
|
- tmpPro["bidopentime"] = pInfo.Bidopentime
|
|
|
+ if thisinfo.Bidopentime > project.Bidopentime {
|
|
|
+ project.Bidopentime = thisinfo.Bidopentime
|
|
|
+ tmpPro["bidopentime"] = thisinfo.Bidopentime
|
|
|
}
|
|
|
// bidtype、bidstatus
|
|
|
pInfo.Bidtype, pInfo.Bidstatus = p.GetBidTypeAndBidStatus(thisinfo)
|
|
|
+ project.Bidtype, project.Bidstatus = p.GetBidTypeAndBidStatus(thisinfo)
|
|
|
tmpPro["bidtype"] = pInfo.Bidtype
|
|
|
tmpPro["bidstatus"] = pInfo.Bidstatus
|
|
|
|
|
|
//相同城市的公告才会合并到一起(全国列外)
|
|
|
if thisinfo.Area != "全国" {
|
|
|
pInfo.Area = thisinfo.Area
|
|
|
+ project.Area = thisinfo.Area
|
|
|
tmpPro["area"] = thisinfo.Area
|
|
|
pInfo.City = thisinfo.City
|
|
|
+ project.City = thisinfo.City
|
|
|
tmpPro["city"] = thisinfo.City
|
|
|
if thisinfo.District != "" {
|
|
|
pInfo.District = thisinfo.District
|
|
|
+ project.District = thisinfo.District
|
|
|
tmpPro["district"] = thisinfo.District
|
|
|
}
|
|
|
}
|
|
|
// 项目名称
|
|
|
if (thisinfo.ProjectName != "" && pInfo.ProjectName == "") || (len([]rune(pInfo.ProjectName)) < 6 && thisinfo.LenPN > 6) {
|
|
|
pInfo.ProjectName = thisinfo.ProjectName
|
|
|
+ project.ProjectName = thisinfo.ProjectName
|
|
|
tmpPro["projectname"] = thisinfo.ProjectName
|
|
|
}
|
|
|
// 项目编号
|
|
|
if (pInfo.ProjectCode == "" && thisinfo.ProjectCode != "") || (len([]rune(pInfo.ProjectCode)) < 6 && len([]rune(thisinfo.ProjectCode)) > 6) {
|
|
|
pInfo.ProjectCode = thisinfo.ProjectCode
|
|
|
+ project.ProjectCode = thisinfo.ProjectCode
|
|
|
tmpPro["projectcode"] = thisinfo.ProjectCode
|
|
|
}
|
|
|
// 采购单位
|
|
|
if (pInfo.Buyer == "" && thisinfo.Buyer != "") || (len([]rune(pInfo.Buyer)) < 5 && len([]rune(thisinfo.Buyer)) > 5) {
|
|
|
pInfo.Buyer = thisinfo.Buyer
|
|
|
tmpPro["buyer"] = thisinfo.Buyer
|
|
|
- pInfo.Buyerclass = thisinfo.Buyerclass
|
|
|
+ project.Buyerclass = thisinfo.Buyerclass
|
|
|
tmpPro["buyerclass"] = thisinfo.Buyerclass
|
|
|
}
|
|
|
if pInfo.Buyer == "" {
|
|
|
+ project.Buyerclass = ""
|
|
|
tmpPro["buyerclass"] = ""
|
|
|
}
|
|
|
// 采购单位联系人
|
|
|
if thisinfo.Buyerperson != "" {
|
|
|
- pInfo.Buyerperson = thisinfo.Buyerperson
|
|
|
- tmpPro["buyerperson"] = pInfo.Buyerperson
|
|
|
+ project.Buyerperson = thisinfo.Buyerperson
|
|
|
+ tmpPro["buyerperson"] = thisinfo.Buyerperson
|
|
|
} else {
|
|
|
- pInfo.Buyerperson = ""
|
|
|
+ project.Buyerperson = ""
|
|
|
tmpPro["buyerperson"] = ""
|
|
|
}
|
|
|
// 采购单位電話
|
|
|
if thisinfo.Buyertel != "" {
|
|
|
- pInfo.Buyertel = thisinfo.Buyertel
|
|
|
- tmpPro["buyertel"] = pInfo.Buyertel
|
|
|
+ project.Buyertel = thisinfo.Buyertel
|
|
|
+ tmpPro["buyertel"] = thisinfo.Buyertel
|
|
|
} else {
|
|
|
- pInfo.Buyertel = ""
|
|
|
+ project.Buyertel = ""
|
|
|
tmpPro["buyertel"] = ""
|
|
|
}
|
|
|
if thisinfo.ContractCode != "" {
|
|
|
- tmpPro["contractcode"] = pInfo.ContractCode + "," + thisinfo.ContractCode
|
|
|
+ tmpPro["contractcode"] = project.ContractCode + "," + thisinfo.ContractCode
|
|
|
}
|
|
|
// 代理机构 相同的代理机构才会合并到一个项目 2020.11.9
|
|
|
//if (pInfo.Agency == "" && thisinfo.Agency != "") || (len([]rune(pInfo.Agency)) < 5 && len([]rune(thisinfo.Agency)) > 5) {
|
|
@@ -1001,26 +1029,26 @@ func (p *ProjectTask) updateOldProField(pInfo *ProjectInfo, thisinfo *Info, tmpP
|
|
|
// set["agency"] = thisinfo.Agency
|
|
|
//}
|
|
|
if len(thisinfo.Topscopeclass) > 0 {
|
|
|
- sort.Strings(pInfo.Topscopeclass)
|
|
|
+ sort.Strings(project.Topscopeclass)
|
|
|
for _, k := range thisinfo.Topscopeclass {
|
|
|
- if BinarySearch(pInfo.Topscopeclass, k) == -1 {
|
|
|
- pInfo.Topscopeclass = append(pInfo.Topscopeclass, k)
|
|
|
- sort.Strings(pInfo.Topscopeclass)
|
|
|
+ if BinarySearch(project.Topscopeclass, k) == -1 {
|
|
|
+ project.Topscopeclass = append(project.Topscopeclass, k)
|
|
|
+ sort.Strings(project.Topscopeclass)
|
|
|
}
|
|
|
}
|
|
|
- tmpPro["topscopeclass"] = pInfo.Topscopeclass
|
|
|
+ tmpPro["topscopeclass"] = project.Topscopeclass
|
|
|
}
|
|
|
// 项目评审专家
|
|
|
if len(thisinfo.ReviewExperts) > 0 {
|
|
|
tmpPro["review_experts"] = thisinfo.ReviewExperts
|
|
|
- pInfo.ReviewExperts = thisinfo.ReviewExperts
|
|
|
+ project.ReviewExperts = thisinfo.ReviewExperts
|
|
|
}
|
|
|
if thisinfo.Purchasing != "" {
|
|
|
- if pInfo.Purchasing == "" {
|
|
|
- pInfo.Purchasing = thisinfo.Purchasing
|
|
|
+ if project.Purchasing == "" {
|
|
|
+ project.Purchasing = thisinfo.Purchasing
|
|
|
tmpPro["purchasing"] = thisinfo.Purchasing
|
|
|
} else {
|
|
|
- list := strings.Split(pInfo.Purchasing, ",")
|
|
|
+ list := strings.Split(project.Purchasing, ",")
|
|
|
for _, k := range list {
|
|
|
if BinarySearch(strings.Split(thisinfo.Purchasing, ","), k) == -1 {
|
|
|
list = append(list, k)
|
|
@@ -1039,55 +1067,55 @@ func (p *ProjectTask) updateOldProField(pInfo *ProjectInfo, thisinfo *Info, tmpP
|
|
|
}
|
|
|
}
|
|
|
tmpPro["winnerorder"] = list
|
|
|
- pInfo.Winnerorder = list
|
|
|
+ project.Winnerorder = list
|
|
|
}
|
|
|
|
|
|
if len(thisinfo.Subscopeclass) > 0 {
|
|
|
- sort.Strings(pInfo.Subscopeclass)
|
|
|
+ sort.Strings(project.Subscopeclass)
|
|
|
for _, k := range thisinfo.Subscopeclass {
|
|
|
- if BinarySearch(pInfo.Subscopeclass, k) == -1 {
|
|
|
- pInfo.Subscopeclass = append(pInfo.Subscopeclass, k)
|
|
|
- sort.Strings(pInfo.Subscopeclass)
|
|
|
+ if BinarySearch(project.Subscopeclass, k) == -1 {
|
|
|
+ project.Subscopeclass = append(project.Subscopeclass, k)
|
|
|
+ sort.Strings(project.Subscopeclass)
|
|
|
}
|
|
|
}
|
|
|
- tmpPro["subscopeclass"] = pInfo.Subscopeclass
|
|
|
- tmpPro["s_subscopeclass"] = strings.Join(pInfo.Subscopeclass, ",")
|
|
|
+ tmpPro["subscopeclass"] = project.Subscopeclass
|
|
|
+ tmpPro["s_subscopeclass"] = strings.Join(project.Subscopeclass, ",")
|
|
|
}
|
|
|
|
|
|
if len(thisinfo.Winners) > 0 {
|
|
|
- if len(pInfo.Winners) <= 0 {
|
|
|
+ if len(project.Winners) <= 0 {
|
|
|
tmpPro["winner"] = qu.ObjToString(tmp["winner"])
|
|
|
}
|
|
|
- sort.Strings(pInfo.Winners)
|
|
|
+ winners := strings.Split(project.Winners, ",")
|
|
|
for _, k := range thisinfo.Winners {
|
|
|
if thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
|
|
|
- if BinarySearch(pInfo.Winners, k) != -1 {
|
|
|
- deleteSlice(pInfo.Winners, k, "")
|
|
|
- sort.Strings(pInfo.Winners)
|
|
|
+ if BinarySearch(winners, k) != -1 {
|
|
|
+ deleteSlice(winners, k, "")
|
|
|
}
|
|
|
} else {
|
|
|
- if BinarySearch(pInfo.Winners, k) == -1 {
|
|
|
- pInfo.Winners = append(pInfo.Winners, k)
|
|
|
- sort.Strings(pInfo.Winners)
|
|
|
+ if BinarySearch(winners, k) == -1 {
|
|
|
+ winners = append(winners, k)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- tmpPro["s_winner"] = strings.Join(pInfo.Winners, ",")
|
|
|
+ tmpPro["s_winner"] = strings.Join(winners, ",")
|
|
|
}
|
|
|
|
|
|
if thisinfo.HasPackage { //多包处理
|
|
|
tmpPro["multipackage"] = 1
|
|
|
- pkg := PackageFormat(thisinfo, pInfo)
|
|
|
- pInfo.Package = pkg
|
|
|
- tmpPro["package"] = pInfo.Package
|
|
|
+ pkg := PackageFormat(thisinfo, project)
|
|
|
+ project.Package = pkg
|
|
|
+ tmpPro["package"] = project.Package
|
|
|
}
|
|
|
//处理多包后,计算预算金额、中标金额
|
|
|
- CountAmount(pInfo, thisinfo, tmp)
|
|
|
- if pInfo.Budget >= 0 && pInfo.Budgettag != 1 {
|
|
|
+ CountAmount(project, thisinfo, tmp)
|
|
|
+ if project.Budget >= 0 && project.Budgettag != 1 {
|
|
|
+ pInfo.Budget = project.Budget
|
|
|
tmpPro["budget"] = pInfo.Budget
|
|
|
tmpPro["budgettag"] = 0
|
|
|
}
|
|
|
- if pInfo.Bidamount >= 0 && pInfo.Bidamounttag != 1 {
|
|
|
+ if project.Bidamount >= 0 && project.Bidamounttag != 1 {
|
|
|
+ pInfo.Bidamount = project.Bidamount
|
|
|
tmpPro["bidamount"] = pInfo.Bidamount
|
|
|
tmpPro["bidamounttag"] = 0
|
|
|
}
|
|
@@ -1105,14 +1133,14 @@ func (p *ProjectTask) updateOldProField(pInfo *ProjectInfo, thisinfo *Info, tmpP
|
|
|
ProjectCode: thisinfo.ProjectCode,
|
|
|
Bidstatus: pInfo.Bidstatus,
|
|
|
}
|
|
|
- copyMap := Copy(pInfo.InfoFiled).(map[string]InfoField)
|
|
|
+ copyMap := Copy(project.InfoFiled).(map[string]InfoField)
|
|
|
copyMap[thisinfo.Id] = infofield
|
|
|
tmpMap := make(map[string]interface{})
|
|
|
for k, v := range copyMap {
|
|
|
tmpMap[k] = StructToMap(v)
|
|
|
}
|
|
|
tmpMap[thisinfo.Id] = StructToMap(infofield)
|
|
|
- pInfo.InfoFiled = copyMap
|
|
|
+ project.InfoFiled = copyMap
|
|
|
tmpPro["infofield"] = tmpMap
|
|
|
tmpPro["mpn"] = pInfo.MPN
|
|
|
tmpPro["mpc"] = pInfo.MPC
|
|
@@ -1185,7 +1213,7 @@ func backupPro(tmp map[string]interface{}) {
|
|
|
tmp1[k] = v
|
|
|
}
|
|
|
if Sysconfig["backupFlag"].(bool) {
|
|
|
- tmp1["sourceprojectid"] = BsonIdToSId(tmp1["_id"])
|
|
|
+ tmp1["sourceprojectid"] = mongodb.BsonIdToSId(tmp1["_id"])
|
|
|
delete(tmp1, "_id")
|
|
|
MongoTool.Save(BackupColl, tmp1)
|
|
|
}
|
|
@@ -1204,12 +1232,12 @@ func delOldPro(pid string) {
|
|
|
// 修改内存中的数据
|
|
|
func (p *ProjectTask) modifyMem(tmpPro map[string]interface{}) {
|
|
|
pid := qu.ObjToString(tmpPro["_id"])
|
|
|
- var pro ProjectInfo
|
|
|
+ var pro ProjectCache
|
|
|
err := mapstructure.Decode(tmpPro, &pro)
|
|
|
if err != nil {
|
|
|
qu.Debug(err)
|
|
|
}
|
|
|
- pro.Id = StringTOBsonId(pid)
|
|
|
+ pro.Id = mongodb.StringTOBsonId(pid)
|
|
|
tmpMap := make(map[string]InfoField)
|
|
|
infoMap := tmpPro["infofield"].(map[string]interface{})
|
|
|
for _, v := range infoMap {
|
|
@@ -1218,7 +1246,6 @@ func (p *ProjectTask) modifyMem(tmpPro map[string]interface{}) {
|
|
|
_ = json.Unmarshal(b, &field)
|
|
|
tmpMap[pid] = field
|
|
|
}
|
|
|
- pro.InfoFiled = tmpMap
|
|
|
p.AllIdsMapLock.Lock()
|
|
|
if v, ok := p.AllIdsMap[pid]; ok {
|
|
|
v.P = &pro
|
|
@@ -1235,3 +1262,646 @@ func (p *ProjectTask) printMemPro(pid string) {
|
|
|
}
|
|
|
p.AllIdsMapLock.Unlock()
|
|
|
}
|
|
|
+
|
|
|
+// @Description id不变,内容变化 重新进行项目合并
|
|
|
+// @Author J 2022/8/10 14:51
|
|
|
+func (p *ProjectTask) taskinfo(id string) {
|
|
|
+ tmpPro, _ := MongoTool.FindOneByField(ProjectColl, map[string]interface{}{"ids": id}, nil)
|
|
|
+ if tmpPro == nil || len(*tmpPro) == 0 {
|
|
|
+ qu.Debug(fmt.Sprintf("taskinfo bidding id=%s 未查询到项目数据", id))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ pid := mongodb.BsonIdToSId((*tmpPro)["_id"])
|
|
|
+ ids := qu.ObjArrToStringArr((*tmpPro)["ids"].([]interface{}))
|
|
|
+ list := (*tmpPro)["list"].([]interface{})
|
|
|
+
|
|
|
+ var newP map[string]interface{}
|
|
|
+ var p1 *ProjectCache
|
|
|
+ for i, s := range ids {
|
|
|
+ temp, _ := MongoTool.FindById(ExtractColl, s, nil)
|
|
|
+ if temp == nil || len(*temp) == 0 {
|
|
|
+ temp, _ = MongoTool.FindById(ExtractColl1, s, nil)
|
|
|
+ if temp == nil || len(*temp) == 0 {
|
|
|
+ qu.Debug("extract not find id...", s)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ push := p.PushListInfo(*temp, id)
|
|
|
+ if s == id {
|
|
|
+ list[i] = push
|
|
|
+ }
|
|
|
+
|
|
|
+ info := ParseInfo(*temp)
|
|
|
+ if i == 0 {
|
|
|
+ newP, p1 = p.createPro(*temp, info, pid)
|
|
|
+ } else {
|
|
|
+ p.updatePro(newP, *temp, p1, info)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ newP["ids"] = ids
|
|
|
+ p.AllIdsMapLock.Lock()
|
|
|
+ _, ok := p.AllIdsMap[pid]
|
|
|
+ if ok {
|
|
|
+ redis.PutCKV("project", pid, newP)
|
|
|
+ p.AllIdsMap[id] = &ID{Id: id, P: p1}
|
|
|
+ }
|
|
|
+ p.AllIdsMapLock.Unlock()
|
|
|
+ newP["list"] = list
|
|
|
+ if len(newP) > 0 {
|
|
|
+ updateInfo := []map[string]interface{}{
|
|
|
+ {
|
|
|
+ "_id": mongodb.StringTOBsonId(pid),
|
|
|
+ },
|
|
|
+ {"$set": newP},
|
|
|
+ }
|
|
|
+ p.updatePool <- updateInfo
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// @Description 创建项目
|
|
|
+// @Author J 2022/8/11 09:17
|
|
|
+func (p *ProjectTask) createPro(tmp map[string]interface{}, thisinfo *Info, pid string) (map[string]interface{}, *ProjectCache) {
|
|
|
+ set := map[string]interface{}{}
|
|
|
+ set["_id"] = mongodb.StringTOBsonId(pid)
|
|
|
+ for _, f := range FIELDS {
|
|
|
+ if tmp[f] != nil && tmp[f] != "" {
|
|
|
+ set[f] = tmp[f]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bidopentime := qu.Int64All(tmp["bidopentime"])
|
|
|
+ if bidopentime > 0 {
|
|
|
+ set["bidopentime"] = bidopentime
|
|
|
+ }
|
|
|
+ //异常标记
|
|
|
+ if thisinfo.TopType != "招标" && thisinfo.TopType != "拟建" && thisinfo.TopType != "预告" {
|
|
|
+ set["exception"] = 1
|
|
|
+ }
|
|
|
+ //projecthref保存
|
|
|
+ if jsonData, ok := tmp["jsondata"].(map[string]interface{}); ok {
|
|
|
+ if jsonData != nil && qu.ObjToString(jsonData["projecthref"]) != "" {
|
|
|
+ set["projecthref"] = jsonData["projecthref"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //合同编号
|
|
|
+ if thisinfo.ContractCode != "" {
|
|
|
+ set["contractcode"] = thisinfo.ContractCode
|
|
|
+ }
|
|
|
+
|
|
|
+ bt := qu.ObjToString(tmp["toptype"])
|
|
|
+ bs := qu.ObjToString(tmp["subtype"])
|
|
|
+ p.mapBidLock.Lock()
|
|
|
+ if thisinfo.Infoformat == 2 || thisinfo.SubType == "拟建" {
|
|
|
+ set["bidstatus"] = "拟建"
|
|
|
+ bt = "拟建"
|
|
|
+ } else {
|
|
|
+ if bidtype[bs] != "" {
|
|
|
+ set["bidtype"] = bidtype[bs]
|
|
|
+ } else {
|
|
|
+ set["bidtype"] = "招标"
|
|
|
+ }
|
|
|
+ if bt == "招标" {
|
|
|
+ set["projectscope"] = qu.ObjToString(tmp["projectscope"])
|
|
|
+ set["bidstatus"] = bt
|
|
|
+ } else {
|
|
|
+ if bidstatus[bs] != "" {
|
|
|
+ set["bidstatus"] = thisinfo.SubType
|
|
|
+ bt = thisinfo.SubType
|
|
|
+ } else if bs == "" {
|
|
|
+ set["bidstatus"] = ""
|
|
|
+ bt = ""
|
|
|
+ } else {
|
|
|
+ set["bidstatus"] = "其它"
|
|
|
+ bt = "其它"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ p.mapBidLock.Unlock()
|
|
|
+
|
|
|
+ pkg := PackageFormat(thisinfo, nil)
|
|
|
+ p1 := p.NewCachePinfo(mongodb.StringTOBsonId(pid), thisinfo, bs, bt)
|
|
|
+
|
|
|
+ now := time.Now().Unix()
|
|
|
+ set["createtime"] = now
|
|
|
+ set["sourceinfoid"] = thisinfo.Id
|
|
|
+ set["sourceinfourl"] = tmp["href"]
|
|
|
+ set["firsttime"] = tmp["publishtime"]
|
|
|
+ set["lasttime"] = tmp["publishtime"]
|
|
|
+ //增量用系统时间,全量(历史)入库时间
|
|
|
+ if p.currentType == "pl" {
|
|
|
+ set["pici"] = tmp["comeintime"]
|
|
|
+ } else {
|
|
|
+ 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"]
|
|
|
+ }
|
|
|
+ if len(thisinfo.Subscopeclass) > 0 {
|
|
|
+ set["s_subscopeclass"] = strings.Join(thisinfo.Subscopeclass, ",")
|
|
|
+ }
|
|
|
+ if len(thisinfo.Winners) > 0 {
|
|
|
+ set["s_winner"] = strings.Join(thisinfo.Winners, ",")
|
|
|
+ }
|
|
|
+ if thisinfo.HasPackage {
|
|
|
+ set["multipackage"] = 1
|
|
|
+ set["package"] = pkg
|
|
|
+ } else {
|
|
|
+ set["multipackage"] = 0
|
|
|
+ }
|
|
|
+ //项目评审专家
|
|
|
+ if len(thisinfo.ReviewExperts) > 0 {
|
|
|
+ set["review_experts"] = thisinfo.ReviewExperts
|
|
|
+ }
|
|
|
+ //标的物
|
|
|
+ if thisinfo.Purchasing != "" {
|
|
|
+ list := Duplicate(strings.Split(thisinfo.Purchasing, ",")) //标的物 去重 03/03
|
|
|
+ p := strings.Join(qu.ObjArrToStringArr(list), ",")
|
|
|
+ set["purchasing"] = p
|
|
|
+ }
|
|
|
+ //中标候选人
|
|
|
+ if len(thisinfo.WinnerOrder) > 0 {
|
|
|
+ var list = []string{}
|
|
|
+ for _, v := range thisinfo.WinnerOrder {
|
|
|
+ if BinarySearch(list, qu.ObjToString(v["entname"])) == -1 {
|
|
|
+ list = append(list, qu.ObjToString(v["entname"]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set["winnerorder"] = list
|
|
|
+ }
|
|
|
+ //项目规模
|
|
|
+ if len(thisinfo.ProjectScale) > 0 {
|
|
|
+ set["project_scale"] = thisinfo.ProjectScale
|
|
|
+ }
|
|
|
+ //工期时长
|
|
|
+ if thisinfo.ProjectDuration > 0 {
|
|
|
+ set["project_duration"] = thisinfo.ProjectDuration
|
|
|
+ }
|
|
|
+ // 工期单位
|
|
|
+ if thisinfo.ProjectDuration > 0 && len(thisinfo.ProjectTimeUnit) > 0 {
|
|
|
+ set["project_timeunit"] = thisinfo.ProjectTimeUnit
|
|
|
+ }
|
|
|
+ //开工日期
|
|
|
+ if thisinfo.ProjectStartDate > 0 {
|
|
|
+ set["project_startdate"] = thisinfo.ProjectStartDate
|
|
|
+ }
|
|
|
+ //竣工日期
|
|
|
+ if thisinfo.ProjectCompleteDate > 0 {
|
|
|
+ set["project_completedate"] = thisinfo.ProjectCompleteDate
|
|
|
+ }
|
|
|
+ //付款方式
|
|
|
+ if len(thisinfo.Payway) > 0 {
|
|
|
+ set["payway"] = thisinfo.Payway
|
|
|
+ }
|
|
|
+ // 履约保证金
|
|
|
+ if tmp["contract_guarantee"] != nil {
|
|
|
+ set["contract_guarantee"] = thisinfo.ContractGuarantee
|
|
|
+ }
|
|
|
+ // 投标保证金
|
|
|
+ if tmp["bid_guarantee"] != nil {
|
|
|
+ set["bid_guarantee"] = thisinfo.BidGuarantee
|
|
|
+ }
|
|
|
+ // 资质条件
|
|
|
+ if len(thisinfo.Qualifies) > 0 {
|
|
|
+ var str []string
|
|
|
+ for _, v := range thisinfo.Qualifies {
|
|
|
+ if len(qu.ObjToString(v["key"])) > 0 {
|
|
|
+ if BinarySearch(str, qu.ObjToString(v["key"])) == -1 {
|
|
|
+ str = append(str, qu.ObjToString(v["key"]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(str) > 0 {
|
|
|
+ set["qualifies"] = strings.Join(str, ",")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(thisinfo.EntIdList) > 0 {
|
|
|
+ set["entidlist"] = thisinfo.EntIdList
|
|
|
+ }
|
|
|
+ // first_cooperation
|
|
|
+ if p1.Buyer != "" && len(thisinfo.Winners) > 0 {
|
|
|
+ FirstCooperation(set, p1.Buyer, thisinfo.Winners, thisinfo.EntIdList)
|
|
|
+ }
|
|
|
+
|
|
|
+ infofield := InfoField{
|
|
|
+ Budget: thisinfo.Budget,
|
|
|
+ Bidamount: thisinfo.Bidamount,
|
|
|
+ ContractCode: thisinfo.ContractCode,
|
|
|
+ ProjectName: thisinfo.ProjectName,
|
|
|
+ ProjectCode: thisinfo.ProjectCode,
|
|
|
+ Bidstatus: bs,
|
|
|
+ }
|
|
|
+ res := StructToMap(infofield)
|
|
|
+ set["infofield"] = map[string]interface{}{
|
|
|
+ thisinfo.Id: res,
|
|
|
+ }
|
|
|
+ if tmp["budget"] != nil && tmp["budget"] != "" {
|
|
|
+ set["budget"] = thisinfo.Budget
|
|
|
+ set["budgettag"] = 0
|
|
|
+ } else {
|
|
|
+ set["budgettag"] = 1
|
|
|
+ }
|
|
|
+ if tmp["bidamount"] != nil && tmp["bidamount"] != "" {
|
|
|
+ set["bidamount"] = thisinfo.Bidamount
|
|
|
+ set["bidamounttag"] = 0
|
|
|
+ } else {
|
|
|
+ set["bidamounttag"] = 1
|
|
|
+ }
|
|
|
+ if p1.Bidamount > 0 {
|
|
|
+ set["sortprice"] = p1.Bidamount
|
|
|
+ } else {
|
|
|
+ if p1.Budget > 0 {
|
|
|
+ set["sortprice"] = p1.Budget
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return set, &p1
|
|
|
+}
|
|
|
+
|
|
|
+// @Description id不变,内容覆盖 修改项目
|
|
|
+// @Author J 2022/8/10 17:00
|
|
|
+func (p *ProjectTask) updatePro(set, tmp map[string]interface{}, pInfo *ProjectCache, thisinfo *Info) {
|
|
|
+ bys, _ := json.Marshal(set)
|
|
|
+ var project *Project
|
|
|
+ err := json.Unmarshal(bys, &project)
|
|
|
+ if err != nil {
|
|
|
+ qu.Debug("project Unmarshal err,", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //zbtime、lasttime、jgtime
|
|
|
+ pInfo.LastTime = thisinfo.Publishtime
|
|
|
+ set["lasttime"] = thisinfo.Publishtime
|
|
|
+
|
|
|
+ if thisinfo.TopType == "招标" {
|
|
|
+ if project.Zbtime <= 0 {
|
|
|
+ project.Zbtime = thisinfo.Publishtime
|
|
|
+ set["zbtime"] = tmp["publishtime"]
|
|
|
+ }
|
|
|
+ if project.Jgtime > 0 {
|
|
|
+ project.Jgtime = int64(0)
|
|
|
+ set["jgtime"] = int64(0)
|
|
|
+ }
|
|
|
+ } else if thisinfo.TopType == "结果" {
|
|
|
+ if thisinfo.SubType == "中标" || thisinfo.SubType == "成交" || thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
|
|
|
+ if project.Jgtime > 0 {
|
|
|
+ //jg1 := int64(math.Abs(float64(pInfo.Jgtime - thisinfo.Publishtime)))
|
|
|
+ //公告状态和项目状态同样都是中标或者成交,
|
|
|
+ if thisinfo.SubType == "成交" && project.Bidstatus == "中标" {
|
|
|
+ if p.jgTime < thisinfo.Publishtime {
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
+ set["jgtime"] = tmp["publishtime"]
|
|
|
+ }
|
|
|
+ //公告状态和项目状态同样是流标或者废标
|
|
|
+ } else if (thisinfo.SubType == "流标" || thisinfo.SubType == "废标") && (project.Bidstatus == "流标" || project.Bidstatus == "废标") {
|
|
|
+ if p.jgTime < thisinfo.Publishtime {
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
+ set["jgtime"] = tmp["publishtime"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
+ set["jgtime"] = tmp["publishtime"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if thisinfo.SubType == "合同" {
|
|
|
+ if project.Bidstatus == "中标" || project.Bidstatus == "成交" || project.Bidstatus == "" {
|
|
|
+ //中标、成交不更新jgtime
|
|
|
+ } else {
|
|
|
+ project.Jgtime = thisinfo.Publishtime
|
|
|
+ set["jgtime"] = tmp["publishtime"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if thisinfo.Bidopentime > project.Bidopentime {
|
|
|
+ project.Bidopentime = thisinfo.Bidopentime
|
|
|
+ set["bidopentime"] = project.Bidopentime
|
|
|
+ }
|
|
|
+
|
|
|
+ bt := qu.ObjToString(tmp["toptype"])
|
|
|
+ bs := qu.ObjToString(tmp["subtype"])
|
|
|
+ p.mapBidLock.Lock()
|
|
|
+ if bt == "招标" {
|
|
|
+ //招标状态,更新projectscope
|
|
|
+ if tmp["projectscope"] != nil {
|
|
|
+ set["projectscope"] = qu.ObjToString(tmp["projectscope"])
|
|
|
+ }
|
|
|
+ set["bidstatus"] = bt
|
|
|
+ project.Bidstatus = bt
|
|
|
+ if bidtype[bs] != "" {
|
|
|
+ set["bidtype"] = bidtype[bs]
|
|
|
+ project.Bidtype = bidtype[bs]
|
|
|
+ } else {
|
|
|
+ set["bidtype"] = "招标"
|
|
|
+ project.Bidtype = "招标"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if bidstatus[bs] != "" {
|
|
|
+ set["bidstatus"] = thisinfo.SubType
|
|
|
+ project.Bidstatus = thisinfo.SubType
|
|
|
+ } else if thisinfo.Infoformat == 2 {
|
|
|
+ set["bidstatus"] = "拟建"
|
|
|
+ project.Bidstatus = "拟建"
|
|
|
+ } else if bs == "" && bt == "结果" {
|
|
|
+ if project.Bidstatus == "招标" {
|
|
|
+ set["bidstatus"] = ""
|
|
|
+ project.Bidstatus = ""
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ set["bidstatus"] = "其它"
|
|
|
+ project.Bidstatus = "其它"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ p.mapBidLock.Unlock()
|
|
|
+
|
|
|
+ //相同城市的公告才会合并到一起(全国列外)
|
|
|
+ if thisinfo.Area != "全国" {
|
|
|
+ pInfo.Area = thisinfo.Area
|
|
|
+ project.Area = thisinfo.Area
|
|
|
+ set["area"] = thisinfo.Area
|
|
|
+ if thisinfo.City != "" {
|
|
|
+ pInfo.City = thisinfo.City
|
|
|
+ project.City = thisinfo.City
|
|
|
+ set["city"] = thisinfo.City
|
|
|
+ }
|
|
|
+ if thisinfo.District != "" {
|
|
|
+ pInfo.District = thisinfo.District
|
|
|
+ project.District = thisinfo.District
|
|
|
+ set["district"] = thisinfo.District
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //项目名称
|
|
|
+ //if (thisinfo.ProjectName != "" && pInfo.ProjectName == "") || (len([]rune(pInfo.ProjectName)) < 6 && thisinfo.LenPN > 6) {
|
|
|
+ if pInfo.ProjectName == "" && thisinfo.ProjectName != "" {
|
|
|
+ pInfo.ProjectName = thisinfo.ProjectName
|
|
|
+ project.ProjectName = thisinfo.ProjectName
|
|
|
+ set["projectname"] = thisinfo.ProjectName
|
|
|
+ }
|
|
|
+ //7--项目编号
|
|
|
+ //if (pInfo.ProjectCode == "" && thisinfo.ProjectCode != "") || (len([]rune(pInfo.ProjectCode)) < 6 && len([]rune(thisinfo.ProjectCode)) > 6) {
|
|
|
+ if pInfo.ProjectCode == "" && thisinfo.ProjectCode != "" {
|
|
|
+ pInfo.ProjectCode = thisinfo.ProjectCode
|
|
|
+ project.ProjectCode = thisinfo.ProjectCode
|
|
|
+ set["projectcode"] = thisinfo.ProjectCode
|
|
|
+ }
|
|
|
+ //7--采购单位
|
|
|
+ if (pInfo.Buyer == "" && thisinfo.Buyer != "") || (len([]rune(pInfo.Buyer)) < 5 && len([]rune(thisinfo.Buyer)) > 5) {
|
|
|
+ pInfo.Buyer = thisinfo.Buyer
|
|
|
+ project.Buyer = thisinfo.Buyer
|
|
|
+ set["buyer"] = thisinfo.Buyer
|
|
|
+
|
|
|
+ project.Buyerclass = thisinfo.Buyerclass
|
|
|
+ set["buyerclass"] = thisinfo.Buyerclass
|
|
|
+ }
|
|
|
+ if pInfo.Buyer == "" {
|
|
|
+ project.Buyerclass = ""
|
|
|
+ set["buyerclass"] = ""
|
|
|
+ }
|
|
|
+ //采购单位联系人
|
|
|
+ if thisinfo.Buyerperson != "" {
|
|
|
+ project.Buyerperson = thisinfo.Buyerperson
|
|
|
+ set["buyerperson"] = thisinfo.Buyerperson
|
|
|
+ } else {
|
|
|
+ project.Buyerperson = ""
|
|
|
+ set["buyerperson"] = ""
|
|
|
+ }
|
|
|
+ //采购单位電話
|
|
|
+ if thisinfo.Buyertel != "" {
|
|
|
+ project.Buyertel = thisinfo.Buyertel
|
|
|
+ set["buyertel"] = project.Buyertel
|
|
|
+ } else {
|
|
|
+ project.Buyertel = ""
|
|
|
+ set["buyertel"] = ""
|
|
|
+ }
|
|
|
+ if thisinfo.ContractCode != "" {
|
|
|
+ if project.ContractCode == "" {
|
|
|
+ set["contractcode"] = thisinfo.ContractCode
|
|
|
+ } else {
|
|
|
+ list := strings.Split(project.ContractCode, ",")
|
|
|
+ if BinarySearch(list, thisinfo.ContractCode) == -1 {
|
|
|
+ list = append(list, thisinfo.ContractCode)
|
|
|
+ sort.Strings(list)
|
|
|
+ }
|
|
|
+ set["contractcode"] = strings.Join(list, ",")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //8--代理机构
|
|
|
+ if (pInfo.Agency == "" && thisinfo.Agency != "") || (len([]rune(pInfo.Agency)) < 5 && len([]rune(thisinfo.Agency)) > 5) {
|
|
|
+ pInfo.Agency = thisinfo.Agency
|
|
|
+ project.Agency = thisinfo.Agency
|
|
|
+ set["agency"] = thisinfo.Agency
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(thisinfo.Topscopeclass) > 0 {
|
|
|
+ sort.Strings(project.Topscopeclass)
|
|
|
+ for _, k := range thisinfo.Topscopeclass {
|
|
|
+ if BinarySearch(project.Topscopeclass, k) == -1 {
|
|
|
+ project.Topscopeclass = append(project.Topscopeclass, k)
|
|
|
+ sort.Strings(project.Topscopeclass)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set["topscopeclass"] = project.Topscopeclass
|
|
|
+ }
|
|
|
+
|
|
|
+ //项目评审专家
|
|
|
+ if len(thisinfo.ReviewExperts) > 0 {
|
|
|
+ set["review_experts"] = thisinfo.ReviewExperts
|
|
|
+ project.ReviewExperts = thisinfo.ReviewExperts
|
|
|
+ }
|
|
|
+ if thisinfo.Purchasing != "" {
|
|
|
+ if project.Purchasing == "" {
|
|
|
+ list := Duplicate(strings.Split(thisinfo.Purchasing, ",")) //标的物 去重 03/03
|
|
|
+ p := strings.Join(qu.ObjArrToStringArr(list), ",")
|
|
|
+ project.Purchasing = p
|
|
|
+ set["purchasing"] = p
|
|
|
+ } else {
|
|
|
+ list := strings.Split(project.Purchasing, ",")
|
|
|
+ list = qu.ObjArrToStringArr(Duplicate(list))
|
|
|
+ for _, k := range list {
|
|
|
+ if BinarySearch(strings.Split(thisinfo.Purchasing, ","), k) == -1 {
|
|
|
+ list = append(list, k)
|
|
|
+ sort.Strings(list)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set["purchasing"] = strings.Join(list, ",")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //中标候选人
|
|
|
+ if len(thisinfo.WinnerOrder) > 0 {
|
|
|
+ var list = []string{}
|
|
|
+ for _, v := range thisinfo.WinnerOrder {
|
|
|
+ if BinarySearch(list, qu.ObjToString(v["entname"])) == -1 {
|
|
|
+ list = append(list, qu.ObjToString(v["entname"]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set["winnerorder"] = list
|
|
|
+ project.Winnerorder = list
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(thisinfo.Subscopeclass) > 0 {
|
|
|
+ sort.Strings(project.Subscopeclass)
|
|
|
+ for _, k := range thisinfo.Subscopeclass {
|
|
|
+ if BinarySearch(project.Subscopeclass, k) == -1 {
|
|
|
+ project.Subscopeclass = append(project.Subscopeclass, k)
|
|
|
+ sort.Strings(project.Subscopeclass)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set["subscopeclass"] = project.Subscopeclass
|
|
|
+ set["s_subscopeclass"] = strings.Join(project.Subscopeclass, ",")
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(thisinfo.Winners) > 0 {
|
|
|
+ if len(project.Winners) <= 0 {
|
|
|
+ set["winner"] = qu.ObjToString(tmp["winner"])
|
|
|
+ }
|
|
|
+ winners := strings.Split(project.Winners, ",")
|
|
|
+ for _, k := range thisinfo.Winners {
|
|
|
+ if thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
|
|
|
+ if BinarySearch(winners, k) != -1 {
|
|
|
+ deleteSlice(winners, k, "")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if BinarySearch(winners, k) == -1 {
|
|
|
+ winners = append(winners, k)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ set["s_winner"] = strings.Join(qu.ObjArrToStringArr(Duplicate(winners)), ",")
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(thisinfo.EntIdList) > 0 {
|
|
|
+ for _, v := range thisinfo.EntIdList {
|
|
|
+ if BinarySearch(project.EntIdList, v) == -1 {
|
|
|
+ project.EntIdList = append(project.EntIdList, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set["entidlist"] = project.EntIdList
|
|
|
+ }
|
|
|
+ // first_cooperation
|
|
|
+ if pInfo.Buyer != "" && len(strings.Split(project.Winners, ",")) > 0 {
|
|
|
+ FirstCooperation(set, pInfo.Buyer, strings.Split(project.Winners, ","), project.EntIdList)
|
|
|
+ }
|
|
|
+
|
|
|
+ //项目规模
|
|
|
+ if len(thisinfo.ProjectScale) > 0 {
|
|
|
+ project.ProjectScale = thisinfo.ProjectScale
|
|
|
+ set["project_scale"] = thisinfo.ProjectScale
|
|
|
+ }
|
|
|
+ //工期时长
|
|
|
+ if thisinfo.ProjectDuration > 0 {
|
|
|
+ project.ProjectDuration = thisinfo.ProjectDuration
|
|
|
+ set["project_duration"] = thisinfo.ProjectDuration
|
|
|
+ }
|
|
|
+ // 工期单位
|
|
|
+ if thisinfo.ProjectDuration > 0 && len(thisinfo.ProjectTimeUnit) > 0 {
|
|
|
+ project.ProjectTimeunit = thisinfo.ProjectTimeUnit
|
|
|
+ set["project_timeunit"] = thisinfo.ProjectTimeUnit
|
|
|
+ }
|
|
|
+ //开工日期
|
|
|
+ if thisinfo.ProjectStartDate > 0 {
|
|
|
+ if project.ProjectStartDate > 0 {
|
|
|
+ if project.ProjectStartDate < thisinfo.ProjectStartDate {
|
|
|
+ project.ProjectStartDate = thisinfo.ProjectStartDate
|
|
|
+ set["project_startdate"] = thisinfo.ProjectStartDate
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ project.ProjectStartDate = thisinfo.ProjectStartDate
|
|
|
+ set["project_startdate"] = thisinfo.ProjectStartDate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //竣工日期
|
|
|
+ if thisinfo.ProjectCompleteDate > 0 {
|
|
|
+ if project.ProjctCompleteDate > 0 {
|
|
|
+ if project.ProjctCompleteDate < thisinfo.ProjectCompleteDate {
|
|
|
+ project.ProjctCompleteDate = thisinfo.ProjectCompleteDate
|
|
|
+ set["project_completedate"] = thisinfo.ProjectCompleteDate
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ project.ProjctCompleteDate = thisinfo.ProjectCompleteDate
|
|
|
+ set["project_completedate"] = thisinfo.ProjectCompleteDate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 付款方式
|
|
|
+ if len(thisinfo.Payway) > 0 {
|
|
|
+ project.Payway = thisinfo.Payway
|
|
|
+ set["payway"] = thisinfo.Payway
|
|
|
+ }
|
|
|
+ // 履约保证金
|
|
|
+ if tmp["contract_guarantee"] != nil {
|
|
|
+ project.ContractGuarantee = thisinfo.ContractGuarantee
|
|
|
+ set["contract_guarantee"] = thisinfo.ContractGuarantee
|
|
|
+ }
|
|
|
+ // 投标保证金
|
|
|
+ if tmp["bid_guarantee"] != nil {
|
|
|
+ project.BidGuarantee = thisinfo.BidGuarantee
|
|
|
+ set["bid_guarantee"] = thisinfo.BidGuarantee
|
|
|
+ }
|
|
|
+ // 资质条件
|
|
|
+ if len(thisinfo.Qualifies) > 0 {
|
|
|
+ var str []string
|
|
|
+ if len(project.Qualifies) > 0 {
|
|
|
+ str = append(str, strings.Split(project.Qualifies, ",")...)
|
|
|
+ }
|
|
|
+ for _, v := range thisinfo.Qualifies {
|
|
|
+ if len(qu.ObjToString(v["key"])) > 0 {
|
|
|
+ if BinarySearch(str, qu.ObjToString(v["key"])) == -1 {
|
|
|
+ str = append(str, qu.ObjToString(v["key"]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(str) > 0 {
|
|
|
+ project.Qualifies = strings.Join(str, ",")
|
|
|
+ set["qualifies"] = strings.Join(str, ",")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if thisinfo.HasPackage { //多包处理
|
|
|
+ set["multipackage"] = 1
|
|
|
+ pkg := PackageFormat(thisinfo, project)
|
|
|
+ project.Package = pkg
|
|
|
+ set["package"] = project.Package
|
|
|
+ }
|
|
|
+ //处理多包后,计算预算金额、中标金额
|
|
|
+ CountAmount(project, thisinfo, tmp)
|
|
|
+ if project.Budget >= 0 && project.Budgettag != 1 {
|
|
|
+ pInfo.Budget = project.Budget
|
|
|
+ set["budget"] = project.Budget
|
|
|
+ set["budgettag"] = 0
|
|
|
+ }
|
|
|
+ if project.Bidamount >= 0 && project.Bidamounttag != 1 {
|
|
|
+ pInfo.Bidamount = project.Bidamount
|
|
|
+ set["bidamount"] = pInfo.Bidamount
|
|
|
+ set["bidamounttag"] = 0
|
|
|
+ }
|
|
|
+ if pInfo.Bidamount > 0 {
|
|
|
+ set["sortprice"] = pInfo.Bidamount
|
|
|
+ } else {
|
|
|
+ if pInfo.Budget > 0 {
|
|
|
+ set["sortprice"] = pInfo.Budget
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ infofield := InfoField{
|
|
|
+ Budget: thisinfo.Budget,
|
|
|
+ Bidamount: thisinfo.Bidamount,
|
|
|
+ ContractCode: thisinfo.ContractCode,
|
|
|
+ ProjectName: thisinfo.ProjectName,
|
|
|
+ ProjectCode: thisinfo.ProjectCode,
|
|
|
+ Bidstatus: bs,
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpMap := set["infofield"].(map[string]interface{})
|
|
|
+ tmpMap[thisinfo.Id] = StructToMap(infofield)
|
|
|
+ set["infofield"] = tmpMap
|
|
|
+ copyMap := Copy(project.InfoFiled).(map[string]InfoField)
|
|
|
+ copyMap[thisinfo.Id] = infofield
|
|
|
+ project.InfoFiled = copyMap
|
|
|
+
|
|
|
+ set["mpn"] = pInfo.MPN
|
|
|
+ set["mpc"] = pInfo.MPC
|
|
|
+}
|