소스 검색

cowDisease: 牛只发病流程

Yi 7 달 전
부모
커밋
c0434e991d

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module kpt-pasture
 go 1.17
 
 require (
-	gitee.com/xuyiping_admin/go_proto v0.0.0-20240920091834-f963e67fe250
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20240923095155-018cf8ed2fc8
 	gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/eko/gocache v1.1.0

+ 6 - 73
go.sum

@@ -36,76 +36,12 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
 cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
 cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240905100333-97e1bcf51bd3 h1:hNO95yUSYiSGfDKRper22iC+UdZFlgfLuwPigAy1WM0=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240905100333-97e1bcf51bd3/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240906022358-d28cc0317fcc h1:q5QHNfCRLFiQnWReEweKch01/2wopT03QBlRN4DQT/4=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240906022358-d28cc0317fcc/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240906085821-e407cf34db4d h1:vUz+UjLU0FgtH0EWdm2B7DWImbY/KF5R0DaCRY1B5Ao=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240906085821-e407cf34db4d/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240909032240-4bb8d1ae9a74 h1:EiIqP3VKAgfxAfTcYb0pahRDF8HTJszMS+6FT69kx5o=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240909032240-4bb8d1ae9a74/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240909053609-bc77419ef76f h1:oRK0jUyGYwyF2hnMPskhWLvlMqlTkUeNwuI/HlTROZ0=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240909053609-bc77419ef76f/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240909054215-306813604abd h1:j34BDfJy91vtzhhEYHU0k5cANdMerKj7Ctjg+n1XwBg=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240909054215-306813604abd/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240909070422-d8e24115eea0 h1:WlkXLe5NFBAg57PLasrp3XvO/TB25+UqKGSXnWrbFBI=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240909070422-d8e24115eea0/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240909083429-fbc0524f090a h1:Vz40n7q51ZKrI2P5BCT0eY1I2Du5ApRaaFkkzqDO1bg=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240909083429-fbc0524f090a/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240910084821-7a933688a3b5 h1:eLdcgCs/bIFhaykTcnBtdDwBJI+r1PqYmbF+d0+AqoU=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240910084821-7a933688a3b5/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240910085752-595a1baf8c90 h1:MoEtVVhW9LMk1FgiYYubNixK1H8hCNdkLMKdKjwETQE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240910085752-595a1baf8c90/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240911082204-134766e09b9c h1:qeS8jqn/lrs6GfXoQkykbDooCYaWI5Gud3xsG8HfNV8=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240911082204-134766e09b9c/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240911090051-338ee53b7bdd h1:sMOix7olqu2kp/AhXZMD4HpW3OtKQ2pCii0k3HscWwI=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240911090051-338ee53b7bdd/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912012226-2a41e99f794f h1:F2JObMAfVnq+8RJAtEhID6UaeF3qpO4mgWZsyQA+6PA=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912012226-2a41e99f794f/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912013108-b140d281ec27 h1:wzQovv4fvjiVP7xTY1DrEEw3De8LtBDe/AOWrkYt+e4=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912013108-b140d281ec27/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912024219-df4ae8e00ef3 h1:wYX+YcTbo+81TrtewBCWExxctetMvjN1sabiq3oPI6k=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912024219-df4ae8e00ef3/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912053920-4574bdb15216 h1:NWizM8am/bDb3L+xZUlNbLrPIyz4hKe7qhBDoaKbbug=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912053920-4574bdb15216/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912072215-f7745ae5f7be h1:c8X60ELEPuwUbjNCQ/ensGzX8vwLa8Bxi2kjUjjp9RA=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912072215-f7745ae5f7be/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912094449-3403561dafd5 h1:1ER5K/jBvlGwG9DtVSS6qznJTBqoWpibxYIliWm6Hvw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240912094449-3403561dafd5/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240913035809-c17813bb52a4 h1:Ngcrr5pqJuVMzOpJL/DDgJJG2Ifp2ddDqJqfpKl5dtA=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240913035809-c17813bb52a4/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240913052245-91b5dc33dc1f h1:Wd3IIMuvUUuLb05hDvYEP09674GJQ20RWZEUbOHpTkg=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240913052245-91b5dc33dc1f/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240913064049-b55eee13d8e3 h1:dWEcyM7ST22AD4n+XYdZ/VPvl/+SYJK+KrrPrAxZUKA=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240913064049-b55eee13d8e3/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240913070925-6c67b84f42fc h1:o8U7cViR7ZmfFOSNBcjVNQXxFRK7PVVo1Sf5NsBP0Ns=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240913070925-6c67b84f42fc/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240913094501-2c3f16e7b53a h1:piTgQ0Z1UJ87ti12F1gUOtglzW92pFy0afPoFSLn+ns=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240913094501-2c3f16e7b53a/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240914085632-2dbb719d5eb9 h1:/irLE00XZY5K9/FryWMEDlPnwDSEn8y4jQn/bepnCQ0=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240914085632-2dbb719d5eb9/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240916154658-fd81c51d9378 h1:60W1C1tbo3bdQJ9WNmBhbPt9hgXZ5lf9Lb7/+6B1+hs=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240916154658-fd81c51d9378/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240918070654-f8e5007dfb14 h1:D8a3ImcphFPiJwaulcEJT6as1PZSumhQAG6gvoV9LZg=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240918070654-f8e5007dfb14/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240918094047-4a5799fc4664 h1:fZ1U58E3S6//eVhJFol1k/bPjACGgfJUEl4mSBypNCc=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240918094047-4a5799fc4664/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240919021444-ca52d1e063b5 h1:gb36NATw2kELss5rqmbf++pnRQEWYfLlJPpz9DKBl2A=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240919021444-ca52d1e063b5/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240919035403-daaeef13157e h1:2ACGSgOvD/2koF/q8R/hNX3hhslDzsfFo1cYuVL/cB0=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240919035403-daaeef13157e/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240919060747-513871220a2c h1:pYRrpTtoq7xPPl++KF6dipddCrLUREvd6UZCN0WvHyQ=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240919060747-513871220a2c/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240919061932-a470f1859b92 h1:pXV0rGbtId8o7XtpG47I/rNzZFsL53S48GlxrPDjAQY=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240919061932-a470f1859b92/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240920035636-9f9a4471aecd h1:7Z/tCTztnuocjWbFhfe9dq4SZUhOw+pCPQtjSJyiW0k=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240920035636-9f9a4471aecd/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240920075539-863a9a1eecfe h1:wccYtNFakuPrU0RrJjzqKIJnwu9aATIXp38yl6NGYdY=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240920075539-863a9a1eecfe/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240920080429-e344d4c3c3b7 h1:1U6uvVC4H14uqTc6NgtcPsDVH9XjmmMri3f4QcfFhJo=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240920080429-e344d4c3c3b7/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240920091834-f963e67fe250 h1:w53i9vZcAYM41E1EYwBIXJ0eGUl5lHb7EC7d7lh1zDM=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240920091834-f963e67fe250/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240923075344-12e649aee807 h1:lGwAI4/LbR+2mioOQeRoVAN2vPp5CmjxET4+nTFjmGg=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240923075344-12e649aee807/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240923085405-91f84f9d76ae h1:xLJpN8gNLW8MuuXJIZNIPkVCBwV6SQ0RsSJUyvMAQBk=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240923085405-91f84f9d76ae/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240923095155-018cf8ed2fc8 h1:8a85MdnwHBChtQJ7DQzd2AE6+FHPsEEFRwYHB6WKEco=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240923095155-018cf8ed2fc8/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015 h1:dfb5dRd57L2HKjdwLT93UFmPYFPOmEl56gtZmqcNnaE=
 gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015/go.mod h1:Fk4GYI/v0IK3XFrm1Gn+VkgCz5Y7mfswD5hsTJYOG6A=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
@@ -176,7 +112,6 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
 github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
 github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
 github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
-github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
 github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
 github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
 github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
@@ -593,8 +528,6 @@ github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
 github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA=
 github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48=
 github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
-github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
-github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
 github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
 github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
 github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=

+ 64 - 0
http/handler/event/event_health.go

@@ -0,0 +1,64 @@
+package event
+
+import (
+	"kpt-pasture/http/middleware"
+	"net/http"
+
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
+	"github.com/gin-gonic/gin"
+)
+
+func CowDiseaseCreate(c *gin.Context) {
+	var req pasturePb.EventCowDisease
+	if err := ginutil.BindProto(c, &req); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	if err := valid.ValidateStruct(&req,
+		valid.Field(&req.CowId, valid.Required),
+		valid.Field(&req.DiseaseAt, valid.Required),
+		valid.Field(&req.DiseaseId, valid.Required),
+		valid.Field(&req.OperationId, valid.Required),
+	); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	if err := middleware.BackendOperation(c).OpsService.CowDiseaseCreate(c, &req); err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	}
+
+	ginutil.JSONResp(c, &operationPb.CommonOK{
+		Code: http.StatusOK,
+		Msg:  "ok",
+		Data: &operationPb.Success{Success: true},
+	})
+}
+
+func CowDiseaseList(c *gin.Context) {
+	var req pasturePb.SearchEventCowTreatmentRequest
+	if err := ginutil.BindProto(c, &req); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	pagination := &pasturePb.PaginationModel{
+		Page:       int32(c.GetInt(middleware.Page)),
+		PageSize:   int32(c.GetInt(middleware.PageSize)),
+		PageOffset: int32(c.GetInt(middleware.PageOffset)),
+	}
+
+	res, err := middleware.Dependency(c).StoreEventHub.OpsService.CowDiseaseList(c, &req, pagination)
+	if err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	}
+	ginutil.JSONResp(c, res)
+
+}

