From db425e3e5022111c8b776fa18f453ed04623deb2 Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期六, 23 九月 2023 15:19:27 +0800
Subject: [PATCH] 1.报废新增、修改、列表、验证
---
constvar/const.go | 1
controllers/product_controller.go | 245 ++++++++++++++++
controllers/operation.go | 9
models/material.go | 21 +
models/operation.go | 10
request/product_request.go | 35 ++
docs/swagger.yaml | 132 ++++++++
docs/docs.go | 207 +++++++++++++
docs/swagger.json | 207 +++++++++++++
router/router.go | 7
10 files changed, 864 insertions(+), 10 deletions(-)
diff --git a/constvar/const.go b/constvar/const.go
index 85b175d..42221db 100644
--- a/constvar/const.go
+++ b/constvar/const.go
@@ -124,6 +124,7 @@
LocationTypeInventoryLoss // 搴撳瓨鎹熷け
LocationTypeProduction // 鐢熶骇
LocationTypeTransit // 涓浆浣嶇疆
+ LocationTypeDisuse
)
func (t LocationType) Valid() bool {
diff --git a/controllers/operation.go b/controllers/operation.go
index 8eca517..9d6fa9b 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -7,6 +7,7 @@
"github.com/shopspring/decimal"
"gorm.io/gorm"
"strconv"
+ "time"
"wms/constvar"
"wms/extend/code"
"wms/extend/util"
@@ -47,6 +48,7 @@
}
params.Status = constvar.OperationStatus_Ready
+ params.Number = strconv.FormatInt(time.Now().Unix(), 10)
if err := models.NewOperationSearch().Create(¶ms); err != nil {
logx.Errorf("Operation create err: %v", err)
util.ResponseFormat(c, code.SaveFail, "娣诲姞澶辫触锛�"+err.Error())
@@ -156,7 +158,6 @@
}
util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize)
-
}
func (slf OperationController) CheckListParams(params *request.OperationList) error {
@@ -318,7 +319,7 @@
if value, ok := mapProdt[v.ID]; !ok {
return errors.New("浜у搧绉嶇被寮傚父")
} else {
- listProdt[k].Amount.Add(value)
+ listProdt[k].Amount = listProdt[k].Amount.Add(value)
if err := tx.Save(listProdt[k]).Error; err != nil {
return err
}
@@ -333,7 +334,7 @@
if v.Amount.LessThan(value) {
return errors.New(fmt.Sprintf("浜у搧锛�%v,搴撳瓨锛�%v,鍑哄簱锛�%v,鏁伴噺涓嶅锛屾棤娉曞畬鎴愬嚭搴撴搷浣�", v.Name, v.Amount.String(), value.String()))
}
- listProdt[k].Amount.Sub(value)
+ listProdt[k].Amount = listProdt[k].Amount.Sub(value)
if err := tx.Save(listProdt[k]).Error; err != nil {
return err
}
@@ -381,7 +382,5 @@
util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error())
return
}
-
util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize)
-
}
diff --git a/controllers/product_controller.go b/controllers/product_controller.go
index ab40488..ca6f24e 100644
--- a/controllers/product_controller.go
+++ b/controllers/product_controller.go
@@ -1,11 +1,19 @@
package controllers
import (
+ "errors"
+ "fmt"
"github.com/gin-gonic/gin"
+ "github.com/shopspring/decimal"
"github.com/spf13/cast"
+ "gorm.io/gorm"
+ "strconv"
+ "time"
+ "wms/constvar"
"wms/extend/code"
"wms/extend/util"
"wms/models"
+ "wms/pkg/logx"
"wms/request"
"wms/utils"
)
@@ -304,3 +312,240 @@
util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize)
}
+
+// AddDisuse
+// @Tags 浜у搧
+// @Summary 娣诲姞鎶ュ簾淇℃伅
+// @Produce application/json
+// @Param object body request.AddDisuse true "鍏ュ簱/鍑哄簱淇℃伅"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/product/addDisuse [post]
+func (slf ProductController) AddDisuse(c *gin.Context) {
+ var params request.AddDisuse
+ if err := c.BindJSON(¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error())
+ return
+ }
+ if params.Amount.LessThanOrEqual(decimal.NewFromInt(0)) {
+ util.ResponseFormat(c, code.RequestParamError, "鏁伴噺寮傚父")
+ return
+ }
+ if params.FromLocationId == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "璇烽�夋嫨婧愪綅缃�")
+ return
+ }
+ if params.ToLocationId == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "璇烽�夋嫨鎶ュ簾浣嶇疆")
+ return
+ }
+ if params.SourceNumber == "" {
+ util.ResponseFormat(c, code.RequestParamError, "璇疯緭鍏ユ簮鍗曟嵁")
+ return
+ }
+ detail := &models.OperationDetails{
+ ProductId: params.ProductId,
+ ProductName: params.ProductName,
+ Amount: params.Amount,
+ Unit: params.Unit,
+ }
+ operation := models.Operation{
+ Number: strconv.FormatInt(time.Now().Unix(), 10),
+ SourceNumber: params.SourceNumber,
+ OperationTypeId: 0,
+ Status: constvar.OperationStatus_Ready,
+ FromLocationID: params.FromLocationId,
+ ToLocationID: params.ToLocationId,
+ OperationDate: time.Now().Format("2006-01-02 15:04:05"),
+ Details: []*models.OperationDetails{detail},
+ }
+ if err := models.NewOperationSearch().Create(&operation); err != nil {
+ logx.Errorf("Operation create err: %v", err)
+ util.ResponseFormat(c, code.SaveFail, "娣诲姞澶辫触锛�"+err.Error())
+ return
+ }
+ util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛")
+}
+
+// ListDisuse
+// @Tags 浜у搧
+// @Summary 鎶ュ簾鍒楄〃
+// @Produce application/json
+// @Param object body request.QueryDisuseList true "鏌ヨ鍙傛暟"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/product/listDisuse [post]
+func (slf ProductController) ListDisuse(c *gin.Context) {
+ var params request.QueryDisuseList
+ if err := c.BindJSON(¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error())
+ return
+ }
+ if !params.PageInfo.Check() {
+ util.ResponseFormat(c, code.RequestParamError, "鏁版嵁鍒嗛〉淇℃伅閿欒")
+ return
+ }
+
+ db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,wms_operation_details.product_name,wms_operation_details.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id")
+
+ if params.SourceNumber != "" {
+ db = db.Where("wms_operation.source_number like ?", fmt.Sprintf("%%%v%%", params.SourceNumber))
+ }
+ if params.Number != "" {
+ db = db.Where("wms_operation.number like ?", fmt.Sprintf("%%%v%%", params.Number))
+ }
+ db = db.Where("wms_operation.operation_type_id=?", 0)
+ var (
+ records = make([]*models.ResponseDisuseList, 0)
+ total int64
+ )
+
+ //list, total, err := search.SetDisuse(true).SetPreload(true).SetOrder("created_at desc").Find()
+
+ if err := db.Count(&total).Error; err != nil {
+ util.ResponseFormat(c, code.RequestError, fmt.Errorf("find count err: %v", err))
+ return
+ }
+ db = db.Preload("ToLocation").Preload("FromLocation")
+ if params.Page*params.PageSize > 0 {
+ db = db.Offset((params.Page - 1) * params.PageSize).Limit(params.PageSize)
+ }
+ if err := db.Find(&records).Error; err != nil {
+ util.ResponseFormat(c, code.RequestError, fmt.Errorf("find count err: %v", err))
+ return
+ }
+ util.ResponseFormatListWithPage(c, code.Success, records, int(total), params.Page, params.PageSize)
+}
+
+// FinishDisuse
+//
+// @Tags 浜у搧
+// @Summary 楠岃瘉鎶ュ簾
+// @Produce application/json
+// @Param id path int true "id"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/product/finishDisuse/{id} [put]
+func (slf ProductController) FinishDisuse(c *gin.Context) {
+ id, err := strconv.Atoi(c.Param("id"))
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "閿欒鐨刬d鍊�")
+ return
+ }
+ if id == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "id涓�0")
+ return
+ }
+ operation, err := models.NewOperationSearch().SetID(id).First()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鏈壘鍒扮浉鍏充俊鎭�:"+err.Error())
+ return
+ }
+ if operation.Status != constvar.OperationStatus_Ready {
+ util.ResponseFormat(c, code.RequestError, "璇ラ獙璇佹棤娉曞畬鎴�")
+ return
+ }
+ if err := models.WithTransaction(func(tx *gorm.DB) error {
+ if err := models.NewOperationSearch().SetOrm(tx).SetID(id).Update(&models.Operation{Status: constvar.OperationStatus_Finish}); err != nil {
+ return err
+ }
+ var listProdtId []string
+ var listProdt []*models.Material
+ mapProdt := make(map[string]decimal.Decimal)
+ listDetails, err := models.NewOperationDetailsSearch().SetOperationId(operation.Id).FindAll()
+ if err != nil {
+ return err
+ }
+ for _, v := range listDetails {
+ listProdtId = append(listProdtId, v.ProductId)
+ mapProdt[v.ProductId] = v.Amount
+ }
+ if err := models.NewMaterialSearch().Orm.Where("id IN ?", listProdtId).Find(&listProdt).Error; err != nil {
+ return err
+ }
+ for k, v := range listProdt {
+ if value, ok := mapProdt[v.ID]; !ok {
+ return errors.New("浜у搧绉嶇被寮傚父")
+ } else {
+ 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 {
+ return err
+ }
+ }
+ }
+ return nil
+ }); err != nil {
+ util.ResponseFormat(c, code.RequestError, err.Error())
+ return
+ }
+ util.ResponseFormat(c, code.Success, "鎿嶄綔鎴愬姛")
+}
+
+// UpdateDisuse
+// @Tags 浜у搧
+// @Summary 淇敼鎶ュ簾淇℃伅
+// @Produce application/json
+// @Param object body request.UpdateDisuse true "鍏ュ簱/鍑哄簱淇℃伅"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/product/updateDisuse [post]
+func (slf ProductController) UpdateDisuse(c *gin.Context) {
+ var params request.UpdateDisuse
+ if err := c.BindJSON(¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error())
+ return
+ }
+ if params.Amount.LessThanOrEqual(decimal.NewFromInt(0)) {
+ util.ResponseFormat(c, code.RequestParamError, "鏁伴噺寮傚父")
+ return
+ }
+ if params.FromLocationId == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "璇烽�夋嫨婧愪綅缃�")
+ return
+ }
+ if params.ToLocationId == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "璇烽�夋嫨鎶ュ簾浣嶇疆")
+ return
+ }
+ if params.SourceNumber == "" {
+ util.ResponseFormat(c, code.RequestParamError, "璇疯緭鍏ユ簮鍗曟嵁")
+ return
+ }
+ if params.Status != constvar.OperationStatus_Ready {
+ util.ResponseFormat(c, code.RequestParamError, "璇ヤ俊鎭棤娉曚慨鏀�")
+ return
+ }
+ detail := &models.OperationDetails{
+ ProductId: params.ProductId,
+ ProductName: params.ProductName,
+ Amount: params.Amount,
+ Unit: params.Unit,
+ }
+ operation := models.Operation{
+ Id: params.Id,
+ Number: params.Number,
+ SourceNumber: params.SourceNumber,
+ OperationTypeId: 0,
+ Status: params.Status,
+ FromLocationID: params.FromLocationId,
+ ToLocationID: params.ToLocationId,
+ OperationDate: params.OperationDate,
+ Details: []*models.OperationDetails{detail},
+ }
+ if err := models.WithTransaction(func(tx *gorm.DB) error {
+ if err := models.NewOperationDetailsSearch().SetOrm(tx).SetOperationId(params.Id).Delete(); err != nil {
+ return err
+ }
+ operationSearch := models.NewOperationSearch().SetOrm(tx)
+ if err := operationSearch.Orm.Model(&operation).Association("Details").Replace(operation.Details); err != nil {
+ return err
+ }
+ if err := models.NewOperationSearch().SetOrm(tx).SetID(params.Id).Save(&operation); err != nil {
+ return err
+ }
+ return nil
+ }); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "淇敼澶辫触锛�"+err.Error())
+ return
+ }
+ util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛")
+}
diff --git a/docs/docs.go b/docs/docs.go
index 3a58589..3d921fd 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -787,6 +787,36 @@
}
}
},
+ "/api-wms/v1/product/addDisuse": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "娣诲姞鎶ュ簾淇℃伅",
+ "parameters": [
+ {
+ "description": "鍏ュ簱/鍑哄簱淇℃伅",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.AddDisuse"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/product/addProduct": {
"post": {
"produces": [
@@ -887,6 +917,34 @@
"parameters": [
{
"type": "string",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/product/finishDisuse/{id}": {
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "楠岃瘉鎶ュ簾",
+ "parameters": [
+ {
+ "type": "integer",
"description": "id",
"name": "id",
"in": "path",
@@ -1073,6 +1131,36 @@
}
}
},
+ "/api-wms/v1/product/listDisuse": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "鎶ュ簾鍒楄〃",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.QueryDisuseList"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/product/listOperaton": {
"post": {
"produces": [
@@ -1113,6 +1201,36 @@
}
}
]
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/product/updateDisuse": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "淇敼鎶ュ簾淇℃伅",
+ "parameters": [
+ {
+ "description": "鍏ュ簱/鍑哄簱淇℃伅",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.UpdateDisuse"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
}
}
}
@@ -1456,7 +1574,8 @@
4,
5,
6,
- 7
+ 7,
+ 8
],
"x-enum-comments": {
"LocationTypeCustomer": "瀹㈡埛浣嶇疆",
@@ -1474,7 +1593,8 @@
"LocationTypeCustomer",
"LocationTypeInventoryLoss",
"LocationTypeProduction",
- "LocationTypeTransit"
+ "LocationTypeTransit",
+ "LocationTypeDisuse"
]
},
"constvar.MaterialMode": {
@@ -2306,6 +2426,32 @@
}
}
},
+ "request.AddDisuse": {
+ "type": "object",
+ "properties": {
+ "amount": {
+ "type": "number"
+ },
+ "fromLocationId": {
+ "type": "integer"
+ },
+ "productId": {
+ "type": "string"
+ },
+ "productName": {
+ "type": "string"
+ },
+ "sourceNumber": {
+ "type": "string"
+ },
+ "toLocationId": {
+ "type": "integer"
+ },
+ "unit": {
+ "type": "string"
+ }
+ }
+ },
"request.AddOperation": {
"type": "object",
"properties": {
@@ -2582,6 +2728,25 @@
}
}
},
+ "request.QueryDisuseList": {
+ "type": "object",
+ "properties": {
+ "number": {
+ "type": "string"
+ },
+ "page": {
+ "description": "椤电爜",
+ "type": "integer"
+ },
+ "pageSize": {
+ "description": "姣忛〉澶у皬",
+ "type": "integer"
+ },
+ "sourceNumber": {
+ "type": "string"
+ }
+ }
+ },
"request.QueryOperationList": {
"type": "object",
"properties": {
@@ -2634,6 +2799,44 @@
}
}
},
+ "request.UpdateDisuse": {
+ "type": "object",
+ "properties": {
+ "amount": {
+ "type": "number"
+ },
+ "fromLocationId": {
+ "type": "integer"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "number": {
+ "type": "string"
+ },
+ "operationDate": {
+ "type": "string"
+ },
+ "productId": {
+ "type": "string"
+ },
+ "productName": {
+ "type": "string"
+ },
+ "sourceNumber": {
+ "type": "string"
+ },
+ "status": {
+ "$ref": "#/definitions/constvar.OperationStatus"
+ },
+ "toLocationId": {
+ "type": "integer"
+ },
+ "unit": {
+ "type": "string"
+ }
+ }
+ },
"request.UpdateOperation": {
"type": "object",
"properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 0e384b5..a8ff32a 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -775,6 +775,36 @@
}
}
},
+ "/api-wms/v1/product/addDisuse": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "娣诲姞鎶ュ簾淇℃伅",
+ "parameters": [
+ {
+ "description": "鍏ュ簱/鍑哄簱淇℃伅",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.AddDisuse"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/product/addProduct": {
"post": {
"produces": [
@@ -875,6 +905,34 @@
"parameters": [
{
"type": "string",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/product/finishDisuse/{id}": {
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "楠岃瘉鎶ュ簾",
+ "parameters": [
+ {
+ "type": "integer",
"description": "id",
"name": "id",
"in": "path",
@@ -1061,6 +1119,36 @@
}
}
},
+ "/api-wms/v1/product/listDisuse": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "鎶ュ簾鍒楄〃",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.QueryDisuseList"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/product/listOperaton": {
"post": {
"produces": [
@@ -1101,6 +1189,36 @@
}
}
]
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/product/updateDisuse": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "淇敼鎶ュ簾淇℃伅",
+ "parameters": [
+ {
+ "description": "鍏ュ簱/鍑哄簱淇℃伅",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.UpdateDisuse"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
}
}
}
@@ -1444,7 +1562,8 @@
4,
5,
6,
- 7
+ 7,
+ 8
],
"x-enum-comments": {
"LocationTypeCustomer": "瀹㈡埛浣嶇疆",
@@ -1462,7 +1581,8 @@
"LocationTypeCustomer",
"LocationTypeInventoryLoss",
"LocationTypeProduction",
- "LocationTypeTransit"
+ "LocationTypeTransit",
+ "LocationTypeDisuse"
]
},
"constvar.MaterialMode": {
@@ -2294,6 +2414,32 @@
}
}
},
+ "request.AddDisuse": {
+ "type": "object",
+ "properties": {
+ "amount": {
+ "type": "number"
+ },
+ "fromLocationId": {
+ "type": "integer"
+ },
+ "productId": {
+ "type": "string"
+ },
+ "productName": {
+ "type": "string"
+ },
+ "sourceNumber": {
+ "type": "string"
+ },
+ "toLocationId": {
+ "type": "integer"
+ },
+ "unit": {
+ "type": "string"
+ }
+ }
+ },
"request.AddOperation": {
"type": "object",
"properties": {
@@ -2570,6 +2716,25 @@
}
}
},
+ "request.QueryDisuseList": {
+ "type": "object",
+ "properties": {
+ "number": {
+ "type": "string"
+ },
+ "page": {
+ "description": "椤电爜",
+ "type": "integer"
+ },
+ "pageSize": {
+ "description": "姣忛〉澶у皬",
+ "type": "integer"
+ },
+ "sourceNumber": {
+ "type": "string"
+ }
+ }
+ },
"request.QueryOperationList": {
"type": "object",
"properties": {
@@ -2622,6 +2787,44 @@
}
}
},
+ "request.UpdateDisuse": {
+ "type": "object",
+ "properties": {
+ "amount": {
+ "type": "number"
+ },
+ "fromLocationId": {
+ "type": "integer"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "number": {
+ "type": "string"
+ },
+ "operationDate": {
+ "type": "string"
+ },
+ "productId": {
+ "type": "string"
+ },
+ "productName": {
+ "type": "string"
+ },
+ "sourceNumber": {
+ "type": "string"
+ },
+ "status": {
+ "$ref": "#/definitions/constvar.OperationStatus"
+ },
+ "toLocationId": {
+ "type": "integer"
+ },
+ "unit": {
+ "type": "string"
+ }
+ }
+ },
"request.UpdateOperation": {
"type": "object",
"properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index ff5c7d4..f0f0d6e 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -77,6 +77,7 @@
- 5
- 6
- 7
+ - 8
type: integer
x-enum-comments:
LocationTypeCustomer: 瀹㈡埛浣嶇疆
@@ -94,6 +95,7 @@
- LocationTypeInventoryLoss
- LocationTypeProduction
- LocationTypeTransit
+ - LocationTypeDisuse
constvar.MaterialMode:
enum:
- 鍘熸潗鏂�
@@ -679,6 +681,23 @@
description: 澶囨敞
type: string
type: object
+ request.AddDisuse:
+ properties:
+ amount:
+ type: number
+ fromLocationId:
+ type: integer
+ productId:
+ type: string
+ productName:
+ type: string
+ sourceNumber:
+ type: string
+ toLocationId:
+ type: integer
+ unit:
+ type: string
+ type: object
request.AddOperation:
properties:
comment:
@@ -870,6 +889,19 @@
sourceNumber:
type: string
type: object
+ request.QueryDisuseList:
+ properties:
+ number:
+ type: string
+ page:
+ description: 椤电爜
+ type: integer
+ pageSize:
+ description: 姣忛〉澶у皬
+ type: integer
+ sourceNumber:
+ type: string
+ type: object
request.QueryOperationList:
properties:
page:
@@ -904,6 +936,31 @@
type: integer
remark:
description: 澶囨敞
+ type: string
+ type: object
+ request.UpdateDisuse:
+ properties:
+ amount:
+ type: number
+ fromLocationId:
+ type: integer
+ id:
+ type: integer
+ number:
+ type: string
+ operationDate:
+ type: string
+ productId:
+ type: string
+ productName:
+ type: string
+ sourceNumber:
+ type: string
+ status:
+ $ref: '#/definitions/constvar.OperationStatus'
+ toLocationId:
+ type: integer
+ unit:
type: string
type: object
request.UpdateOperation:
@@ -1507,6 +1564,25 @@
summary: 缂栬緫浣滀笟绫诲瀷
tags:
- 涓氬姟绫诲瀷
+ /api-wms/v1/product/addDisuse:
+ post:
+ parameters:
+ - description: 鍏ュ簱/鍑哄簱淇℃伅
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.AddDisuse'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 娣诲姞鎶ュ簾淇℃伅
+ tags:
+ - 浜у搧
/api-wms/v1/product/addProduct:
post:
parameters:
@@ -1581,6 +1657,24 @@
summary: 鍒犻櫎浜у搧绫诲瀷
tags:
- 浜у搧绫诲瀷
+ /api-wms/v1/product/finishDisuse/{id}:
+ put:
+ parameters:
+ - description: id
+ in: path
+ name: id
+ required: true
+ type: integer
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 楠岃瘉鎶ュ簾
+ tags:
+ - 浜у搧
/api-wms/v1/product/getProductCategoryDetails/{id}:
get:
parameters:
@@ -1679,6 +1773,25 @@
summary: 鑾峰彇浜у搧鍒楄〃
tags:
- 浜у搧
+ /api-wms/v1/product/listDisuse:
+ post:
+ parameters:
+ - description: 鏌ヨ鍙傛暟
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.QueryDisuseList'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 鎶ュ簾鍒楄〃
+ tags:
+ - 浜у搧
/api-wms/v1/product/listOperaton:
post:
parameters:
@@ -1705,6 +1818,25 @@
summary: 浜у搧鍘嗗彶鍑哄叆搴撲俊鎭�
tags:
- 浜у搧
+ /api-wms/v1/product/updateDisuse:
+ post:
+ parameters:
+ - description: 鍏ュ簱/鍑哄簱淇℃伅
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.UpdateDisuse'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 淇敼鎶ュ簾淇℃伅
+ tags:
+ - 浜у搧
/api-wms/v1/product/updateProduct:
post:
parameters:
diff --git a/models/material.go b/models/material.go
index d8098fd..dd74cb1 100644
--- a/models/material.go
+++ b/models/material.go
@@ -475,3 +475,24 @@
}
return result.Max, nil
}
+
+type ResponseDisuseList struct {
+ Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+ Number string `json:"number" gorm:"type:varchar(255)"` //鍗曞彿
+ SourceNumber string `json:"sourceNumber" gorm:"type:varchar(255)"` //婧愬崟鍙�
+ Status constvar.OperationStatus `json:"status" gorm:"type:int(11);not null;comment:鐘舵��"` //鐘舵��
+ FromLocationID int `json:"fromLocationId" gorm:"type:int;not null;comment:婧愪綅缃甶d"` //婧愪綅缃甶d
+ FromLocation Location `json:"fromLocation" gorm:"foreignKey:FromLocationID;references:Id"` //婧愪綅缃�
+ ToLocation Location `json:"toLocation" gorm:"foreignKey:ToLocationID;references:Id"` //鐩爣浣嶇疆
+ ToLocationID int `json:"toLocationId" gorm:"type:int;not null;comment:鐩爣浣嶇疆id"` //鐩爣浣嶇疆id
+ OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:瀹夋帓鏃ユ湡"`
+ ContacterID int `json:"contacterID" gorm:"type:int;comment:鑱旂郴浜篒D"`
+ ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:鑱旂郴浜哄鍚�"`
+ CompanyID int `json:"companyID" gorm:"type:int;comment:鍏徃ID-瀹㈡埛"`
+ CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О-瀹㈡埛"`
+ Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"`
+ ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id
+ ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О
+ Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:鏁伴噺"` //鏁伴噺
+ Unit string `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"`
+}
diff --git a/models/operation.go b/models/operation.go
index 3142f3b..b0d64d4 100644
--- a/models/operation.go
+++ b/models/operation.go
@@ -45,6 +45,7 @@
Keyword string
Orm *gorm.DB
Preload bool
+ Disuse bool
}
)
@@ -101,6 +102,11 @@
return slf
}
+func (slf *OperationSearch) SetDisuse(disuse bool) *OperationSearch {
+ slf.Disuse = disuse
+ return slf
+}
+
func (slf *OperationSearch) build() *gorm.DB {
var db = slf.Orm.Model(&Operation{})
@@ -131,6 +137,10 @@
db = db.Model(&Operation{}).Preload("Details").Preload("FromLocation").Preload("ToLocation")
}
+ if slf.Disuse {
+ db = db.Where("operation_type_id = ?", 0)
+ }
+
return db
}
diff --git a/request/product_request.go b/request/product_request.go
index c4b8cae..0f16f7b 100644
--- a/request/product_request.go
+++ b/request/product_request.go
@@ -1,5 +1,10 @@
package request
+import (
+ "github.com/shopspring/decimal"
+ "wms/constvar"
+)
+
type GetProductList struct {
PageInfo
KeyWord string `json:"keyWord"`
@@ -9,3 +14,33 @@
PageInfo
ProductId string `json:"productId"`
}
+
+type AddDisuse struct {
+ ProductId string `json:"productId"`
+ ProductName string `json:"productName"`
+ Amount decimal.Decimal `json:"amount"`
+ FromLocationId int `json:"fromLocationId"`
+ ToLocationId int `json:"toLocationId"`
+ SourceNumber string `json:"sourceNumber"`
+ Unit string `json:"unit"`
+}
+
+type QueryDisuseList struct {
+ PageInfo
+ Number string `json:"number"`
+ SourceNumber string `json:"sourceNumber"`
+}
+
+type UpdateDisuse struct {
+ Id int `json:"id"`
+ ProductId string `json:"productId"`
+ ProductName string `json:"productName"`
+ Amount decimal.Decimal `json:"amount"`
+ FromLocationId int `json:"fromLocationId"`
+ ToLocationId int `json:"toLocationId"`
+ SourceNumber string `json:"sourceNumber"`
+ Unit string `json:"unit"`
+ Number string `json:"number"`
+ Status constvar.OperationStatus `json:"status"`
+ OperationDate string `json:"operationDate"`
+}
diff --git a/router/router.go b/router/router.go
index b03a86d..e912304 100644
--- a/router/router.go
+++ b/router/router.go
@@ -102,7 +102,12 @@
productAPI.POST("updateProductCategory", productController.UpdateProductCategory) //淇敼浜у搧绫诲瀷
productAPI.DELETE("deleteProductCategory/:id", productController.DeleteProductCategory) //鍒犻櫎浜у搧绫诲瀷
- productAPI.POST("listOperaton", productController.ListOperation) //鏌ョ湅浜у搧鐨勫巻鍙插嚭鍏ュ簱淇℃伅
+ productAPI.POST("listOperaton", productController.ListOperation) //鏌ョ湅浜у搧鐨勫巻鍙插嚭鍏ュ簱淇℃伅
+ productAPI.POST("addDisuse", productController.AddDisuse) //娣诲姞鎶ュ簾淇℃伅
+ productAPI.POST("listDisuse", productController.ListDisuse) //鏌ョ湅浜у搧鐨勫巻鍙插嚭鍏ュ簱淇℃伅
+ productAPI.PUT("finishDisuse/:id", productController.FinishDisuse) //鎶ュ簾楠岃瘉
+ productAPI.POST("updateDisuse", productController.UpdateDisuse) //淇敼鎶ュ簾淇℃伅
+
}
return r
--
Gitblit v1.8.0