Commit 1ade32c0 by Joneq

提交代码

parent de3b8abf
......@@ -24,12 +24,14 @@ type ErpOrder struct {
Qty int64 `json:"qty"`
Unit string `json:"unit"`
Baseqty int64 `json:"baseqty"`
Scanqty int64 `json:"scanqty"`
Lot string `json:"lot"`
Factorylot string `json:"factorylot"`
Warehouse string `json:"warehouse"`
Location string `json:"location"`
Salegroup string `json:"salegroup"`
Saleperson string `json:"saleperson"`
OrderImageInfo []OrderImage `json:"order_image_info"`
}
type OrderImage struct {
......
......@@ -11,6 +11,7 @@ import (
"photo_taking/internal/dao"
"photo_taking/internal/model"
"photo_taking/internal/service"
"strings"
)
var svc pb.DemoServer
......@@ -43,8 +44,10 @@ func initRouter(e *bm.Engine) {
//获取订单信息
g.GET("/get_order_info/:order_id", getOrderInfo)
//提交明细信息
g.GET("/scan_order_detail/:order_id/:scan_str",getOrderDetailId)
//增加订单图片
g.GET("/add_order_image/:issueentryid/:issueentryid/:image_src", addOrderImage)
g.POST("/add_order_image", addOrderImage)
//提交订单
g.GET("/submit_order/:ordersn",submitOrder)
}
......@@ -141,15 +144,38 @@ func getOrderInfo(c *bm.Context) {
//增加订单图片
func addOrderImage(c *bm.Context) {
orderId,_ := c.Params.Get("issuebillid")
entryid,_ := c.Params.Get("issueentryid")
image_src,_ := c.Params.Get("image_src")
id := c.Request.PostFormValue("id")
scan_str := c.Request.PostFormValue("scan_str")
image_src := c.Request.PostFormValue("image_src")
num,materialno := service.StoreErWeiMaGetData(scan_str)
db,close,err := dao.NewDB()
if err != nil {
service.ErrorReturn(c,"数据库连接失败")
}
_,err = db.Exec(c,"INSERT INTO `lie_order_goods_img` (`issuebillid`, `issueentryid`, `image_src`)VALUES(?,?,?)",orderId,entryid,image_src)
var (
issuebillid,issueentryid string
scanqty int64
)
err = db.QueryRow(c, "select scanqty,issuebillid,issueentryid from lie_erp_order where id = ? and materialno = ? ", id,materialno).Scan(&scanqty,&issuebillid,&issueentryid)
if issuebillid == "" {
close()
service.ErrorReturn(c,"该型号不在该详情中")
}
scanqty = scanqty + num;
_,err = db.Exec(c,"update `lie_erp_order` set scanqty = ? where id = ?",scanqty,id)
imageArr := strings.Split(image_src,",")
for _,image_val := range imageArr {
_,err = db.Exec(c,"INSERT INTO `lie_order_goods_img` (`issuebillid`, `issueentryid`, `image_src`)VALUES(?,?,?)",issuebillid,issueentryid,image_val)
}
close()
c.JSON("添加成功",err)
}
......@@ -177,14 +203,16 @@ func submitOrder(c *bm.Context) {
ErpSubmitImage.OrderSn = ordersn
for _,currentData := range orderAllInfo{
if len(currentData.OrderImageInfo) <= 0 {
if currentData.OrderInfo.Qty != currentData.OrderInfo.Scanqty {
service.ErrorReturn(c,"未全部扫描")
}
if len(currentData.OrderInfo.OrderImageInfo) <= 0 {
service.ErrorReturn(c,"该订单有图片未提交")
}else{
ErpSubmitImage.ImageAll = append(ErpSubmitImage.ImageAll,currentData.OrderImageInfo...)
}
}
if err := service.LoginErp(c); err != nil {
service.ErrorReturn(c,err.Error())
}
......@@ -217,4 +245,33 @@ func submitOrder(c *bm.Context) {
}
c.JSON("提交成功",nil)
}
\ No newline at end of file
}
func getOrderDetailId(c *bm.Context) {
ordersn,_ := c.Params.Get("order_id")
//example |knVJXfVxSYa1o0qjZwznaI4IhhY=|PUI202007220425|100|00160657
scan_str,_ := c.Params.Get("scan_str")
//查询sql select id from (SELECT *,qty-scanqty show_zan FROM `lie_erp_order` where materialno = ? and ordersn = ? order by show_zan asc) abc where show_zan >= ?
var id int64
num,materialno := service.StoreErWeiMaGetData(scan_str)
db,close,err := dao.NewDB()
if err != nil {
service.ErrorReturn(c,"数据库连接失败")
}
err = db.QueryRow(c, "select id from (SELECT *,qty-scanqty show_zan FROM `lie_erp_order` where materialno = ? and ordersn = ? order by show_zan asc) abc where show_zan >= ?", materialno,ordersn,num).Scan(&id)
if id == 0 {
service.ErrorReturn(c,"该订单暂无符合数量的数据")
}
close()
c.JSON(id,nil)
}
......@@ -20,7 +20,7 @@ func SelectOrderInfoFromOrderId(c *bm.Context,orderId string)([]model.OrderAllIn
log.Error(err.Error())
}
rows,err := db.Query(c,"select id,ordersn,issuebillid,issueentryid,materialno,materialname,brand,qty,unit,baseqty,lot,factorylot,warehouse,location,salegroup,saleperson from lie_erp_order where ordersn = ?",orderId)
rows,err := db.Query(c,"select id,ordersn,issuebillid,issueentryid,materialno,materialname,brand,qty,unit,baseqty,scanqty,lot,factorylot,warehouse,location,salegroup,saleperson from lie_erp_order where ordersn = ?",orderId)
defer rows.Close()
if err != nil {
......@@ -32,7 +32,7 @@ func SelectOrderInfoFromOrderId(c *bm.Context,orderId string)([]model.OrderAllIn
var orderInfo model.ErpOrder
if err = rows.Scan(&orderInfo.Id,&orderInfo.Ordersn,&orderInfo.Issuebillid,&orderInfo.Issueentryid,&orderInfo.Materialno,&orderInfo.MaterialName,&orderInfo.Brand,
&orderInfo.Qty,&orderInfo.Unit,&orderInfo.Baseqty,&orderInfo.Lot,&orderInfo.Factorylot,&orderInfo.Warehouse,&orderInfo.Location,&orderInfo.Salegroup,&orderInfo.Saleperson); err != nil {
&orderInfo.Qty,&orderInfo.Unit,&orderInfo.Baseqty,&orderInfo.Scanqty,&orderInfo.Lot,&orderInfo.Factorylot,&orderInfo.Warehouse,&orderInfo.Location,&orderInfo.Salegroup,&orderInfo.Saleperson); err != nil {
log.Error("scan demo log error(%v)", err)
return orderAllInfo
}
......@@ -43,7 +43,7 @@ func SelectOrderInfoFromOrderId(c *bm.Context,orderId string)([]model.OrderAllIn
}
currentOrderAllInfo.OrderInfo = orderInfo
currentOrderAllInfo.OrderImageInfo = GetOrderEntryImage(c,orderInfo.Issuebillid,orderInfo.Issueentryid)
currentOrderAllInfo.OrderInfo.OrderImageInfo = GetOrderEntryImage(c,orderInfo.Issuebillid,orderInfo.Issueentryid)
orderAllInfo = append(orderAllInfo, currentOrderAllInfo)
}
......@@ -61,7 +61,7 @@ func GetOrderEntryImage(c *bm.Context,Issuebillid,Issueentryid string)([]model.O
}
var orderAllImage []model.OrderImage
imagerows,err := db.Query(c,"select issuebillid,issueentryid,image_src from lie_order_goods_img where issuebillid = ? and issueentryid = ?",Issuebillid,Issueentryid)
imagerows,err := db.Query(c,"select issuebillid,issueentryid,image_src from lie_order_goods_img where issuebillid = ? and issueentryid = ? order by id desc limit 0,3",Issuebillid,Issueentryid)
defer imagerows.Close()
for imagerows.Next() {
var orderCurrentImage model.OrderImage
......
package service
import (
"fmt"
"strconv"
"strings"
)
//通过二维码字符串获取数量和物料编码
func StoreErWeiMaGetData(erweima string) (num int64,materialno string) {
paramArr := strings.Split(erweima, "|")
returnNum,_ :=strconv.ParseInt(paramArr[3], 10, 64)
fmt.Println(paramArr)
return returnNum,paramArr[4]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment