浏览代码

查研观向8.2合同升级定时任务,每日定时合同处理

xingzai 2 年之前
父节点
当前提交
dce864f504

+ 3 - 3
models/company/company.go

@@ -63,9 +63,9 @@ func TryOutToFormal(companyId, productId, sellerId, companyContractId int, start
 	}
 	for _, pv := range contractPermission {
 		sql = `INSERT INTO company_report_permission(company_id, report_permission_id,created_time, last_updated_time,
-             chart_permission_id, start_date,end_date,product_id,product_name, modify_time,company_contract_id,status) 
-			VALUES(?,?,NOW(),NOW(),?,?,?,?,?,NOW(),?,?) `
-		_, err = tx.Raw(sql, companyId, pv.ChartPermissionId, pv.ChartPermissionId, pv.StartDate, pv.EndDate, productId, productName, companyContractId, "正式").Exec()
+             chart_permission_id, start_date,end_date,product_id,product_name, modify_time,company_contract_id,status,is_upgrade) 
+			VALUES(?,?,NOW(),NOW(),?,?,?,?,?,NOW(),?,?,?) `
+		_, err = tx.Raw(sql, companyId, pv.ChartPermissionId, pv.ChartPermissionId, pv.StartDate, pv.EndDate, productId, productName, companyContractId, "正式",pv.IsUpgrade).Exec()
 		if err != nil {
 			return
 		}

+ 2 - 0
models/company_report_permission.go

@@ -19,6 +19,8 @@ type CompanyReportPermission struct {
 	StartDate                 string    `description:"合同开始日期"`
 	EndDate                   string    `description:"合同结束日期"`
 	ModifyTime                string    `description:"更新时间"`
+	IsUpgrade                 int       `description:"是否升级,1是,0否"`
+
 }
 
 func GetCompanyReportPermission(companyId int) (items []*CompanyReportPermission, err error) {

+ 1 - 3
models/data_manage/ppt_v2_save_log.go

@@ -1,13 +1,11 @@
 package data_manage
 
 import (
-	"fmt"
 	"github.com/beego/beego/v2/client/orm"
 )
 
 func DeletePPTLogByDate(date string) (err error) {
-	sql := `DELETE FROM ppt_v2_save_log WHERE create_time<%s `
-	sql = fmt.Sprintf(sql, date)
+	sql := `DELETE FROM ppt_v2_save_log WHERE create_time<? `
 	o := orm.NewOrmUsingDB("rddp")
 	_, err = o.Raw(sql, date).Exec()
 

+ 1 - 3
models/data_manage/report_save_log.go

@@ -1,13 +1,11 @@
 package data_manage
 
 import (
-	"fmt"
 	"github.com/beego/beego/v2/client/orm"
 )
 
 func DeleteReportLogByDate(date string) (err error) {
-	sql := `DELETE FROM report_save_log WHERE create_time<%s `
-	sql = fmt.Sprintf(sql, date)
+	sql := `DELETE FROM report_save_log WHERE create_time<? `
 	o := orm.NewOrmUsingDB("rddp")
 	_, err = o.Raw(sql, date).Exec()
 

+ 46 - 1
models/report_view.go

@@ -80,7 +80,7 @@ func GetRddpReportViewersDetail(startTime, endTime string) (items []*ResearchRep
 			WHERE uvh.create_time >?
             AND uvh.create_time <=?
 			AND c.company_id NOT IN (1)
-			AND r.classify_name_first not in ("周报","双周报")
+			AND r.classify_name_first not in ("周报","双周报","月报","数据点评","会议纪要","年报合集","需求报告")
 			ORDER BY uvh.create_time DESC
 `
 	o := orm.NewOrm()
@@ -97,6 +97,7 @@ type RddpWeekReportViewersDetail struct {
 	ResearchReportType string
 	ReportCreateDate   string
 	ChapterTitle       string
+	ClassifyNameFirst  string
 	ClassifyNameSecond string
 }
 
