浏览代码

代码精简

hsun 1 年之前
父节点
当前提交
b6ff6c8a67

+ 4 - 18
models/db.go

@@ -75,9 +75,6 @@ func init() {
 
 	initChart()
 
-	// 上海指标服务 数据表
-	initShEdbData()
-
 	// 指标服务 数据表
 	initEdbData()
 
@@ -112,18 +109,16 @@ func initSystem() {
 func initReport() {
 	orm.RegisterModel(
 		new(Report),
-		new(ResearchReport),                      //日报、周报信息
 		new(ChartPermissionSearchKeyWordMapping), //报告分类权限表
 		new(ReportChapter),                       // 报告章节表
 		new(ReportChapterTicker),                 // 晨报章节ticker
 		new(ReportChapterTypePermission),         // 晨周报章节类型权限表
 		new(YbPcSuncode),
 		new(YbSuncodePars),
-		new(ReportAuthor),                  //报告作者
-		new(ClassifyMenu),                  // 报告分类-子目录表
-		new(ClassifyMenuRelation),          // 报告分类-子目录关联表
-		new(ChartPermissionChapterMapping), // 权限mapping表
-		new(ReportChapterType),             // 报告章节类型表
+		new(ReportAuthor),         //报告作者
+		new(ClassifyMenu),         // 报告分类-子目录表
+		new(ClassifyMenuRelation), // 报告分类-子目录关联表
+		new(ReportChapterType),    // 报告章节类型表
 	)
 }
 
@@ -142,15 +137,6 @@ func initChart() {
 	)
 }
 
-// initShEdbData 上海服务器指标 数据表
-func initShEdbData() {
-	orm.RegisterModel(
-		new(Edbdata),
-		new(EdbdataDeleteRecord),
-		new(Edbinfo), //edb库的edbinfo表
-	)
-}
-
 // initEdbData 指标服务 数据表
 func initEdbData() {
 	orm.RegisterModel(

+ 0 - 275
models/report_chapter_type.go

@@ -3,7 +3,6 @@ package models
 import (
 	"eta/eta_mobile/utils"
 	"github.com/beego/beego/v2/client/orm"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
 )
 
@@ -32,53 +31,6 @@ type ReportChapterType struct {
 	YbBottomIcon           string    `description:"研报小程序详情底部icon"`
 }
 
-func (item *ReportChapterType) Create() (err error) {
-	o := orm.NewOrm()
-	id, err := o.Insert(item)
-	if err != nil {
-		return
-	}
-	item.ReportChapterTypeId = int(id)
-	return
-}
-
-func (item *ReportChapterType) Update(cols []string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Update(item, cols...)
-	return
-}
-
-// DeleteReportChapterType 删除章节类型及相关权限
-func DeleteReportChapterType(typeId int, reportType string) (err error) {
-	o := orm.NewOrm()
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-
-	// 删除章节类型
-	sql := `DELETE FROM report_chapter_type WHERE report_chapter_type_id = ? LIMIT 1`
-	_, err = to.Raw(sql, typeId).Exec()
-
-	// 删除章节类型权限
-	sql = `DELETE FROM report_chapter_type_permission WHERE report_chapter_type_id = ?`
-	_, err = to.Raw(sql, typeId).Exec()
-
-	// 周报-删除实际权限
-	if reportType == utils.REPORT_TYPE_WEEK {
-		sql = `DELETE FROM chart_permission_chapter_mapping WHERE report_chapter_type_id = ? AND research_type = ?`
-		_, err = to.Raw(sql, typeId, reportType).Exec()
-	}
-	return
-}
-
 // GetReportChapterTypeById 获取章节类型
 func GetReportChapterTypeById(reportChapterTypeId int) (item *ReportChapterType, err error) {
 	o := orm.NewOrm()
@@ -111,15 +63,6 @@ func GetAllReportChapterTypeListByResearchType(researchType string) (list []*Rep
 	return
 }
 
-// GetAllReportChapterTypeList 通过传入的条件获取所有的章节类型列表
-func GetAllReportChapterTypeList(condition string, pars []interface{}) (list []*ReportChapterType, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM report_chapter_type WHERE 1=1 `
-	sql += condition
-	_, err = o.Raw(sql, pars).QueryRows(&list)
-	return
-}
-
 // GetEnableReportChapterTypeList 获取未暂停的章节类型列表
 func GetEnableReportChapterTypeList(researchType string) (list []*ReportChapterType, err error) {
 	o := orm.NewOrm()
@@ -142,133 +85,6 @@ func GetEnableReportChapterTypeList(researchType string) (list []*ReportChapterT
 	return
 }
 
-// 晨报周报暂停时间
-type DayWeekReportPauseTime struct {
-	ResearchType   string `description:"报告类型 day; week;"`
-	PauseStartTime string `description:"暂停开始时间"`
-	PauseEndTime   string `description:"暂停结束时间"`
-}
-
-// GetDayWeekReportPauseTimeList 获取晨报周报暂停时间
-func GetDayWeekReportPauseTimeList() (list []*DayWeekReportPauseTime, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT research_type, MAX(a.pause_start_time) AS pause_start_time, MAX(a.pause_end_time) AS pause_end_time FROM report_chapter_type AS a WHERE a.is_set = 1 GROUP BY a.research_type`
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-// SetDayWeekReportUpdateRuleReq 设置章节类型的暂停时间请求体
-type SetDayWeekReportUpdateRuleReq struct {
-	ResearchType string                    `description:"报告类型 day; week;"`
-	List         []DayWeekReportUpdateRule `description:"暂停规则"`
-}
-
-type DayWeekReportUpdateRule struct {
-	ReportChapterTypeId int    `description:"章节类型ID"`
-	PauseStartTime      string `description:"暂停开始时间"`
-	PauseEndTime        string `description:"暂停结束时间"`
-}
-
-// SetDayWeekReportEnableUpdateRuleReq 设置章节类型的永久暂停请求体
-type SetDayWeekReportEnableUpdateRuleReq struct {
-	DayReportChapterTypeId  string `description:"章节类型ID 英文逗号拼接"`
-	WeekReportChapterTypeId string `description:"章节类型ID 英文逗号拼接"`
-}
-
-// ResetDayWeekReportUpdateRule 重置章节类型的暂停时间
-func ResetDayWeekReportUpdateRule(researchType string) (err error) {
-	o := orm.NewOrm()
-	sql := ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 WHERE research_type = ?`
-	_, err = o.Raw(sql, researchType).Exec()
-	return
-}
-
-// SetDayWeekReportUpdateRule 设置章节类型的暂停时间
-func SetDayWeekReportUpdateRule(researchType string, list []DayWeekReportUpdateRule) (err error) {
-	o := orm.NewOrm()
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-
-	// 先将所有品种的状态变更为启用
-	sql := ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 WHERE research_type = ?`
-	_, err = to.Raw(sql, researchType).Exec()
-	if err != nil {
-		return
-	}
-	for _, v := range list {
-		// 时间异常的话,给过滤
-		if v.PauseStartTime == `` || v.PauseEndTime == `` {
-			continue
-		}
-		tmpSql := ` UPDATE report_chapter_type SET pause_start_time = ?, pause_end_time = ?, is_set = 1 WHERE research_type = ? AND report_chapter_type_id = ? `
-		_, err = to.Raw(tmpSql, v.PauseStartTime, v.PauseEndTime, researchType, v.ReportChapterTypeId).Exec()
-		if err != nil {
-			return
-		}
-	}
-
-	return
-}
-
-// SetDayWeekReportEnableUpdateRule 设置章节类型的禁用状态
-func SetDayWeekReportEnableUpdateRule(dayReportChapterTypeIdList, weekReportChapterTypeIdList []string) (err error) {
-	o := orm.NewOrm()
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-	{
-		researchType := `day`
-		// 先将所有品种的状态变更为启用
-		sql := ` UPDATE report_chapter_type SET enabled = 1 WHERE research_type = ?`
-		_, err = to.Raw(sql, researchType).Exec()
-		if err != nil {
-			return
-		}
-
-		// 然后将需要的品种的状态变更为禁用
-		num := len(dayReportChapterTypeIdList)
-		if num > 0 {
-			sql = ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 , enabled = 0 WHERE research_type = ? AND report_chapter_type_id IN (` + utils.GetOrmInReplace(num) + `) `
-			_, err = to.Raw(sql, researchType, dayReportChapterTypeIdList).Exec()
-		}
-	}
-
-	{
-		researchType := `week`
-		// 先将所有品种的状态变更为启用
-		sql := ` UPDATE report_chapter_type SET enabled = 1 WHERE research_type = ?`
-		_, err = to.Raw(sql, researchType).Exec()
-		if err != nil {
-			return
-		}
-
-		// 然后将需要的品种的状态变更为禁用
-		num := len(weekReportChapterTypeIdList)
-		if num > 0 {
-			sql = ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 , enabled = 0 WHERE research_type = ? AND report_chapter_type_id IN (` + utils.GetOrmInReplace(num) + `) `
-			_, err = to.Raw(sql, researchType, weekReportChapterTypeIdList).Exec()
-		}
-	}
-	return
-}
-
 // StopUpdateReportChapterTypeResp 停止更新的报告分类列表
 type StopUpdateReportChapterTypeResp struct {
 	StopDay     []*ReportChapterType `description:"暂时停更晨报"`
@@ -292,94 +108,3 @@ func GetDisableUpdateReportChapterTypeListByResearchType() (list []*ReportChapte
 	_, err = o.Raw(sql).QueryRows(&list)
 	return
 }
-
-// UpdateReportChapterTypeResp 停止更新的报告分类列表
-type UpdateReportChapterTypeResp struct {
-	Day  []*ReportChapterType `description:"所有晨报品种"`
-	Week []*ReportChapterType `description:"所有周报品种"`
-}
-
-type ReportChapterTypePageListResp struct {
-	List   []*ReportChapterTypeListItem
-	Paging *paging.PagingItem `description:"分页数据"`
-}
-
-// GetReportChapterTypeCount 获取章节类型总数
-func GetReportChapterTypeCount(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT COUNT(1) FROM report_chapter_type WHERE 1 = 1 `
-	sql += condition
-	err = o.Raw(sql, pars).QueryRow(&count)
-	return
-}
-
-// GetReportChapterTypeList 获取章节类型列表
-func GetReportChapterTypePageList(condition string, pars []interface{}, startSize, pageSize int) (list []*ReportChapterType, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM report_chapter_type WHERE 1 = 1 `
-	sql += condition
-	sql += ` ORDER BY sort ASC, created_time DESC`
-	sql += ` LIMIT ?,?`
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
-	return
-}
-
-// ReportChapterTypeListItem 章节类型列表信息
-type ReportChapterTypeListItem struct {
-	ReportChapterTypeId   int    `description:"报告章节类型id"`
-	ReportChapterTypeName string `description:"报告章节类型名称"`
-	Sort                  int    `description:"排序字段"`
-	CreatedTime           string `description:"创建时间"`
-	ResearchType          string `description:"研报类型"`
-	SelectedImage         string `description:"选中时的图片"`
-	UnselectedImage       string `description:"没选中时的图片"`
-	WordsImage            string `description:"带字的icon"`
-	EditImgUrl            string `description:"管理后台编辑时选用的图"`
-	IsShow                int    `description:"显示隐藏: 1-显示; 0-隐藏"`
-}
-
-// ReportChapterTypeAddReq 新增章节类型请求体
-type ReportChapterTypeAddReq struct {
-	ReportChapterTypeName string `description:"报告章节类型名称"`
-	Sort                  int    `description:"排序字段"`
-	ResearchType          string `description:"研报类型"`
-	SelectedImage         string `description:"选中时的icon"`
-	UnselectedImage       string `description:"未选中时的icon"`
-	WordsImage            string `description:"带字的icon"`
-	EditImgUrl            string `description:"管理后台编辑时选用的图"`
-	IsShow                int    `description:"显示隐藏: 1-显示; 0-隐藏"`
-}
-
-// ReportChapterTypeEditReq 编辑章节类型请求体
-type ReportChapterTypeEditReq struct {
-	ReportChapterTypeId   int    `description:"报告章节类型id"`
-	ReportChapterTypeName string `description:"报告章节类型名称"`
-	Sort                  int    `description:"排序字段"`
-	ResearchType          string `description:"研报类型"`
-	SelectedImage         string `description:"选中时的icon"`
-	UnselectedImage       string `description:"未选中时的icon"`
-	WordsImage            string `description:"带字的icon"`
-	EditImgUrl            string `description:"管理后台编辑时选用的图"`
-	IsShow                int    `description:"显示隐藏: 1-显示; 0-隐藏"`
-}
-
-// ReportChapterTypeDelReq 删除章节类型请求体
-type ReportChapterTypeDelReq struct {
-	ReportChapterTypeId int `description:"报告章节类型id"`
-}
-
-// ReportChapterTypeAuthSettingReq 章节类型权限配置请求体
-type ReportChapterTypeAuthSettingReq struct {
-	ReportChapterTypeId   int   `description:"章节类型ID"`
-	ChartPermissionIdList []int `description:"权限id数组"`
-}
-
-// GetReportChapterTypeByCondition 获取章节类型
-func GetReportChapterTypeByCondition(condition string, pars []interface{}) (item *ReportChapterType, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM report_chapter_type WHERE 1 = 1 `
-	sql += condition
-	sql += ` LIMIT 1`
-	err = o.Raw(sql, pars).QueryRow(&item)
-	return
-}

+ 0 - 58
models/report_chapter_type_permission.go

@@ -1,7 +1,6 @@
 package models
 
 import (
-	"eta/eta_mobile/utils"
 	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
@@ -16,13 +15,6 @@ type ReportChapterTypePermission struct {
 	CreatedTime           time.Time `description:"创建时间"`
 }
 
-// AddChapterTypePermission 新增章节类型权限
-func AddChapterTypePermission(item *ReportChapterTypePermission) (lastId int64, err error) {
-	o := orm.NewOrm()
-	lastId, err = o.Insert(item)
-	return
-}
-
 // GetChapterTypePermissionByTypeIdAndResearchType 根据章节类型ID及研报类型获取章节类型权限列表
 func GetChapterTypePermissionByTypeIdAndResearchType(typeId int, researchType string) (list []*ReportChapterTypePermission, err error) {
 	o := orm.NewOrm()
@@ -30,53 +22,3 @@ func GetChapterTypePermissionByTypeIdAndResearchType(typeId int, researchType st
 	_, err = o.Raw(sql, typeId, researchType).QueryRows(&list)
 	return
 }
-
-// SetReportChapterTypePermission 设置报告章节类型权限
-func SetReportChapterTypePermission(chapterTypeId int, researchType string, newPermissions []*ReportChapterTypePermission, newWeekPermissions []*ChartPermissionChapterMapping) (err error) {
-	o := orm.NewOrm()
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-
-	// 删除原章节类型权限
-	sql := `DELETE FROM report_chapter_type_permission WHERE report_chapter_type_id = ? AND research_type = ?`
-	_, err = to.Raw(sql, chapterTypeId, researchType).Exec()
-	if err != nil {
-		return
-	}
-
-	// 新增章节类型权限
-	if len(newPermissions) > 0 {
-		_, err = to.InsertMulti(len(newPermissions), newPermissions)
-		if err != nil {
-			return
-		}
-	}
-
-	// 周报章节调整chart_permission_chapter_mapping表
-	if researchType == utils.REPORT_TYPE_WEEK {
-		// 删除原权限
-		sql = `DELETE FROM chart_permission_chapter_mapping WHERE report_chapter_type_id = ? AND research_type = ?`
-		_, err = to.Raw(sql, chapterTypeId, researchType).Exec()
-		if err != nil {
-			return
-		}
-
-		// 新增权限
-		if len(newWeekPermissions) > 0 {
-			_, err = to.InsertMulti(len(newWeekPermissions), newWeekPermissions)
-			if err != nil {
-				return
-			}
-		}
-	}
-	return
-}

+ 0 - 302
models/research_report.go

@@ -1,302 +0,0 @@
-package models
-
-import (
-	"eta/eta_mobile/utils"
-	"fmt"
-	"github.com/beego/beego/v2/client/orm"
-	"strconv"
-	"time"
-)
-
-// ResearchReport 研究报告表(晨报、周报等)结构体
-type ResearchReport struct {
-	ResearchReportId    int       `orm:"column(research_report_id);pk" description:"研究报告id"`
-	ResearchReportName  string    `description:"研究报告名称"`
-	ResearchReportTitle string    `description:"研究报告标题"`
-	ResearchReportImg   string    `description:"报告缩略图URL"`
-	ResearchReportDate  time.Time `description:"报告日期"`
-	Type                string    `description:"报告类型,枚举值:day 晨报  week 周报 twoweek双周报 month 月报;默认:day"`
-	Author              string    `description:"作者"`
-	ReportVariety       string    `description:"研究报告的品种,双周报和月报有标识"`
-	IsHasMenu           int8      `description:"报告是否含有目录"`
-	IsSendedMsg         int8      `description:"是否发送过模板消息"`
-	Periods             int       `description:"期数"`
-	Status              string    `description:"状态,draft:草稿,"`
-	Enabled             int8      `description:"报告状态"`
-	CreatedTime         string    `description:"创建时间"`
-	LastUpdatedTime     time.Time `description:"最近一次更新时间"`
-	Viewers             int       `description:"H5观看用户数"`
-}
-
-// GetResearchReportListByIds 根据报告id集合获取报告数据列表
-func GetResearchReportListByIds(researchReportIds string) (list []*ResearchReport, err error) {
-	if researchReportIds == "" {
-		return
-	}
-	o := orm.NewOrm()
-	sql := `select * from research_report where research_report_id in (` + researchReportIds + `)`
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-// Update 更新数据
-func (researchReport *ResearchReport) Update(updateCols []string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Update(researchReport, updateCols...)
-	return
-}
-
-type ResearchReportList struct {
-	ResearchReportId    int       `orm:"column(research_report_id);pk" description:"研究报告id"`
-	ResearchReportName  string    `description:"研究报告名称"`
-	ResearchReportTitle string    `description:"研究报告标题"`
-	ResearchReportImg   string    `description:"报告缩略图URL"`
-	ResearchReportDate  time.Time `description:"报告日期"`
-	Type                string    `description:"报告类型,枚举值:day 晨报  week 周报 twoweek双周报 month 月报;默认:day"`
-	Author              string    `description:"作者"`
-	ReportVariety       string    `description:"研究报告的品种,双周报和月报有标识"`
-	IsHasMenu           int8      `description:"报告是否含有目录"`
-	IsSendedMsg         int8      `description:"是否发送过模板消息"`
-	Periods             int       `description:"期数"`
-	Status              string    `description:"状态,draft:草稿,"`
-	Enabled             int8      `description:"报告状态"`
-	CreatedTime         string    `description:"创建时间"`
-	LastUpdatedTime     time.Time `description:"最近一次更新时间"`
-	Viewers             int       `description:"H5观看用户数"`
-	LinkUrl             string    `description:"报告阅读地址"`
-}
-
-// GetResearchReportList 获取报告列表
-func GetResearchReportList(condition string, pars []interface{}, startSize, pageSize int) (total int, list []*ResearchReportList, err error) {
-	o := orm.NewOrm()
-
-	sql := `select * from research_report where enabled = 1 `
-	sql += condition
-	sql += ` order by research_report_date desc,created_time desc `
-
-	totalSql := `select count(1) total from (` + sql + `) z `
-	err = o.Raw(totalSql, pars).QueryRow(&total)
-	if err != nil {
-		return
-	}
-	sql += ` LIMIT ?,? `
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
-
-	return
-}
-
-// 获取今年报告
-func GetMigrateReportList() (list []*ResearchReport, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT
-				*
-			FROM
-				research_report AS a
-			WHERE
-				a.enabled = 1
-			AND a.status = "report"
-			AND a.research_report_date >= "2022-01-01"
-			ORDER BY a.research_report_date ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
-
-	return
-}
-
-// ResearchReport 研究报告表(晨报、周报等)结构体
-type ResearchReportType struct {
-	ResearchReportTypeId    int       `orm:"column(research_report_type_id);pk" description:"报告章节ID"`
-	ResearchReportId        int       `description:"报告ID"`
-	TypeId                  int       `description:"分类ID"`
-	Edit                    int       `description:"是否编辑过"`
-	Trend                   string    `description:"趋势观点"`
-	ResearchReportTypeTitle string    `description:"报告标题"`
-	CreatedTime             string    `description:"创建时间"`
-	LastUpdatedTime         time.Time `description:"最近一次更新时间"`
-}
-
-type ResearchReportTypeContent struct {
-	ResearchReportTypeContentId int       `orm:"column(research_report_type_content_id);pk" description:"章节内容ID"`
-	ResearchReportTypeId        int       `description:"报告章节ID"`
-	Sort                        int       `description:"排序"`
-	ContentType                 string    `description:"内容分类类型"`
-	Content                     string    `description:"内容"`
-	ImgUrl                      string    `description:"图片路径"`
-	CreatedTime                 time.Time `description:"创建时间"`
-	LastUpdatedTime             time.Time `description:"最近一次更新时间"`
-}
-
-type ResearchReportTypeTicker struct {
-	ResearchReportTypeTickerId int       `orm:"column(research_report_type_ticker_id);pk" description:"章节tickerID"`
-	ResearchReportTypeId       int       `description:"报告章节ID"`
-	Sort                       int       `description:"排序"`
-	Ticker                     string    `description:"指标的ticker"`
-	CreatedTime                time.Time `description:"创建时间"`
-	LastUpdatedTime            time.Time `description:"最近一次更新时间"`
-}
-
-func GetResearchReportTypeList(researchReportId int) (list []*ResearchReportType, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM research_report_type WHERE research_report_id = ? ORDER BY created_time ASC `
-	_, err = o.Raw(sql, researchReportId).QueryRows(&list)
-	return
-}
-
-func GetResearchReportTypeListByReportIds(reportIds string) (list []*ResearchReportType, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM research_report_type WHERE research_report_id IN (` + reportIds + `) ORDER BY created_time ASC,research_report_type_id ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-func GetResearchReportTypeContentList(researchReportTypeId int) (list []*ResearchReportTypeContent, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM research_report_type_content WHERE research_report_type_id = ? ORDER BY sort ASC `
-	_, err = o.Raw(sql, researchReportTypeId).QueryRows(&list)
-	return
-}
-
-func GetResearchReportTypeContentListByReportTypeIds(reportTypeIds string) (list []*ResearchReportTypeContent, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM research_report_type_content WHERE research_report_type_id IN (` + reportTypeIds + `) ORDER BY research_report_type_id ASC,sort ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-func GetResearchReportTypeTickerList(researchReportTypeId int) (list []*ResearchReportTypeTicker, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM research_report_type_ticker WHERE research_report_type_id = ? ORDER BY sort ASC `
-	_, err = o.Raw(sql, researchReportTypeId).QueryRows(&list)
-	return
-}
-
-func GetResearchReportTypeTickerListByReportTypeIds(reportTypeIds string) (list []*ResearchReportTypeTicker, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM research_report_type_ticker WHERE research_report_type_id IN (` + reportTypeIds + `) ORDER BY research_report_type_id ASC,sort ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-type CreateDayWeekReport struct {
-	Report      *Report
-	ChapterList []*CreateDayWeekReportChapter
-}
-
-type CreateDayWeekReportChapter struct {
-	Chapter    *ReportChapter
-	TickerList []*ReportChapterTicker
-}
-
-// 新增迁移晨周报
-func CreateMigrateNewDayWeekReport(newDayWeekReport *CreateDayWeekReport) (newReportId int, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-
-	// 新增报告
-	reportId, err := to.Insert(newDayWeekReport.Report)
-	if err != nil {
-		fmt.Println("InsertReportErr:" + err.Error())
-		return
-	}
-	// 新增章节
-	for _, chapter := range newDayWeekReport.ChapterList {
-		chapter.Chapter.ReportId = int(reportId)
-		lastChapterId, tmpErr := to.Insert(chapter.Chapter)
-		if tmpErr != nil {
-			err = tmpErr
-			return
-		}
-		// 新增晨报ticker
-		for _, ticker := range chapter.TickerList {
-			ticker.ReportChapterId = int(lastChapterId)
-			if _, tmpErr = to.Insert(ticker); tmpErr != nil {
-				err = tmpErr
-				return
-			}
-		}
-	}
-	// 修改报告code
-	reportCode := utils.MD5(strconv.Itoa(int(reportId)))
-	sql := `UPDATE report SET report_code = ? WHERE id = ? `
-	if _, err = to.Raw(sql, reportCode, reportId).Exec(); err != nil {
-		fmt.Println("UpdateReportCodeErr:" + err.Error())
-	}
-	newReportId = int(reportId)
-
-	return
-}
-
-// 新增迁移其他报告
-func CreateMigrateNewOtherReport(reportInfo *Report, mappingList []*ChartPermissionChapterMapping) (newReportId int, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-
-	// 新增报告
-	reportId, err := to.Insert(reportInfo)
-	if err != nil {
-		fmt.Println("InsertReportErr:" + err.Error())
-		return
-	}
-	// 修改报告code
-	reportCode := utils.MD5(strconv.Itoa(int(reportId)))
-	sql := `UPDATE report SET report_code = ? WHERE id = ? `
-	if _, err = to.Raw(sql, reportCode, reportId).Exec(); err != nil {
-		fmt.Println("UpdateReportCodeErr:" + err.Error())
-		return
-	}
-
-	// 新增权限
-	newReportId = int(reportId)
-	if len(mappingList) > 0 {
-		r := orm.NewOrm()
-		for _, mapping := range mappingList {
-			sql := ` INSERT INTO chart_permission_chapter_mapping (chart_permission_id, report_chapter_type_id,research_type) VALUES(?,?,?) `
-			if _, err = r.Raw(sql, mapping.ChartPermissionId, newReportId, "rddp").Exec(); err != nil {
-				fmt.Println("InsertChartPermissionErr:" + err.Error())
-				return
-			}
-		}
-	}
-
-	return
-}
-
-type ChartPermissionChapterMapping struct {
-	Id                  int    `orm:"column(id);pk"`
-	ChartPermissionId   int    `description:"权限ID"`
-	ReportChapterTypeId int    `description:"report_chapter_type表主键id或research_report表主键id或tactic表主键id"`
-	ResearchType        string `description:"报告类型 week;two_week;tactic;month;other;rddp; "`
-}
-
-func GetChapterPermissionMappingByCondition(reportChapterTypeId int, researchType string) (list []*ChartPermissionChapterMapping, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM chart_permission_chapter_mapping WHERE report_chapter_type_id = ? AND research_type = ? `
-	_, err = o.Raw(sql, reportChapterTypeId, researchType).QueryRows(&list)
-	return
-}
-
-func GetChapterPermissionMappingByResearchReportIds(researchReportIds string) (list []*ChartPermissionChapterMapping, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM chart_permission_chapter_mapping WHERE report_chapter_type_id IN (` + researchReportIds + `) AND research_type != "rddp" ORDER BY report_chapter_type_id ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}

+ 0 - 376
models/system/sys_admin.go

@@ -1,9 +1,7 @@
 package system
 
 import (
-	"fmt"
 	"github.com/beego/beego/v2/client/orm"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"strings"
 	"time"
 )
@@ -42,87 +40,6 @@ type AdminItem struct {
 	EmployeeId              string `description:"员工工号(钉钉/每刻报销)"`
 }
 
-func GetSysuserList(condition string, pars []interface{}, startSize, pageSize int) (items []*AdminItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM admin WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-	sql += `ORDER BY created_time DESC LIMIT ?,?`
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
-	return
-}
-
-func GetSysuserListCount(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT COUNT(1) AS count FROM admin WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-	err = o.Raw(sql, pars).QueryRow(&count)
-	return
-}
-
-type AdminRespItem struct {
-	AdminId                 int    `description:"系统用户id"`
-	AdminName               string `description:"系统用户名称"`
-	RealName                string `description:"系统用户姓名"`
-	Password                string
-	LastUpdatedPasswordTime string `json:"-"`
-	Enabled                 int    `description:"1:有效,0:禁用"`
-	Email                   string `description:"系统用户邮箱"`
-	LastLoginTime           string
-	CreatedTime             time.Time
-	LastUpdatedTime         string
-	Role                    string `description:"系统用户角色"`
-	Mobile                  string `description:"手机号"`
-	RoleType                int    `description:"角色类型:1需要录入指标,0:不需要"`
-	RoleId                  int    `description:"角色id"`
-	RoleName                string `description:"角色名称"`
-	RoleTypeCode            string `description:"角色编码"`
-	DepartmentId            int    `description:"部门id"`
-	DepartmentName          string `json:"-" description:"部门名称"`
-	parentId                int    `description:"父级id"`
-	GroupId                 int    `description:"分组id"`
-	GroupName               string `json:"-" description:"分组名称"`
-	Authority               int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,4:ficc销售组长"`
-	Position                string `description:"职位"`
-	DepartmentGroup         string `description:"部门分组"`
-	LabelVal                int    `description:"标签:1:超级管理员,2:管理员,3:部门经理,4:组长,5:ficc销售主管"`
-}
-
-type SysuserListResp struct {
-	List   []*AdminItem
-	Paging *paging.PagingItem `description:"分页数据"`
-}
-
-type SysuserAddReq struct {
-	AdminName    string `description:"系统用户名称"`
-	AdminAvatar  string `description:"用户头像"`
-	RealName     string `description:"系统用户姓名"`
-	Password     string `description:"密码"`
-	Mobile       string `description:"手机号"`
-	RoleId       int    `description:"角色id"`
-	DepartmentId int    `description:"部门id"`
-	GroupId      int    `description:"分组id"`
-	TeamId       int    `description:"小组id"`
-	//Authority    int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人"`
-	Position         string `description:"职位"`
-	ResearchGroupIds string `description:"研究方向分组IDs"`
-	Province         string `description:"省"`
-	ProvinceCode     string `description:"省编码"`
-	City             string `description:"市"`
-	CityCode         string `description:"市编码"`
-	EmployeeId       string `description:"员工工号(钉钉/每刻报销)"`
-}
-
-func GetSysAdminCount(adminName string) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM admin WHERE admin_name=? `
-	o := orm.NewOrm()
-	err = o.Raw(sql, adminName).QueryRow(&count)
-	return
-}
-
 func GetSysAdminByName(adminName string) (item *Admin, err error) {
 	sql := `SELECT * FROM admin WHERE admin_name=? `
 	o := orm.NewOrm()
@@ -137,193 +54,6 @@ func GetSysAdminById(adminId int) (item *Admin, err error) {
 	return
 }
 
-func AddAdmin(item *Admin) (err error) {
-	o := orm.NewOrm()
-	adminId, err := o.Insert(item)
-	item.AdminId = int(adminId)
-	return
-}
-
-type SysuserEditReq struct {
-	AdminId      int    `description:"系统用户id"`
-	AdminName    string `description:"系统用户名称"`
-	AdminAvatar  string `description:"用户头像"`
-	RealName     string `description:"系统用户姓名"`
-	Password     string `description:"密码"`
-	Mobile       string `description:"手机号"`
-	RoleId       int    `description:"角色id"`
-	DepartmentId int    `description:"部门id"`
-	GroupId      int    `description:"分组id"`
-	TeamId       int    `description:"小组id"`
-	Enabled      int    `description:"1:有效,0:禁用"`
-	//Authority    int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人"`
-	Position         string `description:"职位"`
-	ResearchGroupIds string `description:"研究方向分组IDs"`
-	Province         string `description:"省"`
-	ProvinceCode     string `description:"省编码"`
-	City             string `description:"市"`
-	CityCode         string `description:"市编码"`
-	EmployeeId       string `description:"员工工号(钉钉/每刻报销)"`
-}
-
-// 用户状态编辑
-type SysuserEditEnabledReq struct {
-	AdminId int `description:"系统用户id"`
-	Enabled int `description:"1:有效,0:禁用"`
-}
-
-func EditAdmin(item *Admin) (err error) {
-	o := orm.NewOrm()
-	sql := `UPDATE admin
-			SET
-			  admin_name= ?,
-			  real_name = ?,
-			  password = ?,
-			  last_updated_password_time = NOW(),
-			  email = ?,
-			  last_updated_time = NOW(),
-			  mobile = ?,
-			  role_type = ?,
-			  role_id = ?,
-			  role_name = ?,
-			  department_id = ?,
-			  department_name = ?,
-			  group_id = ?,
-			  group_name = ?,
-			  authority = ?,
-			  position = ?,
-			  role_type_code=?,
-			  enabled=?,
-			  admin_avatar = ?,
-			  province=?,
-			  province_code=?,
-			  city=?,
-			  city_code=?,
-			  employee_id = ?
-			WHERE admin_id = ? `
-	_, err = o.Raw(sql, item.AdminName, item.RealName, item.Password, item.Email, item.Mobile, item.RoleType, item.RoleId, item.RoleName, item.DepartmentId, item.DepartmentName,
-		item.GroupId, item.GroupName, item.Authority, item.Position, item.RoleTypeCode, item.Enabled, item.AdminAvatar, item.Province, item.ProvinceCode, item.City, item.CityCode, item.EmployeeId, item.AdminId).Exec()
-	return
-}
-
-// 变更状态
-func EditAdminEnabled(item *Admin) (err error) {
-	o := orm.NewOrm()
-	sql := `UPDATE admin
-			SET
-			  last_updated_time = NOW(),enabled=? WHERE admin_id = ? `
-	_, err = o.Raw(sql, item.Enabled, item.AdminId).Exec()
-	return
-}
-
-// DisableAdmin 禁用用户
-func DisableAdmin(adminId int) (err error) {
-	o := orm.NewOrm()
-	sql := `UPDATE admin
-			SET
-			  last_updated_time = NOW(),disable_time=now(),enabled=0 WHERE admin_id = ? `
-	_, err = o.Raw(sql, adminId).Exec()
-	return
-}
-
-type SysuserDeleteReq struct {
-	AdminId int `description:"系统用户id"`
-}
-
-func DeleteSysuser(adminId int) (err error) {
-	sql := `DELETE FROM admin WHERE admin_id=? `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, adminId).Exec()
-	return
-}
-
-// GetSysAdminCountByMobile 查询系统中是否存在该手机号(如果有传入用户id,那么排除该用户)
-func GetSysAdminCountByMobile(mobile string, adminId int) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM admin WHERE mobile=? `
-	if adminId > 0 {
-		sql += ` AND admin_id != ` + fmt.Sprint(adminId)
-	}
-	o := orm.NewOrm()
-	err = o.Raw(sql, mobile).QueryRow(&count)
-	return
-}
-
-func GetSysUserItems(condition string, pars []interface{}) (items []*AdminItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM admin WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-	sql += `ORDER BY last_updated_time DESC `
-	_, err = o.Raw(sql, pars).QueryRows(&items)
-	return
-}
-
-func GetSysUserItemsOrderByCreated(condition string, pars []interface{}) (items []*AdminItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM admin WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-	sql += ` ORDER BY created_time DESC `
-	_, err = o.Raw(sql, pars).QueryRows(&items)
-	return
-}
-func GetSysUserItemsList(condition string, pars []interface{}, startSize, pageSize int) (items []*AdminItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM admin WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-	sql += ` ORDER BY created_time DESC limit ?,?`
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
-	return
-}
-func GetSysUserItemsTotal(condition string, pars []interface{}) (total int64, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT count(*) FROM admin WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-	err = o.Raw(sql, pars).QueryRow(&total)
-	return
-}
-
-// GetGroupSysUserList 根据分组id获取系统用户列表
-func GetGroupSysUserList(groupId int) (items []*AdminItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM admin WHERE group_id=? ORDER BY created_time DESC `
-	_, err = o.Raw(sql, groupId).QueryRows(&items)
-	return
-}
-
-// GetDepartmentGroupSysUserList 根据部门id和分组id获取系统用户列表
-func GetDepartmentGroupSysUserList(departmentId, groupId int, roleTypeCodes string) (items []*AdminItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM admin WHERE department_id = ? and group_id=? and enabled=1 `
-	if roleTypeCodes != "" {
-		sql += ` and role_type_code in (` + roleTypeCodes + `) `
-	}
-	sql += ` ORDER BY created_time asc `
-	_, err = o.Raw(sql, departmentId, groupId).QueryRows(&items)
-	return
-}
-
-// GetGrooupsysUserList 根据大组id和小组id获取系统用户列表
-func GetGrooupsysUserList(groupId int, roleTypeCodes string, enabled int) (items []*AdminItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM admin WHERE group_id = ? `
-	if roleTypeCodes != "" {
-		sql += ` and role_type_code in (` + roleTypeCodes + `) `
-	}
-	if enabled >= 0 {
-		sql += fmt.Sprint(` AND enabled=`, enabled, ` `)
-	}
-	sql += ` ORDER BY created_time asc `
-	_, err = o.Raw(sql, groupId).QueryRows(&items)
-	return
-}
-
 // GetSysAdminByIdSlice 根据账户id列表获取账户信息列表
 func GetSysAdminByIdSlice(adminIdList []string) (items []*Admin, err error) {
 	if len(adminIdList) <= 0 {
@@ -335,115 +65,9 @@ func GetSysAdminByIdSlice(adminIdList []string) (items []*Admin, err error) {
 	return
 }
 
-// GetTeamSysUserList 根据小组id获取系统用户列表
-func GetTeamSysUserList(teamId, enabled int) (items []*AdminItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM admin WHERE group_id=? `
-	if enabled >= 0 {
-		sql += fmt.Sprint(` AND enabled=`, enabled, ` `)
-	}
-	sql += ` ORDER BY created_time DESC `
-	_, err = o.Raw(sql, teamId).QueryRows(&items)
-	return
-}
-
-// GetTeamSysUserList 根据小组id获取系统用户列表
-func GetTeamSysUserListByIds(ids string) (items []*AdminItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM admin WHERE group_id IN (` + ids + `) ORDER BY created_time DESC `
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-func GetGroupIdByParentId(groupId int) (items []*string, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT group_id FROM sys_group WHERE parent_id=? ORDER BY create_time DESC `
-	_, err = o.Raw(sql, groupId).QueryRows(&items)
-	return
-}
-
-// GetSysUserByParentIdGroupId 查询主管下的所有组员
-func GetSysUserByParentIdGroupId(groupId int) (items []*AdminItem, err error) {
-	o := orm.NewOrm()
-	sql := `select real_name, role_id, role_type_code, group_id, admin_id from admin where group_id in (SELECT group_id from sys_group where parent_id=?) OR group_id=?`
-	_, err = o.Raw(sql, groupId, groupId).QueryRows(&items)
-	return
-}
 func GetAdminByGroupId(groupId int) (items []*AdminItem, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM admin WHERE group_id=? ORDER BY created_time DESC`
 	_, err = o.Raw(sql, groupId).QueryRows(&items)
 	return
 }
-
-// GetSysAdminByIds 根据主键集合获取管理员信息
-func GetSysAdminByIds(adminIds string) (items []*Admin, err error) {
-	if adminIds == "" {
-		return
-	}
-	o := orm.NewOrm()
-	sql := `SELECT * FROM admin WHERE admin_id IN (` + adminIds + `)`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-type OpenIdList struct {
-	OpenId  string
-	AdminId int
-}
-
-// GetAdminOpenIdListByMobile 根据手机号获取用户的openid列表
-func GetAdminOpenIdListByMobile(mobile string) (items []*OpenIdList, err error) {
-	sql := `SELECT admin_id, open_id FROM admin 
-          WHERE open_id != "" and mobile=? `
-	_, err = orm.NewOrm().Raw(sql, mobile).QueryRows(&items)
-	return
-}
-
-// ResearcherAdminAndUser 研究员admin信息及wx_user信息
-type ResearcherAdminAndUser struct {
-	UserId    int    `description:"用户ID"`
-	UserName  string `description:"用户名称"`
-	AdminId   int    `description:"管理员ID"`
-	AdminName string `description:"管理员姓名"`
-	OpenId    string `description:"openid"`
-}
-
-// GetResearcherAdminAndWxUserByAdminId 通过adminId获取研究员admin及user信息
-func GetResearcherAdminAndWxUserByAdminId(adminId int) (item *ResearcherAdminAndUser, err error) {
-	sql := `SELECT
-				a.admin_id,
-				a.real_name AS admin_name,
-				a.open_id,
-				b.user_id,
-				b.real_name AS user_name
-			FROM
-				admin AS a
-			JOIN wx_user AS b ON a.mobile = b.mobile
-			WHERE
-				a.admin_id = ? AND a.open_id != ""`
-	err = orm.NewOrm().Raw(sql, adminId).QueryRow(&item)
-	return
-}
-
-// 获取本组的销售ID
-func GetSelleridWhichGroup(companyId, productId int) (adminId string, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT
-			GROUP_CONCAT( DISTINCT admin_id SEPARATOR ',' ) AS adminId
-			FROM
-			admin
-			WHERE
-			group_id IN (
-			SELECT
-			a.group_id
-			FROM
-			company_product AS a
-			INNER JOIN admin AS b ON a.seller_id = b.admin_id
-			WHERE
-			a.company_id = ?
-			AND a.product_id = ?
-)`
-	err = o.Raw(sql, companyId, productId).QueryRow(&adminId)
-	return
-}

+ 0 - 226
models/system/sys_role_admin.go

@@ -1,7 +1,6 @@
 package system
 
 import (
-	"eta/eta_mobile/utils"
 	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
@@ -13,25 +12,6 @@ type SysRoleAdmin struct {
 	CreateTime time.Time `orm:"column(create_time);" description:"创建时间"`
 }
 
-type RoleAdminItem struct {
-	SysRoleAdminId  int    `description:"管理员账号和角色映射表id"`
-	AdminId         int    `description:"系统用户id"`
-	AdminName       string `description:"系统用户名称"`
-	RealName        string `description:"系统用户姓名"`
-	Enabled         int    `description:"1:有效,0:禁用"`
-	Mobile          string `description:"手机号"`
-	RoleId          int    `description:"角色Id"`
-	RoleTypeCode    string `description:"角色编码"`
-	DepartmentId    int    `description:"部门id"`
-	DepartmentName  string `description:"部门名称"`
-	DepartmentGroup string `description:"部门分组"`
-	TeamId          int    `description:"小组id"`
-	GroupId         int    `description:"分组id"`
-	GroupName       string `description:"分组名称"`
-	Authority       int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,4:ficc销售组长"`
-	LabelVal        int    `description:"标签:1:超级管理员,2:管理员,3:部门经理,4:组长,5:ficc销售主管"`
-}
-
 func (sa *SysRoleAdmin) TableName() string {
 	return "sys_role_admin"
 }
@@ -42,209 +22,3 @@ func GetRoleIdsByAdminId(adminId int) (items []*SysRoleAdmin, err error) {
 	_, err = orm.NewOrm().Raw(sql, adminId).QueryRows(&items)
 	return
 }
-
-// GetRoleIdsByAdminIdRoleId 根据管理员账号和角色查询
-func GetRoleIdsByAdminIdRoleId(adminId int, roleId int) (item *SysRoleAdmin, err error) {
-	sql := `SELECT * from sys_role_admin where admin_id = ? and role_id=?`
-	err = orm.NewOrm().Raw(sql, adminId, roleId).QueryRow(&item)
-	return
-}
-
-// GetRoleAdminList 查询对应角色绑定的管理员列表
-func GetRoleAdminList(condition string, pars []interface{}, startSize, pageSize int) (list []*RoleAdminItem, err error) {
-	sql := `SELECT
-	s.id as sys_role_admin_id,
-	a.admin_id,
-	a.admin_name,
-	a.real_name,
-	a.mobile,
-	a.department_id,
-	a.department_name,
-	a.enabled,
-	a.role_id,
-	a.role_type_code ,
-	a.group_id,
-	a.authority,
-	a.group_name
-FROM
-	sys_role_admin s
-	INNER JOIN admin a ON s.admin_id = a.admin_id 
-where 1=1`
-	if condition != "" {
-		sql += condition
-	}
-	sql += ` ORDER BY s.id DESC limit ?, ?`
-	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
-	return
-}
-
-// GetRoleAdminListTotal 查询对应角色绑定的管理员列表总数
-func GetRoleAdminListTotal(condition string, pars []interface{}) (total int64, err error) {
-	sql := `SELECT
-	count(*)
-FROM
-	sys_role_admin s
-	INNER JOIN admin a ON s.admin_id = a.admin_id 
-where 1=1`
-	if condition != "" {
-		sql += condition
-	}
-	err = orm.NewOrm().Raw(sql, pars).QueryRow(&total)
-	return
-}
-
-// CheckRoleAdminByAdminIds 判断是否已经绑定过该角色
-func CheckRoleAdminByAdminIds(adminIds string, roleId int) (list []*SysRoleAdmin, err error) {
-	sql := `SELECT
-	s.*
-FROM
-	sys_role_admin s
-	LEFT JOIN admin a ON s.admin_id = a.admin_id 
-where s.role_id=? and s.admin_id in (` + adminIds + `)`
-	_, err = orm.NewOrm().Raw(sql, roleId).QueryRows(&list)
-	return
-}
-
-// AddRoleAdminBatch 批量新增留言版管理员
-func AddRoleAdminBatch(admins []*SysRoleAdmin) (err error) {
-	o := orm.NewOrm()
-	_, err = o.InsertMulti(len(admins), admins)
-	return
-}
-
-// DeleteRoleAdmin 删除管理员和角色的绑定
-func DeleteRoleAdmin(SysRoleAdminId int) (err error) {
-	sql := `DELETE FROM sys_role_admin WHERE id=? `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, SysRoleAdminId).Exec()
-	return
-}
-
-// GetRoleAdminById 根据ID查询绑定记录
-func GetRoleAdminById(SysRoleAdminId int) (item *SysRoleAdmin, err error) {
-	sql := `SELECT
-	*
-FROM
-	sys_role_admin 
-where id=?`
-	err = orm.NewOrm().Raw(sql, SysRoleAdminId).QueryRow(&item)
-	return
-}
-
-// GetEnglishAuthRoleAdminList 查询英文权限管理员列表
-func GetEnglishAuthRoleAdminList(condition string, pars []interface{}, startSize, pageSize int) (total int, list []*RoleAdminItem, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-				s.id as sys_role_admin_id,
-				a.admin_id,
-				a.admin_name,
-				a.real_name,
-				a.mobile,
-				a.department_id,
-				a.department_name,
-				a.enabled,
-				a.role_id,
-				a.role_type_code ,
-				a.group_id,
-				a.authority,
-				a.group_name
-			FROM
-				sys_role_admin AS s
-			JOIN sys_role AS r ON s.role_id = r.role_id
-			JOIN admin AS a ON s.admin_id = a.admin_id
-			WHERE
-				1 = 1 `
-	sql += condition
-	sql += ` GROUP BY s.admin_id `
-
-	totalSQl := `SELECT COUNT(1) total FROM (` + sql + `) z`
-	if err = o.Raw(totalSQl, pars).QueryRow(&total); err != nil {
-		return
-	}
-
-	sql += ` ORDER BY s.create_time DESC,s.admin_id ASC LIMIT ?,? `
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
-	return
-}
-
-// DeleteRoleAdminByAdminIdAndRoleIds 通过管理员ID及角色IDs删除绑定
-func DeleteRoleAdminByAdminIdAndRoleIds(adminId int, roleIds []int) (err error) {
-	if len(roleIds) == 0 {
-		return
-	}
-	o := orm.NewOrm()
-	sql := `DELETE FROM sys_role_admin WHERE admin_id = ? AND role_id IN (` + utils.GetOrmInReplace(len(roleIds)) + `) `
-	_, err = o.Raw(sql, adminId, roleIds).Exec()
-	return
-}
-
-// CheckEnglishAuthRoleAdminByAdminIds 通过管理员IDs判断是否已经绑定过英文权限角色
-func CheckEnglishAuthRoleAdminByAdminIds(adminIds []int, roleCodes []string) (list []*SysRoleAdmin, err error) {
-	if len(adminIds) == 0 || len(roleCodes) == 0 {
-		return
-	}
-	o := orm.NewOrm()
-	sql := `SELECT
-				s.*
-			FROM
-				sys_role_admin AS s
-			JOIN sys_role AS r ON s.role_id = r.role_id
-			JOIN admin AS a ON s.admin_id = a.admin_id
-			WHERE
-				s.admin_id IN (` + utils.GetOrmInReplace(len(adminIds)) + `) AND r.role_type_code IN (` + utils.GetOrmInReplace(len(roleCodes)) + `)
-			GROUP BY
-				s.admin_id`
-	_, err = o.Raw(sql, adminIds, roleCodes).QueryRows(&list)
-	return
-}
-
-// EnglishAuthRoleDetail 英文权限角色详情
-type EnglishAuthRoleDetail struct {
-	AdminId      int    `description:"用户ID"`
-	RoleTypeCode string `description:"角色类型编码"`
-}
-
-// GetAdminEnglishAuthRoleDetail 获取用户英文权限详情
-func GetAdminEnglishAuthRoleDetail(adminId int, roleCodes []string) (list []*EnglishAuthRoleDetail, err error) {
-	if len(roleCodes) == 0 {
-		return
-	}
-	o := orm.NewOrm()
-	sql := `SELECT
-				s.admin_id, r.role_type_code
-			FROM
-				sys_role_admin AS s
-			JOIN sys_role AS r ON s.role_id = r.role_id
-			JOIN admin AS a ON s.admin_id = a.admin_id
-			WHERE
-				s.admin_id = ? AND r.role_type_code IN (` + utils.GetOrmInReplace(len(roleCodes)) + `)`
-	_, err = o.Raw(sql, adminId, roleCodes).QueryRows(&list)
-	return
-}
-
-// EditEnglishAuthRoleAdmin 编辑管理员英文权限
-func EditEnglishAuthRoleAdmin(adminId int, englishRoleIds []int, roleAdmins []*SysRoleAdmin) (err error) {
-	o := orm.NewOrm()
-	tx, e := o.Begin()
-	if e != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = tx.Rollback()
-		} else {
-			_ = tx.Commit()
-		}
-	}()
-
-	// 删除原绑定关系
-	sql := `DELETE FROM sys_role_admin WHERE admin_id = ? AND role_id IN (` + utils.GetOrmInReplace(len(englishRoleIds)) + `)`
-	_, err = tx.Raw(sql, adminId, englishRoleIds).Exec()
-	if err != nil {
-		return
-	}
-
-	// 新增绑定关系
-	_, err = o.InsertMulti(len(roleAdmins), roleAdmins)
-	return
-}

+ 0 - 106
models/system/sys_user.go

@@ -86,100 +86,6 @@ func GetSysUserById(sysUserId int) (item *Admin, err error) {
 	return
 }
 
-// 根据权限code获取系统用户列表
-func GetAdminListByRoleCode(roleTypeCode string) (items []*Admin, err error) {
-	sql := `SELECT * FROM admin WHERE role_type_code=? and enabled=1 `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, roleTypeCode).QueryRows(&items)
-	return
-}
-
-// 根据权限id获取系统用户列表
-func GetAdminListByRoleId(roleId string) (items []*Admin, err error) {
-	sql := `SELECT * FROM admin WHERE role_id=? and enabled=1 `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, roleId).QueryRows(&items)
-	return
-}
-
-// GetAdminListByIds 根据用户id字符串获取系统用户列表
-func GetAdminListByIds(ids string) (items []*Admin, err error) {
-	sql := `SELECT * FROM admin WHERE admin_id in (` + ids + `) and enabled=1 `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-func ModifyPwd(sysUserId int, newPwd string) (err error) {
-	sql := `UPDATE admin SET password=?,last_updated_time=NOW() WHERE admin_id=? `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, newPwd, sysUserId).Exec()
-	return
-}
-
-type ModifyPwdReq struct {
-	OldPwd string `description:"旧密码"`
-	NewPwd string `description:"新密码"`
-}
-
-func GetAdminList() (items []*Admin, err error) {
-	sql := `SELECT * FROM admin`
-	o := orm.NewOrm()
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// GetSysUserByMobile 根据手机号获取管理信息
-//func GetSysUserByMobile(mobile string) (item *Admin, err error) {
-//	sql := `SELECT * FROM admin WHERE mobile = ? LIMIT 1`
-//	o := orm.NewOrm()
-//	err = o.Raw(sql, mobile).QueryRow(&item)
-//	return
-//}
-
-// 通过用户姓名跟身份获取管理员信息
-func CheckSysUserByName(userName, roleTypeCode string) (item *Admin, err error) {
-	sql := ` SELECT a.*  FROM admin AS a WHERE a.real_name=? AND a.role_type_code=? LIMIT 1`
-	o := orm.NewOrm()
-	err = o.Raw(sql, userName, roleTypeCode).QueryRow(&item)
-	return
-}
-
-// GetAdminListByGroupId 根据分组id获取系统用户列表
-func GetAdminListByGroupId(groupId int) (items []*Admin, err error) {
-	sql := `SELECT * FROM admin WHERE group_id=? and enabled=1 `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, groupId).QueryRows(&items)
-	return
-}
-
-// AdminWxUserRelation 管理员-微信用户关联
-type AdminWxUserRelation struct {
-	AdminId   int    `json:"admin_id"`
-	AdminName string `json:"admin_name"`
-	RealName  string `json:"real_name"`
-	UserId    int    `json:"user_id"`
-}
-
-// GetAdminWxUserRelationByWxUserIds 通过微信用户及平台获取后台关联信息
-func GetAdminWxUserRelationByWxUserIds(platform int, userIds []int) (list []*AdminWxUserRelation, err error) {
-	userLen := len(userIds)
-	if userLen == 0 {
-		return
-	}
-	o := orm.NewOrm()
-	sql := `SELECT
-				ad.admin_id, ad.admin_name, ad.real_name, wu.user_id
-			FROM
-				admin AS ad
-			JOIN wx_user AS wu ON ad.mobile = wu.mobile
-			JOIN user_record AS ur ON wu.user_id = ur.user_id AND ur.create_platform = ?
-			WHERE
-				wu.user_id IN (` + utils.GetOrmInReplace(userLen) + `)`
-	_, err = o.Raw(sql, platform, userIds).QueryRows(&list)
-	return
-}
-
 // GetAdminListByIdList 根据用户id列表获取系统用户列表
 func GetAdminListByIdList(idList []int) (items []*Admin, err error) {
 	lenNum := len(idList)
@@ -192,18 +98,6 @@ func GetAdminListByIdList(idList []int) (items []*Admin, err error) {
 	return
 }
 
-// GetAdminListByIdList 根据用户id列表获取系统用户列表
-func GetAdminListByIdListWithoutEnable(idList []int) (items []*Admin, err error) {
-	lenNum := len(idList)
-	if lenNum <= 0 {
-		return
-	}
-	sql := `SELECT * FROM admin WHERE admin_id in (` + utils.GetOrmInReplace(lenNum) + `) `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, idList).QueryRows(&items)
-	return
-}
-
 // GetSysUserByMobile 手机号获取用户
 func GetSysUserByMobile(mobile string) (item *Admin, err error) {
 	o := orm.NewOrm()

+ 0 - 1417
models/target.go

@@ -1,141 +1,9 @@
 package models
 
 import (
-	"eta/eta_mobile/utils"
-	"fmt"
 	"github.com/beego/beego/v2/client/orm"
-	"github.com/rdlucklib/rdluck_tools/paging"
-	"sort"
-	"strconv"
-	"strings"
-	"time"
 )
 
-type DataList struct {
-	TradeCode    string  `orm:"column(TRADE_CODE)" description:"指标编码"`
-	SecName      string  `orm:"column(SEC_NAME)" description:"指标名称"`
-	Unit         string  `orm:"column(UNIT)" description:"单位"`
-	Remark       string  `orm:"column(REMARK)" description:"备注"`
-	Frequency    string  `description:"频度"`
-	ClassifyId   int     `description:"分类id"`
-	ClassifyName string  `description:"分类名称"`
-	Dt           string  `orm:"column(DT)" description:"录入日期"`
-	Close        float64 `orm:"column(CLOSE)" description:"录入值"`
-	ModifyTime   string  `description:"修改时间"`
-}
-
-type DataListResp struct {
-	List   []*DataList
-	Paging *paging.PagingItem `description:"分页数据"`
-}
-
-func GetDataList(condition string, pars []interface{}, startSize, pageSize int) (items []*DataList, err error) {
-	sql := `select a.TRADE_CODE,a.SEC_NAME,a.UNIT,a.frequency,a.classify_id,b.classify_name,c.DT,c.CLOSE,c.modify_time FROM edbdata AS c
-                inner join edbinfo AS a ON a.TRADE_CODE=c.TRADE_CODE
-                left join edbdata_classify AS b ON a.classify_id=b.classify_id
-                where left(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0`
-	if condition != "" {
-		sql += condition
-	}
-	sql += ` order by c.DT desc limit ?,? `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
-	return
-}
-
-func GetDataListCount(condition string, pars []interface{}) (count int, err error) {
-	sql := ` select count(1) as count FROM edbdata AS c
-                    inner join edbinfo AS a ON a.TRADE_CODE=c.TRADE_CODE    
-                    left join edbdata_classify AS b ON a.classify_id=b.classify_id
-                    where left(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0 `
-	if condition != "" {
-		sql += condition
-	}
-	o := orm.NewOrmUsingDB("edb")
-	err = o.Raw(sql, pars).QueryRow(&count)
-	return
-}
-
-type DataAddReq struct {
-	TradeCode  string `description:"指标唯一编码"`
-	CreateDate string `description:"创建日期"`
-	Close      string `description:"录入值"`
-}
-
-type Edbdata struct {
-	TradeCode  string    `orm:"column(TRADE_CODE);pk" description:"指标编码"`
-	Dt         string    `orm:"column(DT)" description:"日期"`
-	Close      string    `orm:"column(CLOSE)" description:"值"`
-	ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"`
-}
-
-func GetDataInfo(tradeCode, creteDate string) (item *Edbdata, err error) {
-	sql := " SELECT * FROM edbdata WHERE TRADE_CODE=? AND DT=? "
-	o := orm.NewOrmUsingDB("edb")
-	err = o.Raw(sql, tradeCode, creteDate).QueryRow(&item)
-	return
-}
-
-func AddEdbdata(item *Edbdata) (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("edb")
-	lastId, err = o.Insert(item)
-	return
-}
-
-type DataEditReq struct {
-	TradeCode     string      `description:"指标唯一编码"`
-	CreateDate    string      `description:"创建日期"`
-	Close         interface{} `description:"录入值"`
-	OldCreateDate string      `description:"旧的录入日期"`
-}
-
-// BatchDataEditReq 批量修改指标
-type BatchDataEditReq struct {
-	OldCreateDate string        `description:"旧的录入日期"`
-	CreateDate    string        `description:"新的录入日期"`
-	List          []DataEditReq `description:"需要修改的数据"`
-}
-
-// 编辑数据
-func EditEdbdata(item *Edbdata) (err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := ` UPDATE edbdata SET CLOSE = ?,modify_time=NOW() WHERE TRADE_CODE = ? AND DT = ? `
-	_, err = o.Raw(sql, item.Close, item.TradeCode, item.Dt).Exec()
-	return
-}
-
-type EdbdataDeleteRecord struct {
-	Id         int       `orm:"column(id);pk"`
-	TradeCode  string    `orm:"column(TRADE_CODE)" description:"指标编码"`
-	Dt         string    `orm:"column(DT)" description:"日期"`
-	Close      string    `orm:"column(CLOSE)" description:"值"`
-	ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"`
-	CreateTime time.Time
-	SysUserId  int
-}
-
-func AddEdbdataDeleteRecord(item *EdbdataDeleteRecord) (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("edb")
-	lastId, err = o.Insert(item)
-	return
-}
-
-// DeleteEdbData 根据指标code和日期删除数据
-func DeleteEdbData(tradeCode, dt string) (err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := ` DELETE FROM edbdata WHERE TRADE_CODE = ? AND DT = ? `
-	_, err = o.Raw(sql, tradeCode, dt).Exec()
-	return
-}
-
-// DeleteAllEdbData 根据指标code删除数据
-func DeleteAllEdbData(tradeCode string) (err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := ` DELETE FROM edbdata WHERE TRADE_CODE = ? `
-	_, err = o.Raw(sql, tradeCode).Exec()
-	return
-}
-
 type Edbinfo struct {
 	TradeCode    string `orm:"column(TRADE_CODE);pk" description:"指标code"`
 	SecName      string `orm:"column(SEC_NAME);" description:"指标名称"`
@@ -151,1294 +19,9 @@ type Edbinfo struct {
 	Mobile       string `description:"录入者手机号"`
 }
 
-func GetEdbinfoListCount(condition string, pars []interface{}, mobile string, roleType int) (count int, err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := ``
-	if mobile != "" && roleType == 1 {
-		sql = `SELECT COUNT(1) AS count FROM edbinfo AS a 
-             INNER JOIN edbinfo_user AS c ON a.TRADE_CODE=c.TRADE_CODE AND c.mobile=?
-             WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0`
-
-		if condition != "" {
-			sql += condition
-		}
-		err = o.Raw(sql, mobile, pars).QueryRow(&count)
-	} else {
-		sql := `SELECT COUNT(1) AS count FROM edbinfo AS a WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0`
-
-		if condition != "" {
-			sql += condition
-		}
-		err = o.Raw(sql, pars).QueryRow(&count)
-	}
-	return
-}
-
-func GetEdbinfoList(condition string, pars []interface{}, startSize, pageSize int, mobile string, roleType int) (items []*Edbinfo, err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := ``
-	if mobile != "" && roleType == 1 {
-		sql = ` SELECT DISTINCT a.*,b.classify_name FROM edbinfo AS a
-                    LEFT JOIN edbdata_classify AS b ON a.classify_id=b.classify_id
-                    INNER JOIN edbinfo_user AS c ON a.TRADE_CODE=c.TRADE_CODE AND c.mobile=?
-                    WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0`
-		if condition != "" {
-			sql += condition
-		}
-		sql += ` ORDER BY a.create_date DESC LIMIT ?,? `
-		_, err = o.Raw(sql, mobile, pars, startSize, pageSize).QueryRows(&items)
-	} else {
-		sql = `SELECT DISTINCT a.*,b.classify_name FROM edbinfo AS a
-                     LEFT JOIN edbdata_classify AS b on a.classify_id=b.classify_id
-                     WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0`
-		if condition != "" {
-			sql += condition
-		}
-		sql += ` ORDER BY a.create_date DESC LIMIT ?,? `
-		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
-	}
-	return
-}
-
-// EdbParamsInfo 指标数据结构体
-type EdbParamsInfo struct {
-	Unit      string `orm:"column(UNIT);" description:"单位"`
-	Frequency string `orm:"column(frequency);" description:"单位"`
-}
-
-// GetEdbUnitList 获取指标单位
-func GetEdbUnitList() (items []*EdbParamsInfo, err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := `SELECT UNIT from edbinfo group by UNIT`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// GetEdbFrequencyList 获取指标频度
-func GetEdbFrequencyList(classifyId, userId int) (items []*EdbParamsInfo, err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := `SELECT frequency from edbinfo a 
-join edbdata b on a.TRADE_CODE=b.TRADE_CODE
- where classify_id = ? `
-	if userId > 0 {
-		sql += ` and a.user_id = ` + fmt.Sprint(userId) + ` `
-	}
-	sql += ` group by a.frequency`
-	_, err = o.Raw(sql, classifyId).QueryRows(&items)
-	return
-}
-
-type TargetListResp struct {
-	List   []*Edbinfo
-	Paging *paging.PagingItem `description:"分页数据"`
-}
-
-type EdbinfoAddReq struct {
-	SecName    string `description:"指标名称"`
-	Unit       string `description:"单位"`
-	Frequency  string `description:"频度"`
-	ClassifyId int    `description:"分类id"`
-	NoticeTime string `description:"通知时间"`
-}
-
-// GetMaxTradeCode 获取指标最大trade_code
-func GetMaxTradeCode() (max_trade_code string, err error) {
-	sql := " SELECT MAX(TRADE_CODE) AS max_trade_code FROM edbinfo WHERE LEFT(TRADE_CODE,1)='W' AND TRADE_CODE not like '%index%'"
-	o := orm.NewOrmUsingDB("edb")
-	err = o.Raw(sql).QueryRow(&max_trade_code)
-	if (err != nil && err.Error() == utils.ErrNoRow()) || max_trade_code == `` {
-		max_trade_code = "W00"
-	}
-	return
-}
-
-func GetEdbinfoBySecName(secName string) (item *Edbinfo, err error) {
-	sql := `SELECT * FROM edbinfo WHERE SEC_NAME=? AND left(TRADE_CODE,1)='W' AND REMARK='手动' `
-	o := orm.NewOrmUsingDB("edb")
-	err = o.Raw(sql, secName).QueryRow(&item)
-	return
-}
-
 func GetEdbinfoByTradeCode(tradeCode string) (item *Edbinfo, err error) {
 	sql := `SELECT * FROM edbinfo WHERE TRADE_CODE=? `
 	o := orm.NewOrmUsingDB("edb")
 	err = o.Raw(sql, tradeCode).QueryRow(&item)
 	return
 }
-
-func AddEdbinfo(tradeCode, secName, unit, remark, frequency, noticeTime string, classifyId int, userId int) (err error) {
-	sql := `INSERT INTO edbinfo(TRADE_CODE, SEC_NAME,UNIT, REMARK,frequency, classify_id,notice_time,user_id,create_date) 
-			VALUES(?,?,?,?,?,?,?,?,now()) `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, tradeCode, secName, unit, remark, frequency, classifyId, noticeTime, userId).Exec()
-	return
-}
-
-func AddEdbinfoUser(tradeCode, mobile string) (err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := `INSERT INTO edbinfo_user(TRADE_CODE, mobile) VALUES (?,?)`
-	_, err = o.Raw(sql, tradeCode, mobile).Exec()
-	return
-}
-
-type EdbinfoEditReq struct {
-	TradeCode  string `description:"指标code"`
-	SecName    string `description:"指标名称"`
-	Unit       string `description:"单位"`
-	Frequency  string `description:"频度"`
-	ClassifyId int    `description:"分类id"`
-	NoticeTime string `description:"通知时间"`
-}
-
-func EditEdbinfo(tradeCode, secName, unit, frequency, noticeTime string, classifyId int) (err error) {
-	sql := `UPDATE edbinfo SET SEC_NAME= ?, UNIT = ?,classify_id=?,frequency=?,notice_time=?,create_date=NOW() WHERE TRADE_CODE=? `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, secName, unit, classifyId, frequency, noticeTime, tradeCode).Exec()
-	return
-}
-
-func SearchTargetEntry(classifyId int, keyWord string) (items []*Edbinfo, err error) {
-	where := ""
-	if keyWord != "" {
-		where = `AND SEC_NAME LIKE '%` + keyWord + `%'`
-	}
-	sql := `SELECT * FROM edbinfo WHERE LEFT(TRADE_CODE,1)='W' AND REMARK='手动' AND classify_id>0 AND classify_id=? `
-	sql += where
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, classifyId).QueryRows(&items)
-	return
-}
-
-type SearchTargetListResp struct {
-	List []*Edbinfo
-}
-
-type EdbdataClassify struct {
-	ClassifyId   int
-	ClassifyName string
-	ParentId     int
-	EdbInfoTotal int
-}
-
-func GetEdbdataClassifyByClassifyName(classifyName string) (item *EdbdataClassify, err error) {
-	sql := `SELECT * FROM edbdata_classify WHERE classify_name=? `
-	o := orm.NewOrmUsingDB("edb")
-	err = o.Raw(sql, classifyName).QueryRow(&item)
-	return
-}
-
-type EdbdataClassifyList struct {
-	ClassifyId   int
-	ClassifyName string
-	ParentId     int
-	Child        []*EdbdataClassify
-}
-
-func GetEdbdataClassify(userId int64) (items []*EdbdataClassifyList, err error) {
-	var newItems []*EdbdataClassifyList
-	o := orm.NewOrmUsingDB("edb")
-	sql := ` SELECT classify_id,classify_name,parent_id FROM edbdata_classify WHERE parent_id=0 `
-	_, err = o.Raw(sql).QueryRows(&newItems)
-	if err != nil {
-		return
-	}
-	classifyLen := len(newItems)
-
-	for i := 0; i < classifyLen; i++ {
-		var childItems []*EdbdataClassify
-		parentId := newItems[i].ClassifyId
-		childSql := ``
-		if userId > 0 {
-			userClassifyList, _ := GetManualUserClassify(int(userId))
-			var userIdArr []string
-			for _, v := range userClassifyList {
-				userIdArr = append(userIdArr, strconv.Itoa(v.ClassifyId))
-			}
-
-			userIdStr := strings.Join(userIdArr, ",")
-			if userIdStr != "" {
-				childSql = "SELECT a.classify_id,a.classify_name,a.parent_id FROM edbdata_classify AS a WHERE a.is_show=1 and a.classify_id IN(" + userIdStr + ") AND parent_id=? ORDER BY a.create_time ASC "
-				_, err = o.Raw(childSql, parentId).QueryRows(&childItems)
-			}
-		} else {
-			childSql = "SELECT classify_id,classify_name,parent_id FROM edbdata_classify WHERE is_show=1 and parent_id=? ORDER BY create_time ASC "
-			_, err = o.Raw(childSql, parentId).QueryRows(&childItems)
-		}
-		if err != nil {
-			return
-		}
-		newItems[i].Child = childItems
-	}
-	for _, v := range newItems {
-		childLen := len(v.Child)
-		if childLen > 0 {
-			items = append(items, v)
-		}
-	}
-	return
-}
-
-type ManualUserClassify struct {
-	ManualUserClassifyId int `orm:"column(manual_user_classify_id);pk"`
-	AdminId              int
-	ClassifyId           int
-	CreateTime           time.Time
-}
-
-func GetManualUserClassify(sysUserId int) (list []*ManualUserClassify, err error) {
-	o := orm.NewOrmUsingDB("data")
-	sql := `SELECT * FROM manual_user_classify WHERE admin_id=? `
-	_, err = o.Raw(sql, sysUserId).QueryRows(&list)
-	return
-}
-
-type EdbdataClassifyResp struct {
-	List []*EdbdataClassifyList
-}
-
-func GetTargetBySecName(secName string) (item *Edbinfo, err error) {
-	sql := `SELECT * FROM edbinfo WHERE SEC_NAME=? AND left(TRADE_CODE,1)='W' AND REMARK='手动' `
-	o := orm.NewOrmUsingDB("edb")
-	err = o.Raw(sql, secName).QueryRow(&item)
-	return
-}
-
-// 更新指标数据信息
-func (edbinfo *Edbinfo) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Update(edbinfo, cols...)
-	return
-}
-
-func ModifyTargetClassifyId(tradeCode string, classifyId int) (err error) {
-	sql := `UPDATE edbinfo SET classify_id=? WHERE TRADE_CODE=? `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, classifyId, tradeCode).Exec()
-	return
-}
-
-func GetTargetsDataCount(tradeCode, dt string) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM edbdata WHERE TRADE_CODE=? AND DT=? `
-	o := orm.NewOrmUsingDB("edb")
-	err = o.Raw(sql, tradeCode, dt).QueryRow(&count)
-	return
-}
-
-// GetTargetsDataList 根据code获取指标数据列表
-func GetTargetsDataList(tradeCode string) (items []*Edbdata, err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := `SELECT * FROM edbdata WHERE TRADE_CODE=? ORDER BY DT ASC `
-	_, err = o.Raw(sql, tradeCode).QueryRows(&items)
-	return
-}
-
-func GetTargetsData(tradeCode, dt string) (item *Edbdata, err error) {
-	sql := `SELECT * FROM edbdata WHERE TRADE_CODE=? AND DT=? `
-	o := orm.NewOrmUsingDB("edb")
-	err = o.Raw(sql, tradeCode, dt).QueryRow(&item)
-	return
-}
-
-func ModifyTargetsDataByImport(tradeCode, dt, close string) (err error) {
-	sql := `UPDATE  edbdata SET CLOSE=?,modify_time=NOW() WHERE  TRADE_CODE=? AND DT=? `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, close, tradeCode, dt).Exec()
-	return
-}
-
-func AddTargetsDataByImport(tradeCode, dt, close string) (err error) {
-	sql := `INSERT INTO edbdata(TRADE_CODE, DT,CLOSE, modify_time)VALUES(?,?,?,NOW()) `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, tradeCode, dt, close).Exec()
-	return
-}
-
-type EdbdataImportResp struct {
-	Status       int
-	Msg          string
-	SuccessCount int
-	FailCount    int
-}
-
-//func GetFailList(sysUserId int) (items []*EdbdataImportFail, err error) {
-//	o := orm.NewOrmUsingDB("edb")
-//	sql := ` SELECT * FROM edbdata_import_fail WHERE sys_user_id=? `
-//	_, err = o.Raw(sql, sysUserId).QueryRows(&items)
-//	return
-//}
-
-type DataListForExport struct {
-	TradeCode    string `orm:"column(TRADE_CODE)" description:"指标code"`
-	SecName      string `orm:"column(SEC_NAME)" description:"指标名称"`
-	Unit         string `orm:"column(UNIT)" description:"单位"`
-	Frequency    string `description:"频度"`
-	ClassifyId   int    `description:"分类id"`
-	NoticeTime   string `description:"通知时间"`
-	ClassifyName string
-	Dt           string  `orm:"column(DT)" description:"日期"`
-	Close        float64 `orm:"column(CLOSE)" description:"值"`
-}
-
-func GetDataListForExport(startDate, endDate, frequency, keyWord string, classifyId int) (items []*DataListForExport, err error) {
-	where := ``
-	var pars []interface{}
-	if keyWord != "" {
-		where = ` AND SEC_NAME LIKE '%` + keyWord + `%`
-	}
-	if startDate != "" {
-		where += ` AND create_date>=? `
-		pars = append(pars, startDate)
-	}
-	if endDate != "" {
-		where += ` AND create_date<=? `
-		pars = append(pars, endDate)
-	}
-	if frequency != "" {
-		where += ` AND frequency=? `
-		pars = append(pars, frequency)
-	}
-	if classifyId > 0 {
-		where += ` AND classify_id=? `
-		pars = append(pars, classifyId)
-	}
-
-	sql := ` SELECT a.TRADE_CODE,a.SEC_NAME,a.UNIT,a.frequency,a.classify_id,b.classify_name,c.DT,c.CLOSE FROM edbdata AS c
-                INNER JOIN edbinfo AS a ON a.TRADE_CODE=c.TRADE_CODE
-                LEFT JOIN edbdata_classify AS b ON a.classify_id=b.classify_id
-                WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0 `
-	if where != "" {
-		sql += where
-	}
-	sql = sql + " ORDER BY c.DT DESC "
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, pars).QueryRows(&items)
-	return
-}
-
-type DataDeleteReq struct {
-	TradeCode  string `description:"指标唯一编码"`
-	CreateDate string `description:"数据录入日期"`
-}
-
-func DataDelete(tradeCode, createDate, close string, modifyTime time.Time, sysUserId int) (err error) {
-	o := orm.NewOrmUsingDB("edb")
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-	recordSql := ` INSERT INTO edbdata_delete_record(TRADE_CODE,DT,CLOSE,modify_time,create_time,sys_user_id) 
-                 VALUES(?,?,?,?,?,?)`
-	_, err = to.Raw(recordSql, tradeCode, createDate, close, modifyTime, time.Now(), sysUserId).Exec()
-	sql := ` DELETE FROM edbdata WHERE TRADE_CODE = ? AND DT = ? `
-	_, err = to.Raw(sql, tradeCode, createDate).Exec()
-	return
-}
-
-func GetTargetInfoCount(tradeCode string) (count int, err error) {
-	sql := ` SELECT COUNT(1) AS count FROM edbdata AS c
-           INNER JOIN edbinfo AS a ON a.TRADE_CODE=c.TRADE_CODE
-           WHERE a.TRADE_CODE=? `
-	o := orm.NewOrmUsingDB("edb")
-	err = o.Raw(sql, tradeCode).QueryRow(&count)
-	return
-}
-
-type TargetDeleteReq struct {
-	TradeCode string `description:"指标唯一编码"`
-}
-
-func TargetDelete(tradeCode string) (err error) {
-	o := orm.NewOrmUsingDB("edb")
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-
-	sql := " DELETE FROM edbinfo WHERE TRADE_CODE = ? "
-	_, err = to.Raw(sql, tradeCode).Exec()
-
-	sql = " DELETE FROM edbdata WHERE TRADE_CODE = ? "
-	_, err = to.Raw(sql, tradeCode).Exec()
-
-	return
-}
-
-type Researcher struct {
-	AdminId     int    `description:"系统用户id"`
-	AdminName   string `description:"系统用户名称"`
-	RealName    string `description:"系统用户姓名"`
-	Role        string `description:"系统用户角色"`
-	Mobile      string `description:"手机号"`
-	TargetCount int    `description:"指标数量"`
-}
-
-type ResearcherListResp struct {
-	List []*Researcher
-}
-
-func GetResearcherEntry() (items []*Researcher, err error) {
-	sql := ` SELECT admin_id,admin_name,real_name,mobile,0 as target_count FROM admin WHERE role_type=1 `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql).QueryRows(&items)
-	researchLen := len(items)
-	edbO := orm.NewOrmUsingDB("edb")
-	for i := 0; i < researchLen; i++ {
-		var count int
-		mobile := items[i].Mobile
-		sqlCount := ` SELECT COUNT(DISTINCT a.TRADE_CODE) AS count FROM  edbinfo_user AS a
-            INNER JOIN edbinfo AS b ON a.TRADE_CODE=b.TRADE_CODE
-            WHERE a.mobile=? AND LEFT(b.TRADE_CODE,1)='W' AND b.REMARK='手动' AND b.classify_id>0 `
-		err = edbO.Raw(sqlCount, mobile).QueryRow(&count)
-		items[i].TargetCount = count
-	}
-	return
-}
-
-func GetResearcherEntryByMobile(mobile string) (items []*Researcher, err error) {
-	sql := ` SELECT admin_id,admin_name,real_name,mobile,0 as target_count FROM admin WHERE  role_type=1 `
-	if mobile != "" {
-		sql += ` AND mobile IN(` + mobile + `)`
-	}
-	o := orm.NewOrm()
-	_, err = o.Raw(sql).QueryRows(&items)
-	researchLen := len(items)
-	edbO := orm.NewOrmUsingDB("edb")
-	for i := 0; i < researchLen; i++ {
-		var count int
-		mobile := items[i].Mobile
-		sqlCount := ` SELECT COUNT(DISTINCT a.TRADE_CODE) AS count FROM  edbinfo_user AS a
-            INNER JOIN edbinfo AS b ON a.TRADE_CODE=b.TRADE_CODE
-            WHERE a.mobile=? AND LEFT(b.TRADE_CODE,1)='W' AND b.REMARK='手动' AND b.classify_id>0 `
-		err = edbO.Raw(sqlCount, mobile).QueryRow(&count)
-		items[i].TargetCount = count
-	}
-	return
-}
-
-type EdbinfoItems struct {
-	TradeCode    string `orm:"column(TRADE_CODE);pk" description:"指标code"`
-	SecName      string `orm:"column(SEC_NAME);" description:"指标名称"`
-	Unit         string `orm:"column(UNIT);" description:"单位"`
-	Remark       string `orm:"column(REMARK);" description:"备注"`
-	Frequency    string `description:"频度"`
-	ClassifyId   int    `description:"分类id"`
-	ClassifyName string `description:"分类名称"`
-	CreateDate   string `description:"创建时间"`
-	UserId       int    `description:"录入用户id"`
-	NoticeTime   string `description:"通知时间"`
-	Mobile       string `description:"录入者手机号"`
-	ModifyDate   string `description:"待更新日期"`
-	Status       string `description:"状态:未完成/完成"`
-}
-
-type TargetItemsResp struct {
-	List SortEdbInfo
-}
-
-type SortEdbInfo []EdbinfoItems
-
-func GetTargetItems(mobile string, classifyId int) (lastItems SortEdbInfo, err error) {
-	var items []*EdbinfoItems
-	o := orm.NewOrmUsingDB("edb")
-	//sql := ` SELECT *,'' modify_date,'' status FROM edbinfo AS a WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0 `
-
-	sql := ` SELECT *,'' modify_date,'' STATUS FROM edbinfo AS a 
-            WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0
-             `
-	if classifyId > 0 {
-		sql += ` AND a.classify_id=` + strconv.Itoa(classifyId) + ``
-	}
-	sql += ` GROUP BY a.TRADE_CODE `
-
-	//if classifyId > 0 {
-	//	sql = ` SELECT *,'' modify_date,'' status FROM edbinfo AS a
-	//        WHERE a.classify_id=` + strconv.Itoa(classifyId) + ` AND LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0
-	//         GROUP BY a.TRADE_CODE `
-	//}
-
-	sql = sql + ` ORDER BY CONVERT(a.SEC_NAME USING gbk )  COLLATE gbk_chinese_ci ASC `
-	_, err = o.Raw(sql).QueryRows(&items)
-	if err != nil {
-		return
-	}
-	itemsLen := len(items)
-	nowWeek := time.Now().Weekday().String()
-
-	fmt.Println(nowWeek)
-	finishEdbInfo := SortEdbInfo{}
-	unFinishEdbInfo := SortEdbInfo{}
-
-	for i := 0; i < itemsLen; i++ {
-		noticeTime := items[i].NoticeTime
-		frequency := items[i].Frequency
-		tradeCode := items[i].TradeCode
-		if noticeTime != "" {
-			if frequency == "周度" {
-				noticeArr := strings.Split(noticeTime, " ")
-				noticeWeek := noticeArr[0]
-				fmt.Println(noticeWeek)
-				addDay := 0
-
-				if nowWeek == "Sunday" {
-					if noticeWeek == "周日" {
-						addDay = 0
-					} else if noticeWeek == "周一" {
-						addDay = 1
-					} else if noticeWeek == "周二" {
-						addDay = 2
-					} else if noticeWeek == "周三" {
-						addDay = 3
-					} else if noticeWeek == "周四" {
-						addDay = 4
-					} else if noticeWeek == "周五" {
-						addDay = 5
-					} else if noticeWeek == "周六" {
-						addDay = 6
-					} else {
-						addDay = 0
-					}
-				} else if nowWeek == "Monday" {
-					if noticeWeek == "周日" {
-						addDay = 6
-					} else if noticeWeek == "周一" {
-						addDay = 0
-					} else if noticeWeek == "周二" {
-						addDay = 1
-					} else if noticeWeek == "周三" {
-						addDay = 2
-					} else if noticeWeek == "周四" {
-						addDay = 3
-					} else if noticeWeek == "周五" {
-						addDay = 4
-					} else if noticeWeek == "周六" {
-						addDay = 5
-					} else {
-						addDay = 0
-					}
-				} else if nowWeek == "Tuesday" {
-					if noticeWeek == "周日" {
-						addDay = 5
-					} else if noticeWeek == "周一" {
-						addDay = 6
-					} else if noticeWeek == "周二" {
-						addDay = 0
-					} else if noticeWeek == "周三" {
-						addDay = 1
-					} else if noticeWeek == "周四" {
-						addDay = 2
-					} else if noticeWeek == "周五" {
-						addDay = 3
-					} else if noticeWeek == "周六" {
-						addDay = 4
-					} else {
-						addDay = 0
-					}
-				} else if nowWeek == "Wednesday" {
-					if noticeWeek == "周日" {
-						addDay = 4
-					} else if noticeWeek == "周一" {
-						addDay = 5
-					} else if noticeWeek == "周二" {
-						addDay = 6
-					} else if noticeWeek == "周三" {
-						addDay = 0
-					} else if noticeWeek == "周四" {
-						addDay = 1
-					} else if noticeWeek == "周五" {
-						addDay = 2
-					} else if noticeWeek == "周六" {
-						addDay = 3
-					} else {
-						addDay = 0
-					}
-				} else if nowWeek == "Thursday" {
-					if noticeWeek == "周日" {
-						addDay = 3
-					} else if noticeWeek == "周一" {
-						addDay = 4
-					} else if noticeWeek == "周二" {
-						addDay = 5
-					} else if noticeWeek == "周三" {
-						addDay = 6
-					} else if noticeWeek == "周四" {
-						addDay = 0
-					} else if noticeWeek == "周五" {
-						addDay = 1
-					} else if noticeWeek == "周六" {
-						addDay = 2
-					} else {
-						addDay = 0
-					}
-				} else if nowWeek == "Friday" {
-					if noticeWeek == "周日" {
-						addDay = 2
-					} else if noticeWeek == "周一" {
-						addDay = 3
-					} else if noticeWeek == "周二" {
-						addDay = 4
-					} else if noticeWeek == "周三" {
-						addDay = 5
-					} else if noticeWeek == "周四" {
-						addDay = 6
-					} else if noticeWeek == "周五" {
-						addDay = 0
-					} else if noticeWeek == "周六" {
-						addDay = 1
-					} else {
-						addDay = 0
-					}
-				} else if nowWeek == "Saturday" {
-					if noticeWeek == "周日" {
-						addDay = 1
-					} else if noticeWeek == "周一" {
-						addDay = 2
-					} else if noticeWeek == "周二" {
-						addDay = 3
-					} else if noticeWeek == "周三" {
-						addDay = 4
-					} else if noticeWeek == "周四" {
-						addDay = 5
-					} else if noticeWeek == "周五" {
-						addDay = 6
-					} else if noticeWeek == "周六" {
-						addDay = 0
-					} else {
-						addDay = 0
-					}
-				}
-
-				modifyDate := time.Now().AddDate(0, 0, addDay)
-				modifyDateStr := modifyDate.Format(utils.FormatDate)
-				items[i].ModifyDate = modifyDateStr
-
-				modifyDateEndStr := modifyDate.AddDate(0, 0, -7).Format(utils.FormatDate)
-
-				fmt.Println("addDay:", addDay)
-				fmt.Println("modifyDateEndStr:", modifyDateEndStr)
-
-				count := 0
-				sqlCount := ` SELECT COUNT(1) AS num FROM edbdata WHERE TRADE_CODE=? AND DT >= ? AND DT <= ? `
-				err = o.Raw(sqlCount, tradeCode, modifyDateEndStr, modifyDateStr).QueryRow(&count)
-				if err != nil {
-					return nil, err
-				}
-				if count > 0 {
-					items[i].Status = "完成"
-					finishEdbInfo = append(finishEdbInfo, *items[i])
-				} else {
-					items[i].Status = "未完成"
-					unFinishEdbInfo = append(unFinishEdbInfo, *items[i])
-				}
-			} else if frequency == "日度" {
-				items[i].Status = "完成"
-				finishEdbInfo = append(finishEdbInfo, *items[i])
-			} else if frequency == "月度" {
-				myYear := time.Now().Year()
-				myMonth := time.Now().Format("01")
-				startDate, endDate := utils.GetMonthStartAndEnd(strconv.Itoa(myYear), myMonth)
-				count := 0
-				sqlCount := ` SELECT COUNT(1) AS num FROM edbdata WHERE TRADE_CODE=? AND DT >= ? AND DT <= ? `
-				err = o.Raw(sqlCount, tradeCode, startDate, endDate).QueryRow(&count)
-				if err != nil {
-					return nil, err
-				}
-				if noticeTime != "" {
-					var modifyDateStr string
-					strArr := strings.Split(noticeTime, "日")
-					myYear := time.Now().Year()
-					myMonth := time.Now().Format("01")
-					modifyDateStr = strconv.Itoa(myYear) + "-" + myMonth + "-" + strArr[0]
-					items[i].ModifyDate = modifyDateStr
-				}
-				if count > 0 {
-					items[i].Status = "完成"
-					finishEdbInfo = append(finishEdbInfo, *items[i])
-				} else {
-					items[i].Status = "未完成"
-					unFinishEdbInfo = append(unFinishEdbInfo, *items[i])
-				}
-			} else {
-				items[i].Status = "完成"
-				finishEdbInfo = append(finishEdbInfo, *items[i])
-			}
-		} else {
-			if frequency == "月度" {
-				myYear := time.Now().Year()
-				myMonth := time.Now().Format("01")
-				startDate, endDate := utils.GetMonthStartAndEnd(strconv.Itoa(myYear), myMonth)
-				count := 0
-				sqlCount := ` SELECT COUNT(1) AS num FROM edbdata WHERE TRADE_CODE=? AND DT >= ? AND DT <= ? `
-				err = o.Raw(sqlCount, tradeCode, startDate, endDate).QueryRow(&count)
-				if err != nil {
-					return nil, err
-				}
-				if count > 0 {
-					items[i].Status = "完成"
-					finishEdbInfo = append(finishEdbInfo, *items[i])
-				} else {
-					items[i].Status = "未完成"
-					unFinishEdbInfo = append(unFinishEdbInfo, *items[i])
-				}
-			} else {
-				items[i].Status = "完成"
-				finishEdbInfo = append(finishEdbInfo, *items[i])
-			}
-		}
-	}
-	sort.Sort(SortByModifyDate{finishEdbInfo})
-	sort.Sort(SortByModifyDate{unFinishEdbInfo})
-	lastItems = append(lastItems, unFinishEdbInfo...)
-	lastItems = append(lastItems, finishEdbInfo...)
-	return
-}
-
-// 获取此 slice 的长度
-func (p SortEdbInfo) Len() int { return len(p) }
-
-// 根据元素的状态降序排序
-func (p SortEdbInfo) Less(i, j int) bool {
-	return p[i].Status > p[j].Status
-}
-
-// 交换数据
-func (p SortEdbInfo) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-
-// 嵌套结构体  将继承 SortEdbInfo 的所有属性和方法
-// 所以相当于SortByName 也实现了 Len() 和 Swap() 方法
-type SortByStatus struct{ SortEdbInfo }
-
-// 根据元素的姓名长度降序排序 (此处按照自己的业务逻辑写)
-func (p SortByStatus) Less(i, j int) bool {
-	return len(p.SortEdbInfo[i].Status) > len(p.SortEdbInfo[j].Status)
-}
-
-type SortByModifyDate struct{ SortEdbInfo }
-
-// 根据元素的年龄降序排序 (此处按照自己的业务逻辑写)
-func (p SortByModifyDate) Less(i, j int) bool {
-	return p.SortEdbInfo[i].ModifyDate > p.SortEdbInfo[j].ModifyDate
-}
-
-type DataCheckResp struct {
-	Status int    `description:"状态:1:该日期已存在数据,是否确认修改?,0:数据不存在"`
-	Close  string `description:"值"`
-}
-
-type TargetCheckResp struct {
-	Status int `description:"状态:1:该指标有关联数据,请先删除数据,0:指标不存在关联数据,可直接删除"`
-}
-
-type EdbdataExportList struct {
-	TradeCode    string `orm:"column(TRADE_CODE);" description:"指标code"`
-	SecName      string `orm:"column(SEC_NAME);" description:"指标名称"`
-	Unit         string `orm:"column(UNIT);" description:"单位"`
-	Remark       string `orm:"column(REMARK);" description:"备注"`
-	Frequency    string `description:"频度"`
-	ClassifyId   int    `description:"分类id"`
-	ClassifyName string `description:"分类名称"`
-	CreateDate   string `description:"创建时间"`
-	Dt           string `orm:"column(Dt);" description:"最新一次录入时间"`
-}
-
-func GetEdbdataSecName(condition string, pars []interface{}) (items []*EdbdataExportList, err error) {
-	//sql := `SELECT a.TRADE_CODE,a.SEC_NAME,a.frequency,a.UNIT,MAX(c.DT) AS Dt
-	//	        FROM edbdata AS c
-	//	        INNER JOIN edbinfo AS a ON a.TRADE_CODE=c.TRADE_CODE
-	//	        INNER JOIN edbinfo_user AS d ON a.TRADE_CODE=d.TRADE_CODE
-	//	        LEFT JOIN edbdata_classify AS b ON a.classify_id=b.classify_id
-	//	        WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0`
-	sql := `SELECT a.TRADE_CODE,a.SEC_NAME,a.frequency,a.UNIT,MAX(c.DT) AS Dt,b.classify_name
-		        FROM edbdata AS c
-		        INNER JOIN edbinfo AS a ON a.TRADE_CODE=c.TRADE_CODE
-		        LEFT JOIN edbdata_classify AS b ON a.classify_id=b.classify_id
-		        WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0`
-	if condition != "" {
-		sql += condition
-	}
-	sql += " GROUP BY a.TRADE_CODE ORDER BY a.TRADE_CODE ASC "
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, pars).QueryRows(&items)
-	return
-}
-
-func GetEdbDataFrequency(classifyId int) (items []*string, err error) {
-	sql := `SELECT DISTINCT frequency FROM edbinfo where classify_id=? AND frequency IS NOT NULL ORDER BY FIELD(frequency,'日度','周度','月度','季度','半年度','年度') `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, classifyId).QueryRows(&items)
-	return
-}
-
-func GetEdbDataFrequencyByKeyord(keyword string) (items []*string, err error) {
-	sql := `SELECT DISTINCT frequency FROM edbinfo where SEC_NAME=? ORDER BY FIELD(frequency,'日度','周度','月度','季度','半年度','年度') `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, keyword).QueryRows(&items)
-	return
-}
-
-type EdbdataList struct {
-	Dt string `orm:"column(DT);" description:"录入时间"`
-}
-
-func GetEdbdataList(tradeCode string) (items []*EdbdataList, err error) {
-	sql := ` SELECT  DT FROM edbdata WHERE TRADE_CODE IN(` + tradeCode + `)  GROUP BY DT ORDER BY DT DESC `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-type EdbdataItem struct {
-	TradeCode string  `orm:"column(TRADE_CODE);" description:"指标code"`
-	Dt        string  `orm:"column(DT);" description:"最新一次录入时间"`
-	Close     float64 `orm:"column(CLOSE);" description:"值"`
-}
-
-func GetEdbdataValueByTradeCode(tradeCode, dt string) (item *EdbdataItem, err error) {
-	sql := ` SELECT  TRADE_CODE,DT,CLOSE FROM edbdata WHERE TRADE_CODE=? AND DT=? `
-	o := orm.NewOrmUsingDB("edb")
-	err = o.Raw(sql, tradeCode, dt).QueryRow(&item)
-	return
-}
-
-func GetEdbdataAllByTradeCode(tradeCode string) (items []*EdbdataItem, err error) {
-	sql := ` SELECT * FROM edbdata WHERE TRADE_CODE=? `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, tradeCode).QueryRows(&items)
-	return
-}
-
-func GetEdbdataClassifyByParentId(parentId int) (items []*EdbdataClassify, err error) {
-	sql := ` SELECT * FROM edbdata_classify WHERE parent_id=? `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, parentId).QueryRows(&items)
-	return
-}
-
-type LzPriceClassify struct {
-	ProductName string
-}
-
-func GetLzPriceClassify() (items []*LzPriceClassify, err error) {
-	sql := ` SELECT product_name  FROM longzhongpriceinfo GROUP BY product_name ORDER BY product_name DESC `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-type Longzhongpriceinfo struct {
-	LongzhongpriceinfoId int `orm:"column(longzhongpriceinfo_id);pk"`
-	Standard             string
-	ModelName            string
-	Unit                 string
-	AreaName             string
-	PriceType            string
-	Memo                 string
-	PriceId              string
-	ProductName          string
-	InfoType             string
-	InfoTypeRemark       string
-	MarketName           string
-	ManufactureName      string
-}
-
-func GetLongzhongpriceinfoByClassifyName(productName string) (items []*Longzhongpriceinfo, err error) {
-	sql := `SELECT * FROM longzhongpriceinfo WHERE product_name=? ORDER BY longzhongpriceinfo_id ASC `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, productName).QueryRows(&items)
-	return
-}
-
-func GetLongzhongPriceDataMaxCount(productName string) (count int, err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := `SELECT MAX(t.num) AS count FROM (
-				SELECT COUNT(1) AS num  FROM longzhongpriceinfo AS a
-				INNER JOIN longzhongpricedata AS b ON a.longzhongpriceinfo_id=b.longzhongpriceinfo_id
-				WHERE a.product_name=?
-				GROUP BY a.product_name
-			)AS t `
-	err = o.Raw(sql, productName).QueryRow(&count)
-	return
-}
-
-type LongzhongpricedataItems struct {
-	LongzhongpricedataId int `orm:"column(longzhongpricedata_id);pk"`
-	LongzhongpriceinfoId int
-	PriceDate            string
-	Memo                 string
-	Price                float64
-	CnyPrice             float64
-	ZsyPrice             float64
-	ZshPrice             float64
-	LowPrice             float64
-	HighPrice            float64
-	RisePrice            float64
-	TonPrice             float64
-	PriceType            string
-	UpdateDate           string
-}
-
-func GetLongzhongPriceDataById(lzPriceInfoId int) (items []*LongzhongpricedataItems, err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := ` SELECT DISTINCT a.longzhongpriceinfo_id,a.price_date,a.memo,a.price,a.cny_price,a.zsy_price,a.zsh_price,a.low_price,a.high_price,a.rise_price,a.ton_price,a.price_type,a.update_date  
-			 FROM longzhongpricedata AS a
-			 WHERE longzhongpriceinfo_id=? ORDER BY price_date DESC `
-	_, err = o.Raw(sql, lzPriceInfoId).QueryRows(&items)
-	return
-}
-
-func GetLzSurveyClassify() (items []*LzPriceClassify, err error) {
-	sql := ` SELECT breed_name AS product_name  FROM longzhong_survey_product GROUP BY breed_name ORDER BY breed_name DESC `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-type LongzhongSurveyProduct struct {
-	SurveyProductId      int `orm:"column(survey_product_id);pk"`
-	ProjectQuotaId       int64
-	BreedId              string
-	BreedName            string
-	QuotaId              string
-	QuotaName            string
-	UnitId               string
-	UnitName             string
-	SampleType           int64
-	SampleId             string
-	SampleName           string
-	DeviceId             string
-	Device               string
-	ProductCraftId       string
-	ProductCraft         string
-	ProductLine          string
-	InputMode            int64
-	Frequency            int64
-	InputValue           string
-	TaskShouldFinishTime int
-	CustomId             string
-	CustomType           int64
-	Custom               string
-	QuotaSampleId        int64
-	StartDate            string
-	EndDate              string
-	LzCode               string
-}
-
-func GetLongzhongSurveyProductByClassifyName(productName string) (items []*LongzhongSurveyProduct, err error) {
-	sql := `SELECT * FROM longzhong_survey_product WHERE breed_name=? ORDER BY survey_product_id ASC `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, productName).QueryRows(&items)
-	return
-}
-
-func GetLzSurveyProductByNameAndFrequency(productName string, frequency int) (items []*LongzhongSurveyProduct, err error) {
-
-	sql := `SELECT * FROM longzhong_survey_product WHERE breed_name=? AND frequency=? ORDER BY survey_product_id ASC `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, productName, frequency).QueryRows(&items)
-	return
-}
-
-func GetExportLzSurveyProductByBreedIds(breedIds []string) (items []*LongzhongSurveyProduct, err error) {
-	if len(breedIds) == 0 {
-		return
-	}
-	field := ` survey_product_id, breed_id, breed_name, sample_name, custom, quota_name, lz_code, frequency, unit_name, end_date, input_value `
-	sql := `SELECT ` + field + ` FROM longzhong_survey_product WHERE breed_id IN (` + utils.GetOrmInReplace(len(breedIds)) + `) ORDER BY breed_id ASC, frequency ASC, survey_product_id ASC `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, breedIds).QueryRows(&items)
-	return
-}
-
-func GetLzFrequency(productName string) (items []*int, err error) {
-	sql := `SELECT DISTINCT frequency FROM longzhong_survey_product WHERE breed_name=? ORDER BY frequency`
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, productName).QueryRows(&items)
-	return
-}
-
-// EdbInfoItem
-type EdbInfoItem struct {
-	TradeCode    string     `orm:"column(TRADE_CODE);pk" description:"指标code"`
-	SecName      string     `orm:"column(SEC_NAME);" description:"指标名称"`
-	Unit         string     `orm:"column(UNIT);" description:"单位"`
-	Remark       string     `orm:"column(REMARK);" description:"备注"`
-	Frequency    string     `description:"频度"`
-	ClassifyId   int        `description:"分类id"`
-	ClassifyName string     `description:"分类名称"`
-	CreateDate   string     `description:"创建时间"`
-	UserId       int        `description:"录入用户id"`
-	NoticeTime   string     `description:"通知时间"`
-	Mobile       string     `description:"录入者手机号"`
-	ModifyDate   string     `description:"待更新日期"`
-	Status       string     `description:"状态:未完成/完成"`
-	DataList     []*Edbdata `description:"指标数据列表"`
-}
-
-// GetTargetItemList 获取指标列表数据
-func GetTargetItemList(classifyId, edbShowType int, frequency, keyword, tradeCode string, classifyIdStrList []string) (items []*EdbInfoItem, err error) {
-	o := orm.NewOrmUsingDB("edb")
-
-	sql := ` SELECT a.*,'' modify_date,'' STATUS FROM edbinfo AS a `
-	if edbShowType != 0 {
-		sql = ` SELECT a.*,b.DT,'' modify_date,'' STATUS FROM edbinfo AS a 
-left join edbdata b on a.TRADE_CODE=b.TRADE_CODE `
-	}
-	sql += ` WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0 `
-
-	//如果没有分类id集合列表,那么就没有数据了,不用往下执行了,直接返回好了
-	if len(classifyIdStrList) <= 0 {
-		return
-	}
-	if len(classifyIdStrList) > 0 {
-		sql += ` AND a.classify_id in (` + strings.Join(classifyIdStrList, ",") + `)  `
-	}
-	if classifyId > 0 {
-		sql += ` AND a.classify_id=` + strconv.Itoa(classifyId) + ` `
-	}
-	//频度
-	if frequency != "" {
-		sql += ` AND a.frequency="` + frequency + `" `
-	}
-	//关键字
-	if keyword != "" {
-		sql += ` AND (a.SEC_NAME like "%` + keyword + `%"  or a.TRADE_CODE like "%` + keyword + `%" )`
-	}
-	//指定指标
-	if tradeCode != "" {
-		sql += ` AND a.TRADE_CODE = "` + tradeCode + `" `
-	}
-	//指标里面是否有数据
-	switch edbShowType {
-	case 1:
-		sql += ` AND b.CLOSE is not null `
-	case 2:
-		sql += ` AND b.CLOSE is null `
-	}
-	sql += ` GROUP BY a.TRADE_CODE `
-
-	sql = sql + ` ORDER BY CONVERT(a.SEC_NAME USING gbk )  COLLATE gbk_chinese_ci ASC `
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-
-}
-
-// GetLzItemList 模糊查询隆众数据库指标列表
-//func GetLzItemList(keyword string) (items []*data_manage.LongzhongSurveyProduct, err error) {
-//	o := orm.NewOrmUsingDB("edb")
-//
-//	sql := "SELECT * FROM longzhong_survey_product WHERE CONCAT(sample_name,breed_name,custom,quota_name,lz_code) LIKE '%" + keyword + "%'"
-//	_, err = o.Raw(sql).QueryRows(&items)
-//	return
-//
-//}
-
-type lzSurveyData struct {
-	DataTime   string `orm:"column(data_time)" description:"日期"`
-	InputValue string `orm:"column(input_value)" description:"值"`
-}
-
-// GetLzItemListByCode 根据code查询隆众数据列表
-func GetLzItemListByCode(lzCode string) (items []*lzSurveyData, err error) {
-	o := orm.NewOrmUsingDB("edb")
-
-	sql := "SELECT * FROM longzhong_survey_data WHERE survey_product_id=? GROUP BY data_time DESC"
-	_, err = o.Raw(sql, lzCode).QueryRows(&items)
-	return
-}
-
-// GetEdbDataListByCodes 通过指标ID获取所有数据
-func GetEdbDataListByCodes(tradeCode string) (items []*Edbdata, err error) {
-	sql := ` SELECT  TRADE_CODE,DT,round(CLOSE,4) CLOSE,modify_time  FROM edbdata WHERE TRADE_CODE IN(` + tradeCode + `)  GROUP BY TRADE_CODE,DT ORDER BY DT DESC `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// TargetItemListResp 指标数据结构体
-type TargetItemListResp struct {
-	List          []*EdbInfoItem
-	FrequencyList []string
-}
-
-// BatchDataDeleteReq 批量删除某日的指标数据请求结构体
-type BatchDataDeleteReq struct {
-	CreateDate    string   `description:"创建日期"`
-	TradeCodeList []string `description:"指标唯一编码列表"`
-}
-
-// BatchDeleteEdbDataByDate 批量删除某日的指标数据
-func BatchDeleteEdbDataByDate(tradeCodes, dt string, opUserId int) (err error) {
-	o := orm.NewOrmUsingDB("edb")
-	var list []*Edbdata
-	sql := ` select * FROM edbdata WHERE TRADE_CODE in  (` + tradeCodes + `) AND DT = ? `
-	_, err = o.Raw(sql, dt).QueryRows(&list)
-	if err != nil {
-		return
-	}
-	deleteRecordList := make([]*EdbdataDeleteRecord, 0)
-	for _, edbDataInfo := range list {
-		deleteRecord := &EdbdataDeleteRecord{
-			TradeCode:  edbDataInfo.TradeCode,
-			Dt:         edbDataInfo.Dt,
-			Close:      edbDataInfo.Close,
-			ModifyTime: time.Now(),
-			CreateTime: time.Now(),
-			SysUserId:  opUserId,
-		}
-		deleteRecordList = append(deleteRecordList, deleteRecord)
-	}
-	if len(deleteRecordList) > 0 {
-		_, tmpErr := o.InsertMulti(len(deleteRecordList), deleteRecordList)
-		if tmpErr != nil {
-			err = tmpErr
-			return
-		}
-	}
-	sql = ` DELETE FROM edbdata WHERE TRADE_CODE in  (` + tradeCodes + `) AND DT = ? `
-	_, err = o.Raw(sql, dt).Exec()
-	return
-}
-
-// BatchDeleteEdbData 批量删除指标数据
-func BatchDeleteEdbData(tradeCode string, opUserId int) (err error) {
-	o := orm.NewOrmUsingDB("edb")
-	var list []*Edbdata
-	sql := ` select * FROM edbdata WHERE TRADE_CODE =  ? `
-	_, err = o.Raw(sql, tradeCode).QueryRows(&list)
-	if err != nil {
-		return
-	}
-	deleteRecordList := make([]*EdbdataDeleteRecord, 0)
-	for _, edbDataInfo := range list {
-		deleteRecord := &EdbdataDeleteRecord{
-			TradeCode:  edbDataInfo.TradeCode,
-			Dt:         edbDataInfo.Dt,
-			Close:      edbDataInfo.Close,
-			ModifyTime: time.Now(),
-			CreateTime: time.Now(),
-			SysUserId:  opUserId,
-		}
-		deleteRecordList = append(deleteRecordList, deleteRecord)
-	}
-	_, err = o.InsertMulti(len(deleteRecordList), deleteRecordList)
-	if err != nil {
-		return
-	}
-	sql = ` DELETE FROM edbdata WHERE TRADE_CODE  = ? `
-	_, err = o.Raw(sql, tradeCode).Exec()
-	return
-}
-
-// GetEdbInfoCountByClassifyId 根据指标分类id获取当前分类下的指标数量
-func GetEdbInfoCountByClassifyId(classifyId int) (count int, err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := `SELECT COUNT(1) AS count FROM ( SELECT a.*,b.CLOSE FROM edbinfo AS a 
-             INNER JOIN edbdata AS b ON a.TRADE_CODE=b.TRADE_CODE
-             WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id=? group by a.TRADE_CODE) d `
-	err = o.Raw(sql, classifyId).QueryRow(&count)
-	return
-}
-
-// EdbInfoGroupCount 指标分类id获取当前分类下的指标数量
-type EdbInfoGroupCount struct {
-	Count      int
-	ClassifyId int
-}
-
-// GetEdbInfoGroupCountByClassifyIds 根据指标分类id获取当前分类下的指标数量
-func GetEdbInfoGroupCountByClassifyIds(classifyIds string) (list []*EdbInfoGroupCount, err error) {
-	o := orm.NewOrmUsingDB("edb")
-	sql := `SELECT COUNT(1) AS count,classify_id FROM ( SELECT a.*,b.CLOSE FROM edbinfo AS a 
-             INNER JOIN edbdata AS b ON a.TRADE_CODE=b.TRADE_CODE
-             WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' and a.classify_id in (` + classifyIds + `) group by a.TRADE_CODE) d 
-						 GROUP BY classify_id `
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-//// GetExcelData 获取excel样式数据
-//func GetExcelData() (list []*data_manage.ExcelStyle, err error) {
-//	o := orm.NewOrmUsingDB("edb")
-//	sql := `SELECT * FROM excel_style `
-//	_, err = o.Raw(sql).QueryRows(&list)
-//	return
-//}
-//
-//// AddExcelData 添加excel样式数据
-//func AddExcelData(item *data_manage.ExcelStyle) (id int64, err error) {
-//	o := orm.NewOrmUsingDB("edb")
-//	id, err = o.Insert(item)
-//	return
-//}
-
-type EdbdataFloat struct {
-	TradeCode  string    `orm:"column(TRADE_CODE);pk" description:"指标编码"`
-	Dt         string    `orm:"column(DT)" description:"日期"`
-	Close      float64   `orm:"column(CLOSE)" description:"值"`
-	ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"`
-}
-
-func GetTargetsDataFloat(tradeCode, dt string) (item *EdbdataFloat, err error) {
-	sql := `SELECT * FROM edbdata WHERE TRADE_CODE=? AND DT=? `
-	o := orm.NewOrmUsingDB("edb")
-	err = o.Raw(sql, tradeCode, dt).QueryRow(&item)
-	return
-}
-
-func ModifyEdbinfo(tradeCode, unit, frequency string, classifyId int) (err error) {
-	sql := `UPDATE edbinfo SET UNIT = ?,frequency=?, classify_id=?, create_date=NOW() WHERE TRADE_CODE=? `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, unit, frequency, classifyId, tradeCode).Exec()
-	return
-}
-
-func DeleteTargetsDataByImport(tradeCode, dt string) (err error) {
-	sql := `DELETE FROM edbdata WHERE TRADE_CODE=? AND DT=? `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql, tradeCode, dt).Exec()
-	return
-}
-
-// GetEdbinfoListByCodeListGroupByUserId 根据指标code列表、用户分组获取指标信息
-func GetEdbinfoListByCodeListGroupByUserId(edbCodeList []string) (items []*Edbinfo, err error) {
-	num := len(edbCodeList)
-	if num <= 0 {
-		return
-	}
-	o := orm.NewOrmUsingDB("edb")
-	sql := `SELECT * FROM edbinfo WHERE TRADE_CODE in (` + utils.GetOrmInReplace(num) + `) GROUP BY user_id `
-	_, err = o.Raw(sql, edbCodeList).QueryRows(&items)
-	return
-}
-
-// ModifyEdbinfoUserIdByCodeList 根据指标code列表修改创建人
-func ModifyEdbinfoUserIdByCodeList(edbCodeList []string, userId int) (err error) {
-	num := len(edbCodeList)
-	if num <= 0 {
-		return
-	}
-	o := orm.NewOrmUsingDB("edb")
-	sql := `UPDATE edbinfo SET user_id=? WHERE TRADE_CODE in (` + utils.GetOrmInReplace(num) + `) `
-	_, err = o.Raw(sql, userId, edbCodeList).Exec()
-	return
-}
-
-func GetEdbInfoAdminList() (list []int, err error) {
-	sql := `SELECT user_id FROM edbinfo GROUP BY user_id `
-	o := orm.NewOrmUsingDB("edb")
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}

