作者 yangfu

导入修改

... ... @@ -128,9 +128,10 @@ func extQuires(operator domain.Operator) []*allied_creation_cooperation.SearchCo
gatewayUser := allied_creation_user.NewHttplibAlliedCreationUser(
operator)
users, err := gatewayUser.UserSearch(allied_creation_user.ReqUserSearch{
Limit: 100,
Offset: 0,
UserBaseId: operator.UserBaseId,
Limit: 100,
Offset: 0,
UserBaseId: operator.UserBaseId,
EnableStatus: domain.UserStatusEnable,
})
if err != nil {
return extQueries
... ... @@ -139,7 +140,7 @@ func extQuires(operator domain.Operator) []*allied_creation_cooperation.SearchCo
u := users.Users[i]
q := &allied_creation_cooperation.SearchCooperationProjectExtQuery{
ExtCompanyId: int64(u.Company.CompanyId),
ExtOrgId: int64(u.Org.OrgId),
//ExtOrgId: int64(u.Org.OrgId),
//ExtOrgIds: int64(u.UserOrg),
ExtUserId: int64(u.UserId),
ExtUserBaseId: int64(u.UserBaseId),
... ...
... ... @@ -119,58 +119,60 @@ func (srv ExcelDataService) ImportCompanyUser2(importDataCommand *command.Import
// ImportCooperationUser 导入共创用户信息
func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
//initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
//excelImport := excel.NewExcelImport()
//excelImport.RowBegin = 2 //第二行开始读取
//excelImport.DataFields = []excel.DataField{
// {EnName: "UserCode", CnName: "*用户编号"},
// {EnName: "UserName", CnName: "*用户姓名"},
// {EnName: "CooperationCompany", CnName: "*合伙公司"},
// {EnName: "CooperationDeadline", CnName: "*合伙到期"},
// {EnName: "Phone", CnName: "*手机号"},
// {EnName: "Email", CnName: "邮箱"},
//}
//excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
//users := make([]allied_creation_user.BatchAddUserItem, 0)
//var fail int
//for _, v := range excelData {
// item := allied_creation_user.BatchAddUserItem{
// CompanyID: importDataCommand.Operator.CompanyId,
// UserType: domain.UserTypeCooperation,
// UserCode: v["UserCode"],
// OrganizationID: int(importDataCommand.Operator.OrgId),
// UserInfo: allied_creation_user.BatchAddUserItemUserInfo{
// UserName: v["UserName"],
// Phone: v["Phone"],
// Email: v["Email"],
// },
// CooperationInfo: allied_creation_user.BatchAddUserItemCooperationInfo{
// CooperationCompany: v["CooperationCompany"],
// },
// }
// item.CooperationInfo.CooperationDeadline, err = time.Parse("2006-01-02", v["CooperationDeadline"])
// if err != nil {
// fail++
// continue
// }
// users = append(users, item)
//}
//userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
//result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
// Users: users,
// Password: initPassword,
//})
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
//return result, nil
return nil, nil
initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
orgResult, err := userGateway.OrgGet(allied_creation_user.ReqOrgGet{
OrgId: int(importDataCommand.Operator.OrgId),
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
excelImport := excel.NewExcelImport()
excelImport.RowBegin = 3 //第二行开始读取
excelImport.DataFields = []excel.DataField{
{EnName: "userCode", CnName: "*用户编码"},
{EnName: "userName", CnName: "*用户姓名"},
{EnName: "cooperationCompany", CnName: "*合伙公司"},
{EnName: "cooperationDeadline", CnName: "*合伙到期"},
{EnName: "enableStatus", CnName: "*用户状态"},
{EnName: "phone", CnName: "*手机号"},
{EnName: "email", CnName: "邮箱"},
}
excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
users := make([]allied_creation_user.BatchAddUserItem, 0)
for _, v := range excelData {
if srv.fieldValueAllEmpty(v) {
continue
}
item := allied_creation_user.BatchAddUserItem{
CompanyId: importDataCommand.Operator.CompanyId,
UserType: domain.UserTypeCooperation,
UserCode: v["userCode"],
Org: orgResult.OrgCode,
UserName: strings.TrimSpace(v["userName"]),
Phone: strings.TrimSpace(v["phone"]),
Email: strings.TrimSpace(v["email"]),
EnableStatus: strings.TrimSpace(v["enableStatus"]),
CooperationCompany: v["cooperationCompany"],
CooperationDeadline: v["cooperationDeadline"],
}
users = append(users, item)
}
result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
Users: users,
Password: initPassword,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return srv.importResultWithHeader(excelImport.DataFields, result.FailRows, len(users)), nil
}
// ImportCompanyUser 导入公司用户信息
... ... @@ -296,12 +298,11 @@ func (srv ExcelDataService) fieldValueAllEmpty(param map[string]string) bool {
// ImportCompanyUser 导入公司用户信息
func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.ImportDataCommand) (interface{}, error) {
var mapTemplate = map[string]string{
domain.ImportCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807485_EaxECeRz23WpzrMZmbwdEPRJ3Pdxpx5X.xlsx",
domain.ImportOrganization: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807490_r2XWhGmbWWmpbeePBkZ3EJQFKcZEMpEm.xlsx",
domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210917/object/1631843469_DykNwexeYYtzxzbwsER5RrzCS7QRwGmd.xlsx",
// 模板待更新
domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
domain.ImportCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807485_EaxECeRz23WpzrMZmbwdEPRJ3Pdxpx5X.xlsx",
domain.ImportOrganization: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807490_r2XWhGmbWWmpbeePBkZ3EJQFKcZEMpEm.xlsx",
domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210917/object/1631843469_DykNwexeYYtzxzbwsER5RrzCS7QRwGmd.xlsx",
domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210918/object/1631932960_fen6RZS7ZesyDPMzXactKKCenhRMkfRb.xlsx",
domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210918/object/1631933214_MbTxsQtnEEMprHADFR6MedfZBkxYWBYA.xlsx",
}
var url string
var ok bool
... ...
... ... @@ -397,7 +397,7 @@ type (
// 共创公司 cooperationCompany
CooperationCompany string `json:"cooperationCompany"`
// 共创到期时间 (yyyy-MM-dd) cooperationDeadline
CooperationDeadline time.Time `json:"cooperationDeadline"`
CooperationDeadline string `json:"cooperationDeadline"`
// 失败理由
FailReason string `json:"failReason"`
}
... ...