Jianghan пре 1 година
родитељ
комит
e4e32efdad
6 измењених фајлова са 24 додато и 14 уклоњено
  1. 1 0
      api/etc/biservice-api.yaml
  2. 5 1
      entity/entity.go
  3. 1 1
      rpc/biservice.go
  4. 2 0
      rpc/etc/biservice.yaml
  5. 2 0
      rpc/internal/config/config.go
  6. 13 12
      service/exprot.go

+ 1 - 0
api/etc/biservice-api.yaml

@@ -115,5 +115,6 @@ Mail:
     User: "public03@topnet.net.cn"
 UpdateProjectUrl: "http://192.168.3.206:7778/updateProject"
 ExportDirectory: "D:/top_git_projects/biService"
+CommonExportDir: "D:/top_git_projects/biComFileRes"
 ExportUrl: "https://jybx-webtest.jydev.jianyu360.com/tietaRes"
 ExportCount: 15000

+ 5 - 1
entity/entity.go

@@ -53,7 +53,9 @@ var (
 	GmailAuth        []*mail.GmailAuth
 	UpdataProjectUrl string
 	ExportDirectory  string
+	ComFileDir       string
 	ExportUrl        string
+	ComFileUrl       string
 	ExportCount      int
 )
 
@@ -230,10 +232,12 @@ func (h *Handler) HandleMessage(m *nsq.Message) error {
 	}
 	return nil
 }
-func InitConfig(directory, projectUrl, exportUrl string, count int) {
+func InitConfig(directory, dir2, projectUrl, exportUrl, url1 string, count int) {
 	ExportDirectory = directory
+	ComFileDir = dir2
 	UpdataProjectUrl = projectUrl
 	ExportUrl = exportUrl
+	ComFileUrl = url1
 	ExportCount = count
 }
 

+ 1 - 1
rpc/biservice.go

@@ -37,7 +37,7 @@ func main() {
 	entity.InitEntEs(c.EntEs.Version, c.EntEs.Address, c.EntEs.UserName, c.EntEs.Password, c.EntEs.DbSize)
 	entity.InitArea()
 	entity.InitRedis(c.RedisAddress)
-	entity.InitConfig(c.ExportDirectory, c.UpdateProjectUrl, c.ExportUrl, c.ExportCount)
+	entity.InitConfig(c.ExportDirectory, c.ComFileDir, c.UpdateProjectUrl, c.ExportUrl, c.ComFileUrl, c.ExportCount)
 	//合力亿捷
 	entity.GetHlyj(c.Hlyj.Appid, c.Hlyj.Account, c.Hlyj.Secret, c.Hlyj.TokenUrl, c.Hlyj.CallUrl, c.Hlyj.Integratedid, c.Hlyj.CallFlag)
 	//nsq

+ 2 - 0
rpc/etc/biservice.yaml

@@ -121,5 +121,7 @@ Mail:
     User: "public03@topnet.net.cn"
 UpdateProjectUrl: "http://192.168.3.206:7778/updateProject"
 ExportDirectory: "D:/top_git_projects/biService"
+ComFileDir: "D:/top_git_projects/biComFileRes"
 ExportUrl: "https://jybx-webtest.jydev.jianyu360.com/tietaRes"
+ComFileUrl: "https://jybx-webtest.jydev.jianyu360.com/tietaRes"
 ExportCount: 15000

+ 2 - 0
rpc/internal/config/config.go

@@ -80,6 +80,8 @@ type Config struct {
 	}
 	UpdateProjectUrl string
 	ExportDirectory  string
+	ComFileDir       string
 	ExportCount      int
 	ExportUrl        string
+	ComFileUrl       string
 }

+ 13 - 12
service/exprot.go

@@ -51,7 +51,7 @@ func (a *ExportReq) AllProjectExport() {
 	timeStr = fmt.Sprintf("%s%s", timeStr, gconv.String(randomInt))
 	pathArr := export("customer_data_ttzl_project", tableColumn, exportKey, timeStr)
 	if len(pathArr) > 0 {
-		pathstr := compressFiles(pathArr, timeStr)
+		pathstr := compressFiles(pathArr, ExportUrl, timeStr)
 		state := sendMail("项目", a.Mail, pathstr)
 		BiService.Insert("export_record", map[string]interface{}{
 			"positionId": a.PositionId,
@@ -79,7 +79,7 @@ func (a *ExportReq) AllInfoExport() {
 	timeStr = fmt.Sprintf("%s%s", timeStr, gconv.String(randomInt))
 	pathArr := export("customer_data_ttzl", tableColumn, exportKey, timeStr)
 	if len(pathArr) > 0 {
-		pathstr := compressFiles(pathArr, timeStr)
+		pathstr := compressFiles(pathArr, ExportUrl, timeStr)
 		state := sendMail("标讯", a.Mail, pathstr)
 		BiService.Insert("export_record", map[string]interface{}{
 			"positionId": a.PositionId,
@@ -135,7 +135,7 @@ func dataHandle(writer *excelize.StreamWriter, l *[]map[string]interface{}, a in
 func Warehousing(writer *excelize.StreamWriter, file *excelize.File, fileCounter int, key []interface{}, timeStr string) (*excelize.StreamWriter, *excelize.File, string) {
 	log.Println(fmt.Sprintf("开始第%d数据", fileCounter))
 	writer.Flush()
-	folderPath := fmt.Sprintf("%s/%s", ExportDirectory, timeStr)
+	folderPath := fmt.Sprintf("%s/%s", ComFileDir, timeStr)
 	_, err := os.Stat(folderPath)
 	if os.IsNotExist(err) {
 		//创建文件夹
@@ -188,8 +188,8 @@ func sendMail(title, target_mail string, path string) bool {
 }
 
 // 文件压缩
-func compressFiles(filePattern []string, timeStr string) string {
-	folderPath := fmt.Sprintf("%s/%s", ExportDirectory, timeStr)
+func compressFiles(filePattern []string, url, timeStr string) string {
+	folderPath := fmt.Sprintf("%s/%s", ComFileDir, timeStr)
 	_, err := os.Stat(folderPath)
 	if os.IsNotExist(err) {
 		//创建文件夹
@@ -244,7 +244,7 @@ func compressFiles(filePattern []string, timeStr string) string {
 		log.Fatal(err)
 	}
 	log.Printf("Files compressed to: %s", absPath)
-	return fmt.Sprintf("%s/%s/%s.zip", ExportUrl, timeStr, timeStr)
+	return fmt.Sprintf("%s/%s/%s.zip", url, timeStr, timeStr)
 }
 
 // 数据导出(通用)
@@ -255,14 +255,15 @@ func (e *ExportByDbReq) ExportDataByDb() []byte {
 	rand.Seed(time.Now().UnixNano())
 	randomInt := rand.Intn(10000) // 生成0到9999之间的随机整数
 	timeStr = fmt.Sprintf("%s%s", timeStr, gconv.String(randomInt))
-	pathArr := exportA(e.Query, timeStr, key)
+	stype := e.Stype
+	if stype == "" {
+		stype = "public"
+	}
+	pathArr := exportA(e.Query, stype, key)
 	if len(pathArr) > 0 {
-		pathstr := compressFiles(pathArr, timeStr)
+		pathstr := compressFiles(pathArr, ComFileUrl, stype)
 		state := sendMailA(e.Title, e.Mails, e.Content, pathstr)
-		stype := e.Stype
-		if stype == "" {
-			stype = "public"
-		}
+
 		BiService.Insert("export_record", map[string]interface{}{
 			"positionId": "0",
 			"type":       stype,