刘光辉
14 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
package jnpf.base.controller;
 
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
import jnpf.base.Pagination;
import jnpf.base.SystemApi;
import jnpf.base.UserInfo;
import jnpf.base.entity.ModuleEntity;
import jnpf.base.entity.PrintDevEntity;
import jnpf.base.entity.SystemEntity;
import jnpf.base.entity.SystemTopEntity;
import jnpf.base.model.AppAuthorizationModel;
import jnpf.base.model.AppAuthorizeVo;
import jnpf.base.model.UserAuthorize;
import jnpf.base.model.base.*;
import jnpf.base.model.export.*;
import jnpf.base.model.module.MenuListModel;
import jnpf.base.service.*;
import jnpf.base.util.ReportExportUtil;
import jnpf.base.vo.DownloadVO;
import jnpf.base.vo.ListVO;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.constant.FileTypeConstant;
import jnpf.constant.JnpfConst;
import jnpf.constant.MsgCode;
import jnpf.constant.PermissionConst;
import jnpf.constant.model.MCode;
import jnpf.emnus.ModuleTypeEnum;
import jnpf.emnus.SysParamEnum;
import jnpf.exception.DataException;
import jnpf.file.FileApi;
import jnpf.flowable.TemplateApi;
import jnpf.message.NoticeApi;
import jnpf.model.BaseSystemInfo;
import jnpf.model.ExportModel;
import jnpf.onlinedev.VisualdevOnlineApi;
import jnpf.permission.AuthorizeApi;
import jnpf.permission.RoleApi;
import jnpf.permission.RoleRelationApi;
import jnpf.permission.UserApi;
import jnpf.permission.entity.RoleEntity;
import jnpf.permission.entity.RoleRelationEntity;
import jnpf.permission.entity.UserEntity;
import jnpf.permission.model.authorize.AuthorizeVO;
import jnpf.permission.model.rolerelaiton.RoleRelationModel;
import jnpf.permission.model.user.UserSystemCountModel;
import jnpf.permission.model.user.WorkHandoverModel;
import jnpf.permission.model.user.vo.BaseInfoVo;
import jnpf.portal.PortalApi;
import jnpf.util.*;
import jnpf.visualdata.VisualScreenApi;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * 应用中心
 *
 * @author :JNPF开发平台组
 * @version: V3.1.0
 * @copyright 引迈信息技术有限公司
 * @date :2022/6/21 15:33
 */
@Slf4j
@Tag(name = "应用中心", description = "system")
@RestController
@RequestMapping("/System")
@RequiredArgsConstructor
public class SystemController extends SuperController<SystemService, SystemEntity> implements SystemApi {
 
   
    private final  RoleApi roleService;
   
    private final  RoleRelationApi roleRelationService;
   
    private final  UserApi userService;
   
    private final  SystemService systemService;
   
    private final  CommonWordsService commonWordsService;
   
    private final  ModuleService moduleService;
   
    private final  AuthorizeApi authorizeService;
   
    private  final SystemTopService systemTopService;
 
   
    private  final FileApi fileApi;
   
    private  final VisualdevOnlineApi visualdevApi;
   
    private final  PortalApi portalApi;
   
    private final  ReportExportUtil reportExportUtil;
   
    private  final PrintDevService printDevService;
   
    private final  VisualScreenApi visualScreenApi;
   
    private final  TemplateApi templateApi;
   
    private  final SysconfigService sysconfigApi;
 
    private final NoticeApi noticeApi;
 
    @Operation(summary = "应用列表")
    @SaCheckPermission(value = {"appCenter", "workFlow.flowQuickLaunch", "teamwork.printTemplate", "monitor.flowMonitor", "monitor.userOnline"}, mode = SaMode.OR)
    @GetMapping
    public ActionResult<ListVO<SystemListVO>> list(SystemPageVO page) {
        List<SystemEntity> list = systemService.getList(page);
        List<SystemListVO> jsonToList = JsonUtil.getJsonToList(list, SystemListVO.class);
        //根据置顶排序
        List<String> topList = systemTopService.getObjectIdList(JnpfConst.SYS_APP_CENTER, getCurStand());
        jsonToList = TopSortUtil.sortByTopIds(jsonToList, topList, SystemListVO::getId);
        //有修改权限列表
        List<String> authList = systemService.getAuthListByUser(UserProvider.getUser().getUserId(), true).stream().map(SystemEntity::getId).collect(Collectors.toList());
        UserInfo user = UserProvider.getUser();
        for (SystemListVO vo : jsonToList) {
            vo.setHasDelete(Boolean.TRUE.equals(user.getIsAdministrator()) || user.getUserId().equals(vo.getUserId()) ? 1 : 0);
            vo.setHasUpdate(Boolean.TRUE.equals(user.getIsAdministrator()) || authList.contains(vo.getId()) ? 1 : 0);
            if (topList.contains(vo.getId())) {
                vo.setIsTop(true);
            }
        }
        return ActionResult.success(new ListVO<>(jsonToList));
    }
 
