|
@@ -120,58 +120,60 @@ func (srv ExcelDataService) ImportCompanyUser2(importDataCommand *command.Import |
|
@@ -120,58 +120,60 @@ func (srv ExcelDataService) ImportCompanyUser2(importDataCommand *command.Import |
120
|
|
120
|
|
121
|
// ImportCooperationUser 导入共创用户信息
|
121
|
// ImportCooperationUser 导入共创用户信息
|
122
|
func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
122
|
func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
123
|
- //initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
|
|
|
124
|
- //if err != nil {
|
|
|
125
|
- // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
126
|
- //}
|
|
|
127
|
- //excelImport := excel.NewExcelImport()
|
|
|
128
|
- //excelImport.RowBegin = 2 //第二行开始读取
|
|
|
129
|
- //excelImport.DataFields = []excel.DataField{
|
|
|
130
|
- // {EnName: "UserCode", CnName: "*用户编号"},
|
|
|
131
|
- // {EnName: "UserName", CnName: "*用户姓名"},
|
|
|
132
|
- // {EnName: "CooperationCompany", CnName: "*合伙公司"},
|
|
|
133
|
- // {EnName: "CooperationDeadline", CnName: "*合伙到期"},
|
|
|
134
|
- // {EnName: "Phone", CnName: "*手机号"},
|
|
|
135
|
- // {EnName: "Email", CnName: "邮箱"},
|
|
|
136
|
- //}
|
|
|
137
|
- //excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
|
|
138
|
- //if err != nil {
|
|
|
139
|
- // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
140
|
- //}
|
|
|
141
|
- //users := make([]allied_creation_user.BatchAddUserItem, 0)
|
|
|
142
|
- //var fail int
|
|
|
143
|
- //for _, v := range excelData {
|
|
|
144
|
- // item := allied_creation_user.BatchAddUserItem{
|
|
|
145
|
- // CompanyID: importDataCommand.Operator.CompanyId,
|
|
|
146
|
- // UserType: domain.UserTypeCooperation,
|
|
|
147
|
- // UserCode: v["UserCode"],
|
|
|
148
|
- // OrganizationID: int(importDataCommand.Operator.OrgId),
|
|
|
149
|
- // UserInfo: allied_creation_user.BatchAddUserItemUserInfo{
|
|
|
150
|
- // UserName: v["UserName"],
|
|
|
151
|
- // Phone: v["Phone"],
|
|
|
152
|
- // Email: v["Email"],
|
|
|
153
|
- // },
|
|
|
154
|
- // CooperationInfo: allied_creation_user.BatchAddUserItemCooperationInfo{
|
|
|
155
|
- // CooperationCompany: v["CooperationCompany"],
|
|
|
156
|
- // },
|
|
|
157
|
- // }
|
|
|
158
|
- // item.CooperationInfo.CooperationDeadline, err = time.Parse("2006-01-02", v["CooperationDeadline"])
|
|
|
159
|
- // if err != nil {
|
|
|
160
|
- // fail++
|
|
|
161
|
- // continue
|
|
|
162
|
- // }
|
|
|
163
|
- // users = append(users, item)
|
|
|
164
|
- //}
|
|
|
165
|
- //userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
|
|
166
|
- //result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
|
|
|
167
|
- // Users: users,
|
|
|
168
|
- // Password: initPassword,
|
|
|
169
|
- //})
|
|
|
170
|
- //if err != nil {
|
|
|
171
|
- // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
172
|
- //}
|
|
|
173
|
- //return result, nil
|
|
|
174
|
- return nil, nil
|
123
|
+ initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
|
|
|
124
|
+ if err != nil {
|
|
|
125
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
126
|
+ }
|
|
|
127
|
+ userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
|
|
128
|
+ orgResult, err := userGateway.OrgGet(allied_creation_user.ReqOrgGet{
|
|
|
129
|
+ OrgId: int(importDataCommand.Operator.OrgId),
|
|
|
130
|
+ })
|
|
|
131
|
+ if err != nil {
|
|
|
132
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
133
|
+ }
|
|
|
134
|
+ excelImport := excel.NewExcelImport()
|
|
|
135
|
+ excelImport.RowBegin = 3 //第二行开始读取
|
|
|
136
|
+ excelImport.DataFields = []excel.DataField{
|
|
|
137
|
+ {EnName: "userCode", CnName: "*用户编码"},
|
|
|
138
|
+ {EnName: "userName", CnName: "*用户姓名"},
|
|
|
139
|
+ {EnName: "cooperationCompany", CnName: "*合伙公司"},
|
|
|
140
|
+ {EnName: "cooperationDeadline", CnName: "*合伙到期"},
|
|
|
141
|
+ {EnName: "enableStatus", CnName: "*用户状态"},
|
|
|
142
|
+ {EnName: "phone", CnName: "*手机号"},
|
|
|
143
|
+ {EnName: "email", CnName: "邮箱"},
|
|
|
144
|
+ }
|
|
|
145
|
+ excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
|
|
146
|
+ if err != nil {
|
|
|
147
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
148
|
+ }
|
|
|
149
|
+ users := make([]allied_creation_user.BatchAddUserItem, 0)
|
|
|
150
|
+ for _, v := range excelData {
|
|
|
151
|
+ if srv.fieldValueAllEmpty(v) {
|
|
|
152
|
+ continue
|
|
|
153
|
+ }
|
|
|
154
|
+ item := allied_creation_user.BatchAddUserItem{
|
|
|
155
|
+ CompanyId: importDataCommand.Operator.CompanyId,
|
|
|
156
|
+ UserType: domain.UserTypeCooperation,
|
|
|
157
|
+ UserCode: v["userCode"],
|
|
|
158
|
+ Org: orgResult.OrgCode,
|
|
|
159
|
+ UserName: strings.TrimSpace(v["userName"]),
|
|
|
160
|
+ Phone: strings.TrimSpace(v["phone"]),
|
|
|
161
|
+ Email: strings.TrimSpace(v["email"]),
|
|
|
162
|
+ EnableStatus: strings.TrimSpace(v["enableStatus"]),
|
|
|
163
|
+ CooperationCompany: v["cooperationCompany"],
|
|
|
164
|
+ CooperationDeadline: v["cooperationDeadline"],
|
|
|
165
|
+ }
|
|
|
166
|
+ users = append(users, item)
|
|
|
167
|
+ }
|
|
|
168
|
+
|
|
|
169
|
+ result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
|
|
|
170
|
+ Users: users,
|
|
|
171
|
+ Password: initPassword,
|
|
|
172
|
+ })
|
|
|
173
|
+ if err != nil {
|
|
|
174
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
175
|
+ }
|
|
|
176
|
+ return srv.importResultWithHeader(excelImport.DataFields, result.FailRows, len(users)), nil
|
175
|
}
|
177
|
}
|
176
|
|
178
|
|
177
|
// ImportCompanyUser 导入公司用户信息
|
179
|
// ImportCompanyUser 导入公司用户信息
|
|
@@ -197,21 +199,19 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
@@ -197,21 +199,19 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
197
|
}
|
199
|
}
|
198
|
users := make([]allied_creation_user.BatchAddUserItem, 0)
|
200
|
users := make([]allied_creation_user.BatchAddUserItem, 0)
|
199
|
for _, v := range excelData {
|
201
|
for _, v := range excelData {
|
|
|
202
|
+ if srv.fieldValueAllEmpty(v) {
|
|
|
203
|
+ continue
|
|
|
204
|
+ }
|
200
|
item := allied_creation_user.BatchAddUserItem{
|
205
|
item := allied_creation_user.BatchAddUserItem{
|
201
|
CompanyId: importDataCommand.Operator.CompanyId,
|
206
|
CompanyId: importDataCommand.Operator.CompanyId,
|
202
|
UserType: domain.UserTypeEmployee,
|
207
|
UserType: domain.UserTypeEmployee,
|
203
|
- UserCode: v["userCode"],
|
|
|
204
|
- Org: v["org"],
|
|
|
205
|
- Department: v["department"],
|
|
|
206
|
- UserName: v["userName"],
|
|
|
207
|
- Phone: v["phone"],
|
|
|
208
|
- Email: v["email"],
|
|
|
209
|
- EnableStatus: domain.UserStatusEnable,
|
|
|
210
|
- }
|
|
|
211
|
- if status, ok := v["status"]; ok {
|
|
|
212
|
- if strings.TrimSpace(status) != "启用" {
|
|
|
213
|
- item.EnableStatus = domain.UserStatusDisable
|
|
|
214
|
- }
|
208
|
+ UserCode: strings.TrimSpace(v["userCode"]),
|
|
|
209
|
+ Org: strings.TrimSpace(v["org"]),
|
|
|
210
|
+ Department: strings.TrimSpace(v["department"]),
|
|
|
211
|
+ UserName: strings.TrimSpace(v["userName"]),
|
|
|
212
|
+ Phone: strings.TrimSpace(v["phone"]),
|
|
|
213
|
+ Email: strings.TrimSpace(v["email"]),
|
|
|
214
|
+ EnableStatus: strings.TrimSpace(v["enableStatus"]),
|
215
|
}
|
215
|
}
|
216
|
users = append(users, item)
|
216
|
users = append(users, item)
|
217
|
}
|
217
|
}
|
|
@@ -223,7 +223,7 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
@@ -223,7 +223,7 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
223
|
if err != nil {
|
223
|
if err != nil {
|
224
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
224
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
225
|
}
|
225
|
}
|
226
|
- return srv.importResultWithHeader(excelImport.DataFields, result.FailRows, len(excelData)), nil
|
226
|
+ return srv.importResultWithHeader(excelImport.DataFields, result.FailRows, len(users)), nil
|
227
|
}
|
227
|
}
|
228
|
|
228
|
|
229
|
func (srv ExcelDataService) ImportOrganization(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
229
|
func (srv ExcelDataService) ImportOrganization(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
|
@@ -240,6 +240,9 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import |
|
@@ -240,6 +240,9 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import |
240
|
}
|
240
|
}
|
241
|
items := make([]allied_creation_user.BatchAddOrgItem, 0)
|
241
|
items := make([]allied_creation_user.BatchAddOrgItem, 0)
|
242
|
for _, v := range excelData {
|
242
|
for _, v := range excelData {
|
|
|
243
|
+ if srv.fieldValueAllEmpty(v) {
|
|
|
244
|
+ continue
|
|
|
245
|
+ }
|
243
|
item := allied_creation_user.BatchAddOrgItem{
|
246
|
item := allied_creation_user.BatchAddOrgItem{
|
244
|
CompanyId: importDataCommand.Operator.CompanyId,
|
247
|
CompanyId: importDataCommand.Operator.CompanyId,
|
245
|
OrgCode: v["orgCode"],
|
248
|
OrgCode: v["orgCode"],
|
|
@@ -255,7 +258,7 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import |
|
@@ -255,7 +258,7 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import |
255
|
if err != nil {
|
258
|
if err != nil {
|
256
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
259
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
257
|
}
|
260
|
}
|
258
|
- return srv.importResultWithHeader(excelImport.DataFields, result.FailRows, len(excelData)), nil
|
261
|
+ return srv.importResultWithHeader(excelImport.DataFields, result.FailRows, len(items)), nil
|
259
|
}
|
262
|
}
|
260
|
|
263
|
|
261
|
// 导入结果
|
264
|
// 导入结果
|
|
@@ -282,15 +285,25 @@ func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, fa |
|
@@ -282,15 +285,25 @@ func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, fa |
282
|
return result
|
285
|
return result
|
283
|
}
|
286
|
}
|
284
|
|
287
|
|
|
|
288
|
+func (srv ExcelDataService) fieldValueAllEmpty(param map[string]string) bool {
|
|
|
289
|
+ isAllEmpty := true
|
|
|
290
|
+ for _, v := range param {
|
|
|
291
|
+ value := strings.TrimSpace(v)
|
|
|
292
|
+ if len(value) > 0 {
|
|
|
293
|
+ isAllEmpty = false
|
|
|
294
|
+ }
|
|
|
295
|
+ }
|
|
|
296
|
+ return isAllEmpty
|
|
|
297
|
+}
|
|
|
298
|
+
|
285
|
// ImportCompanyUser 导入公司用户信息
|
299
|
// ImportCompanyUser 导入公司用户信息
|
286
|
func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
300
|
func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
287
|
var mapTemplate = map[string]string{
|
301
|
var mapTemplate = map[string]string{
|
288
|
domain.ImportCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807485_EaxECeRz23WpzrMZmbwdEPRJ3Pdxpx5X.xlsx",
|
302
|
domain.ImportCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807485_EaxECeRz23WpzrMZmbwdEPRJ3Pdxpx5X.xlsx",
|
289
|
domain.ImportOrganization: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807490_r2XWhGmbWWmpbeePBkZ3EJQFKcZEMpEm.xlsx",
|
303
|
domain.ImportOrganization: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807490_r2XWhGmbWWmpbeePBkZ3EJQFKcZEMpEm.xlsx",
|
290
|
- domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807770_sBtA4dYcmESZy6Q2ycfGSCKGdFtBETQZ.xlsx",
|
|
|
291
|
- // 模板待更新
|
|
|
292
|
- domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
|
|
|
293
|
- domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
|
304
|
+ domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210917/object/1631843469_DykNwexeYYtzxzbwsER5RrzCS7QRwGmd.xlsx",
|
|
|
305
|
+ domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210918/object/1631932960_fen6RZS7ZesyDPMzXactKKCenhRMkfRb.xlsx",
|
|
|
306
|
+ domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210918/object/1631933214_MbTxsQtnEEMprHADFR6MedfZBkxYWBYA.xlsx",
|
294
|
}
|
307
|
}
|
295
|
var url string
|
308
|
var url string
|
296
|
var ok bool
|
309
|
var ok bool
|