Browse Source

Merge branch 'feature/new-scheduled' of baishaojie/tmrgo into master

baishaojie 10 months ago
parent
commit
652673c0ff
60 changed files with 2852 additions and 701 deletions
  1. 18 17
      .drone-bak.yml
  2. 9 8
      Dockerfile
  3. BIN
      KPTAdmin64.exe
  4. 1 1
      Makefile
  5. 4 4
      conf/app-develop.ini
  6. 21 17
      conf/app.ini
  7. 2 1
      conf/setting/setting.go
  8. BIN
      dist/favicon.ico
  9. 0 0
      dist/index.html
  10. 0 0
      dist/static/css/app.005b8c7f.css
  11. 0 0
      dist/static/css/chunk-elementUI.c1c3b808.css
  12. 0 0
      dist/static/css/chunk-libs.f403b559.css
  13. BIN
      dist/static/fonts/element-icons.535877f5.woff
  14. BIN
      dist/static/fonts/element-icons.732389de.ttf
  15. BIN
      dist/static/img/404.a57b6f31.png
  16. BIN
      dist/static/img/404_cloud.0f4bc32b.png
  17. 28 0
      dist/static/img/iconfont.7d9f8392.svg
  18. BIN
      dist/static/img/logo.afed751a.png
  19. BIN
      dist/static/img/logo1.0121925c.png
  20. BIN
      dist/static/img/logo_u3.3c77f543.png
  21. BIN
      dist/static/img/nlogin-bg1.77301f56.jpg
  22. BIN
      dist/static/img/row-bg3.b3be7548.png
  23. BIN
      dist/static/img/topBg.69ecd1e1.png
  24. 0 0
      dist/static/js/app.a193431d.js
  25. 0 0
      dist/static/js/chunk-218b9b2f.443d0c85.js
  26. 0 0
      dist/static/js/chunk-52ecc0ac.ba542cb9.js
  27. 0 0
      dist/static/js/chunk-5c4dc4a9.9bfbd7f4.js
  28. 0 0
      dist/static/js/chunk-b702d234.fadfa57f.js
  29. 0 0
      dist/static/js/chunk-elementUI.c961dc79.js
  30. 0 0
      dist/static/js/chunk-libs.90e56fea.js
  31. 3 2
      go.mod
  32. 4 115
      go.sum
  33. 230 101
      http/handle/api/chart.go
  34. 6 0
      http/handle/api/grfdApi.go
  35. 133 93
      http/handle/api/mqtt.go
  36. 54 0
      http/handle/api/new_api.go
  37. 1103 146
      http/handle/api/ops.go
  38. 274 0
      http/handle/api/pusher.go
  39. 167 9
      http/handle/api/report.go
  40. 99 69
      http/handle/api/scheduled.go
  41. 0 1
      http/handle/api/spillage.go
  42. 4 0
      http/handle/api/upload.go
  43. 5 2
      http/handle/api/user.go
  44. 223 114
      http/handle/gm/udservice.go
  45. 29 0
      http/routers/app_api.go
  46. 2 0
      http/routers/new_api.go
  47. 2 1
      migration/v0001_feedtemplet.sql
  48. 153 0
      migration/v0002_yq_bar.sql
  49. 52 0
      models/tmr_gear.go
  50. 131 0
      module/sheep.go
  51. 84 0
      service/sheep/tmr_gear.go
  52. 4 0
      service/user_service/user.go
  53. BIN
      uploads/file/导入导出模板/栏舍生产/配方干物质导入模板.xlsx
  54. BIN
      uploads/file/导入导出模板/栏舍生产/配方干物质导出模板.xlsx
  55. BIN
      uploads/file/导入导出模板/配方计划/栏舍配方导入模板.xlsx
  56. BIN
      uploads/file/导入导出模板/配方计划/栏舍配方导出模板.xlsx
  57. BIN
      uploads/file/导入导出模板/配方计划/配方模板导入模板.xlsx
  58. BIN
      uploads/file/导入导出模板/配方计划/配方模板导出模板.xlsx
  59. 3 0
      win32.bat
  60. 4 0
      win64.bat

+ 18 - 17
.drone.yml → .drone-bak.yml

@@ -1,18 +1,10 @@
 kind: pipeline
 type: docker
-name: kpt-tmr
+name: test
 
-clone:
-  depth: 1
-  disable: true
 steps:
