|
@@ -0,0 +1,1485 @@
|
|
|
+package main
|
|
|
+
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "log"
|
|
|
+ "math"
|
|
|
+ "mongodb"
|
|
|
+ qu "qfw/util"
|
|
|
+ "sort"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
|
+ "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
+)
|
|
|
+
|
|
|
+/**
|
|
|
+项目合并,对比,计算,合并,生成项目
|
|
|
+**/
|
|
|
+
|
|
|
+//从对应map中获取对比的项目id
|
|
|
+func (p *ProjectTask) getCompareIds(pn, pc, ptc, pb string) (bpn, bpc, bptc, bpb int, res []*Key, idArr []string, IDArr []*ID) {
|
|
|
+ // p.ConCurrentLock(n1, n2, n3, n4)
|
|
|
+ // defer p.ConCurrentUnLock(n1, n2, n3, n4)
|
|
|
+ p.wg.Add(1)
|
|
|
+ //查找到id数组
|
|
|
+ res = []*Key{}
|
|
|
+ //是否查找到,并标识位置。-1代表值为空或已经存在。
|
|
|
+ bpn, bpc, bptc, bpb = -1, -1, -1, -1
|
|
|
+ if pn != "" {
|
|
|
+ ids := p.mapPn[pn]
|
|
|
+ if ids == nil {
|
|
|
+ ids = &Key{Arr: []string{}}
|
|
|
+ p.mapPn[pn] = ids
|
|
|
+ bpn = 0
|
|
|
+ }
|
|
|
+ ids.Lock.Lock()
|
|
|
+ res = append(res, ids)
|
|
|
+ }
|
|
|
+
|
|
|
+ if pc != "" {
|
|
|
+ ids := p.mapPc[pc]
|
|
|
+ if ids == nil {
|
|
|
+ ids = &Key{Arr: []string{}}
|
|
|
+ p.mapPc[pc] = ids
|
|
|
+ bpc = len(res)
|
|
|
+ }
|
|
|
+ ids.Lock.Lock()
|
|
|
+ res = append(res, ids)
|
|
|
+ }
|
|
|
+
|
|
|
+ if ptc != "" {
|
|
|
+ ids := p.mapPc[ptc]
|
|
|
+ if ids == nil {
|
|
|
+ ids = &Key{Arr: []string{}}
|
|
|
+ p.mapPc[ptc] = ids
|
|
|
+ bptc = len(res)
|
|
|
+ }
|
|
|
+ ids.Lock.Lock()
|
|
|
+ res = append(res, ids)
|
|
|
+ }
|
|
|
+
|
|
|
+ if pb != "" {
|
|
|
+ ids := p.mapPb[pb]
|
|
|
+ if ids == nil {
|
|
|
+ ids = &Key{Arr: []string{}}
|
|
|
+ p.mapPb[pb] = ids
|
|
|
+ bpb = len(res)
|
|
|
+ }
|
|
|
+ ids.Lock.Lock()
|
|
|
+ res = append(res, ids)
|
|
|
+ }
|
|
|
+ repeatId := map[string]bool{}
|
|
|
+ idArr = []string{} //项目id
|
|
|
+ IDArr = []*ID{} //项目信息
|
|
|
+ for _, m := range res {
|
|
|
+ for _, id := range m.Arr {
|
|
|
+ if !repeatId[id] {
|
|
|
+ repeatId[id] = true
|
|
|
+ //_, _ = strconv.ParseInt(id[0:8], 16, 64)
|
|
|
+ p.AllIdsMapLock.Lock()
|
|
|
+ Id := p.AllIdsMap[id]
|
|
|
+ p.AllIdsMapLock.Unlock()
|
|
|
+ if Id != nil {
|
|
|
+ Id.Lock.Lock()
|
|
|
+ idArr = append(idArr, id)
|
|
|
+ IDArr = append(IDArr, Id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{}) {
|
|
|
+ p.findLock.Lock()
|
|
|
+ defer p.findLock.Unlock()
|
|
|
+
|
|
|
+ //只有或没有采购单位的无法合并
|
|
|
+ //bpn, bpc, bptc, bpb 是否查找到,并标识位置。-1代表未查找到。
|
|
|
+ //pids 是项目id数组集合
|
|
|
+ //IDArr,是单个项目ID对象集合
|
|
|
+ bpn, bpc, bptc, bpb, pids, _, IDArr := p.getCompareIds(info.ProjectName, info.ProjectCode, info.PTC, info.Buyer) //, info.LenPN, info.LenPC, info.LenPTC, len([]rune(info.Buyer)))
|
|
|
+ defer p.wg.Done()
|
|
|
+ //map--k为pn,ptn,pc,ptc,buyer值 v为Id数组和lock
|
|
|
+
|
|
|
+ for _, m := range pids {
|
|
|
+ defer m.Lock.Unlock()
|
|
|
+ }
|
|
|
+ for _, id := range IDArr {
|
|
|
+ defer id.Lock.Unlock()
|
|
|
+ }
|
|
|
+
|
|
|
+ bFindProject := false
|
|
|
+ findPid := ""
|
|
|
+ //获取完id,进行计算
|
|
|
+ //定义两组
|
|
|
+ comRes1 := []*ProjectInfo{} //优先级最高的对比结果数组
|
|
|
+ comRes2 := []*ProjectInfo{} //优化级其次
|
|
|
+ comRes3 := []*ProjectInfo{}
|
|
|
+ for _, v := range IDArr {
|
|
|
+ comStr := ""
|
|
|
+ compareProject := v.P
|
|
|
+ compareProject.score = 0
|
|
|
+ //问题出地LastTime!!!!!
|
|
|
+ diffTime := int64(math.Abs(float64(info.Publishtime - compareProject.LastTime)))
|
|
|
+ if diffTime <= p.validTime {
|
|
|
+ //代理机构完全不相同,直接新建项目
|
|
|
+ if CheckContain(compareProject.Agency, info.Agency) == 3 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //地区(省、市、区)不同,直接新建项目
|
|
|
+ if ComparePlace(compareProject, info) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ info.PNBH = 0
|
|
|
+ info.PCBH = 0
|
|
|
+ info.PTCBH = 0
|
|
|
+ compareStr, score := comparePNC(info, compareProject)
|
|
|
+
|
|
|
+ resVal, pjVal := Select(compareStr, info, compareProject)
|
|
|
+ //---------------------------------------
|
|
|
+ //log.Println(resVal, pjVal, compareProject)
|
|
|
+ if resVal > 0 {
|
|
|
+ compareBuyer, compareCity, compareTime, compareAgency, compareBudget, compareBidmount, score2 := p.compareBCTABB(info, compareProject, diffTime, score)
|
|
|
+
|
|
|
+ //项目名称、项目编号、标题项目编号、采购单位、省、市、发布时间、代理机构
|
|
|
+ comStr = compareStr + compareBuyer + compareCity + compareTime + compareAgency + compareBudget + compareBidmount
|
|
|
+ compareProject.comStr = comStr
|
|
|
+ compareProject.pjVal = pjVal
|
|
|
+ compareProject.resVal = resVal
|
|
|
+ //log.Println(compareProject.comStr)
|
|
|
+ eqV := compareResult(resVal, pjVal, score2, comStr, compareBuyer, compareCity, compareTime, compareAgency, compareBudget, compareBidmount)
|
|
|
+ if eqV == 1 {
|
|
|
+ comRes1 = append(comRes1, compareProject)
|
|
|
+ } else if eqV == 2 {
|
|
|
+ comRes2 = append(comRes2, compareProject)
|
|
|
+ } else if eqV == 3 {
|
|
|
+ comRes3 = append(comRes3, compareProject)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //--------------------------------对比完成-----------------------
|
|
|
+
|
|
|
+ //更新数组、更新项目
|
|
|
+ for kv, resN := range [][]*ProjectInfo{comRes1, comRes2, comRes3} {
|
|
|
+ if len(resN) > 0 {
|
|
|
+ if len(resN) > 1 {
|
|
|
+ sort.Slice(resN, func(i, j int) bool {
|
|
|
+ return resN[i].score > resN[j].score
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ ex := 0
|
|
|
+ resArr := []*ProjectInfo{}
|
|
|
+ for i, res := range resN {
|
|
|
+ choose, e := p.CompareStatus(resN[i], info)
|
|
|
+ if !choose {
|
|
|
+ ex = e
|
|
|
+ resArr = append(resArr, res)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(resArr) > 0 {
|
|
|
+ bFindProject = true
|
|
|
+ findPid = resArr[0].Id.Hex()
|
|
|
+ p.UpdateProject(tmp, info, resArr[0], kv+1, resArr[0].comStr, ex)
|
|
|
+ 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 {
|
|
|
+ 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 resArr[0].ProjectCode == "" {
|
|
|
+ resArr[0].ProjectCode = qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)
|
|
|
+ } else {
|
|
|
+ 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 resArr[0].Buyer == "" {
|
|
|
+ resArr[0].Buyer = info.Buyer
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ bFindProject = false
|
|
|
+ findPid = ""
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if !bFindProject {
|
|
|
+ //if !IsCreatePro(info) {
|
|
|
+ // qu.Debug("舍弃数据---", info.Id)
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ id, p1 := p.NewProject(tmp, info)
|
|
|
+ p.AllIdsMapLock.Lock()
|
|
|
+ p.AllIdsMap[id] = &ID{Id: id, P: p1}
|
|
|
+ p.AllIdsMapLock.Unlock()
|
|
|
+ for _, m := range pids {
|
|
|
+ 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) {
|
|
|
+ compareBuyer = "D"
|
|
|
+ if len([]rune(info.Buyer)) > 3 && len([]rune(cp.Buyer)) > 3 {
|
|
|
+ v := CheckContain(info.Buyer, cp.Buyer)
|
|
|
+ if v == 1 {
|
|
|
+ compareBuyer = "A"
|
|
|
+ score += 3
|
|
|
+ } else {
|
|
|
+ //v1 := CosineSimilar(info.Buyer, cp.Buyer)
|
|
|
+ if v == 2 {
|
|
|
+ compareBuyer = "B"
|
|
|
+ score += 1
|
|
|
+ } else {
|
|
|
+ compareBuyer = "C"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //---------------------------------------
|
|
|
+
|
|
|
+ compareCity = ""
|
|
|
+ if info.Area != "全国" && info.Area != "" && info.Area == cp.Area {
|
|
|
+ compareCity += "A"
|
|
|
+ score += 2
|
|
|
+ } else if info.Area == "全国" || cp.Area == "全国" {
|
|
|
+ compareCity += "B"
|
|
|
+ score += 1
|
|
|
+ } else {
|
|
|
+ compareCity += "C"
|
|
|
+ }
|
|
|
+ if compareCity != "C" {
|
|
|
+ if info.City != "" && info.City == cp.City {
|
|
|
+ compareCity += "A"
|
|
|
+ score += 2
|
|
|
+ } else {
|
|
|
+ if info.Area == "全国" || cp.Area == "全国" {
|
|
|
+ compareCity += "B"
|
|
|
+ } else if info.City == compareCity {
|
|
|
+ compareCity += "B"
|
|
|
+ } else {
|
|
|
+ compareCity += "C"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ compareCity += "C"
|
|
|
+ }
|
|
|
+ score2 = 0
|
|
|
+ if compareCity == "AA" {
|
|
|
+ if info.District != "" && info.District == cp.District {
|
|
|
+ score2 = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ compareTime = "D"
|
|
|
+ if diffTime < 45*86400 {
|
|
|
+ compareTime = "A"
|
|
|
+ score += 2
|
|
|
+ } else if diffTime < 90*86400 {
|
|
|
+ compareTime = "B"
|
|
|
+ score += 1
|
|
|
+ }
|
|
|
+
|
|
|
+ compareAgency = "D"
|
|
|
+ if info.Agency != "" {
|
|
|
+ if info.Agency == cp.Agency {
|
|
|
+ compareAgency = "A"
|
|
|
+ score += 2
|
|
|
+ score2 += 1
|
|
|
+ } else if cp.Agency != "" {
|
|
|
+ if strings.Contains(info.Agency, cp.Agency) || strings.Contains(cp.Agency, info.Agency) {
|
|
|
+ compareAgency = "B"
|
|
|
+ score += 1
|
|
|
+ score2 += 1
|
|
|
+ } else {
|
|
|
+ compareAgency = "C"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ compareBudget = "C"
|
|
|
+ if info.Budget > 0 && (info.Budget == cp.Budget || (cp.Bidamount > 0 && info.Budget > cp.Bidamount && (info.Budget-cp.Bidamount) < (0.15*info.Budget))) {
|
|
|
+ compareBudget = "A"
|
|
|
+ score += 1
|
|
|
+ score2 += 1
|
|
|
+ }
|
|
|
+ // else if info.Budget == 0 && cp.Budget == 0 {
|
|
|
+ // compareBudget = "B"
|
|
|
+ // }
|
|
|
+ compareBidmount = "C"
|
|
|
+ if info.Bidamount > 0 && (info.Bidamount == cp.Bidamount || (cp.Budget > 0 && cp.Budget > info.Bidamount && (cp.Budget-info.Bidamount) < 0.15*cp.Budget)) {
|
|
|
+ compareBidmount = "A"
|
|
|
+ score += 1
|
|
|
+ score2 += 1
|
|
|
+ }
|
|
|
+ // else if info.Bidamount == 0 && cp.Bidamount == 0 {
|
|
|
+ // compareBidmount = "B"
|
|
|
+ // }
|
|
|
+
|
|
|
+ cp.score = score
|
|
|
+ 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
|
|
|
+}
|
|
|
+
|
|
|
+//招标时间zbtime、中标时间jgtime、项目状态bidstatus、招标类型bidtype、最后发布时间lasttime、首次发布时间firsttime
|
|
|
+func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (string, *ProjectInfo) {
|
|
|
+ //pId := primitive.NewObjectID() //NewObjectId()
|
|
|
+ pId := mongodb.StringTOBsonId(thisinfo.Id)
|
|
|
+ set := map[string]interface{}{}
|
|
|
+ set["_id"] = 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(pId, thisinfo, bs, bt, pkg)
|
|
|
+ set["tag_rule"] = p1.TagRule
|
|
|
+ set["buyertagname"] = tmp["buyertagname"]
|
|
|
+
|
|
|
+ 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 == "project" {
|
|
|
+ set["pici"] = p.pici
|
|
|
+ } else {
|
|
|
+ set["pici"] = tmp["comeintime"]
|
|
|
+ }
|
|
|
+ set["ids"] = []string{thisinfo.Id}
|
|
|
+ if thisinfo.TopType == "招标" {
|
|
|
+ //if thisinfo.SubType != "变更" && thisinfo.SubType != "其它" {
|
|
|
+ set["zbtime"] = tmp["publishtime"]
|
|
|
+ p1.Zbtime = qu.Int64All(tmp["publishtime"])
|
|
|
+ //}
|
|
|
+ } else if thisinfo.TopType == "结果" || thisinfo.SubType == "合同" {
|
|
|
+ set["jgtime"] = tmp["publishtime"]
|
|
|
+ p1.Jgtime = thisinfo.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, ",")
|
|
|
+ p1.Winners = thisinfo.Winners
|
|
|
+ for _, op := range operators {
|
|
|
+ if BinarySearch(p1.Winners, op) > -1 {
|
|
|
+ set["isOperators"] = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if tmp["winnertel"] != nil {
|
|
|
+ set["winnertel"] = tmp["winnertel"]
|
|
|
+ }
|
|
|
+ if tmp["winnerperson"] != nil {
|
|
|
+ set["winnerperson"] = tmp["winnerperson"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if thisinfo.HasPackage {
|
|
|
+ set["multipackage"] = 1
|
|
|
+ set["package"] = pkg
|
|
|
+ } else {
|
|
|
+ set["multipackage"] = 0
|
|
|
+ }
|
|
|
+ //项目评审专家
|
|
|
+ if len(thisinfo.ReviewExperts) > 0 {
|
|
|
+ set["review_experts"] = thisinfo.ReviewExperts
|
|
|
+ p1.ReviewExperts = thisinfo.ReviewExperts
|
|
|
+ }
|
|
|
+ //标的物
|
|
|
+ if thisinfo.Purchasing != "" {
|
|
|
+ list := Duplicate(strings.Split(thisinfo.Purchasing, ",")) //标的物 去重 03/03
|
|
|
+ p := strings.Join(qu.ObjArrToStringArr(list), ",")
|
|
|
+ set["purchasing"] = p
|
|
|
+ p1.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
|
|
|
+ p1.Winnerorder = list
|
|
|
+ }
|
|
|
+ //项目规模
|
|
|
+ if len(thisinfo.ProjectScale) > 0 {
|
|
|
+ p1.ProjectScale = thisinfo.ProjectScale
|
|
|
+ set["project_scale"] = thisinfo.ProjectScale
|
|
|
+ }
|
|
|
+ //工期时长
|
|
|
+ if thisinfo.ProjectDuration > 0 {
|
|
|
+ p1.ProjectDuration = thisinfo.ProjectDuration
|
|
|
+ set["project_duration"] = thisinfo.ProjectDuration
|
|
|
+ }
|
|
|
+ // 工期单位
|
|
|
+ if thisinfo.ProjectDuration > 0 && len(thisinfo.ProjectTimeUnit) > 0 {
|
|
|
+ p1.ProjectTimeunit = thisinfo.ProjectTimeUnit
|
|
|
+ set["project_timeunit"] = thisinfo.ProjectTimeUnit
|
|
|
+ }
|
|
|
+ //开工日期
|
|
|
+ if thisinfo.ProjectStartDate > 0 {
|
|
|
+ p1.ProjectStartDate = thisinfo.ProjectStartDate
|
|
|
+ set["project_startdate"] = thisinfo.ProjectStartDate
|
|
|
+ }
|
|
|
+ //竣工日期
|
|
|
+ if thisinfo.ProjectCompleteDate > 0 {
|
|
|
+ p1.ProjctCompleteDate = thisinfo.ProjectCompleteDate
|
|
|
+ set["project_completedate"] = thisinfo.ProjectCompleteDate
|
|
|
+ }
|
|
|
+ //付款方式
|
|
|
+ if len(thisinfo.Payway) > 0 {
|
|
|
+ p1.Payway = thisinfo.Payway
|
|
|
+ set["payway"] = thisinfo.Payway
|
|
|
+ }
|
|
|
+ // 履约保证金
|
|
|
+ if tmp["contract_guarantee"] != nil {
|
|
|
+ p1.ContractGuarantee = thisinfo.ContractGuarantee
|
|
|
+ set["contract_guarantee"] = thisinfo.ContractGuarantee
|
|
|
+ }
|
|
|
+ // 投标保证金
|
|
|
+ if tmp["bid_guarantee"] != nil {
|
|
|
+ p1.BidGuarantee = thisinfo.BidGuarantee
|
|
|
+ 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 {
|
|
|
+ p1.Qualifies = strings.Join(str, ",")
|
|
|
+ set["qualifies"] = strings.Join(str, ",")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(p1.EntIdList) > 0 {
|
|
|
+ set["entidlist"] = p1.EntIdList
|
|
|
+ }
|
|
|
+ p1.InfoFiled = make(map[string]InfoField)
|
|
|
+ infofield := InfoField{
|
|
|
+ Budget: thisinfo.Budget,
|
|
|
+ Bidamount: thisinfo.Bidamount,
|
|
|
+ ContractCode: thisinfo.ContractCode,
|
|
|
+ ProjectName: thisinfo.ProjectName,
|
|
|
+ ProjectCode: thisinfo.ProjectCode,
|
|
|
+ Bidstatus: bs,
|
|
|
+ }
|
|
|
+ p1.InfoFiled[thisinfo.Id] = infofield
|
|
|
+ res := StructToMap(infofield)
|
|
|
+ set["infofield"] = map[string]interface{}{
|
|
|
+ thisinfo.Id: res,
|
|
|
+ }
|
|
|
+ if tmp["budget"] != nil && tmp["budget"] != "" {
|
|
|
+ set["budget"] = thisinfo.Budget
|
|
|
+ p1.Budgettag = 0
|
|
|
+ set["budgettag"] = 0
|
|
|
+ } else {
|
|
|
+ p1.Budgettag = 1
|
|
|
+ set["budgettag"] = 1
|
|
|
+ }
|
|
|
+ if tmp["bidamount"] != nil && tmp["bidamount"] != "" {
|
|
|
+ set["bidamount"] = thisinfo.Bidamount
|
|
|
+ p1.Bidamounttag = 0
|
|
|
+ set["bidamounttag"] = 0
|
|
|
+ } else {
|
|
|
+ p1.Bidamounttag = 1
|
|
|
+ set["bidamounttag"] = 1
|
|
|
+ }
|
|
|
+ if p1.Bidamount > 0 {
|
|
|
+ set["sortprice"] = p1.Bidamount
|
|
|
+ } else if p1.Budget > 0 {
|
|
|
+ set["sortprice"] = p1.Budget
|
|
|
+ }
|
|
|
+ push := p.PushListInfo(tmp, thisinfo.Id)
|
|
|
+ push["s_winner"] = strings.Join(thisinfo.Winners, ",")
|
|
|
+ set["list"] = []bson.M{
|
|
|
+ push,
|
|
|
+ }
|
|
|
+ //p.savePool <- set
|
|
|
+ p.updatePool <- []map[string]interface{}{
|
|
|
+ {
|
|
|
+ "_id": pId,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "$set": set,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ return pId.Hex(), &p1
|
|
|
+}
|
|
|
+
|
|
|
+//项目中list的信息
|
|
|
+func (p *ProjectTask) PushListInfo(tmp map[string]interface{}, infoid string) bson.M {
|
|
|
+ res := bson.M{
|
|
|
+ "infoid": infoid,
|
|
|
+ }
|
|
|
+ for _, k := range INFOFIELDS {
|
|
|
+ if tmp[k] != nil {
|
|
|
+ res[k] = tmp[k]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res
|
|
|
+}
|
|
|
+
|
|
|
+//生成存放在内存中的对象
|
|
|
+func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidtype, bidstatus string, pkg map[string]interface{}) ProjectInfo {
|
|
|
+ p1 := ProjectInfo{
|
|
|
+ Id: id,
|
|
|
+ Ids: []string{thisinfo.Id},
|
|
|
+ ProjectName: thisinfo.ProjectName,
|
|
|
+ ProjectCode: thisinfo.ProjectCode,
|
|
|
+ ContractCode: thisinfo.ContractCode,
|
|
|
+ Buyer: thisinfo.Buyer,
|
|
|
+ Buyerclass: thisinfo.Buyerclass,
|
|
|
+ Buyerperson: thisinfo.Buyerperson,
|
|
|
+ Buyertel: thisinfo.Buyertel,
|
|
|
+ Topscopeclass: thisinfo.Topscopeclass,
|
|
|
+ Subscopeclass: thisinfo.Subscopeclass,
|
|
|
+ Agency: thisinfo.Agency,
|
|
|
+ Area: thisinfo.Area,
|
|
|
+ City: thisinfo.City,
|
|
|
+ District: thisinfo.District,
|
|
|
+ MPN: []string{},
|
|
|
+ MPC: []string{},
|
|
|
+ FirstTime: thisinfo.Publishtime,
|
|
|
+ LastTime: thisinfo.Publishtime,
|
|
|
+ Budget: thisinfo.Budget,
|
|
|
+ Package: pkg,
|
|
|
+ Bidamount: thisinfo.Bidamount,
|
|
|
+ Bidstatus: bidstatus,
|
|
|
+ Bidtype: bidtype,
|
|
|
+ Winners: thisinfo.Winners,
|
|
|
+ TagRule: thisinfo.TagRule,
|
|
|
+ EntIdList: thisinfo.EntIdList,
|
|
|
+ }
|
|
|
+ if thisinfo.LenPTC > 5 {
|
|
|
+ p1.MPC = append(p1.MPC, thisinfo.PTC)
|
|
|
+ }
|
|
|
+ return p1
|
|
|
+}
|
|
|
+
|
|
|
+//更新项目 全量合并
|
|
|
+func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info, pInfo *ProjectInfo, weight int, comStr string, ex int) {
|
|
|
+ if p.currentType != "updateInfo" {
|
|
|
+ if BinarySearch(pInfo.Ids, thisinfo.Id) > -1 {
|
|
|
+ log.Println("repeat", thisinfo.Id, ",pid", pInfo.Id)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set := map[string]interface{}{}
|
|
|
+ pInfo.Ids = append(pInfo.Ids, thisinfo.Id)
|
|
|
+ if len(pInfo.Ids) > 30 {
|
|
|
+ //异常标记
|
|
|
+ set["listtag"] = 1
|
|
|
+ }
|
|
|
+
|
|
|
+ //zbtime、lasttime、jgtime
|
|
|
+ pInfo.LastTime = thisinfo.Publishtime
|
|
|
+ set["lasttime"] = thisinfo.Publishtime
|
|
|
+ if thisinfo.TopType == "招标" {
|
|
|
+ if pInfo.Zbtime <= 0 {
|
|
|
+ set["zbtime"] = tmp["publishtime"]
|
|
|
+ }
|
|
|
+ if pInfo.Jgtime > 0 {
|
|
|
+ pInfo.Jgtime = int64(0)
|
|
|
+ set["jgtime"] = int64(0)
|
|
|
+ }
|
|
|
+ } 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 thisinfo.SubType == "成交" && pInfo.Bidstatus == "中标" {
|
|
|
+ if p.jgTime < thisinfo.Publishtime {
|
|
|
+ set["jgtime"] = tmp["publishtime"]
|
|
|
+ pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ }
|
|
|
+ //公告状态和项目状态同样是流标或者废标
|
|
|
+ } else if (thisinfo.SubType == "流标" || thisinfo.SubType == "废标") && (pInfo.Bidstatus == "流标" || pInfo.Bidstatus == "废标") {
|
|
|
+ if p.jgTime < thisinfo.Publishtime {
|
|
|
+ set["jgtime"] = tmp["publishtime"]
|
|
|
+ pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ set["jgtime"] = tmp["publishtime"]
|
|
|
+ pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if thisinfo.SubType == "合同" {
|
|
|
+ if pInfo.Bidstatus == "中标" || pInfo.Bidstatus == "成交" || pInfo.Bidstatus == "" {
|
|
|
+ //中标、成交不更新jgtime
|
|
|
+ } else {
|
|
|
+ set["jgtime"] = tmp["publishtime"]
|
|
|
+ pInfo.Jgtime = thisinfo.Publishtime
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if thisinfo.Bidopentime > pInfo.Bidopentime {
|
|
|
+ pInfo.Bidopentime = thisinfo.Bidopentime
|
|
|
+ set["bidopentime"] = pInfo.Bidopentime
|
|
|
+ }
|
|
|
+
|
|
|
+ bt := qu.ObjToString(tmp["toptype"])
|
|
|
+ bs := qu.ObjToString(tmp["subtype"])
|
|
|
+ p.mapBidLock.Lock()
|
|
|
+ if bt == "招标" {
|
|
|
+ //招标状态,更新projectscope
|
|
|
+ if tmp["projectscope"] != nil {
|
|
|
+ set["projectscope"] = qu.ObjToString(tmp["projectscope"])
|
|
|
+ }
|
|
|
+ set["bidstatus"] = bt
|
|
|
+ pInfo.Bidstatus = bt
|
|
|
+ if bidtype[bs] != "" {
|
|
|
+ set["bidtype"] = bidtype[bs]
|
|
|
+ pInfo.Bidtype = bidtype[bs]
|
|
|
+ } else {
|
|
|
+ set["bidtype"] = "招标"
|
|
|
+ pInfo.Bidtype = "招标"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if bidstatus[bs] != "" {
|
|
|
+ set["bidstatus"] = thisinfo.SubType
|
|
|
+ pInfo.Bidstatus = thisinfo.SubType
|
|
|
+ } else if thisinfo.Infoformat == 2 {
|
|
|
+ set["bidstatus"] = "拟建"
|
|
|
+ pInfo.Bidstatus = "拟建"
|
|
|
+ } else if bs == "" && bt == "结果" {
|
|
|
+ if pInfo.Bidstatus == "招标" {
|
|
|
+ set["bidstatus"] = ""
|
|
|
+ pInfo.Bidstatus = ""
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ set["bidstatus"] = "其它"
|
|
|
+ pInfo.Bidstatus = "其它"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ p.mapBidLock.Unlock()
|
|
|
+
|
|
|
+ //异常标记
|
|
|
+ if ex > 0 {
|
|
|
+ set["exception"] = ex
|
|
|
+ }
|
|
|
+ //3\4\5--省、市、县
|
|
|
+ //if thisinfo.Area != "全国" {
|
|
|
+ // if pInfo.Area == "全国" {
|
|
|
+ // pInfo.Area = thisinfo.Area
|
|
|
+ // set["area"] = thisinfo.Area
|
|
|
+ // } else if pInfo.Area != thisinfo.Area {
|
|
|
+ // //xt = false
|
|
|
+ // }
|
|
|
+ // if pInfo.City == "" && thisinfo.City != "" {
|
|
|
+ // pInfo.City = thisinfo.City
|
|
|
+ // set["city"] = thisinfo.City
|
|
|
+ // } else if pInfo.City != thisinfo.City {
|
|
|
+ // //xt = false
|
|
|
+ // }
|
|
|
+ // if thisinfo.District != "" && pInfo.District == "" {
|
|
|
+ // pInfo.District = thisinfo.District
|
|
|
+ // set["district"] = thisinfo.District
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //相同城市的公告才会合并到一起(全国列外)
|
|
|
+ if thisinfo.Area != "全国" {
|
|
|
+ pInfo.Area = thisinfo.Area
|
|
|
+ set["area"] = thisinfo.Area
|
|
|
+ pInfo.City = thisinfo.City
|
|
|
+ set["city"] = thisinfo.City
|
|
|
+ if thisinfo.District != "" {
|
|
|
+ pInfo.District = thisinfo.District
|
|
|
+ set["district"] = thisinfo.District
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //6--项目名称
|
|
|
+ if (thisinfo.ProjectName != "" && pInfo.ProjectName == "") || (len([]rune(pInfo.ProjectName)) < 6 && thisinfo.LenPN > 6) {
|
|
|
+ pInfo.ProjectName = thisinfo.ProjectName
|
|
|
+ set["projectname"] = thisinfo.ProjectName
|
|
|
+ }
|
|
|
+ //7--项目编号
|
|
|
+ if (pInfo.ProjectCode == "" && thisinfo.ProjectCode != "") || (len([]rune(pInfo.ProjectCode)) < 6 && len([]rune(thisinfo.ProjectCode)) > 6) {
|
|
|
+ pInfo.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
|
|
|
+ set["buyer"] = thisinfo.Buyer
|
|
|
+
|
|
|
+ pInfo.Buyerclass = thisinfo.Buyerclass
|
|
|
+ set["buyerclass"] = thisinfo.Buyerclass
|
|
|
+ }
|
|
|
+ if pInfo.Buyer == "" {
|
|
|
+ set["buyerclass"] = ""
|
|
|
+ }
|
|
|
+ //采购单位联系人
|
|
|
+ if thisinfo.Buyerperson != "" {
|
|
|
+ pInfo.Buyerperson = thisinfo.Buyerperson
|
|
|
+ set["buyerperson"] = pInfo.Buyerperson
|
|
|
+ } else {
|
|
|
+ pInfo.Buyerperson = ""
|
|
|
+ set["buyerperson"] = ""
|
|
|
+ }
|
|
|
+ //采购单位電話
|
|
|
+ if thisinfo.Buyertel != "" {
|
|
|
+ pInfo.Buyertel = thisinfo.Buyertel
|
|
|
+ set["buyertel"] = pInfo.Buyertel
|
|
|
+ } else {
|
|
|
+ pInfo.Buyertel = ""
|
|
|
+ set["buyertel"] = ""
|
|
|
+ }
|
|
|
+ if thisinfo.ContractCode != "" {
|
|
|
+ if pInfo.ContractCode == "" {
|
|
|
+ set["contractcode"] = thisinfo.ContractCode
|
|
|
+ } else {
|
|
|
+ list := strings.Split(pInfo.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
|
|
|
+ set["agency"] = thisinfo.Agency
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(thisinfo.Topscopeclass) > 0 {
|
|
|
+ sort.Strings(pInfo.Topscopeclass)
|
|
|
+ for _, k := range thisinfo.Topscopeclass {
|
|
|
+ if BinarySearch(pInfo.Topscopeclass, k) == -1 {
|
|
|
+ pInfo.Topscopeclass = append(pInfo.Topscopeclass, k)
|
|
|
+ sort.Strings(pInfo.Topscopeclass)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set["topscopeclass"] = pInfo.Topscopeclass
|
|
|
+ }
|
|
|
+
|
|
|
+ //项目评审专家
|
|
|
+ if len(thisinfo.ReviewExperts) > 0 {
|
|
|
+ set["review_experts"] = thisinfo.ReviewExperts
|
|
|
+ pInfo.ReviewExperts = thisinfo.ReviewExperts
|
|
|
+ }
|
|
|
+ if thisinfo.Purchasing != "" {
|
|
|
+ if pInfo.Purchasing == "" {
|
|
|
+ list := Duplicate(strings.Split(thisinfo.Purchasing, ",")) //标的物 去重 03/03
|
|
|
+ p := strings.Join(qu.ObjArrToStringArr(list), ",")
|
|
|
+ pInfo.Purchasing = p
|
|
|
+ set["purchasing"] = p
|
|
|
+ } else {
|
|
|
+ list := strings.Split(pInfo.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
|
|
|
+ pInfo.Winnerorder = list
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(thisinfo.Subscopeclass) > 0 {
|
|
|
+ sort.Strings(pInfo.Subscopeclass)
|
|
|
+ for _, k := range thisinfo.Subscopeclass {
|
|
|
+ if BinarySearch(pInfo.Subscopeclass, k) == -1 {
|
|
|
+ pInfo.Subscopeclass = append(pInfo.Subscopeclass, k)
|
|
|
+ sort.Strings(pInfo.Subscopeclass)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set["subscopeclass"] = pInfo.Subscopeclass
|
|
|
+ set["s_subscopeclass"] = strings.Join(pInfo.Subscopeclass, ",")
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(thisinfo.Winners) > 0 {
|
|
|
+ if len(pInfo.Winners) <= 0 {
|
|
|
+ set["winner"] = qu.ObjToString(tmp["winner"])
|
|
|
+ }
|
|
|
+ sort.Strings(pInfo.Winners)
|
|
|
+ for _, k := range thisinfo.Winners {
|
|
|
+ if !pInfo.IsOperators {
|
|
|
+ for _, op := range operators {
|
|
|
+ if strings.Contains(k, op) {
|
|
|
+ pInfo.IsOperators = true
|
|
|
+ set["isOperators"] = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
|
|
|
+ if BinarySearch(pInfo.Winners, k) != -1 {
|
|
|
+ deleteSlice(pInfo.Winners, k, "")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if BinarySearch(pInfo.Winners, k) == -1 {
|
|
|
+ pInfo.Winners = append(pInfo.Winners, k)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set["s_winner"] = strings.Join(pInfo.Winners, ",")
|
|
|
+ if tmp["winnertel"] != nil {
|
|
|
+ set["winnertel"] = tmp["winnertel"]
|
|
|
+ }
|
|
|
+ if tmp["winnerperson"] != nil {
|
|
|
+ set["winnerperson"] = tmp["winnerperson"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 公告标签tag_rule
|
|
|
+ if thisinfo.TagRule != "" {
|
|
|
+ if pInfo.TagRule != "" {
|
|
|
+ tags := strings.Split(pInfo.TagRule, ",")
|
|
|
+ for _, s := range strings.Split(thisinfo.TagRule, ",") {
|
|
|
+ if BinarySearch(tags, s) == -1 {
|
|
|
+ tags = append(tags, s)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set["tag_rule"] = strings.Join(tags, ",")
|
|
|
+ } else {
|
|
|
+ set["tag_rule"] = thisinfo.TagRule
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if tmp["buyertagname"] != nil {
|
|
|
+ set["buyertagname"] = tmp["buyertagname"]
|
|
|
+ }
|
|
|
+ //项目规模
|
|
|
+ if len(thisinfo.ProjectScale) > 0 {
|
|
|
+ pInfo.ProjectScale = thisinfo.ProjectScale
|
|
|
+ set["project_scale"] = thisinfo.ProjectScale
|
|
|
+ }
|
|
|
+ //工期时长
|
|
|
+ if thisinfo.ProjectDuration > 0 {
|
|
|
+ pInfo.ProjectDuration = thisinfo.ProjectDuration
|
|
|
+ set["project_duration"] = thisinfo.ProjectDuration
|
|
|
+ }
|
|
|
+ // 工期单位
|
|
|
+ if thisinfo.ProjectDuration > 0 && len(thisinfo.ProjectTimeUnit) > 0 {
|
|
|
+ pInfo.ProjectTimeunit = thisinfo.ProjectTimeUnit
|
|
|
+ set["project_timeunit"] = thisinfo.ProjectTimeUnit
|
|
|
+ }
|
|
|
+ //开工日期
|
|
|
+ if thisinfo.ProjectStartDate > 0 {
|
|
|
+ if pInfo.ProjectStartDate > 0 {
|
|
|
+ if pInfo.ProjectStartDate < thisinfo.ProjectStartDate {
|
|
|
+ pInfo.ProjectStartDate = thisinfo.ProjectStartDate
|
|
|
+ set["project_startdate"] = thisinfo.ProjectStartDate
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ pInfo.ProjectStartDate = thisinfo.ProjectStartDate
|
|
|
+ set["project_startdate"] = thisinfo.ProjectStartDate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //竣工日期
|
|
|
+ //if thisinfo.ProjectCompleteDate > 0 {
|
|
|
+ // if pInfo.ProjctCompleteDate > 0 {
|
|
|
+ // if pInfo.ProjctCompleteDate < thisinfo.ProjectCompleteDate {
|
|
|
+ // pInfo.ProjctCompleteDate = thisinfo.ProjectCompleteDate
|
|
|
+ // set["project_completedate"] = thisinfo.ProjectCompleteDate
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // pInfo.ProjctCompleteDate = thisinfo.ProjectCompleteDate
|
|
|
+ // set["project_completedate"] = thisinfo.ProjectCompleteDate
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ // 付款方式
|
|
|
+ if len(thisinfo.Payway) > 0 {
|
|
|
+ pInfo.Payway = thisinfo.Payway
|
|
|
+ set["payway"] = thisinfo.Payway
|
|
|
+ }
|
|
|
+ // 履约保证金
|
|
|
+ if tmp["contract_guarantee"] != nil {
|
|
|
+ pInfo.ContractGuarantee = thisinfo.ContractGuarantee
|
|
|
+ set["contract_guarantee"] = thisinfo.ContractGuarantee
|
|
|
+ }
|
|
|
+ // 投标保证金
|
|
|
+ if tmp["bid_guarantee"] != nil {
|
|
|
+ pInfo.BidGuarantee = thisinfo.BidGuarantee
|
|
|
+ set["bid_guarantee"] = thisinfo.BidGuarantee
|
|
|
+ }
|
|
|
+ // 资质条件
|
|
|
+ if len(thisinfo.Qualifies) > 0 {
|
|
|
+ var str []string
|
|
|
+ if len(pInfo.Qualifies) > 0 {
|
|
|
+ str = append(str, strings.Split(pInfo.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 {
|
|
|
+ pInfo.Qualifies = strings.Join(str, ",")
|
|
|
+ set["qualifies"] = strings.Join(str, ",")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(thisinfo.EntIdList) > 0 {
|
|
|
+ for _, v := range thisinfo.EntIdList {
|
|
|
+ if BinarySearch(pInfo.EntIdList, v) == -1 {
|
|
|
+ pInfo.EntIdList = append(pInfo.EntIdList, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ set["entidlist"] = pInfo.EntIdList
|
|
|
+ }
|
|
|
+
|
|
|
+ if thisinfo.HasPackage { //多包处理
|
|
|
+ set["multipackage"] = 1
|
|
|
+ pkg := PackageFormat(thisinfo, pInfo)
|
|
|
+ pInfo.Package = pkg
|
|
|
+ set["package"] = pInfo.Package
|
|
|
+ }
|
|
|
+ //处理多包后,计算预算金额、中标金额
|
|
|
+ CountAmount(pInfo, thisinfo, tmp)
|
|
|
+ if pInfo.Budget >= 0 && pInfo.Budgettag != 1 {
|
|
|
+ set["budget"] = pInfo.Budget
|
|
|
+ set["budgettag"] = 0
|
|
|
+ }
|
|
|
+ if pInfo.Bidamount >= 0 && pInfo.Bidamounttag != 1 {
|
|
|
+ set["bidamount"] = pInfo.Bidamount
|
|
|
+ set["bidamounttag"] = 0
|
|
|
+ }
|
|
|
+ if pInfo.Bidamount >= pInfo.Budget {
|
|
|
+ set["sortprice"] = pInfo.Bidamount
|
|
|
+ } else if pInfo.Budget >= pInfo.Bidamount {
|
|
|
+ set["sortprice"] = pInfo.Budget
|
|
|
+ }
|
|
|
+
|
|
|
+ infofield := InfoField{
|
|
|
+ Budget: thisinfo.Budget,
|
|
|
+ Bidamount: thisinfo.Bidamount,
|
|
|
+ ContractCode: thisinfo.ContractCode,
|
|
|
+ ProjectName: thisinfo.ProjectName,
|
|
|
+ ProjectCode: thisinfo.ProjectCode,
|
|
|
+ Bidstatus: bs,
|
|
|
+ }
|
|
|
+ copyMap := Copy(pInfo.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
|
|
|
+ set["infofield"] = tmpMap
|
|
|
+
|
|
|
+ set["mpn"] = pInfo.MPN
|
|
|
+ set["mpc"] = pInfo.MPC
|
|
|
+ if p.currentType == "project" {
|
|
|
+ set["pici"] = p.pici
|
|
|
+ } else {
|
|
|
+ set["pici"] = tmp["comeintime"]
|
|
|
+ }
|
|
|
+ update := map[string]interface{}{}
|
|
|
+ if len(set) > 0 {
|
|
|
+ update["$set"] = set
|
|
|
+ }
|
|
|
+ push := p.PushListInfo(tmp, thisinfo.Id)
|
|
|
+ push["s_winner"] = strings.Join(thisinfo.Winners, ",")
|
|
|
+ push["compareStr"] = comStr
|
|
|
+ push["resVal"] = pInfo.resVal
|
|
|
+ push["pjVal"] = pInfo.pjVal
|
|
|
+ update["$push"] = map[string]interface{}{
|
|
|
+ "list": push,
|
|
|
+ "ids": thisinfo.Id,
|
|
|
+ }
|
|
|
+ //clearMap := map[string]interface{}{}
|
|
|
+ //ClearData(clearMap, set)
|
|
|
+ //if len(clearMap) > 0 {
|
|
|
+ // update["$unset"] = clearMap
|
|
|
+ //}
|
|
|
+ if len(update) > 0 {
|
|
|
+ updateInfo := []map[string]interface{}{
|
|
|
+ {
|
|
|
+ "_id": pInfo.Id,
|
|
|
+ },
|
|
|
+ update,
|
|
|
+ }
|
|
|
+ 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 if 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.LastTime) > p.statusTime {
|
|
|
+ return true, 0
|
|
|
+ } else {
|
|
|
+ return false, 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 == "" || project.City == "" {
|
|
|
+ return false
|
|
|
+ } else if info.City == project.City {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return true
|
|
|
+}
|
|
|
+
|
|
|
+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{} {
|
|
|
+ p1 := map[string]interface{}{}
|
|
|
+ if project != nil && project.Package != nil && len(project.Package) > 0 {
|
|
|
+ packageCopy := Copy(project.Package).(map[string]interface{})
|
|
|
+ p1 = packageCopy
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ 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"]) {
|
|
|
+ if k1 == k {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ p1[k] = []map[string]interface{}{p2}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return p1
|
|
|
+}
|
|
|
+
|
|
|
+// 计算预算(budget)、中标金额(bidamount)
|
|
|
+func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
|
|
|
+ if info.HasPackage {
|
|
|
+ budget := 0.0
|
|
|
+ for _, v := range project.Package {
|
|
|
+ v1, _ := v.([]map[string]interface{})
|
|
|
+ for _, v2 := range v1 {
|
|
|
+ if v2["budget"] != nil {
|
|
|
+ b1 := qu.Float64All(v2["budget"])
|
|
|
+ if b1 > 0 {
|
|
|
+ budget = budget + b1
|
|
|
+ break
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ project.Budgettag = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if budget > 0 {
|
|
|
+ project.Budget = budget
|
|
|
+ project.Budgettag = 0
|
|
|
+ } else if budget == 0 && info.Budget > 0 {
|
|
|
+ project.Budget = info.Budget
|
|
|
+ project.Budgettag = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //招标没有多包
|
|
|
+ k := KeyPackage.FindStringSubmatch(info.ProjectName)
|
|
|
+ if len(k) > 0 {
|
|
|
+ //招标是单包
|
|
|
+ if len(project.Package) > 0 {
|
|
|
+ //项目有多包
|
|
|
+ flag := false
|
|
|
+ for _, v := range project.Package {
|
|
|
+ v1, _ := v.([]map[string]interface{})
|
|
|
+ if len(v1) > 0 && v1[0]["name"] == info.ProjectName {
|
|
|
+ flag = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !flag {
|
|
|
+ project.Budget = project.Budget + info.Budget
|
|
|
+ project.Budgettag = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //项目没有多包
|
|
|
+ if info.Budget > 0 {
|
|
|
+ project.Budget = project.Budget + info.Budget
|
|
|
+ project.Budgettag = 0
|
|
|
+ } else if info.Budget == 0 && tmp["budget"] != nil {
|
|
|
+ project.Budgettag = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if info.Budget > 0 && project.Budget < info.Budget {
|
|
|
+ project.Budget = info.Budget
|
|
|
+ project.Budgettag = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if info.SubType == "中标" || info.SubType == "成交" || info.SubType == "合同" {
|
|
|
+ if info.HasPackage {
|
|
|
+ bidamount := 0.0
|
|
|
+ for _, v := range project.Package {
|
|
|
+ v1, _ := v.([]map[string]interface{})
|
|
|
+ for _, v2 := range v1 {
|
|
|
+ b1 := qu.Float64All(v2["bidamount"])
|
|
|
+ if b1 > 0 {
|
|
|
+ bidamount = bidamount + b1
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if bidamount > 0 {
|
|
|
+ project.Bidamount = bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ } else if bidamount == 0 && info.Bidamount > 0 {
|
|
|
+ project.Bidamount = info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //招标没有多包
|
|
|
+ k := KeyPackage.FindStringSubmatch(info.ProjectName)
|
|
|
+ if len(k) > 0 {
|
|
|
+ //招标是单包
|
|
|
+ if len(project.Package) > 0 {
|
|
|
+ //项目有多包
|
|
|
+ flag := false
|
|
|
+ for _, v := range project.Package {
|
|
|
+ v1, _ := v.([]map[string]interface{})
|
|
|
+ if len(v1) > 0 && v1[0]["name"] == info.ProjectName {
|
|
|
+ flag = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !flag {
|
|
|
+ project.Bidamount = project.Bidamount + info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //项目没有多包
|
|
|
+ if info.Bidamount > 0 {
|
|
|
+ project.Bidamount = project.Bidamount + info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ } else if info.Bidamount == 0 && tmp["bidamount"] != nil {
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ } else {
|
|
|
+ project.Bidamounttag = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if info.SubType == "中标" || info.SubType == "成交" {
|
|
|
+ if info.Bidamount > 0 {
|
|
|
+ project.Bidamount = info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ } else {
|
|
|
+ flag := false
|
|
|
+ if project.InfoFiled != nil && len(project.InfoFiled) > 0 {
|
|
|
+ for _, res := range project.InfoFiled {
|
|
|
+ if res.ContractCode != "" && res.ContractCode == info.ContractCode {
|
|
|
+ flag = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ if res.Bidamount == project.Bidamount {
|
|
|
+ flag = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !flag {
|
|
|
+ project.Bidamount = project.Bidamount + info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ } else {
|
|
|
+ if info.Budget > 0 && project.Bidamount > info.Bidamount {
|
|
|
+ project.Bidamount = info.Bidamount
|
|
|
+ project.Bidamounttag = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ project.Bidamounttag = 1
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+//结构体转map
|
|
|
+func StructToMap(filed InfoField) map[string]interface{} {
|
|
|
+ //先转json
|
|
|
+ result, err := json.Marshal(filed)
|
|
|
+ if err != nil {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ //json转map
|
|
|
+ res := make(map[string]interface{})
|
|
|
+ err = json.Unmarshal(result, &res)
|
|
|
+ return res
|
|
|
+}
|
|
|
+
|
|
|
+func ClearData(clearMap, tmp map[string]interface{}) {
|
|
|
+ for k, v := range tmp {
|
|
|
+ if v == "" {
|
|
|
+ clearMap[k] = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func IsCreatePro(info *Info) (bol bool) {
|
|
|
+ bol = true
|
|
|
+ if info.SubType == "" || info.SubType == "变更" || info.SubType == "验收" || info.SubType == "违规" ||
|
|
|
+ info.SubType == "结果变更" || info.SubType == "其它" {
|
|
|
+ if info.ProjectName == "" && info.ProjectCode == "" {
|
|
|
+ bol = false
|
|
|
+ } else if info.ProjectName == "" && info.Buyer == "" {
|
|
|
+ bol = false
|
|
|
+ } else if info.ProjectCode == "" && info.Buyer == "" {
|
|
|
+ bol = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return bol
|
|
|
+}
|
|
|
+
|
|
|
+func (p *ProjectTask) GetBidTypeAndBidStatus(info *Info) (string, string) {
|
|
|
+ p.mapBidLock.Lock()
|
|
|
+ defer p.mapBidLock.Unlock()
|
|
|
+ typeStr := bidtype[info.TopType]
|
|
|
+ statusStr := bidstatus[info.SubType]
|
|
|
+ if info.Infoformat == 2 || info.SubType == "拟建" {
|
|
|
+ statusStr = "拟建"
|
|
|
+ typeStr = ""
|
|
|
+ } else {
|
|
|
+ if bidtype[typeStr] == "" {
|
|
|
+ typeStr = "招标"
|
|
|
+ }
|
|
|
+ if typeStr == "招标" {
|
|
|
+ statusStr = typeStr
|
|
|
+ } else {
|
|
|
+ if statusStr == "" {
|
|
|
+ statusStr = "其它"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return typeStr, statusStr
|
|
|
+
|
|
|
+}
|