ソースを参照

Merge branch 'master' of http://8.136.199.33:3000/eta_server/eta_api

hongze 4 ヶ月 前
コミット
6b827d5b87

+ 6 - 1
controllers/document_manage/document_manage_controller.go

@@ -193,6 +193,11 @@ func (this *DocumentManageController) RuiSiReportList() {
 	classifyIdFirst, _ := this.GetInt("ClassifyIdFirst", 0)
 	classifyIdSecond, _ := this.GetInt("ClassifyIdSecond", 0)
 	classifyIdThird, _ := this.GetInt("ClassifyIdThird", 0)
+	chartPermissionIdString := this.GetString("ChartPermissionIdList")
+	var chartPermissionIdList []string
+	if strings.TrimSpace(chartPermissionIdString) != "" {
+		chartPermissionIdList = strings.Split(chartPermissionIdString, ",")
+	}
 
 	keyword := this.GetString("Keyword")
 	orderField := this.GetString("OrderField")
@@ -206,7 +211,7 @@ func (this *DocumentManageController) RuiSiReportList() {
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
-	RuiSiReportPage, err := document_manage_service.RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird, keyword, orderField, orderType, currentIndex, pageSize)
+	RuiSiReportPage, err := document_manage_service.RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird, chartPermissionIdList, keyword, orderField, orderType, currentIndex, pageSize)
 	if err != nil {
 		br.Msg = "获取报告列表失败"
 		br.ErrMsg = "获取报告列表失败,Err:" + err.Error()

+ 2 - 0
models/business_conf.go

@@ -50,6 +50,8 @@ const (
 	BusinessConfSmsJhgjVariable              = "SmsJhgjVariable"              // 聚合国际短信变量
 
 	BusinessConfEdbStopRefreshRule = "EdbStopRefreshRule" // 是否停止指标刷新规则
+	BusinessConfReport2ImgUrl      = "Report2ImgUrl"      // 报告转长图地址(用于兼容内外网环境的)
+	BusinessConfReportViewUrl      = "ReportViewUrl"      // 报告详情地址
 )
 
 const (

+ 4 - 1
models/document_manage_model/outside_report.go

@@ -65,7 +65,10 @@ 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.* 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 distinct 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 `
 	sql += condition
 	sql += ` limit ?, ?`
 	_, err = o.Raw(sql, pars, (currentIndex-1)*pageSize, pageSize).QueryRows(&list)

+ 6 - 2
models/report.go

@@ -166,7 +166,8 @@ 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 WHERE 1=1 `
+	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 `
 	if condition != "" {
 		sql += condition
 	}
@@ -201,7 +202,10 @@ func GetReportListV1(condition string, pars []interface{}, startSize, pageSize i
 func GetReportListByCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportList, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 
-	sql := `SELECT * FROM report as a WHERE 1=1  `
+	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  `
 	if condition != "" {
 		sql += condition
 	}

+ 68 - 0
models/user_collect_classify.go

@@ -0,0 +1,68 @@
+// @Author gmy 2024/9/21 14:47:00
+package models
+
+import "github.com/beego/beego/v2/client/orm"
+
+/**
+CREATE TABLE `user_collect_classify` (
+  `user_collect_classify_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `classify_id` int(9) unsigned NOT NULL DEFAULT '0' COMMENT '分类id',
+  `sys_user_id` int(9) unsigned DEFAULT '0' COMMENT '收藏人用户id',
+  `create_time` datetime DEFAULT NULL COMMENT '收藏时间',
+  PRIMARY KEY (`user_collect_classify_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户收藏的分类id';
+*/
+
+type UserCollectClassify struct {
+	UserCollectClassifyId int    `orm:"column(user_collect_classify_id);pk" description:"用户收藏的分类id"`
+	ClassifyId            int    `orm:"column(classify_id)" description:"分类id"`
+	SysUserId             int    `orm:"column(sys_user_id)" description:"收藏人用户id"`
+	CreateTime            string `orm:"column(create_time)" description:"收藏时间"`
+}
+
+// GetUserCollectClassifyList 查询用户收藏的分类列表
+func GetUserCollectClassifyList(sysUserId, classifyId int) (list []*UserCollectClassify, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `SELECT * FROM user_collect_classify WHERE 1=1`
+	var params []interface{}
+
+	// 处理 sysUserId 参数
+	if sysUserId > 0 {
+		sql += ` AND sys_user_id=?`
+		params = append(params, sysUserId)
+	}
+
+	// 处理 classifyId 参数
+	if classifyId > 0 {
+		sql += ` AND classify_id=?`
+		params = append(params, classifyId)
+	}
+
+	_, err = o.Raw(sql, params...).QueryRows(&list)
+
+	return
+}
+
+// InsertUserCollectClassify 新增用户收藏的分类
+func InsertUserCollectClassify(item UserCollectClassify) (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `INSERT INTO user_collect_classify(classify_id, sys_user_id, create_time) VALUES(?, ?, ?)`
+	_, err = o.Raw(sql, item.ClassifyId, item.SysUserId, item.CreateTime).Exec()
+	return
+}
+
+// DeleteUserCollectClassify 删除分类
+func DeleteUserCollectClassify(sysUserId, classifyId int) (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `DELETE FROM user_collect_classify WHERE sys_user_id=? AND classify_id=?`
+	_, err = o.Raw(sql, sysUserId, classifyId).Exec()
+	return
+}
+
+// DeleteUserCollectClassify 删除分类
+func DeleteCollectByClassifyId(classifyId int) (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `DELETE FROM user_collect_classify WHERE classify_id=?`
+	_, err = o.Raw(sql, classifyId).Exec()
+	return
+}

+ 11 - 6
services/classify.go

@@ -250,6 +250,13 @@ func AddReportClassify(classifyName string, parentId int, chartPermissionIdList
 			return
 		}
 
+		// 清除父级分类的收藏 战研2.1
+		err = models.DeleteCollectByClassifyId(parentId)
+		if err != nil {
+			errMsg = "清除父级分类的收藏失败"
+			return
+		}
+
 	}
 
 	nowTime := time.Now().Local()
@@ -283,7 +290,7 @@ func AddReportClassify(classifyName string, parentId int, chartPermissionIdList
 		return err, "查询分类下所有的分类记录数失败", false
 	}
 
-	if count <= 0 {
+	if count == 1 {
 		// 如果父级分类下 无其他子分类 并且有报告,修改报告到子级分类下
 		reports, err := models.GetReportListByClassifyId(parentId)
 		if err != nil {
@@ -291,13 +298,11 @@ func AddReportClassify(classifyName string, parentId int, chartPermissionIdList
 		}
 		if len(reports) > 0 {
 			for _, report := range reports {
-				if report.ClassifyIdFirst == 0 {
-					report.ClassifyIdFirst = classify.Id
-					report.ClassifyNameFirst = classifyName
-				} else if report.ClassifyIdSecond == 0 {
+				// 一级分类不用判断,有报告一定有分类,二级分类如果等于0,就不用判断三级了
+				if report.ClassifyIdSecond == 0 {
 					report.ClassifyIdSecond = classify.Id
 					report.ClassifyNameSecond = classifyName
-				} else {
+				} else if report.ClassifyIdThird == 0 {
 					report.ClassifyIdThird = classify.Id
 					report.ClassifyNameThird = classifyName
 				}

+ 10 - 4
services/document_manage_service/document_manage_service.go

@@ -213,7 +213,7 @@ func GetAllClassifyIdsByParentId(parentId int) ([]string, error) {
 	return classifyIdList, nil
 }
 
-func RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird int, keyword string, orderField, orderType string, startSize, pageSize int) (*models.ReportListResp, error) {
+func RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird int, chartPermissionIdList []string, keyword string, orderField, orderType string, startSize, pageSize int) (*models.ReportListResp, error) {
 	logs.Info("RuiSiReportList")
 
 	var condition string
@@ -231,6 +231,12 @@ func RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird int, key
 		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+"%")
@@ -371,9 +377,9 @@ func DocumentUpdate(outsideReport *document_manage_model.OutsideReportBO) error
 	if outsideReport.Title != "" {
 		report.Title = outsideReport.Title
 	}
-	if outsideReport.Abstract != "" {
-		report.Abstract = outsideReport.Abstract
-	}
+
+	report.Abstract = outsideReport.Abstract
+
 	if outsideReport.ClassifyId > 0 {
 		report.ClassifyId = outsideReport.ClassifyId
 	}

+ 14 - 5
services/report_v2.go

@@ -1455,18 +1455,27 @@ func GetGeneralPdfUrl(reportCode, classifyFirstName string, reportLayout int8) (
 		return
 	}
 
-	conf, e := models.GetBusinessConfByKey("ReportViewUrl")
-	if e != nil {
-		return
+	// 优先取Report2ImgUrl(用于兼容内外网环境的), 没有的话取报告详情地址
+	var reportUrl string
+	conf, _ := models.GetBusinessConfByKey(models.BusinessConfReport2ImgUrl)
+	if conf != nil && conf.ConfVal != "" {
+		reportUrl = conf.ConfVal
+	}
+	if reportUrl == "" {
+		conf, e := models.GetBusinessConfByKey(models.BusinessConfReportViewUrl)
+		if e != nil {
+			return
+		}
+		reportUrl = conf.ConfVal
 	}
 
 	switch reportLayout {
 	case 1:
 		// 普通布局
-		pdfUrl = fmt.Sprintf("%s/reportshare_pdf?code=%s", conf.ConfVal, reportCode)
+		pdfUrl = fmt.Sprintf("%s/reportshare_pdf?code=%s", reportUrl, reportCode)
 	case 2:
 		// 智能布局
-		pdfUrl = fmt.Sprintf("%s/reportshare_smart_pdf?code=%s", conf.ConfVal, reportCode)
+		pdfUrl = fmt.Sprintf("%s/reportshare_smart_pdf?code=%s", reportUrl, reportCode)
 	}
 
 	return