-  - name: clone
-    image: alpine/git
-    commands:
-     - git clone -b develop http://192.168.1.8:3000/baishaojie/tmrgo.git
-     - cp -R tmrgo/* ./
   - name: build
-    image: plugins/docker:20.14.2
+    image: plugins/docker
     volumes:
       - name: hosts
         path: /etc/hosts
@@ -21,23 +13,32 @@ steps:
       - name: docker-sock
         path: /var/run/docker.sock
     settings:
-      dockerfile: /drone/src/tmrgo/Dockerfile
+      dockerfile: /drone/src/Dockerfile
       username:
         from_secret: aliyun_name
       password:
         from_secret: aliyun_password
-      repo: registry.cn-hangzhou.aliyuncs.com/kpt-event/kpt-tmr
+      repo: registry.cn-hangzhou.aliyuncs.com/kpt-event/kpt-tmr-sheep
       registry: registry.cn-hangzhou.aliyuncs.com
-      tags: [ 1.0.3,latest ]
-
+      tags: [test]
+  - name: ssh commands
+    image: appleboy/drone-ssh
+    settings:
+      host: 192.168.1.70
+      username: tmrwatch
+      password:
+        from_secret: ssh_password
+      port: 22
+      script:
+        - cd /data/docker-compose/kpt-tmr-sheep/
+        - echo "123456" | ./restart.sh
 trigger:
   branch:
     include:
-      - develop
+      - feature/*
   event:
     include:
       - push
-
 volumes:
   - name: host
     host:
@@ -47,4 +48,4 @@ volumes:
       path: /ect/docker
   - name: docker-sock
     host:
-      path: /var/run/docker.sock
+      path: /var/run/docker.sock

+ 9 - 8
Dockerfile

@@ -1,6 +1,6 @@
 FROM golang:1.17-alpine as build
 
-WORKDIR /app/kpt-tmr
+WORKDIR /app/kpt-tmr-sheep
 
 COPY . .
 
@@ -11,24 +11,25 @@ RUN go env -w GO111MODULE=on && \
     go env -w CGO_ENABLED=0 && \
     go env -w GOARCH=amd64 && \
     go env -w GOOS=linux && \
-    go build -o ./bin/kptTmr -ldflags "-X kpt.kptyun.cn:3000/kpt-event/kpt-tmr/pod.appVersion=tmr" main.go
+    go build -o ./bin/kptTmrSheep -ldflags "-X kpt.kptyun.cn:3000/kpt-event/kpt-tmr-sheep/pod.appVersion=tmr" main.go
 
 
 FROM alpine:latest
-LABEL name="kpt-tmr" \
+LABEL name="kpt-tmr-sheep" \
 description="pt service" \
 owner="yiping.xu"
 
-WORKDIR /app/kpt-tmr
+WORKDIR /app/kpt-tmr-sheep
 
 RUN apk update && apk add tzdata
 RUN ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
 && echo "Asia/Shanghai" > /etc/timezone \
 
-COPY --from=0 /app/kpt-tmr/conf/ /app/kpt-tmr/bin/conf/
-COPY --from=0  /app/kpt-tmr/bin/kptTmr /app/kpt-tmr/bin/kptTmr
+COPY --from=0 /app/kpt-tmr-sheep/conf/ /app/kpt-tmr-sheep/bin/conf/
+COPY --from=0 /app/kpt-tmr-sheep/uploads /app/kpt-tmr-sheep/bin/uploads
+COPY --from=0  /app/kpt-tmr-sheep/bin/kptTmr /app/kpt-tmr-sheep/bin/kptTmr
 
 EXPOSE 8081
-VOLUME ["/app/kpt-tmr/logger","/app/kpt-tmr/bin/conf/"]
+VOLUME ["/app/kpt-tmr-sheep/logger","/app/kpt-tmr-sheep/bin/conf/"]
 
-CMD ["/app/kpt-tmr/bin/kptTmr"]
+CMD ["/app/kpt-tmr-sheep/bin/kptTmrSheep"]

BIN
KPTAdmin64.exe


+ 1 - 1
Makefile

@@ -18,4 +18,4 @@ lint:
 build:
 	rm -rf bin
 	mkdir -p bin
-	GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build -o bin/kptTmr -ldflags "-X kpt.kptyun.cn:3000/kpt-event/kpt-tmr/pod.appVersion=${version}" main.go
+	GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build -o bin/kptTmrSheep -ldflags "-X kpt.kptyun.cn:3000/kpt-event/kpt-tmr-sheep/pod.appVersion=${version}" main.go

+ 4 - 4
conf/app-develop.ini

@@ -21,7 +21,7 @@ TimeFormat = 20060102-150405
 #debug or release
 #RunMode = debug
 RunMode = release
-HttpPort = 8082
+HttpPort = 8081
 ReadTimeout = 60
 WriteTimeout = 60
 NoAuth = 1
@@ -41,9 +41,9 @@ Description = tmrgo
 [database]
 Type = mysql
 User = root
-Password = 123456
-Host = 192.168.1.70:3306
-Name = tmrwatch2
+Password = root
+Host = 192.168.1.93:3326
+Name = yq
 TablePrefix =
 
 ShowXormlog = false

+ 21 - 17
conf/app.ini

@@ -19,9 +19,9 @@ TimeFormat = 20060102-150405
 
 [server]
 #debug or release
-#RunMode = debug
+#RunMode = debuggit 
 RunMode = release
-HttpPort = 8082
+HttpPort = 80
 ReadTimeout = 60
 WriteTimeout = 60
 NoAuth = 1
@@ -37,6 +37,7 @@ KeyPath = conf/ssl.key
 ServerName = tmrgo
 DisplayName = tmrgo
 Description = tmrgo
+UDForwardingSvc = "http://127.0.0.1"
 
 # 对接
 GRFD = 1
@@ -47,8 +48,8 @@ Type = mysql
 User = root
 Password = root
 #Host = 8.130.17.8:3306
-#Host = 192.168.1.93:3326
-Host = 127.0.0.1:3316
+Host = 192.168.1.93:3326
+#Host = 127.0.0.1:3316
 #Name = haiyuan
 #Password = root
 #Password = root
@@ -57,13 +58,13 @@ Host = 127.0.0.1:3316
 #Password = root123456
 #Password = keep
 
-#Password = kptzhu@163.com
+
 #Password = kpt123456*
 #Password = kepaiteng!QAZ
 #Host = 47.92.52.73:3306
 #Host = 127.0.0.1:3306
 #Host = 210.16.186.252:3326
-
+#Password = kptzhu@163.com
 #Host = 210.16.186.252:3326
 #Host = 127.0.0.1:3309
 #Name = equipment
@@ -72,7 +73,7 @@ Host = 127.0.0.1:3316
 #Name = tmrgo
 #Password = kepaiteng!QAZ
 #Host = 222.73.129.15:31306
-Name = tmrwatch2
+Name = bmsm8
 TablePrefix =
 
 ShowXormlog = false
@@ -82,7 +83,7 @@ CacheApiSql = false
 
 [sqlserver]
 #Host = "sqlserver://sa:Password@@localhost?database=SysData&connection+timeout=30"
-##张北乐源
+##张北乐源 
 Host = 
 User = 
 Password = 
@@ -90,11 +91,12 @@ Name =
 
 
 [yyn]
-FarmId = ""
-ProductKey = ""
-DeviceName = ""
-DeviceSecret = ""
-HeartBeat = ""
+FarmId = "1830004776"
+ProductKey = "k03txxLKFae"
+DeviceName = "04776_p_breed"
+DeviceSecret = "e1fdb50556b13afe896e738fdcb25bf3"
+HeartBeat = "Tmr183000477604776_p_breed"
+
 
 [comm]
 PortName =
@@ -105,10 +107,12 @@ ParityMode = 0    #PARITY_NONE  0	PARITY_ODD  1	PARITY_EVEN  2
 InterCharacterTimeout = 100
 MinimumReadSize = 0
 
-
-
-
-
+; product_key =k03txxLKFae device_name =4623_p_breed 
+; device_secret =d06ababb2b10ba25bca3041e35ac604d
+;  host = iot-010a5xth.mqtt.iothub.aliyuncs.com 
+;  farmId=1830004623 
+;  heartBeat=18300046234623_p_breed 
+;  TopicName=/k03txxLKFae/4623_p_breed/user/heatwatch/tmrBreed/post
 
 
 

+ 2 - 1
conf/setting/setting.go

@@ -73,6 +73,7 @@ type Server struct {
 	Description      string
 	GRFD             string
 	GRFDURL          string
+	UDForwardingSvc  string
 }
 
 type Database struct {
@@ -114,7 +115,7 @@ func Setup() {
 	switch appEnv {
 	case "test":
 		cfg, err = ini.Load(CurrentPath + "conf/app-test.ini")
-	case "develop":
+	case "development":
 		cfg, err = ini.Load(CurrentPath + "conf/app-develop.ini")
 	default:
 		cfg, err = ini.Load(CurrentPath + "conf/app.ini")

BIN
dist/favicon.ico


File diff suppressed because it is too large
+ 0 - 0
dist/index.html


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.005b8c7f.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/chunk-elementUI.c1c3b808.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/chunk-libs.f403b559.css


BIN
dist/static/fonts/element-icons.535877f5.woff


BIN
dist/static/fonts/element-icons.732389de.ttf


BIN
dist/static/img/404.a57b6f31.png


BIN
dist/static/img/404_cloud.0f4bc32b.png


File diff suppressed because it is too large
+ 28 - 0
dist/static/img/iconfont.7d9f8392.svg


BIN
dist/static/img/logo.afed751a.png


BIN
dist/static/img/logo1.0121925c.png


BIN
dist/static/img/logo_u3.3c77f543.png


BIN
dist/static/img/nlogin-bg1.77301f56.jpg


BIN
dist/static/img/row-bg3.b3be7548.png


BIN
dist/static/img/topBg.69ecd1e1.png


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.a193431d.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-218b9b2f.443d0c85.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-52ecc0ac.ba542cb9.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-5c4dc4a9.9bfbd7f4.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-b702d234.fadfa57f.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-elementUI.c961dc79.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-libs.90e56fea.js


+ 3 - 2
go.mod

@@ -3,7 +3,7 @@ module tmr-watch
 go 1.16
 
 require (
-	gitee.com/xuyiping_admin/go_proto v0.0.0-20231020024751-e01ca61df346
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20240418053639-07f97848df89
 	gitee.com/xuyiping_admin/pkg v0.0.0-20230816061144-c1f079802584
 	github.com/360EntSecGroup-Skylar/excelize v1.4.1
 	github.com/Anderson-Lu/gofasion v0.0.0-20190530065914-6a05b679ee48
@@ -44,8 +44,9 @@ require (
 	github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4 // indirect
 	github.com/bndr/gotabulate v1.1.2 // indirect
 	github.com/clbanning/mxj v1.8.4 // indirect
+	github.com/qichengzx/coordtransform v0.0.0-20220708113031-010878418826
 	github.com/recoilme/pudge v1.0.3 // indirect
+	github.com/syndtr/goleveldb v1.0.0 // indirect
 	github.com/xormplus/builder v0.0.0-20200331055651-240ff40009be // indirect
 	gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4 // indirect
-	xorm.io/xorm v1.3.4 // indirect
 )

+ 4 - 115
go.sum

@@ -724,10 +724,9 @@ gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zum
 git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc=
 gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
 gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
-gitee.com/travelliu/dm v1.8.11192/go.mod h1:DHTzyhCrM843x9VdKVbZ+GKXGRbKM2sJ4LxihRxShkE=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20230802054950-77dee3d12065/go.mod h1:cxbPefIf1o+cyQwvFaM3ndaoUeaK5aWzPV/eZQGJPgE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20231020024751-e01ca61df346 h1:XZR4WvMVxk6fNbraGsReW7onWxR5O6TMLTAmPWnphm8=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20231020024751-e01ca61df346/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240418053639-07f97848df89 h1:dTMfNlgg0JslPWpWusZcV6aRN1dQAGHnVEELS1/XcoQ=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240418053639-07f97848df89/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
 gitee.com/xuyiping_admin/pkg v0.0.0-20230816061144-c1f079802584 h1:5RE5yrMMvnDITrnoX821mFl7dNYfsFA1osDobUV/TDo=
 gitee.com/xuyiping_admin/pkg v0.0.0-20230816061144-c1f079802584/go.mod h1:VQ7WztVDQRlXE1dUu/Yqo3ZdhKsfv7IGJtV+vqNqJVw=
 github.com/360EntSecGroup-Skylar/excelize v1.4.1 h1:l55mJb6rkkaUzOpSsgEeKYtS6/0gHwBYyfo5Jcjv/Ks=
@@ -755,7 +754,6 @@ github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1
 github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
 github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
 github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
-github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
 github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM=
 github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
@@ -838,11 +836,8 @@ github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F
 github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
 github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
 github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
-github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY=
 github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
-github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic=
 github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
-github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
 github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
 github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
@@ -861,13 +856,10 @@ github.com/cncf/xds/go v0.0.0-20220314180256-7f1daf1720fc/go.mod h1:eXthEFrGJvWH
 github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
 github.com/cncf/xds/go v0.0.0-20230310173818-32f1caf87195/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
 github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
-github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
 github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
 github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
 github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
 github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
-github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
-github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
 github.com/couchbase/go-couchbase v0.0.0-20181122212707-3e9b6e1258bb/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
 github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
 github.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
@@ -875,7 +867,6 @@ github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:sr
 github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
 github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
 github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
-github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
 github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
 github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
 github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -1027,13 +1018,11 @@ github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg78
 github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
 github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
 github.com/gobwas/ws v1.1.0/go.mod h1:nzvNcVha5eUziGrbxFCo6qFIojQHjJV5cLYIbezhfL0=
-github.com/goccy/go-json v0.8.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
 github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
 github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
 github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
 github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
 github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
-github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
 github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
 github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
 github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
@@ -1080,7 +1069,6 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg
 github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
 github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
 github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
-github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
 github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
 github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
 github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
@@ -1129,7 +1117,6 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLe
 github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
 github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
 github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
-github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
 github.com/google/s2a-go v0.1.0/go.mod h1:OJpEgntRZo8ugHpF9hkoLJbS5dSI20XZeXJ9JVywLlM=
 github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
@@ -1185,51 +1172,11 @@ github.com/iancoleman/strcase v0.1.1/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5N
 github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
 github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
-github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
 github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
 github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
 github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0=
 github.com/iris-contrib/httpexpect/v2 v2.12.1/go.mod h1:7+RB6W5oNClX7PTwJgJnsQP3ZuUUYB3u61KCqeSgZ88=
 github.com/iris-contrib/schema v0.0.6/go.mod h1:iYszG0IOsuIsfzjymw1kMzTL8YQcCWlm65f3wX8J5iA=
-github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
-github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
-github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
-github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
-github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
-github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s=
-github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
-github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
-github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
-github.com/jackc/pgconn v1.14.0/go.mod h1:9mBNlny0UvkgJdCDvdVHYSjI+8tD2rnKK69Wz8ti++E=
-github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
-github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
-github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c=
-github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
-github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
-github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
-github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
-github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
-github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
-github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
-github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
-github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
-github.com/jackc/pgproto3/v2 v2.3.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
-github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
-github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
-github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
-github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
-github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
-github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
-github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
-github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
-github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
-github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
-github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
-github.com/jackc/pgx/v4 v4.18.0/go.mod h1:FydWkUyadDmdNH/mHnGob881GawxeEm7TcMCzkb+qQE=
-github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
-github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
-github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
-github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
 github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4 h1:G2ztCwXov8mRvP0ZfjE6nAlaCX2XbykaeHdbT6KwDz0=
 github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4/go.mod h1:2RvX5ZjVtsznNZPEt4xwJXNJrM3VTZoQf7V6gk0ysvs=
 github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
@@ -1278,7 +1225,6 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02
 github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
 github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
-github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
@@ -1288,7 +1234,6 @@ github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NB
 github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
 github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
 github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
-github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
@@ -1305,11 +1250,7 @@ github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECae
 github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ=
 github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw=
 github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
-github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
 github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
-github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
-github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
-github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
 github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
 github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
 github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
@@ -1325,12 +1266,9 @@ github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
 github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
 github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs=
-github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
-github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
 github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
 github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
 github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
-github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
 github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
 github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
 github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
@@ -1343,7 +1281,6 @@ github.com/mattn/go-sqlite3 v1.6.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOq
 github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
 github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
 github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
-github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
 github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
 github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
 github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
@@ -1482,6 +1419,8 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1
 github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
 github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
 github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
+github.com/qichengzx/coordtransform v0.0.0-20220708113031-010878418826 h1:xRzV3Mycb7VUY9QSs03UZbmgf7Og7RHEwF2zaHGyTXg=
+github.com/qichengzx/coordtransform v0.0.0-20220708113031-010878418826/go.mod h1:hrRiFtqNSi8E6C+3JsbPGjtCfyS9QFz90IORo3H6mts=
 github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
 github.com/recoilme/pudge v1.0.3 h1:h/9dEv5fRqtzM4lnO69kUoN+k7ukxxrW9NGb9ug0grM=
 github.com/recoilme/pudge v1.0.3/go.mod h1:VMvxBLVkrSStldckzCsETBXox3pfovfrnEchafXk8qA=
@@ -1498,25 +1437,18 @@ github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6po
 github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
 github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
 github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
-github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
-github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
-github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
 github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
 github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
 github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk=
 github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U=
-github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
 github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g=
 github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
 github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
 github.com/shirou/gopsutil/v3 v3.23.2/go.mod h1:gv0aQw33GLo3pG8SiWKiQrbDzbRY1K80RyZJ7V4Th1M=
-github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
-github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
-github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
 github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
 github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
@@ -1524,7 +1456,6 @@ github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKz
 github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=
 github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
 github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
-github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
 github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
 github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
@@ -1548,7 +1479,6 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM
 github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
 github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
 github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
 github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
@@ -1574,7 +1504,6 @@ github.com/swaggo/swag v1.6.2/go.mod h1:YyZstMc22WYm6GEDx/CYWxq+faBbjQ5EqwQcrjRE
 github.com/swaggo/swag v1.16.1 h1:fTNRhKstPKxcnoKsytm4sahr8FaYzUcT7i1/3nd/fBg=
 github.com/swaggo/swag v1.16.1/go.mod h1:9/LMvHycG3NFHfR6LwvikHv5iFvmPADQ359cKikGxto=
 github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
-github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c h1:3eGShk3EQf5gJCYW+WzA0TEJQd37HLOmlYF7N0YJwv0=
 github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
 github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
 github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
@@ -1637,8 +1566,6 @@ github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29Xrm
 github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
 github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
 github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
-github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
-github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
 go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
 go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
 go.etcd.io/gofail v0.1.0/go.mod h1:VZBCXYGZhHAinaBiiqYvuDynvahNsAyLFwB3kEHKz1M=
@@ -1654,10 +1581,6 @@ go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
 go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
 go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
 go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
-go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
-go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
-go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
-go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
 go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
 go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
 go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU=
@@ -1665,15 +1588,8 @@ go.uber.org/dig v1.17.0/go.mod h1:rTxpf7l5I0eBTlE6/9RL+lDybC7WFwY2QH55ZSjy1mU=
 go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
 go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
 go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
-go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
-go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
-go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
 go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
 go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
-go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
-go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
-go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
-go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
 go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
 go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
 go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
@@ -1685,17 +1601,14 @@ golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85/go.mod h1:6SG95UA2DQfeDnf
 golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
 golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
 golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
 golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
-golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
@@ -1706,7 +1619,6 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0
 golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
 golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
 golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
-golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
 golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
 golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
 golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
@@ -1792,7 +1704,6 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL
 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -1908,7 +1819,6 @@ golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5h
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1918,7 +1828,6 @@ golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1989,7 +1898,6 @@ golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -2016,7 +1924,6 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
 golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -2061,7 +1968,6 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3
 golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
-golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
@@ -2070,12 +1976,9 @@ golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgw
 golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
@@ -2084,7 +1987,6 @@ golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtn
 golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
@@ -2130,8 +2032,6 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
 golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
 golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=
 golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
-golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -2455,7 +2355,6 @@ gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4/go.mod h1:bJkYqV5pg
 gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
 gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
 gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
-gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
 gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
 gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
@@ -2494,12 +2393,10 @@ modernc.org/cc/v3 v3.36.0/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
 modernc.org/cc/v3 v3.36.2/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
 modernc.org/cc/v3 v3.36.3/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
 modernc.org/cc/v3 v3.37.0/go.mod h1:vtL+3mdHx/wcj3iEGz84rQa8vEqR6XM84v5Lcvfph20=
-modernc.org/cc/v3 v3.38.1/go.mod h1:vtL+3mdHx/wcj3iEGz84rQa8vEqR6XM84v5Lcvfph20=
 modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0=
 modernc.org/ccgo/v3 v3.0.0-20220428102840-41399a37e894/go.mod h1:eI31LL8EwEBKPpNpA4bU1/i+sKOwOrQy8D87zWUcRZc=
 modernc.org/ccgo/v3 v3.0.0-20220430103911-bc99d88307be/go.mod h1:bwdAnOoaIt8Ax9YdWGjxWsdkPcZyRPHqrOvJxaKAKGw=
 modernc.org/ccgo/v3 v3.0.0-20220904174949-82d86e1b6d56/go.mod h1:YSXjPL62P2AMSxBphRHPn7IkzhVHqkvOnRKAKh+W6ZI=
-modernc.org/ccgo/v3 v3.0.0-20220910160915-348f15de615a/go.mod h1:8p47QxPkdugex9J4n9P2tLZ9bK01yngIVp00g4nomW0=
 modernc.org/ccgo/v3 v3.16.4/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ=
 modernc.org/ccgo/v3 v3.16.6/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ=
 modernc.org/ccgo/v3 v3.16.8/go.mod h1:zNjwkizS+fIFDrDjIAgBSCLkWbJuHF+ar3QRn+Z9aws=
@@ -2517,7 +2414,6 @@ modernc.org/libc v1.17.0/go.mod h1:XsgLldpP4aWlPlsjqKRdHPqCxCjISdHfM/yeWC5GyW0=
 modernc.org/libc v1.17.1/go.mod h1:FZ23b+8LjxZs7XtFMbSzL/EhPxNbfZbErxEHc7cbD9s=
 modernc.org/libc v1.17.4/go.mod h1:WNg2ZH56rDEwdropAJeZPQkXmDwh+JCA1s/htl6r2fA=
 modernc.org/libc v1.18.0/go.mod h1:vj6zehR5bfc98ipowQOM2nIDUZnVew/wNC/2tOGS+q0=
-modernc.org/libc v1.19.0/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0=
 modernc.org/libc v1.20.3/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0=
 modernc.org/libc v1.21.4/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI=
 modernc.org/libc v1.22.2/go.mod h1:uvQavJ1pZ0hIoC/jfqNoMLURIMhKzINIWypNM17puug=
@@ -2534,24 +2430,17 @@ modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
 modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
 modernc.org/sqlite v1.18.1/go.mod h1:6ho+Gow7oX5V+OiOQ6Tr4xeqbx13UZ6t+Fw9IRUG4d4=
 modernc.org/sqlite v1.18.2/go.mod h1:kvrTLEWgxUcHa2GfHBQtanR1H9ht3hTJNtKpzH9k1u0=
-modernc.org/sqlite v1.20.4/go.mod h1:zKcGyrICaxNTMEHSr1HQ2GUraP0j+845GYw37+EyT6A=
 modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
 modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw=
 modernc.org/tcl v1.13.1/go.mod h1:XOLfOwzhkljL4itZkK6T72ckMgvj0BDsnKNdZVUOecw=
 modernc.org/tcl v1.13.2/go.mod h1:7CLiGIPo1M8Rv1Mitpv5akc2+8fxUd2y2UzC/MfMzy0=
-modernc.org/tcl v1.15.0/go.mod h1:xRoGotBZ6dU+Zo2tca+2EqVEeMmOUBzHnhIwq4YrVnE=
 modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
 modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
 modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
 modernc.org/z v1.5.1/go.mod h1:eWFB510QWW5Th9YGZT81s+LwvaAs3Q2yr4sP0rmLkv8=
-modernc.org/z v1.7.0/go.mod h1:hVdgNMh8ggTuRG1rGU8x+xGRFfiQUIAw0ZqlPy8+HyQ=
 moul.io/http2curl/v2 v2.3.0/go.mod h1:RW4hyBjTWSYDOxapodpNEtX0g5Eb16sxklBqmd2RHcE=
 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
 rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
 rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
 sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
-xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 h1:bvLlAPW1ZMTWA32LuZMBEGHAUOcATZjzHcotf3SWweM=
-xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
-xorm.io/xorm v1.3.4 h1:vWFKzR3DhGUDl5b4srhUjhDwjxkZAc4C7BFszpu0swI=
-xorm.io/xorm v1.3.4/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo=

+ 230 - 101
http/handle/api/chart.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"io/ioutil"
 	"net/http"
+	"sort"
 	"strconv"
 	"time"
 
@@ -26,55 +27,33 @@ func GetFeedEffMR(c *gin.Context) {
 	startDate := parammaps.Get("startTime").ValueStr()
 	endDate := parammaps.Get("stopTime").ValueStr()
 	pastureId := parammaps.Get("pastureid").ValueStr()
+	bigcowclass := parammaps.Get("bigcowclass").ValueStr()
 
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
-	var sqlStr = `SELECT ROUND(IFNULL(SUM(d2.actualweightminus
-		* (SELECT AVG(actweight) FROM ftdry fd WHERE fd.pastureid = d2.pastureid AND fd.barid = d2.fbarid
-		AND fd.operatetime = (SELECT MAX(operatetime) FROM ftdry fd1 WHERE fd1.pastureid =  d2.pastureid
-		AND fd1.barid = d2.fbarid AND fd1.operatetime <=d2.date ))
-		),0),2) field1,
-		ROUND(IFNULL(
-		(SELECT SUM(bm.product*bm.cowsum) FROM
-		(SELECT DISTINCT d21.fbarid,d21.date,d21.pastureid,d21.fname,IFNULL(d21.cowclassid,-1)cowclassid FROM
-		downloadedplan d1
-		JOIN downloadplandtl2 d21
-		ON d21.pastureid = d1.pastureid AND d21.pid = d1.id
-		WHERE   d1.mydate between ? and ? AND d1.pastureid =? AND d1.lpplantype IN (0,1,2,5) AND d21.type = 0
-		) ww
-		LEFT JOIN barmilk bm
-		ON bm.pastureid =ww.pastureid AND bm.barid = ww.fbarid AND bm.productdate
-		=
-		(
-		SELECT MAX(productdate) FROM barmilk
-		WHERE barmilk.productdate <= ww.date
-		AND barmilk.pastureid = ww.pastureid
-		AND barmilk.barid = ww.fbarid
-		)
-		WHERE  ww.date = d.mydate and bm.bigcowclass = '泌乳牛'
-		)
-		,0),2) field2, -- 产奶量
-		%s 日期
-		FROM
-		 downloadedplan d
-		LEFT JOIN downloadplandtl2 d2
-		ON d2.pastureid = d.pastureid AND d2.pid = d.id
-	
-		LEFT JOIN barmilk bm
-		ON bm.pastureid =d.pastureid AND bm.barid = d2.fbarid AND bm.productdate =
-		(SELECT MAX(productdate) FROM barmilk WHERE barmilk.productdate <=d.mydate 
-		AND barmilk.pastureid = d.pastureid AND  barmilk.barid = d2.fbarid)
-	
-		WHERE d.pastureid = ? AND d.mydate BETWEEN ? AND ? AND d.lpplantype IN (0,1,2,5) AND d2.type = 0
-		AND bm.bigcowclass = '泌乳牛'`
+	var sqlStr = `SELECT 		ROUND(IFNULL(SUM((select sum(actualweightminus) from downloadplandtl2  where fbarid = d.barid  and date = d.date)
+	* (SELECT AVG(actweight) FROM ftdry fd WHERE fd.pastureid = d.pastureid AND fd.barid = d.barid
+	AND fd.operatetime = (SELECT MAX(operatetime) FROM ftdry fd1 WHERE fd1.pastureid =  d.pastureid
+	AND fd1.barid = d.barid AND fd1.operatetime <=d.date ))
+	),0),2) field1,
+round( sum(ifnull(bm.product*bm.cowsum,0)),2) field2, -- 产奶量
+%s 日期,(select tname from feedtempletdate  where date = d.date and id = d.ftid) 名称
+	FROM
+	 feedpdate d
+	join feedtempletdate  ftd on d.ftid = ftd.id and ftd.date = d.date
+	LEFT JOIN barmilk bm
+	ON bm.pastureid =d.pastureid AND bm.barid = d.barid AND bm.productdate = d.date
+	join cowclass cc on cc.id = bm.cowclassid 
+	WHERE  d.date BETWEEN ? AND ?  and d.pastureid = ?
+and (cc.classname = ? or ? = '' )  `
 
 	var data []map[string]interface{}
 	var err error
 	if status == "0" {
-		sqlStr = fmt.Sprintf(sqlStr, " DATE_FORMAT(d.mydate, '%Y-%m-%d') ")
-		sqlStr += " GROUP BY DATE_FORMAT(d.mydate, '%Y-%m-%d')  ORDER BY  d.mydate "
-		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId, pastureId, startDate, endDate).Query().List()
+		sqlStr = fmt.Sprintf(sqlStr, " DATE_FORMAT(d.date, '%Y-%m-%d') ")
+		sqlStr += " GROUP BY  d.ftid,DATE_FORMAT(d.date, '%Y-%m-%d')  ORDER BY   d.date ,d.ftid"
+		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId, bigcowclass, bigcowclass).Query().List()
 		if err != nil {
 			logs.Error(sqlName, " : ", err)
 			appG.Response(http.StatusInternalServerError, e.ERROR, err)
@@ -90,19 +69,19 @@ func GetFeedEffMR(c *gin.Context) {
 			week = int(start.Weekday()) - 1
 		}
 
-		sqlStr = fmt.Sprintf(sqlStr, "FLOOR( (( DATEDIFF(mydate,'"+startDate+"') +"+strconv.Itoa(week)+")/7)+1)")
-		sqlStr += " GROUP BY 日期  ORDER BY  d.mydate "
-		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId, pastureId, startDate, endDate).Query().List()
+		sqlStr = fmt.Sprintf(sqlStr, "FLOOR( (( DATEDIFF(d.date,'"+startDate+"') +"+strconv.Itoa(week)+")/7)+1)")
+		sqlStr += " GROUP BY  d.ftid,日期  ORDER BY  d.ftid, d.date "
+		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId, bigcowclass, bigcowclass).Query().List()
 		if err != nil {
 			logs.Error(sqlName, " : ", err)
 			appG.Response(http.StatusInternalServerError, e.ERROR, err)
 		}
 
 	} else {
-		sqlStr = fmt.Sprintf(sqlStr, " DATE_FORMAT(d.mydate, '%Y-%m') ")
-		sqlStr += " GROUP BY MONTH(d.mydate)  ORDER BY  d.mydate "
+		sqlStr = fmt.Sprintf(sqlStr, " DATE_FORMAT(d.date, '%Y-%m') ")
+		sqlStr += " GROUP BY  d.ftid,MONTH(d.date)  ORDER BY   d.ftid,d.date "
 
-		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId, pastureId, startDate, endDate).Query().List()
+		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId, bigcowclass, bigcowclass).Query().List()
 		if err != nil {
 			logs.Error(sqlName, " : ", err)
 			appG.Response(http.StatusInternalServerError, e.ERROR, err)
@@ -110,7 +89,93 @@ func GetFeedEffMR(c *gin.Context) {
 
 	}
 
-	queryData, err := getAccuracyV2(data)
+	queryData := make(map[string]interface{}, 0)
+
+	// if status == "0" {
+	// dateMap := make(map[string]bool)
+	// ftMap := make(map[string]bool)
+	var ftname []string
+	var dates []string
+	for _, item := range data {
+		// dateMap[item["日期"].(string)] = true
+		// ftMap[item["名称"].(string)] = true
+		if len(ftname) == 0 {
+			ftname = append(ftname, item["名称"].(string))
+		}
+		if len(dates) == 0 {
+			dates = append(dates, item["日期"].(string))
+		}
+
+		dateExist := false
+		ftExist := false
+		for _, date := range dates {
+			if date == item["日期"].(string) {
+				dateExist = true
+				break
+			}
+		}
+		if !dateExist {
+			dates = append(dates, item["日期"].(string))
+		}
+
+		for _, tname := range ftname {
+			if tname == item["名称"].(string) {
+				ftExist = true
+				break
+			}
+		}
+		if !ftExist {
+			ftname = append(ftname, item["名称"].(string))
+		}
+
+	}
+
+	var dataArr1 []interface{}
+	var dataArr2 []interface{}
+	sort.Strings(dates)
+	for _, tname := range ftname {
+		var field1 []interface{}
+		var field2 []interface{}
+
+		for _, date := range dates {
+			exist := false
+			for _, item := range data {
+				if item["日期"].(string) == date && item["名称"].(string) == tname {
+					exist = true
+					field1 = append(field1, item["field1"])
+					field2 = append(field2, item["field2"])
+					break
+				}
+			}
+			if !exist {
+				field1 = append(field1, "0")
+				field2 = append(field2, 0)
+			}
+		}
+		dataArr1 = append(dataArr1, field1)
+		dataArr2 = append(dataArr2, field2)
+	}
+
+	for _, item := range data {
+		if _, ok := item["field1"]; ok {
+			item["采食量"] = item["field1"]
+		} else {
+			item["采食量"] = "0"
+		}
+		if _, ok := item["field2"]; ok {
+			item["产奶量"] = item["field2"]
+		} else {
+			item["产奶量"] = 0
+		}
+	}
+	queryData["dataArr1"] = dataArr1
+	queryData["dataArr2"] = dataArr2
+	queryData["date"] = dates
+	queryData["ftname"] = ftname
+	queryData["data"] = data
+	// }
+
+	// queryData, err := getAccuracyV2(data)
 	appG.Response(http.StatusOK, e.SUCCESS, queryData)
 }
 
@@ -208,28 +273,30 @@ func GetFeedEffSL(c *gin.Context) {
 	defer tx.Close()
 
 	var sqlStr = `SELECT 
-fp.barname 名称,
-IFNULL(SUM(d2.actualweightminus),0) 撒料量,
-IFNULL((SELECT SUM(remain) FROM barfeedremain bf WHERE bf.pastureid = fp.pastureid AND bf.barid = fp.barid AND bf.remaindate = fp.date),0) 剩料量,
-ifnull(ROUND(IFNULL((SELECT SUM(remain) FROM barfeedremain bf WHERE bf.pastureid = fp.pastureid AND bf.barid = fp.barid AND bf.remaindate = fp.date),0)/SUM(d2.actualweightminus),2) ,0)准确率, -- 剩料率
-%s 日期
-
-FROM 
-downloadedplan d
-JOIN downloadplandtl2 d2
-ON d2.pastureid = d.pastureid AND d2.pid = d.id
+	ft.tname  名称,
+	IFNULL(SUM(d2.actualweightminus),0) 撒料量,
+	IFNULL((SELECT SUM(remain) FROM barfeedremain bf WHERE bf.pastureid = ft.pastureid AND bf.barid = fp.barid AND bf.remaindate = fp.date),0) 剩料量,
+	ifnull(ROUND(IFNULL((SELECT SUM(remain) FROM barfeedremain bf WHERE bf.pastureid = fp.pastureid AND bf.barid = fp.barid AND bf.remaindate = fp.date),0)/SUM(d2.actualweightminus),2)*100 ,0)准确率,
+	%s 日期
+	
+	FROM 
+	downloadedplan d
+	JOIN downloadplandtl2 d2
+	ON d2.pastureid = d.pastureid AND d2.pid = d.id
 
-LEFT JOIN feedpdate fp
+	LEFT JOIN feedpdate fp
 on fp.barid  =  d2.fbarid and d.pastureid = fp.pastureid  AND d.mydate = fp.date 
+	join feedtempletdate  ft on ft.id = fp.ftid AND d.mydate = ft.date
 
-WHERE  d.mydate BETWEEN ? AND ?  AND  fp.pastureid = ? AND d.lpplantype IN (0,1,2,5) AND d2.type = 0`
+	WHERE  d.mydate BETWEEN  ? AND ? and d.pastureid = ? AND d.lpplantype IN (0,1,2,5) AND d2.type = 0 
+	   `
 
 	var data []map[string]interface{}
 	var err error
 	if status == "0" {
-		sqlStr = fmt.Sprintf(sqlStr, " DATE_FORMAT(fp.date, '%Y-%m-%d') ")
+		sqlStr = fmt.Sprintf(sqlStr, " DATE_FORMAT(ft.date, '%Y-%m-%d') ")
 
-		sqlStr += "  GROUP BY fp.barname , DATE_FORMAT(fp.date, '%Y-%m-%d')  ORDER BY  fp.barname ,fp.date "
+		sqlStr += "   GROUP BY fp.ftid, DATE_FORMAT(ft.date, '%Y-%m-%d')  ORDER BY  ft.tname ,ft.date "
 		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId).Query().List()
 		if err != nil {
 			logs.Error(sqlName, " : ", err)
@@ -248,9 +315,9 @@ WHERE  d.mydate BETWEEN ? AND ?  AND  fp.pastureid = ? AND d.lpplantype IN (0,1,
 			week = int(start.Weekday()) - 1
 		}
 
-		sqlStr = fmt.Sprintf(sqlStr, "FLOOR( ((DATEDIFF(fp.date,'"+startDate+"') +"+strconv.Itoa(week)+")/7)+1)")
+		sqlStr = fmt.Sprintf(sqlStr, "FLOOR( ((DATEDIFF(ft.date,'"+startDate+"') +"+strconv.Itoa(week)+")/7)+1)")
 
-		sqlStr += "  GROUP BY fp.barname , 日期 ORDER BY  fp.barname ,fp.date "
+		sqlStr += "  GROUP BY fp.ftid , 日期 ORDER BY  ft.tname ,ft.date "
 		fmt.Println(sqlStr)
 		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId).Query().List()
 		if err != nil {
@@ -261,8 +328,8 @@ WHERE  d.mydate BETWEEN ? AND ?  AND  fp.pastureid = ? AND d.lpplantype IN (0,1,
 		// appG.Response(http.StatusOK, e.SUCCESS, data)
 	} else {
 
-		sqlStr = fmt.Sprintf(sqlStr, " DATE_FORMAT(fp.date, '%Y-%m') ")
-		sqlStr += "  GROUP BY fp.barname , DATE_FORMAT(fp.date, '%Y-%m') ORDER BY  fp.barname ,fp.date "
+		sqlStr = fmt.Sprintf(sqlStr, " DATE_FORMAT(ft.date, '%Y-%m') ")
+		sqlStr += "  GROUP BY fp.ftid , DATE_FORMAT(ft.date, '%Y-%m') ORDER BY  ft.tname ,ft.date "
 
 		// timeTemplate := "2006-01-02"
 		// end, _ := time.ParseInLocation(timeTemplate, endDate, time.Local)
@@ -276,8 +343,13 @@ WHERE  d.mydate BETWEEN ? AND ?  AND  fp.pastureid = ? AND d.lpplantype IN (0,1,
 
 		// appG.Response(http.StatusOK, e.SUCCESS, data)
 	}
-	queryData, err := getAccuracy(data)
-	appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	if status == "1" {
+		queryData, _ := getAccuracy(data, "2006-01-02")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	} else {
+		queryData, _ := getAccuracy(data, "2006-01")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
 }
 
 func GetFeedEffSLJT(c *gin.Context) {
@@ -363,8 +435,13 @@ func GetFeedEffSLJT(c *gin.Context) {
 
 		// appG.Response(http.StatusOK, e.SUCCESS, data)
 	}
-	queryData, err := getAccuracy(data)
-	appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	if status == "1" {
+		queryData, _ := getAccuracy(data, "2006-01-02")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	} else {
+		queryData, _ := getAccuracy(data, "2006-01")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
 }
 
 func GetFeedEffHL(c *gin.Context) {
@@ -382,19 +459,25 @@ func GetFeedEffHL(c *gin.Context) {
 	defer tx.Close()
 
 	var sqlStr = `SELECT 
- %s 日期,
-ifnull(ROUND(SUM(UNIX_TIMESTAMP((SELECT MAX(intime) FROM downloadplandtl1_exec d2 
-WHERE  d.mydate=d2.date AND d.pastureid = d2.pastureid AND d2.pid=d.id))-UNIX_TIMESTAMP(d.intime))/60,2),0) field1 -- 混料时间
- FROM 
-downloadedplan d
-WHERE  d.mydate  BETWEEN ? AND ?  AND  d.pastureid = ? AND d.lpplantype IN (0,1)  `
+	ft.tname 名称,
+
+   ifnull(ROUND(SUM(UNIX_TIMESTAMP((SELECT MAX(intime) FROM downloadplandtl1_exec d2 
+   WHERE  d.mydate=d2.date AND d.pastureid = d2.pastureid AND d2.pid=d.id))-UNIX_TIMESTAMP(d.intime))/60,2),0) 准确率 ,
+   %s 日期,
+   ifnull(ROUND(SUM(UNIX_TIMESTAMP((SELECT MAX(intime) FROM downloadplandtl1_exec d2 
+   WHERE  d.mydate=d2.date AND d.pastureid = d2.pastureid AND d2.pid=d.id))-UNIX_TIMESTAMP(d.intime))/60,2),0) 混料时间(分钟) 
+ 
+	FROM 
+   downloadedplan d
+   join feedtempletdate  ft on ft.id = d.tempid  and ft.date = d.mydate
+   WHERE  d.mydate  BETWEEN ? AND ?  AND  d.pastureid = ? AND d.lpplantype IN (0,1)    `
 
 	var data []map[string]interface{}
 	var err error
 	if status == "0" {
 		sqlStr = fmt.Sprintf(sqlStr, " DATE_FORMAT(d.mydate, '%Y-%m-%d') ")
 
-		sqlStr += "  GROUP BY DATE_FORMAT(d.mydate, '%Y-%m-%d') ORDER BY  d.mydate "
+		sqlStr += "  GROUP BY ft.id,DATE_FORMAT(d.mydate, '%Y-%m-%d') ORDER BY  ft.id,d.mydate "
 		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId).Query().List()
 		if err != nil {
 			logs.Error(sqlName, " : ", err)
@@ -415,7 +498,7 @@ WHERE  d.mydate  BETWEEN ? AND ?  AND  d.pastureid = ? AND d.lpplantype IN (0,1)
 
 		sqlStr = fmt.Sprintf(sqlStr, "FLOOR( ((DATEDIFF(d.mydate,'"+startDate+"') +"+strconv.Itoa(week)+")/7)+1)")
 
-		sqlStr += "  GROUP BY 日期 ORDER BY 日期 "
+		sqlStr += "  GROUP BY ft.id,日期 ORDER BY  ft.id,d.mydate "
 		fmt.Println(sqlStr)
 		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId).Query().List()
 		if err != nil {
@@ -427,7 +510,7 @@ WHERE  d.mydate  BETWEEN ? AND ?  AND  d.pastureid = ? AND d.lpplantype IN (0,1)
 	} else {
 
 		sqlStr = fmt.Sprintf(sqlStr, " DATE_FORMAT(d.mydate, '%Y-%m') ")
-		sqlStr += "  GROUP BY DATE_FORMAT(d.mydate, '%Y-%m') ORDER BY  d.mydate "
+		sqlStr += "  GROUP BY ft.id,DATE_FORMAT(d.mydate, '%Y-%m') ORDER BY  ft.id,d.mydate"
 
 		// timeTemplate := "2006-01-02"
 		// end, _ := time.ParseInLocation(timeTemplate, endDate, time.Local)
@@ -441,8 +524,13 @@ WHERE  d.mydate  BETWEEN ? AND ?  AND  d.pastureid = ? AND d.lpplantype IN (0,1)
 
 		// appG.Response(http.StatusOK, e.SUCCESS, data)
 	}
-	queryData, err := getAccuracyV2(data)
-	appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	if status == "1" {
+		queryData, _ := getAccuracy(data, "2006-01-02")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	} else {
+		queryData, _ := getAccuracy(data, "2006-01")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
 
 }
 
@@ -639,8 +727,13 @@ WHERE d.mydate  BETWEEN ? AND ?  AND   d.pastureid = ?  AND d.lpplantype IN (0,1
 
 		// appG.Response(http.StatusOK, e.SUCCESS, data)
 	}
-	queryData, err := getAccuracy(data)
-	appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	if status == "1" {
+		queryData, _ := getAccuracy(data, "2006-01-02")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	} else {
+		queryData, _ := getAccuracy(data, "2006-01")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
 }
 
 func GetFeedEffZHJT(c *gin.Context) {
@@ -730,8 +823,13 @@ func GetFeedEffZHJT(c *gin.Context) {
 		}
 
 	}
-	queryData, err := getAccuracy(data)
-	appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	if status == "1" {
+		queryData, _ := getAccuracy(data, "2006-01-02")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	} else {
+		queryData, _ := getAccuracy(data, "2006-01")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
 }
 
 func GetFeedEffCBFT(c *gin.Context) {
@@ -860,8 +958,13 @@ WHERE fp.date BETWEEN ? AND ? AND fp.pastureid = ?   AND d.lpplantype IN (0,1,2,
 
 		// appG.Response(http.StatusOK, e.SUCCESS, data)
 	}
-	queryData, err := getAccuracy(data)
-	appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	if status == "1" {
+		queryData, _ := getAccuracy(data, "2006-01-02")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	} else {
+		queryData, _ := getAccuracy(data, "2006-01")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
 }
 
 //成本分析-集团
@@ -952,8 +1055,13 @@ func GetFeedEffCBAllJT(c *gin.Context) {
 		}
 
 	}
-	queryData, err := getAccuracy(data)
-	appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	if status == "1" {
+		queryData, _ := getAccuracy(data, "2006-01-02")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	} else {
+		queryData, _ := getAccuracy(data, "2006-01")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
 }
 
 // getAccuracyAllFT
@@ -1034,8 +1142,13 @@ WHERE  d.mydate  BETWEEN ? AND ?  AND d.pastureid=?   AND d.lpplantype  IN (0,1,
 
 		// appG.Response(http.StatusOK, e.SUCCESS, data)
 	}
-	queryData, err := getAccuracy(data)
-	appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	if status == "1" {
+		queryData, _ := getAccuracy(data, "2006-01-02")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	} else {
+		queryData, _ := getAccuracy(data, "2006-01")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
 }
 
 // getAccuracyAllJH
@@ -1214,8 +1327,13 @@ func GetAccuracyAllNQ(c *gin.Context) {
 
 		// appG.Response(http.StatusOK, e.SUCCESS, data)
 	}
-	queryData, err := getAccuracy(data)
-	appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	if status == "1" {
+		queryData, _ := getAccuracy(data, "2006-01-02")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	} else {
+		queryData, _ := getAccuracy(data, "2006-01")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
 }
 
 // getAccuracyAllCC
@@ -1293,8 +1411,13 @@ func GetAccuracyAllCC(c *gin.Context) {
 
 		// appG.Response(http.StatusOK, e.SUCCESS, data)
 	}
-	queryData, err := getAccuracy(data)
-	appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	if status == "1" {
+		queryData, _ := getAccuracy(data, "2006-01-02")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	} else {
+		queryData, _ := getAccuracy(data, "2006-01")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
 }
 
 // getAccuracyAllHL
@@ -1403,13 +1526,14 @@ func GetAccuracyAllLS(c *gin.Context) {
 	startDate := parammaps.Get("startTime").ValueStr()
 	endDate := parammaps.Get("stopTime").ValueStr()
 	pastureId := parammaps.Get("pastureid").ValueStr()
+	ftId := parammaps.Get("ftId").ValueStr()
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
 	var sqlStr = `SELECT concat(de.fname,'-',d.times,'班') 名称,de.fname,%s 日期, 
 	IFNULL(DATE_FORMAT(de.intime,'%%H.%%i'),'')   准确率  --  撒料时间
 	FROM downloadedplan d right JOIN downloadplandtl2 de ON  d.pastureid = de.pastureid and d.id=de.pid 
-	WHERE d.mydate  BETWEEN ? AND ?  AND  d.pastureid=?  AND d.lpplantype  IN (0,1,2,5) AND de.type = 0
+	WHERE d.mydate  BETWEEN ? AND ?  AND  d.pastureid=?  AND d.lpplantype  IN (0,1,2,5) AND de.type = 0    and (? ='' or   FIND_IN_SET(d.tempid ,?))
 	-- 加上就是不含取消操作
 	-- AND ((ABS(de.actualweightminus-de.lweight)/de.lweight)<=3 OR (de.lweight <30 AND de.actualweightminus <30 )) 
 	GROUP BY d.times,日期,de.fname
@@ -1421,7 +1545,7 @@ func GetAccuracyAllLS(c *gin.Context) {
 		sqlStr = fmt.Sprintf(sqlStr, " DATE_FORMAT(d.Mydate, '%Y-%m-%d') ")
 
 		// sqlStr += "  GROUP BY 日期 "
-		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId).Query().List()
+		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId, ftId, ftId).Query().List()
 		if err != nil {
 			logs.Error(sqlName, " : ", err)
 			appG.Response(http.StatusInternalServerError, e.ERROR, err)
@@ -1442,7 +1566,7 @@ func GetAccuracyAllLS(c *gin.Context) {
 		sqlStr = fmt.Sprintf(sqlStr, "FLOOR( ((DATEDIFF(d.Mydate,'"+startDate+"') +"+strconv.Itoa(week)+")/7)+1)")
 
 		// sqlStr += "  GROUP BY 日期 "
-		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId).Query().List()
+		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId, ftId, ftId).Query().List()
 		if err != nil {
 			logs.Error(sqlName, " : ", err)
 			appG.Response(http.StatusInternalServerError, e.ERROR, err)
@@ -1458,7 +1582,7 @@ func GetAccuracyAllLS(c *gin.Context) {
 		// end, _ := time.ParseInLocation(timeTemplate, endDate, time.Local)
 		// endDate = end.AddDate(0, 1, -1).Format(timeTemplate)
 
-		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId).Query().List()
+		data, err = tx.SQL(sqlStr, startDate, endDate, pastureId, ftId, ftId).Query().List()
 		if err != nil {
 			logs.Error(sqlName, " : ", err)
 			appG.Response(http.StatusInternalServerError, e.ERROR, err)
@@ -1466,8 +1590,13 @@ func GetAccuracyAllLS(c *gin.Context) {
 
 		// appG.Response(http.StatusOK, e.SUCCESS, data)
 	}
-	queryData, err := getAccuracy(data)
-	appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	if status == "0" {
+		queryData, _ := getAccuracy(data, "2006-01-02")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	} else {
+		queryData, _ := getAccuracy(data, "2006-01")
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
 }
 
 //getAccuracyAllQX

+ 6 - 0
http/handle/api/grfdApi.go

@@ -147,6 +147,12 @@ func GetDormBar(pastureid string) error {
 				}
 				//首先将所有栏舍禁用
 
+				_, err = tx.Exec("update bar set bname = ? where bcode = ?",
+					penName, penId)
+				if err != nil {
+					return err
+				}
+
 				_, err = tx.Exec("insert into bar(id,pastureid,bcode,backup1,backup2,bname,enable) "+
 					" values(?,?,?,?,?,?,1)"+
 					" ON DUPLICATE KEY UPDATE bcode=?,backup2=?,enable=if(enable = 2,0,1)",

+ 133 - 93
http/handle/api/mqtt.go

@@ -19,6 +19,7 @@ import (
 
 	"github.com/astaxie/beego/logs"
 	MQTT "github.com/eclipse/paho.mqtt.golang"
+	mqtt "github.com/eclipse/paho.mqtt.golang"
 	"github.com/robfig/cron"
 )
 
@@ -27,14 +28,23 @@ func InitMqttClient() {
 		c, pubTopic := MqttClient()
 		deviceHeartbeat(c, pubTopic)
 
+		// now := time.Now().AddDate(0, 0, -5).Format("2006-01-02")
+		// stirPush(c, pubTopic, now)
+		// dustingPush(c, pubTopic, now)
+		// equipmentAccuracyPush(c, pubTopic, now)
+		// finishedWeightPush(c, pubTopic, now)
+		// feedtempletPush(c, pubTopic)
+		// CompletedTrainNumberPush(c, pubTopic, now)
+
 		mqttCron := cron.New()
 		mqttCron.AddFunc("10 06 * * *", func() {
+			now := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
+			stirPush(c, pubTopic, now)
+			dustingPush(c, pubTopic, now)
+			equipmentAccuracyPush(c, pubTopic, now)
+			finishedWeightPush(c, pubTopic, now)
 			feedtempletPush(c, pubTopic)
-			stirPush(c, pubTopic)
-			dustingPush(c, pubTopic)
-			equipmentAccuracyPush(c, pubTopic)
-			finishedWeightPush(c, pubTopic)
-			CompletedTrainNumberPush(c, pubTopic)
+			CompletedTrainNumberPush(c, pubTopic, now)
 		})
 		mqttCron.Start()
 	}
@@ -53,17 +63,23 @@ func MqttClient() (MQTT.Client, string) {
 	var deviceName string = setting.YynserverSetting.DeviceName
 	var deviceSecret string = setting.YynserverSetting.DeviceSecret
 
-	// set timestamp, clientid, subscribe topic and publish topic
+	// product_key =k03txxLKFae
+	// device_name =4623_p_breed
+	// device_secret =d06ababb2b10ba25bca3041e35ac604d
+	// host = iot-010a5xth.mqtt.iothub.aliyuncs.com
+	// farmId=1830004623
+	// heartBeat=18300046234623_p_breed
+	// TopicName=/k03txxLKFae/4623_p_breed/user/heatwatch/tmrBreed/post
+
 	var timeStamp string = strconv.FormatInt(time.Now().UnixNano(), 10)
-	var clientId string = "go_device_id_0001"
+	var clientId string = "go" + setting.YynserverSetting.FarmId
 	var subTopic string = "/" + productKey + "/" + deviceName + "/user/heatwatch/tmrBreed/get"
 	var pubTopic string = "/" + productKey + "/" + deviceName + "/user/heatwatch/tmrBreed/post"
 
 	// set the login broker url
 	var raw_broker bytes.Buffer
-	raw_broker.WriteString("tls://")
-	raw_broker.WriteString(productKey)
-	raw_broker.WriteString(".iot-as-mqtt.cn-shanghai.aliyuncs.com:1883")
+	raw_broker.WriteString("tcp://")
+	raw_broker.WriteString("iot-010a5xth.mqtt.iothub.aliyuncs.com:1883")
 	opts := MQTT.NewClientOptions().AddBroker(raw_broker.String())
 
 	// calculate the login auth info, and set it into the connection options
@@ -82,39 +98,15 @@ func MqttClient() (MQTT.Client, string) {
 		}
 	}
 
-	// create and start a client using the above ClientOptions
-	c := MQTT.NewClient(opts)
-	if token := c.Connect(); token.Wait() && token.Error() != nil {
-		logging.Error("mqtt Connect err: ", token.Error())
+	c := mqtt.NewClient(opts)
 
+	if token := c.Connect(); token.Wait() && token.Error() != nil {
+		fmt.Println(token.Error())
+		os.Exit(1)
 	}
-	fmt.Print("Connect aliyun IoT Cloud Sucess\n")
-
-	// if token := c.Subscribe(subTopic, 0, feedHeatwatch); token.Wait() && token.Error() != nil {
-	// 	fmt.Println(token.Error())
-	// 	os.Exit(1)
-	// }
-	// subscribe to subTopic("/a1Zd7n5yTt8/deng/user/get") and request messages to be delivered
-
-	// fmt.Println("Subscribe topic "+subTopic+" success\n", c.IsConnected())
 
-	// publish 5 messages to pubTopic("/a1Zd7n5yTt8/deng/user/update")
-	// for i := 0; i < 50; i++ {
-	// 	fmt.Println("publish msg:", i)
-	// 	text := fmt.Sprintf("ABC #%d", i)
-	// 	token := c.Publish(pubTopic, 0, false, text)
-	// 	fmt.Println("publish msg: ", text)
-	// 	token.Wait()
-
-	// 	time.Sleep(2 * time.Second)
-	// }
-	// unsubscribe from subTopic("/a1Zd7n5yTt8/deng/user/get")
-	// if token := c.Unsubscribe(subTopic); token.Wait() && token.Error() != nil {
-	// 	fmt.Println(token.Error())
-	// 	os.Exit(1)
-	// }
+	fmt.Print("Connect aliyun IoT Cloud Sucess\n")
 
-	// c.Disconnect(250)
 	return c, pubTopic
 }
 
@@ -191,10 +183,27 @@ func feedtempletPush(c MQTT.Client, pubTopic string) {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
-	dataList, err := tx.SQL(`select f.id  as recipeId , f.tname recipeName,ft.id ingId,ft.fname ingName,ft.fweight  afQty,
-	ft.sort mixNo,fd.allowratio allowableError ,fd.fclass ingType, ft.fweight * ( fd.dry /100 )  dmQty,null recipeCost 
-	 from feedtemplet  f   join ftdetail ft  on ft.ftid = f.id  join feed fd on fd.id = ft.fid	
-	`).Query().List()
+	dataList, err := tx.SQL(`SELECT 
+	f.id AS recipeId,
+	f.tname recipeName,
+	ft.id ingId,
+	ifnull(fd.fname,fdy.fname) ingName,
+	if(fd.fname is not null, ft.fweight,fty.fweight) afQty,
+	ft.sort mixNo,
+	ifnull(fd.allowratio,fdy.allowratio) allowableError,
+	ifnull(fd.fclass,fdy.fclass) ingType,
+		if(fd.fname is not null,ft.fweight * ( fd.dry / 100 ), fty.fweight * ( fdy.dry / 100 )) dmQty,
+	'' recipeCost 
+FROM
+	feedtemplet f
+	JOIN ftdetail ft ON ft.ftid = f.id
+	 left JOIN feed fd ON fd.id = ft.fid
+	 left join feedtemplet fy  on fy.id = ft.preftid
+ left join ftdetail fty on fty.ftid = fy.id
+ left JOIN feed fdy ON fdy.id = fty.fid
+	 
+
+	`).QueryString()
 	if err != nil {
 		logs.Error("feedtempletPush-error-1:", err)
 		return
@@ -203,7 +212,7 @@ func feedtempletPush(c MQTT.Client, pubTopic string) {
 	pushStr := `{
 		"apiId": "getKPTData", 
 		"param": {
-		"farmId": %s, 
+		"farmId": "%s", 
 				  "method":"getfeedtempletinfo",
 				  "rowCount": "1",
 		"resultData":%s
@@ -220,33 +229,36 @@ func feedtempletPush(c MQTT.Client, pubTopic string) {
 	}
 }
 
-func stirPush(c MQTT.Client, pubTopic string) {
+func stirPush(c MQTT.Client, pubTopic, date string) {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
 	dataList, err := tx.SQL(`SELECT
-	d.mydate dropDate,
-	d.projname tmrNo,
+	DATE_FORMAT(d.mydate,'%Y-%m-%d')  loadDate,
+	d.sort tmrNo,
 	d.times loadShift,
 	d.tempid recipeId,
 	d.templetname recipeName,
 	f.feedcode ingId,
 	d1.fname ingName,
-	f.fclass ingType,
+	12 ingType,
 	f.dry dmPct,
 	d1.sort mixNo,
-	d1.feedallowratio allowableError,
+	d1.feedallowratio allowable_error,
 	d1.lweight expWeight,
 	d1.actualweightminus actualWeight,
-	d1.begintime startTime,
-	d1.intime endTime 
+	 	if((select  count(1) from downloadplandtl1  where pid = d.id and sort < d1.sort order by sort desc) >0 ,(select  DATE_FORMAT(intime,'%Y-%m-%d %H:%i:%s') from downloadplandtl1  where pid = d.id and sort < d1.sort order by sort desc limit 1),DATE_FORMAT(d.intime,'%Y-%m-%d %H:%i:%s')  )   startTime,
+	 DATE_FORMAT(d1.intime,'%Y-%m-%d %H:%i:%s')  endTime ,	ifnull(if(d.driverId !=0 ,(select drivername from driver where id = d.driverId),(SELECT dr.driver FROM dutyrecord dr 
+	WHERE dr.pastureid = d.pastureid AND dr.eqid = d.tmrid and dr.times= d.times  AND dr.operatetime <=d.mydate 
+	ORDER BY dr.operatetime DESC LIMIT 1)),'')tmrName 
 FROM
 	downloadedplan d
 	JOIN downloadplandtl1 d1 ON d1.pid = d.id
 	JOIN feed f ON f.feedcode = d1.feedcode 
 	AND f.pastureid = d.pastureid 
 WHERE
-	DATE_FORMAT( d.mydate ,'%Y-%m-%d' ) = DATE_FORMAT(subdate(now(),1) ,'%Y-%m-%d' )`).Query().List()
+	DATE_FORMAT( d.mydate ,'%Y-%m-%d' ) = ?
+	`, date).QueryString()
 	if err != nil {
 		logs.Error("feedtempletPush-error-1:", err)
 		return
@@ -255,16 +267,17 @@ WHERE
 	pushStr := `{
 		"apiId": "getKPTData", 
 	   "param": {
-	   "farmId": %s, 
+	   "farmId":  "%s", 
 				 "method":"uploadadddata",
-				"rowCount": "1",
+				"rowCount": "%d",
 	   "resultData":%s
 		}
 	   }`
 	if len(dataList) > 0 {
 		b, _ := json.Marshal(dataList)
-		pushStr = fmt.Sprintf(pushStr, setting.YynserverSetting.FarmId, string(b))
+		pushStr = fmt.Sprintf(pushStr, setting.YynserverSetting.FarmId, len(dataList), string(b))
 		token := c.Publish(pubTopic, 2, false, pushStr)
+
 		fmt.Println("publish msg: ", pushStr, token.Error())
 		// token.Wait()
 		// time.Sleep(2 * time.Second)
@@ -272,28 +285,34 @@ WHERE
 }
 
 // 撒料信息
-func dustingPush(c MQTT.Client, pubTopic string) {
+func dustingPush(c MQTT.Client, pubTopic, date string) {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
 	dataList, err := tx.SQL(`SELECT
-	d.mydate dropDate,
-	d.projname tmrNo,
-	d.times loadShift,
-  d2.fbarid  penId,
-  b.bcode penName,
-	d2.cowcount cowCount,
-	d2.sort feedingNo,
-	d2.lweight expWeight,
-	d2.actualweightminus actualWeight,
-	d2.begintime startTime,
-	d2.intime endTime
-FROM
-	downloadedplan d
-	JOIN downloadplandtl2 d2 ON d2.pid = d.id
-	JOIN bar b ON b.id = d2.fbarid 
-WHERE
-	DATE_FORMAT( d.mydate ,'%Y-%m-%d' ) = DATE_FORMAT(subdate(now(),1) ,'%Y-%m-%d' )`).Query().List()
+	ifnull(if(d.driverId !=0 ,(select drivername from driver where id = d.driverId),(SELECT dr.driver FROM dutyrecord dr 
+	WHERE dr.pastureid = d.pastureid AND dr.eqid = d.tmrid and dr.times= d.times  AND dr.operatetime <=d.mydate 
+	ORDER BY dr.operatetime DESC LIMIT 1)),'')tmrName ,
+		DATE_FORMAT(d.mydate,'%Y-%m-%d')   dropDate,
+		d.sort tmrNo,
+		d.times dropShift,
+	  d2.fbarid  penId,
+	  b.bname penName,
+		fp.ccount cowCount,
+		d2.sort feedingNo,
+		d2.lweight expWeight,
+		d2.actualweightminus actualWeight,
+		if((select  count(1) from downloadplandtl2  where pid = d.id and sort < d2.sort order by sort desc) >0 ,(select  DATE_FORMAT(intime,'%Y-%m-%d %H:%i:%s') from downloadplandtl2  where pid = d.id and sort < d2.sort order by sort desc limit 1),  (select DATE_FORMAT(intime,'%Y-%m-%d %H:%i:%s') from downloadplandtl1  where pid = d.id order by sort desc limit 1) )  startTime,
+		  DATE_FORMAT(d2.intime,'%Y-%m-%d %H:%i:%s') endTime
+	FROM
+		downloadedplan d
+		JOIN downloadplandtl2 d2 ON d2.pid = d.id
+		JOIN bar b ON b.id = d2.fbarid 
+		join feedp fp on fp.barid = b.id
+		join tmr t on t.id = d.tmrid 
+		left join driver on driver.drivercode = t.eqcode
+	WHERE
+		DATE_FORMAT( d.mydate ,'%Y-%m-%d' ) = ? `, date).QueryString()
 	if err != nil {
 		logs.Error("feedtempletPush-error-1:", err)
 		return
@@ -302,15 +321,15 @@ WHERE
 	pushStr := `{
 		"apiId": "getKPTData", 
 		"param": {
-		"farmId": %s, 
+		"farmId":  "%s", 
 				  "method":"uploaddiliverdata",
-				  "rowCount": "1",
+				  "rowCount": "%d",
 		"resultData":%s
 		 }
 		}`
 	if len(dataList) > 0 {
 		b, _ := json.Marshal(dataList)
-		pushStr = fmt.Sprintf(pushStr, setting.YynserverSetting.FarmId, string(b))
+		pushStr = fmt.Sprintf(pushStr, setting.YynserverSetting.FarmId, len(dataList), string(b))
 		token := c.Publish(pubTopic, 2, false, pushStr)
 		fmt.Println("publish msg: ", pushStr, token.Error())
 		// token.Wait()
@@ -333,7 +352,7 @@ func deviceHeartbeat(c MQTT.Client, pubTopic string) {
 	device := cron.New()
 	device.AddFunc(spec1, func() {
 		token := c.Publish(pubTopic, 2, false, pushStr)
-		fmt.Println("publish msg: ", pushStr, token.Error())
+		fmt.Println("publish msg: ", pushStr, token.Error(), time.Now())
 		// token.Wait()
 	})
 	// }
@@ -342,13 +361,24 @@ func deviceHeartbeat(c MQTT.Client, pubTopic string) {
 }
 
 // 准确率
-func equipmentAccuracyPush(c MQTT.Client, pubTopic string) {
+func equipmentAccuracyPush(c MQTT.Client, pubTopic, date string) {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
-	dataList, err := tx.SQL(`select t.tname tname,1-abs(sum(d1.actualweightminus)- sum(d1.lweight))/sum(d1.lweight) rate ,d.mydate rateDate  from downloadedplan d join downloadplandtl1 d1 on d1.pid = d.id  join tmr t on t.datacaptureno = d.datacaptureno 
-	where DATE_FORMAT( d.mydate ,'%Y-%m-%d' ) = DATE_FORMAT(subdate(now(),1) ,'%Y-%m-%d' )
-	 group by d.datacaptureno`).Query().List()
+	dataList, err := tx.SQL(`SELECT
+	t.tname Name,
+	1-abs (
+	sum( d1.actualweightminus )- sum( d1.lweight ))/ sum( d1.lweight ) Rate,
+	d.mydate RateDate ,  DATE_FORMAT(d.intime,'%Y-%m-%d %H:%i:%s') startTime,
+	(select DATE_FORMAT(intime,'%Y-%m-%d %H:%i:%s')  from downloadplandtl2  where pid = d.id  order by sort desc limit 1) endTime
+FROM
+	downloadedplan d
+	JOIN downloadplandtl1 d1 ON d1.pid = d.id
+	JOIN tmr t ON t.datacaptureno = d.datacaptureno 
+WHERE
+	DATE_FORMAT( d.mydate, '%Y-%m-%d' ) = ?   and d.lpplantype in(0,1)
+GROUP BY
+	d.datacaptureno`, date).QueryString()
 	if err != nil {
 		logs.Error("feedtempletPush-error-1:", err)
 		return
@@ -358,7 +388,7 @@ func equipmentAccuracyPush(c MQTT.Client, pubTopic string) {
 		"apiId": "getKPTData",
 		"param": {
 			"resultData": %s,
-			"farmId": %s,         
+			"farmId":  "%s",        
 			"method": "uploadrate",          
 			"rowCount": %d                  
 		}
@@ -374,13 +404,21 @@ func equipmentAccuracyPush(c MQTT.Client, pubTopic string) {
 }
 
 // 完成重量
-func finishedWeightPush(c MQTT.Client, pubTopic string) {
+func finishedWeightPush(c MQTT.Client, pubTopic, date string) {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
-	dataList, err := tx.SQL(`select  sum(d1.actualweightminus) CompleteWeught,sum(d1.lweight) planWeight,d.mydate weightDate 
-	 from downloadedplan d join downloadplandtl1 d1 on d1.pid = d.id  join tmr t on t.datacaptureno = d.datacaptureno 
-	where DATE_FORMAT( d.mydate ,'%Y-%m-%d' ) = DATE_FORMAT(subdate(now(),1),'%Y-%m-%d' )`).Query().List()
+	dataList, err := tx.SQL(`SELECT
+	sum( d1.actualweightminus ) completeWeight,
+	sum( d1.lweight ) planWeight,
+	d.mydate weightDate ,  DATE_FORMAT(d.intime,'%Y-%m-%d %H:%i:%s') startTime,
+	(select DATE_FORMAT(intime,'%Y-%m-%d %H:%i:%s')  from downloadedplan  where mydate = d.mydate and intime is not null order by sort desc limit 1) endTime
+FROM
+	downloadedplan d
+	JOIN downloadplandtl1 d1 ON d1.pid = d.id
+	JOIN tmr t ON t.datacaptureno = d.datacaptureno 
+WHERE
+	DATE_FORMAT( d.mydate, '%Y-%m-%d' ) =  ?   and lpplantype in(0,1)`, date).QueryString()
 	if err != nil {
 		logs.Error("feedtempletPush-error-1:", err)
 		return
@@ -390,7 +428,7 @@ func finishedWeightPush(c MQTT.Client, pubTopic string) {
 		"apiId": "getKPTData",
 		"param": {
 			"resultData": %s,
-			"farmId": %s,          
+			"farmId": "%s",          
 			"method": "uploadweight",
 			"rowCount": "1"                 
 		}
@@ -406,14 +444,16 @@ func finishedWeightPush(c MQTT.Client, pubTopic string) {
 }
 
 // 完成车次
-func CompletedTrainNumberPush(c MQTT.Client, pubTopic string) {
+func CompletedTrainNumberPush(c MQTT.Client, pubTopic, date string) {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
-	dataList, err := tx.SQL(`select (select count(1) from downloadedplan  where  DATE_FORMAT(mydate ,'%Y-%m-%d' ) =  DATE_FORMAT(subdate(now(),1),'%Y-%m-%d' )  )  planCar, 
-	(select count(1) from downloadedplan  where  DATE_FORMAT(mydate ,'%Y-%m-%d' ) =  DATE_FORMAT(subdate(now(),1),'%Y-%m-%d' ) and iscompleted = 1 ) CompleteCar ,
-	DATE_FORMAT(subdate(now(),1),'%Y-%m-%d' ) carDate
-	`).Query().List()
+	dataList, err := tx.SQL(`	select (select count(1) from downloadedplan  where  DATE_FORMAT(mydate ,'%Y-%m-%d' ) =  ? and lpplantype in(0,1) )  planCar, 
+	(select count(1) from downloadedplan  where  DATE_FORMAT(mydate ,'%Y-%m-%d' ) =  ? and iscompleted = 1 and lpplantype in(0,1)) CompleteCar ,
+	? carDate,
+	(select   DATE_FORMAT(intime,'%Y-%m-%d %H:%i:%s')  from downloadedplan  where  DATE_FORMAT(mydate ,'%Y-%m-%d' ) =  ? and iscompleted = 1 and lpplantype in(0,1)  order by intime asc limit 1 ) startTime,
+		(select   DATE_FORMAT(intime,'%Y-%m-%d %H:%i:%s')  from downloadedplan  where  DATE_FORMAT(mydate ,'%Y-%m-%d' ) =  ? and iscompleted = 1 and lpplantype in(0,1) and intime is not null order by intime desc limit 1 ) endTime
+	`, date, date, date, date, date).QueryString()
 	if err != nil {
 		logs.Error("feedtempletPush-error-1:", err)
 		return
@@ -423,7 +463,7 @@ func CompletedTrainNumberPush(c MQTT.Client, pubTopic string) {
 		"apiId": "getKPTData",
 		"param": {
 			"resultData": %s,
-			"farmId": %s,       
+			"farmId":  "%s",      
 			"method": "uploadcarnumber",
 			"rowCount": "1"             
 		}

+ 54 - 0
http/handle/api/new_api.go

@@ -5,6 +5,7 @@ import (
 	"strconv"
 	"tmr-watch/middleware"
 	"tmr-watch/service/group"
+	"tmr-watch/service/sheep"
 
 	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	feedPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/pasture"
@@ -89,3 +90,56 @@ func FeetTemplateUpgradeNewVersion(c *gin.Context) {
 		Data: &operationPb.Success{Success: true},
 	})
 }
+
+// UpdateTmrGear 更新tmr_gear表数据
+func UpdateTmrGear(c *gin.Context) {
+	var req operationPb.UpdateOrCreateTmrGearRequest
+	if err := ginutil.BindProto(c, &req); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	if err := valid.ValidateStruct(&req,
+		valid.Field(&req.TmrId, valid.Required),
+		valid.Field(&req.Params, valid.Required),
+	); err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	}
+
+	if err := sheep.UpdateOrCreateTmrGear(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 UseGear(c *gin.Context) {
+	var req operationPb.UseGearRequest
+	if err := ginutil.BindProto(c, &req); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	if err := valid.ValidateStruct(&req,
+		valid.Field(&req.TmrId, valid.Required),
+		valid.Field(&req.Id, valid.Required),
+		valid.Field(&req.TmrId, valid.Required),
+	); err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	}
+
+	data, err := sheep.UseGear(c, &req)
+	if err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	}
+
+	ginutil.JSONResp(c, data)
+}

+ 1103 - 146
http/handle/api/ops.go

@@ -17,6 +17,7 @@ import (
 	"sync"
 	"time"
 	"tmr-watch/conf/setting"
+	"tmr-watch/http/handle/gm"
 	"tmr-watch/http/handle/restful"
 	"tmr-watch/module"
 	"tmr-watch/pkg/app"
@@ -27,6 +28,7 @@ import (
 	"github.com/Anderson-Lu/gofasion/gofasion"
 	"github.com/astaxie/beego/logs"
 	"github.com/gin-gonic/gin"
+	"github.com/qichengzx/coordtransform"
 	"github.com/tealeg/xlsx"
 	"github.com/xormplus/xorm"
 )
@@ -704,6 +706,7 @@ func GetReportform(c *gin.Context) {
 	pagecount := fsion.Get("pagecount").ValueDefaultInt(0)
 	parammaps := fsion.Get("parammaps")
 	typea := parammaps.Get("typea").ValueDefaultInt(0) //0 全部  1 理论, 2实际
+	mode := parammaps.Get("mode").ValueDefaultInt(0)
 	logging.Info("GetReportform ", c.Keys, sqlnamestr, parammaps)
 	tx := restful.Engine.NewSession()
 	err := tx.Begin()
@@ -723,7 +726,7 @@ func GetReportform(c *gin.Context) {
 		}
 	}()
 
-	queryData, err := praseReportform(sqlnamestr, parammaps, tx, checked, offset, pagecount, typea)
+	queryData, err := praseReportform(sqlnamestr, parammaps, tx, checked, offset, pagecount, typea, mode)
 	if err != nil {
 		appG.Response(http.StatusOK, e.ERROR, err.Error())
 	} else {
@@ -1143,15 +1146,15 @@ func GetRJSBData(c *gin.Context) {
 				arr, _ := tx.SQL(sql1, s_params1...).QueryString() //获取
 				queryData.(map[string]interface{})["list"].([]map[string]interface{})[index]["arrList"] = arr
 			}
-			// var wg sync.WaitGroup
-			// for _, value := range queryData.(map[string]interface{})["list"].([]map[string]interface{}) {
-			// 	wg.Add(1)
-			// 	go func(value map[string]interface{}) {
-			// 		defer wg.Done()
-			// 		_, err = tx.SQL(`update downloadedplan set  havebutton = 1 where id = ? and pastureid = ? `, value["projuctid"], value["pastureid"]).Execute()
-			// 	}(value)
-			// }
-			// wg.Wait()
+			var wg sync.WaitGroup
+			for _, value := range queryData.(map[string]interface{})["list"].([]map[string]interface{}) {
+				wg.Add(1)
+				go func(value map[string]interface{}) {
+					defer wg.Done()
+					_, err = tx.SQL(`update downloadedplan set  artificial = 2 where id = ? and pastureid = ? `, value["projuctid"], value["pastureid"]).Execute()
+				}(value)
+			}
+			wg.Wait()
 			appG.Response(http.StatusOK, e.SUCCESS, queryData)
 		}
 	} else {
@@ -1202,7 +1205,8 @@ func PostRJSBData(c *gin.Context) {
 	if err != nil {
 		logging.Error("PostRJSBData  err: ", err)
 		msg := geterrmsg(err.Error())
-		appG.Response(http.StatusOK, e.ERROR, msg)
+		// appG.Response(http.StatusOK, e.ERROR, msg)
+		appG.Response(http.StatusOK, e.SUCCESS, msg)
 		return
 	}
 
@@ -1326,6 +1330,11 @@ func PostRJSBDatas(c *gin.Context) {
 			return
 		}
 		parammaps := fsion.Get("parammaps")
+		ID := parammaps.Get("ID").ValueStr()
+		if ID == "" {
+			continue
+		}
+
 		s_params := make([]interface{}, 0)
 		paramslist := strings.Split(p, ",")
 		if len(paramslist) > 0 && p != "" {
@@ -1338,7 +1347,8 @@ func PostRJSBDatas(c *gin.Context) {
 		if err != nil {
 			logging.Error("PostRJSBData  err: ", err)
 			msg := geterrmsg(err.Error())
-			appG.Response(http.StatusOK, e.ERROR, msg)
+			// appG.Response(http.StatusOK, e.ERROR, msg)
+			appG.Response(http.StatusOK, e.SUCCESS, msg)
 			return
 		}
 
@@ -1511,6 +1521,9 @@ func ExecDataByConfig(c *gin.Context) {
 					logging.Error("ExecDataParam error:", err)
 					break
 				}
+				if paramvalue["name"].(string) == "createdownloadedplan" {
+					checkPlan(tx, paramvalue, tempCommon, tempval, 0)
+				}
 			}
 			if err == nil {
 				if tempCommon["returnmap"] != nil && tempCommon["returnmap"] != "" {
@@ -3108,19 +3121,20 @@ func UpdateFTdetail(c *gin.Context) {
 		parammaps := fTChange["parammaps"].(map[string]interface{})
 		if parammaps["type"].(float64) == 1 {
 			_, err = tx.SQL(`UPDATE feedp fp
-				set
-				fp.ftweight= IFNULL(IF(
-				(SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
-				IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid ),0)*ccountratio,
-				IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*ccountratio +
-				IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*ccount
-				),0),fp.feedweight = IFNULL(IF(
-				(SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
-				IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid ),0)*ccountratio,
-				IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*ccountratio +
-				IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*ccount
-				),0) +ifnull(fp.supplyweight,0)
-				WHERE fp.pastureid = ? AND fp.ftid =?`, parammaps["pastureid"], parammaps["ftid"]).Execute()
+			set
+			ccountratio =  ccount *(ratio /100 ),
+			fp.ftweight= IFNULL(IF(
+			(SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid ),0)*(ccount *(ratio /100 )),
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*ccountratio +
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*(ccount *(ratio /100 ))
+			),0),fp.feedweight = IFNULL(IF(
+			(SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid ),0)*(ccount *(ratio /100 )),
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*(ccount *(ratio /100 )) +
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*(ccount *(ratio /100 ))
+			),0) +ifnull(fp.supplyweight,0)
+			WHERE fp.pastureid = ? AND fp.ftid =?`, parammaps["pastureid"], parammaps["ftid"]).Execute()
 
 			_, err = tx.SQL(`UPDATE fpdetail fpd
 		INNER JOIN feedp fp
@@ -3130,19 +3144,19 @@ func UpdateFTdetail(c *gin.Context) {
 
 		} else {
 			_, err = tx.SQL(`UPDATE feedp fp
-					SET
-					fp.supplyweight= IFNULL(IF(
-					(SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
-					IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid ),0)*ccountratio,
-					IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*ccountratio +
-					IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*ccount
-					),0),fp.feedweight = IFNULL(IF(
-					(SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
-					IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid ),0)*ccountratio,
-					IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*ccountratio +
-					IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*ccount
-					),0) +ifnull(fp.supplyweight,0)
-					WHERE fp.pastureid = ? AND fp.ptsfid =?`, parammaps["pastureid"], parammaps["ftid"]).Execute()
+			SET  ccountratio =  ccount *(ratio /100 ),
+			fp.supplyweight= IFNULL(IF(
+			(SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid ),0)*(ccount *(ratio /100 )),
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*(ccount *(ratio /100 )) +
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*(ccount *(ratio /100 ))
+			),0),fp.feedweight = IFNULL(IF(
+			(SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid ),0)*(ccount *(ratio /100 )),
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*(ccount *(ratio /100 )) +
+			IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*(ccount *(ratio /100 ))
+			),0) +ifnull(fp.supplyweight,0)
+			WHERE fp.pastureid = ? AND fp.ptsfid =?`, parammaps["pastureid"], parammaps["ftid"]).Execute()
 
 			_, err = tx.SQL(`UPDATE fpdetail fpd
 				INNER JOIN feedp fp
@@ -3407,9 +3421,6 @@ func UpdateFTdetail(c *gin.Context) {
 			appG.Response(http.StatusOK, e.ERROR, false)
 			return
 		}
-		// }()
-		// }
-		// }
 	}
 
 	appG.Response(http.StatusOK, e.SUCCESS, true)
@@ -3523,14 +3534,10 @@ func UpdateFpdetailBar(c *gin.Context) {
 		ftmap["ptsid"] = list.Get("ptsid").ValueStr()
 		// fmt.Println(ftmap)
 
-		fpdDataList, err := tx.SQL(`select * from (SELECT TRIM(id) id,times,tratio,ifnull(ROUND(ptsrate*weight,2)-ptsuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) ptid,TRIM(-1 ) ptsid ,
-			(select bname  from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,0 AS fttype,cowcount,ccountradio,1 isfill  FROM fpdetail
-			WHERE fpdetail.pastureid = ?   and barid =(select barid from feedp where id = ? )  and  times = ?
-			UNION
+		fpdDataList, err := tx.SQL(`
 			SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) ptid,TRIM(ifnull(ptsid,-1) ) ptsid ,
-			(select bname  from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,1 AS fttype,cowcount,ccountradio,0 isfill  FROM fpdetail
-			WHERE fpdetail.pastureid = ?  and barid = (select barid from feedp where id = ? )  and  times = ? ) t
-			order by t.barname,t.times`, pastureid, id, ftmap["times"], pastureid, id, ftmap["times"]).Query().List()
+			(select bname  from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,concat(1) AS fttype,cowcount,ccountradio,0 isfill  FROM fpdetail
+			WHERE fpdetail.pastureid = ?  and barid = (select barid from feedp where id = ? )  and  times = ? `, pastureid, id, ftmap["times"]).Query().List()
 		// fmt.Println(pastureid, id, ftmap["times"], pastureid, id, ftmap["times"])
 		if err != nil {
 			tx.Rollback()
@@ -3540,15 +3547,17 @@ func UpdateFpdetailBar(c *gin.Context) {
 		for _, fpd := range fpdDataList {
 			if fpd["times"].(int64) == ftmap["times"].(int64) && (fpd["ptid"].(string) == ftmap["ptid"].(string)) {
 				fttype := -1
-				if ftmap["ptid"].(string) != "-1" {
+				if fpd["fttype"].(string) == "1" {
 					fttype = 1
 				}
 
 				var fweight float64
 				var lweight float64
 				lpplandtl1List := make([]*lpplandtlInfo, 0)
-				err = tx.SQL(`select lppland.*,lpp.maxweight from lpplan lpp
-					join lpplandtl1 lppland on lpp.id = lppland.lppid  where lppland.fpdid =?
+				err = tx.SQL(`select lppland.*,t.maxstirfeed maxweight from lpplan lpp
+					join lpplandtl1 lppland on lpp.id = lppland.lppid
+					join tmr  t on t.id = lpp.tmrid
+					where lppland.fpdid =?
 					and lppland.fttype = ? and lpp.pastureid = ?  and lpp.times  = ? order by lpp.sort desc `,
 					fpd["id"], fttype, pastureid, ftmap["times"]).Find(&lpplandtl1List)
 				if err != nil {
@@ -3561,7 +3570,7 @@ func UpdateFpdetailBar(c *gin.Context) {
 				var w float64
 				var status int
 				fmt.Println(ftmap["new"].(float64), ftmap["old"].(float64))
-				if ftmap["new"].(float64) < ftmap["old"].(float64) {
+				if ftmap["new"].(float64) < ftmap["old"].(float64) && weight <= 0 {
 					if weight >= 0 {
 						continue
 					}
@@ -3576,11 +3585,14 @@ func UpdateFpdetailBar(c *gin.Context) {
 					status = 1
 				}
 
-				for _, lppland := range lpplandtl1List {
-					lweight += lppland.Lweight
-				}
+				// for _, lppland := range lpplandtl1List {
+				// 	lweight += lppland.Lweight
+				// }
 
 				for _, lppland := range lpplandtl1List {
+					lpplandInfo := new(lpplandtlInfo)
+					err := tx.SQL(` select ifnull(sum(lweight),0) lweight from lpplandtl1  where lppid = ? `, lppland.Lppid).GetFirst(lpplandInfo).Error
+					lweight = lpplandInfo.Lweight
 
 					if status == 1 {
 						// if w <= lppland.Lweight {
@@ -3619,13 +3631,26 @@ func UpdateFpdetailBar(c *gin.Context) {
 
 					}
 
-					_, err = tx.SQL(`update lpplandtl1  set Lweight = ?  where id = ? and pastureid = ?`, lppland.Lweight, lppland.Id, pastureid).Execute()
-					if err != nil {
-						tx.Rollback()
-						logs.Error(err)
-						return
+					if lppland.Lweight > 0 {
+
+						_, err = tx.SQL(`update lpplandtl1  set Lweight = ?  where id = ? and pastureid = ?`, lppland.Lweight, lppland.Id, pastureid).Execute()
+						if err != nil {
+							tx.Rollback()
+							logs.Error(err)
+							return
+						}
+					} else {
+						_, err = tx.SQL(`delete from  lpplandtl1    where id = ? and pastureid = ?`, lppland.Id, pastureid).Execute()
+						if err != nil {
+							tx.Rollback()
+							logs.Error(err)
+							return
+						}
 					}
-					break
+					if w == 0 {
+						break
+					}
+					// break
 				}
 				_, err = tx.SQL(`UPDATE fpdetail SET ptuse=IF(?=1,IF(ptuse+? <0,0,ptuse+?),ptuse),
 					ptsuse=IF(?=0,IF(ptsuse+?<0,0,ptsuse+?),ptsuse)
@@ -4121,6 +4146,7 @@ func FpdImportExcel(c *gin.Context) {
 		rows = rows[:10000]
 	}
 
+	dataList := make(map[string][]*upFpdetail, 0)
 	for i, row := range rows {
 		if i > 0 {
 
@@ -4278,6 +4304,7 @@ func FpdImportExcel(c *gin.Context) {
 					}
 				}
 			}
+
 			if !errExist {
 
 				dataexcel := make(map[string]interface{}, 0)
@@ -4312,7 +4339,7 @@ func FpdImportExcel(c *gin.Context) {
 				}
 
 				if _, ok := outentry["第五班比例(%)"]; ok {
-					dataexcel["5"] = outentry["第班比例(%)"]
+					dataexcel["5"] = outentry["第班比例(%)"]
 				}
 
 				if _, ok := outentry["第六班比例(%)"]; ok {
@@ -4329,6 +4356,28 @@ func FpdImportExcel(c *gin.Context) {
 					continue
 				}
 
+				_, err = tx.SQL(` update feedp fp set barname =  (select bname from  bar where bname = ?  and pastureid = ? )   where barid = (select id from  bar where bname = ?  and pastureid = ? )`, dataexcel["barname"], pastureid, dataexcel["barname"], pastureid).Execute()
+				if err != nil {
+					appG.Response(http.StatusInternalServerError, e.ERROR, err)
+					return
+				}
+
+				_, err = tx.SQL(` update fpdetail fp set barname =  (select bname from  bar where bname = ?  and pastureid = ? )   where barid = (select id from  bar where bname = ?  and pastureid = ? )`, dataexcel["barname"], pastureid, dataexcel["barname"], pastureid).Execute()
+				if err != nil {
+					appG.Response(http.StatusInternalServerError, e.ERROR, err)
+					return
+				}
+
+				existft, err := tx.SQL(` select id from  feedtemplet where tname = ?  and pastureid = ?  `, dataexcel["ftname"], pastureid).Exist()
+				if err != nil {
+					logs.Error(err)
+					appG.Response(http.StatusInternalServerError, e.ERROR, "配方不存在!")
+					return
+				}
+				if !existft {
+					continue
+				}
+
 				ftexist, err := tx.SQL(` select id from  feedp where barname = ?  and pastureid = ? and ftname = ?  `, dataexcel["barname"], pastureid, dataexcel["ftname"]).Exist()
 				if err != nil {
 					logs.Error(err)
@@ -4503,7 +4552,7 @@ func FpdImportExcel(c *gin.Context) {
 					dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 1)
 				_, err = tx.SQL(upFpdSql, fpdargs1...).Execute()
 				if err != nil {
-					appG.Response(http.StatusInternalServerError, e.ERROR, false)
+					appG.Response(http.StatusInternalServerError, e.ERROR, err)
 					return
 				}
 
@@ -4587,17 +4636,20 @@ func FpdImportExcel(c *gin.Context) {
 						}
 					}
 				}
-
-				updateFpdetailByBar(pastureid, dataexcel["barname"].(string), upFpdetailList)
-
+				// fmt.Println(dataexcel["barname"])
+				dataList[dataexcel["barname"].(string)] = upFpdetailList
+				// updateFpdetailByBar(pastureid, dataexcel["barname"].(string), upFpdetailList)
 			}
-
 		}
 		if !isdone {
 			ok++
 			isdone = true
 		}
 	}
+	for barname, v := range dataList {
+		updateFpdetailByBar(pastureid, barname, v)
+	}
+
 	data := make(map[string]interface{})
 	data["result"] = queryData
 	data["success"] = ok
@@ -4699,65 +4751,69 @@ where lppland.pastureid = ?  and lppland.fpdid = ? and lpp.times = ?  order by l
 		ftmap["ptid"] = strconv.FormatInt(list.Ptid, 10)
 		ftmap["ptsid"] = ""
 		// fmt.Println(ftmap)
-
-		fpdDataList, err := tx.SQL(`select * from (SELECT TRIM(id) id,times,tratio,ifnull(ROUND(ptsrate*weight,2)-ptsuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM(ptid) ptid,TRIM(ptsid ) ptsid ,
-			(select bname  from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,0 AS fttype,cowcount,ccountradio,1 isfill  FROM fpdetail
-			WHERE fpdetail.pastureid = ?   and barname = ? and  times = ?
-			UNION
+		// select * from (SELECT TRIM(id) id,times,tratio,ifnull(ROUND(ptsrate*weight,2)-ptsuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM(ptid) ptid,TRIM(ptsid ) ptsid ,
+		// (select bname  from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,concat(0) AS fttype,cowcount,ccountradio,1 isfill  FROM fpdetail
+		// WHERE fpdetail.pastureid = ?   and barname = ? and  times = ?
+		// UNION
+		fpdDataList, err := tx.SQL(`
 			SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM(ptid) ptid,TRIM(ptsid ) ptsid ,
-			(select bname  from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,1 AS fttype,cowcount,ccountradio,0 isfill  FROM fpdetail
-			WHERE fpdetail.pastureid = ?  and barname = ? and  times = ? ) t
-			order by t.barname,t.times`, pastureid, barname, ftmap["times"], pastureid, barname, ftmap["times"]).Query().List()
+			(select bname  from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,concat(1) AS fttype,cowcount,ccountradio,0 isfill  FROM fpdetail
+			WHERE fpdetail.pastureid = ?  and barname = ? and  times = ? `, pastureid, barname, ftmap["times"]).Query().List()
 		// fmt.Println(pastureid, id, ftmap["times"], pastureid, id, ftmap["times"])
 		if err != nil {
 			tx.Rollback()
 			logs.Error(err)
 		}
-
 		for _, fpd := range fpdDataList {
 			if fpd["times"].(int64) == ftmap["times"].(int64) && (fpd["ptid"].(string) == ftmap["ptid"].(string) || fpd["ptsid"].(string) == ftmap["ptsid"].(string)) {
-				fttype := -1
-				if ftmap["ptid"].(string) != "-1" {
-					fttype = 1
-				}
+				// fttype := -1
+				// if fpd["fttype"].(string) == "1" {
+				fttype := 1
+				// }
 
 				var fweight float64
 				var lweight float64
 				lpplandtl1List := make([]*lpplandtlInfo, 0)
-				err = tx.SQL(`select lppland.*,lpp.maxweight from lpplan lpp
-					join lpplandtl1 lppland on lpp.id = lppland.lppid  where lppland.fpdid =?
+				err = tx.SQL(`select lppland.*,t.maxstirfeed  maxweight from lpplan lpp
+					join lpplandtl1 lppland on lpp.id = lppland.lppid  
+					join tmr t on t.id = lpp.tmrid
+					where lppland.fpdid =?
 					and lppland.fttype = ? and lpp.pastureid = ?  and lpp.times  = ? order by lpp.sort desc `,
 					fpd["id"], fttype, pastureid, ftmap["times"]).Find(&lpplandtl1List)
 				if err != nil {
 					tx.Rollback()
 					logs.Error(err)
 				}
-
+				// [map[barid:4719430583171155825 barname:泌乳1-5西 ccountradio:131 cowcount:30 fttype:0 id:4828050527277810688 isfill:1 pastureid:1705635208 ptid:83
+				//  ptsid:-1 times:1 tratio:48.000 weight:0.00] map[barid:4719430583171155825
+				//  barname:泌乳1-5西 ccountradio:131 cowcount:30 fttype:1 id:4828050527277810688 isfill:0 pastureid:1705635208 ptid:83 ptsid:-1 times:1 tratio:48.000 weight:32.0
 				weight, _ := strconv.ParseFloat(fpd["weight"].(string), 64)
-				// ptuse, _ := strconv.ParseFloat(fpd["ptuse"].(string), 64)
 
 				var w float64
 				var status int
 
-				if ftmap["new"].(float64) < ftmap["old"].(float64) {
+				if ftmap["new"].(float64) < ftmap["old"].(float64) && weight <= 0 {
 					if weight >= 0 {
 						continue
 					}
 					w = weight
 					status = 0
 				} else {
-					if weight-(ftmap["new"].(float64)-ftmap["old"].(float64)) > 0 {
-						continue
-					}
+					// if weight-(ftmap["new"].(float64)-ftmap["old"].(float64)) > 0 {
+					// 	continue
+					// }
 					w = weight
 					status = 1
 				}
 
-				for _, lppland := range lpplandtl1List {
-					lweight += lppland.Lweight
-				}
+				// for _, lppland := range lpplandtl1List {
+				// 	lweight += lppland.Lweight
+				// }
 
 				for _, lppland := range lpplandtl1List {
+					lpplandInfo := new(lpplandtlInfo)
+					err := tx.SQL(` select ifnull(sum(lweight),0) lweight from lpplandtl1  where lppid = ? `, lppland.Lppid).GetFirst(lpplandInfo).Error
+					lweight = lpplandInfo.Lweight
 
 					if status == 1 {
 						// if w <= lppland.Lweight {
@@ -4770,7 +4826,6 @@ where lppland.pastureid = ?  and lppland.fpdid = ? and lpp.times = ?  order by l
 							fweight += w
 							w = 0
 						} else {
-
 							w = w - (lppland.Maxweight - lweight)
 							n := (lppland.Maxweight - lweight)
 							lppland.Lweight = lppland.Lweight + n
@@ -4796,13 +4851,25 @@ where lppland.pastureid = ?  and lppland.fpdid = ? and lpp.times = ?  order by l
 
 					}
 
-					_, err = tx.SQL(`update lpplandtl1  set Lweight = ?  where id = ? and pastureid = ?`, lppland.Lweight, lppland.Id, pastureid).Execute()
-					if err != nil {
-						tx.Rollback()
-						logs.Error(err)
-						return err
+					if lppland.Lweight > 0 {
+
+						_, err = tx.SQL(`update lpplandtl1  set Lweight = ?  where id = ? and pastureid = ?`, lppland.Lweight, lppland.Id, pastureid).Execute()
+						if err != nil {
+							tx.Rollback()
+							logs.Error(err)
+							return err
+						}
+					} else {
+						_, err = tx.SQL(`delete from  lpplandtl1    where id = ? and pastureid = ?`, lppland.Id, pastureid).Execute()
+						if err != nil {
+							tx.Rollback()
+							logs.Error(err)
+							return err
+						}
+					}
+					if w == 0 {
+						break
 					}
-					break
 				}
 				_, err = tx.SQL(`UPDATE fpdetail SET ptuse=IF(?=1,IF(ptuse+? <0,0,ptuse+?),ptuse),
 					ptsuse=IF(?=0,IF(ptsuse+?<0,0,ptsuse+?),ptsuse)
@@ -4962,7 +5029,7 @@ where lppland.pastureid = ?  and lppland.fpdid = ? and lpp.times = ?  order by l
 		if err != nil {
 			logs.Error(err)
 			// appG.Response(http.StatusOK, e.ERROR, false)
-			return nil
+			return err
 		}
 	}
 
@@ -4974,7 +5041,7 @@ where lppland.pastureid = ?  and lppland.fpdid = ? and lpp.times = ?  order by l
 		if err != nil {
 			logs.Error(err)
 			// appG.Response(http.StatusOK, e.ERROR, false)
-			return nil
+			return err
 		}
 	}
 	for _, newFeedp := range newFeedpList {
@@ -4989,7 +5056,7 @@ where lppland.pastureid = ?  and lppland.fpdid = ? and lpp.times = ?  order by l
 		if err != nil {
 			logs.Error(err)
 			// appG.Response(http.StatusOK, e.ERROR, false)
-			return nil
+			return err
 		}
 	}
 
@@ -5660,7 +5727,7 @@ join lpplan lpp on lpp.id = lppland.lppid  where lppland.barname = ? and lppland
 					for _, history1 := range historyList {
 						if history1["createdate"].(string) == nextcreatedate && history1["id"].(int64) == history["id"].(int64) &&
 							history1["times"].(int64) == history["times"].(int64) {
-							data[fmt.Sprintf("a%d", times[history["times"]])] = fmt.Sprintf("%v/%v", data[fmt.Sprintf("a%d", times[history["times"]])], history["lweight"])
+							data[fmt.Sprintf("a%d", times[history["times"]])] = fmt.Sprintf("%v/%v", history1["lweight"], history["lweight"])
 							break
 							// exist = true
 						}
@@ -6657,6 +6724,19 @@ func UpdateDailyData(c *gin.Context) {
 
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
+
+	count, err := tx.SQL(`select  count(1)  from  downloadedplan where pid in(select  pid from  downloadedplan where id= ? )  and havebutton = 1   and mydate = ?`, pid, date).Count()
+	if err != nil {
+		logs.Error("UpdateDailyData-error-0:", err)
+		appG.Response(http.StatusOK, e.ERROR, fmt.Sprintf("该计划已开始执行,禁止修改!"))
+		return
+	}
+
+	if count > 0 {
+		appG.Response(http.StatusOK, e.ERROR, fmt.Sprintf("该计划已开始执行,禁止修改!"))
+		return
+	}
+
 	tx.Begin()
 
 	if location == 0 {
@@ -6949,7 +7029,7 @@ func UpdateDailyData(c *gin.Context) {
 
 	}
 
-	err := tx.Commit()
+	err = tx.Commit()
 	if err != nil {
 		logs.Error("UpdateDailyData-error-20:", err)
 		tx.Rollback()
@@ -7002,7 +7082,7 @@ func GetFormulaStatistics(c *gin.Context) {
 	}
 
 	downloadedplanList, err := tx.SQL(`select  count(1) total,ft.tname,date_format(d.mydate ,'%Y-%m-%d')  mydate  from downloadedplan d  
-	join  feedtemplet ft on ft.id = d.tempid  where d.mydate between ?  and ? and  d.lpplantype in(0,1) and d.iscompleted = 1  and d.pastureId= ? 
+	join  feedtempletdate ft on ft.id = d.tempid and ft.date = d.mydate  where d.mydate between ?  and ? and  d.lpplantype in(0,1) and d.iscompleted = 1  and d.pastureId= ? 
 	group by d.tempid,d.mydate `, startTime, endTime, pastureId).Query().List()
 	if err != nil {
 		logs.Error("GetFormulaStatistics-error-2:", err)
@@ -7171,32 +7251,32 @@ func PostPlanData(c *gin.Context) {
 			tx.Close()
 		}
 	}()
-	sql, p := restful.GetSqlByNameDBT("updatedownloadedplanYJ", tx)
-	sql1, p1 := restful.GetSqlByNameDBT("updated1YJ", tx)
-	sql2, p2 := restful.GetSqlByNameDBT("updated1execYJ", tx)
-	sql3, p3 := restful.GetSqlByNameDBT("updated2YJ", tx)
+	// sql, p := restful.GetSqlByNameDBT("updatedownloadedplanYJ", tx)
+	sql1, p1 := restful.GetSqlByNameDBT("updated1YJXY", tx)
+	sql2, p2 := restful.GetSqlByNameDBT("updated1execYJXY", tx)
+	sql3, p3 := restful.GetSqlByNameDBT("updated2YJXY", tx)
 	if !fsion.HasKey("parammaps") {
 		appG.Response(http.StatusOK, e.ERROR, "参数解析失败")
 		return
 	}
 	parammaps := fsion.Get("parammaps")
 
-	paramslist := strings.Split(p, ",")
-	if len(paramslist) > 0 && p != "" {
-		for _, value := range paramslist {
-			s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
-		}
-	}
-	_, err = tx.SQL(sql, s_params...).Execute()
-	if err != nil {
-		logging.Error("PostRJSBData  err: ", err)
-		msg := geterrmsg(err.Error())
-		appG.Response(http.StatusOK, e.ERROR, msg)
-		return
-	}
+	// paramslist := strings.Split(p, ",")
+	// if len(paramslist) > 0 && p != "" {
+	// 	for _, value := range paramslist {
+	// 		s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+	// 	}
+	// }
+	// _, err = tx.SQL(sql, s_params...).Execute()
+	// if err != nil {
+	// 	logging.Error("PostRJSBData  err: ", err)
+	// 	msg := geterrmsg(err.Error())
+	// 	appG.Response(http.StatusOK, e.ERROR, msg)
+	// 	return
+	// }
 
 	s_params = make([]interface{}, 0)
-	paramslist = strings.Split(p1, ",")
+	paramslist := strings.Split(p1, ",")
 	if len(paramslist) > 0 && p1 != "" {
 		for _, value := range paramslist {
 			// if value == "ID" {
@@ -7790,39 +7870,44 @@ func PostPlanDatas(c *gin.Context) {
 	// sql2, p2 := restful.GetSqlByNameDBT("updated1execYJ", tx)
 	// sql3, p3 := restful.GetSqlByNameDBT("updated2YJ", tx)
 
-	sql, p := restful.GetSqlByNameDBT("updatedownloadedplanYJ", tx)
-	sql1, p1 := restful.GetSqlByNameDBT("updated1YJ", tx)
-	sql2, p2 := restful.GetSqlByNameDBT("updated1execYJ", tx)
-	sql3, p3 := restful.GetSqlByNameDBT("updated2YJ", tx)
+	// sql, p := restful.GetSqlByNameDBT("updatedownloadedplanYJ", tx)
+	sql1, p1 := restful.GetSqlByNameDBT("updated1YJXY", tx)
+	sql2, p2 := restful.GetSqlByNameDBT("updated1execYJXY", tx)
+	sql3, p3 := restful.GetSqlByNameDBT("updated2YJXY", tx)
 
 	for _, parammaps := range fsions.Get("arrList").Array() {
+		fmt.Println(parammaps.Json())
+		if parammaps.Json() == "null" {
+			continue
+		}
 		// if !fsion.HasKey("arrList") {
-		// 	appG.Response(http.StatusOK, e.ERROR, "参数解析失败")
-		// 	return
+		// appG.Response(http.StatusOK, e.ERROR, "参数解析失败")
+		// return
+		// 	continue
 		// }
 		// parammaps := fsion.Get("arrList")
 		s_params := make([]interface{}, 0)
-		paramslist := strings.Split(p, ",")
-		if len(paramslist) > 0 && p != "" {
-			for _, value := range paramslist {
-				if value == "pastureid" {
-					s_params = append(s_params, pastureId)
-				} else {
-					s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
-				}
-			}
-		}
-		_, err = tx.SQL(sql, s_params...).Execute()
+		// paramslist := strings.Split(p, ",")
+		// if len(paramslist) > 0 && p != "" {
+		// 	for _, value := range paramslist {
+		// 		if value == "pastureid" {
+		// 			s_params = append(s_params, pastureId)
+		// 		} else {
+		// 			s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+		// 		}
+		// 	}
+		// }
+		// _, err = tx.SQL(sql, s_params...).Execute()
 
-		if err != nil {
-			logging.Error("PostRJSBData  err: ", err)
-			msg := geterrmsg(err.Error())
-			appG.Response(http.StatusOK, e.ERROR, msg)
-			return
-		}
+		// if err != nil {
+		// 	logging.Error("PostRJSBData  err: ", err)
+		// 	msg := geterrmsg(err.Error())
+		// 	appG.Response(http.StatusOK, e.ERROR, msg)
+		// 	return
+		// }
 
 		s_params = make([]interface{}, 0)
-		paramslist = strings.Split(p1, ",")
+		paramslist := strings.Split(p1, ",")
 		if len(paramslist) > 0 && p1 != "" {
 			for _, value := range paramslist {
 				// if value == "ID" {
@@ -7917,3 +8002,875 @@ func PostPlanDatas(c *gin.Context) {
 	}
 	appG.Response(http.StatusOK, e.SUCCESS, "ok")
 }
+
+func FpdBatchEdit(c *gin.Context) {
+
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsions := gofasion.NewFasion(string(dataByte))
+	barList := fsions.Get("barList").Array()
+	pastureid := fsions.Get("pastureId").ValueStr()
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	oldFpdList, err := tx.SQL(` select  ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") fweight,fpd.id,fpd.barname,fpd.weight,fpd.times,fp.ftweight,fp.supplyweight  from fpdetail fpd
+	join feedp fp on fp.barid = fpd.barid and fpd.pastureid = fp.pastureid where fpd.pastureid = ?`, pastureid).Query().List()
+	if err != nil {
+		appG.Response(http.StatusInternalServerError, e.ERROR, false)
+		return
+	}
+
+	for _, barFsions := range barList {
+
+		dataexcel := make(map[string]interface{}, 0)
+		dataexcel["barname"] = barFsions.Get("barname").ValueStr()
+		dataexcel["ccount"] = barFsions.Get("ccount").ValueStr()
+		dataexcel["ratio"] = barFsions.Get("ratio").ValueStr()
+		dataexcel["ftname"] = barFsions.Get("ftname").ValueStr()
+		dataexcel["ptsfname"] = barFsions.Get("ptsfname").ValueStr()
+		if dataexcel["ftname"] == "" || dataexcel["ccount"] == "0" || dataexcel["ratio"] == "0" {
+			continue
+		}
+
+		dataexcel["1"] = barFsions.Get("times1").ValueStr()
+		dataexcel["2"] = barFsions.Get("times2").ValueStr()
+		dataexcel["3"] = barFsions.Get("times3").ValueStr()
+		dataexcel["4"] = barFsions.Get("times4").ValueStr()
+		dataexcel["5"] = barFsions.Get("times5").ValueStr()
+		dataexcel["6"] = barFsions.Get("times6").ValueStr()
+
+		ftexist, err := tx.SQL(` select id from  feedp where barname = ?  and pastureid = ? and ftname = ?  `, dataexcel["barname"], pastureid, dataexcel["ftname"]).Exist()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+		if !ftexist {
+			fmt.Println(dataexcel["barname"], pastureid, dataexcel["ftname"])
+			tx.SQL(` delete from lpplandtl1 where barname = ? and pastureid = ?  `, dataexcel["barname"], pastureid).Exist()
+			if err != nil {
+				logs.Error(err)
+				appG.Response(http.StatusInternalServerError, e.ERROR, false)
+				return
+			}
+			tx.SQL(`  update fpdetail set ptuse = 0  where  barname = ? and pastureid = ?   `, dataexcel["barname"], pastureid).Exist()
+			if err != nil {
+				logs.Error(err)
+				appG.Response(http.StatusInternalServerError, e.ERROR, false)
+				return
+			}
+		}
+
+		exist, err := tx.SQL(` select id from  feedp where barname = ?  and pastureid = ?  `, dataexcel["barname"], pastureid).Exist()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+		if !exist {
+			_, err := tx.SQL(` insert into  feedp(pastureid,barid,barname,ccount)values(?,(select id from bar where  bname = ? and pastureid = ? ),?,?) `,
+				pastureid, dataexcel["barname"], pastureid, dataexcel["barname"], 0).Execute()
+			if err != nil {
+				logs.Error(err)
+				appG.Response(http.StatusInternalServerError, e.ERROR, false)
+				return
+			}
+		}
+
+		var feedpargs []interface{}
+		upFeedpSql := `update  feedp set ccount = ? ,ratio = ? ,ccountratio = ?*(?*0.01)  `
+		feedpargs = append(feedpargs, dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"])
+		if _, ok := dataexcel["ftname"]; ok {
+			feedpargs = append(feedpargs, dataexcel["ftname"], pastureid, dataexcel["ftname"])
+			upFeedpSql += ` , ftid = (select id from feedtemplet where tname = ? and pastureid = ? ),ftname = ? `
+
+			upFeedpSql += `,ftweight = (select sum(fweight) fweight from ftdetail 
+	where  ftid = (select  id from feedtemplet  where tname = ? and pastureid = ?  )) *  (?*(?*0.01)) `
+			feedpargs = append(feedpargs, dataexcel["ftname"], pastureid, dataexcel["ccount"], dataexcel["ratio"])
+		} else {
+			upFeedpSql += ` , ftid = -1,ftname = '' ,ftweight = 0 `
+		}
+
+		if _, ok := dataexcel["ptsfname"]; ok {
+			feedpargs = append(feedpargs, dataexcel["ptsfname"], pastureid, dataexcel["ptsfname"])
+			upFeedpSql += ` , ptsfid = (select id from feedtemplet where tname = ? and pastureid = ? ),ptsfname = ? `
+
+			upFeedpSql += `,supplyweight = (select sum(fweight) fweight from ftdetail 
+	where  ftid = (select  id from feedtemplet  where tname = ? and pastureid = ?  )) *  (?*(?*0.01))`
+			feedpargs = append(feedpargs, dataexcel["ptsfname"], pastureid, dataexcel["ccount"], dataexcel["ratio"])
+		} else {
+			upFeedpSql += ` , ptsfid = -1,ptsfname = '',supplyweight = 0  `
+		}
+		upFeedpSql += " where barname = ?  and pastureid = ?  "
+		feedpargs = append(feedpargs, dataexcel["barname"], pastureid)
+		_, err = tx.SQL(upFeedpSql, feedpargs...).Execute()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+
+		exist1, err := tx.SQL(` select id from  fpdetail where barname = ?  and pastureid = ? and times = 1 `, dataexcel["barname"], pastureid).Exist()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+
+		if !exist1 {
+			_, err := tx.SQL(` insert into  fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where  bname = ? and pastureid = ? ),?,1,0,0,0,-1,-1) `,
+				pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
+			if err != nil {
+				logs.Error(err)
+				appG.Response(http.StatusInternalServerError, e.ERROR, false)
+				return
+			}
+		}
+		exist2, err := tx.SQL(` select id from  fpdetail where barname = ?  and pastureid = ? and times = 2 `, dataexcel["barname"], pastureid).Exist()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+		if !exist2 {
+			_, err = tx.SQL(` insert into  fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where  bname = ? and pastureid = ? ),?,2,0,0,0,-1,-1) `,
+				pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
+			if err != nil {
+				logs.Error(err)
+				appG.Response(http.StatusInternalServerError, e.ERROR, false)
+				return
+			}
+		}
+
+		exist3, err := tx.SQL(` select id from  fpdetail where barname = ?  and pastureid = ? and times =3 `, dataexcel["barname"], pastureid).Exist()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+		if !exist3 {
+			_, err = tx.SQL(` insert into  fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where  bname = ? and pastureid = ? ),?,3,0,0,0,-1,-1) `,
+				pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
+			if err != nil {
+				logs.Error(err)
+				appG.Response(http.StatusInternalServerError, e.ERROR, false)
+				return
+			}
+		}
+		exist4, err := tx.SQL(` select id from  fpdetail where barname = ?  and pastureid = ? and times = 4 `, dataexcel["barname"], pastureid).Exist()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+		if !exist4 {
+			_, err = tx.SQL(` insert into  fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where  bname = ? and pastureid = ? ),?,4,0,0,0,-1,-1) `,
+				pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
+			if err != nil {
+				logs.Error(err)
+				appG.Response(http.StatusInternalServerError, e.ERROR, false)
+				return
+			}
+		}
+		exist5, err := tx.SQL(` select id from  fpdetail where barname = ?  and pastureid = ? and times = 5 `, dataexcel["barname"], pastureid).Exist()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+		if !exist5 {
+			_, err = tx.SQL(` insert into  fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where  bname = ? and pastureid = ? ),?,5,0,0,0,-1,-1) `,
+				pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
+			if err != nil {
+				logs.Error(err)
+				appG.Response(http.StatusInternalServerError, e.ERROR, false)
+				return
+			}
+		}
+		exist6, err := tx.SQL(` select id from  fpdetail where barname = ?  and pastureid = ? and times = 6 `, dataexcel["barname"], pastureid).Exist()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+		if !exist6 {
+			_, err = tx.SQL(` insert into  fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where  bname = ? and pastureid = ? ),?,6,0,0,0,-1,-1) `,
+				pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
+			if err != nil {
+				logs.Error(err)
+				appG.Response(http.StatusInternalServerError, e.ERROR, false)
+				return
+			}
+		}
+
+		upFpdSql := ` update fpdetail set  tratio = ? ,weight = (? *0.01) * ((select sum(fweight) fweight from ftdetail 
+	where  ftid = (select  id from feedtemplet  where tname = ? and pastureid = ?  )) *  (?*(?*0.01))) ,cowcount = ? ,
+	ccountradio= ?,ptid= (select id from feedtemplet where tname = ? and pastureid = ? )   where barname = ?
+	and pastureid = ? and times = ?`
+		var fpdargs1 []interface{}
+		fpdargs1 = append(fpdargs1, dataexcel["1"], dataexcel["1"], dataexcel["ftname"], pastureid,
+			dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
+			dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 1)
+		_, err = tx.SQL(upFpdSql, fpdargs1...).Execute()
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+
+		var fpdargs2 []interface{}
+		fpdargs2 = append(fpdargs2, dataexcel["2"], dataexcel["2"], dataexcel["ftname"], pastureid,
+			dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
+			dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 2)
+		_, err = tx.SQL(upFpdSql, fpdargs2...).Execute()
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+		var fpdargs3 []interface{}
+		fpdargs3 = append(fpdargs3, dataexcel["3"], dataexcel["3"], dataexcel["ftname"], pastureid,
+			dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
+			dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 3)
+		_, err = tx.SQL(upFpdSql, fpdargs3...).Execute()
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+		var fpdargs4 []interface{}
+		fpdargs4 = append(fpdargs4, dataexcel["4"], dataexcel["4"], dataexcel["ftname"], pastureid,
+			dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
+			dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 4)
+		_, err = tx.SQL(upFpdSql, fpdargs4...).Execute()
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+
+		var fpdargs5 []interface{}
+		fpdargs5 = append(fpdargs5, dataexcel["5"], dataexcel["5"], dataexcel["ftname"], pastureid,
+			dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
+			dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 5)
+		_, err = tx.SQL(upFpdSql, fpdargs5...).Execute()
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+
+		var fpdargs6 []interface{}
+		fpdargs6 = append(fpdargs6, dataexcel["6"], dataexcel["6"], dataexcel["ftname"], pastureid,
+			dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
+			dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 6)
+		_, err = tx.SQL(upFpdSql, fpdargs6...).Execute()
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+		// _, err = tx.SQL(`call updateLPPbyFPChange(?,( select id from feedp where barname = ?  and pastureid = ?))`, pastureid, dataexcel["barname"], pastureid).Execute()
+
+		newList, err := tx.SQL(` select  ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") fweight,id,ptid,weight,times from fpdetail where barname = ? and  pastureid = ? `, dataexcel["barname"], pastureid).Query().List()
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, false)
+			return
+		}
+		// oldFpdList, err := tx.SQL(` select  fpd.id,fpd.barname,fpd.weight,fpd.times,fp.ftweight,fp.supplyweight  from fpdetail fpd
+		// join feedp fp on fp.barid = fpd.barid and fpd.pastureid = fp.pastureid where fpd.pastureid = ?`, pastureid).Query().List()
+		upFpdetailList := make([]*upFpdetail, 0)
+		for _, newfpd := range newList {
+			for _, oldfpd := range oldFpdList {
+				if oldfpd["id"].(int64) == newfpd["id"].(int64) {
+					var oldweight, newweight float64
+					if oldfpd["weight"] != nil {
+						oldweight, _ = strconv.ParseFloat(oldfpd["weight"].(string), 64)
+					}
+					if newfpd["weight"] != nil {
+						newweight, _ = strconv.ParseFloat(newfpd["weight"].(string), 64)
+					}
+					fweight, _ := strconv.ParseFloat(newfpd["fweight"].(string), 64)
+					upFpdetailList = append(upFpdetailList, &upFpdetail{
+						Old:     oldweight,
+						New:     newweight,
+						Times:   newfpd["times"].(int64),
+						Ptid:    newfpd["ptid"].(int64),
+						Fweight: fweight,
+						Id:      oldfpd["id"].(int64),
+					})
+					break
+				}
+			}
+		}
+
+		updateFpdetailByBar(pastureid, dataexcel["barname"].(string), upFpdetailList)
+	}
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}
+
+func UdBarSync(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsions := gofasion.NewFasion(string(dataByte))
+	pastureid := fsions.Get("pastureId").ValueStr()
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	pastureinfo := new(udPastureInfo)
+	err := tx.SQL(`select werks from pasture where pastureid = ? `, pastureid).GetFirst(pastureinfo).Error
+	if err != nil {
+		logs.Error(err)
+		return
+	}
+
+	gm.UdBarSync(pastureid, pastureinfo.Werks)
+
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}
+
+func UdFeedSync(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsions := gofasion.NewFasion(string(dataByte))
+	pastureid := fsions.Get("pastureId").ValueStr()
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	pastureinfo := new(udPastureInfo)
+	err := tx.SQL(`select werks from pasture where pastureid = ?`, pastureid).GetFirst(pastureinfo).Error
+	if err != nil {
+		logs.Error(err)
+		return
+	}
+
+	gm.UdFeedSync(pastureid, pastureinfo.Werks)
+
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}
+
+func UdFeedtempletPush(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsions := gofasion.NewFasion(string(dataByte))
+	pastureid := fsions.Get("pastureId").ValueStr()
+	date := fsions.Get("date").ValueStr()
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	pastureinfo := new(udPastureInfo)
+	err := tx.SQL(`select werks from pasture where pastureid = ?`, pastureid).GetFirst(pastureinfo).Error
+	if err != nil {
+		logs.Error(err)
+		return
+	}
+
+	gm.UdFeedtempletPush(pastureid, pastureinfo.Werks, date)
+
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}
+
+func UdUtirPush(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsions := gofasion.NewFasion(string(dataByte))
+	pastureid := fsions.Get("pastureId").ValueStr()
+	date := fsions.Get("date").ValueStr()
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	pastureinfo := new(udPastureInfo)
+	err := tx.SQL(`select werks from pasture where pastureid = ?`, pastureid).GetFirst(pastureinfo).Error
+	if err != nil {
+		logs.Error(err)
+		return
+	}
+
+	gm.UdUtirPush(pastureid, pastureinfo.Werks, date)
+
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}
+
+func UdBarFeedRemainPush(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsions := gofasion.NewFasion(string(dataByte))
+	pastureid := fsions.Get("pastureId").ValueStr()
+	date := fsions.Get("date").ValueStr()
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	pastureinfo := new(udPastureInfo)
+	err := tx.SQL(`select werks from pasture where pastureid = ?`, pastureid).GetFirst(pastureinfo).Error
+	if err != nil {
+		logs.Error(err)
+		return
+	}
+
+	gm.UdBarFeedRemainPush(pastureid, pastureinfo.Werks, date)
+
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}
+
+func UdMaterialIssuePush(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsions := gofasion.NewFasion(string(dataByte))
+	pastureid := fsions.Get("pastureId").ValueStr()
+	date := fsions.Get("date").ValueStr()
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	pastureinfo := new(udPastureInfo)
+	err := tx.SQL(`select werks from pasture where pastureid = ?`, pastureid).GetFirst(pastureinfo).Error
+	if err != nil {
+		logs.Error(err)
+		return
+	}
+
+	gm.UdMaterialIssuePush(pastureid, pastureinfo.Werks, date)
+
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}
+
+func DelFeedTemplet(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsions := gofasion.NewFasion(string(dataByte))
+	ftId := fsions.Get("ftId").ValueStr()
+	// userId := fsions.Get("userId").ValueStr()
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	_, err := tx.Exec(` update feedtemplet set enable = 1 , isdelete = 1  where id = ? `, ftId)
+	if err != nil {
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
+		return
+	}
+
+	// barIdList, err := tx.SQL(`select barid from feedp where ftid = ? `, ftId).QueryString()
+	// if err != nil {
+	// 	logs.Error(err)
+	// 	appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
+	// 	return
+	// }
+
+	_, err = tx.Exec(` update feedp set ftid = 0 , ftname = '',feedweight = 0,ftweight = 0  where ftid = ? `, ftId)
+	if err != nil {
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, errors.New("删除栏舍配方失败"))
+		return
+	}
+
+	_, err = tx.Exec(` update fpdetail set weight = 0 ,ptid =  0,ptuse= 0   where ptid = ? `, ftId)
+	if err != nil {
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, errors.New("删除栏舍配方失败"))
+		return
+	}
+
+	count, _ := tx.SQL(`select count(1)  from lpplan  where ftid = ? `, ftId).Count()
+	if count > 0 {
+		_, err = tx.Exec(` delete from  lpplandtl1   where lppid in(select id from lpplan  where ftid = ?  ) `, ftId)
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusOK, e.ERROR, errors.New("删除子计划失败"))
+			return
+		}
+	}
+	_, err = tx.Exec(` delete from  lpplan    where ftid = ? `, ftId)
+	if err != nil {
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, errors.New("删除计划失败"))
+		return
+	}
+
+	// var barIdStr []string
+	// for _, bar := range barIdList {
+	// 	barIdStr = append(barIdStr, bar["barid"])
+	// }
+
+	// if len(barIdStr) > 0 {
+
+	// 	newFpdDataList, err := tx.Table("fpdetail").Where(`barid in(?)`, barIdStr).Query().List()
+	// 	if err != nil {
+	// 		logs.Error(err)
+	// 		appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
+	// 		return
+	// 	}
+
+	// 	newFeedpList, err := tx.Table("feedp").Where(`barid in(?)`, barIdStr).Query().List()
+	// 	if err != nil {
+	// 		logs.Error(err)
+	// 		appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
+	// 		return
+	// 	}
+
+	// 	now := time.Now()
+	// 	for _, newFpd := range newFpdDataList {
+	// 		_, err := tx.SQL(` insert into fpdetailhistory(pastureid,barid,barname,times,tratio,weight,ptsrate,cowcount,ccountradio,ptid,ptsid,ptuse,ptsuse,supplement,createdate,userId)
+	// 				 values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, newFpd["pastureid"], newFpd["barid"], newFpd["barname"], newFpd["times"],
+	// 			newFpd["tratio"], newFpd["weight"], newFpd["ptsrate"], newFpd["cowcount"], newFpd["ccountradio"],
+	// 			newFpd["ptid"], newFpd["ptsid"], newFpd["ptuse"], newFpd["ptsuse"], newFpd["supplement"], now, userId).Execute()
+	// 		if err != nil {
+	// 			logs.Error(err)
+	// 			appG.Response(http.StatusOK, e.ERROR, false)
+	// 			return
+	// 		}
+	// 	}
+
+	// 	for _, newFeedp := range newFeedpList {
+	// 		_, err := tx.SQL(` insert into feedphistory(pastureid,barname,barid,softccount,ccount,ratio,ccountratio,ftid,
+	// 				ftname,ptsfid,ptsfname,feedweight,ftweight,supplyweight,owner,createdate,userId)
+	// 			values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
+	// 			newFeedp["pastureid"], newFeedp["barname"], newFeedp["barid"],
+	// 			newFeedp["softccount"], newFeedp["ccount"], newFeedp["ratio"],
+	// 			newFeedp["ccountratio"], newFeedp["ftid"], newFeedp["ftname"],
+	// 			newFeedp["ptsfid"], newFeedp["ptsfname"], newFeedp["feedweight"],
+	// 			newFeedp["ftweight"], newFeedp["supplyweight"], newFeedp["owner"], now, userId).Execute()
+	// 		if err != nil {
+	// 			logs.Error(err)
+	// 			appG.Response(http.StatusOK, e.ERROR, false)
+	// 			return
+	// 		}
+	// 	}
+	// }
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}
+
+func checkPlan(tx *xorm.Session, fasion map[string]interface{}, CommonParamMap map[string]interface{}, ParamMap []map[string]interface{}, number int) {
+	data := fasion["parammaps"].(map[string]interface{})
+	plancount, err := tx.Table("downloadedplan").Where(" mydate  = ? ", data["startTime"]).Where(" havebutton = 0 ").Where(" lpplantype in(0,1,2) ").Count()
+	fmt.Println(err)
+	plancount1, err := tx.SQL(`SELECT
+	count( 1 ) 
+FROM
+	(
+	SELECT
+		d.id 
+	FROM
+		downloadedplan d
+		JOIN downloadplandtl1 d1 ON d1.pid = d.id
+		JOIN downloadplandtl1_exec d1e ON d1e.pid = d.id
+		JOIN downloadplandtl2 d2 ON d2.pid = d.id 
+	WHERE
+		d.mydate = ?
+		AND d.havebutton = 0 
+		AND lpplantype IN ( 0, 1, 2 ) 
+		AND ( SELECT count( 1 ) FROM downloadplandtl2 dd2 WHERE dd2.pid = d.id ) = 
+		( SELECT count( 1 ) FROM downloadplandtl2 dd2   WHERE dd2.pid = d.pid  and (select count(1) from downloadplandtl2  where pid = dd2.pid  and fname = dd2.fname   ) = 1 )
+	GROUP BY
+	d.id 
+	) d 
+	 `,
+		data["startTime"]).Count()
+	fmt.Println(err)
+	if plancount != plancount1 && number < 10 {
+		number++
+		ExecDataParam(fasion, CommonParamMap, ParamMap, nil, nil, tx)
+		checkPlan(tx, fasion, CommonParamMap, ParamMap, number)
+	}
+}
+
+func EditPlanSort(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsions := gofasion.NewFasion(string(dataByte))
+	planIdStr := fsions.Get("planId").ValueStr()
+	mydate := fsions.Get("mydate").ValueStr()
+	sort := fsions.Get("sort").ValueStr()
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	tx.Begin()
+
+	type downloadedplan struct {
+		Id   int64 `xorm:"id"`
+		Sort int   `xorm:"sort"`
+		Pid  int64 `xorm:"pid"`
+	}
+	planInfo := new(downloadedplan)
+	err := tx.SQL(`select d.id,d.sort,d.pid from downloadedplan d   where d.id = ? `, planIdStr).GetFirst(planInfo).Error
+	if err != nil {
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
+		tx.Rollback()
+		return
+	}
+	sort1, _ := strconv.Atoi(sort)
+	if sort1 == planInfo.Sort {
+		appG.Response(http.StatusOK, e.ERROR, "计划顺序一致修改失败!")
+		tx.Rollback()
+		return
+	}
+
+	count1, err := tx.SQL(` select count(1) from downloadedplan  where pid =  (select pid from downloadedplan  where sort = ? and mydate = ? )  and mydate = ?    `, sort, mydate, mydate).Count()
+	if err != nil {
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
+		tx.Rollback()
+		return
+	}
+
+	if count1 == 0 {
+		tx.Rollback()
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, "您所排序的数值不存在!")
+		return
+	}
+
+	count, err := tx.SQL(` select count(1) from downloadedplan  where pid =  (select pid from downloadedplan  where sort = ? and mydate = ? )  and havebutton = 1  and mydate = ?    `, sort, mydate, mydate).Count()
+	if err != nil {
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
+		tx.Rollback()
+		return
+	}
+
+	if count > 0 {
+		tx.Rollback()
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败,该计划已执行!")
+		return
+	}
+
+	if planInfo.Sort > sort1 {
+		minSortList, err := tx.SQL(`select min(d.sort) sort from downloadedplan d   where d.mydate = ?  and d.pid = (select pid from downloadedplan  where sort = ? and mydate = ? ) `, mydate, sort, mydate).QueryString()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
+			tx.Rollback()
+			return
+		}
+		var minSort, pidCount int
+		for _, sort := range minSortList {
+			minSort, _ = strconv.Atoi(sort["sort"])
+		}
+
+		planList := make([]*downloadedplan, 0)
+		err = tx.SQL(`select id,d.sort sort,d.pid from downloadedplan d   where d.mydate = ? and  sort >= ? order by sort`, mydate, minSort).Find(&planList)
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
+			tx.Rollback()
+			return
+		}
+
+		planPid := planInfo.Pid
+		planList1 := make([]*downloadedplan, 0)
+		planList2 := make([]*downloadedplan, 0)
+
+		for _, plan := range planList {
+			if plan.Pid == planPid {
+				pidCount++
+				planList1 = append(planList1, plan)
+			} else {
+				planList2 = append(planList2, plan)
+			}
+		}
+		planList1 = append(planList1, planList2...)
+
+		for i, plan := range planList1 {
+			_, err := tx.Exec(` update downloadedplan set sort = ? where id = ? `, minSort+i, plan.Id)
+			if err != nil {
+				logs.Error(err)
+				appG.Response(http.StatusOK, e.ERROR, "修改计划顺序失败!"+err.Error())
+				tx.Rollback()
+				return
+			}
+		}
+	} else {
+		maxSortList, err := tx.SQL(`select max(d.sort) sort from downloadedplan d   where d.mydate = ?  and d.pid = (select pid from downloadedplan  where sort = ? and mydate = ? ) `, mydate, sort, mydate).QueryString()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
+			tx.Rollback()
+			return
+		}
+		var maxSort int
+		for _, sort := range maxSortList {
+			maxSort, _ = strconv.Atoi(sort["sort"])
+		}
+
+		planList := make([]*downloadedplan, 0)
+		err = tx.SQL(`select id,d.sort sort,d.pid from downloadedplan d   where d.mydate = ? and  sort <= ? order by sort`, mydate, maxSort).Find(&planList)
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
+			tx.Rollback()
+			return
+		}
+
+		planPid := planInfo.Pid
+		planList1 := make([]*downloadedplan, 0)
+		planList2 := make([]*downloadedplan, 0)
+
+		for _, plan := range planList {
+			if plan.Pid == planPid {
+				// pidCount++
+				planList1 = append(planList1, plan)
+			} else {
+				planList2 = append(planList2, plan)
+			}
+		}
+		planList2 = append(planList2, planList1...)
+
+		for i, plan := range planList2 {
+			_, err := tx.Exec(` update downloadedplan set sort = ? where id = ? `, i+1, plan.Id)
+			if err != nil {
+				logs.Error(err)
+				appG.Response(http.StatusOK, e.ERROR, "修改计划顺序失败!"+err.Error())
+				tx.Rollback()
+				return
+			}
+		}
+	}
+
+	err = tx.Commit()
+	if err != nil {
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, "修改计划顺序失败!"+err.Error())
+		tx.Rollback()
+		return
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}
+
+func EditDownloadedplanArtificial(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsions := gofasion.NewFasion(string(dataByte))
+	planIdStr := fsions.Get("planId").ValueStr()
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+	tx.Begin()
+
+	planIdList := strings.Split(planIdStr, ",")
+
+	for _, planId := range planIdList {
+		_, err := tx.Exec(` update downloadedplan set artificial = 1 ,havebutton = 1,iscompleted = 1  where id = ?  and havebutton != 1`, planId)
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusOK, e.ERROR, "修改计划状态失败!"+err.Error())
+			tx.Rollback()
+			return
+		}
+	}
+
+	err := tx.Commit()
+	if err != nil {
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, "修改计划状态失败!"+err.Error())
+		tx.Rollback()
+		return
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}
+
+type PlanRFID struct {
+	RFID    string `json:"RFID"`
+	Lweight string `json:"lweight"`
+	Gear    string `json:"gear"`
+	Speed   string `json:"speed"`
+}
+
+func GetPlanRFID(c *gin.Context) {
+	appG := app.Gin{C: c}
+	RFIDStr := c.Query("RFID")
+
+	planRFIDList := make([]*PlanRFID, 0)
+	planRFIDList = append(planRFIDList, &PlanRFID{
+		RFID:    RFIDStr,
+		Lweight: "1411.1",
+		Gear:    "1",
+		Speed:   "10",
+	})
+
+	planRFIDList = append(planRFIDList, &PlanRFID{
+		RFID:    RFIDStr,
+		Lweight: "1322.1",
+		Gear:    "1",
+		Speed:   "10",
+	})
+	planRFIDList = append(planRFIDList, &PlanRFID{
+		RFID:    RFIDStr,
+		Lweight: "1904.1",
+		Gear:    "1",
+		Speed:   "10",
+	})
+	planRFIDList = append(planRFIDList, &PlanRFID{
+		RFID:    RFIDStr,
+		Lweight: "1870.1",
+		Gear:    "1",
+		Speed:   "10",
+	})
+	planRFIDList = append(planRFIDList, &PlanRFID{
+		RFID:    RFIDStr,
+		Lweight: "2041.1",
+		Gear:    "1",
+		Speed:   "10",
+	})
+	appG.Response(http.StatusOK, e.SUCCESS, planRFIDList)
+}
+
+type tmrEquipmentMuster struct {
+	A string
+	N string
+}
+
+func GetTmrEquipmentMuster(c *gin.Context) {
+	appG := app.Gin{C: c}
+	id := c.Query("id")
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	dataList, err := tx.SQL(`  select *  from tmr_equipment_muster where pid = ?  `, id).QueryString()
+	if err != nil {
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, err.Error())
+
+		return
+	}
+
+	tmrEquipmentMusterList := make([]*tmrEquipmentMuster, 0)
+
+	for _, data := range dataList {
+		json.Unmarshal([]byte(data["gptjson"]), &tmrEquipmentMusterList)
+		for _, g := range tmrEquipmentMusterList {
+			a, _ := strconv.ParseFloat(g.A, 64)
+			n, _ := strconv.ParseFloat(g.N, 64)
+			a1, n1 := ddmmtoddd(a, n)
+			g.A = fmt.Sprintf("%f", n1)
+			g.N = fmt.Sprintf("%f", a1)
+		}
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, tmrEquipmentMusterList)
+}
+
+func ddmmtoddd(lng, lat float64) (float64, float64) {
+	lngDegree := fmt.Sprintf("%f", lng/100)
+	lngDegreefloat, _ := strconv.ParseFloat(strings.Split(lngDegree, ".")[1], 64)
+
+	lngDegreeInt := int(lngDegreefloat * 1000000)
+	dd := lngDegreeInt / 100 * 100 / 60
+	fmt.Println(dd)
+	lngStr := strings.Split(lngDegree, ".")[0] + "." + strings.Replace(fmt.Sprintf("%d", lngDegreeInt/100*100/60), ".", "", 0)
+
+	latDegree := fmt.Sprintf("%f", lat/100)
+	// latDegreeInt, _ := strconv.ParseInt(strings.Split(latDegree, ".")[1], 10, 64)
+
+	latDegreefloat, _ := strconv.ParseFloat(strings.Split(latDegree, ".")[1], 64)
+	latDegreeInt := int(latDegreefloat * 1000000)
+	latStr := strings.Split(latDegree, ".")[0] + "." + strings.Replace(fmt.Sprintf("%d", latDegreeInt/100*100/60), ".", "", 0)
+
+	a, _ := strconv.ParseFloat(lngStr, 64)
+	b, _ := strconv.ParseFloat(latStr, 64)
+	return coordtransform.WGS84toGCJ02(b, a)
+}

+ 274 - 0
http/handle/api/pusher.go

@@ -0,0 +1,274 @@
+package api
+
+import (
+	"encoding/json"
+	"fmt"
+	"io/ioutil"
+	"net/http"
+	"strconv"
+	"strings"
+	"time"
+	"tmr-watch/http/handle/restful"
+	"tmr-watch/pkg/app"
+	"tmr-watch/pkg/e"
+
+	"github.com/Anderson-Lu/gofasion/gofasion"
+	"github.com/gin-gonic/gin"
+)
+
+// 三个接口,车 顺序 时间  描述   牛舍
+// 执行接口    会  哪些牛舍  具体那个牛舍列出来
+// 第三个   gps
+
+type Pusher struct {
+	Id      int          `xorm:"id" json:"id"`
+	EqCode  string       `xorm:"eqcode" json:"eqCode"`
+	Sort    int64        `xorm:"sort" json:"sort"`
+	Date    string       `xorm:"date" json:"date"`
+	Remark  string       `xorm:"remark" json:"remark"`
+	BarId   string       `xorm:"barId" json:"barId"`
+	BarName string       `xorm:"barName" json:"barName"`
+	BarList []*PusherBar `json:"barList"`
+}
+
+// Id        int64  `xorm:"id" json:"id"`
+// TmrId     int64  `xorm:"tmrId" json:"tmrId"`
+// PastureId int64  `xorm:"pastureId" json:"pastureId"`
+// Date      string `xorm:"date" json:"date"`
+// Remark    string `xorm:"remark" json:"remark"`
+// Enable    int64  `xorm:"enable" json:"enable"`
+// BarId     string `xorm:"barId" json:"barId"`
+// BName     string `xorm:"bname" json:"bname"`
+// TName     string `xorm:"tname" json:"tname"`
+
+type PusherBar struct {
+	BarId   int64  `json:"barId"`
+	BarName string `json:"barName"`
+}
+
+func GetPusherList(c *gin.Context) {
+	appG := app.Gin{C: c}
+	// dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	// fsion := gofasion.NewFasion(string(dataByte))
+	// date := fsion.Get("date").ValueDefaultStr(time.Now().Format("2006-01-02"))
+	// eqcode := fsion.Get("eqCode").ValueDefaultStr("")
+
+	date := c.Query("date")
+	eqCode := c.Query("eqCode")
+
+	if date == "" {
+		date = time.Now().Format("2006-01-02")
+	} else {
+		_, err := time.Parse("2006-01-02", date)
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, fmt.Sprintf("%s 日期解析错误!", date))
+			return
+		}
+	}
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	tmrEquipmentList := make([]*Pusher, 0)
+	err := tx.SQL(` select  te.*,t.eqcode  from  tmr_equipment te join tmr t on t.id = te.tmrId  where (t.eqcode  = ? or ? = '' )  
+	and  te.id not in(select id from tmr_equipment_date where plandate =  ? )  and te.enable = 1   order by te.date`, eqCode, eqCode, date).Find(&tmrEquipmentList)
+	if err != nil {
+		appG.Response(http.StatusInternalServerError, e.ERROR, err)
+		return
+	}
+
+	for i, tmr := range tmrEquipmentList {
+		tmr.Sort = int64(i + 1)
+		barList := make([]*Bar, 0)
+		err := tx.Table("bar").In("id", strings.Split(tmr.BarId, ",")).Find(&barList)
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, err)
+			return
+		}
+
+		tmr.Date = fmt.Sprintf("%s %s", date, tmr.Date)
+		var barNameList []string
+		for _, bar := range barList {
+			barNameList = append(barNameList, bar.BName)
+		}
+		tmr.BarName = strings.Join(barNameList, ",")
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, tmrEquipmentList)
+}
+
+type PusherGPS struct {
+	Id        int    `json:"id"`
+	EndDate   string `json:"endDate"`
+	StartDate string `json:"startDate"`
+	GPS       []*GPS `json:"GPS"`
+}
+
+type GPS struct {
+	A string `json:"A"`
+	N string `json:"N"`
+}
+
+func EditPusherGPS(c *gin.Context) {
+	appG := app.Gin{C: c}
+	pusherGPS := new(PusherGPS)
+
+	if err := c.ShouldBind(&pusherGPS); err != nil {
+		fmt.Println(err)
+		appG.Response(http.StatusInternalServerError, e.ERROR, false)
+		return
+	}
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	gpsByte, _ := json.Marshal(pusherGPS.GPS)
+
+	_, err := tx.Exec(` INSERT INTO tmr_equipment_date (pid,tmrId,pastureId,date,remark,enable,barId,plandate,startdate,enddate) 
+	select id,tmrId,pastureId,date,remark,enable,barId,now(),?,? from tmr_equipment  where id = ?     ON DUPLICATE KEY UPDATE  startdate = ? ,enddate = ?  `,
+		pusherGPS.StartDate, pusherGPS.EndDate, pusherGPS.Id, pusherGPS.StartDate, pusherGPS.EndDate)
+	if err != nil {
+		fmt.Println(err)
+		appG.Response(http.StatusInternalServerError, e.ERROR, err)
+		return
+	}
+
+	data := new(TMREquipmentDate)
+	_, err = tx.SQL(`  select id,pid,plandate  from tmr_equipment_date  where pid = ? and  plandate = ? `, pusherGPS.Id, time.Now().Format("2006-01-02")).Get(data)
+	if err != nil {
+		fmt.Println(err)
+		appG.Response(http.StatusInternalServerError, e.ERROR, err)
+		return
+	}
+
+	_, err = tx.Exec(` INSERT INTO tmr_equipment_muster (pid,gptjson) 
+	values(?,?) `,
+		data.Id, string(gpsByte))
+	if err != nil {
+		fmt.Println(err)
+		appG.Response(http.StatusInternalServerError, e.ERROR, err)
+		return
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, true)
+}
+
+type TMREquipment struct {
+	Id        string `xorm:"id" json:"id"`
+	TmrId     string `xorm:"tmrId" json:"tmrId"`
+	PastureId string `xorm:"pastureId" json:"pastureId"`
+	Date      string `xorm:"date" json:"date"`
+	Remark    string `xorm:"remark" json:"remark"`
+	Enable    int64  `xorm:"enable" json:"enable"`
+	BarId     string `xorm:"barId" json:"barId"`
+	BName     string `xorm:"bname" json:"bname"`
+	TName     string `xorm:"tname" json:"tname"`
+}
+
+type TMREquipmentDate struct {
+	Id   string `xorm:"id" json:"id"`
+	Pid  string `xorm:"pid" json:"pid"`
+	Date string `xorm:"plandate" json:"plandate"`
+}
+
+func AddTmrEquipment(c *gin.Context) {
+	appG := app.Gin{C: c}
+	req := new(TMREquipment)
+	if err := c.ShouldBind(&req); err != nil {
+		appG.Response(http.StatusInternalServerError, e.ERROR, false)
+		return
+	}
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	if req.Id == "" {
+		_, err := tx.SQL(` INSERT INTO tmr_equipment (tmrId, pastureId, date, remark, enable, barId) VALUES ( ?, ?, ?, ?, ?, ?) `,
+			req.TmrId, req.PastureId, req.Date, req.Remark, req.Enable, req.BarId).Execute()
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, err)
+			return
+		}
+	} else {
+		_, err := tx.SQL(`UPDATE tmr_equipment SET tmrId = ? , pastureId = ? , date = ? , remark = ? , enable = ? , barId = ? WHERE id =  ? `,
+			req.TmrId, req.PastureId, req.Date, req.Remark, req.Enable, req.BarId, req.Id).Execute()
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, err)
+			return
+		}
+	}
+	appG.Response(http.StatusOK, e.SUCCESS, true)
+}
+
+type GetTmrEquipmentResp struct {
+	TmrEquipmentList []*TMREquipment `json:"data"`
+	Count            int64           `json:"count"`
+}
+
+func GetTmrEquipment(c *gin.Context) {
+	appG := app.Gin{C: c}
+	pastureId := c.Query("pastureId")
+	offsetStr := c.Query("offset")
+	pageStr := c.Query("page")
+
+	offset, _ := strconv.Atoi(offsetStr)
+	page, _ := strconv.Atoi(pageStr)
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+	tmrEquipmentList := make([]*TMREquipment, 0)
+	err := tx.SQL(` select  te.*,t.tname  from  tmr_equipment te join tmr t on t.id = te.tmrId  where te.pastureId  = ?   order by te.date limit ?,? `, pastureId, offset-1, page).Find(&tmrEquipmentList)
+	if err != nil {
+		appG.Response(http.StatusInternalServerError, e.ERROR, err)
+		return
+	}
+
+	for _, tmr := range tmrEquipmentList {
+		barList := make([]*Bar, 0)
+		err := tx.Table("bar").In("id", strings.Split(tmr.BarId, ",")).Find(&barList)
+		if err != nil {
+			appG.Response(http.StatusInternalServerError, e.ERROR, err)
+			return
+		}
+
+		var barNameList []string
+		for _, bar := range barList {
+			barNameList = append(barNameList, bar.BName)
+		}
+		tmr.BName = strings.Join(barNameList, ",")
+	}
+
+	resp := new(GetTmrEquipmentResp)
+	count, err := tx.SQL(`select count(1)  from  tmr_equipment te join tmr t  on t.id = te.tmrId   where te.pastureId  = ?`, pastureId).Count()
+	if err != nil {
+		appG.Response(http.StatusInternalServerError, e.ERROR, err)
+		return
+	}
+	resp.Count = count
+	resp.TmrEquipmentList = tmrEquipmentList
+
+	appG.Response(http.StatusOK, e.SUCCESS, resp)
+}
+
+func DelTmrEquipment(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsion := gofasion.NewFasion(string(dataByte))
+	id := fsion.Get("id").ValueStr()
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	_, err := tx.SQL(`delete from  tmr_equipment  WHERE id =  ? `, id).Execute()
+	if err != nil {
+		appG.Response(http.StatusInternalServerError, e.ERROR, err)
+		return
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, true)
+}
+
+type Bar struct {
+	Id    int64  `xorm:"id" json:"id"`
+	BName string `xorm:"bname" json:"bname"`
+}

+ 167 - 9
http/handle/api/report.go

@@ -3,6 +3,7 @@ package api
 import (
 	"encoding/json"
 	"fmt"
+	"math"
 	"sort"
 	"strconv"
 	"strings"
@@ -15,7 +16,7 @@ import (
 )
 
 //包含报表模块前端需要的各种数据格式转换
-func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Session, checked string, offset, count, typea int) (queryData map[string]interface{}, err error) {
+func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Session, checked string, offset, count, typea, mode int) (queryData map[string]interface{}, err error) {
 
 	sql, p := restful.GetSqlByNameDBT(sqlnamestr, tx)
 	s_params := make([]interface{}, 0)
@@ -41,6 +42,7 @@ func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Ses
 	}
 	queryList2, err := tx.SQL(sql2, s_params2...).Query().List()
 	var feednamesort []string
+	var feedcodelist []string
 	if len(queryList2) > 0 {
 		for i := 0; i < len(queryList2); i++ {
 			feednamesort = append(feednamesort, queryList2[i]["fname"].(string))
@@ -59,7 +61,7 @@ func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Ses
 		}
 	}
 	// var queryList3 []map[string]interface{}
-	// queryList3 = make([]map[string]interface{}, 0)
+	feedDataList := make([]map[string]interface{}, 0)
 	var feednamesort3 []string
 	if sql3 != "" {
 		queryList3, err := tx.SQL(sql3, s_params3...).Query().List()
@@ -70,7 +72,9 @@ func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Ses
 		if len(queryList3) > 0 {
 			for z := 0; z < len(queryList3); z++ {
 				feednamesort3 = append(feednamesort3, queryList3[z]["feedname"].(string))
+				feedcodelist = append(feedcodelist, queryList3[z]["feedcode"].(string))
 			}
+			feedDataList = append(feedDataList, queryList3...)
 		}
 	}
 
@@ -93,7 +97,7 @@ func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Ses
 	// 根据名称选择不通类型的转换-(可自动扩展,不需要使用之前的)
 	switch temstr {
 	case "getAccurac", "getFeedEff":
-		queryData, err = getAccuracy(queryList) // 不定参数
+		queryData, err = getAccuracy(queryList, "2006-01-02") // 不定参数
 	case "getprocess":
 		//queryData, err = getAccuracyV3v1(queryList)
 		queryData, err = getAccuracyV3(queryList)
@@ -125,7 +129,13 @@ func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Ses
 			}
 		}
 		queryListSum, _ := tx.SQL(sql1, s_params1...).Query().List()
-		queryData, err = getAccuracyV4(queryList, queryListSum, checked, feednamesort3, typea)
+		if mode == 0 {
+			queryData, err = getAccuracyV4(queryList, queryListSum, checked, feednamesort3, typea)
+		} else {
+			queryData, _ = getAccuracyV41(queryList, queryListSum, checked, feednamesort3, typea, feedDataList)
+		}
+		queryData["feedcode"] = feedcodelist
+
 	case "getPriceAn":
 		queryData, err = getAccuracyV5(queryList)
 	case "getJT1Accu":
@@ -1094,7 +1104,7 @@ func getAccuracyV2(queryList []map[string]interface{}) (map[string]interface{},
 	queryData["data"] = queryList
 	return queryData, nil
 }
-func getAccuracy(queryList []map[string]interface{}) (map[string]interface{}, error) {
+func getAccuracy(queryList []map[string]interface{}, layout string) (map[string]interface{}, error) {
 
 	queryData := make(map[string]interface{})
 	chartData := make(map[string]interface{})
@@ -1131,6 +1141,8 @@ func getAccuracy(queryList []map[string]interface{}) (map[string]interface{}, er
 		}
 		if b != queryList[i]["名称"] {
 			if a < len(e2)-1 {
+				eee := len(e2) - a
+				fmt.Println(eee)
 				for k := 0; k < len(e2)-a; k++ {
 					data["data"] = append(data["data"], "")
 				}
@@ -1142,7 +1154,7 @@ func getAccuracy(queryList []map[string]interface{}) (map[string]interface{}, er
 		}
 		switch queryList[i]["日期"].(type) {
 		case string:
-			dates, _ := time.Parse("2006-01-02", queryList[i]["日期"].(string))
+			dates, _ := time.Parse(layout, queryList[i]["日期"].(string))
 			dates1 := ""
 			if a < len(e2)-1 {
 				dates1 = e2[a]
@@ -1153,15 +1165,21 @@ func getAccuracy(queryList []map[string]interface{}) (map[string]interface{}, er
 				if e2[a] != queryList[i]["日期"].(string) {
 					if e2[a] < queryList[i]["日期"].(string) {
 						dates1 = queryList[i]["日期"].(string)
-						dates, _ = time.Parse("2006-01-02", e2[a])
+						dates, _ = time.Parse(layout, e2[a])
 						for ; a < len(e2)-1; a++ {
 							if e2[a] >= queryList[i]["日期"].(string) {
 								break
 							}
 						}
 					}
-					for ; dates.Format("2006-01-02") < dates1; dates = dates.Add(24 * time.Hour) {
-						data["data"] = append(data["data"], "")
+					if layout == "2006-01-02" {
+						for ; dates.Format(layout) < dates1; dates = dates.Add(24 * time.Hour) {
+							data["data"] = append(data["data"], "")
+						}
+					} else if layout == "2006-01" {
+						for ; dates.Format(layout) < dates1; dates = dates.AddDate(0, 1, 0) {
+							data["data"] = append(data["data"], "")
+						}
 					}
 				}
 			}
@@ -1247,3 +1265,143 @@ func GetprocessAnalysisTB(parammaps *gofasion.Fasion, tx *xorm.Session, quertDat
 	query1["realWandT"] = realWandT
 	return query1, nil
 }
+
+type Columns struct {
+	Prop  string `json:"prop"`
+	Label string `json:"label"`
+}
+
+func getAccuracyV41(queryList []map[string]interface{}, queryListSum []map[string]interface{}, checked string, feednamesort3 []string, typea int, feednameCodes []map[string]interface{}) (map[string]interface{}, error) {
+	columns := make([]*Columns, 0)
+	columns = append(columns, &Columns{
+		Prop:  "A",
+		Label: "饲料编码",
+	})
+	columns = append(columns, &Columns{
+		Prop:  "B",
+		Label: "饲料名称",
+	})
+
+	label := "类别"
+
+	// column1 := new(Columns)
+
+	columns1 := make([]*Columns, 0)
+	dataList := make([]map[string]interface{}, 0)
+
+	for i := 0; i < len(queryList); i++ {
+		label = queryList[i]["typestr"].(string)
+		exist1 := false
+		for _, data := range dataList {
+			if data["B"].(string) == queryList[i]["feedname"].(string) {
+				exist1 = true
+			}
+		}
+
+		if !exist1 {
+			data1 := make(map[string]interface{}, 0)
+			data2 := make(map[string]interface{}, 0)
+			for _, v := range feednameCodes {
+				if v["feedname"].(string) == queryList[i]["feedname"].(string) {
+					data1["A"] = v["feedcode"]
+					data2["A"] = v["feedcode"]
+					break
+				}
+			}
+			data1["B"] = queryList[i]["feedname"]
+			data1["C"] = "理论"
+			// data1[queryList[i]["fname"].(string)] = 0
+			dataList = append(dataList, data1)
+			data2["B"] = queryList[i]["feedname"]
+			data2["C"] = "实际"
+			// data2[queryList[i]["fname"].(string)] = 0
+			dataList = append(dataList, data2)
+		}
+
+		column := new(Columns)
+		column.Prop = queryList[i]["fname"].(string)
+		column.Label = queryList[i]["fname"].(string)
+
+		exist := false
+		for _, c := range columns1 {
+			if c.Prop == queryList[i]["fname"].(string) {
+				exist = true
+			}
+		}
+		if exist {
+			continue
+		}
+		columns1 = append(columns1, column)
+	}
+
+	for _, data := range dataList {
+		for _, c := range columns1 {
+			data[c.Prop] = 0
+		}
+	}
+
+	data1 := make(map[string]interface{}, 0)
+	data2 := make(map[string]interface{}, 0)
+	data1["B"] = "合计"
+	data1["C"] = "理论"
+	data2["B"] = "合计"
+	data2["C"] = "实际"
+
+	for _, c := range columns1 {
+		if c.Prop != "合计" {
+			data1[c.Prop] = 0.0
+			data2[c.Prop] = 0.0
+		}
+	}
+
+	columns = append(columns, &Columns{
+		Prop:  "C",
+		Label: label,
+	})
+
+	columns = append(columns, columns1...)
+	for _, data := range dataList {
+		for i := 0; i < len(queryList); i++ {
+			if queryList[i]["feedname"].(string) == data["B"] {
+				if data["C"].(string) == "理论" {
+					f1, _ := strconv.ParseFloat(fmt.Sprintf("%v", queryList[i]["lweight"]), 64)
+					data[queryList[i]["fname"].(string)] = Round(f1, 2)
+				} else {
+					if queryList[i]["actualweightminus"] == nil {
+						data[queryList[i]["fname"].(string)] = 0.0
+					} else {
+						f1, _ := strconv.ParseFloat(fmt.Sprintf("%v", queryList[i]["actualweightminus"]), 64)
+						data[queryList[i]["fname"].(string)] = Round(f1, 2)
+					}
+				}
+			}
+		}
+	}
+
+	for _, data := range dataList {
+		for _, c := range columns1 {
+			if c.Prop != "合计" {
+				if data["C"].(string) == "理论" {
+					f1, _ := strconv.ParseFloat(fmt.Sprintf("%v", data1[c.Prop]), 64)
+					f2, _ := strconv.ParseFloat(fmt.Sprintf("%v", data[c.Prop]), 64)
+					data1[c.Prop] = Round(f1+f2, 2)
+				} else {
+					f1, _ := strconv.ParseFloat(fmt.Sprintf("%v", data2[c.Prop]), 64)
+					f2, _ := strconv.ParseFloat(fmt.Sprintf("%v", data[c.Prop]), 64)
+					data2[c.Prop] = Round(f1+f2, 2)
+				}
+			}
+		}
+	}
+	dataList = append(dataList, data1)
+	dataList = append(dataList, data2)
+
+	respData := make(map[string]interface{})
+	respData["data"] = dataList
+	respData["columns"] = columns
+	return respData, nil
+}
+
+func Round(number float64, size int) float64 {
+	return math.Round(number*100) / 100
+}

+ 99 - 69
http/handle/api/scheduled.go

@@ -129,21 +129,20 @@ func CronScheduled(ctx context.Context) {
 		}
 	})
 	dayCron.Start()
-
-	//
+	// udFeedSync(pastureinfo)
 	// //圣牧自动同步前天有进行中的任务
-	manualUdData(pastureinfo)
-
-	//现代牧业sap同步
+	// manualUdData(pastureinfo)
+	// gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
 	// xdmy := cron.New()
-	// xdmy.AddFunc("50 04 * * *", func() {
-	// 	sap.SyncMaterialOutbound()
+	// err = xdmy.AddFunc("0 30 8 * * *", func() {
+	// 	// 	//现代牧业sap同步
+	// 	// sap.SyncMaterialOutbound()
+	// 	// 	// 光明ud同步
+	// 	// 	fmt.Println(time.Now())
+	// 	gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
 	// })
 	// xdmy.Start()
-
-	//光明ud同步
-	// gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
-
+	// InitMqttClient()
 }
 
 type ScheduledInfo struct {
@@ -658,6 +657,7 @@ func (h *ScheduledDown) SyncFeed(pastureid string, feedList []interface{}) {
 		insertSql := `insert into feed(id,pastureid,feedcode,fname,fclassid,fclass,dry)VALUES(?,?,?,?,?,?,?) 
 		ON DUPLICATE KEY UPDATE fname = ? ,dry = ? `
 		_, err = tx.SQL(insertSql, ids, pastureid, feedcode, fname, fclassid, fclass, dry, fname, dry).Execute()
+		fmt.Println(feedcode, fname, fclassid)
 		if err != nil {
 			tx.Rollback()
 			logs.Error("syncFeed-error-5:", err)
@@ -1045,76 +1045,76 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
 }
 
 func manualUdData(pastureinfo *udPastureInfo) {
-	// c := cron.New()
-	// c.AddFunc("10 06 * * *", func() {
-	tx := restful.Engine.NewSession()
-	defer tx.Close()
-	now := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
-	// now := "2023-02-22"
-	dataList, err := tx.SQL(" select id  from downloadedplan where mydate = ? ", now).QueryString()
-	if err != nil {
-		logging.Error("manualUdData-error-1:", err)
-		return
-	}
-	var idList []string
-	for _, data := range dataList {
-		idList = append(idList, data["id"])
-	}
+	c := cron.New()
+	c.AddFunc("10 06 * * *", func() {
+		tx := restful.Engine.NewSession()
+		defer tx.Close()
+		now := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
+		// now := "2023-02-22"
+		dataList, err := tx.SQL(" select id  from downloadedplan where mydate = ? ", now).QueryString()
+		if err != nil {
+			logging.Error("manualUdData-error-1:", err)
+			return
+		}
+		var idList []string
+		for _, data := range dataList {
+			idList = append(idList, data["id"])
+		}
 
-	upList := make([]*ScheduledUpInfo, 0)
-	up := tx.Table("scheduled_up")
+		upList := make([]*ScheduledUpInfo, 0)
+		up := tx.Table("scheduled_up")
 
-	up.Where("company = ? ", "ud")
-	up.Where("datatype in (3,4)")
-	up.Where("automatic = 1")
-	err = up.Find(&upList)
-	if err != nil {
-		logging.Error("manualUdData-error-2: ", err)
-		return
-	}
+		up.Where("company = ? ", "ud")
+		up.Where("datatype in (3,4)")
+		up.Where("automatic = 1")
+		err = up.Find(&upList)
+		if err != nil {
+			logging.Error("manualUdData-error-2: ", err)
+			return
+		}
 
-	for _, item := range upList {
-		if item.Datasql != "" {
-			// if item.Datatype == 4 {
-			targetdataList := strings.Split(item.Targetdata, ",")
-			var args []interface{}
-			for _, targetdata := range targetdataList {
-				if targetdata == "pastureid" {
-					args = append(args, pastureinfo.Pastureid)
-				} else if targetdata == "idlist" {
-					item.Datasql = strings.ReplaceAll(item.Datasql, "idlist", strings.Join(idList, ","))
-				} else if targetdata == "date" {
-					args = append(args, now)
+		for _, item := range upList {
+			if item.Datasql != "" {
+				// if item.Datatype == 4 {
+				targetdataList := strings.Split(item.Targetdata, ",")
+				var args []interface{}
+				for _, targetdata := range targetdataList {
+					if targetdata == "pastureid" {
+						args = append(args, pastureinfo.Pastureid)
+					} else if targetdata == "idlist" {
+						item.Datasql = strings.ReplaceAll(item.Datasql, "idlist", strings.Join(idList, ","))
+					} else if targetdata == "date" {
+						args = append(args, now)
+					}
 				}
-			}
-			data, err := tx.SQL(item.Datasql, args...).Query().List()
-			if err != nil {
-				logging.Error("manualUdData-error-3: ", err)
-				continue
-			}
-			if len(data) > 0 {
-				databyte, err := json.Marshal(data)
+				data, err := tx.SQL(item.Datasql, args...).Query().List()
 				if err != nil {
-					logging.Error("manualUdData-error-4: ", err)
-					continue
-				}
-				exist, err := tx.SQL(`select * from saplog where pastureId = ? and msgtype = ? and date_format(dataDate ,'%Y-%m-%d') = ?  `,
-					pastureinfo.Pastureid, item.Datatype, now).Exist()
-				if exist {
+					logging.Error("manualUdData-error-3: ", err)
 					continue
 				}
+				if len(data) > 0 {
+					databyte, err := json.Marshal(data)
+					if err != nil {
+						logging.Error("manualUdData-error-4: ", err)
+						continue
+					}
+					exist, err := tx.SQL(`select * from saplog where pastureId = ? and msgtype = ? and date_format(dataDate ,'%Y-%m-%d') = ?  `,
+						pastureinfo.Pastureid, item.Datatype, now).Exist()
+					if exist {
+						continue
+					}
 
-				tx.Exec(` insert into saplog(pastureId,request,response,status,msgtext,createTime,msgtype,dataDate,url)
+					tx.Exec(` insert into saplog(pastureId,request,response,status,msgtext,createTime,msgtype,dataDate,url)
 					values(?,?,?,?,?,now(),?,?,?)`, pastureinfo.Pastureid, string(databyte), "", "", "", item.Datatype, now, "https://wdc.unidairy.cn/copartner_uploads/")
 
-				var method string
-				UDPostPush1(fmt.Sprintf(item.Package, string(databyte), len(data)), method)
+					var method string
+					UDPostPush1(fmt.Sprintf(item.Package, string(databyte), len(data)), method)
+				}
+				// }
 			}
-			// }
 		}
-	}
-	// })
-	// c.Start()
+	})
+	c.Start()
 
 	c1 := cron.New()
 	c1.AddFunc("01 18 * * *", func() {
@@ -1131,6 +1131,7 @@ func manualUdData(pastureinfo *udPastureInfo) {
 	c3 := cron.New()
 	c3.AddFunc("59 23 * * *", func() {
 		udFeedpSync(pastureinfo)
+		udFeedSync(pastureinfo)
 	})
 	c3.Start()
 
@@ -1800,3 +1801,32 @@ func UdFeedpSync(c *gin.Context) {
 	appG.Response(http.StatusOK, e.SUCCESS, true)
 	// return
 }
+
+func udFeedSync(pastureinfo *udPastureInfo) error {
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	downList := make([]*ScheduledDownInfo, 0)
+	down := tx.Table("scheduled_down")
+
+	down.Where("company = ? ", "ud")
+	down.Where("methods = ? ", "SyncFeed")
+	err := down.Find(&downList)
+	if err != nil {
+		log.Println("UpdateDown-error-1: ", err)
+		return err
+	}
+
+	for _, item := range downList {
+		list := httpGetMC(item.Addres, item.Targetdata)
+		if item.Methods != "" {
+			s := ScheduledDown{}
+			value := reflect.ValueOf(&s)
+			f := value.MethodByName(item.Methods)
+			f.Call([]reflect.Value{reflect.ValueOf(pastureinfo.Pastureid), reflect.ValueOf(list)})
+
+		}
+
+	}
+	return nil
+}

+ 0 - 1
http/handle/api/spillage.go

@@ -1221,7 +1221,6 @@ func UpdateLpplan(c *gin.Context) {
 		for _, data := range dataList {
 			updateStatus := true
 			for _, old := range oldList {
-				fmt.Println(old.Get("lweight").ValueStr(), data["lweight"], old.Get("barid").ValueInt64(), data["barid"], "aaaaaaaaaaa")
 				if (old.Get("lweight").ValueStr() == data["lweight"].(string)) && old.Get("barid").ValueInt64() == data["barid"].(int64) {
 					updateStatus = false
 					break

+ 4 - 0
http/handle/api/upload.go

@@ -758,6 +758,10 @@ func GetBarfeedremainExcel(c *gin.Context) {
 	cell.SetStyle(style)
 	cell = row.AddCell()
 
+	cell.SetValue("干物质")
+	cell.SetStyle(style)
+	cell = row.AddCell()
+
 	cell.SetValue("班次(第一班/第二班/第三班)")
 	cell.SetStyle(style)
 	cell = row.AddCell()

+ 5 - 2
http/handle/api/user.go

@@ -57,8 +57,11 @@ func Auth(c *gin.Context) {
 	}
 
 	if !isExist {
-		appG.Response(http.StatusInternalServerError, e.ERROR_AUTH, "")
-		return
+		isExist, err = authService.MD5Check()
+		if !isExist {
+			appG.Response(http.StatusInternalServerError, e.ERROR_AUTH, "")
+			return
+		}
 	}
 
 	token, err := util.GenerateToken(reqInfo.Username, reqInfo.Password)

+ 223 - 114
http/handle/gm/udservice.go

@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"io/ioutil"
 	"net/http"
+	"strings"
 	"time"
 	"tmr-watch/conf/setting"
 	"tmr-watch/http/handle/restful"
@@ -17,15 +18,21 @@ import (
 
 // "../../../pkg/setting"
 // "../../../routers/restful"
-
+// http://172.16.86.95:8080/copartner_downloads?equipmentId=48ffa4de-7870-4b18-a052-9f8d3a46089a&farmId=ef275fb06fd847d88422517773e5a616&method=downloadpen
 func GmUdSync(pastureId, farmId string) {
-	UdBarFeedRemainPush(pastureId, farmId)
+	UdMaterialIssuePush(pastureId, farmId, "")
+	UdFeedtempletPush(pastureId, farmId, "")
+	UdUtirPush(pastureId, farmId, "")
+	UdBarFeedRemainPush(pastureId, farmId, "")
+
+	UdBarSync(pastureId, farmId)
+	UdFeedSync(pastureId, farmId)
 }
 
 func UdBarSync(pastureId, farmId string) {
 	url := fmt.Sprintf("http://172.16.86.95:8080/copartner_downloads?equipmentId=48ffa4de-7870-4b18-a052-9f8d3a46089a&farmId=%s&method=downloadpen", farmId)
 	barByte := getPull(url)
-
+	fmt.Println(string(barByte))
 	barMap := make(map[string]interface{})
 	json.Unmarshal(barByte, &barMap)
 
@@ -33,38 +40,44 @@ func UdBarSync(pastureId, farmId string) {
 	defer tx.Close()
 	tx.Exec(` insert into saplog(pastureId,request,response,status,msgtext,createTime,msgtype,dataDate,url)
 	values(?,?,?,?,?,now(),?,now(),?)`, pastureId, "", string(barByte), "", "", 3, url)
-
-	for _, item := range barMap["msg"].([]interface{}) {
-		bar := item.(map[string]interface{})
-		barname := bar["barname"].(string) + "_ud"
-		barExist, _ := tx.SQL(` select count(1) from bar where bcode = ? `, bar["barcode"]).Exist()
-		tx.Exec(`insert into bar(pastureid,bcode,bname)values(?,?,?)   ON DUPLICATE KEY UPDATE  bname = ? `, pastureId, bar["barcode"], barname, barname)
-		_, _ = tx.Exec(`insert into feedp(pastureid,barid,barname,softccount,ccount)values(?,(select id from bar where bcode=  ? and pastureId = ? ),?,?,?)
-		 ON DUPLICATE KEY UPDATE  softccount = ? `,
-			pastureId, bar["barcode"], pastureId, barname, bar["cowcount"], bar["cowcount"], bar["cowcount"])
-		// fmt.Println(err)
-		if !barExist {
-			tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
-				pastureId, bar["barcode"], 1, barname)
-			tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
-				pastureId, bar["barcode"], 2, barname)
-			tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
-				pastureId, bar["barcode"], 3, barname)
-			tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
-				pastureId, bar["barcode"], 4, barname)
-			tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
-				pastureId, bar["barcode"], 5, barname)
-			tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
-				pastureId, bar["barcode"], 6, barname)
+	if len(barMap) > 0 {
+		if barMap["status"].(string) != "ok" {
+			return
+		}
+		for _, item := range barMap["msg"].([]interface{}) {
+			bar := item.(map[string]interface{})
+			barname := bar["barname"].(string)
+			count, _ := tx.Table("bar").Where("pastureId = ? ", pastureId).Count()
+			barExist, _ := tx.SQL(` select count(1) from bar where bcode = ? `, bar["barcode"]).Exist()
+			_, err := tx.Exec(`insert into bar(pastureid,bcode,bname,sort)values(?,?,?,?)   ON DUPLICATE KEY UPDATE  bname = ?,udname = ?  `, pastureId, bar["barcode"], barname, count+1, barname, barname)
+			_, err = tx.Exec(`insert into feedp(pastureid,barid,barname,softccount,ccount)values(?,(select id from bar where bcode=  concat(?) and pastureId = ? ),?,?,?)
+		 ON DUPLICATE KEY UPDATE  softccount = ?  `,
+				//  tx.Exec(`update bar  `, pastureId, bar["barcode"], barname, count+1, barname, barname)
+
+				pastureId, bar["barcode"], pastureId, barname, bar["cowcount"], bar["cowcount"], bar["cowcount"])
+			fmt.Println(bar["barcode"], barname, bar["cowcount"], pastureId, err)
+			if !barExist {
+				tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
+					pastureId, bar["barcode"], 1, barname)
+				tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
+					pastureId, bar["barcode"], 2, barname)
+				tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
+					pastureId, bar["barcode"], 3, barname)
+				tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
+					pastureId, bar["barcode"], 4, barname)
+				tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
+					pastureId, bar["barcode"], 5, barname)
+				tx.Exec(`insert into fpdetail(pastureId,barid,weight,ptsrate,times,barname) values(?,(select id from bar where bcode=  ? and pastureId = ? ),0,0,?,?)`,
+					pastureId, bar["barcode"], 6, barname)
+			}
 		}
 	}
-
 }
 
 func UdFeedSync(pastureId, farmId string) {
 	url := fmt.Sprintf("http://172.16.86.95:8080/copartner_downloads?equipmentId=48ffa4de-7870-4b18-a052-9f8d3a46089a&farmId=%s&method=downloadmaterial", farmId)
 	feedByte := getPull(url)
-
+	fmt.Println(string(feedByte))
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 	tx.Exec(` insert into saplog(pastureId,request,response,status,msgtext,createTime,msgtype,dataDate,url)
@@ -72,79 +85,107 @@ func UdFeedSync(pastureId, farmId string) {
 
 	feedMap := make(map[string]interface{})
 	json.Unmarshal(feedByte, &feedMap)
-
-	for _, item := range feedMap["msg"].([]interface{}) {
-		fmt.Println(item)
-		feed := item.(map[string]interface{})
-		feedname := feed["feedname"].(string) + "_ud"
-		feedClassExist, _ := tx.SQL(` select count(1) from feedclass where fccode = ? and pastureId = ? `, feed["feedclass"], pastureId).Exist()
-
-		if !feedClassExist {
-			tx.Exec(`insert into feedclass(pastureId,fcname,fccode,bigfeedclassname,sort) values(?,?,?,?,(select max(sort) +1 from feedclass where pastureId = ? and fccode = ? ))`,
-				pastureId, feed["feedclass"], feed["feedclass"], feed["feedclass"], pastureId, feed["feedclass"])
+	fmt.Println(string(feedByte))
+	if len(feedMap) > 0 {
+		if feedMap["status"].(string) != "ok" {
+			return
 		}
-
-		ids, err := setting.SnowIds.NextId()
-		if err != nil {
-			ids = time.Now().UnixNano()
-			logging.Info("create SnowIds err", err)
+		for _, item := range feedMap["msg"].([]interface{}) {
+			fmt.Println(item)
+			feed := item.(map[string]interface{})
+			feedname := feed["feedname"].(string)
+			feedClassExist, err := tx.Table("feedclass").Where("fccode = ? ", feed["feedclass"]).Where(" pastureId = ? ", pastureId).Exist()
+			fmt.Println(err)
+			if !feedClassExist {
+				count, _ := tx.Table("feedclass").Where("pastureId = ? ", pastureId).Count()
+				ids, err := setting.SnowIds.NextId()
+				if err != nil {
+					ids = time.Now().UnixNano()
+					logging.Info("create SnowIds err", err)
+				}
+				_, err = tx.Exec(`insert into feedclass(id,pastureId,fcname,fccode,bigfeedclassname,sort,bigfeedclassid) values(?,?,?,?,?,?,?)`,
+					ids, pastureId, feed["feedclass"], feed["feedclass"], feed["feedclass"], count+1, ids)
+				fmt.Println(err)
+			}
+
+			ids, err := setting.SnowIds.NextId()
+			if err != nil {
+				ids = time.Now().UnixNano()
+				logging.Info("create SnowIds err", err)
+			}
+
+			_, err = tx.Exec(`insert into feed(id,pastureId,feedcode,udname,fclassid,fclass,fname) values(?,?,?,?,(select id from feedclass where fccode = ? and pastureId = ? ),?,if(char_length(?) > 7, left(?,7),?) )
+		ON DUPLICATE KEY UPDATE udname = ? ,fclassid = (select id from feedclass where fccode = ? and pastureId = ? ) ,fclass = ?`,
+				ids, pastureId, feed["feedcode"], feedname, feed["feedclass"], pastureId, feed["feedclass"], feedname, feedname, feedname, feedname, feed["feedclass"], pastureId, feed["feedclass"])
+			fmt.Println(err)
 		}
-
-		_, err = tx.Exec(`insert into feed(id,pastureId,feedcode,fname,fclassid,fclass) values(?,?,?,?,(select id from feedclass where fccode = ? and pastureId = ? ),?)
-		ON DUPLICATE KEY UPDATE fname = ? `,
-			ids, pastureId, feed["feedcode"], feedname, feed["feedclass"], pastureId, feed["feedclass"], feedname)
 	}
 
 }
 
 func getPull(url string) []byte {
-	// 创建一个HTTP客户端
-	client := &http.Client{}
+	forwardingReq := new(ForwardingReq)
+	forwardingReq.Url = url
+	forwardingReq.Method = "GET"
+	jsonStr, _ := json.Marshal(forwardingReq)
 
-	// 创建一个GET请求
-	req, err := http.NewRequest("GET", url, nil)
+	req, err := http.NewRequest("POST", setting.ServerSetting.UDForwardingSvc+":8080/forwarding", bytes.NewBuffer(jsonStr))
 	if err != nil {
-		fmt.Println("创建请求时发生错误:", err)
-		return nil
+		logs.Error(err)
+		// return nil
 	}
 
-	// 发送请求
+	req.Header.Set("Content-Type", "application/json")
+	client := &http.Client{}
 	resp, err := client.Do(req)
 	if err != nil {
-		fmt.Println("发送请求时发生错误:", err)
+		logs.Error(err)
 		return nil
 	}
 	defer resp.Body.Close()
 
-	// 读取响应内容
-	body, err := ioutil.ReadAll(resp.Body)
-	if err != nil {
-		fmt.Println("读取响应时发生错误:", err)
-		return nil
+	body, _ := ioutil.ReadAll(resp.Body)
+	if strings.Index(resp.Status, "200") > -1 {
+		bodyData := make(map[string]string)
+		json.Unmarshal(body, &bodyData)
+		if _, ok := bodyData["data"]; ok {
+			return []byte(bodyData["data"])
+		}
 	}
-
-	// 打印响应内容
-	// fmt.Println(string(body))
-
-	return body
+	return nil
 }
 
 //搅拌
-func UdUtirPush(pastureId, farmId string) error {
+func UdUtirPush(pastureId, farmId, date string) error {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
-	now := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
-	dataList, err := tx.SQL(`select d1.date loadDate,d.times loadShift,d.datacaptureno  tmrNo,ft.id recipeId,ft.ccname,d1.feedcode,d1.fname,f.fclass,
-	f.dry * d1.actualweightminus  dmPct,d1.sort mixNo,d1.feedallowratio allowableError ,d1.lweight expWeight,d1.actualweightminus actualWeight,d1.begintime startTime,
-	d1.intime endTime, d.tmrtname tmrName , d.pid id ,ftd.sort premixFeedSort ,
-	 (select feedcode from feed where id = ftd.fid) premixFeedId,ftd.fname  premixFeedName,
-	ftd.fweight / (select sum(fweight)  from ftdetaildate  where  date =  d1.date and ftid = d1.fid ) *  d1.actualweightminus premixFeedWeight
+	var now string
+	if date != "" {
+		now = date
+	} else {
+		now = time.Now().AddDate(0, 0, -1).Format("2006-01-02")
+	}
 
+	dataList, err := tx.SQL(`select date_format(d1.date,'%Y-%m-%d')  dropDate,d.times loadShift,d.datacaptureno  tmrNo,ft.tcode recipeId,ft.ccname recipeName,if(d1.feedcode = -1 ,d1.fid,f.feedcode) ingId,ifnull(f.fname,ftd.fname)  ingName,
+	ifnull(ifnull(fc.fcname,(select fcname from feedclass fc1 join feed f1 on f1.fclassid = fc1.id where f1.id =ftd.fid )),'饲料') ingType,
+	ifnull(f.dry * d1.actualweightminus,0)  dmPct,d1.sort mixNo,ifnull(d1.feedallowratio,0) allowableError , if(f.fname is not null, ifnull(d1.lweight,''),	ifnull(ftd.fweight / (select sum(fweight)  from ftdetaildate  where  date =  d1.date and ftid = d1.fid ) *  d1.lweight,"") )  expWeight,
+	
+	if(f.fname is not null, ifnull(d1.actualweightminus,''),	ifnull(ftd.fweight / (select sum(fweight)  from ftdetaildate  where  date =  d1.date and ftid = d1.fid ) *  d1.actualweightminus,"") ) actualWeight,
+	DATE_FORMAT(IFNULL((SELECT MAX(intime) FROM downloadplandtl1 d2 
+WHERE  d1.pid=d2.pid AND d1.pastureid = d2.pastureid AND d2.intime<d1.intime)
+, (SELECT MAX(intime) FROM downloadedplan d2 
+WHERE  d1.date=d2.mydate AND d1.pastureid = d2.pastureid AND d2.id=d1.pid)
+), '%Y-%m-%d %H:%i:%s') 
+   startTime  ,
+	 date_format(d1.intime,'%Y-%m-%d %H:%i:%s')   endTime, driver.drivername tmrName ,d1.feedallowratio allowable_error
 	from downloadplandtl1  d1 join  downloadedplan d on d.id = d1.pid
 	left join feedtempletdate ft  on ft.id = d.tempid  and ft.date = d1.date
 	left join feed f on f.feedcode  = d1.feedcode
+	left join feedclass fc on fc.id = f.fclassid
 	left join ftdetaildate  ftd  on  ftd.date =  d1.date and ftd.ftid = d1.fid
-	where d1.date = ?`, now).Query().List()
+	join tmr t on t.id = d.tmrid 
+	left driver on driver.drivercode = t.eqcode
+	where d1.date = DATE_FORMAT(subdate(now(),1) ,'%Y-%m-%d' ) and d.havebutton = 1 and d1.type = 0 `, now).Query().List()
 	if err != nil {
 		logging.Error(err)
 		return err
@@ -173,38 +214,64 @@ func UdUtirPush(pastureId, farmId string) error {
 	return nil
 }
 
-func UdMaterialIssuePush(pastureId, farmId string) error {
+func UdMaterialIssuePush(pastureId, farmId, date string) error {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
-	now := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
-	dataList, err := tx.SQL(`SELECT  dd.feedsort feedSort, dd.feedcode feedId,dd.fname feedName,
-	d.id,IFNULL(ft.id,d2.feedtempletid ) recipeId,
+
+	var now string
+	if date != "" {
+		now = date
+	} else {
+		now = time.Now().AddDate(0, 0, -1).Format("2006-01-02")
+	}
+
+	dataList, err := tx.SQL(`SELECT  d1.sort feedSort, ifnull(f.feedcode,d1.fid) feedId,ifnull(ifnull(f.udname,f.fname),d1.fname) feedName,
+	d.id,IFNULL(ft.tcode,d2.feedtempletid ) recipeId,IFNULL(ft.tcode,d2.feedtempletid ) feedtempletId,ifnull(ft.tname,d.templetName) feedtempletName ,
 	IFNULL(d.templetName,d2.feedtempletName ) recipeName,
 	date_format(d.mydate,'%Y-%m-%d') as dropDate,ifnull((select sort from downloadedplan where pid=d.pid and lpplanType !=d.lpplanType and mydate=d.mydate),d.sort) as tmrNo,
-	d.Times as dropShift,b.bcode as penId,d2.Fname as penName,fp.CCOUNT as cowCount, d2.SORT as feedingNo,
-ifnull(ROUND(d2.lweight * (dd.actualweightminus/ (select sum(actualweightminus) from downloadplandtl1 where pid = dd.pid and type = 0) ),2) ,0)as expWeight,
+	d.Times as dropShift,ifnull(b.bcode,b.id) as penId,b.bname as penName,fp.CCOUNT as cowCount, d2.SORT as feedingNo,
+ifnull(ROUND(d2.lweight * (d1.actualweightminus/ (select sum(actualweightminus) from downloadplandtl1 where pid = d1.pid and type = 0) ),2) ,0)as expWeight,
 	ifnull(d2.ActualWeightMinus,0) as actualWeight, ifnull(date_format(timestamp(d2.InTime,CONCAT('-',d2.processTime)),'%Y-%m-%d %H:%i:%s'),d.mydate) as startTime,
 	ifnull(date_format(d2.InTime,'%Y-%m-%d %H:%i:%s'),d.mydate) as endTime,ifnull((SELECT dr.driver FROM dutyrecord dr
 WHERE dr.pastureid = d.pastureid AND dr.eqid = d.tmrid AND dr.times= d.times  AND dr.operatetime <=d.mydate
 ORDER BY dr.operatetime DESC LIMIT 1),"") as tmrName ,d.tmrtname equipmentId ,
-dd.fname,
-  ifnull(TRIM(if(( select sum(dd2.actualweightminus) from downloadplandtl2 dd2 where dd2.pid = d2.pid) >0 ,   ROUND( d2.actualweightminus/( select sum(dd2.actualweightminus) from downloadplandtl2 dd2 where dd2.pid = d2.pid) * (dd.actualweightminus ),2), ROUND( d2.lweight/( select sum(dd2.lweight) from downloadplandtl2 dd2 where dd2.pid = d2.pid) * (dd.actualweightminus ),2))),0) feedWeight
-
-	,ftd.sort premixFeedSort ,
-	 (select feedcode from feed where id = ftd.fid) premixFeedId,ftd.fname  premixFeedName,
-	ftd.fweight / (select sum(fweight)  from ftdetaildate  where  date =  dd.date and ftid = dd.fid ) *  dd.actualweightminus premixFeedWeight
-
+d1.fname,
+ifnull(TRIM(if(d1.feedcode != '-1', if ( (SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date) > 0 ,
+d2.actualweightminus/(SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
+d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE  ftd2.date = d1.date AND ftd2.version = ftd.version  AND ftd2.ftid = d1.fid  )),
+  
+   d2.lweight/(SELECT SUM(lweight) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
+d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE  ftd2.date = d1.date AND ftd2.version = ftd.version  AND ftd2.ftid = d1.fid  ))
+  ),'')),0) feedWeight
+
+
+  
+	,ifnull(ftd.sort,"") premixFeedSort ,
+	 ifnull((select feedcode from feed where id = ftd.fid),"") premixFeedId,ifnull(ftd.fname,"")  premixFeedName,
+	 
+ 
+ 	ifnull(if(d1.feedcode = '-1', if ( (SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date) > 0 ,
+  d2.actualweightminus/(SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
+  d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE  ftd2.date = d1.date AND ftd2.version = ftd.version  AND ftd2.ftid = d1.fid  )),
+	
+	 d2.lweight/(SELECT SUM(lweight) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
+  d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE  ftd2.date = d1.date AND ftd2.version = ftd.version  AND ftd2.ftid = d1.fid  ))
+	),''),'0')
+  premixFeedWeight
+	
 	from  downloadedplan d
 	LEFT JOIN downloadplandtl2 d2 on d.id=d2.PID
 	LEFT JOIN (select dd.pid as lppid,dd1.* from downloadedplan dd join downloadplandtl1  dd1 on dd1.pid = dd.id and dd1.type = 0
-		where dd.mydate= date_format(?,'%Y-%m-%d')  and dd.lpplanType in (0,1) ) dd on dd.lppid = d.pid
+		where dd.mydate= date_format(?,'%Y-%m-%d')  and dd.lpplanType in (0,1) ) d1 on d1.lppid = d.pid
 
 	LEFT JOIN feedp fp on d2.FBarID=fp.barid
 	left join bar b on fp.barid = b.id and d.pastureid = b.pastureid
-	left JOIN feedtemplet ft on d.tempid=ft.id
-		left join ftdetaildate  ftd  on  ftd.date =  dd.date and ftd.ftid = dd.fid
+	left join feed f   on f.feedcode  = d1.feedcode
+	left JOIN feedtempletdate ft on d.tempid=ft.id and  ft.date =  d1.date   and d.tversion = ft.version           
+	left join feedtempletdate  ft1 on   d1.feedcode = '-1'  and ft1.date = d1.date and ft1.id = d1.fid 
+	left join ftdetaildate  ftd  on  ftd.date =  d1.date and ftd.ftid = d1.fid AND d1.feedcode = '-1'  and ftd.version = ft1.version
 
-	where d.mydate= date_format(?,'%Y-%m-%d')  and d.lpplanType!=1 and d.pastureid = ?   and dd.fname is not null  order by tmrno `, now, now, pastureId).Query().List()
+	where d.mydate= date_format(?,'%Y-%m-%d')  and d2.type = 0   and d.havebutton = 1  and d.pastureid = ?  and d1.fname is not null  order by tmrno   `, now, now, pastureId).Query().List()
 	if err != nil {
 		logging.Error(err)
 		return err
@@ -229,19 +296,26 @@ dd.fname,
 	reqJson = fmt.Sprintf(reqJson, string(dataByte), farmId, len(dataList))
 	//  '0饲喂  1剩料  2原料  3栏舍  4配方 5栏舍牛头数 6库存',
 	postPush(reqJson, 0, tx, pastureId)
+	fmt.Println(reqJson)
 	return nil
 }
 
-func UdBarFeedRemainPush(pastureId, farmId string) error {
-
+func UdBarFeedRemainPush(pastureId, farmId, date string) error {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
-	now := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
+
+	var now string
+	if date != "" {
+		now = date
+	} else {
+		now = time.Now().AddDate(0, 0, -1).Format("2006-01-02")
+	}
+
 	dataList, err := tx.SQL(`SELECT
 	'' startTime,
 	'' endTime,
 	br.RemainDate AS overplusDate,
-	 b.bcode AS penId,
+	ifnull(b.bcode,b.id) AS penId,
 	b.BNAME AS penName,
 	br.Remain AS actualWeight
 FROM
@@ -284,29 +358,36 @@ WHERE
 // 撒料数据 uploaddiliverdata
 // 剩料 uploadoverplusdata
 
-func UdFeedtempletPush(pastureId, farmId string) error {
+func UdFeedtempletPush(pastureId, farmId, date string) error {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
+	var now string
+	if date != "" {
+		now = date
+	} else {
+		now = time.Now().AddDate(0, 0, -1).Format("2006-01-02")
+	}
+
 	dataList, err := tx.SQL(`SELECT
-	ft.ID AS recipeId,
+	ft.tcode AS recipeId,
 	ft.TNAME AS recipeName,
-	ifnull( f.feedcode, f.id ) AS ingId,
-	f.FNAME AS ingName,
+	f.feedcode   AS ingId,
+	ifnull(f.udname,f.fname) AS ingName,
 	round( f.dry * ftd.FWEIGHT, 2 ) AS dmQty,
 	ftd.FWEIGHT AS afQty,
 	ftd.SORT AS mixNo,
 	round( f.Uprice * ftd.FWEIGHT, 2 ) AS recipeCost,
-	fc.FCNAME AS ingType,
-	f.AllowRatio AS allowableError 
+	fc.fcname AS ingType,
+	f.AllowRatio AS allowableError ,fc.fcname ingType
 FROM
-	feedtemplet ft
-	LEFT JOIN ftdetail ftd ON ft.id = ftd.FTID
-	LEFT JOIN feed f ON ftd.FID = f.id
-	LEFT JOIN feedclass fc ON f.FCLASS = fc.id 
+	feedtempletdate ft 
+	 JOIN ftdetaildate ftd ON ft.id = ftd.FTID  and ft.date = ftd.date
+	 JOIN feed f ON ftd.FID = f.id
+	 JOIN feedclass fc ON f.fclassid = fc.id 
 WHERE
 	ft.ENABLE = 1 
-	AND ft.isDelete != 1 `).Query().List()
+	AND ft.isDelete != 1  and ft.date = ?  `, now).Query().List()
 	if err != nil {
 		logging.Error(err)
 		return err
@@ -329,22 +410,37 @@ WHERE
     "apiId": "getCptData"
 }`
 	reqJson = fmt.Sprintf(reqJson, string(dataByte), farmId, len(dataList))
-
+	fmt.Println(reqJson)
 	postPush(reqJson, 4, tx, pastureId)
 	return nil
 }
 
+type ForwardingReq struct {
+	Body    string     `json:"body"`
+	Headers []*Headers `json:"headers"`
+	Url     string     `json:"url"`
+	Method  string     `json:"method"`
+}
+
+type Headers struct {
+	Key   string `json:"key"`
+	Value string `json:"value"`
+}
+
 func postPush(data string, msgtype int, tx *xorm.Session, pastureId string) {
-	url := "http://dev.unidairy.cn:8011/copartner_uploads/"
-	var jsonStr = []byte(data)
-	req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
+
+	forwardingReq := new(ForwardingReq)
+	forwardingReq.Url = "http://172.16.86.95:8080/copartner_uploads/"
+	forwardingReq.Method = "POST"
+	forwardingReq.Body = data
+	jsonStr, _ := json.Marshal(forwardingReq)
+	fmt.Println(setting.ServerSetting.UDForwardingSvc)
+	req, err := http.NewRequest("POST", setting.ServerSetting.UDForwardingSvc+":8080/forwarding", bytes.NewBuffer(jsonStr))
 	if err != nil {
 		logs.Error(err)
 		// return nil
 	}
 
-	// req.SetBasicAuth("zinf_TMR", "zinf_TMR@1234")  测试线密码
-	// req.SetBasicAuth("zinf_TMR", "$C2Cj$\\Uv#")
 	req.Header.Set("Content-Type", "application/json")
 	client := &http.Client{}
 	resp, err := client.Do(req)
@@ -352,11 +448,24 @@ func postPush(data string, msgtype int, tx *xorm.Session, pastureId string) {
 		logs.Error(err)
 		return
 	}
-
 	defer resp.Body.Close()
+
 	body, _ := ioutil.ReadAll(resp.Body)
 	fmt.Println(string(body))
-	tx.Exec(` insert into saplog(pastureId,request,response,status,msgtext,createTime,msgtype,dataDate,url)
-	values(?,?,?,?,?,now(),?,now(),?)`, pastureId, data, string(body), "", "", msgtype, url)
+
+	if strings.Index(resp.Status, "200") > -1 {
+		bodyData := make(map[string]string)
+		json.Unmarshal(body, &bodyData)
+		if _, ok := bodyData["data"]; ok {
+			tx.Exec(` insert into saplog(pastureId,request,response,status,msgtext,createTime,msgtype,dataDate,url)
+			values(?,?,?,?,?,now(),?,now(),?)`, pastureId, data, bodyData["data"], "", "", msgtype, forwardingReq.Url)
+		} else {
+			tx.Exec(` insert into saplog(pastureId,request,response,status,msgtext,createTime,msgtype,dataDate,url)
+			values(?,?,?,?,?,now(),?,now(),?)`, pastureId, data, string(body), "", "", msgtype, forwardingReq.Url)
+		}
+	} else {
+		tx.Exec(` insert into saplog(pastureId,request,response,status,msgtext,createTime,msgtype,dataDate,url)
+		values(?,?,?,?,?,now(),?,now(),?)`, pastureId, data, string(body), "", "", msgtype, forwardingReq.Url)
+	}
 
 }

+ 29 - 0
http/routers/app_api.go

@@ -136,6 +136,7 @@ func AppAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 
 			apiV1.POST("/ftdetail/edit", api.UpdateFTdetail)
 			apiV1.POST("/fpdetail/edit", api.UpdateFpdetailBar)
+			apiV1.POST("/fpdetail/batch/edit", api.FpdBatchEdit)
 			apiV1.POST("/ftdetai/del", api.DeleteFTdetail)
 			apiV1.POST("/lpplandtl/add", api.AddLpplandtl)
 			apiV1.POST("/lpplandtl/edit/sort", api.UpdateLpplandtlSort)
@@ -210,6 +211,26 @@ func AppAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 
 			apiV1.POST("/ud/feedp/sync", api.UdFeedpSync)
 
+			apiV1.POST("/tmrequipment/del", api.DelTmrEquipment)
+			apiV1.POST("/tmrequipment/edit", api.AddTmrEquipment)
+			apiV1.GET("/tmrequipment", api.GetTmrEquipment)
+
+			//光明ud手动上传
+			apiV1.POST("/gm/udbar", api.UdBarSync)
+			apiV1.POST("/gm/udfeed", api.UdFeedSync)
+			apiV1.POST("/gm/udfeedtemplet/push", api.UdFeedtempletPush)
+
+			apiV1.POST("/gm/udutir/push", api.UdUtirPush)
+			apiV1.POST("/gm/udbarfeedremain/push", api.UdBarFeedRemainPush)
+			apiV1.POST("/gm/udmaterialIssue/push", api.UdMaterialIssuePush)
+
+			apiV1.POST("/feedtemplet/del", api.DelFeedTemplet)
+
+			apiV1.POST("/plan/sort/edit", api.EditPlanSort)
+			//日执行计划修改为完成
+			apiV1.POST("/plan/artificial/edit", api.EditDownloadedplanArtificial)
+
+			apiV1.GET("/equipment/muster", api.GetTmrEquipmentMuster)
 		}
 
 		//不需要登录验证的接口
@@ -221,6 +242,14 @@ func AppAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 			apiV3.POST("/plandata", api.GetPlanData)
 			apiV3.POST("/plandata/edit", api.PostPlanData)
 			apiV3.POST("/plandata/batch/edit", api.PostPlanDatas)
+
+			//推料接口
+			apiV3.GET("/pusher/list", api.GetPusherList)
+			apiV3.POST("/pusher/edit", api.EditPusherGPS)
+
+			//羊圈通过RFID 需要传输的值:
+			apiV3.GET("/plan/rfid", api.GetPlanRFID)
+
 		}
 
 		apiV4 := s.Group("/customreport") // restful  接口 tablename 是 表名字

+ 2 - 0
http/routers/new_api.go

@@ -15,5 +15,7 @@ func NewAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 		newApiGroup.POST("feet_template/list", api.SearchFeetTemplateList)
 		newApiGroup.POST("feet_template/version", api.GetFeetTemplateVersion)
 		newApiGroup.POST("feet_template/upgrade", api.FeetTemplateUpgradeNewVersion)
+		newApiGroup.POST("tmr/gear", api.UpdateTmrGear)
+		newApiGroup.POST("user/gear", api.UseGear)
 	}
 }

+ 2 - 1
migration/v0001_feedtemplet.sql

@@ -262,4 +262,5 @@ CREATE TABLE `feed_detail_version_log` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='集团端最新配方详情表';
 
 ALTER TABLE ftdetail DROP INDEX ftdetail_ftid,
-ADD UNIQUE KEY ftdetail_ftid (`ftid`,`fid`,`pastureid`,`is_show`);
+ADD UNIQUE KEY ftdetail_ftid (`ftid`,`fid`,`pastureid`,`is_show`);
+

+ 153 - 0
migration/v0002_yq_bar.sql

@@ -0,0 +1,153 @@
+# 新增圈舍名称字段pen和长度length字段
+UPDATE apisql SET sqlstr = 'SELECT
+bcode,bname,allowratio,autozone,autosecond,isstart,
+begintag,endtag,sort,enable,autosecondname,length,pen,
+TRIM(id) id,
+TRIM(pastureid)pastureid,
+udcode,udname
+FROM
+  bar
+WHERE pastureid = ?
+ AND ( bname LIKE CONCAT(''%'',?,''%'')  OR ? = '''')
+ AND ( bcode LIKE CONCAT(''%'',?,''%'')  OR ? = '''')
+ AND ( pen LIKE CONCAT(''%'',?,''%'')  OR ? = '''')
+ AND (allowratio = ? OR ? = '''')
+ AND (enable =? OR ? = '''')
+ AND (autozone= ? OR ? = '''')
+ AND (autosecond = ? OR ? = '''')
+ORDER BY sort ',
+params = 'pastureid,bname,bname,bcode ,bcode,pen,pen ,allowratio ,allowratio ,enable ,enable,autozone,autozone,autosecond,autosecond'
+where sqlname = 'getBarList' and enable = 1;
+
+
+# 新增圈舍名称字段pen和长度length字段
+UPDATE apisql SET sqlstr = '
+update bar set bcode=? ,bname=?,allowratio=? ,autozone=?,autosecond=?,autosecondname=?,isstart=? ,enable=?,AUFNR = ?,pen = ?,length = ?
+where pastureid=? and id=?',
+params = 'bcode,bname,allowratio,autozone,autosecond,autosecondname,isstart,enable,AUFNR,pen,length,pastureid,id'
+where sqlname = 'updateBar' and enable = 1;
+
+# 新增speend 车速字段
+UPDATE apisql SET sqlstr ="SELECT 0 islock,
+eqcode,tname,datacaptureno,trim(tclassid) tclassid,
+(SELECT dictlist.label FROM dictlist JOIN dict ON dict.id=dictlist.pid WHERE dict.name='TMR设备类型' AND dict.ENABLE=1  and dictlist .enable=1  and value = tclassid) as tclassname,
+maxstirfeed,remark,enable,TRIM(id) id,TRIM(pastureid)pastureid,
+tcolor,imei,ifnull(datainterface,1),autozone,autosecond,if(autosecondname= '' or autosecondname is null,'禁用',autosecondname ) autosecondname,(select pasture_name from pasture where pastureid = tmr.pastureid) as pasturename,
+ifnull(gps,'')  gps ,volume,speed,
+TRIM(TRAILING ''.'' FROM TRIM(TRAILING ''0'' FROM FORMAT(volume_rate, 20))) AS volume_rate
+FROM
+  tmr
+WHERE pastureid = ?  and  if(?=0,tclassid in (0,6,7),tclassid in (1,2,3,4))
+  AND (tmr.eqcode LIKE CONCAT('%',?,'%')  OR ? = '')
+ AND (tmr.tclassname =? OR ? = '')
+AND (tmr.tname =? OR ? = '')
+  AND (tmr.enable =? OR ? = '')  AND (tmr.imei =? OR ? = '')
+ORDER BY tmr.id DESC",params = 'pastureid,eqtype,eqcode,eqcode,classname,classname,tname,tname,enable,enable,imei,imei'
+where sqlname = 'getTmrList' and enable = 1;
+
+# 新增speend 车速字段
+update  apisql SET sqlstr ="update tmr join dictlist  JOIN `dict` ON `dict`.`id`=dictlist.`pid` set eqcode=? ,tname=? ,datacaptureno=?,tclassid=?,tclassname=? ,maxstirfeed=?,tmr.enable=?,remark=? ,tcolor = ?,imei=?,datainterface=?,autozone=if(?='',null,?),autosecond=if(?='',null,?),  autosecondname=dictlist.label,gps = ?,volume = ?,speed = ifnull(?,0), volume_rate = ? where tmr.pastureid=? and tmr.id= ? and `dict`.`name`='跳转延时' AND `dict`.ENABLE=1  and dictlist.enable=1 and  dictlist.`value` =? ",
+params = 'eqcode,tname,datacaptureno,tclassid,tclassname,maxstirfeed,enable,remark,tcolor,imei,datainterface,autozone,autozone,autosecond,autosecond,gps,volume,speed,volume_rate,pastureid,id,autosecond'
+where sqlname = 'updateTMR' and enable = 1;
+
+# 新增TMR设备撒料档位操作
+insert into apisql(sqlname,sqlstr,params) values ('getTmrGearList','select * from tmr_gear where tmr_id = ? order by rev', 'tmrId');
+
+# 新增圈舍下拉框列表数据
+insert into apisql(sqlname,sqlstr,params) values ('getPenList','select id,pen from bar where pastureid = ? and enable = 1 and isdelete = 0 and pen is not null group by pen order by sort', 'pastureid');
+
+ALTER TABLE `tmr`  ADD COLUMN `volume_rate` decimal(12,5) NOT NULL COMMENT '撒料机每转体积';
+
+# 新增圈舍
+update apisql SET sqlstr = "INSERT INTO bar
+(pastureid,bcode,bname,allowratio,autozone,autosecond,autosecondname,isstart,enable,sort,AUFNR,pen,length)
+VALUES (?,?,?,?,?,?,?,?,?,( select max(b.sort) + 1 from bar b where b.pastureid = ? ),?,?,?)",
+params = 'pastureid,bcode,bname,allowratio,autozone,autosecond,autosecondname,isstart,enable,pastureid,AUFNR,pen,length'
+where sqlname = 'insertBar' and enable = 1;
+
+# 修改栏舍索引
+delete table from bar;
+
+# 新建栏舍表
+CREATE TABLE `bar` (
+    `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '栏舍id',
+    `pastureid` BIGINT(20) UNSIGNED NOT NULL COMMENT '牧场id',
+    `bcode` VARCHAR(50) DEFAULT NULL COMMENT '栏舍编号',
+    `bname` VARCHAR(200) NOT NULL COMMENT '栏舍名称',
+    `allowratio` INT(11) DEFAULT 0 COMMENT '允许误差数',
+    `autozone` INT(11) DEFAULT 0 COMMENT '跳转重量域(kg)',
+    `autosecond` INT(4) DEFAULT 0 COMMENT '跳转延时值',
+    `autosecondname` VARCHAR(50) DEFAULT NULL COMMENT '跳转延时名称',
+    `isstart` TINYINT(1) DEFAULT 1 COMMENT '确认开始',
+    `begintag` INT(11) DEFAULT NULL,
+    `endtag` INT(11) DEFAULT NULL,
+    `sort` INT(11) DEFAULT 0 COMMENT '排序',
+    `enable` TINYINT(1) DEFAULT 1 COMMENT '是否启用',
+    `isdelete` TINYINT(1) DEFAULT 0 COMMENT '是否删除(0为未删除,1为伪删除)',
+    `backup1` VARCHAR(255) DEFAULT NULL COMMENT '备用1',
+    `backup2` VARCHAR(255) DEFAULT NULL COMMENT '备用2',
+    `AUFNR` VARCHAR(50) DEFAULT NULL COMMENT 'sap牛群订单行号',
+    `class` VARCHAR(50) DEFAULT NULL COMMENT '牛舍类型',
+    `classcode` VARCHAR(50) DEFAULT NULL COMMENT '牛舍类型编码',
+    `cattle` VARCHAR(50) DEFAULT NULL COMMENT '牛群',
+    `cattlecode` VARCHAR(50) DEFAULT NULL COMMENT '牛群编码',
+    `sapCode` VARCHAR(50) DEFAULT NULL,
+    `udcode` VARCHAR(50) DEFAULT NULL,
+    `udname` VARCHAR(50) DEFAULT NULL,
+    `length` DECIMAL(12,0) NOT NULL DEFAULT 0 COMMENT '栏舍长度',
+    `pen` VARCHAR(30) DEFAULT NULL COMMENT '圈舍',
+    PRIMARY KEY (`id`) USING BTREE,
+    UNIQUE KEY `ind_pastureId_bname` (`pastureid`,`bname`)
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC COMMENT='栏舍';
+
+# 删除tmr表
+delete table from tmr;
+
+CREATE TABLE `tmr` (
+    `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'tmr',
+    `pastureid` BIGINT(20) UNSIGNED NOT NULL,
+    `eqcode` CHAR(20) DEFAULT NULL COMMENT 'tmr设备编号',
+    `tname` VARCHAR(20) NOT NULL COMMENT 'tmr车名称',
+    `datacaptureno` INT(11) NOT NULL DEFAULT 0 COMMENT '数据采集卡编号',
+    `tclassid` BIGINT(20) NOT NULL COMMENT 'tmr设备类型',
+    `tclassname` VARCHAR(50) DEFAULT NULL,
+    `ttype` TINYINT(4) DEFAULT NULL COMMENT '设备类型 0铲车,1tmr,3撒料设备,4小料',
+    `maxstirfeed` INT(11) DEFAULT 0 COMMENT '最大搅料量(kg)(默认0)',
+    `sort` INT(11) NOT NULL DEFAULT 0 COMMENT '顺序',
+    `enable` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '启用',
+    `inorout` SMALLINT(1) NOT NULL DEFAULT 0 COMMENT '当前是否撒料(默认2车不在使用,1撒料,0是做料)',
+    `projid` BIGINT(20) DEFAULT 0 COMMENT '当前执行计划',
+    `lastsort` VARCHAR(20) DEFAULT NULL COMMENT '上一个料',
+    `lastweight` DECIMAL(20,3) DEFAULT NULL COMMENT '上次目标重量',
+    `lastbuttontime` DATETIME DEFAULT NULL COMMENT '上次执行时间',
+    `nextsort` BIGINT(20) DEFAULT 0 COMMENT '下一个料',
+    `nextweight` DECIMAL(20,3) DEFAULT NULL COMMENT '下次目标重量',
+    `issounding` INT(11) DEFAULT 0,
+    `tcolor` VARCHAR(50) DEFAULT '#ccc',
+    `remark` VARCHAR(255) DEFAULT NULL COMMENT '备注',
+    `imei` VARCHAR(255) DEFAULT NULL COMMENT 'imei唯一标识',
+    `datainterface` VARCHAR(255) DEFAULT NULL COMMENT '数据接口',
+    `autozone` INT(11) DEFAULT NULL COMMENT '跳转重量(kg',
+    `autosecond` INT(11) DEFAULT NULL COMMENT '跳转延时值',
+    `autosecondname` VARCHAR(50) DEFAULT NULL COMMENT '跳转延时名称',
+    `lastinorout` INT(1) DEFAULT 0,
+    `gps` VARCHAR(50) DEFAULT NULL,
+    `volume` DECIMAL(12,2) NOT NULL DEFAULT 0.00 COMMENT '容积',
+    `speed` DECIMAL(12,0) NOT NULL DEFAULT 0 COMMENT '速度',
+    `volume_rate` DECIMAL(12,5) NOT NULL COMMENT '撒料机每转体积',
+    PRIMARY KEY (`id`) USING BTREE,
+    UNIQUE KEY `tmr_datacaptureno` (`datacaptureno`,`pastureid`) USING BTREE,
+    UNIQUE KEY `tmr_tname` (`pastureid`,`tname`,`ttype`) USING BTREE,
+    UNIQUE KEY `tmr_eqcode` (`pastureid`,`eqcode`,`ttype`) USING BTREE
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COMMENT='TMR设备表';
+
+# 新增TMR 栏舍表
+update apisql SET sqlstr = "INSERT INTO tmr(pastureid,eqcode,tname,datacaptureno,tclassid,tclassname,maxstirfeed,
+                `enable`,remark,ttype,tcolor,imei,datainterface,autozone,autosecond,autosecondname,gps,volume,speed,volume_rate)
+VALUES (?,?,?,?,?,?,?,?,?,if(?<>0,1,0),?,if(?='''',null,?),?,if(?='''',null,?),if(?='''',null,?),?,?,?,ifnull(?,0),?)",
+params = 'pastureid,eqcode,tname,datacaptureno,tclassid,tclassname,maxstirfeed,enable,remark,tclassid,tcolor,imei,imei,datainterface,autozone,autozone,autosecond,autosecond,autosecondname,gps,volume,speed,volume_rate'
+where sqlname = 'insertTmr' and enable = 1;
+
+update apisql SET sqlstr = "SELECT bname,TRIM(id) id FROM bar WHERE pastureid = ? and pen = ? and enable=1 ORDER BY id DESC",
+                  params = "pastureid,pen"
+where sqlname = 'getBarListEnable' and enable = 1;

+ 52 - 0
models/tmr_gear.go

@@ -0,0 +1,52 @@
+package models
+
+import (
+	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"sort"
+	"time"
+)
+
+type TmrGear struct {
+	Id        int64  `json:"id"`
+	TmrId     int64  `json:"tmr_id"`
+	Gear      string `json:"name"`
+	Rev       int64  `json:"rev"`
+	CreatedAt int64  `json:"created_at"`
+	UpdatedAt int64  `json:"updated_at"`
+}
+
+func (t *TmrGear) TableName() string {
+	return "tmr_gear"
+}
+
+func NewTmrGearList(tmrId int64, req *operationPb.UpdateOrCreateTmrGearRequest) []*TmrGear {
+	sort.Slice(req.Params, func(i, j int) bool {
+		return req.Params[i].Rev < req.Params[j].Rev
+	})
+	res := make([]*TmrGear, len(req.Params))
+	for i, v := range req.Params {
+		res[i] = &TmrGear{
+			TmrId:     tmrId,
+			Gear:      fmt.Sprintf("%d", i+1),
+			Rev:       int64(v.Rev),
+			CreatedAt: time.Now().Unix(),
+			UpdatedAt: time.Now().Unix(),
+		}
+	}
+	return res
+}
+
+type TmrGearDetail struct {
+	BCode    string  `json:"bcode"`
+	CCount   int32   `json:"ccount"`
+	FName    string  `json:"fname"`
+	GearRate float64 `json:"gear_rate"`
+	Length   int32   `json:"length"`
+	Sort     int32   `json:"sort"`
+	Speed    float64 `json:"speed"`
+	UseInBar string  `json:"useinbar"`
+	Weight   float64 `json:"weight"`
+	Pid      int64   `json:"pid"`
+	FBarid   int64   `json:"fbarid"`
+}

+ 131 - 0
module/sheep.go

@@ -0,0 +1,131 @@
+package module
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/xerr"
+	"github.com/xormplus/xorm"
+	"go.uber.org/zap"
+	"strconv"
+	"tmr-watch/http/handle/restful"
+	"tmr-watch/models"
+	"tmr-watch/pkg/logger/zaplog"
+)
+
+// SearchTrmGearByTmrId 查询撒料电机档位数据
+func SearchTrmGearByTmrId(ctx context.Context, tmrId int64) ([]*models.TmrGear, error) {
+	res := make([]*models.TmrGear, 0)
+	if err := restful.Engine.NewSession().Table(new(models.TmrGear).TableName()).
+		Where("tmr_id = ?", tmrId).Find(&res); err != nil {
+		if !errors.Is(err, xorm.ErrNotExist) {
+			return nil, err
+		}
+	}
+	return res, nil
+}
+
+func CreateOrUpdateTmrGear(ctx context.Context, req *operationPb.UpdateOrCreateTmrGearRequest) error {
+	tmrId, _ := strconv.ParseInt(req.TmrId, 10, 64)
+	tmrGearList, err := SearchTrmGearByTmrId(ctx, tmrId)
+	if err != nil {
+		return xerr.WithStack(err)
+	}
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	if err = tx.Begin(); err != nil {
+		return xerr.WithStack(err)
+	}
+
+	if len(tmrGearList) >= 1 {
+		if _, err = tx.Table(new(models.TmrGear).TableName()).Where("tmr_id = ?", req.TmrId).Delete(new(models.TmrGear)); err != nil {
+			tx.Rollback()
+			return xerr.WithStack(err)
+		}
+	}
+
+	newTmrGearList := models.NewTmrGearList(tmrId, req)
+	if _, err = tx.Table(new(models.TmrGear).TableName()).Insert(newTmrGearList); err != nil {
+		tx.Rollback()
+		return xerr.WithStack(err)
+	}
+	return tx.Commit()
+}
+
+func UseTmrGear(ctx context.Context, req *operationPb.UseGearRequest) ([]*models.TmrGearDetail, error) {
+	sqlName := fmt.Sprintf(
+		`SELECT sort,fname,weight,length,bcode,ccount,speed,gear_rate,useinbar,pid,fbarid FROM 
+		(SELECT a.sort,a.fname,a.lweight weight,a.fpid, IF(a.useinbartype=0,'转投剩料', IF(a.useinbartype=1,'撒','继续饲喂') ) useinbar, 
+		CONCAT(a.fbarid) fbarid,
+		CONCAT(a.pid) pid,
+		b.bcode,
+		b.length,
+		c.cowcount AS ccount,
+		ROUND( c.ccountradio * c.cowcount / 100, 2 ) ccountratio,
+		d.speed,
+		(((a.lweight /  b.length) * f.volume) / d.volume_rate) / (1 / (d.speed * 1000 / 3600)) * 60  AS gear_rate 
+		FROM  downloadplandtl2 a  
+		JOIN bar b ON a.fbarid = b.id  
+		JOIN fpdetaildate c ON c.barid = a.fbarid  
+		JOIN downloadedplan g ON a.pid = g.id  
+		JOIN tmr d ON d.id = g.tmrid  
+		JOIN feedtemplet f ON a.feedtempletid = f.id
+		WHERE a.pastureid = %s
+		AND a.pid= %s
+		AND d.id = %d
+        GROUP BY a.sort
+		ORDER BY a.sort
+	) AS B`, req.PastureId, req.Id, req.TmrId)
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	resultList, err := tx.QueryString(sqlName)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
+	zaplog.Info("UseTmrGear", zap.Any("resultList", resultList), zap.Any("sqlName", sqlName))
+
+	tmrGearDetailList := make([]*models.TmrGearDetail, 0)
+	for _, v := range resultList {
+		sort, _ := strconv.ParseInt(v["sort"], 10, 64)
+		fname := v["fname"]
+		bcode := v["bcode"]
+		weight, _ := strconv.ParseFloat(v["weight"], 64)
+		length, _ := strconv.ParseInt(v["length"], 10, 64)
+		ccount, _ := strconv.ParseInt(v["ccount"], 10, 64)
+		speed, _ := strconv.ParseFloat(v["speed"], 64)
+		gearRate, _ := strconv.ParseFloat(v["gear_rate"], 64)
+		pid, _ := strconv.ParseInt(v["pid"], 10, 64)
+		fbarid, _ := strconv.ParseInt(v["fbarid"], 10, 64)
+		tmrGearDetailList = append(tmrGearDetailList, &models.TmrGearDetail{
+			Sort:     int32(sort),
+			FName:    fname,
+			Weight:   weight,
+			Length:   int32(length),
+			BCode:    bcode,
+			CCount:   int32(ccount),
+			Speed:    speed,
+			GearRate: gearRate,
+			Pid:      pid,
+			FBarid:   fbarid,
+		})
+	}
+
+	return tmrGearDetailList, nil
+}
+
+func TmrGearListByTmrId(tmrId int64) ([]*models.TmrGear, error) {
+	tmrGearList := make([]*models.TmrGear, 0)
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+	err := tx.Table(new(models.TmrGear).TableName()).Where("tmr_id = ?", tmrId).Select("*").Find(&tmrGearList)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
+	return tmrGearList, nil
+}

+ 84 - 0
service/sheep/tmr_gear.go

@@ -0,0 +1,84 @@
+package sheep
+
+import (
+	"context"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/xerr"
+	"net/http"
+	"tmr-watch/module"
+)
+
+func UpdateOrCreateTmrGear(ctx context.Context, req *operationPb.UpdateOrCreateTmrGearRequest) error {
+	if len(req.Params) <= 0 {
+		return xerr.Customf("参数错误: params")
+	}
+
+	if len(req.TmrId) <= 0 {
+		return xerr.Customf("参数错误: tmr_id")
+	}
+	revList := make(map[int32]struct{})
+	for _, v := range req.Params {
+		if _, ok := revList[v.Rev]; ok {
+			return xerr.Customf("不能出现同样转速的数据")
+		}
+		revList[v.Rev] = struct{}{}
+	}
+
+	if err := module.CreateOrUpdateTmrGear(ctx, req); err != nil {
+		return xerr.WithStack(err)
+	}
+	return nil
+}
+
+func UseGear(ctx context.Context, req *operationPb.UseGearRequest) (*operationPb.UseGearResponse, error) {
+	list, err := module.UseTmrGear(ctx, req)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
+	tmrGearList, err := module.TmrGearListByTmrId(int64(req.TmrId))
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
+	gear := "0"
+	useGearDataList := make([]*operationPb.UseGearDataList, 0)
+	for _, v := range list {
+		if len(tmrGearList) > 0 {
+			for i := 0; i < len(tmrGearList)-1; i++ {
+				if v.GearRate > float64(tmrGearList[i].Rev) && v.GearRate <= float64(tmrGearList[i+1].Rev) {
+					gear = tmrGearList[i+1].Gear
+				}
+			}
+
+			if v.GearRate <= float64(tmrGearList[0].Rev) {
+				gear = tmrGearList[0].Gear
+			}
+			if v.GearRate >= float64(tmrGearList[len(tmrGearList)-1].Rev) {
+				gear = tmrGearList[len(tmrGearList)-1].Gear
+			}
+		}
+
+		newData := &operationPb.UseGearDataList{
+			Bcode:    v.BCode,
+			Fname:    v.FName,
+			Length:   v.Length,
+			Sort:     v.Sort,
+			Speed:    float32(v.Speed),
+			Useinbar: v.UseInBar,
+			Weight:   float32(v.Weight),
+			Gear:     gear,
+			Ccount:   v.CCount,
+			GearRate: float32(v.GearRate),
+			Pid:      v.Pid,
+			Fbarid:   v.FBarid,
+		}
+		useGearDataList = append(useGearDataList, newData)
+	}
+
+	return &operationPb.UseGearResponse{
+		Code: http.StatusOK,
+		Msg:  "ok",
+		Data: &operationPb.UseGearData{List: useGearDataList},
+	}, nil
+}

+ 4 - 0
service/user_service/user.go

@@ -2,6 +2,7 @@ package user_service
 
 import (
 	"tmr-watch/http/handle/restful"
+	"tmr-watch/pkg/util"
 
 	"github.com/casbin/casbin"
 )
@@ -26,7 +27,10 @@ type User struct {
 
 func (a *User) Check() (bool, error) {
 	return restful.CheckUser(a.Username, a.Password)
+}
 
+func (a *User) MD5Check() (bool, error) {
+	return restful.CheckUser(a.Username, util.EncodeMD5(a.Password))
 }
 
 func (a *User) CheckFace() (bool, error) {

BIN
uploads/file/导入导出模板/栏舍生产/配方干物质导入模板.xlsx


BIN
uploads/file/导入导出模板/栏舍生产/配方干物质导出模板.xlsx


BIN
uploads/file/导入导出模板/配方计划/栏舍配方导入模板.xlsx


BIN
uploads/file/导入导出模板/配方计划/栏舍配方导出模板.xlsx


BIN
uploads/file/导入导出模板/配方计划/配方模板导入模板.xlsx


BIN
uploads/file/导入导出模板/配方计划/配方模板导出模板.xlsx


+ 3 - 0
win32.bat

@@ -0,0 +1,3 @@
+set GOARCH=386
+set GOOS=windows
+go build -o KPTAdmin32.exe

+ 4 - 0
win64.bat

@@ -0,0 +1,4 @@
+set GOARCH=amd64
+set GOOS=windows
+go clean
+go build -o KPTAdmin64.exe

Some files were not shown because too many files changed in this diff