+ 0 - 1
http/handler/event/event_vet.go

@@ -1 +0,0 @@
-package event

+ 4 - 0
http/route/event_api.go

@@ -49,5 +49,9 @@ func EventAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 		eventRoute.POST("/abortion/list", event.AbortionList)
 		eventRoute.POST("/abortion/create", event.AbortionCreate)
 
+		// 发病
+		eventRoute.POST("/disease/create", event.CowDiseaseCreate)
+		eventRoute.POST("/disease/list", event.CowDiseaseList)
+
 	}
 }

+ 41 - 40
model/cow.go

@@ -9,46 +9,47 @@ import (
 )
 
 type Cow struct {
-	Id                  int64                      `json:"id"`
-	Sex                 pasturePb.Genders_Kind     `json:"sex"`
-	NeckRingNumber      string                     `json:"neckRingNumber"`
-	EarNumber           string                     `json:"earNumber"`
-	EarOldNumber        string                     `json:"earOldNumber"`
-	PenId               int32                      `json:"penId"`
-	Lact                int32                      `json:"lact"`
-	DayAge              int32                      `json:"dayAge"`
-	CalvingAge          int64                      `json:"calvingAge"`
-	PregnancyAge        int64                      `json:"pregnancyAge"` // 怀孕天数 孕检结果有阳性更新,产犊后至0
-	AdmissionAge        int64                      `json:"admissionAge"`
-	AbortionAge         int64                      `json:"abortionAge"` // 流产天数
-	CowType             pasturePb.CowType_Kind     `json:"cowType"`
-	BreedStatus         pasturePb.BreedStatus_Kind `json:"breedStatus"`
-	CowKind             pasturePb.CowKind_Kind     `json:"cowKind"`
-	BirthWeight         int64                      `json:"birthWeight"`
-	CurrentWeight       int64                      `json:"currentWeight"`
-	SourceId            pasturePb.CowSource_Kind   `json:"sourceId"`
-	FatherNumber        string                     `json:"fatherNumber"`
-	MotherNumber        string                     `json:"motherNumber"`
-	IsRemove            pasturePb.IsShow_Kind      `json:"isRemove"`
-	IsPregnant          pasturePb.IsShow_Kind      `json:"isPregnant"`
-	IsHealth            pasturePb.IsShow_Kind      `json:"isHealth"`
-	WeaningAt           int64                      `json:"weaningAt"`
-	CalvingAt           int64                      `json:"calvingAt"`
-	BirthAt             int64                      `json:"birthAti"`
-	AdmissionAt         int64                      `json:"admissionAt"`
-	FirstMatingAt       int64                      `json:"firstMatingAt"`
-	LastEstrusAt        int64                      `json:"lastEstrusAt"`
-	LastCalvingAt       int64                      `json:"lastCalvingAt"`
-	LastMatingAt        int64                      `json:"lastMatingAt"`
-	LastBullNumber      string                     `json:"lastBullNumber"`
-	LastPregnantCheckAt int64                      `json:"lastPregnantCheckAt"`
-	LastDryMilkAt       int64                      `json:"lastDryMilkAt"`
-	LastSecondWeight    int64                      `json:"lastSecondWeight"`
-	LastSecondWeightAt  int64                      `json:"lastSecondWeightAt"`
-	LastAbortionAt      int64                      `json:"lastAbortionAt"`
-	LastWeightAt        int64                      `json:"lastWeightAt"`
-	CreatedAt           int64                      `json:"createdAt"`
-	UpdatedAt           int64                      `json:"updatedAt"`
+	Id                  int64                       `json:"id"`
+	Sex                 pasturePb.Genders_Kind      `json:"sex"`
+	NeckRingNumber      string                      `json:"neckRingNumber"`
+	EarNumber           string                      `json:"earNumber"`
+	EarOldNumber        string                      `json:"earOldNumber"`
+	PenId               int32                       `json:"penId"`
+	Lact                int32                       `json:"lact"`
+	DayAge              int32                       `json:"dayAge"`
+	CalvingAge          int64                       `json:"calvingAge"`
+	PregnancyAge        int64                       `json:"pregnancyAge"` // 怀孕天数 孕检结果有阳性更新,产犊后至0
+	AdmissionAge        int64                       `json:"admissionAge"`
+	AbortionAge         int64                       `json:"abortionAge"` // 流产天数
+	CowType             pasturePb.CowType_Kind      `json:"cowType"`
+	BreedStatus         pasturePb.BreedStatus_Kind  `json:"breedStatus"`
+	CowKind             pasturePb.CowKind_Kind      `json:"cowKind"`
+	BirthWeight         int64                       `json:"birthWeight"`
+	CurrentWeight       int64                       `json:"currentWeight"`
+	SourceId            pasturePb.CowSource_Kind    `json:"sourceId"`
+	FatherNumber        string                      `json:"fatherNumber"`
+	MotherNumber        string                      `json:"motherNumber"`
+	IsRemove            pasturePb.IsShow_Kind       `json:"isRemove"`
+	IsPregnant          pasturePb.IsShow_Kind       `json:"isPregnant"`
+	IsHealth            pasturePb.IsShow_Kind       `json:"isHealth"`
+	HealthStatus        pasturePb.HealthStatus_Kind `json:"healthStatus"`
+	WeaningAt           int64                       `json:"weaningAt"`
+	CalvingAt           int64                       `json:"calvingAt"`
+	BirthAt             int64                       `json:"birthAti"`
+	AdmissionAt         int64                       `json:"admissionAt"`
+	FirstMatingAt       int64                       `json:"firstMatingAt"`
+	LastEstrusAt        int64                       `json:"lastEstrusAt"`
+	LastCalvingAt       int64                       `json:"lastCalvingAt"`
+	LastMatingAt        int64                       `json:"lastMatingAt"`
+	LastBullNumber      string                      `json:"lastBullNumber"`
+	LastPregnantCheckAt int64                       `json:"lastPregnantCheckAt"`
+	LastDryMilkAt       int64                       `json:"lastDryMilkAt"`
+	LastSecondWeight    int64                       `json:"lastSecondWeight"`
+	LastSecondWeightAt  int64                       `json:"lastSecondWeightAt"`
+	LastAbortionAt      int64                       `json:"lastAbortionAt"`
+	LastWeightAt        int64                       `json:"lastWeightAt"`
+	CreatedAt           int64                       `json:"createdAt"`
+	UpdatedAt           int64                       `json:"updatedAt"`
 }
 
 func (c *Cow) TableName() string {

+ 72 - 0
model/event_cow_disease.go

@@ -0,0 +1,72 @@
+package model
+
+import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+
+type EventCowDisease struct {
+	Id                    int64                       `json:"id"`
+	CowId                 int64                       `json:"cowId"`
+	Lact                  int32                       `json:"lact"`
+	DayAge                int32                       `json:"dayAge"`
+	DiseaseId             int32                       `json:"diseaseId"`
+	DiseaseName           string                      `json:"diseaseName"`
+	DiagnoseId            int32                       `json:"diagnoseId"`
+	DiagnoseName          string                      `json:"diagnoseName"`
+	PenId                 int32                       `json:"penId"`
+	HealthStatus          pasturePb.HealthStatus_Kind `json:"healthStatus"`
+	DiseaseAt             int64                       `json:"diseaseAt"`
+	Temperature           int32                       `json:"temperature"`
+	Remarks               string                      `json:"remarks"`
+	OperationId           int32                       `json:"operationId"`
+	OperationName         string                      `json:"operationName"`
+	DiagnoseOperationId   int32                       `json:"diagnoseOperationId"`
+	DiagnoseOperationName string                      `json:"diagnoseOperationName"`
+	CreatedAt             int64                       `json:"createdAt"`
+	UpdatedAt             int64                       `json:"updatedAt"`
+}
+
+func (e *EventCowDisease) TableName() string {
+	return "event_cow_disease"
+}
+
+func NewEventCowDisease(cow *Cow, req *pasturePb.EventCowDisease) *EventCowDisease {
+	return &EventCowDisease{
+		CowId:         cow.Id,
+		Lact:          cow.Lact,
+		DayAge:        cow.DayAge,
+		DiseaseId:     req.DiseaseId,
+		DiseaseName:   req.DiseaseName,
+		PenId:         req.PenId,
+		HealthStatus:  pasturePb.HealthStatus_Disease,
+		DiseaseAt:     int64(req.DiseaseAt),
+		Temperature:   int32(req.Temperature * 10),
+		OperationId:   req.OperationId,
+		OperationName: req.OperationName,
+		Remarks:       req.Remarks,
+	}
+}
+
+type EventCowDiseaseSlice []*EventCowDisease
+
+func (e EventCowDiseaseSlice) ToPB() []*pasturePb.EventCowDisease {
+	res := make([]*pasturePb.EventCowDisease, len(e))
+	for i, v := range e {
+		res[i] = &pasturePb.EventCowDisease{
+			Id:            int32(v.Id),
+			CowId:         int32(v.CowId),
+			Lact:          v.Lact,
+			DayAge:        v.DayAge,
+			DiseaseId:     v.DiseaseId,
+			DiseaseName:   v.DiseaseName,
+			DiagnoseId:    v.DiagnoseId,
+			DiagnoseName:  v.DiagnoseName,
+			PenId:         v.PenId,
+			HealthStatus:  v.HealthStatus,
+			Temperature:   float32(v.HealthStatus / 10),
+			DiseaseAt:     int32(v.DiseaseAt),
+			Remarks:       v.Remarks,
+			OperationId:   v.OperationId,
+			OperationName: v.OperationName,
+		}
+	}
+	return res
+}

+ 22 - 0
model/event_cow_treatment.go

@@ -0,0 +1,22 @@
+package model
+
+import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+
+type EventCowTreatment struct {
+	Id                 int64                 `json:"id"`
+	CowId              int64                 `json:"cowId"`
+	CowDiseaseId       int64                 `json:"cowDiseaseId"`
+	PrescriptionId     int32                 `json:"prescriptionId"`
+	PrescriptionName   string                `json:"prescriptionName"`
+	PrescriptionDetail string                `json:"prescriptionDetail"`
+	TreatmentResult    pasturePb.IsShow_Kind `json:"treatmentResult"`
+	OperationId        int64                 `json:"operationId"`
+	OperationName      string                `json:"operationName"`
+	Remarks            string                `json:"remarks"`
+	CreatedAt          int64                 `json:"createdAt"`
+	UpdatedAt          int64                 `json:"updatedAt"`
+}
+
+func (e *EventCowTreatment) TableName() string {
+	return "event_cow_treatment"
+}

+ 1 - 1
model/prescription.go

@@ -9,7 +9,7 @@ import (
 )
 
 type Prescription struct {
-	Id                int64                 `json:"id"`
+	Id                int32                 `json:"id"`
 	Name              string                `json:"name"`
 	ApplicableDisease string                `json:"applicable_disease"`
 	UseDays           int32                 `json:"use_days"`

+ 3 - 3
model/prescription_drugs.go

@@ -3,8 +3,8 @@ package model
 import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 
 type PrescriptionDrugs struct {
-	Id             int64                 `json:"id"`
-	PrescriptionId int64                 `json:"prescription_id"`
+	Id             int32                 `json:"id"`
+	PrescriptionId int32                 `json:"prescription_id"`
 	DrugsId        int64                 `json:"drugs_id"`
 	DrugsName      string                `json:"drugs_name"`
 	UseDays        int32                 `json:"use_days"`
@@ -21,7 +21,7 @@ func (p *PrescriptionDrugs) TableName() string {
 	return "prescription_drugs"
 }
 
-func NewPrescriptionDrugs(prescriptionId int64, req *pasturePb.PrescriptionRequest) []*PrescriptionDrugs {
+func NewPrescriptionDrugs(prescriptionId int32, req *pasturePb.PrescriptionRequest) []*PrescriptionDrugs {
 	res := make([]*PrescriptionDrugs, len(req.DrugsList))
 	for i, v := range req.DrugsList {
 		res[i] = &PrescriptionDrugs{

+ 26 - 0
module/backend/config_data.go

@@ -796,3 +796,29 @@ func (s *StoreEntry) AbortionReasonsEnumList() []*pasturePb.ConfigOptionsList {
 	})
 	return configOptions
 }
+
+func (s *StoreEntry) HealthStatusEnumList() []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.HealthStatus_Health),
+		Label:    "健康",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.HealthStatus_Disease),
+		Label:    "发病",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.HealthStatus_Diagnosed),
+		Label:    "确诊",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.HealthStatus_Treatment),
+		Label:    "治疗",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.HealthStatus_Curable),
+		Label:    "治愈",
+		Disabled: true,
+	})
+	return configOptions
+}

