config_data_other.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. package backend
  2. import (
  3. "fmt"
  4. "kpt-pasture/model"
  5. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  6. "gitee.com/xuyiping_admin/pkg/logger/zaplog"
  7. "go.uber.org/zap"
  8. )
  9. func (s *StoreEntry) PregnantCheckMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  10. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  11. if isAll == model.IsAllYes {
  12. configOptions = append(configOptions,
  13. &pasturePb.ConfigOptionsList{
  14. Value: int32(pasturePb.PregnantCheckMethod_Invalid),
  15. })
  16. }
  17. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  18. Value: int32(pasturePb.PregnantCheckMethod_B_Ultrasound),
  19. Label: "B超",
  20. Disabled: true,
  21. }, &pasturePb.ConfigOptionsList{
  22. Value: int32(pasturePb.PregnantCheckMethod_Blood_Testing),
  23. Label: "血检",
  24. Disabled: true,
  25. }, &pasturePb.ConfigOptionsList{
  26. Value: int32(pasturePb.PregnantCheckMethod_Manual_Inspection),
  27. Label: "人工检查",
  28. Disabled: true,
  29. })
  30. return configOptions
  31. }
  32. func (s *StoreEntry) DrugCategoryEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  33. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  34. if isAll == model.IsAllYes {
  35. configOptions = append(configOptions,
  36. &pasturePb.ConfigOptionsList{
  37. Value: int32(pasturePb.DrugCategory_Invalid),
  38. Label: "全部",
  39. Disabled: true,
  40. })
  41. }
  42. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  43. Value: int32(pasturePb.DrugCategory_Antibiotics),
  44. Label: "抗生素类",
  45. Disabled: true,
  46. }, &pasturePb.ConfigOptionsList{
  47. Value: int32(pasturePb.DrugCategory_Antivirals),
  48. Label: "抗病毒类",
  49. Disabled: true,
  50. }, &pasturePb.ConfigOptionsList{
  51. Value: int32(pasturePb.DrugCategory_Antifungals),
  52. Label: "抗真菌类",
  53. Disabled: true,
  54. }, &pasturePb.ConfigOptionsList{
  55. Value: int32(pasturePb.DrugCategory_Antiparasitics),
  56. Label: "驱虫类",
  57. Disabled: true,
  58. }, &pasturePb.ConfigOptionsList{
  59. Value: int32(pasturePb.DrugCategory_Analgesics),
  60. Label: "镇痛类",
  61. Disabled: true,
  62. }, &pasturePb.ConfigOptionsList{
  63. Value: int32(pasturePb.DrugCategory_Antipyretic),
  64. Label: "退烧类",
  65. Disabled: true,
  66. }, &pasturePb.ConfigOptionsList{
  67. Value: int32(pasturePb.DrugCategory_Vitamin),
  68. Label: "维生素类",
  69. Disabled: true,
  70. }, &pasturePb.ConfigOptionsList{
  71. Value: int32(pasturePb.DrugCategory_Brine),
  72. Label: "盐水",
  73. Disabled: true,
  74. }, &pasturePb.ConfigOptionsList{
  75. Value: int32(pasturePb.DrugCategory_Glucose),
  76. Label: "葡萄糖",
  77. Disabled: true,
  78. }, &pasturePb.ConfigOptionsList{
  79. Value: int32(pasturePb.DrugCategory_Hormone),
  80. Label: "激素类",
  81. Disabled: true,
  82. }, &pasturePb.ConfigOptionsList{
  83. Value: int32(pasturePb.DrugCategory_Anti_Stress),
  84. Label: "抗应激类",
  85. Disabled: true,
  86. }, &pasturePb.ConfigOptionsList{
  87. Value: int32(pasturePb.DrugCategory_Disinfect),
  88. Label: "消毒类",
  89. Disabled: true,
  90. }, &pasturePb.ConfigOptionsList{
  91. Value: int32(pasturePb.DrugCategory_Chinese_Herbal),
  92. Label: "中药合剂",
  93. Disabled: true,
  94. }, &pasturePb.ConfigOptionsList{
  95. Value: int32(pasturePb.DrugCategory_Tocolytic),
  96. Label: "保胎类",
  97. Disabled: true,
  98. }, &pasturePb.ConfigOptionsList{
  99. Value: int32(pasturePb.DrugCategory_Immunity),
  100. Label: "疫苗类",
  101. Disabled: true,
  102. })
  103. return configOptions
  104. }
  105. func (s *StoreEntry) DrugUsageEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  106. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  107. if isAll == model.IsAllYes {
  108. configOptions = append(configOptions,
  109. &pasturePb.ConfigOptionsList{
  110. Value: int32(pasturePb.DrugUsage_Invalid),
  111. Label: "全部",
  112. Disabled: true,
  113. })
  114. }
  115. configOptions = append(configOptions,
  116. &pasturePb.ConfigOptionsList{
  117. Value: int32(pasturePb.DrugUsage_Oral_Medications),
  118. Label: "口服",
  119. Disabled: true,
  120. }, &pasturePb.ConfigOptionsList{
  121. Value: int32(pasturePb.DrugUsage_Injectable_Medications),
  122. Label: "肌注",
  123. Disabled: true,
  124. }, &pasturePb.ConfigOptionsList{
  125. Value: int32(pasturePb.DrugUsage_Topical_Medications),
  126. Label: "外用",
  127. Disabled: true,
  128. }, &pasturePb.ConfigOptionsList{
  129. Value: int32(pasturePb.DrugUsage_Inhalation_Medications),
  130. Label: "吸入",
  131. Disabled: true,
  132. }, &pasturePb.ConfigOptionsList{
  133. Value: int32(pasturePb.DrugUsage_Drink_Medications),
  134. Label: "饮水",
  135. Disabled: true,
  136. })
  137. return configOptions
  138. }
  139. func (s *StoreEntry) UnitEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  140. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  141. configOptions = append(configOptions,
  142. &pasturePb.ConfigOptionsList{
  143. Value: int32(pasturePb.Unit_Pieces),
  144. Label: "个",
  145. Disabled: true,
  146. }, &pasturePb.ConfigOptionsList{
  147. Value: int32(pasturePb.Unit_Package),
  148. Label: "包/袋",
  149. Disabled: true,
  150. }, &pasturePb.ConfigOptionsList{
  151. Value: int32(pasturePb.Unit_Bottle),
  152. Label: "瓶",
  153. Disabled: true,
  154. }, &pasturePb.ConfigOptionsList{
  155. Value: int32(pasturePb.Unit_Box),
  156. Label: "盒",
  157. Disabled: true,
  158. }, &pasturePb.ConfigOptionsList{
  159. Value: int32(pasturePb.Unit_Boxful),
  160. Label: "箱",
  161. Disabled: true,
  162. }, &pasturePb.ConfigOptionsList{
  163. Value: int32(pasturePb.Unit_Branch),
  164. Label: "支",
  165. Disabled: true,
  166. }, &pasturePb.ConfigOptionsList{
  167. Value: int32(pasturePb.Unit_Barrel),
  168. Label: "桶",
  169. Disabled: true,
  170. }, &pasturePb.ConfigOptionsList{
  171. Value: int32(pasturePb.Unit_Pot),
  172. Label: "罐",
  173. Disabled: true,
  174. }, &pasturePb.ConfigOptionsList{
  175. Value: int32(pasturePb.Unit_ML),
  176. Label: "毫升",
  177. Disabled: true,
  178. }, &pasturePb.ConfigOptionsList{
  179. Value: int32(pasturePb.Unit_L),
  180. Label: "升",
  181. Disabled: true,
  182. })
  183. return configOptions
  184. }
  185. func (s *StoreEntry) ExposeEstrusTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  186. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  187. if isAll == model.IsAllYes {
  188. configOptions = append(configOptions,
  189. &pasturePb.ConfigOptionsList{
  190. Value: int32(pasturePb.ExposeEstrusType_Invalid),
  191. Label: "全部",
  192. Disabled: true,
  193. })
  194. }
  195. configOptions = append(configOptions,
  196. &pasturePb.ConfigOptionsList{
  197. Value: int32(pasturePb.ExposeEstrusType_Neck_Ring),
  198. Label: "脖环揭发",
  199. Disabled: true,
  200. }, &pasturePb.ConfigOptionsList{
  201. Value: int32(pasturePb.ExposeEstrusType_Foot_Ring),
  202. Label: "脚环揭发",
  203. Disabled: true,
  204. }, &pasturePb.ConfigOptionsList{
  205. Value: int32(pasturePb.ExposeEstrusType_Natural_Estrus),
  206. Label: "自然发情",
  207. Disabled: true,
  208. })
  209. return configOptions
  210. }
  211. func (s *StoreEntry) FrozenSemenTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  212. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  213. if isAll == model.IsAllYes {
  214. configOptions = append(configOptions,
  215. &pasturePb.ConfigOptionsList{
  216. Value: int32(pasturePb.FrozenSemenType_Invalid),
  217. Label: "全部",
  218. Disabled: true,
  219. })
  220. }
  221. configOptions = append(configOptions,
  222. &pasturePb.ConfigOptionsList{
  223. Value: int32(pasturePb.FrozenSemenType_Ordinary),
  224. Label: "常规冻精",
  225. Disabled: true,
  226. }, &pasturePb.ConfigOptionsList{
  227. Value: int32(pasturePb.FrozenSemenType_Gender_Control),
  228. Label: "性控冻精",
  229. Disabled: true,
  230. })
  231. return configOptions
  232. }
  233. func (s *StoreEntry) BullNumberEnumList(isAll string, pastureId int64) []*pasturePb.BullOptionsList {
  234. frozenSemenList := make([]*model.FrozenSemen, 0)
  235. bullNumberList := make([]*pasturePb.BullOptionsList, 0)
  236. if err := s.DB.Model(new(model.FrozenSemen)).
  237. Where("pasture_id = ?", pastureId).
  238. Where("quantity > 0").
  239. Group("bull_id").
  240. Find(&frozenSemenList).Error; err != nil {
  241. zaplog.Error("BullNumberEnumList", zap.Any("Find", err))
  242. }
  243. for _, v := range frozenSemenList {
  244. bullNumberList = append(bullNumberList, &pasturePb.BullOptionsList{
  245. Value: v.BullId,
  246. Label: v.BullId,
  247. Disabled: true,
  248. })
  249. }
  250. return bullNumberList
  251. }
  252. func (s *StoreEntry) WeekEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  253. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  254. configOptions = append(configOptions,
  255. &pasturePb.ConfigOptionsList{
  256. Value: int32(pasturePb.Week_Monday),
  257. Label: "周一",
  258. Disabled: true,
  259. }, &pasturePb.ConfigOptionsList{
  260. Value: int32(pasturePb.Week_Tuesday),
  261. Label: "周二",
  262. Disabled: true,
  263. }, &pasturePb.ConfigOptionsList{
  264. Value: int32(pasturePb.Week_Wednesday),
  265. Label: "周三",
  266. Disabled: true,
  267. }, &pasturePb.ConfigOptionsList{
  268. Value: int32(pasturePb.Week_Thursday),
  269. Label: "周四",
  270. Disabled: true,
  271. }, &pasturePb.ConfigOptionsList{
  272. Value: int32(pasturePb.Week_Friday),
  273. Label: "周五",
  274. Disabled: true,
  275. }, &pasturePb.ConfigOptionsList{
  276. Value: int32(pasturePb.Week_Saturday),
  277. Label: "周六",
  278. Disabled: true,
  279. }, &pasturePb.ConfigOptionsList{
  280. Value: int32(pasturePb.Week_Sunday),
  281. Label: "周日",
  282. Disabled: true,
  283. })
  284. return configOptions
  285. }
  286. func (s *StoreEntry) MonthEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  287. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  288. for v := 1; v <= 31; v++ {
  289. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  290. Value: int32(v),
  291. Label: fmt.Sprintf("%d号", v),
  292. Disabled: true,
  293. })
  294. }
  295. return configOptions
  296. }
  297. func (s *StoreEntry) WorkOrderFrequencyEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  298. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  299. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  300. Value: int32(pasturePb.WorkOrderFrequency_None),
  301. Label: "一次性",
  302. Disabled: true,
  303. }, &pasturePb.ConfigOptionsList{
  304. Value: int32(pasturePb.WorkOrderFrequency_Daily),
  305. Label: "每天",
  306. Disabled: true,
  307. }, &pasturePb.ConfigOptionsList{
  308. Value: int32(pasturePb.WorkOrderFrequency_Weekly),
  309. Label: "每周",
  310. Disabled: true,
  311. }, &pasturePb.ConfigOptionsList{
  312. Value: int32(pasturePb.WorkOrderFrequency_Monthly),
  313. Label: "每月",
  314. Disabled: true,
  315. })
  316. return configOptions
  317. }
  318. func (s *StoreEntry) OutTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  319. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  320. if isAll == model.IsAllYes {
  321. configOptions = append(configOptions,
  322. &pasturePb.ConfigOptionsList{
  323. Value: int32(pasturePb.OutType_Invalid),
  324. Label: "全部",
  325. Disabled: true,
  326. })
  327. }
  328. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  329. Value: int32(pasturePb.OutType_Drugs),
  330. Label: "药品",
  331. Disabled: true,
  332. }, &pasturePb.ConfigOptionsList{
  333. Value: int32(pasturePb.OutType_Medical_Equipment),
  334. Label: "医疗器械",
  335. Disabled: true,
  336. })
  337. return configOptions
  338. }
  339. func (s *StoreEntry) AuditStatusEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  340. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  341. if isAll == model.IsAllYes {
  342. configOptions = append(configOptions,
  343. &pasturePb.ConfigOptionsList{
  344. Value: int32(pasturePb.AuditStatus_Invalid),
  345. Label: "全部",
  346. Disabled: true,
  347. })
  348. }
  349. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  350. Value: int32(pasturePb.AuditStatus_Pending),
  351. Label: "待审核",
  352. Disabled: true,
  353. }, &pasturePb.ConfigOptionsList{
  354. Value: int32(pasturePb.AuditStatus_Pass),
  355. Label: "已通过",
  356. Disabled: true,
  357. }, &pasturePb.ConfigOptionsList{
  358. Value: int32(pasturePb.AuditStatus_Reject),
  359. Label: "已拒绝",
  360. Disabled: true,
  361. }, &pasturePb.ConfigOptionsList{
  362. Value: int32(pasturePb.AuditStatus_Cancel),
  363. Label: "已取消",
  364. Disabled: true,
  365. }, &pasturePb.ConfigOptionsList{
  366. Value: int32(pasturePb.AuditStatus_Delete),
  367. Label: "已删除",
  368. Disabled: true,
  369. })
  370. return configOptions
  371. }
  372. func (s *StoreEntry) PregnantCheckNameEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  373. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  374. if isAll == model.IsAllYes {
  375. configOptions = append(configOptions,
  376. &pasturePb.ConfigOptionsList{
  377. Value: int32(0),
  378. Label: "全部",
  379. Disabled: true,
  380. })
  381. }
  382. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  383. Value: int32(1),
  384. Label: "初检",
  385. Disabled: true,
  386. }, &pasturePb.ConfigOptionsList{
  387. Value: int32(2),
  388. Label: "复检",
  389. Disabled: true,
  390. })
  391. return configOptions
  392. }
  393. func (s *StoreEntry) UnMatingReasonsEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  394. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  395. if isAll == model.IsAllYes {
  396. configOptions = append(configOptions,
  397. &pasturePb.ConfigOptionsList{
  398. Value: int32(0),
  399. Label: "全部",
  400. Disabled: true,
  401. })
  402. }
  403. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  404. Value: int32(pasturePb.UnMatingReasons_Irregular_Estrus),
  405. Label: "不规则发情",
  406. Disabled: true,
  407. }, &pasturePb.ConfigOptionsList{
  408. Value: int32(pasturePb.UnMatingReasons_No_Mating),
  409. Label: "禁配",
  410. Disabled: true,
  411. }, &pasturePb.ConfigOptionsList{
  412. Value: int32(pasturePb.UnMatingReasons_Disease),
  413. Label: "疾病",
  414. Disabled: true,
  415. }, &pasturePb.ConfigOptionsList{
  416. Value: int32(pasturePb.UnMatingReasons_Out),
  417. Label: "淘汰",
  418. Disabled: true,
  419. }, &pasturePb.ConfigOptionsList{
  420. Value: int32(pasturePb.UnMatingReasons_Other),
  421. Label: "其他",
  422. Disabled: true,
  423. })
  424. return configOptions
  425. }
  426. func (s *StoreEntry) EventTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  427. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  428. if isAll == model.IsAllYes {
  429. configOptions = append(configOptions,
  430. &pasturePb.ConfigOptionsList{
  431. Value: int32(0),
  432. Label: "全部",
  433. Disabled: true,
  434. })
  435. }
  436. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  437. Value: int32(pasturePb.EventType_Enter),
  438. Label: "入场",
  439. Disabled: true,
  440. }, &pasturePb.ConfigOptionsList{
  441. Value: int32(pasturePb.EventType_Transfer_Ben),
  442. Label: "转栏",
  443. Disabled: true,
  444. }, &pasturePb.ConfigOptionsList{
  445. Value: int32(pasturePb.EventType_Body_Score),
  446. Label: "体况评分",
  447. Disabled: true,
  448. }, &pasturePb.ConfigOptionsList{
  449. Value: int32(pasturePb.EventType_Pregnancy_Check),
  450. Label: "孕检",
  451. Disabled: true,
  452. }, &pasturePb.ConfigOptionsList{
  453. Value: int32(pasturePb.EventType_Estrus),
  454. Label: "发情",
  455. Disabled: true,
  456. }, &pasturePb.ConfigOptionsList{
  457. Value: int32(pasturePb.EventType_Calving),
  458. Label: "产犊",
  459. Disabled: true,
  460. }, &pasturePb.ConfigOptionsList{
  461. Value: int32(pasturePb.EventType_Seme_Time),
  462. Label: "同期",
  463. Disabled: true,
  464. }, &pasturePb.ConfigOptionsList{
  465. Value: int32(pasturePb.EventType_Mating),
  466. Label: "配种",
  467. Disabled: true,
  468. }, &pasturePb.ConfigOptionsList{
  469. Value: int32(pasturePb.EventType_Birth),
  470. Label: "出生",
  471. Disabled: true,
  472. }, &pasturePb.ConfigOptionsList{
  473. Value: int32(pasturePb.EventType_Death),
  474. Label: "死亡",
  475. Disabled: true,
  476. }, &pasturePb.ConfigOptionsList{
  477. Value: int32(pasturePb.EventType_Transfer_Out),
  478. Label: "转出",
  479. Disabled: true,
  480. }, &pasturePb.ConfigOptionsList{
  481. Value: int32(pasturePb.EventType_Transfer_In),
  482. Label: "转入",
  483. Disabled: true,
  484. }, &pasturePb.ConfigOptionsList{
  485. Value: int32(pasturePb.EventType_Out),
  486. Label: "淘汰",
  487. Disabled: true,
  488. }, &pasturePb.ConfigOptionsList{
  489. Value: int32(pasturePb.EventType_Immunication),
  490. Label: "免疫",
  491. Disabled: true,
  492. }, &pasturePb.ConfigOptionsList{
  493. Value: int32(pasturePb.EventType_Weaning),
  494. Label: "断奶",
  495. Disabled: true,
  496. }, &pasturePb.ConfigOptionsList{
  497. Value: int32(pasturePb.EventType_Sale),
  498. Label: "出售",
  499. Disabled: true,
  500. }, &pasturePb.ConfigOptionsList{
  501. Value: int32(pasturePb.EventType_Abort),
  502. Label: "流产",
  503. Disabled: true,
  504. }, &pasturePb.ConfigOptionsList{
  505. Value: int32(pasturePb.EventType_Weight),
  506. Label: "称重",
  507. Disabled: true,
  508. }, &pasturePb.ConfigOptionsList{
  509. Value: int32(pasturePb.EventType_Castrated),
  510. Label: "去势",
  511. Disabled: true,
  512. }, &pasturePb.ConfigOptionsList{
  513. Value: int32(pasturePb.EventType_Insect_Repellent),
  514. Label: "驱虫",
  515. Disabled: true,
  516. })
  517. return configOptions
  518. }