|
@@ -6662,3 +6662,132 @@ func initCommpanyList() {
|
|
|
}
|
|
|
fmt.Println("end")
|
|
|
}
|
|
|
+
|
|
|
+//func init() {
|
|
|
+// initCommpanyNum()
|
|
|
+//}
|
|
|
+
|
|
|
+// 公司研选剩余点数
|
|
|
+func initCommpanyNum() {
|
|
|
+ //行业
|
|
|
+
|
|
|
+ listContract, e := company.CompanyContractListNum()
|
|
|
+ if e != nil {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var companyIds []int
|
|
|
+
|
|
|
+ for _, v := range listContract {
|
|
|
+ companyIds = append(companyIds, v.CompanyId)
|
|
|
+ }
|
|
|
+
|
|
|
+ mapNum := make(map[int]int)
|
|
|
+ mapYearNum := make(map[string]bool)
|
|
|
+
|
|
|
+ for _, v := range listContract {
|
|
|
+ year := v.StartDate[:4]
|
|
|
+ keyMap := fmt.Sprint("CID", v.CompanyId, "Year", year)
|
|
|
+ if mapYearNum[keyMap] {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapNum[v.CompanyId]++
|
|
|
+ mapYearNum[keyMap] = true
|
|
|
+ }
|
|
|
+
|
|
|
+ listCompanyProduct, err := company.GetCompanyProductsByCompanyIdsAndProductIdinit(companyIds)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ listCompany, err := company.GetOverseasCompanysByCompanyIds(companyIds)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ mapCompamyName := make(map[int]string)
|
|
|
+ mapInteractionNum := make(map[int]int)
|
|
|
+
|
|
|
+ for _, v := range listCompany {
|
|
|
+ mapCompamyName[v.CompanyId] = v.CompanyName
|
|
|
+ mapInteractionNum[v.CompanyId] = v.InteractionNum
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建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 = "正式、试用客户明细"
|
|
|
+ sheet, err := xlsxFile.AddSheet(sheetName)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //标头
|
|
|
+ rowTitle := sheet.AddRow()
|
|
|
+
|
|
|
+ cellB := rowTitle.AddCell()
|
|
|
+ cellB.Value = "客户名称"
|
|
|
+
|
|
|
+ cellPd := rowTitle.AddCell()
|
|
|
+ cellPd.Value = "次数 "
|
|
|
+
|
|
|
+ cellAt := rowTitle.AddCell()
|
|
|
+ cellAt.Value = "所属销售"
|
|
|
+
|
|
|
+ cellPerssion := rowTitle.AddCell()
|
|
|
+ cellPerssion.Value = "状态"
|
|
|
+
|
|
|
+ for _, v := range listCompanyProduct {
|
|
|
+ if mapNum[v.CompanyId] < 3 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ row := sheet.AddRow()
|
|
|
+ cellADatatitle := row.AddCell()
|
|
|
+ cellADatatitle.Value = mapCompamyName[v.CompanyId]
|
|
|
+
|
|
|
+ cellADataPd := row.AddCell()
|
|
|
+ cellADataPd.Value = fmt.Sprint(mapNum[v.CompanyId])
|
|
|
+
|
|
|
+ cellCompanyData := row.AddCell()
|
|
|
+ cellCompanyData.Value = fmt.Sprint(v.StartDate, " / ", v.EndDate)
|
|
|
+
|
|
|
+ cellBData := row.AddCell()
|
|
|
+ cellBData.Value = v.Status
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ err = xlsxFile.Save(downLoadnFilePath)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println("end")
|
|
|
+}
|