    @Operation(summary = "获取应用授权信息")
    @SaCheckPermission(value = {"appConfig.appAuth"})
    @GetMapping("/getAppAuthorization/{systemId}")
    public ActionResult<AppAuthorizeVo> getAppAuthorization(@PathVariable String systemId) {
        Pagination pagination = new Pagination();
        AppAuthorizeVo appAuthorizeVo = new AppAuthorizeVo();
        SystemEntity info = systemService.getInfo(systemId);
        if (BeanUtil.isEmpty(info)) {
            return ActionResult.fail(MsgCode.FA001.getDesc());
        }
        String userId = "";
        String authorizeId = "";
        List<BaseInfoVo> baseInfoVos ;
        if (null == info.getUserId() || info.getUserId().isEmpty()) {
            appAuthorizeVo.setDevUsers(new ArrayList<>());
            appAuthorizeVo.setIsAllDevUser(1);
            appAuthorizeVo.setCreateUserId(info.getCreatorUserId());
            return ActionResult.success(appAuthorizeVo);
        } else {
            userId = info.getUserId();
            List<String> strings = new ArrayList<>();
            strings.add(userId);
            baseInfoVos = getBaseInfoVos(pagination, strings);
            List<UserAuthorize> userAuthorizes = baseInfoVos.stream()
                    .map(item -> BeanUtil.copyProperties(item, UserAuthorize.class)).collect(Collectors.toList());
            appAuthorizeVo.setCreateUserId(userAuthorizes.get(0).getId());
            appAuthorizeVo.setFullName(baseInfoVos.get(0).getFullName());
        }
 
 
        if (null == info.getAuthorizeId()) {
 
            appAuthorizeVo.setDevUsers(new ArrayList<>());
            appAuthorizeVo.setIsAllDevUser(0);
            return ActionResult.success(appAuthorizeVo);
        }
        authorizeId = info.getAuthorizeId();
 
        if (PermissionConst.ALL_DEV_USER.equals(authorizeId)) {
            List<String> collect = getUserIdListByRoleId();
            baseInfoVos = getBaseInfoVos(pagination, collect);
            appAuthorizeVo.setIsAllDevUser(1);
        } else {
            String[] split = authorizeId.split(",");
            List<String> collect = Arrays.stream(split).distinct().collect(Collectors.toList());
            baseInfoVos = getBaseInfoVos(pagination, collect);
            appAuthorizeVo.setIsAllDevUser(0);
        }
 
        List<UserAuthorize> userAuthorizes = baseInfoVos.stream()
                .map(item -> BeanUtil.copyProperties(item, UserAuthorize.class)).collect(Collectors.toList());
        appAuthorizeVo.setDevUsers(userAuthorizes.stream().map(UserAuthorize::getId).collect(Collectors.toList()));
        return ActionResult.success(appAuthorizeVo);
    }
 
    @Operation(summary = "保存应用授权信息")
    @SaCheckPermission(value = {"appConfig.appAuth"})
    @PostMapping("/saveAppAuthorization")
    public ActionResult<MCode> appAuthorization(@RequestBody AppAuthorizationModel model) {
        systemService.saveSystemAuthorizion(model);
        return ActionResult.success(MsgCode.SU005.get());
    }
 
    @Operation(summary = "移交应用创建者")
    @SaCheckPermission(value = {"appConfig.appAuth"})
    @PostMapping("/changeAppAuthorization")
    public ActionResult<MCode> changeAppAuthorization(@RequestBody AppAuthorizationModel model) {
        systemService.changeSystemAuthorizion(model);
        return ActionResult.success(MsgCode.SU005.get());
    }
 
