From 221108b0e0416968ca8417513ebf65c8b5109662 Mon Sep 17 00:00:00 2001
From: lishihai <dslsh@dscom>
Date: 星期三, 26 六月 2024 11:40:47 +0800
Subject: [PATCH] 库存盘点应用按钮记录创建人,创建时间,应用时间、应用人员等信息;根据条形码查询产品详情;新增编辑产品增加条形码字段->添加条形码被使用验证
---
models/db.go | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/models/db.go b/models/db.go
index e4c25d0..de0c2d2 100644
--- a/models/db.go
+++ b/models/db.go
@@ -3,11 +3,14 @@
import (
"fmt"
"gorm.io/gorm/schema"
+ "strconv"
+ "time"
"wms/conf"
"wms/extend/util"
"wms/pkg/logx"
"wms/pkg/mysqlx"
"wms/pkg/snowflake"
+ "wms/proto/code"
"gorm.io/gorm"
)
@@ -55,6 +58,31 @@
return nil
}
+func GetAutoCode(id int, codeStandard *code.CodeStandard) string {
+ autoCode := ""
+ var prefixValue string
+ if codeStandard.AutoRule.PrefixMethod == 2 { // 鏉ユ簮鍗曟嵁
+ prefixValue = ""
+ } else { // 鍥哄畾鍊�
+ prefixValue = codeStandard.AutoRule.PrefixValue
+ }
+ strMaxAutoIncr := strconv.Itoa(id + 1)
+ count := int(codeStandard.AutoRule.AutoLength) - len(strMaxAutoIncr)
+ for i := 0; i < count; i++ {
+ strMaxAutoIncr = "0" + strMaxAutoIncr
+ }
+
+ var suffixValue string
+ if codeStandard.AutoRule.SuffixMethod == 2 { // 骞存湀鏃�+鑷闀�
+ suffixValue = fmt.Sprintf("%v%v", time.Now().Format("20060102"), strMaxAutoIncr)
+ } else { // 鑷闀�
+ suffixValue = strMaxAutoIncr
+ }
+
+ autoCode = prefixValue + suffixValue
+ return autoCode
+}
+
func Init() error {
fmt.Printf("dsn=%v\n", conf.DbConf.Dsn)
if err := mysqlx.Init(conf.DbConf, logx.GetLogger()); err != nil {
@@ -88,6 +116,12 @@
ReorderRule{},
Attachment{},
LogisticCompany{},
+ FileTemplateAttachment{},
+ MoveHistory{},
+ Lock{},
+ MonthStats{},
+ Attribute{},
+ AttributeValue{},
)
return err
}
--
Gitblit v1.8.0