...
|
...
|
@@ -701,14 +701,6 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
file, h, _ := c.GetFile("file")
|
|
|
companyId := c.GetUserCompany()
|
|
|
|
|
|
// Json数据解析
|
|
|
//jsonMap := make(map[string]interface{})
|
|
|
//err := json.Unmarshal([]byte(where), &jsonMap)
|
|
|
//if err != nil {
|
|
|
// logs.Error(err)
|
|
|
// c.ResponseError(errors.New("json数据解析失败"))
|
|
|
//}
|
|
|
|
|
|
if typeCode != "PARTNER_ORDER_FILE" {
|
|
|
c.ResponseError(errors.New("类型编码错误"))
|
|
|
}
|
...
|
...
|
@@ -779,41 +771,53 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
|
|
|
// 必填项校验
|
|
|
nullLine := make([]interface{}, 0)
|
|
|
nullCell := make([]interface{}, 0)
|
|
|
nullFlag := false
|
|
|
for i, row := range rows {
|
|
|
if i > 2 && row != nil {
|
|
|
rowCnt++
|
|
|
if len(row) == constant.EXCEL_COLUMN { // 中间空字符校验
|
|
|
// 单个空格
|
|
|
|
|
|
// 多个空格
|
|
|
|
|
|
fmt.Print(len(row), "\n")
|
|
|
if len(row) == constant.EXCEL_COLUMN { // 必填项内容为空
|
|
|
var tmpRow = row
|
|
|
var myRow []string
|
|
|
for j, _ := range row {
|
|
|
if j != 7 { // 业务员抽成比例非必填
|
|
|
if row[j] == "" || row[j] == " " { // 空字符补位s
|
|
|
if row[j] == "" || row[j] == " " { // 空字符补位
|
|
|
tmpRow[j] = ""
|
|
|
r := strconv.Itoa(i + 1)
|
|
|
c := strconv.Itoa(j + 1)
|
|
|
myRow = append(myRow, "第"+r+"行的第"+c+"列必填项为空") // 错误信息
|
|
|
myRow = append(myRow, r) // 行号
|
|
|
myRow = append(myRow, tmpRow...) // 错误行数据
|
|
|
nullLine = append(nullLine, myRow)
|
|
|
col := strconv.Itoa(j + 1)
|
|
|
nullCell = append(nullCell, col)
|
|
|
nullFlag = true
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else if len(row) > 0 && len(row) < constant.EXCEL_COLUMN { // 尾部空字符校验
|
|
|
var myRow []string
|
|
|
for k := 0; k < constant.EXCEL_COLUMN-len(row); k++ { // 空字符补位
|
|
|
myRow = append(myRow, "")
|
|
|
if nullFlag {
|
|
|
s := strconv.Itoa(i + 1)
|
|
|
b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)
|
|
|
myRow = append(myRow, "第"+s+"行的第"+b+"列必填项为空") // 错误信息
|
|
|
myRow = append(myRow, s) // 行号
|
|
|
myRow = append(myRow, tmpRow...) // 错误行数据
|
|
|
nullLine = append(nullLine, myRow)
|
|
|
nullFlag = false
|
|
|
}
|
|
|
myRow = append(myRow, "必填项不能为空") // 错误信息
|
|
|
} else if len(row) > 0 && len(row) < constant.EXCEL_COLUMN { // 必填项不存在
|
|
|
var myRow []string
|
|
|
myRow = append(myRow, "必填项为空")
|
|
|
s := strconv.Itoa(i + 1)
|
|
|
myRow = append(myRow, s) // 行号
|
|
|
myRow = append(myRow, row...) // 错误行数据
|
|
|
emptyCell := make([]interface{}, 0)
|
|
|
// 错误信息
|
|
|
for k := 0; k < constant.EXCEL_COLUMN-len(row); k++ { // 空字符补位
|
|
|
myRow = append(myRow, "")
|
|
|
}
|
|
|
for k, cell := range myRow {
|
|
|
if k != 0 && cell == "" {
|
|
|
emptyCell = append(emptyCell, k-1)
|
|
|
}
|
|
|
}
|
|
|
b := strings.Replace(strings.Trim(fmt.Sprint(emptyCell), "[]"), " ", ",", -1)
|
|
|
myRow[0] = "第" + s + "行的第" + b + "列必填项为空"
|
|
|
nullLine = append(nullLine, myRow)
|
|
|
} else {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
|