多单位版国产化地质资料管理系统
zs
2025-12-18 4f0d9bde31a80f6279e26466250da7716eec627f
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
package com.zbooksoft.gdmis.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruili.wcp.common.CustomConfigUtil;
import com.ruili.wcp.data.entity.config.View;
import com.ruili.wcp.data.entity.management.User;
import com.ruili.wcp.engine.ExpressionParser;
import com.ruili.wcp.service.config.ViewService;
import com.ruili.wcp.web.model.AjaxResponse;
import com.ruili.wcp.web.model.ErrorInfo;
import com.zbooksoft.gdmis.config.ArchivesCustomConfig;
import com.zbooksoft.gdmis.data.entity.CatCgwjxx;
import com.zbooksoft.gdmis.data.entity.CatCheck;
import com.zbooksoft.gdmis.data.entity.CatYswjxx;
import com.zbooksoft.gdmis.service.*;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.dom4j.Document;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
 
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import static com.zbooksoft.gdmis.common.XmlUtil.getDocument;
 
 
/**
 * @author 15280  secretLedger
 */
@Controller
@RequestMapping("/catAjjxx")
public class CatAjjxxController {
 
    @Autowired
    ViewService viewService;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    CatYswjxxService catYswjxxService;
    @Autowired
    ReadXml2017Service readXml2017Service;
    @Autowired
    ReadXml2023Service readXml2023Service;
    @Autowired
    UpdateXml2017Service updateXml2017Service;
    @Autowired
    UpdateXml2023Service updateXml2023Service;
    @Autowired
    XmlService xmlService;
 
    @Autowired
    CustomConfigUtil customConfigUtil;
 
    @Autowired
    CatCheckService catCheckService;
 
    private static final Logger logger = LoggerFactory.getLogger(CatAjjxxController.class);
 
 
    /**
     * 小工具xml导入页面
     *
     * @return
     */
    @RequestMapping(value = "/importXmlIndex")
    @RequiresUser
    public ModelAndView importXmlIndex() {
        ArchivesCustomConfig archivesCustomConfig = customConfigUtil.getConfigObj(ArchivesCustomConfig.class);
        ModelAndView mv = new ModelAndView("gh/catAjjxx/importXmlIndex");
        mv.addObject("archivesCustomConfig", archivesCustomConfig);
        return mv;
    }
 
    /**
     * XML导入
     *
     * @param file
     * @param startData
     * @return
     */
 
