浏览代码

Merge remote-tracking branch 'origin/debug' into debug

ziwen 2 年之前
父节点
当前提交
96ad9a8fea
共有 4 个文件被更改,包括 45 次插入29 次删除
  1. 22 7
      controllers/report.go
  2. 1 0
      models/article.go
  3. 19 19
      models/report_mapping.go
  4. 3 3
      services/send_company_user.go

+ 22 - 7
controllers/report.go

@@ -53,16 +53,32 @@ func (this *ReportController) TradeList() {
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
+	var condition string
+	var pars []interface{}
 	for k, v := range list {
-		list[k].UpdateTime = utils.TimeRemoveHms(v.UpdateTime)
-		count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
-		if err != nil {
+		if v.PolymerizationId != "" {
+			condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
+		} else {
+			condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
+		}
+		listArticle, err := models.GetHomeList(condition, pars, 0, 1)
+		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
+			br.Msg = "GetHomeList,Err:" + err.Error()
 			return
 		}
-		if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
-			list[k].IsRed = true
+		if len(listArticle) > 0 {
+			list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
+
+			count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
+				return
+			}
+			if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
+				list[k].IsRed = true
+			}
 		}
 	}
 	resp := new(models.TradeReportMappingResp)
@@ -451,7 +467,6 @@ func (this *ReportController) List() {
 			imgUrlChartPermission = vslice[len(vslice)-1]
 			mapChartPermission[permissionName] = imgUrlChartPermission
 		}
-
 		total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
 		if err != nil {
 			br.Msg = "获取信息失败"

+ 1 - 0
models/article.go

@@ -110,6 +110,7 @@ type HomeArticle struct {
 	ArticleTypeName     string               `description:"权限名称"`
 	IsReport            int                  `description:"是否属于报告,1是,0否"`
 	ArticleResponse     int                  `description:"报告类型 0:啥也不是,1研选报告,2:研选纪要,3:研选沙龙,4;研选观点"`
+	Readnum             int                  `description:"阅读数量"`
 	List                []*IndustrialManagementIdInt
 }
 

+ 19 - 19
models/report_mapping.go

@@ -13,6 +13,7 @@ type ReportMapping struct {
 	ChartPermissionId   int    `description:"行业ID"`
 	IsRed               bool   `description:"是否标红"`
 	PermissionType      int    `description:"1主观,2客观"`
+	PolymerizationId    string `description:"分类聚合ID"`
 }
 
 type ReportMappingHome struct {
@@ -23,12 +24,14 @@ type ReportMappingHome struct {
 }
 
 type TradeReportMapping struct {
-	CategoryId      int    `description:"分类ID"`
-	SubCategoryName string `description:"主题名称"`
-	MatchTypeName   string `description:"匹配类型"`
-	IsRed           bool   `description:"是否标红"`
-	UpdateTime      string `description:"更新时间"`
-	Readnum         int    `description:"阅读数量"`
+	CategoryId       int    `description:"分类ID"`
+	CategoryIdSet    int    `description:"分类映射id"`
+	PolymerizationId string `description:"分类聚合ID"`
+	SubCategoryName  string `description:"主题名称"`
+	MatchTypeName    string `description:"匹配类型"`
+	IsRed            bool   `description:"是否标红"`
+	UpdateTime       string `description:"更新时间"`
+	Readnum          int    `description:"阅读数量"`
 }
 
 type ReportMappingResp struct {
@@ -74,22 +77,19 @@ ORDER BY
 func GetTradeAll(ChartPermissionId int) (items []*TradeReportMapping, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
-		MAX( art.publish_date ) AS update_time,
-		re.category_id,
-		re.sub_category_name,
-		re.match_type_name 
+			re.category_id,
+			re.category_id_set,
+			re.polymerization_id,
+			re.sub_category_name,
+			re.match_type_name 
 		FROM
-		cygx_report_mapping AS re
-		INNER JOIN cygx_article AS art ON re.category_id = art.category_id 
+			cygx_report_mapping AS re 
 		WHERE
-		re.chart_permission_id =? 
-		AND re.report_type = 1 
-		AND art.is_class = 1 
-		AND re.category_id NOT IN (67)
-		GROUP BY
-		art.category_id 
+			re.chart_permission_id = ? 
+			AND re.report_type = 1 
+			AND re.category_id NOT IN ( 67 ) 
 		ORDER BY
-		update_time DESC`
+			re.sort DESC `
 	_, err = o.Raw(sql, ChartPermissionId).QueryRows(&items)
 	return
 }

+ 3 - 3
services/send_company_user.go

@@ -169,7 +169,7 @@ func DotongbuShangHai(cont context.Context) (err error) {
 	}
 
 	//偶尔需要单独同步某一个公司的人员
-	//condition = ` AND c.company_id  =  6599  `
+	//condition = ` AND c.company_id  =  13902  `
 
 	//同30小时有变更的公司
 	DotongbuShangHaApi(condition)
@@ -321,8 +321,8 @@ func DotongbuShangHaApi(condition string) (err error) {
 		for k, _ := range companyFiccList {
 			companyFiccList[k].Fe = "FICC"
 			companyFiccList[k].EndDate = strconv.Itoa(int(companyFiccList[k].EndDateTime.Unix()))
-			if len(mappermissionData[companyList[k].Cid]) > 0 {
-				companyList[k].PermissionData = mappermissionData[companyList[k].Cid]
+			if len(mappermissionDataFicc[companyFiccList[k].Cid]) > 0 {
+				companyFiccList[k].PermissionData = mappermissionDataFicc[companyFiccList[k].Cid]
 			}
 			//一次同步一百条
 			companyFiccItems = append(companyFiccItems, companyFiccList[k])