    @Operation(summary = "获取开发人员")
    @SaCheckPermission(value = {"appConfig.appAuth", "permission.user"}, mode = SaMode.OR)
    @GetMapping("/getDevUser")
    public ActionResult<PageListVO<BaseInfoVo>> getDevRole(Pagination pagination) {
        List<String> collect = getUserIdListByRoleId();
        List<BaseInfoVo> baseInfoVoList = getBaseInfoVos(pagination, collect, true);
        PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
 
        return ActionResult.page(baseInfoVoList, paginationVO);
    }
 
    /**
     * 根据开发者角色获取用户id集合
     *
     * @return 返回用户id集合
     */
    private @NotNull List<String> getUserIdListByRoleId() {
        List<RoleEntity> listAll = roleService.getListAll();
        List<RoleEntity> list = listAll.stream().filter(t -> PermissionConst.DEVELOPER_CODE.equals(t.getEnCode())).collect(Collectors.toList());
        String id = list.get(0).getId();
        //获取用户id集合
        return roleRelationService.getListByRoleId(new RoleRelationModel(null, PermissionConst.USER, Arrays.asList(id)))
                .stream()
                .map(RoleRelationEntity::getObjectId)
                .collect(Collectors.toList());
    }
 
    /**
     * 根据关键词查询用户信息
     *
     * @param pagination 关键词
     * @param collect    用户id集合
     * @return 用户信息集合
     */
    private @NotNull List<BaseInfoVo> getBaseInfoVos(Pagination pagination, List<String> collect) {
        return getBaseInfoVos(pagination, collect, false);
    }
 
    private @NotNull List<BaseInfoVo> getBaseInfoVos(Pagination pagination, List<String> collect, Boolean filter) {
        if (CollectionUtils.isEmpty(collect)) {
            return Collections.emptyList();
        }
        List<UserEntity> entities = userService.pageUser(new UserSystemCountModel(pagination, filter, collect));
        if (CollectionUtils.isEmpty(entities)) {
            return Collections.emptyList();
        }
        return entities.stream()
                .map(item -> {
                    BaseInfoVo vo = JsonUtil.getJsonToBean(item, BaseInfoVo.class);
                    vo.setType(SysParamEnum.USER.getCode());
                    vo.setHeadIcon(UploaderUtil.uploaderImg(vo.getHeadIcon()));
                    vo.setFullName(vo.getRealName() + "/" + vo.getAccount());
                    return vo;
                }).collect(Collectors.toList());
    }
 
 
    @Operation(summary = "应用基础设置详情")
    @Parameter(name = "id", description = "主键", required = true)
    @SaCheckPermission(value = {"appConfig.baseConfig"})
    @GetMapping("/{id}")
    public ActionResult<SystemVO> info(@PathVariable("id") String id) {
        SystemEntity entity = systemService.getInfo(id);
        if (entity == null) {
            return ActionResult.fail(MsgCode.FA001.get());
        }
        SystemVO jsonToBean = JsonUtil.getJsonToBean(entity, SystemVO.class);
        return ActionResult.success(jsonToBean);
    }
 
    @Operation(summary = "应用主题配置保存")
     @Parameter(name = "id", description = "主键", required = true)
    @SaCheckPermission(value = {"appConfig.baseConfig"})
    @PostMapping("/preferenceSave/{id}")
    public ActionResult<SystemVO> preferenceSave(@PathVariable("id") String id, @RequestBody SystemUpModel upModel) {
        SystemEntity entity = systemService.getInfo(id);
        if (entity == null) {
            return ActionResult.fail(MsgCode.FA001.get());
        }
        entity.setPreferenceJson(upModel.getPreferenceJson());
        systemService.saveOrUpdate(entity);
        return ActionResult.success(MsgCode.SU005.get());
    }
 
 
    @Operation(summary = "新建应用")
    @Parameter(name = "systemCrModel", description = "新建模型", required = true)
    @SaCheckPermission(value = {"appCenter"})
    @PostMapping
    public ActionResult<Object> create(@RequestBody SystemCrModel systemCrModel) {
        SystemEntity entity = JsonUtil.getJsonToBean(systemCrModel, SystemEntity.class);
        if (Boolean.TRUE.equals(systemService.isExistEnCode(entity.getId(), entity.getEnCode()))) {
            return ActionResult.fail(MsgCode.EXIST002.get());
        }
        systemService.create(entity);
        return ActionResult.success(MsgCode.SU001.get(), entity.getEnCode());
    }
 
