zhangchuanxing 4 miesięcy temu
rodzic
commit
beb7a6f2a1

+ 88 - 1
controllers/cygx/report_article.go

@@ -4067,7 +4067,7 @@ func initAct22() {
 }
 
 //func init() {
-//	initLuyan()
+//	initQuanyi()
 //}
 
 func initLuyan() {
@@ -4234,3 +4234,90 @@ func initLuyan() {
 	}
 
 }
+
+func initQuanyi() {
+
+	var condition string
+	var pars []interface{}
+	condition = ` AND product_id = 2 AND industry_id > 0  GROUP BY industry_id `
+	productList, err := company.GetCompanyProductList(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	condition = ` AND  product_id = 2 AND industry_id > 0  `
+	productListData, err := company.GetCompanyProductList(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	//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
+
+	for _, v := range productList {
+		var sheetName string
+
+		sheetName = v.IndustryName
+		sheet, err := xlsxFile.AddSheet(sheetName)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+		//标头
+		rowTitle := sheet.AddRow()
+		cellA := rowTitle.AddCell()
+		cellA.Value = "客户名称"
+		cellB := rowTitle.AddCell()
+		cellB.Value = "行业"
+		cellC := rowTitle.AddCell()
+		cellC.Value = "状态"
+		cellCSeller := rowTitle.AddCell()
+		cellCSeller.Value = "销售"
+
+		for _, vE := range productListData {
+			if vE.IndustryId != v.IndustryId {
+				continue
+			}
+			row := sheet.AddRow()
+			cellAData := row.AddCell()
+			cellAData.Value = vE.CompanyName
+
+			cellBData := row.AddCell()
+			cellBData.Value = vE.IndustryName
+
+			cellCData := row.AddCell()
+			cellCData.Value = vE.Status
+
+			cellDData := row.AddCell()
+			cellDData.Value = vE.SellerName
+		}
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+
+}

+ 18 - 0
models/company/company_product.go

@@ -602,6 +602,24 @@ func GetCompanyProductList(condition string, pars []interface{}) (items []*Compa
 	return
 }
 
+// 获取列表
+func GetCompanyProductListInit(industry_id int) (items []*CompanyProduct, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT
+			c.company_name,
+			p.industry_name,
+			p.status,
+			p.seller_name 
+		FROM
+			company_product AS p
+			INNER JOIN company AS c ON c.company_id = p.company_id 
+		WHERE
+			p.product_id = 2 
+			AND p.industry_id = ? `
+	_, err = o.Raw(sql, industry_id).QueryRows(&items)
+	return
+}
+
 // 获取列表
 func GetCompanyProductListBycondition(condition string, pars []interface{}) (items []*CompanyProduct, err error) {
 	o := orm.NewOrm()