Răsfoiți Sursa

fix: 已审批的报告

hsun 1 an în urmă
părinte
comite
ea8fce075a

+ 2 - 1
go.mod

@@ -9,6 +9,7 @@ require (
 	github.com/gin-gonic/gin v1.8.1
 	github.com/go-redis/redis/v8 v8.11.5
 	github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
+	github.com/gonum/stat v0.0.0-20181125101827-41a0da705a5b
 	github.com/json-iterator/go v1.1.12
 	github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
 	github.com/nosixtools/solarlunar v0.0.0-20211112060703-1b6dea7b4a19
@@ -50,10 +51,10 @@ require (
 	github.com/goccy/go-json v0.9.7 // indirect
 	github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac // indirect
 	github.com/gonum/floats v0.0.0-20181209220543-c233463c7e82 // indirect
+	github.com/gonum/integrate v0.0.0-20181209220457-a422b5c0fdf2 // indirect
 	github.com/gonum/internal v0.0.0-20181124074243-f884aa714029 // indirect
 	github.com/gonum/lapack v0.0.0-20181123203213-e4cdc5a0bff9 // indirect
 	github.com/gonum/matrix v0.0.0-20181209220409-c518dec07be9 // indirect
-	github.com/gonum/stat v0.0.0-20181125101827-41a0da705a5b // indirect
 	github.com/hashicorp/hcl v1.0.0 // indirect
 	github.com/jinzhu/inflection v1.0.0 // indirect
 	github.com/jinzhu/now v1.1.5 // indirect

+ 2 - 0
go.sum

@@ -191,6 +191,8 @@ github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac h1:Q0Jsdxl5jbxouNs1TQYt
 github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac/go.mod h1:P32wAyui1PQ58Oce/KYkOqQv8cVw1zAapXOl+dRFGbc=
 github.com/gonum/floats v0.0.0-20181209220543-c233463c7e82 h1:EvokxLQsaaQjcWVWSV38221VAK7qc2zhaO17bKys/18=
 github.com/gonum/floats v0.0.0-20181209220543-c233463c7e82/go.mod h1:PxC8OnwL11+aosOB5+iEPoV3picfs8tUpkVd0pDo+Kg=
+github.com/gonum/integrate v0.0.0-20181209220457-a422b5c0fdf2 h1:GUSkTcIe1SlregbHNUKbYDhBsS8lNgYfIp4S4cToUyU=
+github.com/gonum/integrate v0.0.0-20181209220457-a422b5c0fdf2/go.mod h1:pDgmNM6seYpwvPos3q+zxlXMsbve6mOIPucUnUOrI7Y=
 github.com/gonum/internal v0.0.0-20181124074243-f884aa714029 h1:8jtTdc+Nfj9AR+0soOeia9UZSvYBvETVHZrugUowJ7M=
 github.com/gonum/internal v0.0.0-20181124074243-f884aa714029/go.mod h1:Pu4dmpkhSyOzRwuXkOgAvijx4o+4YMUJJo9OvPYMkks=
 github.com/gonum/lapack v0.0.0-20181123203213-e4cdc5a0bff9 h1:7qnwS9+oeSiOIsiUMajT+0R7HR6hw5NegnKPmn/94oI=

+ 1 - 1
models/response/pc/report.go

@@ -77,7 +77,7 @@ FROM
 	report 
 WHERE
 	classify_name_first IN  (?) 
-AND state = 2 
+AND state IN (2, 6) 
 ORDER BY
 	publish_time DESC) t GROUP BY t.classify_name_first`
 	err = global.MYSQL["rddp"].Raw(sql, classifyNames).Scan(&items).Error

+ 24 - 24
models/tables/rddp/report/query.go

@@ -24,7 +24,7 @@ INNER JOIN
     SELECT classify_id_first, max( publish_time ) AS max_publish_time
     FROM report
     WHERE
-	state = 2 
+	state IN (2, 6) 
 	AND classify_name_first !="权益研报"
     AND classify_id_second IN ?
 GROUP BY
@@ -32,7 +32,7 @@ GROUP BY
 ) t2
     ON t1.classify_id_first = t2.classify_id_first AND
        t1.publish_time   = t2.max_publish_time
-	 WHERE t1.state = 2 
+	 WHERE t1.state IN (2, 6) 
 	 AND t1.classify_name_first !="权益研报"
 	 AND t1.classify_id_second IN ?`
 	err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds, classifyIdSeconds).Scan(&reportList).Error
