config_data.go 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  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. pasturePb.DrugCategory_Immunity: "免疫类",
  27. }
  28. var UnitMap = map[pasturePb.Unit_Kind]string{
  29. pasturePb.Unit_Pieces: "个",
  30. pasturePb.Unit_Package: "包/袋",
  31. pasturePb.Unit_Bottle: "瓶",
  32. pasturePb.Unit_Box: "盒",
  33. pasturePb.Unit_Boxful: "箱",
  34. pasturePb.Unit_Branch: "支",
  35. pasturePb.Unit_Barrel: "桶",
  36. pasturePb.Unit_Pot: "罐",
  37. pasturePb.Unit_ML: "毫升",
  38. pasturePb.Unit_L: "升",
  39. }
  40. var DrugUsageMap = map[pasturePb.DrugUsage_Kind]string{
  41. pasturePb.DrugUsage_Oral_Medications: "口服",
  42. pasturePb.DrugUsage_Injectable_Medications: "肌注",
  43. pasturePb.DrugUsage_Topical_Medications: "外用",
  44. pasturePb.DrugUsage_Drink_Medications: "饮水",
  45. }
  46. func (s *StoreEntry) BarnTypeEnumList() []*pasturePb.ConfigOptionsList {
  47. barnTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  48. barnTypeList = append(barnTypeList, &pasturePb.ConfigOptionsList{
  49. Value: int32(pasturePb.PenType_Lactating_Calves),
  50. Label: "哺乳犊牛舍",
  51. Disabled: true,
  52. }, &pasturePb.ConfigOptionsList{
  53. Value: int32(pasturePb.PenType_Weaned_Calves),
  54. Label: "断奶犊牛舍",
  55. Disabled: true,
  56. }, &pasturePb.ConfigOptionsList{
  57. Value: int32(pasturePb.PenType_Youth),
  58. Label: "育成牛舍",
  59. Disabled: true,
  60. }, &pasturePb.ConfigOptionsList{
  61. Value: int32(pasturePb.PenType_Nurturing),
  62. Label: "育成牛舍",
  63. Disabled: true,
  64. }, &pasturePb.ConfigOptionsList{
  65. Value: int32(pasturePb.PenType_Lactation),
  66. Label: "泌乳牛舍",
  67. Disabled: true,
  68. }, &pasturePb.ConfigOptionsList{
  69. Value: int32(pasturePb.PenType_Peripartum),
  70. Label: "围产牛舍",
  71. Disabled: true,
  72. }, &pasturePb.ConfigOptionsList{
  73. Value: int32(pasturePb.PenType_Dry_Milking),
  74. Label: "干奶牛舍",
  75. Disabled: true,
  76. }, &pasturePb.ConfigOptionsList{
  77. Value: int32(pasturePb.PenType_Sick_Cow),
  78. Label: "病牛舍",
  79. Disabled: true,
  80. }, &pasturePb.ConfigOptionsList{
  81. Value: int32(pasturePb.PenType_Eliminate),
  82. Label: "淘汰牛舍",
  83. Disabled: true,
  84. })
  85. return barnTypeList
  86. }
  87. func (s *StoreEntry) BreedStatusEnumList() []*pasturePb.ConfigOptionsList {
  88. breedStatusList := make([]*pasturePb.ConfigOptionsList, 0)
  89. breedStatusList = append(breedStatusList, &pasturePb.ConfigOptionsList{
  90. Value: int32(pasturePb.BreedStatus_Unmarried),
  91. Label: "未配",
  92. Disabled: true,
  93. }, &pasturePb.ConfigOptionsList{
  94. Value: int32(pasturePb.BreedStatus_InCheck_Unpregnant),
  95. Label: "初检无胎",
  96. Disabled: true,
  97. }, &pasturePb.ConfigOptionsList{
  98. Value: int32(pasturePb.BreedStatus_InCheck_Pregnant),
  99. Label: "初检有胎",
  100. Disabled: true,
  101. }, &pasturePb.ConfigOptionsList{
  102. Value: int32(pasturePb.BreedStatus_Recheck_Unpregnant),
  103. Label: "复检无胎",
  104. Disabled: true,
  105. }, &pasturePb.ConfigOptionsList{
  106. Value: int32(pasturePb.BreedStatus_Recheck_Pregnant),
  107. Label: "复检有胎",
  108. Disabled: true,
  109. }, &pasturePb.ConfigOptionsList{
  110. Value: int32(pasturePb.BreedStatus_Pause_Pregnant),
  111. Label: "停配",
  112. Disabled: true,
  113. }, &pasturePb.ConfigOptionsList{
  114. Value: int32(pasturePb.BreedStatus_No_Pregnant),
  115. Label: "禁配",
  116. Disabled: true,
  117. })
  118. return breedStatusList
  119. }
  120. func (s *StoreEntry) CowKindEnumList() []*pasturePb.ConfigOptionsList {
  121. cowKindList := make([]*pasturePb.ConfigOptionsList, 0)
  122. cowKindList = append(cowKindList, &pasturePb.ConfigOptionsList{
  123. Value: int32(pasturePb.CowKind_HST),
  124. Label: "荷斯坦",
  125. Disabled: true,
  126. }, &pasturePb.ConfigOptionsList{
  127. Value: int32(pasturePb.CowKind_JSN),
  128. Label: "娟姗牛",
  129. Disabled: true,
  130. }, &pasturePb.ConfigOptionsList{
  131. Value: int32(pasturePb.CowKind_SHN),
  132. Label: "三河牛",
  133. Disabled: true,
  134. }, &pasturePb.ConfigOptionsList{
  135. Value: int32(pasturePb.CowKind_XJHN),
  136. Label: "新疆褐牛",
  137. Disabled: true,
  138. }, &pasturePb.ConfigOptionsList{
  139. Value: int32(pasturePb.CowKind_MN),
  140. Label: "牦牛",
  141. Disabled: true,
  142. }, &pasturePb.ConfigOptionsList{
  143. Value: int32(pasturePb.CowKind_XMTEN),
  144. Label: "西门塔尔牛",
  145. Disabled: true,
  146. })
  147. return cowKindList
  148. }
  149. func (s *StoreEntry) CowSourceEnumList() []*pasturePb.ConfigOptionsList {
  150. cowSourceList := make([]*pasturePb.ConfigOptionsList, 0)
  151. cowSourceList = append(cowSourceList, &pasturePb.ConfigOptionsList{
  152. Value: int32(pasturePb.CowSource_Calving),
  153. Label: "产犊",
  154. Disabled: true,
  155. }, &pasturePb.ConfigOptionsList{
  156. Value: int32(pasturePb.CowSource_Transfer_In),
  157. Label: "调入",
  158. Disabled: true,
  159. }, &pasturePb.ConfigOptionsList{
  160. Value: int32(pasturePb.CowSource_Buy),
  161. Label: "购买",
  162. Disabled: true,
  163. })
  164. return cowSourceList
  165. }
  166. func (s *StoreEntry) CowStatusEnumList() []*pasturePb.ConfigOptionsList {
  167. cowStatusList := make([]*pasturePb.ConfigOptionsList, 0)
  168. cowStatusList = append(cowStatusList, &pasturePb.ConfigOptionsList{
  169. Value: int32(pasturePb.CowStatus_Calving),
  170. Label: "产犊",
  171. Disabled: true,
  172. }, &pasturePb.ConfigOptionsList{
  173. Value: int32(pasturePb.CowStatus_Empty),
  174. Label: "空怀",
  175. Disabled: true,
  176. }, &pasturePb.ConfigOptionsList{
  177. Value: int32(pasturePb.CowStatus_Breeding),
  178. Label: "配种",
  179. Disabled: true,
  180. }, &pasturePb.ConfigOptionsList{
  181. Value: int32(pasturePb.CowStatus_Pregnant),
  182. Label: "怀孕",
  183. Disabled: true,
  184. }, &pasturePb.ConfigOptionsList{
  185. Value: int32(pasturePb.CowStatus_Dry_Milk),
  186. Label: "干奶",
  187. Disabled: true,
  188. }, &pasturePb.ConfigOptionsList{
  189. Value: int32(pasturePb.CowStatus_Peripartum),
  190. Label: "围产",
  191. Disabled: true,
  192. }, &pasturePb.ConfigOptionsList{
  193. Value: int32(pasturePb.CowStatus_No_Pregnant),
  194. Label: "禁配",
  195. Disabled: true,
  196. })
  197. return cowStatusList
  198. }
  199. func (s *StoreEntry) CowTypeEnumList() []*pasturePb.ConfigOptionsList {
  200. cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  201. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  202. Value: int32(pasturePb.CowType_Lactating_Calf),
  203. Label: "哺乳犊牛",
  204. Disabled: true,
  205. }, &pasturePb.ConfigOptionsList{
  206. Value: int32(pasturePb.CowType_Weaned_Calf),
  207. Label: "断奶犊牛",
  208. Disabled: true,
  209. }, &pasturePb.ConfigOptionsList{
  210. Value: int32(pasturePb.CowType_Youth_Calf),
  211. Label: "青年牛",
  212. Disabled: true,
  213. }, &pasturePb.ConfigOptionsList{
  214. Value: int32(pasturePb.CowType_Fattening_Calf),
  215. Label: "育肥牛",
  216. Disabled: true,
  217. }, &pasturePb.ConfigOptionsList{
  218. Value: int32(pasturePb.CowType_Reserve_Calf),
  219. Label: "后备牛",
  220. Disabled: true,
  221. }, &pasturePb.ConfigOptionsList{
  222. Value: int32(pasturePb.CowType_Breeding_Calf),
  223. Label: "种母牛",
  224. Disabled: true,
  225. }, &pasturePb.ConfigOptionsList{
  226. Value: int32(pasturePb.CowType_Breeding_Bull),
  227. Label: "种公牛",
  228. Disabled: true,
  229. })
  230. return cowTypeList
  231. }
  232. func (s *StoreEntry) SemeTimeCowTypeEnumList() []*pasturePb.ConfigOptionsList {
  233. cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  234. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  235. Value: int32(pasturePb.CowType_Reserve_Calf),
  236. Label: "后备牛",
  237. Disabled: true,
  238. }, &pasturePb.ConfigOptionsList{
  239. Value: int32(pasturePb.CowType_Breeding_Calf),
  240. Label: "种母牛",
  241. Disabled: true,
  242. })
  243. return cowTypeList
  244. }
  245. func (s *StoreEntry) ImmunizationCowTypeEnumList() []*pasturePb.ConfigOptionsList {
  246. cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  247. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  248. Value: int32(pasturePb.ImmunizationCowType_Reserve_Cattle),
  249. Label: "后备牛",
  250. Disabled: true,
  251. }, &pasturePb.ConfigOptionsList{
  252. Value: int32(pasturePb.ImmunizationCowType_Adult_Cow),
  253. Label: "种母牛",
  254. Disabled: true,
  255. }, &pasturePb.ConfigOptionsList{
  256. Value: int32(pasturePb.ImmunizationCowType_Adult_bulls),
  257. Label: "种公牛",
  258. Disabled: true,
  259. }, &pasturePb.ConfigOptionsList{
  260. Value: int32(pasturePb.ImmunizationCowType_Calf),
  261. Label: "犊牛",
  262. Disabled: true,
  263. })
  264. return cowTypeList
  265. }
  266. func (s *StoreEntry) ImmunizationConditionsEnumList() []*pasturePb.ConfigOptionsList {
  267. cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  268. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  269. Value: int32(pasturePb.ImmunizationConditions_Days_Age),
  270. Label: "日龄",
  271. Disabled: true,
  272. }, &pasturePb.ConfigOptionsList{
  273. Value: int32(pasturePb.ImmunizationConditions_Days_After_Delivery),
  274. Label: "产后天数",
  275. Disabled: true,
  276. }, &pasturePb.ConfigOptionsList{
  277. Value: int32(pasturePb.ImmunizationConditions_Days_Of_Pregnancy),
  278. Label: "怀孕天数",
  279. Disabled: true,
  280. }, &pasturePb.ConfigOptionsList{
  281. Value: int32(pasturePb.ImmunizationConditions_Month),
  282. Label: "每年月份",
  283. Disabled: true,
  284. })
  285. return cowTypeList
  286. }
  287. func (s *StoreEntry) TransferPenEnumList() []*pasturePb.ConfigOptionsList {
  288. transferPenList := make([]*pasturePb.ConfigOptionsList, 0)
  289. transferPenList = append(transferPenList, &pasturePb.ConfigOptionsList{
  290. Value: int32(pasturePb.TransferPenReason_Normal),
  291. Label: "正常转群",
  292. Disabled: true,
  293. }, &pasturePb.ConfigOptionsList{
  294. Value: int32(pasturePb.TransferPenReason_Feed),
  295. Label: "饲喂转群",
  296. Disabled: true,
  297. }, &pasturePb.ConfigOptionsList{
  298. Value: int32(pasturePb.TransferPenReason_Dry_Milk),
  299. Label: "干奶转群",
  300. Disabled: true,
  301. }, &pasturePb.ConfigOptionsList{
  302. Value: int32(pasturePb.TransferPenReason_Pregnant),
  303. Label: "怀孕转群",
  304. Disabled: true,
  305. }, &pasturePb.ConfigOptionsList{
  306. Value: int32(pasturePb.TransferPenReason_Overantibody),
  307. Label: "过抗转群",
  308. Disabled: true,
  309. })
  310. return transferPenList
  311. }
  312. func (s *StoreEntry) ChildNumberEnumList() []*pasturePb.ConfigOptionsList {
  313. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  314. configOptions = append(configOptions,
  315. &pasturePb.ConfigOptionsList{
  316. Value: int32(pasturePb.ChildNumber_One),
  317. Label: "单胎",
  318. Disabled: true,
  319. }, &pasturePb.ConfigOptionsList{
  320. Value: int32(pasturePb.ChildNumber_Two),
  321. Label: "双胎",
  322. Disabled: true,
  323. }, &pasturePb.ConfigOptionsList{
  324. Value: int32(pasturePb.ChildNumber_Three),
  325. Label: "三胎",
  326. Disabled: true,
  327. }, &pasturePb.ConfigOptionsList{
  328. Value: int32(pasturePb.ChildNumber_Four),
  329. Label: "四胎",
  330. Disabled: true,
  331. })
  332. return configOptions
  333. }
  334. func (s *StoreEntry) CalvingLevelEnumList() []*pasturePb.ConfigOptionsList {
  335. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  336. configOptions = append(configOptions,
  337. &pasturePb.ConfigOptionsList{
  338. Value: int32(pasturePb.CalvingLevel_Natural_Childbirth),
  339. Label: "自然分娩",
  340. Disabled: true,
  341. }, &pasturePb.ConfigOptionsList{
  342. Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery1),
  343. Label: "人工助产(1-2人)",
  344. Disabled: true,
  345. }, &pasturePb.ConfigOptionsList{
  346. Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery2),
  347. Label: "人工助产(3人以上)",
  348. Disabled: true,
  349. }, &pasturePb.ConfigOptionsList{
  350. Value: int32(pasturePb.CalvingLevel_Caesarean_Section),
  351. Label: "剖腹产",
  352. Disabled: true,
  353. })
  354. return configOptions
  355. }
  356. func (s *StoreEntry) DystociaReasonEnumList() []*pasturePb.ConfigOptionsList {
  357. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  358. configOptions = append(configOptions,
  359. &pasturePb.ConfigOptionsList{
  360. Value: int32(pasturePb.DystociaReason_Malposition),
  361. Label: "胎位不正",
  362. Disabled: true,
  363. }, &pasturePb.ConfigOptionsList{
  364. Value: int32(pasturePb.DystociaReason_Fetal_Overgrowth),
  365. Label: "胎儿过大",
  366. Disabled: true,
  367. }, &pasturePb.ConfigOptionsList{
  368. Value: int32(pasturePb.DystociaReason_Uterine_Atony),
  369. Label: "子宫收缩无力",
  370. Disabled: true,
  371. }, &pasturePb.ConfigOptionsList{
  372. Value: int32(pasturePb.DystociaReason_Pelvic_Stenosis),
  373. Label: "盆骨狭小",
  374. Disabled: true,
  375. }, &pasturePb.ConfigOptionsList{
  376. Value: int32(pasturePb.DystociaReason_Sub_Health),
  377. Label: "母牛亚健康状态",
  378. Disabled: true,
  379. })
  380. return configOptions
  381. }
  382. func (s *StoreEntry) PregnantCheckResultEnumList() []*pasturePb.ConfigOptionsList {
  383. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  384. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  385. Value: int32(pasturePb.PregnantCheckResult_InCheck_UnPregnant),
  386. Label: "初检未孕",
  387. Disabled: true,
  388. }, &pasturePb.ConfigOptionsList{
  389. Value: int32(pasturePb.PregnantCheckResult_InCheck_Pregnant),
  390. Label: "初检已孕",
  391. Disabled: true,
  392. }, &pasturePb.ConfigOptionsList{
  393. Value: int32(pasturePb.PregnantCheckResult_Recheck_UnPregnant),
  394. Label: "复检未孕",
  395. Disabled: true,
  396. }, &pasturePb.ConfigOptionsList{
  397. Value: int32(pasturePb.PregnantCheckResult_Recheck_Pregnant),
  398. Label: "初检已孕",
  399. Disabled: true,
  400. })
  401. return configOptions
  402. }
  403. func (s *StoreEntry) PregnantCheckMethodEnumList() []*pasturePb.ConfigOptionsList {
  404. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  405. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  406. Value: int32(pasturePb.PregnantCheckMethod_B_Ultrasound),
  407. Label: "B超",
  408. Disabled: true,
  409. }, &pasturePb.ConfigOptionsList{
  410. Value: int32(pasturePb.PregnantCheckMethod_Blood_Testing),
  411. Label: "血检",
  412. Disabled: true,
  413. }, &pasturePb.ConfigOptionsList{
  414. Value: int32(pasturePb.PregnantCheckMethod_Manual_Inspection),
  415. Label: "人工检查",
  416. Disabled: true,
  417. })
  418. return configOptions
  419. }
  420. func (s *StoreEntry) DrugCategoryEnumList() []*pasturePb.ConfigOptionsList {
  421. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  422. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  423. Value: int32(pasturePb.DrugCategory_Antibiotics),
  424. Label: "抗生素类",
  425. Disabled: true,
  426. }, &pasturePb.ConfigOptionsList{
  427. Value: int32(pasturePb.DrugCategory_Antivirals),
  428. Label: "抗病毒类",
  429. Disabled: true,
  430. }, &pasturePb.ConfigOptionsList{
  431. Value: int32(pasturePb.DrugCategory_Antifungals),
  432. Label: "抗真菌类",
  433. Disabled: true,
  434. }, &pasturePb.ConfigOptionsList{
  435. Value: int32(pasturePb.DrugCategory_Antiparasitics),
  436. Label: "驱虫类",
  437. Disabled: true,
  438. }, &pasturePb.ConfigOptionsList{
  439. Value: int32(pasturePb.DrugCategory_Analgesics),
  440. Label: "镇痛类",
  441. Disabled: true,
  442. }, &pasturePb.ConfigOptionsList{
  443. Value: int32(pasturePb.DrugCategory_Antipyretic),
  444. Label: "退烧类",
  445. Disabled: true,
  446. }, &pasturePb.ConfigOptionsList{
  447. Value: int32(pasturePb.DrugCategory_Vitamin),
  448. Label: "维生素类",
  449. Disabled: true,
  450. }, &pasturePb.ConfigOptionsList{
  451. Value: int32(pasturePb.DrugCategory_Brine),
  452. Label: "盐水",
  453. Disabled: true,
  454. }, &pasturePb.ConfigOptionsList{
  455. Value: int32(pasturePb.DrugCategory_Glucose),
  456. Label: "葡萄糖",
  457. Disabled: true,
  458. }, &pasturePb.ConfigOptionsList{
  459. Value: int32(pasturePb.DrugCategory_Hormone),
  460. Label: "激素类",
  461. Disabled: true,
  462. }, &pasturePb.ConfigOptionsList{
  463. Value: int32(pasturePb.DrugCategory_Anti_Stress),
  464. Label: "抗应激类",
  465. Disabled: true,
  466. }, &pasturePb.ConfigOptionsList{
  467. Value: int32(pasturePb.DrugCategory_Disinfect),
  468. Label: "消毒类",
  469. Disabled: true,
  470. }, &pasturePb.ConfigOptionsList{
  471. Value: int32(pasturePb.DrugCategory_Chinese_Herbal),
  472. Label: "中药合剂",
  473. Disabled: true,
  474. }, &pasturePb.ConfigOptionsList{
  475. Value: int32(pasturePb.DrugCategory_Tocolytic),
  476. Label: "保胎类",
  477. Disabled: true,
  478. }, &pasturePb.ConfigOptionsList{
  479. Value: int32(pasturePb.DrugCategory_Immunity),
  480. Label: "免疫类",
  481. Disabled: true,
  482. })
  483. return configOptions
  484. }
  485. func (s *StoreEntry) DrugUsageEnumList() []*pasturePb.ConfigOptionsList {
  486. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  487. configOptions = append(configOptions,
  488. &pasturePb.ConfigOptionsList{
  489. Value: int32(pasturePb.DrugUsage_Oral_Medications),
  490. Label: "口服",
  491. Disabled: true,
  492. }, &pasturePb.ConfigOptionsList{
  493. Value: int32(pasturePb.DrugUsage_Injectable_Medications),
  494. Label: "肌注",
  495. Disabled: true,
  496. }, &pasturePb.ConfigOptionsList{
  497. Value: int32(pasturePb.DrugUsage_Topical_Medications),
  498. Label: "外用",
  499. Disabled: true,
  500. }, &pasturePb.ConfigOptionsList{
  501. Value: int32(pasturePb.DrugUsage_Drink_Medications),
  502. Label: "饮水",
  503. Disabled: true,
  504. })
  505. return configOptions
  506. }
  507. func (s *StoreEntry) UnitEnumList() []*pasturePb.ConfigOptionsList {
  508. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  509. configOptions = append(configOptions,
  510. &pasturePb.ConfigOptionsList{
  511. Value: int32(pasturePb.Unit_Pieces),
  512. Label: "个",
  513. Disabled: true,
  514. }, &pasturePb.ConfigOptionsList{
  515. Value: int32(pasturePb.Unit_Package),
  516. Label: "包/袋",
  517. Disabled: true,
  518. }, &pasturePb.ConfigOptionsList{
  519. Value: int32(pasturePb.Unit_Bottle),
  520. Label: "瓶",
  521. Disabled: true,
  522. }, &pasturePb.ConfigOptionsList{
  523. Value: int32(pasturePb.Unit_Box),
  524. Label: "盒",
  525. Disabled: true,
  526. }, &pasturePb.ConfigOptionsList{
  527. Value: int32(pasturePb.Unit_Boxful),
  528. Label: "箱",
  529. Disabled: true,
  530. }, &pasturePb.ConfigOptionsList{
  531. Value: int32(pasturePb.Unit_Branch),
  532. Label: "支",
  533. Disabled: true,
  534. }, &pasturePb.ConfigOptionsList{
  535. Value: int32(pasturePb.Unit_Barrel),
  536. Label: "桶",
  537. Disabled: true,
  538. }, &pasturePb.ConfigOptionsList{
  539. Value: int32(pasturePb.Unit_Pot),
  540. Label: "罐",
  541. Disabled: true,
  542. }, &pasturePb.ConfigOptionsList{
  543. Value: int32(pasturePb.Unit_ML),
  544. Label: "毫升",
  545. Disabled: true,
  546. }, &pasturePb.ConfigOptionsList{
  547. Value: int32(pasturePb.Unit_L),
  548. Label: "升",
  549. Disabled: true,
  550. })
  551. return configOptions
  552. }
  553. func (s *StoreEntry) ExposeEstrusTypeEnumList() []*pasturePb.ConfigOptionsList {
  554. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  555. configOptions = append(configOptions,
  556. &pasturePb.ConfigOptionsList{
  557. Value: int32(pasturePb.ExposeEstrusType_Neck_Ring),
  558. Label: "脖环揭发",
  559. Disabled: true,
  560. }, &pasturePb.ConfigOptionsList{
  561. Value: int32(pasturePb.ExposeEstrusType_Foot_Ring),
  562. Label: "脚环/计步器揭发",
  563. Disabled: true,
  564. }, &pasturePb.ConfigOptionsList{
  565. Value: int32(pasturePb.ExposeEstrusType_Manual_Observation),
  566. Label: "人工观察",
  567. Disabled: true,
  568. })
  569. return configOptions
  570. }
  571. func (s *StoreEntry) FrozenSemenTypeEnumList() []*pasturePb.ConfigOptionsList {
  572. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  573. configOptions = append(configOptions,
  574. &pasturePb.ConfigOptionsList{
  575. Value: int32(pasturePb.FrozenSemenType_Ordinary),
  576. Label: "常规冻精",
  577. Disabled: true,
  578. }, &pasturePb.ConfigOptionsList{
  579. Value: int32(pasturePb.FrozenSemenType_Gender_Control),
  580. Label: "性控冻精",
  581. Disabled: true,
  582. })
  583. return configOptions
  584. }
  585. func (s *StoreEntry) BullNumberEnumList() []*pasturePb.BullOptionsList {
  586. frozenSemenList := make([]*model.EventFrozenSemen, 0)
  587. bullNumberList := make([]*pasturePb.BullOptionsList, 0)
  588. if err := s.DB.Where("quantity > 0").Group("bull_id").Find(&frozenSemenList).Error; err != nil {
  589. zaplog.Error("BullNumberEnumList", zap.Any("Find", err))
  590. }
  591. for _, v := range frozenSemenList {
  592. bullNumberList = append(bullNumberList, &pasturePb.BullOptionsList{
  593. Value: v.BullId,
  594. Label: v.BullId,
  595. Disabled: true,
  596. })
  597. }
  598. return bullNumberList
  599. }
  600. func (s *StoreEntry) WeekEnumList() []*pasturePb.ConfigOptionsList {
  601. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  602. configOptions = append(configOptions,
  603. &pasturePb.ConfigOptionsList{
  604. Value: int32(pasturePb.Week_Monday),
  605. Label: "周一",
  606. Disabled: true,
  607. }, &pasturePb.ConfigOptionsList{
  608. Value: int32(pasturePb.Week_Tuesday),
  609. Label: "周二",
  610. Disabled: true,
  611. }, &pasturePb.ConfigOptionsList{
  612. Value: int32(pasturePb.Week_Wednesday),
  613. Label: "周三",
  614. Disabled: true,
  615. }, &pasturePb.ConfigOptionsList{
  616. Value: int32(pasturePb.Week_Thursday),
  617. Label: "周四",
  618. Disabled: true,
  619. }, &pasturePb.ConfigOptionsList{
  620. Value: int32(pasturePb.Week_Friday),
  621. Label: "周五",
  622. Disabled: true,
  623. }, &pasturePb.ConfigOptionsList{
  624. Value: int32(pasturePb.Week_Saturday),
  625. Label: "周六",
  626. Disabled: true,
  627. }, &pasturePb.ConfigOptionsList{
  628. Value: int32(pasturePb.Week_Sunday),
  629. Label: "周日",
  630. Disabled: true,
  631. })
  632. return configOptions
  633. }
  634. func (s *StoreEntry) DrugUsageMaps() map[pasturePb.DrugUsage_Kind]string {
  635. res := make(map[pasturePb.DrugUsage_Kind]string)
  636. for _, v := range s.DrugUsageEnumList() {
  637. res[pasturePb.DrugUsage_Kind(v.Value)] = v.Label
  638. }
  639. return res
  640. }
  641. func (s *StoreEntry) ExposeEstrusTypeMap() map[pasturePb.ExposeEstrusType_Kind]string {
  642. res := make(map[pasturePb.ExposeEstrusType_Kind]string)
  643. for _, v := range s.ExposeEstrusTypeEnumList() {
  644. res[pasturePb.ExposeEstrusType_Kind(v.Value)] = v.Label
  645. }
  646. return res
  647. }
  648. func (s *StoreEntry) FrozenSemenTypeMap() map[pasturePb.FrozenSemenType_Kind]string {
  649. res := make(map[pasturePb.FrozenSemenType_Kind]string)
  650. for _, v := range s.FrozenSemenTypeEnumList() {
  651. res[pasturePb.FrozenSemenType_Kind(v.Value)] = v.Label
  652. }
  653. return res
  654. }
  655. func (s *StoreEntry) UnitMap() map[pasturePb.Unit_Kind]string {
  656. res := make(map[pasturePb.Unit_Kind]string)
  657. for _, v := range s.UnitEnumList() {
  658. res[pasturePb.Unit_Kind(v.Value)] = v.Label
  659. }
  660. return res
  661. }
  662. func (s *StoreEntry) WeekMap() map[pasturePb.Week_Kind]string {
  663. res := make(map[pasturePb.Week_Kind]string)
  664. for _, v := range s.WeekEnumList() {
  665. res[pasturePb.Week_Kind(v.Value)] = v.Label
  666. }
  667. return res
  668. }
  669. func (s *StoreEntry) CowTypeMap() map[pasturePb.CowType_Kind]string {
  670. res := make(map[pasturePb.CowType_Kind]string)
  671. for _, v := range s.CowTypeEnumList() {
  672. res[pasturePb.CowType_Kind(v.Value)] = v.Label
  673. }
  674. return res
  675. }
  676. func (s *StoreEntry) CowStatusMap() map[pasturePb.CowStatus_Kind]string {
  677. res := make(map[pasturePb.CowStatus_Kind]string)
  678. for _, v := range s.CowStatusEnumList() {
  679. res[pasturePb.CowStatus_Kind(v.Value)] = v.Label
  680. }
  681. return res
  682. }
  683. func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  684. return &pasturePb.ConfigOptionsListResponse{
  685. Code: http.StatusOK,
  686. Message: "ok",
  687. Data: s.BarnTypeEnumList(),
  688. }, nil
  689. }
  690. func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int) (*pasturePb.ConfigOptionsListResponse, error) {
  691. penList := make([]*model.Pen, 0)
  692. pref := s.DB.Table(new(model.Pen).TableName()).
  693. Where("is_delete = ?", pasturePb.IsShow_Ok)
  694. if penType != -1 {
  695. pref.Where("pen_type = ?", penType)
  696. }
  697. if err := pref.Find(&penList).Error; err != nil {
  698. return nil, err
  699. }
  700. return &pasturePb.ConfigOptionsListResponse{
  701. Code: http.StatusOK,
  702. Message: "ok",
  703. Data: model.PenSlice(penList).ToPB2(s.BarnTypeEnumList()),
  704. }, nil
  705. }
  706. func (s *StoreEntry) DiseaseTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  707. diseaseTypeList := make([]*model.ConfigDiseaseType, 0)
  708. pref := s.DB.Table(new(model.ConfigDiseaseType).TableName()).
  709. Where("is_show =? ", pasturePb.IsShow_Ok)
  710. if err := pref.Find(&diseaseTypeList).Error; err != nil {
  711. return nil, xxerr.WithStack(err)
  712. }
  713. return &pasturePb.ConfigOptionsListResponse{
  714. Code: http.StatusOK,
  715. Message: "ok",
  716. Data: model.ConfigDiseaseTypeSlice(diseaseTypeList).ToPB2(),
  717. }, nil
  718. }
  719. func (s *StoreEntry) DiseaseOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  720. diseaseList := make([]*model.Disease, 0)
  721. pref := s.DB.Table(new(model.Disease).TableName()).
  722. Where("is_show =? ", pasturePb.IsShow_Ok)
  723. if err := pref.Find(&diseaseList).Error; err != nil {
  724. return nil, xxerr.WithStack(err)
  725. }
  726. return &pasturePb.ConfigOptionsListResponse{
  727. Code: http.StatusOK,
  728. Message: "ok",
  729. Data: model.DiseaseSlice(diseaseList).ToPB2(),
  730. }, nil
  731. }
  732. func (s *StoreEntry) BreedStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  733. return &pasturePb.ConfigOptionsListResponse{
  734. Code: http.StatusOK,
  735. Message: "ok",
  736. Data: s.BreedStatusEnumList(),
  737. }, nil
  738. }
  739. func (s *StoreEntry) CowKindOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  740. return &pasturePb.ConfigOptionsListResponse{
  741. Code: http.StatusOK,
  742. Message: "ok",
  743. Data: s.CowKindEnumList(),
  744. }, nil
  745. }
  746. func (s *StoreEntry) CowSourceOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  747. return &pasturePb.ConfigOptionsListResponse{
  748. Code: http.StatusOK,
  749. Message: "ok",
  750. Data: s.CowSourceEnumList(),
  751. }, nil
  752. }
  753. func (s *StoreEntry) CowStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  754. return &pasturePb.ConfigOptionsListResponse{
  755. Code: http.StatusOK,
  756. Message: "ok",
  757. Data: s.CowStatusEnumList(),
  758. }, nil
  759. }
  760. func (s *StoreEntry) CowTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  761. return &pasturePb.ConfigOptionsListResponse{
  762. Code: http.StatusOK,
  763. Message: "ok",
  764. Data: s.CowTypeEnumList(),
  765. }, nil
  766. }
  767. func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  768. return &pasturePb.ConfigOptionsListResponse{
  769. Code: http.StatusOK,
  770. Message: "ok",
  771. Data: s.TransferPenEnumList(),
  772. }, nil
  773. }
  774. func (s *StoreEntry) SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error) {
  775. systemUserList := make([]*model.SystemUser, 0)
  776. pref := s.DB.Table(new(model.SystemUser).TableName()).
  777. Where("is_delete = ?", pasturePb.IsShow_Ok).
  778. Where("is_show =? ", pasturePb.IsShow_Ok)
  779. if depId != -1 && depId > 0 {
  780. pref = pref.Where("dept_id = ?", depId)
  781. }
  782. if err := pref.Find(&systemUserList).Error; err != nil {
  783. return nil, xxerr.WithStack(err)
  784. }
  785. return &pasturePb.ConfigOptionsListResponse{
  786. Code: http.StatusOK,
  787. Message: "ok",
  788. Data: model.SystemUserSlice(systemUserList).ToPB2(),
  789. }, nil
  790. }
  791. func (s *StoreEntry) BullOptions(ctx context.Context) (*pasturePb.BullOptionsListResponse, error) {
  792. return &pasturePb.BullOptionsListResponse{
  793. Code: http.StatusOK,
  794. Message: "ok",
  795. Data: s.BullNumberEnumList(),
  796. }, nil
  797. }
  798. func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName string) (*pasturePb.ConfigOptionsListResponse, error) {
  799. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  800. switch optionsName {
  801. case "childNumber":
  802. configOptions = s.ChildNumberEnumList()
  803. case "calvingLevel":
  804. configOptions = s.CalvingLevelEnumList()
  805. case "dystociaReason":
  806. configOptions = s.DystociaReasonEnumList()
  807. case "drugCategory":
  808. configOptions = s.DrugCategoryEnumList()
  809. case "drugUsage":
  810. configOptions = s.DrugUsageEnumList()
  811. case "unit":
  812. configOptions = s.UnitEnumList()
  813. case "pregnantCheckResult":
  814. configOptions = s.PregnantCheckResultEnumList()
  815. case "pregnantCheckMethod":
  816. configOptions = s.PregnantCheckMethodEnumList()
  817. case "exposeEstrusType":
  818. configOptions = s.ExposeEstrusTypeEnumList()
  819. case "frozenSemenType":
  820. configOptions = s.FrozenSemenTypeEnumList()
  821. case "week":
  822. configOptions = s.WeekEnumList()
  823. case "sameTimeCowType":
  824. configOptions = s.SemeTimeCowTypeEnumList()
  825. case "immunizationCowType":
  826. configOptions = s.ImmunizationCowTypeEnumList()
  827. case "immunizationConditions":
  828. configOptions = s.ImmunizationConditionsEnumList()
  829. }
  830. return &pasturePb.ConfigOptionsListResponse{
  831. Code: http.StatusOK,
  832. Message: "ok",
  833. Data: configOptions,
  834. }, nil
  835. }