config_data.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. package backend
  2. import (
  3. "kpt-pasture/model"
  4. "go.uber.org/zap"
  5. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  6. "gitee.com/xuyiping_admin/pkg/logger/zaplog"
  7. )
  8. func (s *StoreEntry) BarnTypeEnumList(excludeTypes []pasturePb.PenType_Kind) []*pasturePb.ConfigOptionsList {
  9. allBarnTypes := s.BarnTypeMap()
  10. barnTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  11. for v1 := range allBarnTypes {
  12. var info bool
  13. for _, v2 := range excludeTypes {
  14. if v1 == v2 {
  15. info = true
  16. break
  17. }
  18. }
  19. if !info {
  20. barnTypeList = append(barnTypeList, &pasturePb.ConfigOptionsList{
  21. Value: int32(v1),
  22. Label: allBarnTypes[v1],
  23. Disabled: true,
  24. })
  25. }
  26. }
  27. return barnTypeList
  28. }
  29. func (s *StoreEntry) BreedStatusEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  30. dataList := make([]*model.ConfigSaleCowAnalysisMethod, 0)
  31. pref := s.DB.Model(new(model.ConfigSaleCowAnalysisMethod)).
  32. Where("is_show =? ", pasturePb.IsShow_Ok).
  33. Where("pasture_id =? ", userModel.AppPasture.Id)
  34. if isAll == model.IsAllYes {
  35. pref = pref.Where("kind >= ?", pasturePb.SaleCowAnalysisMethod_Invalid)
  36. } else {
  37. pref = pref.Where("kind > ?", pasturePb.SaleCowAnalysisMethod_Invalid)
  38. }
  39. if err := pref.Order("kind ASC").
  40. Find(&dataList).Error; err != nil {
  41. zaplog.Error("LactIntervalSymbolEnumList", zap.Any("err", err))
  42. return make([]*pasturePb.ConfigOptionsList, 0)
  43. }
  44. return model.ConfigSaleCowAnalysisMethodSlice(dataList).ToPB(userModel.Language)
  45. /*breedStatusList := make([]*pasturePb.ConfigOptionsList, 0)
  46. breedStatusList = append(breedStatusList, &pasturePb.ConfigOptionsList{
  47. Value: int32(pasturePb.BreedStatus_UnBreed),
  48. Label: "未配",
  49. Disabled: true,
  50. }, &pasturePb.ConfigOptionsList{
  51. Value: int32(pasturePb.BreedStatus_Breeding),
  52. Label: "已配未检",
  53. Disabled: true,
  54. }, &pasturePb.ConfigOptionsList{
  55. Value: int32(pasturePb.BreedStatus_Pregnant),
  56. Label: "怀孕",
  57. Disabled: true,
  58. }, &pasturePb.ConfigOptionsList{
  59. Value: int32(pasturePb.BreedStatus_Empty),
  60. Label: "空怀",
  61. Disabled: true,
  62. }, &pasturePb.ConfigOptionsList{
  63. Value: int32(pasturePb.BreedStatus_Calving),
  64. Label: "产犊",
  65. Disabled: true,
  66. }, &pasturePb.ConfigOptionsList{
  67. Value: int32(pasturePb.BreedStatus_Abort),
  68. Label: "流产",
  69. Disabled: true,
  70. }, &pasturePb.ConfigOptionsList{
  71. Value: int32(pasturePb.BreedStatus_No_Mating),
  72. Label: "禁配",
  73. Disabled: true,
  74. })
  75. return breedStatusList*/
  76. }
  77. func (s *StoreEntry) CowKindEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  78. dataList := make([]*model.ConfigCowKind, 0)
  79. pref := s.DB.Model(new(model.ConfigCowKind)).
  80. Where("is_show =? ", pasturePb.IsShow_Ok).
  81. Where("pasture_id =? ", userModel.AppPasture.Id)
  82. if isAll == model.IsAllYes {
  83. pref = pref.Where("kind >= ?", pasturePb.CowKind_Invalid)
  84. } else {
  85. pref = pref.Where("kind > ?", pasturePb.CowKind_Invalid)
  86. }
  87. if err := pref.Order("kind ASC").
  88. Find(&dataList).Error; err != nil {
  89. zaplog.Error("CowKindEnumList", zap.Any("err", err))
  90. return make([]*pasturePb.ConfigOptionsList, 0)
  91. }
  92. return model.ConfigCowKindSlice(dataList).ToPB2(userModel.Language)
  93. /*cowKindList := make([]*pasturePb.ConfigOptionsList, 0)
  94. cowKindList = append(cowKindList, &pasturePb.ConfigOptionsList{
  95. Value: int32(pasturePb.CowKind_XMTEN),
  96. Label: "西门塔尔牛",
  97. Disabled: true,
  98. }, &pasturePb.ConfigOptionsList{
  99. Value: int32(pasturePb.CowKind_AGSN),
  100. Label: "安格斯牛",
  101. Disabled: true,
  102. }, &pasturePb.ConfigOptionsList{
  103. Value: int32(pasturePb.CowKind_XNLN),
  104. Label: "夏洛莱牛",
  105. Disabled: true,
  106. }, &pasturePb.ConfigOptionsList{
  107. Value: int32(pasturePb.CowKind_LMZN),
  108. Label: "利木赞牛",
  109. Disabled: true,
  110. }, &pasturePb.ConfigOptionsList{
  111. Value: int32(pasturePb.CowKind_HFTN),
  112. Label: "海福特牛",
  113. Disabled: true,
  114. }, &pasturePb.ConfigOptionsList{
  115. Value: int32(pasturePb.CowKind_HN),
  116. Label: "和牛",
  117. Disabled: true,
  118. })
  119. return cowKindList*/
  120. }
  121. func (s *StoreEntry) CowSourceEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  122. dataList := make([]*model.ConfigCowSource, 0)
  123. pref := s.DB.Model(new(model.ConfigCowSource)).
  124. Where("is_show =? ", pasturePb.IsShow_Ok).
  125. Where("pasture_id =? ", userModel.AppPasture.Id)
  126. if isAll == model.IsAllYes {
  127. pref = pref.Where("kind >= ?", pasturePb.CowSource_Invalid)
  128. } else {
  129. pref = pref.Where("kind > ?", pasturePb.CowSource_Invalid)
  130. }
  131. if err := pref.Order("kind ASC").
  132. Find(&dataList).Error; err != nil {
  133. zaplog.Error("CowKindEnumList", zap.Any("err", err))
  134. return make([]*pasturePb.ConfigOptionsList, 0)
  135. }
  136. return model.ConfigCowSourceSlice(dataList).ToPB2(userModel.Language)
  137. /*cowSourceList := make([]*pasturePb.ConfigOptionsList, 0)
  138. cowSourceList = append(cowSourceList, &pasturePb.ConfigOptionsList{
  139. Value: int32(pasturePb.CowSource_Calving),
  140. Label: "产犊",
  141. Disabled: true,
  142. }, &pasturePb.ConfigOptionsList{
  143. Value: int32(pasturePb.CowSource_Transfer_In),
  144. Label: "调入",
  145. Disabled: true,
  146. }, &pasturePb.ConfigOptionsList{
  147. Value: int32(pasturePb.CowSource_Buy),
  148. Label: "购买",
  149. Disabled: true,
  150. })
  151. return cowSourceList*/
  152. }
  153. func (s *StoreEntry) CowTypeEnumList(optionName, isAll string) []*pasturePb.ConfigOptionsList {
  154. cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  155. if isAll == model.IsAllYes {
  156. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  157. Value: int32(pasturePb.CowType_Invalid),
  158. Label: "全部",
  159. Disabled: true,
  160. })
  161. }
  162. if optionName == "breed" {
  163. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  164. Value: int32(pasturePb.CowType_Reserve_Calf),
  165. Label: "后备牛",
  166. Disabled: true,
  167. }, &pasturePb.ConfigOptionsList{
  168. Value: int32(pasturePb.CowType_Breeding_Calf),
  169. Label: "成母牛",
  170. Disabled: true,
  171. })
  172. return cowTypeList
  173. }
  174. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  175. Value: int32(pasturePb.CowType_Lactating_Calf),
  176. Label: "哺乳犊牛",
  177. Disabled: true,
  178. }, &pasturePb.ConfigOptionsList{
  179. Value: int32(pasturePb.CowType_Weaned_Calf),
  180. Label: "育成牛",
  181. Disabled: true,
  182. }, &pasturePb.ConfigOptionsList{
  183. Value: int32(pasturePb.CowType_Youth_Calf),
  184. Label: "青年牛",
  185. Disabled: true,
  186. }, &pasturePb.ConfigOptionsList{
  187. Value: int32(pasturePb.CowType_Fattening_Calf),
  188. Label: "育肥牛",
  189. Disabled: true,
  190. }, &pasturePb.ConfigOptionsList{
  191. Value: int32(pasturePb.CowType_Reserve_Calf),
  192. Label: "后备牛",
  193. Disabled: true,
  194. }, &pasturePb.ConfigOptionsList{
  195. Value: int32(pasturePb.CowType_Breeding_Calf),
  196. Label: "成母牛",
  197. Disabled: true,
  198. }, &pasturePb.ConfigOptionsList{
  199. Value: int32(pasturePb.CowType_Breeding_Bull),
  200. Label: "种公牛",
  201. Disabled: true,
  202. })
  203. return cowTypeList
  204. }
  205. func (s *StoreEntry) SameTimeCowTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  206. dataList := make([]*model.ConfigSameTimeCowType, 0)
  207. pref := s.DB.Model(new(model.ConfigSameTimeCowType)).
  208. Where("is_show =? ", pasturePb.IsShow_Ok).
  209. Where("pasture_id =? ", userModel.AppPasture.Id)
  210. if isAll == model.IsAllYes {
  211. pref = pref.Where("kind >= ?", pasturePb.SameTimeCowType_Invalid)
  212. } else {
  213. pref = pref.Where("kind > ?", pasturePb.SameTimeCowType_Invalid)
  214. }
  215. if err := pref.Order("kind ASC").
  216. Find(&dataList).Error; err != nil {
  217. zaplog.Error("ConfigSameTimeCowType", zap.Any("err", err))
  218. return make([]*pasturePb.ConfigOptionsList, 0)
  219. }
  220. return model.ConfigSameTimeCowTypeSlice(dataList).ToPB(userModel.Language)
  221. /*cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  222. if isAll == model.IsAllYes {
  223. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  224. Value: int32(pasturePb.SameTimeCowType_Invalid),
  225. Label: "全部",
  226. Disabled: true,
  227. })
  228. }
  229. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  230. Value: int32(pasturePb.SameTimeCowType_Empty),
  231. Label: "空怀牛",
  232. Disabled: true,
  233. }, &pasturePb.ConfigOptionsList{
  234. Value: int32(pasturePb.SameTimeCowType_Breeding_Calf),
  235. Label: "成母牛",
  236. Disabled: true,
  237. })
  238. return cowTypeList*/
  239. }
  240. func (s *StoreEntry) SameTimeTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  241. dataList := make([]*model.ConfigSameTimeType, 0)
  242. pref := s.DB.Model(new(model.ConfigSameTimeType)).
  243. Where("is_show =? ", pasturePb.IsShow_Ok).
  244. Where("pasture_id =? ", userModel.AppPasture.Id)
  245. if isAll == model.IsAllYes {
  246. pref = pref.Where("kind >= ?", pasturePb.SameTimeType_Invalid)
  247. } else {
  248. pref = pref.Where("kind > ?", pasturePb.SameTimeType_Invalid)
  249. }
  250. if err := pref.Order("kind ASC").
  251. Find(&dataList).Error; err != nil {
  252. zaplog.Error("SameTimeTypeEnumList", zap.Any("err", err))
  253. return make([]*pasturePb.ConfigOptionsList, 0)
  254. }
  255. return model.ConfigSameTimeTypeSlice(dataList).ToPB(userModel.Language)
  256. /*cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  257. if isAll == model.IsAllYes {
  258. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  259. Value: int32(pasturePb.SameTimeType_Invalid),
  260. Label: "全部",
  261. Disabled: true,
  262. })
  263. }
  264. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  265. Value: int32(pasturePb.SameTimeType_PGBJ),
  266. Label: "PG保健",
  267. Disabled: true,
  268. }, &pasturePb.ConfigOptionsList{
  269. Value: int32(pasturePb.SameTimeType_PGTQ),
  270. Label: "PG同期",
  271. Disabled: true,
  272. }, &pasturePb.ConfigOptionsList{
  273. Value: int32(pasturePb.SameTimeType_RnGH),
  274. Label: "RnGH",
  275. Disabled: true,
  276. }, &pasturePb.ConfigOptionsList{
  277. Value: int32(pasturePb.SameTimeType_TAI),
  278. Label: "TAI输精",
  279. Disabled: true,
  280. })
  281. return cowTypeList*/
  282. }
  283. func (s *StoreEntry) ImmunizationCowTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  284. dataList := make([]*model.ConfigImmunizationCowType, 0)
  285. pref := s.DB.Model(new(model.ConfigImmunizationCowType)).
  286. Where("is_show =? ", pasturePb.IsShow_Ok).
  287. Where("pasture_id =? ", userModel.AppPasture.Id)
  288. if isAll == model.IsAllYes {
  289. pref = pref.Where("kind >= ?", pasturePb.CowKind_Invalid)
  290. } else {
  291. pref = pref.Where("kind > ?", pasturePb.CowKind_Invalid)
  292. }
  293. if err := pref.Order("kind ASC").
  294. Find(&dataList).Error; err != nil {
  295. zaplog.Error("SameTimeTypeEnumList", zap.Any("err", err))
  296. return make([]*pasturePb.ConfigOptionsList, 0)
  297. }
  298. return model.ConfigImmunizationCowTypeSlice(dataList).ToPB(userModel.Language)
  299. /*cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  300. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  301. Value: int32(pasturePb.CowType_Lactating_Calf),
  302. Label: "犊牛",
  303. Disabled: true,
  304. }, &pasturePb.ConfigOptionsList{
  305. Value: int32(pasturePb.CowType_Weaned_Calf),
  306. Label: "育成牛",
  307. Disabled: true,
  308. }, &pasturePb.ConfigOptionsList{
  309. Value: int32(pasturePb.CowType_Youth_Calf),
  310. Label: "青年牛",
  311. Disabled: true,
  312. }, &pasturePb.ConfigOptionsList{
  313. Value: int32(pasturePb.CowType_Fattening_Calf),
  314. Label: "育肥牛",
  315. Disabled: true,
  316. }, &pasturePb.ConfigOptionsList{
  317. Value: int32(pasturePb.CowType_Reserve_Calf),
  318. Label: "后备牛",
  319. Disabled: true,
  320. }, &pasturePb.ConfigOptionsList{
  321. Value: int32(pasturePb.CowType_Breeding_Calf),
  322. Label: "成母牛",
  323. Disabled: true,
  324. }, &pasturePb.ConfigOptionsList{
  325. Value: int32(pasturePb.CowType_Breeding_Bull),
  326. Label: "种公牛",
  327. Disabled: true,
  328. })
  329. return cowTypeList*/
  330. }
  331. func (s *StoreEntry) ImmunizationConditionsEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  332. dataList := make([]*model.ConfigImmunizationConditions, 0)
  333. pref := s.DB.Model(new(model.ConfigImmunizationConditions)).
  334. Where("is_show =? ", pasturePb.IsShow_Ok).
  335. Where("pasture_id =? ", userModel.AppPasture.Id)
  336. if isAll == model.IsAllYes {
  337. pref = pref.Where("kind >= ?", pasturePb.ImmunizationConditions_Invalid)
  338. } else {
  339. pref = pref.Where("kind > ?", pasturePb.ImmunizationConditions_Invalid)
  340. }
  341. if err := pref.Order("kind ASC").
  342. Find(&dataList).Error; err != nil {
  343. zaplog.Error("ImmunizationConditionsEnumList", zap.Any("err", err))
  344. return make([]*pasturePb.ConfigOptionsList, 0)
  345. }
  346. return model.ConfigImmunizationConditionsSlice(dataList).ToPB(userModel.Language)
  347. /*cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  348. if isAll == model.IsAllYes {
  349. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  350. Value: int32(pasturePb.ImmunizationConditions_Invalid),
  351. Label: "全部",
  352. Disabled: true,
  353. })
  354. }
  355. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  356. Value: int32(pasturePb.ImmunizationConditions_Days_Age),
  357. Label: "日龄",
  358. Disabled: true,
  359. }, &pasturePb.ConfigOptionsList{
  360. Value: int32(pasturePb.ImmunizationConditions_Days_After_Delivery),
  361. Label: "产后天数",
  362. Disabled: true,
  363. }, &pasturePb.ConfigOptionsList{
  364. Value: int32(pasturePb.ImmunizationConditions_Days_Of_Pregnancy),
  365. Label: "怀孕天数",
  366. Disabled: true,
  367. }, &pasturePb.ConfigOptionsList{
  368. Value: int32(pasturePb.ImmunizationConditions_Admission_Days),
  369. Label: "入场天数",
  370. Disabled: true,
  371. }, &pasturePb.ConfigOptionsList{
  372. Value: int32(pasturePb.ImmunizationConditions_Other_Vaccine_After),
  373. Label: "基于其他疫苗之后",
  374. Disabled: true,
  375. })
  376. return cowTypeList*/
  377. }
  378. func (s *StoreEntry) TransferPenEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  379. dataList := make([]*model.ConfigTransferPenReason, 0)
  380. pref := s.DB.Model(new(model.ConfigTransferPenReason)).
  381. Where("is_show =? ", pasturePb.IsShow_Ok).
  382. Where("pasture_id =? ", userModel.AppPasture.Id)
  383. if isAll == model.IsAllYes {
  384. pref = pref.Where("kind >= ?", pasturePb.TransferPenReason_Invalid)
  385. } else {
  386. pref = pref.Where("kind > ?", pasturePb.TransferPenReason_Invalid)
  387. }
  388. if err := pref.Order("kind ASC").
  389. Find(&dataList).Error; err != nil {
  390. zaplog.Error("TransferPenEnumList", zap.Any("err", err))
  391. return make([]*pasturePb.ConfigOptionsList, 0)
  392. }
  393. return model.ConfigTransferPenReasonSlice(dataList).ToPB2(userModel.Language)
  394. /*transferPenList := make([]*pasturePb.ConfigOptionsList, 0)
  395. if isAll == model.IsAllYes {
  396. transferPenList = append(transferPenList, &pasturePb.ConfigOptionsList{
  397. Value: int32(pasturePb.TransferPenReason_Invalid),
  398. Label: "全部",
  399. Disabled: true,
  400. })
  401. }
  402. transferPenList = append(transferPenList, &pasturePb.ConfigOptionsList{
  403. Value: int32(pasturePb.TransferPenReason_Normal),
  404. Label: "正常转群",
  405. Disabled: true,
  406. }, &pasturePb.ConfigOptionsList{
  407. Value: int32(pasturePb.TransferPenReason_Feed),
  408. Label: "饲喂转群",
  409. Disabled: true,
  410. }, &pasturePb.ConfigOptionsList{
  411. Value: int32(pasturePb.TransferPenReason_Dry_Milk),
  412. Label: "干奶转群",
  413. Disabled: true,
  414. }, &pasturePb.ConfigOptionsList{
  415. Value: int32(pasturePb.TransferPenReason_Pregnant),
  416. Label: "怀孕转群",
  417. Disabled: true,
  418. }, &pasturePb.ConfigOptionsList{
  419. Value: int32(pasturePb.TransferPenReason_Overantibody),
  420. Label: "过抗转群",
  421. Disabled: true,
  422. })
  423. return transferPenList*/
  424. }
  425. func (s *StoreEntry) ChildNumberEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  426. dataList := make([]*model.ConfigChildNumber, 0)
  427. pref := s.DB.Model(new(model.ConfigChildNumber)).
  428. Where("is_show =? ", pasturePb.IsShow_Ok).
  429. Where("pasture_id =? ", userModel.AppPasture.Id)
  430. if isAll == model.IsAllYes {
  431. pref = pref.Where("kind >= ?", pasturePb.ChildNumber_Invalid)
  432. } else {
  433. pref = pref.Where("kind > ?", pasturePb.ChildNumber_Invalid)
  434. }
  435. if err := pref.Order("kind ASC").
  436. Find(&dataList).Error; err != nil {
  437. zaplog.Error("ChildNumberEnumList", zap.Any("err", err))
  438. return make([]*pasturePb.ConfigOptionsList, 0)
  439. }
  440. return model.ConfigChildNumberSlice(dataList).ToPB(userModel.Language)
  441. /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  442. if isAll == model.IsAllYes {
  443. configOptions = append(configOptions,
  444. &pasturePb.ConfigOptionsList{
  445. Value: int32(pasturePb.ChildNumber_Invalid),
  446. Label: "全部",
  447. Disabled: true,
  448. })
  449. }
  450. configOptions = append(configOptions,
  451. &pasturePb.ConfigOptionsList{
  452. Value: int32(pasturePb.ChildNumber_One),
  453. Label: "单胎",
  454. Disabled: true,
  455. }, &pasturePb.ConfigOptionsList{
  456. Value: int32(pasturePb.ChildNumber_Two),
  457. Label: "双胎",
  458. Disabled: true,
  459. }, &pasturePb.ConfigOptionsList{
  460. Value: int32(pasturePb.ChildNumber_Three),
  461. Label: "三胎",
  462. Disabled: true,
  463. }, &pasturePb.ConfigOptionsList{
  464. Value: int32(pasturePb.ChildNumber_Four),
  465. Label: "四胎",
  466. Disabled: true,
  467. })
  468. return configOptions*/
  469. }
  470. func (s *StoreEntry) CalvingLevelEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  471. dataList := make([]*model.ConfigCalvingLevel, 0)
  472. pref := s.DB.Model(new(model.ConfigCalvingLevel)).
  473. Where("is_show =? ", pasturePb.IsShow_Ok).
  474. Where("pasture_id =? ", userModel.AppPasture.Id)
  475. if isAll == model.IsAllYes {
  476. pref = pref.Where("kind >= ?", pasturePb.CalvingLevel_Invalid)
  477. } else {
  478. pref = pref.Where("kind > ?", pasturePb.CalvingLevel_Invalid)
  479. }
  480. if err := pref.Order("kind ASC").
  481. Find(&dataList).Error; err != nil {
  482. zaplog.Error("CalvingLevelEnumList", zap.Any("err", err))
  483. return make([]*pasturePb.ConfigOptionsList, 0)
  484. }
  485. return model.ConfigCalvingLevelSlice(dataList).ToPB(userModel.Language)
  486. /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  487. if isAll == model.IsAllYes {
  488. configOptions = append(configOptions,
  489. &pasturePb.ConfigOptionsList{
  490. Value: int32(pasturePb.CalvingLevel_Invalid),
  491. Label: "全部",
  492. Disabled: true,
  493. })
  494. }
  495. configOptions = append(configOptions,
  496. &pasturePb.ConfigOptionsList{
  497. Value: int32(pasturePb.CalvingLevel_Natural_Childbirth),
  498. Label: "自然分娩",
  499. Disabled: true,
  500. }, &pasturePb.ConfigOptionsList{
  501. Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery1),
  502. Label: "人工助产(1-2人)",
  503. Disabled: true,
  504. }, &pasturePb.ConfigOptionsList{
  505. Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery2),
  506. Label: "人工助产(3人以上)",
  507. Disabled: true,
  508. }, &pasturePb.ConfigOptionsList{
  509. Value: int32(pasturePb.CalvingLevel_Caesarean_Section),
  510. Label: "剖腹产",
  511. Disabled: true,
  512. })
  513. return configOptions*/
  514. }
  515. func (s *StoreEntry) DystociaReasonEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  516. dataList := make([]*model.ConfigDystociaReason, 0)
  517. pref := s.DB.Model(new(model.ConfigDystociaReason)).
  518. Where("is_show =? ", pasturePb.IsShow_Ok).
  519. Where("pasture_id =? ", userModel.AppPasture.Id)
  520. if isAll == model.IsAllYes {
  521. pref = pref.Where("kind >= ?", pasturePb.DystociaReason_Invalid)
  522. } else {
  523. pref = pref.Where("kind > ?", pasturePb.DystociaReason_Invalid)
  524. }
  525. if err := pref.Order("kind ASC").
  526. Find(&dataList).Error; err != nil {
  527. zaplog.Error("CalvingLevelEnumList", zap.Any("err", err))
  528. return make([]*pasturePb.ConfigOptionsList, 0)
  529. }
  530. return model.ConfigDystociaReasonSlice(dataList).ToPB(userModel.Language)
  531. /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  532. if isAll == model.IsAllYes {
  533. configOptions = append(configOptions,
  534. &pasturePb.ConfigOptionsList{
  535. Value: int32(pasturePb.DystociaReason_Invalid),
  536. Label: "全部",
  537. Disabled: true,
  538. })
  539. }
  540. configOptions = append(configOptions,
  541. &pasturePb.ConfigOptionsList{
  542. Value: int32(pasturePb.DystociaReason_Malposition),
  543. Label: "胎位不正",
  544. Disabled: true,
  545. }, &pasturePb.ConfigOptionsList{
  546. Value: int32(pasturePb.DystociaReason_Fetal_Overgrowth),
  547. Label: "胎儿过大",
  548. Disabled: true,
  549. }, &pasturePb.ConfigOptionsList{
  550. Value: int32(pasturePb.DystociaReason_Uterine_Atony),
  551. Label: "子宫收缩无力",
  552. Disabled: true,
  553. }, &pasturePb.ConfigOptionsList{
  554. Value: int32(pasturePb.DystociaReason_Pelvic_Stenosis),
  555. Label: "盆骨狭小",
  556. Disabled: true,
  557. }, &pasturePb.ConfigOptionsList{
  558. Value: int32(pasturePb.DystociaReason_Sub_Health),
  559. Label: "母牛亚健康状态",
  560. Disabled: true,
  561. })
  562. return configOptions*/
  563. }
  564. func (s *StoreEntry) PregnantCheckResultEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  565. dataList := make([]*model.ConfigPregnantCheckResult, 0)
  566. pref := s.DB.Model(new(model.ConfigPregnantCheckResult)).
  567. Where("is_show =? ", pasturePb.IsShow_Ok).
  568. Where("pasture_id =? ", userModel.AppPasture.Id)
  569. if isAll == model.IsAllYes {
  570. pref = pref.Where("kind >= ?", pasturePb.PregnantCheckResult_Invalid)
  571. } else {
  572. pref = pref.Where("kind > ?", pasturePb.PregnantCheckResult_Invalid)
  573. }
  574. if err := pref.Order("kind ASC").
  575. Find(&dataList).Error; err != nil {
  576. zaplog.Error("PregnantCheckResultEnumList", zap.Any("err", err))
  577. return make([]*pasturePb.ConfigOptionsList, 0)
  578. }
  579. return model.ConfigPregnantCheckResultSlice(dataList).ToPB(userModel.Language)
  580. /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  581. if isAll == model.IsAllYes {
  582. configOptions = append(configOptions,
  583. &pasturePb.ConfigOptionsList{
  584. Value: int32(pasturePb.PregnantCheckResult_Invalid),
  585. Label: "全部",
  586. Disabled: true,
  587. })
  588. }
  589. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  590. Value: int32(pasturePb.PregnantCheckResult_Pregnant),
  591. Label: "有胎",
  592. Disabled: true,
  593. }, &pasturePb.ConfigOptionsList{
  594. Value: int32(pasturePb.PregnantCheckResult_UnPregnant),
  595. Label: "无胎",
  596. Disabled: true,
  597. })
  598. return configOptions*/
  599. }