config_data.go 26 KB

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