+ 1 - 0
module/backend/enum_options.go

@@ -159,6 +159,7 @@ func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName st
 		"workOrderCategory":      s.WorkOrderCategoryEnumList,
 		"immunizationConditions": s.ImmunizationConditionsEnumList,
 		"abortionReasons":        s.AbortionReasonsEnumList,
+		"healthStatus":           s.HealthStatusEnumList,
 	}
 
 	getConfigFunc, ok := getConfigFuncMap[optionsName]

+ 115 - 0
module/backend/event_health.go

@@ -0,0 +1,115 @@
+package backend
+
+import (
+	"context"
+	"kpt-pasture/model"
+	"net/http"
+
+	"gorm.io/gorm"
+
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"gitee.com/xuyiping_admin/pkg/xerr"
+)
+
+// CowDiseaseCreate 牛只发病提交
+func (s *StoreEntry) CowDiseaseCreate(ctx context.Context, req *pasturePb.EventCowDisease) error {
+	cow, err := s.GetCowInfoByCowId(ctx, int64(req.CowId))
+	if err != nil {
+		return xerr.WithStack(err)
+	}
+
+	systemUser, err := s.GetSystemUserById(ctx, int64(req.OperationId))
+	if err != nil {
+		return xerr.WithStack(err)
+	}
+
+	req.OperationName = systemUser.Name
+
+	disease, err := s.GetDiseaseById(ctx, req.DiseaseId)
+	if err != nil {
+		return xerr.WithStack(err)
+	}
+
+	req.DiseaseName = disease.Name
+	newEventCowDisease := model.NewEventCowDisease(cow, req)
+	if err = s.DB.Transaction(func(tx *gorm.DB) error {
+		if err = tx.Create(newEventCowDisease).Error; err != nil {
+			return xerr.WithStack(err)
+		}
+
+		// 更新牛舍
+		if req.PenId > 0 {
+			if err = tx.Model(new(model.Cow)).
+				Where("id = ?", req.CowId).
+				Updates(map[string]interface{}{
+					"pen_id": req.PenId,
+				}).Error; err != nil {
+				return xerr.WithStack(err)
+			}
+		}
+
+		return nil
+	}); err != nil {
+		return xerr.WithStack(err)
+	}
+
+	return nil
+}
+
+func (s *StoreEntry) CowDiseaseList(ctx context.Context, req *pasturePb.SearchEventCowTreatmentRequest, pagination *pasturePb.PaginationModel) (*pasturePb.EventCowDiseaseResponse, error) {
+	cowDiseaseList := make([]*model.EventCowDisease, 0)
+	var count int64 = 0
+	pref := s.DB.Model(new(model.EventCowDisease))
+
+	if len(req.CowIds) > 0 {
+		pref.Where("cow_id IN ?", req.CowIds)
+	}
+
+	if req.DiseaseId > 0 {
+		pref.Where("disease_id = ?", req.DiseaseId)
+	}
+
+	if req.PenId > 0 {
+		pref.Where("pen_id = ?", req.PenId)
+	}
+
+	if req.Lact > 0 {
+		pref.Where("lact = ?", req.Lact)
+	}
+
+	if req.MinDayAge > 0 && req.MaxDayAge > 0 && req.MaxDayAge >= req.MinDayAge {
+		pref.Where("day_age BETWEEN ? AND ?", req.MinDayAge, req.MaxDayAge)
+	}
+
+	if req.HealthStatus > 0 {
+		pref.Where("health_status = ?", req.HealthStatus)
+	} else {
+		pref.Where("health_status IN ?", []pasturePb.HealthStatus_Kind{
+			pasturePb.HealthStatus_Disease,
+			pasturePb.HealthStatus_Treatment,
+			pasturePb.HealthStatus_Diagnosed,
+		})
+	}
+
+	if err := pref.Order("id desc").
+		Count(&count).Limit(int(pagination.PageSize)).
+		Offset(int(pagination.PageOffset)).
+		Find(&cowDiseaseList).Error; err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
+	return &pasturePb.EventCowDiseaseResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data: &pasturePb.EventCowDiseaseData{
+			List:     model.EventCowDiseaseSlice(cowDiseaseList).ToPB(),
+			Total:    int32(count),
+			PageSize: pagination.PageSize,
+			Page:     pagination.Page,
+		},
+	}, nil
+}
+
+func (s *StoreEntry) CowDiseaseTreatment(ctx context.Context) {
+
+}

