...
|
...
|
@@ -16,7 +16,6 @@ import ( |
|
|
"reflect"
|
|
|
"regexp"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -309,7 +308,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
rowCnt++
|
|
|
nullCell := make([]interface{}, 0)
|
|
|
//var myRow []string
|
|
|
var myRow []interface{}
|
|
|
var myRow interface{}
|
|
|
t := reflect.TypeOf(dividendsOrder)
|
|
|
v := reflect.ValueOf(dividendsOrder)
|
|
|
for k := 0; k < t.NumField(); k++ {
|
...
|
...
|
@@ -324,12 +323,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
}
|
|
|
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, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
myRow = append(myRow, map[string]interface{}{
|
|
|
"failReason": "第" + s + "行第" + b + "列订单日期格式错误,请输入正确的订单日期",
|
|
|
myRow = map[string]interface{}{
|
|
|
"failReason": "第" + s + "行订单日期格式错误,请输入正确的订单日期",
|
|
|
"originalOrderNum": dividendsOrder.OriginalOrderNum,
|
|
|
"dividendsCustomerName": dividendsOrder.DividendsCustomerName,
|
|
|
"orderGoodName": dividendsOrder.OrderGoodName,
|
...
|
...
|
@@ -339,7 +334,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": dividendsOrder.OrderGoodPrice,
|
|
|
"expense": dividendsOrder.Expense,
|
|
|
"cooperationContractNumber": dividendsOrder.CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
nullCellError = append(nullCellError, myRow)
|
|
|
nullFlag = false
|
|
|
}
|
...
|
...
|
@@ -359,26 +354,21 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
// 单元格类型校验
|
|
|
typeError := make([]interface{}, 0)
|
|
|
for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData { // 行
|
|
|
var myRow []interface{}
|
|
|
var myRow interface{}
|
|
|
//var myRow []string
|
|
|
t := reflect.TypeOf(dividendsOrder)
|
|
|
v := reflect.ValueOf(dividendsOrder)
|
|
|
for k := 0; k < t.NumField(); k++ { // 列
|
|
|
r := strconv.Itoa(i + 1)
|
|
|
col := strconv.Itoa(k + 1)
|
|
|
//col := strconv.Itoa(k + 1)
|
|
|
switch k {
|
|
|
case 3: // 订单日期校验
|
|
|
{
|
|
|
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
|
|
|
ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
|
|
|
if !ok {
|
|
|
//var tmpRow []string
|
|
|
//tmpRow = append(tmpRow, "第"+r+"行第"+col+"列订单日期格式错误,请输入正确的订单日期") // 错误信息
|
|
|
//tmpRow = append(tmpRow, r) // 行号
|
|
|
//tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
"failReason": "第" + r + "行第" + col + "列订单日期格式错误,请输入正确的订单日期",
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + r + "行订单日期格式错误,请输入正确的订单日期",
|
|
|
"originalOrderNum": dividendsOrder.OriginalOrderNum,
|
|
|
"dividendsCustomerName": dividendsOrder.DividendsCustomerName,
|
|
|
"orderGoodName": dividendsOrder.OrderGoodName,
|
...
|
...
|
@@ -388,7 +378,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": dividendsOrder.OrderGoodPrice,
|
|
|
"expense": dividendsOrder.Expense,
|
|
|
"cooperationContractNumber": dividendsOrder.CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -397,13 +387,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
//参数类型转换
|
|
|
orderGoodQuantity, err := strconv.ParseInt(fmt.Sprintf("%v", v.Field(k).Interface()), 10, 64)
|
|
|
if err != nil {
|
|
|
//var tmpRow []string
|
|
|
//tmpRow = append(tmpRow, "第"+r+"行第"+col+"列产品数量格式错误,产品数量必须整数") // 错误信息
|
|
|
//tmpRow = append(tmpRow, r) // 行号
|
|
|
//tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
"failReason": "第" + r + "行第" + col + "列产品数量格式错误,产品数量必须整数",
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + r + "行产品数量格式错误,产品数量必须整数",
|
|
|
"originalOrderNum": dividendsOrder.OriginalOrderNum,
|
|
|
"dividendsCustomerName": dividendsOrder.DividendsCustomerName,
|
|
|
"orderGoodName": dividendsOrder.OrderGoodName,
|
...
|
...
|
@@ -413,18 +398,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": dividendsOrder.OrderGoodPrice,
|
|
|
"expense": dividendsOrder.Expense,
|
|
|
"cooperationContractNumber": dividendsOrder.CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
// 正负判断
|
|
|
if orderGoodQuantity < 0 {
|
|
|
//var tmpRow []string
|
|
|
//tmpRow = append(tmpRow, "第"+r+"行第"+col+"列产品数量必须大于0,请重新填写") // 错误信息
|
|
|
//tmpRow = append(tmpRow, r) // 行号
|
|
|
//tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
"failReason": "第" + r + "行第" + col + "列产品数量必须大于0,请重新填写",
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + r + "行产品数量必须大于0,请重新填写",
|
|
|
"originalOrderNum": dividendsOrder.OriginalOrderNum,
|
|
|
"dividendsCustomerName": dividendsOrder.DividendsCustomerName,
|
|
|
"orderGoodName": dividendsOrder.OrderGoodName,
|
...
|
...
|
@@ -434,7 +414,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": dividendsOrder.OrderGoodPrice,
|
|
|
"expense": dividendsOrder.Expense,
|
|
|
"cooperationContractNumber": dividendsOrder.CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -443,13 +423,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
// 参数类型转换
|
|
|
univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64)
|
|
|
if typeErr != nil {
|
|
|
//var tmpRow []string
|
|
|
//tmpRow = append(tmpRow, "第"+r+"行第"+col+"列产品价格格式错误,产品价格必须为数字类型") // 错误信息
|
|
|
//tmpRow = append(tmpRow, r) // 行号
|
|
|
//tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
"failReason": "第" + r + "行第" + col + "列产品价格格式错误,产品价格必须为数字类型",
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + r + "行产品价格格式错误,产品价格必须为数字类型",
|
|
|
"originalOrderNum": dividendsOrder.OriginalOrderNum,
|
|
|
"dividendsCustomerName": dividendsOrder.DividendsCustomerName,
|
|
|
"orderGoodName": dividendsOrder.OrderGoodName,
|
...
|
...
|
@@ -459,19 +434,14 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": dividendsOrder.OrderGoodPrice,
|
|
|
"expense": dividendsOrder.Expense,
|
|
|
"cooperationContractNumber": dividendsOrder.CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
|
|
|
// 长度校验
|
|
|
if univalent >= 1e16 {
|
|
|
//var tmpRow []string
|
|
|
//tmpRow = append(tmpRow, "第"+r+"行第"+col+"列产品价格超过最大限制,产品价格小数点前面不能超过十六位数字,并保留两位小数") // 错误信息
|
|
|
//tmpRow = append(tmpRow, r) // 行号
|
|
|
//tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface()))
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
"failReason": "第" + r + "行第" + col + "列产品价格超过最大限制,产品价格小数点前面不能超过十六位数字,并保留两位小数",
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + r + "行产品价格超过最大限制,产品价格小数点前面不能超过十六位数字,并保留两位小数",
|
|
|
"originalOrderNum": dividendsOrder.OriginalOrderNum,
|
|
|
"dividendsCustomerName": dividendsOrder.DividendsCustomerName,
|
|
|
"orderGoodName": dividendsOrder.OrderGoodName,
|
...
|
...
|
@@ -481,7 +451,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": dividendsOrder.OrderGoodPrice,
|
|
|
"expense": dividendsOrder.Expense,
|
|
|
"cooperationContractNumber": dividendsOrder.CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
// 错误行数据
|
|
|
myRow = tmpRow
|
|
|
}
|
...
|
...
|
@@ -492,13 +462,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
// 参数类型转换
|
|
|
univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64)
|
|
|
if typeErr != nil {
|
|
|
//var tmpRow []string
|
|
|
//tmpRow = append(tmpRow, "第"+r+"行第"+col+"列费用格式错误,费用必须为数字类型") // 错误信息
|
|
|
//tmpRow = append(tmpRow, r) // 行号
|
|
|
//tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
"failReason": "第" + r + "行第" + col + "列费用格式错误,费用必须为数字类型",
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + r + "行费用格式错误,费用必须为数字类型",
|
|
|
"originalOrderNum": dividendsOrder.OriginalOrderNum,
|
|
|
"dividendsCustomerName": dividendsOrder.DividendsCustomerName,
|
|
|
"orderGoodName": dividendsOrder.OrderGoodName,
|
...
|
...
|
@@ -508,19 +473,14 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": dividendsOrder.OrderGoodPrice,
|
|
|
"expense": dividendsOrder.Expense,
|
|
|
"cooperationContractNumber": dividendsOrder.CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
|
|
|
// 长度校验
|
|
|
if univalent >= 1e16 {
|
|
|
//var tmpRow []string
|
|
|
//tmpRow = append(tmpRow, "第"+r+"行第"+col+"列费用超过最大限制,费用小数点前面不能超过十六位数字,并保留两位小数") // 错误信息
|
|
|
//tmpRow = append(tmpRow, r) // 行号
|
|
|
//tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
"failReason": "第" + r + "行第" + col + "列费用超过最大限制,费用小数点前面不能超过十六位数字,并保留两位小数",
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + r + "行费用超过最大限制,费用小数点前面不能超过十六位数字,并保留两位小数",
|
|
|
"originalOrderNum": dividendsOrder.OriginalOrderNum,
|
|
|
"dividendsCustomerName": dividendsOrder.DividendsCustomerName,
|
|
|
"orderGoodName": dividendsOrder.OrderGoodName,
|
...
|
...
|
@@ -530,7 +490,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": dividendsOrder.OrderGoodPrice,
|
|
|
"expense": dividendsOrder.Expense,
|
|
|
"cooperationContractNumber": dividendsOrder.CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -564,13 +524,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
// 订单日期时间格式转换
|
|
|
timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
|
|
|
if err != nil {
|
|
|
//var tmpRow []string
|
|
|
//tmpRow = append(tmpRow, "无效的订单日期") // 错误信息
|
|
|
s := strconv.Itoa(i + 1)
|
|
|
//tmpRow = append(tmpRow, s) // 行号
|
|
|
//tmpRow = append(tmpRow, dividendsOrder.OriginalOrderNum)
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + s + "行无效的订单日期",
|
|
|
"originalOrderNum": dividendsOrder.OriginalOrderNum,
|
|
|
"dividendsCustomerName": dividendsOrder.DividendsCustomerName,
|
...
|
...
|
@@ -581,7 +536,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": dividendsOrder.OrderGoodPrice,
|
|
|
"expense": dividendsOrder.Expense,
|
|
|
"cooperationContractNumber": dividendsOrder.CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
aggregateErrorList = append(aggregateErrorList, tmpRow)
|
|
|
break
|
|
|
}
|
...
|
...
|
@@ -704,13 +659,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
for _, errorData := range errorDataList {
|
|
|
if len(errorData.GoodLine) == 0 { // 订单错误
|
|
|
for _, line := range errorData.LineNumbers {
|
|
|
//var tmpRow []string5
|
|
|
//tmpRow = append(tmpRow, errorData.Error.Error()) // 错误信息
|
|
|
s := strconv.Itoa(line + 1)
|
|
|
//tmpRow = append(tmpRow, s) // 行号
|
|
|
//tmpRow = append(tmpRow, importDividendsOrderCommand.DividendsOrderData[line]...) // 错误行数据
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + s + "行数据校验错误:" + errorData.Error.Error(),
|
|
|
"originalOrderNum": importDividendsOrderCommand.DividendsOrderData[line].OriginalOrderNum,
|
|
|
"dividendsCustomerName": importDividendsOrderCommand.DividendsOrderData[line].DividendsCustomerName,
|
...
|
...
|
@@ -721,18 +671,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodPrice,
|
|
|
"expense": importDividendsOrderCommand.DividendsOrderData[line].Expense,
|
|
|
"cooperationContractNumber": importDividendsOrderCommand.DividendsOrderData[line].CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
failureDataList = append(failureDataList, tmpRow)
|
|
|
}
|
|
|
} else if len(errorData.GoodLine) > 0 { // 订单产品错误
|
|
|
for line := range errorData.GoodLine {
|
|
|
//var tmpRow []string
|
|
|
//tmpRow = append(tmpRow, errorData.Error.Error()) // 错误信息
|
|
|
s := strconv.Itoa(line + 1)
|
|
|
//tmpRow = append(tmpRow, s) // 行号
|
|
|
//tmpRow = append(tmpRow, importDividendsOrderCommand.DividendsOrderData[line]...) // 错误行数据
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + s + "行订单产品信息错误:" + errorData.Error.Error(),
|
|
|
"originalOrderNum": importDividendsOrderCommand.DividendsOrderData[line].OriginalOrderNum,
|
|
|
"dividendsCustomerName": importDividendsOrderCommand.DividendsOrderData[line].DividendsCustomerName,
|
...
|
...
|
@@ -743,7 +688,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodPrice,
|
|
|
"expense": importDividendsOrderCommand.DividendsOrderData[line].Expense,
|
|
|
"cooperationContractNumber": importDividendsOrderCommand.DividendsOrderData[line].CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
failureDataList = append(failureDataList, tmpRow)
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -862,13 +807,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
for _, errorData := range errorDataList {
|
|
|
if len(errorData.GoodLine) == 0 { // 订单错误
|
|
|
for _, line := range errorData.LineNumbers {
|
|
|
//var tmpRow []string
|
|
|
//tmpRow = append(tmpRow, errorData.Error.Error()) // 错误信息
|
|
|
s := strconv.Itoa(line + 1)
|
|
|
//tmpRow = append(tmpRow, s) // 行号
|
|
|
//tmpRow = append(tmpRow, importDividendsOrderCommand.DividendsOrderData[line]...) // 错误行数据
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + s + "行订单数据新增错误:" + errorData.Error.Error(),
|
|
|
"originalOrderNum": importDividendsOrderCommand.DividendsOrderData[line].OriginalOrderNum,
|
|
|
"dividendsCustomerName": importDividendsOrderCommand.DividendsOrderData[line].DividendsCustomerName,
|
...
|
...
|
@@ -879,18 +819,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodPrice,
|
|
|
"expense": importDividendsOrderCommand.DividendsOrderData[line].Expense,
|
|
|
"cooperationContractNumber": importDividendsOrderCommand.DividendsOrderData[line].CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
failureDataList = append(failureDataList, tmpRow)
|
|
|
}
|
|
|
} else if len(errorData.GoodLine) > 0 { // 订单产品错误
|
|
|
for line := range errorData.GoodLine {
|
|
|
//var tmpRow []string
|
|
|
//tmpRow = append(tmpRow, errorData.Error.Error()) // 错误信息
|
|
|
s := strconv.Itoa(line + 1)
|
|
|
//tmpRow = append(tmpRow, s) // 行号
|
|
|
//tmpRow = append(tmpRow, importDividendsOrderCommand.DividendsOrderData[line]...) // 错误行数据
|
|
|
var tmpRow []interface{}
|
|
|
tmpRow = append(tmpRow, map[string]interface{}{
|
|
|
tmpRow := map[string]interface{}{
|
|
|
"failReason": "第" + s + "行订单数据新增错误:" + errorData.Error.Error(),
|
|
|
"originalOrderNum": importDividendsOrderCommand.DividendsOrderData[line].OriginalOrderNum,
|
|
|
"dividendsCustomerName": importDividendsOrderCommand.DividendsOrderData[line].DividendsCustomerName,
|
...
|
...
|
@@ -901,7 +836,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD |
|
|
"orderGoodPrice": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodPrice,
|
|
|
"expense": importDividendsOrderCommand.DividendsOrderData[line].Expense,
|
|
|
"cooperationContractNumber": importDividendsOrderCommand.DividendsOrderData[line].CooperationContractNumber,
|
|
|
})
|
|
|
}
|
|
|
failureDataList = append(failureDataList, tmpRow)
|
|
|
}
|
|
|
}
|
...
|
...
|
|