V0 导入结批报告

This commit is contained in:
Simmons 2024-09-27 18:31:32 +08:00
parent ebeb17d3ea
commit c09873d17f
8 changed files with 132 additions and 5 deletions

View File

@ -1,12 +1,15 @@
package test_data
import (
"gitee.com/golang-module/carbon/v2"
"github.com/gin-gonic/gin"
"os"
"path/filepath"
"testData/model"
"testData/model/response"
"testData/repository"
test_data "testData/repository/test.data"
"testData/request"
"testData/utils"
)
@ -19,8 +22,8 @@ func InitImportService() *ImportService {
return &ImportService{}
}
// @Tags 解答系统-上传文件管理
// @Summary 上传回答附
// @Tags 数据分析平台-导入文件
// @Summary 导入测试文
// @Security ApiKeyAuth
// @accept multipart/form-data
// @Param file formData file true "file"
@ -82,3 +85,53 @@ func (D *ImportService) ImportTestFile(c *gin.Context) {
SubBatch: subBatch}, step)
response.Ok(c)
}
// @Tags 数据分析平台-导入文件
// @Summary 上传结批报告
// @Security ApiKeyAuth
// @accept multipart/form-data
// @Param file formData file true "file"
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
// @Router /testData/import/finalReport [post]
func (D *ImportService) ImportFinalReport(c *gin.Context) {
file, err := c.FormFile("file")
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
filePath := filepath.Join("files", carbon.Now().Format("Y-m"), "结批报告")
os.MkdirAll(filePath, os.ModePerm)
filePath = filepath.Join(filePath, file.Filename)
if _, err = os.Stat(filePath); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err = c.SaveUploadedFile(file, filePath); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
response.OkWithData(gin.H{"file_path": filePath}, c)
}
// @Tags 数据分析平台-导入文件
// @Summary 导入结批报告
// @Security ApiKeyAuth
// @accept multipart/form-data
// -// @Param file formData file true "file"
// @Param data body request.ImportFinalReport true "查询参数"
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
// @Router /testData/import/finalReport/commit [post]
func (D *ImportService) ImportFinalReportCommit(c *gin.Context) {
r := request.ImportFinalReport{}
_ = c.ShouldBind(&r)
if msg, ok := utils.ValidateInfo2CN(r); !ok {
response.FailWithMessage(msg, c)
return
}
test_data.ImportFinalReport(&r)
response.Ok(c)
}

5
go.mod
View File

