面包店
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

645 wiersze
18 KiB

  1. package svc
  2. import (
  3. md2 "applet/app/admin/md"
  4. "applet/app/bigData/md"
  5. "applet/app/db"
  6. "applet/app/db/model"
  7. "applet/app/utils"
  8. "encoding/json"
  9. "fmt"
  10. "github.com/gin-gonic/gin"
  11. "strings"
  12. "time"
  13. )
  14. func LeftDataForMake() (resp []md.LeftDataForMakeResp, err error) {
  15. //now := time.Now()
  16. //startDate := now.Format("2006-01-02") + " 00:00:00"
  17. //endDate := now.AddDate(0, 0, 1).Format("2006-01-02") + " 00:00:00"
  18. //engine := db.Db
  19. //var enterprise []model.Enterprise
  20. //err = engine.Where("1=1").Find(&enterprise)
  21. //if err != nil {
  22. // return
  23. //}
  24. //var enterpriseMap = map[int]model.Enterprise{}
  25. //for _, v := range enterprise {
  26. // enterpriseMap[v.Id] = v
  27. //}
  28. //
  29. ////1、查找当天的 order 数据(大于 待制作)
  30. //var orders []model.Order
  31. //err = engine.Where("create_at >= ?", startDate).And("create_at < ?", endDate).And("state > ? and state != 5", 0).Find(&orders)
  32. //if err != nil {
  33. // return
  34. //}
  35. //var oIds []int64
  36. //for _, v := range orders {
  37. // oIds = append(oIds, v.Oid)
  38. //}
  39. //
  40. ////2、查找对应的订单产品记录
  41. //var orderGoods []model.OrderGoods
  42. //err = engine.In("oid", oIds).Find(&orderGoods)
  43. //if err != nil {
  44. // return
  45. //}
  46. //var orderGoodsMap = map[int64][]model.OrderGoods{}
  47. //var records []int
  48. //for _, v := range orderGoods {
  49. // if orderGoodsMap[v.Oid] == nil {
  50. // orderGoodsMap[v.Oid] = []model.OrderGoods{}
  51. // }
  52. // orderGoodsMap[v.Oid] = append(orderGoodsMap[v.Oid], v)
  53. // records = append(records, v.Id)
  54. //}
  55. //
  56. ////3、用户订单商品操作流程
  57. //var orderGoodsDoingFlows []model.OrderGoodsDoingFlow
  58. //err = engine.Where("state = 2").In("record_id", records).Find(&orderGoodsDoingFlows)
  59. //if err != nil {
  60. // return
  61. //}
  62. //var orderGoodsDoingFlowsMap = map[int]model.OrderGoodsDoingFlow{}
  63. //for _, v := range orderGoodsDoingFlows {
  64. // orderGoodsDoingFlowsMap[v.RecordId] = v
  65. //}
  66. //
  67. ////4、整合数据
  68. //orderStateArr := []string{"待制作", "制作中", "烘焙完成", "分拣完成", "已取消"}
  69. //for _, v := range orders {
  70. // var list []md.LeftDataForMakeList
  71. // if len(orderGoodsMap[v.Oid]) > 0 {
  72. // orderGoodsStateArr := []string{"待制作", "制作中"}
  73. // for _, vv := range orderGoodsMap[v.Oid] {
  74. // skuData := make([]md2.Sku, 0)
  75. // json.Unmarshal([]byte(vv.Sku), &skuData)
  76. // skuStr := ""
  77. // for _, v1 := range skuData {
  78. // if skuStr != "" {
  79. // skuStr += ";"
  80. // }
  81. // skuStr += v1.Value
  82. // }
  83. // var stateZh = "已完成"
  84. // if vv.State <= 1 {
  85. // stateZh = orderGoodsStateArr[vv.State]
  86. // }
  87. // list = append(list, md.LeftDataForMakeList{
  88. // GoodsName: vv.GoodsTitle,
  89. // Sku: skuStr,
  90. // Num: vv.Num,
  91. // SuccessNum: orderGoodsDoingFlowsMap[vv.Id].SuccessNum,
  92. // StateZh: stateZh,
  93. // State: vv.State,
  94. // })
  95. // }
  96. //
  97. // resp = append(resp, md.LeftDataForMakeResp{
  98. // EnterpriseName: enterpriseMap[v.EnterpriseId].Name,
  99. // EnterpriseId: v.EnterpriseId,
  100. // StateZh: orderStateArr[v.State],
  101. // State: v.State,
  102. // List: list,
  103. // })
  104. // }
  105. //}
  106. return
  107. }
  108. func LeftDataForBaking() (resp []md.LeftDataForMakeResp, err error) {
  109. //now := time.Now()
  110. //startDate := now.Format("2006-01-02") + " 00:00:00"
  111. //endDate := now.AddDate(0, 0, 1).Format("2006-01-02") + " 00:00:00"
  112. //engine := db.Db
  113. //var enterprise []model.Enterprise
  114. //err = engine.Where("1=1").Find(&enterprise)
  115. //if err != nil {
  116. // return
  117. //}
  118. //var enterpriseMap = map[int]model.Enterprise{}
  119. //for _, v := range enterprise {
  120. // enterpriseMap[v.Id] = v
  121. //}
  122. //
  123. ////1、查找当天的 order 数据(大于 待制作)
  124. //var orders []model.Order
  125. //err = engine.Where("create_at >= ?", startDate).And("create_at < ?", endDate).And("state > ? and state != 5", 1).Find(&orders)
  126. //if err != nil {
  127. // return
  128. //}
  129. //var oIds []int64
  130. //for _, v := range orders {
  131. // oIds = append(oIds, v.Oid)
  132. //}
  133. //
  134. ////2、查找对应的订单产品记录
  135. //var orderGoods []model.OrderGoods
  136. //err = engine.In("oid", oIds).Find(&orderGoods)
  137. //if err != nil {
  138. // return
  139. //}
  140. //var orderGoodsMap = map[int64][]model.OrderGoods{}
  141. //var records []int
  142. //for _, v := range orderGoods {
  143. // if orderGoodsMap[v.Oid] == nil {
  144. // orderGoodsMap[v.Oid] = []model.OrderGoods{}
  145. // }
  146. // orderGoodsMap[v.Oid] = append(orderGoodsMap[v.Oid], v)
  147. // records = append(records, v.Id)
  148. //}
  149. //
  150. ////3、用户订单商品操作流程
  151. //var orderGoodsDoingFlows []model.OrderGoodsDoingFlow
  152. //err = engine.Where("state = 2").In("record_id", records).Find(&orderGoodsDoingFlows)
  153. //if err != nil {
  154. // return
  155. //}
  156. //var orderGoodsDoingFlowsMap = map[int]model.OrderGoodsDoingFlow{}
  157. //for _, v := range orderGoodsDoingFlows {
  158. // orderGoodsDoingFlowsMap[v.RecordId] = v
  159. //}
  160. //
  161. ////4、整合数据
  162. //orderStateArr := []string{"待制作", "制作中", "制作完成", "烘焙完成", "分拣完成", "已取消"}
  163. //for _, v := range orders {
  164. // var list []md.LeftDataForMakeList
  165. // if len(orderGoodsMap[v.Oid]) > 0 {
  166. // for _, vv := range orderGoodsMap[v.Oid] {
  167. // skuData := make([]md2.Sku, 0)
  168. // json.Unmarshal([]byte(vv.Sku), &skuData)
  169. // skuStr := ""
  170. // for _, v1 := range skuData {
  171. // if skuStr != "" {
  172. // skuStr += ";"
  173. // }
  174. // skuStr += v1.Value
  175. // }
  176. // var stateZh = "已完成"
  177. // if vv.State == 2 {
  178. // stateZh = "烘焙中"
  179. // }
  180. //
  181. // list = append(list, md.LeftDataForMakeList{
  182. // GoodsName: vv.GoodsTitle,
  183. // Sku: skuStr,
  184. // Num: vv.Num,
  185. // SuccessNum: orderGoodsDoingFlowsMap[vv.Id].SuccessNum,
  186. // StateZh: stateZh,
  187. // State: vv.State,
  188. // })
  189. // }
  190. //
  191. // resp = append(resp, md.LeftDataForMakeResp{
  192. // EnterpriseName: enterpriseMap[v.EnterpriseId].Name,
  193. // EnterpriseId: v.EnterpriseId,
  194. // StateZh: orderStateArr[v.State],
  195. // State: v.State,
  196. // List: list,
  197. // })
  198. // }
  199. //}
  200. return
  201. }
  202. func LeftDataForSorting() (resp []md.LeftDataForMakeResp, err error) {
  203. engine := db.Db
  204. var enterprise []model.Enterprise
  205. err = engine.Where("1=1").Find(&enterprise)
  206. if err != nil {
  207. return
  208. }
  209. var enterpriseMap = map[int]model.Enterprise{}
  210. for _, v := range enterprise {
  211. enterpriseMap[v.Id] = v
  212. }
  213. //1、查找不等于4 5
  214. sysCfgDb := db.SysCfgDb{}
  215. sysCfgDb.Set()
  216. now := CommDate()
  217. var orders []model.Order
  218. err = engine.Where(" state != 4 and state != 5 and make_date=?", now).Find(&orders)
  219. if err != nil {
  220. return
  221. }
  222. var oIds []int64
  223. for _, v := range orders {
  224. v1 := v
  225. if v1.State == 4 || v1.State == 5 {
  226. continue
  227. }
  228. oIds = append(oIds, v.Oid)
  229. }
  230. //2、查找对应的订单产品记录
  231. var orderGoods []model.OrderGoods
  232. err = engine.In("oid", oIds).Find(&orderGoods)
  233. if err != nil {
  234. return
  235. }
  236. var orderGoodsMap = map[int64][]model.OrderGoods{}
  237. var records []int
  238. for _, v := range orderGoods {
  239. if orderGoodsMap[v.Oid] == nil {
  240. orderGoodsMap[v.Oid] = []model.OrderGoods{}
  241. }
  242. orderGoodsMap[v.Oid] = append(orderGoodsMap[v.Oid], v)
  243. records = append(records, v.Id)
  244. }
  245. //4、整合数据
  246. orderStateArr := []string{"待分拣", "待分拣", "待分拣", "待分拣", "已完成", "已取消"}
  247. for _, v := range orders {
  248. var list []md.LeftDataForMakeList
  249. if len(orderGoodsMap[v.Oid]) > 0 {
  250. orderGoodsStateArr := []string{"待分拣", "待分拣", "待分拣", "待分拣", "已完成"}
  251. for _, vv := range orderGoodsMap[v.Oid] {
  252. skuData := make([]md2.Sku, 0)
  253. json.Unmarshal([]byte(vv.Sku), &skuData)
  254. skuStr := ""
  255. for _, v1 := range skuData {
  256. if skuStr != "" {
  257. skuStr += ";"
  258. }
  259. skuStr += v1.Value
  260. }
  261. var stateZh = orderGoodsStateArr[vv.State]
  262. list = append(list, md.LeftDataForMakeList{
  263. GoodsName: vv.GoodsTitle,
  264. Sku: skuStr,
  265. Num: vv.Num,
  266. SuccessNum: vv.SuccessNum,
  267. StateZh: stateZh,
  268. State: vv.State,
  269. })
  270. }
  271. resp = append(resp, md.LeftDataForMakeResp{
  272. EnterpriseName: enterpriseMap[v.EnterpriseId].Name,
  273. EnterpriseId: v.EnterpriseId,
  274. StateZh: orderStateArr[v.State],
  275. State: v.State,
  276. List: list,
  277. })
  278. }
  279. }
  280. return
  281. }
  282. func RightDataForMake(req md.RightDataForMakeReq) (resp []md.RightDataForMakeResp, total int64, err error) {
  283. now := time.Now()
  284. startDate := now.Format("2006-01-02") + " 00:00:00"
  285. endDate := now.AddDate(0, 0, 1).Format("2006-01-02") + " 00:00:00"
  286. engine := db.Db
  287. var enterprise []model.Enterprise
  288. err = engine.Where("1=1").Find(&enterprise)
  289. if err != nil {
  290. return
  291. }
  292. var enterpriseMap = map[int]model.Enterprise{}
  293. for _, v := range enterprise {
  294. enterpriseMap[v.Id] = v
  295. }
  296. //1、查找当天的 order 数据(大于 待制作)
  297. var orders []model.Order
  298. total, err = engine.Where("create_at >= ?", startDate).And("create_at < ?", endDate).And("state > ? and state != 5", 0).
  299. Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&orders)
  300. if err != nil {
  301. return
  302. }
  303. var oIds []int64
  304. for _, v := range orders {
  305. oIds = append(oIds, v.Oid)
  306. }
  307. //2、整合数据
  308. orderStateArr := []string{"待制作", "制作中", "制作完成", "烘焙完成", "分拣完成", "已取消"}
  309. for _, v := range orders {
  310. resp = append(resp, md.RightDataForMakeResp{
  311. EnterpriseName: enterpriseMap[v.EnterpriseId].Name,
  312. EnterpriseId: v.EnterpriseId,
  313. StateZh: orderStateArr[v.State],
  314. State: v.State,
  315. })
  316. }
  317. return
  318. }
  319. func RightDataForBaking(req md.RightDataForMakeReq) (resp []md.RightDataForMakeResp, total int64, err error) {
  320. now := time.Now()
  321. startDate := now.Format("2006-01-02") + " 00:00:00"
  322. endDate := now.AddDate(0, 0, 1).Format("2006-01-02") + " 00:00:00"
  323. engine := db.Db
  324. var enterprise []model.Enterprise
  325. err = engine.Where("1=1").Find(&enterprise)
  326. if err != nil {
  327. return
  328. }
  329. var enterpriseMap = map[int]model.Enterprise{}
  330. for _, v := range enterprise {
  331. enterpriseMap[v.Id] = v
  332. }
  333. //1、查找当天的 order 数据(大于 待制作)
  334. var orders []model.Order
  335. total, err = engine.Where("create_at >= ?", startDate).And("create_at < ?", endDate).And("state > ? and state != 5", 1).
  336. Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&orders)
  337. if err != nil {
  338. return
  339. }
  340. var oIds []int64
  341. for _, v := range orders {
  342. oIds = append(oIds, v.Oid)
  343. }
  344. //2、整合数据
  345. orderStateArr := []string{"待制作", "制作中", "制作完成", "烘焙完成", "分拣完成", "已取消"}
  346. for _, v := range orders {
  347. resp = append(resp, md.RightDataForMakeResp{
  348. EnterpriseName: enterpriseMap[v.EnterpriseId].Name,
  349. EnterpriseId: v.EnterpriseId,
  350. StateZh: orderStateArr[v.State],
  351. State: v.State,
  352. })
  353. }
  354. return
  355. }
  356. func RightDataForSorting(req md.RightDataForMakeReq) (resp []md.RightDataForMakeResp, total int64, err error) {
  357. now := time.Now()
  358. startDate := now.Format("2006-01-02") + " 00:00:00"
  359. endDate := now.AddDate(0, 0, 1).Format("2006-01-02") + " 00:00:00"
  360. engine := db.Db
  361. var enterprise []model.Enterprise
  362. err = engine.Where("1=1").Find(&enterprise)
  363. if err != nil {
  364. return
  365. }
  366. var enterpriseMap = map[int]model.Enterprise{}
  367. for _, v := range enterprise {
  368. enterpriseMap[v.Id] = v
  369. }
  370. //1、查找当天的 order 数据(大于 待制作)
  371. var orders []model.Order
  372. total, err = engine.Where("create_at >= ?", startDate).And("create_at < ?", endDate).And("state > ? and state != 5", 2).
  373. Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&orders)
  374. if err != nil {
  375. return
  376. }
  377. var oIds []int64
  378. for _, v := range orders {
  379. oIds = append(oIds, v.Oid)
  380. }
  381. //2、整合数据
  382. orderStateArr := []string{"待制作", "制作中", "制作完成", "烘焙完成", "分拣完成", "已取消"}
  383. for _, v := range orders {
  384. resp = append(resp, md.RightDataForMakeResp{
  385. EnterpriseName: enterpriseMap[v.EnterpriseId].Name,
  386. EnterpriseId: v.EnterpriseId,
  387. StateZh: orderStateArr[v.State],
  388. State: v.State,
  389. })
  390. }
  391. return
  392. }
  393. func NewSortingCate(c *gin.Context) []map[string]string {
  394. engine := db.Db
  395. res := make([]map[string]string, 0)
  396. var args = make(map[string]string)
  397. c.ShouldBindJSON(&args)
  398. var enterprise []model.Enterprise
  399. sess := engine.Where("1=1")
  400. if args["name"] != "" {
  401. sess.And("name like ? or inside_name like ?", "%"+args["name"]+"%", "%"+args["name"]+"%")
  402. }
  403. err := sess.Find(&enterprise)
  404. if err != nil {
  405. return res
  406. }
  407. var enterpriseMap = map[int]model.Enterprise{}
  408. enterpriseId := []int{-1}
  409. for _, v := range enterprise {
  410. enterpriseMap[v.Id] = v
  411. enterpriseId = append(enterpriseId, v.Id)
  412. }
  413. //1、查找不等于4 5
  414. now := CommDate()
  415. var orders []model.Order
  416. sess1 := engine.Where(" state != 4 and state != 5 and make_date=?", now)
  417. if args["name"] != "" {
  418. sess1.In("enterprise_id", enterpriseId)
  419. }
  420. err = sess1.Find(&orders)
  421. if err != nil {
  422. return res
  423. }
  424. ids := make([]string, 0)
  425. orderStateArr := []string{"待分拣", "待分拣", "待分拣", "待分拣", "已完成", "已取消"}
  426. for _, v := range orders {
  427. if utils.InArr(utils.IntToStr(v.EnterpriseId), ids) {
  428. continue
  429. }
  430. tmp := map[string]string{
  431. "id": utils.IntToStr(v.EnterpriseId),
  432. "name": enterpriseMap[v.EnterpriseId].Name,
  433. "state": utils.IntToStr(v.State),
  434. "state_str": orderStateArr[v.State],
  435. }
  436. ids = append(ids, utils.IntToStr(v.EnterpriseId))
  437. res = append(res, tmp)
  438. }
  439. return res
  440. }
  441. func NewSortingData(c *gin.Context) []map[string]string {
  442. res := make([]map[string]string, 0)
  443. var args map[string]string
  444. if err := c.ShouldBindJSON(&args); err != nil {
  445. return res
  446. }
  447. engine := db.Db
  448. var enterprise []model.Enterprise
  449. err := engine.Where("1=1").Find(&enterprise)
  450. if err != nil {
  451. return res
  452. }
  453. var enterpriseMap = map[int]model.Enterprise{}
  454. for _, v := range enterprise {
  455. enterpriseMap[v.Id] = v
  456. }
  457. //1、查找不等于4 5
  458. now := CommDate()
  459. var orders []model.Order
  460. err = engine.Where(" state != 4 and state != 5 and make_date=? and enterprise_id=?", now, args["id"]).Find(&orders)
  461. if err != nil {
  462. return res
  463. }
  464. var oIds []string
  465. for _, v := range orders {
  466. v1 := v
  467. if v1.State == 4 || v1.State == 5 {
  468. continue
  469. }
  470. oIds = append(oIds, utils.Int64ToStr(v.Oid))
  471. }
  472. sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku FROM order_goods WHERE %s oid in (%s) and make_date=%s and goods_type=0 GROUP BY enterprise_id,goods_id,sku_id ORDER BY id asc`
  473. str := ""
  474. if args["name"] != "" {
  475. str = " goods_title like %" + args["name"] + "% and "
  476. }
  477. sql = fmt.Sprintf(sql, str, strings.Join(oIds, ","), now)
  478. nativeString, err := db.QueryNativeString(engine, sql)
  479. for _, v := range nativeString {
  480. skuData := make([]md2.Sku, 0)
  481. json.Unmarshal([]byte(v["sku"]), &skuData)
  482. skuStr := ""
  483. for _, v1 := range skuData {
  484. if skuStr != "" {
  485. skuStr += ";"
  486. }
  487. skuStr += v1.Value
  488. }
  489. tmp := map[string]string{
  490. "goods_name": v["goods_title"],
  491. "sku": skuStr,
  492. "num": v["num"],
  493. "success_num": v["success_num"],
  494. "state": "1",
  495. "state_str": "待分拣",
  496. }
  497. if utils.StrToInt(v["num"]) <= utils.StrToInt(v["success_num"]) {
  498. tmp["state"] = "4"
  499. tmp["state_str"] = "分拣完成"
  500. }
  501. res = append(res, tmp)
  502. }
  503. return res
  504. }
  505. func NewSortingGoodsCate(c *gin.Context) []map[string]string {
  506. res := make([]map[string]string, 0)
  507. engine := db.Db
  508. //1、查找不等于4 5
  509. now := CommDate()
  510. var orders []model.Order
  511. var args = make(map[string]string)
  512. c.ShouldBindJSON(&args)
  513. err := engine.Where(" state != 4 and state != 5 and make_date=? ", now).Find(&orders)
  514. if err != nil {
  515. return res
  516. }
  517. var oIds []string
  518. for _, v := range orders {
  519. v1 := v
  520. if v1.State == 4 || v1.State == 5 {
  521. continue
  522. }
  523. oIds = append(oIds, utils.Int64ToStr(v.Oid))
  524. }
  525. sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id FROM order_goods WHERE %s oid in (%s) and goods_type=0 and make_date=%s GROUP BY goods_id,sku_id ORDER BY id asc`
  526. str := ""
  527. if args["name"] != "" {
  528. str = " goods_title like %" + args["name"] + "% and "
  529. }
  530. sql = fmt.Sprintf(sql, str, strings.Join(oIds, ","), now)
  531. nativeString, err := db.QueryNativeString(engine, sql)
  532. for _, v := range nativeString {
  533. skuData := make([]md2.Sku, 0)
  534. json.Unmarshal([]byte(v["sku"]), &skuData)
  535. skuStr := ""
  536. for _, v1 := range skuData {
  537. if skuStr != "" {
  538. skuStr += ";"
  539. }
  540. skuStr += v1.Value
  541. }
  542. tmp := map[string]string{
  543. "goods_id": v["goods_id"],
  544. "sku_id": v["sku_id"],
  545. "goods_name": v["goods_title"],
  546. "sku": skuStr,
  547. "num": v["num"],
  548. "success_num": v["success_num"],
  549. "state": "1",
  550. "state_str": "待分拣",
  551. }
  552. if utils.StrToInt(v["num"]) <= utils.StrToInt(v["success_num"]) {
  553. tmp["state"] = "4"
  554. tmp["state_str"] = "分拣完成"
  555. }
  556. res = append(res, tmp)
  557. }
  558. return res
  559. }
  560. func NewSortingGoodsData(c *gin.Context, arg map[string]string) []map[string]string {
  561. engine := db.Db
  562. res := make([]map[string]string, 0)
  563. var enterprise []model.Enterprise
  564. err := engine.Where("1=1").Find(&enterprise)
  565. if err != nil {
  566. return res
  567. }
  568. var enterpriseMap = map[int]model.Enterprise{}
  569. for _, v := range enterprise {
  570. enterpriseMap[v.Id] = v
  571. }
  572. //1、查找不等于4 5
  573. now := CommDate()
  574. var args = make(map[string]string)
  575. c.ShouldBindJSON(&args)
  576. var orders []model.Order
  577. err = engine.Where(" state != 4 and state != 5 and make_date=? ", now).Find(&orders)
  578. if err != nil {
  579. return res
  580. }
  581. var oIds []string
  582. for _, v := range orders {
  583. v1 := v
  584. if v1.State == 4 || v1.State == 5 {
  585. continue
  586. }
  587. oIds = append(oIds, utils.Int64ToStr(v.Oid))
  588. }
  589. sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id,enterprise_id FROM order_goods WHERE %s oid in (%s) and goods_id=%s and goods_type=0 and sku_id=%s and make_date=%s GROUP BY enterprise_id ORDER BY id asc`
  590. str := ""
  591. if args["name"] != "" {
  592. str = " goods_title like %" + args["name"] + "% and "
  593. }
  594. sql = fmt.Sprintf(sql, str, strings.Join(oIds, ","), arg["goods_id"], arg["sku_id"], now)
  595. nativeString, err := db.QueryNativeString(engine, sql)
  596. for _, v := range nativeString {
  597. skuData := make([]md2.Sku, 0)
  598. json.Unmarshal([]byte(v["sku"]), &skuData)
  599. skuStr := ""
  600. for _, v1 := range skuData {
  601. if skuStr != "" {
  602. skuStr += ";"
  603. }
  604. skuStr += v1.Value
  605. }
  606. tmp := map[string]string{
  607. "enterprise_name": enterpriseMap[utils.StrToInt(v["enterprise_id"])].Name,
  608. "num": v["num"],
  609. "success_num": v["success_num"],
  610. "state": "1",
  611. "state_str": "待分拣",
  612. }
  613. if utils.StrToInt(v["num"]) <= utils.StrToInt(v["success_num"]) {
  614. tmp["state"] = "4"
  615. tmp["state_str"] = "分拣完成"
  616. }
  617. res = append(res, tmp)
  618. }
  619. return res
  620. }