    @Operation(summary = "修改应用")
    @Parameter(name = "id", description = "主键", required = true)
    @Parameter(name = "systemCrModel", description = "修改模型", required = true)
    @SaCheckPermission(value = {"appConfig.baseConfig"})
    @PutMapping("/{id}")
    public ActionResult<Object> update(@PathVariable("id") String id, @RequestBody SystemUpModel systemUpModel) {
        SystemEntity systemEntity = systemService.getInfo(id);
        if (systemEntity == null) {
            return ActionResult.fail(MsgCode.FA002.get());
        }
        SystemEntity entity = JsonUtil.getJsonToBean(systemUpModel, SystemEntity.class);
        entity.setIsMain(systemEntity.getIsMain());
        if (Boolean.TRUE.equals(systemService.isExistEnCode(id, entity.getEnCode()))) {
            return ActionResult.fail(MsgCode.EXIST002.get());
        }
 
        systemService.update(id, entity);
        // 如果禁用了系统,则需要将系统
        if (systemEntity.getEnabledMark() == 1 && entity.getEnabledMark() == 0) {
            // 通知下线
            noticeApi.autoSystem(Map.of("entity", systemEntity, "message", "应用已被禁用,正为您切换应用"));
        }
        return ActionResult.success(MsgCode.SU004.get());
    }
 
    @Operation(summary = "删除应用")
    @Parameter(name = "id", description = "主键", required = true)
    @SaCheckPermission(value = {"appCenter"})
    @DeleteMapping("/{id}")
    public ActionResult<String> delete(@PathVariable("id") String id) {
        SystemEntity entity = systemService.getInfo(id);
        if (entity == null) {
            return ActionResult.fail(MsgCode.FA003.get());
        }
        // 查询平台下菜单
        MenuListModel paramW = new MenuListModel();
        paramW.setAppCode(entity.getEnCode());
        paramW.setCategory(JnpfConst.WEB);
        paramW.setRelease(false);
        AuthorizeVO authorize = authorizeService.getAuthorize(true, entity.getEnCode(), null);
        paramW.setModuleList(authorize.getModuleList());
        MenuListModel paramA = BeanUtil.copyProperties(paramW, MenuListModel.class);
        paramW.setCategory(JnpfConst.APP);
        List<ModuleEntity> webData = moduleService.getList(paramW);
        List<ModuleEntity> appData = moduleService.getList(paramA);
        if (CollectionUtils.isNotEmpty(webData) || CollectionUtils.isNotEmpty(appData)) {
            return ActionResult.fail(MsgCode.SYS040.get());
        }
        if (entity.getIsMain() != null && entity.getIsMain() == 1) {
            return ActionResult.fail(MsgCode.SYS102.get());
        }
        // 系统绑定审批常用语时不允许被删除
        if (Boolean.TRUE.equals(commonWordsService.existSystem(id))) {
            return ActionResult.fail(MsgCode.SYS103.get());
        } else {
            systemService.delete(id);
            // 通知下线
            noticeApi.autoSystem(Map.of("entity", entity, "message", "应用已被删除,正为您切换应用"));
        }
        return ActionResult.success(MsgCode.SU003.get());
    }
 
    @Operation(summary = "获取当前用户有权限的应用")
    @GetMapping("/userAuthList")
    public ActionResult<List<SystemListVO>> userAuthList(Pagination pagination) {
        AuthorizeVO authorizeByUser = authorizeService.getAuthorizeByUser(false);
        List<String> systemIds = authorizeByUser.getSystemList().stream().filter(t -> !Objects.equals(t.getIsMain(), 1))
                .map(SystemBaeModel::getId).collect(Collectors.toList());
        List<SystemEntity> list = systemService.getListByIdsKey(systemIds, pagination.getKeyword());
        List<SystemListVO> listVo = JsonUtil.getJsonToList(list, SystemListVO.class);
        return ActionResult.success(listVo);
    }
 
    @Operation(summary = "获取所有应用")
    @GetMapping("/Selector")
    public ActionResult<List<SystemListVO>> getSelector(@RequestParam(value = "keyword", required = false) String keyword) {
        List<SystemEntity> list = systemService.getList().stream().filter(t -> !Objects.equals(t.getIsMain(), 1)).collect(Collectors.toList());
        if (StringUtil.isNotEmpty(keyword)) {
            list = list.stream().filter(t -> t.getFullName().contains(keyword)).collect(Collectors.toList());
        }
        List<SystemListVO> listVo = JsonUtil.getJsonToList(list, SystemListVO.class);
        return ActionResult.success(listVo);
    }
 