+ 0 - 426
models/user_view_history.go

@@ -1,435 +1,9 @@
 package models
 
 import (
-	"eta/eta_mobile/utils"
 	"github.com/beego/beego/v2/client/orm"
-	"time"
 )
 
-type UserViewHistory struct {
-	ViewHistoryId        int       `orm:"column(id);pk"`
-	UserId               int       `description:"用户id"`
-	Mobile               string    `description:"手机号"`
-	Email                string    `description:"邮箱"`
-	RealName             string    `description:"用户实际姓名"`
-	CompanyName          string    `description:"公司名称"`
-	ViewTitle            string    `description:"访问标题"`
-	ViewPage             string    `description:"访问页面"`
-	ReportChapterModule  string    `description:"访问核心观点或者图文逻辑"`
-	CreatedTime          string    `description:"创建时间"`
-	LastUpdatedTime      time.Time `description:"访问历史类型,weekly_report 周报,pdf;默认值:weekly_report"`
-	ResearchReportId     int       `description:"研报id"`
-	ResearchReportTypeId int       `description:"报告章节id,为0时表示查看目录或者首页"`
-}
-
-// 根据用户id字符串获取用户的浏览数
-type UserViewTotalSlice struct {
-	UserId      int       `description:"用户id"`
-	Total       int       `description:"总阅读数"`
-	CreatedTime time.Time `description:"用户浏览时间"`
-}
-
-func GetCountUserViewHistoryByUserIds(userIds string) (items []*UserViewTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT count(1) total,user_id,max(created_time) as created_time FROM user_view_history WHERE user_id in (` + userIds + `) group by user_id`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-	//return items2,err
-}
-
-// 根据用户手机号字符串获取用户的浏览数
-type UserViewMobileTotalSlice struct {
-	Mobile      string    `description:"用户手机号"`
-	Total       int       `description:"总阅读数"`
-	CreatedTime time.Time `description:"用户浏览时间"`
-}
-
-func GetCountUserViewHistoryByMobiles(mobiles string) (items []*UserViewMobileTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT count(1) total,mobile,max(created_time) as created_time FROM user_view_history WHERE mobile in (` + mobiles + `) group by mobile`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// 根据用户id字符串获取用户的浏览数
-type UserViewEmailTotalSlice struct {
-	Email       string    `description:"用户邮箱"`
-	Total       int       `description:"总阅读数"`
-	CreatedTime time.Time `description:"用户浏览时间"`
-}
-
-func GetCountUserViewHistoryByEmails(emails string) (items []*UserViewEmailTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT count(1) total,email,max(created_time) as created_time FROM user_view_history WHERE email in (` + emails + `) group by email`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-	//return items2,err
-}
-
-func GetCountCygxArticleHistoryRecordByMobiles(mobiles string) (items []*UserViewMobileTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT count(1) total,h.mobile,max(h.create_time) as created_time FROM cygx_article_history_record_all  AS h  INNER JOIN cygx_article  AS art  ON  art.article_id = h.article_id  WHERE h.mobile in (` + mobiles + `) AND h.is_del = 0  AND h.company_id != 16 group by h.mobile`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-func GetCountCygxArticleHistoryRecordByEmails(emails string) (items []*UserViewEmailTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT count(1) total,h.email,max(h.create_time) as created_time FROM cygx_article_history_record_all AS h  INNER JOIN cygx_article  AS art  ON  art.article_id = h.article_id  WHERE h.email in (` + emails + `) AND h.is_del = 0 AND h.company_id != 16 group by email`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// CompanyLastViewSlice 根据手机号获取客户的最新浏览时间
-type CompanyLastViewSlice struct {
-	CompanyId int       `description:"客户id"`
-	ViewTime  time.Time `description:"用户浏览时间"`
-}
-
-// GetLastUserViewHistoryByCompanyIdsMobile 根据手机号获取客户的最新浏览时间
-func GetLastUserViewHistoryByCompanyIdsMobile(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.created_time) view_time
-FROM
-	wx_user a
-	JOIN user_view_history b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and b.created_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastUserViewHistoryByCompanyIdsEmail 根据邮箱获取客户的最新浏览时间
-func GetLastUserViewHistoryByCompanyIdsEmail(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	//	sql := `SELECT
-	//	a.company_id ,max(b.created_time) view_time
-	//FROM
-	//	wx_user a
-	//	JOIN user_view_history b ON a.email = b.email
-	//WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile=""  and b.created_time>=?  GROUP BY company_id`
-
-	sql := `SELECT
-	a.company_id ,max(b.created_time) view_time FROM wx_user a
-	JOIN user_view_history b ON a.email = b.email 
-WHERE b.email !="" and b.mobile=""  and b.created_time>=?  GROUP BY company_id`
-
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastAdvisoryArticleViewRecordByCompanyIdsMobile 根据手机号获取客户的最新浏览时间
-func GetLastAdvisoryArticleViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.create_time) view_time
-FROM
-	wx_user a
-	JOIN advisory_user_chart_article_record b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and b.create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastAdvisoryArticleViewRecordByCompanyIdsEmail 根据邮箱获取客户的最新浏览时间
-func GetLastAdvisoryArticleViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.create_time) view_time
-FROM
-	wx_user a
-	JOIN advisory_user_chart_article_record b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile=""  and b.create_time>=?  GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastCygxArticleViewRecordByCompanyIdsMobile 根据手机号获取客户的最新浏览时间
-func GetLastCygxArticleViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	o := orm.NewOrm()
-	//dataName := ""
-	//if utils.RunMode == "debug" {
-	//	dataName = "test_v2_hongze_rddp"
-	//} else {
-	//	dataName = "hongze_rddp"
-	//}
-	sql := `SELECT
-	a.company_id ,max(b.create_time) view_time
-FROM
-	wx_user a
-	JOIN cygx_article_history_record_newpv b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" GROUP BY company_id`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// GetLastCygxArticleViewRecordByCompanyIdsEmail 根据邮箱获取客户的最新浏览时间
-func GetLastCygxArticleViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.create_time) view_time
-FROM
-	wx_user a
-	JOIN cygx_article_history_record_newpv b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile=""   GROUP BY company_id`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// GetLastReportViewRecordByCompanyIdsMobile 根据手机号获取客户的最新浏览时间
-func GetLastReportViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	dataName := ""
-	if utils.RunMode == "debug" {
-		dataName = "test_v2_hongze_rddp"
-	} else {
-		dataName = "hongze_rddp"
-	}
-	sql := `SELECT
-	a.company_id ,max(b.create_time) view_time
-FROM
-	wx_user a
-	JOIN ` + dataName + `.report_view_record b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and b.create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastReportViewRecordByCompanyIdsEmail 根据邮箱获取客户的最新浏览时间
-func GetLastReportViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	dataName := ""
-	if utils.RunMode == "debug" {
-		dataName = "test_v2_hongze_rddp"
-	} else {
-		dataName = "hongze_rddp"
-	}
-	sql := `SELECT	a.company_id ,max(b.create_time) view_time FROM wx_user a
-	JOIN ` + dataName + `.report_view_record b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile=""   and b.create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastUserViewStatisticsByCompanyIdsMobile 根据手机号获取客户的最新浏览时间
-func GetLastUserViewStatisticsByCompanyIdsMobile(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.last_view_time) view_time
-FROM
-	wx_user a
-	JOIN user_view_statistics b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and a.mobile !="" and b.mobile !="" and b.date<=? GROUP BY a.company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetLastUserViewStatisticsByCompanyIdsEmail 根据邮箱获取客户的最新浏览时间
-func GetLastUserViewStatisticsByCompanyIdsEmail(companyIds string) (items []*CompanyLastViewSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,max(b.last_view_time) view_time
-FROM
-	wx_user a
-	JOIN user_view_statistics b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and a.email !="" and b.email !="" and a.mobile="" and b.mobile="" and b.date<=? GROUP BY a.company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// CompanyViewTotalSlice 获取客户的浏览次数
-type CompanyViewTotalSlice struct {
-	CompanyId int `description:"客户id"`
-	ViewTotal int `description:"用户浏览次数"`
-}
-
-// GetCountUserViewHistoryByCompanyIdsMobile 根据手机号获取客户的浏览次数
-func GetCountUserViewHistoryByCompanyIdsMobile(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,count(1) view_total FROM 	wx_user a
-	JOIN user_view_history b ON a.mobile = b.mobile 
-WHERE 	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and b.created_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetCountUserViewHistoryByCompanyIdsEmail 根据邮箱获取客户的浏览次数
-func GetCountUserViewHistoryByCompanyIdsEmail(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	//	sql := `SELECT
-	//	a.company_id ,count(1) view_total
-	//FROM
-	//	wx_user a
-	//	JOIN user_view_history b ON a.email = b.email
-	//WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile=""  and b.created_time>=? GROUP BY company_id`
-
-	sql := `SELECT a.company_id ,count(1) view_total FROM wx_user a 
-JOIN user_view_history b ON a.email = b.email 
-WHERE  b.email !="" and b.mobile=""  and b.created_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetCountAdvisoryArticleViewRecordByCompanyIdsMobile 根据手机号获取客户的浏览次数
-func GetCountAdvisoryArticleViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,count(1) view_total
-FROM
-	wx_user a
-	JOIN advisory_user_chart_article_record b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetCountAdvisoryArticleViewRecordByCompanyIdsEmail 根据邮箱获取客户的浏览次数
-func GetCountAdvisoryArticleViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,count(1) view_total
-FROM
-	wx_user a
-	JOIN advisory_user_chart_article_record b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile="" and create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetCountCygxArticleViewRecordByCompanyIdsMobile 根据手机号获取客户的浏览次数
-func GetCountCygxArticleViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	o := orm.NewOrm()
-	//dataName := ""
-	//if utils.RunMode == "debug" {
-	//	dataName = "test_v2_hongze_rddp"
-	//} else {
-	//	dataName = "hongze_rddp"
-	//}
-	sql := `SELECT
-	a.company_id ,count(1) view_total
-FROM
-	wx_user a
-	JOIN cygx_article_history_record_newpv b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" GROUP BY company_id`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// GetCountCygxArticleViewRecordByCompanyIdsEmail 根据邮箱获取客户的浏览次数
-func GetCountCygxArticleViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,count(1) view_total
-FROM
-	wx_user a
-	JOIN cygx_article_history_record_newpv b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile="" GROUP BY company_id`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
-// GetCountReportViewRecordByCompanyIdsMobile 根据手机号获取客户的浏览次数
-func GetCountReportViewRecordByCompanyIdsMobile(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	dataName := ""
-	if utils.RunMode == "debug" {
-		dataName = "test_v2_hongze_rddp"
-	} else {
-		dataName = "hongze_rddp"
-	}
-	sql := `SELECT
-	a.company_id ,count(1) view_total
-FROM
-	wx_user a
-	JOIN ` + dataName + `.report_view_record b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and b.mobile !="" and create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetCountReportViewRecordByCompanyIdsEmail 根据邮箱获取客户的浏览次数
-func GetCountReportViewRecordByCompanyIdsEmail(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate) + " 00:00:00"
-	o := orm.NewOrm()
-	dataName := ""
-	if utils.RunMode == "debug" {
-		dataName = "test_v2_hongze_rddp"
-	} else {
-		dataName = "hongze_rddp"
-	}
-	sql := `SELECT	a.company_id ,count(1) view_total FROM wx_user a
-	JOIN ` + dataName + `.report_view_record b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and b.email !="" and b.mobile="" and create_time>=? GROUP BY company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetUserViewStatisticsByCompanyIdsMobile 根据手机号获取客户的浏览次数
-func GetUserViewStatisticsByCompanyIdsMobile(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,sum(b.view_num) view_total
-FROM
-	wx_user a
-	JOIN user_view_statistics b ON a.mobile = b.mobile 
-WHERE
-	a.company_id IN ( ` + companyIds + ` )  and a.mobile !="" and b.mobile !="" and date<=? GROUP BY a.company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// GetUserViewStatisticsByCompanyIdsEmail 根据邮箱获取客户的浏览次数
-func GetUserViewStatisticsByCompanyIdsEmail(companyIds string) (items []*CompanyViewTotalSlice, err error) {
-	today := time.Now().Format(utils.FormatDate)
-	o := orm.NewOrm()
-	sql := `SELECT
-	a.company_id ,sum(b.view_num) view_total
-FROM
-	wx_user a
-	JOIN user_view_statistics b ON a.email = b.email 
-WHERE a.company_id IN ( ` + companyIds + ` ) and a.email !="" and b.email !="" and a.mobile="" and b.mobile="" and date<=? GROUP BY a.company_id`
-	_, err = o.Raw(sql, today).QueryRows(&items)
-	return
-}
-
-// UserViewStatisticsInfo 根据用户手机号字符串获取用户的浏览数和最晚阅读次数
-type UserViewStatisticsInfo struct {
-	Mobile       string    `description:"用户手机号"`
-	Total        int       `description:"总阅读数"`
-	LastViewTime time.Time `description:"用户浏览时间"`
-}
-
-// GetUserViewStatisticsByMobile 根据手机号获取联系人的浏览次数
-func GetUserViewStatisticsByMobile(mobile string) (item *UserViewStatisticsInfo, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT mobile,sum(view_num) total,max(last_view_time) last_view_time FROM  user_view_statistics  WHERE mobile = ? `
-	err = o.Raw(sql, mobile).QueryRow(&item)
-	return
-}
-
 type ResearchReportViewPUV struct {
 	ResearchReportId int
 	Pv               int

+ 0 - 444
models/wechat_send_msg.go

@@ -1,248 +1,9 @@
 package models
 
 import (
-	"eta/eta_mobile/utils"
 	"github.com/beego/beego/v2/client/orm"
-	"strings"
 )
 
-type OpenIdList struct {
-	OpenId string
-	UserId int
-}
-
-func GetOpenIdList() (items []*OpenIdList, err error) {
-	//openIdstr := WxUsersGet()
-	//sql:=` SELECT DISTINCT open_id FROM wx_user AS wu
-	//      INNER JOIN company AS c ON c.company_id = wu.company_id
-	//      INNER JOIN company_product AS d ON c.company_id=d.company_id
-	//      WHERE wu.open_id IS NOT NULL AND  d.status IN('正式','试用','永续') `
-	sql := `SELECT DISTINCT ur.open_id,wu.user_id FROM wx_user AS wu 
-          INNER JOIN company AS c ON c.company_id = wu.company_id 
-          INNER JOIN company_product AS d ON c.company_id=d.company_id
-		INNER join user_record  as ur on wu.user_id=ur.user_id
-          WHERE ur.open_id != "" AND ur.subscribe=1 and ur.create_platform=1 AND  d.status IN('正式','试用','永续') `
-	//if openIdstr != "" {
-	//	sql += ` AND ur.open_id in (` + openIdstr + `) `
-	//}
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
-	return
-}
-
-func GetOpenIdListByMobile(mobile string) (items []*OpenIdList, err error) {
-	//openIdstr := WxUsersGet()
-	sql := `SELECT DISTINCT ur.open_id,wu.user_id FROM wx_user AS wu 
-          INNER JOIN company AS c ON c.company_id = wu.company_id 
-          INNER join user_record  as ur on wu.user_id=ur.user_id
-          WHERE ur.open_id != "" AND ur.subscribe=1 and ur.create_platform=1 AND wu.mobile=? `
-	//if openIdstr != "" {
-	//	sql += ` AND ur.open_id in (` + openIdstr + `) `
-	//}
-	_, err = orm.NewOrm().Raw(sql, mobile).QueryRows(&items)
-	return
-}
-
-// 获取预约活动的用户的openID
-func GetActivityOpenIdList(activityId int) (items []*OpenIdList, err error) {
-	sql := `SELECT DISTINCT cr.open_id,u.user_id
-			FROM
-			cygx_my_schedule AS m
-			INNER JOIN user_record AS u ON u.bind_account = m.mobile 
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
-			WHERE m.activity_id = ? AND u.create_platform = 4 `
-	_, err = orm.NewOrm().Raw(sql, activityId).QueryRows(&items)
-	return
-}
-
-// 获取预约活动的用户的openID测试环境
-func GetActivityOpenIdListByDeBug(activityId int) (items []*OpenIdList, err error) {
-	sql := `SELECT
-			u.open_id,
-			u.user_id 
-		FROM
-			cygx_my_schedule AS s
-			INNER JOIN wx_user AS wx ON wx.user_id = s.user_id
-			INNER JOIN user_record AS u ON u.bind_account = wx.mobile
-			INNER JOIN company_product AS p ON p.company_id = wx.company_id 
-		WHERE
-			s.activity_id = ? 
-			AND u.create_platform = 1 
-			AND p.STATUS IN ( '正式', '试用', '永续' ) 
-		GROUP BY
-			u.open_id`
-	_, err = orm.NewOrm().Raw(sql, activityId).QueryRows(&items)
-	return
-}
-
-// 获取预约活动的用户的openID
-func GetActivitySpecialOpenIdList() (items []*OpenIdList, err error) {
-	sql := `SELECT DISTINCT cr.open_id,u.user_id
-			FROM
-			cygx_user_follow_special AS m
-			INNER JOIN user_record AS u ON u.bind_account = m.mobile 
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
-			WHERE  u.create_platform = 4 `
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
-	return
-}
-
-// 获取预约活动的用户的openID测试环境
-func GetActivitySpecialOpenIdListByDeBug() (items []*OpenIdList, err error) {
-	sql := `SELECT
-			u.open_id,
-			u.user_id 
-		FROM
-			cygx_user_follow_special AS s
-			INNER JOIN wx_user AS wx ON wx.user_id = s.user_id
-			INNER JOIN user_record AS u ON u.bind_account = wx.mobile
-			INNER JOIN company_product AS p ON p.company_id = wx.company_id 
-		WHERE
-			u.create_platform = 1 
-			AND p.STATUS IN ( '正式', '试用', '永续' ) 
-		GROUP BY
-			u.open_id`
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
-	return
-}
-
-// 获取关注作者的用户的openID
-func GetFollowDepartmentOpenIdList(departmentId int) (items []*OpenIdList, err error) {
-	sql := `SELECT cr.open_id,u.user_id
-			FROM
-				cygx_article_department_follow AS f
-				INNER JOIN user_record AS u ON u.bind_account = f.mobile
-				INNER JOIN wx_user AS wx ON wx.user_id = f.user_id
-				INNER JOIN company_product AS p ON p.company_id = wx.company_id 
-				INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
-			WHERE
-				f.department_id = ?
-				AND u.create_platform = 4 
-				AND f.type = 1 
-				AND p.status IN ('正式','试用','永续')
-			GROUP BY
-				cr.open_id `
-	_, err = orm.NewOrm().Raw(sql, departmentId).QueryRows(&items)
-	return
-}
-
-// 获取关注作者的用户的openID测试环境
-func GetFollowDepartmentOpenIdListByDeBug(departmentId int) (items []*OpenIdList, err error) {
-	sql := `SELECT
-			u.open_id,
-			u.user_id 
-		FROM
-			cygx_article_department_follow AS f
-			INNER JOIN wx_user AS wx ON wx.user_id = f.user_id
-			INNER JOIN user_record AS u ON u.bind_account = wx.mobile
-			INNER JOIN company_product AS p ON p.company_id = wx.company_id
-		WHERE
-			f.department_id = ? 
-			AND u.create_platform = 1
-			AND f.type = 1 
-			AND p.STATUS IN ( '正式', '试用', '永续' ) 
-		GROUP BY
-			u.open_id`
-	_, err = orm.NewOrm().Raw(sql, departmentId).QueryRows(&items)
-	return
-}
-
-// 获取关注产业的用户的openID
-func GetFollowindustrialOpenIdList(industrialManagementId int) (items []*OpenIdList, err error) {
-	sql := `SELECT cr.open_id,u.user_id
-			FROM
-			cygx_industry_fllow AS f
-			INNER JOIN wx_user AS wx ON wx.user_id = f.user_id
-			INNER JOIN user_record AS u ON u.bind_account = wx.mobile 
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
-			WHERE
-			f.industrial_management_id = ? 
-			AND u.create_platform = 4 
-			AND f.type = 1 GROUP BY cr.open_id `
-	_, err = orm.NewOrm().Raw(sql, industrialManagementId).QueryRows(&items)
-	return
-}
-
-// 获取关注产业的用户的openID 测试环境
-func GetFollowindustrialOpenIdListByDeBug(industrialManagementId int) (items []*OpenIdList, err error) {
-	sql := `SELECT
-			u.open_id,
-			u.user_id 
-		FROM
-			cygx_industry_fllow AS f
-			INNER JOIN wx_user AS wx ON wx.user_id = f.user_id
-			INNER JOIN user_record AS u ON u.bind_account = wx.mobile
-		WHERE
-			f.industrial_management_id = ? 
-			AND u.create_platform = 1 
-			AND u.bind_account != ""
-			AND f.type = 1 
-		GROUP BY
-			u.open_id`
-	_, err = orm.NewOrm().Raw(sql, industrialManagementId).QueryRows(&items)
-	return
-}
-
-// GetUserOpenidListByUserIds 根据用户id字符串集合来获取他的openid列表集合
-func GetUserOpenidListByUserIds(userIdStr []string) (list []*OpenIdList, err error) {
-	if len(userIdStr) <= 0 {
-		return
-	}
-	sql := `SELECT open_id,u.user_id FROM user_record WHERE user_id in (` + strings.Join(userIdStr, ",") + `) and create_platform = 1`
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&list)
-	return
-}
-
-func GetAdminOpenIdByMobile(mobile string) (items []*OpenIdList, err error) {
-	sql := `SELECT DISTINCT ur.open_id,wu.user_id FROM wx_user AS wu 
-          INNER JOIN company AS c ON c.company_id = wu.company_id 
-          INNER join user_record  as ur on wu.user_id=ur.user_id
-          WHERE ur.open_id != "" and ur.create_platform=1 AND wu.mobile=? `
-	_, err = orm.NewOrm().Raw(sql, mobile).QueryRows(&items)
-	return
-}
-
-// 根据手机号获取用户的openid查研观向小助手专用
-func GetUserRecordListByMobile(platform int, bindAccount string) (items []*OpenIdList, err error) {
-	var sql string
-	if utils.RunMode == "release" {
-		sql = `SELECT cr.open_id FROM user_record  as u 
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
-			WHERE create_platform=? AND bind_account IN (` + bindAccount + `)`
-	} else {
-		platform = 1
-		sql = `SELECT open_id FROM	user_record  WHERE create_platform =? AND bind_account IN (` + bindAccount + `)`
-	}
-	_, err = orm.NewOrm().Raw(sql, platform).QueryRows(&items)
-	return
-}
-
-// 获取单个用户openid
-func GetCompanyDetailByIdGroup(platform int, bindAccount string) (item *OpenIdList, err error) {
-	o := orm.NewOrm()
-	var sql string
-	sql = `SELECT cr.open_id,wu.user_id FROM user_record  as u 
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
-			INNER JOIN wx_user AS wu ON wu.mobile = u.bind_account 
-			WHERE create_platform=? AND u.bind_account = ?`
-	err = o.Raw(sql, platform, bindAccount).QueryRow(&item)
-	return
-}
-
-// 获取小助手所有的用户的openid
-func GetCygxUserAllOpneid() (items []*OpenIdList, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-			cr.open_id,
-			r.user_id 
-		FROM
-			user_record AS r
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = r.union_id 
-		WHERE
-			r.create_platform = 4`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
 func GetOpenIdArr() (items []string, err error) {
 	sql := ` SELECT DISTINCT ur.open_id FROM wx_user AS wu 
           INNER JOIN company AS c ON c.company_id = wu.company_id 
@@ -254,182 +15,6 @@ func GetOpenIdArr() (items []string, err error) {
 	return
 }
 
-// 获取预约活动的用户的openID测试环境
-func GetActivitySpecialOpenIdListMobile(condition string, pars []interface{}) (items []*OpenIdList, err error) {
-	sql := `SELECT
-			cr.open_id,
-			u.user_id
-		FROM
-			company_report_permission AS p
-			INNER JOIN wx_user AS u ON u.company_id = p.company_id
-			INNER JOIN user_record AS r ON r.user_id = u.user_id
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = r.union_id 
-		WHERE
-			 r.create_platform = 4  AND p.STATUS IN ('正式','试用','永续')  ` + condition + ` GROUP BY cr.open_id`
-	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&items)
-	return
-}
-
-// 获取所有关注了该产业用户的openid
-func GetCygxUserIndustryFllowOpneid(IndustrialManagementId int) (items []*OpenIdList, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-			cr.open_id,
-			r.user_id 
-		FROM
-			user_record AS r
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = r.union_id 
-			INNER join cygx_industry_fllow  as cf on cf.user_id = r.user_id 
-		WHERE
-			r.create_platform = 4
-			AND cf.industrial_management_id = ?`
-	_, err = o.Raw(sql, IndustrialManagementId).QueryRows(&items)
-	return
-}
-
-// 获取所有关注了该产业用户的openid
-func GetCygxUserIndustryFllowOpneidByActivityIds(activityId int) (items []*OpenIdList, err error) {
-	o := orm.NewOrm()
-	sql := `			
-SELECT
-	cr.open_id,
-	r.user_id 
-FROM
-	cygx_industrial_activity_group_management AS agm
-	INNER JOIN cygx_industry_fllow AS f ON f.industrial_management_id = agm.industrial_management_id
-	INNER JOIN user_record AS r
-	INNER JOIN cygx_user_record AS cr 
-WHERE
-	agm.activity_id = ? 
-	AND cr.union_id = r.union_id 
-	AND r.create_platform = 4 
-	AND r.user_id = f.user_id;`
-	_, err = o.Raw(sql, activityId).QueryRows(&items)
-	return
-}
-
-// 获取所有关注了该产业永续客户的openid
-func GetCygxForeverUserIndustryFllowOpneidByActivityIds(activityId int) (items []*OpenIdList, err error) {
-	o := orm.NewOrm()
-	sql := `			
-SELECT
-	cr.open_id,
-	r.user_id 
-FROM
-	cygx_industrial_activity_group_management AS agm
-	INNER JOIN cygx_industry_fllow AS f ON f.industrial_management_id = agm.industrial_management_id
-	INNER JOIN user_record AS r
-	INNER JOIN cygx_user_record AS cr 
-	INNER JOIN wx_user AS wx ON wx.user_id = r.user_id 
-	INNER JOIN company_product AS p ON p.company_id = wx.company_id 
-WHERE
-	agm.activity_id = ? 
-	AND cr.union_id = r.union_id 
-	AND r.create_platform = 4 
-	AND r.user_id = f.user_id
-	AND p.status = "永续";`
-	_, err = o.Raw(sql, activityId).QueryRows(&items)
-	return
-}
-
-// 获取所有关注了该产业试用客户的openid
-func GetCygxTryOutUserIndustryFllowOpneidByActivityIds(activityId int) (items []*OpenIdList, err error) {
-	o := orm.NewOrm()
-	sql := `			
-SELECT
-	cr.open_id,
-	r.user_id 
-FROM
-	cygx_industrial_activity_group_management AS agm
-	INNER JOIN cygx_industry_fllow AS f ON f.industrial_management_id = agm.industrial_management_id
-	INNER JOIN user_record AS r
-	INNER JOIN cygx_user_record AS cr 
-	INNER JOIN wx_user AS wx ON wx.user_id = r.user_id 
-	INNER JOIN company_product AS p ON p.company_id = wx.company_id 
-WHERE
-	agm.activity_id = ? 
-	AND cr.union_id = r.union_id 
-	AND r.create_platform = 4 
-	AND r.user_id = f.user_id
-	AND p.status = "试用";`
-	_, err = o.Raw(sql, activityId).QueryRows(&items)
-	return
-}
-
-// 获取所有关注了该产业用户的companyIds
-func GetCygxIndustryFollowCompanyIdsByActivityId(activityId int) (item *string, err error) {
-	o := orm.NewOrm()
-	sql := `			
-SELECT
-	GROUP_CONCAT( DISTINCT f.company_id SEPARATOR ',' ) AS company_ids
-FROM
-	cygx_industrial_activity_group_management AS agm
-	INNER JOIN cygx_industry_fllow AS f ON f.industrial_management_id = agm.industrial_management_id
-	INNER JOIN user_record AS r
-	INNER JOIN cygx_user_record AS cr 
-WHERE
-	agm.activity_id = ? 
-	AND r.create_platform = 4 
-	AND r.user_id = f.user_id;`
-	err = o.Raw(sql, activityId).QueryRow(&item)
-	return
-}
-
-// 获取所有关注了该产业用户的openidBy公司id
-func GetCygxUserIndustryFllowOpneidByActivityIdAndCompanyIds(activityId int, companyIds string) (items []*OpenIdList, err error) {
-	o := orm.NewOrm()
-	sql := `			
-SELECT
-	cr.open_id,
-	r.user_id 
-FROM
-	cygx_industrial_activity_group_management AS agm
-	INNER JOIN cygx_industry_fllow AS f ON f.industrial_management_id = agm.industrial_management_id
-	INNER JOIN user_record AS r
-	INNER JOIN cygx_user_record AS cr 
-WHERE
-	agm.activity_id = ? 
-	AND cr.union_id = r.union_id 
-	AND r.create_platform = 4 
-	AND r.user_id = f.user_id
-	AND f.company_id IN (` + companyIds + `);`
-	_, err = o.Raw(sql, activityId).QueryRows(&items)
-	return
-}
-
-// 获取所有互动过的用户id
-func GetCygxInteractiveUserByActivityId(activityId int) (items []*int, err error) {
-	o := orm.NewOrm()
-	sql := `			
-SELECT user_id FROM cygx_activity_signup WHERE activity_id =? AND fail_type = 0
-UNION ALL
-SELECT user_id FROM cygx_activity_appointment WHERE activity_id = ?
-UNION ALL
-SELECT user_id FROM cygx_activity_meeting_reminder WHERE activity_id = ?
-UNION ALL
-SELECT user_id FROM cygx_activity_help_ask  WHERE activity_id = ? `
-	_, err = o.Raw(sql, activityId, activityId, activityId, activityId).QueryRows(&items)
-	return
-}
-
-// 获取所有用户的openid
-func GetCygxUserOpneidByUserIds(userIds string) (items []*OpenIdList, err error) {
-	o := orm.NewOrm()
-	sql := `			
-SELECT
-	cr.open_id,
-	r.user_id 
-FROM
-	user_record AS r
-	INNER JOIN cygx_user_record AS cr 
-WHERE
-	cr.union_id = r.union_id 
-	AND r.create_platform = 4 
-	AND r.user_id IN (` + userIds + `);`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
 func GetOpenIdArrByClassifyNameSecond(classifyNameSecond string) (items []string, err error) {
 	sql := ` SELECT DISTINCT ur.open_id FROM wx_user AS wu 
 			INNER JOIN company AS c ON c.company_id = wu.company_id 
@@ -445,32 +30,3 @@ func GetOpenIdArrByClassifyNameSecond(classifyNameSecond string) (items []string
 	_, err = orm.NewOrm().Raw(sql, classifyNameSecond).QueryRows(&items)
 	return
 }
-
-func GetOpenIdArrByChartPermissionIds(chartPermissionIds string) (items []string, err error) {
-	sql := ` SELECT DISTINCT ur.open_id FROM wx_user AS wu 
-INNER JOIN company AS c ON c.company_id = wu.company_id 
-INNER JOIN company_product AS d ON c.company_id=d.company_id
-INNER JOIN user_record  AS ur ON wu.user_id=ur.user_id
-INNER JOIN company_report_permission AS e ON d.company_id=e.company_id
-INNER JOIN chart_permission AS f ON e.chart_permission_id=f.chart_permission_id
-WHERE ur.open_id != "" AND ur.subscribe=1 AND ur.create_platform=1 AND  d.status IN('正式','试用','永续')
-AND f.chart_permission_id IN(` + chartPermissionIds + `)
-ORDER BY FIELD(c.company_id, 16) DESC, ur.user_record_id ASC  `
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
-	return
-}
-
-func GetOpenIdArrByVarietyTag(varietyTagId int) (items []string, err error) {
-	sql := ` SELECT DISTINCT ur.open_id FROM wx_user AS wu 
-INNER JOIN company AS c ON c.company_id = wu.company_id 
-INNER JOIN company_product AS d ON c.company_id=d.company_id
-INNER JOIN user_record  AS ur ON wu.user_id=ur.user_id
-INNER JOIN company_report_permission AS e ON d.company_id=e.company_id
-INNER JOIN chart_permission AS f ON e.chart_permission_id=f.chart_permission_id
-INNER JOIN variety_tag AS g ON f.chart_permission_id=g.chart_permission_id
-WHERE ur.open_id != "" AND ur.subscribe=1 AND ur.create_platform=1 AND  d.status IN('正式','试用','永续')
-AND g.variety_tag_id=?
-ORDER BY FIELD(c.company_id, 16) DESC, ur.user_record_id ASC  `
-	_, err = orm.NewOrm().Raw(sql, varietyTagId).QueryRows(&items)
-	return
-}

+ 0 - 114
services/data/edb_data.go

@@ -2,7 +2,6 @@ package data
 
 import (
 	"errors"
-	"eta/eta_mobile/models"
 	"eta/eta_mobile/models/data_manage"
 	"eta/eta_mobile/utils"
 	"fmt"
@@ -10,71 +9,6 @@ import (
 	"time"
 )
 
-// EdbDataEdit 指标数据修改
-type EdbDataEdit struct {
-	OldCreateDate string `description:"旧的录入日期"`
-	CreateDate    string `description:"新的录入日期"`
-	TradeCode     string `description:"指标唯一编码"`
-	Close         string `description:"录入值"`
-}
-
-// BatchEdbData 批量修改指标数据
-func BatchEdbData(oldCreateDate, createDate string, list []EdbDataEdit, opUserId int) (failEdbDataList []EdbDataEdit, err error) {
-	if oldCreateDate == createDate { //修改
-		err = errors.New("开始日期与结束日期一致!")
-		return
-	}
-	for _, newEdbData := range list {
-		edbdata := new(models.Edbdata)
-		edbdata.TradeCode = newEdbData.TradeCode
-		edbdata.Dt = newEdbData.CreateDate
-		edbdata.Close = newEdbData.Close
-		edbdata.ModifyTime = time.Now()
-
-		item, err := models.GetDataInfo(newEdbData.TradeCode, createDate)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			failEdbDataList = append(failEdbDataList, newEdbData)
-			continue
-		}
-		if item == nil {
-			_, err = models.AddEdbdata(edbdata)
-			if err != nil {
-				failEdbDataList = append(failEdbDataList, newEdbData)
-				continue
-			}
-		} else {
-			err = models.EditEdbdata(edbdata)
-			if err != nil {
-				failEdbDataList = append(failEdbDataList, newEdbData)
-				continue
-			}
-		}
-		oldItem, err := models.GetDataInfo(newEdbData.TradeCode, oldCreateDate)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			failEdbDataList = append(failEdbDataList, newEdbData)
-			continue
-		}
-		if oldItem != nil {
-			record := new(models.EdbdataDeleteRecord)
-			record.TradeCode = oldItem.TradeCode
-			record.Dt = oldItem.Dt
-			record.Close = oldItem.Close
-			record.ModifyTime = oldItem.ModifyTime
-			record.CreateTime = time.Now()
-			record.SysUserId = opUserId
-			_, err = models.AddEdbdataDeleteRecord(record)
-			if err != nil {
-
-				failEdbDataList = append(failEdbDataList, newEdbData)
-				continue
-			}
-			//删除数据
-			models.DeleteEdbData(newEdbData.TradeCode, newEdbData.OldCreateDate)
-		}
-	}
-	return
-}
-
 // GetEdbDataTbz 获取指标的同比值数据
 func GetEdbDataTbz(edbInfo *data_manage.EdbInfo, tmpDataList []*data_manage.EdbDataList, startDateTime time.Time) (dataList []*data_manage.EdbDataList, minValue, maxValue float64, err error) {
 	dataList = make([]*data_manage.EdbDataList, 0)
@@ -357,51 +291,3 @@ func GetDateData(edbInfo *data_manage.EdbInfo, startDate, endDate string) (item
 
 	return
 }
-
-// GetEdbBeforeAndAfterDateData 获取指标的单个日期的值
-func GetEdbBeforeAndAfterDateData(edbInfo *data_manage.EdbInfo, startDate, endDate string, dataType, num int) (list []*data_manage.EdbDataList, err error) {
-	var dataList []*data_manage.EdbDataList
-	switch edbInfo.EdbInfoType {
-	case 0:
-		dataList, err = data_manage.GetEdbDataList(edbInfo.Source, edbInfo.EdbInfoId, startDate, endDate)
-	case 1:
-		_, dataList, _, _, err, _ = GetPredictDataListByPredictEdbInfoId(edbInfo.EdbInfoId, startDate, endDate, true)
-	default:
-		err = errors.New(fmt.Sprint("获取失败,指标类型异常", edbInfo.EdbInfoType))
-
-	}
-	if err != nil {
-		return
-	}
-
-	lenDataList := len(dataList)
-	if lenDataList <= 0 {
-		return
-	}
-
-	switch dataType {
-	case 1: // 取前面的数据
-		if lenDataList <= 1 { // 如果只有一个,那么也返回,因为自己不算
-			return
-		}
-		if lenDataList <= num {
-			num = lenDataList - 1
-		}
-
-		for i := num; i >= 0; i-- {
-			list = append(list, dataList[lenDataList-1-i])
-		}
-
-	case 2: // 取后面的数据
-		num = num + 1
-		if lenDataList < num {
-			num = lenDataList
-		}
-
-		for i := 0; i < num; i++ {
-			list = append(list, dataList[i])
-		}
-	}
-
-	return
-}

+ 0 - 11
services/wechat_send_msg.go

@@ -13,17 +13,6 @@ import (
 	"strings"
 )
 
-type SendTemplateResponse struct {
-	Errcode int    `json:"errcode"`
-	Errmsg  string `json:"errmsg"`
-	MsgID   int    `json:"msgid"`
-}
-
-type ClearQuotaResponse struct {
-	Errcode int    `json:"errcode"`
-	Errmsg  string `json:"errmsg"`
-}
-
 // SendMiniProgramReportWxMsg 推送报告微信模板消息-小程序链接
 func SendMiniProgramReportWxMsg(reportId int) (err error) {
 	var msg string