...
|
...
|
@@ -10,6 +10,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service"
|
|
|
utils_tool "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils"
|
|
|
"os"
|
|
|
"path"
|
|
|
"strconv"
|
...
|
...
|
@@ -427,6 +428,7 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
|
return
|
|
|
}
|
|
|
|
|
|
// 打开文件
|
|
|
xlsx, err := excelize.OpenReader(file)
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|
...
|
...
|
@@ -436,8 +438,6 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
|
// 文件行数校验
|
|
|
rows, _ := xlsx.GetRows("Sheet1")
|
|
|
fmt.Print(len(rows), "\n")
|
|
|
|
|
|
// 表格超行判断
|
|
|
if len(rows) > 302 {
|
|
|
err := &application.ServiceError{
|
|
|
Code: 500,
|
...
|
...
|
@@ -461,48 +461,53 @@ func (controller *SuMoneyController) ImportExchangeList () { |
|
|
return
|
|
|
}
|
|
|
|
|
|
// 空字段判断
|
|
|
//newstr := []string{"null"}
|
|
|
// 单元格校验
|
|
|
newstr := []string{"null"}
|
|
|
//nullChar := []string{"单元格包含空字符"}
|
|
|
nullLine := make([]interface{}, 0)
|
|
|
for i, row := range rows {
|
|
|
if i > 2 {
|
|
|
fmt.Print(len(row), "\n")
|
|
|
|
|
|
// 头部、中间空
|
|
|
if len(row) == 3 {
|
|
|
for j, cell := range row {
|
|
|
fmt.Print(cell, "\n")
|
|
|
if cell == "" {
|
|
|
utils_tool.InsertSlice(j, newstr, row)
|
|
|
row = append(row, "单元格包含空字符")
|
|
|
nullLine = append(nullLine, row)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 尾空
|
|
|
if len(row) < 3 {
|
|
|
for j, cell := range row {
|
|
|
fmt.Print(cell, "\n")
|
|
|
if cell == "" {
|
|
|
utils_tool.InsertSlice(j, row, newstr)
|
|
|
row = append(row, "单元格包含空字符")
|
|
|
nullLine = append(nullLine, row)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//nullLine := make([]interface{}, 0)
|
|
|
//for i, row := range rows {
|
|
|
// if i > 2 {
|
|
|
// if len(row) < 3 {
|
|
|
// r2, _ := strconv.ParseFloat(row[2], 64)
|
|
|
// if row[0] == "" {
|
|
|
// utils_tool.InsertSlice(0, row, newstr)
|
|
|
// } else if row[1] == "" {
|
|
|
// utils_tool.InsertSlice(1, row, newstr)
|
|
|
// } else if r2 == 0 {
|
|
|
// utils_tool.InsertSlice(2, row, newstr)
|
|
|
// }
|
|
|
//
|
|
|
// //for j, cell := range row {
|
|
|
// // if cell == "" {
|
|
|
// // utils_tool.InsertSlice(j, row, newstr)
|
|
|
// // }
|
|
|
// //}
|
|
|
// //utils_tool.InsertSlice(1, row, nullChar)
|
|
|
// row = append(row, "单元格包含空字符")
|
|
|
// nullLine = append(nullLine, row)
|
|
|
// }
|
|
|
// }
|
|
|
//}
|
|
|
//
|
|
|
//if len(nullLine) > 0 {
|
|
|
// ret = map[string]interface{}{
|
|
|
// "successCount": 0,
|
|
|
// "fail": map[string]interface{}{
|
|
|
// "tableHeader": tableHeader,
|
|
|
// "tableData": nullLine,
|
|
|
// },
|
|
|
// }
|
|
|
// response = utils.ResponseData(controller.Ctx, ret)
|
|
|
// controller.Data["json"] = response
|
|
|
// controller.ServeJSON()
|
|
|
// return
|
|
|
//}
|
|
|
if len(nullLine) > 0 {
|
|
|
ret = map[string]interface{}{
|
|
|
"successCount": 0,
|
|
|
"fail": map[string]interface{}{
|
|
|
"tableHeader": tableHeader,
|
|
|
"tableData": nullLine,
|
|
|
},
|
|
|
}
|
|
|
response = utils.ResponseData(controller.Ctx, ret)
|
|
|
controller.Data["json"] = response
|
|
|
controller.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 新增失败记录
|
|
|
failureDataList := make([]interface{}, 0)
|
...
|
...
|
|