数据分析平台 测试文件导入生成PBI接口
This commit is contained in:
parent
ed8a5525ae
commit
12b03fcb2b
@ -138,3 +138,13 @@ func (D *ImportService) ImportFinalReportCommit(c *gin.Context) {
|
||||
test_data.ImportFinalReport(&r)
|
||||
response.Ok(c)
|
||||
}
|
||||
|
||||
// @Tags 数据分析平台-导入文件
|
||||
// @Summary 初始化PBI
|
||||
// @Security ApiKeyAuth
|
||||
// @Produce application/json
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
|
||||
// @Router /testData/import/initPBI [get]
|
||||
func (D *ImportService) InitNewPBI(c *gin.Context) {
|
||||
response.OkWithData(test_data.InitNewPBI(), c)
|
||||
}
|
||||
|
@ -1,6 +1,12 @@
|
||||
package test_data
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"gitee.com/golang-module/carbon/v2"
|
||||
"github.com/shopspring/decimal"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"testData/global"
|
||||
"testData/model"
|
||||
reader2 "testData/repository/report_reader"
|
||||
"testData/request"
|
||||
@ -31,5 +37,22 @@ func ImportFinalReport(r *request.ImportFinalReport) {
|
||||
reader2.CPYuChengReportReader(r.FilePath)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func InitNewPBI() string {
|
||||
pbiStart := carbon.Now().Format("Ymd")
|
||||
var newHandler *model.FileHandled
|
||||
var pbi string
|
||||
if errors.Is(global.PostGreSQL.Where("pbi LIKE ?", pbiStart+"%").Order("pbi desc").First(&newHandler).Error, gorm.ErrRecordNotFound) {
|
||||
after, _ := strings.CutPrefix(newHandler.PBI, pbiStart)
|
||||
afterDecimal, _ := decimal.NewFromString(after)
|
||||
pbiSuffix := afterDecimal.Add(decimal.NewFromInt(1)).String()
|
||||
if len(pbiSuffix) < 4 {
|
||||
pbiSuffix = strings.Repeat("0", 4-len(pbiSuffix)) + pbiSuffix
|
||||
}
|
||||
pbi = pbiStart + pbiSuffix
|
||||
} else {
|
||||
return pbiStart + "0001"
|
||||
}
|
||||
return pbi
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ func InitImportRouter(R *gin.RouterGroup) {
|
||||
importGroup.POST("testFile", importService.ImportTestFile)
|
||||
importGroup.POST("finalReport", importService.ImportFinalReport)
|
||||
importGroup.POST("finalReport/commit", importService.ImportFinalReportCommit)
|
||||
importGroup.GET("initPBI", importService.InitNewPBI)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user