Pārlūkot izejas kodu

项目索引bidcycle

maxiaoshan 4 gadi atpakaļ
vecāks
revīzija
d2f3d0a906
2 mainītis faili ar 40 papildinājumiem un 5 dzēšanām
  1. 5 5
      udpcreateindex/src/config.json
  2. 35 0
      udpcreateindex/src/projectindex.go

+ 5 - 5
udpcreateindex/src/config.json

@@ -4,12 +4,12 @@
     "mongodb": {
         "addr": "192.168.3.207:27092",
         "pool": 10,
-        "db": "qfw_data"
+        "db": "mxs"
     },
 	"savedb": {
         "addr": "192.168.3.207:27092",
         "size": 10,
-        "db": "qfw_data"
+        "db": "mxs"
     },
     "jkmail": {
         "to":"zhangjinkun@topnet.net.cn",
@@ -56,9 +56,9 @@
     "filelength": 50000,
     "detaillength": 50000,
     "project": {
-        "db": "qfw_data",
+        "db": "mxs",
         "collect": "projectset",
-        "index": "projectset_v6",
+        "index": "projectset_v5",
         "type": "projectset"
     },
     "project2": {
@@ -100,7 +100,7 @@
 		}
     },
     "elastic": {
-        "addr": "http://192.168.3.128:9800",
+        "addr": "http://192.168.3.11:9800",
         "index": "bidding",
         "itype": "bidding",
         "pool": 12

+ 35 - 0
udpcreateindex/src/projectindex.go

@@ -1,7 +1,9 @@
 package main
 
 import (
+	"math"
 	"strconv"
+
 	//"fmt"
 	"log"
 	"qfw/util"
@@ -124,6 +126,10 @@ func projectTask(data []byte, project, mapInfo map[string]interface{}) {
 		//不生索引字段
 		delete(tmp, "package")
 		delete(tmp, "infofield")
+
+		bidopentime := util.Int64All(tmp["bidopentime"]) //开标日期
+		fzb_publishtime := int64(0)                      //记录第一个招标信息的publishtime
+		bidcycle_flag := false                           //判断是否已计算出标书表编制周期
 		list := tmp["list"].([]interface{})
 		for _, m := range list {
 			tmpM := m.(map[string]interface{})
@@ -139,6 +145,35 @@ func projectTask(data []byte, project, mapInfo map[string]interface{}) {
 			if len(listProjectscopeRune) > 1000 {
 				tmpM["projectscope"] = string(listProjectscopeRune[:1000])
 			}
+			//计算bidcycle标书表编制周期字段
+			if !bidcycle_flag && bidopentime > 0 { //bidopentime>0证明list中有bidopentime,无则不用计算bidcycle
+				if toptype := util.ObjToString(tmpM["toptype"]); toptype == "招标" {
+					zb_bidopentime := util.Int64All(tmpM["bidopentime"])
+					zb_publishtime := util.Int64All(tmpM["publishtime"])
+					if zb_publishtime > 0 {
+						if zb_bidopentime > 0 {
+							if tmpTime := zb_bidopentime - zb_publishtime; tmpTime > 0 {
+								f_day := float64(tmpTime) / float64(86400)
+								day := math.Ceil(f_day)
+								tmp["bidcycle"] = int(day)
+								bidcycle_flag = true
+							}
+						}
+						if fzb_publishtime == 0 { //仅赋值第一个招标信息的publishtime
+							fzb_publishtime = zb_publishtime
+						}
+					}
+				}
+			}
+		}
+		//计算bidcycle标书表编制周期字段
+		//list中招标信息中未能计算出bidcycle,用第一个招标信息的fzb_publishtime和外围bidopentime计算
+		if !bidcycle_flag && bidopentime > 0 && fzb_publishtime > 0 {
+			if tmpTime := bidopentime - fzb_publishtime; tmpTime > 0 {
+				f_day := float64(tmpTime) / float64(86400)
+				day := math.Ceil(f_day)
+				tmp["bidcycle"] = int(day)
+			}
 		}
 		//projectscope截断
 		projectscopeRune := []rune(util.ObjToString(tmp["projectscope"]))