zhaowenxuan
2025-02-27 1c4935c13c44f35bc59e77cff6a66e3131a35d94
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
package com.ltkj.web.config.wordUtil;
 
import com.ltkj.hosp.domain.Tables;
import com.ltkj.web.config.wordUtil.mapper.TableMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.io.File;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
 
 
/**
 * <p> 实现类 </p>
 *
 * @author : 赵佳豪
 */
@Slf4j
@Service
public class TableService implements ITableService {
 
    @Resource
    private TableMapper tableMapper;
    @Resource
    private TableToWordUtil tableToWordUtil;
 
    @Override
    public String getTableInfo() {
        // 1、获取数据库所有表信息
        List<Tables> tables = tableMapper.getAllTables(Constants.DATABASE);
 
        // 2、生成文件名信息 - 年月日时分秒
        String date = null;
        try {
            date = DateTimeUtils.dateFormat(new Date(), DateTimeUtils.PARSE_PATTERNS[12]);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        String docFileName = Constants.FILE_PATH + File.separator + Constants.FILE_NAME + ".doc";
 
        // 3、调用工具类生成文件
        tableToWordUtil.toWord(tables, docFileName, Constants.FILE_NAME);
 
        // 4、返回文件地址
        String filePath = docFileName.replaceAll("\\\\", "/");
        return filePath;
    }
}