Browse Source

Merge branch 'ETA_2.4.0' into debug

# Conflicts:
#	models/db.go
xiziwen 1 day ago
parent
commit
e2b85045c7

+ 109 - 0
controllers/data_manage/excel/excel_info.go

@@ -3363,3 +3363,112 @@ func (c *ExcelInfoController) GetExcelRuleDetail() {
 	br.Ret = 200
 	br.Success = true
 }
+
+// GetExcelReferenceDetail
+// @Title 表格引用配置详情
+// @Description 表格引用配置详情
+// @Param   ExcelInfoRuleMappingId   query   int  true       "id"
+// @Success Ret=200 获取成功
+// @router /excel_info/reference/detail [get]
+//func (c *ExcelInfoController) GetExcelReferenceDetail() {
+//	br := new(models.BaseResponse).Init()
+//	defer func() {
+//		c.Data["json"] = br
+//		c.ServeJSON()
+//	}()
+//	sysUser := c.SysUser
+//	if sysUser == nil {
+//		br.Msg = "请登录"
+//		br.ErrMsg = "请登录,SysUser Is Empty"
+//		br.Ret = 408
+//		return
+//	}
+//	excelReferenceCode := c.GetString("ExcelReferenceCode")
+//
+//	item, err := excel3.GetReferencedExcelConfigByUniqueCode(excelReferenceCode)
+//	if err != nil && err.Error() != utils.ErrNoRow() {
+//		br.Msg = "获取规则"
+//		br.ErrMsg = "管理规则添加失败,Err:" + err.Error()
+//		return
+//	}
+//
+//	br.Data = item
+//	br.Msg = "获取成功"
+//	br.Ret = 200
+//	br.Success = true
+//}
+
+// GetExcelReferenceDetail
+// @Title 表格引用配置保存
+// @Description 表格引用配置保存
+// @Param   ExcelInfoRuleMappingId   query   int  true       "id"
+// @Success Ret=200 获取成功
+// @router /excel_info/reference/save [post]
+func (c *ExcelInfoController) SaveExcelReference() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req []excel3.ExcelReferencesReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	addList := make([]*excel3.ReferencedExcelConfig, 0)
+	for _, v := range req {
+		exist, e := excel3.GetReferencedExcelConfig(v.ReferencedId, v.FromScene, v.Uuid)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			br.Msg = "查找引用失败"
+			br.ErrMsg = "查找引用失败,Err:" + e.Error()
+			return
+		}
+		if exist.ReferencedExcelConfigId == 0 {
+			item := excel3.ReferencedExcelConfig{
+				UniqueCode:   v.UniqueCode,
+				ReferencedId: v.ReferencedId,
+				FromScene:    v.FromScene,
+				Uuid:         v.Uuid,
+				WidthList:    v.WidthList,
+				HeightList:   v.HeightList,
+				OpUserId:     sysUser.AdminId,
+				OpUserName:   sysUser.RealName,
+				CreateTime:   time.Now(),
+				ModifyTime:   time.Now(),
+			}
+			addList = append(addList, &item)
+		} else {
+			exist.WidthList = v.WidthList
+			exist.HeightList = v.HeightList
+			exist.OpUserId = sysUser.AdminId
+			exist.OpUserName = sysUser.RealName
+			exist.ModifyTime = time.Now()
+			err = excel3.UpdateReferencedExcelConfig(&exist)
+			if err != nil {
+				br.Msg = "更新引用失败"
+				br.ErrMsg = "更新引用失败,Err:" + err.Error()
+				return
+			}
+		}
+	}
+	err = excel3.AddReferencedExcelConfig(addList)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "添加引用失败"
+		br.ErrMsg = "添加引用失败,Err:" + err.Error()
+		return
+	}
+
+	br.Msg = "添加成功"
+	br.Ret = 200
+	br.Success = true
+}

+ 25 - 0
controllers/english_report/report.go