    @RequestMapping({"/importXML"})
    @ResponseBody
    @RequiresUser
    public Object importXML(@RequestParam(value = "file", required = false) MultipartFile file, String startData, String endData) {
        try {
            Document document = getDocument(file);
            Element rootElement = document.getRootElement();
            String rootName = rootElement.getName();
            xmlService.readXml(document, startData, endData);
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
 
    /**
     * xml更新页面
     *
     * @return
     */
    @RequestMapping(value = "/updateXmlIndex")
    @RequiresUser
    public ModelAndView updateXmlIndex() {
        ModelAndView mv = new ModelAndView("gh/catAjjxx/updateXmlIndex");
        return mv;
    }
 
 
    /**
     * 需更新xml文件
     *
     * @param file
     * @param checkData
     * @param ajId
     * @return
     */
    @RequestMapping({"/updateXML"})
    @ResponseBody
    @RequiresUser
    public Object updateXML(@RequestParam(value = "file", required = false) MultipartFile file, String checkData, String ajId) {
        try {
            Document document = getDocument(file);
            Long updateId = Long.parseLong(ajId);
            Element rootElement = document.getRootElement();
            String rootName = rootElement.getName();
            if ("AJXX".equals(rootName)) {
                updateXml2017Service.updateXml(document, checkData, updateId);
            } else if ("DZZLXX".equals(rootName)) {
                updateXml2023Service.updateXml(document, checkData, updateId);
            }
            if (checkData != null && !"".equals(checkData)) {
                QueryWrapper<CatCheck> catCheckQueryWrapper = new QueryWrapper<>();
                catCheckQueryWrapper.eq("aj_id", Long.parseLong(ajId));
                catCheckQueryWrapper.isNull("check_date");
                CatCheck catCheck = catCheckService.getOne(catCheckQueryWrapper);
                catCheck.setAjId(Long.parseLong(ajId));
//                catCheck.setCheckDate(stringToDate(checkData));
                catCheckService.saveOrUpdate(catCheck);
            }
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
 
    /**
     * XML导入
     *
     * @param file
     * @param startData
     * @return
     */
 
    @RequestMapping({"/importBaoPanXML"})
    @ResponseBody
    @RequiresUser
    public Object importBaoPanXML(@RequestParam(value = "file", required = false) MultipartFile file, String startData, String endData) {
        try {
            Document document = getDocument(file);
            Element rootElement = document.getRootElement();
            String rootName = rootElement.getName();
            //暂时不判断重复
            if ("AJXX".equals(rootName)) {
                readXml2017Service.readXml(document, startData, endData);
            } else if ("DZZLXX".equals(rootName)) {
                readXml2023Service.readXml(document, startData, endData);
            }
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
    /**
     * 关联附件
     *
     * @param viewId
     * @param idList
     * @return
     */
    @RequestMapping({"/relationFile"})
    @ResponseBody
    @RequiresUser
    public AjaxResponse relationFile(Long viewId, @RequestBody List<Long> idList) {
        try {
            //查询业务数据
            //获取文件信息
            Map<String, Object> resultMap = new HashMap<>();
            int ysTotal = 0;
            int ysSuccess = 0;
            int ysFailed = 0;
            ArchivesCustomConfig archivesCustomConfig = customConfigUtil.getConfigObj(ArchivesCustomConfig.class);
            View view = viewService.getViewById(viewId);
            String strIds = "";
            String strParam = "";
            if (idList != null && idList.size() > 0) {
                strIds = " and id in( " + StringUtils.join(idList, ",") + ")";
            } else {
                String sqlWhere = view.getSqlWhere();
                if (sqlWhere != null && !"".equals(sqlWhere)) {
                    //添加表达式解析,去掉${CurUserName}等之类的参数
                    if (sqlWhere.contains("$")) {
                        ExpressionParser expressionParser = new ExpressionParser();
                        sqlWhere = expressionParser.parsing(sqlWhere);
                    }
                    strParam = " and " + sqlWhere;
                }
            }
            String strSql = "select * from " + view.getMainTableName() + " where 1=1 " + strIds + strParam;
 
            // 查询业务数据
            List<Map<String, Object>> list = jdbcTemplate.queryForList(strSql);
//
            String uploadPath = archivesCustomConfig.getOriginalPath();
            String newUploadPath = archivesCustomConfig.getViewPath();
            String provinceCode = archivesCustomConfig.getProvinceCode();
            for (Map<String, Object> map : list) {
                String pathIn = "";
                String sgdh = map.get("SGDH").toString();
                boolean enableSimple = archivesCustomConfig.getEnableSimple();
                if (enableSimple) {
                    pathIn = sgdh;
                } else {
                    //取第一层文件夹(省馆档号取前三位,形成5位数字前加hn)
                    String pr = sgdh.substring(0, 3);
                    int num = Integer.parseInt(pr);
                    String fistFileName = String.format("%05d", num);
                    pathIn = provinceCode + fistFileName + "/";
                    //取第二层文件夹(省馆档号,形成6位数字前加hn)
                    String secondFileName = String.format("%06d", Long.parseLong(sgdh));
                    pathIn = pathIn + provinceCode + secondFileName;
                }
                //d/省馆档号
                String filePath = uploadPath + pathIn + File.separator;
                String newFilePath = newUploadPath + sgdh + File.separator;
                Long id = Long.parseLong(map.get("ID").toString());
                QueryWrapper<CatCgwjxx> catCgwjxxQueryWrapper = new QueryWrapper<>();
                catCgwjxxQueryWrapper.eq("aj_id", id);
 
                //d/省馆档号/
                String path = filePath + "源电子文件";
                String cdPath = filePath + "存档电子文件";
                String newCdPath = newFilePath + "存档电子文件";
 
                QueryWrapper<CatYswjxx> catYswjxxQueryWrapper = new QueryWrapper<>();
                catYswjxxQueryWrapper.eq("aj_id", id);
                List<CatYswjxx> catYswjxxList = catYswjxxService.list(catYswjxxQueryWrapper);
                String ysPath = filePath + "原始资料电子文件";
                String newYsPath = newFilePath + "原始资料电子文件";
                ysTotal += catYswjxxList.size();
                for (CatYswjxx catYswjxx : catYswjxxList) {
                    String wjm = catYswjxx.getWjm();
                    String yswjPath = ysPath + File.separator + wjm;
                    String newYswjPath = newYsPath + File.separator + wjm;
                    File file = new File(yswjPath);
                    if (file.exists() && file.isFile()) {
                        catYswjxx.setWjlj(yswjPath);
                        ysSuccess++;
                    } else {
                        ysFailed++;
                    }
                    catYswjxxService.saveOrUpdate(catYswjxx);
                }
 
            }
            resultMap.put("ysTotal", ysTotal);
            resultMap.put("ysSuccess", ysSuccess);
            resultMap.put("ysFailed", ysFailed);
 
            AjaxResponse ajaxResponse = new AjaxResponse(true);
            if (resultMap != null) {
                StringBuilder sb = new StringBuilder();
                sb.append("top.layer.open({");
                sb.append("   title : '提示',");
                sb.append("   type : 2,");
                sb.append("   area : [ '700px', '180px' ],");
                sb.append("   fixed : true, ");
                sb.append("   content : 'common/relationFileTips?ysTotal=" + resultMap.get("ysTotal") + "&ysSuccess=" + resultMap.get("ysSuccess") + "&ysFailed=" + resultMap.get("ysFailed") + "'");
                sb.append("});");
                Map<String, String> result = new HashMap<String, String>();
                result.put("jsExpression", sb.toString());
                ajaxResponse.setResult(result);
            }
            return ajaxResponse;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
    /**
     * 关联附件
     *
     * @param viewId
     * @param idList
     * @return
     */
    @RequestMapping({"/relationFiles"})
    @ResponseBody
    @RequiresUser
    public AjaxResponse relationFiles(Long viewId, @RequestBody List<Long> idList) {
        try {
            //查询业务数据
            //获取文件信息
            Map<String, Object> resultMap = new HashMap<>();
            int ysTotal = 0;
            int ysSuccess = 0;
            int ysFailed = 0;
            ArchivesCustomConfig archivesCustomConfig = customConfigUtil.getConfigObj(ArchivesCustomConfig.class);
            View view = viewService.getViewById(viewId);
            String strIds = "";
            String strParam = "";
            if (idList != null && idList.size() > 0) {
                strIds = " and id in( " + StringUtils.join(idList, ",") + ")";
            } else {
                String sqlWhere = view.getSqlWhere();
                if (sqlWhere != null && !"".equals(sqlWhere)) {
                    //添加表达式解析,去掉${CurUserName}等之类的参数
                    if (sqlWhere.contains("$")) {
                        ExpressionParser expressionParser = new ExpressionParser();
                        sqlWhere = expressionParser.parsing(sqlWhere);
                    }
                    strParam = " and " + sqlWhere;
                }
            }
            String strSql = "select * from " + view.getMainTableName() + " where 1=1 " + strIds + strParam;
 
            // 查询业务数据
            List<Map<String, Object>> list = jdbcTemplate.queryForList(strSql);
//
            String uploadPath = archivesCustomConfig.getOriginalPath();
            for (Map<String, Object> map : list) {
//                String dh = map.get("DH").toString();
                String dh = map.get("XMKYQBH").toString();
                //d/省馆档号
                String filePath = uploadPath + dh + File.separator + "电子文件" + File.separator;
                Long id = Long.parseLong(map.get("ID").toString());
 
                QueryWrapper<CatYswjxx> catYswjxxQueryWrapper = new QueryWrapper<>();
                catYswjxxQueryWrapper.eq("aj_id", id);
                List<CatYswjxx> catYswjxxList = catYswjxxService.list(catYswjxxQueryWrapper);
 
 
                ysTotal += catYswjxxList.size();
                for (CatYswjxx catYswjxx : catYswjxxList) {
                    String yswjPath = "";
                    String wjtm = catYswjxx.getWjtm();
                    String wjgs = catYswjxx.getWjgs();
                    if (wjgs != null && !"".equals(wjgs)) {
                        String wjm = wjtm + wjgs;
                        yswjPath = filePath + wjm;
                    } else {
                        yswjPath = filePath + wjtm;
                    }
 
                    File file = new File(yswjPath);
                    if (file.exists()) {
                        Long folderSize = getFolderSize(file);
                        double fileSizeMB = (double) folderSize / 1024 / 1024;
                        String fileSizeStr = String.format("%.2f", fileSizeMB);
                        catYswjxx.setWjdx(fileSizeStr);
                        catYswjxx.setWjlj(yswjPath);
                        ysSuccess++;
                    }
                    catYswjxx.setWjm(wjtm);
                    catYswjxxService.saveOrUpdate(catYswjxx);
                }
 
            }
            resultMap.put("ysTotal", ysTotal);
            resultMap.put("ysSuccess", ysSuccess);
            resultMap.put("ysFailed", ysFailed);
 
            AjaxResponse ajaxResponse = new AjaxResponse(true);
            if (resultMap != null) {
                StringBuilder sb = new StringBuilder();
                sb.append("top.layer.open({");
                sb.append("   title : '提示',");
                sb.append("   type : 2,");
                sb.append("   area : [ '700px', '180px' ],");
                sb.append("   fixed : true, ");
                sb.append("   content : 'common/relationFileTips?ysTotal=" + resultMap.get("ysTotal") + "&ysSuccess=" + resultMap.get("ysSuccess") + "&ysFailed=" + resultMap.get("ysFailed") + "'");
                sb.append("});");
                Map<String, String> result = new HashMap<String, String>();
                result.put("jsExpression", sb.toString());
                ajaxResponse.setResult(result);
            }
            return ajaxResponse;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
 
    /**
     * 关联附件
     *
     * @param viewId
     * @param idList
     * @return
     */
    @RequestMapping({"/digitalRelationFiles"})
    @ResponseBody
    @RequiresUser
    public AjaxResponse digitalRelationFiles(Long viewId, @RequestBody List<Long> idList) {
        try {
            //查询业务数据
            //获取文件信息
            Map<String, Object> resultMap = new HashMap<>();
            int ysTotal = 0;
            int ysSuccess = 0;
            int ysFailed = 0;
            ArchivesCustomConfig archivesCustomConfig = customConfigUtil.getConfigObj(ArchivesCustomConfig.class);
            View view = viewService.getViewById(viewId);
            String strIds = "";
            String strParam = "";
            if (idList != null && idList.size() > 0) {
                strIds = " and id in( " + StringUtils.join(idList, ",") + ")";
            } else {
                String sqlWhere = view.getSqlWhere();
                if (sqlWhere != null && !"".equals(sqlWhere)) {
                    //添加表达式解析,去掉${CurUserName}等之类的参数
                    if (sqlWhere.contains("$")) {
                        ExpressionParser expressionParser = new ExpressionParser();
                        sqlWhere = expressionParser.parsing(sqlWhere);
                    }
                    strParam = " and " + sqlWhere;
                }
            }
            String strSql = "select * from " + view.getMainTableName() + " where 1=1 " + strIds + strParam;
 
            // 查询业务数据
            List<Map<String, Object>> list = jdbcTemplate.queryForList(strSql);
//
            String uploadPath = archivesCustomConfig.getOriginalPath();
            for (Map<String, Object> map : list) {
                String dh = map.get("DH").toString();
                //d/省馆档号
                String filePath = uploadPath + dh + File.separator;
                Long id = Long.parseLong(map.get("ID").toString());
 
                QueryWrapper<CatYswjxx> catYswjxxQueryWrapper = new QueryWrapper<>();
                catYswjxxQueryWrapper.eq("aj_id", id);
                List<CatYswjxx> catYswjxxList = catYswjxxService.list(catYswjxxQueryWrapper);
 
 
                ysTotal += catYswjxxList.size();
                for (CatYswjxx catYswjxx : catYswjxxList) {
                    String wjDh = catYswjxx.getDh();
                    String yswjPath = "";
                    yswjPath = filePath + wjDh + File.separator + wjDh + ".pdf";
 
                    File file = new File(yswjPath);
                    if (file.exists() && file.isFile()) {
                        long fileSize = file.length();
                        double fileSizeMB = fileSize / (1024.0 * 1024.0);
                        String fileSizeStr = String.format("%.2f", fileSizeMB);
                        catYswjxx.setWjdx(fileSizeStr);
                        catYswjxx.setWjgs(".pdf");
                        catYswjxx.setWjlj(yswjPath);
                        catYswjxx.setWjm(wjDh);
                        ysSuccess++;
                    } else {
                        ysFailed++;
                    }
                    catYswjxxService.saveOrUpdate(catYswjxx);
                }
 
            }
            resultMap.put("ysTotal", ysTotal);
            resultMap.put("ysSuccess", ysSuccess);
            resultMap.put("ysFailed", ysFailed);
 
            AjaxResponse ajaxResponse = new AjaxResponse(true);
            if (resultMap != null) {
                StringBuilder sb = new StringBuilder();
                sb.append("top.layer.open({");
                sb.append("   title : '提示',");
                sb.append("   type : 2,");
                sb.append("   area : [ '700px', '180px' ],");
                sb.append("   fixed : true, ");
                sb.append("   content : 'common/relationFileTips?ysTotal=" + resultMap.get("ysTotal") + "&ysSuccess=" + resultMap.get("ysSuccess") + "&ysFailed=" + resultMap.get("ysFailed") + "'");
                sb.append("});");
                Map<String, String> result = new HashMap<String, String>();
                result.put("jsExpression", sb.toString());
                ajaxResponse.setResult(result);
            }
            return ajaxResponse;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
 
    /**
     * 档案验收页面
     *
     * @return
     */
    @RequestMapping(value = "/checkIndex")
    @RequiresUser
    public ModelAndView acceptanceIndex() {
        ModelAndView mv = new ModelAndView("gh/catAjjxx/checkIndex");
        return mv;
    }
 
    /**
     * 资料验收
     *
     * @return
     */
 
    @RequestMapping({"/check"})
    @ResponseBody
    @RequiresUser
    public Object check(@RequestBody Map<String, Object> postData) {
        try {
            Subject currentUser = SecurityUtils.getSubject();
            Session session = currentUser.getSession();
            User user = (User) session.getAttribute("user");
            Long id = Long.parseLong(postData.get("id").toString());
            int checkState = Integer.parseInt(postData.get("checkState").toString());
 
            String selectSql = "SELECT * FROM BUS_TRANSFER_LOG WHERE ID =" + id;
            Map<String, Object> map = jdbcTemplate.queryForMap(selectSql);
            Object ajId = map.get("AJ_ID");
 
            CatCheck catCheck = new CatCheck();
            catCheck.setItemId(id);
            catCheck.setAjId(Long.parseLong(ajId.toString()));
            catCheck.setQuestion(postData.get("question").toString());
            catCheck.setIsPass(checkState);
            catCheck.setCreateTime(new Date());
            catCheck.setCreateUserName(user.getUserName());
            catCheck.setCreateUserId(user.getUserId());
            catCheck.setCheckQuestion(postData.get("checkQuestion") == null ? "" : postData.get("checkQuestion").toString());
            catCheckService.saveOrUpdate(catCheck);
 
            String updateSql = "update BUS_TRANSFER_LOG set YSZT = '" + checkState + "' where ID = " + id;
            jdbcTemplate.execute(updateSql);
            String updateSqlY = "update CAT_ITEM_YSWJXX set YSZT = '" + checkState + "' where YJ_ID = " + id;
            jdbcTemplate.execute(updateSqlY);
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
    public static void main(String[] args) {
        File file = new File("E:\\Desktop\\DD20240091\\DD20240091");
        long folderSize = getFolderSize(file);
        long l = folderSize / 1024 / 1024;
        long folder = (folderSize / 1024 / 1024);
        System.out.println(folderSize / 1024 / 1024);
    }
 
    public static Long getFolderSize(File folder) {
        if (!folder.exists()) {
            return 0L;
        }
 
        if (folder.isFile()) {
            return folder.length();
        }
 
        Long totalSize = 0L;
        File[] files = folder.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isFile()) {
                    totalSize += file.length();
                } else if (file.isDirectory()) {
                    totalSize += getFolderSize(file);
                }
            }
        }
        return totalSize;
    }
}