xuzhiheng hace 1 año
padre
commit
f98dddad35
Se han modificado 4 ficheros con 75 adiciones y 46 borrados
  1. 2 2
      src/config.json
  2. 26 8
      src/history/historytask.go
  3. 36 28
      src/history/util_history.go
  4. 11 8
      src/push/push.go

+ 2 - 2
src/config.json

@@ -64,7 +64,7 @@
     "size": 15
   },
   "es": {
-    "addr": "http://127.0.0.1:9802",
+    "addr": "http://192.168.3.241:9205",
     "index": "bidding",
     "itype": "bidding",
     "pool": 15,
@@ -216,7 +216,7 @@
   "need_projectid_appid": [
     "jyFApXQQIEAw5TTUZOMBpD"
   ],
-  "redis_addrs": "datag=192.168.3.11:1712,session=192.168.3.11:1712,other=192.168.3.11:1712",
+  "redis_addrs": "datag=192.168.3.128:1712,session=192.168.3.128:1712,other=192.168.3.128:1712",
   "jyPushMysql": {
     "username": "root",
     "password": "Topnet123",

+ 26 - 8
src/history/historytask.go

@@ -715,9 +715,18 @@ func (this *HistoryData) ImportDataUpload() error {
 				for i := 0; i < len(row.Cells); i++ {
 					valueStr := row.Cells[i].String()
 					isOk := false
-					for _, fieldValue := range FieldMap {
-						if fieldValue == valueStr {
-							isOk = true
+					log.Println("fileName ", fileName)
+					if strings.Contains(fileName, "铁塔") {
+						for _, fieldValue := range TtFieldMap {
+							if fieldValue == valueStr {
+								isOk = true
+							}
+						}
+					} else {
+						for _, fieldValue := range FieldMap {
+							if fieldValue == valueStr {
+								isOk = true
+							}
 						}
 					}
 					if !isOk {
@@ -769,7 +778,7 @@ func (this *HistoryData) ImportData() {
 	if dataTable == "1" {
 		dataTables = "usermail"
 	}
-	go SaveImportData(fileUrl, dataTables, appid, historyId)
+	go SaveImportData(fileName, fileUrl, dataTables, appid, historyId)
 	MgoSave.Save("importData", map[string]interface{}{
 		"fileName":   fileName,
 		"userName":   userName,
@@ -800,10 +809,11 @@ func (this *HistoryData) DelImportData() {
 	}
 }
 
-func SaveImportData(fileUrl, dataTables, appid, historyId string) {
+func SaveImportData(fileName, fileUrl, dataTables, appid, historyId string) {
 	filePath := "/nas/jyqyfw/datatag" + fileUrl
 	xlFile, err := xlsx.OpenFile(filePath)
 	if err != nil {
+		log.Println("打开excel错误 ", err)
 		return
 	}
 	//获取行数
@@ -820,9 +830,17 @@ func SaveImportData(fileUrl, dataTables, appid, historyId string) {
 				// continue
 				for i := 0; i < len(row.Cells); i++ {
 					valueStr := row.Cells[i].String()
-					for filed, fieldValue := range FieldMap {
-						if fieldValue == valueStr {
-							filedArr = append(filedArr, filed)
+					if strings.Contains(fileName, "铁塔") {
+						for filed, fieldValue := range TtFieldMap {
+							if fieldValue == valueStr {
+								filedArr = append(filedArr, filed)
+							}
+						}
+					} else {
+						for filed, fieldValue := range FieldMap {
+							if fieldValue == valueStr {
+								filedArr = append(filedArr, filed)
+							}
 						}
 					}
 				}

+ 36 - 28
src/history/util_history.go

@@ -129,42 +129,50 @@ var FieldMap = map[string]interface{}{
 	"agency_credit_no": "招标代理机构统一社会信用代码",
 	"contact":          "中标单位历史联系信息",
 	"id":               "唯一标识",
+}
+
+var TtFieldMap = map[string]string{
 	//铁塔
-	"infoId":            "信息id",
-	"infoTitle":         "信息标题",
-	"agentRelationName": "代理机构联系人",
-	"areaCity":          "信息地区--市",
-	"areaCountry":       "信息地区--区县",
-	"areaProvince":      "信息地区--省",
+	"infoId":            "唯一标识",
+	"projectId":         "项目标识",
+	"infoTitle":         "标题",
+	"areaCity":          "市",
+	"areaCountry":       "区县",
+	"areaProvince":      "省",
 	"keywords":          "关键词",
-	"bidWinnerAmount":   "中标金额",
-	"businessType":      "业务场景",
-	"bidingEndTime":     "标书截止时间",
-	"isElectronic":      "是否电子招标",
-	"infoType":          "信息类型",
-	"zhaoIndustry":      "招标单位行业归类",
-	"firstLevel":        "招标单位一级标签",
-	"secondLevel":       "招标单位二级行业",
-	"openBidingTime":    "开标时间",
-	"zhongIndustry":     "中标单位行业归类",
-	"tenderEndTime":     "投标截止时间",
-	"zhaoRelationName":  "招标单位联系人",
-	"zhaoBiaoUnit":      "招标单位",
-	"xmNumber":          "招标编号",
-	"zhongRelationWay":  "中标单位联系方式",
-	"tenderBeginTime":   "投标开始时间",
+	"infoPublishTime":   "发布时间",
+	"bidWinnerAmount":   "中标金额(元)",
+	"businessType":      "业务场景标签",
+	"bidingAcquireTime": "招标文件获取开始时间",
+	"bidingEndTime":     "招标文件获取截止时间",
+	"openBidingTime":    "开标日期",
+	"tenderBeginTime":   "投标文件递交开始时间",
+	"tenderEndTime":     "投标文件递交截止时间",
+	"isElectronic":      "投标方式",
+	"infoType":          "公告类型一级",
+	"infoTypeSegment":   "公告类型二级",
+	"zhaoIndustry":      "铁塔行业",
+	"firstLevel":        "采购单位类型",
+	"secondLevel":       "采购单位标签",
+	"zhongIndustry":     "中标单位标签",
+	"zhaoRelationName":  "采购单位联系人",
+	"zhaoRelationWay":   "采购单位联系电话",
+	"zhaoBiaoUnit":      "采购单位",
+	"xmNumber":          "项目编号",
+	"zhongRelationWay":  "中标单位联系电话",
 	"biddingType":       "招标方式",
-	"infoTypeSegment":   "二级信息类型细分",
 	"zhongRelationName": "中标单位联系人",
-	"agentUnit":         "代理机构",
+	"agentUnit":         "招标代理机构",
+	"agentRelationName": "招标代理机构联系人",
+	"agentRelationWay":  "招标代理机构联系电话",
 	"zhongBiaoUnit":     "中标单位",
-	"zhaoRelationWay":   "招标单位联系方式",
 	"isOptimization":    "是否优选",
-	"bidingAcquireTime": "标书获取开始时间",
-	"agentRelationWay":  "代理机构联系方式",
-	"bidBudget":         "预算金额",
+	"bidBudget":         "预算(元)",
 	"infoContent":       "信息内容",
 	"infoFile":          "附件下载链接",
+	"projectname":       "项目名称",
+	"href":              "公告地址",
+	"jybxhref":          "剑鱼标讯地址",
 }
 
 type (

+ 11 - 8
src/push/push.go

@@ -88,7 +88,8 @@ func (this *Push) DataPush() {
 		fields = fields2
 	}
 	if appid == "jyIhxXQQoJAgVZQURLLwRE" {
-		ttCRM(dataSource, historyId)
+		errstr := ttCRM(dataSource, historyId)
+		this.ServeJson(map[string]interface{}{"errMsg": errstr})
 	} else {
 		if getDataType == "0" {
 			query := map[string]interface{}{"appid": appid, "historyId": historyId}
@@ -282,8 +283,8 @@ func getAccessTokens(token string) string {
 	}
 }
 
-func ttCRM(dataSource, historyId string) {
-	query := map[string]interface{}{"historyId": historyId}
+func ttCRM(dataSource, historyId string) string {
+	query, errStr := map[string]interface{}{"historyId": historyId}, ""
 	data, ok := MgoSave.Find(dataSource, query, nil, nil, false, -1, -1)
 	if ok && data != nil && len(*data) > 0 {
 		for _, v := range *data {
@@ -356,13 +357,17 @@ func ttCRM(dataSource, historyId string) {
 			delete(v, "appid")
 			delete(v, "createtime")
 			delete(v, "historyId")
-			postTT(dataSource, v)
+			errStr = postTT(dataSource, v)
+			if strings.Contains(errStr, "失败") {
+				return errStr
+			}
 		}
 	}
+	return errStr
 }
 
 func postTT(dataSource string, data map[string]interface{}) string {
-	apiurl := "https://www.fxiaoke.com/erp/syncdatagray/open/objdata/push"
+	apiurl := "https://zlbss-crm.chinatowercom.cn/erp/syncdata/open/objdata/push"
 	log.Println("apiurl:", apiurl)
 	header := map[string]string{
 		"token":             "43f8e3c05a8edf8ee85bbc8755043b01",
@@ -377,6 +382,7 @@ func postTT(dataSource string, data map[string]interface{}) string {
 	}
 	dataMap := map[string]interface{}{"objAPIName": "object_HDngT__c", "masterFieldVal": data, "detailFieldVals": map[string]interface{}{}}
 	dataJson, _ := json.Marshal(&dataMap)
+	log.Println("dataJson ", string(dataJson))
 	response, err := HttpPost(apiurl, header, bytes.NewReader(dataJson))
 	errstr := ""
 	if err == nil {
@@ -387,12 +393,9 @@ func postTT(dataSource string, data map[string]interface{}) string {
 			errMsg := qutil.ObjToString((*resMap)["errMsg"])
 			if errMsg == "成功" {
 				log.Println("成功")
-			} else {
-				Mgo.UpdateById(dataSource, qutil.ObjToString(data["infoId"]), map[string]interface{}{"$set": map[string]interface{}{"result": false}})
 			}
 		}
 	} else {
-		Mgo.UpdateById(dataSource, qutil.ObjToString(data["infoId"]), map[string]interface{}{"$set": map[string]interface{}{"result": false}})
 		errstr = "响应失败 " + err.Error()
 		log.Println("响应失败 ", err)
 	}