@@ -43,7 +43,7 @@ GROUP BY
 func GetReportsByClassifyIdSecondsAndDate(classifyIdSeconds []int, publishTime string) (reportList []*Report, err error) {
 	err = global.MYSQL["rddp"].Model(Report{}).
 		Select("id, classify_name_first").
-		Where("classify_id_second in (?) and state = 2 and publish_time > ? ", classifyIdSeconds, publishTime).Scan(&reportList).Error
+		Where("classify_id_second in (?) and state IN (2, 6) and publish_time > ? ", classifyIdSeconds, publishTime).Scan(&reportList).Error
 	return
 }
 
@@ -51,7 +51,7 @@ func GetReportsByClassifyIdSecondsAndDate(classifyIdSeconds []int, publishTime s
 func GetListByIDsAndClassifyIdFirst(ids []int, classifyIdFirst int, offset, limit int) (reportList []*Report, err error) {
 	err = global.MYSQL["rddp"].Model(Report{}).
 		Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
-		Where("id in (?) and classify_id_first=? and state = 2 ", ids, classifyIdFirst).
+		Where("id in (?) and classify_id_first=? and state IN (2, 6) ", ids, classifyIdFirst).
 		Order("publish_time desc, id desc").
 		Offset(offset).
 		Limit(limit).
@@ -63,7 +63,7 @@ func GetListByIDsAndClassifyIdFirst(ids []int, classifyIdFirst int, offset, limi
 func GetListCountByIDsAndClassifyIdFirst(ids []int, classifyIdFirst int) (total int64, err error) {
 	err = global.MYSQL["rddp"].Model(Report{}).
 		Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
-		Where("id in (?) and classify_id_first=? and state = 2 ", ids, classifyIdFirst).
+		Where("id in (?) and classify_id_first=? and state IN (2, 6) ", ids, classifyIdFirst).
 		Count(&total).Error
 	return
 }
@@ -72,7 +72,7 @@ func GetListCountByIDsAndClassifyIdFirst(ids []int, classifyIdFirst int) (total
 func GetListByClassifyIdSeconds(classifyIdSeconds []int, offset, limit int) (reportList []*Report, err error) {
 	err = global.MYSQL["rddp"].Model(Report{}).
 		Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
-		Where("classify_id_second in (?) and state = 2 ", classifyIdSeconds).
+		Where("classify_id_second in (?) and state IN (2, 6) ", classifyIdSeconds).
 		Order("publish_time desc, id desc").
 		Offset(offset).
 		Limit(limit).
@@ -84,7 +84,7 @@ func GetListByClassifyIdSeconds(classifyIdSeconds []int, offset, limit int) (rep
 func GetListCountByClassifyIdSeconds(classifyIdSeconds []int) (total int64, err error) {
 	err = global.MYSQL["rddp"].Model(Report{}).
 		Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
-		Where("classify_id_second in (?) and state = 2 ", classifyIdSeconds).
+		Where("classify_id_second in (?) and state IN (2, 6) ", classifyIdSeconds).
 		Count(&total).Error
 	return
 }
@@ -93,7 +93,7 @@ func GetListCountByClassifyIdSeconds(classifyIdSeconds []int) (total int64, err
 func GetListByClassifyIdFirst(classifyIdFirst int, offset, limit int) (reportList []*Report, err error) {
 	err = global.MYSQL["rddp"].Model(Report{}).
 		Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
-		Where("classify_id_first=? and state = 2 ", classifyIdFirst).
+		Where("classify_id_first=? and state IN (2, 6) ", classifyIdFirst).
 		Order("publish_time desc, id desc").
 		Offset(offset).
 		Limit(limit).
@@ -105,14 +105,14 @@ func GetListByClassifyIdFirst(classifyIdFirst int, offset, limit int) (reportLis
 func GetListCountByClassifyIdFirst(classifyIdFirst int) (total int64, err error) {
 	err = global.MYSQL["rddp"].Model(Report{}).
 		Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
-		Where("classify_id_first=? and state = 2 ", classifyIdFirst).
+		Where("classify_id_first=? and state IN (2, 6) ", classifyIdFirst).
 		Count(&total).Error
 	return
 }
 
 // GetLatestByReportIds 根据ids获取报告
 func GetLatestByReportIds(ids []int) (item *Report, err error) {
-	err = global.MYSQL["rddp"].Where("id in ? and state = 2", ids).Order("publish_time desc, id desc").First(&item).Error
+	err = global.MYSQL["rddp"].Where("id in ? and state IN (2, 6)", ids).Order("publish_time desc, id desc").First(&item).Error
 	if err == utils.ErrNoRow {
 		err = nil
 	}
@@ -121,7 +121,7 @@ func GetLatestByReportIds(ids []int) (item *Report, err error) {
 
 // GetPublishByReportId 根据id获取报告
 func GetPublishByReportId(id int) (item *Report, err error) {
-	err = global.MYSQL["rddp"].Where("id = ? and state = 2", id).First(&item).Error
+	err = global.MYSQL["rddp"].Where("id = ? and state IN (2, 6)", id).First(&item).Error
 	if err == utils.ErrNoRow {
 		err = nil
 	}
@@ -140,7 +140,7 @@ func GetByReportId(id int) (item *Report, err error) {
 // GetByReportIds 根据id获取报告
 func GetByReportIds(ids []int) (list []*Report, err error) {
 	err = global.MYSQL["rddp"].Model(Report{}).
-		Where("id in (?) and state = 2", ids).
+		Where("id in (?) and state IN (2, 6)", ids).
 		Select("id, create_time").
 		Scan(&list).Error
 	if err == utils.ErrNoRow {
@@ -174,7 +174,7 @@ INNER JOIN
     SELECT classify_id_first, classify_id_second, max( publish_time ) AS max_publish_time
     FROM report
     WHERE
-	state = 2 
+	state IN (2, 6) 
 	AND classify_id_first = ?
     AND classify_id_second IN ?
 GROUP BY
@@ -183,7 +183,7 @@ GROUP BY
     ON t1.classify_id_second = t2.classify_id_second AND
 		 t1.classify_id_first = t2.classify_id_first AND
        t1.publish_time   = t2.max_publish_time
-	 WHERE t1.state = 2 
+	 WHERE t1.state IN (2, 6) 
 	 AND t1.classify_id_first = ?
 	 AND t1.classify_id_second IN ?`
 	err = global.MYSQL["rddp"].Raw(sql, classifyIdFirst, classifyIdSeconds, classifyIdFirst, classifyIdSeconds).Scan(&reportList).Error
@@ -201,7 +201,7 @@ func GetReportListByCondition(condition string, pars []interface{}) (list []*Rep
 func GetListByClassifyIdSecond(classifyIdSecond int, offset, limit int) (reportList []*Report, err error) {
 	err = global.MYSQL["rddp"].Model(Report{}).
 		Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time, author, video_name, video_url, video_play_seconds, abstract").
-		Where("classify_id_second = ? and state = 2 ", classifyIdSecond).
+		Where("classify_id_second = ? and state IN (2, 6) ", classifyIdSecond).
 		Order("publish_time desc, id desc").
 		Offset(offset).
 		Limit(limit).
@@ -215,7 +215,7 @@ func GetListByClassifyIdSecond(classifyIdSecond int, offset, limit int) (reportL
 // GetListCountByClassifyIdSecond 按照二级分类总条数
 func GetListCountByClassifyIdSecond(classifyIdSecond int) (total int64, err error) {
 	err = global.MYSQL["rddp"].Model(Report{}).
-		Where("classify_id_second=? and state = 2 ", classifyIdSecond).Count(&total).Error
+		Where("classify_id_second=? and state IN (2, 6) ", classifyIdSecond).Count(&total).Error
 	if err == utils.ErrNoRow {
 		err = nil
 	}
@@ -260,7 +260,7 @@ WHERE
 	classify_name_first != "晨报" 
 	AND classify_name_first != "周报" 
 	AND classify_id_second in ?
-	AND state = 2
+	AND state IN (2, 6)
 	)
 UNION
 	
@@ -298,7 +298,7 @@ WHERE
         classify_name_first != "晨报" 
         AND classify_name_first != "周报" 
         AND classify_id_second in ?
-        AND state = 2
+        AND state IN (2, 6)
         )
 UNION
         
@@ -347,7 +347,7 @@ WHERE
 	classify_name_first != "晨报" 
 	AND classify_name_first != "周报" 
 	AND classify_id_second in ?
-	AND state = 2
+	AND state IN (2, 6)
 	ORDER BY publish_time DESC LIMIT 3
 	`
 	err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds).Scan(&list).Error
@@ -376,7 +376,7 @@ WHERE
 	r.classify_name_first = c.classify_name
 	AND c.show_type = 2
 	AND c.is_show = 1
-	AND state = 2
+	AND state IN (2, 6)
 	ORDER BY publish_time DESC LIMIT 1
 	`
 	err = global.MYSQL["rddp"].Raw(sql).First(&list).Error
@@ -398,7 +398,7 @@ FROM
 	report as a
 	JOIN classify as b
 WHERE
-	a.state = 2 
+	a.state IN (2, 6) 
 	AND a.classify_name_first = "%v" 
 	AND a.classify_id_second = %v 
 	AND a.classify_id_second = b.id
@@ -419,7 +419,7 @@ WHERE
 	classify_name_first != "晨报" 
 	AND classify_name_first != "周报" 
 	AND classify_id_second in ?
-	AND state = 2
+	AND state IN (2, 6)
 	ORDER BY publish_time DESC, id desc LIMIT ? OFFSET ?
 	`
 	err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds, limit, offset).Scan(&list).Error
@@ -435,7 +435,7 @@ WHERE
         classify_name_first != "晨报" 
         AND classify_name_first != "周报" 
         AND classify_id_second in ?
-        AND state = 2
+        AND state IN (2, 6)
         
 	`
 	err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds).Count(&total).Error
@@ -445,7 +445,7 @@ WHERE
 // GetListByReportIds 根据IDs获取列表
 func GetListByReportIds(reportIds []int) (list []*Report, err error) {
 	var where string
-	where = `state = 2`
+	where = `state IN (2, 6)`
 	if len(reportIds) > 0 {
 		where += ` AND id IN (?)`
 	}

+ 1 - 1
models/tables/rddp/report_chapter/query.go

@@ -143,7 +143,7 @@ WHERE
 	AND a.report_id <> %v
 	AND a.classify_name_first = "%v"
 	AND a.report_id=b.id
-	AND b.state = 2
+	AND b.state IN (2, 6)
 ORDER BY
 	publish_time DESC) t
 	GROUP BY report_id 

+ 2 - 2
services/report/report.go

@@ -638,7 +638,7 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
 		err = errors.New("该分类不存在")
 		return
 	}
-	condition = `classify_id_first = ? and state = 2`
+	condition = `classify_id_first = ? and state IN (2, 6)`
 	pars = append(pars, classifyIdFirst)
 
 	// 子目录
@@ -1564,7 +1564,7 @@ func GetVarietyReportList(user user.UserInfo, classifyId, chartPermissionId, pag
 //		err = errors.New("该分类不存在")
 //		return
 //	}
-//	condition = `classify_id_first = ? and state = 2`
+//	condition = `classify_id_first = ? and state IN (2, 6)`
 //	pars = append(pars, classifyIdFirst)
 //	permissionMap := make(map[string][]int)
 //	checkPermissionMap := make(map[string]bool)

+ 5 - 8
services/report/report_view_log.go

@@ -8,7 +8,6 @@ import (
 	"time"
 )
 
-
 // GetUnRead 获取未读数
 func GetUnRead(classifyIdSeconds []int, userId uint64) (unReadItem map[string]int, err error) {
 	firstDay := "2022-01-01"
@@ -65,11 +64,11 @@ func BatchInsertReportView(userId uint64, weekReportIds []int, classifyNameFirst
 
 	var condition string
 	// 特殊处理三种分类
-	if classifyNameFirst == "大事点评" || classifyNameFirst == "会议纪要" || classifyNameFirst == "年报合集"  {
-		condition = "state = 2 and publish_time > ? "
+	if classifyNameFirst == "大事点评" || classifyNameFirst == "会议纪要" || classifyNameFirst == "年报合集" {
+		condition = "state IN (2, 6) and publish_time > ? "
 		pars = append(pars, firstDay)
-	}else{
-		condition = "state = 2 and classify_name_first = ? and publish_time > ? "
+	} else {
+		condition = "state IN (2, 6) and classify_name_first = ? and publish_time > ? "
 		pars = append(pars, classifyNameFirst, firstDay)
 	}
 
@@ -110,7 +109,7 @@ func BatchInsertReportView(userId uint64, weekReportIds []int, classifyNameFirst
 		}
 
 		var reportLogs []*report_view_log.ReportViewLog
-		for _, v := range reportMap{
+		for _, v := range reportMap {
 			temp := new(report_view_log.ReportViewLog)
 			temp.ReportId = v
 			temp.UserId = userId
@@ -126,5 +125,3 @@ func BatchInsertReportView(userId uint64, weekReportIds []int, classifyNameFirst
 	}
 	return
 }
-
-