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();
|
}
|
}
|