@@ -5,6 +5,7 @@ import (
 	"eta/eta_api/controllers"
 	"eta/eta_api/models"
 	"eta/eta_api/models/company"
+	"eta/eta_api/models/data_manage/excel"
 	"eta/eta_api/models/report_approve"
 	"eta/eta_api/models/system"
 	"eta/eta_api/services"
@@ -140,6 +141,30 @@ func (this *EnglishReportController) Add() {
 	{
 		go models.ModifyEnglishReportCode(newReportId, reportCode)
 	}
+
+	excelReferences := make([]*excel.ReferencedExcelConfig, len(req.ExcelReferences))
+	for _, r := range req.ExcelReferences {
+		refItem := excel.ReferencedExcelConfig{
+			UniqueCode:   r.UniqueCode,
+			ReferencedId: int(newReportId),
+			FromScene:    3,
+			Uuid:         r.Uuid,
+			WidthList:    r.WidthList,
+			HeightList:   r.HeightList,
+			OpUserId:     this.SysUser.AdminId,
+			OpUserName:   this.SysUser.RealName,
+			CreateTime:   time.Now(),
+			ModifyTime:   time.Now(),
+		}
+		excelReferences = append(excelReferences, &refItem)
+	}
+	err = excel.AddReferencedExcelConfig(excelReferences)
+	if err != nil {
+		br.Msg = "新增引用失败"
+		br.ErrMsg = "新增引用失败,Err:" + err.Error()
+		return
+	}
+
 	resp := new(models.AddEnglishReportResp)
 	resp.ReportId = newReportId
 	resp.ReportCode = reportCode

+ 24 - 0
controllers/ppt_english.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"eta/eta_api/models"
 	"eta/eta_api/models/company"
+	"eta/eta_api/models/data_manage/excel"
 	"eta/eta_api/models/ppt_english"
 	"eta/eta_api/services"
 	"eta/eta_api/services/ppt"
@@ -190,6 +191,29 @@ func (this *PptEnglishController) AddPpt() {
 			return
 		}
 		msg = "新增成功"
+
+		excelReferences := make([]*excel.ReferencedExcelConfig, len(req.ExcelReferences))
+		for _, r := range req.ExcelReferences {
+			refItem := excel.ReferencedExcelConfig{
+				UniqueCode:   r.UniqueCode,
+				ReferencedId: int(newId),
+				FromScene:    5,
+				Uuid:         r.Uuid,
+				WidthList:    r.WidthList,
+				HeightList:   r.HeightList,
+				OpUserId:     this.SysUser.AdminId,
+				OpUserName:   this.SysUser.RealName,
+				CreateTime:   time.Now(),
+				ModifyTime:   time.Now(),
+			}
+			excelReferences = append(excelReferences, &refItem)
+		}
+		err = excel.AddReferencedExcelConfig(excelReferences)
+		if err != nil {
+			br.Msg = "新增引用失败"
+			br.ErrMsg = "新增引用失败,Err:" + err.Error()
+			return
+		}
 	} else {
 		newId = req.PptId
 

+ 24 - 0
controllers/ppt_v2.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"eta/eta_api/models"
 	"eta/eta_api/models/company"
+	"eta/eta_api/models/data_manage/excel"
 	"eta/eta_api/models/ppt_english"
 	"eta/eta_api/services"
 	"eta/eta_api/services/ppt"
@@ -193,6 +194,29 @@ func (this *PptV2Controller) AddPpt() {
 			return
 		}
 		msg = "新增成功"
+
+		excelReferences := make([]*excel.ReferencedExcelConfig, len(req.ExcelReferences))
+		for _, r := range req.ExcelReferences {
+			refItem := excel.ReferencedExcelConfig{
+				UniqueCode:   r.UniqueCode,
+				ReferencedId: int(newId),
+				FromScene:    4,
+				Uuid:         r.Uuid,
+				WidthList:    r.WidthList,
+				HeightList:   r.HeightList,
+				OpUserId:     this.SysUser.AdminId,
+				OpUserName:   this.SysUser.RealName,
+				CreateTime:   time.Now(),
+				ModifyTime:   time.Now(),
+			}
+			excelReferences = append(excelReferences, &refItem)
+		}
+		err = excel.AddReferencedExcelConfig(excelReferences)
+		if err != nil {
+			br.Msg = "新增引用失败"
+			br.ErrMsg = "新增引用失败,Err:" + err.Error()
+			return
+		}
 	} else {
 		newId = req.PptId
 

+ 52 - 0
models/data_manage/excel/referenced_excel_config.go

@@ -0,0 +1,52 @@
+package excel
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type ReferencedExcelConfig struct {
+	ReferencedExcelConfigId int       `orm:"column(referenced_excel_config_id);pk;auto" ` // excel表格配置id
+	UniqueCode              string    // 表格唯一编码
+	ReferencedId            int       // 被引用的id,报告就是报告id,pptId
+	FromScene               int       // 引用类型 1智能研报 2研报列表 3英文研报 4PPT 5英文ppt
+	Uuid                    string    // 引用唯一标识
+	WidthList               string    // 宽度数组
+	HeightList              string    // 高度数组
+	OpUserId                int       // 当前编辑操作的用户id
+	OpUserName              string    // 当前编辑的用户名称(冗余字段,避免查表)
+	CreateTime              time.Time // 创建时间
+	Content                 string    // 内容
+	ModifyTime              time.Time // 修改时间
+}
+
+type ExcelReferencesReq struct {
+	UniqueCode   string `description:"表格唯一编码"`
+	ReferencedId int    `description:"被引用的ID"`
+	FromScene    int    `description:"引用类型 1智能研报 2研报列表 3英文研报 4PPT 5英文PPT"`
+	Uuid         string `description:"引用唯一标识"`
+	WidthList    string `description:"宽度数组"`
+	HeightList   string `description:"高度数组"`
+}
+
+// add
+func AddReferencedExcelConfig(items []*ReferencedExcelConfig) (err error) {
+	o := orm.NewOrmUsingDB("data")
+	_, err = o.InsertMulti(len(items), items)
+	return
+}
+
+// getByCode
+func GetReferencedExcelConfig(referencedId, fromScene int, uuid string) (item ReferencedExcelConfig, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT * FROM referenced_excel_config WHERE referenced_id = ? AND from_scene = ? AND uuid = ? `
+	err = o.Raw(sql, referencedId, fromScene, uuid).QueryRow(&item)
+	return
+}
+
+// update
+func UpdateReferencedExcelConfig(item *ReferencedExcelConfig) (err error) {
+	o := orm.NewOrmUsingDB("data")
+	_, err = o.Update(item, "WidthList", "HeightList", "OpUserId", "OpUserName", "ModifyTime")
+	return
+}

+ 1 - 0
models/db.go

@@ -550,6 +550,7 @@ func initExcel() {
 		new(excel.ExcelChartData),                        // 平衡表作图数据
 		new(excel.ExcelInfoRuleMapping),                  //表格的管理规则
 		new(tradeAnalysisModel.TradeAnalysisTableColumn), // 持仓分析表格-自定义列
+		new(excel.ReferencedExcelConfig),                 //表格的样式引用
 	)
 }
 

+ 15 - 13
models/english_report.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"errors"
+	"eta/eta_api/models/data_manage/excel"
 	"eta/eta_api/utils"
 	"fmt"
 	"strings"
@@ -91,19 +92,20 @@ func ModifyEnglishReportCode(reportId int64, reportCode string) (err error) {
 }
 
 type AddEnglishReportReq struct {
-	AddType            int    `description:"新增方式:1:新增报告,2:继承报告"`
-	ClassifyIdFirst    int    `description:"一级分类id"`
-	ClassifyNameFirst  string `description:"一级分类名称"`
-	ClassifyIdSecond   int    `description:"二级分类id"`
-	ClassifyNameSecond string `description:"二级分类名称"`
-	Title              string `description:"标题"`
-	Abstract           string `description:"摘要"`
-	Author             string `description:"作者"`
-	Frequency          string `description:"频度"`
-	State              int    `description:"状态:1:未发布,2:已发布"`
-	Content            string `description:"内容"`
-	CreateTime         string `description:"创建时间"`
-	Overview           string `description:"英文概述部分"`
+	AddType            int                        `description:"新增方式:1:新增报告,2:继承报告"`
+	ClassifyIdFirst    int                        `description:"一级分类id"`
+	ClassifyNameFirst  string                     `description:"一级分类名称"`
+	ClassifyIdSecond   int                        `description:"二级分类id"`
+	ClassifyNameSecond string                     `description:"二级分类名称"`
+	Title              string                     `description:"标题"`
+	Abstract           string                     `description:"摘要"`
+	Author             string                     `description:"作者"`
+	Frequency          string                     `description:"频度"`
+	State              int                        `description:"状态:1:未发布,2:已发布"`
+	Content            string                     `description:"内容"`
+	CreateTime         string                     `description:"创建时间"`
+	Overview           string                     `description:"英文概述部分"`
+	ExcelReferences    []excel.ExcelReferencesReq `description:"引用的Excel信息"`
 }
 
 type AddEnglishReportResp struct {

+ 6 - 4
models/ppt_english/ppt_english.go

@@ -1,6 +1,7 @@
 package ppt_english
 
 import (
+	"eta/eta_api/models/data_manage/excel"
 	"time"
 
 	"github.com/beego/beego/v2/client/orm"
@@ -119,10 +120,11 @@ type AddPptEnglishReq struct {
 		BackIndex    int    `description:"背景图片下标"`
 		TemplateType int    `description:"模版id"`
 	} `description:"首页"`
-	Content      string `description:"ppt的json数据"`
-	GroupId      int64  `description:"目录id"`
-	CoverContent string `description:"PPT内容-JSON"`
-	TitleSetting string `description:"PPT标题设置"`
+	Content         string                     `description:"ppt的json数据"`
+	GroupId         int64                      `description:"目录id"`
+	CoverContent    string                     `description:"PPT内容-JSON"`
+	TitleSetting    string                     `description:"PPT标题设置"`
+	ExcelReferences []excel.ExcelReferencesReq `description:"引用的Excel信息"`
 }
 
 type AddPptEnglishResp struct {

+ 6 - 4
models/ppt_v2.go

@@ -1,6 +1,7 @@
 package models
 
 import (
+	"eta/eta_api/models/data_manage/excel"
 	"eta/eta_api/models/ppt_english"
 	"time"
 
@@ -124,10 +125,11 @@ type AddPptV2Req struct {
 		BackIndex    int    `description:"背景图片下标"`
 		TemplateType int    `description:"模版id"`
 	} `description:"首页"`
-	Content      string `description:"ppt的json数据"`
-	GroupId      int64  `description:"目录id"`
-	CoverContent string `description:"封面图内容-JSON数据"`
-	TitleSetting string `description:"PPT标题设置"`
+	Content         string                     `description:"ppt的json数据"`
+	GroupId         int64                      `description:"目录id"`
+	CoverContent    string                     `description:"封面图内容-JSON数据"`
+	TitleSetting    string                     `description:"PPT标题设置"`
+	ExcelReferences []excel.ExcelReferencesReq `description:"引用的Excel信息"`
 }
 
 type AddPptResp struct {

+ 9 - 0
routers/commentsRouter.go

@@ -1375,6 +1375,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/excel:ExcelInfoController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/excel:ExcelInfoController"],
+        beego.ControllerComments{
+            Method: "SaveExcelReference",
+            Router: `/excel_info/reference/save`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/excel:ExcelInfoController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/excel:ExcelInfoController"],
         beego.ControllerComments{
             Method: "Rename",