作者 tangxuhui

导入分红单修正数据处理逻辑

... ... @@ -66,6 +66,7 @@ func (cooperationModeService *CooperationModeService) ListCooperationMode(listCo
OrganizationName: listCooperationModeQuery.OrganizationName,
CompanyId: listCooperationModeQuery.Operator.CompanyId,
UserId: 0,
OrgIds: listCooperationModeQuery.Operator.OrgIds,
OrgId: 0,
UserBaseId: 0,
})
... ...
... ... @@ -160,11 +160,12 @@ type (
//模式名称
CooperationModeName string `json:"cooperationModeName"`
//组织名称
OrganizationName string `json:"organizationName"`
CompanyId int64 `json:"companyId"`
OrgId int64 `json:"orgId"`
UserId int64 `json:"userId"`
UserBaseId int64 `json:"userBaseId"`
OrganizationName string `json:"organizationName"`
CompanyId int64 `json:"companyId"`
OrgId int64 `json:"orgId"`
UserId int64 `json:"userId"`
UserBaseId int64 `json:"userBaseId"`
OrgIds []int64 `json:"orgIds"`
//模式编码列表
CooperationModeNumbers []string `cname:"模式编码列表" json:"cooperationModeNumbers,omitempty"`
}
... ...
package web_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/command"
"errors"
"path/filepath"
"strings"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/command"
"github.com/beego/beego/v2/server/web/context"
"github.com/linmadan/egglib-go/utils/excel"
... ... @@ -29,6 +32,17 @@ func (controller *ExcelDataController) responseExcelByFile(ctx *context.Context,
return nil
}
func (controller *ExcelDataController) fieldValueAllEmpty(param map[string]string) bool {
isAllEmpty := true
for _, v := range param {
value := strings.TrimSpace(v)
if len(value) > 0 {
isAllEmpty = false
}
}
return isAllEmpty
}
//导出公司用户
func (controller ExcelDataController) ExportCompanyUser() {
excelService := service.NewExcelDataService(nil)
... ... @@ -91,12 +105,14 @@ func (controller ExcelDataController) ImportDividendsOrder() {
controller.Response(nil, err)
return
}
if filepath.Ext(fileHeader.Filename) == "" {
if filepath.Ext(fileHeader.Filename) != ".xlsx" {
//TODO 判断文件类型
log.Logger.Error("获取到的文件:" + fileHeader.Filename)
controller.Response(nil, errors.New("上传到的文件类型错误"))
return
}
excelImport := excel.NewExcelImport()
excelImport.RowBegin = 3 //第三行开始读取
excelImport.RowBegin = 2 //第2行开始读取
excelImport.DataFields = []excel.DataField{
{EnName: "OriginalOrderNum", CnName: "*来源单号"},
{EnName: "DividendsCustomerName", CnName: "*客户名称"},
... ... @@ -117,17 +133,21 @@ func (controller ExcelDataController) ImportDividendsOrder() {
//订单数据
var returnedOrderData []allied_creation_cooperation.ImportDividendsOrderData
for _, v := range excelData {
if allEmpty := controller.fieldValueAllEmpty(v); allEmpty {
//以全字段空跳过
continue
}
//TODO 按需转化
item := allied_creation_cooperation.ImportDividendsOrderData{
OriginalOrderNum: v["OriginalOrderNum"],
DividendsCustomerName: v["DividendsCustomerName"],
OrderGoodName: v["OrderGoodName"],
OrderTime: v["OrderTime"],
RegionName: v["RegionName"],
OrderGoodQuantity: v["OrderGoodQuantity"],
OrderGoodPrice: v["OrderGoodPrice"],
Expense: v["Expense"],
CooperationContractNumber: v["CooperationContractNumber"],
OriginalOrderNum: strings.TrimSpace(v["OriginalOrderNum"]),
DividendsCustomerName: strings.TrimSpace(v["DividendsCustomerName"]),
OrderGoodName: strings.TrimSpace(v["OrderGoodName"]),
OrderTime: strings.TrimSpace(v["OrderTime"]),
RegionName: strings.TrimSpace(v["RegionName"]),
OrderGoodQuantity: strings.TrimSpace(v["OrderGoodQuantity"]),
OrderGoodPrice: strings.TrimSpace(v["OrderGoodPrice"]),
Expense: strings.TrimSpace(v["Expense"]),
CooperationContractNumber: strings.TrimSpace(v["CooperationContractNumber"]),
}
returnedOrderData = append(returnedOrderData, item)
}
... ... @@ -150,12 +170,14 @@ func (controller ExcelDataController) ImportDividendsReturnedOrder() {
controller.Response(nil, err)
return
}
if filepath.Ext(fileHeader.Filename) == "" {
if filepath.Ext(fileHeader.Filename) != ".xlsx" {
//TODO 判断文件类型
log.Logger.Error("获取到的文件:" + fileHeader.Filename)
log.Logger.Error("获取到的文件:" + filepath.Ext(fileHeader.Filename))
controller.Response(nil, errors.New("上传的文件类型错误"))
return
}
excelImport := excel.NewExcelImport()
excelImport.RowBegin = 3 //第三行开始读取
excelImport.RowBegin = 2 //第2行表头开始读取
excelImport.DataFields = []excel.DataField{
{EnName: "OriginalOrderNum", CnName: "*来源单号"},
{EnName: "DividendsReturnedCustomerName", CnName: "*客户名称"},
... ... @@ -176,17 +198,21 @@ func (controller ExcelDataController) ImportDividendsReturnedOrder() {
//退货单数据
returnedOrderData := []allied_creation_cooperation.ImportDividendsReturnedOrderData{}
for _, v := range excelData {
if allEmpty := controller.fieldValueAllEmpty(v); allEmpty {
//以全字段空跳过
continue
}
//TODO 按需转化
item := allied_creation_cooperation.ImportDividendsReturnedOrderData{
OriginalOrderNum: v["OriginalOrderNum"],
DividendsReturnedCustomerName: v["DividendsReturnedCustomerName"],
OrderGoodName: v["OrderGoodName"],
DividendsReturnedDate: v["DividendsReturnedDate"],
OrderTime: v["OrderTime"],
RegionName: v["RegionName"],
OrderGoodQuantity: v["OrderGoodQuantity"],
OrderGoodPrice: v["OrderGoodPrice"],
CooperationContractNumber: v["CooperationContractNumber"],
OriginalOrderNum: strings.TrimSpace(v["OriginalOrderNum"]),
DividendsReturnedCustomerName: strings.TrimSpace(v["DividendsReturnedCustomerName"]),
OrderGoodName: strings.TrimSpace(v["OrderGoodName"]),
DividendsReturnedDate: strings.TrimSpace(v["DividendsReturnedDate"]),
OrderTime: strings.TrimSpace(v["OrderTime"]),
RegionName: strings.TrimSpace(v["RegionName"]),
OrderGoodQuantity: strings.TrimSpace(v["OrderGoodQuantity"]),
OrderGoodPrice: strings.TrimSpace(v["OrderGoodPrice"]),
CooperationContractNumber: strings.TrimSpace(v["CooperationContractNumber"]),
}
returnedOrderData = append(returnedOrderData, item)
}
... ...