|
@@ -3,10 +3,13 @@ package entity
|
|
|
import (
|
|
|
"log"
|
|
|
|
|
|
+ "encoding/json"
|
|
|
+
|
|
|
util "app.yhyue.com/moapp/jybase/common"
|
|
|
elastic "app.yhyue.com/moapp/jybase/esv1"
|
|
|
"app.yhyue.com/moapp/jybase/mongodb"
|
|
|
"app.yhyue.com/moapp/jybase/mysql"
|
|
|
+ "github.com/nsqio/go-nsq"
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
)
|
|
|
|
|
@@ -21,6 +24,9 @@ var (
|
|
|
AreaCode = map[string]string{}
|
|
|
)
|
|
|
|
|
|
+type Handler struct {
|
|
|
+}
|
|
|
+
|
|
|
func InitMysql(n, x, y, z, s *mysql.Mysql) {
|
|
|
JyMysql = &mysql.Mysql{
|
|
|
Address: n.Address,
|
|
@@ -99,3 +105,28 @@ func InitArea() {
|
|
|
}
|
|
|
log.Println("AreaCodeLen ", len(AreaCode))
|
|
|
}
|
|
|
+
|
|
|
+func (h *Handler) HandleMessage(m *nsq.Message) error {
|
|
|
+ defer util.Catch()
|
|
|
+ if len(m.Body) == 0 {
|
|
|
+ // Returning nil will automatically send a FIN command to NSQ to mark the message as processed.
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ var msg *map[string]interface{}
|
|
|
+ err := json.Unmarshal(m.Body, &msg)
|
|
|
+ if err != nil {
|
|
|
+ log.Println(err)
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ entPostionId := util.Int64All((*msg)["entPostionId"])
|
|
|
+ userPositionId := util.Int64All((*msg)["userPositionId"])
|
|
|
+ entId := util.Int64All((*msg)["entId"])
|
|
|
+ log.Println(userPositionId, entPostionId, entId)
|
|
|
+ ok := JyBiMysql.Update("dwd_f_report_data_baseinfo", map[string]interface{}{"position_id": userPositionId}, map[string]interface{}{"position_id": entPostionId, "ent_id": entId, "position_type": 1})
|
|
|
+ if ok {
|
|
|
+ log.Println("个人销售数据同步企业数据成功!!!")
|
|
|
+ } else {
|
|
|
+ log.Println("个人销售数据同步企业数据失败-----")
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|