| | |
| | | package controllers |
| | | |
| | | import ( |
| | | "encoding/json" |
| | | "errors" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | | "os" |
| | | "sort" |
| | | "strconv" |
| | | "time" |
| | |
| | | "wms/extend/code" |
| | | "wms/extend/util" |
| | | "wms/models" |
| | | "wms/opa" |
| | | "wms/pkg/logx" |
| | | "wms/pkg/structx" |
| | | "wms/request" |
| | |
| | | util.ResponseFormat(c, code.Success, "修改成功") |
| | | } |
| | | |
| | | // DeleteDevice |
| | | // Delete |
| | | // |
| | | // @Tags 入库/出库 |
| | | // @Summary 删除入库/出库信息 |
| | |
| | | util.ResponseFormat(c, code.Success, "删除成功") |
| | | } |
| | | |
| | | // DeleteDevice |
| | | // Finish |
| | | // |
| | | // @Tags 入库/出库 |
| | | // @Summary 更改记录状态 |
| | |
| | | if !ok { |
| | | return errors.New("产品种类异常") |
| | | } |
| | | if v.Amount.LessThan(value) { |
| | | return errors.New(fmt.Sprintf("产品:%v,库存:%v,出库:%v,数量不够,无法完成出库操作", v.Name, v.Amount.String(), value.String())) |
| | | //todo 演示测试数据 |
| | | data, err := os.ReadFile("conf/input.json") |
| | | if err != nil { |
| | | return errors.New("文件读取失败") |
| | | } |
| | | m := make(map[string]interface{}) |
| | | err = json.Unmarshal(data, &m) |
| | | if err != nil { |
| | | return errors.New("格式转换失败") |
| | | } |
| | | if opa.OpaCheck(c, m, "operation") { |
| | | if v.Amount.LessThan(value) { |
| | | return errors.New(fmt.Sprintf("产品:%v,库存:%v,出库:%v,数量不够,无法完成出库操作", v.Name, v.Amount.String(), value.String())) |
| | | } |
| | | } |
| | | listProdt[k].Amount = listProdt[k].Amount.Sub(value) |
| | | if err := tx.Save(listProdt[k]).Error; err != nil { |
| | |
| | | util.ResponseFormat(c, code.Success, "操作成功") |
| | | } |
| | | |
| | | // listTransfer |
| | | // ListTransfer |
| | | // @Tags 入库/出库 |
| | | // @Summary 库存调拨列表 |
| | | // @Produce application/json |
| | |
| | | } |
| | | util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize) |
| | | } |
| | | |
| | | // GetLogisticCompanyList |
| | | // @Tags 入库/出库 |
| | | // @Summary 获取物流公司列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} util.ResponseList{data=[]models.LogisticCompany} "成功" |
| | | // @Router /api-wms/v1/operation/getLogisticCompanyList [get] |
| | | func (slf OperationController) GetLogisticCompanyList(c *gin.Context) { |
| | | companies, err := models.NewLogisticCompanySearch().FindNotTotal() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestError, "查找失败:"+err.Error()) |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.Success, companies) |
| | | } |