From 73b6baf6af3d88cdcb0e2df7932a9bd96b0b85c5 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 01 七月 2024 22:32:34 +0800
Subject: [PATCH] 月度统计出入库按类型汇总报表定时任务和手动跑任务接口

---
 models/db.go |   46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/models/db.go b/models/db.go
index e32a28e..07c3fb9 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 {
@@ -81,9 +109,22 @@
 		Operation{},
 		OperationDetails{},
 		Scrap{},
-		MoveHistory{},
-		Product{},
 		ProductCategory{},
+		Material{},
+		LocationProduct{},
+		LocationProductAmount{},
+		ReorderRule{},
+		Attachment{},
+		LogisticCompany{},
+		FileTemplateAttachment{},
+		MoveHistory{},
+		Lock{},
+		MonthStats{},
+		Attribute{},
+		AttributeValue{},
+		SystemConfig{},
+		WarehouseMonthStats{},
+		WarehouseStatsItems{},
 	)
 	return err
 }
@@ -95,6 +136,7 @@
 func InsertDefaultData() {
 	models := []interface{}{
 		NewDepartmentSearch(),
+		NewLocationSearch(),
 	}
 	for _, model := range models {
 		if id, ok := model.(InitDefaultData); ok {

--
Gitblit v1.8.0