From 7f22e4058d0b27eca88181629caa14e1fba5c18e Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期三, 13 十二月 2023 10:07:01 +0800
Subject: [PATCH] 入库、出库、调拨、报废根据编码规则自动生成单号
---
constvar/const.go | 10 +++++
controllers/code.go | 13 +++++-
models/operation.go | 12 ++++++
docs/swagger.yaml | 13 ++++++
docs/docs.go | 18 ++++++++
docs/swagger.json | 18 ++++++++
6 files changed, 79 insertions(+), 5 deletions(-)
diff --git a/constvar/const.go b/constvar/const.go
index b8b90e3..ff66bdd 100644
--- a/constvar/const.go
+++ b/constvar/const.go
@@ -230,3 +230,13 @@
FileTemplateCategory_Selfmade FileTemplateCategory = iota + 1 //鍏ュ簱-鑷埗
FileTemplateCategory_Output //鍑哄簱
)
+
+type CodeStandardType string
+
+const (
+ CodeStandardType_Material CodeStandardType = "鐗╂枡缂栫爜"
+ CodeStandardType_Incoming CodeStandardType = "鍏ュ簱缂栫爜"
+ CodeStandardType_Outgoing CodeStandardType = "鍑哄簱缂栫爜"
+ CodeStandardType_Internal CodeStandardType = "璋冩嫧缂栫爜"
+ CodeStandardType_Disuse CodeStandardType = "鎶ュ簾缂栫爜"
+)
diff --git a/controllers/code.go b/controllers/code.go
index f539fc4..eea0f4a 100644
--- a/controllers/code.go
+++ b/controllers/code.go
@@ -3,6 +3,7 @@
import (
"github.com/gin-gonic/gin"
"github.com/spf13/cast"
+ "wms/constvar"
cd "wms/extend/code"
"wms/extend/util"
"wms/models"
@@ -87,9 +88,17 @@
id = 0
err error
)
- switch params.Type {
- case "鐗╂枡缂栫爜":
+ switch constvar.CodeStandardType(params.Type) {
+ case constvar.CodeStandardType_Material:
id, err = models.NewMaterialSearch().MaxAutoIncr()
+ case constvar.CodeStandardType_Incoming:
+ id, err = models.NewOperationSearch().SetBaseOperationType(constvar.BaseOperationTypeIncoming).MaxAutoIncr()
+ case constvar.CodeStandardType_Outgoing:
+ id, err = models.NewOperationSearch().SetBaseOperationType(constvar.BaseOperationTypeOutgoing).MaxAutoIncr()
+ case constvar.CodeStandardType_Internal:
+ id, err = models.NewOperationSearch().SetBaseOperationType(constvar.BaseOperationTypeInternal).MaxAutoIncr()
+ case constvar.CodeStandardType_Disuse:
+ id, err = models.NewOperationSearch().SetBaseOperationType(constvar.BaseOperationTypeDisuse).MaxAutoIncr()
default:
util.ResponseFormat(c, cd.RequestError, "缂栫爜瑙勫垯涓嶅瓨鍦�")
return
diff --git a/docs/docs.go b/docs/docs.go
index 2f60e96..1ec49df 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -1243,7 +1243,7 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/request.OperationAllList"
+ "$ref": "#/definitions/request.OperationCondition"
}
}
],
@@ -4193,6 +4193,22 @@
}
}
},
+ "request.OperationCondition": {
+ "type": "object",
+ "properties": {
+ "condition": {
+ "type": "string"
+ },
+ "page": {
+ "description": "椤电爜",
+ "type": "integer"
+ },
+ "pageSize": {
+ "description": "姣忛〉澶у皬",
+ "type": "integer"
+ }
+ }
+ },
"request.OperationDetails": {
"type": "object",
"properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index cb0dd14..8022c96 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -1231,7 +1231,7 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/request.OperationAllList"
+ "$ref": "#/definitions/request.OperationCondition"
}
}
],
@@ -4181,6 +4181,22 @@
}
}
},
+ "request.OperationCondition": {
+ "type": "object",
+ "properties": {
+ "condition": {
+ "type": "string"
+ },
+ "page": {
+ "description": "椤电爜",
+ "type": "integer"
+ },
+ "pageSize": {
+ "description": "姣忛〉澶у皬",
+ "type": "integer"
+ }
+ }
+ },
"request.OperationDetails": {
"type": "object",
"properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index fb15671..2f29308 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1179,6 +1179,17 @@
sourceNumber:
type: string
type: object
+ request.OperationCondition:
+ properties:
+ condition:
+ type: string
+ page:
+ description: 椤电爜
+ type: integer
+ pageSize:
+ description: 姣忛〉澶у皬
+ type: integer
+ type: object
request.OperationDetails:
properties:
OperationId:
@@ -2353,7 +2364,7 @@
name: object
required: true
schema:
- $ref: '#/definitions/request.OperationAllList'
+ $ref: '#/definitions/request.OperationCondition'
produces:
- application/json
responses:
diff --git a/models/operation.go b/models/operation.go
index d076b88..2009733 100644
--- a/models/operation.go
+++ b/models/operation.go
@@ -337,3 +337,15 @@
return records, nil
}
+
+func (slf *OperationSearch) MaxAutoIncr() (int, error) {
+ var (
+ db = slf.build()
+ total int64
+ )
+
+ if err := db.Count(&total).Error; err != nil {
+ return int(total), fmt.Errorf("max err: %v", err)
+ }
+ return int(total), nil
+}
--
Gitblit v1.8.0