@@ -143,6 +144,50 @@ FROM
 	return
 }
 
+// GetRddpMonthReportViewersDetail 获取月度数据
+func GetRddpMonthReportViewersDetail(startTime, endTime string) (items []*RddpWeekReportViewersDetail, 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,r.classify_name_second 
+FROM
+	hongze_rddp.report_view_record AS uvh
+	INNER JOIN hongze_rddp.report AS r ON uvh.report_id = r.id
+	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)
+			AND r.classify_name_first = "月报"
+			ORDER BY uvh.create_time DESC
+`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, startTime, endTime).QueryRows(&items)
+	return
+}
+
+// GetRddpDataReviewReportViewersDetail 获取数据点评数据
+func GetRddpDataReviewReportViewersDetail(startTime, endTime string) (items []*RddpWeekReportViewersDetail, 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,r.classify_name_second,r.classify_name_first 
+FROM
+	hongze_rddp.report_view_record AS uvh
+	INNER JOIN hongze_rddp.report AS r ON uvh.report_id = r.id
+	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)
+			AND r.classify_name_first IN ("数据点评","会议纪要","年报合集","需求报告")
+			ORDER BY uvh.create_time DESC
+`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, startTime, endTime).QueryRows(&items)
+	return
+}
+
 type HistoryViewTimes struct {
 	RealName    string
 	CompanyName string

+ 7 - 4
services/data/edb_info_sync.go

@@ -46,6 +46,7 @@ func SyncGlDataBase() {
 }
 
 var lzLock sync.Mutex
+
 //同步隆重数据
 func SyncLzDataBase() {
 	lzLock.Lock()
@@ -53,7 +54,7 @@ func SyncLzDataBase() {
 	defer func() {
 		if err != nil {
 			utils.FileLog.Info("SyncLzDataBase Err:" + err.Error())
-			go utils.SendEmailByHongze("同步隆众数据失败","同步隆众数据失败 Err:"+err.Error() , utils.RefreshEdbInfoEmailSendToUsers, "", "")
+			go utils.SendEmailByHongze("同步隆众数据失败", "同步隆众数据失败 Err:"+err.Error(), utils.RefreshEdbInfoEmailSendToUsers, "", "")
 		}
 	}()
 	var condition string
@@ -84,6 +85,7 @@ func SyncLzDataBase() {
 }
 
 var smmLock sync.Mutex
+
 //同步有色数据
 func SyncSmmDataBase() {
 	smmLock.Lock()
@@ -91,7 +93,7 @@ func SyncSmmDataBase() {
 	defer func() {
 		if err != nil {
 			utils.FileLog.Info("SyncSmmDataBase Err:" + err.Error())
-			go utils.SendEmailByHongze("同步有色数据失败","同步隆众数据失败 Err:"+err.Error() , utils.RefreshEdbInfoEmailSendToUsers, "", "")
+			go utils.SendEmailByHongze("同步有色数据失败", "同步隆众数据失败 Err:"+err.Error(), utils.RefreshEdbInfoEmailSendToUsers, "", "")
 		}
 	}()
 	var condition string
@@ -123,6 +125,7 @@ func SyncSmmDataBase() {
 }
 
 var manualLock sync.Mutex
+
 //同步手工数据
 func SyncManualDataBase() {
 	var err error
@@ -130,13 +133,13 @@ func SyncManualDataBase() {
 	defer func() {
 		if err != nil {
 			utils.FileLog.Info("SyncLzDataBase Err:" + err.Error())
-			go utils.SendEmailByHongze("同步手工数据失败","同步手工数据失败 Err:"+err.Error() , utils.RefreshEdbInfoEmailSendToUsers, "", "")
+			go utils.SendEmailByHongze("同步手工数据失败", "同步手工数据失败 Err:"+err.Error(), utils.RefreshEdbInfoEmailSendToUsers, "", "")
 		}
 	}()
 	var condition string
 	var pars []interface{}
 	condition += " AND source=? "
-	condition += " AND edb_code='W000156' "
+	//condition += " AND edb_code='W000156' "
 
 	pars = append(pars, utils.DATA_SOURCE_MANUAL)
 	items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)

+ 123 - 0
services/report_view.go

@@ -258,6 +258,128 @@ func ReportViewDetail() (err error) {
 				cellF.Value = `双周报`
 			}
 			continue
+		} else if v.TypeName == `月报` {
+			sheet, err := file.AddSheet(v.TypeName + "研报阅读统计")
+			if err != nil {
+				return err
+			}
+			//标头
+			rowTitle := sheet.AddRow()
+			cellA := rowTitle.AddCell()
+			cellA.Value = "用户名称"
+			cellB := rowTitle.AddCell()
+			cellB.Value = "公司名称"
+			cellC := rowTitle.AddCell()
+			cellC.Value = "访问时间"
+			cellD := rowTitle.AddCell()
+			cellD.Value = "访问标题"
+			cellE := rowTitle.AddCell()
+			cellE.Value = "访问页面"
+			cellF := rowTitle.AddCell()
+			cellF.Value = "报告类型"
+
+			items, err := models.GetResearchReportViewersDetail(startTime, endTime, v.TypeValue)
+			if err != nil {
+				return err
+			}
+			for _, item := range items {
+				row := sheet.AddRow()
+				cellA := row.AddCell()
+				cellA.Value = item.RealName
+				cellB := row.AddCell()
+				cellB.Value = item.CompanyName
+				cellC := row.AddCell()
+				cellC.Value = item.CreatedTime
+				cellD := row.AddCell()
+				cellD.Value = item.ResearchReportName
+				cellE := row.AddCell()
+				cellE.Value = item.ReportVariety
+				cellF := row.AddCell()
+				cellF.Value = v.TypeName
+			}
+
+			//新月报的数据
+			monthItems, err := models.GetRddpMonthReportViewersDetail(startTime, endTime)
+			if err != nil {
+				return err
+			}
+			for _, item := range monthItems {
+				row := sheet.AddRow()
+				cellA := row.AddCell()
+				cellA.Value = item.RealName
+				cellB := row.AddCell()
+				cellB.Value = item.CompanyName
+				cellC := row.AddCell()
+				cellC.Value = item.CreatedTime
+				cellD := row.AddCell()
+				cellD.Value = `【弘则` + item.ClassifyNameSecond + `】` + item.ResearchReportName
+				cellE := row.AddCell()
+				cellE.Value = item.ClassifyNameSecond
+				cellF := row.AddCell()
+				cellF.Value = `月报`
+			}
+			continue
+		} else if v.TypeName == `数据点评` {
+			sheet, err := file.AddSheet(v.TypeName + "研报阅读统计")
+			if err != nil {
+				return err
+			}
+			//标头
+			rowTitle := sheet.AddRow()
+			cellA := rowTitle.AddCell()
+			cellA.Value = "用户名称"
+			cellB := rowTitle.AddCell()
+			cellB.Value = "公司名称"
+			cellC := rowTitle.AddCell()
+			cellC.Value = "访问时间"
+			cellD := rowTitle.AddCell()
+			cellD.Value = "访问标题"
+			cellE := rowTitle.AddCell()
+			cellE.Value = "访问页面"
+			cellF := rowTitle.AddCell()
+			cellF.Value = "报告类型"
+
+			items, err := models.GetResearchReportViewersDetail(startTime, endTime, v.TypeValue)
+			if err != nil {
+				return err
+			}
+			for _, item := range items {
+				row := sheet.AddRow()
+				cellA := row.AddCell()
+				cellA.Value = item.RealName
+				cellB := row.AddCell()
+				cellB.Value = item.CompanyName
+				cellC := row.AddCell()
+				cellC.Value = item.CreatedTime
+				cellD := row.AddCell()
+				cellD.Value = item.ResearchReportName
+				cellE := row.AddCell()
+				cellE.Value = item.ReportVariety
+				cellF := row.AddCell()
+				cellF.Value = v.TypeName
+			}
+
+			//新数据点评的数据
+			monthItems, err := models.GetRddpDataReviewReportViewersDetail(startTime, endTime)
+			if err != nil {
+				return err
+			}
+			for _, item := range monthItems {
+				row := sheet.AddRow()
+				cellA := row.AddCell()
+				cellA.Value = item.RealName
+				cellB := row.AddCell()
+				cellB.Value = item.CompanyName
+				cellC := row.AddCell()
+				cellC.Value = item.CreatedTime
+				cellD := row.AddCell()
+				cellD.Value = `【弘则` + item.ClassifyNameSecond + `】` + item.ResearchReportName
+				cellE := row.AddCell()
+				cellE.Value = item.ClassifyNameSecond
+				cellF := row.AddCell()
+				cellF.Value = item.ClassifyNameFirst
+			}
+			continue
 		}
 
 		if v.TypeValue == "rddp" {
@@ -384,6 +506,7 @@ func ReportViewDetail() (err error) {
 	if sendResult {
 		os.Remove(savePath)
 	}
+
 	//fmt.Println("send result:", sendResult)
 	//fmt.Println("end send email")
 	return nil

+ 1 - 1
services/save_log.go

@@ -10,7 +10,7 @@ import (
 )
 
 func DeleteLog(cont context.Context) (err error) {
-	date := time.Now().AddDate(0,-1,0).Format(utils.FormatDateTime)
+	date := time.Now().AddDate(0,-1,0).Format(utils.FormatDate)
 	go func() {
 		err = data_manage.DeletePPTLogByDate(date)
 		if err != nil {

+ 8 - 7
services/task.go

@@ -109,7 +109,7 @@ func Task() {
 	task.AddTask("syncSubStatus", syncSubStatus)
 
 	//删除日志 report_save_log,ppt_v2_save_log,保留一个月的
-	deleteLog := task.NewTask("syncSubStatus", "0 0 2 1 * *", DeleteLog)
+	deleteLog := task.NewTask("syncSubStatus", "0 0 2 2 * *", DeleteLog)
 	task.AddTask("deleteLog", deleteLog)
 
 	// 定时发布研报语音播报
@@ -139,12 +139,12 @@ func Task() {
 
 //生产环境需要走的任务
 func releaseTask() {
-	//隆众调研指标获取
-	getLzSurveyProduct := task.NewTask("getLzSurveyProduct", "0 5 08-19/1 * * * ", GetLzSurveyProduct)
-	task.AddTask("getLzSurveyProduct", getLzSurveyProduct)
-	//隆众调研指标数据获取
-	getLzSurveyProductData := task.NewTask("getLzSurveyProductData", "0 10 08-20/1 * * * ", GetLzSurveyProductData)
-	task.AddTask("getLzSurveyProductData", getLzSurveyProductData)
+	////隆众调研指标获取
+	//getLzSurveyProduct := task.NewTask("getLzSurveyProduct", "0 5 08-19/1 * * * ", GetLzSurveyProduct)
+	//task.AddTask("getLzSurveyProduct", getLzSurveyProduct)
+	////隆众调研指标数据获取
+	//getLzSurveyProductData := task.NewTask("getLzSurveyProductData", "0 10 08-20/1 * * * ", GetLzSurveyProductData)
+	//task.AddTask("getLzSurveyProductData", getLzSurveyProductData)
 
 	//发送邮件
 	sendEmail := task.NewTask("sendEmail", "0 0 12 * * 0 ", SendEmail)
@@ -788,6 +788,7 @@ func checkDataServer(cont context.Context) (err error) {
 	go data.CheckWindDataInterface(cont)
 	//检测同花顺数据服务器
 	//go data.CheckThsDataInterface(cont)
+
 	//检测路透数据服务器
 	go data.CheckLtDataInterface(cont)
 	//检测彭博