config_data.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. package backend
  2. import (
  3. "context"
  4. "kpt-pasture/model"
  5. "net/http"
  6. "gitee.com/xuyiping_admin/pkg/logger/zaplog"
  7. "go.uber.org/zap"
  8. xxerr "gitee.com/xuyiping_admin/pkg/xerr"
  9. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  10. )
  11. var DrugCategoryMap = map[pasturePb.DrugCategory_Kind]string{
  12. pasturePb.DrugCategory_Antibiotics: "抗生素类",
  13. pasturePb.DrugCategory_Antivirals: "抗病毒类",
  14. pasturePb.DrugCategory_Antifungals: "抗真菌类",
  15. pasturePb.DrugCategory_Antiparasitics: "抗寄生虫类",
  16. pasturePb.DrugCategory_Analgesics: "镇痛类",
  17. pasturePb.DrugCategory_Antipyretic: "退烧类",
  18. pasturePb.DrugCategory_Vitamin: "维生素类",
  19. pasturePb.DrugCategory_Brine: "盐水",
  20. pasturePb.DrugCategory_Glucose: "葡萄糖",
  21. pasturePb.DrugCategory_Hormone: "激素类",
  22. pasturePb.DrugCategory_Anti_Stress: "抗应激类",
  23. pasturePb.DrugCategory_Disinfect: "消毒类",
  24. pasturePb.DrugCategory_Chinese_Herbal: "中药合剂",
  25. pasturePb.DrugCategory_Tocolytic: "保胎类",
  26. }
  27. var UnitMap = map[pasturePb.Unit_Kind]string{
  28. pasturePb.Unit_Pieces: "个",
  29. pasturePb.Unit_Package: "包/袋",
  30. pasturePb.Unit_Bottle: "瓶",
  31. pasturePb.Unit_Box: "盒",
  32. pasturePb.Unit_Boxful: "箱",
  33. pasturePb.Unit_Branch: "支",
  34. pasturePb.Unit_Barrel: "桶",
  35. pasturePb.Unit_Pot: "罐",
  36. }
  37. var DrugUsageMap = map[pasturePb.DrugUsage_Kind]string{
  38. pasturePb.DrugUsage_Oral_Medications: "口服",
  39. pasturePb.DrugUsage_Injectable_Medications: "肌注",
  40. pasturePb.DrugUsage_Topical_Medications: "外用",
  41. pasturePb.DrugUsage_Drink_Medications: "饮水",
  42. }
  43. func (s *StoreEntry) BarnTypeEnumList() []*pasturePb.ConfigOptionsList {
  44. barnTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  45. barnTypeList = append(barnTypeList, &pasturePb.ConfigOptionsList{
  46. Value: int32(pasturePb.PenType_Lactating_Calves),
  47. Label: "哺乳犊牛舍",
  48. Disabled: true,
  49. }, &pasturePb.ConfigOptionsList{
  50. Value: int32(pasturePb.PenType_Weaned_Calves),
  51. Label: "断奶犊牛舍",
  52. Disabled: true,
  53. }, &pasturePb.ConfigOptionsList{
  54. Value: int32(pasturePb.PenType_Youth),
  55. Label: "育成牛舍",
  56. Disabled: true,
  57. }, &pasturePb.ConfigOptionsList{
  58. Value: int32(pasturePb.PenType_Nurturing),
  59. Label: "育成牛舍",
  60. Disabled: true,
  61. }, &pasturePb.ConfigOptionsList{
  62. Value: int32(pasturePb.PenType_Lactation),
  63. Label: "泌乳牛舍",
  64. Disabled: true,
  65. }, &pasturePb.ConfigOptionsList{
  66. Value: int32(pasturePb.PenType_Peripartum),
  67. Label: "围产牛舍",
  68. Disabled: true,
  69. }, &pasturePb.ConfigOptionsList{
  70. Value: int32(pasturePb.PenType_Dry_Milking),
  71. Label: "干奶牛舍",
  72. Disabled: true,
  73. }, &pasturePb.ConfigOptionsList{
  74. Value: int32(pasturePb.PenType_Sick_Cow),
  75. Label: "病牛舍",
  76. Disabled: true,
  77. }, &pasturePb.ConfigOptionsList{
  78. Value: int32(pasturePb.PenType_Eliminate),
  79. Label: "淘汰牛舍",
  80. Disabled: true,
  81. })
  82. return barnTypeList
  83. }
  84. func (s *StoreEntry) BreedStatusEnumList() []*pasturePb.ConfigOptionsList {
  85. breedStatusList := make([]*pasturePb.ConfigOptionsList, 0)
  86. breedStatusList = append(breedStatusList, &pasturePb.ConfigOptionsList{
  87. Value: int32(pasturePb.BreedStatus_Unmarried),
  88. Label: "未配",
  89. Disabled: true,
  90. }, &pasturePb.ConfigOptionsList{
  91. Value: int32(pasturePb.BreedStatus_InCheck_Unpregnant),
  92. Label: "初检无胎",
  93. Disabled: true,
  94. }, &pasturePb.ConfigOptionsList{
  95. Value: int32(pasturePb.BreedStatus_InCheck_Pregnant),
  96. Label: "初检有胎",
  97. Disabled: true,
  98. }, &pasturePb.ConfigOptionsList{
  99. Value: int32(pasturePb.BreedStatus_Recheck_Unpregnant),
  100. Label: "复检无胎",
  101. Disabled: true,
  102. }, &pasturePb.ConfigOptionsList{
  103. Value: int32(pasturePb.BreedStatus_Recheck_Pregnant),
  104. Label: "复检有胎",
  105. Disabled: true,
  106. }, &pasturePb.ConfigOptionsList{
  107. Value: int32(pasturePb.BreedStatus_Pause_Pregnant),
  108. Label: "停配",
  109. Disabled: true,
  110. }, &pasturePb.ConfigOptionsList{
  111. Value: int32(pasturePb.BreedStatus_No_Pregnant),
  112. Label: "禁配",
  113. Disabled: true,
  114. })
  115. return breedStatusList
  116. }
  117. func (s *StoreEntry) CowKindEnumList() []*pasturePb.ConfigOptionsList {
  118. cowKindList := make([]*pasturePb.ConfigOptionsList, 0)
  119. cowKindList = append(cowKindList, &pasturePb.ConfigOptionsList{
  120. Value: int32(pasturePb.CowKind_HST),
  121. Label: "荷斯坦",
  122. Disabled: true,
  123. }, &pasturePb.ConfigOptionsList{
  124. Value: int32(pasturePb.CowKind_JSN),
  125. Label: "娟姗牛",
  126. Disabled: true,
  127. }, &pasturePb.ConfigOptionsList{
  128. Value: int32(pasturePb.CowKind_SHN),
  129. Label: "三河牛",
  130. Disabled: true,
  131. }, &pasturePb.ConfigOptionsList{
  132. Value: int32(pasturePb.CowKind_XJHN),
  133. Label: "新疆褐牛",
  134. Disabled: true,
  135. }, &pasturePb.ConfigOptionsList{
  136. Value: int32(pasturePb.CowKind_MN),
  137. Label: "牦牛",
  138. Disabled: true,
  139. }, &pasturePb.ConfigOptionsList{
  140. Value: int32(pasturePb.CowKind_XMTEN),
  141. Label: "西门塔尔牛",
  142. Disabled: true,
  143. })
  144. return cowKindList
  145. }
  146. func (s *StoreEntry) CowSourceEnumList() []*pasturePb.ConfigOptionsList {
  147. cowSourceList := make([]*pasturePb.ConfigOptionsList, 0)
  148. cowSourceList = append(cowSourceList, &pasturePb.ConfigOptionsList{
  149. Value: int32(pasturePb.CowSource_Calving),
  150. Label: "产犊",
  151. Disabled: true,
  152. }, &pasturePb.ConfigOptionsList{
  153. Value: int32(pasturePb.CowSource_Transfer_In),
  154. Label: "调入",
  155. Disabled: true,
  156. }, &pasturePb.ConfigOptionsList{
  157. Value: int32(pasturePb.CowSource_Buy),
  158. Label: "购买",
  159. Disabled: true,
  160. })
  161. return cowSourceList
  162. }
  163. func (s *StoreEntry) CowStatusEnumList() []*pasturePb.ConfigOptionsList {
  164. cowStatusList := make([]*pasturePb.ConfigOptionsList, 0)
  165. cowStatusList = append(cowStatusList, &pasturePb.ConfigOptionsList{
  166. Value: int32(pasturePb.CowStatus_Calving),
  167. Label: "产犊",
  168. Disabled: true,
  169. }, &pasturePb.ConfigOptionsList{
  170. Value: int32(pasturePb.CowStatus_Empty),
  171. Label: "空怀",
  172. Disabled: true,
  173. }, &pasturePb.ConfigOptionsList{
  174. Value: int32(pasturePb.CowStatus_Breeding),
  175. Label: "配种",
  176. Disabled: true,
  177. }, &pasturePb.ConfigOptionsList{
  178. Value: int32(pasturePb.CowStatus_Pregnant),
  179. Label: "怀孕",
  180. Disabled: true,
  181. }, &pasturePb.ConfigOptionsList{
  182. Value: int32(pasturePb.CowStatus_Dry_Milk),
  183. Label: "干奶",
  184. Disabled: true,
  185. }, &pasturePb.ConfigOptionsList{
  186. Value: int32(pasturePb.CowStatus_Peripartum),
  187. Label: "围产",
  188. Disabled: true,
  189. }, &pasturePb.ConfigOptionsList{
  190. Value: int32(pasturePb.CowStatus_No_Pregnant),
  191. Label: "禁配",
  192. Disabled: true,
  193. })
  194. return cowStatusList
  195. }
  196. func (s *StoreEntry) CowTypeEnumList() []*pasturePb.ConfigOptionsList {
  197. cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  198. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  199. Value: int32(pasturePb.CowType_Lactating_Calf),
  200. Label: "哺乳犊牛",
  201. Disabled: true,
  202. }, &pasturePb.ConfigOptionsList{
  203. Value: int32(pasturePb.CowType_Weaned_Calf),
  204. Label: "断奶犊牛",
  205. Disabled: true,
  206. }, &pasturePb.ConfigOptionsList{
  207. Value: int32(pasturePb.CowType_Youth),
  208. Label: "青年牛",
  209. Disabled: true,
  210. }, &pasturePb.ConfigOptionsList{
  211. Value: int32(pasturePb.CowType_Nurturing),
  212. Label: "育成牛",
  213. Disabled: true,
  214. }, &pasturePb.ConfigOptionsList{
  215. Value: int32(pasturePb.CowType_Lactation),
  216. Label: "泌乳牛",
  217. Disabled: true,
  218. }, &pasturePb.ConfigOptionsList{
  219. Value: int32(pasturePb.CowType_Dry_Milk),
  220. Label: "干奶牛",
  221. Disabled: true,
  222. })
  223. return cowTypeList
  224. }
  225. func (s *StoreEntry) TransferPenEnumList() []*pasturePb.ConfigOptionsList {
  226. transferPenList := make([]*pasturePb.ConfigOptionsList, 0)
  227. transferPenList = append(transferPenList, &pasturePb.ConfigOptionsList{
  228. Value: int32(pasturePb.TransferPenReason_Normal),
  229. Label: "正常转群",
  230. Disabled: true,
  231. }, &pasturePb.ConfigOptionsList{
  232. Value: int32(pasturePb.TransferPenReason_Feed),
  233. Label: "饲喂转群",
  234. Disabled: true,
  235. }, &pasturePb.ConfigOptionsList{
  236. Value: int32(pasturePb.TransferPenReason_Dry_Milk),
  237. Label: "干奶转群",
  238. Disabled: true,
  239. }, &pasturePb.ConfigOptionsList{
  240. Value: int32(pasturePb.TransferPenReason_Pregnant),
  241. Label: "怀孕转群",
  242. Disabled: true,
  243. }, &pasturePb.ConfigOptionsList{
  244. Value: int32(pasturePb.TransferPenReason_Overantibody),
  245. Label: "过抗转群",
  246. Disabled: true,
  247. })
  248. return transferPenList
  249. }
  250. func (s *StoreEntry) ChildNumberEnumList() []*pasturePb.ConfigOptionsList {
  251. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  252. configOptions = append(configOptions,
  253. &pasturePb.ConfigOptionsList{
  254. Value: int32(pasturePb.ChildNumber_One),
  255. Label: "单胎",
  256. Disabled: true,
  257. }, &pasturePb.ConfigOptionsList{
  258. Value: int32(pasturePb.ChildNumber_Two),
  259. Label: "双胎",
  260. Disabled: true,
  261. }, &pasturePb.ConfigOptionsList{
  262. Value: int32(pasturePb.ChildNumber_Three),
  263. Label: "三胎",
  264. Disabled: true,
  265. }, &pasturePb.ConfigOptionsList{
  266. Value: int32(pasturePb.ChildNumber_Four),
  267. Label: "四胎",
  268. Disabled: true,
  269. })
  270. return configOptions
  271. }
  272. func (s *StoreEntry) CalvingLevelEnumList() []*pasturePb.ConfigOptionsList {
  273. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  274. configOptions = append(configOptions,
  275. &pasturePb.ConfigOptionsList{
  276. Value: int32(pasturePb.CalvingLevel_Natural_Childbirth),
  277. Label: "自然分娩",
  278. Disabled: true,
  279. }, &pasturePb.ConfigOptionsList{
  280. Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery1),
  281. Label: "人工助产(1-2人)",
  282. Disabled: true,
  283. }, &pasturePb.ConfigOptionsList{
  284. Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery2),
  285. Label: "人工助产(3人以上)",
  286. Disabled: true,
  287. }, &pasturePb.ConfigOptionsList{
  288. Value: int32(pasturePb.CalvingLevel_Caesarean),
  289. Label: "剖腹产",
  290. Disabled: true,
  291. })
  292. return configOptions
  293. }
  294. func (s *StoreEntry) DystociaReasonEnumList() []*pasturePb.ConfigOptionsList {
  295. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  296. configOptions = append(configOptions,
  297. &pasturePb.ConfigOptionsList{
  298. Value: int32(pasturePb.DystociaReason_Malposition),
  299. Label: "胎位不正",
  300. Disabled: true,
  301. }, &pasturePb.ConfigOptionsList{
  302. Value: int32(pasturePb.DystociaReason_Fetal_Overgrowth),
  303. Label: "胎儿过大",
  304. Disabled: true,
  305. }, &pasturePb.ConfigOptionsList{
  306. Value: int32(pasturePb.DystociaReason_Uterine_Atony),
  307. Label: "子宫收缩无力",
  308. Disabled: true,
  309. }, &pasturePb.ConfigOptionsList{
  310. Value: int32(pasturePb.DystociaReason_Pelvic_Stenosis),
  311. Label: "盆骨狭小",
  312. Disabled: true,
  313. }, &pasturePb.ConfigOptionsList{
  314. Value: int32(pasturePb.DystociaReason_Sub_Health),
  315. Label: "母牛亚健康状态",
  316. Disabled: true,
  317. })
  318. return configOptions
  319. }
  320. func (s *StoreEntry) PregnantCheckResultEnumList() []*pasturePb.ConfigOptionsList {
  321. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  322. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  323. Value: int32(pasturePb.PregnantCheckResult_InCheck_UnPregnant),
  324. Label: "初检未孕",
  325. Disabled: true,
  326. }, &pasturePb.ConfigOptionsList{
  327. Value: int32(pasturePb.PregnantCheckResult_InCheck_Pregnant),
  328. Label: "初检已孕",
  329. Disabled: true,
  330. }, &pasturePb.ConfigOptionsList{
  331. Value: int32(pasturePb.PregnantCheckResult_Recheck_UnPregnant),
  332. Label: "复检未孕",
  333. Disabled: true,
  334. }, &pasturePb.ConfigOptionsList{
  335. Value: int32(pasturePb.PregnantCheckResult_Recheck_Pregnant),
  336. Label: "初检已孕",
  337. Disabled: true,
  338. })
  339. return configOptions
  340. }
  341. func (s *StoreEntry) PregnantCheckMethodEnumList() []*pasturePb.ConfigOptionsList {
  342. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  343. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  344. Value: int32(pasturePb.PregnantCheckMethod_B_Ultrasound),
  345. Label: "B超",
  346. Disabled: true,
  347. }, &pasturePb.ConfigOptionsList{
  348. Value: int32(pasturePb.PregnantCheckMethod_Blood_Testing),
  349. Label: "血检",
  350. Disabled: true,
  351. }, &pasturePb.ConfigOptionsList{
  352. Value: int32(pasturePb.PregnantCheckMethod_Manual_Inspection),
  353. Label: "人工检查",
  354. Disabled: true,
  355. })
  356. return configOptions
  357. }
  358. func (s *StoreEntry) DrugCategoryEnumList() []*pasturePb.ConfigOptionsList {
  359. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  360. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  361. Value: int32(pasturePb.DrugCategory_Antibiotics),
  362. Label: "抗生素类",
  363. Disabled: true,
  364. }, &pasturePb.ConfigOptionsList{
  365. Value: int32(pasturePb.DrugCategory_Antivirals),
  366. Label: "抗病毒类",
  367. Disabled: true,
  368. }, &pasturePb.ConfigOptionsList{
  369. Value: int32(pasturePb.DrugCategory_Antifungals),
  370. Label: "抗真菌类",
  371. Disabled: true,
  372. }, &pasturePb.ConfigOptionsList{
  373. Value: int32(pasturePb.DrugCategory_Antiparasitics),
  374. Label: "抗寄生虫类",
  375. Disabled: true,
  376. }, &pasturePb.ConfigOptionsList{
  377. Value: int32(pasturePb.DrugCategory_Analgesics),
  378. Label: "镇痛类",
  379. Disabled: true,
  380. }, &pasturePb.ConfigOptionsList{
  381. Value: int32(pasturePb.DrugCategory_Antipyretic),
  382. Label: "退烧类",
  383. Disabled: true,
  384. }, &pasturePb.ConfigOptionsList{
  385. Value: int32(pasturePb.DrugCategory_Vitamin),
  386. Label: "维生素类",
  387. Disabled: true,
  388. }, &pasturePb.ConfigOptionsList{
  389. Value: int32(pasturePb.DrugCategory_Brine),
  390. Label: "盐水",
  391. Disabled: true,
  392. }, &pasturePb.ConfigOptionsList{
  393. Value: int32(pasturePb.DrugCategory_Glucose),
  394. Label: "葡萄糖",
  395. Disabled: true,
  396. }, &pasturePb.ConfigOptionsList{
  397. Value: int32(pasturePb.DrugCategory_Hormone),
  398. Label: "激素类",
  399. Disabled: true,
  400. }, &pasturePb.ConfigOptionsList{
  401. Value: int32(pasturePb.DrugCategory_Anti_Stress),
  402. Label: "抗应激类",
  403. Disabled: true,
  404. }, &pasturePb.ConfigOptionsList{
  405. Value: int32(pasturePb.DrugCategory_Disinfect),
  406. Label: "消毒类",
  407. Disabled: true,
  408. }, &pasturePb.ConfigOptionsList{
  409. Value: int32(pasturePb.DrugCategory_Chinese_Herbal),
  410. Label: "中药合剂",
  411. Disabled: true,
  412. }, &pasturePb.ConfigOptionsList{
  413. Value: int32(pasturePb.DrugCategory_Tocolytic),
  414. Label: "保胎类",
  415. Disabled: true,
  416. })
  417. return configOptions
  418. }
  419. func (s *StoreEntry) DrugUsageEnumList() []*pasturePb.ConfigOptionsList {
  420. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  421. configOptions = append(configOptions,
  422. &pasturePb.ConfigOptionsList{
  423. Value: int32(pasturePb.DrugUsage_Oral_Medications),
  424. Label: "口服",
  425. Disabled: true,
  426. }, &pasturePb.ConfigOptionsList{
  427. Value: int32(pasturePb.DrugUsage_Injectable_Medications),
  428. Label: "肌注",
  429. Disabled: true,
  430. }, &pasturePb.ConfigOptionsList{
  431. Value: int32(pasturePb.DrugUsage_Topical_Medications),
  432. Label: "外用",
  433. Disabled: true,
  434. }, &pasturePb.ConfigOptionsList{
  435. Value: int32(pasturePb.DrugUsage_Drink_Medications),
  436. Label: "饮水",
  437. Disabled: true,
  438. })
  439. return configOptions
  440. }
  441. func (s *StoreEntry) UnitEnumList() []*pasturePb.ConfigOptionsList {
  442. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  443. configOptions = append(configOptions,
  444. &pasturePb.ConfigOptionsList{
  445. Value: int32(pasturePb.Unit_Pieces),
  446. Label: "个",
  447. Disabled: true,
  448. }, &pasturePb.ConfigOptionsList{
  449. Value: int32(pasturePb.Unit_Package),
  450. Label: "包/袋",
  451. Disabled: true,
  452. }, &pasturePb.ConfigOptionsList{
  453. Value: int32(pasturePb.Unit_Bottle),
  454. Label: "瓶",
  455. Disabled: true,
  456. }, &pasturePb.ConfigOptionsList{
  457. Value: int32(pasturePb.Unit_Box),
  458. Label: "盒",
  459. Disabled: true,
  460. }, &pasturePb.ConfigOptionsList{
  461. Value: int32(pasturePb.Unit_Boxful),
  462. Label: "箱",
  463. Disabled: true,
  464. }, &pasturePb.ConfigOptionsList{
  465. Value: int32(pasturePb.Unit_Branch),
  466. Label: "支",
  467. Disabled: true,
  468. }, &pasturePb.ConfigOptionsList{
  469. Value: int32(pasturePb.Unit_Barrel),
  470. Label: "桶",
  471. Disabled: true,
  472. }, &pasturePb.ConfigOptionsList{
  473. Value: int32(pasturePb.Unit_Pot),
  474. Label: "罐",
  475. Disabled: true,
  476. })
  477. return configOptions
  478. }
  479. func (s *StoreEntry) ExposeEstrusTypeEnumList() []*pasturePb.ConfigOptionsList {
  480. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  481. configOptions = append(configOptions,
  482. &pasturePb.ConfigOptionsList{
  483. Value: int32(pasturePb.ExposeEstrusType_Neck_Ring),
  484. Label: "脖环揭发",
  485. Disabled: true,
  486. }, &pasturePb.ConfigOptionsList{
  487. Value: int32(pasturePb.ExposeEstrusType_Foot_Ring),
  488. Label: "脚环/计步器揭发",
  489. Disabled: true,
  490. }, &pasturePb.ConfigOptionsList{
  491. Value: int32(pasturePb.ExposeEstrusType_Manual_Observation),
  492. Label: "人工观察",
  493. Disabled: true,
  494. })
  495. return configOptions
  496. }
  497. func (s *StoreEntry) FrozenSemenTypeEnumList() []*pasturePb.ConfigOptionsList {
  498. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  499. configOptions = append(configOptions,
  500. &pasturePb.ConfigOptionsList{
  501. Value: int32(pasturePb.FrozenSemenType_Ordinary),
  502. Label: "常规冻精",
  503. Disabled: true,
  504. }, &pasturePb.ConfigOptionsList{
  505. Value: int32(pasturePb.FrozenSemenType_Gender_Control),
  506. Label: "性控冻精",
  507. Disabled: true,
  508. })
  509. return configOptions
  510. }
  511. func (s *StoreEntry) BullNumberEnumList() []*pasturePb.BullOptionsList {
  512. frozenSemenList := make([]*model.EventFrozenSemen, 0)
  513. bullNumberList := make([]*pasturePb.BullOptionsList, 0)
  514. if err := s.DB.Where("quantity > 0").Group("bull_id").Find(&frozenSemenList).Error; err != nil {
  515. zaplog.Error("BullNumberEnumList", zap.Any("Find", err))
  516. }
  517. for _, v := range frozenSemenList {
  518. bullNumberList = append(bullNumberList, &pasturePb.BullOptionsList{
  519. Value: v.BullId,
  520. Label: v.BullId,
  521. Disabled: true,
  522. })
  523. }
  524. return bullNumberList
  525. }
  526. func (s *StoreEntry) DrugUsageMaps() map[pasturePb.DrugUsage_Kind]string {
  527. res := make(map[pasturePb.DrugUsage_Kind]string)
  528. for _, v := range s.DrugUsageEnumList() {
  529. res[pasturePb.DrugUsage_Kind(v.Value)] = v.Label
  530. }
  531. return res
  532. }
  533. func (s *StoreEntry) ExposeEstrusTypeMap() map[pasturePb.ExposeEstrusType_Kind]string {
  534. res := make(map[pasturePb.ExposeEstrusType_Kind]string)
  535. for _, v := range s.ExposeEstrusTypeEnumList() {
  536. res[pasturePb.ExposeEstrusType_Kind(v.Value)] = v.Label
  537. }
  538. return res
  539. }
  540. func (s *StoreEntry) FrozenSemenTypeMap() map[pasturePb.FrozenSemenType_Kind]string {
  541. res := make(map[pasturePb.FrozenSemenType_Kind]string)
  542. for _, v := range s.FrozenSemenTypeEnumList() {
  543. res[pasturePb.FrozenSemenType_Kind(v.Value)] = v.Label
  544. }
  545. return res
  546. }
  547. func (s *StoreEntry) UnitMap() map[pasturePb.Unit_Kind]string {
  548. res := make(map[pasturePb.Unit_Kind]string)
  549. for _, v := range s.UnitEnumList() {
  550. res[pasturePb.Unit_Kind(v.Value)] = v.Label
  551. }
  552. return res
  553. }
  554. func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  555. return &pasturePb.ConfigOptionsListResponse{
  556. Code: http.StatusOK,
  557. Message: "ok",
  558. Data: s.BarnTypeEnumList(),
  559. }, nil
  560. }
  561. func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int) (*pasturePb.ConfigOptionsListResponse, error) {
  562. penList := make([]*model.Pen, 0)
  563. pref := s.DB.Table(new(model.Pen).TableName()).
  564. Where("is_delete = ?", pasturePb.IsShow_Ok)
  565. if penType != -1 {
  566. pref.Where("pen_type = ?", penType)
  567. }
  568. if err := pref.Find(&penList).Error; err != nil {
  569. return nil, err
  570. }
  571. return &pasturePb.ConfigOptionsListResponse{
  572. Code: http.StatusOK,
  573. Message: "ok",
  574. Data: model.PenSlice(penList).ToPB2(s.BarnTypeEnumList()),
  575. }, nil
  576. }
  577. func (s *StoreEntry) BreedStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  578. return &pasturePb.ConfigOptionsListResponse{
  579. Code: http.StatusOK,
  580. Message: "ok",
  581. Data: s.BreedStatusEnumList(),
  582. }, nil
  583. }
  584. func (s *StoreEntry) CowKindOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  585. return &pasturePb.ConfigOptionsListResponse{
  586. Code: http.StatusOK,
  587. Message: "ok",
  588. Data: s.CowKindEnumList(),
  589. }, nil
  590. }
  591. func (s *StoreEntry) CowSourceOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  592. return &pasturePb.ConfigOptionsListResponse{
  593. Code: http.StatusOK,
  594. Message: "ok",
  595. Data: s.CowSourceEnumList(),
  596. }, nil
  597. }
  598. func (s *StoreEntry) CowStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  599. return &pasturePb.ConfigOptionsListResponse{
  600. Code: http.StatusOK,
  601. Message: "ok",
  602. Data: s.CowStatusEnumList(),
  603. }, nil
  604. }
  605. func (s *StoreEntry) CowTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  606. return &pasturePb.ConfigOptionsListResponse{
  607. Code: http.StatusOK,
  608. Message: "ok",
  609. Data: s.CowTypeEnumList(),
  610. }, nil
  611. }
  612. func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  613. return &pasturePb.ConfigOptionsListResponse{
  614. Code: http.StatusOK,
  615. Message: "ok",
  616. Data: s.TransferPenEnumList(),
  617. }, nil
  618. }
  619. func (s *StoreEntry) SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error) {
  620. systemUserList := make([]*model.SystemUser, 0)
  621. pref := s.DB.Table(new(model.SystemUser).TableName()).
  622. Where("is_delete = ?", pasturePb.IsShow_Ok).
  623. Where("is_show =? ", pasturePb.IsShow_Ok)
  624. if depId != -1 && depId > 0 {
  625. pref = pref.Where("dept_id = ?", depId)
  626. }
  627. if err := pref.Find(&systemUserList).Error; err != nil {
  628. return nil, xxerr.WithStack(err)
  629. }
  630. return &pasturePb.ConfigOptionsListResponse{
  631. Code: http.StatusOK,
  632. Message: "ok",
  633. Data: model.SystemUserSlice(systemUserList).ToPB2(),
  634. }, nil
  635. }
  636. func (s *StoreEntry) BullOptions(ctx context.Context) (*pasturePb.BullOptionsListResponse, error) {
  637. return &pasturePb.BullOptionsListResponse{
  638. Code: http.StatusOK,
  639. Message: "ok",
  640. Data: s.BullNumberEnumList(),
  641. }, nil
  642. }
  643. func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName string) (*pasturePb.ConfigOptionsListResponse, error) {
  644. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  645. switch optionsName {
  646. case "childNumber":
  647. configOptions = s.ChildNumberEnumList()
  648. case "calvingLevel":
  649. configOptions = s.CalvingLevelEnumList()
  650. case "dystociaReason":
  651. configOptions = s.DystociaReasonEnumList()
  652. case "drugCategory":
  653. configOptions = s.DrugCategoryEnumList()
  654. case "drugUsage":
  655. configOptions = s.DrugUsageEnumList()
  656. case "unit":
  657. configOptions = s.UnitEnumList()
  658. case "pregnantCheckResult":
  659. configOptions = s.PregnantCheckResultEnumList()
  660. case "pregnantCheckMethod":
  661. configOptions = s.PregnantCheckMethodEnumList()
  662. case "exposeEstrusType":
  663. configOptions = s.ExposeEstrusTypeEnumList()
  664. case "frozenSemenType":
  665. configOptions = s.FrozenSemenTypeEnumList()
  666. }
  667. return &pasturePb.ConfigOptionsListResponse{
  668. Code: http.StatusOK,
  669. Message: "ok",
  670. Data: configOptions,
  671. }, nil
  672. }