    @Operation(summary = "应用置顶")
    @PostMapping("/actionTop")
    public ActionResult<Object> actionTop(@RequestBody SystemTopModel model) {
        if (Objects.equals(model.getActionType(), 0)) {//取消
            SystemTopEntity entity = new SystemTopEntity();
            entity.setObjectId(model.getId());
            entity.setType(model.getType());
            entity.setUserId(UserProvider.getUser().getUserId());
            entity.setStandId(getCurStand());
            systemTopService.canleTop(entity);
            return ActionResult.success(MsgCode.SYS107.get());
        } else {//置顶
            List<String> sysIds = new ArrayList<>();
            if (JnpfConst.SYS_HOME.equalsIgnoreCase(model.getType())) {
                AuthorizeVO authorizeModel = authorizeService.getAuthorize(false, JnpfConst.MAIN_SYSTEM_CODE, 0);
                sysIds.addAll(authorizeModel.getSystemList().stream().map(SystemBaeModel::getId).collect(Collectors.toList()));
            }
            if (JnpfConst.SYS_APP_CENTER.equalsIgnoreCase(model.getType())) {
                SystemPageVO systemPageVO = new SystemPageVO();
                systemPageVO.setType(1);
                List<SystemEntity> list = systemService.getList(systemPageVO);
                sysIds.addAll(list.stream().map(SystemEntity::getId).collect(Collectors.toList()));
            }
            SystemTopEntity entity = new SystemTopEntity();
            entity.setObjectId(model.getId());
            entity.setType(model.getType());
            entity.setUserId(UserProvider.getUser().getUserId());
            entity.setStandId(getCurStand());
            systemTopService.saveTop(entity, sysIds);
            return ActionResult.success(MsgCode.SYS106.get());
        }
    }
 
    private String getCurStand() {
        String standId = null;
        BaseSystemInfo sysInfo = sysconfigApi.getSysInfo();
        //有开启身份才去取当前身份,没开启身份存储身份为null
        if (Objects.equals(sysInfo.getStandingSwitch(), 1)) {
            standId = UserProvider.getUser().getCurrentStandId();
        }
        return standId;
    }
 
    //+++++++++++++++++++++++++++++导入导出复制start+++++++++++++++++++++++++++++
 
    private void deleteAll(String systemId) {
        ThreadPoolExecutorUtil.getExecutor().execute(() -> {
            visualdevApi.deleteBySystemId(systemId);
            portalApi.deleteBySystemId(systemId);
            reportExportUtil.deleteBySystemId(systemId);
            reportExportUtil.deleteBySystemIdOld(systemId);
            printDevService.deleteBySystemId(systemId);
            visualScreenApi.deleteBySystemId(systemId);
            templateApi.deleteBySystemId(systemId);
        });
    }
 