@ -13,10 +13,11 @@ require (
github.com/PuerkitoBio/purell v1.2.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/bytedance/sonic v1.11.2 // indirect
github.com/casbin/casbin/v2 v2.82.0 // indirect
github.com/casbin/casbin/v2 v2.100.0 // indirect
github.com/casbin/gorm-adapter/v3 v3.21.0 // indirect
github.com/casbin/govaluate v1.1.1 // indirect
github.com/casbin/govaluate v1.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect

6
go.sum
View File

@ -22,17 +22,23 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ=
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIgjX4RBBcHnJ05h//6/k6foqmgE45jTQtxg=
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.11.2 h1:ywfwo0a/3j9HR8wsYGWsIWl2mvRsI950HyoxiBERw5A=
github.com/bytedance/sonic v1.11.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/casbin/casbin/v2 v2.82.0 h1:2CgvunqQQoepcbGRnMc9vEcDhuqh3B5yWKoj+kKSxf8=
github.com/casbin/casbin/v2 v2.82.0/go.mod h1:jX8uoN4veP85O/n2674r2qtfSXI6myvxW85f6TH50fw=
github.com/casbin/casbin/v2 v2.100.0 h1:aeugSNjjHfCrgA22nHkVvw2xsscboHv5r0a13ljQKGQ=
github.com/casbin/casbin/v2 v2.100.0/go.mod h1:LO7YPez4dX3LgoTCqSQAleQDo0S0BeZBDxYnPUl95Ng=
github.com/casbin/gorm-adapter/v3 v3.21.0 h1:1YOVpBvGc38H717WKSNCUuhsixFOjF8jmNukq792WBc=
github.com/casbin/gorm-adapter/v3 v3.21.0/go.mod h1:pvTTuyP2Es8VPHLyUssGtvOb3ETYD2tG7TfT5K8X2Sg=
github.com/casbin/govaluate v1.1.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A=
github.com/casbin/govaluate v1.1.1 h1:J1rFKIBhiC5xr0APd5HP6rDL+xt+BRoyq1pa4o2i/5c=
github.com/casbin/govaluate v1.1.1/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A=
github.com/casbin/govaluate v1.2.0 h1:wXCXFmqyY+1RwiKfYo3jMKyrtZmOL3kHwaqDyCPOYak=
github.com/casbin/govaluate v1.2.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=

View File

@ -1440,3 +1440,35 @@
2024-09-12 10:31:43 INFO | 192.168.0.219 | 200 | 3.7083ms | POST | 未登录 | /testData/report/passProbability
2024-09-12 10:33:11 INFO | 192.168.0.219 | 200 | 3.4306ms | POST | 未登录 | /testData/report/passProbability
2024-09-13 09:41:44 INFO | 192.168.0.219 | 200 | 15.013559s | POST | 未登录 | /testData/report/binProbability
2024-09-27 15:40:30 INFO | 192.168.0.219 | 200 | 505.3µs | POST | 未登录 | /testData/import/finalReport
2024-09-27 15:41:50 INFO | 192.168.0.219 | 200 | 1.3603ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 15:43:56 INFO | 192.168.0.219 | 200 | 47.9024459s | POST | 未登录 | /testData/import/finalReport
2024-09-27 15:45:01 INFO | 192.168.0.219 | 200 | 2.7496ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 16:00:34 INFO | 192.168.0.219 | 200 | 2.9786ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 16:01:50 INFO | 192.168.0.219 | 200 | 2.0028ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 16:02:11 INFO | 192.168.0.219 | 200 | 1.2239ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:12:45 INFO | 192.168.0.219 | 200 | 835.4µs | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:13:46 INFO | 192.168.0.219 | 200 | 2.7128ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:20:10 INFO | 192.168.0.219 | 200 | 843.2µs | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:21:37 INFO | 192.168.0.219 | 200 | 1.26ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:21:56 INFO | 192.168.0.219 | 200 | 1.4323ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:22:09 INFO | 192.168.0.219 | 200 | 44.6418ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:22:22 INFO | 192.168.0.219 | 200 | 505.3µs | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:23:02 INFO | 192.168.0.219 | 200 | 1.3549ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:23:10 INFO | 192.168.0.219 | 200 | 1.2668ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:23:30 INFO | 192.168.0.219 | 200 | 1.0275ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:23:51 INFO | 192.168.0.219 | 200 | 1.3723ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 17:24:26 INFO | 192.168.0.219 | 200 | 2.1121ms | POST | 未登录 | /testData/import/finalReport
2024-09-27 18:02:28 INFO | 192.168.0.219 | 200 | 3.54ms | GET | 未登录 | /testData/finalReport/excel?page=1&pageSize=20&key_word=
2024-09-27 18:02:31 INFO | 192.168.0.219 | 200 | 658.7µs | POST | 未登录 | /testData/import/finalReport
2024-09-27 18:02:36 INFO | 192.168.0.219 | 200 | 191µs | POST | 未登录 | /testData/import/finalReport/commit
2024-09-27 18:12:35 INFO | 192.168.0.219 | 200 | 2.6249ms | GET | 未登录 | /testData/finalReport/excel?page=1&pageSize=20&key_word=
2024-09-27 18:12:36 INFO | 192.168.0.219 | 200 | 1.9948ms | GET | 未登录 | /testData/finalReport/excel?page=1&pageSize=20&key_word=
2024-09-27 18:14:10 INFO | 192.168.0.219 | 200 | 2.9168ms | GET | 未登录 | /testData/finalReport/excel?page=1&pageSize=20&key_word=
2024-09-27 18:14:11 INFO | 192.168.0.219 | 200 | 13.1377ms | GET | 未登录 | /testData/finalReport/excel?page=1&pageSize=20&key_word=
2024-09-27 18:14:15 INFO | 192.168.0.219 | 200 | 16.0106ms | GET | 未登录 | /testData/finalReport/excel?page=1&pageSize=20&key_word=
2024-09-27 18:14:51 INFO | 192.168.0.219 | 200 | 3.9154ms | GET | 未登录 | /testData/finalReport/excel?page=1&pageSize=20&key_word=
2024-09-27 18:15:37 INFO | 192.168.0.219 | 200 | 2.0105ms | GET | 未登录 | /testData/finalReport/excel?page=1&pageSize=20&key_word=
2024-09-27 18:19:26 INFO | 192.168.0.219 | 200 | 2.8389ms | GET | 未登录 | /testData/finalReport/excel?page=1&pageSize=20&key_word=
2024-09-27 18:28:54 INFO | 192.168.0.219 | 200 | 2.5925ms | GET | 未登录 | /testData/finalReport/excel?page=1&pageSize=20&key_word=
2024-09-27 18:28:55 INFO | 192.168.0.219 | 200 | 25.5084ms | GET | 未登录 | /testData/finalReport/excel?page=1&pageSize=20&key_word=

View File

@ -2,7 +2,34 @@ package test_data
import (
"testData/model"
reader2 "testData/repository/report_reader"
"testData/request"
)
func ImportSTS8200(fileText *model.FileText) {
}
func ImportFinalReport(r *request.ImportFinalReport) {
if r.Step == "FT" {
if r.Factory == "赛美科" {
reader2.FTSMCReportReader(r.FilePath)
} else if r.Factory == "长电" {
reader2.FTSuYinChangDianReportReader(r.FilePath)
} else if r.Factory == "气派" {
reader2.FTQiPaiReportReader(r.FilePath)
} else if r.Factory == "睿思" {
reader2.FTRuiSiReportReader(r.FilePath)
} else if r.Factory == "芯德" {
reader2.FTXinDeReportReader(r.FilePath)
}
} else if r.Step == "CP" {
if r.Factory == "赛美科" {
reader2.CPSMCReportReader(r.FilePath)
} else if r.Factory == "圆方" {
reader2.CPYuanFangReportReader(r.FilePath)
} else if r.Factory == "育诚" {
reader2.CPYuChengReportReader(r.FilePath)
}
}
}

View File

@ -2,3 +2,9 @@ package request
type ImportTestFile struct {
}
type ImportFinalReport struct {
Step string `json:"step"`
Factory string `json:"factory"`
FilePath string `json:"file_path"`
}

View File

@ -10,5 +10,7 @@ func InitImportRouter(R *gin.RouterGroup) {
importGroup := R.Group("import")
{
importGroup.POST("testFile", importService.ImportTestFile)
importGroup.POST("finalReport", importService.ImportFinalReport)
importGroup.POST("finalReport/commit", importService.ImportFinalReportCommit)
}
}

View File

@ -61,7 +61,7 @@ func (ca *CasbinService) UpdateCasbinApi(oldPath string, newPath string, oldMeth
func (ca *CasbinService) GetPolicyPathByAuthorityId(authorityId string) (pathMaps []request.CasbinInfo) {
e := ca.Casbin()
list := e.GetFilteredPolicy(0, authorityId)
list, _ := e.GetFilteredPolicy(0, authorityId)
for _, v := range list {
pathMaps = append(pathMaps, request.CasbinInfo{
Path: v[1],