正在显示
3 个修改的文件
包含
19 行增加
和
8 行删除
@@ -412,7 +412,13 @@ func (c *AuditController) ChanceDataExcel() { | @@ -412,7 +412,13 @@ func (c *AuditController) ChanceDataExcel() { | ||
412 | sourceData, excelHead := serveaudit.GetAuditListForExcel(param, companyId, uid) | 412 | sourceData, excelHead := serveaudit.GetAuditListForExcel(param, companyId, uid) |
413 | xlsMaker := exceltool.NewExcelMaker() | 413 | xlsMaker := exceltool.NewExcelMaker() |
414 | xlsMaker.SetListHead(excelHead) | 414 | xlsMaker.SetListHead(excelHead) |
415 | - xlsMaker.MakeListExcelForBeego(sourceData) | 415 | + err = xlsMaker.MakeListExcelForBeego(sourceData) |
416 | + if err != nil { | ||
417 | + log.Error("合成excel失败,err:%s", err) | ||
418 | + msg = protocol.BadRequestParam("1") | ||
419 | + c.ResposeJson(msg) | ||
420 | + return | ||
421 | + } | ||
416 | c.ResponseExcelByFile(c.Ctx, xlsMaker) | 422 | c.ResponseExcelByFile(c.Ctx, xlsMaker) |
417 | return | 423 | return |
418 | } | 424 | } |
@@ -107,7 +107,7 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user | @@ -107,7 +107,7 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user | ||
107 | publishStatusS := fmt.Sprint(soureData[i]["publish_status"]) | 107 | publishStatusS := fmt.Sprint(soureData[i]["publish_status"]) |
108 | publishStatus, _ := strconv.Atoi(publishStatusS) | 108 | publishStatus, _ := strconv.Atoi(publishStatusS) |
109 | soureData[i]["publish_status"] = models.ChancePublishStatusMap[publishStatus] | 109 | soureData[i]["publish_status"] = models.ChancePublishStatusMap[publishStatus] |
110 | - soureContentJson := fmt.Sprint(soureData[i]["soure_content"]) | 110 | + soureContentJson := fmt.Sprint(soureData[i]["source_content"]) |
111 | var ( | 111 | var ( |
112 | soureContentData []protocol.InputElement | 112 | soureContentData []protocol.InputElement |
113 | soureContentText strings.Builder | 113 | soureContentText strings.Builder |
@@ -118,7 +118,7 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user | @@ -118,7 +118,7 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user | ||
118 | soureContentText.WriteString(soureContentData[ii].Label + ":" + soureContentData[ii].CurrentValue + ",") | 118 | soureContentText.WriteString(soureContentData[ii].Label + ":" + soureContentData[ii].CurrentValue + ",") |
119 | } | 119 | } |
120 | } | 120 | } |
121 | - soureData[i]["soure_content"] = soureContentText.String() | 121 | + soureData[i]["source_content"] = soureContentText.String() |
122 | signString := signature.SignaString(fmt.Sprint(soureData[i]["id"])) | 122 | signString := signature.SignaString(fmt.Sprint(soureData[i]["id"])) |
123 | var frontHost string | 123 | var frontHost string |
124 | if "prod" == myconfig.MConfig.ConfigName { | 124 | if "prod" == myconfig.MConfig.ConfigName { |
@@ -141,7 +141,7 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user | @@ -141,7 +141,7 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user | ||
141 | exceltool.ExcelHead{Key: "publish_status", Name: "公开状态"}, | 141 | exceltool.ExcelHead{Key: "publish_status", Name: "公开状态"}, |
142 | exceltool.ExcelHead{Key: "review_status", Name: "审核状态"}, | 142 | exceltool.ExcelHead{Key: "review_status", Name: "审核状态"}, |
143 | exceltool.ExcelHead{Key: "status", Name: "关闭状态"}, | 143 | exceltool.ExcelHead{Key: "status", Name: "关闭状态"}, |
144 | - exceltool.ExcelHead{Key: "soure_content", Name: "内容"}, | 144 | + exceltool.ExcelHead{Key: "source_content", Name: "内容"}, |
145 | exceltool.ExcelHead{Key: "media", Name: "视频/图片/语音"}, | 145 | exceltool.ExcelHead{Key: "media", Name: "视频/图片/语音"}, |
146 | exceltool.ExcelHead{Key: "discovery_score", Name: "得分"}, | 146 | exceltool.ExcelHead{Key: "discovery_score", Name: "得分"}, |
147 | } | 147 | } |
@@ -91,7 +91,7 @@ func (e *ExcelMaker) MakeListExcelForBeego(sourData []orm.Params) (err error) { | @@ -91,7 +91,7 @@ func (e *ExcelMaker) MakeListExcelForBeego(sourData []orm.Params) (err error) { | ||
91 | for key, val := range e.header { | 91 | for key, val := range e.header { |
92 | headEn = append(headEn, val.Key) | 92 | headEn = append(headEn, val.Key) |
93 | headCn = append(headCn, val.Name) | 93 | headCn = append(headCn, val.Name) |
94 | - alpha, err := excelize.ColumnNumberToName(key) | 94 | + alpha, err := excelize.ColumnNumberToName(key + 1) |
95 | if err != nil { | 95 | if err != nil { |
96 | return err | 96 | return err |
97 | } | 97 | } |
@@ -102,8 +102,10 @@ func (e *ExcelMaker) MakeListExcelForBeego(sourData []orm.Params) (err error) { | @@ -102,8 +102,10 @@ func (e *ExcelMaker) MakeListExcelForBeego(sourData []orm.Params) (err error) { | ||
102 | for index := range headCn { | 102 | for index := range headCn { |
103 | //索引转列名,索引从0开始 | 103 | //索引转列名,索引从0开始 |
104 | cellAlpha := fmt.Sprintf("%s%d", alphaSlice[index], 1) // 单元格行坐标从1开始,如:a1,指第一行a列。 | 104 | cellAlpha := fmt.Sprintf("%s%d", alphaSlice[index], 1) // 单元格行坐标从1开始,如:a1,指第一行a列。 |
105 | - e.Xlsx.SetCellStr("Sheet1", cellAlpha, headCn[index]) | ||
106 | - | 105 | + err := e.Xlsx.SetCellStr("Sheet1", cellAlpha, headCn[index]) |
106 | + if err != nil { | ||
107 | + fmt.Println(err) | ||
108 | + } | ||
107 | } | 109 | } |
108 | //从excel第二行开始设置实际数据的值 | 110 | //从excel第二行开始设置实际数据的值 |
109 | for key1 := range sourData { | 111 | for key1 := range sourData { |
@@ -112,7 +114,10 @@ func (e *ExcelMaker) MakeListExcelForBeego(sourData []orm.Params) (err error) { | @@ -112,7 +114,10 @@ func (e *ExcelMaker) MakeListExcelForBeego(sourData []orm.Params) (err error) { | ||
112 | if sourData[key1][headEn[i]] == nil { | 114 | if sourData[key1][headEn[i]] == nil { |
113 | sourData[key1][headEn[i]] = "" | 115 | sourData[key1][headEn[i]] = "" |
114 | } | 116 | } |
115 | - e.Xlsx.SetCellStr("Sheet1", cellAlpha, fmt.Sprintf("%s", sourData[key1][headEn[i]])) | 117 | + err := e.Xlsx.SetCellStr("Sheet1", cellAlpha, fmt.Sprintf("%s", sourData[key1][headEn[i]])) |
118 | + if err != nil { | ||
119 | + fmt.Println(err) | ||
120 | + } | ||
116 | } | 121 | } |
117 | } | 122 | } |
118 | if len(e.fileName) == 0 { | 123 | if len(e.fileName) == 0 { |
-
请 注册 或 登录 后发表评论