10 Commits 1c453e6598 ... cadd3e28f2

Author SHA1 Message Date
  xiziwen cadd3e28f2 Merge branch 'bugfix_6452' 3 days ago
  xiziwen 7eeba9f84a Merge branch 'out_report_2.1' 3 days ago
  xiziwen 2dce8c235a first 1 week ago
  xiziwen a3c55ce203 fix 1 week ago
  xiziwen ebee7f2f53 fix 1 week ago
  xiziwen ea6f0ac6b6 品种筛选sql修改 1 week ago
  xiziwen 42a0406c7d 编辑时不更新收件日期 2 weeks ago
  xiziwen 1d1a69d233 fix. count 2 weeks ago
  xiziwen ed2f694b7c fix count 2 weeks ago
  xiziwen de0ad46b62 fix 2 weeks ago

+ 18 - 2
models/data_manage/chart_classify.go

@@ -481,7 +481,15 @@ func GetChartClassifyAndInfoByParentId(parentId int) (items []*ChartClassifyItem
 	sys_user_real_name,
 	sort,
 	level,
-	unique_code
+	unique_code,
+	source,
+	0 as date_type,
+	'' as start_date,
+	'' as end_date,
+	0 as chart_type,
+	'' as calendar,
+	'' as season_start_date,
+	'' as season_end_date
 FROM
 	chart_classify 
 WHERE
@@ -498,7 +506,15 @@ SELECT
 	sys_user_real_name,
 	sort,
 	0 AS level,
-	unique_code
+	unique_code,
+	source,
+	date_type,
+	start_date,
+	end_date,
+	chart_type,
+	calendar,
+	season_start_date,
+	season_end_date
 FROM
 	chart_info 
 WHERE

+ 2 - 2
models/document_manage_model/outside_report.go

@@ -52,7 +52,7 @@ func init() {
 // GetOutsideReportListByConditionCount 根据条件查询列表条数
 func GetOutsideReportListByConditionCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := `select count(distinct t1.outside_report_id) from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id  where 1 = 1 `
+	sql := `select count(DISTINCT t1.outside_report_id) from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id  where 1 = 1 `
 	sql += condition
 	err = o.Raw(sql, pars).QueryRow(&count)
 	if err != nil {
@@ -65,7 +65,7 @@ func GetOutsideReportListByConditionCount(condition string, pars []interface{})
 // GetOutsideReportListByCondition 根据条件查询列表
 func GetOutsideReportListByCondition(condition string, pars []interface{}, currentIndex int, pageSize int) (list []OutsideReport, err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := `select distinct t1.outside_report_id, t1.source, t1.title, t1.abstract, t1.classify_id, 
+	sql := `select t1.outside_report_id, t1.source, t1.title, t1.abstract, t1.classify_id, 
 t1.classify_name, t1.sys_user_id, t1.sys_user_name, t1.email_message_uid, t1.report_update_time, 
 t1.modify_time, t1.create_time, t1.report_code from outside_report t1 
 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id  where 1 = 1 `

+ 11 - 1
models/permission.go

@@ -1,6 +1,9 @@
 package models
 
-import "github.com/beego/beego/v2/client/orm"
+import (
+	"eta/eta_api/utils"
+	"github.com/beego/beego/v2/client/orm"
+)
 
 // ChartPermissionSearchKeyWordMapping 权限相关
 type ChartPermissionSearchKeyWordMapping struct {
@@ -124,3 +127,10 @@ func GetPermissionByClassifyId(classifyId int) (items []*ChartPermissionSearchKe
 	_, err = o.Raw(sql, classifyId).QueryRows(&items)
 	return
 }
+
+func GetClassifyIdsByPermissionId(chartPermissionIdList []string) (classifyIds []string, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := "SELECT classify_id FROM chart_permission_search_key_word_mapping WHERE `from` =  'rddp' and chart_permission_id IN (" + utils.GetOrmInReplace(len(chartPermissionIdList)) + ") and classify_id <> 0; "
+	_, err = o.Raw(sql, chartPermissionIdList).QueryRows(&classifyIds)
+	return
+}

+ 2 - 4
models/report.go

@@ -166,8 +166,7 @@ type ReportListResp struct {
 // @return err error
 func GetReportListCountV1(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT COUNT(1) AS count  FROM report as a left join chart_permission_search_key_word_mapping b on
-a.classify_id_first = b.classify_id WHERE 1=1 `
+	sql := `SELECT COUNT(DISTINCT a.id) AS count  FROM report as a WHERE 1=1 `
 	if condition != "" {
 		sql += condition
 	}
@@ -204,8 +203,7 @@ func GetReportListByCondition(condition string, pars []interface{}, startSize, p
 
 	sql := `SELECT a.id, a.title, a.author, a.modify_time, a.publish_time,a.classify_id_first,
 a.classify_name_first,a.classify_id_second,a.classify_name_second,a.classify_id_third,
-a.classify_name_third FROM report as a left join chart_permission_search_key_word_mapping b on
-a.classify_id_first = b.classify_id WHERE 1=1  `
+a.classify_name_third FROM report as a WHERE 1=1  `
 	if condition != "" {
 		sql += condition
 	}

+ 27 - 11
services/document_manage_service/document_manage_service.go

@@ -174,9 +174,9 @@ func DocumentReportList(documentType int, chartPermissionIdList []string, classi
 	}
 
 	if orderField != "" && orderType != "" {
-		condition += ` order by t1.` + orderField + ` ` + orderType
+		condition += ` group by t1.outside_report_id order by t1.` + orderField + ` ` + orderType
 	} else {
-		condition += ` order by t1.modify_time desc`
+		condition += ` group by t1.outside_report_id order by t1.report_update_time desc`
 	}
 
 	outsideReportList, err := document_manage_model.GetOutsideReportListByCondition(condition, pars, startSize, pageSize)
@@ -231,12 +231,6 @@ func RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird int, cha
 		condition += ` AND a.classify_id_third = ? `
 		pars = append(pars, classifyIdThird)
 	}
-	if len(chartPermissionIdList) > 0 {
-		condition += ` and b.chart_permission_id in (` + utils.GetOrmInReplace(len(chartPermissionIdList)) + `)`
-		for _, chartPermissionId := range chartPermissionIdList {
-			pars = append(pars, chartPermissionId)
-		}
-	}
 	if keyword != "" {
 		condition += ` and ( a.title like ? or a.admin_real_name like ? ) `
 		pars = append(pars, "%"+keyword+"%", "%"+keyword+"%")
@@ -247,6 +241,28 @@ func RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird int, cha
 	// 已发布的报告
 	condition += ` and a.state = 2`
 
+	if len(chartPermissionIdList) > 0 {
+		classifyIds, err := models.GetClassifyIdsByPermissionId(chartPermissionIdList)
+		if err != nil {
+			return nil, err
+		}
+
+		if len(classifyIds) > 0 {
+			condition += ` AND ( (a.classify_id_first IN (` + utils.GetOrmInReplace(len(classifyIds)) + `) AND a.classify_id_second = 0) 
+			OR (a.classify_id_second IN (` + utils.GetOrmInReplace(len(classifyIds)) + `) AND a.classify_id_third = 0) 
+			OR a.classify_id_third IN (` + utils.GetOrmInReplace(len(classifyIds)) + `) )`
+			for _, classifyId := range classifyIds {
+				pars = append(pars, classifyId)
+			}
+			for _, classifyId := range classifyIds {
+				pars = append(pars, classifyId)
+			}
+			for _, classifyId := range classifyIds {
+				pars = append(pars, classifyId)
+			}
+		}
+	}
+
 	count, err := models.GetReportListCountV1(condition, pars)
 	if err != nil {
 		return nil, err
@@ -260,9 +276,9 @@ func RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird int, cha
 	}
 
 	if orderField != "" && orderType != "" {
-		condition += ` order by a.` + orderField + ` ` + orderType
+		condition += ` group by a.id order by a.` + orderField + ` ` + orderType
 	} else {
-		condition += ` order by a.publish_time desc`
+		condition += ` group by a.id order by a.publish_time desc`
 	}
 
 	reportList, err := models.GetReportListByCondition(condition, pars, startSize, pageSize)
@@ -390,7 +406,7 @@ func DocumentUpdate(outsideReport *document_manage_model.OutsideReportBO) error
 		report.Content = outsideReport.Content
 	}
 	report.ModifyTime = utils.GetCurrentTime()
-	report.ReportUpdateTime = utils.GetCurrentTime()
+	//report.ReportUpdateTime = utils.GetCurrentTime()
 	err = document_manage_model.UpdateOutsideReport(report)
 	if err != nil {
 		return fmt.Errorf("更新报告失败, Err: %s", err.Error())