|
@@ -40,6 +40,9 @@ func (s *StoreEntry) CowDiseaseCreate(ctx context.Context, req *pasturePb.EventC
|
|
return xerr.WithStack(err)
|
|
return xerr.WithStack(err)
|
|
}
|
|
}
|
|
newEventCowDisease := model.NewEventCowDisease(userModel.AppPasture.Id, cow, disease, req, operationUser, userModel.SystemUser)
|
|
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() {
|
|
defer func() {
|
|
// 更新牛只健康状态
|
|
// 更新牛只健康状态
|
|
if newEventCowDisease.HealthStatus == pasturePb.HealthStatus_Disease || newEventCowDisease.HealthStatus == pasturePb.HealthStatus_Treatment {
|
|
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端直接跳过诊断过程
|
|
// PC端直接跳过诊断过程
|
|
- if source == model.SourcePC {
|
|
|
|
|
|
+ if source == model.SourcePC || req.ExposeDiseaseType == pasturePb.ExposeDiseaseType_Neck_Ring {
|
|
newEventCowDisease.DiagnosedResult = pasturePb.IsShow_Ok
|
|
newEventCowDisease.DiagnosedResult = pasturePb.IsShow_Ok
|
|
newEventCowDisease.DiagnoseOperationId = int32(operationUser.Id)
|
|
newEventCowDisease.DiagnoseOperationId = int32(operationUser.Id)
|
|
newEventCowDisease.DiagnoseOperationName = operationUser.Name
|
|
newEventCowDisease.DiagnoseOperationName = operationUser.Name
|
|
@@ -334,21 +337,9 @@ func (s *StoreEntry) CowDiseaseTreatment(ctx context.Context, req *pasturePb.Cow
|
|
return xerr.WithStack(err)
|
|
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 {
|
|
if err != nil {
|
|
return xerr.WithStack(err)
|
|
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 {
|
|
if err != nil {
|
|
return xerr.WithStack(err)
|
|
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 {
|
|
if err != nil {
|
|
return xerr.WithStack(err)
|
|
return xerr.WithStack(err)
|
|
}
|
|
}
|
|
@@ -374,11 +365,25 @@ func (s *StoreEntry) CowDiseaseTreatment(ctx context.Context, req *pasturePb.Cow
|
|
req.DiseaseType = disease.DiseaseType
|
|
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 {
|
|
if err != nil {
|
|
return xerr.WithStack(err)
|
|
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()
|
|
unitMap := s.UnitMap()
|
|
prescriptionDetail := make([]*pasturePb.PrescriptionDrugsList, len(prescriptionDrugs))
|
|
prescriptionDetail := make([]*pasturePb.PrescriptionDrugsList, len(prescriptionDrugs))
|
|
@@ -405,7 +410,7 @@ func (s *StoreEntry) CowDiseaseTreatment(ctx context.Context, req *pasturePb.Cow
|
|
healthStatus = pasturePb.HealthStatus_Dead
|
|
healthStatus = pasturePb.HealthStatus_Dead
|
|
}
|
|
}
|
|
diseaseTypeMap := s.DiseaseTypeMap()
|
|
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 = s.DB.Transaction(func(tx *gorm.DB) error {
|
|
if err = tx.Create(newEventCowTreatment).Error; err != nil {
|
|
if err = tx.Create(newEventCowTreatment).Error; err != nil {
|