rdluck %!s(int64=4) %!d(string=hai) anos
pai
achega
51c055234e
Modificáronse 4 ficheiros con 14 adicións e 8 borrados
  1. 6 4
      models/report_view.go
  2. 6 4
      services/report_view.go
  3. 1 0
      services/task.go
  4. 1 0
      utils/constants.go

+ 6 - 4
models/report_view.go

@@ -50,7 +50,7 @@ type ResearchReportViewersDetail struct {
 	ReportCreateDate string
 }
 
-func GetResearchReportViewersDetail(startTime, reportType string) (items []*ResearchReportViewersDetail, err error) {
+func GetResearchReportViewersDetail(startTime,endTime, reportType string) (items []*ResearchReportViewersDetail, err error) {
 	sql := `
 			select u.real_name,c.company_name,uvh.created_time,rr.research_report_name,ifnull(rct.report_chapter_type_name,rr.report_variety) as report_variety,rr.type as research_report_type
 			from user_view_history uvh
@@ -60,15 +60,16 @@ func GetResearchReportViewersDetail(startTime, reportType string) (items []*Rese
 			left join research_report_type rrt on rrt.research_report_type_id = uvh.research_report_type_id
 			left join report_chapter_type rct on rct.report_chapter_type_id	= rrt.type_id
 			where uvh.created_time > ?
+            and uvh.created_time <= ?
 			and rr.type =?
 			and c.company_id not in (1,16)
 `
 	o := orm.NewOrm()
-	_, err = o.Raw(sql, startTime, reportType).QueryRows(&items)
+	_, err = o.Raw(sql, startTime,endTime, reportType).QueryRows(&items)
 	return
 }
 
-func GetRddpReportViewersDetail(startTime string) (items []*ResearchReportViewersDetail, err error) {
+func GetRddpReportViewersDetail(startTime,endTime string) (items []*ResearchReportViewersDetail, err error) {
 	sql := `
 			SELECT u.real_name,c.company_name,uvh.create_time as created_time,REPLACE(SUBSTRING(r.create_time,6,5),'-','') AS report_create_date,r.title as research_report_name,r.classify_name_second as research_report_type
 			FROM hongze_rddp.report_view_record AS uvh
@@ -76,10 +77,11 @@ func GetRddpReportViewersDetail(startTime string) (items []*ResearchReportViewer
 			INNER JOIN wx_user u ON u.user_id = uvh.user_id
 			INNER JOIN company c ON c.company_id = u.company_id
 			WHERE uvh.create_time >?
+            AND uvh.create_time <=?
 			AND c.company_id NOT IN (1,16)
 			ORDER BY uvh.create_time DESC
 `
 	o := orm.NewOrm()
-	_, err = o.Raw(sql, startTime).QueryRows(&items)
+	_, err = o.Raw(sql, startTime,endTime).QueryRows(&items)
 	return
 }

+ 6 - 4
services/report_view.go

@@ -31,7 +31,7 @@ func ReportViewTimes() (err error) {
 
 	two_week:=new(models.ReportType)
 	two_week.TypeName="双周报"
-	two_week.TypeValue="week"
+	two_week.TypeValue="two_week"
 	typeList=append(typeList,two_week)
 
 	month:=new(models.ReportType)
@@ -142,7 +142,7 @@ func ReportViewDetail() (err error) {
 
 	two_week:=new(models.ReportType)
 	two_week.TypeName="双周报"
-	two_week.TypeValue="week"
+	two_week.TypeValue="two_week"
 	typeList=append(typeList,two_week)
 
 	month:=new(models.ReportType)
@@ -161,6 +161,7 @@ func ReportViewDetail() (err error) {
 	typeList=append(typeList,rddp)
 
 	startTime:=time.Now().AddDate(0,0,-7).Format(utils.FormatDateTime)
+	endTime:=time.Now().Format(utils.FormatDateTime)
 	//创建excel
 	file:=xlsx.NewFile()
 	for _, v := range typeList {
@@ -183,7 +184,7 @@ func ReportViewDetail() (err error) {
 			cellF:=rowTitle.AddCell()
 			cellF.Value="报告类型"
 
-			items, err := models.GetRddpReportViewersDetail(startTime)
+			items, err := models.GetRddpReportViewersDetail(startTime,endTime)
 			if err != nil {
 				return err
 			}
@@ -220,7 +221,7 @@ func ReportViewDetail() (err error) {
 			cellF:=rowTitle.AddCell()
 			cellF.Value="报告类型"
 
-			items, err := models.GetResearchReportViewersDetail(startTime,v.TypeValue)
+			items, err := models.GetResearchReportViewersDetail(startTime,endTime,v.TypeValue)
 			if err != nil {
 				return err
 			}
@@ -250,6 +251,7 @@ func ReportViewDetail() (err error) {
 	title:="研报阅读统计报表"
 	fmt.Println("start send email")
 	sendResult:=utils.SendEmailByHongze(title,"你好,上周研报阅读统计见附件。",utils.EmailSendToHzUsers,savePath)
+	//sendResult:=utils.SendEmailByHongze(title,"你好,上周研报阅读统计见附件。",utils.EmailSendToMe,savePath)
 	if sendResult {
 		os.Remove(savePath)
 	}

+ 1 - 0
services/task.go

@@ -16,5 +16,6 @@ func Task() {
 	toolbox.AddTask("reportViewDetail", reportViewDetail)
 
 	toolbox.StartTask()
+
 	fmt.Println("end")
 }

+ 1 - 0
utils/constants.go

@@ -21,6 +21,7 @@ const (
 const (
 	APPNAME          = "弘则-数据录入"
 	EmailSendToUsers = "lnyan@hzinsights.com;317699326@qq.com"
+	EmailSendToMe = "317699326@qq.com"
 )
 
 //手机号,电子邮箱正则