+ 0 - 1
module/backend/event_vet.go

@@ -1 +0,0 @@
-package backend

+ 4 - 0
module/backend/interface.go

@@ -178,6 +178,10 @@ type EventService interface {
 	// WeightList 称重
 	WeightList(ctx context.Context, req *pasturePb.SearchEventRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchWeightEventResponse, error)
 	WeightCreate(ctx context.Context, req *pasturePb.EventWeight) error
+
+	// CowDiseaseCreate 牛只发病
+	CowDiseaseCreate(ctx context.Context, req *pasturePb.EventCowDisease) error
+	CowDiseaseList(ctx context.Context, req *pasturePb.SearchEventCowTreatmentRequest, pagination *pasturePb.PaginationModel) (*pasturePb.EventCowDiseaseResponse, error)
 }
 
 //go:generate mockgen -destination mock/CowService.go -package kptservicemock kpt-pasture/module/backend CowService

+ 3 - 3
module/backend/prescription.go

@@ -207,7 +207,7 @@ func (s *StoreEntry) SearchPrescriptionList(ctx context.Context, req *pasturePb.
 		return nil, xerr.WithStack(err)
 	}
 
-	prescriptionIds := make([]int64, 0)
+	prescriptionIds := make([]int32, 0)
 	for _, prescription := range prescriptionList {
 		prescriptionIds = append(prescriptionIds, prescription.Id)
 	}
