config_data.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  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) SemeTimeCowTypeEnumList() []*pasturePb.ConfigOptionsList {
  226. cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  227. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  228. Value: int32(pasturePb.CowType_Nurturing),
  229. Label: "育成牛",
  230. Disabled: true,
  231. }, &pasturePb.ConfigOptionsList{
  232. Value: int32(pasturePb.CowType_Lactation),
  233. Label: "泌乳牛",
  234. Disabled: true,
  235. })
  236. return cowTypeList
  237. }
  238. func (s *StoreEntry) TransferPenEnumList() []*pasturePb.ConfigOptionsList {
  239. transferPenList := make([]*pasturePb.ConfigOptionsList, 0)
  240. transferPenList = append(transferPenList, &pasturePb.ConfigOptionsList{
  241. Value: int32(pasturePb.TransferPenReason_Normal),
  242. Label: "正常转群",
  243. Disabled: true,
  244. }, &pasturePb.ConfigOptionsList{
  245. Value: int32(pasturePb.TransferPenReason_Feed),
  246. Label: "饲喂转群",
  247. Disabled: true,
  248. }, &pasturePb.ConfigOptionsList{
  249. Value: int32(pasturePb.TransferPenReason_Dry_Milk),
  250. Label: "干奶转群",
  251. Disabled: true,
  252. }, &pasturePb.ConfigOptionsList{
  253. Value: int32(pasturePb.TransferPenReason_Pregnant),
  254. Label: "怀孕转群",
  255. Disabled: true,
  256. }, &pasturePb.ConfigOptionsList{
  257. Value: int32(pasturePb.TransferPenReason_Overantibody),
  258. Label: "过抗转群",
  259. Disabled: true,
  260. })
  261. return transferPenList
  262. }
  263. func (s *StoreEntry) ChildNumberEnumList() []*pasturePb.ConfigOptionsList {
  264. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  265. configOptions = append(configOptions,
  266. &pasturePb.ConfigOptionsList{
  267. Value: int32(pasturePb.ChildNumber_One),
  268. Label: "单胎",
  269. Disabled: true,
  270. }, &pasturePb.ConfigOptionsList{
  271. Value: int32(pasturePb.ChildNumber_Two),
  272. Label: "双胎",
  273. Disabled: true,
  274. }, &pasturePb.ConfigOptionsList{
  275. Value: int32(pasturePb.ChildNumber_Three),
  276. Label: "三胎",
  277. Disabled: true,
  278. }, &pasturePb.ConfigOptionsList{
  279. Value: int32(pasturePb.ChildNumber_Four),
  280. Label: "四胎",
  281. Disabled: true,
  282. })
  283. return configOptions
  284. }
  285. func (s *StoreEntry) CalvingLevelEnumList() []*pasturePb.ConfigOptionsList {
  286. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  287. configOptions = append(configOptions,
  288. &pasturePb.ConfigOptionsList{
  289. Value: int32(pasturePb.CalvingLevel_Natural_Childbirth),
  290. Label: "自然分娩",
  291. Disabled: true,
  292. }, &pasturePb.ConfigOptionsList{
  293. Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery1),
  294. Label: "人工助产(1-2人)",
  295. Disabled: true,
  296. }, &pasturePb.ConfigOptionsList{
  297. Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery2),
  298. Label: "人工助产(3人以上)",
  299. Disabled: true,
  300. }, &pasturePb.ConfigOptionsList{
  301. Value: int32(pasturePb.CalvingLevel_Caesarean),
  302. Label: "剖腹产",
  303. Disabled: true,
  304. })
  305. return configOptions
  306. }
  307. func (s *StoreEntry) DystociaReasonEnumList() []*pasturePb.ConfigOptionsList {
  308. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  309. configOptions = append(configOptions,
  310. &pasturePb.ConfigOptionsList{
  311. Value: int32(pasturePb.DystociaReason_Malposition),
  312. Label: "胎位不正",
  313. Disabled: true,
  314. }, &pasturePb.ConfigOptionsList{
  315. Value: int32(pasturePb.DystociaReason_Fetal_Overgrowth),
  316. Label: "胎儿过大",
  317. Disabled: true,
  318. }, &pasturePb.ConfigOptionsList{
  319. Value: int32(pasturePb.DystociaReason_Uterine_Atony),
  320. Label: "子宫收缩无力",
  321. Disabled: true,
  322. }, &pasturePb.ConfigOptionsList{
  323. Value: int32(pasturePb.DystociaReason_Pelvic_Stenosis),
  324. Label: "盆骨狭小",
  325. Disabled: true,
  326. }, &pasturePb.ConfigOptionsList{
  327. Value: int32(pasturePb.DystociaReason_Sub_Health),
  328. Label: "母牛亚健康状态",
  329. Disabled: true,
  330. })
  331. return configOptions
  332. }
  333. func (s *StoreEntry) PregnantCheckResultEnumList() []*pasturePb.ConfigOptionsList {
  334. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  335. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  336. Value: int32(pasturePb.PregnantCheckResult_InCheck_UnPregnant),
  337. Label: "初检未孕",
  338. Disabled: true,
  339. }, &pasturePb.ConfigOptionsList{
  340. Value: int32(pasturePb.PregnantCheckResult_InCheck_Pregnant),
  341. Label: "初检已孕",
  342. Disabled: true,
  343. }, &pasturePb.ConfigOptionsList{
  344. Value: int32(pasturePb.PregnantCheckResult_Recheck_UnPregnant),
  345. Label: "复检未孕",
  346. Disabled: true,
  347. }, &pasturePb.ConfigOptionsList{
  348. Value: int32(pasturePb.PregnantCheckResult_Recheck_Pregnant),
  349. Label: "初检已孕",
  350. Disabled: true,
  351. })
  352. return configOptions
  353. }
  354. func (s *StoreEntry) PregnantCheckMethodEnumList() []*pasturePb.ConfigOptionsList {
  355. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  356. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  357. Value: int32(pasturePb.PregnantCheckMethod_B_Ultrasound),
  358. Label: "B超",
  359. Disabled: true,
  360. }, &pasturePb.ConfigOptionsList{
  361. Value: int32(pasturePb.PregnantCheckMethod_Blood_Testing),
  362. Label: "血检",
  363. Disabled: true,
  364. }, &pasturePb.ConfigOptionsList{
  365. Value: int32(pasturePb.PregnantCheckMethod_Manual_Inspection),
  366. Label: "人工检查",
  367. Disabled: true,
  368. })
  369. return configOptions
  370. }
  371. func (s *StoreEntry) DrugCategoryEnumList() []*pasturePb.ConfigOptionsList {
  372. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  373. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  374. Value: int32(pasturePb.DrugCategory_Antibiotics),
  375. Label: "抗生素类",
  376. Disabled: true,
  377. }, &pasturePb.ConfigOptionsList{
  378. Value: int32(pasturePb.DrugCategory_Antivirals),
  379. Label: "抗病毒类",
  380. Disabled: true,
  381. }, &pasturePb.ConfigOptionsList{
  382. Value: int32(pasturePb.DrugCategory_Antifungals),
  383. Label: "抗真菌类",
  384. Disabled: true,
  385. }, &pasturePb.ConfigOptionsList{
  386. Value: int32(pasturePb.DrugCategory_Antiparasitics),
  387. Label: "抗寄生虫类",
  388. Disabled: true,
  389. }, &pasturePb.ConfigOptionsList{
  390. Value: int32(pasturePb.DrugCategory_Analgesics),
  391. Label: "镇痛类",
  392. Disabled: true,
  393. }, &pasturePb.ConfigOptionsList{
  394. Value: int32(pasturePb.DrugCategory_Antipyretic),
  395. Label: "退烧类",
  396. Disabled: true,
  397. }, &pasturePb.ConfigOptionsList{
  398. Value: int32(pasturePb.DrugCategory_Vitamin),
  399. Label: "维生素类",
  400. Disabled: true,
  401. }, &pasturePb.ConfigOptionsList{
  402. Value: int32(pasturePb.DrugCategory_Brine),
  403. Label: "盐水",
  404. Disabled: true,
  405. }, &pasturePb.ConfigOptionsList{
  406. Value: int32(pasturePb.DrugCategory_Glucose),
  407. Label: "葡萄糖",
  408. Disabled: true,
  409. }, &pasturePb.ConfigOptionsList{
  410. Value: int32(pasturePb.DrugCategory_Hormone),
  411. Label: "激素类",
  412. Disabled: true,
  413. }, &pasturePb.ConfigOptionsList{
  414. Value: int32(pasturePb.DrugCategory_Anti_Stress),
  415. Label: "抗应激类",
  416. Disabled: true,
  417. }, &pasturePb.ConfigOptionsList{
  418. Value: int32(pasturePb.DrugCategory_Disinfect),
  419. Label: "消毒类",
  420. Disabled: true,
  421. }, &pasturePb.ConfigOptionsList{
  422. Value: int32(pasturePb.DrugCategory_Chinese_Herbal),
  423. Label: "中药合剂",
  424. Disabled: true,
  425. }, &pasturePb.ConfigOptionsList{
  426. Value: int32(pasturePb.DrugCategory_Tocolytic),
  427. Label: "保胎类",
  428. Disabled: true,
  429. })
  430. return configOptions
  431. }
  432. func (s *StoreEntry) DrugUsageEnumList() []*pasturePb.ConfigOptionsList {
  433. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  434. configOptions = append(configOptions,
  435. &pasturePb.ConfigOptionsList{
  436. Value: int32(pasturePb.DrugUsage_Oral_Medications),
  437. Label: "口服",
  438. Disabled: true,
  439. }, &pasturePb.ConfigOptionsList{
  440. Value: int32(pasturePb.DrugUsage_Injectable_Medications),
  441. Label: "肌注",
  442. Disabled: true,
  443. }, &pasturePb.ConfigOptionsList{
  444. Value: int32(pasturePb.DrugUsage_Topical_Medications),
  445. Label: "外用",
  446. Disabled: true,
  447. }, &pasturePb.ConfigOptionsList{
  448. Value: int32(pasturePb.DrugUsage_Drink_Medications),
  449. Label: "饮水",
  450. Disabled: true,
  451. })
  452. return configOptions
  453. }
  454. func (s *StoreEntry) UnitEnumList() []*pasturePb.ConfigOptionsList {
  455. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  456. configOptions = append(configOptions,
  457. &pasturePb.ConfigOptionsList{
  458. Value: int32(pasturePb.Unit_Pieces),
  459. Label: "个",
  460. Disabled: true,
  461. }, &pasturePb.ConfigOptionsList{
  462. Value: int32(pasturePb.Unit_Package),
  463. Label: "包/袋",
  464. Disabled: true,
  465. }, &pasturePb.ConfigOptionsList{
  466. Value: int32(pasturePb.Unit_Bottle),
  467. Label: "瓶",
  468. Disabled: true,
  469. }, &pasturePb.ConfigOptionsList{
  470. Value: int32(pasturePb.Unit_Box),
  471. Label: "盒",
  472. Disabled: true,
  473. }, &pasturePb.ConfigOptionsList{
  474. Value: int32(pasturePb.Unit_Boxful),
  475. Label: "箱",
  476. Disabled: true,
  477. }, &pasturePb.ConfigOptionsList{
  478. Value: int32(pasturePb.Unit_Branch),
  479. Label: "支",
  480. Disabled: true,
  481. }, &pasturePb.ConfigOptionsList{
  482. Value: int32(pasturePb.Unit_Barrel),
  483. Label: "桶",
  484. Disabled: true,
  485. }, &pasturePb.ConfigOptionsList{
  486. Value: int32(pasturePb.Unit_Pot),
  487. Label: "罐",
  488. Disabled: true,
  489. })
  490. return configOptions
  491. }
  492. func (s *StoreEntry) ExposeEstrusTypeEnumList() []*pasturePb.ConfigOptionsList {
  493. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  494. configOptions = append(configOptions,
  495. &pasturePb.ConfigOptionsList{
  496. Value: int32(pasturePb.ExposeEstrusType_Neck_Ring),
  497. Label: "脖环揭发",
  498. Disabled: true,
  499. }, &pasturePb.ConfigOptionsList{
  500. Value: int32(pasturePb.ExposeEstrusType_Foot_Ring),
  501. Label: "脚环/计步器揭发",
  502. Disabled: true,
  503. }, &pasturePb.ConfigOptionsList{
  504. Value: int32(pasturePb.ExposeEstrusType_Manual_Observation),
  505. Label: "人工观察",
  506. Disabled: true,
  507. })
  508. return configOptions
  509. }
  510. func (s *StoreEntry) FrozenSemenTypeEnumList() []*pasturePb.ConfigOptionsList {
  511. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  512. configOptions = append(configOptions,
  513. &pasturePb.ConfigOptionsList{
  514. Value: int32(pasturePb.FrozenSemenType_Ordinary),
  515. Label: "常规冻精",
  516. Disabled: true,
  517. }, &pasturePb.ConfigOptionsList{
  518. Value: int32(pasturePb.FrozenSemenType_Gender_Control),
  519. Label: "性控冻精",
  520. Disabled: true,
  521. })
  522. return configOptions
  523. }
  524. func (s *StoreEntry) BullNumberEnumList() []*pasturePb.BullOptionsList {
  525. frozenSemenList := make([]*model.EventFrozenSemen, 0)
  526. bullNumberList := make([]*pasturePb.BullOptionsList, 0)
  527. if err := s.DB.Where("quantity > 0").Group("bull_id").Find(&frozenSemenList).Error; err != nil {
  528. zaplog.Error("BullNumberEnumList", zap.Any("Find", err))
  529. }
  530. for _, v := range frozenSemenList {
  531. bullNumberList = append(bullNumberList, &pasturePb.BullOptionsList{
  532. Value: v.BullId,
  533. Label: v.BullId,
  534. Disabled: true,
  535. })
  536. }
  537. return bullNumberList
  538. }
  539. func (s *StoreEntry) WeekEnumList() []*pasturePb.ConfigOptionsList {
  540. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  541. configOptions = append(configOptions,
  542. &pasturePb.ConfigOptionsList{
  543. Value: int32(pasturePb.Week_Monday),
  544. Label: "周一",
  545. Disabled: true,
  546. }, &pasturePb.ConfigOptionsList{
  547. Value: int32(pasturePb.Week_Tuesday),
  548. Label: "周二",
  549. Disabled: true,
  550. }, &pasturePb.ConfigOptionsList{
  551. Value: int32(pasturePb.Week_Wednesday),
  552. Label: "周三",
  553. Disabled: true,
  554. }, &pasturePb.ConfigOptionsList{
  555. Value: int32(pasturePb.Week_Thursday),
  556. Label: "周四",
  557. Disabled: true,
  558. }, &pasturePb.ConfigOptionsList{
  559. Value: int32(pasturePb.Week_Friday),
  560. Label: "周五",
  561. Disabled: true,
  562. }, &pasturePb.ConfigOptionsList{
  563. Value: int32(pasturePb.Week_Saturday),
  564. Label: "周六",
  565. Disabled: true,
  566. }, &pasturePb.ConfigOptionsList{
  567. Value: int32(pasturePb.Week_Sunday),
  568. Label: "周日",
  569. Disabled: true,
  570. })
  571. return configOptions
  572. }
  573. func (s *StoreEntry) DrugUsageMaps() map[pasturePb.DrugUsage_Kind]string {
  574. res := make(map[pasturePb.DrugUsage_Kind]string)
  575. for _, v := range s.DrugUsageEnumList() {
  576. res[pasturePb.DrugUsage_Kind(v.Value)] = v.Label
  577. }
  578. return res
  579. }
  580. func (s *StoreEntry) ExposeEstrusTypeMap() map[pasturePb.ExposeEstrusType_Kind]string {
  581. res := make(map[pasturePb.ExposeEstrusType_Kind]string)
  582. for _, v := range s.ExposeEstrusTypeEnumList() {
  583. res[pasturePb.ExposeEstrusType_Kind(v.Value)] = v.Label
  584. }
  585. return res
  586. }
  587. func (s *StoreEntry) FrozenSemenTypeMap() map[pasturePb.FrozenSemenType_Kind]string {
  588. res := make(map[pasturePb.FrozenSemenType_Kind]string)
  589. for _, v := range s.FrozenSemenTypeEnumList() {
  590. res[pasturePb.FrozenSemenType_Kind(v.Value)] = v.Label
  591. }
  592. return res
  593. }
  594. func (s *StoreEntry) UnitMap() map[pasturePb.Unit_Kind]string {
  595. res := make(map[pasturePb.Unit_Kind]string)
  596. for _, v := range s.UnitEnumList() {
  597. res[pasturePb.Unit_Kind(v.Value)] = v.Label
  598. }
  599. return res
  600. }
  601. func (s *StoreEntry) WeekMap() map[pasturePb.Week_Kind]string {
  602. res := make(map[pasturePb.Week_Kind]string)
  603. for _, v := range s.WeekEnumList() {
  604. res[pasturePb.Week_Kind(v.Value)] = v.Label
  605. }
  606. return res
  607. }
  608. func (s *StoreEntry) CowTypeMap() map[pasturePb.CowType_Kind]string {
  609. res := make(map[pasturePb.CowType_Kind]string)
  610. for _, v := range s.CowTypeEnumList() {
  611. res[pasturePb.CowType_Kind(v.Value)] = v.Label
  612. }
  613. return res
  614. }
  615. func (s *StoreEntry) CowStatusMap() map[pasturePb.CowStatus_Kind]string {
  616. res := make(map[pasturePb.CowStatus_Kind]string)
  617. for _, v := range s.CowStatusEnumList() {
  618. res[pasturePb.CowStatus_Kind(v.Value)] = v.Label
  619. }
  620. return res
  621. }
  622. func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  623. return &pasturePb.ConfigOptionsListResponse{
  624. Code: http.StatusOK,
  625. Message: "ok",
  626. Data: s.BarnTypeEnumList(),
  627. }, nil
  628. }
  629. func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int) (*pasturePb.ConfigOptionsListResponse, error) {
  630. penList := make([]*model.Pen, 0)
  631. pref := s.DB.Table(new(model.Pen).TableName()).
  632. Where("is_delete = ?", pasturePb.IsShow_Ok)
  633. if penType != -1 {
  634. pref.Where("pen_type = ?", penType)
  635. }
  636. if err := pref.Find(&penList).Error; err != nil {
  637. return nil, err
  638. }
  639. return &pasturePb.ConfigOptionsListResponse{
  640. Code: http.StatusOK,
  641. Message: "ok",
  642. Data: model.PenSlice(penList).ToPB2(s.BarnTypeEnumList()),
  643. }, nil
  644. }
  645. func (s *StoreEntry) BreedStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  646. return &pasturePb.ConfigOptionsListResponse{
  647. Code: http.StatusOK,
  648. Message: "ok",
  649. Data: s.BreedStatusEnumList(),
  650. }, nil
  651. }
  652. func (s *StoreEntry) CowKindOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  653. return &pasturePb.ConfigOptionsListResponse{
  654. Code: http.StatusOK,
  655. Message: "ok",
  656. Data: s.CowKindEnumList(),
  657. }, nil
  658. }
  659. func (s *StoreEntry) CowSourceOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  660. return &pasturePb.ConfigOptionsListResponse{
  661. Code: http.StatusOK,
  662. Message: "ok",
  663. Data: s.CowSourceEnumList(),
  664. }, nil
  665. }
  666. func (s *StoreEntry) CowStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  667. return &pasturePb.ConfigOptionsListResponse{
  668. Code: http.StatusOK,
  669. Message: "ok",
  670. Data: s.CowStatusEnumList(),
  671. }, nil
  672. }
  673. func (s *StoreEntry) CowTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  674. return &pasturePb.ConfigOptionsListResponse{
  675. Code: http.StatusOK,
  676. Message: "ok",
  677. Data: s.CowTypeEnumList(),
  678. }, nil
  679. }
  680. func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  681. return &pasturePb.ConfigOptionsListResponse{
  682. Code: http.StatusOK,
  683. Message: "ok",
  684. Data: s.TransferPenEnumList(),
  685. }, nil
  686. }
  687. func (s *StoreEntry) SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error) {
  688. systemUserList := make([]*model.SystemUser, 0)
  689. pref := s.DB.Table(new(model.SystemUser).TableName()).
  690. Where("is_delete = ?", pasturePb.IsShow_Ok).
  691. Where("is_show =? ", pasturePb.IsShow_Ok)
  692. if depId != -1 && depId > 0 {
  693. pref = pref.Where("dept_id = ?", depId)
  694. }
  695. if err := pref.Find(&systemUserList).Error; err != nil {
  696. return nil, xxerr.WithStack(err)
  697. }
  698. return &pasturePb.ConfigOptionsListResponse{
  699. Code: http.StatusOK,
  700. Message: "ok",
  701. Data: model.SystemUserSlice(systemUserList).ToPB2(),
  702. }, nil
  703. }
  704. func (s *StoreEntry) BullOptions(ctx context.Context) (*pasturePb.BullOptionsListResponse, error) {
  705. return &pasturePb.BullOptionsListResponse{
  706. Code: http.StatusOK,
  707. Message: "ok",
  708. Data: s.BullNumberEnumList(),
  709. }, nil
  710. }
  711. func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName string) (*pasturePb.ConfigOptionsListResponse, error) {
  712. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  713. switch optionsName {
  714. case "childNumber":
  715. configOptions = s.ChildNumberEnumList()
  716. case "calvingLevel":
  717. configOptions = s.CalvingLevelEnumList()
  718. case "dystociaReason":
  719. configOptions = s.DystociaReasonEnumList()
  720. case "drugCategory":
  721. configOptions = s.DrugCategoryEnumList()
  722. case "drugUsage":
  723. configOptions = s.DrugUsageEnumList()
  724. case "unit":
  725. configOptions = s.UnitEnumList()
  726. case "pregnantCheckResult":
  727. configOptions = s.PregnantCheckResultEnumList()
  728. case "pregnantCheckMethod":
  729. configOptions = s.PregnantCheckMethodEnumList()
  730. case "exposeEstrusType":
  731. configOptions = s.ExposeEstrusTypeEnumList()
  732. case "frozenSemenType":
  733. configOptions = s.FrozenSemenTypeEnumList()
  734. case "week":
  735. configOptions = s.WeekEnumList()
  736. case "sameTimeCowType":
  737. configOptions = s.SemeTimeCowTypeEnumList()
  738. }
  739. return &pasturePb.ConfigOptionsListResponse{
  740. Code: http.StatusOK,
  741. Message: "ok",
  742. Data: configOptions,
  743. }, nil
  744. }