正在显示
1 个修改的文件
包含
31 行增加
和
27 行删除
@@ -701,14 +701,6 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | @@ -701,14 +701,6 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | ||
701 | file, h, _ := c.GetFile("file") | 701 | file, h, _ := c.GetFile("file") |
702 | companyId := c.GetUserCompany() | 702 | companyId := c.GetUserCompany() |
703 | 703 | ||
704 | - // Json数据解析 | ||
705 | - //jsonMap := make(map[string]interface{}) | ||
706 | - //err := json.Unmarshal([]byte(where), &jsonMap) | ||
707 | - //if err != nil { | ||
708 | - // logs.Error(err) | ||
709 | - // c.ResponseError(errors.New("json数据解析失败")) | ||
710 | - //} | ||
711 | - | ||
712 | if typeCode != "PARTNER_ORDER_FILE" { | 704 | if typeCode != "PARTNER_ORDER_FILE" { |
713 | c.ResponseError(errors.New("类型编码错误")) | 705 | c.ResponseError(errors.New("类型编码错误")) |
714 | } | 706 | } |
@@ -779,41 +771,53 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | @@ -779,41 +771,53 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | ||
779 | 771 | ||
780 | // 必填项校验 | 772 | // 必填项校验 |
781 | nullLine := make([]interface{}, 0) | 773 | nullLine := make([]interface{}, 0) |
774 | + nullCell := make([]interface{}, 0) | ||
775 | + nullFlag := false | ||
782 | for i, row := range rows { | 776 | for i, row := range rows { |
783 | if i > 2 && row != nil { | 777 | if i > 2 && row != nil { |
784 | rowCnt++ | 778 | rowCnt++ |
785 | - if len(row) == constant.EXCEL_COLUMN { // 中间空字符校验 | ||
786 | - // 单个空格 | ||
787 | - | ||
788 | - // 多个空格 | ||
789 | - | 779 | + fmt.Print(len(row), "\n") |
780 | + if len(row) == constant.EXCEL_COLUMN { // 必填项内容为空 | ||
790 | var tmpRow = row | 781 | var tmpRow = row |
791 | var myRow []string | 782 | var myRow []string |
792 | for j, _ := range row { | 783 | for j, _ := range row { |
793 | if j != 7 { // 业务员抽成比例非必填 | 784 | if j != 7 { // 业务员抽成比例非必填 |
794 | - if row[j] == "" || row[j] == " " { // 空字符补位s | 785 | + if row[j] == "" || row[j] == " " { // 空字符补位 |
795 | tmpRow[j] = "" | 786 | tmpRow[j] = "" |
796 | - r := strconv.Itoa(i + 1) | ||
797 | - c := strconv.Itoa(j + 1) | ||
798 | - myRow = append(myRow, "第"+r+"行的第"+c+"列必填项为空") // 错误信息 | ||
799 | - myRow = append(myRow, r) // 行号 | ||
800 | - myRow = append(myRow, tmpRow...) // 错误行数据 | ||
801 | - nullLine = append(nullLine, myRow) | 787 | + col := strconv.Itoa(j + 1) |
788 | + nullCell = append(nullCell, col) | ||
789 | + nullFlag = true | ||
802 | } | 790 | } |
803 | } | 791 | } |
804 | } | 792 | } |
805 | - } else if len(row) > 0 && len(row) < constant.EXCEL_COLUMN { // 尾部空字符校验 | ||
806 | - var myRow []string | ||
807 | - for k := 0; k < constant.EXCEL_COLUMN-len(row); k++ { // 空字符补位 | ||
808 | - myRow = append(myRow, "") | 793 | + if nullFlag { |
794 | + s := strconv.Itoa(i + 1) | ||
795 | + b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1) | ||
796 | + myRow = append(myRow, "第"+s+"行的第"+b+"列必填项为空") // 错误信息 | ||
797 | + myRow = append(myRow, s) // 行号 | ||
798 | + myRow = append(myRow, tmpRow...) // 错误行数据 | ||
799 | + nullLine = append(nullLine, myRow) | ||
800 | + nullFlag = false | ||
809 | } | 801 | } |
810 | - myRow = append(myRow, "必填项不能为空") // 错误信息 | 802 | + } else if len(row) > 0 && len(row) < constant.EXCEL_COLUMN { // 必填项不存在 |
803 | + var myRow []string | ||
804 | + myRow = append(myRow, "必填项为空") | ||
811 | s := strconv.Itoa(i + 1) | 805 | s := strconv.Itoa(i + 1) |
812 | myRow = append(myRow, s) // 行号 | 806 | myRow = append(myRow, s) // 行号 |
813 | myRow = append(myRow, row...) // 错误行数据 | 807 | myRow = append(myRow, row...) // 错误行数据 |
808 | + emptyCell := make([]interface{}, 0) | ||
809 | + // 错误信息 | ||
810 | + for k := 0; k < constant.EXCEL_COLUMN-len(row); k++ { // 空字符补位 | ||
811 | + myRow = append(myRow, "") | ||
812 | + } | ||
813 | + for k, cell := range myRow { | ||
814 | + if k != 0 && cell == "" { | ||
815 | + emptyCell = append(emptyCell, k-1) | ||
816 | + } | ||
817 | + } | ||
818 | + b := strings.Replace(strings.Trim(fmt.Sprint(emptyCell), "[]"), " ", ",", -1) | ||
819 | + myRow[0] = "第" + s + "行的第" + b + "列必填项为空" | ||
814 | nullLine = append(nullLine, myRow) | 820 | nullLine = append(nullLine, myRow) |
815 | - } else { | ||
816 | - | ||
817 | } | 821 | } |
818 | } | 822 | } |
819 | } | 823 | } |
-
请 注册 或 登录 后发表评论