Selaa lähdekoodia

event: disease update

Yi 1 viikko sitten
vanhempi
commit
7ae09426d9

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module kpt-pasture
 go 1.17
 
 require (
-	gitee.com/xuyiping_admin/go_proto v0.0.0-20250611092629-ca524a76d63c
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20250612030131-3c8b446ca813
 	gitee.com/xuyiping_admin/pkg v0.0.0-20250514071642-f92d2ac9a85d
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/eclipse/paho.mqtt.golang v1.4.3

+ 4 - 0
go.sum

@@ -152,6 +152,10 @@ gitee.com/xuyiping_admin/go_proto v0.0.0-20250609060156-a9a9e557016e h1:xDIjht8O
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250609060156-a9a9e557016e/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250611092629-ca524a76d63c h1:qmsW30h4rIb9gmyHp+zgIK58TIyFElUo9ntH0SRgU2Y=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250611092629-ca524a76d63c/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20250612024540-e99718a813f5 h1:wamhokmjikNkC3y4VPhgCGHZMmiRdIFykEm4nEucjvA=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20250612024540-e99718a813f5/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20250612030131-3c8b446ca813 h1:ttDGhXoyHlmBy+R7WiiDU95VjVYjZfR2sx16VQ5B9KI=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20250612030131-3c8b446ca813/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/pkg v0.0.0-20241108060137-caea58c59f5b h1:w05MxH7yqveRlaRbxHhbif5YjPrJFodRPfOjYhXn7Zk=
 gitee.com/xuyiping_admin/pkg v0.0.0-20241108060137-caea58c59f5b/go.mod h1:8tF25X6pE9WkFCczlNAC0K2mrjwKvhhp02I7o0HtDxY=
 gitee.com/xuyiping_admin/pkg v0.0.0-20250514071642-f92d2ac9a85d h1:vBXmMRggF7mZVPGRDgavZ87igJgkezwX0a3v1/XtIMQ=

+ 35 - 34
model/event_cow_disease.go

@@ -7,40 +7,41 @@ import (
 )
 
 type EventCowDisease struct {
-	Id                    int64                       `json:"id"`
-	PastureId             int64                       `json:"pastureId"`
-	CowId                 int64                       `json:"cowId"`
-	EarNumber             string                      `json:"earNumber"`
-	CowType               pasturePb.CowType_Kind      `json:"cowType"`
-	Lact                  int32                       `json:"lact"`
-	DayAge                int32                       `json:"dayAge"`
-	PenId                 int32                       `json:"penId"`
-	PenName               string                      `json:"penName"`
-	DiseaseId             int32                       `json:"diseaseId"`
-	DiseaseName           string                      `json:"diseaseName"`
-	DiseaseType           int32                       `json:"diseaseType"`
-	DiseaseTypeName       string                      `json:"diseaseTypeName"`
-	DiagnoseId            int32                       `json:"diagnoseId"`
-	DiagnoseName          string                      `json:"diagnoseName"`
-	HealthStatus          pasturePb.HealthStatus_Kind `json:"healthStatus"`
-	DiagnosedResult       pasturePb.IsShow_Kind       `json:"diagnosedResult"`
-	DiagnosedAt           int64                       `json:"diagnosedAt"`
-	DiseaseAt             int64                       `json:"diseaseAt"`
-	FirstTreatmentAt      int64                       `json:"firstTreatmentAt"`
-	LastTreatmentAt       int64                       `json:"lastTreatmentAt"`
-	LastPrescriptionName  string                      `json:"LastPrescriptionName"`
-	Temperature           int32                       `json:"temperature"`
-	Remarks               string                      `json:"remarks"`
-	OperationId           int32                       `json:"operationId"`
-	OperationName         string                      `json:"operationName"`
-	MessageId             int32                       `json:"messageId"`
-	MessageName           string                      `json:"messageName"`
-	DiagnoseOperationId   int32                       `json:"diagnoseOperationId"`
-	DiagnoseOperationName string                      `json:"diagnoseOperationName"`
-	CurableAt             int64                       `json:"curableAt"`
-	Source                string                      `json:"source"`
-	CreatedAt             int64                       `json:"createdAt"`
-	UpdatedAt             int64                       `json:"updatedAt"`
+	Id                    int64                            `json:"id"`
+	PastureId             int64                            `json:"pastureId"`
+	CowId                 int64                            `json:"cowId"`
+	EarNumber             string                           `json:"earNumber"`
+	CowType               pasturePb.CowType_Kind           `json:"cowType"`
+	Lact                  int32                            `json:"lact"`
+	DayAge                int32                            `json:"dayAge"`
+	PenId                 int32                            `json:"penId"`
+	PenName               string                           `json:"penName"`
+	DiseaseId             int32                            `json:"diseaseId"`
+	DiseaseName           string                           `json:"diseaseName"`
+	DiseaseType           int32                            `json:"diseaseType"`
+	DiseaseTypeName       string                           `json:"diseaseTypeName"`
+	DiagnoseId            int32                            `json:"diagnoseId"`
+	DiagnoseName          string                           `json:"diagnoseName"`
+	HealthStatus          pasturePb.HealthStatus_Kind      `json:"healthStatus"`
+	DiagnosedResult       pasturePb.IsShow_Kind            `json:"diagnosedResult"`
+	DiagnosedAt           int64                            `json:"diagnosedAt"`
+	DiseaseAt             int64                            `json:"diseaseAt"`
+	FirstTreatmentAt      int64                            `json:"firstTreatmentAt"`
+	LastTreatmentAt       int64                            `json:"lastTreatmentAt"`
+	LastPrescriptionName  string                           `json:"LastPrescriptionName"`
+	Temperature           int32                            `json:"temperature"`
+	ExposeDiseaseType     pasturePb.ExposeDiseaseType_Kind `json:"exposeDiseaseType"`
+	Remarks               string                           `json:"remarks"`
+	OperationId           int32                            `json:"operationId"`
+	OperationName         string                           `json:"operationName"`
+	MessageId             int32                            `json:"messageId"`
+	MessageName           string                           `json:"messageName"`
+	DiagnoseOperationId   int32                            `json:"diagnoseOperationId"`
+	DiagnoseOperationName string                           `json:"diagnoseOperationName"`
+	CurableAt             int64                            `json:"curableAt"`
+	Source                string                           `json:"source"`
+	CreatedAt             int64                            `json:"createdAt"`
+	UpdatedAt             int64                            `json:"updatedAt"`
 }
 
 func (e *EventCowDisease) TableName() string {

+ 7 - 0
model/indicators_data.go

@@ -69,6 +69,13 @@ const (
 	Day75DayMatingRate               = "day75_day_mating_rate"                 // 75天配种率(在群)
 	Day75DMonthMatingRate            = "day75_month_mating_rate"               // 75天配种率(月度)
 	AvgAdultCowEmptyNumber           = "avg_adult_cow_empty_number"            // 成母牛平均空怀天数
+	AdultCowPregnantCheckOkRate      = "adult_cow_pregnant_check_ok_rate"      // 成母牛孕检怀孕比
+	YouthCowPregnantCheckOkRate      = "youth_cow_pregnant_check_ok_rate"      // 后备牛孕检怀孕比
+	AdultCowForbiddenMatingRate      = "adult_cow_forbidden_mating_rate"       // 成母牛禁配占比
+	YouthCowForbiddenMatingRate      = "youth_cow_forbidden_mating_rate"       // 青年牛禁配占比
+	AdultCowForbiddenMatingNumber    = "adult_cow_forbidden_mating_number"     // 成母牛禁配事件数
+	YouthCowForbiddenMatingNumber    = "youth_cow_forbidden_mating_number"     // 后备牛禁配事件数
+	NoPregnant110SecondMatingRate    = "no_pregnant110_second_mating_rate"     // 110天未孕成母牛二次参配率
 )
 
 type IndicatorsData struct {

+ 1 - 2
module/backend/cow.go

@@ -41,8 +41,7 @@ func (s *StoreEntry) Detail(ctx context.Context, req *pasturePb.SearchEventReque
 		pref.Where("neck_ring_number = ?", req.NeckRingNumber)
 	}
 
-	if err = pref.Order("id desc").
-		First(cowInfo).Error; err != nil {
+	if err = pref.First(cowInfo).Error; err != nil {
 		if errors.Is(err, gorm.ErrRecordNotFound) {
 			return nil, xerr.Custom("该牛只未找到")
 		} else {

+ 3 - 2
module/backend/dashboard_more.go

@@ -103,13 +103,14 @@ func (s *StoreEntry) NeckRingWarning(ctx context.Context) (*pasturePb.IndexNeckR
 	}
 
 	healthWarningNumber := int64(0)
-	if err = s.DB.Model(new(model.NeckRingHealthWarning)).
+	// todo 待测试
+	/*if err = s.DB.Model(new(model.NeckRingHealthWarning)).
 		Where("pasture_id = ?", userModel.AppPasture.Id).
 		Where("is_show = ?", pasturePb.IsShow_Ok).
 		Group("cow_id").
 		Count(&healthWarningNumber).Error; err != nil {
 		zaplog.Error("NeckRingWarning", zap.Any("estrusWarningNumber", err))
-	}
+	}*/
 
 	return &pasturePb.IndexNeckRingResponse{
 		Code: http.StatusOK,

+ 24 - 19
module/backend/event_health.go

@@ -40,6 +40,9 @@ func (s *StoreEntry) CowDiseaseCreate(ctx context.Context, req *pasturePb.EventC
 		return xerr.WithStack(err)
 	}
 	newEventCowDisease := model.NewEventCowDisease(userModel.AppPasture.Id, cow, disease, req, operationUser, userModel.SystemUser)
+	if req.ExposeDiseaseType == pasturePb.ExposeDiseaseType_Neck_Ring {
+		newEventCowDisease.ExposeDiseaseType = pasturePb.ExposeDiseaseType_Neck_Ring
+	}
 	defer func() {
 		// 更新牛只健康状态
 		if newEventCowDisease.HealthStatus == pasturePb.HealthStatus_Disease || newEventCowDisease.HealthStatus == pasturePb.HealthStatus_Treatment {
@@ -68,7 +71,7 @@ func (s *StoreEntry) CowDiseaseCreate(ctx context.Context, req *pasturePb.EventC
 		}
 	}()
 	// PC端直接跳过诊断过程
-	if source == model.SourcePC {
+	if source == model.SourcePC || req.ExposeDiseaseType == pasturePb.ExposeDiseaseType_Neck_Ring {
 		newEventCowDisease.DiagnosedResult = pasturePb.IsShow_Ok
 		newEventCowDisease.DiagnoseOperationId = int32(operationUser.Id)
 		newEventCowDisease.DiagnoseOperationName = operationUser.Name
@@ -334,21 +337,9 @@ func (s *StoreEntry) CowDiseaseTreatment(ctx context.Context, req *pasturePb.Cow
 		return xerr.WithStack(err)
 	}
 
-	// 牛只疾病信息
-	eventCowDisease := &model.EventCowDisease{}
-	if err = s.DB.Where("cow_id = ?", req.CowId).
-		Where("pasture_id = ?", userModel.AppPasture.Id).
-		Where("id = ?", req.Id).
-		First(eventCowDisease).Error; err != nil {
-		return xerr.WithStack(err)
-	}
+	pastureId := userModel.AppPasture.Id
 
-	if eventCowDisease.HealthStatus != pasturePb.HealthStatus_Disease &&
-		eventCowDisease.HealthStatus != pasturePb.HealthStatus_Treatment {
-		return xerr.Custom("异常牛只数据")
-	}
-
-	cow, err := s.GetCowInfoByCowId(ctx, userModel.AppPasture.Id, int64(req.CowId))
+	cow, err := s.GetCowInfoByCowId(ctx, pastureId, int64(req.CowId))
 	if err != nil {
 		return xerr.WithStack(err)
 	}
@@ -360,13 +351,13 @@ func (s *StoreEntry) CowDiseaseTreatment(ctx context.Context, req *pasturePb.Cow
 	}
 
 	// 处方信息
-	prescription, err := s.GetPrescriptionById(ctx, userModel.AppPasture.Id, req.PrescriptionId)
+	prescription, err := s.GetPrescriptionById(ctx, pastureId, req.PrescriptionId)
 	if err != nil {
 		return xerr.WithStack(err)
 	}
 
 	// 疾病信息
-	disease, err := s.GetDiseaseById(ctx, userModel.AppPasture.Id, eventCowDisease.DiseaseId)
+	disease, err := s.GetDiseaseById(ctx, pastureId, req.DiseaseId)
 	if err != nil {
 		return xerr.WithStack(err)
 	}
@@ -374,11 +365,25 @@ func (s *StoreEntry) CowDiseaseTreatment(ctx context.Context, req *pasturePb.Cow
 	req.DiseaseType = disease.DiseaseType
 
 	// 处方信息
-	prescriptionDrugs, err := s.PrescriptionDrugsByPrescriptionId(ctx, userModel.AppPasture.Id, prescription.Id)
+	prescriptionDrugs, err := s.PrescriptionDrugsByPrescriptionId(ctx, pastureId, prescription.Id)
 	if err != nil {
 		return xerr.WithStack(err)
 	}
 
+	// 牛只疾病信息
+	eventCowDisease := &model.EventCowDisease{}
+	if err = s.DB.Where("cow_id = ?", req.CowId).
+		Where("pasture_id = ?", userModel.AppPasture.Id).
+		Where("id = ?", req.Id).
+		First(eventCowDisease).Error; err != nil {
+		return xerr.WithStack(err)
+	}
+
+	if eventCowDisease.HealthStatus != pasturePb.HealthStatus_Disease &&
+		eventCowDisease.HealthStatus != pasturePb.HealthStatus_Treatment {
+		return xerr.Custom("异常牛只数据")
+	}
+
 	// 处方详情
 	unitMap := s.UnitMap()
 	prescriptionDetail := make([]*pasturePb.PrescriptionDrugsList, len(prescriptionDrugs))
@@ -405,7 +410,7 @@ func (s *StoreEntry) CowDiseaseTreatment(ctx context.Context, req *pasturePb.Cow
 		healthStatus = pasturePb.HealthStatus_Dead
 	}
 	diseaseTypeMap := s.DiseaseTypeMap()
-	newEventCowTreatment := model.NewEventCowTreatment(userModel.AppPasture.Id, prescription, req, diseaseTypeMap, operationUser, userModel.SystemUser)
+	newEventCowTreatment := model.NewEventCowTreatment(pastureId, prescription, req, diseaseTypeMap, operationUser, userModel.SystemUser)
 
 	if err = s.DB.Transaction(func(tx *gorm.DB) error {
 		if err = tx.Create(newEventCowTreatment).Error; err != nil {

+ 3 - 0
module/backend/neck_ring_warning.go

@@ -128,6 +128,9 @@ func (s *StoreEntry) NeckRingWarningHealthCowList(ctx context.Context, req *past
 		return nil, xerr.WithStack(err)
 	}
 
+	// Todo : 待优化
+	neckWaringHealthList = make([]*model.NeckRingHealthWarning, 0)
+
 	warningHealthLevelMap := s.WarningHealthLevelMap()
 	cowMap := make(map[int64]*model.Cow)
 	eventLogMap := make(map[int64]string)

+ 13 - 0
module/crontab/cow_cron.go

@@ -199,6 +199,19 @@ func (e *Entry) Indicators() error {
 			pastureIndicatorList = e.Day75MonthMatingRate(pastureList, indicatorsDetail.Id)
 		case model.AvgAdultCowEmptyNumber:
 			pastureIndicatorList = e.AvgAdultCowEmptyNumber(pastureList, startTime, endTime)
+		case model.AdultCowPregnantCheckOkRate:
+			pastureIndicatorList = e.CowPregnantCheckOkRate(pastureList, "lact >= 1", startTime, endTime)
+		case model.YouthCowPregnantCheckOkRate:
+			pastureIndicatorList = e.CowPregnantCheckOkRate(pastureList, "lact = 0", startTime, endTime)
+		case model.AdultCowForbiddenMatingRate:
+			pastureIndicatorList = e.CowForbiddenMatingRate(pastureList, "calving_age >=", startTime, endTime)
+		case model.YouthCowForbiddenMatingRate:
+			pastureIndicatorList = e.CowForbiddenMatingRate(pastureList, "day_age >= 395", startTime, endTime)
+		case model.AdultCowForbiddenMatingNumber:
+			pastureIndicatorList = e.CowForbiddenMatingNumber(pastureList, "lact >= 1", startTime, endTime)
+		case model.YouthCowForbiddenMatingNumber:
+			pastureIndicatorList = e.CowForbiddenMatingNumber(pastureList, "lact = 0", startTime, endTime)
+
 		}
 
 		for pastureId, value := range pastureIndicatorList {

+ 93 - 1
module/crontab/cow_indicators_breed_more.go

@@ -301,10 +301,102 @@ func (e *Entry) AvgAdultCowEmptyNumber(pastureList []*model.AppPastureList, star
 			zaplog.Error("AvgAdultCowEmptyNumber", zap.Any("err", err))
 		}
 		if v.CowCount > 0 && v.EmptyDays > 0 {
-			res[pasture.Id] = fmt.Sprintf("%.2f", float64(v.EmptyDays)/float64(v.CowCount))
+			res[pasture.Id] = fmt.Sprintf("%d", v.EmptyDays/v.CowCount)
 		} else {
 			res[pasture.Id] = "0"
 		}
 	}
 	return res
 }
+
+// CowPregnantCheckOkRate 牛孕检怀孕比
+func (e *Entry) CowPregnantCheckOkRate(pastureList []*model.AppPastureList, condition string, startTime, endTime int64) map[int64]string {
+	res := make(map[int64]string)
+	for _, pasture := range pastureList {
+		var pregnantCheckOkCount int64
+		eventPregnantCheckList := make([]*model.EventPregnantCheck, 0)
+		if err := e.DB.Model(new(model.EventPregnantCheck)).
+			Where("pasture_id = ?", pasture.Id).
+			Where("status = ?", pasturePb.IsShow_Ok).
+			Where("reality_day BETWEEN ? AND ?", startTime, endTime).
+			Where(condition).
+			Find(&eventPregnantCheckList).Error; err != nil {
+			zaplog.Error("CowPregnantCheckOkRate", zap.Any("err", err))
+		}
+		for _, eventPregnantCheck := range eventPregnantCheckList {
+			if eventPregnantCheck.PregnantCheckResult != pasturePb.PregnantCheckResult_Pregnant {
+				continue
+			}
+			pregnantCheckOkCount++
+		}
+
+		if pregnantCheckOkCount > 0 && len(eventPregnantCheckList) > 0 {
+			res[pasture.Id] = fmt.Sprintf("%.2f", float64(pregnantCheckOkCount)/float64(len(eventPregnantCheckList)))
+		} else {
+			res[pasture.Id] = "0"
+		}
+	}
+	return res
+}
+
+// CowForbiddenMatingRate 禁配占比
+func (e *Entry) CowForbiddenMatingRate(pastureList []*model.AppPastureList, condition string, startTime, endTime int64) map[int64]string {
+	res := make(map[int64]string)
+	for _, pasture := range pastureList {
+		var (
+			forbiddenMatingCount int64
+			cowCount             int64
+		)
+
+		if err := e.DB.Model(new(model.Cow)).
+			Where("pasture_id = ?", pasture.Id).
+			Where("sex = ?", pasturePb.Genders_Female).
+			Where("admission_status = ?", pasturePb.AdmissionStatus_Admission).
+			Where(condition).
+			Where("lact >= ?", 1).
+			Count(&cowCount).Error; err != nil {
+			zaplog.Error("AdultCowForbiddenMatingRate", zap.Any("err", err))
+		}
+		if cowCount > 0 {
+			if err := e.DB.Model(new(model.EventForbiddenMating)).
+				Where("pasture_id = ?", pasture.Id).
+				Where("status = ?", pasturePb.IsShow_Ok).
+				Where("lact >= ?", 1).
+				Where("reality_day BETWEEN ? AND ?", startTime, endTime).
+				Count(&forbiddenMatingCount).Error; err != nil {
+				zaplog.Error("AdultCowForbiddenMatingRate", zap.Any("err", err))
+			}
+			if forbiddenMatingCount > 0 {
+				res[pasture.Id] = fmt.Sprintf("%.2f", float64(forbiddenMatingCount)/float64(cowCount))
+			} else {
+				res[pasture.Id] = "0"
+			}
+		} else {
+			res[pasture.Id] = "0"
+		}
+	}
+	return res
+}
+
+// CowForbiddenMatingNumber 禁配牛头数
+func (e *Entry) CowForbiddenMatingNumber(pastureList []*model.AppPastureList, condition string, startTime, endTime int64) map[int64]string {
+	res := make(map[int64]string)
+	for _, pasture := range pastureList {
+		var forbiddenMatingCount int64
+		if err := e.DB.Model(new(model.EventForbiddenMating)).
+			Where("pasture_id = ?", pasture.Id).
+			Where("status = ?", pasturePb.IsShow_Ok).
+			Where(condition).
+			Where("reality_day BETWEEN ? AND ?", startTime, endTime).
+			Count(&forbiddenMatingCount).Error; err != nil {
+			zaplog.Error("AdultCowForbiddenMatingRate", zap.Any("err", err))
+		}
+		if forbiddenMatingCount > 0 {
+			res[pasture.Id] = fmt.Sprintf("%d", forbiddenMatingCount)
+		} else {
+			res[pasture.Id] = "0"
+		}
+
+	}
+	return res
+}

+ 1 - 1
module/crontab/health_warning.go

@@ -217,7 +217,7 @@ func (e *Entry) FindNewNeckRingHealthWarning(pastureId int64, healthValue int32)
 		min_intake,sum_chew,before_three_sum_chew`).
 		Where("pasture_id = ?", pastureId).
 		Where("heat_date >= ?", startTime).
-		Group("neck_ring_number").
+		Group("cow_id").
 		Find(&neckRingHealthList).Error; err != nil {
 		return nil, xerr.WithStack(err)
 	}

+ 28 - 8
module/mqtt/mqtt_handle.go

@@ -7,6 +7,7 @@ import (
 	"strconv"
 	"strings"
 	"sync"
+	"time"
 
 	"github.com/jinzhu/copier"
 
@@ -28,14 +29,33 @@ var (
 	}
 	mu sync.Mutex
 
-	ReceiverMap map[string]int64 // 接收器数据
+	receiverMap   map[string]int64 // 接收器数据
+	receiverMutex sync.Mutex
 )
 
+// InitReceiverMapUpdater 2小时更新接收器数据
+func (e *Entry) InitReceiverMapUpdater() {
+	go func() {
+		ticker := time.NewTicker(2 * time.Hour)
+		defer ticker.Stop()
+		for {
+			select {
+			case <-ticker.C:
+				receiverMutex.Lock()
+				receiverMap = e.FindAppPastureReceiver()
+				receiverMutex.Unlock()
+				zaplog.Info("ReceiverMap updated successfully")
+			}
+		}
+	}()
+}
+
 func (e *Entry) NeckRingHandle(data []byte) {
-	if len(ReceiverMap) <= 0 {
-		ReceiverMap = e.FindAppPastureReceiver()
-	}
-	newData := e.MsgDataFormat2(data, ReceiverMap)
+	receiverMutex.Lock()
+	newReceiverMap := receiverMap
+	receiverMutex.Unlock()
+
+	newData := e.MsgDataFormat2(data, newReceiverMap)
 	if newData == nil {
 		return
 	}
@@ -53,11 +73,11 @@ func (e *Entry) FindAppPastureReceiver() map[string]int64 {
 		Find(&appPastureReceiverList).Error; err != nil {
 		zaplog.Error("FindAppPastureReceiver", zap.Any("err", err))
 	}
-	receiverMap := make(map[string]int64)
+	newReceiverMap := make(map[string]int64)
 	for _, v := range appPastureReceiverList {
-		receiverMap[v.ReceiverNumber] = v.PastureId
+		newReceiverMap[v.ReceiverNumber] = v.PastureId
 	}
-	return receiverMap
+	return newReceiverMap
 }
 
 // 处理批量数据

+ 1 - 0
service/mqtt/interface.go

@@ -145,5 +145,6 @@ func (s *IMqttClient) Run(enter handleMqtt.Entry) {
 	}
 
 	// 启动数据处理
+	enter.InitReceiverMapUpdater()
 	s.Consumer(enter.NeckRingHandle)
 }