|
@@ -9,8 +9,7 @@ import ( |
|
@@ -9,8 +9,7 @@ import ( |
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/domainService"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/domainService"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
|
12
|
- "strconv"
|
|
|
13
|
- "time"
|
12
|
+ "strings"
|
14
|
)
|
13
|
)
|
15
|
|
14
|
|
16
|
type ExcelDataService struct {
|
15
|
type ExcelDataService struct {
|
|
@@ -61,6 +60,120 @@ func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.Co |
|
@@ -61,6 +60,120 @@ func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.Co |
61
|
}
|
60
|
}
|
62
|
|
61
|
|
63
|
// ImportCompanyUser 导入公司用户信息
|
62
|
// ImportCompanyUser 导入公司用户信息
|
|
|
63
|
+func (srv ExcelDataService) ImportCompanyUser2(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
|
|
64
|
+ //initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
|
|
|
65
|
+ //if err != nil {
|
|
|
66
|
+ // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
67
|
+ //}
|
|
|
68
|
+ //excelImport := excel.NewExcelImport()
|
|
|
69
|
+ //excelImport.RowBegin = 2 //第二行开始读取
|
|
|
70
|
+ //excelImport.DataFields = []excel.DataField{
|
|
|
71
|
+ // {EnName: "UserCode", CnName: "*用户编号"},
|
|
|
72
|
+ // {EnName: "UserName", CnName: "*用户姓名"},
|
|
|
73
|
+ // {EnName: "OrganizationID", CnName: "*组织机构"},
|
|
|
74
|
+ // {EnName: "DepartmentID", CnName: "*所属部门"},
|
|
|
75
|
+ // {EnName: "Phone", CnName: "*手机号"},
|
|
|
76
|
+ // {EnName: "Email", CnName: "邮箱"},
|
|
|
77
|
+ // {EnName: "Status", CnName: "状态"},
|
|
|
78
|
+ //}
|
|
|
79
|
+ //excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
|
|
80
|
+ //if err != nil {
|
|
|
81
|
+ // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
82
|
+ //}
|
|
|
83
|
+ //users := make([]allied_creation_user.BatchAddUserItem, 0)
|
|
|
84
|
+ //for _, v := range excelData {
|
|
|
85
|
+ // item := allied_creation_user.BatchAddUserItem{
|
|
|
86
|
+ // CompanyID: importDataCommand.Operator.CompanyId,
|
|
|
87
|
+ // UserType: domain.UserTypeEmployee,
|
|
|
88
|
+ // UserCode: v["UserCode"],
|
|
|
89
|
+ // OrganizationID: 0,
|
|
|
90
|
+ // DepartmentID: 0,
|
|
|
91
|
+ // UserInfo: allied_creation_user.BatchAddUserItemUserInfo{
|
|
|
92
|
+ // UserName: v["UserName"],
|
|
|
93
|
+ // Phone: v["Phone"],
|
|
|
94
|
+ // Email: v["Email"],
|
|
|
95
|
+ // },
|
|
|
96
|
+ // CooperationInfo: allied_creation_user.BatchAddUserItemCooperationInfo{},
|
|
|
97
|
+ // }
|
|
|
98
|
+ // item.OrganizationID, err = strconv.Atoi(v["OrganizationID"])
|
|
|
99
|
+ // if err != nil {
|
|
|
100
|
+ // return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 组织值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.OrganizationID))
|
|
|
101
|
+ // }
|
|
|
102
|
+ // item.DepartmentID, err = strconv.Atoi(v["DepartmentID"])
|
|
|
103
|
+ // if err != nil {
|
|
|
104
|
+ // return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 部门值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.DepartmentID))
|
|
|
105
|
+ // }
|
|
|
106
|
+ // users = append(users, item)
|
|
|
107
|
+ //}
|
|
|
108
|
+ //userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
|
|
109
|
+ //result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
|
|
|
110
|
+ // Users: users,
|
|
|
111
|
+ // Password: initPassword,
|
|
|
112
|
+ //})
|
|
|
113
|
+ //if err != nil {
|
|
|
114
|
+ // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
115
|
+ //}
|
|
|
116
|
+ //return result, nil
|
|
|
117
|
+ return nil, nil
|
|
|
118
|
+}
|
|
|
119
|
+
|
|
|
120
|
+// ImportCooperationUser 导入共创用户信息
|
|
|
121
|
+func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
|
|
122
|
+ //initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
|
|
|
123
|
+ //if err != nil {
|
|
|
124
|
+ // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
125
|
+ //}
|
|
|
126
|
+ //excelImport := excel.NewExcelImport()
|
|
|
127
|
+ //excelImport.RowBegin = 2 //第二行开始读取
|
|
|
128
|
+ //excelImport.DataFields = []excel.DataField{
|
|
|
129
|
+ // {EnName: "UserCode", CnName: "*用户编号"},
|
|
|
130
|
+ // {EnName: "UserName", CnName: "*用户姓名"},
|
|
|
131
|
+ // {EnName: "CooperationCompany", CnName: "*合伙公司"},
|
|
|
132
|
+ // {EnName: "CooperationDeadline", CnName: "*合伙到期"},
|
|
|
133
|
+ // {EnName: "Phone", CnName: "*手机号"},
|
|
|
134
|
+ // {EnName: "Email", CnName: "邮箱"},
|
|
|
135
|
+ //}
|
|
|
136
|
+ //excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
|
|
137
|
+ //if err != nil {
|
|
|
138
|
+ // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
139
|
+ //}
|
|
|
140
|
+ //users := make([]allied_creation_user.BatchAddUserItem, 0)
|
|
|
141
|
+ //var fail int
|
|
|
142
|
+ //for _, v := range excelData {
|
|
|
143
|
+ // item := allied_creation_user.BatchAddUserItem{
|
|
|
144
|
+ // CompanyID: importDataCommand.Operator.CompanyId,
|
|
|
145
|
+ // UserType: domain.UserTypeCooperation,
|
|
|
146
|
+ // UserCode: v["UserCode"],
|
|
|
147
|
+ // OrganizationID: int(importDataCommand.Operator.OrgId),
|
|
|
148
|
+ // UserInfo: allied_creation_user.BatchAddUserItemUserInfo{
|
|
|
149
|
+ // UserName: v["UserName"],
|
|
|
150
|
+ // Phone: v["Phone"],
|
|
|
151
|
+ // Email: v["Email"],
|
|
|
152
|
+ // },
|
|
|
153
|
+ // CooperationInfo: allied_creation_user.BatchAddUserItemCooperationInfo{
|
|
|
154
|
+ // CooperationCompany: v["CooperationCompany"],
|
|
|
155
|
+ // },
|
|
|
156
|
+ // }
|
|
|
157
|
+ // item.CooperationInfo.CooperationDeadline, err = time.Parse("2006-01-02", v["CooperationDeadline"])
|
|
|
158
|
+ // if err != nil {
|
|
|
159
|
+ // fail++
|
|
|
160
|
+ // continue
|
|
|
161
|
+ // }
|
|
|
162
|
+ // users = append(users, item)
|
|
|
163
|
+ //}
|
|
|
164
|
+ //userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
|
|
165
|
+ //result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
|
|
|
166
|
+ // Users: users,
|
|
|
167
|
+ // Password: initPassword,
|
|
|
168
|
+ //})
|
|
|
169
|
+ //if err != nil {
|
|
|
170
|
+ // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
171
|
+ //}
|
|
|
172
|
+ //return result, nil
|
|
|
173
|
+ return nil, nil
|
|
|
174
|
+}
|
|
|
175
|
+
|
|
|
176
|
+// ImportCompanyUser 导入公司用户信息
|
64
|
func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
177
|
func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
65
|
initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
|
178
|
initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
|
66
|
if err != nil {
|
179
|
if err != nil {
|
|
@@ -71,8 +184,8 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
@@ -71,8 +184,8 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
71
|
excelImport.DataFields = []excel.DataField{
|
184
|
excelImport.DataFields = []excel.DataField{
|
72
|
{EnName: "UserCode", CnName: "*用户编号"},
|
185
|
{EnName: "UserCode", CnName: "*用户编号"},
|
73
|
{EnName: "UserName", CnName: "*用户姓名"},
|
186
|
{EnName: "UserName", CnName: "*用户姓名"},
|
74
|
- {EnName: "OrganizationID", CnName: "*组织机构"},
|
|
|
75
|
- {EnName: "DepartmentID", CnName: "*所属部门"},
|
187
|
+ {EnName: "Organization", CnName: "*组织机构"},
|
|
|
188
|
+ {EnName: "Department", CnName: "*所属部门"},
|
76
|
{EnName: "Phone", CnName: "*手机号"},
|
189
|
{EnName: "Phone", CnName: "*手机号"},
|
77
|
{EnName: "Email", CnName: "邮箱"},
|
190
|
{EnName: "Email", CnName: "邮箱"},
|
78
|
{EnName: "Status", CnName: "状态"},
|
191
|
{EnName: "Status", CnName: "状态"},
|
|
@@ -84,25 +197,20 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
@@ -84,25 +197,20 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
84
|
users := make([]allied_creation_user.BatchAddUserItem, 0)
|
197
|
users := make([]allied_creation_user.BatchAddUserItem, 0)
|
85
|
for _, v := range excelData {
|
198
|
for _, v := range excelData {
|
86
|
item := allied_creation_user.BatchAddUserItem{
|
199
|
item := allied_creation_user.BatchAddUserItem{
|
87
|
- CompanyID: importDataCommand.Operator.CompanyId,
|
|
|
88
|
- UserType: domain.UserTypeEmployee,
|
|
|
89
|
- UserCode: v["UserCode"],
|
|
|
90
|
- OrganizationID: 0,
|
|
|
91
|
- DepartmentID: 0,
|
|
|
92
|
- UserInfo: allied_creation_user.BatchAddUserItemUserInfo{
|
|
|
93
|
- UserName: v["UserName"],
|
|
|
94
|
- Phone: v["Phone"],
|
|
|
95
|
- Email: v["Email"],
|
|
|
96
|
- },
|
|
|
97
|
- CooperationInfo: allied_creation_user.BatchAddUserItemCooperationInfo{},
|
200
|
+ CompanyId: importDataCommand.Operator.CompanyId,
|
|
|
201
|
+ UserType: domain.UserTypeEmployee,
|
|
|
202
|
+ UserCode: v["UserCode"],
|
|
|
203
|
+ Org: v["Organization"],
|
|
|
204
|
+ Department: v["Department"],
|
|
|
205
|
+ UserName: v["UserName"],
|
|
|
206
|
+ Phone: v["Phone"],
|
|
|
207
|
+ Email: v["Email"],
|
|
|
208
|
+ EnableStatus: domain.UserStatusEnable,
|
98
|
}
|
209
|
}
|
99
|
- item.OrganizationID, err = strconv.Atoi(v["OrganizationID"])
|
|
|
100
|
- if err != nil {
|
|
|
101
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 组织值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.OrganizationID))
|
|
|
102
|
- }
|
|
|
103
|
- item.DepartmentID, err = strconv.Atoi(v["DepartmentID"])
|
|
|
104
|
- if err != nil {
|
|
|
105
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 部门值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.DepartmentID))
|
210
|
+ if status, ok := v["Status"]; ok {
|
|
|
211
|
+ if strings.TrimSpace(status) != "启用" {
|
|
|
212
|
+ item.EnableStatus = domain.UserStatusDisable
|
|
|
213
|
+ }
|
106
|
}
|
214
|
}
|
107
|
users = append(users, item)
|
215
|
users = append(users, item)
|
108
|
}
|
216
|
}
|
|
@@ -117,54 +225,31 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
@@ -117,54 +225,31 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
117
|
return result, nil
|
225
|
return result, nil
|
118
|
}
|
226
|
}
|
119
|
|
227
|
|
120
|
-// ImportCooperationUser 导入共创用户信息
|
|
|
121
|
-func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
|
|
122
|
- initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
|
|
|
123
|
- if err != nil {
|
|
|
124
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
125
|
- }
|
228
|
+func (srv ExcelDataService) ImportOrganization(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
126
|
excelImport := excel.NewExcelImport()
|
229
|
excelImport := excel.NewExcelImport()
|
127
|
excelImport.RowBegin = 2 //第二行开始读取
|
230
|
excelImport.RowBegin = 2 //第二行开始读取
|
128
|
excelImport.DataFields = []excel.DataField{
|
231
|
excelImport.DataFields = []excel.DataField{
|
129
|
- {EnName: "UserCode", CnName: "*用户编号"},
|
|
|
130
|
- {EnName: "UserName", CnName: "*用户姓名"},
|
|
|
131
|
- {EnName: "CooperationCompany", CnName: "*合伙公司"},
|
|
|
132
|
- {EnName: "CooperationDeadline", CnName: "*合伙到期"},
|
|
|
133
|
- {EnName: "Phone", CnName: "*手机号"},
|
|
|
134
|
- {EnName: "Email", CnName: "邮箱"},
|
232
|
+ {EnName: "OrgCode", CnName: "*部门编码"},
|
|
|
233
|
+ {EnName: "OrgName", CnName: "*部门名称"},
|
|
|
234
|
+ {EnName: "ParentOrgCode", CnName: "*上级部门编码"},
|
135
|
}
|
235
|
}
|
136
|
excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
236
|
excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
137
|
if err != nil {
|
237
|
if err != nil {
|
138
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
238
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
139
|
}
|
239
|
}
|
140
|
- users := make([]allied_creation_user.BatchAddUserItem, 0)
|
|
|
141
|
- var fail int
|
240
|
+ items := make([]allied_creation_user.BatchAddOrgItem, 0)
|
142
|
for _, v := range excelData {
|
241
|
for _, v := range excelData {
|
143
|
- item := allied_creation_user.BatchAddUserItem{
|
|
|
144
|
- CompanyID: importDataCommand.Operator.CompanyId,
|
|
|
145
|
- UserType: domain.UserTypeCooperation,
|
|
|
146
|
- UserCode: v["UserCode"],
|
|
|
147
|
- OrganizationID: int(importDataCommand.Operator.OrgId),
|
|
|
148
|
- UserInfo: allied_creation_user.BatchAddUserItemUserInfo{
|
|
|
149
|
- UserName: v["UserName"],
|
|
|
150
|
- Phone: v["Phone"],
|
|
|
151
|
- Email: v["Email"],
|
|
|
152
|
- },
|
|
|
153
|
- CooperationInfo: allied_creation_user.BatchAddUserItemCooperationInfo{
|
|
|
154
|
- CooperationCompany: v["CooperationCompany"],
|
|
|
155
|
- },
|
|
|
156
|
- }
|
|
|
157
|
- item.CooperationInfo.CooperationDeadline, err = time.Parse("2006-01-02", v["CooperationDeadline"])
|
|
|
158
|
- if err != nil {
|
|
|
159
|
- fail++
|
|
|
160
|
- continue
|
242
|
+ item := allied_creation_user.BatchAddOrgItem{
|
|
|
243
|
+ CompanyId: importDataCommand.Operator.CompanyId,
|
|
|
244
|
+ OrgCode: v["OrgCode"],
|
|
|
245
|
+ OrgName: v["OrgName"],
|
|
|
246
|
+ ParentOrgCode: v["ParentOrgCode"],
|
161
|
}
|
247
|
}
|
162
|
- users = append(users, item)
|
248
|
+ items = append(items, item)
|
163
|
}
|
249
|
}
|
164
|
userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
250
|
userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
165
|
- result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
|
|
|
166
|
- Users: users,
|
|
|
167
|
- Password: initPassword,
|
251
|
+ result, err := userGateway.OrgBatchAdd(allied_creation_user.ReqBatchAddOrg{
|
|
|
252
|
+ OrgList: items,
|
168
|
})
|
253
|
})
|
169
|
if err != nil {
|
254
|
if err != nil {
|
170
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
255
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|