557ecfb1fc2b5867cb39befb843c14705bdb5e68.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. package api
  2. import (
  3. "../../pkg/util"
  4. "../../routers/restful"
  5. "encoding/json"
  6. "fmt"
  7. "github.com/gin-gonic/gin"
  8. "github.com/hequan2017/go-admin/pkg/e"
  9. "github.com/hequan2017/go-admin/pkg/logging"
  10. "net/http"
  11. "strconv"
  12. "time"
  13. "../../pkg/app"
  14. //"time"
  15. "../../pkg/setting"
  16. )
  17. func GetDorm(c *gin.Context) {
  18. //appG := app.Gin{C: c}
  19. //dataByte, _ := ioutil.ReadAll(c.Request.Body)
  20. //fsion := gofasion.NewFasion(string(dataByte))
  21. //sqlnamestr := fsion.Get("name").ValueStr()
  22. //offset := fsion.Get("offset").ValueDefaultInt(0)
  23. //pagecount := fsion.Get("pagecount").ValueDefaultInt(0)
  24. //returntype := fsion.Get("returntype").ValueDefaultStr("map")
  25. data := util.Send_Message1("{\"farmId\":4090}", "http://120.48.30.31:88/kaps-cow/api/tmr/getDorm")
  26. if data != nil {
  27. var feedp util.Feedp
  28. json.Unmarshal(data, &feedp)
  29. status := feedp.Status
  30. feedpData := feedp.Data
  31. if status == 0 {
  32. //dataByte, _ := ioutil.ReadAll(c.Request.Body)
  33. //fsion := gofasion.NewFasion(string(dataByte))
  34. //pastureid := fsion.Get("pastureid").ValueStr()
  35. pastureid := 3445271849683387392
  36. // 开启事务
  37. appG := app.Gin{C: c}
  38. tx := restful.Engine.NewSession()
  39. err := tx.Begin()
  40. defer func() {
  41. switch {
  42. case err != nil:
  43. logging.Error("tx.Begin 事务启动失败__error:", err)
  44. if tx != nil {
  45. tx.Rollback()
  46. }
  47. default:
  48. if tx != nil {
  49. err = tx.Commit()
  50. }
  51. }
  52. if tx != nil {
  53. tx.Close()
  54. }
  55. }()
  56. for _, val := range feedpData {
  57. penId := val.PenId
  58. penName := val.PenName
  59. cowCount := val.CowCount
  60. ccountRatio := val.CcountRatio
  61. //createdAt := val.CreatedAt
  62. //modifiedAt := val.ModifiedAt
  63. ids, err := setting.SnowIds.NextId()
  64. if err != nil {
  65. ids = time.Now().UnixNano()
  66. logging.Info("create SnowIds err", err)
  67. }
  68. exec, err := tx.Exec("insert into bar(id,pastureid,bcode,bname) "+
  69. " values(?,?,?,?)"+
  70. " ON DUPLICATE KEY UPDATE bcode=?,bname=?",
  71. ids, pastureid, penId, penName, penId, penName)
  72. if err != nil {
  73. fmt.Println(err)
  74. continue
  75. } else {
  76. fmt.Println(exec)
  77. }
  78. exec2, err := tx.Exec("insert into feedp(id,pastureid,barid,barname,ccount,ratio,ccountratio) "+
  79. " values(?,?,(select id from bar where pastureid=? and bname=?),?,(if(?='',0,?)),REPLACE(?,'%',''),REPLACE(?,'%','')*(if(?='',0,?)))"+
  80. " ON DUPLICATE KEY UPDATE barid=(select id from bar where pastureid=? and bname=?),barname=?,ccount=(if(?='',0,?)),ratio=REPLACE(?,'%',''),ccountratio=REPLACE(?,'%','')*(if(?='',0,?))",
  81. ids, pastureid, pastureid, penName, penName, cowCount, cowCount, ccountRatio, ccountRatio, cowCount, cowCount, pastureid, penName, penName,
  82. cowCount, cowCount, ccountRatio, ccountRatio, cowCount, cowCount)
  83. if err != nil {
  84. fmt.Println(err)
  85. continue
  86. } else {
  87. fmt.Println(exec2)
  88. }
  89. }
  90. appG.Response(http.StatusOK, e.SUCCESS, nil)
  91. }
  92. }
  93. }
  94. func GetMaterial(c *gin.Context) {
  95. data := util.Send_Message1("{\"farmId\":4090}", "http://120.48.30.31:88/kaps-cow/api/tmr/getMaterial")
  96. if data != nil {
  97. var feed util.Feed
  98. json.Unmarshal(data, &feed)
  99. status := feed.Status
  100. feedpData := feed.Data
  101. if status == 0 {
  102. //dataByte, _ := ioutil.ReadAll(c.Request.Body)
  103. //fsion := gofasion.NewFasion(string(dataByte))
  104. //pastureid := fsion.Get("pastureid").ValueStr()
  105. pastureid := 3445271849683387392
  106. // 开启事务
  107. appG := app.Gin{C: c}
  108. tx := restful.Engine.NewSession()
  109. err := tx.Begin()
  110. defer func() {
  111. switch {
  112. case err != nil:
  113. logging.Error("tx.Begin 事务启动失败__error:", err)
  114. if tx != nil {
  115. tx.Rollback()
  116. }
  117. default:
  118. if tx != nil {
  119. err = tx.Commit()
  120. }
  121. }
  122. if tx != nil {
  123. tx.Close()
  124. }
  125. }()
  126. for _, val := range feedpData {
  127. fId := val.FId
  128. fName := val.FName
  129. price := val.Price
  130. dryMatter := val.DryMatter
  131. //autoChange := val.AutoChange
  132. //allowDev := val.AllowDev
  133. feedclassName := val.FeedclassName
  134. createdAt := val.CreatedAt
  135. modifiedAt := val.ModifiedAt
  136. fmt.Println(fName, feedclassName, createdAt, modifiedAt)
  137. ids, err := setting.SnowIds.NextId()
  138. if err != nil {
  139. ids = time.Now().UnixNano()
  140. logging.Info("create SnowIds err", err)
  141. }
  142. exec, err := tx.Exec("insert into feed(id,pastureid,feedcode,fname,fclass,fclassid,uprice,dry) "+
  143. " values(?,?,?,?,?,(select id from feedclass where fcname=? and pastureid=?),(if(?='',0,?)),(if(?='' or ?='~',0,?)))"+
  144. " ON DUPLICATE KEY UPDATE feedcode=?,fname=?,fclass=?,fclassid=(select id from feedclass where fcname=? and pastureid=?),uprice=(if(?='',0,?)),dry=(if(?='' or ?='~',0,?))",
  145. ids, pastureid, fId, fName, feedclassName, feedclassName, pastureid, price, price, dryMatter, dryMatter, dryMatter, fId, fName, feedclassName, feedclassName, pastureid, price, price, dryMatter, dryMatter, dryMatter)
  146. if err != nil {
  147. fmt.Println(err)
  148. continue
  149. } else {
  150. fmt.Println(exec)
  151. }
  152. }
  153. appG.Response(http.StatusOK, e.SUCCESS, nil)
  154. }
  155. }
  156. }
  157. func GetMaterialCategory(c *gin.Context) {
  158. data := util.Send_Message1("{\"farmId\":4090}", "http://120.48.30.31:88/kaps-cow/api/tmr/getMaterialCategory")
  159. if data != nil {
  160. var feedClass util.FeedClass
  161. json.Unmarshal(data, &feedClass)
  162. status := feedClass.Status
  163. feedpData := feedClass.Data
  164. if status == 0 {
  165. //dataByte, _ := ioutil.ReadAll(c.Request.Body)
  166. //fsion := gofasion.NewFasion(string(dataByte))
  167. //pastureid := fsion.Get("pastureid").ValueStr()
  168. pastureid := 3445271849683387392
  169. // 开启事务
  170. appG := app.Gin{C: c}
  171. tx := restful.Engine.NewSession()
  172. err := tx.Begin()
  173. defer func() {
  174. switch {
  175. case err != nil:
  176. logging.Error("tx.Begin 事务启动失败__error:", err)
  177. if tx != nil {
  178. tx.Rollback()
  179. }
  180. default:
  181. if tx != nil {
  182. err = tx.Commit()
  183. }
  184. }
  185. if tx != nil {
  186. tx.Close()
  187. }
  188. }()
  189. for _, val := range feedpData {
  190. feedclassName := val.FeedclassName
  191. feedclassId := val.FeedclassId
  192. createdAt := val.CreatedAt
  193. modifiedAt := val.ModifiedAt
  194. fmt.Println(feedclassId, feedclassName, createdAt, modifiedAt)
  195. ids, err := setting.SnowIds.NextId()
  196. if err != nil {
  197. ids = time.Now().UnixNano()
  198. logging.Info("create SnowIds err", err)
  199. }
  200. exec, err := tx.Exec("insert into feedclass(id,pastureid,fcname,fccode,bigfeedclassid,bigfeedclassname,sort,`enable`) values(?,?,?,?,?,?,?,?)"+
  201. " ON DUPLICATE KEY UPDATE fcname=?,fccode=?",
  202. ids, pastureid, feedclassName, feedclassId, 3, "精粗各半", 0, 1, feedclassName, feedclassId)
  203. if err != nil {
  204. fmt.Println(err)
  205. continue
  206. } else {
  207. fmt.Println(exec)
  208. }
  209. }
  210. appG.Response(http.StatusOK, e.SUCCESS, nil)
  211. }
  212. }
  213. }
  214. func GetCowCategory(c *gin.Context) {
  215. data := util.Send_Message1("{\"farmId\":4090}", "http://120.48.30.31:88/kaps-cow/api/tmr/getCowCategory")
  216. if data != nil {
  217. var cowClass util.CowClass
  218. json.Unmarshal(data, &cowClass)
  219. status := cowClass.Status
  220. feedpData := cowClass.Data
  221. if status == 0 {
  222. //dataByte, _ := ioutil.ReadAll(c.Request.Body)
  223. //fsion := gofasion.NewFasion(string(dataByte))
  224. //pastureid := fsion.Get("pastureid").ValueStr()
  225. pastureid := 3445271849683387392
  226. // 开启事务
  227. appG := app.Gin{C: c}
  228. tx := restful.Engine.NewSession()
  229. err := tx.Begin()
  230. defer func() {
  231. switch {
  232. case err != nil:
  233. logging.Error("tx.Begin 事务启动失败__error:", err)
  234. if tx != nil {
  235. tx.Rollback()
  236. }
  237. default:
  238. if tx != nil {
  239. err = tx.Commit()
  240. }
  241. }
  242. if tx != nil {
  243. tx.Close()
  244. }
  245. }()
  246. for _, val := range feedpData {
  247. cowClassCode := val.CowClassCode
  248. cowClassName := val.CowClassName
  249. createdAt := val.CreatedAt
  250. modifiedAt := val.ModifiedAt
  251. fmt.Println(cowClassCode, cowClassName, createdAt, modifiedAt)
  252. ids, err := setting.SnowIds.NextId()
  253. if err != nil {
  254. ids = time.Now().UnixNano()
  255. logging.Info("create SnowIds err", err)
  256. }
  257. exec, err := tx.Exec("insert into cowclass(id,pastureid,classcode,classname) values(?,?,?,?)"+
  258. " ON DUPLICATE KEY UPDATE classcode=?,classname=?",
  259. ids, pastureid, cowClassCode, cowClassName, cowClassCode, cowClassName)
  260. if err != nil {
  261. fmt.Println(err)
  262. continue
  263. } else {
  264. fmt.Println(exec)
  265. }
  266. }
  267. appG.Response(http.StatusOK, e.SUCCESS, nil)
  268. }
  269. }
  270. }
  271. func GetFormula(c *gin.Context) {
  272. data := util.Send_Message1("{\"farmId\":4090}", "http://120.48.30.31:88/kaps-cow/api/tmr/getFormula")
  273. if data != nil {
  274. var feedTemplet util.FeedTemplet
  275. json.Unmarshal(data, &feedTemplet)
  276. status := feedTemplet.Status
  277. feedpData := feedTemplet.Data
  278. if status == 0 {
  279. //dataByte, _ := ioutil.ReadAll(c.Request.Body)
  280. //fsion := gofasion.NewFasion(string(dataByte))
  281. //pastureid := fsion.Get("pastureid").ValueStr()
  282. pastureid := 3445271849683387392
  283. // 开启事务
  284. appG := app.Gin{C: c}
  285. tx := restful.Engine.NewSession()
  286. err := tx.Begin()
  287. defer func() {
  288. switch {
  289. case err != nil:
  290. logging.Error("tx.Begin 事务启动失败__error:", err)
  291. if tx != nil {
  292. tx.Rollback()
  293. }
  294. default:
  295. if tx != nil {
  296. err = tx.Commit()
  297. }
  298. }
  299. if tx != nil {
  300. tx.Close()
  301. }
  302. }()
  303. for _, val := range feedpData {
  304. ftId := val.FtId
  305. ftName := val.FtName
  306. feedList := val.FeedList
  307. //createdAt := val.CreatedAt
  308. //modifiedAt := val.ModifiedAt
  309. ids, err := setting.SnowIds.NextId()
  310. if err != nil {
  311. ids = time.Now().UnixNano()
  312. logging.Info("create SnowIds err", err)
  313. }
  314. exec, err := tx.Exec("insert into feedtemplet(id,pastureid,ccid,tcode,tname,fttypeid,fttype) values(?,?,null,?,?,1,'饲喂配方')"+
  315. " ON DUPLICATE KEY UPDATE tcode=?,tname=?",
  316. ids, pastureid, ftId, ftName, ftId, ftName)
  317. if err != nil {
  318. fmt.Println(err)
  319. continue
  320. } else {
  321. fmt.Println(exec)
  322. }
  323. // tx.Exec("delete from ftdetail where ftid=(select id from feedtemplet where pastureid=? and tname=?)",pastureid, ftName)
  324. for _, val := range feedList {
  325. fId := val.FId
  326. fName := val.FName
  327. fodderWeight := val.FodderWeight
  328. mixNo := val.MixNo
  329. ids, err := setting.SnowIds.NextId()
  330. if err != nil {
  331. ids = time.Now().UnixNano()
  332. logging.Info("create SnowIds err", err)
  333. }
  334. exec, err := tx.Exec("insert into ftdetail(id,pastureid,ftid,fid,fname,fweight,sort) "+
  335. " values(?,?,(select id from feedtemplet where pastureid=? and tname=? limit 1),(select id from feed where pastureid=? and feedcode=? limit 1),?,(if(?='',0,?)),(if(?='',0,?)))",
  336. ids, pastureid, pastureid, ftName, pastureid, fId, fName, fodderWeight, fodderWeight, mixNo, mixNo)
  337. if err != nil {
  338. fmt.Println(err)
  339. continue
  340. } else {
  341. fmt.Println(exec)
  342. }
  343. }
  344. }
  345. appG.Response(http.StatusOK, e.SUCCESS, nil)
  346. }
  347. }
  348. }
  349. func AddOtherDevice(c *gin.Context) {
  350. appG := app.Gin{C: c}
  351. tx := restful.Engine.NewSession()
  352. err := tx.Begin()
  353. defer func() {
  354. switch {
  355. case err != nil:
  356. logging.Error("tx.Begin 事务启动失败__error:", err)
  357. if tx != nil {
  358. tx.Rollback()
  359. }
  360. default:
  361. if tx != nil {
  362. err = tx.Commit()
  363. }
  364. }
  365. if tx != nil {
  366. tx.Close()
  367. }
  368. }()
  369. queryIdList, err1 := tx.SQL("select d.id,d.projname projName from downloadedplan d where d.pastureid=? and d.mydate=date_format(NOW(),'%Y-%m-%d') and iscompleted=1 and d.isuse=0 " +
  370. " and d.pastureid =(SELECT column_default FROM information_schema.COLUMNS WHERE table_name = 'recweight' AND table_schema = 'tmrwatch' AND column_name = 'pastureid') ").Query().List()
  371. queryDataList, err2 := tx.SQL("select d.id id,d.projname projName,round(d.lweight,2) lWeight,date_format(d.mydate,'%Y-%m-%d') as loadDate,d.SORT as tmrNo,d.Times as times,ft.tcode as ftId,d.templetName as ftName,f.feedcode as fId,"+
  372. " de.Fname as fName,fc.FCNAME as feedclassName,de.SORT as sort,de.feedallowratio as allowableError, "+
  373. " cast(de.LWEIGHT as decimal(10,2)) as expWeight,cast(de.ActualWeightMinus as decimal(10,2)) as actualWeight,"+
  374. " date_format(de.intime,'%Y-%m-%d %H:%i:%s') as endTime ,d.tmrtname as tName ,'' dName "+
  375. " from downloadedplan d LEFT JOIN downloadplandtl1 de on d.id=de.PID and d.pastureid=de.pastureid "+
  376. " LEFT JOIN feed f on de.fid=f.id and f.pastureid=d.pastureid LEFT JOIN feedtemplet ft on d.tempid=ft.id and ft.pastureid=d.pastureid "+
  377. " LEFT JOIN feedclass fc on f.fclassid=fc.id and fc.pastureid=d.pastureid "+
  378. " where d.mydate=date_format(NOW(),'%Y-%m-%d') and iscompleted=1 and d.isuse=0 " +
  379. " and d.pastureid =(SELECT column_default FROM information_schema.COLUMNS WHERE table_name = 'recweight' AND table_schema = 'tmrwatch' AND column_name = 'pastureid') ").Query().List()
  380. if err1 == nil && err2 == nil {
  381. for i := 0; i < len(queryIdList); i++ {
  382. id := queryIdList[i]["id"]
  383. projName := queryIdList[i]["projName"]
  384. listData := make(map[string]interface{})
  385. listData["farmId"] = 4090
  386. listData["id"] = id
  387. listData["projName"] = projName
  388. feedList := []interface{}{}
  389. for j := 0; j < len(queryDataList); j++ {
  390. id2 := queryDataList[j]["id"]
  391. if id == id2 {
  392. dataList := make(map[string]interface{})
  393. dataList["tmrNo"] = queryDataList[j]["tmrNo"]
  394. dataList["times"] = queryDataList[j]["times"]
  395. dataList["loadDate"] = queryDataList[j]["loadDate"]
  396. dataList["ftId"] = queryDataList[j]["ftId"]
  397. dataList["ftName"] = queryDataList[j]["ftName"]
  398. dataList["fId"] = queryDataList[j]["fId"]
  399. dataList["tName"] = queryDataList[j]["tName"]
  400. dataList["feedclassName"] = queryDataList[j]["feedclassName"]
  401. dataList["fName"] = queryDataList[j]["fName"]
  402. dataList["sort"] = queryDataList[j]["sort"]
  403. dataList["allowableError"] = queryDataList[j]["allowableError"]
  404. expWeight, _ := strconv.ParseFloat(queryDataList[j]["expWeight"].(string), 64)
  405. actualWeight, _ := strconv.ParseFloat((queryDataList[j]["actualWeight"]).(string), 64)
  406. lWeight, _ := strconv.ParseFloat(queryDataList[j]["lWeight"].(string), 64)
  407. dataList["expWeight"] = expWeight
  408. dataList["actualWeight"] = actualWeight
  409. dataList["lWeight"] = lWeight
  410. dataList["endTime"] = queryDataList[j]["endTime"]
  411. dataList["dName"] = queryDataList[j]["dName"]
  412. feedList = append(feedList, dataList)
  413. }
  414. }
  415. listData["data"] = feedList
  416. jsonStr, _ := json.Marshal(listData)
  417. postData := make(map[string]string)
  418. postData["formData"] = string(jsonStr)
  419. fmt.Println(&postData)
  420. data := util.PostWithFormData("POST", "http://120.48.30.31:88/kaps-cow/api/tmr/addOtherDevice", &postData)
  421. appG.Response(http.StatusOK, e.SUCCESS, string(data))
  422. }
  423. }
  424. }
  425. func AddOtherDeviceFeeding(c *gin.Context) {
  426. appG := app.Gin{C: c}
  427. tx := restful.Engine.NewSession()
  428. err := tx.Begin()
  429. defer func() {
  430. switch {
  431. case err != nil:
  432. logging.Error("tx.Begin 事务启动失败__error:", err)
  433. if tx != nil {
  434. tx.Rollback()
  435. }
  436. default:
  437. if tx != nil {
  438. err = tx.Commit()
  439. }
  440. }
  441. if tx != nil {
  442. tx.Close()
  443. }
  444. }()
  445. queryIdList, err1 := tx.SQL("select d.id,d.projname projName from downloadedplan d where d.mydate=date_format(NOW(),'%Y-%m-%d') and iscompleted=1 and d.isuse=0 " +
  446. " and d.pastureid =(SELECT column_default FROM information_schema.COLUMNS WHERE table_name = 'recweight' AND table_schema = 'tmrwatch' AND column_name = 'pastureid')").Query().List()
  447. queryDataList, err2 := tx.SQL("SELECT d.id id,d.projname projName,date_format(d.mydate,'%Y-%m-%d') as dropDate,d.Times as times,d.SORT as tmrNo,"+
  448. " bar.bcode as penId,d2.fname as penName,fp.CCOUNT as cowCount, d2.SORT as sort,d.templetName ftName, ft.tcode ftId,"+
  449. " d2.LWEIGHT as expWeight,d2.ActualWeightMinus as actualWeight,date_format(d2.intime,'%Y-%m-%d %H:%i:%s') as endTime,d.tmrtname as tName,'' dName "+
  450. " from downloadedplan d LEFT JOIN downloadplandtl2 d2 on d.id=d2.PID and d.pastureid=d2.pastureid "+
  451. " LEFT JOIN bar on d2.fbarid=bar.id and bar.pastureid=d2.pastureid LEFT JOIN feedp fp on d2.fbarid=fp.barid and fp.pastureid=d2.pastureid "+
  452. " LEFT JOIN feedtemplet ft on d.tempid=ft.id and ft.pastureid=d.pastureid "+
  453. " where d.mydate=date_format(NOW(),'%Y-%m-%d') and iscompleted=1 and d.isuse=0 " +
  454. " and d.pastureid =(SELECT column_default FROM information_schema.COLUMNS WHERE table_name = 'recweight' AND table_schema = 'tmrwatch' AND column_name = 'pastureid') ").Query().List()
  455. if err1 == nil && err2 == nil {
  456. for i := 0; i < len(queryIdList); i++ {
  457. id := queryIdList[i]["id"]
  458. projName := queryIdList[i]["projName"]
  459. listData := make(map[string]interface{})
  460. listData["farmId"] = 4090
  461. listData["id"] = id
  462. listData["projName"] = projName
  463. feedList := []interface{}{}
  464. for j := 0; j < len(queryDataList); j++ {
  465. id2 := queryDataList[j]["id"]
  466. if id == id2 {
  467. dataList := make(map[string]interface{})
  468. dataList["dropDate"] = queryDataList[j]["dropDate"]
  469. dataList["times"] = queryDataList[j]["times"]
  470. dataList["tmrNo"] = queryDataList[j]["tmrNo"]
  471. dataList["tName"] = queryDataList[j]["tName"]
  472. dataList["dName"] = queryDataList[j]["dName"]
  473. expWeight, _ := strconv.ParseFloat(queryDataList[j]["expWeight"].(string), 64)
  474. actualWeight, _ := strconv.ParseFloat((queryDataList[j]["actualWeight"]).(string), 64)
  475. dataList["expWeight"] = expWeight
  476. dataList["actualWeight"] = actualWeight
  477. dataList["endTime"] = queryDataList[j]["endTime"]
  478. dataList["penId"] = queryDataList[j]["penId"]
  479. dataList["penName"] = queryDataList[j]["penName"]
  480. dataList["cowCount"] = queryDataList[j]["cowCount"]
  481. dataList["sort"] = queryDataList[j]["sort"]
  482. dataList["ftId"] = queryDataList[j]["ftId"]
  483. dataList["ftName"] = queryDataList[j]["ftName"]
  484. feedList = append(feedList, dataList)
  485. }
  486. }
  487. listData["data"] = feedList
  488. jsonStr, _ := json.Marshal(listData)
  489. postData := make(map[string]string)
  490. postData["formData"] = string(jsonStr)
  491. fmt.Println(&postData)
  492. data := util.PostWithFormData("POST", "http://120.48.30.31:88/kaps-cow/api/tmr/addOtherDeviceFeeding", &postData)
  493. // todo === 修改d isuse =1
  494. appG.Response(http.StatusOK, e.SUCCESS, string(data))
  495. }
  496. }
  497. //data := util.Send_Message1("{\"farmId\":4090}", "http://120.48.30.31:86/kaps-cow/api/tmr/getMaterial")
  498. }