@@ -280,7 +280,7 @@ func (s *StoreEntry) CreateOrUpdatePrescription(ctx context.Context, req *pastur
 	newPrescription := model.NewPrescription(req, applicableDisease, maxUseDays, maxMeatExpiredDays, maxMilkExpiredDays, currUser)
 
 	if req.Id > 0 {
-		prescription := &model.Prescription{Id: int64(req.Id)}
+		prescription := &model.Prescription{Id: req.Id}
 		if err := s.DB.Model(&model.Prescription{}).First(prescription).Error; err != nil {
 			if !errors.Is(err, gorm.ErrRecordNotFound) {
 				return xerr.WithStack(err)
@@ -304,7 +304,7 @@ func (s *StoreEntry) CreateOrUpdatePrescription(ctx context.Context, req *pastur
 				return xerr.WithStack(err)
 			}
 			// 创建处方药品
-			newPrescriptionDrugs := model.NewPrescriptionDrugs(int64(req.Id), req)
+			newPrescriptionDrugs := model.NewPrescriptionDrugs(req.Id, req)
 			if err := tx.Create(&newPrescriptionDrugs).Error; err != nil {
 				return xerr.WithStack(err)
 			}

+ 15 - 7
module/backend/sql.go

@@ -145,6 +145,17 @@ func (s *StoreEntry) GetCowWeightByLastSecond(ctx context.Context, cowId, lastWe
 	return cowWeightData, nil
 }
 
+func (s *StoreEntry) GetDrugsById(ctx context.Context, id int64) (*model.Drugs, error) {
+	drugs := &model.Drugs{Id: id}
+	if err := s.DB.First(drugs).Error; err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return nil, xerr.Customf("该药品数据不存在: %d", id)
+		}
+		return nil, xerr.WithStack(err)
+	}
+	return drugs, nil
+}
+
 func (s *StoreEntry) DiseaseTypeList(ctx context.Context) ([]*model.ConfigDiseaseType, error) {
 	diseaseTypeList := make([]*model.ConfigDiseaseType, 0)
 	if err := s.DB.Where("is_show = ?", pasturePb.IsShow_Ok).Find(&diseaseTypeList).Error; err != nil {
@@ -153,15 +164,12 @@ func (s *StoreEntry) DiseaseTypeList(ctx context.Context) ([]*model.ConfigDiseas
 	return diseaseTypeList, nil
 }
 
-func (s *StoreEntry) GetDrugsById(ctx context.Context, id int64) (*model.Drugs, error) {
-	drugs := &model.Drugs{Id: id}
-	if err := s.DB.First(drugs).Error; err != nil {
-		if errors.Is(err, gorm.ErrRecordNotFound) {
-			return nil, xerr.Customf("该药品数据不存在: %d", id)
-		}
+func (s *StoreEntry) GetDiseaseById(ctx context.Context, id int32) (*model.Disease, error) {
+	newDisease := &model.Disease{}
+	if err := s.DB.Where("id = ?", id).First(newDisease).Error; err != nil {
 		return nil, xerr.WithStack(err)
 	}
-	return drugs, nil
+	return newDisease, nil
 }
 
 func (s *StoreEntry) DiseaseListByIds(ctx context.Context, ids []int32) ([]*model.Disease, error) {

+ 1 - 1
module/consumer/consumer.go

@@ -52,6 +52,6 @@ func (entry *Entry) DayWorkOrder(ctx context.Context, t *asynq.Task) error {
 	if err := entry.DB.Create(workOrderSubList).Error; err != nil {
 		zaplog.Error("consumer", zap.Any("mark", "DayWorkOrder"), zap.Any("NewWorkOrderSub", err))
 	}
-	zaplog.Error("consumer", zap.Any("DayWorkOrder", "success"))
+	zaplog.Info("consumer", zap.Any("DayWorkOrder", "success"))
 	return nil
 }