config_data.go 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  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. }, &pasturePb.ConfigOptionsList{
  434. Value: int32(pasturePb.DrugCategory_Immunity),
  435. Label: "免疫类",
  436. Disabled: true,
  437. })
  438. return configOptions
  439. }
  440. func (s *StoreEntry) DrugUsageEnumList() []*pasturePb.ConfigOptionsList {
  441. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  442. configOptions = append(configOptions,
  443. &pasturePb.ConfigOptionsList{
  444. Value: int32(pasturePb.DrugUsage_Oral_Medications),
  445. Label: "口服",
  446. Disabled: true,
  447. }, &pasturePb.ConfigOptionsList{
  448. Value: int32(pasturePb.DrugUsage_Injectable_Medications),
  449. Label: "肌注",
  450. Disabled: true,
  451. }, &pasturePb.ConfigOptionsList{
  452. Value: int32(pasturePb.DrugUsage_Topical_Medications),
  453. Label: "外用",
  454. Disabled: true,
  455. }, &pasturePb.ConfigOptionsList{
  456. Value: int32(pasturePb.DrugUsage_Drink_Medications),
  457. Label: "饮水",
  458. Disabled: true,
  459. })
  460. return configOptions
  461. }
  462. func (s *StoreEntry) UnitEnumList() []*pasturePb.ConfigOptionsList {
  463. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  464. configOptions = append(configOptions,
  465. &pasturePb.ConfigOptionsList{
  466. Value: int32(pasturePb.Unit_Pieces),
  467. Label: "个",
  468. Disabled: true,
  469. }, &pasturePb.ConfigOptionsList{
  470. Value: int32(pasturePb.Unit_Package),
  471. Label: "包/袋",
  472. Disabled: true,
  473. }, &pasturePb.ConfigOptionsList{
  474. Value: int32(pasturePb.Unit_Bottle),
  475. Label: "瓶",
  476. Disabled: true,
  477. }, &pasturePb.ConfigOptionsList{
  478. Value: int32(pasturePb.Unit_Box),
  479. Label: "盒",
  480. Disabled: true,
  481. }, &pasturePb.ConfigOptionsList{
  482. Value: int32(pasturePb.Unit_Boxful),
  483. Label: "箱",
  484. Disabled: true,
  485. }, &pasturePb.ConfigOptionsList{
  486. Value: int32(pasturePb.Unit_Branch),
  487. Label: "支",
  488. Disabled: true,
  489. }, &pasturePb.ConfigOptionsList{
  490. Value: int32(pasturePb.Unit_Barrel),
  491. Label: "桶",
  492. Disabled: true,
  493. }, &pasturePb.ConfigOptionsList{
  494. Value: int32(pasturePb.Unit_Pot),
  495. Label: "罐",
  496. Disabled: true,
  497. }, &pasturePb.ConfigOptionsList{
  498. Value: int32(pasturePb.Unit_ML),
  499. Label: "毫升",
  500. Disabled: true,
  501. }, &pasturePb.ConfigOptionsList{
  502. Value: int32(pasturePb.Unit_L),
  503. Label: "升",
  504. Disabled: true,
  505. })
  506. return configOptions
  507. }
  508. func (s *StoreEntry) ExposeEstrusTypeEnumList() []*pasturePb.ConfigOptionsList {
  509. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  510. configOptions = append(configOptions,
  511. &pasturePb.ConfigOptionsList{
  512. Value: int32(pasturePb.ExposeEstrusType_Neck_Ring),
  513. Label: "脖环揭发",
  514. Disabled: true,
  515. }, &pasturePb.ConfigOptionsList{
  516. Value: int32(pasturePb.ExposeEstrusType_Foot_Ring),
  517. Label: "脚环/计步器揭发",
  518. Disabled: true,
  519. }, &pasturePb.ConfigOptionsList{
  520. Value: int32(pasturePb.ExposeEstrusType_Manual_Observation),
  521. Label: "人工观察",
  522. Disabled: true,
  523. })
  524. return configOptions
  525. }
  526. func (s *StoreEntry) FrozenSemenTypeEnumList() []*pasturePb.ConfigOptionsList {
  527. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  528. configOptions = append(configOptions,
  529. &pasturePb.ConfigOptionsList{
  530. Value: int32(pasturePb.FrozenSemenType_Ordinary),
  531. Label: "常规冻精",
  532. Disabled: true,
  533. }, &pasturePb.ConfigOptionsList{
  534. Value: int32(pasturePb.FrozenSemenType_Gender_Control),
  535. Label: "性控冻精",
  536. Disabled: true,
  537. })
  538. return configOptions
  539. }
  540. func (s *StoreEntry) BullNumberEnumList() []*pasturePb.BullOptionsList {
  541. frozenSemenList := make([]*model.EventFrozenSemen, 0)
  542. bullNumberList := make([]*pasturePb.BullOptionsList, 0)
  543. if err := s.DB.Where("quantity > 0").Group("bull_id").Find(&frozenSemenList).Error; err != nil {
  544. zaplog.Error("BullNumberEnumList", zap.Any("Find", err))
  545. }
  546. for _, v := range frozenSemenList {
  547. bullNumberList = append(bullNumberList, &pasturePb.BullOptionsList{
  548. Value: v.BullId,
  549. Label: v.BullId,
  550. Disabled: true,
  551. })
  552. }
  553. return bullNumberList
  554. }
  555. func (s *StoreEntry) WeekEnumList() []*pasturePb.ConfigOptionsList {
  556. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  557. configOptions = append(configOptions,
  558. &pasturePb.ConfigOptionsList{
  559. Value: int32(pasturePb.Week_Monday),
  560. Label: "周一",
  561. Disabled: true,
  562. }, &pasturePb.ConfigOptionsList{
  563. Value: int32(pasturePb.Week_Tuesday),
  564. Label: "周二",
  565. Disabled: true,
  566. }, &pasturePb.ConfigOptionsList{
  567. Value: int32(pasturePb.Week_Wednesday),
  568. Label: "周三",
  569. Disabled: true,
  570. }, &pasturePb.ConfigOptionsList{
  571. Value: int32(pasturePb.Week_Thursday),
  572. Label: "周四",
  573. Disabled: true,
  574. }, &pasturePb.ConfigOptionsList{
  575. Value: int32(pasturePb.Week_Friday),
  576. Label: "周五",
  577. Disabled: true,
  578. }, &pasturePb.ConfigOptionsList{
  579. Value: int32(pasturePb.Week_Saturday),
  580. Label: "周六",
  581. Disabled: true,
  582. }, &pasturePb.ConfigOptionsList{
  583. Value: int32(pasturePb.Week_Sunday),
  584. Label: "周日",
  585. Disabled: true,
  586. })
  587. return configOptions
  588. }
  589. func (s *StoreEntry) DrugUsageMaps() map[pasturePb.DrugUsage_Kind]string {
  590. res := make(map[pasturePb.DrugUsage_Kind]string)
  591. for _, v := range s.DrugUsageEnumList() {
  592. res[pasturePb.DrugUsage_Kind(v.Value)] = v.Label
  593. }
  594. return res
  595. }
  596. func (s *StoreEntry) ExposeEstrusTypeMap() map[pasturePb.ExposeEstrusType_Kind]string {
  597. res := make(map[pasturePb.ExposeEstrusType_Kind]string)
  598. for _, v := range s.ExposeEstrusTypeEnumList() {
  599. res[pasturePb.ExposeEstrusType_Kind(v.Value)] = v.Label
  600. }
  601. return res
  602. }
  603. func (s *StoreEntry) FrozenSemenTypeMap() map[pasturePb.FrozenSemenType_Kind]string {
  604. res := make(map[pasturePb.FrozenSemenType_Kind]string)
  605. for _, v := range s.FrozenSemenTypeEnumList() {
  606. res[pasturePb.FrozenSemenType_Kind(v.Value)] = v.Label
  607. }
  608. return res
  609. }
  610. func (s *StoreEntry) UnitMap() map[pasturePb.Unit_Kind]string {
  611. res := make(map[pasturePb.Unit_Kind]string)
  612. for _, v := range s.UnitEnumList() {
  613. res[pasturePb.Unit_Kind(v.Value)] = v.Label
  614. }
  615. return res
  616. }
  617. func (s *StoreEntry) WeekMap() map[pasturePb.Week_Kind]string {
  618. res := make(map[pasturePb.Week_Kind]string)
  619. for _, v := range s.WeekEnumList() {
  620. res[pasturePb.Week_Kind(v.Value)] = v.Label
  621. }
  622. return res
  623. }
  624. func (s *StoreEntry) CowTypeMap() map[pasturePb.CowType_Kind]string {
  625. res := make(map[pasturePb.CowType_Kind]string)
  626. for _, v := range s.CowTypeEnumList() {
  627. res[pasturePb.CowType_Kind(v.Value)] = v.Label
  628. }
  629. return res
  630. }
  631. func (s *StoreEntry) CowStatusMap() map[pasturePb.CowStatus_Kind]string {
  632. res := make(map[pasturePb.CowStatus_Kind]string)
  633. for _, v := range s.CowStatusEnumList() {
  634. res[pasturePb.CowStatus_Kind(v.Value)] = v.Label
  635. }
  636. return res
  637. }
  638. func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  639. return &pasturePb.ConfigOptionsListResponse{
  640. Code: http.StatusOK,
  641. Message: "ok",
  642. Data: s.BarnTypeEnumList(),
  643. }, nil
  644. }
  645. func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int) (*pasturePb.ConfigOptionsListResponse, error) {
  646. penList := make([]*model.Pen, 0)
  647. pref := s.DB.Table(new(model.Pen).TableName()).
  648. Where("is_delete = ?", pasturePb.IsShow_Ok)
  649. if penType != -1 {
  650. pref.Where("pen_type = ?", penType)
  651. }
  652. if err := pref.Find(&penList).Error; err != nil {
  653. return nil, err
  654. }
  655. return &pasturePb.ConfigOptionsListResponse{
  656. Code: http.StatusOK,
  657. Message: "ok",
  658. Data: model.PenSlice(penList).ToPB2(s.BarnTypeEnumList()),
  659. }, nil
  660. }
  661. func (s *StoreEntry) DiseaseTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  662. diseaseTypeList := make([]*model.ConfigDiseaseType, 0)
  663. pref := s.DB.Table(new(model.ConfigDiseaseType).TableName()).
  664. Where("is_show =? ", pasturePb.IsShow_Ok)
  665. if err := pref.Find(&diseaseTypeList).Error; err != nil {
  666. return nil, xxerr.WithStack(err)
  667. }
  668. return &pasturePb.ConfigOptionsListResponse{
  669. Code: http.StatusOK,
  670. Message: "ok",
  671. Data: model.ConfigDiseaseTypeSlice(diseaseTypeList).ToPB2(),
  672. }, nil
  673. }
  674. func (s *StoreEntry) DiseaseOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  675. diseaseList := make([]*model.Disease, 0)
  676. pref := s.DB.Table(new(model.Disease).TableName()).
  677. Where("is_show =? ", pasturePb.IsShow_Ok)
  678. if err := pref.Find(&diseaseList).Error; err != nil {
  679. return nil, xxerr.WithStack(err)
  680. }
  681. return &pasturePb.ConfigOptionsListResponse{
  682. Code: http.StatusOK,
  683. Message: "ok",
  684. Data: model.DiseaseSlice(diseaseList).ToPB2(),
  685. }, nil
  686. }
  687. func (s *StoreEntry) BreedStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  688. return &pasturePb.ConfigOptionsListResponse{
  689. Code: http.StatusOK,
  690. Message: "ok",
  691. Data: s.BreedStatusEnumList(),
  692. }, nil
  693. }
  694. func (s *StoreEntry) CowKindOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  695. return &pasturePb.ConfigOptionsListResponse{
  696. Code: http.StatusOK,
  697. Message: "ok",
  698. Data: s.CowKindEnumList(),
  699. }, nil
  700. }
  701. func (s *StoreEntry) CowSourceOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  702. return &pasturePb.ConfigOptionsListResponse{
  703. Code: http.StatusOK,
  704. Message: "ok",
  705. Data: s.CowSourceEnumList(),
  706. }, nil
  707. }
  708. func (s *StoreEntry) CowStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  709. return &pasturePb.ConfigOptionsListResponse{
  710. Code: http.StatusOK,
  711. Message: "ok",
  712. Data: s.CowStatusEnumList(),
  713. }, nil
  714. }
  715. func (s *StoreEntry) CowTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  716. return &pasturePb.ConfigOptionsListResponse{
  717. Code: http.StatusOK,
  718. Message: "ok",
  719. Data: s.CowTypeEnumList(),
  720. }, nil
  721. }
  722. func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  723. return &pasturePb.ConfigOptionsListResponse{
  724. Code: http.StatusOK,
  725. Message: "ok",
  726. Data: s.TransferPenEnumList(),
  727. }, nil
  728. }
  729. func (s *StoreEntry) SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error) {
  730. systemUserList := make([]*model.SystemUser, 0)
  731. pref := s.DB.Table(new(model.SystemUser).TableName()).
  732. Where("is_delete = ?", pasturePb.IsShow_Ok).
  733. Where("is_show =? ", pasturePb.IsShow_Ok)
  734. if depId != -1 && depId > 0 {
  735. pref = pref.Where("dept_id = ?", depId)
  736. }
  737. if err := pref.Find(&systemUserList).Error; err != nil {
  738. return nil, xxerr.WithStack(err)
  739. }
  740. return &pasturePb.ConfigOptionsListResponse{
  741. Code: http.StatusOK,
  742. Message: "ok",
  743. Data: model.SystemUserSlice(systemUserList).ToPB2(),
  744. }, nil
  745. }
  746. func (s *StoreEntry) BullOptions(ctx context.Context) (*pasturePb.BullOptionsListResponse, error) {
  747. return &pasturePb.BullOptionsListResponse{
  748. Code: http.StatusOK,
  749. Message: "ok",
  750. Data: s.BullNumberEnumList(),
  751. }, nil
  752. }
  753. func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName string) (*pasturePb.ConfigOptionsListResponse, error) {
  754. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  755. switch optionsName {
  756. case "childNumber":
  757. configOptions = s.ChildNumberEnumList()
  758. case "calvingLevel":
  759. configOptions = s.CalvingLevelEnumList()
  760. case "dystociaReason":
  761. configOptions = s.DystociaReasonEnumList()
  762. case "drugCategory":
  763. configOptions = s.DrugCategoryEnumList()
  764. case "drugUsage":
  765. configOptions = s.DrugUsageEnumList()
  766. case "unit":
  767. configOptions = s.UnitEnumList()
  768. case "pregnantCheckResult":
  769. configOptions = s.PregnantCheckResultEnumList()
  770. case "pregnantCheckMethod":
  771. configOptions = s.PregnantCheckMethodEnumList()
  772. case "exposeEstrusType":
  773. configOptions = s.ExposeEstrusTypeEnumList()
  774. case "frozenSemenType":
  775. configOptions = s.FrozenSemenTypeEnumList()
  776. case "week":
  777. configOptions = s.WeekEnumList()
  778. case "sameTimeCowType":
  779. configOptions = s.SemeTimeCowTypeEnumList()
  780. }
  781. return &pasturePb.ConfigOptionsListResponse{
  782. Code: http.StatusOK,
  783. Message: "ok",
  784. Data: configOptions,
  785. }, nil
  786. }