zhangchuanxing 1 долоо хоног өмнө
parent
commit
75c2d9299f

+ 318 - 0
controllers/cygx/report_article.go

@@ -8300,3 +8300,321 @@ func initAct5349() {
 	}
 	fmt.Println("end")
 }
+
+//func init() {
+//	//companyIdArr := []int{7408, 12442, 5618, 7577, 15736}
+//	//
+//	//for _, v := range companyIdArr {
+//	//	initconmap(v)
+//	//}
+//	initconmapMobile()
+//}
+
+func initconmap(companyId int) {
+	item, err := company.GetCompanyDetailById(companyId)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	//创建excel
+	dir, err := os.Executable()
+	exPath := filepath.Dir(dir)
+	downLoadnFilePath := exPath + "/" + item.CompanyName + ".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 pidIndex := 0; pidIndex <= 1; pidIndex++ {
+		var sheetName string
+		if pidIndex == 0 {
+			sheetName = "活动信息"
+			//listDate = list
+		} else {
+			sheetName = "报告信息"
+			//listDate = listClPvPower
+		}
+		sheet, err := xlsxFile.AddSheet(sheetName)
+		if err != nil {
+			fmt.Println(err)
+			return
+		}
+		if pidIndex == 0 {
+			//标头
+			rowTitle := sheet.AddRow()
+
+			cellA := rowTitle.AddCell()
+			cellA.Value = "手机号"
+
+			cellA2 := rowTitle.AddCell()
+			cellA2.Value = "姓名"
+
+			cellA4 := rowTitle.AddCell()
+			cellA4.Value = "公司名"
+
+			cellB := rowTitle.AddCell()
+			cellB.Value = "活动名称"
+
+			cellAt := rowTitle.AddCell()
+			cellAt.Value = "活动时间"
+
+			cellUser := rowTitle.AddCell()
+			cellUser.Value = "入会时间"
+
+			cellCompany := rowTitle.AddCell()
+			cellCompany.Value = "退出时间"
+
+			cellTime := rowTitle.AddCell()
+			cellTime.Value = "参会时长"
+
+			signUpDetailList, err := cygx.GetSignupDetailListinit521(companyId)
+			if err != nil {
+				fmt.Println(err)
+				return
+			}
+			var mobils []string
+
+			for _, v := range signUpDetailList {
+				mobils = append(mobils, v.Mobile)
+			}
+
+			listUserFicc, err := models.GetWxUserRaiSllerListByUserMobileFiic(mobils)
+			if err != nil {
+				fmt.Println(err)
+				return
+			}
+			mapUser := make(map[string]string)
+			for _, v := range listUserFicc {
+				mapUser[v.Mobile] = v.RealName
+			}
+			for _, vs := range signUpDetailList {
+				if vs.CompanyName == "弘则研究" {
+					continue
+				}
+				row := sheet.AddRow()
+
+				cellA1Datatitle := row.AddCell()
+				cellA1Datatitle.Value = vs.Mobile
+
+				cellA2Datatitle := row.AddCell()
+				if vs.RealName == "" {
+					vs.RealName = mapUser[vs.Mobile]
+				}
+				cellA2Datatitle.Value = vs.RealName
+
+				cellA4Datatitle := row.AddCell()
+				cellA4Datatitle.Value = vs.CompanyName
+
+				cellADatatitle := row.AddCell()
+				cellADatatitle.Value = vs.ActivityName
+
+				cellADatatitle2 := row.AddCell()
+				cellADatatitle2.Value = vs.ActivityTime
+
+				cellADataPd := row.AddCell()
+				cellADataPd.Value = vs.FirstMeetingTime
+
+				cellADataPd2 := row.AddCell()
+				cellADataPd2.Value = vs.LastMeetingTime
+
+				cellBData := row.AddCell()
+				cellBData.Value = vs.Duration
+			}
+		} else {
+			//标头
+			rowTitle := sheet.AddRow()
+
+			cellB := rowTitle.AddCell()
+			cellB.Value = "手机号"
+
+			cellActime := rowTitle.AddCell()
+			cellActime.Value = "姓名"
+
+			cellD := rowTitle.AddCell()
+			cellD.Value = "公司名"
+
+			cellE := rowTitle.AddCell()
+			cellE.Value = "阅读时间"
+
+			cellE5 := rowTitle.AddCell()
+			cellE5.Value = "报告标题"
+
+			cellE6 := rowTitle.AddCell()
+			cellE6.Value = "报告发布时间"
+
+			signUpDetailList, err := cygx.GetArticleHistoryListInitsscompany_id(companyId)
+			if err != nil {
+				fmt.Println(err)
+				return
+			}
+			var mobils []string
+
+			for _, v := range signUpDetailList {
+				mobils = append(mobils, v.Mobile)
+			}
+			listUserFicc, err := models.GetWxUserRaiSllerListByUserMobileFiic(mobils)
+			if err != nil {
+				fmt.Println(err)
+				return
+			}
+			mapUser := make(map[string]string)
+			for _, v := range listUserFicc {
+				mapUser[v.Mobile] = v.RealName
+			}
+
+			for _, v2 := range signUpDetailList {
+				row := sheet.AddRow()
+				cellActData1 := row.AddCell()
+				cellActData1.Value = v2.Mobile
+
+				cellActData2 := row.AddCell()
+				if v2.RealName == "" {
+					v2.RealName = mapUser[v2.Mobile]
+				}
+				cellActData2.Value = v2.RealName
+
+				cellActData3 := row.AddCell()
+				cellActData3.Value = v2.CompanyName
+
+				cellActData4 := row.AddCell()
+				cellActData4.Value = v2.CreateTime
+
+				cellActData5 := row.AddCell()
+				cellActData5.Value = v2.Title
+
+				cellActData6 := row.AddCell()
+				cellActData6.Value = v2.PublishDate
+			}
+		}
+
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+}
+
+func initconmapMobile() {
+
+	//创建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
+
+	var sheetName string
+	sheetName = "活动信息"
+	sheet, err := xlsxFile.AddSheet(sheetName)
+
+	//标头
+	rowTitle := sheet.AddRow()
+
+	cellA := rowTitle.AddCell()
+	cellA.Value = "手机号"
+
+	cellA2 := rowTitle.AddCell()
+	cellA2.Value = "姓名"
+
+	cellA4 := rowTitle.AddCell()
+	cellA4.Value = "公司名"
+
+	cellB := rowTitle.AddCell()
+	cellB.Value = "活动名称"
+
+	cellAt := rowTitle.AddCell()
+	cellAt.Value = "活动时间"
+
+	cellUser := rowTitle.AddCell()
+	cellUser.Value = "入会时间"
+
+	cellCompany := rowTitle.AddCell()
+	cellCompany.Value = "退出时间"
+
+	cellTime := rowTitle.AddCell()
+	cellTime.Value = "参会时长"
+
+	signUpDetailList, err := cygx.GetSignupDetailListinit521m()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	var mobils []string
+
+	for _, v := range signUpDetailList {
+		mobils = append(mobils, v.Mobile)
+	}
+
+	listUserFicc, err := models.GetWxUserRaiSllerListByUserMobileFiic(mobils)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	mapUser := make(map[string]string)
+	for _, v := range listUserFicc {
+		mapUser[v.Mobile] = v.RealName
+	}
+	for _, vs := range signUpDetailList {
+		if vs.CompanyName == "弘则研究" {
+			continue
+		}
+		row := sheet.AddRow()
+
+		cellA1Datatitle := row.AddCell()
+		cellA1Datatitle.Value = vs.Mobile
+
+		cellA2Datatitle := row.AddCell()
+		if vs.RealName == "" {
+			vs.RealName = mapUser[vs.Mobile]
+		}
+		cellA2Datatitle.Value = vs.RealName
+
+		cellA4Datatitle := row.AddCell()
+		cellA4Datatitle.Value = vs.CompanyName
+
+		cellADatatitle := row.AddCell()
+		cellADatatitle.Value = vs.ActivityName
+
+		cellADatatitle2 := row.AddCell()
+		cellADatatitle2.Value = vs.ActivityTime
+
+		cellADataPd := row.AddCell()
+		cellADataPd.Value = vs.FirstMeetingTime
+
+		cellADataPd2 := row.AddCell()
+		cellADataPd2.Value = vs.LastMeetingTime
+
+		cellBData := row.AddCell()
+		cellBData.Value = vs.Duration
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+}

+ 67 - 0
models/cygx/activity_signup_detail.go

@@ -243,3 +243,70 @@ func GetCygxActivitySignupDetailDetailLast(articleId int, mobile string) (item *
 	err = o.Raw(sql, articleId, mobile).QueryRow(&item)
 	return
 }
+
+type CygxActivitySignupDetail521 struct {
+	Mobile           string `description:"手机号"`
+	RealName         string `description:"用户实际名称"`
+	CompanyName      string `description:"公司名称"`
+	FirstMeetingTime string `description:"首次入会时间"`
+	LastMeetingTime  string `description:"最后退出时间"`
+	Duration         string `description:"参会时长"`
+	ActivityTime     string `description:"活动时间"`
+	ActivityName     string `description:"活动名称"`
+}
+
+// 获取参会记录表列表
+func GetSignupDetailListinit521(company_id int) (list []*CygxActivitySignupDetail521, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+			s.mobile,
+			s.real_name,
+			s.company_name,
+			s.first_meeting_time,
+			s.last_meeting_time,
+			s.duration,
+			a.activity_name,
+			a.activity_time,
+			a.activity_name 
+		FROM
+			cygx_activity_signup_detail AS s
+			INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id 
+		WHERE
+			1 = 1 
+			AND ( s.is_meeting = 1 OR s.duration != "" ) 
+			AND s.company_id = ? 
+			AND a.activity_time >= '2024-01-01' 
+			AND a.activity_time < '2025-01-01' 
+		ORDER BY
+			a.activity_time ASC `
+	_, err = o.Raw(sql, company_id).QueryRows(&list)
+	return
+}
+
+// 获取参会记录表列表
+func GetSignupDetailListinit521m() (list []*CygxActivitySignupDetail521, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+			s.mobile,
+			s.real_name,
+			s.company_name,
+			s.first_meeting_time,
+			s.last_meeting_time,
+			s.duration,
+			a.activity_name,
+			a.activity_time,
+			a.activity_name 
+		FROM
+			cygx_activity_signup_detail AS s
+			INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id 
+		WHERE
+			1 = 1 
+			AND ( s.is_meeting = 1 OR s.duration != "" ) 
+			AND s.mobile IN  (15669219918,96582719,56955949,90009909988,909808783909,22388888,67644885,55295728,4157460042,22388696,14714925361,90445630,22388817,22388806) 
+			AND a.activity_time >= '2024-01-01' 
+			AND a.activity_time < '2025-01-01' 
+		ORDER BY
+			a.activity_time ASC `
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}

+ 22 - 0
models/cygx/summary_manage.go

@@ -615,6 +615,28 @@ WHERE
 	return
 }
 
+func GetArticleHistoryListInitsscompany_id(company_id int) (items []*ArticleHistoryRep, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+			s.mobile,
+			s.real_name,
+			s.company_name,
+			s.create_time,
+			a.title,
+			a.publish_date 
+		FROM
+			cygx_article_history_record_all AS s
+			INNER JOIN cygx_article AS a ON a.article_id = s.article_id 
+		WHERE
+			1 = 1 
+			AND s.company_id = ?
+			AND s.create_time >= '2024-01-01' 
+			AND s.create_time < '2025-01-01' 
+			AND s.is_del = 0  ORDER BY s.create_time ASC  `
+	_, err = o.Raw(sql, company_id).QueryRows(&items)
+	return
+}
+
 // 列表
 func GetArticleHistoryList121(articleId int, condition string) (items []*ArticleHistoryRep, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")