more 5 months ago
parent
commit
919ccd08b8

+ 7 - 7
models/data_manage/excel/excel_draft.go

@@ -17,13 +17,13 @@ import (
 //		CreateTime   time.Time `description:"创建时间"`
 //	}
 type ExcelDraft struct {
-	ExcelDraftId int       `gorm:"column:excel_draft_id;primaryKey" json:"excel_draft_id" description:"excel表格草稿记录id"`
-	ExcelId      int       `gorm:"column:excel_id" json:"excel_id" description:"excel表格id"`
-	Name         string    `gorm:"column:name" json:"name" description:"excel表格名称"`
-	Content      string    `gorm:"column:content" json:"content" description:"excel数据"`
-	OpUserId     int       `gorm:"column:op_user_id" json:"op_user_id" description:"最近一次编辑操作的用户id"`
-	OpUserName   string    `gorm:"column:op_user_name" json:"op_user_name" description:"最近一次编辑的用户名称(冗余字段,避免查表)"`
-	CreateTime   time.Time `gorm:"column:create_time" json:"create_time" description:"创建时间"`
+	ExcelDraftId int       `gorm:"column:excel_draft_id;primaryKey" description:"excel表格草稿记录id"`
+	ExcelId      int       `gorm:"column:excel_id" description:"excel表格id"`
+	Name         string    `gorm:"column:name" description:"excel表格名称"`
+	Content      string    `gorm:"column:content" description:"excel数据"`
+	OpUserId     int       `gorm:"column:op_user_id" description:"最近一次编辑操作的用户id"`
+	OpUserName   string    `gorm:"column:op_user_name" description:"最近一次编辑的用户名称(冗余字段,避免查表)"`
+	CreateTime   time.Time `gorm:"column:create_time" description:"创建时间"`
 }
 
 // AddExcelDraft 添加一个新的excel表格草稿

+ 14 - 14
models/data_manage/excel/excel_edb_mapping.go

@@ -18,12 +18,12 @@ import (
 //
 // ExcelEdbMapping excel与指标的关系表
 type ExcelEdbMapping struct {
-	ExcelEdbMappingId int       `gorm:"column:excel_edb_mapping_id;primaryKey" json:"excel_edb_mapping_id"`
-	ExcelInfoId       int       `gorm:"column:excel_info_id" json:"excel_info_id" description:"excel的id"`
-	Source            int       `gorm:"column:source" json:"source" description:"表格来源,1:excel插件的表格,2:自定义表格,3:混合表格,4:自定义分析,默认:1"`
-	EdbInfoId         int       `gorm:"column:edb_info_id" json:"edb_info_id" description:"计算指标id"`
-	CreateTime        time.Time `gorm:"column:create_time" json:"create_time" description:"创建时间"`
-	ModifyTime        time.Time `gorm:"column:modify_time" json:"modify_time" description:"修改时间"`
+	ExcelEdbMappingId int       `gorm:"column:excel_edb_mapping_id;primaryKey"`
+	ExcelInfoId       int       `gorm:"column:excel_info_id" description:"excel的id"`
+	Source            int       `gorm:"column:source" description:"表格来源,1:excel插件的表格,2:自定义表格,3:混合表格,4:自定义分析,默认:1"`
+	EdbInfoId         int       `gorm:"column:edb_info_id" description:"计算指标id"`
+	CreateTime        time.Time `gorm:"column:create_time" description:"创建时间"`
+	ModifyTime        time.Time `gorm:"column:modify_time" description:"修改时间"`
 }
 
 // AddExcelEdbMappingMulti 批量添加excel与指标的关系
@@ -106,15 +106,15 @@ func GetExcelEdbMappingByExcelInfoId(excelInfoId int) (items []*ExcelEdbMapping,
 //		DataSequenceStr  string `description:"数据序列公式"`
 //	}
 type ExcelEdbMappingItem struct {
-	EdbInfoId        int    `gorm:"column:edb_info_id" json:"edb_info_id" description:"指标id"`
-	UniqueCode       string `gorm:"column:unique_code" json:"unique_code" description:"唯一编码"`
-	EdbName          string `gorm:"column:edb_name" json:"edb_name" description:"指标名称"`
-	ClassifyId       int    `gorm:"column:classify_id" json:"classify_id" description:"分类id"`
-	Frequency        string `gorm:"column:frequency" json:"frequency" description:"频度"`
-	Unit             string `gorm:"column:unit" json:"unit" description:"单位"`
+	EdbInfoId        int    `gorm:"column:edb_info_id" description:"指标id"`
+	UniqueCode       string `gorm:"column:unique_code" description:"唯一编码"`
+	EdbName          string `gorm:"column:edb_name" description:"指标名称"`
+	ClassifyId       int    `gorm:"column:classify_id" description:"分类id"`
+	Frequency        string `gorm:"column:frequency" description:"频度"`
+	Unit             string `gorm:"column:unit" description:"单位"`
 	CalculateFormula string `gorm:"column:calculate_formula" json:"-"` // 隐藏该字段
-	DateSequenceStr  string `gorm:"column:date_sequence_str" json:"date_sequence_str" description:"日期序列公式"`
-	DataSequenceStr  string `gorm:"column:data_sequence_str" json:"data_sequence_str" description:"数据序列公式"`
+	DateSequenceStr  string `gorm:"column:date_sequence_str" description:"日期序列公式"`
+	DataSequenceStr  string `gorm:"column:data_sequence_str" description:"数据序列公式"`
 }
 
 // CalculateFormula 计算公式

+ 89 - 89
models/data_manage/excel/excel_info.go

@@ -33,27 +33,27 @@ import (
 //		VersionName        string    `description:"静态表版本名称"`
 //	}
 type ExcelInfo struct {
-	ExcelInfoId        int       `gorm:"column:excel_info_id;primaryKey" json:"excel_info_id" orm:"column(excel_info_id);pk"`
-	Source             int       `gorm:"column:source" json:"source" description:"表格来源,1:excel插件的表格,2:自定义表格,3:混合表格,4:自定义分析,默认:1"`
-	ExcelType          int       `gorm:"column:excel_type" json:"excel_type" description:"表格类型,1:指标列,2:日期列,默认:1"`
-	ExcelName          string    `gorm:"column:excel_name" json:"excel_name" description:"表格名称"`
-	UniqueCode         string    `gorm:"column:unique_code" json:"unique_code" description:"表格唯一编码"`
-	ExcelClassifyId    int       `gorm:"column:excel_classify_id" json:"excel_classify_id" description:"表格分类id"`
-	SysUserId          int       `gorm:"column:sys_user_id" json:"sys_user_id" description:"操作人id"`
-	SysUserRealName    string    `gorm:"column:sys_user_real_name" json:"sys_user_real_name" description:"操作人真实姓名"`
-	Content            string    `gorm:"column:content" json:"content" description:"表格内容"`
-	ExcelImage         string    `gorm:"column:excel_image" json:"excel_image" description:"表格图片"`
-	FileUrl            string    `gorm:"column:file_url" json:"file_url" description:"表格下载地址"`
-	Sort               int       `gorm:"column:sort" json:"sort" description:"排序字段,数字越小越排前面"`
-	IsDelete           int       `gorm:"column:is_delete" json:"is_delete" description:"是否删除,0:未删除,1:已删除"`
-	ModifyTime         time.Time `gorm:"column:modify_time" json:"modify_time" description:"最近修改日期"`
-	CreateTime         time.Time `gorm:"column:create_time" json:"create_time" description:"创建日期"`
-	IsJoinPermission   int       `gorm:"column:is_join_permission" json:"is_join_permission" description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
-	BalanceType        int       `gorm:"column:balance_type" json:"balance_type" description:"平衡表类型:0 动态表,1静态表"`
-	UpdateUserId       int       `gorm:"column:update_user_id" json:"update_user_id" description:"更新人id"`
-	UpdateUserRealName string    `gorm:"column:update_user_real_name" json:"update_user_real_name" description:"更新人真实姓名"`
-	RelExcelInfoId     int       `gorm:"column:rel_excel_info_id" json:"rel_excel_info_id" description:"平衡表里静态表关联的动态表excel id"`
-	VersionName        string    `gorm:"column:version_name" json:"version_name" description:"静态表版本名称"`
+	ExcelInfoId        int       `gorm:"column:excel_info_id;primaryKey" orm:"column(excel_info_id);pk"`
+	Source             int       `gorm:"column:source" description:"表格来源,1:excel插件的表格,2:自定义表格,3:混合表格,4:自定义分析,默认:1"`
+	ExcelType          int       `gorm:"column:excel_type" description:"表格类型,1:指标列,2:日期列,默认:1"`
+	ExcelName          string    `gorm:"column:excel_name" description:"表格名称"`
+	UniqueCode         string    `gorm:"column:unique_code" description:"表格唯一编码"`
+	ExcelClassifyId    int       `gorm:"column:excel_classify_id" description:"表格分类id"`
+	SysUserId          int       `gorm:"column:sys_user_id" description:"操作人id"`
+	SysUserRealName    string    `gorm:"column:sys_user_real_name" description:"操作人真实姓名"`
+	Content            string    `gorm:"column:content" description:"表格内容"`
+	ExcelImage         string    `gorm:"column:excel_image" description:"表格图片"`
+	FileUrl            string    `gorm:"column:file_url" description:"表格下载地址"`
+	Sort               int       `gorm:"column:sort" description:"排序字段,数字越小越排前面"`
+	IsDelete           int       `gorm:"column:is_delete" description:"是否删除,0:未删除,1:已删除"`
+	ModifyTime         time.Time `gorm:"column:modify_time" description:"最近修改日期"`
+	CreateTime         time.Time `gorm:"column:create_time" description:"创建日期"`
+	IsJoinPermission   int       `gorm:"column:is_join_permission" description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
+	BalanceType        int       `gorm:"column:balance_type" description:"平衡表类型:0 动态表,1静态表"`
+	UpdateUserId       int       `gorm:"column:update_user_id" description:"更新人id"`
+	UpdateUserRealName string    `gorm:"column:update_user_real_name" description:"更新人真实姓名"`
+	RelExcelInfoId     int       `gorm:"column:rel_excel_info_id" description:"平衡表里静态表关联的动态表excel id"`
+	VersionName        string    `gorm:"column:version_name" description:"静态表版本名称"`
 }
 
 // Update 更新 excel表格基础信息
@@ -81,21 +81,21 @@ func (excelInfo *ExcelInfo) Update(cols []string) (err error) {
 //		HaveOperaAuth    bool      `description:"是否有数据权限"`
 //	}
 type MyExcelInfoList struct {
-	ExcelInfoId      int       `gorm:"column:excel_info_id;primaryKey" json:"excel_info_id" orm:"column(excel_info_id);pk"`
-	Source           int       `gorm:"column:source" json:"source" description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
-	ExcelType        int       `gorm:"column:excel_type" json:"excel_type" description:"表格类型,1:指标列,2:日期列,默认:1"`
-	ExcelName        string    `gorm:"column:excel_name" json:"excel_name" description:"表格名称"`
-	UniqueCode       string    `gorm:"column:unique_code" json:"unique_code" description:"表格唯一编码"`
-	ExcelClassifyId  int       `gorm:"column:excel_classify_id" json:"excel_classify_id" description:"表格分类id"`
-	SysUserId        int       `gorm:"column:sys_user_id" json:"sys_user_id" description:"操作人id"`
-	SysUserRealName  string    `gorm:"column:sys_user_real_name" json:"sys_user_real_name" description:"操作人真实姓名"`
-	ExcelImage       string    `gorm:"column:excel_image" json:"excel_image" description:"表格图片"`
-	FileUrl          string    `gorm:"column:file_url" json:"file_url" description:"表格下载地址"`
-	Sort             int       `gorm:"column:sort" json:"sort" description:"排序字段,数字越小越排前面"`
-	ModifyTime       time.Time `gorm:"column:modify_time" json:"modify_time" description:"最近修改日期"`
-	CreateTime       time.Time `gorm:"column:create_time" json:"create_time" description:"创建日期"`
-	IsJoinPermission int       `gorm:"column:is_join_permission" json:"is_join_permission" description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
-	HaveOperaAuth    bool      `gorm:"column:have_opera_auth" json:"have_opera_auth" description:"是否有数据权限"`
+	ExcelInfoId      int       `gorm:"column:excel_info_id;primaryKey" orm:"column(excel_info_id);pk"`
+	Source           int       `gorm:"column:source" description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
+	ExcelType        int       `gorm:"column:excel_type" description:"表格类型,1:指标列,2:日期列,默认:1"`
+	ExcelName        string    `gorm:"column:excel_name" description:"表格名称"`
+	UniqueCode       string    `gorm:"column:unique_code" description:"表格唯一编码"`
+	ExcelClassifyId  int       `gorm:"column:excel_classify_id" description:"表格分类id"`
+	SysUserId        int       `gorm:"column:sys_user_id" description:"操作人id"`
+	SysUserRealName  string    `gorm:"column:sys_user_real_name" description:"操作人真实姓名"`
+	ExcelImage       string    `gorm:"column:excel_image" description:"表格图片"`
+	FileUrl          string    `gorm:"column:file_url" description:"表格下载地址"`
+	Sort             int       `gorm:"column:sort" description:"排序字段,数字越小越排前面"`
+	ModifyTime       time.Time `gorm:"column:modify_time" description:"最近修改日期"`
+	CreateTime       time.Time `gorm:"column:create_time" description:"创建日期"`
+	IsJoinPermission int       `gorm:"column:is_join_permission" description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
+	HaveOperaAuth    bool      `gorm:"column:have_opera_auth" description:"是否有数据权限"`
 }
 
 // AddExcelInfo 新增表格
@@ -586,35 +586,35 @@ func UpdateExcelInfoSortByClassifyId(classifyId, nowSort, prevExcelInfoId int, u
 //	}
 
 type ExcelInfoView struct {
-	ExcelInfoId       int                  `gorm:"column:excel_info_id;primaryKey" json:"excel_info_id" orm:"column(excel_info_id);pk"`
-	ExcelName         string               `gorm:"column:excel_name" json:"excel_name" description:"来源名称"`
-	ExcelClassifyId   int                  `gorm:"column:excel_classify_id" json:"excel_classify_id" description:"表格分类id"`
-	ExcelClassifyName string               `gorm:"column:excel_classify_name" json:"excel_classify_name" description:"表格名称"`
-	SysUserId         int                  `gorm:"column:sys_user_id" json:"sys_user_id"`
-	SysUserRealName   string               `gorm:"column:sys_user_real_name" json:"sys_user_real_name"`
-	UniqueCode        string               `gorm:"column:unique_code" json:"unique_code" description:"表格唯一编码"`
-	CreateTime        time.Time            `gorm:"column:create_time" json:"create_time"`
-	ModifyTime        time.Time            `gorm:"column:modify_time" json:"modify_time"`
-	DateType          int                  `gorm:"column:date_type" json:"date_type" description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
-	StartDate         string               `gorm:"column:start_date" json:"start_date" description:"自定义开始日期"`
-	EndDate           string               `gorm:"column:end_date" json:"end_date" description:"自定义结束日期"`
-	IsSetName         int                  `gorm:"column:is_set_name" json:"is_set_name" description:"设置名称"`
-	EdbInfoIds        string               `gorm:"column:edb_info_ids" json:"edb_info_ids" description:"指标id"`
-	ExcelType         int                  `gorm:"column:excel_type" json:"excel_type" description:"生成样式:1:曲线图,2:季节性图"`
-	Calendar          string               `gorm:"column:calendar" json:"calendar" description:"公历/农历"`
-	SeasonStartDate   string               `gorm:"column:season_start_date" json:"season_start_date" description:"季节性图开始日期"`
-	SeasonEndDate     string               `gorm:"column:season_end_date" json:"season_end_date" description:"季节性图结束日期"`
-	ExcelImage        string               `gorm:"column:excel_image" json:"excel_image" description:"表格图片"`
-	Sort              int                  `gorm:"column:sort" json:"sort" description:"排序字段,数字越小越排前面"`
-	IsAdd             bool                 `gorm:"column:is_add" json:"is_add" description:"true:已加入我的图库,false:未加入我的图库"`
-	MyExcelId         int                  `gorm:"column:my_excel_id" json:"my_excel_id"`
-	MyExcelClassifyId string               `gorm:"column:my_excel_classify_id" json:"my_excel_classify_id" description:"我的表格分类,多个用逗号隔开"`
-	ExcelClassify     []*ExcelClassifyView `json:"excel_classify"`
-	EdbEndDate        string               `gorm:"column:edb_end_date" json:"edb_end_date" description:"指标最新更新日期"`
-	LeftMin           string               `gorm:"column:left_min" json:"left_min" description:"表格左侧最小值"`
-	LeftMax           string               `gorm:"column:left_max" json:"left_max" description:"表格左侧最大值"`
-	RightMin          string               `gorm:"column:right_min" json:"right_min" description:"表格右侧最小值"`
-	RightMax          string               `gorm:"column:right_max" json:"right_max" description:"表格右侧最大值"`
+	ExcelInfoId       int       `gorm:"column:excel_info_id;primaryKey" orm:"column(excel_info_id);pk"`
+	ExcelName         string    `gorm:"column:excel_name" description:"来源名称"`
+	ExcelClassifyId   int       `gorm:"column:excel_classify_id" description:"表格分类id"`
+	ExcelClassifyName string    `gorm:"column:excel_classify_name" description:"表格名称"`
+	SysUserId         int       `gorm:"column:sys_user_id"`
+	SysUserRealName   string    `gorm:"column:sys_user_real_name"`
+	UniqueCode        string    `gorm:"column:unique_code" description:"表格唯一编码"`
+	CreateTime        time.Time `gorm:"column:create_time"`
+	ModifyTime        time.Time `gorm:"column:modify_time"`
+	DateType          int       `gorm:"column:date_type"  description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
+	StartDate         string    `gorm:"column:start_date"  description:"自定义开始日期"`
+	EndDate           string    `gorm:"column:end_date"  description:"自定义结束日期"`
+	IsSetName         int       `gorm:"column:is_set_name"  description:"设置名称"`
+	EdbInfoIds        string    `gorm:"column:edb_info_ids"  description:"指标id"`
+	ExcelType         int       `gorm:"column:excel_type"  description:"生成样式:1:曲线图,2:季节性图"`
+	Calendar          string    `gorm:"column:calendar"  description:"公历/农历"`
+	SeasonStartDate   string    `gorm:"column:season_start_date" description:"季节性图开始日期"`
+	SeasonEndDate     string    `gorm:"column:season_end_date" description:"季节性图结束日期"`
+	ExcelImage        string    `gorm:"column:excel_image" description:"表格图片"`
+	Sort              int       `gorm:"column:sort" description:"排序字段,数字越小越排前面"`
+	IsAdd             bool      `gorm:"column:is_add" description:"true:已加入我的图库,false:未加入我的图库"`
+	MyExcelId         int       `gorm:"column:my_excel_id"`
+	MyExcelClassifyId string    `gorm:"column:my_excel_classify_id" description:"我的表格分类,多个用逗号隔开"`
+	ExcelClassify     []*ExcelClassifyView
+	EdbEndDate        string `gorm:"column:edb_end_date" description:"指标最新更新日期"`
+	LeftMin           string `gorm:"column:left_min" description:"表格左侧最小值"`
+	LeftMax           string `gorm:"column:left_max" description:"表格左侧最大值"`
+	RightMin          string `gorm:"column:right_min" description:"表格右侧最小值"`
+	RightMax          string `gorm:"column:right_max" description:"表格右侧最大值"`
 }
 
 // GetExcelInfoByClassifyIdAndName 根据分类id和表格名获取表格信息
@@ -1061,10 +1061,10 @@ func SaveExcelInfoAndSheet(excelInfo *ExcelInfo, updateExcelInfoParam []string,
 //
 // BatchRefreshExcelReq 批量刷新表格请求
 type BatchRefreshExcelReq struct {
-	ExcelCodes      []string `gorm:"column:excel_codes" json:"excel_codes" description:"表格编码"`
-	ReportId        int      `gorm:"column:report_id" json:"report_id" description:"报告ID"`
-	ReportChapterId int      `gorm:"column:report_chapter_id" json:"report_chapter_id" description:"报告章节ID"`
-	Source          string   `gorm:"column:source" json:"source" description:"来源,枚举值:report、english_report、smart_report"`
+	ExcelCodes      []string `gorm:"column:excel_codes" description:"表格编码"`
+	ReportId        int      `gorm:"column:report_id" description:"报告ID"`
+	ReportChapterId int      `gorm:"column:report_chapter_id" description:"报告章节ID"`
+	Source          string   `gorm:"column:source" description:"来源,枚举值:report、english_report、smart_report"`
 }
 
 // GetExcelMaxSortByClassifyId 获取当前分类下,且排序数最大的excel
@@ -1253,24 +1253,24 @@ func ModifyExcelInfoUserIdByOldUserId(oldUserIdList []int, userId int, userName
 //
 // ExcelInfoDetail excel表格详情(前端使用)
 type ExcelInfoDetail struct {
-	ExcelInfoId      int         `gorm:"column:excel_info_id;primaryKey" json:"excel_info_id" orm:"column(excel_info_id);pk"`
-	Source           int         `gorm:"column:source" json:"source" description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
-	ExcelType        int         `gorm:"column:excel_type" json:"excel_type" description:"表格类型,1:指标列,2:日期列,默认:1"`
-	ExcelName        string      `gorm:"column:excel_name" json:"excel_name" description:"表格名称"`
-	UniqueCode       string      `gorm:"column:unique_code" json:"unique_code" description:"表格唯一编码"`
-	ExcelClassifyId  int         `gorm:"column:excel_classify_id" json:"excel_classify_id" description:"表格分类id"`
-	SysUserId        int         `gorm:"column:sys_user_id" json:"sys_user_id" description:"操作人id"`
-	SysUserRealName  string      `gorm:"column:sys_user_real_name" json:"sys_user_real_name" description:"操作人真实姓名"`
-	Content          string      `gorm:"column:content" json:"content" description:"表格内容"`
-	ExcelImage       string      `gorm:"column:excel_image" json:"excel_image" description:"表格图片"`
-	FileUrl          string      `gorm:"column:file_url" json:"file_url" description:"表格下载地址"`
-	Sort             int         `gorm:"column:sort" json:"sort" description:"排序字段,数字越小越排前面"`
-	IsDelete         int         `gorm:"column:is_delete" json:"is_delete" description:"是否删除,0:未删除,1:已删除"`
-	ModifyTime       time.Time   `gorm:"column:modify_time" json:"modify_time" description:"最近修改日期"`
-	CreateTime       time.Time   `gorm:"column:create_time" json:"create_time" description:"创建日期"`
-	TableData        interface{} `gorm:"column:table_data" json:"table_data" description:"表格内容"`
-	CanEdit          bool        `gorm:"column:can_edit" json:"can_edit" description:"是否可编辑"`
-	Editor           string      `gorm:"column:editor" json:"editor" description:"编辑人"`
-	IsJoinPermission int         `gorm:"column:is_join_permission" json:"is_join_permission" description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
-	HaveOperaAuth    bool        `gorm:"column:have_opera_auth" json:"have_opera_auth" description:"是否有数据权限"`
+	ExcelInfoId      int         `gorm:"column:excel_info_id;primaryKey" orm:"column(excel_info_id);pk"`
+	Source           int         `gorm:"column:source" description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
+	ExcelType        int         `gorm:"column:excel_type" description:"表格类型,1:指标列,2:日期列,默认:1"`
+	ExcelName        string      `gorm:"column:excel_name" description:"表格名称"`
+	UniqueCode       string      `gorm:"column:unique_code" description:"表格唯一编码"`
+	ExcelClassifyId  int         `gorm:"column:excel_classify_id" description:"表格分类id"`
+	SysUserId        int         `gorm:"column:sys_user_id" description:"操作人id"`
+	SysUserRealName  string      `gorm:"column:sys_user_real_name" description:"操作人真实姓名"`
+	Content          string      `gorm:"column:content" description:"表格内容"`
+	ExcelImage       string      `gorm:"column:excel_image" description:"表格图片"`
+	FileUrl          string      `gorm:"column:file_url" description:"表格下载地址"`
+	Sort             int         `gorm:"column:sort" description:"排序字段,数字越小越排前面"`
+	IsDelete         int         `gorm:"column:is_delete" description:"是否删除,0:未删除,1:已删除"`
+	ModifyTime       time.Time   `gorm:"column:modify_time" description:"最近修改日期"`
+	CreateTime       time.Time   `gorm:"column:create_time" description:"创建日期"`
+	TableData        interface{} `gorm:"column:table_data" description:"表格内容"`
+	CanEdit          bool        `gorm:"column:can_edit" description:"是否可编辑"`
+	Editor           string      `gorm:"column:editor" description:"编辑人"`
+	IsJoinPermission int         `gorm:"column:is_join_permission" description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
+	HaveOperaAuth    bool        `gorm:"column:have_opera_auth" description:"是否有数据权限"`
 }

+ 26 - 26
models/data_manage/excel/excel_sheet.go

@@ -22,16 +22,16 @@ import (
 //
 // ExcelSheet excel表格详情表
 type ExcelSheet struct {
-	ExcelSheetId int       `gorm:"column:excel_sheet_id;primaryKey" json:"excel_sheet_id" orm:"column(excel_sheet_id);pk"`
-	ExcelInfoId  int       `gorm:"column:excel_info_id" json:"excel_info_id" description:"excel的id"`
-	SheetName    string    `gorm:"column:sheet_name" json:"sheet_name" description:"sheet名称"`
-	PageNum      int       `gorm:"column:page_num" json:"page_num" description:"总页码数"`
-	Index        string    `gorm:"column:index" json:"index" description:"excel数据中的index"`
-	Sort         int       `gorm:"column:sort" json:"sort" description:"排序"`
-	Config       string    `gorm:"column:config" json:"config" description:"配置信息"`
-	CalcChain    string    `gorm:"column:calc_chain" json:"calc_chain" description:"计算公式"`
-	ModifyTime   time.Time `gorm:"column:modify_time" json:"modify_time" description:"最近修改日期"`
-	CreateTime   time.Time `gorm:"column:create_time" json:"create_time" description:"创建日期"`
+	ExcelSheetId int       `gorm:"column:excel_sheet_id;primaryKey" orm:"column(excel_sheet_id);pk"`
+	ExcelInfoId  int       `gorm:"column:excel_info_id" description:"excel的id"`
+	SheetName    string    `gorm:"column:sheet_name" description:"sheet名称"`
+	PageNum      int       `gorm:"column:page_num" description:"总页码数"`
+	Index        string    `gorm:"column:index" description:"excel数据中的index"`
+	Sort         int       `gorm:"column:sort" description:"排序"`
+	Config       string    `gorm:"column:config" description:"配置信息"`
+	CalcChain    string    `gorm:"column:calc_chain" description:"计算公式"`
+	ModifyTime   time.Time `gorm:"column:modify_time" description:"最近修改日期"`
+	CreateTime   time.Time `gorm:"column:create_time" description:"创建日期"`
 }
 
 // Update 更新 excel表格的sheet基础信息
@@ -109,15 +109,15 @@ FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
 type SheetItem struct {
 	ExcelSheetId int             `gorm:"column:excel_sheet_id;primaryKey" json:"-" orm:"column(excel_sheet_id);pk"`
 	ExcelInfoId  int             `gorm:"column:excel_info_id" description:"excel的id" json:"-"`
-	SheetName    string          `gorm:"column:sheet_name" description:"sheet名称" json:"sheet_name"`
-	PageNum      int             `gorm:"column:page_num" description:"数据总页码数" json:"page_num"`
-	Index        string          `gorm:"column:index" description:"excel数据中的index" json:"index"`
-	Sort         int             `gorm:"column:sort" description:"排序" json:"sort"`
-	Config       string          `gorm:"column:config" description:"sheet配置" json:"config"`
-	CalcChain    string          `gorm:"column:calc_chain" description:"计算公式" json:"calc_chain"`
+	SheetName    string          `gorm:"column:sheet_name" description:"sheet名称" `
+	PageNum      int             `gorm:"column:page_num" description:"数据总页码数" `
+	Index        string          `gorm:"column:index" description:"excel数据中的index" `
+	Sort         int             `gorm:"column:sort" description:"排序" `
+	Config       string          `gorm:"column:config" description:"sheet配置" `
+	CalcChain    string          `gorm:"column:calc_chain" description:"计算公式"`
 	ModifyTime   time.Time       `gorm:"column:modify_time" description:"最近修改日期" json:"-"`
-	CreateTime   time.Time       `gorm:"column:create_time" description:"创建日期" json:"create_time"`
-	Data         *ExcelSheetData `description:"excel的数据" json:"data"`
+	CreateTime   time.Time       `gorm:"column:create_time" description:"创建日期"`
+	Data         *ExcelSheetData `description:"excel的数据"`
 }
 
 // GetAllSheetItemList 根据excel_id获取所有的sheet详情
@@ -155,12 +155,12 @@ FROM excel_sheet WHERE 1=1 AND excel_info_id = ? `
 
 // AddExcelSheetParams excel表格详情表
 type AddExcelSheetParams struct {
-	ExcelSheetId int               `gorm:"column:excel_sheet_id;primaryKey" json:"excel_sheet_id" orm:"column(excel_sheet_id);pk"`
-	ExcelInfoId  int               `gorm:"column:excel_info_id" description:"excel的id" json:"excel_info_id"`
-	SheetName    string            `gorm:"column:sheet_name" description:"sheet名称" json:"sheet_name"`
-	Index        string            `gorm:"column:index" description:"excel数据中的index" json:"index"`
-	Sort         int               `gorm:"column:sort" description:"排序" json:"sort"`
-	Config       string            `gorm:"column:config" description:"配置信息" json:"config"`
-	CalcChain    string            `gorm:"column:calc_chain" description:"计算公式" json:"calc_chain"`
-	DataList     []*ExcelSheetData `gorm:"column:data_list" description:"excel的数据" json:"data_list"`
+	ExcelSheetId int               `gorm:"column:excel_sheet_id;primaryKey" orm:"column(excel_sheet_id);pk"`
+	ExcelInfoId  int               `gorm:"column:excel_info_id" description:"excel的id" `
+	SheetName    string            `gorm:"column:sheet_name" description:"sheet名称" `
+	Index        string            `gorm:"column:index" description:"excel数据中的index" `
+	Sort         int               `gorm:"column:sort" description:"排序" `
+	Config       string            `gorm:"column:config" description:"配置信息" `
+	CalcChain    string            `gorm:"column:calc_chain" description:"计算公式" `
+	DataList     []*ExcelSheetData `gorm:"column:data_list" description:"excel的数据" `
 }

+ 7 - 7
models/data_manage/excel/excel_sheet_data.go

@@ -20,13 +20,13 @@ import (
 //
 // ExcelSheetData excel表格详情表
 type ExcelSheetData struct {
-	ExcelDataId  int       `gorm:"column:excel_data_id;primaryKey" json:"excel_data_id" orm:"column(excel_data_id);pk"`
-	ExcelInfoId  int       `gorm:"column:excel_info_id" json:"excel_info_id" description:"数据归属的excel_info的id"`
-	ExcelSheetId int       `gorm:"column:excel_sheet_id" json:"excel_sheet_id" description:"数据归属sheet"`
-	Sort         int       `gorm:"column:sort" json:"sort" description:"数据排序"`
-	Data         string    `gorm:"column:data" json:"data" description:"数据,分页存储"`
-	ModifyTime   time.Time `gorm:"column:modify_time" json:"modify_time" description:"最近修改日期"`
-	CreateTime   time.Time `gorm:"column:create_time" json:"create_time" description:"创建日期"`
+	ExcelDataId  int       `gorm:"column:excel_data_id;primaryKey" orm:"column(excel_data_id);pk"`
+	ExcelInfoId  int       `gorm:"column:excel_info_id" description:"数据归属的excel_info的id"`
+	ExcelSheetId int       `gorm:"column:excel_sheet_id" description:"数据归属sheet"`
+	Sort         int       `gorm:"column:sort" description:"数据排序"`
+	Data         string    `gorm:"column:data" description:"数据,分页存储"`
+	ModifyTime   time.Time `gorm:"column:modify_time" description:"最近修改日期"`
+	CreateTime   time.Time `gorm:"column:create_time" description:"创建日期"`
 }
 
 // Update 更新 excel表格的sheet基础信息

+ 337 - 87
models/excel_info.go

@@ -1,125 +1,164 @@
 package models
 
 import (
+	"eta_gn/eta_chart_lib/global"
 	"eta_gn/eta_chart_lib/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
 
+// ExcelInfo excel表格详情表
+// type ExcelInfo struct {
+// 	ExcelInfoId     int       `orm:"column(excel_info_id);pk"`
+// 	Source          int       `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
+// 	ExcelType       int       `description:"表格类型,1:指标列,2:日期列,默认:1"`
+// 	ExcelName       string    `description:"表格名称"`
+// 	UniqueCode      string    `description:"表格唯一编码"`
+// 	ExcelClassifyId int       `description:"表格分类id"`
+// 	SysUserId       int       `description:"操作人id"`
+// 	SysUserRealName string    `description:"操作人真实姓名"`
+// 	Content         string    `description:"表格内容"`
+// 	ExcelImage      string    `description:"表格图片"`
+// 	FileUrl         string    `description:"表格下载地址"`
+// 	Sort            int       `description:"排序字段,数字越小越排前面"`
+// 	IsDelete        int       `description:"是否删除,0:未删除,1:已删除"`
+// 	ModifyTime      time.Time `description:"最近修改日期"`
+// 	CreateTime      time.Time `description:"创建日期"`
+// }
+
 // ExcelInfo excel表格详情表
 type ExcelInfo struct {
-	ExcelInfoId     int       `orm:"column(excel_info_id);pk"`
-	Source          int       `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
-	ExcelType       int       `description:"表格类型,1:指标列,2:日期列,默认:1"`
-	ExcelName       string    `description:"表格名称"`
-	UniqueCode      string    `description:"表格唯一编码"`
-	ExcelClassifyId int       `description:"表格分类id"`
-	SysUserId       int       `description:"操作人id"`
-	SysUserRealName string    `description:"操作人真实姓名"`
-	Content         string    `description:"表格内容"`
-	ExcelImage      string    `description:"表格图片"`
-	FileUrl         string    `description:"表格下载地址"`
-	Sort            int       `description:"排序字段,数字越小越排前面"`
-	IsDelete        int       `description:"是否删除,0:未删除,1:已删除"`
-	ModifyTime      time.Time `description:"最近修改日期"`
-	CreateTime      time.Time `description:"创建日期"`
+	ExcelInfoId     int       `gorm:"column:excel_info_id;primaryKey" description:"表格ID"`
+	Source          int       `gorm:"column:source" description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
+	ExcelType       int       `gorm:"column:excel_type" description:"表格类型,1:指标列,2:日期列,默认:1"`
+	ExcelName       string    `gorm:"column:excel_name" description:"表格名称"`
+	UniqueCode      string    `gorm:"column:unique_code" description:"表格唯一编码"`
+	ExcelClassifyId int       `gorm:"column:excel_classify_id" description:"表格分类id"`
+	SysUserId       int       `gorm:"column:sys_user_id" description:"操作人id"`
+	SysUserRealName string    `gorm:"column:sys_user_real_name" description:"操作人真实姓名"`
+	Content         string    `gorm:"column:content" description:"表格内容"`
+	ExcelImage      string    `gorm:"column:excel_image" description:"表格图片"`
+	FileUrl         string    `gorm:"column:file_url" description:"表格下载地址"`
+	Sort            int       `gorm:"column:sort" description:"排序字段,数字越小越排前面"`
+	IsDelete        int       `gorm:"column:is_delete" description:"是否删除,0:未删除,1:已删除"`
+	ModifyTime      time.Time `gorm:"column:modify_time" description:"最近修改日期"`
+	CreateTime      time.Time `gorm:"column:create_time" description:"创建日期"`
+}
+
+func (e *ExcelInfo) TableName() string {
+	return "excel_info"
 }
 
 // Update 更新 excel表格基础信息
 func (excelInfo *ExcelInfo) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.Update(excelInfo, cols...)
+	o := global.DmSQL["data"]
+	err = o.Model(excelInfo).Select(cols).Updates(excelInfo).Error
 	return
 }
 
+// Update 更新 excel表格基础信息
+// func (excelInfo *ExcelInfo) Update(cols []string) (err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	_, err = o.Update(excelInfo, cols...)
+// 	return
+// }
+
+//	type MyExcelInfoList struct {
+//		ExcelInfoId     int       `orm:"column(excel_info_id);pk"`
+//		ExcelName       string    `description:"表格名称"`
+//		UniqueCode      string    `description:"表格唯一编码"`
+//		ExcelClassifyId int       `description:"表格分类id"`
+//		SysUserId       int       `description:"操作人id"`
+//		SysUserRealName string    `description:"操作人真实姓名"`
+//		ExcelImage      string    `description:"表格图片"`
+//		FileUrl         string    `description:"表格下载地址"`
+//		Sort            int       `description:"排序字段,数字越小越排前面"`
+//		ModifyTime      time.Time `description:"最近修改日期"`
+//		CreateTime      time.Time `description:"创建日期"`
+//	}
 type MyExcelInfoList struct {
-	ExcelInfoId     int       `orm:"column(excel_info_id);pk"`
-	ExcelName       string    `description:"表格名称"`
-	UniqueCode      string    `description:"表格唯一编码"`
-	ExcelClassifyId int       `description:"表格分类id"`
-	SysUserId       int       `description:"操作人id"`
-	SysUserRealName string    `description:"操作人真实姓名"`
-	ExcelImage      string    `description:"表格图片"`
-	FileUrl         string    `description:"表格下载地址"`
-	Sort            int       `description:"排序字段,数字越小越排前面"`
-	ModifyTime      time.Time `description:"最近修改日期"`
-	CreateTime      time.Time `description:"创建日期"`
+	ExcelInfoId     int       `gorm:"column:excel_info_id;primaryKey" description:"表格ID" orm:"column(excel_info_id);pk"`
+	ExcelName       string    `gorm:"column:excel_name" description:"表格名称"`
+	UniqueCode      string    `gorm:"column:unique_code" description:"表格唯一编码"`
+	ExcelClassifyId int       `gorm:"column:excel_classify_id" description:"表格分类id"`
+	SysUserId       int       `gorm:"column:sys_user_id" description:"操作人id"`
+	SysUserRealName string    `gorm:"column:sys_user_real_name" description:"操作人真实姓名"`
+	ExcelImage      string    `gorm:"column:excel_image" description:"表格图片"`
+	FileUrl         string    `gorm:"column:file_url" description:"表格下载地址"`
+	Sort            int       `gorm:"column:sort" description:"排序字段,数字越小越排前面"`
+	ModifyTime      time.Time `gorm:"column:modify_time" description:"最近修改日期"`
+	CreateTime      time.Time `gorm:"column:create_time" description:"创建日期"`
 }
 
 // AddExcelInfo 新增表格
 func AddExcelInfo(excelInfo *ExcelInfo) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	// 表格信息入库
-	lastId, err := o.Insert(excelInfo)
-	if err != nil {
-		return
-	}
-	excelInfo.ExcelInfoId = int(lastId)
+	err = o.Create(excelInfo).Error
 	return
 }
 
 // EditExcelInfo 编辑表格
 func EditExcelInfo(excelInfo *ExcelInfo, updateExcelInfoParams []string) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	// ETA表格信息变更
-	_, err = o.Update(excelInfo, updateExcelInfoParams...)
+	err = o.Model(excelInfo).Select(updateExcelInfoParams).Updates(excelInfo).Error
 	return
 }
 
 // GetExcelInfoById 根据id 获取eta表格详情
 func GetExcelInfoById(excelInfoId int) (item *ExcelInfo, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
-	err = o.Raw(sql, excelInfoId).QueryRow(&item)
+	err = o.Raw(sql, excelInfoId).First(&item).Error
 	return
 }
 
 func GetExcelInfoViewById(excelInfoId int) (item *ExcelInfoView, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
-	err = o.Raw(sql, excelInfoId).QueryRow(&item)
+	err = o.Raw(sql, excelInfoId).First(&item).Error
 	return
 }
 
 func GetExcelInfoCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
 	if condition != "" {
 		sql += condition
 	}
-	err = o.Raw(sql, pars).QueryRow(&count)
+	err = o.Raw(sql, pars).Scan(&count).Error
 	return
 }
 
 func GetExcelInfoByCondition(condition string, pars []interface{}) (item *ExcelInfo, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
 	if condition != "" {
 		sql += condition
 	}
-	err = o.Raw(sql, pars).QueryRow(&item)
+	err = o.Raw(sql, pars).First(&item).Error
 	return
 }
 
 // GetNextExcelInfo 根据分类id获取下一个excel表格
 func GetNextExcelInfo(classifyId int) (item *ExcelInfo, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT b.* FROM excel_classify AS a
 			INNER JOIN excel_info AS b ON a.excel_classify_id=b.excel_classify_id
 			WHERE a.excel_classify_id>? AND is_delete=0
 			ORDER BY a.excel_classify_id ASC
 			LIMIT 1 `
-	err = o.Raw(sql, classifyId).QueryRow(&item)
+	err = o.Raw(sql, classifyId).First(&item).Error
 	return
 }
 
 // EditExcelInfoImage 修改excel表格的图片
 func EditExcelInfoImage(excelInfoId int, imageUrl string) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 
 	sql := ` UPDATE  excel_info SET excel_image=?, modify_time = NOW() WHERE excel_info_id = ? AND is_delete=0 `
-	_, err = o.Raw(sql, imageUrl, excelInfoId).Exec()
+	err = o.Exec(sql, imageUrl, excelInfoId).Error
 	if err != nil {
 		fmt.Println("EditExcelInfoImage Err:", err.Error())
 		return err
@@ -130,55 +169,181 @@ func EditExcelInfoImage(excelInfoId int, imageUrl string) (err error) {
 
 // GetExcelInfoByUniqueCode 根据unique_code来获取excel表格详情
 func GetExcelInfoByUniqueCode(uniqueCode string) (item *ExcelInfoView, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM excel_info WHERE unique_code=? AND is_delete=0 `
-	err = o.Raw(sql, uniqueCode).QueryRow(&item)
+	err = o.Raw(sql, uniqueCode).First(&item).Error
 	return
 }
 
 // GetFirstExcelInfoByClassifyId 获取当前分类下,且排序数相同 的排序第一条的数据
 func GetFirstExcelInfoByClassifyId(classifyId int) (item *ExcelInfo, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM excel_info WHERE excel_classify_id=? AND is_delete=0 order by sort asc,excel_info_id asc limit 1`
-	err = o.Raw(sql, classifyId).QueryRow(&item)
+	err = o.Raw(sql, classifyId).First(&item).Error
 	return
 }
 
 // UpdateExcelInfoSortByClassifyId 根据表格id更新排序
 func UpdateExcelInfoSortByClassifyId(classifyId, nowSort, prevExcelInfoId int, updateSort string) (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` update excel_info set sort = ` + updateSort + ` WHERE excel_classify_id=? and sort > ? AND is_delete=0 `
 	if prevExcelInfoId > 0 {
 		sql += ` or (excel_info_id > ` + fmt.Sprint(prevExcelInfoId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
 	}
-	_, err = o.Raw(sql, classifyId, nowSort).Exec()
+	err = o.Exec(sql, classifyId, nowSort).Error
 	return
 }
 
+// AddExcelInfo 新增表格
+// func AddExcelInfo(excelInfo *ExcelInfo) (err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	// 表格信息入库
+// 	lastId, err := o.Insert(excelInfo)
+// 	if err != nil {
+// 		return
+// 	}
+// 	excelInfo.ExcelInfoId = int(lastId)
+// 	return
+// }
+
+// // EditExcelInfo 编辑表格
+// func EditExcelInfo(excelInfo *ExcelInfo, updateExcelInfoParams []string) (err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	// ETA表格信息变更
+// 	_, err = o.Update(excelInfo, updateExcelInfoParams...)
+// 	return
+// }
+
+// // GetExcelInfoById 根据id 获取eta表格详情
+// func GetExcelInfoById(excelInfoId int) (item *ExcelInfo, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
+// 	err = o.Raw(sql, excelInfoId).QueryRow(&item)
+// 	return
+// }
+
+// func GetExcelInfoViewById(excelInfoId int) (item *ExcelInfoView, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
+// 	err = o.Raw(sql, excelInfoId).QueryRow(&item)
+// 	return
+// }
+
+// func GetExcelInfoCountByCondition(condition string, pars []interface{}) (count int, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
+// 	if condition != "" {
+// 		sql += condition
+// 	}
+// 	err = o.Raw(sql, pars).QueryRow(&count)
+// 	return
+// }
+
+// func GetExcelInfoByCondition(condition string, pars []interface{}) (item *ExcelInfo, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
+// 	if condition != "" {
+// 		sql += condition
+// 	}
+// 	err = o.Raw(sql, pars).QueryRow(&item)
+// 	return
+// }
+
+// // GetNextExcelInfo 根据分类id获取下一个excel表格
+// func GetNextExcelInfo(classifyId int) (item *ExcelInfo, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT b.* FROM excel_classify AS a
+// 			INNER JOIN excel_info AS b ON a.excel_classify_id=b.excel_classify_id
+// 			WHERE a.excel_classify_id>? AND is_delete=0
+// 			ORDER BY a.excel_classify_id ASC
+// 			LIMIT 1 `
+// 	err = o.Raw(sql, classifyId).QueryRow(&item)
+// 	return
+// }
+
+// // EditExcelInfoImage 修改excel表格的图片
+// func EditExcelInfoImage(excelInfoId int, imageUrl string) (err error) {
+// 	o := orm.NewOrmUsingDB("data")
+
+// 	sql := ` UPDATE  excel_info SET excel_image=?, modify_time = NOW() WHERE excel_info_id = ? AND is_delete=0 `
+// 	_, err = o.Raw(sql, imageUrl, excelInfoId).Exec()
+// 	if err != nil {
+// 		fmt.Println("EditExcelInfoImage Err:", err.Error())
+// 		return err
+// 	}
+
+// 	return
+// }
+
+// // GetExcelInfoByUniqueCode 根据unique_code来获取excel表格详情
+// func GetExcelInfoByUniqueCode(uniqueCode string) (item *ExcelInfoView, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT * FROM excel_info WHERE unique_code=? AND is_delete=0 `
+// 	err = o.Raw(sql, uniqueCode).QueryRow(&item)
+// 	return
+// }
+
+// // GetFirstExcelInfoByClassifyId 获取当前分类下,且排序数相同 的排序第一条的数据
+// func GetFirstExcelInfoByClassifyId(classifyId int) (item *ExcelInfo, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT * FROM excel_info WHERE excel_classify_id=? AND is_delete=0 order by sort asc,excel_info_id asc limit 1`
+// 	err = o.Raw(sql, classifyId).QueryRow(&item)
+// 	return
+// }
+
+// // UpdateExcelInfoSortByClassifyId 根据表格id更新排序
+// func UpdateExcelInfoSortByClassifyId(classifyId, nowSort, prevExcelInfoId int, updateSort string) (err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` update excel_info set sort = ` + updateSort + ` WHERE excel_classify_id=? and sort > ? AND is_delete=0 `
+// 	if prevExcelInfoId > 0 {
+// 		sql += ` or (excel_info_id > ` + fmt.Sprint(prevExcelInfoId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
+// 	}
+// 	_, err = o.Raw(sql, classifyId, nowSort).Exec()
+// 	return
+// }
+
+//	type ExcelInfoView struct {
+//		ExcelInfoId     int       `orm:"column(excel_info_id);pk"`
+//		Source          int       `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
+//		ExcelType       int       `description:"表格类型,1:指标列,2:日期列,默认:1"`
+//		ExcelName       string    `description:"表格名称"`
+//		UniqueCode      string    `description:"表格唯一编码"`
+//		ExcelClassifyId int       `description:"表格分类id"`
+//		SysUserId       int       `description:"操作人id"`
+//		SysUserRealName string    `description:"操作人真实姓名"`
+//		Content         string    `description:"表格内容"`
+//		ExcelImage      string    `description:"表格图片"`
+//		FileUrl         string    `description:"表格下载地址"`
+//		Sort            int       `description:"排序字段,数字越小越排前面"`
+//		IsDelete        int       `description:"是否删除,0:未删除,1:已删除" json:"-"`
+//		ModifyTime      time.Time `description:"最近修改日期"`
+//		CreateTime      time.Time `description:"创建日期"`
+//		SourcesFrom     string    `description:"图表来源"`
+//	}
 type ExcelInfoView struct {
-	ExcelInfoId     int       `orm:"column(excel_info_id);pk"`
-	Source          int       `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
-	ExcelType       int       `description:"表格类型,1:指标列,2:日期列,默认:1"`
-	ExcelName       string    `description:"表格名称"`
-	UniqueCode      string    `description:"表格唯一编码"`
-	ExcelClassifyId int       `description:"表格分类id"`
-	SysUserId       int       `description:"操作人id"`
-	SysUserRealName string    `description:"操作人真实姓名"`
-	Content         string    `description:"表格内容"`
-	ExcelImage      string    `description:"表格图片"`
-	FileUrl         string    `description:"表格下载地址"`
-	Sort            int       `description:"排序字段,数字越小越排前面"`
-	IsDelete        int       `description:"是否删除,0:未删除,1:已删除" json:"-"`
-	ModifyTime      time.Time `description:"最近修改日期"`
-	CreateTime      time.Time `description:"创建日期"`
-	SourcesFrom     string    `description:"图表来源"`
+	ExcelInfoId     int       `gorm:"column:excel_info_id;primaryKey" description:"表格ID" orm:"column(excel_info_id);pk"`
+	Source          int       `gorm:"column:source" description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
+	ExcelType       int       `gorm:"column:excel_type" description:"表格类型,1:指标列,2:日期列,默认:1"`
+	ExcelName       string    `gorm:"column:excel_name" description:"表格名称"`
+	UniqueCode      string    `gorm:"column:unique_code" description:"表格唯一编码"`
+	ExcelClassifyId int       `gorm:"column:excel_classify_id" description:"表格分类id"`
+	SysUserId       int       `gorm:"column:sys_user_id" description:"操作人id"`
+	SysUserRealName string    `gorm:"column:sys_user_real_name" description:"操作人真实姓名"`
+	Content         string    `gorm:"column:content" description:"表格内容"`
+	ExcelImage      string    `gorm:"column:excel_image" description:"表格图片"`
+	FileUrl         string    `gorm:"column:file_url" description:"表格下载地址"`
+	Sort            int       `gorm:"column:sort" description:"排序字段,数字越小越排前面"`
+	IsDelete        int       `gorm:"column:is_delete" description:"是否删除,0:未删除,1:已删除" json:"-"`
+	ModifyTime      time.Time `gorm:"column:modify_time" description:"最近修改日期"`
+	CreateTime      time.Time `gorm:"column:create_time" description:"创建日期"`
+	SourcesFrom     string    `gorm:"column:sources_from" description:"图表来源"`
 }
 
 // GetExcelInfoByClassifyIdAndName 根据分类id和表格名获取表格信息
 func GetExcelInfoByClassifyIdAndName(classifyId int, excelName string) (item *ExcelInfo, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM excel_info WHERE excel_classify_id = ? and excel_name=? AND is_delete=0 `
-	err = o.Raw(sql, classifyId, excelName).QueryRow(&item)
+	err = o.Raw(sql, classifyId, excelName).First(&item).Error
 	return
 }
 
@@ -188,28 +353,29 @@ func GetExcelInfoListByUniqueCodeSlice(uniqueCodeSlice []string) (total int64, i
 	if num <= 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM excel_info WHERE unique_code in ("` + utils.GetOrmInReplace(num) + `") AND is_delete=0 `
-	total, err = o.Raw(sql, uniqueCodeSlice).QueryRows(&items)
+	err = o.Raw(sql, uniqueCodeSlice).Scan(&items).Error
+	total = int64(len(items))
 	return
 }
 
 // GetExcelListByCondition 获取excel表格列表数据
 func GetExcelListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*MyExcelInfoList, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
 	if condition != "" {
 		sql += condition
 	}
 	//sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
 	sql += " ORDER BY create_time DESC LIMIT ?,? "
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
+	err = o.Raw(sql, pars, startSize, pageSize).Scan(&item).Error
 	return
 }
 
 // GetNoContentExcelListByCondition 获取没有content的excel表格列表数据
 func GetNoContentExcelListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*MyExcelInfoList, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT excel_info_id,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time
 FROM excel_info WHERE 1=1 AND is_delete=0 `
 	if condition != "" {
@@ -217,43 +383,127 @@ FROM excel_info WHERE 1=1 AND is_delete=0 `
 	}
 	//sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
 	sql += " ORDER BY create_time DESC LIMIT ?,? "
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
+	err = o.Raw(sql, pars, startSize, pageSize).Scan(&item).Error
 	return
 }
 
 func GetExcelListCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
 	if condition != "" {
 		sql += condition
 	}
-	err = o.Raw(sql, pars).QueryRow(&count)
+	err = o.Raw(sql, pars).Scan(&count).Error
 	return
 }
 
 // GetExcelViewInfoByExcelInfoId 根据excelInfoId 获取ETA表格详情
 func GetExcelViewInfoByExcelInfoId(excelInfoId int) (item *MyExcelInfoList, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM excel_info WHERE excel_info_id = ? AND is_delete=0 `
-	err = o.Raw(sql, excelInfoId).QueryRow(&item)
+	err = o.Raw(sql, excelInfoId).First(&item).Error
 	return
 }
 
 // GetExcelInfoCountByClassifyId 根据分类id获取名下表格数量
 func GetExcelInfoCountByClassifyId(classifyId int) (total int64, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT count(1) total FROM excel_info WHERE excel_classify_id = ? AND is_delete=0 `
-	err = o.Raw(sql, classifyId).QueryRow(&total)
+	err = o.Raw(sql, classifyId).Scan(&total).Error
 	return
 }
 
 func GetExcelInfoListByCondition(condition string, pars []interface{}) (items []*ExcelInfo, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` ORDER BY sort asc, excel_info_id asc`
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	err = o.Raw(sql, pars).Scan(&items).Error
 	return
 }
+
+// GetExcelInfoByClassifyIdAndName 根据分类id和表格名获取表格信息
+// func GetExcelInfoByClassifyIdAndName(classifyId int, excelName string) (item *ExcelInfo, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT * FROM excel_info WHERE excel_classify_id = ? and excel_name=? AND is_delete=0 `
+// 	err = o.Raw(sql, classifyId, excelName).QueryRow(&item)
+// 	return
+// }
+
+// // GetExcelInfoListByUniqueCodeSlice 根据表格编码获取表格列表数据
+// func GetExcelInfoListByUniqueCodeSlice(uniqueCodeSlice []string) (total int64, items []*ExcelInfo, err error) {
+// 	num := len(uniqueCodeSlice)
+// 	if num <= 0 {
+// 		return
+// 	}
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT * FROM excel_info WHERE unique_code in ("` + utils.GetOrmInReplace(num) + `") AND is_delete=0 `
+// 	total, err = o.Raw(sql, uniqueCodeSlice).QueryRows(&items)
+// 	return
+// }
+
+// // GetExcelListByCondition 获取excel表格列表数据
+// func GetExcelListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*MyExcelInfoList, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
+// 	if condition != "" {
+// 		sql += condition
+// 	}
+// 	//sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
+// 	sql += " ORDER BY create_time DESC LIMIT ?,? "
+// 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
+// 	return
+// }
+
+// // GetNoContentExcelListByCondition 获取没有content的excel表格列表数据
+// func GetNoContentExcelListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*MyExcelInfoList, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT excel_info_id,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time
+// FROM excel_info WHERE 1=1 AND is_delete=0 `
+// 	if condition != "" {
+// 		sql += condition
+// 	}
+// 	//sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
+// 	sql += " ORDER BY create_time DESC LIMIT ?,? "
+// 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
+// 	return
+// }
+
+// func GetExcelListCountByCondition(condition string, pars []interface{}) (count int, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
+// 	if condition != "" {
+// 		sql += condition
+// 	}
+// 	err = o.Raw(sql, pars).QueryRow(&count)
+// 	return
+// }
+
+// // GetExcelViewInfoByExcelInfoId 根据excelInfoId 获取ETA表格详情
+// func GetExcelViewInfoByExcelInfoId(excelInfoId int) (item *MyExcelInfoList, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT * FROM excel_info WHERE excel_info_id = ? AND is_delete=0 `
+// 	err = o.Raw(sql, excelInfoId).QueryRow(&item)
+// 	return
+// }
+
+// // GetExcelInfoCountByClassifyId 根据分类id获取名下表格数量
+// func GetExcelInfoCountByClassifyId(classifyId int) (total int64, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT count(1) total FROM excel_info WHERE excel_classify_id = ? AND is_delete=0 `
+// 	err = o.Raw(sql, classifyId).QueryRow(&total)
+// 	return
+// }
+
+// func GetExcelInfoListByCondition(condition string, pars []interface{}) (items []*ExcelInfo, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
+// 	if condition != "" {
+// 		sql += condition
+// 	}
+// 	sql += ` ORDER BY sort asc, excel_info_id asc`
+// 	_, err = o.Raw(sql, pars).QueryRows(&items)
+// 	return
+// }

+ 188 - 44
models/factor_edb_series_calculate_data_qjjs.go

@@ -1,24 +1,36 @@
 package models
 
 import (
+	"eta_gn/eta_chart_lib/global"
 	"eta_gn/eta_chart_lib/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"strings"
 	"time"
 )
 
 // FactorEdbSeriesCalculateDataQjjs 因子指标系列-区间计算数据表
+// type FactorEdbSeriesCalculateDataQjjs struct {
+// 	FactorEdbSeriesCalculateDataId int       `orm:"column(factor_edb_series_calculate_data_id);pk"`
+// 	FactorEdbSeriesId              int       `description:"因子指标系列ID"`
+// 	EdbInfoId                      int       `description:"指标ID"`
+// 	EdbCode                        string    `description:"指标编码"`
+// 	DataTime                       time.Time `description:"数据日期"`
+// 	Value                          float64   `description:"数据值"`
+// 	CreateTime                     time.Time `description:"创建时间"`
+// 	ModifyTime                     time.Time `description:"修改时间"`
+// 	DataTimestamp                  int64     `description:"数据日期时间戳"`
+// }
+
 type FactorEdbSeriesCalculateDataQjjs struct {
-	FactorEdbSeriesCalculateDataId int       `orm:"column(factor_edb_series_calculate_data_id);pk"`
-	FactorEdbSeriesId              int       `description:"因子指标系列ID"`
-	EdbInfoId                      int       `description:"指标ID"`
-	EdbCode                        string    `description:"指标编码"`
-	DataTime                       time.Time `description:"数据日期"`
-	Value                          float64   `description:"数据值"`
-	CreateTime                     time.Time `description:"创建时间"`
-	ModifyTime                     time.Time `description:"修改时间"`
-	DataTimestamp                  int64     `description:"数据日期时间戳"`
+	FactorEdbSeriesCalculateDataId int       `gorm:"column:factor_edb_series_calculate_data_id;primaryKey" description:"因子指标系列计算数据ID" orm:"column(factor_edb_series_calculate_data_id);pk"`
+	FactorEdbSeriesId              int       `gorm:"column:factor_edb_series_id" description:"因子指标系列ID"`
+	EdbInfoId                      int       `gorm:"column:edb_info_id" description:"指标ID"`
+	EdbCode                        string    `gorm:"column:edb_code" description:"指标编码"`
+	DataTime                       time.Time `gorm:"column:data_time" description:"数据日期"`
+	Value                          float64   `gorm:"column:value" description:"数据值"`
+	CreateTime                     time.Time `gorm:"column:create_time" description:"创建时间"`
+	ModifyTime                     time.Time `gorm:"column:modify_time" description:"修改时间"`
+	DataTimestamp                  int64     `gorm:"column:data_timestamp" description:"数据日期时间戳"`
 }
 
 func (m *FactorEdbSeriesCalculateDataQjjs) TableName() string {
@@ -52,12 +64,8 @@ func (m *FactorEdbSeriesCalculateDataQjjs) Cols() FactorEdbSeriesCalculateDataQj
 }
 
 func (m *FactorEdbSeriesCalculateDataQjjs) Create() (err error) {
-	o := orm.NewOrmUsingDB("data")
-	id, err := o.Insert(m)
-	if err != nil {
-		return
-	}
-	m.FactorEdbSeriesCalculateDataId = int(id)
+	o := global.DmSQL["data"]
+	err = o.Create(m).Error
 	return
 }
 
@@ -65,21 +73,21 @@ func (m *FactorEdbSeriesCalculateDataQjjs) CreateMulti(items []*FactorEdbSeriesC
 	if len(items) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.InsertMulti(500, items)
+	o := global.DmSQL["data"]
+	err = o.CreateInBatches(items, utils.MultiAddNum).Error
 	return
 }
 
 func (m *FactorEdbSeriesCalculateDataQjjs) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.Update(m, cols...)
+	o := global.DmSQL["data"]
+	err = o.Model(m).Select(cols).Updates(m).Error
 	return
 }
 
 func (m *FactorEdbSeriesCalculateDataQjjs) Remove() (err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	_, err = o.Raw(sql, m.FactorEdbSeriesCalculateDataId).Exec()
+	err = o.Exec(sql, m.FactorEdbSeriesCalculateDataId).Error
 	return
 }
 
@@ -87,9 +95,9 @@ func (m *FactorEdbSeriesCalculateDataQjjs) MultiRemove(ids []int) (err error) {
 	if len(ids) == 0 {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.Cols().PrimaryId, utils.GetOrmInReplace(len(ids)))
-	_, err = o.Raw(sql, ids).Exec()
+	err = o.Exec(sql, ids).Error
 	return
 }
 
@@ -97,39 +105,39 @@ func (m *FactorEdbSeriesCalculateDataQjjs) RemoveByCondition(condition string, p
 	if condition == "" {
 		return
 	}
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s`, m.TableName(), condition)
-	_, err = o.Raw(sql, pars).Exec()
+	err = o.Exec(sql, pars).Error
 	return
 }
 
 func (m *FactorEdbSeriesCalculateDataQjjs) GetItemById(id int) (item *FactorEdbSeriesCalculateDataQjjs, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
-	err = o.Raw(sql, id).QueryRow(&item)
+	err = o.Raw(sql, id).First(&item).Error
 	return
 }
 
 func (m *FactorEdbSeriesCalculateDataQjjs) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *FactorEdbSeriesCalculateDataQjjs, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	order := ``
 	if orderRule != "" {
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
-	err = o.Raw(sql, pars).QueryRow(&item)
+	err = o.Raw(sql, pars).First(&item).Error
 	return
 }
 
 func (m *FactorEdbSeriesCalculateDataQjjs) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = o.Raw(sql, pars).QueryRow(&count)
+	err = o.Raw(sql, pars).Scan(&count).Error
 	return
 }
 
 func (m *FactorEdbSeriesCalculateDataQjjs) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*FactorEdbSeriesCalculateDataQjjs, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -139,12 +147,12 @@ func (m *FactorEdbSeriesCalculateDataQjjs) GetItemsByCondition(condition string,
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars).QueryRows(&items)
+	err = o.Raw(sql, pars).Scan(&items).Error
 	return
 }
 
 func (m *FactorEdbSeriesCalculateDataQjjs) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*FactorEdbSeriesCalculateDataQjjs, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	fields := strings.Join(fieldArr, ",")
 	if len(fieldArr) == 0 {
 		fields = `*`
@@ -154,18 +162,134 @@ func (m *FactorEdbSeriesCalculateDataQjjs) GetPageItemsByCondition(condition str
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	err = o.Raw(sql, pars, startSize, pageSize).Scan(&items).Error
 	return
 }
 
+// func (m *FactorEdbSeriesCalculateDataQjjs) Create() (err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	id, err := o.Insert(m)
+// 	if err != nil {
+// 		return
+// 	}
+// 	m.FactorEdbSeriesCalculateDataId = int(id)
+// 	return
+// }
+
+// func (m *FactorEdbSeriesCalculateDataQjjs) CreateMulti(items []*FactorEdbSeriesCalculateDataQjjs) (err error) {
+// 	if len(items) == 0 {
+// 		return
+// 	}
+// 	o := orm.NewOrmUsingDB("data")
+// 	_, err = o.InsertMulti(500, items)
+// 	return
+// }
+
+// func (m *FactorEdbSeriesCalculateDataQjjs) Update(cols []string) (err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	_, err = o.Update(m, cols...)
+// 	return
+// }
+
+// func (m *FactorEdbSeriesCalculateDataQjjs) Remove() (err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
+// 	_, err = o.Raw(sql, m.FactorEdbSeriesCalculateDataId).Exec()
+// 	return
+// }
+
+// func (m *FactorEdbSeriesCalculateDataQjjs) MultiRemove(ids []int) (err error) {
+// 	if len(ids) == 0 {
+// 		return
+// 	}
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.Cols().PrimaryId, utils.GetOrmInReplace(len(ids)))
+// 	_, err = o.Raw(sql, ids).Exec()
+// 	return
+// }
+
+// func (m *FactorEdbSeriesCalculateDataQjjs) RemoveByCondition(condition string, pars []interface{}) (err error) {
+// 	if condition == "" {
+// 		return
+// 	}
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := fmt.Sprintf(`DELETE FROM %s WHERE %s`, m.TableName(), condition)
+// 	_, err = o.Raw(sql, pars).Exec()
+// 	return
+// }
+
+// func (m *FactorEdbSeriesCalculateDataQjjs) GetItemById(id int) (item *FactorEdbSeriesCalculateDataQjjs, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.Cols().PrimaryId)
+// 	err = o.Raw(sql, id).QueryRow(&item)
+// 	return
+// }
+
+// func (m *FactorEdbSeriesCalculateDataQjjs) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *FactorEdbSeriesCalculateDataQjjs, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	order := ``
+// 	if orderRule != "" {
+// 		order = ` ORDER BY ` + orderRule
+// 	}
+// 	sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
+// 	err = o.Raw(sql, pars).QueryRow(&item)
+// 	return
+// }
+
+// func (m *FactorEdbSeriesCalculateDataQjjs) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
+// 	err = o.Raw(sql, pars).QueryRow(&count)
+// 	return
+// }
+
+// func (m *FactorEdbSeriesCalculateDataQjjs) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*FactorEdbSeriesCalculateDataQjjs, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	fields := strings.Join(fieldArr, ",")
+// 	if len(fieldArr) == 0 {
+// 		fields = `*`
+// 	}
+// 	order := fmt.Sprintf(`ORDER BY %s DESC`, m.Cols().CreateTime)
+// 	if orderRule != "" {
+// 		order = ` ORDER BY ` + orderRule
+// 	}
+// 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
+// 	_, err = o.Raw(sql, pars).QueryRows(&items)
+// 	return
+// }
+
+// func (m *FactorEdbSeriesCalculateDataQjjs) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*FactorEdbSeriesCalculateDataQjjs, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	fields := strings.Join(fieldArr, ",")
+// 	if len(fieldArr) == 0 {
+// 		fields = `*`
+// 	}
+// 	order := fmt.Sprintf(`ORDER BY %s DESC`, m.Cols().CreateTime)
+// 	if orderRule != "" {
+// 		order = ` ORDER BY ` + orderRule
+// 	}
+// 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
+// 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+// 	return
+// }
+
 // FactorEdbSeriesCalculateDataQjjsItem 因子指标系列-计算数据信息
+//
+//	type FactorEdbSeriesCalculateDataQjjsItem struct {
+//		DataId            int     `description:"数据ID"`
+//		FactorEdbSeriesId int     `description:"因子指标系列ID"`
+//		EdbInfoId         int     `description:"指标ID"`
+//		EdbCode           string  `description:"指标编码"`
+//		DataTime          string  `description:"数据日期"`
+//		Value             float64 `description:"数据值"`
+//	}
 type FactorEdbSeriesCalculateDataQjjsItem struct {
-	DataId            int     `description:"数据ID"`
-	FactorEdbSeriesId int     `description:"因子指标系列ID"`
-	EdbInfoId         int     `description:"指标ID"`
-	EdbCode           string  `description:"指标编码"`
-	DataTime          string  `description:"数据日期"`
-	Value             float64 `description:"数据值"`
+	DataId            int     `gorm:"column:data_id;primaryKey" description:"数据ID"`
+	FactorEdbSeriesId int     `gorm:"column:factor_edb_series_id" description:"因子指标系列ID"`
+	EdbInfoId         int     `gorm:"column:edb_info_id" description:"指标ID"`
+	EdbCode           string  `gorm:"column:edb_code" description:"指标编码"`
+	DataTime          string  `gorm:"column:data_time" description:"数据日期"`
+	Value             float64 `gorm:"column:value" description:"数据值"`
 }
 
 func (m *FactorEdbSeriesCalculateDataQjjs) Format2Item() (item *FactorEdbSeriesCalculateDataQjjsItem) {
@@ -192,7 +316,27 @@ func (m *FactorEdbSeriesCalculateDataQjjs) GetEdbDataList(seriesId int, edbInfoI
 
 	sql += ` ORDER BY data_time ASC `
 	sql = fmt.Sprintf(sql, m.TableName())
-	o := orm.NewOrmUsingDB("data")
-	_, err = o.Raw(sql, pars).QueryRows(&list)
+	o := global.DmSQL["data"]
+	err = o.Raw(sql, pars).Scan(&list).Error
 	return
 }
+
+// func (m *FactorEdbSeriesCalculateDataQjjs) GetEdbDataList(seriesId int, edbInfoId int, startDate, endDate string) (list []*EdbDataList, err error) {
+// 	var pars []interface{}
+// 	sql := `SELECT factor_edb_series_calculate_data_id as edb_data_id  ,edb_info_id,data_time,value,data_timestamp FROM %s WHERE edb_info_id=? and factor_edb_series_id=? `
+// 	pars = append(pars, edbInfoId, seriesId)
+// 	if startDate != "" {
+// 		sql += ` AND data_time>=? `
+// 		pars = append(pars, startDate)
+// 	}
+// 	if endDate != "" {
+// 		sql += ` AND data_time<=? `
+// 		pars = append(pars, endDate)
+// 	}
+
+// 	sql += ` ORDER BY data_time ASC `
+// 	sql = fmt.Sprintf(sql, m.TableName())
+// 	o := orm.NewOrmUsingDB("data")
+// 	_, err = o.Raw(sql, pars).QueryRows(&list)
+// 	return
+// }

+ 21 - 7
models/share_chart_refresh_log.go

@@ -1,21 +1,35 @@
 package models
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_chart_lib/global"
 	"time"
 )
 
 // ShareChartRefreshLog 分享图表的日志
+//
+//	type ShareChartRefreshLog struct {
+//		Id         int    `orm:"column(id);pk"`
+//		Ip         string `description:"来源ip"`
+//		ChartId    int    `description:"图表分类id"`
+//		CreateTime time.Time
+//	}
 type ShareChartRefreshLog struct {
-	Id         int    `orm:"column(id);pk"`
-	Ip         string `description:"来源ip"`
-	ChartId    int    `description:"图表分类id"`
-	CreateTime time.Time
+	Id         int       `gorm:"column:id;primaryKey" description:"主键ID" orm:"column(id);pk"`
+	Ip         string    `gorm:"column:ip" description:"来源IP"`
+	ChartId    int       `gorm:"column:chart_id" description:"图表分类ID"`
+	CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
 }
 
 // AddShareChartRefreshLog 添加日志
 func AddShareChartRefreshLog(item *ShareChartRefreshLog) (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("data")
-	lastId, err = o.Insert(item)
+	o := global.DmSQL["data"]
+	err = o.Create(item).Error
+	lastId = int64(item.Id)
 	return
 }
+
+// func AddShareChartRefreshLog(item *ShareChartRefreshLog) (lastId int64, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	lastId, err = o.Insert(item)
+// 	return
+// }

+ 40 - 17
models/table.go

@@ -1,35 +1,58 @@
 package models
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_chart_lib/global"
 	"time"
 )
 
+//	type TableInfo struct {
+//		TableInfoId     int       `orm:"column(table_info_id);pk"`
+//		TableName       string    `description:"表格名称"`
+//		UniqueCode      string    `description:"表格唯一编码"`
+//		TableClassifyId int       `description:"表格分类id"`
+//		SysUserId       int       `description:"操作人id"`
+//		SysUserRealName string    `description:"操作人真实姓名"`
+//		StartDate       time.Time `description:"开始日期"`
+//		EdbInfoIds      string    `description:"指标id"`
+//		TableType       int       `description:"表格类型,1:指标+日期"`
+//		TableImage      string    `description:"图表图片"`
+//		Sort            int       `description:"排序字段,数字越小越排前面"`
+//		EdbEndDate      time.Time `description:"指标最后更新日期"`
+//		ModifyTime      time.Time
+//		CreateTime      time.Time
+//	}
 type TableInfo struct {
-	TableInfoId     int       `orm:"column(table_info_id);pk"`
-	TableName       string    `description:"表格名称"`
-	UniqueCode      string    `description:"表格唯一编码"`
-	TableClassifyId int       `description:"表格分类id"`
-	SysUserId       int       `description:"操作人id"`
-	SysUserRealName string    `description:"操作人真实姓名"`
-	StartDate       time.Time `description:"开始日期"`
-	EdbInfoIds      string    `description:"指标id"`
-	TableType       int       `description:"表格类型,1:指标+日期"`
-	TableImage      string    `description:"图表图片"`
-	Sort            int       `description:"排序字段,数字越小越排前面"`
-	EdbEndDate      time.Time `description:"指标最后更新日期"`
-	ModifyTime      time.Time
-	CreateTime      time.Time
+	TableInfoId     int       `gorm:"column:table_info_id;primaryKey" description:"表格ID" orm:"column(table_info_id);pk"`
+	TableName       string    `gorm:"column:table_name" description:"表格名称"`
+	UniqueCode      string    `gorm:"column:unique_code" description:"表格唯一编码"`
+	TableClassifyId int       `gorm:"column:table_classify_id" description:"表格分类ID"`
+	SysUserId       int       `gorm:"column:sys_user_id" description:"操作人ID"`
+	SysUserRealName string    `gorm:"column:sys_user_real_name" description:"操作人真实姓名"`
+	StartDate       time.Time `gorm:"column:start_date" description:"开始日期"`
+	EdbInfoIds      string    `gorm:"column:edb_info_ids" description:"指标ID"`
+	TableType       int       `gorm:"column:table_type" description:"表格类型,1:指标+日期"`
+	TableImage      string    `gorm:"column:table_image" description:"表图片"`
+	Sort            int       `gorm:"column:sort" description:"排序字段,数字越小越排前面"`
+	EdbEndDate      time.Time `gorm:"column:edb_end_date" description:"指标最后更新日期"`
+	ModifyTime      time.Time `gorm:"column:modify_time" description:"修改时间"`
+	CreateTime      time.Time `gorm:"column:create_time" description:"创建时间"`
 }
 
 // GetTableInfoByUniqueCode 根据union_code 获取表格信息
 func GetTableInfoByUniqueCode(uniqueCode string) (item *TableInfo, err error) {
-	o := orm.NewOrmUsingDB("data")
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM table_info WHERE unique_code=? `
-	err = o.Raw(sql, uniqueCode).QueryRow(&item)
+	err = o.Raw(sql, uniqueCode).First(&item).Error
 	return
 }
 
+// func GetTableInfoByUniqueCode(uniqueCode string) (item *TableInfo, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	sql := ` SELECT * FROM table_info WHERE unique_code=? `
+// 	err = o.Raw(sql, uniqueCode).QueryRow(&item)
+// 	return
+// }
+
 // TableInfoDetailResp 表格详情返回
 type TableInfoDetailResp struct {
 	TableInfo     *TableInfo

+ 33 - 26
models/table_data.go

@@ -1,40 +1,47 @@
 package models
 
 import (
-	"github.com/beego/beego/v2/client/orm"
+	"eta_gn/eta_chart_lib/global"
 	"time"
 )
 
 type TableData struct {
-	TableDataId       int       `orm:"column(table_data_id);pk"`
-	TableInfoId       int       `description:"表格id"`
-	Date              time.Time `description:"指标时间"`
-	DataCol1          string    `orm:"column(data_col_1);" description:"第1个表格的数据"`
-	DataCol2          string    `orm:"column(data_col_2);" description:"第2个表格的数据"`
-	DataCol3          string    `orm:"column(data_col_3);" description:"第3个表格的数据"`
-	DataCol4          string    `orm:"column(data_col_4);" description:"第4个表格的数据"`
-	DataCol5          string    `orm:"column(data_col_5);" description:"第5个表格的数据"`
-	DataCol6          string    `orm:"column(data_col_6);" description:"第6个表格的数据"`
-	DataCol7          string    `orm:"column(data_col_7);" description:"第7个表格的数据"`
-	DataCol8          string    `orm:"column(data_col_8);" description:"第8个表格的数据"`
-	DataCol9          string    `orm:"column(data_col_9);" description:"第9个表格的数据"`
-	DataCol10         string    `orm:"column(data_col_10);" description:"第10个表格的数据"`
-	DataType          int8      `description:"数据类型,默认的区间数据是 1;插入数据是 2"`
-	Sort              int       `description:"排序字段,越小越靠前"`
-	AfterTableDataId  int       `description:"在某个表格数据id后面"`
-	BeforeTableDataId int       `description:"在某个表格数据id前面"`
-	ModifyTime        time.Time `description:"修改时间"`
-	CreateTime        time.Time `description:"创建时间"`
+	TableDataId       int       `orm:"column(table_data_id);pk" gorm:"column:table_data_id;primary_key"`
+	TableInfoId       int       `description:"表格id" gorm:"column:table_info_id"`
+	Date              time.Time `description:"指标时间" gorm:"column:date"`
+	DataCol1          string    `orm:"column(data_col_1);" description:"第1个表格的数据" gorm:"column:data_col_1"`
+	DataCol2          string    `orm:"column(data_col_2);" description:"第2个表格的数据" gorm:"column:data_col_2"`
+	DataCol3          string    `orm:"column(data_col_3);" description:"第3个表格的数据" gorm:"column:data_col_3"`
+	DataCol4          string    `orm:"column(data_col_4);" description:"第4个表格的数据" gorm:"column:data_col_4"`
+	DataCol5          string    `orm:"column(data_col_5);" description:"第5个表格的数据" gorm:"column:data_col_5"`
+	DataCol6          string    `orm:"column(data_col_6);" description:"第6个表格的数据" gorm:"column:data_col_6"`
+	DataCol7          string    `orm:"column(data_col_7);" description:"第7个表格的数据" gorm:"column:data_col_7"`
+	DataCol8          string    `orm:"column(data_col_8);" description:"第8个表格的数据" gorm:"column:data_col_8"`
+	DataCol9          string    `orm:"column(data_col_9);" description:"第9个表格的数据" gorm:"column:data_col_9"`
+	DataCol10         string    `orm:"column(data_col_10);" description:"第10个表格的数据" gorm:"column:data_col_10"`
+	DataType          int8      `description:"数据类型,默认的区间数据是 1;插入数据是 2" gorm:"column:data_type"`
+	Sort              int       `description:"排序字段,越小越靠前" gorm:"column:sort"`
+	AfterTableDataId  int       `description:"在某个表格数据id后面" gorm:"column:after_table_data_id"`
+	BeforeTableDataId int       `description:"在某个表格数据id前面" gorm:"column:before_table_data_id"`
+	ModifyTime        time.Time `description:"修改时间" gorm:"column:modify_time"`
+	CreateTime        time.Time `description:"创建时间" gorm:"column:create_time"`
 }
 
 // GetTableDataListByTableInfoId 根据表格id获取数据列表
 func GetTableDataListByTableInfoId(tableInfoId int) (items []*TableData, err error) {
-	o := orm.NewOrmUsingDB("data")
-	pars := make([]interface{}, 0)
-	pars = append(pars, tableInfoId)
-
+	o := global.DmSQL["data"]
 	sql := ` SELECT * FROM table_data WHERE table_info_id = ? order by sort asc `
-
-	_, err = o.Raw(sql, tableInfoId).QueryRows(&items)
+	err = o.Raw(sql, tableInfoId).Scan(&items).Error
 	return
 }
+
+// func GetTableDataListByTableInfoId(tableInfoId int) (items []*TableData, err error) {
+// 	o := orm.NewOrmUsingDB("data")
+// 	pars := make([]interface{}, 0)
+// 	pars = append(pars, tableInfoId)
+
+// 	sql := ` SELECT * FROM table_data WHERE table_info_id = ? order by sort asc `
+
+// 	_, err = o.Raw(sql, tableInfoId).QueryRows(&items)
+// 	return
+// }