config_data_base.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. package backend
  2. import (
  3. "kpt-pasture/model"
  4. "gitee.com/xuyiping_admin/pkg/logger/zaplog"
  5. "go.uber.org/zap"
  6. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  7. )
  8. func (s *StoreEntry) OutReasonEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  9. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  10. if isAll == model.IsAllYes {
  11. configOptions = append(configOptions,
  12. &pasturePb.ConfigOptionsList{
  13. Value: int32(pasturePb.OutReasons_Invalid),
  14. Label: "全部",
  15. Disabled: true,
  16. })
  17. }
  18. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  19. Value: int32(pasturePb.OutReasons_Respiratory_System_Disease),
  20. Label: "呼吸系统疾病",
  21. Disabled: true,
  22. }, &pasturePb.ConfigOptionsList{
  23. Value: int32(pasturePb.OutReasons_Nutritional_Metabolic_Disease),
  24. Label: "营养代谢疾病",
  25. Disabled: true,
  26. }, &pasturePb.ConfigOptionsList{
  27. Value: int32(pasturePb.OutReasons_Breeding_Disease),
  28. Label: "繁殖疾病",
  29. Disabled: true,
  30. }, &pasturePb.ConfigOptionsList{
  31. Value: int32(pasturePb.OutReasons_Breast_Disease),
  32. Label: "乳房疾病",
  33. Disabled: true,
  34. }, &pasturePb.ConfigOptionsList{
  35. Value: int32(pasturePb.OutReasons_Long_Term_infertility),
  36. Label: "久配不孕",
  37. Disabled: true,
  38. }, &pasturePb.ConfigOptionsList{
  39. Value: int32(pasturePb.OutReasons_Multiple_Miscarriages),
  40. Label: "多次流产",
  41. Disabled: true,
  42. }, &pasturePb.ConfigOptionsList{
  43. Value: int32(pasturePb.OutReasons_Long_Treatment_Without_Recovery),
  44. Label: "久治不愈",
  45. Disabled: true,
  46. }, &pasturePb.ConfigOptionsList{
  47. Value: int32(pasturePb.OutReasons_Postpartum_Paralysis),
  48. Label: "产后瘫痪",
  49. Disabled: true,
  50. }, &pasturePb.ConfigOptionsList{
  51. Value: int32(pasturePb.OutReasons_Mastitis),
  52. Label: "乳房炎",
  53. Disabled: true,
  54. }, &pasturePb.ConfigOptionsList{
  55. Value: int32(pasturePb.OutReasons_Hoof_Disease),
  56. Label: "蹄病",
  57. Disabled: true,
  58. }, &pasturePb.ConfigOptionsList{
  59. Value: int32(pasturePb.OutReasons_Congenital_Malformation),
  60. Label: "先天畸形",
  61. Disabled: true,
  62. }, &pasturePb.ConfigOptionsList{
  63. Value: int32(pasturePb.OutReasons_Congenital_Malformation),
  64. Label: "先天畸形",
  65. Disabled: true,
  66. }, &pasturePb.ConfigOptionsList{
  67. Value: int32(pasturePb.OutReasons_Dysplasia),
  68. Label: "发育不良",
  69. Disabled: true,
  70. }, &pasturePb.ConfigOptionsList{
  71. Value: int32(pasturePb.OutReasons_Hernia),
  72. Label: "疝气",
  73. Disabled: true,
  74. }, &pasturePb.ConfigOptionsList{
  75. Value: int32(pasturePb.OutReasons_Excessive_Age),
  76. Label: "月龄过大",
  77. Disabled: true,
  78. }, &pasturePb.ConfigOptionsList{
  79. Value: int32(pasturePb.OutReasons_Excessive_Age),
  80. Label: "月龄过大",
  81. Disabled: true,
  82. }, &pasturePb.ConfigOptionsList{
  83. Value: int32(pasturePb.OutReasons_Excessive_Weight),
  84. Label: "体重过肥",
  85. Disabled: true,
  86. }, &pasturePb.ConfigOptionsList{
  87. Value: int32(pasturePb.OutReasons_Other_Disease),
  88. Label: "其他疾病",
  89. Disabled: true,
  90. }, &pasturePb.ConfigOptionsList{
  91. Value: int32(pasturePb.OutReasons_Weak_Child),
  92. Label: "弱仔",
  93. Disabled: true,
  94. }, &pasturePb.ConfigOptionsList{
  95. Value: int32(pasturePb.OutReasons_Obsessive_Bull),
  96. Label: "恶癖牛",
  97. Disabled: true,
  98. }, &pasturePb.ConfigOptionsList{
  99. Value: int32(pasturePb.OutReasons_Low_Milk),
  100. Label: "低产",
  101. Disabled: true,
  102. }, &pasturePb.ConfigOptionsList{
  103. Value: int32(pasturePb.OutReasons_Slow_Growing),
  104. Label: "生长缓慢",
  105. Disabled: true,
  106. }, &pasturePb.ConfigOptionsList{
  107. Value: int32(pasturePb.OutReasons_Other),
  108. Label: "其他",
  109. Disabled: true,
  110. }, &pasturePb.ConfigOptionsList{
  111. Value: int32(pasturePb.OutReasons_Unknown),
  112. Label: "未知原因",
  113. Disabled: true,
  114. })
  115. return configOptions
  116. }
  117. func (s *StoreEntry) DeathReasonEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  118. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  119. if isAll == model.IsAllYes {
  120. configOptions = append(configOptions,
  121. &pasturePb.ConfigOptionsList{
  122. Value: int32(pasturePb.DeathReason_Invalid),
  123. Label: "全部",
  124. Disabled: true,
  125. })
  126. }
  127. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  128. Value: int32(pasturePb.DeathReason_Digestive_System_Diseases),
  129. Label: "消化性疾病",
  130. Disabled: true,
  131. }, &pasturePb.ConfigOptionsList{
  132. Value: int32(pasturePb.DeathReason_Respiratory_System_Diseases),
  133. Label: "呼吸性疾病",
  134. Disabled: true,
  135. }, &pasturePb.ConfigOptionsList{
  136. Value: int32(pasturePb.DeathReason_Reproductive_System_Diseases),
  137. Label: "繁殖性疾病",
  138. Disabled: true,
  139. }, &pasturePb.ConfigOptionsList{
  140. Value: int32(pasturePb.DeathReason_Metabolic_System_Diseases),
  141. Label: "代谢性疾病",
  142. Disabled: true,
  143. }, &pasturePb.ConfigOptionsList{
  144. Value: int32(pasturePb.DeathReason_Infectious_Diseases),
  145. Label: "传染性疾病",
  146. Disabled: true,
  147. }, &pasturePb.ConfigOptionsList{
  148. Value: int32(pasturePb.DeathReason_Difficult_Birth),
  149. Label: "难产",
  150. Disabled: true,
  151. }, &pasturePb.ConfigOptionsList{
  152. Value: int32(pasturePb.DeathReason_Accident_Dead),
  153. Label: "意外死亡",
  154. Disabled: true,
  155. }, &pasturePb.ConfigOptionsList{
  156. Value: int32(pasturePb.DeathReason_Stress),
  157. Label: "应激",
  158. Disabled: true,
  159. }, &pasturePb.ConfigOptionsList{
  160. Value: int32(pasturePb.DeathReason_Trauma),
  161. Label: "外伤",
  162. Disabled: true,
  163. }, &pasturePb.ConfigOptionsList{
  164. Value: int32(pasturePb.DeathReason_Pneumonia),
  165. Label: "肺炎",
  166. Disabled: true,
  167. }, &pasturePb.ConfigOptionsList{
  168. Value: int32(pasturePb.DeathReason_Diarrhea),
  169. Label: "腹泻",
  170. Disabled: true,
  171. }, &pasturePb.ConfigOptionsList{
  172. Value: int32(pasturePb.DeathReason_Ketosis),
  173. Label: "酮症",
  174. Disabled: true,
  175. }, &pasturePb.ConfigOptionsList{
  176. Value: int32(pasturePb.DeathReason_Acidosis),
  177. Label: "酸中毒",
  178. Disabled: true,
  179. }, &pasturePb.ConfigOptionsList{
  180. Value: int32(pasturePb.DeathReason_Rumina_Impaction),
  181. Label: "瘤胃积食",
  182. Disabled: true,
  183. }, &pasturePb.ConfigOptionsList{
  184. Value: int32(pasturePb.DeathReason_Intestinal_Torsion),
  185. Label: "肠扭转",
  186. Disabled: true,
  187. }, &pasturePb.ConfigOptionsList{
  188. Value: int32(pasturePb.DeathReason_Other),
  189. Label: "其他",
  190. Disabled: true,
  191. })
  192. return configOptions
  193. }
  194. func (s *StoreEntry) MatingResultEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  195. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  196. if isAll == model.IsAllYes {
  197. configOptions = append(configOptions,
  198. &pasturePb.ConfigOptionsList{
  199. Value: int32(pasturePb.MatingResult_Invalid),
  200. Label: "全部",
  201. Disabled: true,
  202. })
  203. }
  204. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  205. Value: int32(pasturePb.MatingResult_Unknown),
  206. Label: "未知",
  207. Disabled: true,
  208. }, &pasturePb.ConfigOptionsList{
  209. Value: int32(pasturePb.MatingResult_ReMatch),
  210. Label: "复配",
  211. Disabled: true,
  212. }, &pasturePb.ConfigOptionsList{
  213. Value: int32(pasturePb.MatingResult_Pregnant),
  214. Label: "怀孕",
  215. Disabled: true,
  216. }, &pasturePb.ConfigOptionsList{
  217. Value: int32(pasturePb.MatingResult_Empty),
  218. Label: "空怀",
  219. Disabled: true,
  220. }, &pasturePb.ConfigOptionsList{
  221. Value: int32(pasturePb.MatingResult_Abort),
  222. Label: "流产",
  223. Disabled: true,
  224. })
  225. return configOptions
  226. }
  227. func (s *StoreEntry) EventCategoryEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  228. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  229. if isAll == model.IsAllYes {
  230. configOptions = append(configOptions,
  231. &pasturePb.ConfigOptionsList{
  232. Value: int32(pasturePb.EventCategory_Invalid),
  233. Label: "全部",
  234. Disabled: true,
  235. })
  236. }
  237. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  238. Value: int32(pasturePb.EventCategory_Base),
  239. Label: "基础事件",
  240. Disabled: true,
  241. }, &pasturePb.ConfigOptionsList{
  242. Value: int32(pasturePb.EventCategory_Breed),
  243. Label: "繁殖事件",
  244. Disabled: true,
  245. }, &pasturePb.ConfigOptionsList{
  246. Value: int32(pasturePb.EventCategory_Health),
  247. Label: "兽医事件",
  248. Disabled: true,
  249. }, &pasturePb.ConfigOptionsList{
  250. Value: int32(pasturePb.EventCategory_Other),
  251. Label: "其他事件",
  252. Disabled: true,
  253. })
  254. return configOptions
  255. }
  256. func (s *StoreEntry) IndicatorsCategoryEnumList(isAll string) []*pasturePb.ConfigOptionsList {
  257. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  258. if isAll == model.IsAllYes {
  259. configOptions = append(configOptions,
  260. &pasturePb.ConfigOptionsList{
  261. Value: int32(0),
  262. Label: "全部",
  263. Disabled: true,
  264. })
  265. }
  266. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  267. Value: int32(pasturePb.IndicatorType_Basic),
  268. Label: "基本指标",
  269. Disabled: true,
  270. }, &pasturePb.ConfigOptionsList{
  271. Value: int32(pasturePb.IndicatorType_Breed),
  272. Label: "繁殖指标",
  273. Disabled: true,
  274. }, &pasturePb.ConfigOptionsList{
  275. Value: int32(pasturePb.IndicatorType_Health),
  276. Label: "健康指标",
  277. Disabled: true,
  278. }, &pasturePb.ConfigOptionsList{
  279. Value: int32(pasturePb.IndicatorType_Feed),
  280. Label: "饲喂指标",
  281. Disabled: true,
  282. }, &pasturePb.ConfigOptionsList{
  283. Value: int32(pasturePb.IndicatorType_Calf),
  284. Label: "犊牛指标",
  285. Disabled: true,
  286. }, &pasturePb.ConfigOptionsList{
  287. Value: int32(pasturePb.IndicatorType_Fatten),
  288. Label: "育肥指标",
  289. Disabled: true,
  290. })
  291. return configOptions
  292. }
  293. func (s *StoreEntry) IndicatorsDetailsList(isAll string) []*pasturePb.ConfigOptionsList {
  294. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  295. if isAll == model.IsAllYes {
  296. configOptions = append(configOptions,
  297. &pasturePb.ConfigOptionsList{
  298. Value: int32(0),
  299. Label: "全部",
  300. Disabled: true,
  301. })
  302. }
  303. indicatorsDetailsList, _ := s.FindIndicatorsDetailsList()
  304. if len(indicatorsDetailsList) <= 0 {
  305. return configOptions
  306. }
  307. for _, v := range indicatorsDetailsList {
  308. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  309. Label: v.Name,
  310. Disabled: true,
  311. Props: v.Kind,
  312. })
  313. }
  314. return configOptions
  315. }
  316. func (s *StoreEntry) CowPurposeList(isAll string) []*pasturePb.ConfigOptionsList {
  317. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  318. if isAll == model.IsAllYes {
  319. configOptions = append(configOptions,
  320. &pasturePb.ConfigOptionsList{
  321. Value: int32(0),
  322. Label: "全部",
  323. Disabled: true,
  324. })
  325. }
  326. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  327. Value: int32(pasturePb.Purpose_Breeding),
  328. Label: "繁殖",
  329. Disabled: true,
  330. }, &pasturePb.ConfigOptionsList{
  331. Value: int32(pasturePb.Purpose_Fatten),
  332. Label: "育肥",
  333. Disabled: true,
  334. })
  335. return configOptions
  336. }
  337. func (s *StoreEntry) CowOutReasonList(isAll string) []*pasturePb.ConfigOptionsList {
  338. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  339. if isAll == model.IsAllYes {
  340. configOptions = append(configOptions,
  341. &pasturePb.ConfigOptionsList{
  342. Value: int32(0),
  343. Label: "全部",
  344. Disabled: true,
  345. })
  346. }
  347. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  348. Value: int32(pasturePb.OutReasons_Respiratory_System_Disease),
  349. Label: "呼吸系统疾病",
  350. Disabled: true,
  351. }, &pasturePb.ConfigOptionsList{
  352. Value: int32(pasturePb.OutReasons_Nutritional_Metabolic_Disease),
  353. Label: "营养代谢疾病",
  354. Disabled: true,
  355. }, &pasturePb.ConfigOptionsList{
  356. Value: int32(pasturePb.OutReasons_Breeding_Disease),
  357. Label: "繁殖疾病",
  358. Disabled: true,
  359. }, &pasturePb.ConfigOptionsList{
  360. Value: int32(pasturePb.OutReasons_Breast_Disease),
  361. Label: "乳房疾病",
  362. Disabled: true,
  363. }, &pasturePb.ConfigOptionsList{
  364. Value: int32(pasturePb.OutReasons_Hoof_Disease),
  365. Label: "蹄病",
  366. Disabled: true,
  367. }, &pasturePb.ConfigOptionsList{
  368. Value: int32(pasturePb.OutReasons_Low_Milk),
  369. Label: "低产",
  370. Disabled: true,
  371. }, &pasturePb.ConfigOptionsList{
  372. Value: int32(pasturePb.OutReasons_Slow_Growing),
  373. Label: "生长缓慢",
  374. Disabled: true,
  375. }, &pasturePb.ConfigOptionsList{
  376. Value: int32(pasturePb.OutReasons_Slow_Growing),
  377. Label: "生长缓慢",
  378. Disabled: true,
  379. }, &pasturePb.ConfigOptionsList{
  380. Value: int32(pasturePb.OutReasons_Other),
  381. Label: "其他原因",
  382. Disabled: true,
  383. })
  384. return configOptions
  385. }
  386. func (s *StoreEntry) CowDeathDestinationList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
  387. dataList := make([]*model.ConfigCowDeathDestination, 0)
  388. pref := s.DB.Model(new(model.ConfigCowDeathDestination)).
  389. Where("is_show =? ", pasturePb.IsShow_Ok).
  390. Where("pasture_id =? ", userModel.AppPasture.Id)
  391. if isAll == model.IsAllYes {
  392. pref = pref.Where("kind >= ?", pasturePb.PregnantCheckResult_Invalid)
  393. } else {
  394. pref = pref.Where("kind > ?", pasturePb.PregnantCheckResult_Invalid)
  395. }
  396. if err := pref.Order("kind ASC").
  397. Find(&dataList).Error; err != nil {
  398. zaplog.Error("CowDeathDestinationList", zap.Any("err", err))
  399. return make([]*pasturePb.ConfigOptionsList, 0)
  400. }
  401. return model.ConfigCowDeathDestinationSlice(dataList).ToPB(userModel.Language)
  402. /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  403. if isAll == model.IsAllYes {
  404. configOptions = append(configOptions,
  405. &pasturePb.ConfigOptionsList{
  406. Value: int32(0),
  407. Label: "全部",
  408. Disabled: true,
  409. })
  410. }
  411. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  412. Value: int32(pasturePb.DeathDestination_NuisanceLess),
  413. Label: "无公害处理",
  414. Disabled: true,
  415. }, &pasturePb.ConfigOptionsList{
  416. Value: int32(pasturePb.DeathDestination_Slaughterhouse),
  417. Label: "屠宰场",
  418. Disabled: true,
  419. }, &pasturePb.ConfigOptionsList{
  420. Value: int32(pasturePb.DeathDestination_Other),
  421. Label: "其他",
  422. Disabled: true,
  423. })
  424. return configOptions*/
  425. }