|
@@ -1,54 +1,14 @@
|
|
|
package backend
|
|
|
|
|
|
import (
|
|
|
- "context"
|
|
|
"kpt-pasture/model"
|
|
|
- "net/http"
|
|
|
|
|
|
"gitee.com/xuyiping_admin/pkg/logger/zaplog"
|
|
|
"go.uber.org/zap"
|
|
|
|
|
|
- xxerr "gitee.com/xuyiping_admin/pkg/xerr"
|
|
|
-
|
|
|
pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
|
)
|
|
|
|
|
|
-var DrugCategoryMap = map[pasturePb.DrugCategory_Kind]string{
|
|
|
- pasturePb.DrugCategory_Antibiotics: "抗生素类",
|
|
|
- pasturePb.DrugCategory_Antivirals: "抗病毒类",
|
|
|
- pasturePb.DrugCategory_Antifungals: "抗真菌类",
|
|
|
- pasturePb.DrugCategory_Antiparasitics: "驱虫类",
|
|
|
- pasturePb.DrugCategory_Analgesics: "镇痛类",
|
|
|
- pasturePb.DrugCategory_Antipyretic: "退烧类",
|
|
|
- pasturePb.DrugCategory_Vitamin: "维生素类",
|
|
|
- pasturePb.DrugCategory_Brine: "盐水",
|
|
|
- pasturePb.DrugCategory_Glucose: "葡萄糖",
|
|
|
- pasturePb.DrugCategory_Hormone: "激素类",
|
|
|
- pasturePb.DrugCategory_Anti_Stress: "抗应激类",
|
|
|
- pasturePb.DrugCategory_Disinfect: "消毒类",
|
|
|
- pasturePb.DrugCategory_Chinese_Herbal: "中药合剂",
|
|
|
- pasturePb.DrugCategory_Tocolytic: "保胎类",
|
|
|
- pasturePb.DrugCategory_Immunity: "免疫类",
|
|
|
-}
|
|
|
-var UnitMap = map[pasturePb.Unit_Kind]string{
|
|
|
- pasturePb.Unit_Pieces: "个",
|
|
|
- pasturePb.Unit_Package: "包/袋",
|
|
|
- pasturePb.Unit_Bottle: "瓶",
|
|
|
- pasturePb.Unit_Box: "盒",
|
|
|
- pasturePb.Unit_Boxful: "箱",
|
|
|
- pasturePb.Unit_Branch: "支",
|
|
|
- pasturePb.Unit_Barrel: "桶",
|
|
|
- pasturePb.Unit_Pot: "罐",
|
|
|
- pasturePb.Unit_ML: "毫升",
|
|
|
- pasturePb.Unit_L: "升",
|
|
|
-}
|
|
|
-var DrugUsageMap = map[pasturePb.DrugUsage_Kind]string{
|
|
|
- pasturePb.DrugUsage_Oral_Medications: "口服",
|
|
|
- pasturePb.DrugUsage_Injectable_Medications: "肌注",
|
|
|
- pasturePb.DrugUsage_Topical_Medications: "外用",
|
|
|
- pasturePb.DrugUsage_Drink_Medications: "饮水",
|
|
|
-}
|
|
|
-
|
|
|
func (s *StoreEntry) BarnTypeEnumList() []*pasturePb.ConfigOptionsList {
|
|
|
barnTypeList := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
barnTypeList = append(barnTypeList, &pasturePb.ConfigOptionsList{
|
|
@@ -295,6 +255,10 @@ func (s *StoreEntry) ImmunizationConditionsEnumList() []*pasturePb.ConfigOptions
|
|
|
Value: int32(pasturePb.ImmunizationConditions_Month),
|
|
|
Label: "每年月份",
|
|
|
Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.ImmunizationConditions_Admission_Days),
|
|
|
+ Label: "入场天数",
|
|
|
+ Disabled: true,
|
|
|
})
|
|
|
return cowTypeList
|
|
|
}
|
|
@@ -498,7 +462,7 @@ func (s *StoreEntry) DrugCategoryEnumList() []*pasturePb.ConfigOptionsList {
|
|
|
Disabled: true,
|
|
|
}, &pasturePb.ConfigOptionsList{
|
|
|
Value: int32(pasturePb.DrugCategory_Immunity),
|
|
|
- Label: "免疫类",
|
|
|
+ Label: "疫苗类",
|
|
|
Disabled: true,
|
|
|
})
|
|
|
return configOptions
|
|
@@ -659,228 +623,3 @@ func (s *StoreEntry) WeekEnumList() []*pasturePb.ConfigOptionsList {
|
|
|
})
|
|
|
return configOptions
|
|
|
}
|
|
|
-
|
|
|
-func (s *StoreEntry) DrugUsageMaps() map[pasturePb.DrugUsage_Kind]string {
|
|
|
- res := make(map[pasturePb.DrugUsage_Kind]string)
|
|
|
- for _, v := range s.DrugUsageEnumList() {
|
|
|
- res[pasturePb.DrugUsage_Kind(v.Value)] = v.Label
|
|
|
- }
|
|
|
- return res
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) ExposeEstrusTypeMap() map[pasturePb.ExposeEstrusType_Kind]string {
|
|
|
- res := make(map[pasturePb.ExposeEstrusType_Kind]string)
|
|
|
- for _, v := range s.ExposeEstrusTypeEnumList() {
|
|
|
- res[pasturePb.ExposeEstrusType_Kind(v.Value)] = v.Label
|
|
|
- }
|
|
|
- return res
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) FrozenSemenTypeMap() map[pasturePb.FrozenSemenType_Kind]string {
|
|
|
- res := make(map[pasturePb.FrozenSemenType_Kind]string)
|
|
|
- for _, v := range s.FrozenSemenTypeEnumList() {
|
|
|
- res[pasturePb.FrozenSemenType_Kind(v.Value)] = v.Label
|
|
|
- }
|
|
|
- return res
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) UnitMap() map[pasturePb.Unit_Kind]string {
|
|
|
- res := make(map[pasturePb.Unit_Kind]string)
|
|
|
- for _, v := range s.UnitEnumList() {
|
|
|
- res[pasturePb.Unit_Kind(v.Value)] = v.Label
|
|
|
- }
|
|
|
- return res
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) WeekMap() map[pasturePb.Week_Kind]string {
|
|
|
- res := make(map[pasturePb.Week_Kind]string)
|
|
|
- for _, v := range s.WeekEnumList() {
|
|
|
- res[pasturePb.Week_Kind(v.Value)] = v.Label
|
|
|
- }
|
|
|
- return res
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) CowTypeMap() map[pasturePb.CowType_Kind]string {
|
|
|
- res := make(map[pasturePb.CowType_Kind]string)
|
|
|
- for _, v := range s.CowTypeEnumList() {
|
|
|
- res[pasturePb.CowType_Kind(v.Value)] = v.Label
|
|
|
- }
|
|
|
- return res
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) CowStatusMap() map[pasturePb.CowStatus_Kind]string {
|
|
|
- res := make(map[pasturePb.CowStatus_Kind]string)
|
|
|
- for _, v := range s.CowStatusEnumList() {
|
|
|
- res[pasturePb.CowStatus_Kind(v.Value)] = v.Label
|
|
|
- }
|
|
|
- return res
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: s.BarnTypeEnumList(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- penList := make([]*model.Pen, 0)
|
|
|
- pref := s.DB.Table(new(model.Pen).TableName()).
|
|
|
- Where("is_delete = ?", pasturePb.IsShow_Ok)
|
|
|
- if penType != -1 {
|
|
|
- pref.Where("pen_type = ?", penType)
|
|
|
- }
|
|
|
- if err := pref.Find(&penList).Error; err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
-
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: model.PenSlice(penList).ToPB2(s.BarnTypeEnumList()),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) DiseaseTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- diseaseTypeList := make([]*model.ConfigDiseaseType, 0)
|
|
|
- pref := s.DB.Table(new(model.ConfigDiseaseType).TableName()).
|
|
|
- Where("is_show =? ", pasturePb.IsShow_Ok)
|
|
|
-
|
|
|
- if err := pref.Find(&diseaseTypeList).Error; err != nil {
|
|
|
- return nil, xxerr.WithStack(err)
|
|
|
- }
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: model.ConfigDiseaseTypeSlice(diseaseTypeList).ToPB2(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) DiseaseOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- diseaseList := make([]*model.Disease, 0)
|
|
|
- pref := s.DB.Table(new(model.Disease).TableName()).
|
|
|
- Where("is_show =? ", pasturePb.IsShow_Ok)
|
|
|
-
|
|
|
- if err := pref.Find(&diseaseList).Error; err != nil {
|
|
|
- return nil, xxerr.WithStack(err)
|
|
|
- }
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: model.DiseaseSlice(diseaseList).ToPB2(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) BreedStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: s.BreedStatusEnumList(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-func (s *StoreEntry) CowKindOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: s.CowKindEnumList(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) CowSourceOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: s.CowSourceEnumList(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) CowStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: s.CowStatusEnumList(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) CowTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: s.CowTypeEnumList(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: s.TransferPenEnumList(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- systemUserList := make([]*model.SystemUser, 0)
|
|
|
- pref := s.DB.Table(new(model.SystemUser).TableName()).
|
|
|
- Where("is_delete = ?", pasturePb.IsShow_Ok).
|
|
|
- Where("is_show =? ", pasturePb.IsShow_Ok)
|
|
|
- if depId != -1 && depId > 0 {
|
|
|
- pref = pref.Where("dept_id = ?", depId)
|
|
|
- }
|
|
|
- if err := pref.Find(&systemUserList).Error; err != nil {
|
|
|
- return nil, xxerr.WithStack(err)
|
|
|
- }
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: model.SystemUserSlice(systemUserList).ToPB2(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) BullOptions(ctx context.Context) (*pasturePb.BullOptionsListResponse, error) {
|
|
|
- return &pasturePb.BullOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: s.BullNumberEnumList(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName string) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
- switch optionsName {
|
|
|
- case "childNumber":
|
|
|
- configOptions = s.ChildNumberEnumList()
|
|
|
- case "calvingLevel":
|
|
|
- configOptions = s.CalvingLevelEnumList()
|
|
|
- case "dystociaReason":
|
|
|
- configOptions = s.DystociaReasonEnumList()
|
|
|
- case "drugCategory":
|
|
|
- configOptions = s.DrugCategoryEnumList()
|
|
|
- case "drugUsage":
|
|
|
- configOptions = s.DrugUsageEnumList()
|
|
|
- case "unit":
|
|
|
- configOptions = s.UnitEnumList()
|
|
|
- case "pregnantCheckResult":
|
|
|
- configOptions = s.PregnantCheckResultEnumList()
|
|
|
- case "pregnantCheckMethod":
|
|
|
- configOptions = s.PregnantCheckMethodEnumList()
|
|
|
- case "exposeEstrusType":
|
|
|
- configOptions = s.ExposeEstrusTypeEnumList()
|
|
|
- case "frozenSemenType":
|
|
|
- configOptions = s.FrozenSemenTypeEnumList()
|
|
|
- case "week":
|
|
|
- configOptions = s.WeekEnumList()
|
|
|
- case "sameTimeCowType":
|
|
|
- configOptions = s.SemeTimeCowTypeEnumList()
|
|
|
- case "immunizationCowType":
|
|
|
- configOptions = s.ImmunizationCowTypeEnumList()
|
|
|
- case "immunizationConditions":
|
|
|
- configOptions = s.ImmunizationConditionsEnumList()
|
|
|
- }
|
|
|
-
|
|
|
- return &pasturePb.ConfigOptionsListResponse{
|
|
|
- Code: http.StatusOK,
|
|
|
- Message: "ok",
|
|
|
- Data: configOptions,
|
|
|
- }, nil
|
|
|
-}
|