|
@@ -0,0 +1,106 @@
|
|
|
+package util
|
|
|
+
|
|
|
+import (
|
|
|
+ "config"
|
|
|
+ "encoding/json"
|
|
|
+ "log"
|
|
|
+ "net/rpc"
|
|
|
+ "qfw/util"
|
|
|
+ qrpc "qfw/util/rpc"
|
|
|
+)
|
|
|
+
|
|
|
+//项目更新推送
|
|
|
+func FollowPush(p *qrpc.FollowPush) (repls []*map[string]interface{}, err error) {
|
|
|
+ util.Try(func() {
|
|
|
+ client, e := rpc.DialHTTP("tcp", config.Config.FollowPushRpc)
|
|
|
+ defer client.Close()
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ log.Println(err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var repl []byte
|
|
|
+ err = client.Call("FollowPushRpc.FollowPush", p, &repl)
|
|
|
+ if err == nil && repl != nil && len(repl) > 0 {
|
|
|
+ var mp []*map[string]interface{}
|
|
|
+ json.Unmarshal(repl, &mp)
|
|
|
+ repls = mp
|
|
|
+ }
|
|
|
+ if err != nil {
|
|
|
+ log.Println(err.Error())
|
|
|
+ }
|
|
|
+ }, func(e interface{}) {})
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+type JyMemberRequest struct {
|
|
|
+ InfoId string
|
|
|
+}
|
|
|
+
|
|
|
+type JyMemberResponse struct {
|
|
|
+ Rep []map[string]interface{}
|
|
|
+}
|
|
|
+
|
|
|
+//附件下载
|
|
|
+func Attachment(am *JyMemberRequest) (rep *JyMemberResponse, err error) {
|
|
|
+ util.Try(func() {
|
|
|
+ client, e := rpc.DialHTTP("tcp", config.Config.AttachmentRPC)
|
|
|
+ defer client.Close()
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ log.Println(err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = client.Call("JyService.Download", am, &rep)
|
|
|
+ if err == nil && rep != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if err != nil {
|
|
|
+ log.Println(err.Error())
|
|
|
+ }
|
|
|
+ }, func(e interface{}) {})
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+//JyService.Forecast 中标预测分析rpc接口
|
|
|
+
|
|
|
+type ForecastS struct {
|
|
|
+ Pname string `json:"pname"` //项目名称
|
|
|
+ Id string `json:"id"` //项目id
|
|
|
+ Infoid string `json:"infoid"` //项目第一个listid
|
|
|
+ BuyerContent []string `json:"buyerContent"` //采购内容
|
|
|
+ Buyer string `json:"buyer"` //采购单位
|
|
|
+ Budget float64 `json:"budget"` //预算
|
|
|
+ Area string `json:"area"` //地区
|
|
|
+ City string `json:"city"` //城市
|
|
|
+ RedisFKey string `json:"redisFKey"` //保存数据rediskey值
|
|
|
+ Agency string `json:"agency"` //招标代理机构
|
|
|
+ Buyertel string `json:"buyertel"` //采购联系方式
|
|
|
+ Buyerperson string `json:"buyerperson"` //采购联系人
|
|
|
+ Type string `json:"type"` //是否需要传参数
|
|
|
+ ServiceId int `json:"serviceId"` //服务id
|
|
|
+ MobileModel string `json:"mobileModel"` //手机型号
|
|
|
+ AppVersion string `json:"appVersion"` //app版本号
|
|
|
+}
|
|
|
+
|
|
|
+type repBool struct {
|
|
|
+ Rep bool
|
|
|
+}
|
|
|
+
|
|
|
+func JyForecastByRpc(getRes *ForecastS) bool {
|
|
|
+ // log.Println("-------:", getRes)
|
|
|
+ var ok repBool
|
|
|
+ util.Try(func() {
|
|
|
+ client, err := rpc.DialHTTP("tcp", config.Config.AttachmentRPC)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("Forecast-1-err:", err)
|
|
|
+ }
|
|
|
+ defer client.Close()
|
|
|
+ err = client.Call("JyService.Forecast", getRes, &ok)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("Forecast-2-err:", err)
|
|
|
+ }
|
|
|
+ }, func(e interface{}) {})
|
|
|
+ log.Println(ok.Rep)
|
|
|
+ return ok.Rep
|
|
|
+}
|