Browse Source

no message

zhangchuanxing 5 ngày trước cách đây
mục cha
commit
67e2e4a4f6

+ 82 - 1
controllers/cygx/report_article.go

@@ -6669,7 +6669,7 @@ func initCommpanyList() {
 }
 
 //func init() {
-//	initart121_326()
+//	initart121_328()
 //}
 
 // 公司研选剩余点数
@@ -7052,3 +7052,84 @@ func initart121_326() {
 		}
 	}
 }
+
+// 研选专栏阅读内容
+func initart121_328() {
+
+	listComapny, err := company.GetCompanyProductsByCompanyId23423()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	//创建excel
+	dir, err := os.Executable()
+	exPath := filepath.Dir(dir)
+	downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	xlsxFile := xlsx.NewFile()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	style := xlsx.NewStyle()
+	alignment := xlsx.Alignment{
+		Horizontal: "center",
+		Vertical:   "center",
+		WrapText:   true,
+	}
+	style.Alignment = alignment
+	style.ApplyAlignment = true
+
+	redStyle := xlsx.NewStyle()
+	redStyle.Alignment = alignment
+	redStyle.ApplyAlignment = true
+	redStyle.Font.Color = "ff0000"
+	//定义底色需要标黄的 单元格颜色
+	redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
+	redStyle.Fill = redFill
+	//redStyle.Border = *border
+
+	var sheetName string
+	sheetName = "PV"
+	sheet, err := xlsxFile.AddSheet(sheetName)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	//标头
+	rowTitle := sheet.AddRow()
+
+	cellC := rowTitle.AddCell()
+	cellC.Value = "公司名称"
+
+	cellDCreatedTime := rowTitle.AddCell()
+	cellDCreatedTime.Value = "Uv"
+
+	for k, v := range listComapny {
+		fmt.Println("kkkk", k)
+
+		listPv, err := cygx.GetCygxYanxuanSpecialRecordListsss(v.CompanyId)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+
+		row := sheet.AddRow()
+
+		cellADatatitle := row.AddCell()
+		cellADatatitle.Value = v.CompanyName
+
+		cellADataPd := row.AddCell()
+		cellADataPd.Value = strconv.Itoa(len(listPv))
+
+		cellADataPdId := row.AddCell()
+		cellADataPdId.Value = strconv.Itoa(v.CompanyId)
+
+	}
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	return
+}

+ 16 - 0
models/company/company_product.go

@@ -117,6 +117,22 @@ func GetCompanyProductsByCompanyId(companyId int) (items []*CompanyProductDetail
 	return
 }
 
+func GetCompanyProductsByCompanyId23423() (items []*CompanyProductDetail, err error) {
+	sql := `SELECT
+	c.* 
+FROM
+	company_report_permission AS a
+	INNER JOIN company_product AS b ON b.company_id = a.company_id
+	INNER JOIN company AS c ON c.company_id = a.company_id 
+WHERE
+	a.chart_permission_id = 31 
+	AND a.status = '正式' 
+	AND b.product_id = 2 `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 func GetCompanyProductById(companyProductId int) (item *CompanyProduct, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM company_product WHERE company_product_id=? `

+ 16 - 0
models/cygx/cygx_yanxuan_special_collect.go

@@ -61,3 +61,19 @@ func GetCygxYanxuanSpecialRecordList(condition string, pars []interface{}) (item
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// 列表
+func GetCygxYanxuanSpecialRecordListsss(company_id int) (items []*CygxYanxuanSpecialRecordResp, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+	cygx_yanxuan_special_record_id
+FROM
+	cygx_yanxuan_special_record 
+WHERE
+	company_id  = ?
+	AND yanxuan_special_id IN ( SELECT id FROM cygx_yanxuan_special WHERE user_id = 959 )
+	GROUP BY user_id ,yanxuan_special_id ;`
+
+	_, err = o.Raw(sql, company_id).QueryRows(&items)
+	return
+}