From 9b60ddba27ef778419da5089e3b30ebe173afd7d Mon Sep 17 00:00:00 2001
From: yinbentan <yinbentan@live.com>
Date: 星期五, 28 六月 2024 14:24:35 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/jialian' into jialian
---
controllers/product_controller.go | 95 ++
models/system_config.go | 244 +++++++
controllers/report_forms_controller.go | 34 +
request/config_type.go | 14
models/material.go | 21
models/operation.go | 1
docs/swagger.yaml | 225 ++++++
service/system_config.go | 73 ++
task/month_stats.go | 158 ----
utils/util.go | 22
service/month_forms.go | 101 ++
controllers/location_product_amount.go | 16
controllers/operation.go | 60 +
controllers/system_config.go | 89 ++
request/operation.go | 53
docs/docs.go | 353 ++++++++++
conf/config.yaml | 4
docs/swagger.json | 350 ++++++++++
router/router.go | 20
task/tasklist.go | 41
constvar/const.go | 6
/dev/null | 0
models/db.go | 1
main.go | 5
service/more_units.go | 5
25 files changed, 1,764 insertions(+), 227 deletions(-)
diff --git a/conf/config.yaml b/conf/config.yaml
index 35102d0..d608c0d 100644
--- a/conf/config.yaml
+++ b/conf/config.yaml
@@ -27,8 +27,8 @@
storePath: uploads/file
grpcServer:
apsAddr: 127.0.0.1:9091
- crmAddr: 192.168.20.119:9092
- srmAddr: 192.168.20.119:9093
+ crmAddr: 127.0.0.1:9092
+ srmAddr: 127.0.0.1:9093
dingTalk:
alarmKey: SEC31ccce95daf26763ab54575bd4cac156f22ed0a42f3e27d3edd06edb77b3d221
alarmUrl: https://oapi.dingtalk.com/robot/send?access_token=c6023d2c55058b86d59290ad205eff86a8c681a7807f76c569f91434663081fa
diff --git a/constvar/const.go b/constvar/const.go
index c128d57..b965525 100644
--- a/constvar/const.go
+++ b/constvar/const.go
@@ -316,3 +316,9 @@
)
const DoMonthStatsToken = "Eoh2ZAUJjtbmu0TBkc3dq7MPCpL4riw5NVxOfgXYlKvHF6sR"
+
+type SystemConfigType int
+
+const (
+ SystemConfigTypeInventoryCutOffPoint SystemConfigType = 1 //搴撳瓨缁撶畻鏃堕棿鐐�
+)
diff --git a/controllers/location_product_amount.go b/controllers/location_product_amount.go
index 5a62cb9..87ff91b 100644
--- a/controllers/location_product_amount.go
+++ b/controllers/location_product_amount.go
@@ -11,6 +11,7 @@
"wms/constvar"
"wms/extend/code"
"wms/extend/util"
+ "wms/middleware"
"wms/models"
"wms/pkg/mysqlx"
"wms/request"
@@ -155,8 +156,8 @@
util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
return
}
-
- if err := AddLocationProductAmount(reqParams); err != nil {
+ userInfo := middleware.GetUserInfo(c)
+ if err := AddLocationProductAmount(reqParams, userInfo); err != nil {
util.ResponseFormat(c, code.RequestError, err)
return
}
@@ -164,7 +165,7 @@
util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛")
}
-func AddLocationProductAmount(reqParams request.UpdateLocationProductAmount) error {
+func AddLocationProductAmount(reqParams request.UpdateLocationProductAmount, userInfo *request.CustomClaims) error {
if reqParams.LocationId == 0 {
return errors.New("鍙傛暟寮傚父锛屼綅缃甶d淇℃伅涓嶅瓨鍦�")
}
@@ -219,6 +220,7 @@
Details: []*models.OperationDetails{detail},
LocationID: location.Id,
OperationTypeName: "搴撳瓨璋冩暣",
+ CreatedBy: userInfo.Username,
}
if err := models.WithTransaction(func(tx *gorm.DB) error {
@@ -278,8 +280,9 @@
util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
return
}
+ userInfo := middleware.GetUserInfo(c)
if reqParams.OperationId == 0 {
- if err := AddLocationProductAmount(reqParams); err != nil {
+ if err := AddLocationProductAmount(reqParams, userInfo); err != nil {
util.ResponseFormat(c, code.RequestError, err.Error())
return
}
@@ -349,8 +352,11 @@
return
}
adjustAmount := operation.Details[0].Amount.Sub(locProductAmount.Amount)
+ userInfo := middleware.GetUserInfo(c)
if err := models.WithTransaction(func(tx *gorm.DB) error {
- if err := models.NewOperationSearch().SetOrm(tx).SetID(reqParams.OperationId).Update(&models.Operation{Status: constvar.OperationStatus_Finish}); err != nil {
+ if err := models.NewOperationSearch().SetOrm(tx).SetID(reqParams.OperationId).Update(&models.Operation{
+ Status: constvar.OperationStatus_Finish, CheckedBy: userInfo.Username,
+ AuditDate: time.Now().Format("2006-01-02 15:04:05")}); err != nil {
return err
}
if err := models.NewMaterialSearch().SetOrm(tx).SetID(reqParams.ProductId).Update(&models.Material{Amount: material.Amount.Add(adjustAmount)}); err != nil {
diff --git a/controllers/operation.go b/controllers/operation.go
index 2cc1671..e174c67 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -72,17 +72,28 @@
util.ResponseFormat(c, code.RequestParamError, "鏄庣粏涓笉鑳藉瓨鍦ㄩ噸澶嶇殑浜у搧")
return
}
-
- operationType, err := models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First()
- if err != nil {
- util.ResponseFormat(c, code.RequestParamError, err.Error())
- return
+ var operationType *models.OperationType
+ var err error
+ if params.OperationTypeId == 0 {
+ operationType, err = models.NewOperationTypeSearch().SetWarehouseId(params.WarehouseId).SetBaseOperationType(params.BaseOperationType).First()
+ if err != nil || params.WarehouseId != operationType.WarehouseId {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟缂哄け")
+ return
+ }
+ } else {
+ operationType, err = models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, err.Error())
+ return
+ }
}
+
userInfo := middleware.GetUserInfo(c)
params.CreatedBy = userInfo.Username
params.Status = constvar.OperationStatus_Ready
//params.Number = strconv.FormatInt(time.Now().Unix(), 10)
params.BaseOperationType = operationType.BaseOperationType
+ params.WarehouseId = operationType.WarehouseId
var numberNum int64
if err := mysqlx.GetDB().Model(&models.Operation{}).Where("number=?", params.Number).Count(&numberNum).Error; err != nil {
@@ -191,7 +202,13 @@
}
if params.OperationTypeId == 0 && int(params.BaseOperationType) == 0 {
- return errors.New("鏈瘑鍒璁板綍绫诲瀷")
+ return errors.New("鏈瘑鍒璁板綍绫诲瀷1")
+ }
+
+ if params.BaseOperationType != 0 {
+ if params.WarehouseId == 0 {
+ return errors.New("鏈瘑鍒璁板綍绫诲瀷2")
+ }
}
if params.OperationDate == "" {
@@ -282,7 +299,9 @@
costMap[material.ID] = material.Cost
salePriceMap[material.ID] = material.SalePrice
}
- list, total, err := search.SetOperationTypeId(params.OperationTypeId).SetPreload(true).SetOrder("created_at desc").Find()
+ list, total, err := search.SetOperationTypeId(params.OperationTypeId).
+ SetBaseOperationType(params.BaseOperationType).
+ SetPreload(true).SetOrder("created_at desc").Find()
if err != nil {
util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error())
return
@@ -303,8 +322,8 @@
if !params.PageInfo.Check() {
return errors.New("鏁版嵁鍒嗛〉淇℃伅閿欒")
}
- if params.OperationTypeId == 0 {
- return errors.New("operationTypeId涓�0")
+ if params.OperationTypeId == 0 && params.BaseOperationType == 0 {
+ return errors.New("operationTypeId鍜宐aseOperationType涓嶈兘鍚屾椂涓�0")
}
return nil
}
@@ -1002,8 +1021,8 @@
sheet := "Sheet1"
f.SetCellValue(sheet, "A2", "鍗曚綅(閮ㄩ棬):"+operation.CompanyName) // 鍗曚綅閮ㄩ棬
- f.SetCellValue(sheet, "H2", operation.OperationDate) // 鏃堕棿
- f.SetCellValue(sheet, "O2", operation.Number) // 缂栧彿
+ f.SetCellValue(sheet, "J2", operation.OperationDate) // 鏃堕棿
+ f.SetCellValue(sheet, "Q2", operation.Number) // 缂栧彿
totalAmount := decimal.NewFromInt(0) // 鎬婚噾棰�
totalPrice := decimal.NewFromInt(0) // 鎬讳环
@@ -1013,14 +1032,19 @@
if i > 9 {
break
}
- f.SetCellValue(sheet, "A"+strconv.Itoa(rowIndex), v.Product.Name) // 浜у搧鍚嶇О
- f.SetCellValue(sheet, "B"+strconv.Itoa(rowIndex), v.Product.Specs) //瑙勬牸
- f.SetCellValue(sheet, "C"+strconv.Itoa(rowIndex), v.TotalGrossWeight.String()) //閲嶉噺
- f.SetCellValue(sheet, "D"+strconv.Itoa(rowIndex), v.Amount.String()) //鏁伴噺
- f.SetCellValue(sheet, "E"+strconv.Itoa(rowIndex), v.AuxiliaryAmount.String()) //杈呭姪鏁伴噺
- f.SetCellValue(sheet, "F"+strconv.Itoa(rowIndex), v.AuxiliaryUnit) //杈呭姪鍗曚綅
+ f.SetCellValue(sheet, "A"+strconv.Itoa(rowIndex), v.Product.Name) // 鍝佸悕
+ f.SetCellValue(sheet, "B"+strconv.Itoa(rowIndex), v.Product.Type) // 鍨嬪彿
+ f.SetCellValue(sheet, "C"+strconv.Itoa(rowIndex), v.Product.Unit) // 鍗曚綅
+ f.SetCellValue(sheet, "D"+strconv.Itoa(rowIndex), v.Amount.String()) // 鏁伴噺
+ unit := service.CreateMoreUnit(v.Amount, v.Product.MoreUnitList)
+ for _, v1 := range unit {
+ if !v1.Amount.IsZero() {
+ f.SetCellValue(sheet, "E"+strconv.Itoa(rowIndex), v1.Amount) // 杈呮暟閲�
+ f.SetCellValue(sheet, "F"+strconv.Itoa(rowIndex), v1.Unit) // 杈呭崟浣�
+ break
+ }
+ }
f.SetCellValue(sheet, "G"+strconv.Itoa(rowIndex), v.Product.SalePrice.String()) // 鍗曚环
-
// 閲戦
if !v.Product.SalePrice.IsZero() {
ap := v.Amount.Mul(v.Product.SalePrice)
diff --git a/controllers/product_controller.go b/controllers/product_controller.go
index 86f4178..0a0bc3f 100644
--- a/controllers/product_controller.go
+++ b/controllers/product_controller.go
@@ -54,6 +54,13 @@
util.ResponseFormat(c, code.RequestParamError, "鍗曚綅涓嶈兘涓虹┖")
return
}
+ if params.BarCode != "" {
+ m, err := models.NewMaterialSearch().SetBarCode(params.BarCode).First()
+ if err == nil && m.ID != "" { //鏌ュ嚭鐗╂枡琛ㄦ槸鐗╂枡宸插瓨鍦�
+ util.ResponseFormat(c, code.RequestParamError, "鏉″舰鐮佸凡缁忚浣跨敤")
+ return
+ }
+ }
//params.ID = utils.GetUUID()
err := models.WithTransaction(func(tx *gorm.DB) error {
@@ -218,7 +225,7 @@
// GetProductDetails
// @Tags 浜у搧
-// @Summary 鑾峰彇浜у搧璇︽儏
+// @Summary 閫氳繃浜у搧/鍟嗗搧/鐗╂枡 ID鑾峰彇浜у搧璇︽儏
// @Produce application/json
// @Param Authorization header string true "token"
// @Param id path string true "id" "鏌ヨ鍙傛暟"
@@ -231,6 +238,62 @@
return
}
material, err := models.NewMaterialSearch().SetID(id).SetPreload(true).First()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触")
+ return
+ }
+ attributeValues, err := models.NewAttributeValueSearch().SetEntityID(material.ID).FindNotTotal()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触")
+ return
+ }
+ aids := make([]uint, 0)
+ for _, v := range attributeValues {
+ aids = append(aids, v.AttributeID)
+ }
+ attributes, err := models.NewAttributeSearch().SetIDs(aids).FindNotTotal()
+ attributesMap := make(map[uint]*models.Attribute, len(attributes))
+ for _, v := range attributes {
+ attributesMap[v.ID] = v
+ }
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鏈煡鍔ㄦ�佸睘鎬�")
+ }
+ for _, v1 := range attributeValues {
+ attribute := attributesMap[v1.AttributeID]
+ if attribute == nil {
+ continue
+ }
+ //product.Attributes = append(product.Attributes,v1)
+ material.Attributes = append(material.Attributes, models.Attribute{
+ Model: gorm.Model{ID: v1.ID, CreatedAt: v1.CreatedAt, UpdatedAt: v1.UpdatedAt, DeletedAt: v1.DeletedAt},
+ Name: attribute.Name,
+ DataType: attribute.DataType,
+ EntityType: attribute.EntityType,
+ SelectValues: attribute.SelectValues,
+ SelectValue: attribute.SelectValue,
+ //Value: v1.Value,
+ Value: v1.Value,
+ })
+ }
+ util.ResponseFormat(c, code.Success, material)
+}
+
+// GetProductDetailsByBarCode
+// @Tags 浜у搧
+// @Summary 閫氳繃浜у搧/鍟嗗搧/鐗╂枡 鏉″舰鐮� 鑾峰彇浜у搧璇︽儏
+// @Produce application/json
+// @Param Authorization header string true "token"
+// @Param barCode path string true "barCode" "鏌ヨ鍙傛暟"
+// @Success 200 {object} util.Response{data=models.Material} "鎴愬姛"
+// @Router /api-wms/v1/product/getProductDetailsByBarCode/{barCode} [get]
+func (slf ProductController) GetProductDetailsByBarCode(c *gin.Context) {
+ barCode := c.Param("barCode")
+ if barCode == "" {
+ util.ResponseFormat(c, code.RequestParamError, "鏃犳晥鏉″舰鐮�")
+ return
+ }
+ material, err := models.NewMaterialSearch().SetBarCode(barCode).SetPreload(true).First()
if err != nil {
util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触")
return
@@ -296,6 +359,13 @@
if params.Unit == "" {
util.ResponseFormat(c, code.RequestParamError, "鍗曚綅涓嶈兘涓虹┖")
return
+ }
+ if params.BarCode != "" {
+ m, err := models.NewMaterialSearch().SetBarCode(params.BarCode).First()
+ if err == nil && m.ID != params.ID { //鏌ュ嚭鐗╂枡涓擨D涓嶄竴鏍�,
+ util.ResponseFormat(c, code.RequestParamError, "鏉″舰鐮佸凡缁忚浣跨敤")
+ return
+ }
}
err := models.NewMaterialSearch().SetID(params.ID).Save(¶ms)
if err != nil {
@@ -365,7 +435,7 @@
// DeleteProduct
// @Tags 浜у搧
-// @Summary 鍒犻櫎浜у搧
+// @Summary 閫氳繃浜у搧/鍟嗗搧/鐗╂枡 ID鍒犻櫎浜у搧
// @Produce application/json
// @Param id path string true "id" "鏌ヨ鍙傛暟"
// @Success 200 {object} util.Response "鎴愬姛"
@@ -384,6 +454,27 @@
util.ResponseFormat(c, code.Success, "鍒犻櫎鎴愬姛")
}
+// DeleteProductByBarCode
+// @Tags 浜у搧
+// @Summary 閫氳繃浜у搧/鍟嗗搧/鐗╂枡 鏉″舰鐮佸垹闄や骇鍝�
+// @Produce application/json
+// @Param barCode path string true "barCode" "鏌ヨ鍙傛暟"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/product/deleteProductByBarCode/{barCode} [delete]
+func (slf ProductController) DeleteProductByBarCode(c *gin.Context) {
+ barCode := c.Param("barCode")
+ if barCode == "" {
+ util.ResponseFormat(c, code.RequestParamError, "鏃犳晥id")
+ return
+ }
+ err := models.NewMaterialSearch().SetBarCode(barCode).Delete()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍒犻櫎澶辫触")
+ return
+ }
+ util.ResponseFormat(c, code.Success, "鍒犻櫎鎴愬姛")
+}
+
// AddProductCategory
// @Tags 浜у搧绫诲瀷
// @Summary 娣诲姞浜у搧绫诲瀷
diff --git a/controllers/report_forms_controller.go b/controllers/report_forms_controller.go
index 5f907fa..e3346ae 100644
--- a/controllers/report_forms_controller.go
+++ b/controllers/report_forms_controller.go
@@ -5,9 +5,11 @@
"github.com/shopspring/decimal"
"net/url"
"os"
+ "time"
"wms/constvar"
"wms/extend/code"
"wms/extend/util"
+ "wms/models"
"wms/pkg/logx"
"wms/request"
"wms/service"
@@ -335,6 +337,7 @@
util.ResponseFormat(c, code.InternalError, "鏌ヨ鎬绘暟澶辫触")
return
}
+
result, err := monthFormsService.Query(params)
if err != nil {
logx.Errorf("MonthStats query err:%v", err)
@@ -342,6 +345,37 @@
return
}
+ now := time.Now().Local()
+ today := now.Day()
+ nowMonth := now.Format("2006-01")
+
+ day, dateStr, err := service.NewSystemConfigService().GetInventoryCutOffPoint()
+ if nowMonth == params.Date && today < day || today == day && now.Format("15:04") < dateStr { //鏈湀鏈嚦缁撶畻鏃堕棿鐐�
+ productIds := make([]string, 0, len(result))
+ for _, item := range result {
+ productIds = append(productIds, item.ProductId)
+ }
+ statsRecords, err := service.GetCurrentStats(params.Date, productIds)
+ if err != nil {
+ util.ResponseFormat(c, code.InternalError, "鍐呴儴閿欒")
+ return
+ }
+ statsMap := models.MonthStatsMap(statsRecords)
+ for k, v := range result {
+ if statsMap[v.ProductId] == nil {
+ continue
+ }
+
+ result[k].OutputAmount = statsMap[v.ProductId].OutputAmount
+ result[k].OutputMoreUnits = statsMap[v.ProductId].OutputMoreUnits
+ result[k].EndAmount = statsMap[v.ProductId].EndAmount
+ result[k].EndMoreUnits = statsMap[v.ProductId].EndMoreUnits
+ result[k].InputAmount = statsMap[v.ProductId].InputAmount
+ result[k].InputMoreUnits = statsMap[v.ProductId].InputMoreUnits
+ }
+
+ }
+
util.ResponseFormatList(c, code.Success, result, int(total))
}
diff --git a/controllers/system_config.go b/controllers/system_config.go
new file mode 100644
index 0000000..7c73191
--- /dev/null
+++ b/controllers/system_config.go
@@ -0,0 +1,89 @@
+package controllers
+
+import (
+ "github.com/gin-gonic/gin"
+ "wms/extend/code"
+ "wms/extend/util"
+ "wms/models"
+ "wms/pkg/logx"
+ "wms/pkg/structx"
+ "wms/request"
+ "wms/service"
+ "wms/task"
+)
+
+type SystemConfigController struct{}
+
+// SaveConfig
+// @Tags 绯荤粺璁剧疆
+// @Summary 淇濆瓨绯荤粺璁剧疆
+// @Produce application/json
+// @Param object body request.SystemConfig true "绯荤粺璁剧疆淇℃伅"'
+// @Param Authorization header string true "token"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/systemConfig/save [post]
+func (slf SystemConfigController) SaveConfig(c *gin.Context) {
+ var reqParams request.SystemConfig
+ var params models.SystemConfig
+ if err := c.BindJSON(&reqParams); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
+ return
+ }
+ if err := structx.AssignTo(reqParams, ¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鏁版嵁杞崲閿欒")
+ return
+ }
+
+ srv := service.NewSystemConfigService()
+
+ if err := srv.ParamsCheck(params); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, err.Error())
+ return
+ }
+
+ if params.Id == 0 {
+ if err := models.NewSystemConfigSearch().Create(¶ms); err != nil {
+ logx.Errorf("SystemConfig create err: %v", err)
+ util.ResponseFormat(c, code.SaveFail, "鎻掑叆澶辫触")
+ return
+ }
+ } else {
+ if err := models.NewSystemConfigSearch().SetID(params.ID).Update(¶ms); err != nil {
+ logx.Errorf("SystemConfig update err: %v", err)
+ util.ResponseFormat(c, code.SaveFail, "鎻掑叆澶辫触")
+ return
+ }
+ }
+
+ if err := task.RestartDynamicTask(); err != nil {
+ util.ResponseFormat(c, code.SaveFail, "閲嶅惎瀹氭椂浠诲姟澶辫触")
+ return
+ }
+
+ util.ResponseFormat(c, code.Success, "淇濆瓨鎴愬姛")
+}
+
+// GetSystemConfig
+// @Tags 绯荤粺璁剧疆
+// @Summary 鏍规嵁璁剧疆绫诲瀷鏌ヨ绯荤粺璁剧疆
+// @Produce application/json
+// @Param object query request.GetSystemConfig true "鏌ヨ鍙傛暟"
+// @Param Authorization header string true "token"
+// @Success 200 {object} util.Response{data=models.SystemConfig} "鎴愬姛"
+// @Router /api-wms/v1/systemConfig/get [get]
+func (slf SystemConfigController) GetSystemConfig(c *gin.Context) {
+ var params request.GetSystemConfig
+ if err := c.ShouldBindQuery(¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, err.Error())
+ return
+ }
+
+ if params.ConfigType == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "閰嶇疆绫诲瀷缂哄け")
+ return
+ }
+
+ config, _ := models.NewSystemConfigSearch().SetConfigType(params.ConfigType).First()
+
+ util.ResponseFormat(c, code.Success, config)
+}
diff --git a/docs/docs.go b/docs/docs.go
index a30715f..6bec29b 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -1,5 +1,4 @@
-// Code generated by swaggo/swag. DO NOT EDIT.
-
+// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs
import "github.com/swaggo/swag"
@@ -167,7 +166,7 @@
}
},
"/api-wms/v1/attribute/attribute": {
- "post": {
+ "get": {
"produces": [
"application/json"
],
@@ -184,6 +183,41 @@
"schema": {
"$ref": "#/definitions/request.AttributeList"
}
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ },
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "灞炴��"
+ ],
+ "summary": "娣诲姞灞炴��",
+ "parameters": [
+ {
+ "description": "灞炴�т俊鎭�",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.AddAttribute"
+ }
+ },
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
}
],
"responses": {
@@ -2356,12 +2390,40 @@
"tags": [
"浜у搧"
],
- "summary": "鍒犻櫎浜у搧",
+ "summary": "閫氳繃浜у搧/鍟嗗搧/鐗╂枡 ID鍒犻櫎浜у搧",
"parameters": [
{
"type": "string",
"description": "id",
"name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/product/deleteProductByBarCode/{barCode}": {
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "閫氳繃浜у搧/鍟嗗搧/鐗╂枡 鏉″舰鐮佸垹闄や骇鍝�",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "barCode",
+ "name": "barCode",
"in": "path",
"required": true
}
@@ -2525,12 +2587,66 @@
"tags": [
"浜у搧"
],
- "summary": "鑾峰彇浜у搧璇︽儏",
+ "summary": "閫氳繃浜у搧/鍟嗗搧/鐗╂枡 ID鑾峰彇浜у搧璇︽儏",
"parameters": [
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ },
{
"type": "string",
"description": "id",
"name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/models.Material"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/product/getProductDetailsByBarCode/{barCode}": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "閫氳繃浜у搧/鍟嗗搧/鐗╂枡 鏉″舰鐮� 鑾峰彇浜у搧璇︽儏",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "barCode",
+ "name": "barCode",
"in": "path",
"required": true
}
@@ -2670,6 +2786,9 @@
},
"/api-wms/v1/product/inputProduct": {
"post": {
+ "consumes": [
+ "multipart/form-data"
+ ],
"produces": [
"application/xlsx"
],
@@ -2677,6 +2796,22 @@
"鐗╂枡绠$悊"
],
"summary": "瀵煎叆鐗╂枡",
+ "parameters": [
+ {
+ "type": "file",
+ "description": "file",
+ "name": "file",
+ "in": "formData",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ }
+ ],
"responses": {
"200": {
"description": "鎴愬姛",
@@ -3138,6 +3273,99 @@
}
}
},
+ "/api-wms/v1/systemConfig/get": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "绯荤粺璁剧疆"
+ ],
+ "summary": "鏍规嵁璁剧疆绫诲瀷鏌ヨ绯荤粺璁剧疆",
+ "parameters": [
+ {
+ "enum": [
+ 1
+ ],
+ "type": "integer",
+ "x-enum-comments": {
+ "SystemConfigTypeInventoryCutOffPoint": "搴撳瓨缁撶畻鏃堕棿鐐�"
+ },
+ "x-enum-varnames": [
+ "SystemConfigTypeInventoryCutOffPoint"
+ ],
+ "description": "1 姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�",
+ "name": "configType",
+ "in": "query",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/models.SystemConfig"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/systemConfig/save": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "绯荤粺璁剧疆"
+ ],
+ "summary": "淇濆瓨绯荤粺璁剧疆",
+ "parameters": [
+ {
+ "description": "绯荤粺璁剧疆淇℃伅",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.SystemConfig"
+ }
+ },
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/warehouse/getWarehouseDetails/{id}": {
"get": {
"produces": [
@@ -3424,6 +3652,21 @@
"CostingMethodAverageCost"
]
},
+ "constvar.FileTemplateCategory": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2
+ ],
+ "x-enum-comments": {
+ "FileTemplateCategory_Output": "鍑哄簱",
+ "FileTemplateCategory_Selfmade": "鍏ュ簱-鑷埗"
+ },
+ "x-enum-varnames": [
+ "FileTemplateCategory_Selfmade",
+ "FileTemplateCategory_Output"
+ ]
+ },
"constvar.FileType": {
"type": "string",
"enum": [
@@ -3696,6 +3939,18 @@
"x-enum-varnames": [
"RuleType_Product",
"RuleType_ProductCategory"
+ ]
+ },
+ "constvar.SystemConfigType": {
+ "type": "integer",
+ "enum": [
+ 1
+ ],
+ "x-enum-comments": {
+ "SystemConfigTypeInventoryCutOffPoint": "搴撳瓨缁撶畻鏃堕棿鐐�"
+ },
+ "x-enum-varnames": [
+ "SystemConfigTypeInventoryCutOffPoint"
]
},
"constvar.WhetherType": {
@@ -4047,7 +4302,7 @@
"autoIncr": {
"type": "integer"
},
- "barcode": {
+ "barCode": {
"description": "鏉$爜",
"type": "string"
},
@@ -4587,6 +4842,9 @@
"receiverPhone": {
"type": "string"
},
+ "remark": {
+ "type": "string"
+ },
"salesDetailsNumber": {
"type": "string"
},
@@ -4619,6 +4877,9 @@
},
"updateTime": {
"type": "string"
+ },
+ "warehouseId": {
+ "type": "integer"
},
"waybillNumber": {
"description": "杩愬崟鍙�",
@@ -4829,6 +5090,36 @@
}
}
},
+ "models.SystemConfig": {
+ "type": "object",
+ "properties": {
+ "configType": {
+ "description": "姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.SystemConfigType"
+ }
+ ]
+ },
+ "createTime": {
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "description": "璁剧疆鍚嶇О",
+ "type": "string"
+ },
+ "updateTime": {
+ "type": "string"
+ },
+ "val": {
+ "description": "璁剧疆鍊�",
+ "type": "string"
+ }
+ }
+ },
"models.UnitDict": {
"type": "object",
"properties": {
@@ -4889,6 +5180,12 @@
},
"createTime": {
"type": "string"
+ },
+ "fileTemplateCategoryIn": {
+ "$ref": "#/definitions/constvar.FileTemplateCategory"
+ },
+ "fileTemplateCategoryOut": {
+ "$ref": "#/definitions/constvar.FileTemplateCategory"
},
"id": {
"type": "integer"
@@ -5066,6 +5363,14 @@
"accountantId": {
"type": "string"
},
+ "baseOperationType": {
+ "description": "鍩虹浣滀笟绫诲瀷 5搴撳瓨鐩樼偣",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.BaseOperationType"
+ }
+ ]
+ },
"comment": {
"description": "澶囨敞",
"type": "string"
@@ -5157,6 +5462,10 @@
},
"toLocationId": {
"description": "鐩爣浣嶇疆id",
+ "type": "integer"
+ },
+ "warehouseId": {
+ "description": "浠撳簱id",
"type": "integer"
},
"waybillNumber": {
@@ -5669,6 +5978,14 @@
"request.OperationList": {
"type": "object",
"properties": {
+ "baseOperationType": {
+ "description": "1 鍏ュ簱 2 鍑哄簱 3 鍐呴儴璋冩嫧 4 鎶ュ簾 5 搴撳瓨鐩樼偣",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.BaseOperationType"
+ }
+ ]
+ },
"number": {
"type": "string"
},
@@ -5763,6 +6080,30 @@
}
}
},
+ "request.SystemConfig": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "integer"
+ },
+ "configType": {
+ "description": "1 姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.SystemConfigType"
+ }
+ ]
+ },
+ "name": {
+ "description": "璁剧疆鍚嶇О",
+ "type": "string"
+ },
+ "val": {
+ "description": "璁剧疆鍊�",
+ "type": "string"
+ }
+ }
+ },
"request.UnitDict": {
"type": "object",
"properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index e2c314e..93d6dd4 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -155,7 +155,7 @@
}
},
"/api-wms/v1/attribute/attribute": {
- "post": {
+ "get": {
"produces": [
"application/json"
],
@@ -172,6 +172,41 @@
"schema": {
"$ref": "#/definitions/request.AttributeList"
}
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ },
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "灞炴��"
+ ],
+ "summary": "娣诲姞灞炴��",
+ "parameters": [
+ {
+ "description": "灞炴�т俊鎭�",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.AddAttribute"
+ }
+ },
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
}
],
"responses": {
@@ -2344,12 +2379,40 @@
"tags": [
"浜у搧"
],
- "summary": "鍒犻櫎浜у搧",
+ "summary": "閫氳繃浜у搧/鍟嗗搧/鐗╂枡 ID鍒犻櫎浜у搧",
"parameters": [
{
"type": "string",
"description": "id",
"name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/product/deleteProductByBarCode/{barCode}": {
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "閫氳繃浜у搧/鍟嗗搧/鐗╂枡 鏉″舰鐮佸垹闄や骇鍝�",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "barCode",
+ "name": "barCode",
"in": "path",
"required": true
}
@@ -2513,12 +2576,66 @@
"tags": [
"浜у搧"
],
- "summary": "鑾峰彇浜у搧璇︽儏",
+ "summary": "閫氳繃浜у搧/鍟嗗搧/鐗╂枡 ID鑾峰彇浜у搧璇︽儏",
"parameters": [
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ },
{
"type": "string",
"description": "id",
"name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/models.Material"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/product/getProductDetailsByBarCode/{barCode}": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "閫氳繃浜у搧/鍟嗗搧/鐗╂枡 鏉″舰鐮� 鑾峰彇浜у搧璇︽儏",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "barCode",
+ "name": "barCode",
"in": "path",
"required": true
}
@@ -2658,6 +2775,9 @@
},
"/api-wms/v1/product/inputProduct": {
"post": {
+ "consumes": [
+ "multipart/form-data"
+ ],
"produces": [
"application/xlsx"
],
@@ -2665,6 +2785,22 @@
"鐗╂枡绠$悊"
],
"summary": "瀵煎叆鐗╂枡",
+ "parameters": [
+ {
+ "type": "file",
+ "description": "file",
+ "name": "file",
+ "in": "formData",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ }
+ ],
"responses": {
"200": {
"description": "鎴愬姛",
@@ -3126,6 +3262,99 @@
}
}
},
+ "/api-wms/v1/systemConfig/get": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "绯荤粺璁剧疆"
+ ],
+ "summary": "鏍规嵁璁剧疆绫诲瀷鏌ヨ绯荤粺璁剧疆",
+ "parameters": [
+ {
+ "enum": [
+ 1
+ ],
+ "type": "integer",
+ "x-enum-comments": {
+ "SystemConfigTypeInventoryCutOffPoint": "搴撳瓨缁撶畻鏃堕棿鐐�"
+ },
+ "x-enum-varnames": [
+ "SystemConfigTypeInventoryCutOffPoint"
+ ],
+ "description": "1 姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�",
+ "name": "configType",
+ "in": "query",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/models.SystemConfig"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/systemConfig/save": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "绯荤粺璁剧疆"
+ ],
+ "summary": "淇濆瓨绯荤粺璁剧疆",
+ "parameters": [
+ {
+ "description": "绯荤粺璁剧疆淇℃伅",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.SystemConfig"
+ }
+ },
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/warehouse/getWarehouseDetails/{id}": {
"get": {
"produces": [
@@ -3412,6 +3641,21 @@
"CostingMethodAverageCost"
]
},
+ "constvar.FileTemplateCategory": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2
+ ],
+ "x-enum-comments": {
+ "FileTemplateCategory_Output": "鍑哄簱",
+ "FileTemplateCategory_Selfmade": "鍏ュ簱-鑷埗"
+ },
+ "x-enum-varnames": [
+ "FileTemplateCategory_Selfmade",
+ "FileTemplateCategory_Output"
+ ]
+ },
"constvar.FileType": {
"type": "string",
"enum": [
@@ -3684,6 +3928,18 @@
"x-enum-varnames": [
"RuleType_Product",
"RuleType_ProductCategory"
+ ]
+ },
+ "constvar.SystemConfigType": {
+ "type": "integer",
+ "enum": [
+ 1
+ ],
+ "x-enum-comments": {
+ "SystemConfigTypeInventoryCutOffPoint": "搴撳瓨缁撶畻鏃堕棿鐐�"
+ },
+ "x-enum-varnames": [
+ "SystemConfigTypeInventoryCutOffPoint"
]
},
"constvar.WhetherType": {
@@ -4035,7 +4291,7 @@
"autoIncr": {
"type": "integer"
},
- "barcode": {
+ "barCode": {
"description": "鏉$爜",
"type": "string"
},
@@ -4575,6 +4831,9 @@
"receiverPhone": {
"type": "string"
},
+ "remark": {
+ "type": "string"
+ },
"salesDetailsNumber": {
"type": "string"
},
@@ -4607,6 +4866,9 @@
},
"updateTime": {
"type": "string"
+ },
+ "warehouseId": {
+ "type": "integer"
},
"waybillNumber": {
"description": "杩愬崟鍙�",
@@ -4817,6 +5079,36 @@
}
}
},
+ "models.SystemConfig": {
+ "type": "object",
+ "properties": {
+ "configType": {
+ "description": "姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.SystemConfigType"
+ }
+ ]
+ },
+ "createTime": {
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "description": "璁剧疆鍚嶇О",
+ "type": "string"
+ },
+ "updateTime": {
+ "type": "string"
+ },
+ "val": {
+ "description": "璁剧疆鍊�",
+ "type": "string"
+ }
+ }
+ },
"models.UnitDict": {
"type": "object",
"properties": {
@@ -4877,6 +5169,12 @@
},
"createTime": {
"type": "string"
+ },
+ "fileTemplateCategoryIn": {
+ "$ref": "#/definitions/constvar.FileTemplateCategory"
+ },
+ "fileTemplateCategoryOut": {
+ "$ref": "#/definitions/constvar.FileTemplateCategory"
},
"id": {
"type": "integer"
@@ -5054,6 +5352,14 @@
"accountantId": {
"type": "string"
},
+ "baseOperationType": {
+ "description": "鍩虹浣滀笟绫诲瀷 5搴撳瓨鐩樼偣",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.BaseOperationType"
+ }
+ ]
+ },
"comment": {
"description": "澶囨敞",
"type": "string"
@@ -5145,6 +5451,10 @@
},
"toLocationId": {
"description": "鐩爣浣嶇疆id",
+ "type": "integer"
+ },
+ "warehouseId": {
+ "description": "浠撳簱id",
"type": "integer"
},
"waybillNumber": {
@@ -5657,6 +5967,14 @@
"request.OperationList": {
"type": "object",
"properties": {
+ "baseOperationType": {
+ "description": "1 鍏ュ簱 2 鍑哄簱 3 鍐呴儴璋冩嫧 4 鎶ュ簾 5 搴撳瓨鐩樼偣",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.BaseOperationType"
+ }
+ ]
+ },
"number": {
"type": "string"
},
@@ -5751,6 +6069,30 @@
}
}
},
+ "request.SystemConfig": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "integer"
+ },
+ "configType": {
+ "description": "1 姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.SystemConfigType"
+ }
+ ]
+ },
+ "name": {
+ "description": "璁剧疆鍚嶇О",
+ "type": "string"
+ },
+ "val": {
+ "description": "璁剧疆鍊�",
+ "type": "string"
+ }
+ }
+ },
"request.UnitDict": {
"type": "object",
"properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index f99e6fd..83f23c2 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -74,6 +74,17 @@
- CostingMethodStandardPrice
- CostingMethodFIFO
- CostingMethodAverageCost
+ constvar.FileTemplateCategory:
+ enum:
+ - 1
+ - 2
+ type: integer
+ x-enum-comments:
+ FileTemplateCategory_Output: 鍑哄簱
+ FileTemplateCategory_Selfmade: 鍏ュ簱-鑷埗
+ x-enum-varnames:
+ - FileTemplateCategory_Selfmade
+ - FileTemplateCategory_Output
constvar.FileType:
enum:
- file
@@ -297,6 +308,14 @@
x-enum-varnames:
- RuleType_Product
- RuleType_ProductCategory
+ constvar.SystemConfigType:
+ enum:
+ - 1
+ type: integer
+ x-enum-comments:
+ SystemConfigTypeInventoryCutOffPoint: 搴撳瓨缁撶畻鏃堕棿鐐�
+ x-enum-varnames:
+ - SystemConfigTypeInventoryCutOffPoint
constvar.WhetherType:
enum:
- 1
@@ -540,7 +559,7 @@
type: array
autoIncr:
type: integer
- barcode:
+ barCode:
description: 鏉$爜
type: string
buyExplain:
@@ -926,6 +945,8 @@
type: string
receiverPhone:
type: string
+ remark:
+ type: string
salesDetailsNumber:
type: string
source:
@@ -946,6 +967,8 @@
type: integer
updateTime:
type: string
+ warehouseId:
+ type: integer
waybillNumber:
description: 杩愬崟鍙�
type: string
@@ -1085,6 +1108,25 @@
updateTime:
type: string
type: object
+ models.SystemConfig:
+ properties:
+ configType:
+ allOf:
+ - $ref: '#/definitions/constvar.SystemConfigType'
+ description: 姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�
+ createTime:
+ type: string
+ id:
+ type: integer
+ name:
+ description: 璁剧疆鍚嶇О
+ type: string
+ updateTime:
+ type: string
+ val:
+ description: 璁剧疆鍊�
+ type: string
+ type: object
models.UnitDict:
properties:
id:
@@ -1127,6 +1169,10 @@
type: string
createTime:
type: string
+ fileTemplateCategoryIn:
+ $ref: '#/definitions/constvar.FileTemplateCategory'
+ fileTemplateCategoryOut:
+ $ref: '#/definitions/constvar.FileTemplateCategory'
id:
type: integer
inboundTransportation:
@@ -1248,6 +1294,10 @@
type: string
accountantId:
type: string
+ baseOperationType:
+ allOf:
+ - $ref: '#/definitions/constvar.BaseOperationType'
+ description: 鍩虹浣滀笟绫诲瀷 5搴撳瓨鐩樼偣
comment:
description: 澶囨敞
type: string
@@ -1314,6 +1364,9 @@
description: 鐘舵��
toLocationId:
description: 鐩爣浣嶇疆id
+ type: integer
+ warehouseId:
+ description: 浠撳簱id
type: integer
waybillNumber:
description: 杩愬崟鍙�
@@ -1672,6 +1725,10 @@
type: object
request.OperationList:
properties:
+ baseOperationType:
+ allOf:
+ - $ref: '#/definitions/constvar.BaseOperationType'
+ description: 1 鍏ュ簱 2 鍑哄簱 3 鍐呴儴璋冩嫧 4 鎶ュ簾 5 搴撳瓨鐩樼偣
number:
type: string
operationTypeId:
@@ -1735,6 +1792,21 @@
items:
$ref: '#/definitions/request.UnitDict'
type: array
+ type: object
+ request.SystemConfig:
+ properties:
+ ID:
+ type: integer
+ configType:
+ allOf:
+ - $ref: '#/definitions/constvar.SystemConfigType'
+ description: 1 姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�
+ name:
+ description: 璁剧疆鍚嶇О
+ type: string
+ val:
+ description: 璁剧疆鍊�
+ type: string
type: object
request.UnitDict:
properties:
@@ -2217,7 +2289,7 @@
tags:
- 闄勪欢绠$悊
/api-wms/v1/attribute/attribute:
- post:
+ get:
parameters:
- description: 灞炴�у�煎拰瀵硅薄淇℃伅
in: body
@@ -2235,6 +2307,29 @@
summary: 娣诲姞灞炴�у�煎拰瀵硅薄
tags:
- 灞炴�у�煎拰瀵硅薄
+ post:
+ parameters:
+ - description: 灞炴�т俊鎭�
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.AddAttribute'
+ - description: token
+ in: header
+ name: Authorization
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 娣诲姞灞炴��
+ tags:
+ - 灞炴��
/api-wms/v1/attribute/delete/{id}:
delete:
parameters:
@@ -3577,7 +3672,25 @@
description: 鎴愬姛
schema:
$ref: '#/definitions/util.Response'
- summary: 鍒犻櫎浜у搧
+ summary: 閫氳繃浜у搧/鍟嗗搧/鐗╂枡 ID鍒犻櫎浜у搧
+ tags:
+ - 浜у搧
+ /api-wms/v1/product/deleteProductByBarCode/{barCode}:
+ delete:
+ parameters:
+ - description: barCode
+ in: path
+ name: barCode
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 閫氳繃浜у搧/鍟嗗搧/鐗╂枡 鏉″舰鐮佸垹闄や骇鍝�
tags:
- 浜у搧
/api-wms/v1/product/deleteProductCategory/{id}:
@@ -3668,6 +3781,11 @@
/api-wms/v1/product/getProductDetails/{id}:
get:
parameters:
+ - description: token
+ in: header
+ name: Authorization
+ required: true
+ type: string
- description: id
in: path
name: id
@@ -3685,7 +3803,35 @@
data:
$ref: '#/definitions/models.Material'
type: object
- summary: 鑾峰彇浜у搧璇︽儏
+ summary: 閫氳繃浜у搧/鍟嗗搧/鐗╂枡 ID鑾峰彇浜у搧璇︽儏
+ tags:
+ - 浜у搧
+ /api-wms/v1/product/getProductDetailsByBarCode/{barCode}:
+ get:
+ parameters:
+ - description: token
+ in: header
+ name: Authorization
+ required: true
+ type: string
+ - description: barCode
+ in: path
+ name: barCode
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ allOf:
+ - $ref: '#/definitions/util.Response'
+ - properties:
+ data:
+ $ref: '#/definitions/models.Material'
+ type: object
+ summary: 閫氳繃浜у搧/鍟嗗搧/鐗╂枡 鏉″舰鐮� 鑾峰彇浜у搧璇︽儏
tags:
- 浜у搧
/api-wms/v1/product/getProductList:
@@ -3753,6 +3899,19 @@
- 浜у搧
/api-wms/v1/product/inputProduct:
post:
+ consumes:
+ - multipart/form-data
+ parameters:
+ - description: file
+ in: formData
+ name: file
+ required: true
+ type: file
+ - description: token
+ in: header
+ name: Authorization
+ required: true
+ type: string
produces:
- application/xlsx
responses:
@@ -4039,6 +4198,64 @@
summary: 鏇存柊閲嶈璐ц鍒�
tags:
- 閲嶈璐ц鍒�
+ /api-wms/v1/systemConfig/get:
+ get:
+ parameters:
+ - description: 1 姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�
+ enum:
+ - 1
+ in: query
+ name: configType
+ required: true
+ type: integer
+ x-enum-comments:
+ SystemConfigTypeInventoryCutOffPoint: 搴撳瓨缁撶畻鏃堕棿鐐�
+ x-enum-varnames:
+ - SystemConfigTypeInventoryCutOffPoint
+ - description: token
+ in: header
+ name: Authorization
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ allOf:
+ - $ref: '#/definitions/util.Response'
+ - properties:
+ data:
+ $ref: '#/definitions/models.SystemConfig'
+ type: object
+ summary: 鏍规嵁璁剧疆绫诲瀷鏌ヨ绯荤粺璁剧疆
+ tags:
+ - 绯荤粺璁剧疆
+ /api-wms/v1/systemConfig/save:
+ post:
+ parameters:
+ - description: 绯荤粺璁剧疆淇℃伅
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.SystemConfig'
+ - description: token
+ in: header
+ name: Authorization
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 淇濆瓨绯荤粺璁剧疆
+ tags:
+ - 绯荤粺璁剧疆
/api-wms/v1/warehouse/getWarehouseDetails/{id}:
get:
parameters:
diff --git a/example.xlsx b/example.xlsx
deleted file mode 100644
index 5e4b104..0000000
--- a/example.xlsx
+++ /dev/null
Binary files differ
diff --git a/main.go b/main.go
index 99e764c..a2ea7c2 100644
--- a/main.go
+++ b/main.go
@@ -78,7 +78,10 @@
go service.InitHistoryReportData()
//瀹氭椂浠诲姟鍒濆鍖�
- task.Init()
+ if err := task.Init(); err != nil {
+ logx.Errorf("task init error: %v", err.Error())
+ return
+ }
//閽夐拤鏈哄櫒浜哄垵濮嬪寲
dingtalkrobot.Init(conf.DingTalkConf.AlarmKey, conf.DingTalkConf.AlarmUrl)
diff --git a/models/db.go b/models/db.go
index de0c2d2..4708383 100644
--- a/models/db.go
+++ b/models/db.go
@@ -122,6 +122,7 @@
MonthStats{},
Attribute{},
AttributeValue{},
+ SystemConfig{},
)
return err
}
diff --git a/models/material.go b/models/material.go
index 5350fc2..e410f35 100644
--- a/models/material.go
+++ b/models/material.go
@@ -51,7 +51,6 @@
CategoryId int `gorm:"type:int(11);comment:浜у搧绫诲埆id" json:"categoryId"` //浜у搧绫诲埆id
CategoryName string `gorm:"type:varchar(255);comment:浜у搧绫诲埆鍚嶇О" json:"categoryName"` //浜у搧绫诲埆鍚嶇О
InternalReference string `gorm:"type:varchar(255);comment:鍐呴儴鍙傝��" json:"internalReference"` //鍐呴儴鍙傝��
- Barcode string `gorm:"type:varchar(255);comment:鏉$爜" json:"barcode"` //鏉$爜
ProductTagId int `gorm:"type:int(11);comment:浜у搧鏍囩id" json:"productTagId"` //浜у搧鏍囩id
ProductTagName string `gorm:"type:varchar(255);comment:浜у搧鏍囩鍚嶇О" json:"productTagName"` //浜у搧鏍囩鍚嶇О
CompanyId int `gorm:"type:int(11);comment:鍏徃id" json:"companyId"` //鍏徃id
@@ -96,7 +95,8 @@
MinInventoryRule decimal.Decimal `json:"minInventoryRule" gorm:"-"` //鏈�灏忓簱瀛�
MaxInventoryRule decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //鏈�澶у簱瀛�
- CreateBy string `gorm:"type:varchar(255);comment:瀵煎叆浜恒�佸垱寤轰汉" json:"createBy"` //鍒涘缓浜�
+ CreateBy string `gorm:"type:varchar(255);comment:瀵煎叆浜恒�佸垱寤轰汉" json:"createBy"` //鍒涘缓浜�
+ BarCode string `gorm:"type:varchar(255);comment:(鍟嗗搧/浜у搧/鐗╂枡鐨�)鏉″舰鐮�" json:"barCode"` //鏉$爜
}
MaterialSearch struct {
@@ -164,7 +164,14 @@
}
}
if len(slf.MoreUnitList) != 0 {
- str, err := json.Marshal(slf.MoreUnitList)
+ items := make([]UnitItems, 0)
+ for k, item := range slf.MoreUnitList {
+ if item.Unit != "" && !item.Amount.IsZero() {
+ items = append(items, slf.MoreUnitList[k])
+ }
+ }
+
+ str, err := json.Marshal(items)
if err != nil {
return err
}
@@ -198,6 +205,11 @@
func (slf *MaterialSearch) SetID(id string) *MaterialSearch {
slf.ID = id
+ return slf
+}
+
+func (slf *MaterialSearch) SetBarCode(barCode string) *MaterialSearch {
+ slf.BarCode = barCode
return slf
}
@@ -272,6 +284,9 @@
if slf.ID != "" {
db = db.Where("id = ?", slf.ID)
}
+ if slf.BarCode != "" {
+ db = db.Where("bar_code = ?", slf.BarCode)
+ }
if slf.Name != "" {
db = db.Where("name = ?", slf.Name)
diff --git a/models/operation.go b/models/operation.go
index 8eb2fb8..fb9a0c7 100644
--- a/models/operation.go
+++ b/models/operation.go
@@ -61,6 +61,7 @@
CheckedBy string `json:"checkedBy" gorm:"type:varchar(255);comment:楠岃瘉鑰匲serId"`
Remark string `json:"remark"`
+ WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:浠撳簱id"`
IsInternalOutput bool `json:"isInternalOutput"` //鏄惁璋冩嫧浜х敓鐨勫嚭搴�
}
diff --git a/models/system_config.go b/models/system_config.go
new file mode 100644
index 0000000..e36d115
--- /dev/null
+++ b/models/system_config.go
@@ -0,0 +1,244 @@
+package models
+
+import (
+ "fmt"
+ "gorm.io/gorm"
+ "wms/constvar"
+ "wms/pkg/mysqlx"
+)
+
+type (
+ // SystemConfig 绯荤粺璁剧疆
+ SystemConfig struct {
+ WmsModel
+ Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+ ConfigType constvar.SystemConfigType `json:"configType" gorm:"type:int;not null"` //姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�
+ Name string `json:"name" gorm:"index;type:varchar(255);not null;default:'';comment:璁剧疆鍚�"` //璁剧疆鍚嶇О
+ Val string `json:"val" gorm:"index;type:varchar(255);not null;comment:璁剧疆鍊�"` //璁剧疆鍊�
+ }
+
+ SystemConfigSearch struct {
+ SystemConfig
+ Order string
+ PageNum int
+ PageSize int
+ Keyword string
+ Orm *gorm.DB
+ }
+)
+
+func (slf *SystemConfig) TableName() string {
+ return "wms_system_config"
+}
+
+func NewSystemConfigSearch() *SystemConfigSearch {
+ return &SystemConfigSearch{Orm: mysqlx.GetDB()}
+}
+
+func (slf *SystemConfigSearch) SetOrm(tx *gorm.DB) *SystemConfigSearch {
+ slf.Orm = tx
+ return slf
+}
+
+func (slf *SystemConfigSearch) SetPage(page, size int) *SystemConfigSearch {
+ slf.PageNum, slf.PageSize = page, size
+ return slf
+}
+
+func (slf *SystemConfigSearch) SetOrder(order string) *SystemConfigSearch {
+ slf.Order = order
+ return slf
+}
+
+func (slf *SystemConfigSearch) SetConfigType(configType constvar.SystemConfigType) *SystemConfigSearch {
+ slf.ConfigType = configType
+ return slf
+}
+
+func (slf *SystemConfigSearch) SetID(id uint) *SystemConfigSearch {
+ slf.ID = id
+ return slf
+}
+
+func (slf *SystemConfigSearch) SetValue(name string) *SystemConfigSearch {
+ slf.Name = name
+ return slf
+}
+
+func (slf *SystemConfigSearch) SetKeyword(keyword string) *SystemConfigSearch {
+ slf.Keyword = keyword
+ return slf
+}
+
+func (slf *SystemConfigSearch) build() *gorm.DB {
+ var db = slf.Orm.Table(slf.TableName())
+
+ if slf.ID != 0 {
+ db = db.Where("id = ?", slf.ID)
+ }
+
+ if slf.Order != "" {
+ db = db.Order(slf.Order)
+ }
+
+ if slf.Keyword != "" {
+ db = db.Where("name like ?", fmt.Sprintf("%%%v%%", slf.Keyword))
+ }
+ if slf.Name != "" {
+ db = db.Where("name = ?", slf.Name)
+ }
+
+ if slf.ConfigType != 0 {
+ db = db.Where("config_type = ?", slf.ConfigType)
+ }
+
+ return db
+}
+
+// Create 鍗曟潯鎻掑叆
+func (slf *SystemConfigSearch) Create(record *SystemConfig) error {
+ var db = slf.build()
+
+ if err := db.Create(record).Error; err != nil {
+ return err
+ }
+
+ return nil
+}
+
+// CreateBatch 鎵归噺鎻掑叆
+func (slf *SystemConfigSearch) CreateBatch(records []*SystemConfig) error {
+ var db = slf.build()
+
+ if err := db.Create(&records).Error; err != nil {
+ return fmt.Errorf("create batch err: %v, records: %+v", err, records)
+ }
+
+ return nil
+}
+
+func (slf *SystemConfigSearch) Update(record *SystemConfig) error {
+ var db = slf.build()
+
+ if err := db.Omit("CreatedAt").Updates(record).Error; err != nil {
+ return fmt.Errorf("save err: %v, record: %+v", err, record)
+ }
+
+ return nil
+}
+
+func (slf *SystemConfigSearch) UpdateByMap(upMap map[string]interface{}) error {
+ var (
+ db = slf.build()
+ )
+
+ if err := db.Updates(upMap).Error; err != nil {
+ return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap)
+ }
+
+ return nil
+}
+
+func (slf *SystemConfigSearch) UpdateByQuery(query string, args []interface{}, upMap map[string]interface{}) error {
+ var (
+ db = slf.Orm.Table(slf.TableName()).Where(query, args...)
+ )
+
+ if err := db.Updates(upMap).Error; err != nil {
+ return fmt.Errorf("update by query err: %v, query: %s, args: %+v, upMap: %+v", err, query, args, upMap)
+ }
+
+ return nil
+}
+
+func (slf *SystemConfigSearch) Delete() error {
+ var db = slf.build()
+ return db.Delete(&SystemConfig{}).Error
+}
+
+func (slf *SystemConfigSearch) First() (*SystemConfig, error) {
+ var (
+ record = new(SystemConfig)
+ db = slf.build()
+ )
+
+ if err := db.First(record).Error; err != nil {
+ return record, err
+ }
+
+ return record, nil
+}
+
+func (slf *SystemConfigSearch) Find() ([]*SystemConfig, int64, error) {
+ var (
+ records = make([]*SystemConfig, 0)
+ total int64
+ db = slf.build()
+ )
+
+ if err := db.Count(&total).Error; err != nil {
+ return records, total, fmt.Errorf("find count err: %v", err)
+ }
+ if slf.PageNum*slf.PageSize > 0 {
+ db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+ }
+ if err := db.Find(&records).Error; err != nil {
+ return records, total, fmt.Errorf("find records err: %v", err)
+ }
+
+ return records, total, nil
+}
+
+func (slf *SystemConfigSearch) FindNotTotal() ([]*SystemConfig, error) {
+ var (
+ records = make([]*SystemConfig, 0)
+ db = slf.build()
+ )
+
+ if slf.PageNum*slf.PageSize > 0 {
+ db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+ }
+ if err := db.Find(&records).Error; err != nil {
+ return records, fmt.Errorf("find records err: %v", err)
+ }
+
+ return records, nil
+}
+
+// FindByQuery 鎸囧畾鏉′欢鏌ヨ.
+func (slf *SystemConfigSearch) FindByQuery(query string, args []interface{}) ([]*SystemConfig, int64, error) {
+ var (
+ records = make([]*SystemConfig, 0)
+ total int64
+ db = slf.Orm.Table(slf.TableName()).Where(query, args...)
+ )
+
+ if err := db.Count(&total).Error; err != nil {
+ return records, total, fmt.Errorf("find by query count err: %v", err)
+ }
+ if slf.PageNum*slf.PageSize > 0 {
+ db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+ }
+ if err := db.Find(&records).Error; err != nil {
+ return records, total, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args)
+ }
+
+ return records, total, nil
+}
+
+// FindByQueryNotTotal 鎸囧畾鏉′欢鏌ヨ&涓嶆煡璇㈡�绘潯鏁�.
+func (slf *SystemConfigSearch) FindByQueryNotTotal(query string, args []interface{}) ([]*SystemConfig, error) {
+ var (
+ records = make([]*SystemConfig, 0)
+ db = slf.Orm.Table(slf.TableName()).Where(query, args...)
+ )
+
+ if slf.PageNum*slf.PageSize > 0 {
+ db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+ }
+ if err := db.Find(&records).Error; err != nil {
+ return records, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args)
+ }
+
+ return records, nil
+}
diff --git a/request/config_type.go b/request/config_type.go
new file mode 100644
index 0000000..f0430d7
--- /dev/null
+++ b/request/config_type.go
@@ -0,0 +1,14 @@
+package request
+
+import "wms/constvar"
+
+type SystemConfig struct {
+ ID uint `json:"ID"`
+ ConfigType constvar.SystemConfigType `json:"configType" gorm:"type:int;not null"` //1 姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�
+ Name string `json:"name" gorm:"index;type:varchar(255);not null;default:'';comment:璁剧疆鍚�"` //璁剧疆鍚嶇О
+ Val string `json:"val" gorm:"index;type:varchar(255);not null;comment:璁剧疆鍊�"` //璁剧疆鍊�
+}
+
+type GetSystemConfig struct {
+ ConfigType constvar.SystemConfigType `form:"configType" binding:"required"` //1 姣忔湀搴撳瓨缁撶畻鏃堕棿鐐�
+}
diff --git a/request/operation.go b/request/operation.go
index bc4942e..a68aa72 100644
--- a/request/operation.go
+++ b/request/operation.go
@@ -14,28 +14,30 @@
Status constvar.OperationStatus `json:"status" gorm:"type:int(11);not null;comment:鐘舵��"` //鐘舵��
//FromLocationId int `json:"fromLocationId" gorm:"type:int;not null;comment:婧愪綅缃甶d"` //婧愪綅缃甶d
//ToLocationId int `json:"toLocationId" gorm:"type:int;not null;comment:鐩爣浣嶇疆id"` //鐩爣浣嶇疆id
- OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:瀹夋帓鏃ユ湡"` //瀹夋帓鏃ユ湡
- Details []*OperationDetails `json:"details"`
- ContacterID int `json:"contacterID" gorm:"type:int;comment:鑱旂郴浜篒D"` //鑱旂郴浜篒D-闈炲繀濉�
- ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:鑱旂郴浜哄鍚�"` //鑱旂郴浜哄鍚�-闈炲繀濉�
- CompanyID string `json:"companyID"` //鍏徃ID-瀹㈡埛
- CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О"` //鍏徃鍚嶇О-瀹㈡埛鍚嶇О
- Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"` //澶囨敞
- LogisticCompanyId string `json:"logisticCompanyId" gorm:"type:varchar(191);comment:鐗╂祦鍏徃id"`
- WaybillNumber string `json:"waybillNumber" gorm:"type:varchar(255);comment:杩愬崟鍙�"` //杩愬崟鍙�
- Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"` //閲嶉噺
- LogisticWeight decimal.Decimal `gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺" json:"logisticWeight"` //鐗╂祦閲嶉噺
- ReceiverName string `json:"receiverName" gorm:"type:varchar(31);comment:鏀惰揣浜哄鍚�"`
- ReceiverPhone string `json:"receiverPhone" gorm:"type:varchar(31);comment:鑱旂郴鐢佃瘽"`
- ReceiverAddr string `json:"receiverAddr" gorm:"type:varchar(255);comment:鏀惰揣鍦板潃"`
- LocationId int `json:"locationId" gorm:"type:int;not null;comment:婧愪綅缃甶d"` //婧愪綅缃甶d
- ToLocationId int `json:"toLocationId" gorm:"type:int;not null;comment:浠撳簱浣嶇疆id"` //鐩爣浣嶇疆id
- ManagerId string `json:"managerId" gorm:"type:varchar(255);comment:涓荤id"`
- Manager string `json:"manager" gorm:"type:varchar(255);comment:涓荤鍚嶇О"`
- AccountantId string `json:"accountantId" gorm:"type:varchar(255);comment:浼氳id"`
- Accountant string `json:"accountant" gorm:"type:varchar(255);comment:浼氳鍚嶇О"`
- CustodianId string `json:"custodianId" gorm:"type:varchar(255);comment:淇濈鍛榠d"`
- Custodian string `json:"custodian" gorm:"type:varchar(255);comment:淇濈鍛樺悕绉�"`
+ OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:瀹夋帓鏃ユ湡"` //瀹夋帓鏃ユ湡
+ Details []*OperationDetails `json:"details"`
+ ContacterID int `json:"contacterID" gorm:"type:int;comment:鑱旂郴浜篒D"` //鑱旂郴浜篒D-闈炲繀濉�
+ ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:鑱旂郴浜哄鍚�"` //鑱旂郴浜哄鍚�-闈炲繀濉�
+ CompanyID string `json:"companyID"` //鍏徃ID-瀹㈡埛
+ CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О"` //鍏徃鍚嶇О-瀹㈡埛鍚嶇О
+ Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"` //澶囨敞
+ LogisticCompanyId string `json:"logisticCompanyId" gorm:"type:varchar(191);comment:鐗╂祦鍏徃id"`
+ WaybillNumber string `json:"waybillNumber" gorm:"type:varchar(255);comment:杩愬崟鍙�"` //杩愬崟鍙�
+ Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"` //閲嶉噺
+ LogisticWeight decimal.Decimal `gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺" json:"logisticWeight"` //鐗╂祦閲嶉噺
+ ReceiverName string `json:"receiverName" gorm:"type:varchar(31);comment:鏀惰揣浜哄鍚�"`
+ ReceiverPhone string `json:"receiverPhone" gorm:"type:varchar(31);comment:鑱旂郴鐢佃瘽"`
+ ReceiverAddr string `json:"receiverAddr" gorm:"type:varchar(255);comment:鏀惰揣鍦板潃"`
+ LocationId int `json:"locationId" gorm:"type:int;not null;comment:婧愪綅缃甶d"` //婧愪綅缃甶d
+ ToLocationId int `json:"toLocationId" gorm:"type:int;not null;comment:浠撳簱浣嶇疆id"` //鐩爣浣嶇疆id
+ ManagerId string `json:"managerId" gorm:"type:varchar(255);comment:涓荤id"`
+ Manager string `json:"manager" gorm:"type:varchar(255);comment:涓荤鍚嶇О"`
+ AccountantId string `json:"accountantId" gorm:"type:varchar(255);comment:浼氳id"`
+ Accountant string `json:"accountant" gorm:"type:varchar(255);comment:浼氳鍚嶇О"`
+ CustodianId string `json:"custodianId" gorm:"type:varchar(255);comment:淇濈鍛榠d"`
+ Custodian string `json:"custodian" gorm:"type:varchar(255);comment:淇濈鍛樺悕绉�"`
+ BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:鍩虹浣滀笟绫诲瀷"` //鍩虹浣滀笟绫诲瀷 5搴撳瓨鐩樼偣
+ WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:浠撳簱id"` //浠撳簱id
}
type OperationDetails struct {
@@ -59,9 +61,10 @@
type OperationList struct {
PageInfo
- OperationTypeId int `json:"operationTypeId" form:"operationTypeId"`
- Number string `json:"number"`
- Status constvar.OperationStatus `json:"status"`
+ OperationTypeId int `json:"operationTypeId" form:"operationTypeId"`
+ BaseOperationType constvar.BaseOperationType `json:"baseOperationType"` // 1 鍏ュ簱 2 鍑哄簱 3 鍐呴儴璋冩嫧 4 鎶ュ簾 5 搴撳瓨鐩樼偣
+ Number string `json:"number"`
+ Status constvar.OperationStatus `json:"status"`
}
type UpdateOperation struct {
diff --git a/router/router.go b/router/router.go
index 460dd93..d336bb3 100644
--- a/router/router.go
+++ b/router/router.go
@@ -115,11 +115,13 @@
productController := new(controllers.ProductController)
productAPI := r.Group(urlPrefix + "/product")
{
- productAPI.POST("addProduct", productController.AddProduct) // 鏂板浜у搧
- productAPI.POST("getProductList", productController.GetProductList) // 鑾峰彇浜у搧鍒楄〃
- productAPI.GET("getProductDetails/:id", productController.GetProductDetails) // 鑾峰彇浜у搧璇︽儏
- productAPI.POST("updateProduct", productController.UpdateProduct) // 淇敼浜у搧璇︽儏
- productAPI.DELETE("deleteProduct/:id", productController.DeleteProduct) // 鍒犻櫎浜у搧
+ productAPI.POST("addProduct", productController.AddProduct) // 鏂板浜у搧
+ productAPI.POST("getProductList", productController.GetProductList) // 鑾峰彇浜у搧鍒楄〃
+ productAPI.GET("getProductDetails/:id", productController.GetProductDetails) // 閫氳繃ID鑾峰彇浜у搧璇︽儏
+ productAPI.GET("getProductDetailsByBarCode/:barCode", productController.GetProductDetailsByBarCode) // 閫氳繃鏉″舰鐮佽幏鍙栦骇鍝佽鎯�
+ productAPI.POST("updateProduct", productController.UpdateProduct) // 淇敼浜у搧璇︽儏
+ productAPI.DELETE("deleteProduct/:id", productController.DeleteProduct) // 閫氳繃ID鑾峰垹闄や骇鍝�
+ productAPI.DELETE("deleteProductByBarCode/:barCode", productController.DeleteProductByBarCode) // 閫氳繃鏉″舰鐮佸垹闄や骇鍝�
productAPI.POST("addProductCategory", productController.AddProductCategory) //娣诲姞浜у搧绫诲瀷
productAPI.POST("getProductCategoryList", productController.GetProductCategoryList) //鑾峰彇浜у搧绫诲瀷鍒楄〃
@@ -212,5 +214,13 @@
attributeValueAPI.GET("primary/:id", attributeValueController.PrimaryAttributeValue) //鍒犻櫎
}
+ //绯荤粺閰嶇疆
+ sysCfgCtl := new(controllers.SystemConfigController)
+ sysCfgApi := r.Group(urlPrefix + "/systemConfig")
+ {
+ sysCfgApi.POST("save", sysCfgCtl.SaveConfig) //淇濆瓨绯荤粺璁剧疆
+ sysCfgApi.GET("get", sysCfgCtl.GetSystemConfig) //鑾峰彇绯荤粺閰嶇疆
+ }
+
return r
}
diff --git a/service/month_forms.go b/service/month_forms.go
index 4bde4dc..aca3f1a 100644
--- a/service/month_forms.go
+++ b/service/month_forms.go
@@ -1,13 +1,17 @@
package service
import (
+ "encoding/json"
"fmt"
+ "github.com/shopspring/decimal"
"github.com/xuri/excelize/v2"
"strconv"
"time"
+ "wms/constvar"
"wms/models"
"wms/pkg/logx"
"wms/request"
+ "wms/utils"
)
type MonthFormsService struct{}
@@ -178,3 +182,100 @@
return fileName, nil
}
+
+func GetCurrentStats(date string, productIds []string) (statRecords []*models.MonthStats, err error) {
+ //鏈湀鏈熷垵鏁伴噺/涓婃湀缁撲綑鏁伴噺
+ groupSumList, err := models.NewLocationProductAmountSearch().SetProductIds(productIds).GroupSum("product_id", "amount")
+ productIds = make([]string, 0, len(groupSumList))
+ for _, groupSum := range groupSumList {
+ productIds = append(productIds, groupSum.Class)
+ }
+ products, err := models.NewMaterialSearch().SetFields("id, name, unit, weight, more_unit, more_unit_value").SetIDs(productIds).FindNotTotal()
+ if err != nil {
+ logx.Errorf("MonthStats GetCurrentStats get products err:%v", err)
+ return
+ }
+ productMap := models.MaterialMap(products)
+
+ beginTime, endTime := utils.GetLastMonthPeriod()
+ inputMap, err := GetStatsByOperationType(beginTime, endTime, constvar.BaseOperationTypeIncoming)
+ if err != nil {
+ logx.Errorf("MonthStats GetStatsByOperationType input err:%v", err)
+ return
+ }
+
+ outputMap, err := GetStatsByOperationType(beginTime, endTime, constvar.BaseOperationTypeOutgoing)
+ if err != nil {
+ logx.Errorf("MonthStats GetStatsByOperationType output err:%v", err)
+ return
+ }
+
+ for _, groupSum := range groupSumList {
+ productId := groupSum.Class
+ if productMap[productId] == nil {
+ continue
+ }
+ product := productMap[productId]
+ amount := groupSum.Sum
+ record := models.MonthStats{
+ ProductId: productId,
+ ProductName: product.Name,
+ Unit: product.Unit,
+ Weight: product.Weight.Mul(amount),
+ Date: date,
+ }
+
+ var (
+ moreUnits string
+ inputMoreUnits string
+ outputMoreUnits string
+ )
+ if *product.MoreUnit {
+ moreValueArr := make([]models.UnitItems, 0, len(product.MoreUnitList))
+ inputMoreValueArr := make([]models.UnitItems, 0, len(product.MoreUnitList))
+ outputMoreValueArr := make([]models.UnitItems, 0, len(product.MoreUnitList))
+ if !amount.IsZero() {
+ moreValueArr = CreateMoreUnit(amount, product.MoreUnitList)
+ }
+ if !inputMap[productId].IsZero() {
+ inputMoreValueArr = CreateMoreUnit(inputMap[productId], product.MoreUnitList)
+ }
+
+ if !outputMap[productId].IsZero() {
+ outputMoreValueArr = CreateMoreUnit(outputMap[productId], product.MoreUnitList)
+ }
+ bys, _ := json.Marshal(moreValueArr)
+ moreUnits = string(bys)
+ bys, _ = json.Marshal(inputMoreValueArr)
+ inputMoreUnits = string(bys)
+ bys, _ = json.Marshal(outputMoreValueArr)
+ outputMoreUnits = string(bys)
+ }
+
+ record.InputAmount = inputMap[productId]
+ record.InputMoreUnits = inputMoreUnits
+ record.OutputAmount = outputMap[productId]
+ record.OutputMoreUnits = outputMoreUnits
+ record.EndAmount = amount
+ record.EndMoreUnits = moreUnits
+ statRecords = append(statRecords, &record)
+ }
+
+ return
+}
+
+func GetStatsByOperationType(beginTime, endTime time.Time, operationType constvar.BaseOperationType) (m map[string]decimal.Decimal, err error) {
+ operationIds, err := models.NewOperationSearch().SetBaseOperationType(operationType).SetFields("id").SetTimeBetween(beginTime, endTime).FindIds()
+ if err != nil {
+ return
+ }
+ groupSumList, err := models.NewOperationDetailsSearch().SetOperationIds(operationIds).SetFields("product_id, amount").GroupSum("product_id", "amount")
+ if err != nil {
+ return
+ }
+ m = make(map[string]decimal.Decimal, len(groupSumList))
+ for _, v := range groupSumList {
+ m[v.Class] = v.Sum
+ }
+ return
+}
diff --git a/service/more_units.go b/service/more_units.go
index 3a4cf49..5abdb09 100644
--- a/service/more_units.go
+++ b/service/more_units.go
@@ -11,8 +11,11 @@
func CreateMoreUnit(amount decimal.Decimal, units []models.UnitItems) []models.UnitItems {
moreValueArr := make([]models.UnitItems, 0, len(units))
for _, unitItem := range units {
+ if unitItem.Amount.IsZero() {
+ continue
+ }
moreValueArr = append(moreValueArr, models.UnitItems{
- Amount: amount.Mul(unitItem.Amount),
+ Amount: amount.Div(unitItem.Amount),
Unit: unitItem.Unit,
Floating: unitItem.Floating,
})
diff --git a/service/system_config.go b/service/system_config.go
new file mode 100644
index 0000000..daab2d6
--- /dev/null
+++ b/service/system_config.go
@@ -0,0 +1,73 @@
+package service
+
+import (
+ "errors"
+ "github.com/spf13/cast"
+ "gorm.io/gorm"
+ "strings"
+ "time"
+ "wms/constvar"
+ "wms/models"
+)
+
+type SystemConfigService struct {
+}
+
+func NewSystemConfigService() *SystemConfigService {
+ return &SystemConfigService{}
+}
+
+func (slf SystemConfigService) ParamsCheck(params models.SystemConfig) (err error) {
+ var oldRecord *models.SystemConfig
+ if params.Id != 0 {
+ oldRecord, err = models.NewSystemConfigSearch().SetID(params.ID).First()
+ if err == gorm.ErrRecordNotFound {
+ return errors.New("閰嶇疆涓嶅瓨鍦�")
+ }
+ }
+ if oldRecord == nil || params.ConfigType != oldRecord.ConfigType {
+ _, err = models.NewSystemConfigSearch().SetConfigType(params.ConfigType).First()
+ if err != gorm.ErrRecordNotFound {
+ return errors.New("閰嶇疆椤归噸澶�")
+ }
+ }
+
+ switch params.ConfigType {
+ case constvar.SystemConfigTypeInventoryCutOffPoint:
+ _, _, err = slf.CheckInventoryCutOffPoint(params.Val)
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+func (slf SystemConfigService) CheckInventoryCutOffPoint(val string) (day int, timeStr string, err error) {
+ if !strings.Contains(val, "-") {
+ err = errors.New("搴撳瓨缁撶畻鏃堕棿鐐瑰簲璇ョ敤鍒嗛殧绗�'-'鍒嗛殧鏃ユ湡鍜屾椂闂�")
+ return
+ }
+ arr := strings.Split(val, "-")
+ if len(arr) != 2 {
+ err = errors.New("搴撳瓨缁撶畻鏃堕棿鐐瑰簲璇ョ敤鍒嗛殧绗�'-'鍒嗛殧鏃ユ湡鍜屾椂闂达紝涓斿彧鑳芥湁涓�涓垎闅旂")
+ return
+ }
+ day = cast.ToInt(arr[0])
+ if day < 0 || day > 28 {
+ err = errors.New("搴撳瓨缁撶畻鏃堕棿鐐规棩鏈熶笉姝g‘锛屽簲鍦�1~28涔嬮棿")
+ return
+ }
+ timeStr = arr[1]
+ _, err = time.ParseInLocation("15:04", arr[1], time.Local)
+ return
+}
+
+func (slf SystemConfigService) GetInventoryCutOffPoint() (day int, timeStr string, err error) {
+ config, err := models.NewSystemConfigSearch().SetConfigType(constvar.SystemConfigTypeInventoryCutOffPoint).First()
+ if err != nil {
+ err = errors.New("搴撳瓨缁撶畻鏃堕棿鐐规湭閰嶇疆")
+ return
+ }
+ return slf.CheckInventoryCutOffPoint(config.Val)
+}
diff --git a/task/month_stats.go b/task/month_stats.go
index 6d82bb4..b2de4fb 100644
--- a/task/month_stats.go
+++ b/task/month_stats.go
@@ -1,12 +1,9 @@
package task
import (
- "encoding/json"
"fmt"
- "github.com/shopspring/decimal"
"gorm.io/gorm"
"time"
- "wms/constvar"
"wms/models"
"wms/pkg/logx"
"wms/service"
@@ -45,126 +42,40 @@
oldRecordsMap := models.MonthStatsMap(oldRecords)
//鏈湀鏈熷垵鏁伴噺/涓婃湀缁撲綑鏁伴噺
- groupSumList, err := models.NewLocationProductAmountSearch().GroupSum("product_id", "amount")
-
- productIds := make([]string, 0, len(groupSumList))
-
- for _, groupSum := range groupSumList {
- productIds = append(productIds, groupSum.Class)
- }
- products, err := models.NewMaterialSearch().SetFields("id, name, unit, weight, more_unit, more_unit_value").SetIDs(productIds).FindNotTotal()
+ statsRecords, err := service.GetCurrentStats(date, nil)
if err != nil {
- logx.Errorf("MonthStats get products err:%v", err)
- return
+ return err
}
- productMap := models.MaterialMap(products)
-
- beginTime, endTime := GetLastMonthPeriod()
- inputMap, err := GetStatsByOperationType(beginTime, endTime, constvar.BaseOperationTypeIncoming)
- if err != nil {
- logx.Errorf("MonthStats GetStatsByOperationType input err:%v", err)
- return
- }
-
- outputMap, err := GetStatsByOperationType(beginTime, endTime, constvar.BaseOperationTypeOutgoing)
- if err != nil {
- logx.Errorf("MonthStats GetStatsByOperationType output err:%v", err)
- return
- }
- var record models.MonthStats
err = models.NewMonthStatsSearch().SetDate(date).Delete()
if err != nil {
return
}
- for _, groupSum := range groupSumList {
- productId := groupSum.Class
- if productMap[productId] == nil {
- continue
- }
- product := productMap[productId]
- amount := groupSum.Sum
- record = models.MonthStats{
- ProductId: productId,
- ProductName: product.Name,
- BeginAmount: amount,
- Unit: product.Unit,
- Weight: product.Weight.Mul(amount),
- Date: date,
- }
-
- var (
- moreUnits string
- inputMoreUnits string
- outputMoreUnits string
- )
- if *product.MoreUnit {
- moreValueArr := make([]models.UnitItems, 0, len(product.MoreUnitList))
- inputMoreValueArr := make([]models.UnitItems, 0, len(product.MoreUnitList))
- outputMoreValueArr := make([]models.UnitItems, 0, len(product.MoreUnitList))
- for _, unitItem := range product.MoreUnitList {
- if !amount.IsZero() {
- moreValueArr = append(moreValueArr, models.UnitItems{
- Amount: amount.Mul(unitItem.Amount),
- Unit: unitItem.Unit,
- Floating: unitItem.Floating,
- })
- }
-
- if !inputMap[productId].IsZero() {
- inputMoreValueArr = append(inputMoreValueArr, models.UnitItems{
- Amount: inputMap[productId].Mul(unitItem.Amount),
- Unit: unitItem.Unit,
- Floating: unitItem.Floating,
- })
- }
-
- if !outputMap[productId].IsZero() {
- outputMoreValueArr = append(outputMoreValueArr, models.UnitItems{
- Amount: outputMap[productId].Mul(unitItem.Amount),
- Unit: unitItem.Unit,
- Floating: unitItem.Floating,
- })
- }
- }
- bys, _ := json.Marshal(moreValueArr)
- if len(moreValueArr) > 0 {
- fmt.Println(moreValueArr)
- }
- moreUnits = string(bys)
- bys, _ = json.Marshal(inputMoreValueArr)
- inputMoreUnits = string(bys)
- bys, _ = json.Marshal(outputMoreValueArr)
- outputMoreUnits = string(bys)
- }
-
- record.BeginMoreUnits = moreUnits
+ for _, record := range statsRecords {
+ record.BeginAmount = record.EndAmount
+ record.BeginMoreUnits = record.EndMoreUnits
err = models.WithTransaction(func(db *gorm.DB) error {
- err = models.NewMonthStatsSearch().SetOrm(db).Create(&record)
+ err = models.NewMonthStatsSearch().SetOrm(db).Create(record)
if err != nil {
logx.Errorf("NewMonthStatsSearch Create err:%v, record: %+v", err, record)
service.SendAlarm("鏈堝害缁熻鍒涘缓鏈湀澶辫触", fmt.Sprintf("NewMonthStatsSearch Create err:%v, record: %+v", err, record))
}
- if oldRecordsMap[productId] != nil {
+ if oldRecordsMap[record.ProductId] != nil && oldRecordsMap[record.ProductId].Id != 0 {
m := map[string]interface{}{
- "end_more_units": moreUnits,
- "end_amount": amount,
+ "end_more_units": record.BeginMoreUnits,
+ "end_amount": record.BeginAmount,
}
- if !inputMap[productId].IsZero() || !outputMap[productId].IsZero() {
- record.InputAmount = inputMap[productId]
- record.InputMoreUnits = inputMoreUnits
- record.OutputAmount = outputMap[productId]
- record.OutputMoreUnits = outputMoreUnits
- m["input_amount"] = inputMap[productId]
- m["input_more_units"] = inputMoreUnits
- m["output_amount"] = outputMap[productId]
- m["output_more_units"] = outputMoreUnits
+ if !record.InputAmount.IsZero() || !record.InputAmount.IsZero() {
+ m["input_amount"] = record.InputAmount
+ m["input_more_units"] = record.InputMoreUnits
+ m["output_amount"] = record.InputAmount
+ m["output_more_units"] = record.OutputMoreUnits
}
- err = models.NewMonthStatsSearch().SetOrm(db).SetID(oldRecordsMap[productId].Id).UpdateByMap(m)
+ err = models.NewMonthStatsSearch().SetOrm(db).SetID(oldRecordsMap[record.ProductId].Id).UpdateByMap(m)
if err != nil {
- logx.Errorf("NewMonthStatsSearch UpdateByMap err:%v, id:%v, m:%+v", err, oldRecordsMap[productId].ID, m)
+ logx.Errorf("NewMonthStatsSearch UpdateByMap err:%v, id:%v, m:%+v", err, oldRecordsMap[record.ProductId].Id, m)
service.SendAlarm("鏈堝害缁熻鏇存敼涓婃湀澶辫触", fmt.Sprintf("NewMonthStatsSearch Create err:%v, record: %+v", err, record))
}
}
@@ -175,41 +86,4 @@
service.SendAlarm("鏈堝害缁熻鎵ц鎴愬姛", "")
}
return
-}
-
-func GetStatsByOperationType(beginTime, endTime time.Time, operationType constvar.BaseOperationType) (m map[string]decimal.Decimal, err error) {
- operationIds, err := models.NewOperationSearch().SetBaseOperationType(operationType).SetFields("id").SetTimeBetween(beginTime, endTime).FindIds()
- if err != nil {
- return
- }
- groupSumList, err := models.NewOperationDetailsSearch().SetOperationIds(operationIds).SetFields("product_id, amount").GroupSum("product_id", "amount")
- if err != nil {
- return
- }
- m = make(map[string]decimal.Decimal, len(groupSumList))
- for _, v := range groupSumList {
- m[v.Class] = v.Sum
- }
- return
-}
-
-// GetLastMonthPeriod 杩斿洖涓婁釜鏈堢殑鏈堝垵鏃堕棿鍜屾湀鏈椂闂�
-func GetLastMonthPeriod() (time.Time, time.Time) {
- // 鑾峰彇褰撳墠鏃堕棿
- now := time.Now()
-
- // 璁$畻涓婁釜鏈堢殑骞翠唤鍜屾湀浠�
- lastMonth := now.AddDate(0, -1, 0)
- lastYear, lastMonthNum, _ := lastMonth.Date()
-
- // 鑾峰彇涓婁釜鏈堢殑绗竴澶╃殑鏃ユ湡锛堝嵆涓婁釜鏈堟湀鍒濓級
- firstDayOfLastMonth := time.Date(lastYear, lastMonthNum, 1, 0, 0, 0, 0, now.Location())
-
- // 鑾峰彇鏈湀绗竴澶╃殑鏃ユ湡锛堝嵆鏈湀鏈堝垵锛�
- firstDayOfThisMonth := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
-
- // 涓婁釜鏈堟湀鏈椂闂村嵆涓烘湰鏈堟湀鍒濆噺鍘讳竴绉�
- lastDayOfLastMonth := firstDayOfThisMonth.Add(-time.Second)
-
- return firstDayOfLastMonth, lastDayOfLastMonth
}
diff --git a/task/tasklist.go b/task/tasklist.go
index 755558d..ec6298b 100644
--- a/task/tasklist.go
+++ b/task/tasklist.go
@@ -4,19 +4,42 @@
"github.com/go-co-op/gocron"
"time"
"wms/pkg/logx"
+ "wms/service"
)
-var s *gocron.Scheduler
+var dynamicScheduler *gocron.Scheduler
func init() {
- s = gocron.NewScheduler(time.UTC)
+ dynamicScheduler = gocron.NewScheduler(time.Local)
}
-func Init() {
- _, err := s.Every(1).Month(1).Do(MonthStats) //姣忔湀鍒濇墽琛屼竴娆�
- if err != nil {
- logx.Errorf("init task err:%v", err)
- panic(err)
- }
+func Init() error {
+ return StartDynamicTask()
+}
- s.StartAsync()
+func StartDynamicTask() (err error) {
+ sysCfgService := service.NewSystemConfigService()
+ day, timeStr, err := sysCfgService.GetInventoryCutOffPoint()
+ if err != nil {
+ return
+ }
+ if day != 0 && timeStr != "" {
+ _, err = dynamicScheduler.Every(1).Month(day).At(timeStr).Do(MonthStats) //姣忔湀鍒濇墽琛屼竴娆�
+ if err != nil {
+ logx.Errorf("init task err:%v", err)
+ return err
+ }
+ }
+ if dynamicScheduler.Len() == 0 {
+ return
+ }
+ dynamicScheduler.StartAsync()
+ return nil
+}
+
+func RestartDynamicTask() error {
+ if dynamicScheduler != nil {
+ dynamicScheduler.Stop()
+ dynamicScheduler.Clear()
+ }
+ return StartDynamicTask()
}
diff --git a/utils/util.go b/utils/util.go
index 61c9c1c..c1b4d52 100644
--- a/utils/util.go
+++ b/utils/util.go
@@ -3,9 +3,31 @@
import (
"github.com/google/uuid"
"strings"
+ "time"
)
func GetUUID() string {
s := uuid.New().String()
return strings.ReplaceAll(s, "-", "")
}
+
+// GetLastMonthPeriod 杩斿洖涓婁釜鏈堢殑鏈堝垵鏃堕棿鍜屾湀鏈椂闂�
+func GetLastMonthPeriod() (time.Time, time.Time) {
+ // 鑾峰彇褰撳墠鏃堕棿
+ now := time.Now()
+
+ // 璁$畻涓婁釜鏈堢殑骞翠唤鍜屾湀浠�
+ lastMonth := now.AddDate(0, -1, 0)
+ lastYear, lastMonthNum, _ := lastMonth.Date()
+
+ // 鑾峰彇涓婁釜鏈堢殑绗竴澶╃殑鏃ユ湡锛堝嵆涓婁釜鏈堟湀鍒濓級
+ firstDayOfLastMonth := time.Date(lastYear, lastMonthNum, 1, 0, 0, 0, 0, now.Location())
+
+ // 鑾峰彇鏈湀绗竴澶╃殑鏃ユ湡锛堝嵆鏈湀鏈堝垵锛�
+ firstDayOfThisMonth := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
+
+ // 涓婁釜鏈堟湀鏈椂闂村嵆涓烘湰鏈堟湀鍒濆噺鍘讳竴绉�
+ lastDayOfLastMonth := firstDayOfThisMonth.Add(-time.Second)
+
+ return firstDayOfLastMonth, lastDayOfLastMonth
+}
--
Gitblit v1.8.0