|
@@ -196,3 +196,158 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs |
|
@@ -196,3 +196,158 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs |
196
|
}
|
196
|
}
|
197
|
return &result, nil
|
197
|
return &result, nil
|
198
|
}
|
198
|
}
|
|
|
199
|
+
|
|
|
200
|
+type excelTableHeader struct {
|
|
|
201
|
+ Level1 string
|
|
|
202
|
+ Level2 string
|
|
|
203
|
+ Level3 string
|
|
|
204
|
+ Level4 string
|
|
|
205
|
+}
|
|
|
206
|
+
|
|
|
207
|
+func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCycleDay) ([]byte, error) {
|
|
|
208
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
209
|
+ if err != nil {
|
|
|
210
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
211
|
+ }
|
|
|
212
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
213
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
214
|
+ }
|
|
|
215
|
+ defer func() {
|
|
|
216
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
217
|
+ }()
|
|
|
218
|
+
|
|
|
219
|
+ roleRepo := factory.CreateRoleRepository(map[string]interface{}{
|
|
|
220
|
+ "transactionContext": transactionContext,
|
|
|
221
|
+ })
|
|
|
222
|
+ roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{
|
|
|
223
|
+ "transactionContext": transactionContext,
|
|
|
224
|
+ })
|
|
|
225
|
+ _, roleList, err := roleRepo.Find(map[string]interface{}{
|
|
|
226
|
+ "type": domain.RoleTypeSystem,
|
|
|
227
|
+ "companyId": param.CompanyId,
|
|
|
228
|
+ })
|
|
|
229
|
+ if err != nil {
|
|
|
230
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
|
|
|
231
|
+ }
|
|
|
232
|
+ _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{
|
|
|
233
|
+ "companyId": param.CompanyId,
|
|
|
234
|
+ "userId": param.OperaterId,
|
|
|
235
|
+ })
|
|
|
236
|
+ if err != nil {
|
|
|
237
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
|
|
|
238
|
+ }
|
|
|
239
|
+ hrbp := -1
|
|
|
240
|
+ for _, v := range userRoleList {
|
|
|
241
|
+ for _, v2 := range roleList {
|
|
|
242
|
+ if v.RoleId == v2.Id {
|
|
|
243
|
+ hrbp = 1
|
|
|
244
|
+ break
|
|
|
245
|
+ }
|
|
|
246
|
+ }
|
|
|
247
|
+ if hrbp == 1 {
|
|
|
248
|
+ break
|
|
|
249
|
+ }
|
|
|
250
|
+ }
|
|
|
251
|
+ assessDao := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
252
|
+ "transactionContext": transactionContext,
|
|
|
253
|
+ })
|
|
|
254
|
+ contentList, err := assessDao.ExportDataUserAssess(dao.SearchConditin1{
|
|
|
255
|
+ CompanyId: param.CompanyId,
|
|
|
256
|
+ CycleId: param.CycleId,
|
|
|
257
|
+ BeginDay: param.BeginDay,
|
|
|
258
|
+ TargetUserName: param.TargetUserName,
|
|
|
259
|
+ Limit: 5000,
|
|
|
260
|
+ Offset: 0,
|
|
|
261
|
+ OperaterId: param.OperaterId,
|
|
|
262
|
+ Hrbp: hrbp,
|
|
|
263
|
+ })
|
|
|
264
|
+ if err != nil {
|
|
|
265
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取数据列表"+err.Error())
|
|
|
266
|
+ }
|
|
|
267
|
+
|
|
|
268
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
269
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
270
|
+ }
|
|
|
271
|
+
|
|
|
272
|
+ //处理查询到的数据
|
|
|
273
|
+ //汇总 Excel表格的表头描述
|
|
|
274
|
+ level1 := []string{} //分类
|
|
|
275
|
+ level3 := map[string][]string{} // key=分类+得分项类型 val=名称
|
|
|
276
|
+ level4 := map[string]string{} //key=分类+名称 val=评估标准
|
|
|
277
|
+ for _, v := range contentList {
|
|
|
278
|
+ level1Item := ""
|
|
|
279
|
+ for _, v1 := range level1 {
|
|
|
280
|
+ if v.Category == v1 {
|
|
|
281
|
+ level1Item = v1
|
|
|
282
|
+ }
|
|
|
283
|
+ }
|
|
|
284
|
+ if len(level1Item) == 0 {
|
|
|
285
|
+ level1 = append(level1, v.Category)
|
|
|
286
|
+ }
|
|
|
287
|
+ if v.Weight == 0 {
|
|
|
288
|
+ level3Key := v.Category + "-加分项"
|
|
|
289
|
+ if _, ok := level3[level3Key]; !ok {
|
|
|
290
|
+ level3[level3Key] = []string{}
|
|
|
291
|
+ }
|
|
|
292
|
+ level3Item := ""
|
|
|
293
|
+ for _, v3 := range level3[level3Key] {
|
|
|
294
|
+ if v3 == v.ContentName {
|
|
|
295
|
+ level3Item = v.ContentName
|
|
|
296
|
+ }
|
|
|
297
|
+ }
|
|
|
298
|
+ if len(level3Item) == 0 {
|
|
|
299
|
+ level3[level3Key] = append(level3[level3Key], v.ContentName)
|
|
|
300
|
+ }
|
|
|
301
|
+ }
|
|
|
302
|
+ if v.Weight > 0 {
|
|
|
303
|
+ level3Key := v.Category + "-得分项"
|
|
|
304
|
+ if _, ok := level3[level3Key]; !ok {
|
|
|
305
|
+ level3[level3Key] = []string{}
|
|
|
306
|
+ }
|
|
|
307
|
+ level3Item := ""
|
|
|
308
|
+ for _, v3 := range level3[level3Key] {
|
|
|
309
|
+ if v3 == v.ContentName {
|
|
|
310
|
+ level3Item = v.ContentName
|
|
|
311
|
+ }
|
|
|
312
|
+ }
|
|
|
313
|
+ if len(level3Item) == 0 {
|
|
|
314
|
+ level3[level3Key] = append(level3[level3Key], v.ContentName)
|
|
|
315
|
+ }
|
|
|
316
|
+ }
|
|
|
317
|
+
|
|
|
318
|
+ level4Key := v.Category + "+" + v.ContentName
|
|
|
319
|
+ if _, ok := level4[level4Key]; !ok {
|
|
|
320
|
+ level4[level4Key] = v.PromptText
|
|
|
321
|
+ }
|
|
|
322
|
+ }
|
|
|
323
|
+ //汇总表头
|
|
|
324
|
+ headerList := []excelTableHeader{}
|
|
|
325
|
+ for _, v := range level1 {
|
|
|
326
|
+ item := excelTableHeader{
|
|
|
327
|
+ Level1: v,
|
|
|
328
|
+ }
|
|
|
329
|
+ level3Key := v + "-加分项"
|
|
|
330
|
+ if _, ok := level3[level3Key]; ok {
|
|
|
331
|
+ for _, v2 := range level3[level3Key] {
|
|
|
332
|
+ item.Level2 = "加分项"
|
|
|
333
|
+ item.Level3 = v2
|
|
|
334
|
+ level4Key := v + "+" + v2
|
|
|
335
|
+ item.Level4 = level4[level4Key]
|
|
|
336
|
+ headerList = append(headerList, item)
|
|
|
337
|
+ }
|
|
|
338
|
+ }
|
|
|
339
|
+ level3Key = v + "-得分项"
|
|
|
340
|
+ if _, ok := level3[level3Key]; ok {
|
|
|
341
|
+ for _, v2 := range level3[level3Key] {
|
|
|
342
|
+ item.Level2 = "得分项"
|
|
|
343
|
+ item.Level3 = v2
|
|
|
344
|
+ level4Key := v + "+" + v2
|
|
|
345
|
+ item.Level4 = level4[level4Key]
|
|
|
346
|
+ headerList = append(headerList, item)
|
|
|
347
|
+ }
|
|
|
348
|
+ }
|
|
|
349
|
+ }
|
|
|
350
|
+ //
|
|
|
351
|
+ // tab
|
|
|
352
|
+ return nil, nil
|
|
|
353
|
+} |