    @Operation(summary = "导出")
    @Parameter(name = "id", description = "主键值", required = true)
    @SaCheckPermission("appCenter")
    @GetMapping("/{id}/Actions/Export")
    public ActionResult<Object> exportFile(@PathVariable("id") String id) {
        try {
            SystemEntity info = systemService.getInfo(id);
            SystemExportVo exportModel = new SystemExportVo();
            exportModel.setSystemEntity(info);
            exportModel.setVisualList(visualdevApi.getExportList(id));
            exportModel.setPortalList(portalApi.getExportList(id));
            exportModel.setReportList(reportExportUtil.getExportList(id));
            exportModel.setOldReportList(reportExportUtil.getExportListOld(id));
            exportModel.setPrintList(printDevService.getExportList(id));
            exportModel.setVisualScreen(visualScreenApi.getExportList(id));
            exportModel.setTemplateList(templateApi.getExportList(id));
            DownloadVO downloadVO = fileApi.exportFile(new ExportModel(exportModel, FileTypeConstant.TEMPORARY, UserProvider.getUser().getId(), info.getFullName(), ModuleTypeEnum.BASE_SYSTEM.getTableName()));
            return ActionResult.success(downloadVO);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage(), e);
        }
        return ActionResult.fail(MsgCode.IMP005.get());
    }
 
    @Operation(summary = "导入")
    @SaCheckPermission("appCenter")
    @PostMapping(value = "/Actions/Import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ActionResult<Object> importFile(@RequestPart("file") MultipartFile multipartFile) throws DataException {
        //判断是否为.bm结尾
        if (FileUtil.existsSuffix(multipartFile, ModuleTypeEnum.BASE_SYSTEM.getTableName())) {
            return ActionResult.fail(MsgCode.IMP002.get());
        }
        String systemId = RandomUtil.uuId();
        try {
            String fileContent = FileUtil.getFileContent(multipartFile);
            SystemExportVo exportModel = JsonUtil.getJsonToBean(fileContent, SystemExportVo.class);
            exportModel.getSystemEntity().setId(systemId);
            systemService.importCopy(exportModel.getSystemEntity(), true);
            if (CollectionUtils.isNotEmpty(exportModel.getVisualList())) {
                boolean a = visualdevApi.importCopy(exportModel.getVisualList(), systemId);
                if (!a) throw new DataException(MsgCode.FA058.get());
            }
            if (CollectionUtils.isNotEmpty(exportModel.getPortalList())) {
                boolean b = portalApi.importCopy(exportModel.getPortalList(), systemId);
                if (!b) throw new DataException(MsgCode.FA058.get());
            }
            if (CollectionUtils.isNotEmpty(exportModel.getReportList())) {
                boolean c = reportExportUtil.importCopy(exportModel.getReportList(), systemId);
                if (!c) throw new DataException(MsgCode.FA058.get());
            }
            if (CollectionUtils.isNotEmpty(exportModel.getOldReportList())) {
                boolean c1 = reportExportUtil.importCopyOld(exportModel.getOldReportList(), systemId);
                if (!c1) throw new DataException(MsgCode.FA058.get());
            }
            if (CollectionUtils.isNotEmpty(exportModel.getPrintList())) {
                boolean d = printDevService.importCopy(exportModel.getPrintList(), systemId);
                if (!d) throw new DataException(MsgCode.FA058.get());
            }
            if (exportModel.getVisualScreen() != null) {
                boolean e = visualScreenApi.importCopy(exportModel.getVisualScreen(), systemId);
                if (!e) throw new DataException(MsgCode.FA058.get());
            }
            if (CollectionUtils.isNotEmpty(exportModel.getTemplateList())) {
                boolean f = templateApi.importCopy(exportModel.getTemplateList(), systemId);
                if (!f) throw new DataException(MsgCode.FA058.get());
            }
            return ActionResult.success(MsgCode.IMP001.get());
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            //异常回退,手动删除相关数据
            try {
                systemService.delete(systemId);
                this.deleteAll(systemId);
            } catch (Exception e1) {
                log.error(e1.getMessage(), e1);
            }
        }
        return ActionResult.fail(MsgCode.FA058.get());
    }
 
    @Operation(summary = "复制")
    @Parameter(name = "id", description = "主键值")
    @SaCheckPermission("appCenter")
    @PostMapping("/{id}/Actions/Copy")
    @DSTransactional
    public ActionResult<PageListVO<PrintDevEntity>> copy(@PathVariable String id) {
        String systemId = RandomUtil.uuId();
        SystemEntity info = systemService.getInfo(id);
        try {
            SystemEntity systemEntity = BeanUtil.copyProperties(info, SystemEntity.class);
            systemEntity.setId(systemId);
            systemService.importCopy(systemEntity, false);
            List<VisualExportVo> visualVoList = visualdevApi.getExportList(id);
            List<PortalExportDataVo> portalList = portalApi.getExportList(id);
            List<Object> reportList = reportExportUtil.getExportList(id);
            List<Object> oldReportList = reportExportUtil.getExportListOld(id);
            List<PrintExportVo> printList = printDevService.getExportList(id);
            VisualScreenExportVo screenEntity = visualScreenApi.getExportList(id);
            List<TemplateExportVo> templateList = templateApi.getExportList(id);
 
            if (CollectionUtils.isNotEmpty(visualVoList)) {
                boolean a = visualdevApi.importCopy(visualVoList, systemId);
                if (!a) throw new DataException(MsgCode.FA059.get());
            }
            if (CollectionUtils.isNotEmpty(portalList)) {
                boolean b = portalApi.importCopy(portalList, systemId);
                if (!b) throw new DataException(MsgCode.FA059.get());
            }
            if (CollectionUtils.isNotEmpty(reportList)) {
                boolean c = reportExportUtil.importCopy(reportList, systemId);
                if (!c) throw new DataException(MsgCode.FA059.get());
            }
            if (CollectionUtils.isNotEmpty(oldReportList)) {
                boolean c1 = reportExportUtil.importCopyOld(oldReportList, systemId);
                if (!c1) throw new DataException(MsgCode.FA058.get());
            }
            if (CollectionUtils.isNotEmpty(printList)) {
                boolean d = printDevService.importCopy(printList, systemId);
                if (!d) throw new DataException(MsgCode.FA059.get());
            }
            if (screenEntity != null) {
                boolean e = visualScreenApi.importCopy(screenEntity, systemId);
                if (!e) throw new DataException(MsgCode.FA059.get());
            }
            if (CollectionUtils.isNotEmpty(templateList)) {
                boolean f = templateApi.importCopy(templateList, systemId);
                if (!f) throw new DataException(MsgCode.FA059.get());
            }
            return ActionResult.success(MsgCode.SU007.get());
        } catch (Exception e) {
 
            log.error(e.getMessage(), e);
            //异常回退,手动删除相关数据
            try {
                systemService.delete(systemId);
                this.deleteAll(systemId);
            } catch (Exception e1) {
                log.error(e1.getMessage(), e1);
            }
        }
        return ActionResult.fail(MsgCode.FA059.get());
    }
 
    //+++++++++++++++++++++++++++++导入导出复制end+++++++++++++++++++++++++++++
 
 
    //++++++++++++++++++++++++++++++++++以下为api接口
    @Override
    @GetMapping("/getList")
    public List<SystemEntity> getList() {
        return systemService.getList();
    }
 
    @Override
    @PostMapping("/getList")
    public List<SystemEntity> getList(@RequestBody SystemApiListModel model) {
        return systemService.getList(model.getKeyword(), model.getVerifyAuth(), model.getFilterMain());
    }
 
    @Override
    @PostMapping("/getListByIds")
    public List<SystemEntity> getListByIds(@RequestBody SystemApiByIdsModel model) {
        return systemService.getListByIds(model.getIds(), model.getModuleAuthorize(), model.getStand());
    }
 
    @Override
    @GetMapping("/getInfoById")
    public SystemEntity getInfoById(@RequestParam("systemId") String systemId) {
        return systemService.getInfo(systemId);
    }
 
    @Override
    @GetMapping("/getInfoByEnCode")
    public SystemEntity getInfoByEnCode(@RequestParam("enCode") String enCode) {
        return systemService.getInfoByEnCode(enCode);
    }
 
    @Override
    @PostMapping("/findSystemAdmin")
    public List<SystemEntity> findSystemAdmin(@RequestBody SystemApiModel model) {
        return systemService.findSystemAdmin(model.getModuleAuthorize());
    }
 
    @Override
    @PostMapping("/getListAll")
    public List<SystemEntity> getListAll() {
        return systemService.getList();
    }
 
    @PostMapping("/addCommonWordsNum")
    public void addCommonWordsNum(@RequestBody String commonWordsText) {
        commonWordsService.addCommonWordsNum(commonWordsText);
    }
 
    @Override
    @GetMapping("/getListByCreUser")
    public List<SystemEntity> getListByCreUser(@RequestParam("userId") String userId) {
        return systemService.getListByCreUser(userId);
    }
 
    @Override
    @GetMapping("/getAuthListByUser")
    public List<SystemEntity> getAuthListByUser(@RequestParam("userId") String userId, @RequestParam(value = "isStand") Boolean isStand) {
        return systemService.getAuthListByUser(userId, isStand);
    }
 
    @Override
    @PostMapping("/workHandover")
    public void workHandover(@RequestBody WorkHandoverModel workHandoverModel) {
        systemService.workHandover(workHandoverModel);
    }
 
    @Override
    @PostMapping("/changeSystemAuthorizion")
    public void changeSystemAuthorizion(@RequestBody AppAuthorizationModel model) {
        systemService.changeSystemAuthorizion(model);
    }
 
    @Override
    @GetMapping("/getMainList")
    public List<SystemEntity> getMainList() {
        return systemService.getMainList();
    }
}