config_data.go 28 KB

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