Fixiaobai
2023-09-07 e29f147aab5b0b0b794d611b522b67b94423e3cf
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
package com.yuanchu.limslaboratory;
 
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
import com.yuanchu.limslaboratory.mapper.OrganizationalMapper;
import com.yuanchu.limslaboratory.service.PlanService;
import com.yuanchu.limslaboratory.service.UserService;
import com.yuanchu.limslaboratory.utils.MyUtil;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
 
import javax.annotation.Resource;
import java.io.FileInputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@SpringBootTest
class SysApplicationTests {
 
    @Resource
    private OrganizationalMapper organizationalMapper;
 
    @Resource
    private UserService userService;
 
    @Test
    void contextLoads() {
        List<Map<String, Object>> test = organizationalMapper.OrganizationalTree(0);
        MyUtil.PrintLog(test.toString());
    }
 
    @Test
    void TT() {
        Map<String, Object> userInfo = userService.getUserInfo("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50IjoiYzhiMWFhYWNlYzM2NmMyNGU1ZDE4YzdlZWE5ZTU1MWIiLCJleHAiOjE2OTE3Mzk4MjV9.IZyU5jhTzpxedmmL25dhpkzQS7hth7gt-bzCx9fZyOk");
        System.out.println(userInfo.get("name"));
    }
 
    @Test
    void TT2(){
        String adminMD5 = SecureUtil.md5(SecureUtil.md5("admin"));
        System.out.println(adminMD5);
    }
 
    @Test
    void uploading() {
        // 替换为doc或docx文件的路径
        String filePath = "D:\\20892\\desktop\\QR-14-01-02+++内部审核年度计划.doc";
        String info = "";
        try {
            FileInputStream fis = new FileInputStream(filePath);
            if (filePath.endsWith(".doc")) {
                // 读取doc文件
                HWPFDocument doc = new HWPFDocument(fis);
                WordExtractor docExtractor = new WordExtractor(doc);
                String text = docExtractor.getText();
                System.out.println("doc:");
                info = text.trim();
                docExtractor.close();
            } else if (filePath.endsWith(".docx")) {
                // 读取docx文件
                XWPFDocument docx = new XWPFDocument(fis);
                XWPFWordExtractor docxExtractor = new XWPFWordExtractor(docx);
                String text = docxExtractor.getText();
                System.out.println("docx:");
                info = text.trim();
                docxExtractor.close();
            } else {
                System.out.println("不是word文件");
            }
            fis.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        List<String> infoList = new ArrayList<String>();
        String[] split = info.split("\n");
        for (int i = 0; i < split.length; i++) {
            System.out.println("======>" + split[i]);
            if (i > 2) {
                infoList.add(split[i]);
            }
        }
        Map<String, String> result = new HashMap<>();
        //客户单位/项目名称
        String[] proAndUnit = infoList.get(0).split("\t");
        for (int i = 0; i < proAndUnit.length; i++) {
            if (i == 1) {
                result.put("unitName", proAndUnit[i]);
            }
            if (i == 3) {
                result.put("projectName", proAndUnit[i]);
            }
        }
        //填表人姓名/职位/联系电话/邮编
        String npty = infoList.get(1);
        String nameAndDate = npty.split("form")[1].split("职位")[0];
        //姓名/日期
        result.put("nameAndDate", nameAndDate.trim());
        //职位
        String post = npty.split("Posts")[1].split("联系电话")[0];
        result.put("post", post.trim());
        //联系电话
        String phone = npty.split("number")[1].split("邮编")[0];
        result.put("telephone", phone);
        //邮编
        String email = npty.split("邮编")[1].split("\t")[1];
        result.put("email", email);
        //服务态度
        String replace = infoList.get(2).replace(" ", "").replace("\t", "");
        System.out.println(replace);
        String[] split1 = replace.split("☑");
        for (int i = 0; i < split1.length; i++) {
            System.out.println(split1[i]);
        }
        result.forEach((k, v) -> {
            System.out.println("k======>" + k);
            System.out.println("v======>" + v);
        });
    }
 
    @Test
    void upload() throws Exception {
        String filePath = "D:\\20892\\desktop\\QR-14-01-02+++内部审核年度计划.doc";
 
        String info = "";
 
        FileInputStream fis = new FileInputStream(filePath);
        if (filePath.endsWith(".doc")) {
            // 读取doc文件
            HWPFDocument doc = new HWPFDocument(fis);
            WordExtractor docExtractor = new WordExtractor(doc);
            String text = docExtractor.getText();
            System.out.println("doc:");
            info = text.trim();
            docExtractor.close();
        } else if (filePath.endsWith(".docx")) {
            // 读取docx文件
            XWPFDocument docx = new XWPFDocument(fis);
            XWPFWordExtractor docxExtractor = new XWPFWordExtractor(docx);
            String text = docxExtractor.getText();
            System.out.println("docx:");
            info = text.trim();
            docxExtractor.close();
        } else {
            System.out.println("不是word文件");
        }
//        System.out.println(info);
        List<String> infoList = new ArrayList<>();
        String[] split = info.split("\n");
        for (int i = 0; i < split.length; i++) {
            System.out.println("======>" + split[i]);
            if (i > 2) {
                infoList.add(split[i]);
            }
        }
    }
    @Test
    void testRedis(){
        boolean b=true;
        if (b) {
            this.contextLoads();
        } else {
            this.TT();
        }
        System.out.println(2024%100);
        new Thread(()->{
            String timeSixNumberCode = MyUtil.getTimeSixNumberCode("CS", "number");
            System.out.println(timeSixNumberCode);
        }).start();
        //new Thread(()->{
        //    String timeSixNumberCode = MyUtil.getTimeSixNumberCode("CS", "number");
        //    System.out.println(timeSixNumberCode);
        //}).start();
        //new Thread(()->{
        //    String timeSixNumberCode = MyUtil.getTimeSixNumberCode("CS", "number");
        //    System.out.println(timeSixNumberCode);
        //}).start();
    }
}